diff --git a/asm/non_matching/game/InitializePlayer.inc b/asm/non_matching/game/InitializePlayer.inc deleted file mode 100644 index fc2e8da64..000000000 --- a/asm/non_matching/game/InitializePlayer.inc +++ /dev/null @@ -1,295 +0,0 @@ - -.syntax unified -.text - push {r4, r5, r6, lr} - adds r5, r0, #0 - ldr r0, _080216B4 @ =gGameMode - ldrb r0, [r0] - cmp r0, #5 - bne _080216B8 - ldr r0, [r5, #8] - ldr r1, [r5, #0xc] - ands r0, r1 - adds r0, #1 - cmp r0, #0 - beq _080216B8 - movs r0, #0xe6 - lsls r0, r0, #9 - b _080216C2 - .align 2, 0 -_080216B4: .4byte gGameMode -_080216B8: - adds r0, r5, #0 - adds r0, #0x74 - movs r1, #0 - ldrsh r0, [r0, r1] - lsls r0, r0, #8 -_080216C2: - str r0, [r5, #8] - adds r0, r5, #0 - adds r0, #0x76 - movs r1, #0 - ldrsh r0, [r0, r1] - lsls r0, r0, #8 - str r0, [r5, #0xc] - ldr r0, _0802181C @ =Player_TouchGround - str r0, [r5] - ldr r0, _08021820 @ =gPlayerControls - ldrh r2, [r0] - ldrh r1, [r0, #2] - orrs r2, r1 - ldrh r0, [r0, #4] - orrs r2, r0 - adds r0, r5, #0 - adds r0, #0x5c - movs r3, #0 - movs r4, #0 - strh r2, [r0] - adds r0, #2 - strh r2, [r0] - strh r4, [r5, #0x10] - strh r4, [r5, #0x12] - strh r4, [r5, #0x14] - movs r0, #0x80 - lsls r0, r0, #0xe - str r0, [r5, #0x20] - adds r0, r5, #0 - adds r0, #0x24 - strb r3, [r0] - movs r0, #6 - strb r0, [r5, #0x16] - movs r0, #0xe - strb r0, [r5, #0x17] - adds r1, r5, #0 - adds r1, #0x25 - movs r0, #0x78 - strb r0, [r1] - strh r4, [r5, #0x26] - adds r0, r5, #0 - adds r0, #0x29 - strb r3, [r0] - subs r0, #1 - strb r3, [r0] - adds r1, #0x13 - movs r0, #1 - strb r0, [r1] - movs r0, #0x90 - lsls r0, r0, #4 - str r0, [r5, #0x40] - movs r0, #0xc0 - lsls r0, r0, #3 - str r0, [r5, #0x44] - movs r0, #8 - str r0, [r5, #0x48] - movs r0, #0x40 - str r0, [r5, #0x4c] - adds r0, r5, #0 - adds r0, #0x64 - strh r4, [r0] - adds r1, #0x2e - ldr r0, _08021824 @ =0x0000FFFF - strh r0, [r1] - adds r1, #2 - movs r0, #1 - rsbs r0, r0, #0 - strh r0, [r1] - adds r1, #2 - strh r0, [r1] - strh r4, [r5, #0x2c] - strh r4, [r5, #0x2e] - strh r4, [r5, #0x30] - strh r4, [r5, #0x32] - str r4, [r5, #0x3c] - adds r0, r5, #0 - adds r0, #0x37 - strb r3, [r0] - strh r4, [r5, #0x2a] - adds r1, #8 - movs r0, #0xb4 - lsls r0, r0, #1 - strh r0, [r1] - adds r0, r5, #0 - adds r0, #0x7e - strh r4, [r0] - subs r0, #2 - strh r4, [r0] - adds r0, #6 - movs r1, #0x80 - lsls r1, r1, #1 - strh r1, [r0] - subs r0, #2 - strh r1, [r0] - adds r0, #4 @ p->defeatScoreIndex 0x84 - strb r3, [r0] - subs r0, #0x23 - strb r3, [r0] - adds r0, #1 - strb r3, [r0] - adds r0, #1 - strb r3, [r0] - adds r1, r5, #0 - adds r1, #0x86 - movs r0, #0x1e - strb r0, [r1] - adds r1, #1 - movs r0, #0x3c - strb r0, [r1] - adds r1, #1 - movs r0, #0xa - strb r0, [r1] - adds r0, r5, #0 - adds r0, #0x6d - strb r3, [r0] - adds r0, #1 - strb r3, [r0] - adds r0, #1 - strb r3, [r0] - subs r0, #0x15 - strb r3, [r0] - subs r0, #2 - strh r4, [r0] - adds r0, #0x14 - strb r3, [r0] - adds r0, #5 - strb r3, [r0] - subs r0, #1 - strb r3, [r0] - subs r0, #0x3a - strb r3, [r0] - bl sub_8015750 - bl sub_801561C - adds r0, r5, #0 - bl sub_802989C - adds r1, r5, #0 - adds r1, #0x99 - movs r2, #3 - adds r6, r1, #0 - adds r4, r5, #0 - adds r4, #0x60 - movs r0, #0x85 - adds r0, r0, r5 - mov ip, r0 - movs r3, #0 -_080217EA: - stm r1!, {r3} - adds r0, r2, #0 - subs r2, #1 - cmp r0, #0 - bne _080217EA - movs r0, #0x7f - strb r0, [r6] - movs r2, #0 - ldrsb r2, [r4, r2] - cmp r2, #0 - bne _08021840 - ldr r0, _08021828 @ =gGameMode - ldrb r0, [r0] - cmp r0, #2 - bhi _08021840 - ldr r3, _0802182C @ =gCourseTime - ldr r1, [r3] - ldr r0, _08021830 @ =0x00008C9F - cmp r1, r0 - bls _08021838 - ldr r0, _08021834 @ =gCheckpointTime - str r2, [r0] - str r2, [r3] - str r2, [r5, #0x78] - b _08021840 - .align 2, 0 -_0802181C: .4byte Player_TouchGround -_08021820: .4byte gPlayerControls -_08021824: .4byte 0x0000FFFF -_08021828: .4byte gGameMode -_0802182C: .4byte gCourseTime -_08021830: .4byte 0x00008C9F -_08021834: .4byte gCheckpointTime -_08021838: - ldr r1, _08021854 @ =gCheckpointTime - ldr r0, [r5, #0x78] - str r0, [r1] - str r0, [r3] -_08021840: - mov r1, ip - movs r0, #0 - ldrsb r0, [r1, r0] - cmp r0, #4 - bhi _080218C2 - lsls r0, r0, #2 - ldr r1, _08021858 @ =_0802185C - adds r0, r0, r1 - ldr r0, [r0] - mov pc, r0 - .align 2, 0 -_08021854: .4byte gCheckpointTime -_08021858: .4byte _0802185C -_0802185C: @ jump table - .4byte _08021870 @ case 0 - .4byte _08021882 @ case 1 - .4byte _08021896 @ case 2 - .4byte _080218A8 @ case 3 - .4byte _080218BA @ case 4 -_08021870: - adds r0, r5, #0 - adds r0, #0xac - movs r1, #0 - strb r1, [r0] - adds r0, #2 - strh r1, [r0] - adds r0, #2 - strh r1, [r0] - b _080218C2 -_08021882: - adds r0, r5, #0 - adds r0, #0xae - movs r2, #0 - movs r1, #0 - strh r1, [r0] - subs r0, #2 - strh r1, [r0] - adds r0, #4 - strb r2, [r0] - b _080218C2 -_08021896: - adds r0, r5, #0 - adds r0, #0xac - movs r1, #0 - strb r1, [r0] - adds r0, #4 - str r1, [r0] - subs r0, #3 - strb r1, [r0] - b _080218C2 -_080218A8: - adds r0, r5, #0 - adds r0, #0xac - movs r1, #0 - strb r1, [r0] - adds r0, #1 - strb r1, [r0] - adds r0, #1 - strb r1, [r0] - b _080218C2 -_080218BA: - adds r1, r5, #0 - adds r1, #0xac - movs r0, #0 - strb r0, [r1] -_080218C2: - ldr r1, _080218D8 @ =gUnknown_03005B7C - movs r0, #0 - strb r0, [r1] - ldr r0, _080218DC @ =gUnknown_03005840 - movs r1, #0 - str r1, [r0] - ldr r0, _080218E0 @ =gUnknown_0300583C - strb r1, [r0] - pop {r4, r5, r6} - pop {r0} - bx r0 - .align 2, 0 -_080218D8: .4byte gUnknown_03005B7C -_080218DC: .4byte gUnknown_03005840 -_080218E0: .4byte gUnknown_0300583C - -.syntax divided diff --git a/asm/non_matching/game/bosses/boss_9__TrueArea53BossMove.inc b/asm/non_matching/game/bosses/boss_9__TrueArea53BossMove.inc deleted file mode 100644 index 7467f7d6f..000000000 --- a/asm/non_matching/game/bosses/boss_9__TrueArea53BossMove.inc +++ /dev/null @@ -1,146 +0,0 @@ -.include "constants/constants.inc" - -.syntax unified -.text - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, sb - mov r5, r8 - push {r5, r6, r7} - sub sp, #0xc - adds r7, r0, #0 @ r7 = dX - adds r6, r1, #0 @ r6 = dY - ldr r0, _0804D694 @ =gActiveBossTask - ldr r0, [r0] - cmp r0, #0 - beq _0804D684 - ldrh r2, [r0, #6] - movs r3, #0xc0 - lsls r3, r3, #0x12 - adds r3, r2, r3 @ r3 = boss - ldr r0, _0804D698 @ =IWRAM_START + 0x1C - adds r1, r2, r0 @ r1 = &boss->unk1C - adds r0, #0x7c - adds r0, r0, r2 - mov sb, r0 @ sb = r0 = &boss->unk98 - ldr r0, [r1, #0x24] - adds r0, r0, r7 - str r0, [r1, #0x24] - ldr r0, [r1, #0x28] - adds r0, r0, r6 - str r0, [r1, #0x28] - ldr r0, [r3, #0x14] - adds r0, r0, r7 - str r0, [r3, #0x14] - ldr r0, [r3, #0x18] - adds r0, r0, r6 - str r0, [r3, #0x18] @ boss->pos14.y += dY; - movs r4, #0 - ldr r0, _0804D69C @ =IWRAM_START + 0x5D4 - adds r0, r2, r0 - str r0, [sp, #4] @ sp04 = &boss->unk594.unk40[0].x - ldr r0, _0804D6A0 @ =IWRAM_START + 0x5D8 - adds r0, r0, r2 - mov sl, r0 @ sl = &boss->unk594.unk40[0].y - ldr r0, _0804D6A4 @ =IWRAM_START + 0x6C4 - adds r0, r2, r0 - str r0, [sp, #8] @ sp08 = &boss->unk654.unk70[0].x - ldr r0, _0804D6A8 @ =IWRAM_START + 0x6C8 - adds r0, r2, r0 - str r0, [sp] @ sp00 = &boss->unk654.unk70[0].y - asrs r0, r7, #8 - mov r8, r0 @ r8 = I(dX) - asrs r0, r6, #8 - mov ip, r0 @ ip = I(dY) -_0804D5F8: - lsls r1, r4, #1 - adds r1, r1, r4 - lsls r1, r1, #3 - adds r1, r1, r4 - lsls r1, r1, #4 @ r1 = i*0x190 - adds r1, #0x10 - add r1, sb @ r1 = &boss->unk98.unk10[i] - ldr r0, [r1, #0x14] - adds r0, r0, r7 - str r0, [r1, #0x14] - ldr r0, [r1, #0x18] - adds r0, r0, r6 - str r0, [r1, #0x18] - movs r5, #0 - lsls r2, r4, #3 @ r2 = i * 8 - adds r0, r1, #0 - adds r0, #0x78 - adds r3, r0, r2 - adds r1, #0x7c - adds r1, r1, r2 -_0804D620: - ldr r0, [r3] - add r0, r8 - str r0, [r3] - ldr r0, [r1] - add r0, ip - str r0, [r1] - adds r0, r5, #1 - lsls r0, r0, #0x18 - lsrs r5, r0, #0x18 - cmp r5, #4 - bls _0804D620 - adds r0, r4, #1 - lsls r0, r0, #0x18 - lsrs r4, r0, #0x18 - cmp r4, #2 - bls _0804D5F8 - movs r4, #0 - ldr r5, [sp, #4] @ r5 = sp04 = &boss->unk594.unk40[0].x - mov r3, sl -_0804D646: - lsls r1, r4, #3 - adds r2, r5, r1 - ldr r0, [r2] - adds r0, r0, r7 - str r0, [r2] - adds r1, r3, r1 - ldr r0, [r1] - adds r0, r0, r6 - str r0, [r1] - adds r0, r4, #1 - lsls r0, r0, #0x18 - lsrs r4, r0, #0x18 - cmp r4, #9 - bls _0804D646 - movs r4, #0 - ldr r5, [sp, #8] @ r5 = &boss->unk654.unk70[0].x - ldr r3, [sp] -_0804D668: - lsls r1, r4, #3 - adds r2, r5, r1 - ldr r0, [r2] - adds r0, r0, r7 - str r0, [r2] - adds r1, r3, r1 - ldr r0, [r1] - adds r0, r0, r6 - str r0, [r1] - adds r0, r4, #1 - lsls r0, r0, #0x18 - lsrs r4, r0, #0x18 - cmp r4, #0xf - bls _0804D668 -_0804D684: - add sp, #0xc - pop {r3, r4, r5} - mov r8, r3 - mov sb, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_0804D694: .4byte gActiveBossTask -_0804D698: .4byte IWRAM_START + 0x1C -_0804D69C: .4byte IWRAM_START + 0x5D4 -_0804D6A0: .4byte IWRAM_START + 0x5D8 -_0804D6A4: .4byte IWRAM_START + 0x6C4 -_0804D6A8: .4byte IWRAM_START + 0x6C8 - -.syntax divided diff --git a/asm/non_matching/game/bosses/boss_9__sub_804F850.inc b/asm/non_matching/game/bosses/boss_9__sub_804F850.inc deleted file mode 100644 index 1f9e9cf50..000000000 --- a/asm/non_matching/game/bosses/boss_9__sub_804F850.inc +++ /dev/null @@ -1,190 +0,0 @@ -.include "constants/constants.inc" - -.syntax unified -.text - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, sb - mov r5, r8 - push {r5, r6, r7} - sub sp, #0x20 - str r0, [sp, #8] @ sp08 = qX - str r1, [sp, #0xc] @ sp0C = qY - lsls r3, r3, #0x10 - lsrs r6, r3, #0x10 @ r6 = sinIndex = sinIndex_; - ldr r0, _0804F8C4 @ =gCurTask - ldr r0, [r0] - ldrh r0, [r0, #6] - ldr r1, _0804F8C8 @ =IWRAM_START + 0x654 - adds r4, r0, r1 @ r4 = unk654 - mov r1, sp - movs r5, #0 - movs r3, #0 - movs r2, #0 - ldr r7, _0804F8CC @ =IWRAM_START + 0x662 - adds r0, r0, r7 - ldrb r0, [r0] - cmp r0, #0 - bne _0804F886 - strb r5, [r1] - adds r1, #1 - movs r3, #1 -_0804F886: - adds r0, r2, #1 - lsls r0, r0, #0x18 - lsrs r2, r0, #0x18 - cmp r2, #0xf - bhi _0804F8AA - adds r0, r4, #0 - adds r0, #0xe - adds r0, r0, r2 - ldrb r0, [r0] - cmp r0, #0 - bne _0804F886 - strb r2, [r1] - adds r1, #1 - adds r0, r3, #1 - lsls r0, r0, #0x18 - lsrs r3, r0, #0x18 - cmp r3, #8 - bne _0804F886 -_0804F8AA: - cmp r3, #8 - bne _0804F8B0 - movs r5, #1 -_0804F8B0: - cmp r5, #0 - beq sub_804F850__return - mov r0, sp - ldrb r0, [r0, #7] - cmp r0, #7 - bhi _0804F8D0 - adds r0, r6, #0 - adds r0, #0x3c - b _0804F8D4 - .align 2, 0 -_0804F8C4: .4byte gCurTask -_0804F8C8: .4byte IWRAM_START + 0x654 -_0804F8CC: .4byte IWRAM_START + 0x662 -_0804F8D0: - adds r0, r6, #0 - subs r0, #0x3c -_0804F8D4: - lsls r0, r0, #0x10 - lsrs r6, r0, #0x10 - ldr r0, _0804F9B4 @ =0x000003FF - ands r6, r0 -__0804F8DC: - movs r5, #0 @ i = 0 - adds r0, r4, #0 - adds r0, #0xe - str r0, [sp, #0x10] @ sp10 = &unk654->unkE[0] - adds r1, r4, #0 - adds r1, #0x1e - str r1, [sp, #0x14] @ sp14 = &unk654->unk1E[0] - adds r2, r4, #0 - adds r2, #0x2e - str r2, [sp, #0x18] @ sp18 = &unk654->unk2E[0][0] - adds r7, r4, #0 - adds r7, #0x30 - str r7, [sp, #0x1c] @ sp1C = &unk654->unk2E[0][1] - movs r0, #0x70 - adds r0, r0, r4 - mov sl, r0 @ sl = &unk654->qPos70[0].x - adds r4, #0x74 - mov sb, r4 @ sb = &unk654->qPos70[0].y - movs r1, #0x80 - lsls r1, r1, #1 - mov ip, r1 @ ip = 0x100 - adds r0, r6, r1 - lsls r0, r0, #1 - ldr r2, _0804F9B8 @ =gSineTable - adds r0, r0, r2 - movs r4, #0 - ldrsh r1, [r0, r4] - lsls r0, r1, #1 - adds r0, r0, r1 - asrs r0, r0, #6 - mov r8, r0 @ r8 = (COS(sinIndex) * 3) >> 6 -_0804F91A: - mov r7, sp - adds r0, r7, r5 - ldrb r2, [r0] - ldr r0, [sp, #0x10] - adds r1, r0, r2 - movs r0, #1 - strb r0, [r1] - ldr r4, [sp, #0x14] - adds r1, r4, r2 - movs r0, #0xff - strb r0, [r1] - lsls r3, r2, #2 - ldr r7, [sp, #0x18] - adds r4, r7, r3 - mov r0, r8 - strh r0, [r4] - ldr r1, [sp, #0x1c] - adds r3, r1, r3 - lsls r0, r6, #1 - ldr r7, _0804F9B8 @ =gSineTable - adds r0, r0, r7 - movs r7, #0 - ldrsh r1, [r0, r7] - lsls r0, r1, #1 - adds r0, r0, r1 - asrs r0, r0, #6 - strh r0, [r3] - lsls r0, r5, #7 @ r0 = (i * 128) - add r0, ip - lsls r0, r0, #1 - ldr r1, _0804F9B8 @ =gSineTable - adds r0, r0, r1 - movs r7, #0 - ldrsh r1, [r0, r7] - lsls r0, r1, #1 - adds r0, r0, r1 - asrs r0, r0, #8 - ldrh r1, [r4] - adds r0, r0, r1 - strh r0, [r4] - lsls r0, r5, #8 - ldr r4, _0804F9B8 @ =gSineTable - adds r0, r0, r4 - movs r7, #0 - ldrsh r1, [r0, r7] - lsls r0, r1, #1 - adds r0, r0, r1 - asrs r0, r0, #8 - ldrh r1, [r3] - adds r0, r0, r1 - strh r0, [r3] - lsls r2, r2, #3 - mov r4, sl - adds r0, r4, r2 - ldr r7, [sp, #8] - str r7, [r0] - add r2, sb - ldr r0, [sp, #0xc] - str r0, [r2] - adds r0, r5, #1 - lsls r0, r0, #0x18 - lsrs r5, r0, #0x18 - cmp r5, #7 - bls _0804F91A - movs r0, #0x81 - lsls r0, r0, #1 - bl m4aSongNumStart -sub_804F850__return: - add sp, #0x20 - pop {r3, r4, r5} - mov r8, r3 - mov sb, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - .align 2, 0 -_0804F9B4: .4byte 0x000003FF -_0804F9B8: .4byte gSineTable - -.syntax divided diff --git a/src/game/bosses/boss_9.c b/src/game/bosses/boss_9.c index 30d6f909d..685cc7368 100644 --- a/src/game/bosses/boss_9.c +++ b/src/game/bosses/boss_9.c @@ -738,15 +738,17 @@ NONMATCH("asm/non_matching/game/bosses/boss_9__CreateTrueArea53Boss.inc", void C } END_NONMATCH -// (95.99%) https://decomp.me/scratch/05cvE -NONMATCH("asm/non_matching/game/bosses/boss_9__TrueArea53BossMove.inc", void TrueArea53BossMove(s32 dX, s32 dY)) +void TrueArea53BossMove(s32 dX, s32 dY) { u8 i, j; TA53Boss *boss; +#ifndef NON_MATCHING + TA53_unk594 *hack; +#endif + TA53_unk594 *unk594; TA53_unk1C *unk1C; TA53_unk98 *unk98; TA53_unkA8 *unkA8; - TA53_unk594 *unk594; TA53_unk654 *unk654; if (gActiveBossTask == NULL) @@ -754,6 +756,11 @@ NONMATCH("asm/non_matching/game/bosses/boss_9__TrueArea53BossMove.inc", void Tru boss = TASK_DATA(gActiveBossTask); unk1C = &boss->unk1C; + +#ifndef NON_MATCHING + hack = &boss->unk594; +#endif + unk98 = &boss->unk98; unk1C->qPos.x += dX; @@ -777,6 +784,9 @@ NONMATCH("asm/non_matching/game/bosses/boss_9__TrueArea53BossMove.inc", void Tru for (i = 0; i < 10; i++) { unk594 = &boss->unk594; +#ifndef NON_MATCHING + unk594 = hack; +#endif unk594->unk40[i].x += dX; unk594->unk40[i].y += dY; } @@ -789,7 +799,6 @@ NONMATCH("asm/non_matching/game/bosses/boss_9__TrueArea53BossMove.inc", void Tru } // _0804D684 } -END_NONMATCH void Task_EggmanKidnapsVanilla(void) { @@ -2067,8 +2076,7 @@ void sub_804F768(u32 qX, u32 qY, s16 param2, u32 sinIndex_) } } -// (98.75%) https://decomp.me/scratch/h8qQS -NONMATCH("asm/non_matching/game/bosses/boss_9__sub_804F850.inc", void sub_804F850(u32 qX, u32 qY, s16 param2, u32 sinIndex_)) +void sub_804F850(u32 qX, u32 qY, s16 param2, u32 sinIndex_) { u8 array[0x8]; u8 i; @@ -2081,6 +2089,12 @@ NONMATCH("asm/non_matching/game/bosses/boss_9__sub_804F850.inc", void sub_804F85 u8 r3 = 0; u8 r2; +#ifndef NON_MATCHING + register u32 r0 asm("r0"); +#else + u32 r0; +#endif + for (r2 = 0; r2 < 16; r2++) { if (unk654->unkE[r2] == 0) { *pArray++ = r2; @@ -2117,7 +2131,9 @@ NONMATCH("asm/non_matching/game/bosses/boss_9__sub_804F850.inc", void sub_804F85 unk654->unkE[arrIndex] = 1; unk654->unk1E[arrIndex] = 255; unk654->unk2E[arrIndex][0] = (COS(sinIndex) * 3) >> 6; - unk654->unk2E[arrIndex][1] = (SIN(sinIndex) * 3) >> 6; + + r0 = sinIndex; + unk654->unk2E[arrIndex][1] = (SIN(r0) * 3) >> 6; unk654->unk2E[arrIndex][0] += (COS(i * 128) * 3) >> 8; unk654->unk2E[arrIndex][1] += (SIN(i * 128) * 3) >> 8; @@ -2128,7 +2144,6 @@ NONMATCH("asm/non_matching/game/bosses/boss_9__sub_804F850.inc", void sub_804F85 m4aSongNumStart(SE_258); } -END_NONMATCH void sub_804F9BC(u32 qX, u32 qY, UNUSED s16 param2, UNUSED u32 sinIndex_) { diff --git a/src/game/stage/player.c b/src/game/stage/player.c index 4e8dfc72a..8657fa555 100644 --- a/src/game/stage/player.c +++ b/src/game/stage/player.c @@ -697,9 +697,17 @@ void SetStageSpawnPos(u32 character, u32 level, u32 p2, Player *p) p->unk94 = &gUnknown_03005AA0; } -// NOTE: Only reg-alloc mismatch in loop (see comment below) -NONMATCH("asm/non_matching/game/InitializePlayer.inc", void InitializePlayer(Player *p)) +void InitializePlayer(Player *p) { +#ifndef NON_MATCHING + register u8 *u99_r6 asm("r6"); + register s8 *unk60 asm("r4"); +#else + u8 *u99_r6; + s8 *unk60; +#endif + s8 *character; + if ((gGameMode == GAME_MODE_MULTI_PLAYER_COLLECT_RINGS) && (((p->x & p->y) + 1) != 0)) { p->x = Q(460); } else { @@ -764,19 +772,47 @@ NONMATCH("asm/non_matching/game/InitializePlayer.inc", void InitializePlayer(Pla sub_801561C(); sub_802989C(p); - { // This smells like a memset macro. - // Nonmatching reg-alloc between r4 & r6 here - u32 *u99 = (void *)p->unk99; - s32 i = 4; - - while (i-- != 0) { - *u99++ = 0; - } +#ifndef NON_MATCHING + { + // Should be this but can't get it to match (even though it's functionally correct) + // so we resort back to asm + // + // u32 *u99 = (void *)p->unk99; + // s32 i = 4; + // u99_r6 = (void *)u99; + // unk60 = &p->unk60; + // character = &p->character; + + // while (i-- != 0) { + // *u99++ = 0; + // } + + register u32 *u99 asm("r1") = (void *)p->unk99; + register s32 i asm("r2") = 3; + u99_r6 = (void *)u99; + unk60 = &p->unk60; + character = &p->character; + asm("movs r3, #0\n" + "loop:\n" + "stm r1!, {r3}\n" + "add r0, r2, #0\n" + "sub r2, #1\n" + "cmp r0, #0\n" + "bne loop\n" + : + : "r"(u99), "r"(i)); } - p->unk99[0] = 0x7F; +#else + u99_r6 = p->unk99; + unk60 = &p->unk60; + character = &p->character; + memset(p->unk99, 0, 16); +#endif + + *u99_r6 = 0x7F; - if ((p->unk60 == 0) && IS_SINGLE_PLAYER) { + if ((*unk60 == 0) && IS_SINGLE_PLAYER) { if (gCourseTime >= MAX_COURSE_TIME) { gCheckpointTime = 0; gCourseTime = 0; @@ -787,7 +823,7 @@ NONMATCH("asm/non_matching/game/InitializePlayer.inc", void InitializePlayer(Pla } } - switch (p->character) { + switch (*character) { case CHARACTER_SONIC: { p->w.sf.flags = 0; p->w.sf.unkAE = 0; @@ -821,7 +857,6 @@ NONMATCH("asm/non_matching/game/InitializePlayer.inc", void InitializePlayer(Pla gUnknown_03005840 = NULL; gUnknown_0300583C = 0; } -END_NONMATCH // Called anytime the player actively jumps, "autojumps" through touching an IA, // touches a Boost Pad or a Rotating Handle, touches the ground, etc.