mirror of https://github.com/PrimeDecomp/prime.git
parent
c12d72f97f
commit
1204c8ede6
|
@ -3,7 +3,7 @@
|
|||
.section .data, "wa"
|
||||
.balign 8
|
||||
|
||||
D54:
|
||||
.obj D54, local
|
||||
.byte 0x18
|
||||
.byte 0xFC
|
||||
.byte 0xC0
|
||||
|
@ -29,14 +29,11 @@ D54:
|
|||
.byte 0x10
|
||||
.byte 0xbf
|
||||
.byte 0x18
|
||||
.byte 0x00
|
||||
.byte 0x00
|
||||
.byte 0x00
|
||||
.endobj D54
|
||||
|
||||
.section .text, "ax"
|
||||
|
||||
.global GBAJoyBootAsync
|
||||
GBAJoyBootAsync:
|
||||
.fn GBAJoyBootAsync
|
||||
/* 803C9A5C 003C69BC 7C 08 02 A6 */ mflr r0
|
||||
/* 803C9A60 003C69C0 90 01 00 04 */ stw r0, 4(r1)
|
||||
/* 803C9A64 003C69C4 54 60 00 3B */ rlwinm. r0, r3, 0, 0, 0x1d
|
||||
|
@ -103,9 +100,9 @@ lbl_803C9B20:
|
|||
lbl_803C9B38:
|
||||
/* 803C9B38 003C6A98 93 3F 00 00 */ stw r25, 0(r31)
|
||||
/* 803C9B3C 003C6A9C 3C 80 80 3F */ lis r4, D54@ha
|
||||
/* 803C9B40 003C6AA0 3C 60 80 3D */ lis r3, _F23@ha
|
||||
/* 803C9B40 003C6AA0 3C 60 80 3D */ lis r3, F23@ha
|
||||
/* 803C9B44 003C6AA4 93 5F 00 04 */ stw r26, 4(r31)
|
||||
/* 803C9B48 003C6AA8 38 A3 9B 98 */ addi r5, r3, _F23@l
|
||||
/* 803C9B48 003C6AA8 38 A3 9B 98 */ addi r5, r3, F23@l
|
||||
/* 803C9B4C 003C6AAC 38 84 71 70 */ addi r4, r4, D54@l
|
||||
/* 803C9B50 003C6AB0 93 7F 00 08 */ stw r27, 8(r31)
|
||||
/* 803C9B54 003C6AB4 7F 03 C3 78 */ mr r3, r24
|
||||
|
@ -126,9 +123,9 @@ lbl_803C9B84:
|
|||
/* 803C9B8C 003C6AEC 38 21 00 48 */ addi r1, r1, 0x48
|
||||
/* 803C9B90 003C6AF0 7C 08 03 A6 */ mtlr r0
|
||||
/* 803C9B94 003C6AF4 4E 80 00 20 */ blr
|
||||
.endfn GBAJoyBootAsync
|
||||
|
||||
.global _F23
|
||||
_F23:
|
||||
.fn F23, local
|
||||
/* 803C9B98 003C6AF8 7C 08 02 A6 */ mflr r0
|
||||
/* 803C9B9C 003C6AFC 90 01 00 04 */ stw r0, 4(r1)
|
||||
/* 803C9BA0 003C6B00 94 21 FF D8 */ stwu r1, -0x28(r1)
|
||||
|
@ -144,9 +141,9 @@ _F23:
|
|||
/* 803C9BC8 003C6B28 7F E0 22 14 */ add r31, r0, r4
|
||||
/* 803C9BCC 003C6B2C 3B DF 00 40 */ addi r30, r31, 0x40
|
||||
/* 803C9BD0 003C6B30 40 82 00 20 */ bne lbl_803C9BF0
|
||||
/* 803C9BD4 003C6B34 3C 60 80 3D */ lis r3, _F25@ha
|
||||
/* 803C9BD4 003C6B34 3C 60 80 3D */ lis r3, F25@ha
|
||||
/* 803C9BD8 003C6B38 80 9E 00 10 */ lwz r4, 0x10(r30)
|
||||
/* 803C9BDC 003C6B3C 38 A3 9C 40 */ addi r5, r3, _F25@l
|
||||
/* 803C9BDC 003C6B3C 38 A3 9C 40 */ addi r5, r3, F25@l
|
||||
/* 803C9BE0 003C6B40 38 7C 00 00 */ addi r3, r28, 0
|
||||
/* 803C9BE4 003C6B44 4B FF FC 01 */ bl GBAResetAsync
|
||||
/* 803C9BE8 003C6B48 7C 7D 1B 79 */ or. r29, r3, r3
|
||||
|
@ -173,9 +170,9 @@ lbl_803C9C1C:
|
|||
/* 803C9C34 003C6B94 38 21 00 28 */ addi r1, r1, 0x28
|
||||
/* 803C9C38 003C6B98 7C 08 03 A6 */ mtlr r0
|
||||
/* 803C9C3C 003C6B9C 4E 80 00 20 */ blr
|
||||
.endfn F23
|
||||
|
||||
.global _F25
|
||||
_F25:
|
||||
.fn F25, local
|
||||
/* 803C9C40 003C6BA0 7C 08 02 A6 */ mflr r0
|
||||
/* 803C9C44 003C6BA4 90 01 00 04 */ stw r0, 4(r1)
|
||||
/* 803C9C48 003C6BA8 94 21 FF D8 */ stwu r1, -0x28(r1)
|
||||
|
@ -202,9 +199,9 @@ _F25:
|
|||
lbl_803C9C9C:
|
||||
/* 803C9C9C 003C6BFC 2C 1D 00 00 */ cmpwi r29, 0
|
||||
/* 803C9CA0 003C6C00 40 82 00 20 */ bne lbl_803C9CC0
|
||||
/* 803C9CA4 003C6C04 3C 60 80 3D */ lis r3, _F27@ha
|
||||
/* 803C9CA4 003C6C04 3C 60 80 3D */ lis r3, F27@ha
|
||||
/* 803C9CA8 003C6C08 80 9E 00 10 */ lwz r4, 0x10(r30)
|
||||
/* 803C9CAC 003C6C0C 38 A3 9D 10 */ addi r5, r3, _F27@l
|
||||
/* 803C9CAC 003C6C0C 38 A3 9D 10 */ addi r5, r3, F27@l
|
||||
/* 803C9CB0 003C6C10 38 7C 00 00 */ addi r3, r28, 0
|
||||
/* 803C9CB4 003C6C14 4B FF FA 3D */ bl GBAGetStatusAsync
|
||||
/* 803C9CB8 003C6C18 7C 7D 1B 79 */ or. r29, r3, r3
|
||||
|
@ -231,9 +228,9 @@ lbl_803C9CEC:
|
|||
/* 803C9D04 003C6C64 38 21 00 28 */ addi r1, r1, 0x28
|
||||
/* 803C9D08 003C6C68 7C 08 03 A6 */ mtlr r0
|
||||
/* 803C9D0C 003C6C6C 4E 80 00 20 */ blr
|
||||
.endfn F25
|
||||
|
||||
.global _F27
|
||||
_F27:
|
||||
.fn F27, local
|
||||
/* 803C9D10 003C6C70 7C 08 02 A6 */ mflr r0
|
||||
/* 803C9D14 003C6C74 90 01 00 04 */ stw r0, 4(r1)
|
||||
/* 803C9D18 003C6C78 94 21 FF D8 */ stwu r1, -0x28(r1)
|
||||
|
@ -259,9 +256,9 @@ _F27:
|
|||
lbl_803C9D68:
|
||||
/* 803C9D68 003C6CC8 2C 1D 00 00 */ cmpwi r29, 0
|
||||
/* 803C9D6C 003C6CCC 40 82 00 24 */ bne lbl_803C9D90
|
||||
/* 803C9D70 003C6CD0 3C 60 80 3D */ lis r3, _F29@ha
|
||||
/* 803C9D70 003C6CD0 3C 60 80 3D */ lis r3, F29@ha
|
||||
/* 803C9D74 003C6CD4 80 BE 00 10 */ lwz r5, 0x10(r30)
|
||||
/* 803C9D78 003C6CD8 38 C3 9D E0 */ addi r6, r3, _F29@l
|
||||
/* 803C9D78 003C6CD8 38 C3 9D E0 */ addi r6, r3, F29@l
|
||||
/* 803C9D7C 003C6CDC 38 7C 00 00 */ addi r3, r28, 0
|
||||
/* 803C9D80 003C6CE0 38 9E 00 18 */ addi r4, r30, 0x18
|
||||
/* 803C9D84 003C6CE4 48 00 0B FD */ bl GBAReadAsync
|
||||
|
@ -289,9 +286,9 @@ lbl_803C9DBC:
|
|||
/* 803C9DD4 003C6D34 38 21 00 28 */ addi r1, r1, 0x28
|
||||
/* 803C9DD8 003C6D38 7C 08 03 A6 */ mtlr r0
|
||||
/* 803C9DDC 003C6D3C 4E 80 00 20 */ blr
|
||||
.endfn F27
|
||||
|
||||
.global _F29
|
||||
_F29:
|
||||
.fn F29, local
|
||||
/* 803C9DE0 003C6D40 7C 08 02 A6 */ mflr r0
|
||||
/* 803C9DE4 003C6D44 54 65 40 2E */ slwi r5, r3, 8
|
||||
/* 803C9DE8 003C6D48 90 01 00 04 */ stw r0, 4(r1)
|
||||
|
@ -326,9 +323,9 @@ lbl_803C9E44:
|
|||
/* 803C9E54 003C6DB4 38 21 00 20 */ addi r1, r1, 0x20
|
||||
/* 803C9E58 003C6DB8 7C 08 03 A6 */ mtlr r0
|
||||
/* 803C9E5C 003C6DBC 4E 80 00 20 */ blr
|
||||
.endfn F29
|
||||
|
||||
.global __GBAX01
|
||||
__GBAX01:
|
||||
.fn __GBAX01
|
||||
/* 803C9E60 003C6DC0 7C 08 02 A6 */ mflr r0
|
||||
/* 803C9E64 003C6DC4 3C A0 80 3F */ lis r5, D54@ha
|
||||
/* 803C9E68 003C6DC8 90 01 00 04 */ stw r0, 4(r1)
|
||||
|
@ -419,8 +416,8 @@ lbl_803C9F48:
|
|||
/* 803C9FB0 003C6F10 90 1E 00 34 */ stw r0, 0x34(r30)
|
||||
/* 803C9FB4 003C6F14 4B FB B3 F5 */ bl OSGetTime
|
||||
/* 803C9FB8 003C6F18 90 9E 00 2C */ stw r4, 0x2c(r30)
|
||||
/* 803C9FBC 003C6F1C 3C 80 80 3D */ lis r4, _F31@ha
|
||||
/* 803C9FC0 003C6F20 38 C4 A0 3C */ addi r6, r4, _F31@l
|
||||
/* 803C9FBC 003C6F1C 3C 80 80 3D */ lis r4, F31@ha
|
||||
/* 803C9FC0 003C6F20 38 C4 A0 3C */ addi r6, r4, F31@l
|
||||
/* 803C9FC4 003C6F24 90 7E 00 28 */ stw r3, 0x28(r30)
|
||||
/* 803C9FC8 003C6F28 38 00 00 01 */ li r0, 1
|
||||
/* 803C9FCC 003C6F2C 38 7D 00 00 */ addi r3, r29, 0
|
||||
|
@ -453,9 +450,9 @@ lbl_803CA018:
|
|||
/* 803CA030 003C6F90 38 21 00 28 */ addi r1, r1, 0x28
|
||||
/* 803CA034 003C6F94 7C 08 03 A6 */ mtlr r0
|
||||
/* 803CA038 003C6F98 4E 80 00 20 */ blr
|
||||
.endfn __GBAX01
|
||||
|
||||
.global _F31
|
||||
_F31:
|
||||
.fn F31, local
|
||||
/* 803CA03C 003C6F9C 7C 08 02 A6 */ mflr r0
|
||||
/* 803CA040 003C6FA0 3C A0 80 3F */ lis r5, D54@ha
|
||||
/* 803CA044 003C6FA4 90 01 00 04 */ stw r0, 4(r1)
|
||||
|
@ -731,9 +728,9 @@ lbl_803CA368:
|
|||
/* 803CA430 003C7390 7C 7E 02 14 */ add r3, r30, r0
|
||||
/* 803CA434 003C7394 90 83 00 3C */ stw r4, 0x3c(r3)
|
||||
lbl_803CA438:
|
||||
/* 803CA438 003C7398 3C 60 80 3D */ lis r3, _F31@ha
|
||||
/* 803CA438 003C7398 3C 60 80 3D */ lis r3, F31@ha
|
||||
/* 803CA43C 003C739C 80 BE 00 10 */ lwz r5, 0x10(r30)
|
||||
/* 803CA440 003C73A0 38 C3 A0 3C */ addi r6, r3, _F31@l
|
||||
/* 803CA440 003C73A0 38 C3 A0 3C */ addi r6, r3, F31@l
|
||||
/* 803CA444 003C73A4 38 7D 00 00 */ addi r3, r29, 0
|
||||
/* 803CA448 003C73A8 38 9E 00 1C */ addi r4, r30, 0x1c
|
||||
/* 803CA44C 003C73AC 48 00 06 65 */ bl GBAWriteAsync
|
||||
|
@ -742,8 +739,8 @@ lbl_803CA438:
|
|||
lbl_803CA458:
|
||||
/* 803CA458 003C73B8 4B FB AF 69 */ bl OSGetTick
|
||||
/* 803CA45C 003C73BC 90 7E 00 24 */ stw r3, 0x24(r30)
|
||||
/* 803CA460 003C73C0 3C 60 80 3D */ lis r3, _F33@ha
|
||||
/* 803CA464 003C73C4 38 C3 A4 D4 */ addi r6, r3, _F33@l
|
||||
/* 803CA460 003C73C0 3C 60 80 3D */ lis r3, F33@ha
|
||||
/* 803CA464 003C73C4 38 C3 A4 D4 */ addi r6, r3, F33@l
|
||||
/* 803CA468 003C73C8 80 BE 00 10 */ lwz r5, 0x10(r30)
|
||||
/* 803CA46C 003C73CC 38 7D 00 00 */ addi r3, r29, 0
|
||||
/* 803CA470 003C73D0 38 9E 00 18 */ addi r4, r30, 0x18
|
||||
|
@ -773,9 +770,9 @@ lbl_803CA4B0:
|
|||
/* 803CA4C8 003C7428 38 21 00 38 */ addi r1, r1, 0x38
|
||||
/* 803CA4CC 003C742C 7C 08 03 A6 */ mtlr r0
|
||||
/* 803CA4D0 003C7430 4E 80 00 20 */ blr
|
||||
.endfn F31
|
||||
|
||||
.global _F33
|
||||
_F33:
|
||||
.fn F33, local
|
||||
/* 803CA4D4 003C7434 7C 08 02 A6 */ mflr r0
|
||||
/* 803CA4D8 003C7438 90 01 00 04 */ stw r0, 4(r1)
|
||||
/* 803CA4DC 003C743C 94 21 FF D8 */ stwu r1, -0x28(r1)
|
||||
|
@ -845,8 +842,8 @@ lbl_803CA5C0:
|
|||
lbl_803CA5D0:
|
||||
/* 803CA5D0 003C7530 4B FB AD F1 */ bl OSGetTick
|
||||
/* 803CA5D4 003C7534 90 7E 00 24 */ stw r3, 0x24(r30)
|
||||
/* 803CA5D8 003C7538 3C 60 80 3D */ lis r3, _F35@ha
|
||||
/* 803CA5DC 003C753C 38 A3 A6 48 */ addi r5, r3, _F35@l
|
||||
/* 803CA5D8 003C7538 3C 60 80 3D */ lis r3, F35@ha
|
||||
/* 803CA5DC 003C753C 38 A3 A6 48 */ addi r5, r3, F35@l
|
||||
/* 803CA5E0 003C7540 80 9E 00 10 */ lwz r4, 0x10(r30)
|
||||
/* 803CA5E4 003C7544 7F A3 EB 78 */ mr r3, r29
|
||||
/* 803CA5E8 003C7548 4B FF F1 09 */ bl GBAGetStatusAsync
|
||||
|
@ -875,9 +872,9 @@ lbl_803CA624:
|
|||
/* 803CA63C 003C759C 38 21 00 28 */ addi r1, r1, 0x28
|
||||
/* 803CA640 003C75A0 7C 08 03 A6 */ mtlr r0
|
||||
/* 803CA644 003C75A4 4E 80 00 20 */ blr
|
||||
.endfn F33
|
||||
|
||||
.global _F35
|
||||
_F35:
|
||||
.fn F35, local
|
||||
/* 803CA648 003C75A8 7C 08 02 A6 */ mflr r0
|
||||
/* 803CA64C 003C75AC 90 01 00 04 */ stw r0, 4(r1)
|
||||
/* 803CA650 003C75B0 94 21 FF D8 */ stwu r1, -0x28(r1)
|
||||
|
@ -914,8 +911,8 @@ lbl_803CA6B0:
|
|||
lbl_803CA6C8:
|
||||
/* 803CA6C8 003C7628 28 03 00 08 */ cmplwi r3, 8
|
||||
/* 803CA6CC 003C762C 41 82 00 1C */ beq lbl_803CA6E8
|
||||
/* 803CA6D0 003C7630 3C 60 80 3D */ lis r3, _F35@ha
|
||||
/* 803CA6D4 003C7634 38 A3 A6 48 */ addi r5, r3, _F35@l
|
||||
/* 803CA6D0 003C7630 3C 60 80 3D */ lis r3, F35@ha
|
||||
/* 803CA6D4 003C7634 38 A3 A6 48 */ addi r5, r3, F35@l
|
||||
/* 803CA6D8 003C7638 38 7D 00 00 */ addi r3, r29, 0
|
||||
/* 803CA6DC 003C763C 4B FF F0 15 */ bl GBAGetStatusAsync
|
||||
/* 803CA6E0 003C7640 7C 7C 1B 78 */ mr r28, r3
|
||||
|
@ -928,9 +925,9 @@ lbl_803CA6E8:
|
|||
/* 803CA6F8 003C7658 38 7D 00 00 */ addi r3, r29, 0
|
||||
/* 803CA6FC 003C765C 38 A0 00 00 */ li r5, 0
|
||||
/* 803CA700 003C7660 48 00 08 1D */ bl __GBASetDelay
|
||||
/* 803CA704 003C7664 3C 60 80 3D */ lis r3, _F37@ha
|
||||
/* 803CA704 003C7664 3C 60 80 3D */ lis r3, F37@ha
|
||||
/* 803CA708 003C7668 80 BE 00 10 */ lwz r5, 0x10(r30)
|
||||
/* 803CA70C 003C766C 38 C3 A7 A4 */ addi r6, r3, _F37@l
|
||||
/* 803CA70C 003C766C 38 C3 A7 A4 */ addi r6, r3, F37@l
|
||||
/* 803CA710 003C7670 38 7D 00 00 */ addi r3, r29, 0
|
||||
/* 803CA714 003C7674 38 9E 00 18 */ addi r4, r30, 0x18
|
||||
/* 803CA718 003C7678 48 00 02 69 */ bl GBAReadAsync
|
||||
|
@ -970,9 +967,9 @@ lbl_803CA780:
|
|||
/* 803CA798 003C76F8 38 21 00 28 */ addi r1, r1, 0x28
|
||||
/* 803CA79C 003C76FC 7C 08 03 A6 */ mtlr r0
|
||||
/* 803CA7A0 003C7700 4E 80 00 20 */ blr
|
||||
.endfn F35
|
||||
|
||||
.global _F37
|
||||
_F37:
|
||||
.fn F37,local
|
||||
/* 803CA7A4 003C7704 7C 08 02 A6 */ mflr r0
|
||||
/* 803CA7A8 003C7708 90 01 00 04 */ stw r0, 4(r1)
|
||||
/* 803CA7AC 003C770C 94 21 FF D8 */ stwu r1, -0x28(r1)
|
||||
|
@ -1008,9 +1005,9 @@ _F37:
|
|||
/* 803CA824 003C7784 3B 80 00 03 */ li r28, 3
|
||||
/* 803CA828 003C7788 48 00 00 20 */ b lbl_803CA848
|
||||
lbl_803CA82C:
|
||||
/* 803CA82C 003C778C 3C 60 80 3D */ lis r3, _F39@ha
|
||||
/* 803CA82C 003C778C 3C 60 80 3D */ lis r3, F39@ha
|
||||
/* 803CA830 003C7790 80 BE 00 10 */ lwz r5, 0x10(r30)
|
||||
/* 803CA834 003C7794 38 C3 A8 A0 */ addi r6, r3, _F39@l
|
||||
/* 803CA834 003C7794 38 C3 A8 A0 */ addi r6, r3, F39@l
|
||||
/* 803CA838 003C7798 38 7D 00 00 */ addi r3, r29, 0
|
||||
/* 803CA83C 003C779C 38 9E 00 18 */ addi r4, r30, 0x18
|
||||
/* 803CA840 003C77A0 48 00 02 71 */ bl GBAWriteAsync
|
||||
|
@ -1039,9 +1036,9 @@ lbl_803CA87C:
|
|||
/* 803CA894 003C77F4 38 21 00 28 */ addi r1, r1, 0x28
|
||||
/* 803CA898 003C77F8 7C 08 03 A6 */ mtlr r0
|
||||
/* 803CA89C 003C77FC 4E 80 00 20 */ blr
|
||||
.endfn F37
|
||||
|
||||
.global _F39
|
||||
_F39:
|
||||
.fn F39, local
|
||||
/* 803CA8A0 003C7800 7C 08 02 A6 */ mflr r0
|
||||
/* 803CA8A4 003C7804 54 65 40 2E */ slwi r5, r3, 8
|
||||
/* 803CA8A8 003C7808 90 01 00 04 */ stw r0, 4(r1)
|
||||
|
@ -1076,3 +1073,4 @@ lbl_803CA904:
|
|||
/* 803CA914 003C7874 38 21 00 20 */ addi r1, r1, 0x20
|
||||
/* 803CA918 003C7878 7C 08 03 A6 */ mtlr r0
|
||||
/* 803CA91C 003C787C 4E 80 00 20 */ blr
|
||||
.endfn F39
|
||||
|
|
|
@ -1027,7 +1027,7 @@ LIBS = [
|
|||
"objects": [
|
||||
["Dolphin/GBA/GBA", True],
|
||||
["Dolphin/GBA/GBAGetProcessStatus", False],
|
||||
"Dolphin/GBA/GBAJoyBoot",
|
||||
["Dolphin/GBA/GBAJoyBoot", False],
|
||||
["Dolphin/GBA/GBARead", True],
|
||||
["Dolphin/GBA/GBAWrite", True],
|
||||
["Dolphin/GBA/GBAXfer", True],
|
||||
|
|
|
@ -42,7 +42,7 @@ typedef struct GBABootInfo {
|
|||
u32 crc;
|
||||
u32 dummyWord[7];
|
||||
u32 keyA;
|
||||
u32 keyB;
|
||||
s32 keyB;
|
||||
u32 initialCode;
|
||||
int realLength;
|
||||
} GBABootInfo;
|
||||
|
|
|
@ -25,7 +25,7 @@ typedef s64 OSTime;
|
|||
typedef u32 OSTick;
|
||||
u32 __OSBusClock AT_ADDRESS(OS_BASE_CACHED | 0x00F8); // sync with OSLoMem.h
|
||||
u32 __OSCoreClock AT_ADDRESS(OS_BASE_CACHED | 0x00FC); // sync with OSLoMem.h
|
||||
#define OS_BUS_CLOCK __OSBusClock
|
||||
#define OS_BUS_CLOCK (u32)__OSBusClock
|
||||
#define OS_CORE_CLOCK __OSCoreClock
|
||||
#define OS_TIMER_CLOCK (OS_BUS_CLOCK / 4)
|
||||
|
||||
|
@ -41,7 +41,7 @@ u32 __OSCoreClock AT_ADDRESS(OS_BASE_CACHED | 0x00FC); // sync with OSLoMem.h
|
|||
#define OSTicksToMilliseconds(ticks) ((ticks) / (OS_TIMER_CLOCK / 1000))
|
||||
#define OSTicksToMicroseconds(ticks) (((ticks)*8) / (OS_TIMER_CLOCK / 125000))
|
||||
#define OSTicksToNanoseconds(ticks) (((ticks)*8000) / (OS_TIMER_CLOCK / 125000))
|
||||
#define OSSecondsToTicks(sec) ((sec)*OS_TIMER_CLOCK)
|
||||
#define OSSecondsToTicks(sec) ((sec)*OS_TIMER_CLOCK)
|
||||
#define OSMillisecondsToTicks(msec) ((msec) * (OS_TIMER_CLOCK / 1000))
|
||||
#define OSMicrosecondsToTicks(usec) (((usec) * (OS_TIMER_CLOCK / 125000)) / 8)
|
||||
#define OSNanosecondsToTicks(nsec) (((nsec) * (OS_TIMER_CLOCK / 125000)) / 8000)
|
||||
|
|
|
@ -0,0 +1,366 @@
|
|||
#include "dolphin/GBAPriv.h"
|
||||
|
||||
static volatile u8 D54[] = {
|
||||
0x18, 0xFC, 0xC0, 0x80, 0x7f, 0x40, 0x3f, 0x01, 0x00, 0x2f, 0x2f, 0x20, 0x43, 0x6f, 0x64,
|
||||
0x65, 0x64, 0x20, 0x62, 0x79, 0x20, 0x4b, 0x61, 0x77, 0x61, 0x73, 0x65, 0x64, 0x6f, 0x00,
|
||||
0x00, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0xAC, 0xC4, 0xF8, 0x08, 0x10, 0xBF, 0x18,
|
||||
};
|
||||
|
||||
static void F23(s32 chan, s32 ret);
|
||||
static void F25(s32 chan, s32 ret);
|
||||
static void F27(s32 chan, s32 ret);
|
||||
static void F29(s32 chan, s32 ret);
|
||||
static void F31(s32 chan, s32 ret);
|
||||
static void F33(s32 chan, s32 ret);
|
||||
static void F35(s32 chan, s32 ret);
|
||||
static void F37(s32 chan, s32 ret);
|
||||
static void F39(s32 chan, s32 ret);
|
||||
|
||||
static u32 F72(u32 crc, u32 src, vu8* keyp) {
|
||||
int i;
|
||||
int poly;
|
||||
|
||||
for (i = keyp[1]; i > keyp[11]; --i) {
|
||||
if ((src ^ crc) & 1 != 0) {
|
||||
crc = (crc >> 1) ^ ((keyp[19] * 256 + keyp[21] + keyp[24] + keyp[24] * -16) - keyp[16]);
|
||||
} else {
|
||||
crc >>= 1;
|
||||
}
|
||||
src >>= 1;
|
||||
}
|
||||
}
|
||||
|
||||
u32 F95(u32 src, vu8* keyp) {
|
||||
return src * ((keyp[3] << keyp[0x16]) | keyp[1] | (keyp[4] << keyp[0x11]) |
|
||||
(keyp[4] << keyp[0x18])) -
|
||||
(keyp[7] - keyp[6]);
|
||||
}
|
||||
|
||||
static void F104(s32 chan, s32 ret) {
|
||||
GBABootInfo* bootInfo;
|
||||
GBACallback callback;
|
||||
|
||||
bootInfo = &__GBA[chan].bootInfo;
|
||||
bootInfo->begin = 0;
|
||||
if (bootInfo->callback != NULL) {
|
||||
callback = bootInfo->callback;
|
||||
bootInfo->callback = NULL;
|
||||
callback(chan, ret);
|
||||
}
|
||||
}
|
||||
|
||||
s32 GBAJoyBootAsync(s32 chan, s32 paletteColor, s32 paletteSpeed, u8* programp, s32 length,
|
||||
u8* status, GBACallback callback) {
|
||||
int ret;
|
||||
GBABootInfo* bootInfo;
|
||||
u8 percent;
|
||||
bootInfo = &__GBA[chan].bootInfo;
|
||||
if (chan & ~3) {
|
||||
ret = GBA_JOYBOOT_ERR_INVALID;
|
||||
} else if (length == 0 || GBA_JOYBOOT_PROGRAM_SIZE_MAX < length) {
|
||||
ret = GBA_JOYBOOT_ERR_INVALID;
|
||||
} else if (paletteSpeed < -4 || paletteSpeed > 4) {
|
||||
ret = GBA_JOYBOOT_ERR_INVALID;
|
||||
} else if (paletteColor < 0 || paletteColor > 6) {
|
||||
ret = GBA_JOYBOOT_ERR_INVALID;
|
||||
} else if (programp[0xac] * programp[0xad] * programp[0xae] * programp[0xaf] == 0) {
|
||||
ret = GBA_JOYBOOT_ERR_INVALID;
|
||||
} else {
|
||||
ret = GBAGetProcessStatus(chan, &percent);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
bootInfo->paletteColor = paletteColor;
|
||||
bootInfo->paletteSpeed = paletteSpeed;
|
||||
bootInfo->programp = programp;
|
||||
bootInfo->length = length;
|
||||
bootInfo->status = status;
|
||||
bootInfo->callback = callback;
|
||||
bootInfo->curOffset = D54[8];
|
||||
ret = GBAGetStatusAsync(chan, bootInfo->status, F23);
|
||||
if (ret != GBA_READY) {
|
||||
bootInfo->callback = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
static void F23(s32 chan, s32 ret) {
|
||||
GBAControl* gba;
|
||||
GBABootInfo* bootInfo;
|
||||
|
||||
gba = &__GBA[chan];
|
||||
bootInfo = &gba->bootInfo;
|
||||
|
||||
if (ret != GBA_READY || (ret = GBAResetAsync(chan, bootInfo->status, F25)) != GBA_READY) {
|
||||
F104(chan, ret);
|
||||
}
|
||||
|
||||
gba->ret = ret;
|
||||
}
|
||||
|
||||
static void F25(s32 chan, s32 ret) {
|
||||
GBAControl* gba = &__GBA[chan];
|
||||
GBABootInfo* bootInfo = &gba->bootInfo;
|
||||
|
||||
if (ret == GBA_READY && *bootInfo->status != D54[37]) {
|
||||
ret = GBA_JOYBOOT_UNKNOWN_STATE;
|
||||
}
|
||||
|
||||
if (ret != GBA_READY || (ret = GBAGetStatusAsync(chan, bootInfo->status, F27))) {
|
||||
F104(chan, ret);
|
||||
}
|
||||
|
||||
gba->ret = ret;
|
||||
}
|
||||
|
||||
static void F27(s32 chan, s32 ret) {
|
||||
GBAControl* gba = &__GBA[chan];
|
||||
GBABootInfo* bootInfo = &gba->bootInfo;
|
||||
|
||||
if (ret == GBA_READY && *bootInfo->status != D54[0]) {
|
||||
ret = GBA_JOYBOOT_UNKNOWN_STATE;
|
||||
}
|
||||
|
||||
if (ret != GBA_READY || (ret = GBAReadAsync(chan, bootInfo->readbuf, bootInfo->status, F29))) {
|
||||
F104(chan, ret);
|
||||
}
|
||||
|
||||
gba->ret = ret;
|
||||
}
|
||||
|
||||
static void F29(s32 chan, s32 ret) {
|
||||
GBAControl* gba = &__GBA[chan];
|
||||
GBABootInfo* bootInfo = &gba->bootInfo;
|
||||
|
||||
if (ret == GBA_READY) {
|
||||
__GBAX02(chan, bootInfo->readbuf);
|
||||
} else {
|
||||
F104(chan, ret);
|
||||
}
|
||||
|
||||
gba->ret = ret;
|
||||
}
|
||||
void __GBAX01(s32 chan, s32 ret) {
|
||||
GBAControl* gba = &__GBA[chan];
|
||||
GBABootInfo* bootInfo = &gba->bootInfo;
|
||||
int val200;
|
||||
|
||||
if (ret == GBA_READY) {
|
||||
bootInfo->keyA = gba->param->keyA;
|
||||
bootInfo->keyB = gba->param->keyB;
|
||||
if (bootInfo->readbuf[3] == 0 || bootInfo->readbuf[2] == 0 ||
|
||||
(bootInfo->keyA & (D54[5] << 9)) == 0 || bootInfo->readbuf[1] == 0 ||
|
||||
(bootInfo->keyA >> 15) == 0 || bootInfo->readbuf[0] == 0) {
|
||||
ret = GBA_JOYBOOT_UNKNOWN_STATE;
|
||||
} else {
|
||||
bootInfo->i = ~D54[36] & bootInfo->length + D54[36];
|
||||
val200 = D54[20] << D54[33];
|
||||
|
||||
if (bootInfo->i < val200) {
|
||||
bootInfo->i = val200;
|
||||
}
|
||||
|
||||
bootInfo->realLength = bootInfo->i;
|
||||
bootInfo->i -= val200;
|
||||
bootInfo->i >>= D54[32];
|
||||
bootInfo->writebuf[0] = (u8)(bootInfo->keyB >> 0);
|
||||
bootInfo->writebuf[1] = (u8)(bootInfo->keyB >> 8);
|
||||
bootInfo->writebuf[3] = (u8)(bootInfo->keyB >> 24);
|
||||
bootInfo->writebuf[2] = (u8)(bootInfo->keyB >> 16);
|
||||
bootInfo->crc = (D54[38] + 1) << D54[34];
|
||||
bootInfo->curOffset = D54[8];
|
||||
bootInfo->begin = OSGetTime();
|
||||
bootInfo->firstXfer = TRUE;
|
||||
ret = GBAWriteAsync(chan, bootInfo->writebuf, bootInfo->status, F31);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret != GBA_READY) {
|
||||
F104(chan, ret);
|
||||
}
|
||||
gba->ret = ret;
|
||||
}
|
||||
|
||||
static void F31(s32 chan, s32 ret) {
|
||||
GBAControl* gba;
|
||||
GBABootInfo* bootInfo;
|
||||
u32 writeWord;
|
||||
gba = &__GBA[chan];
|
||||
bootInfo = &gba->bootInfo;
|
||||
|
||||
if (ret == GBA_READY) {
|
||||
if (bootInfo->firstXfer != FALSE) {
|
||||
bootInfo->firstXfer = FALSE;
|
||||
} else if ((*bootInfo->status & D54[20]) == 0 ||
|
||||
(*bootInfo->status & D54[42]) >> D54[33] !=
|
||||
(bootInfo->curOffset & D54[33]) >> D54[31]) {
|
||||
ret = GBA_JOYBOOT_UNKNOWN_STATE;
|
||||
goto exit;
|
||||
} else {
|
||||
bootInfo->curOffset -= D54[25] - D54[23];
|
||||
}
|
||||
|
||||
if (bootInfo->curOffset <= bootInfo->realLength) {
|
||||
if (bootInfo->curOffset < bootInfo->realLength) {
|
||||
writeWord = D54[29];
|
||||
for (bootInfo->i = D54[29]; bootInfo->i < D54[33]; ++bootInfo->i) {
|
||||
if (bootInfo->length != 0) {
|
||||
writeWord |= *(bootInfo->programp++) << (bootInfo->i * D54[37]);
|
||||
--bootInfo->length;
|
||||
}
|
||||
}
|
||||
|
||||
if (bootInfo->curOffset == D54[38]) {
|
||||
bootInfo->initialCode = writeWord;
|
||||
} else if (bootInfo->curOffset == D54[39]) {
|
||||
writeWord = chan << D54[37];
|
||||
}
|
||||
|
||||
if (bootInfo->curOffset >= D54[2]) {
|
||||
bootInfo->crc = F72(bootInfo->crc, writeWord, &D54[19]);
|
||||
}
|
||||
|
||||
if (bootInfo->curOffset == D54[40] + 0x100) {
|
||||
bootInfo->dummyWord[0] = writeWord;
|
||||
} else if (bootInfo->curOffset == D54[1] + 0x100) {
|
||||
bootInfo->i = D54[7];
|
||||
bootInfo->dummyWord[bootInfo->i] = writeWord;
|
||||
}
|
||||
} else {
|
||||
writeWord = bootInfo->crc | (bootInfo->curOffset << 16);
|
||||
}
|
||||
|
||||
if (D54[43] < bootInfo->curOffset) {
|
||||
bootInfo->keyA = F95(bootInfo->keyA, &D54[20]);
|
||||
writeWord ^= bootInfo->keyA ^ -(bootInfo->curOffset + D54[11] * 0x100000) ^
|
||||
((D54[18] << 8) | (D54[19] << 16) | (D54[11] << 24) | D54[11]);
|
||||
}
|
||||
|
||||
bootInfo->writebuf[3] = (writeWord >> D54[0]);
|
||||
bootInfo->writebuf[0] = (writeWord >> D54[30]);
|
||||
bootInfo->writebuf[1] = (writeWord >> D54[41]);
|
||||
bootInfo->writebuf[2] = (writeWord >> D54[42]);
|
||||
|
||||
if (bootInfo->curOffset == D54[1] + D54[1]) {
|
||||
bootInfo->dummyWord[2] = writeWord;
|
||||
}
|
||||
|
||||
if (bootInfo->i < D54[33]) {
|
||||
bootInfo->dummyWord[bootInfo->i] = writeWord;
|
||||
}
|
||||
|
||||
ret = GBAWriteAsync(chan, bootInfo->writebuf, bootInfo->status, F31);
|
||||
} else {
|
||||
bootInfo->start = OSGetTick();
|
||||
ret = GBAReadAsync(chan, bootInfo->readbuf, bootInfo->status, F33);
|
||||
}
|
||||
}
|
||||
exit:
|
||||
if (ret != GBA_READY) {
|
||||
F104(chan, ret);
|
||||
}
|
||||
|
||||
gba->ret = ret;
|
||||
}
|
||||
static void F33(s32 chan, s32 ret) {
|
||||
GBAControl* gba = &__GBA[chan];
|
||||
GBABootInfo* bootInfo = &gba->bootInfo;
|
||||
|
||||
if (ret == GBA_READY) {
|
||||
for (bootInfo->i = 33; bootInfo->i < 36; ++bootInfo->i) {
|
||||
ret = (((bootInfo->readbuf[3] ^ (bootInfo->dummyWord[D54[bootInfo->i]] >> 24)) |
|
||||
(bootInfo->readbuf[2] ^ (bootInfo->dummyWord[D54[bootInfo->i]] >> 16)) |
|
||||
(bootInfo->readbuf[1] ^ (bootInfo->dummyWord[D54[bootInfo->i]] >> 8)) |
|
||||
(bootInfo->readbuf[0] ^ (bootInfo->dummyWord[D54[bootInfo->i]] >> 0)))
|
||||
<< 24);
|
||||
|
||||
if (ret == GBA_READY) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (ret != GBA_READY) {
|
||||
ret = GBA_JOYBOOT_UNKNOWN_STATE;
|
||||
} else {
|
||||
bootInfo->start = OSGetTick();
|
||||
ret = GBAGetStatusAsync(chan, bootInfo->status, F35);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret != GBA_READY) {
|
||||
F104(chan, ret);
|
||||
}
|
||||
|
||||
gba->ret = ret;
|
||||
}
|
||||
static void F35(s32 chan, s32 ret) {
|
||||
GBAControl* gba = &__GBA[chan];
|
||||
GBABootInfo* bootInfo = &gba->bootInfo;
|
||||
|
||||
if (ret == 0) {
|
||||
if (OSSecondsToTicks(10) <= OSGetTick() - bootInfo->start) {
|
||||
ret = GBA_JOYBOOT_UNKNOWN_STATE;
|
||||
} else if ((*bootInfo->status & 0x32) != 0) {
|
||||
ret = GBA_JOYBOOT_UNKNOWN_STATE;
|
||||
} else if (*bootInfo->status != 8) {
|
||||
ret = GBAGetStatusAsync(chan, bootInfo->status, F35);
|
||||
} else {
|
||||
__GBASetDelay(chan, OSMillisecondsToTicks(8));
|
||||
ret = GBAReadAsync(chan, bootInfo->readbuf, bootInfo->status, F37);
|
||||
__GBASetDelay(chan, OSMicrosecondsToTicks(60));
|
||||
}
|
||||
}
|
||||
|
||||
if (ret != GBA_READY) {
|
||||
F104(chan, ret);
|
||||
}
|
||||
|
||||
gba->ret = ret;
|
||||
}
|
||||
|
||||
static void F37(s32 chan, s32 ret) {
|
||||
GBAControl* gba = &__GBA[chan];
|
||||
GBABootInfo* bootInfo = &gba->bootInfo;
|
||||
|
||||
if (ret == GBA_READY) {
|
||||
if ((((bootInfo->readbuf[3] ^ (bootInfo->initialCode >> 24)) |
|
||||
(bootInfo->readbuf[2] ^ (bootInfo->initialCode >> 16)) |
|
||||
(bootInfo->readbuf[1] ^ (bootInfo->initialCode >> 8)) |
|
||||
(bootInfo->readbuf[0] ^ (bootInfo->initialCode >> 0)))
|
||||
<< 24) != 0) {
|
||||
ret = GBA_JOYBOOT_UNKNOWN_STATE;
|
||||
} else {
|
||||
ret = GBAWriteAsync(chan, bootInfo->readbuf, bootInfo->status, F39);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret != GBA_READY) {
|
||||
F104(chan, ret);
|
||||
}
|
||||
gba->ret = ret;
|
||||
}
|
||||
|
||||
static void F39(s32 chan, s32 ret) {
|
||||
GBAControl* gba = &__GBA[chan];
|
||||
GBABootInfo* bootInfo = &gba->bootInfo;
|
||||
|
||||
if (ret == GBA_READY) {
|
||||
*bootInfo->status = 0;
|
||||
}
|
||||
|
||||
F104(chan, ret);
|
||||
gba->ret = ret;
|
||||
}
|
||||
|
||||
s32 GBAJoyBoot(s32 chan, s32 paletteColor, s32 paletteSpeed, unsigned char* programp, s32 length,
|
||||
unsigned char* status) {
|
||||
s32 ret = GBAJoyBootAsync(chan, paletteColor, paletteSpeed, programp, length, status,
|
||||
__GBASyncCallback);
|
||||
if (ret == GBA_READY) {
|
||||
ret = __GBASync(chan);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
|
@ -188,7 +188,7 @@ void CScriptPlatform::DecayRiders(rstl::vector< SRiders >& riders, float dt, CSt
|
|||
}
|
||||
|
||||
// TODO: minor regswap
|
||||
void CScriptPlatform::MoveRiders(CStateManager& mgr, float dt, bool active,
|
||||
void CScriptPlatform::MoveRiders(CStateManager& mgr, float dt, nbdbool active,
|
||||
rstl::vector< SRiders >& riders,
|
||||
rstl::vector< SRiders >& collidedRiders, const CTransform4f& oldXf,
|
||||
const CTransform4f& newXf, const CVector3f& dragDelta,
|
||||
|
|
Loading…
Reference in New Issue