From 90e555d23eaf92ae5132c76d420e3d8e0a5d2d16 Mon Sep 17 00:00:00 2001 From: Marcus Huderle Date: Tue, 16 Apr 2019 16:11:59 -0500 Subject: [PATCH] Match sub_81A1224 --- src/apprentice.c | 183 ++--------------------------------------------- 1 file changed, 4 insertions(+), 179 deletions(-) diff --git a/src/apprentice.c b/src/apprentice.c index ac2bba48f..4ad295e1a 100644 --- a/src/apprentice.c +++ b/src/apprentice.c @@ -2013,28 +2013,27 @@ static void sub_81A1218(void) sub_81AAC28(); } -#ifdef NONMATCHING static void sub_81A1224(void) { - u8 count; u8 i, j; + u8 count; if (PLAYER_APPRENTICE.field_B1_1 < 3) return; - count = 0; - for (j = 0; j < 9 && PLAYER_APPRENTICE.field_B8[j].unk0_0; count++, j++) + for (count = 0, j = 0; j < 9 && PLAYER_APPRENTICE.field_B8[j].unk0_0; count++, j++) ; for (i = 0; i < count && i < PLAYER_APPRENTICE.field_B1_1 - 3; i++) { + do {} while(0); if (PLAYER_APPRENTICE.field_B8[i].unk0_0 == 1 && PLAYER_APPRENTICE.field_B8[i].unk0_3 && PLAYER_APPRENTICE.field_B8[i].unk2 == gSpecialVar_0x8005) { PLAYER_APPRENTICE.field_B8[PLAYER_APPRENTICE.field_B1_1 - 3].unk0_3 = 0; PLAYER_APPRENTICE.field_B8[PLAYER_APPRENTICE.field_B1_1 - 3].unk2 = gSpecialVar_0x8005; - gSpecialVar_Result = i; + gSpecialVar_Result = 0; return; } } @@ -2043,180 +2042,6 @@ static void sub_81A1224(void) PLAYER_APPRENTICE.field_B8[PLAYER_APPRENTICE.field_B1_1 - 3].unk2 = gSpecialVar_0x8005; gSpecialVar_Result = 1; } -#else -NAKED -static void sub_81A1224(void) -{ - asm_unified("\n\ - push {r4-r7,lr}\n\ - mov r7, r9\n\ - mov r6, r8\n\ - push {r6,r7}\n\ - ldr r1, =gSaveBlock2Ptr\n\ - ldr r3, [r1]\n\ - adds r0, r3, 0\n\ - adds r0, 0xB1\n\ - ldrb r0, [r0]\n\ - lsls r0, 26\n\ - lsrs r0, 28\n\ - adds r7, r1, 0\n\ - cmp r0, 0x2\n\ - bhi _081A1242\n\ - b _081A1362\n\ -_081A1242:\n\ - movs r5, 0\n\ - movs r2, 0\n\ - adds r0, r3, 0\n\ - adds r0, 0xB8\n\ - ldrb r0, [r0]\n\ - lsls r0, 30\n\ - ldr r1, =gSpecialVar_0x8005\n\ - mov r12, r1\n\ - ldr r1, =gSpecialVar_Result\n\ - mov r8, r1\n\ - cmp r0, 0\n\ - beq _081A127C\n\ - adds r3, r7, 0\n\ -_081A125C:\n\ - adds r0, r5, 0x1\n\ - lsls r0, 24\n\ - lsrs r5, r0, 24\n\ - adds r0, r2, 0x1\n\ - lsls r0, 24\n\ - lsrs r2, r0, 24\n\ - cmp r2, 0x8\n\ - bhi _081A127C\n\ - ldr r0, [r3]\n\ - lsls r1, r2, 2\n\ - adds r0, r1\n\ - adds r0, 0xB8\n\ - ldrb r0, [r0]\n\ - lsls r0, 30\n\ - cmp r0, 0\n\ - bne _081A125C\n\ -_081A127C:\n\ - movs r4, 0\n\ - cmp r4, r5\n\ - bcs _081A1322\n\ - ldr r0, [r7]\n\ - adds r0, 0xB1\n\ - ldrb r0, [r0]\n\ - lsls r0, 26\n\ - lsrs r0, 28\n\ - subs r0, 0x3\n\ - cmp r4, r0\n\ - bge _081A1322\n\ - adds r6, r7, 0\n\ - mov r9, r4\n\ -_081A1296:\n\ - ldr r3, [r6]\n\ - lsls r0, r4, 2\n\ - adds r2, r3, r0\n\ - adds r0, r2, 0\n\ - adds r0, 0xB8\n\ - ldrb r1, [r0]\n\ - lsls r0, r1, 30\n\ - lsrs r0, 30\n\ - cmp r0, 0x1\n\ - bne _081A1308\n\ - lsrs r0, r1, 6\n\ - cmp r0, 0\n\ - beq _081A1308\n\ - adds r0, r2, 0\n\ - adds r0, 0xBA\n\ - ldrh r0, [r0]\n\ - mov r2, r12\n\ - ldrh r2, [r2]\n\ - cmp r0, r2\n\ - bne _081A1308\n\ - adds r0, r3, 0\n\ - adds r0, 0xB1\n\ - ldrb r0, [r0]\n\ - lsls r0, 26\n\ - lsrs r0, 28\n\ - subs r0, 0x3\n\ - lsls r0, 2\n\ - adds r0, r3, r0\n\ - adds r0, 0xB8\n\ - ldrb r2, [r0]\n\ - movs r1, 0x3F\n\ - ands r1, r2\n\ - strb r1, [r0]\n\ - ldr r1, [r6]\n\ - adds r0, r1, 0\n\ - adds r0, 0xB1\n\ - ldrb r0, [r0]\n\ - lsls r0, 26\n\ - lsrs r0, 28\n\ - subs r0, 0x3\n\ - lsls r0, 2\n\ - adds r1, r0\n\ - mov r2, r12\n\ - ldrh r0, [r2]\n\ - adds r1, 0xBA\n\ - strh r0, [r1]\n\ - mov r1, r9\n\ - mov r0, r8\n\ - strh r1, [r0]\n\ - b _081A1362\n\ - .pool\n\ -_081A1308:\n\ - adds r0, r4, 0x1\n\ - lsls r0, 24\n\ - lsrs r4, r0, 24\n\ - cmp r4, r5\n\ - bcs _081A1322\n\ - ldr r0, [r6]\n\ - adds r0, 0xB1\n\ - ldrb r0, [r0]\n\ - lsls r0, 26\n\ - lsrs r0, 28\n\ - subs r0, 0x3\n\ - cmp r4, r0\n\ - blt _081A1296\n\ -_081A1322:\n\ - ldr r2, [r7]\n\ - adds r0, r2, 0\n\ - adds r0, 0xB1\n\ - ldrb r0, [r0]\n\ - lsls r0, 26\n\ - lsrs r0, 28\n\ - subs r0, 0x3\n\ - lsls r0, 2\n\ - adds r2, r0\n\ - adds r2, 0xB8\n\ - ldrb r1, [r2]\n\ - movs r0, 0x3F\n\ - ands r0, r1\n\ - movs r1, 0x40\n\ - orrs r0, r1\n\ - strb r0, [r2]\n\ - ldr r1, [r7]\n\ - adds r0, r1, 0\n\ - adds r0, 0xB1\n\ - ldrb r0, [r0]\n\ - lsls r0, 26\n\ - lsrs r0, 28\n\ - subs r0, 0x3\n\ - lsls r0, 2\n\ - adds r1, r0\n\ - mov r2, r12\n\ - ldrh r0, [r2]\n\ - adds r1, 0xBA\n\ - strh r0, [r1]\n\ - movs r0, 0x1\n\ - mov r1, r8\n\ - strh r0, [r1]\n\ -_081A1362:\n\ - pop {r3,r4}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ -"); -} -#endif // NONMATCHING static void sub_81A1370(void) {