From d35cf06854be09a6bcf5ceb63cdb54cefd6d48a2 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 21 Jan 2018 18:25:23 -0500 Subject: [PATCH] nonmatching sub_801120C --- asm/link_rfu.s | 241 ----------------------- include/global.h | 1 + include/librfu.h | 39 +++- include/link_rfu.h | 22 --- src/battle_2.c | 2 +- src/battle_interface.c | 2 +- src/battle_script_commands.c | 6 +- src/berry_fix_program.c | 2 +- src/bg.c | 6 +- src/braille_puzzles.c | 2 +- src/decompress.c | 2 +- src/decoration.c | 2 +- src/lilycove_lady.c | 2 +- src/link_rfu.c | 364 +++++++++++++++++++++++++++++++++-- src/palette.c | 4 +- src/pokemon_summary_screen.c | 16 +- src/recorded_battle.c | 2 +- src/scrcmd.c | 2 +- src/secret_base.c | 2 +- src/sprite.c | 2 +- src/text.c | 8 +- src/tv.c | 4 +- src/util.c | 2 +- 23 files changed, 413 insertions(+), 322 deletions(-) diff --git a/asm/link_rfu.s b/asm/link_rfu.s index e1bf3bbc9..e53685c28 100644 --- a/asm/link_rfu.s +++ b/asm/link_rfu.s @@ -5,247 +5,6 @@ .text - thumb_func_start sub_801120C -sub_801120C: @ 801120C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - lsls r0, 24 - lsrs r4, r0, 24 - movs r6, 0 - cmp r4, 0x32 - bne _08011222 - b _08011360 -_08011222: - cmp r4, 0x32 - bgt _08011252 - cmp r4, 0x13 - bgt _08011240 - cmp r4, 0x12 - blt _08011230 - b _080113EE -_08011230: - cmp r4, 0x10 - bne _08011236 - b _080113EE -_08011236: - cmp r4, 0x10 - bgt _0801128C - cmp r4, 0 - beq _0801127E - b _080113EE -_08011240: - cmp r4, 0x30 - bne _08011246 - b _0801136C -_08011246: - cmp r4, 0x30 - ble _0801124C - b _08011354 -_0801124C: - cmp r4, 0x14 - beq _08011328 - b _080113EE -_08011252: - cmp r4, 0x44 - bgt _08011264 - cmp r4, 0x42 - blt _0801125C - b _080113EE -_0801125C: - cmp r4, 0x33 - bne _08011262 - b _0801136C -_08011262: - b _080113EE -_08011264: - cmp r4, 0xF3 - bne _0801126A - b _080113BA -_0801126A: - cmp r4, 0xF3 - bgt _08011276 - cmp r4, 0xF0 - bge _08011274 - b _080113EE -_08011274: - b _080113D4 -_08011276: - cmp r4, 0xFF - bne _0801127C - b _080113D4 -_0801127C: - b _080113EE -_0801127E: - ldr r1, =gUnknown_03005000 - movs r0, 0x2 - strh r0, [r1, 0x4] - b _080113EE - .pool -_0801128C: - ldr r0, =gUnknown_03004140 - ldrh r0, [r0, 0x14] - bl sub_80115EC - movs r5, 0 - movs r0, 0x1 - mov r8, r0 - ldr r1, =gUnknown_03005000 - mov r9, r1 - ldr r3, =0x00000cd5 - add r3, r9 - mov r10, r3 - movs r7, 0x7F -_080112A6: - ldr r0, =gUnknown_03004140 - ldrh r0, [r0, 0x14] - asrs r0, r5 - mov r1, r8 - ands r0, r1 - cmp r0, 0 - beq _0801130E - ldr r0, =gUnknown_03007890 - lsls r1, r5, 5 - adds r1, 0x14 - ldr r0, [r0] - adds r0, r1 - ldrb r0, [r0, 0x10] - adds r4, r7, 0 - ands r4, r0 - bl sub_800F7DC - ldrb r1, [r0, 0xA] - adds r0, r7, 0 - ands r0, r1 - cmp r4, r0 - bne _08011304 - ldr r0, =0x00000cd1 - add r0, r9 - adds r0, r5, r0 - movs r1, 0 - strb r1, [r0] - mov r3, r10 - adds r2, r5, r3 - strb r1, [r2] - movs r0, 0x20 - adds r1, r5, 0 - movs r3, 0x1 - bl rfu_setRecvBuffer - b _0801130E - .pool -_08011304: - mov r0, r8 - lsls r0, r5 - orrs r6, r0 - lsls r0, r6, 24 - lsrs r6, r0, 24 -_0801130E: - adds r0, r5, 0x1 - lsls r0, 24 - lsrs r5, r0, 24 - cmp r5, 0x3 - bls _080112A6 - cmp r6, 0 - beq _080113EE - adds r0, r6, 0 - bl rfu_REQ_disconnect - bl rfu_waitREQComplete - b _080113EE -_08011328: - ldr r4, =gUnknown_03005000 - ldr r1, =0x00000ce7 - adds r0, r4, r1 - ldr r1, =gUnknown_03004140 - ldrb r2, [r0] - ldrb r0, [r1] - cmp r2, r0 - beq _08011342 - eors r0, r2 - bl rfu_REQ_disconnect - bl rfu_waitREQComplete -_08011342: - movs r0, 0x11 - strh r0, [r4, 0x4] - b _080113EE - .pool -_08011354: - ldr r0, =gUnknown_03005000 - adds r0, 0xF0 - b _080113EA - .pool -_08011360: - ldr r0, =gUnknown_03005000 - adds r0, 0xF0 - movs r1, 0x3 - b _080113EC - .pool -_0801136C: - ldr r1, =gUnknown_03005000 - adds r2, r1, 0 - adds r2, 0xF0 - movs r0, 0x4 - strb r0, [r2] - ldr r3, =0x00000ce2 - adds r1, r3 - ldr r0, =gUnknown_03004140 - ldrb r2, [r0, 0x14] - ldrb r0, [r1] - adds r3, r0, 0 - bics r3, r2 - adds r2, r3, 0 - strb r2, [r1] - ldr r0, =gReceivedRemoteLinkPlayers - ldrb r0, [r0] - cmp r0, 0x1 - bne _080113B0 - cmp r2, 0 - bne _080113AC - adds r0, r4, 0 - bl sub_8011170 - b _080113B0 - .pool -_080113AC: - bl sub_80111FC -_080113B0: - movs r0, 0x2 - adds r1, r4, 0 - bl sub_8011A64 - b _080113EE -_080113BA: - movs r0, 0x1 - movs r1, 0xF3 - bl sub_8011A64 - movs r0, 0xF3 - bl sub_8011170 - ldr r0, =gUnknown_03005000 - adds r0, 0xEF - b _080113EA - .pool -_080113D4: - adds r0, r4, 0 - bl sub_8011170 - movs r0, 0x1 - adds r1, r4, 0 - bl sub_8011A64 - ldr r0, =gUnknown_03005000 - ldr r1, =0x00000cdb - adds r0, r1 - ldrb r1, [r0] -_080113EA: - movs r1, 0x1 -_080113EC: - strb r1, [r0] -_080113EE: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end sub_801120C - thumb_func_start sub_8011404 sub_8011404: @ 8011404 push {r4,r5,lr} diff --git a/include/global.h b/include/global.h index 1987a0ada..c32909c93 100644 --- a/include/global.h +++ b/include/global.h @@ -10,6 +10,7 @@ // to help in decompiling #define asm_comment(x) asm volatile("@ -- " x " -- ") #define asm_unified(x) asm(".syntax unified\n" x "\n.syntax divided") +#define ASM_DIRECT __attribute__((naked)) #if defined (__APPLE__) || defined (__CYGWIN__) void *memset(void *, int, size_t); diff --git a/include/librfu.h b/include/librfu.h index 9dd547eee..aae7df4e9 100644 --- a/include/librfu.h +++ b/include/librfu.h @@ -67,6 +67,28 @@ union RfuPacket struct RfuPacket8 rfuPacket8; }; +struct __attribute__((packed)) UnkLinkRfuStruct_02022B14 +{ + u16 unk_00_0:4; + u16 unk_00_4:1; + u16 unk_00_5:1; + u16 unk_00_6:1; + u16 unk_00_7:1; + u16 unk_01_0:1; + u16 unk_01_1:1; + u16 unk_01_2:4; + u16 unk_01_6:2; + u8 playerTrainerId[2]; + u8 unk_04[4]; + u16 unk_08_0:10; + u16 unk_09_2:6; + u8 unk_0a_0:7; + u8 unk_0a_7:1; + u8 playerGender:1; + u8 unk_0b_1:7; + u8 unk_0c; +}; + struct RfuStruct { vs32 unk_0; @@ -142,6 +164,15 @@ struct RfuUnk3 u32 unk_dc; }; +struct RfuUnk5Sub { + u16 unk_00; + u8 unk_02; + u16 unk_04; + struct UnkLinkRfuStruct_02022B14 unk_06; + u8 fill_13[2]; + u8 unk_15[8]; +}; + struct RfuUnk5 { u8 unk_00; @@ -156,13 +187,7 @@ struct RfuUnk5 u8 filler_09[1]; u8 unk_0a[4]; u8 filler_0e[6]; - struct RfuUnk5Sub { - u16 unk_00; - u8 unk_02; - u16 unk_04; - u8 unk_06[15]; - u8 unk_15[11]; - } unk_14[4]; + struct RfuUnk5Sub unk_14[4]; }; extern struct RfuStruct *gRfuState; diff --git a/include/link_rfu.h b/include/link_rfu.h index 0f7c52524..a6084b138 100644 --- a/include/link_rfu.h +++ b/include/link_rfu.h @@ -3,28 +3,6 @@ // Exported type declarations -struct __attribute__((packed)) UnkLinkRfuStruct_02022B14 -{ - u16 unk_00_0:4; - u16 unk_00_4:1; - u16 unk_00_5:1; - u16 unk_00_6:1; - u16 unk_00_7:1; - u16 unk_01_0:1; - u16 unk_01_1:1; - u16 unk_01_2:4; - u16 unk_01_6:2; - u8 playerTrainerId[2]; - u8 unk_04[4]; - u16 unk_08_0:10; - u16 unk_09_2:6; - u8 unk_0a_0:7; - u8 unk_0a_7:1; - u8 playerGender:1; - u8 unk_0b_1:7; - u8 unk_0c; -}; - struct UnkLinkRfuStruct_02022B2C { u8 unk_00; diff --git a/src/battle_2.c b/src/battle_2.c index aa033c537..2d7f860c7 100644 --- a/src/battle_2.c +++ b/src/battle_2.c @@ -3362,7 +3362,7 @@ static void BattleIntroOpponent1SendsOutMonAnimation(void) } #else -__attribute__((naked)) +ASM_DIRECT static void BattleIntroOpponent1SendsOutMonAnimation(void) { asm(".syntax unified\n\ diff --git a/src/battle_interface.c b/src/battle_interface.c index 6a6bf00a2..47e1d7db3 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -657,7 +657,7 @@ static void sub_8072308(s16 arg0, u16 *arg1, u8 arg2) } #else -__attribute__((naked)) +ASM_DIRECT static void sub_8072308(s16 arg0, u16 *arg1, u8 arg2) { asm(".syntax unified\n\ diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index c7976fc2a..b7e493122 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -3713,7 +3713,7 @@ static void atk24(void) } } #else -__attribute__((naked)) +ASM_DIRECT static void atk24(void) { asm("\n\ @@ -4593,7 +4593,7 @@ static void atk48_playstatchangeanimation(void) } } #else -__attribute__((naked)) +ASM_DIRECT static void atk48_playstatchangeanimation(void) { asm("\n\ @@ -9486,7 +9486,7 @@ static void atkC1_hiddenpowercalc(void) } #else -__attribute__((naked)) +ASM_DIRECT static void atkC1_hiddenpowercalc(void) { asm(".syntax unified\n\ diff --git a/src/berry_fix_program.c b/src/berry_fix_program.c index 3b2bfb5f7..f233dc645 100644 --- a/src/berry_fix_program.c +++ b/src/berry_fix_program.c @@ -265,7 +265,7 @@ static void berry_fix_gpu_set(void) } #else -__attribute__((naked)) static void berry_fix_gpu_set(void) +ASM_DIRECT static void berry_fix_gpu_set(void) { asm(".syntax unified\n" "\tpush {r4-r6,lr}\n" diff --git a/src/bg.c b/src/bg.c index b699a0b1f..22861b64d 100644 --- a/src/bg.c +++ b/src/bg.c @@ -463,7 +463,7 @@ bool8 IsDma3ManagerBusyWithBgCopy(void) return FALSE; } #else -__attribute__((naked)) +ASM_DIRECT bool8 IsDma3ManagerBusyWithBgCopy(void) { asm("push {r4-r7,lr}\n\ @@ -1048,7 +1048,7 @@ void CopyRectToBgTilemapBufferRect(u8 bg, const void* src, u8 srcX, u8 srcY, u8 } } }*/ -__attribute__((naked)) +ASM_DIRECT void CopyRectToBgTilemapBufferRect(u8 bg, const void* src, u8 srcX, u8 srcY, u8 srcWidth, u8 srcHeight, u8 destX, u8 destY, u8 rectWidth, u8 rectHeight, u8 palette1, u16 tileOffset, u16 palette2) { asm("push {r4-r7,lr}\n\ @@ -1495,7 +1495,7 @@ void CopyTileMapEntry(u16 *src, u16 *dest, s32 palette1, u32 tileOffset, u32 pal *dest = test; } #else -__attribute__((naked)) +ASM_DIRECT void CopyTileMapEntry(u16 *src, u16 *dest, s32 palette1, u32 tileOffset, u32 palette2) { asm("push {r4-r6,lr}\n\ diff --git a/src/braille_puzzles.c b/src/braille_puzzles.c index d6924de9f..55e75bfbf 100755 --- a/src/braille_puzzles.c +++ b/src/braille_puzzles.c @@ -421,7 +421,7 @@ bool8 ShouldDoBrailleRegicePuzzle(void) return FALSE; } #else -__attribute__((naked)) +ASM_DIRECT bool8 ShouldDoBrailleRegicePuzzle(void) { asm(".syntax unified\n\ diff --git a/src/decompress.c b/src/decompress.c index 8e8827194..fb288bf4a 100644 --- a/src/decompress.c +++ b/src/decompress.c @@ -117,7 +117,7 @@ void Unused_LZDecompressWramIndirect(const void **src, void *dest) } // This one (unused) function is really challenging, won't even try to decompile it. -__attribute__((naked)) +ASM_DIRECT void sub_803471C() { asm(".syntax unified\n\ diff --git a/src/decoration.c b/src/decoration.c index c539091c8..3bff5208e 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -2542,7 +2542,7 @@ void sub_812A0E8(u8 taskId) } } #else -__attribute__((naked)) void sub_812A0E8(u8 taskId) +ASM_DIRECT void sub_812A0E8(u8 taskId) { asm_unified("\tpush {r4-r7,lr}\n" "\tlsls r0, 24\n" diff --git a/src/lilycove_lady.c b/src/lilycove_lady.c index 927b87c72..dcdf9b45a 100644 --- a/src/lilycove_lady.c +++ b/src/lilycove_lady.c @@ -641,7 +641,7 @@ static u8 sub_818E13C(void) return retval; } #else -__attribute__((naked)) static u8 sub_818E13C(void) +ASM_DIRECT static u8 sub_818E13C(void) { asm_unified("\tpush {r4-r7,lr}\n" "\tmovs r7, 0x1\n" diff --git a/src/link_rfu.c b/src/link_rfu.c index ed7062d98..186d54fd3 100644 --- a/src/link_rfu.c +++ b/src/link_rfu.c @@ -72,6 +72,7 @@ void sub_80109E8(u16 a0); void sub_8010A70(void *a0); void sub_8010AAC(u8 taskId); void sub_8010D0C(u8 taskId); +void sub_80115EC(u16 a0); u8 sub_8011CE4(const u8 *a0, u16 a1); void sub_8011D6C(u8 a0); void sub_8011E94(u8 a0, u8 a1); @@ -2048,7 +2049,7 @@ u8 sub_800DD1C(u8 maxFlags) return 0; } #else -__attribute__((naked)) u8 sub_800DD1C(u8 maxFlags) +ASM_DIRECT u8 sub_800DD1C(u8 maxFlags) { asm_unified("\tpush {r4-r7,lr}\n" "\tlsls r0, 24\n" @@ -2143,7 +2144,7 @@ void sub_800DD94(struct UnkLinkRfuStruct_02022B14 *data, u8 r9, bool32 r2, int r data->unk_01_1 = FlagGet(FLAG_SYS_GAME_CLEAR); } -bool8 sub_800DE7C(void *buff1, void *buff2, u8 idx) +bool8 sub_800DE7C(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2, u8 idx) { bool8 retVal; @@ -2152,13 +2153,13 @@ bool8 sub_800DE7C(void *buff1, void *buff2, u8 idx) retVal = TRUE; if (sub_8010454(gUnknown_03007890->unk_14[idx].unk_04) && ((gUnknown_03007890->unk_07 >> idx) & 1)) { - memcpy(buff1, gUnknown_03007890->unk_14[idx].unk_06, 13); - memcpy(buff2, gUnknown_03007890->unk_14[idx].unk_15, 8); + memcpy(buff1, &gUnknown_03007890->unk_14[idx].unk_06, sizeof(gUnknown_03007890->unk_14[idx].unk_06)); + memcpy(buff2, gUnknown_03007890->unk_14[idx].unk_15, sizeof(gUnknown_03007890->unk_14[idx].unk_15)); } else { - memset(buff1, 0, 13); - memset(buff2, 0, 8); + memset(buff1, 0, sizeof(gUnknown_03007890->unk_14[idx].unk_06)); + memset(buff2, 0, sizeof(gUnknown_03007890->unk_14[idx].unk_15)); } } else @@ -2166,38 +2167,38 @@ bool8 sub_800DE7C(void *buff1, void *buff2, u8 idx) retVal = FALSE; if (sub_8010454(gUnknown_03007890->unk_14[idx].unk_04)) { - memcpy(buff1, gUnknown_03007890->unk_14[idx].unk_06, 13); - memcpy(buff2, gUnknown_03007890->unk_14[idx].unk_15, 8); + memcpy(buff1, &gUnknown_03007890->unk_14[idx].unk_06, sizeof(gUnknown_03007890->unk_14[idx].unk_06)); + memcpy(buff2, gUnknown_03007890->unk_14[idx].unk_15, sizeof(gUnknown_03007890->unk_14[idx].unk_15)); } else { - memset(buff1, 0, 13); - memset(buff2, 0, 8); + memset(buff1, 0, sizeof(gUnknown_03007890->unk_14[idx].unk_06)); + memset(buff2, 0, sizeof(gUnknown_03007890->unk_14[idx].unk_15)); } } return retVal; } -bool8 sub_800DF34(void *buff1, void *buff2, u8 idx) +bool8 sub_800DF34(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2, u8 idx) { bool8 retVal = FALSE; if (gUnknown_03007890->unk_14[idx].unk_04 == 0x7F7D) { - memcpy(buff1, gUnknown_03007890->unk_14[idx].unk_06, 13); + *buff1 = gUnknown_03007890->unk_14[idx].unk_06; memcpy(buff2, gUnknown_03007890->unk_14[idx].unk_15, 8); retVal = TRUE; } else { - memset(buff1, 0, 13); + *buff1 = (struct UnkLinkRfuStruct_02022B14){}; memset(buff2, 0, 8); } return retVal; } -void sub_800DF90(void *buff1, void *buff2) +void sub_800DF90(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2) { - memcpy(buff1, &gUnknown_02022B14, 13); + *buff1 = gUnknown_02022B14; memcpy(buff2, gUnknown_02022B22, 8); } @@ -2894,7 +2895,7 @@ void sub_800EFB0(void) CpuFill16(0, gRecvCmds, sizeof gRecvCmds); } #else -__attribute__((naked)) void sub_800EFB0(void) +ASM_DIRECT void sub_800EFB0(void) { asm_unified("\tpush {r4-r7,lr}\n" "\tsub sp, 0x4\n" @@ -3230,7 +3231,7 @@ void sub_800F638(u8 unused, u32 flags) } } #else -__attribute__((naked)) void sub_800F638(u8 unused, u32 flags) +ASM_DIRECT void sub_800F638(u8 unused, u32 flags) { asm_unified("\tpush {r4-r7,lr}\n" "\tmov r7, r10\n" @@ -3598,7 +3599,7 @@ void sub_800FD14(u16 command) } } #else -__attribute__((naked)) void sub_800FD14(u16 command) +ASM_DIRECT void sub_800FD14(u16 command) { asm_unified("\tpush {r4,r5,lr}\n" "\tlsls r0, 16\n" @@ -4610,3 +4611,330 @@ void sub_80111FC(void) { gUnknown_03005000.unk_00 = sub_80111DC; } + +#ifdef NONMATCHING +void sub_801120C(u8 a0) +{ + u8 i; + u8 r6 = 0; + struct RfuUnk5Sub *unk5Sub; + switch (a0) + { + case 0x00: + gUnknown_03005000.unk_04 = 2; + break; + case 0x10: + break; + case 0x11: + sub_80115EC(gUnknown_03004140.unk_14); + for (i = 0; i < 4; i++) + { + if ((gUnknown_03004140.unk_14 >> i) & 1) + { + unk5Sub = &gUnknown_03007890->unk_14[i]; + if (unk5Sub->unk_06.unk_0a_0 == sub_800F7DC()->unk_0a_0) + { + gUnknown_03005000.unk_cd1[i] = 0; + gUnknown_03005000.unk_cd5[i] = 0; + rfu_setRecvBuffer(0x20, i, gUnknown_03005000.unk_cd5 + i, 1); + } + else + { + r6 |= (1 << i); + } + } + } + if (r6) + { + rfu_REQ_disconnect(r6); + rfu_waitREQComplete(); + } + break; + case 0x12: + break; + case 0x13: + break; + case 0x14: + if (gUnknown_03005000.unk_ce7 != gUnknown_03004140.unk_00) + { + rfu_REQ_disconnect(gUnknown_03005000.unk_ce7 ^ gUnknown_03004140.unk_00); + rfu_waitREQComplete(); + } + gUnknown_03005000.unk_04 = 0x11; + break; + case 0x31: + gUnknown_03005000.unk_f0 = 1; + break; + case 0x32: + gUnknown_03005000.unk_f0 = 3; + break; + case 0x30: + case 0x33: + gUnknown_03005000.unk_f0 = 4; + gUnknown_03005000.unk_ce2 &= ~gUnknown_03004140.unk_14; + if (gReceivedRemoteLinkPlayers == 1) + { + if (gUnknown_03005000.unk_ce2 == 0) + sub_8011170(a0); + else + sub_80111FC(); + } + sub_8011A64(2, a0); + break; + case 0x42 ... 0x44: + break; + case 0xf3: + sub_8011A64(1, a0); + sub_8011170(a0); + gUnknown_03005000.unk_ef = 1; + break; + case 0xf0 ... 0xf2: + case 0xff: + sub_8011170(a0); + sub_8011A64(1, a0); + gUnknown_03005000.unk_cdb = 1; + break; + } +} +#else +ASM_DIRECT void sub_801120C(u8 a0) +{ + asm_unified("\tpush {r4-r7,lr}\n" + "\tmov r7, r10\n" + "\tmov r6, r9\n" + "\tmov r5, r8\n" + "\tpush {r5-r7}\n" + "\tlsls r0, 24\n" + "\tlsrs r4, r0, 24\n" + "\tmovs r6, 0\n" + "\tcmp r4, 0x32\n" + "\tbne _08011222\n" + "\tb _08011360_case_32\n" + "_08011222:\n" + "\tcmp r4, 0x32\n" + "\tbgt _08011252\n" + "\tcmp r4, 0x13\n" + "\tbgt _08011240\n" + "\tcmp r4, 0x12\n" + "\tblt _08011230\n" + "\tb _080113EE_break\n" + "_08011230:\n" + "\tcmp r4, 0x10\n" + "\tbne _08011236\n" + "\tb _080113EE_break\n" + "_08011236:\n" + "\tcmp r4, 0x10\n" + "\tbgt _0801128C_case_11\n" + "\tcmp r4, 0\n" + "\tbeq _0801127E_case_00\n" + "\tb _080113EE_break\n" + "_08011240:\n" + "\tcmp r4, 0x30\n" + "\tbne _08011246\n" + "\tb _0801136C_case_30_case_33\n" + "_08011246:\n" + "\tcmp r4, 0x30\n" + "\tble _0801124C\n" + "\tb _08011354_case_31\n" + "_0801124C:\n" + "\tcmp r4, 0x14\n" + "\tbeq _08011328_case_14\n" + "\tb _080113EE_break\n" + "_08011252:\n" + "\tcmp r4, 0x44\n" + "\tbgt _08011264\n" + "\tcmp r4, 0x42\n" + "\tblt _0801125C\n" + "\tb _080113EE_break\n" + "_0801125C:\n" + "\tcmp r4, 0x33\n" + "\tbne _08011262\n" + "\tb _0801136C_case_30_case_33\n" + "_08011262:\n" + "\tb _080113EE_break\n" + "_08011264:\n" + "\tcmp r4, 0xF3\n" + "\tbne _0801126A\n" + "\tb _080113BA_case_f3\n" + "_0801126A:\n" + "\tcmp r4, 0xF3\n" + "\tbgt _08011276\n" + "\tcmp r4, 0xF0\n" + "\tbge _08011274\n" + "\tb _080113EE_break\n" + "_08011274:\n" + "\tb _080113D4_case_f0_f1_f2_ff\n" + "_08011276:\n" + "\tcmp r4, 0xFF\n" + "\tbne _0801127C\n" + "\tb _080113D4_case_f0_f1_f2_ff\n" + "_0801127C:\n" + "\tb _080113EE_break\n" + "_0801127E_case_00:\n" + "\tldr r1, =gUnknown_03005000\n" + "\tmovs r0, 0x2\n" + "\tstrh r0, [r1, 0x4]\n" + "\tb _080113EE_break\n" + "\t.pool\n" + "_0801128C_case_11:\n" + "\tldr r0, =gUnknown_03004140\n" + "\tldrh r0, [r0, 0x14]\n" + "\tbl sub_80115EC\n" + "\tmovs r5, 0\n" + "\tmovs r0, 0x1\n" + "\tmov r8, r0\n" + "\tldr r1, =gUnknown_03005000\n" + "\tmov r9, r1\n" + "\tldr r3, =0x00000cd5\n" + "\tadd r3, r9\n" + "\tmov r10, r3\n" + "\tmovs r7, 0x7F\n" + "_080112A6:\n" + "\tldr r0, =gUnknown_03004140\n" + "\tldrh r0, [r0, 0x14]\n" + "\tasrs r0, r5\n" + "\tmov r1, r8\n" + "\tands r0, r1\n" + "\tcmp r0, 0\n" + "\tbeq _0801130E\n" + "\tldr r0, =gUnknown_03007890\n" + "\tlsls r1, r5, 5\n" + "\tadds r1, 0x14\n" + "\tldr r0, [r0]\n" + "\tadds r0, r1\n" + "\tldrb r0, [r0, 0x10]\n" + "\tadds r4, r7, 0\n" + "\tands r4, r0\n" + "\tbl sub_800F7DC\n" + "\tldrb r1, [r0, 0xA]\n" + "\tadds r0, r7, 0\n" + "\tands r0, r1\n" + "\tcmp r4, r0\n" + "\tbne _08011304\n" + "\tldr r0, =0x00000cd1\n" + "\tadd r0, r9\n" + "\tadds r0, r5, r0\n" + "\tmovs r1, 0\n" + "\tstrb r1, [r0]\n" + "\tmov r3, r10\n" + "\tadds r2, r5, r3\n" + "\tstrb r1, [r2]\n" + "\tmovs r0, 0x20\n" + "\tadds r1, r5, 0\n" + "\tmovs r3, 0x1\n" + "\tbl rfu_setRecvBuffer\n" + "\tb _0801130E\n" + "\t.pool\n" + "_08011304:\n" + "\tmov r0, r8\n" + "\tlsls r0, r5\n" + "\torrs r6, r0\n" + "\tlsls r0, r6, 24\n" + "\tlsrs r6, r0, 24\n" + "_0801130E:\n" + "\tadds r0, r5, 0x1\n" + "\tlsls r0, 24\n" + "\tlsrs r5, r0, 24\n" + "\tcmp r5, 0x3\n" + "\tbls _080112A6\n" + "\tcmp r6, 0\n" + "\tbeq _080113EE_break\n" + "\tadds r0, r6, 0\n" + "\tbl rfu_REQ_disconnect\n" + "\tbl rfu_waitREQComplete\n" + "\tb _080113EE_break\n" + "_08011328_case_14:\n" + "\tldr r4, =gUnknown_03005000\n" + "\tldr r1, =0x00000ce7\n" + "\tadds r0, r4, r1\n" + "\tldr r1, =gUnknown_03004140\n" + "\tldrb r2, [r0]\n" + "\tldrb r0, [r1]\n" + "\tcmp r2, r0\n" + "\tbeq _08011342\n" + "\teors r0, r2\n" + "\tbl rfu_REQ_disconnect\n" + "\tbl rfu_waitREQComplete\n" + "_08011342:\n" + "\tmovs r0, 0x11\n" + "\tstrh r0, [r4, 0x4]\n" + "\tb _080113EE_break\n" + "\t.pool\n" + "_08011354_case_31:\n" + "\tldr r0, =gUnknown_03005000\n" + "\tadds r0, 0xF0\n" + "\tb _080113EA\n" + "\t.pool\n" + "_08011360_case_32:\n" + "\tldr r0, =gUnknown_03005000\n" + "\tadds r0, 0xF0\n" + "\tmovs r1, 0x3\n" + "\tb _080113EC\n" + "\t.pool\n" + "_0801136C_case_30_case_33:\n" + "\tldr r1, =gUnknown_03005000\n" + "\tadds r2, r1, 0\n" + "\tadds r2, 0xF0\n" + "\tmovs r0, 0x4\n" + "\tstrb r0, [r2]\n" + "\tldr r3, =0x00000ce2\n" + "\tadds r1, r3\n" + "\tldr r0, =gUnknown_03004140\n" + "\tldrb r2, [r0, 0x14]\n" + "\tldrb r0, [r1]\n" + "\tadds r3, r0, 0\n" + "\tbics r3, r2\n" + "\tadds r2, r3, 0\n" + "\tstrb r2, [r1]\n" + "\tldr r0, =gReceivedRemoteLinkPlayers\n" + "\tldrb r0, [r0]\n" + "\tcmp r0, 0x1\n" + "\tbne _080113B0\n" + "\tcmp r2, 0\n" + "\tbne _080113AC\n" + "\tadds r0, r4, 0\n" + "\tbl sub_8011170\n" + "\tb _080113B0\n" + "\t.pool\n" + "_080113AC:\n" + "\tbl sub_80111FC\n" + "_080113B0:\n" + "\tmovs r0, 0x2\n" + "\tadds r1, r4, 0\n" + "\tbl sub_8011A64\n" + "\tb _080113EE_break\n" + "_080113BA_case_f3:\n" + "\tmovs r0, 0x1\n" + "\tmovs r1, 0xF3\n" + "\tbl sub_8011A64\n" + "\tmovs r0, 0xF3\n" + "\tbl sub_8011170\n" + "\tldr r0, =gUnknown_03005000\n" + "\tadds r0, 0xEF\n" + "\tb _080113EA\n" + "\t.pool\n" + "_080113D4_case_f0_f1_f2_ff:\n" + "\tadds r0, r4, 0\n" + "\tbl sub_8011170\n" + "\tmovs r0, 0x1\n" + "\tadds r1, r4, 0\n" + "\tbl sub_8011A64\n" + "\tldr r0, =gUnknown_03005000\n" + "\tldr r1, =0x00000cdb\n" + "\tadds r0, r1\n" + "\tldrb r1, [r0]\n" + "_080113EA:\n" + "\tmovs r1, 0x1\n" + "_080113EC:\n" + "\tstrb r1, [r0]\n" + "_080113EE_break:\n" + "\tpop {r3-r5}\n" + "\tmov r8, r3\n" + "\tmov r9, r4\n" + "\tmov r10, r5\n" + "\tpop {r4-r7}\n" + "\tpop {r0}\n" + "\tbx r0\n" + "\t.pool"); +} +#endif diff --git a/src/palette.c b/src/palette.c index d7b6ad479..417981e47 100644 --- a/src/palette.c +++ b/src/palette.c @@ -930,7 +930,7 @@ void TintPalette_SepiaTone(u16 *palette, u16 count) } } #else -__attribute__((naked)) +ASM_DIRECT void TintPalette_SepiaTone(u16 *palette, u16 count) { asm("push {r4-r7,lr}\n\ @@ -1036,7 +1036,7 @@ void TintPalette_CustomTone(u16 *palette, u16 count, u16 a3, u16 a4, u16 a5) return; } #else -__attribute__((naked)) +ASM_DIRECT void TintPalette_CustomTone(u16 *palette, u16 count, u16 a3, u16 a4, u16 a5) { asm("push {r4-r7,lr}\n\ diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index e56448d8b..31af2bf2f 100755 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -1435,7 +1435,7 @@ void sub_81C14BC(struct Pokemon *mon, u8 swappingFromId, u8 swappingToId) *ppBonusesPtr = localPpBonuses; } #else -__attribute__((naked)) +ASM_DIRECT void sub_81C14BC(struct Pokemon *mon, u8 swappingFromId, u8 swappingToId) { asm(".syntax unified\n\ @@ -1646,7 +1646,7 @@ void sub_81C15EC(struct BoxPokemon *mon, u8 swappingFromId, u8 swappingToId) *ppBonusesPtr = localPpBonuses; } #else -__attribute__((naked)) +ASM_DIRECT void sub_81C15EC(struct BoxPokemon *mon, u8 swappingFromId, u8 swappingToId) { asm(".syntax unified\n\ @@ -2057,7 +2057,7 @@ void sub_81C1CB0(struct UnkStruct_61CC04 *a, u16 *b, u8 c, u8 d) Free(alloced); } #else -__attribute__((naked)) +ASM_DIRECT void sub_81C1CB0(struct UnkStruct_61CC04 *a, u16 *b, u8 c, u8 d) { asm(".syntax unified\n\ @@ -2359,7 +2359,7 @@ void sub_81C2194(u16 *a, u16 b, u8 c) } } #else -__attribute__((naked)) +ASM_DIRECT void sub_81C2194(u16 *a, u16 b, u8 c) { asm(".syntax unified\n\ @@ -2808,7 +2808,7 @@ u8 sub_81C2D2C(struct WindowTemplate *template, u8 a) return r4[a]; } #else -__attribute__((naked)) +ASM_DIRECT u8 sub_81C2D2C(struct WindowTemplate *template, u8 a) { asm(".syntax unified\n\ @@ -2853,7 +2853,7 @@ void sub_81C2D68(u8 a) } } #else -__attribute__((naked)) +ASM_DIRECT void sub_81C2D68(u8 a) { asm(".syntax unified\n\ @@ -3110,7 +3110,7 @@ void sub_81C335C() sub_81C25A4(r4, gText_FiveMarks, r5, 1, 0, 1); } #else -__attribute__((naked)) +ASM_DIRECT void sub_81C335C() { asm(".syntax unified\n\ @@ -3453,7 +3453,7 @@ void sub_81C3B08(u8 a) sub_81C25A4(sp, text, offset, (a<<4), 0, r5); } #else -__attribute__((naked)) +ASM_DIRECT void sub_81C3B08(u8 a) { asm(".syntax unified\n\ diff --git a/src/recorded_battle.c b/src/recorded_battle.c index c88229c61..db8e2816d 100644 --- a/src/recorded_battle.c +++ b/src/recorded_battle.c @@ -484,7 +484,7 @@ u32 MoveRecordedBattleToSaveData(void) } #else -__attribute__((naked)) +ASM_DIRECT u32 MoveRecordedBattleToSaveData(void) { asm(".syntax unified\n\ diff --git a/src/scrcmd.c b/src/scrcmd.c index 0557cd95e..16a39cd8c 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -1537,7 +1537,7 @@ bool8 ScrCmd_braillemessage(struct ScriptContext *ctx) CopyWindowToVram(gUnknown_03000F30, 3); return FALSE; }*/ -__attribute__((naked)) +ASM_DIRECT bool8 ScrCmd_braillemessage(struct ScriptContext *ctx) { asm("push {r4-r7,lr}\n\ diff --git a/src/secret_base.c b/src/secret_base.c index bf6bec1f8..e2cb3b520 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -765,7 +765,7 @@ void sub_80E9914(void) } } #else -__attribute__((naked)) void sub_80E9914(void) +ASM_DIRECT void sub_80E9914(void) { asm_unified("\tpush {r4-r7,lr}\n" "\tmov r7, r10\n" diff --git a/src/sprite.c b/src/sprite.c index 6d76b9854..8d416f578 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -1228,7 +1228,7 @@ void obj_update_pos2(struct Sprite* sprite, s32 a1, s32 a2) } } #else -__attribute__((naked)) +ASM_DIRECT void obj_update_pos2(struct Sprite* sprite, s32 a1, s32 a2) { asm(".syntax unified\n\ diff --git a/src/text.c b/src/text.c index 5db3ba308..52ea06f84 100644 --- a/src/text.c +++ b/src/text.c @@ -374,7 +374,7 @@ void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor) *(current++) = (shadowColor << 12) | (shadowColor << 8) | (shadowColor << 4) | shadowColor; } #else -__attribute__((naked)) +ASM_DIRECT void GenerateFontHalfRowLookupTable(u8 fgColor, u8 bgColor, u8 shadowColor) { asm("push {r4-r7,lr}\n\ @@ -870,7 +870,7 @@ void DecompressGlyphTile(const u16 *src, u16 *dest) *(dest) = (gFontHalfRowLookupTable[gFontHalfRowOffsets[src[1] & 0xFF]] << 16) | gFontHalfRowLookupTable[gFontHalfRowOffsets[src[1] >> 8]]; } #else -__attribute__((naked)) +ASM_DIRECT void DecompressGlyphTile(const u16 *src, u16 *dest) { asm("push {r4-r7,lr}\n\ @@ -1051,7 +1051,7 @@ u8 GetLastTextColor(u8 colorType) } } -__attribute__((naked)) +ASM_DIRECT void CopyGlyphToWindow(struct TextPrinter *x) { asm("push {r4-r7,lr}\n\ @@ -2047,7 +2047,7 @@ void DrawDownArrow(u8 windowId, u16 x, u16 y, u8 bgColor, bool8 drawArrow, u8 *c } } -__attribute__((naked)) +ASM_DIRECT u16 RenderText(struct TextPrinter *textPrinter) // 80057B4 { asm("push {r4-r6,lr}\n\ diff --git a/src/tv.c b/src/tv.c index af0c7069c..1053e51af 100644 --- a/src/tv.c +++ b/src/tv.c @@ -2154,7 +2154,7 @@ void sub_80EDE98(TVShow *show) } } #else -__attribute__((naked)) +ASM_DIRECT void sub_80EDE98(TVShow *show) { asm_unified("\tpush {r4-r7,lr}\n" @@ -4110,7 +4110,7 @@ void sub_80F0708(void) // FIXME: register allocation shenanigans } } #else -__attribute__((naked)) void sub_80F0708(void) +ASM_DIRECT void sub_80F0708(void) { asm_unified("\tpush {r4-r7,lr}\n" "\tmov r7, r9\n" diff --git a/src/util.c b/src/util.c index 58088c3ee..4f9241b21 100644 --- a/src/util.c +++ b/src/util.c @@ -230,7 +230,7 @@ void CopySpriteTiles(u8 shape, u8 size, u8 *tiles, u16 *tilemap, u8 *output) } #else -__attribute__((naked)) void CopySpriteTiles(u8 shape, u8 size, u8 *tiles, u16 *tilemap, u8 *output) +ASM_DIRECT void CopySpriteTiles(u8 shape, u8 size, u8 *tiles, u16 *tilemap, u8 *output) { asm("\n\ .syntax unified\n\