From 6d98675f561431883bf9907f600097bb860525f1 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 1 Apr 2018 11:39:27 -0400 Subject: Start decompiling nakamura functions --- asm/nakamura_debug_menu.s | 172 ---------------------------------------- include/choose_party.h | 3 + src/debug/nakamura_debug_menu.c | 90 ++++++++++++++++++--- 3 files changed, 84 insertions(+), 181 deletions(-) diff --git a/asm/nakamura_debug_menu.s b/asm/nakamura_debug_menu.s index 21092fe4b..f479a209c 100644 --- a/asm/nakamura_debug_menu.s +++ b/asm/nakamura_debug_menu.s @@ -5,178 +5,6 @@ .text - thumb_func_start debug_sub_815F1B8 -debug_sub_815F1B8: - push {lr} - add sp, sp, #0xfffffff8 - bl Menu_EraseScreen - mov r0, #0xe - mov r1, #0x0 - mov r2, #0x1d - mov r3, #0x13 - bl Menu_DrawStdWindowFrame - ldr r3, ._1 @ _843E3DC - mov r0, #0x10 - mov r1, #0x1 - mov r2, #0x9 - bl Menu_PrintItems - mov r0, #0x0 - str r0, [sp] - mov r0, #0xe - str r0, [sp, #0x4] - mov r0, #0x0 - mov r1, #0xf - mov r2, #0x1 - mov r3, #0x9 - bl InitMenu - add sp, sp, #0x8 - pop {r0} - bx r0 -._2: - .align 2, 0 -._1: - .word _843E3DC - - thumb_func_end debug_sub_815F1B8 - - thumb_func_start InitNakamuraDebugMenu -InitNakamuraDebugMenu: - push {lr} - bl debug_sub_815F1B8 - ldr r1, ._3 @ gMenuCallback - ldr r0, ._3 + 4 @ debug_sub_815F214 - str r0, [r1] - mov r0, #0x0 - pop {r1} - bx r1 -._4: - .align 2, 0 -._3: - .word gMenuCallback - .word debug_sub_815F214+1 - - thumb_func_end InitNakamuraDebugMenu - - thumb_func_start debug_sub_815F214 -debug_sub_815F214: - push {r4, lr} - ldr r4, ._9 @ gMain - ldrh r1, [r4, #0x2e] - mov r0, #0x40 - and r0, r0, r1 - cmp r0, #0 - beq ._5 @cond_branch - mov r0, #0x1 - neg r0, r0 - bl Menu_MoveCursor -._5: - ldrh r1, [r4, #0x2e] - mov r0, #0x80 - and r0, r0, r1 - cmp r0, #0 - beq ._6 @cond_branch - mov r0, #0x1 - bl Menu_MoveCursor -._6: - ldrh r1, [r4, #0x2e] - mov r0, #0x1 - and r0, r0, r1 - cmp r0, #0 - beq ._7 @cond_branch - ldr r4, ._9 + 4 @ _843E3DC - bl Menu_GetCursorPos - lsl r0, r0, #0x18 - lsr r0, r0, #0x15 - add r4, r4, #0x4 - add r0, r0, r4 - ldr r4, [r0] - bl Menu_DestroyCursor - bl _call_via_r4 - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - b ._12 -._10: - .align 2, 0 -._9: - .word gMain - .word _843E3DC -._7: - mov r0, #0x2 - and r0, r0, r1 - cmp r0, #0 - bne ._11 @cond_branch - mov r0, #0x0 - b ._12 -._11: - bl CloseMenu - mov r0, #0x1 -._12: - pop {r4} - pop {r1} - bx r1 - - thumb_func_end debug_sub_815F214 - - thumb_func_start debug_sub_815F284 -debug_sub_815F284: - push {r4, lr} - lsl r0, r0, #0x18 - lsr r4, r0, #0x18 - ldr r0, ._14 @ gPaletteFade - ldrb r1, [r0, #0x7] - mov r0, #0x80 - and r0, r0, r1 - cmp r0, #0 - bne ._13 @cond_branch - bl debug_sub_81381B4 - mov r0, #0x5 - mov r1, #0x0 - bl OpenPartyMenu - add r0, r4, #0 - bl DestroyTask -._13: - pop {r4} - pop {r0} - bx r0 -._15: - .align 2, 0 -._14: - .word gPaletteFade - - thumb_func_end debug_sub_815F284 - - thumb_func_start debug_sub_815F2B4 -debug_sub_815F2B4: - push {lr} - add sp, sp, #0xfffffffc - bl CloseMenu - bl Menu_EraseScreen - ldr r1, ._16 @ gMain - ldr r0, ._16 + 4 @ sub_805469C - str r0, [r1, #0x8] - ldr r0, ._16 + 8 @ debug_sub_815F284 - mov r1, #0x0 - bl CreateTask - mov r0, #0x1 - neg r0, r0 - mov r1, #0x0 - str r1, [sp] - mov r2, #0x0 - mov r3, #0x10 - bl BeginNormalPaletteFade - mov r0, #0x1 - add sp, sp, #0x4 - pop {r1} - bx r1 -._17: - .align 2, 0 -._16: - .word gMain - .word sub_805469C+1 - .word debug_sub_815F284+1 - - thumb_func_end debug_sub_815F2B4 - thumb_func_start debug_sub_815F2F4 debug_sub_815F2F4: push {r4, r5, r6, r7, lr} diff --git a/include/choose_party.h b/include/choose_party.h index 853202a89..1f7d48f59 100644 --- a/include/choose_party.h +++ b/include/choose_party.h @@ -9,5 +9,8 @@ bool8 SetupLinkMultiBattlePartyMenu(void); void HandleLinkMultiBattlePartyMenu(u8 taskId); void HandleDaycarePartyMenu(u8 taskId); void sub_8123138(u8 taskId); +#if DEBUG +void debug_sub_81381B4(void); +#endif #endif // GUARD_CHOOSE_PARTY_H diff --git a/src/debug/nakamura_debug_menu.c b/src/debug/nakamura_debug_menu.c index 550ac7bbd..2045933f7 100644 --- a/src/debug/nakamura_debug_menu.c +++ b/src/debug/nakamura_debug_menu.c @@ -1,7 +1,15 @@ #if DEBUG #include "global.h" +#include "palette.h" +#include "main.h" +#include "overworld.h" +#include "start_menu.h" +#include "party_menu.h" +#include "choose_party.h" #include "menu.h" +typedef bool8 (*MenuFunc)(void); + EWRAM_DATA u8 _nakamuraData0 = 0; EWRAM_DATA u8 _nakamuraData1 = 0; EWRAM_DATA u8 _nakamuraData2 = 0; @@ -20,15 +28,16 @@ __attribute__((unused)) static u8 gDebugFiller3000814[4]; asm(".global _nakamuraStatic0"); asm(".global _nakamuraStatic18"); -u8 debug_sub_815FC54(); -u8 debug_sub_815F2B4(); -u8 debug_sub_815FC94(); -u8 debug_sub_815FB1C(); -u8 debug_sub_815F2F4(); -u8 debug_sub_815F62C(); -u8 debug_sub_815FBE8(); -u8 debug_sub_815FE1C(); -u8 debug_sub_8160D98(); +bool8 debug_sub_815F214(void); +bool8 debug_sub_815FC54(void); +bool8 debug_sub_815F2B4(void); +bool8 debug_sub_815FC94(void); +bool8 debug_sub_815FB1C(void); +bool8 debug_sub_815F2F4(void); +bool8 debug_sub_815F62C(void); +bool8 debug_sub_815FBE8(void); +bool8 debug_sub_815FE1C(void); +bool8 debug_sub_8160D98(void); const u8 Str_843E36C[] = _("Berries"); const u8 Str_843E374[] = _("Goods"); @@ -186,4 +195,67 @@ const u8 Str_843E655[] = _("かい"); const u8 Str_843E658[] = _("0"); const u8 Str_843E65A[] = _("はんい"); +void debug_sub_815F1B8(void) +{ + Menu_EraseScreen(); + Menu_DrawStdWindowFrame(14, 0, 29, 19); + Menu_PrintItems(16, 1, ARRAY_COUNT(_843E3DC), _843E3DC); + InitMenu(0, 15, 1, ARRAY_COUNT(_843E3DC), 0, 14); +} + +bool8 InitNakamuraDebugMenu(void) +{ + debug_sub_815F1B8(); + gMenuCallback = debug_sub_815F214; + return FALSE; +} + +bool8 debug_sub_815F214(void) +{ + if (gMain.newKeys & DPAD_UP) + { + Menu_MoveCursor(-1); + } + + if (gMain.newKeys & DPAD_DOWN) + { + Menu_MoveCursor(+1); + } + + if (gMain.newKeys & A_BUTTON) + { + MenuFunc func = _843E3DC[Menu_GetCursorPos()].func; + Menu_DestroyCursor(); + return func(); + } + + if (gMain.newKeys & B_BUTTON) + { + CloseMenu(); + return TRUE; + } + + return FALSE; +} + +void debug_sub_815F284(u8 taskId) +{ + if (!gPaletteFade.active) + { + debug_sub_81381B4(); + OpenPartyMenu(5, 0); + DestroyTask(taskId); + } +} + +bool8 debug_sub_815F2B4(void) +{ + CloseMenu(); + Menu_EraseScreen(); + gMain.savedCallback = sub_805469C; + CreateTask(debug_sub_815F284, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + return TRUE; +} + #endif // DEBUG -- cgit v1.2.3 From 6725a429fe84f0b024695c4fa176f1c6f8b842e5 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 1 Apr 2018 14:11:21 -0400 Subject: debug_sub_815F2F4 --- asm/nakamura_debug_menu.s | 198 ---------------------------------------- include/secret_base.h | 3 + src/debug/nakamura_debug_menu.c | 56 ++++++++++++ 3 files changed, 59 insertions(+), 198 deletions(-) diff --git a/asm/nakamura_debug_menu.s b/asm/nakamura_debug_menu.s index f479a209c..7e6feb25c 100644 --- a/asm/nakamura_debug_menu.s +++ b/asm/nakamura_debug_menu.s @@ -5,204 +5,6 @@ .text - thumb_func_start debug_sub_815F2F4 -debug_sub_815F2F4: - push {r4, r5, r6, r7, lr} - mov r7, sl - mov r6, r9 - mov r5, r8 - push {r5, r6, r7} - add sp, sp, #0xfffffffc - bl CloseMenu - mov r7, #0x1 -._34: - lsl r1, r7, #0x2 - add r0, r1, r7 - lsl r2, r0, #0x5 - ldr r3, ._24 @ gSaveBlock1 - add r0, r2, r3 - ldr r5, ._24 + 4 @ 0x1a08 - add r0, r0, r5 - ldrb r0, [r0] - mov r9, r1 - add r1, r7, #1 - str r1, [sp] - cmp r0, #0 - beq ._18 @cond_branch - b ._19 -._18: - mov r5, #0x0 - ldr r6, ._24 + 8 @ gSaveBlock2 - add r4, r7, #0 - sub r4, r4, #0x46 - ldr r3, ._24 + 12 @ gSaveBlock1 -._21: - add r1, r5, r2 - add r1, r1, r3 - add r0, r5, r6 - ldrb r0, [r0] - strb r0, [r1] - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - cmp r0, #0xff - beq ._20 @cond_branch - add r0, r5, #1 - lsl r0, r0, #0x18 - lsr r5, r0, #0x18 - cmp r5, #0x6 - bls ._21 @cond_branch -._20: - cmp r5, #0x7 - bne ._22 @cond_branch - add r0, r2, #6 - b ._23 -._25: - .align 2, 0 -._24: - .word gSaveBlock1 - .word 0x1a08 - .word gSaveBlock2 - .word gSaveBlock1+0x1a0a -._22: - add r0, r5, r2 -._23: - add r0, r0, r3 - strb r4, [r0] - ldr r1, ._35 @ gSaveBlock1 - ldr r2, ._35 + 4 @ 0x1a08 - add r2, r2, r1 - mov sl, r2 - mov r3, r9 - add r0, r3, r7 - lsl r6, r0, #0x5 - add r1, r6, r1 - ldr r5, ._35 + 4 @ 0x1a08 - add r5, r5, r1 - mov r8, r5 -._30: - bl Random - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - mov r1, #0x4b - bl __umodsi3 - lsl r0, r0, #0x10 - lsr r0, r0, #0xe - ldr r1, ._35 + 8 @ _843E424 - add r0, r0, r1 - ldrb r0, [r0] - mov r2, r8 - strb r0, [r2] - mov r5, #0x0 - cmp r5, r7 - bcs ._28 @cond_branch - mov r3, sl - ldrb r3, [r3] - cmp r0, r3 - beq ._28 @cond_branch - ldr r4, ._35 @ gSaveBlock1 - add r0, r6, r4 - ldr r2, ._35 + 4 @ 0x1a08 - add r3, r0, r2 -._29: - add r0, r5, #1 - lsl r0, r0, #0x18 - lsr r5, r0, #0x18 - cmp r5, r7 - bcs ._28 @cond_branch - lsl r0, r5, #0x2 - add r0, r0, r5 - lsl r0, r0, #0x5 - add r0, r0, r4 - add r0, r0, r2 - ldrb r1, [r3] - ldrb r0, [r0] - cmp r1, r0 - bne ._29 @cond_branch -._28: - cmp r5, r7 - bne ._30 @cond_branch - bl Random - mov r5, r9 - add r4, r5, r7 - lsl r4, r4, #0x5 - ldr r1, ._35 @ gSaveBlock1 - add r3, r4, r1 - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - mov r1, #0x1 - ldr r2, ._35 + 12 @ 0x1a09 - add r3, r3, r2 - and r0, r0, r1 - lsl r0, r0, #0x4 - ldrb r1, [r3] - mov r5, #0x11 - neg r5, r5 - add r2, r5, #0 - and r1, r1, r2 - orr r1, r1, r0 - strb r1, [r3] - mov r5, #0x0 - ldr r6, ._35 + 16 @ gSaveBlock1 -._31: - bl Random - add r1, r5, r4 - add r1, r1, r6 - strb r0, [r1] - add r0, r5, #1 - lsl r0, r0, #0x18 - lsr r5, r0, #0x18 - cmp r5, #0x3 - bls ._31 @cond_branch - mov r5, #0x0 - mov r1, r9 - add r0, r1, r7 - lsl r4, r0, #0x5 - ldr r3, ._35 + 20 @ gSaveBlock1 - mov r2, #0x0 - add r6, r3, #0 - add r6, r6, #0x10 -._32: - add r1, r5, r4 - add r0, r1, r3 - strb r2, [r0] - add r1, r1, r6 - strb r2, [r1] - add r0, r5, #1 - lsl r0, r0, #0x18 - lsr r5, r0, #0x18 - cmp r5, #0xf - bls ._32 @cond_branch - add r0, r7, #0 - bl unref_sub_80BCD7C -._19: - ldr r2, [sp] - lsl r0, r2, #0x18 - lsr r7, r0, #0x18 - cmp r7, #0x13 - bhi ._33 @cond_branch - b ._34 -._33: - mov r0, #0x1 - add sp, sp, #0x4 - pop {r3, r4, r5} - mov r8, r3 - mov r9, r4 - mov sl, r5 - pop {r4, r5, r6, r7} - pop {r1} - bx r1 -._36: - .align 2, 0 -._35: - .word gSaveBlock1 - .word 0x1a08 - .word _843E424 - .word 0x1a09 - .word gSaveBlock1+0x1a11 - .word gSaveBlock1+0x1a1a - - thumb_func_end debug_sub_815F2F4 - thumb_func_start debug_sub_815F470 debug_sub_815F470: push {r4, r5, r6, r7, lr} diff --git a/include/secret_base.h b/include/secret_base.h index a3fa22c05..7f60e0f79 100644 --- a/include/secret_base.h +++ b/include/secret_base.h @@ -20,5 +20,8 @@ u8 sub_80BCCA4(u8 secretBaseIndex); const u8 *GetSecretBaseTrainerLoseText(void); void sub_80BCF1C(u8 taskId); void sub_80BD674(void *playerRecords, u32 size, u8 c); +#if DEBUG +void unref_sub_80BCD7C(u8 secretBaseIndex); +#endif #endif // GUARD_SECRET_BASE_H diff --git a/src/debug/nakamura_debug_menu.c b/src/debug/nakamura_debug_menu.c index 2045933f7..6d5a27a30 100644 --- a/src/debug/nakamura_debug_menu.c +++ b/src/debug/nakamura_debug_menu.c @@ -1,11 +1,13 @@ #if DEBUG #include "global.h" +#include "random.h" #include "palette.h" #include "main.h" #include "overworld.h" #include "start_menu.h" #include "party_menu.h" #include "choose_party.h" +#include "secret_base.h" #include "menu.h" typedef bool8 (*MenuFunc)(void); @@ -258,4 +260,58 @@ bool8 debug_sub_815F2B4(void) return TRUE; } +bool8 debug_sub_815F2F4(void) +{ + u8 i; + CloseMenu(); + + for (i = 1; i < 20; i++) + { + if (gSaveBlock1.secretBases[i].secretBaseId == 0) + { + u8 j; + + for (j = 0; j < 7; j++) + { + gSaveBlock1.secretBases[i].playerName[j] = gSaveBlock2.playerName[j]; + if (gSaveBlock1.secretBases[i].playerName[j] == EOS) + break; + } + + if (j == 7) + gSaveBlock1.secretBases[i].playerName[j - 1] = CHAR_A + i - 1; + else + gSaveBlock1.secretBases[i].playerName[j] = CHAR_A + i - 1; + + do + { + gSaveBlock1.secretBases[i].secretBaseId = _843E424[Random() % ARRAY_COUNT(_843E424)][0]; + + for (j = 0; j < i; j++) + { + if (gSaveBlock1.secretBases[i].secretBaseId == gSaveBlock1.secretBases[j].secretBaseId) + break; + } + } while (j != i); + + gSaveBlock1.secretBases[i].gender = Random() % 2; + + for (j = 0; j < 4; j++) + { + gSaveBlock1.secretBases[i].trainerId[j] = Random(); + } + + for (j = 0; j < 16; j++) + { + gSaveBlock1.secretBases[i].decorations[j] = 0; + gSaveBlock1.secretBases[i].decorationPos[j] = 0; + } + + unref_sub_80BCD7C(i); + } + } + + return TRUE; +} + #endif // DEBUG -- cgit v1.2.3 From cd0a93d88b8f05db0e4b68490392186c918cad57 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 1 Apr 2018 16:05:19 -0400 Subject: through debug_sub_815F5C4 --- asm/nakamura_debug_menu.s | 227 -------------------------------------- include/secret_base.h | 1 + src/debug/nakamura_debug_menu.c | 233 +++++++++++++++++++++++++++------------- 3 files changed, 157 insertions(+), 304 deletions(-) diff --git a/asm/nakamura_debug_menu.s b/asm/nakamura_debug_menu.s index 7e6feb25c..6ddce1855 100644 --- a/asm/nakamura_debug_menu.s +++ b/asm/nakamura_debug_menu.s @@ -5,233 +5,6 @@ .text - thumb_func_start debug_sub_815F470 -debug_sub_815F470: - push {r4, r5, r6, r7, lr} - add r6, r0, #0 - add r7, r1, #0 - mov ip, r2 - ldr r2, ._39 @ gSaveBlock1 - ldr r0, ._39 + 4 @ _nakamuraData0 - ldrb r1, [r0] - lsl r0, r1, #0x2 - add r0, r0, r1 - lsl r0, r0, #0x5 - add r0, r0, r2 - ldr r1, ._39 + 8 @ 0x1a08 - add r0, r0, r1 - ldrb r4, [r0] - mov r2, #0x0 - ldr r3, ._39 + 12 @ _843E424 - add r5, r3, #0 -._41: - lsl r1, r2, #0x2 - add r0, r1, r5 - ldrb r0, [r0] - cmp r0, r4 - bne ._37 @cond_branch - add r0, r1, #1 - add r0, r0, r3 - ldrb r0, [r0] - strb r0, [r6] - add r0, r1, #2 - add r0, r0, r3 - ldrb r0, [r0] - strb r0, [r7] - add r0, r1, #3 - add r0, r0, r3 - ldrb r0, [r0] - mov r1, ip - strb r0, [r1] - b ._38 -._40: - .align 2, 0 -._39: - .word gSaveBlock1 - .word _nakamuraData0 - .word 0x1a08 - .word _843E424 -._37: - add r0, r2, #1 - lsl r0, r0, #0x18 - lsr r2, r0, #0x18 - cmp r2, #0x4a - bls ._41 @cond_branch -._38: - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - - thumb_func_end debug_sub_815F470 - - thumb_func_start debug_sub_815F4D8 -debug_sub_815F4D8: - push {r4, r5, r6, r7, lr} - add sp, sp, #0xfffffffc - mov r0, #0x1 - mov r1, #0x1 - mov r2, #0xa - mov r3, #0xa - bl Menu_BlankWindowRect - ldr r6, ._43 @ gStringVar1 - ldr r7, ._43 + 4 @ _nakamuraData0 - ldrb r1, [r7] - add r0, r6, #0 - mov r2, #0x0 - mov r3, #0x2 - bl ConvertIntToDecimalStringN - add r0, r6, #0 - mov r1, #0x1 - mov r2, #0x1 - bl Menu_PrintText - ldr r2, ._43 + 8 @ gSaveBlock1 - ldrb r1, [r7] - lsl r0, r1, #0x2 - add r0, r0, r1 - lsl r0, r0, #0x5 - add r0, r0, r2 - ldr r1, ._43 + 12 @ 0x1a08 - add r0, r0, r1 - ldrb r0, [r0] - cmp r0, #0 - beq ._42 @cond_branch - mov r4, sp - add r4, r4, #0x1 - mov r5, sp - add r5, r5, #0x2 - mov r0, sp - add r1, r4, #0 - add r2, r5, #0 - bl debug_sub_815F470 - ldrb r1, [r7] - add r0, r6, #0 - bl sub_80BC190 - add r0, r6, #0 - mov r1, #0x1 - mov r2, #0x3 - bl Menu_PrintText - ldr r0, ._43 + 16 @ Str_843E550 - mov r1, #0x1 - mov r2, #0x5 - bl Menu_PrintText - mov r0, sp - ldrb r1, [r0] - add r0, r6, #0 - mov r2, #0x0 - mov r3, #0x3 - bl ConvertIntToDecimalStringN - add r0, r6, #0 - mov r1, #0x2 - mov r2, #0x5 - bl Menu_PrintText - ldr r0, ._43 + 20 @ Str_843E552 - mov r1, #0x1 - mov r2, #0x7 - bl Menu_PrintText - ldrb r1, [r4] - add r0, r6, #0 - mov r2, #0x0 - mov r3, #0x3 - bl ConvertIntToDecimalStringN - add r0, r6, #0 - mov r1, #0x3 - mov r2, #0x7 - bl Menu_PrintText - ldr r0, ._43 + 24 @ Str_843E554 - mov r1, #0x1 - mov r2, #0x9 - bl Menu_PrintText - ldrb r1, [r5] - add r0, r6, #0 - mov r2, #0x0 - mov r3, #0x3 - bl ConvertIntToDecimalStringN - add r0, r6, #0 - mov r1, #0x3 - mov r2, #0x9 - bl Menu_PrintText -._42: - add sp, sp, #0x4 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 -._44: - .align 2, 0 -._43: - .word gStringVar1 - .word _nakamuraData0 - .word gSaveBlock1 - .word 0x1a08 - .word Str_843E550 - .word Str_843E552 - .word Str_843E554 - - thumb_func_end debug_sub_815F4D8 - - thumb_func_start debug_sub_815F5C4 -debug_sub_815F5C4: - push {lr} - ldr r0, ._48 @ gMain - ldrh r1, [r0, #0x2e] - mov r0, #0x20 - and r0, r0, r1 - lsl r0, r0, #0x10 - lsr r2, r0, #0x10 - cmp r2, #0 - beq ._45 @cond_branch - ldr r1, ._48 + 4 @ _nakamuraData0 - ldrb r0, [r1] - cmp r0, #0 - bne ._46 @cond_branch - mov r0, #0x13 - b ._50 -._49: - .align 2, 0 -._48: - .word gMain - .word _nakamuraData0 -._46: - sub r0, r0, #0x1 - b ._50 -._45: - mov r0, #0x10 - and r0, r0, r1 - cmp r0, #0 - beq ._51 @cond_branch - ldr r1, ._54 @ _nakamuraData0 - ldrb r0, [r1] - cmp r0, #0x13 - bne ._52 @cond_branch - strb r2, [r1] - b ._53 -._55: - .align 2, 0 -._54: - .word _nakamuraData0 -._52: - add r0, r0, #0x1 -._50: - strb r0, [r1] -._53: - bl debug_sub_815F4D8 - mov r0, #0x0 - b ._58 -._51: - mov r0, #0x2 - and r0, r0, r1 - cmp r0, #0 - bne ._57 @cond_branch - mov r0, #0x0 - b ._58 -._57: - bl CloseMenu - mov r0, #0x1 -._58: - pop {r1} - bx r1 - - thumb_func_end debug_sub_815F5C4 - thumb_func_start debug_sub_815F62C debug_sub_815F62C: push {lr} diff --git a/include/secret_base.h b/include/secret_base.h index 7f60e0f79..450850155 100644 --- a/include/secret_base.h +++ b/include/secret_base.h @@ -22,6 +22,7 @@ void sub_80BCF1C(u8 taskId); void sub_80BD674(void *playerRecords, u32 size, u8 c); #if DEBUG void unref_sub_80BCD7C(u8 secretBaseIndex); +u8 *sub_80BC190(u8 *dest, u8 arg1); #endif #endif // GUARD_SECRET_BASE_H diff --git a/src/debug/nakamura_debug_menu.c b/src/debug/nakamura_debug_menu.c index 6d5a27a30..623294254 100644 --- a/src/debug/nakamura_debug_menu.c +++ b/src/debug/nakamura_debug_menu.c @@ -3,6 +3,7 @@ #include "random.h" #include "palette.h" #include "main.h" +#include "string_util.h" #include "overworld.h" #include "start_menu.h" #include "party_menu.h" @@ -64,82 +65,82 @@ const struct MenuAction _843E3DC[] = { { Str_843E3AF, debug_sub_8160D98 }, }; -const u8 _843E424[][4] = { - { 1, 118, 47, 14 }, - { 2, 125, 53, 10 }, - { 3, 113, 49, 8 }, - { 0xB, 118, 67, 6 }, - { 0xC, 121, 40, 11 }, - { 0xD, 111, 35, 1 }, - { 0x15, 115, 20, 53 }, - { 0x16, 121, 18, 13 }, - { 0x17, 119, 26, 81 }, - { 0x1F, 127, 59, 67 }, - { 0x20, 125, 55, 11 }, - { 0x21, 111, 27, 27 }, - { 0x29, 114, 9, 47 }, - { 0x2A, 115, 32, 39 }, - { 0x2B, 115, 23, 8 }, - { 0x33, 114, 30, 51 }, - { 0x34, 115, 26, 15 }, - { 0x35, 115, 32, 46 }, - { 0x3D, 114, 11, 62 }, - { 0x3E, 115, 21, 18 }, - { 0x3F, 115, 25, 24 }, - { 0x47, 114, 19, 70 }, - { 0x48, 115, 32, 6 }, - { 0x49, 114, 32, 57 }, - { 0x51, 116, 71, 4 }, - { 0x52, 123, 47, 3 }, - { 0x53, 123, 57, 5 }, - { 0x5B, 116, 79, 11 }, - { 0x5C, 123, 49, 3 }, - { 0x5D, 120, 18, 12 }, - { 0x65, 120, 28, 62 }, - { 0x66, 116, 56, 6 }, - { 0x67, 119, 16, 81 }, - { 0x6F, 120, 30, 62 }, - { 0x70, 116, 55, 15 }, - { 0x71, 119, 16, 28 }, - { 0x79, 111, 33, 34 }, - { 0x7A, 118, 29, 5 }, - { 0x7B, 127, 45, 24 }, - { 0x83, 111, 24, 36 }, - { 0x84, 125, 7, 25 }, - { 0x85, 115, 8, 30 }, - { 0x8D, 111, 34, 50 }, - { 0x8E, 127, 59, 72 }, - { 0x8F, 127, 61, 21 }, - { 0x97, 127, 67, 63 }, - { 0x98, 125, 24, 32 }, - { 0x99, 111, 35, 31 }, - { 0xA1, 111, 13, 19 }, - { 0xA2, 121, 43, 7 }, - { 0xA3, 118, 47, 5 }, - { 0xA4, 111, 14, 19 }, - { 0xAB, 118, 46, 5 }, - { 0xAC, 121, 42, 7 }, - { 0xAD, 119, 19, 76 }, - { 0xAE, 115, 7, 20 }, - { 0xB5, 110, 16, 25 }, - { 0xB6, 114, 11, 27 }, - { 0xB7, 115, 8, 20 }, - { 0xBF, 110, 17, 25 }, - { 0xC0, 114, 12, 27 }, - { 0xC1, 119, 18, 76 }, - { 0xC9, 119, 5, 2 }, - { 0xCA, 119, 4, 89 }, - { 0xCB, 120, 38, 54 }, - { 0xCC, 120, 5, 76 }, - { 0xD3, 119, 5, 15 }, - { 0xD4, 119, 7, 101 }, - { 0xD5, 120, 31, 23 }, - { 0xDD, 119, 34, 24 }, - { 0xDE, 120, 26, 10 }, - { 0xDF, 119, 4, 15 }, - { 0xE7, 119, 31, 73 }, - { 0xE8, 120, 29, 85 }, - { 0xE9, 119, 6, 2 }, +const u8 _843E424[] = { + 1, 118, 47, 14 , + 2, 125, 53, 10 , + 3, 113, 49, 8 , + 0xB, 118, 67, 6 , + 0xC, 121, 40, 11 , + 0xD, 111, 35, 1 , + 0x15, 115, 20, 53 , + 0x16, 121, 18, 13 , + 0x17, 119, 26, 81 , + 0x1F, 127, 59, 67 , + 0x20, 125, 55, 11 , + 0x21, 111, 27, 27 , + 0x29, 114, 9, 47 , + 0x2A, 115, 32, 39 , + 0x2B, 115, 23, 8 , + 0x33, 114, 30, 51 , + 0x34, 115, 26, 15 , + 0x35, 115, 32, 46 , + 0x3D, 114, 11, 62 , + 0x3E, 115, 21, 18 , + 0x3F, 115, 25, 24 , + 0x47, 114, 19, 70 , + 0x48, 115, 32, 6 , + 0x49, 114, 32, 57 , + 0x51, 116, 71, 4 , + 0x52, 123, 47, 3 , + 0x53, 123, 57, 5 , + 0x5B, 116, 79, 11 , + 0x5C, 123, 49, 3 , + 0x5D, 120, 18, 12 , + 0x65, 120, 28, 62 , + 0x66, 116, 56, 6 , + 0x67, 119, 16, 81 , + 0x6F, 120, 30, 62 , + 0x70, 116, 55, 15 , + 0x71, 119, 16, 28 , + 0x79, 111, 33, 34 , + 0x7A, 118, 29, 5 , + 0x7B, 127, 45, 24 , + 0x83, 111, 24, 36 , + 0x84, 125, 7, 25 , + 0x85, 115, 8, 30 , + 0x8D, 111, 34, 50 , + 0x8E, 127, 59, 72 , + 0x8F, 127, 61, 21 , + 0x97, 127, 67, 63 , + 0x98, 125, 24, 32 , + 0x99, 111, 35, 31 , + 0xA1, 111, 13, 19 , + 0xA2, 121, 43, 7 , + 0xA3, 118, 47, 5 , + 0xA4, 111, 14, 19 , + 0xAB, 118, 46, 5 , + 0xAC, 121, 42, 7 , + 0xAD, 119, 19, 76 , + 0xAE, 115, 7, 20 , + 0xB5, 110, 16, 25 , + 0xB6, 114, 11, 27 , + 0xB7, 115, 8, 20 , + 0xBF, 110, 17, 25 , + 0xC0, 114, 12, 27 , + 0xC1, 119, 18, 76 , + 0xC9, 119, 5, 2 , + 0xCA, 119, 4, 89 , + 0xCB, 120, 38, 54 , + 0xCC, 120, 5, 76 , + 0xD3, 119, 5, 15 , + 0xD4, 119, 7, 101 , + 0xD5, 120, 31, 23 , + 0xDD, 119, 34, 24 , + 0xDE, 120, 26, 10 , + 0xDF, 119, 4, 15 , + 0xE7, 119, 31, 73 , + 0xE8, 120, 29, 85 , + 0xE9, 119, 6, 2 , }; const u8 Str_843E550[] = _("R"); @@ -285,7 +286,7 @@ bool8 debug_sub_815F2F4(void) do { - gSaveBlock1.secretBases[i].secretBaseId = _843E424[Random() % ARRAY_COUNT(_843E424)][0]; + gSaveBlock1.secretBases[i].secretBaseId = _843E424[(Random() % (ARRAY_COUNT(_843E424) / 4)) * 4]; for (j = 0; j < i; j++) { @@ -314,4 +315,82 @@ bool8 debug_sub_815F2F4(void) return TRUE; } +void debug_sub_815F470(u8 * a0, u8 * a1, u8 * a2) +{ + u8 i; + u8 sbId = gSaveBlock1.secretBases[_nakamuraData0].secretBaseId; + + for (i = 0; i < ARRAY_COUNT(_843E424) / 4; i++) + { + if (_843E424[i * 4] == sbId) + { + *a0 = _843E424[i * 4 + 1]; + *a1 = _843E424[i * 4 + 2]; + *a2 = _843E424[i * 4 + 3]; + break; + } + } +} + +void debug_sub_815F4D8(void) +{ + Menu_BlankWindowRect(1, 1, 10, 10); + ConvertIntToDecimalStringN(gStringVar1, _nakamuraData0, STR_CONV_MODE_LEFT_ALIGN, 2); + Menu_PrintText(gStringVar1, 1, 1); + + if (gSaveBlock1.secretBases[_nakamuraData0].secretBaseId != 0) + { + u8 a0; + u8 a1; + u8 a2; + debug_sub_815F470(&a0, &a1, &a2); + + sub_80BC190(gStringVar1, _nakamuraData0); + Menu_PrintText(gStringVar1, 1, 3); + + Menu_PrintText(Str_843E550, 1, 5); + ConvertIntToDecimalStringN(gStringVar1, a0, STR_CONV_MODE_LEFT_ALIGN, 3); + Menu_PrintText(gStringVar1, 2, 5); + + Menu_PrintText(Str_843E552, 1, 7); + ConvertIntToDecimalStringN(gStringVar1, a1, STR_CONV_MODE_LEFT_ALIGN, 3); + Menu_PrintText(gStringVar1, 3, 7); + + Menu_PrintText(Str_843E554, 1, 9); + ConvertIntToDecimalStringN(gStringVar1, a2, STR_CONV_MODE_LEFT_ALIGN, 3); + Menu_PrintText(gStringVar1, 3, 9); + } +} + +bool8 debug_sub_815F5C4(void) +{ + if (gMain.newKeys & DPAD_LEFT) + { + if (_nakamuraData0 == 0) + _nakamuraData0 = 19; + else + _nakamuraData0--; + debug_sub_815F4D8(); + return FALSE; + } + + if (gMain.newKeys & DPAD_RIGHT) + { + if (_nakamuraData0 == 19) + _nakamuraData0 = 0; + else + _nakamuraData0++; + debug_sub_815F4D8(); + return FALSE; + } + + if (gMain.newKeys & B_BUTTON) + { + CloseMenu(); + return TRUE; + } + + return FALSE; +} + #endif // DEBUG -- cgit v1.2.3 From 27eba7b20cf25eb8e49a72ec72e1b7564f543439 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 1 Apr 2018 18:25:48 -0400 Subject: through debug_sub_815F7F0 --- asm/nakamura_debug_menu.s | 305 ---------------------------------------- src/debug/nakamura_debug_menu.c | 85 ++++++++++- 2 files changed, 80 insertions(+), 310 deletions(-) diff --git a/asm/nakamura_debug_menu.s b/asm/nakamura_debug_menu.s index 6ddce1855..e9072f6dd 100644 --- a/asm/nakamura_debug_menu.s +++ b/asm/nakamura_debug_menu.s @@ -5,311 +5,6 @@ .text - thumb_func_start debug_sub_815F62C -debug_sub_815F62C: - push {lr} - ldr r1, ._59 @ _nakamuraData0 - mov r0, #0x0 - strb r0, [r1] - ldr r1, ._59 + 4 @ gMenuCallback - ldr r0, ._59 + 8 @ debug_sub_815F5C4 - str r0, [r1] - mov r0, #0x0 - mov r1, #0x0 - mov r2, #0x1d - mov r3, #0x13 - bl Menu_EraseWindowRect - mov r0, #0x0 - mov r1, #0x0 - mov r2, #0xb - mov r3, #0xb - bl Menu_DrawStdWindowFrame - bl debug_sub_815F4D8 - mov r0, #0x0 - pop {r1} - bx r1 -._60: - .align 2, 0 -._59: - .word _nakamuraData0 - .word gMenuCallback - .word debug_sub_815F5C4+1 - - thumb_func_end debug_sub_815F62C - - thumb_func_start debug_sub_815F668 -debug_sub_815F668: - push {r4, r5, r6, lr} - ldr r0, ._61 @ _nakamuraData0 - ldrb r0, [r0] - lsl r1, r0, #0x2 - add r1, r1, r0 - lsl r1, r1, #0x5 - ldr r0, ._61 + 4 @ gSaveBlock1 - add r1, r1, r0 - ldrb r4, [r1, #0x3] - lsl r4, r4, #0x18 - ldrb r0, [r1, #0x2] - lsl r0, r0, #0x10 - orr r4, r4, r0 - ldrb r0, [r1, #0x1] - lsl r0, r0, #0x8 - orr r4, r4, r0 - ldrb r0, [r1] - orr r4, r4, r0 - ldr r5, ._61 + 8 @ gStringVar1 - ldr r6, ._61 + 12 @ 0x186a0 - add r0, r4, #0 - add r1, r6, #0 - bl __udivsi3 - add r1, r0, #0 - add r0, r5, #0 - mov r2, #0x2 - mov r3, #0x5 - bl ConvertIntToDecimalStringN - add r0, r5, #0 - mov r1, #0x2 - mov r2, #0x7 - bl Menu_PrintText - add r0, r4, #0 - add r1, r6, #0 - bl __umodsi3 - add r1, r0, #0 - add r0, r5, #0 - mov r2, #0x2 - mov r3, #0x5 - bl ConvertIntToDecimalStringN - add r0, r5, #0 - mov r1, #0x7 - mov r2, #0x7 - bl Menu_PrintText - pop {r4, r5, r6} - pop {r0} - bx r0 -._62: - .align 2, 0 -._61: - .word _nakamuraData0 - .word gSaveBlock1+0x1a11 - .word gStringVar1 - .word 0x186a0 - - thumb_func_end debug_sub_815F668 - - thumb_func_start debug_sub_815F6E4 -debug_sub_815F6E4: - push {r4, lr} - mov r0, #0x2 - mov r1, #0x3 - mov r2, #0xb - mov r3, #0x4 - bl Menu_BlankWindowRect - ldr r4, ._63 @ gStringVar1 - ldr r0, ._63 + 4 @ _nakamuraData0 - ldrb r0, [r0] - lsl r1, r0, #0x2 - add r1, r1, r0 - lsl r1, r1, #0x5 - ldr r0, ._63 + 8 @ gSaveBlock1 - add r1, r1, r0 - add r0, r4, #0 - mov r2, #0x7 - bl StringCopyN - mov r1, #0xff - strb r1, [r0] - add r0, r4, #0 - mov r1, #0x2 - mov r2, #0x3 - bl Menu_PrintText - pop {r4} - pop {r0} - bx r0 -._64: - .align 2, 0 -._63: - .word gStringVar1 - .word _nakamuraData0 - .word gSaveBlock1+0x1a0a - - thumb_func_end debug_sub_815F6E4 - - thumb_func_start debug_sub_815F72C -debug_sub_815F72C: - push {r4, r5, lr} - mov r0, #0x2 - mov r1, #0x1 - mov r2, #0xb - mov r3, #0xa - bl Menu_BlankWindowRect - ldr r4, ._66 @ gStringVar1 - ldr r5, ._66 + 4 @ _nakamuraData0 - ldrb r1, [r5] - add r0, r4, #0 - mov r2, #0x0 - mov r3, #0x2 - bl ConvertIntToDecimalStringN - add r0, r4, #0 - mov r1, #0x2 - mov r2, #0x1 - bl Menu_PrintText - ldr r2, ._66 + 8 @ gSaveBlock1 - ldrb r1, [r5] - lsl r0, r1, #0x2 - add r0, r0, r1 - lsl r0, r0, #0x5 - add r0, r0, r2 - ldr r1, ._66 + 12 @ 0x1a08 - add r0, r0, r1 - ldrb r0, [r0] - cmp r0, #0 - beq ._65 @cond_branch - bl debug_sub_815F6E4 - bl debug_sub_815F668 -._65: - pop {r4, r5} - pop {r0} - bx r0 -._67: - .align 2, 0 -._66: - .word gStringVar1 - .word _nakamuraData0 - .word gSaveBlock1 - .word 0x1a08 - - thumb_func_end debug_sub_815F72C - - thumb_func_start debug_sub_815F788 -debug_sub_815F788: - push {lr} - mov r0, #0x2 - mov r1, #0x5 - mov r2, #0xb - mov r3, #0x6 - bl Menu_BlankWindowRect - ldr r0, ._68 @ Str_843E574 - ldr r1, ._68 + 4 @ _nakamuraData2 - ldrb r1, [r1] - add r1, r1, #0x2 - lsl r1, r1, #0x18 - lsr r1, r1, #0x18 - mov r2, #0x5 - bl Menu_PrintText - pop {r0} - bx r0 -._69: - .align 2, 0 -._68: - .word Str_843E574 - .word _nakamuraData2 - - thumb_func_end debug_sub_815F788 - - thumb_func_start debug_sub_815F7B4 -debug_sub_815F7B4: - push {lr} - ldr r0, ._72 @ _nakamuraData1 - ldrb r0, [r0] - cmp r0, #0 - beq ._70 @cond_branch - mov r0, #0xb - mov r1, #0x1 - mov r2, #0xb - mov r3, #0x2 - bl Menu_BlankWindowRect - b ._71 -._73: - .align 2, 0 -._72: - .word _nakamuraData1 -._70: - ldr r0, ._74 @ _nakamuraData3 - ldrb r0, [r0] - lsl r0, r0, #0x1 - ldr r1, ._74 + 4 @ Str_843E576 - add r0, r0, r1 - mov r1, #0xb - mov r2, #0x1 - bl Menu_PrintText -._71: - pop {r0} - bx r0 -._75: - .align 2, 0 -._74: - .word _nakamuraData3 - .word Str_843E576 - - thumb_func_end debug_sub_815F7B4 - - thumb_func_start debug_sub_815F7F0 -debug_sub_815F7F0: - push {r4, r5, lr} - ldr r1, ._78 @ _nakamuraData0 - ldrb r2, [r1] - lsl r1, r2, #0x2 - add r1, r1, r2 - lsl r1, r1, #0x5 - ldr r2, ._78 + 4 @ gSaveBlock1 - add r3, r1, r2 - ldrb r1, [r3, #0x3] - lsl r2, r1, #0x18 - ldrb r1, [r3, #0x2] - lsl r1, r1, #0x10 - orr r2, r2, r1 - ldrb r1, [r3, #0x1] - lsl r1, r1, #0x8 - orr r2, r2, r1 - ldrb r1, [r3] - orr r2, r2, r1 - lsl r0, r0, #0x18 - asr r1, r0, #0x18 - mov r4, #0x9 - ldr r0, ._78 + 8 @ _nakamuraData2 - ldrb r0, [r0] - cmp r4, r0 - ble ._76 @cond_branch - add r5, r0, #0 -._77: - lsl r0, r1, #0x2 - add r0, r0, r1 - lsl r1, r0, #0x1 - lsl r0, r4, #0x18 - mov r4, #0xff - lsl r4, r4, #0x18 - add r0, r0, r4 - lsr r4, r0, #0x18 - asr r0, r0, #0x18 - cmp r0, r5 - bgt ._77 @cond_branch -._76: - add r2, r2, r1 - lsr r0, r2, #0x18 - strb r0, [r3, #0x3] - mov r0, #0xff - lsl r0, r0, #0x10 - and r0, r0, r2 - lsr r0, r0, #0x10 - strb r0, [r3, #0x2] - mov r0, #0xff - lsl r0, r0, #0x8 - and r0, r0, r2 - lsr r0, r0, #0x8 - strb r0, [r3, #0x1] - strb r2, [r3] - bl debug_sub_815F668 - pop {r4, r5} - pop {r0} - bx r0 -._79: - .align 2, 0 -._78: - .word _nakamuraData0 - .word gSaveBlock1+0x1a11 - .word _nakamuraData2 - - thumb_func_end debug_sub_815F7F0 - thumb_func_start debug_sub_815F86C debug_sub_815F86C: push {r4, r5, r6, lr} diff --git a/src/debug/nakamura_debug_menu.c b/src/debug/nakamura_debug_menu.c index 623294254..38026b546 100644 --- a/src/debug/nakamura_debug_menu.c +++ b/src/debug/nakamura_debug_menu.c @@ -158,11 +158,13 @@ const u8 Str_843E556[] = _( "♀4\n" "♀5"); const u8 Str_843E574[] = _("ー"); -const u8 Str_843E576[] = _("あ"); -const u8 Str_843E578[] = _("ア"); -const u8 Str_843E57A[] = _("A"); -const u8 Str_843E57C[] = _("a"); -const u8 Str_843E57E[] = _("0"); +const u8 Str_843E576[][2] = { + _("あ"), + _("ア"), + _("A"), + _("a"), + _("0") +}; const u8 Str_843E580[] = _( "ADD\n" "DEL\n" @@ -393,4 +395,77 @@ bool8 debug_sub_815F5C4(void) return FALSE; } +bool8 debug_sub_815F62C(void) +{ + _nakamuraData0 = 0; + gMenuCallback = debug_sub_815F5C4; + Menu_EraseWindowRect(0, 0, 29, 19); + Menu_DrawStdWindowFrame(0, 0, 11, 11); + debug_sub_815F4D8(); + return FALSE; +} + +void debug_sub_815F668(void) +{ + u8 * otIdPtr = gSaveBlock1.secretBases[_nakamuraData0].trainerId; + u32 otId = (otIdPtr[3] << 24) | (otIdPtr[2] << 16) | (otIdPtr[1] << 8) | (otIdPtr[0] << 0); + ConvertIntToDecimalStringN(gStringVar1, otId / 100000, STR_CONV_MODE_LEADING_ZEROS, 5); + Menu_PrintText(gStringVar1, 2, 7); + ConvertIntToDecimalStringN(gStringVar1, otId % 100000, STR_CONV_MODE_LEADING_ZEROS, 5); + Menu_PrintText(gStringVar1, 7, 7); +} + +void debug_sub_815F6E4(void) +{ + Menu_BlankWindowRect(2, 3, 11, 4); + *StringCopyN(gStringVar1, gSaveBlock1.secretBases[_nakamuraData0].playerName, 7) = EOS; + Menu_PrintText(gStringVar1, 2, 3); +} + +void debug_sub_815F72C(void) +{ + Menu_BlankWindowRect(2, 1, 11, 10); + + ConvertIntToDecimalStringN(gStringVar1, _nakamuraData0, STR_CONV_MODE_LEFT_ALIGN, 2); + Menu_PrintText(gStringVar1, 2, 1); + + if (gSaveBlock1.secretBases[_nakamuraData0].secretBaseId != 0) + { + debug_sub_815F6E4(); + debug_sub_815F668(); + } +} + +void debug_sub_815F788(void) +{ + Menu_BlankWindowRect(2, 5, 11, 6); + Menu_PrintText(Str_843E574, _nakamuraData2 + 2, 5); +} + +void debug_sub_815F7B4(void) +{ + if (_nakamuraData1) + Menu_BlankWindowRect(11, 1, 11, 2); + else + Menu_PrintText(Str_843E576[_nakamuraData3], 11, 1); +} + +void debug_sub_815F7F0(s8 a0) +{ + u8 * otIdPtr = gSaveBlock1.secretBases[_nakamuraData0].trainerId; + u32 otId = (otIdPtr[3] << 24) | (otIdPtr[2] << 16) | (otIdPtr[1] << 8) | (otIdPtr[0] << 0); + s8 r4; + int r1 = a0; + + for (r4 = 9; r4 > _nakamuraData2; r4--) + r1 *= 10; + + otId += r1; + otIdPtr[3] = (otId & 0xFF000000) >> 24; + otIdPtr[2] = (otId & 0x00FF0000) >> 16; + otIdPtr[1] = (otId & 0x0000FF00) >> 8; + otIdPtr[0] = (otId & 0x000000FF) >> 0; + debug_sub_815F668(); +} + #endif // DEBUG -- cgit v1.2.3 From af04028ecebcc5631987699b399f745550794db2 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 1 Apr 2018 19:03:19 -0400 Subject: through (nonmatching) debug_sub_815F930 --- asm/nakamura_debug_menu.s | 260 -------------------------------------- src/debug/nakamura_debug_menu.c | 269 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 266 insertions(+), 263 deletions(-) diff --git a/asm/nakamura_debug_menu.s b/asm/nakamura_debug_menu.s index e9072f6dd..408fa7a4e 100644 --- a/asm/nakamura_debug_menu.s +++ b/asm/nakamura_debug_menu.s @@ -5,266 +5,6 @@ .text - thumb_func_start debug_sub_815F86C -debug_sub_815F86C: - push {r4, r5, r6, lr} - lsl r0, r0, #0x18 - ldr r1, ._84 @ _nakamuraData0 - ldrb r2, [r1] - lsl r1, r2, #0x2 - add r1, r1, r2 - lsl r1, r1, #0x5 - ldr r2, ._84 + 4 @ gSaveBlock1 - add r5, r1, r2 - mov r2, #0x0 - mov r3, #0x0 - lsr r6, r0, #0x18 - asr r0, r0, #0x18 - cmp r0, #0x64 - bne ._80 @cond_branch - ldr r0, ._84 + 8 @ _nakamuraData2 - ldrb r1, [r0] - cmp r1, #0x6 - bhi ._100 @cond_branch - mov r2, #0xff -._82: - add r0, r5, r1 - strb r2, [r0] - add r0, r1, #1 - lsl r0, r0, #0x18 - lsr r1, r0, #0x18 - cmp r1, #0x6 - bls ._82 @cond_branch - b ._100 -._85: - .align 2, 0 -._84: - .word _nakamuraData0 - .word gSaveBlock1+0x1a0a - .word _nakamuraData2 -._80: - ldr r0, ._87 @ _nakamuraData3 - ldrb r0, [r0] - cmp r0, #0x4 - bhi ._98 @cond_branch - lsl r0, r0, #0x2 - ldr r1, ._87 + 4 @ - add r0, r0, r1 - ldr r0, [r0] - mov pc, r0 -._88: - .align 2, 0 -._87: - .word _nakamuraData3 - .word ._89 -._89: - .word ._90 - .word ._91 - .word ._92 - .word ._93 - .word ._94 -._90: - mov r3, #0x1 - mov r2, #0x50 - b ._98 -._91: - mov r3, #0x51 - mov r2, #0xa0 - b ._98 -._92: - mov r3, #0xbb - mov r2, #0xd4 - b ._98 -._93: - mov r3, #0xd5 - mov r2, #0xee - b ._98 -._94: - mov r3, #0xa1 - mov r2, #0xaa -._98: - ldr r4, ._101 @ _nakamuraData2 - ldrb r1, [r4] - add r1, r5, r1 - ldrb r0, [r1] - add r0, r0, r6 - strb r0, [r1] - ldrb r0, [r4] - add r1, r5, r0 - ldrb r0, [r1] - cmp r0, r3 - bcs ._99 @cond_branch - strb r2, [r1] -._99: - ldrb r0, [r4] - add r1, r5, r0 - ldrb r0, [r1] - cmp r0, r2 - bls ._100 @cond_branch - strb r3, [r1] -._100: - bl debug_sub_815F6E4 - pop {r4, r5, r6} - pop {r0} - bx r0 -._102: - .align 2, 0 -._101: - .word _nakamuraData2 - - thumb_func_end debug_sub_815F86C - - thumb_func_start debug_sub_815F930 -debug_sub_815F930: - push {r4, r5, lr} - ldr r0, ._107 @ _nakamuraData1 - ldrb r2, [r0] - mov r4, #0xa - cmp r2, #0 - bne ._103 @cond_branch - mov r4, #0x7 -._103: - ldr r5, ._107 + 4 @ gMain - ldrh r1, [r5, #0x30] - mov r0, #0x40 - and r0, r0, r1 - cmp r0, #0 - beq ._104 @cond_branch - cmp r2, #0 - beq ._105 @cond_branch - mov r0, #0x1 - bl debug_sub_815F7F0 - b ._136 -._108: - .align 2, 0 -._107: - .word _nakamuraData1 - .word gMain -._105: - mov r0, #0x1 - b ._113 -._104: - mov r0, #0x80 - and r0, r0, r1 - cmp r0, #0 - beq ._110 @cond_branch - cmp r2, #0 - beq ._111 @cond_branch - mov r0, #0x1 - neg r0, r0 - bl debug_sub_815F7F0 - b ._136 -._111: - mov r0, #0x1 - neg r0, r0 - b ._113 -._110: - mov r0, #0x20 - and r0, r0, r1 - lsl r0, r0, #0x10 - lsr r3, r0, #0x10 - cmp r3, #0 - beq ._114 @cond_branch - ldr r1, ._117 @ _nakamuraData2 - ldrb r0, [r1] - cmp r0, #0 - bne ._115 @cond_branch - sub r0, r4, #1 - b ._116 -._118: - .align 2, 0 -._117: - .word _nakamuraData2 -._115: - sub r0, r0, #0x1 -._116: - strb r0, [r1] -._125: - bl debug_sub_815F788 - b ._136 -._114: - mov r0, #0x10 - and r0, r0, r1 - cmp r0, #0 - beq ._120 @cond_branch - ldr r2, ._123 @ _nakamuraData2 - ldrb r1, [r2] - sub r0, r4, #1 - cmp r1, r0 - bne ._121 @cond_branch - strb r3, [r2] - b ._125 -._124: - .align 2, 0 -._123: - .word _nakamuraData2 -._121: - add r0, r1, #1 - strb r0, [r2] - b ._125 -._120: - ldrh r1, [r5, #0x2e] - mov r0, #0x4 - and r0, r0, r1 - cmp r0, #0 - beq ._126 @cond_branch - cmp r2, #0 - bne ._127 @cond_branch - ldr r4, ._129 @ _nakamuraData3 - ldrb r0, [r4] - add r0, r0, #0x1 - mov r1, #0x5 - bl __modsi3 - strb r0, [r4] -._127: - bl debug_sub_815F7B4 - b ._136 -._130: - .align 2, 0 -._129: - .word _nakamuraData3 -._126: - mov r0, #0x1 - and r0, r0, r1 - cmp r0, #0 - beq ._131 @cond_branch - mov r0, #0x2 - mov r1, #0x5 - mov r2, #0xb - mov r3, #0x6 - bl Menu_BlankWindowRect - mov r0, #0xb - mov r1, #0x1 - mov r2, #0xb - mov r3, #0x2 - bl Menu_BlankWindowRect - ldr r1, ._133 @ gMenuCallback - ldr r0, ._133 + 4 @ debug_sub_815FA38 - str r0, [r1] - b ._136 -._134: - .align 2, 0 -._133: - .word gMenuCallback - .word debug_sub_815FA38+1 -._131: - mov r0, #0x2 - and r0, r0, r1 - cmp r0, #0 - beq ._136 @cond_branch - cmp r2, #0 - bne ._136 @cond_branch - mov r0, #0x64 -._113: - bl debug_sub_815F86C -._136: - mov r0, #0x0 - pop {r4, r5} - pop {r1} - bx r1 - - thumb_func_end debug_sub_815F930 - thumb_func_start debug_sub_815FA38 debug_sub_815FA38: push {r4, lr} diff --git a/src/debug/nakamura_debug_menu.c b/src/debug/nakamura_debug_menu.c index 38026b546..959b9eae3 100644 --- a/src/debug/nakamura_debug_menu.c +++ b/src/debug/nakamura_debug_menu.c @@ -32,13 +32,14 @@ asm(".global _nakamuraStatic0"); asm(".global _nakamuraStatic18"); bool8 debug_sub_815F214(void); -bool8 debug_sub_815FC54(void); bool8 debug_sub_815F2B4(void); -bool8 debug_sub_815FC94(void); -bool8 debug_sub_815FB1C(void); bool8 debug_sub_815F2F4(void); bool8 debug_sub_815F62C(void); +bool8 debug_sub_815FA38(void); +bool8 debug_sub_815FB1C(void); bool8 debug_sub_815FBE8(void); +bool8 debug_sub_815FC54(void); +bool8 debug_sub_815FC94(void); bool8 debug_sub_815FE1C(void); bool8 debug_sub_8160D98(void); @@ -468,4 +469,266 @@ void debug_sub_815F7F0(s8 a0) debug_sub_815F668(); } +void debug_sub_815F86C(s8 a0) +{ + u8 * namePtr = gSaveBlock1.secretBases[_nakamuraData0].playerName; + u8 r2 = 0; + u8 r3 = 0; + u8 i; + + if (a0 == 100) + { + for (i = _nakamuraData2; i < 7; i++) + { + namePtr[i] = EOS; + } + } + else + { + switch (_nakamuraData3) + { + case 0: + r3 = 1; + r2 = 80; + break; + case 1: + r3 = 81; + r2 = 160; + break; + case 2: + r3 = CHAR_A; + r2 = CHAR_Z; + break; + case 3: + r3 = CHAR_a; + r2 = CHAR_z; + break; + case 4: + r3 = CHAR_0; + r2 = CHAR_0 + 9; + break; + } + + namePtr[_nakamuraData2] += a0; + if (namePtr[_nakamuraData2] < r3) + namePtr[_nakamuraData2] = r2; + if (namePtr[_nakamuraData2] > r2) + namePtr[_nakamuraData2] = r3; + } + debug_sub_815F6E4(); +} + +#ifdef NONMATCHING +bool8 debug_sub_815F930(void) +{ + u32 r4 = _nakamuraData1 == 0 ? 7 : 10; + + if (gMain.newAndRepeatedKeys & DPAD_UP) + { + if (_nakamuraData1) + debug_sub_815F7F0(1); + else + debug_sub_815F86C(1); + } + + else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + { + if (_nakamuraData1) + debug_sub_815F7F0(-1); + else + debug_sub_815F86C(-1); + } + + else if (gMain.newAndRepeatedKeys & DPAD_LEFT) + { + if (_nakamuraData2 == 0) + _nakamuraData2 = r4 - 1; + else + _nakamuraData2--; + debug_sub_815F788(); + } + + else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + { + if (_nakamuraData2 == r4 - 1) + _nakamuraData2 = 0; + else + _nakamuraData2++; + debug_sub_815F788(); + } + + else if (gMain.newKeys & SELECT_BUTTON) + { + if (_nakamuraData1 == 0) + _nakamuraData3 = (_nakamuraData3 + 1) % 5; + debug_sub_815F7B4(); + } + + else if (gMain.newKeys & A_BUTTON) + { + Menu_BlankWindowRect(2, 5, 11, 6); + Menu_BlankWindowRect(11, 1, 11, 2); + gMenuCallback = debug_sub_815FA38; + } + + else if (gMain.newKeys & B_BUTTON) + { + if (_nakamuraData1 == 0) + debug_sub_815F86C(100); + } + + return FALSE; +} +#else +__attribute__((naked)) bool8 debug_sub_815F930(void) +{ + asm("\tpush\t{r4, r5, lr}\n" + "\tldr\tr0, ._107 @ _nakamuraData1\n" + "\tldrb\tr2, [r0]\n" + "\tmov\tr4, #0xa\n" + "\tcmp\tr2, #0\n" + "\tbne\t._103\t@cond_branch\n" + "\tmov\tr4, #0x7\n" + "._103:\n" + "\tldr\tr5, ._107 + 4 @ gMain\n" + "\tldrh\tr1, [r5, #0x30]\n" + "\tmov\tr0, #0x40\n" + "\tand\tr0, r0, r1\n" + "\tcmp\tr0, #0\n" + "\tbeq\t._104\t@cond_branch\n" + "\tcmp\tr2, #0\n" + "\tbeq\t._105\t@cond_branch\n" + "\tmov\tr0, #0x1\n" + "\tbl\tdebug_sub_815F7F0\n" + "\tb\t._136\n" + "._108:\n" + "\t.align\t2, 0\n" + "._107:\n" + "\t.word\t_nakamuraData1\n" + "\t.word\tgMain\n" + "._105:\n" + "\tmov\tr0, #0x1\n" + "\tb\t._113\n" + "._104:\n" + "\tmov\tr0, #0x80\n" + "\tand\tr0, r0, r1\n" + "\tcmp\tr0, #0\n" + "\tbeq\t._110\t@cond_branch\n" + "\tcmp\tr2, #0\n" + "\tbeq\t._111\t@cond_branch\n" + "\tmov\tr0, #0x1\n" + "\tneg\tr0, r0\n" + "\tbl\tdebug_sub_815F7F0\n" + "\tb\t._136\n" + "._111:\n" + "\tmov\tr0, #0x1\n" + "\tneg\tr0, r0\n" + "\tb\t._113\n" + "._110:\n" + "\tmov\tr0, #0x20\n" + "\tand\tr0, r0, r1\n" + "\tlsl\tr0, r0, #0x10\n" + "\tlsr\tr3, r0, #0x10\n" + "\tcmp\tr3, #0\n" + "\tbeq\t._114\t@cond_branch\n" + "\tldr\tr1, ._117 @ _nakamuraData2\n" + "\tldrb\tr0, [r1]\n" + "\tcmp\tr0, #0\n" + "\tbne\t._115\t@cond_branch\n" + "\tsub\tr0, r4, #1\n" + "\tb\t._116\n" + "._118:\n" + "\t.align\t2, 0\n" + "._117:\n" + "\t.word\t_nakamuraData2\n" + "._115:\n" + "\tsub\tr0, r0, #0x1\n" + "._116:\n" + "\tstrb\tr0, [r1]\n" + "._125:\n" + "\tbl\tdebug_sub_815F788\n" + "\tb\t._136\n" + "._114:\n" + "\tmov\tr0, #0x10\n" + "\tand\tr0, r0, r1\n" + "\tcmp\tr0, #0\n" + "\tbeq\t._120\t@cond_branch\n" + "\tldr\tr2, ._123 @ _nakamuraData2\n" + "\tldrb\tr1, [r2]\n" + "\tsub\tr0, r4, #1\n" + "\tcmp\tr1, r0\n" + "\tbne\t._121\t@cond_branch\n" + "\tstrb\tr3, [r2]\n" + "\tb\t._125\n" + "._124:\n" + "\t.align\t2, 0\n" + "._123:\n" + "\t.word\t_nakamuraData2\n" + "._121:\n" + "\tadd\tr0, r1, #1\n" + "\tstrb\tr0, [r2]\n" + "\tb\t._125\n" + "._120:\n" + "\tldrh\tr1, [r5, #0x2e]\n" + "\tmov\tr0, #0x4\n" + "\tand\tr0, r0, r1\n" + "\tcmp\tr0, #0\n" + "\tbeq\t._126\t@cond_branch\n" + "\tcmp\tr2, #0\n" + "\tbne\t._127\t@cond_branch\n" + "\tldr\tr4, ._129 @ _nakamuraData3\n" + "\tldrb\tr0, [r4]\n" + "\tadd\tr0, r0, #0x1\n" + "\tmov\tr1, #0x5\n" + "\tbl\t__modsi3\n" + "\tstrb\tr0, [r4]\n" + "._127:\n" + "\tbl\tdebug_sub_815F7B4\n" + "\tb\t._136\n" + "._130:\n" + "\t.align\t2, 0\n" + "._129:\n" + "\t.word\t_nakamuraData3\n" + "._126:\n" + "\tmov\tr0, #0x1\n" + "\tand\tr0, r0, r1\n" + "\tcmp\tr0, #0\n" + "\tbeq\t._131\t@cond_branch\n" + "\tmov\tr0, #0x2\n" + "\tmov\tr1, #0x5\n" + "\tmov\tr2, #0xb\n" + "\tmov\tr3, #0x6\n" + "\tbl\tMenu_BlankWindowRect\n" + "\tmov\tr0, #0xb\n" + "\tmov\tr1, #0x1\n" + "\tmov\tr2, #0xb\n" + "\tmov\tr3, #0x2\n" + "\tbl\tMenu_BlankWindowRect\n" + "\tldr\tr1, ._133 @ gMenuCallback\n" + "\tldr\tr0, ._133 + 4 @ debug_sub_815FA38\n" + "\tstr\tr0, [r1]\n" + "\tb\t._136\n" + "._134:\n" + "\t.align\t2, 0\n" + "._133:\n" + "\t.word\tgMenuCallback\n" + "\t.word\tdebug_sub_815FA38+1\n" + "._131:\n" + "\tmov\tr0, #0x2\n" + "\tand\tr0, r0, r1\n" + "\tcmp\tr0, #0\n" + "\tbeq\t._136\t@cond_branch\n" + "\tcmp\tr2, #0\n" + "\tbne\t._136\t@cond_branch\n" + "\tmov\tr0, #0x64\n" + "._113:\n" + "\tbl\tdebug_sub_815F86C\n" + "._136:\n" + "\tmov\tr0, #0x0\n" + "\tpop\t{r4, r5}\n" + "\tpop\t{r1}\n" + "\tbx\tr1"); +} +#endif // NONMATCHING + #endif // DEBUG -- cgit v1.2.3 From b74fb2562faee0317013ec9b1ea50032973508ef Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Sun, 1 Apr 2018 21:07:55 -0400 Subject: through debug_sub_815FC94 --- asm/nakamura_debug_menu.s | 342 ---------------------------------------- include/decoration_inventory.h | 3 + include/roamer.h | 7 +- src/debug/nakamura_debug_menu.c | 312 ++++++++++++++++++------------------ 4 files changed, 165 insertions(+), 499 deletions(-) diff --git a/asm/nakamura_debug_menu.s b/asm/nakamura_debug_menu.s index 408fa7a4e..76db41a4d 100644 --- a/asm/nakamura_debug_menu.s +++ b/asm/nakamura_debug_menu.s @@ -5,348 +5,6 @@ .text - thumb_func_start debug_sub_815FA38 -debug_sub_815FA38: - push {r4, lr} - ldr r0, ._139 @ gMain - ldrh r1, [r0, #0x2e] - mov r0, #0x40 - and r0, r0, r1 - cmp r0, #0 - beq ._137 @cond_branch - mov r0, #0x2 - neg r0, r0 - b ._138 -._140: - .align 2, 0 -._139: - .word gMain -._137: - mov r0, #0x80 - and r0, r0, r1 - cmp r0, #0 - beq ._141 @cond_branch - mov r0, #0x2 -._138: - bl Menu_MoveCursor -._161: - mov r0, #0x0 - b ._142 -._141: - mov r0, #0x20 - and r0, r0, r1 - lsl r0, r0, #0x10 - lsr r2, r0, #0x10 - cmp r2, #0 - beq ._143 @cond_branch - ldr r1, ._146 @ _nakamuraData0 - ldrb r0, [r1] - cmp r0, #0 - bne ._144 @cond_branch - mov r0, #0x13 - b ._148 -._147: - .align 2, 0 -._146: - .word _nakamuraData0 -._144: - sub r0, r0, #0x1 - b ._148 -._143: - mov r0, #0x10 - and r0, r0, r1 - lsl r0, r0, #0x10 - lsr r4, r0, #0x10 - cmp r4, #0 - beq ._149 @cond_branch - ldr r1, ._152 @ _nakamuraData0 - ldrb r0, [r1] - cmp r0, #0x13 - bne ._150 @cond_branch - strb r2, [r1] - b ._151 -._153: - .align 2, 0 -._152: - .word _nakamuraData0 -._150: - add r0, r0, #0x1 -._148: - strb r0, [r1] -._151: - bl debug_sub_815F72C - b ._161 -._149: - mov r0, #0x1 - and r0, r0, r1 - cmp r0, #0 - beq ._155 @cond_branch - ldr r1, ._159 @ _nakamuraData0 - ldrb r0, [r1] - cmp r0, #0 - beq ._161 @cond_branch - ldr r2, ._159 + 4 @ gSaveBlock1 - add r1, r0, #0 - lsl r0, r1, #0x2 - add r0, r0, r1 - lsl r0, r0, #0x5 - add r0, r0, r2 - ldr r1, ._159 + 8 @ 0x1a08 - add r0, r0, r1 - ldrb r0, [r0] - cmp r0, #0 - beq ._161 @cond_branch - bl Menu_GetCursorPos - ldr r1, ._159 + 12 @ _nakamuraData1 - strb r0, [r1] - ldr r0, ._159 + 16 @ _nakamuraData2 - strb r4, [r0] - bl debug_sub_815F788 - bl debug_sub_815F7B4 - ldr r1, ._159 + 20 @ gMenuCallback - ldr r0, ._159 + 24 @ debug_sub_815F930 - str r0, [r1] - b ._161 -._160: - .align 2, 0 -._159: - .word _nakamuraData0 - .word gSaveBlock1 - .word 0x1a08 - .word _nakamuraData1 - .word _nakamuraData2 - .word gMenuCallback - .word debug_sub_815F930+1 -._155: - mov r0, #0x2 - and r0, r0, r1 - cmp r0, #0 - beq ._161 @cond_branch - bl CloseMenu - mov r0, #0x1 -._142: - pop {r4} - pop {r1} - bx r1 - - thumb_func_end debug_sub_815FA38 - - thumb_func_start debug_sub_815FB1C -debug_sub_815FB1C: - push {lr} - add sp, sp, #0xfffffff8 - ldr r0, ._162 @ _nakamuraData0 - mov r1, #0x0 - strb r1, [r0] - ldr r0, ._162 + 4 @ _nakamuraData3 - strb r1, [r0] - ldr r1, ._162 + 8 @ gMenuCallback - ldr r0, ._162 + 12 @ debug_sub_815FA38 - str r0, [r1] - mov r0, #0x0 - mov r1, #0x0 - mov r2, #0x1d - mov r3, #0x13 - bl Menu_EraseWindowRect - mov r0, #0x0 - mov r1, #0x0 - mov r2, #0xc - mov r3, #0xb - bl Menu_DrawStdWindowFrame - bl debug_sub_815F72C - mov r0, #0x0 - str r0, [sp] - mov r0, #0xb - str r0, [sp, #0x4] - mov r0, #0x0 - mov r1, #0x1 - mov r2, #0x3 - mov r3, #0x3 - bl InitMenu - mov r0, #0x0 - add sp, sp, #0x8 - pop {r1} - bx r1 -._163: - .align 2, 0 -._162: - .word _nakamuraData0 - .word _nakamuraData3 - .word gMenuCallback - .word debug_sub_815FA38+1 - - thumb_func_end debug_sub_815FB1C - - thumb_func_start debug_sub_815FB78 -debug_sub_815FB78: - push {lr} - ldr r0, ._166 @ gMain - ldrh r1, [r0, #0x2e] - mov r0, #0x40 - and r0, r0, r1 - cmp r0, #0 - beq ._164 @cond_branch - mov r0, #0x1 - neg r0, r0 - b ._165 -._167: - .align 2, 0 -._166: - .word gMain -._164: - mov r0, #0x80 - and r0, r0, r1 - cmp r0, #0 - beq ._168 @cond_branch - mov r0, #0x1 -._165: - bl Menu_MoveCursor - mov r0, #0x0 - b ._177 -._168: - mov r0, #0x1 - and r0, r0, r1 - cmp r0, #0 - beq ._170 @cond_branch - bl CloseMenu - bl Menu_GetCursorPos - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - cmp r0, #0 - beq ._171 @cond_branch - cmp r0, #0x1 - beq ._172 @cond_branch - b ._175 -._171: - bl debug_sub_814A714 - b ._175 -._172: - bl ClearRoamerData - bl ClearRoamerLocationData - b ._175 -._170: - mov r0, #0x2 - and r0, r0, r1 - cmp r0, #0 - bne ._176 @cond_branch - mov r0, #0x0 - b ._177 -._176: - bl CloseMenu -._175: - mov r0, #0x1 -._177: - pop {r1} - bx r1 - - thumb_func_end debug_sub_815FB78 - - thumb_func_start debug_sub_815FBE8 -debug_sub_815FBE8: - push {r4, lr} - add sp, sp, #0xfffffff8 - ldr r1, ._178 @ gMenuCallback - ldr r0, ._178 + 4 @ debug_sub_815FB78 - str r0, [r1] - mov r0, #0x0 - mov r1, #0x0 - mov r2, #0x1d - mov r3, #0x13 - bl Menu_EraseWindowRect - ldr r4, ._178 + 8 @ gStringVar1 - add r0, r4, #0 - bl debug_sub_814A73C - mov r0, #0x0 - mov r1, #0x0 - mov r2, #0xb - mov r3, #0x9 - bl Menu_DrawStdWindowFrame - add r0, r4, #0 - mov r1, #0x1 - mov r2, #0x1 - bl Menu_PrintText - ldr r0, ._178 + 12 @ Str_843E580 - mov r1, #0x2 - mov r2, #0x3 - bl Menu_PrintText - mov r0, #0x0 - str r0, [sp] - mov r0, #0xa - str r0, [sp, #0x4] - mov r0, #0x0 - mov r1, #0x1 - mov r2, #0x3 - mov r3, #0x3 - bl InitMenu - mov r0, #0x0 - add sp, sp, #0x8 - pop {r4} - pop {r1} - bx r1 -._179: - .align 2, 0 -._178: - .word gMenuCallback - .word debug_sub_815FB78+1 - .word gStringVar1 - .word Str_843E580 - - thumb_func_end debug_sub_815FBE8 - - thumb_func_start debug_sub_815FC54 -debug_sub_815FC54: - push {r4, r5, r6, r7, lr} - mov r3, #0x0 - ldr r7, ._181 @ gSaveBlock1 - mov r6, #0xe8 - lsl r6, r6, #0x3 - ldr r5, ._181 + 4 @ 0x3e7 - ldr r4, ._181 + 8 @ 0x742 -._180: - lsl r1, r3, #0x2 - add r1, r1, r7 - add r2, r3, #0 - add r2, r2, #0x85 - add r0, r1, r6 - strh r2, [r0] - add r1, r1, r4 - strh r5, [r1] - add r0, r3, #1 - lsl r0, r0, #0x10 - lsr r3, r0, #0x10 - cmp r3, #0x2a - bls ._180 @cond_branch - bl CloseMenu - mov r0, #0x1 - pop {r4, r5, r6, r7} - pop {r1} - bx r1 -._182: - .align 2, 0 -._181: - .word gSaveBlock1 - .word 0x3e7 - .word 0x742 - - thumb_func_end debug_sub_815FC54 - - thumb_func_start debug_sub_815FC94 -debug_sub_815FC94: - push {lr} - bl ClearDecorationInventories - bl debug_sub_814A3A8 - mov r0, #0x0 - mov r1, #0x0 - mov r2, #0x1d - mov r3, #0x13 - bl Menu_EraseWindowRect - bl CloseMenu - mov r0, #0x1 - pop {r1} - bx r1 - - thumb_func_end debug_sub_815FC94 - thumb_func_start debug_sub_815FCB4 debug_sub_815FCB4: push {r4, r5, r6, r7, lr} diff --git a/include/decoration_inventory.h b/include/decoration_inventory.h index e59a23008..0772aacf6 100644 --- a/include/decoration_inventory.h +++ b/include/decoration_inventory.h @@ -8,5 +8,8 @@ u8 IsThereStorageSpaceForDecoration(u8); u8 sub_8134074(u8); s8 sub_81340A8(u8); u8 sub_8134194(u8); +#if DEBUG +void debug_sub_814A3A8(void); +#endif // DEBUG #endif // GUARD_DECORATION_INVENTORY_H diff --git a/include/roamer.h b/include/roamer.h index 86908bd00..c91742d44 100644 --- a/include/roamer.h +++ b/include/roamer.h @@ -10,4 +10,9 @@ u8 TryStartRoamerEncounter(void); void UpdateRoamerHPStatus(struct Pokemon *mon); void SetRoamerInactive(void); -#endif +#if DEBUG +void debug_sub_814A714(void); +void debug_sub_814A73C(u8 *); +#endif // DEBUG + +#endif // GUARD_ROAMER_H diff --git a/src/debug/nakamura_debug_menu.c b/src/debug/nakamura_debug_menu.c index 959b9eae3..e16f0332a 100644 --- a/src/debug/nakamura_debug_menu.c +++ b/src/debug/nakamura_debug_menu.c @@ -1,5 +1,6 @@ #if DEBUG #include "global.h" +#include "constants/items.h" #include "random.h" #include "palette.h" #include "main.h" @@ -9,6 +10,8 @@ #include "party_menu.h" #include "choose_party.h" #include "secret_base.h" +#include "roamer.h" +#include "decoration_inventory.h" #include "menu.h" typedef bool8 (*MenuFunc)(void); @@ -518,7 +521,6 @@ void debug_sub_815F86C(s8 a0) debug_sub_815F6E4(); } -#ifdef NONMATCHING bool8 debug_sub_815F930(void) { u32 r4 = _nakamuraData1 == 0 ? 7 : 10; @@ -529,206 +531,204 @@ bool8 debug_sub_815F930(void) debug_sub_815F7F0(1); else debug_sub_815F86C(1); + return FALSE; } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + if (gMain.newAndRepeatedKeys & DPAD_DOWN) { if (_nakamuraData1) debug_sub_815F7F0(-1); else debug_sub_815F86C(-1); + return FALSE; } - else if (gMain.newAndRepeatedKeys & DPAD_LEFT) + if (gMain.newAndRepeatedKeys & DPAD_LEFT) { if (_nakamuraData2 == 0) _nakamuraData2 = r4 - 1; else _nakamuraData2--; debug_sub_815F788(); + return FALSE; } - else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + if (gMain.newAndRepeatedKeys & DPAD_RIGHT) { if (_nakamuraData2 == r4 - 1) _nakamuraData2 = 0; else _nakamuraData2++; debug_sub_815F788(); + return FALSE; } - else if (gMain.newKeys & SELECT_BUTTON) + if (gMain.newKeys & SELECT_BUTTON) { if (_nakamuraData1 == 0) _nakamuraData3 = (_nakamuraData3 + 1) % 5; debug_sub_815F7B4(); + return FALSE; } - else if (gMain.newKeys & A_BUTTON) + if (gMain.newKeys & A_BUTTON) { Menu_BlankWindowRect(2, 5, 11, 6); Menu_BlankWindowRect(11, 1, 11, 2); gMenuCallback = debug_sub_815FA38; + return FALSE; } - else if (gMain.newKeys & B_BUTTON) + if (gMain.newKeys & B_BUTTON) { if (_nakamuraData1 == 0) debug_sub_815F86C(100); + return FALSE; + } + + return FALSE; +} + +bool8 debug_sub_815FA38(void) +{ + if (gMain.newKeys & DPAD_UP) + { + Menu_MoveCursor(-2); + return FALSE; + } + + if (gMain.newKeys & DPAD_DOWN) + { + Menu_MoveCursor(+2); + return FALSE; + } + + if (gMain.newKeys & DPAD_LEFT) + { + if (_nakamuraData0 == 0) + _nakamuraData0 = 19; + else + _nakamuraData0--; + debug_sub_815F72C(); + return FALSE; + } + + if (gMain.newKeys & DPAD_RIGHT) + { + if (_nakamuraData0 == 19) + _nakamuraData0 = 0; + else + _nakamuraData0++; + debug_sub_815F72C(); + return FALSE; + } + + if (gMain.newKeys & A_BUTTON) + { + if (_nakamuraData0 != 0 && gSaveBlock1.secretBases[_nakamuraData0].secretBaseId != 0) + { + _nakamuraData1 = Menu_GetCursorPos(); + _nakamuraData2 = 0; + debug_sub_815F788(); + debug_sub_815F7B4(); + gMenuCallback = debug_sub_815F930; + } + return FALSE; + } + + if (gMain.newKeys & B_BUTTON) + { + CloseMenu(); + return TRUE; + } + + return FALSE; +} + +bool8 debug_sub_815FB1C(void) +{ + _nakamuraData0 = 0; + _nakamuraData3 = 0; + gMenuCallback = debug_sub_815FA38; + Menu_EraseWindowRect(0, 0, 29, 19); + Menu_DrawStdWindowFrame(0, 0, 12, 11); + debug_sub_815F72C(); + InitMenu(0, 1, 3, 3, 0, 11); + return FALSE; +} + +bool8 debug_sub_815FB78(void) +{ + if (gMain.newKeys & DPAD_UP) + { + Menu_MoveCursor(-1); + return FALSE; } + if (gMain.newKeys & DPAD_DOWN) + { + Menu_MoveCursor(+1); + return FALSE; + } + + if (gMain.newKeys & A_BUTTON) + { + CloseMenu(); + switch (Menu_GetCursorPos()) + { + case 0: + debug_sub_814A714(); + break; + case 1: + ClearRoamerData(); + ClearRoamerLocationData(); + break; + } + return TRUE; + } + + if (gMain.newKeys & B_BUTTON) + { + CloseMenu(); + return TRUE; + } + + return FALSE; +} + +bool8 debug_sub_815FBE8(void) +{ + gMenuCallback = debug_sub_815FB78; + Menu_EraseWindowRect(0, 0, 29, 19); + debug_sub_814A73C(gStringVar1); + Menu_DrawStdWindowFrame(0, 0, 11, 9); + Menu_PrintText(gStringVar1, 1, 1); + Menu_PrintText(Str_843E580, 2, 3); + InitMenu(0, 1, 3, 3, 0, 10); return FALSE; } -#else -__attribute__((naked)) bool8 debug_sub_815F930(void) + +bool8 debug_sub_815FC54(void) +{ + u16 i; + + for (i = 0; i < 43; i++) + { + gSaveBlock1.bagPocket_Berries[i].itemId = ITEM_CHERI_BERRY + i; + gSaveBlock1.bagPocket_Berries[i].quantity = 999; + } + + CloseMenu(); + return TRUE; +} + +bool8 debug_sub_815FC94(void) { - asm("\tpush\t{r4, r5, lr}\n" - "\tldr\tr0, ._107 @ _nakamuraData1\n" - "\tldrb\tr2, [r0]\n" - "\tmov\tr4, #0xa\n" - "\tcmp\tr2, #0\n" - "\tbne\t._103\t@cond_branch\n" - "\tmov\tr4, #0x7\n" - "._103:\n" - "\tldr\tr5, ._107 + 4 @ gMain\n" - "\tldrh\tr1, [r5, #0x30]\n" - "\tmov\tr0, #0x40\n" - "\tand\tr0, r0, r1\n" - "\tcmp\tr0, #0\n" - "\tbeq\t._104\t@cond_branch\n" - "\tcmp\tr2, #0\n" - "\tbeq\t._105\t@cond_branch\n" - "\tmov\tr0, #0x1\n" - "\tbl\tdebug_sub_815F7F0\n" - "\tb\t._136\n" - "._108:\n" - "\t.align\t2, 0\n" - "._107:\n" - "\t.word\t_nakamuraData1\n" - "\t.word\tgMain\n" - "._105:\n" - "\tmov\tr0, #0x1\n" - "\tb\t._113\n" - "._104:\n" - "\tmov\tr0, #0x80\n" - "\tand\tr0, r0, r1\n" - "\tcmp\tr0, #0\n" - "\tbeq\t._110\t@cond_branch\n" - "\tcmp\tr2, #0\n" - "\tbeq\t._111\t@cond_branch\n" - "\tmov\tr0, #0x1\n" - "\tneg\tr0, r0\n" - "\tbl\tdebug_sub_815F7F0\n" - "\tb\t._136\n" - "._111:\n" - "\tmov\tr0, #0x1\n" - "\tneg\tr0, r0\n" - "\tb\t._113\n" - "._110:\n" - "\tmov\tr0, #0x20\n" - "\tand\tr0, r0, r1\n" - "\tlsl\tr0, r0, #0x10\n" - "\tlsr\tr3, r0, #0x10\n" - "\tcmp\tr3, #0\n" - "\tbeq\t._114\t@cond_branch\n" - "\tldr\tr1, ._117 @ _nakamuraData2\n" - "\tldrb\tr0, [r1]\n" - "\tcmp\tr0, #0\n" - "\tbne\t._115\t@cond_branch\n" - "\tsub\tr0, r4, #1\n" - "\tb\t._116\n" - "._118:\n" - "\t.align\t2, 0\n" - "._117:\n" - "\t.word\t_nakamuraData2\n" - "._115:\n" - "\tsub\tr0, r0, #0x1\n" - "._116:\n" - "\tstrb\tr0, [r1]\n" - "._125:\n" - "\tbl\tdebug_sub_815F788\n" - "\tb\t._136\n" - "._114:\n" - "\tmov\tr0, #0x10\n" - "\tand\tr0, r0, r1\n" - "\tcmp\tr0, #0\n" - "\tbeq\t._120\t@cond_branch\n" - "\tldr\tr2, ._123 @ _nakamuraData2\n" - "\tldrb\tr1, [r2]\n" - "\tsub\tr0, r4, #1\n" - "\tcmp\tr1, r0\n" - "\tbne\t._121\t@cond_branch\n" - "\tstrb\tr3, [r2]\n" - "\tb\t._125\n" - "._124:\n" - "\t.align\t2, 0\n" - "._123:\n" - "\t.word\t_nakamuraData2\n" - "._121:\n" - "\tadd\tr0, r1, #1\n" - "\tstrb\tr0, [r2]\n" - "\tb\t._125\n" - "._120:\n" - "\tldrh\tr1, [r5, #0x2e]\n" - "\tmov\tr0, #0x4\n" - "\tand\tr0, r0, r1\n" - "\tcmp\tr0, #0\n" - "\tbeq\t._126\t@cond_branch\n" - "\tcmp\tr2, #0\n" - "\tbne\t._127\t@cond_branch\n" - "\tldr\tr4, ._129 @ _nakamuraData3\n" - "\tldrb\tr0, [r4]\n" - "\tadd\tr0, r0, #0x1\n" - "\tmov\tr1, #0x5\n" - "\tbl\t__modsi3\n" - "\tstrb\tr0, [r4]\n" - "._127:\n" - "\tbl\tdebug_sub_815F7B4\n" - "\tb\t._136\n" - "._130:\n" - "\t.align\t2, 0\n" - "._129:\n" - "\t.word\t_nakamuraData3\n" - "._126:\n" - "\tmov\tr0, #0x1\n" - "\tand\tr0, r0, r1\n" - "\tcmp\tr0, #0\n" - "\tbeq\t._131\t@cond_branch\n" - "\tmov\tr0, #0x2\n" - "\tmov\tr1, #0x5\n" - "\tmov\tr2, #0xb\n" - "\tmov\tr3, #0x6\n" - "\tbl\tMenu_BlankWindowRect\n" - "\tmov\tr0, #0xb\n" - "\tmov\tr1, #0x1\n" - "\tmov\tr2, #0xb\n" - "\tmov\tr3, #0x2\n" - "\tbl\tMenu_BlankWindowRect\n" - "\tldr\tr1, ._133 @ gMenuCallback\n" - "\tldr\tr0, ._133 + 4 @ debug_sub_815FA38\n" - "\tstr\tr0, [r1]\n" - "\tb\t._136\n" - "._134:\n" - "\t.align\t2, 0\n" - "._133:\n" - "\t.word\tgMenuCallback\n" - "\t.word\tdebug_sub_815FA38+1\n" - "._131:\n" - "\tmov\tr0, #0x2\n" - "\tand\tr0, r0, r1\n" - "\tcmp\tr0, #0\n" - "\tbeq\t._136\t@cond_branch\n" - "\tcmp\tr2, #0\n" - "\tbne\t._136\t@cond_branch\n" - "\tmov\tr0, #0x64\n" - "._113:\n" - "\tbl\tdebug_sub_815F86C\n" - "._136:\n" - "\tmov\tr0, #0x0\n" - "\tpop\t{r4, r5}\n" - "\tpop\t{r1}\n" - "\tbx\tr1"); + ClearDecorationInventories(); + debug_sub_814A3A8(); + Menu_EraseWindowRect(0, 0, 29, 19); + CloseMenu(); + return TRUE; } -#endif // NONMATCHING #endif // DEBUG -- cgit v1.2.3 From d43e750b88e346847cf5f90e31d82aacf31e058c Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 2 Apr 2018 00:12:58 -0400 Subject: debug_sub_815FCB4 --- asm/nakamura_debug_menu.s | 79 ----------------------------------------- src/debug/nakamura_debug_menu.c | 24 +++++++++++++ 2 files changed, 24 insertions(+), 79 deletions(-) diff --git a/asm/nakamura_debug_menu.s b/asm/nakamura_debug_menu.s index 76db41a4d..d17caccb5 100644 --- a/asm/nakamura_debug_menu.s +++ b/asm/nakamura_debug_menu.s @@ -5,85 +5,6 @@ .text - thumb_func_start debug_sub_815FCB4 -debug_sub_815FCB4: - push {r4, r5, r6, r7, lr} - mov r7, r9 - mov r6, r8 - push {r6, r7} - add r4, r0, #0 - lsl r4, r4, #0x18 - lsr r4, r4, #0x18 - mov r7, #0x0 - ldr r5, ._188 @ gMapHeader - ldr r0, [r5] - ldr r0, [r0, #0x4] - mov r1, #0x3 - bl __divsi3 - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - add r1, r0, #0 - mul r1, r1, r4 - lsl r1, r1, #0x10 - lsr r6, r1, #0x10 - add r0, r6, r0 - mov r9, r5 - cmp r6, r0 - bge ._183 @cond_branch - mov r8, r0 -._187: - mov r4, #0x0 - mov r1, r9 - ldr r0, [r1] - ldr r0, [r0] - add r5, r6, #1 - cmp r4, r0 - bge ._184 @cond_branch - ldr r0, ._188 @ gMapHeader - mov r9, r0 -._186: - add r0, r4, #7 - add r1, r6, #7 - bl MapGridGetMetatileBehaviorAt - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - bl sub_805759C - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - cmp r0, #0x1 - bne ._185 @cond_branch - add r0, r7, #1 - lsl r0, r0, #0x10 - lsr r7, r0, #0x10 -._185: - add r0, r4, #1 - lsl r0, r0, #0x10 - lsr r4, r0, #0x10 - ldr r0, ._188 @ gMapHeader - ldr r0, [r0] - ldr r0, [r0] - cmp r4, r0 - blt ._186 @cond_branch -._184: - lsl r0, r5, #0x10 - lsr r6, r0, #0x10 - cmp r6, r8 - blt ._187 @cond_branch -._183: - add r0, r7, #0 - pop {r3, r4} - mov r8, r3 - mov r9, r4 - pop {r4, r5, r6, r7} - pop {r1} - bx r1 -._189: - .align 2, 0 -._188: - .word gMapHeader - - thumb_func_end debug_sub_815FCB4 - thumb_func_start debug_sub_815FD40 debug_sub_815FD40: push {r4, r5, r6, r7, lr} diff --git a/src/debug/nakamura_debug_menu.c b/src/debug/nakamura_debug_menu.c index e16f0332a..d4614416c 100644 --- a/src/debug/nakamura_debug_menu.c +++ b/src/debug/nakamura_debug_menu.c @@ -6,6 +6,8 @@ #include "main.h" #include "string_util.h" #include "overworld.h" +#include "fieldmap.h" +#include "metatile_behavior.h" #include "start_menu.h" #include "party_menu.h" #include "choose_party.h" @@ -731,4 +733,26 @@ bool8 debug_sub_815FC94(void) return TRUE; } +u16 debug_sub_815FCB4(u8 a0) +{ + u16 retval = 0; + u16 height = gMapHeader.mapData->height / 3; + u16 r6; + u16 r4; + u16 start = height * a0; + + for (r6 = start; r6 < start + height; r6++) + { + for (r4 = 0; r4 < gMapHeader.mapData->width; r4++) + { + if (sub_805759C(MapGridGetMetatileBehaviorAt(r4 + 7, r6 + 7)) == TRUE) + { + retval++; + } + } + } + + return retval; +} + #endif // DEBUG -- cgit v1.2.3 From a61e8646af82098604ffc0afbc195607f0733ff3 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 2 Apr 2018 08:48:16 -0400 Subject: through debug_sub_815FFDC --- asm/nakamura_debug_menu.s | 414 ---------------------------------------- include/menu_helpers.h | 3 + include/wild_encounter.h | 5 + src/debug/nakamura_debug_menu.c | 133 ++++++++++++- 4 files changed, 140 insertions(+), 415 deletions(-) diff --git a/asm/nakamura_debug_menu.s b/asm/nakamura_debug_menu.s index d17caccb5..7a95bc953 100644 --- a/asm/nakamura_debug_menu.s +++ b/asm/nakamura_debug_menu.s @@ -5,420 +5,6 @@ .text - thumb_func_start debug_sub_815FD40 -debug_sub_815FD40: - push {r4, r5, r6, r7, lr} - add sp, sp, #0xfffffffc - mov r6, #0x0 - mov r4, sp - add r4, r4, #0x2 - mov r0, sp - add r1, r4, #0 - bl GetXYCoordsOneStepInFrontOfPlayer - mov r1, sp - mov r0, sp - ldrh r0, [r0] - sub r0, r0, #0x7 - strh r0, [r1] - ldrh r0, [r4] - sub r0, r0, #0x7 - strh r0, [r4] - mov r5, #0x0 - ldr r1, ._192 @ gMapHeader - ldr r0, [r1] - ldr r0, [r0, #0x4] - add r7, r4, #0 - cmp r6, r0 - bge ._190 @cond_branch -._199: - mov r4, #0x0 - ldr r0, [r1] - b ._191 -._193: - .align 2, 0 -._192: - .word gMapHeader -._198: - add r0, r4, #7 - add r1, r5, #7 - bl MapGridGetMetatileBehaviorAt - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - bl sub_805759C - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - cmp r0, #0x1 - bne ._196 @cond_branch - add r0, r6, #1 - lsl r0, r0, #0x10 - lsr r6, r0, #0x10 - mov r0, sp - mov r1, #0x0 - ldsh r0, [r0, r1] - cmp r0, r4 - bne ._196 @cond_branch - mov r1, #0x0 - ldsh r0, [r7, r1] - cmp r0, r5 - bne ._196 @cond_branch - add r0, r6, #0 - b ._197 -._196: - add r0, r4, #1 - lsl r0, r0, #0x10 - lsr r4, r0, #0x10 - ldr r0, ._200 @ gMapHeader - ldr r0, [r0] -._191: - ldr r0, [r0] - cmp r4, r0 - blt ._198 @cond_branch - add r0, r5, #1 - lsl r0, r0, #0x10 - lsr r5, r0, #0x10 - ldr r1, ._200 @ gMapHeader - ldr r0, [r1] - ldr r0, [r0, #0x4] - cmp r5, r0 - blt ._199 @cond_branch -._190: - add r0, r6, #1 - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 -._197: - add sp, sp, #0x4 - pop {r4, r5, r6, r7} - pop {r1} - bx r1 -._201: - .align 2, 0 -._200: - .word gMapHeader - - thumb_func_end debug_sub_815FD40 - - thumb_func_start debug_sub_815FDE4 -debug_sub_815FDE4: - push {lr} - ldr r0, ._205 @ gMain - ldrh r1, [r0, #0x2e] - mov r0, #0x1 - and r0, r0, r1 - cmp r0, #0 - bne ._202 @cond_branch - mov r0, #0x2 - and r0, r0, r1 - cmp r0, #0 - beq ._203 @cond_branch -._202: - mov r0, #0x0 - mov r1, #0x0 - mov r2, #0x1d - mov r3, #0x13 - bl Menu_EraseWindowRect - bl CloseMenu - mov r0, #0x1 - b ._204 -._206: - .align 2, 0 -._205: - .word gMain -._203: - mov r0, #0x0 -._204: - pop {r1} - bx r1 - - thumb_func_end debug_sub_815FDE4 - - thumb_func_start debug_sub_815FE1C -debug_sub_815FE1C: - push {r4, r5, r6, r7, lr} - mov r0, #0x0 - mov r1, #0x0 - mov r2, #0x1d - mov r3, #0x13 - bl Menu_EraseWindowRect - mov r0, #0x0 - mov r1, #0x0 - mov r2, #0x10 - mov r3, #0x13 - bl Menu_DrawStdWindowFrame - ldr r0, ._210 @ Str_843E58D - mov r1, #0x1 - mov r2, #0x1 - bl Menu_PrintText - ldr r6, ._210 + 4 @ gStringVar1 - mov r0, #0x0 - bl debug_sub_815FCB4 - add r1, r0, #0 - lsl r1, r1, #0x10 - lsr r1, r1, #0x10 - add r0, r6, #0 - mov r2, #0x1 - mov r3, #0x5 - bl ConvertIntToDecimalStringN - add r0, r6, #0 - mov r1, #0x5 - mov r2, #0x3 - bl Menu_PrintText - mov r0, #0x1 - bl debug_sub_815FCB4 - add r1, r0, #0 - lsl r1, r1, #0x10 - lsr r1, r1, #0x10 - add r0, r6, #0 - mov r2, #0x1 - mov r3, #0x5 - bl ConvertIntToDecimalStringN - add r0, r6, #0 - mov r1, #0x5 - mov r2, #0x5 - bl Menu_PrintText - mov r0, #0x2 - bl debug_sub_815FCB4 - add r1, r0, #0 - lsl r1, r1, #0x10 - lsr r1, r1, #0x10 - add r0, r6, #0 - mov r2, #0x1 - mov r3, #0x5 - bl ConvertIntToDecimalStringN - add r0, r6, #0 - mov r1, #0x5 - mov r2, #0x7 - bl Menu_PrintText - mov r0, #0x0 - bl debug_sub_8092344 - add r1, r0, #0 - lsl r1, r1, #0x10 - lsr r1, r1, #0x10 - add r0, r6, #0 - mov r2, #0x1 - mov r3, #0x5 - bl ConvertIntToDecimalStringN - add r0, r6, #0 - mov r1, #0xb - mov r2, #0x3 - bl Menu_PrintText - mov r0, #0x1 - bl debug_sub_8092344 - add r1, r0, #0 - lsl r1, r1, #0x10 - lsr r1, r1, #0x10 - add r0, r6, #0 - mov r2, #0x1 - mov r3, #0x5 - bl ConvertIntToDecimalStringN - add r0, r6, #0 - mov r1, #0xb - mov r2, #0x5 - bl Menu_PrintText - mov r0, #0x2 - bl debug_sub_8092344 - add r1, r0, #0 - lsl r1, r1, #0x10 - lsr r1, r1, #0x10 - add r0, r6, #0 - mov r2, #0x1 - mov r3, #0x5 - bl ConvertIntToDecimalStringN - add r0, r6, #0 - mov r1, #0xb - mov r2, #0x7 - bl Menu_PrintText - ldr r0, ._210 + 8 @ gSaveBlock1 - ldr r1, ._210 + 12 @ 0x2dd6 - add r0, r0, r1 - ldrh r0, [r0] - bl FeebasSeedRng - mov r0, #0x0 - bl debug_sub_815FCB4 - add r4, r0, #0 - mov r0, #0x1 - bl debug_sub_815FCB4 - add r5, r0, #0 - mov r0, #0x2 - bl debug_sub_815FCB4 - add r4, r4, r5 - add r0, r0, r4 - lsl r0, r0, #0x10 - lsr r7, r0, #0x10 - mov r5, #0x0 -._209: - bl FeebasRandom - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - add r1, r7, #0 - bl __umodsi3 - lsl r0, r0, #0x10 - lsr r1, r0, #0x10 - cmp r1, #0 - bne ._207 @cond_branch - add r1, r7, #0 -._207: - sub r0, r1, #1 - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - cmp r0, #0x2 - bls ._208 @cond_branch - add r0, r6, #0 - mov r2, #0x1 - mov r3, #0x4 - bl ConvertIntToDecimalStringN - add r0, r5, #0 - mov r1, #0x3 - bl __umodsi3 - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - lsl r4, r0, #0x2 - add r4, r4, r0 - add r4, r4, #0x2 - lsl r4, r4, #0x18 - lsr r4, r4, #0x18 - add r0, r5, #0 - mov r1, #0x3 - bl __udivsi3 - add r2, r0, #0 - lsl r2, r2, #0x19 - mov r0, #0xb0 - lsl r0, r0, #0x14 - add r2, r2, r0 - lsr r2, r2, #0x18 - add r0, r6, #0 - add r1, r4, #0 - bl Menu_PrintText - add r0, r5, #1 - lsl r0, r0, #0x10 - lsr r5, r0, #0x10 -._208: - cmp r5, #0x6 - bne ._209 @cond_branch - ldr r4, ._210 + 4 @ gStringVar1 - bl debug_sub_815FD40 - add r1, r0, #0 - lsl r1, r1, #0x10 - lsr r1, r1, #0x10 - add r0, r4, #0 - mov r2, #0x1 - mov r3, #0x4 - bl ConvertIntToDecimalStringN - add r0, r4, #0 - mov r1, #0x2 - mov r2, #0x11 - bl Menu_PrintText - ldr r1, ._210 + 16 @ gMenuCallback - ldr r0, ._210 + 20 @ debug_sub_815FDE4 - str r0, [r1] - mov r0, #0x0 - pop {r4, r5, r6, r7} - pop {r1} - bx r1 -._211: - .align 2, 0 -._210: - .word Str_843E58D - .word gStringVar1 - .word gSaveBlock1 - .word 0x2dd6 - .word gMenuCallback - .word debug_sub_815FDE4+1 - - thumb_func_end debug_sub_815FE1C - - thumb_func_start debug_sub_815FFDC -debug_sub_815FFDC: - push {r4, r5, r6, r7, lr} - mov r7, r8 - push {r7} - mov r0, #0xe - mov r1, #0x0 - mov r2, #0x1d - mov r3, #0xd - bl Menu_DrawStdWindowFrame - mov r0, #0x0 - mov r1, #0xe - mov r2, #0x1d - mov r3, #0x13 - bl Menu_DrawStdWindowFrame - ldr r0, ._214 @ Str_843E5D4 - mov r1, #0x1 - mov r2, #0xf - bl Menu_PrintText - mov r5, #0x0 - ldr r0, ._214 + 4 @ _nakamuraStatic0 - mov r8, r0 -._216: - mov r0, #0x64 - add r1, r5, #0 - mul r1, r1, r0 - ldr r0, ._214 + 8 @ gPlayerParty - add r6, r1, r0 - add r0, r6, #0 - mov r1, #0xb - bl GetMonData - lsl r1, r5, #0x2 - mov r2, r8 - add r4, r1, r2 - strh r0, [r4] - lsl r0, r0, #0x10 - add r7, r1, #0 - cmp r0, #0 - beq ._212 @cond_branch - add r0, r6, #0 - mov r1, #0x38 - bl GetMonData - strb r0, [r4, #0x2] - add r0, r5, #0 - bl debug_sub_816009C - add r0, r5, #0 - bl debug_sub_81600D0 - add r0, r5, #0 - bl debug_sub_816013C - b ._213 -._215: - .align 2, 0 -._214: - .word Str_843E5D4 - .word _nakamuraStatic0 - .word gPlayerParty -._212: - mov r0, #0x1 - strb r0, [r4, #0x2] -._213: - mov r0, r8 - add r1, r7, r0 - mov r0, #0x0 - strb r0, [r1, #0x3] - add r0, r5, #1 - lsl r0, r0, #0x18 - lsr r5, r0, #0x18 - cmp r5, #0x5 - bls ._216 @cond_branch - ldr r1, ._217 @ _nakamuraData4 - mov r0, #0x0 - strb r0, [r1] - mov r0, #0xf - mov r1, #0x1 - mov r2, #0xff - bl PrintTriangleCursorWithPalette - ldr r1, ._217 + 4 @ gMenuCallback - ldr r0, ._217 + 8 @ debug_sub_8160498 - str r0, [r1] - pop {r3} - mov r8, r3 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 -._218: - .align 2, 0 -._217: - .word _nakamuraData4 - .word gMenuCallback - .word debug_sub_8160498+1 - - thumb_func_end debug_sub_815FFDC - thumb_func_start debug_sub_816009C debug_sub_816009C: push {lr} diff --git a/include/menu_helpers.h b/include/menu_helpers.h index a1c872c73..fb50ae724 100644 --- a/include/menu_helpers.h +++ b/include/menu_helpers.h @@ -50,5 +50,8 @@ void StartVerticalScrollIndicators(u8); void sub_80F98DC(u8); void PauseVerticalScrollIndicator(u8); void SetVerticalScrollIndicatorPriority(u8, u8); +#if DEBUG +void PrintTriangleCursorWithPalette(u8, u8, u8); +#endif // DEBUG #endif // GUARD_MENU_HELPERS_H diff --git a/include/wild_encounter.h b/include/wild_encounter.h index c9d7c3fa1..2846c12f5 100644 --- a/include/wild_encounter.h +++ b/include/wild_encounter.h @@ -35,5 +35,10 @@ void FishingWildEncounter(u8 rod); u16 GetLocalWildMon(bool8 *isWaterMon); u16 GetLocalWaterMon(void); bool8 UpdateRepelCounter(void); +#if DEBUG +u16 debug_sub_8092344(u8 arg0); +void FeebasSeedRng(u16 seed); +u16 FeebasRandom(void); +#endif // DEBUG #endif // GUARD_WILD_ENCOUNTER_H diff --git a/src/debug/nakamura_debug_menu.c b/src/debug/nakamura_debug_menu.c index d4614416c..5ceb0896f 100644 --- a/src/debug/nakamura_debug_menu.c +++ b/src/debug/nakamura_debug_menu.c @@ -1,12 +1,14 @@ #if DEBUG #include "global.h" #include "constants/items.h" +#include "constants/species.h" #include "random.h" #include "palette.h" #include "main.h" #include "string_util.h" #include "overworld.h" #include "fieldmap.h" +#include "field_player_avatar.h" #include "metatile_behavior.h" #include "start_menu.h" #include "party_menu.h" @@ -14,7 +16,9 @@ #include "secret_base.h" #include "roamer.h" #include "decoration_inventory.h" +#include "wild_encounter.h" #include "menu.h" +#include "menu_helpers.h" typedef bool8 (*MenuFunc)(void); @@ -29,7 +33,11 @@ EWRAM_DATA u16 _nakamuraData8 = 0; EWRAM_DATA u16 _nakamuraDataA = 0; EWRAM_DATA u16 _nakamuraDataC = 0; -__attribute__((unused)) static u8 _nakamuraStatic0[0x18]; +__attribute__((unused)) static struct { + u16 species; + u8 level; + u8 unk3; +} _nakamuraStatic0[PARTY_SIZE]; __attribute__((unused)) static u8 _nakamuraStatic18; __attribute__((unused)) static u8 gDebugFiller3000814[4]; @@ -46,6 +54,10 @@ bool8 debug_sub_815FBE8(void); bool8 debug_sub_815FC54(void); bool8 debug_sub_815FC94(void); bool8 debug_sub_815FE1C(void); +void debug_sub_816009C(u8); +void debug_sub_81600D0(u8); +void debug_sub_816013C(u8); +bool8 debug_sub_8160498(void); bool8 debug_sub_8160D98(void); const u8 Str_843E36C[] = _("Berries"); @@ -755,4 +767,123 @@ u16 debug_sub_815FCB4(u8 a0) return retval; } +u16 debug_sub_815FD40(void) +{ + u16 retval = 0; + s16 x; + s16 y; + u16 xx; + u16 yy; + + GetXYCoordsOneStepInFrontOfPlayer(&x, &y); + x -= 7; + y -= 7; + + for (yy = 0; yy < gMapHeader.mapData->height; yy++) + { + for (xx = 0; xx < gMapHeader.mapData->width; xx++) + { + if (sub_805759C(MapGridGetMetatileBehaviorAt(xx + 7, yy + 7)) == TRUE) + { + retval++; + if (x == xx && y == yy) + return retval; + } + } + } + return retval + 1; +} + +bool8 debug_sub_815FDE4(void) +{ + if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + { + Menu_EraseWindowRect(0, 0, 29, 19); + CloseMenu(); + return TRUE; + } + + return FALSE; +} + +bool8 debug_sub_815FE1C(void) +{ + u16 r7; + u16 r5; + + Menu_EraseWindowRect(0, 0, 29, 19); + Menu_DrawStdWindowFrame(0, 0, 16, 19); + Menu_PrintText(Str_843E58D, 1, 1); + + ConvertIntToDecimalStringN(gStringVar1, debug_sub_815FCB4(0), STR_CONV_MODE_RIGHT_ALIGN, 5); + Menu_PrintText(gStringVar1, 5, 3); + + ConvertIntToDecimalStringN(gStringVar1, debug_sub_815FCB4(1), STR_CONV_MODE_RIGHT_ALIGN, 5); + Menu_PrintText(gStringVar1, 5, 5); + + ConvertIntToDecimalStringN(gStringVar1, debug_sub_815FCB4(2), STR_CONV_MODE_RIGHT_ALIGN, 5); + Menu_PrintText(gStringVar1, 5, 7); + + ConvertIntToDecimalStringN(gStringVar1, debug_sub_8092344(0), STR_CONV_MODE_RIGHT_ALIGN, 5); + Menu_PrintText(gStringVar1, 11, 3); + + ConvertIntToDecimalStringN(gStringVar1, debug_sub_8092344(1), STR_CONV_MODE_RIGHT_ALIGN, 5); + Menu_PrintText(gStringVar1, 11, 5); + + ConvertIntToDecimalStringN(gStringVar1, debug_sub_8092344(2), STR_CONV_MODE_RIGHT_ALIGN, 5); + Menu_PrintText(gStringVar1, 11, 7); + + FeebasSeedRng(gSaveBlock1.easyChatPairs[0].unk2); + r7 = debug_sub_815FCB4(0) + debug_sub_815FCB4(1) + debug_sub_815FCB4(2); + r5 = 0; + + while (r5 != 6) + { + u16 r1 = FeebasRandom() % r7; + if (r1 == 0) + r1 = r7; + if (r1 == 0 || r1 > 3) + { + ConvertIntToDecimalStringN(gStringVar1, r1, STR_CONV_MODE_RIGHT_ALIGN, 4); + Menu_PrintText(gStringVar1, (r5 % 3) * 5 + 2, (r5 / 3) * 2 + 11); + r5++; + } + } + + ConvertIntToDecimalStringN(gStringVar1, debug_sub_815FD40(), STR_CONV_MODE_RIGHT_ALIGN, 4); + Menu_PrintText(gStringVar1, 2, 17); + + gMenuCallback = debug_sub_815FDE4; + + return FALSE; +} + +void debug_sub_815FFDC(void) +{ + u8 i; + + Menu_DrawStdWindowFrame(14, 0, 29, 13); + Menu_DrawStdWindowFrame(0, 14, 29, 19); + Menu_PrintText(Str_843E5D4, 1, 15); + + for (i = 0; i < PARTY_SIZE; i++) + { + _nakamuraStatic0[i].species = GetMonData(gPlayerParty + i, MON_DATA_SPECIES); + if (_nakamuraStatic0[i].species != SPECIES_NONE) + { + _nakamuraStatic0[i].level = GetMonData(gPlayerParty + i, MON_DATA_LEVEL); + debug_sub_816009C(i); + debug_sub_81600D0(i); + debug_sub_816013C(i); + } + else + _nakamuraStatic0[i].level = 1; + _nakamuraStatic0[i].unk3 = 0; + } + + _nakamuraData4 = 0; + PrintTriangleCursorWithPalette(15, 1, 0xFF); + gMenuCallback = debug_sub_8160498; +} + #endif // DEBUG -- cgit v1.2.3 From e83a8d3454a451eb57a6c6d5e41cd64d3517ba40 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 2 Apr 2018 10:07:40 -0400 Subject: through debug_sub_8160308 --- asm/nakamura_debug_menu.s | 436 ---------------------------------------- include/pokemon.h | 4 + src/debug/nakamura_debug_menu.c | 109 +++++++++- 3 files changed, 111 insertions(+), 438 deletions(-) diff --git a/asm/nakamura_debug_menu.s b/asm/nakamura_debug_menu.s index 7a95bc953..76684feef 100644 --- a/asm/nakamura_debug_menu.s +++ b/asm/nakamura_debug_menu.s @@ -5,442 +5,6 @@ .text - thumb_func_start debug_sub_816009C -debug_sub_816009C: - push {lr} - add r2, r0, #0 - lsl r2, r2, #0x18 - lsr r2, r2, #0x18 - ldr r1, ._219 @ _nakamuraStatic0 - lsl r0, r2, #0x2 - add r0, r0, r1 - mov r3, #0x0 - ldsh r1, [r0, r3] - mov r0, #0xb - mul r0, r0, r1 - ldr r1, ._219 + 4 @ gSpeciesNames - add r0, r0, r1 - lsl r2, r2, #0x1 - add r2, r2, #0x1 - lsl r2, r2, #0x18 - lsr r2, r2, #0x18 - mov r1, #0x10 - bl Menu_PrintText - pop {r0} - bx r0 -._220: - .align 2, 0 -._219: - .word _nakamuraStatic0 - .word gSpeciesNames - - thumb_func_end debug_sub_816009C - - thumb_func_start debug_sub_81600D0 -debug_sub_81600D0: - push {r4, r5, lr} - add sp, sp, #0xfffffffc - lsl r0, r0, #0x18 - lsr r4, r0, #0x18 - add r5, r4, #0 - ldr r1, ._223 @ Str_843E5F0 - mov r0, sp - mov r2, #0x2 - bl memcpy - mov r0, #0x64 - mul r0, r0, r4 - ldr r1, ._223 + 4 @ gPlayerParty - add r0, r0, r1 - bl GetMonGender - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - cmp r0, #0 - bne ._221 @cond_branch - ldr r0, ._223 + 8 @ gOtherText_MaleSymbol2 - b ._222 -._224: - .align 2, 0 -._223: - .word Str_843E5F0 - .word gPlayerParty - .word gOtherText_MaleSymbol2 -._221: - cmp r0, #0xfe - bne ._225 @cond_branch - ldr r0, ._227 @ gOtherText_FemaleSymbolAndLv -._222: - lsl r2, r4, #0x1 - add r2, r2, #0x1 - lsl r2, r2, #0x18 - lsr r2, r2, #0x18 - mov r1, #0x17 - bl Menu_PrintText - b ._226 -._228: - .align 2, 0 -._227: - .word gOtherText_FemaleSymbolAndLv -._225: - lsl r2, r5, #0x1 - add r2, r2, #0x1 - lsl r2, r2, #0x18 - lsr r2, r2, #0x18 - mov r0, sp - mov r1, #0x17 - bl Menu_PrintText -._226: - add sp, sp, #0x4 - pop {r4, r5} - pop {r0} - bx r0 - - thumb_func_end debug_sub_81600D0 - - thumb_func_start debug_sub_816013C -debug_sub_816013C: - push {r4, r5, lr} - add r4, r0, #0 - lsl r4, r4, #0x18 - lsr r4, r4, #0x18 - ldr r5, ._229 @ gStringVar1 - ldr r1, ._229 + 4 @ _nakamuraStatic0 - lsl r0, r4, #0x2 - add r0, r0, r1 - mov r1, #0x2 - ldrsb r1, [r0, r1] - add r0, r5, #0 - mov r2, #0x1 - mov r3, #0x3 - bl ConvertIntToDecimalStringN - lsl r4, r4, #0x1 - add r4, r4, #0x1 - lsl r4, r4, #0x18 - lsr r4, r4, #0x18 - add r0, r5, #0 - mov r1, #0x1a - add r2, r4, #0 - bl Menu_PrintText - pop {r4, r5} - pop {r0} - bx r0 -._230: - .align 2, 0 -._229: - .word gStringVar1 - .word _nakamuraStatic0 - - thumb_func_end debug_sub_816013C - - thumb_func_start debug_sub_816017C -debug_sub_816017C: - push {r4, lr} - lsl r0, r0, #0x18 - lsr r4, r0, #0x18 - lsl r3, r4, #0x1 - add r1, r3, #1 - lsl r1, r1, #0x18 - lsr r1, r1, #0x18 - add r3, r3, #0x2 - lsl r3, r3, #0x18 - lsr r3, r3, #0x18 - mov r0, #0x10 - mov r2, #0x1c - bl Menu_BlankWindowRect - ldr r1, ._232 @ _nakamuraStatic0 - lsl r0, r4, #0x2 - add r0, r0, r1 - mov r1, #0x0 - ldsh r0, [r0, r1] - cmp r0, #0 - beq ._231 @cond_branch - add r0, r4, #0 - bl debug_sub_816009C - add r0, r4, #0 - bl debug_sub_81600D0 - add r0, r4, #0 - bl debug_sub_816013C -._231: - mov r0, #0x5 - bl debug_sub_81603B8 - pop {r4} - pop {r0} - bx r0 -._233: - .align 2, 0 -._232: - .word _nakamuraStatic0 - - thumb_func_end debug_sub_816017C - - thumb_func_start debug_sub_81601C8 -debug_sub_81601C8: - push {r4, r5, lr} - add sp, sp, #0xfffffff0 - lsl r0, r0, #0x18 - lsr r5, r0, #0x18 - lsl r1, r1, #0x18 - lsr r3, r1, #0x18 - ldr r1, ._239 @ _nakamuraStatic0 - lsl r0, r5, #0x2 - add r2, r0, r1 - mov r4, #0x0 - ldsh r0, [r2, r4] - cmp r0, #0 - bne ._236 @cond_branch - ldrb r0, [r2, #0x3] - cmp r0, #0 - bne ._236 @cond_branch - cmp r3, #0x1 - bne ._236 @cond_branch - mov r0, #0x8a - lsl r0, r0, #0x1 - strh r0, [r2] -._236: - lsl r0, r5, #0x2 - add r4, r0, r1 - lsl r0, r3, #0x18 - asr r0, r0, #0x18 - ldrh r1, [r4] - add r2, r0, r1 - mov r3, #0x0 - strh r2, [r4] - lsl r1, r2, #0x10 - mov r0, #0xcd - lsl r0, r0, #0x11 - cmp r1, r0 - ble ._237 @cond_branch - ldr r1, ._239 + 4 @ 0xfffffe65 - add r0, r2, r1 - strh r0, [r4] -._237: - ldrh r1, [r4] - mov r2, #0x0 - ldsh r0, [r4, r2] - cmp r0, #0 - bge ._238 @cond_branch - ldr r2, ._239 + 8 @ 0x19b - add r0, r1, r2 - strh r0, [r4] -._238: - mov r0, #0x64 - mul r0, r0, r5 - ldr r1, ._239 + 12 @ gPlayerParty - add r0, r0, r1 - ldrh r1, [r4] - ldrb r2, [r4, #0x2] - str r3, [sp] - str r3, [sp, #0x4] - str r3, [sp, #0x8] - str r3, [sp, #0xc] - mov r3, #0x20 - bl CreateMon - mov r0, #0x1 - strb r0, [r4, #0x3] - add sp, sp, #0x10 - pop {r4, r5} - pop {r0} - bx r0 -._240: - .align 2, 0 -._239: - .word _nakamuraStatic0 - .word 0xfffffe65 - .word 0x19b - .word gPlayerParty - - thumb_func_end debug_sub_81601C8 - - thumb_func_start debug_sub_8160258 -debug_sub_8160258: - push {lr} - lsl r0, r0, #0x18 - lsr r2, r0, #0x18 - ldr r1, ._242 @ _nakamuraStatic0 - lsl r0, r2, #0x2 - add r0, r0, r1 - mov r1, #0x0 - ldsh r0, [r0, r1] - cmp r0, #0 - beq ._241 @cond_branch - add r0, r2, #0 - bl debug_sub_816062C -._241: - pop {r0} - bx r0 -._243: - .align 2, 0 -._242: - .word _nakamuraStatic0 - - thumb_func_end debug_sub_8160258 - - thumb_func_start debug_sub_816027C -debug_sub_816027C: - push {r4, lr} - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - add r4, r0, #0 - lsl r1, r1, #0x18 - lsr r2, r1, #0x18 - ldr r1, ._247 @ _nakamuraStatic0 - lsl r0, r4, #0x2 - add r3, r0, r1 - mov r1, #0x0 - ldsh r0, [r3, r1] - cmp r0, #0 - beq ._244 @cond_branch - lsl r0, r2, #0x18 - asr r0, r0, #0x18 - ldrb r1, [r3, #0x2] - add r0, r0, r1 - strb r0, [r3, #0x2] - lsl r0, r0, #0x18 - asr r0, r0, #0x18 - cmp r0, #0x64 - ble ._245 @cond_branch - mov r0, #0x1 - strb r0, [r3, #0x2] -._245: - mov r0, #0x2 - ldrsb r0, [r3, r0] - cmp r0, #0 - bgt ._246 @cond_branch - mov r0, #0x64 - strb r0, [r3, #0x2] -._246: - mov r0, #0x64 - mul r4, r4, r0 - ldr r0, ._247 + 4 @ gPlayerParty - add r4, r4, r0 - ldr r2, ._247 + 8 @ gBaseStats - mov r0, #0x0 - ldsh r1, [r3, r0] - lsl r0, r1, #0x3 - sub r0, r0, r1 - lsl r0, r0, #0x2 - add r0, r0, r2 - ldrb r1, [r0, #0x13] - mov r0, #0xca - lsl r0, r0, #0x1 - add r2, r1, #0 - mul r2, r2, r0 - mov r0, #0x2 - ldrsb r0, [r3, r0] - lsl r0, r0, #0x2 - ldr r1, ._247 + 12 @ gExperienceTables - add r0, r0, r1 - add r2, r2, r0 - add r0, r4, #0 - mov r1, #0x19 - bl SetMonData - add r0, r4, #0 - bl debug_sub_803F55C -._244: - pop {r4} - pop {r0} - bx r0 -._248: - .align 2, 0 -._247: - .word _nakamuraStatic0 - .word gPlayerParty - .word gBaseStats - .word gExperienceTables - - thumb_func_end debug_sub_816027C - - thumb_func_start debug_sub_8160308 -debug_sub_8160308: - push {r4, r5, r6, r7, lr} - mov r7, r9 - mov r6, r8 - push {r6, r7} - add sp, sp, #0xffffff8c - mov r0, #0x0 - mov r1, #0x0 - mov r2, #0x1d - mov r3, #0x13 - bl Menu_EraseWindowRect - mov r2, #0x0 -._252: - add r1, r2, #1 - lsl r0, r1, #0x18 - lsr r5, r0, #0x18 - mov r8, r1 - cmp r5, #0x5 - bhi ._249 @cond_branch - mov r0, #0x64 - mov r9, r0 - mov r0, r9 - mul r0, r0, r2 - ldr r7, ._254 @ gPlayerParty - add r6, r0, r7 -._251: - add r0, r6, #0 - mov r1, #0xb - mov r2, #0x0 - bl GetMonData - cmp r0, #0 - bne ._250 @cond_branch - add r0, sp, #0x10 - add r1, r6, #0 - mov r2, #0x64 - bl memcpy - mov r4, r9 - mul r4, r4, r5 - add r4, r4, r7 - add r0, r6, #0 - add r1, r4, #0 - mov r2, #0x64 - bl memcpy - add r0, r4, #0 - add r1, sp, #0x10 - mov r2, #0x64 - bl memcpy -._250: - add r0, r5, #1 - lsl r0, r0, #0x18 - lsr r5, r0, #0x18 - cmp r5, #0x5 - bls ._251 @cond_branch -._249: - mov r1, r8 - lsl r0, r1, #0x18 - lsr r2, r0, #0x18 - cmp r2, #0x4 - bls ._252 @cond_branch - bl CalculatePlayerPartyCount - ldr r4, ._254 + 4 @ gPlayerPartyCount - ldrb r1, [r4] - cmp r1, #0 - bne ._253 @cond_branch - ldr r0, ._254 @ gPlayerParty - str r1, [sp] - str r1, [sp, #0x4] - str r1, [sp, #0x8] - str r1, [sp, #0xc] - mov r1, #0x1 - mov r2, #0xa - mov r3, #0x20 - bl CreateMon - mov r0, #0x1 - strb r0, [r4] -._253: - add sp, sp, #0x74 - pop {r3, r4} - mov r8, r3 - mov r9, r4 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 -._255: - .align 2, 0 -._254: - .word gPlayerParty - .word gPlayerPartyCount - - thumb_func_end debug_sub_8160308 - thumb_func_start debug_sub_81603B8 debug_sub_81603B8: push {r4, r5, r6, r7, lr} diff --git a/include/pokemon.h b/include/pokemon.h index 169045c0c..c827e3cd5 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -631,4 +631,8 @@ void BoxMonRestorePP(struct BoxPokemon *); bool8 HealStatusConditions(struct Pokemon *mon, u32 unused, u32 healMask, u8 battleId); +#if DEBUG +void debug_sub_803F55C(struct Pokemon *); +#endif // DEBUG + #endif // GUARD_POKEMON_H diff --git a/src/debug/nakamura_debug_menu.c b/src/debug/nakamura_debug_menu.c index 5ceb0896f..5840a5ebf 100644 --- a/src/debug/nakamura_debug_menu.c +++ b/src/debug/nakamura_debug_menu.c @@ -2,6 +2,8 @@ #include "global.h" #include "constants/items.h" #include "constants/species.h" +#include "data2.h" +#include "strings.h" #include "random.h" #include "palette.h" #include "main.h" @@ -34,8 +36,8 @@ EWRAM_DATA u16 _nakamuraDataA = 0; EWRAM_DATA u16 _nakamuraDataC = 0; __attribute__((unused)) static struct { - u16 species; - u8 level; + s16 species; + s8 level; u8 unk3; } _nakamuraStatic0[PARTY_SIZE]; __attribute__((unused)) static u8 _nakamuraStatic18; @@ -57,7 +59,9 @@ bool8 debug_sub_815FE1C(void); void debug_sub_816009C(u8); void debug_sub_81600D0(u8); void debug_sub_816013C(u8); +void debug_sub_81603B8(u8); bool8 debug_sub_8160498(void); +void debug_sub_816062C(u8); bool8 debug_sub_8160D98(void); const u8 Str_843E36C[] = _("Berries"); @@ -201,6 +205,8 @@ const u8 Str_843E5D4[] = _( "Aボタン {ESCAPE}\p" "  Bボタン ー\n" "START けってい"); + +// The following may be defined in the functions in which they are invoked const u8 Str_843E5F0[] = _("?"); const u8 Str_843E5F2[] = _("HP どりょくち"); const u8 Str_843E5FB[] = _("こうげき どりょくち"); @@ -886,4 +892,103 @@ void debug_sub_815FFDC(void) gMenuCallback = debug_sub_8160498; } +void debug_sub_816009C(u8 i) +{ + Menu_PrintText(gSpeciesNames[_nakamuraStatic0[i].species], 16, 2 * i + 1); +} + +void debug_sub_81600D0(u8 i) +{ + // u8 sp0[] = _("?"); + + u8 sp0[2]; + u8 gender; + + memcpy(sp0, Str_843E5F0, sizeof Str_843E5F0); + gender = GetMonGender(gPlayerParty + i); + if (gender == MON_MALE) + Menu_PrintText(gOtherText_MaleSymbol2, 23, 2 * i + 1); + else if (gender == MON_FEMALE) + Menu_PrintText(gOtherText_FemaleSymbolAndLv, 23, 2 * i + 1); + else + Menu_PrintText(sp0, 23, 2 * i + 1); +} + +void debug_sub_816013C(u8 i) +{ + ConvertIntToDecimalStringN(gStringVar1, _nakamuraStatic0[i].level, STR_CONV_MODE_RIGHT_ALIGN, 3); + Menu_PrintText(gStringVar1, 26, 2 * i + 1); +} + +void debug_sub_816017C(u8 i) +{ + Menu_BlankWindowRect(16, 2 * i + 1, 28, 2 * i + 2); + if (_nakamuraStatic0[i].species != SPECIES_NONE) + { + debug_sub_816009C(i); + debug_sub_81600D0(i); + debug_sub_816013C(i); + } + debug_sub_81603B8(5); +} + +void debug_sub_81601C8(u8 i, s8 dirn) +{ + if (_nakamuraStatic0[i].species == SPECIES_NONE && _nakamuraStatic0[i].unk3 == 0 && dirn == 1) + _nakamuraStatic0[i].species = SPECIES_TREECKO - 1; + _nakamuraStatic0[i].species += dirn; + if (_nakamuraStatic0[i].species >= SPECIES_CHIMECHO) + _nakamuraStatic0[i].species -= SPECIES_CHIMECHO; + if (_nakamuraStatic0[i].species < 0) + _nakamuraStatic0[i].species += SPECIES_CHIMECHO; + CreateMon(gPlayerParty + i, _nakamuraStatic0[i].species, _nakamuraStatic0[i].level, 0x20, 0, 0, 0, 0); + _nakamuraStatic0[i].unk3 = 1; +} + +void debug_sub_8160258(u8 i) +{ + if (_nakamuraStatic0[i].species != SPECIES_NONE) + debug_sub_816062C(i); +} + +void debug_sub_816027C(u8 i, s8 dirn) +{ + if (_nakamuraStatic0[i].species != SPECIES_NONE) + { + _nakamuraStatic0[i].level += dirn; + if (_nakamuraStatic0[i].level > 100) + _nakamuraStatic0[i].level = 1; + if (_nakamuraStatic0[i].level < 1) + _nakamuraStatic0[i].level = 100; + SetMonData(gPlayerParty + i, MON_DATA_EXP, gExperienceTables[gBaseStats[_nakamuraStatic0[i].species].growthRate] + _nakamuraStatic0[i].level); + debug_sub_803F55C(gPlayerParty + i); + } +} + +void debug_sub_8160308(void) +{ + u8 i; + u8 j; + + Menu_EraseWindowRect(0, 0, 29, 19); + for (i = 0; i < 5; i++) + { + for (j = i + 1; j < 6; j++) + { + if (GetMonData(gPlayerParty + i, MON_DATA_SPECIES, NULL) == SPECIES_NONE) + { + struct Pokemon tmp = gPlayerParty[i]; + gPlayerParty[i] = gPlayerParty[j]; + gPlayerParty[j] = tmp; + } + } + } + CalculatePlayerPartyCount(); + if (gPlayerPartyCount == 0) + { + CreateMon(gPlayerParty + 0, SPECIES_BULBASAUR, 10, 0x20, 0, 0, 0, 0); + gPlayerPartyCount = 1; + } +} + #endif // DEBUG -- cgit v1.2.3 From 28b5a25d69d8627c66ced0d47f5bf540ac81a76a Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 2 Apr 2018 10:58:51 -0400 Subject: through debug_sub_8160498 --- asm/nakamura_debug_menu.s | 339 ---------------------------------------- src/debug/nakamura_debug_menu.c | 132 ++++++++++++++++ 2 files changed, 132 insertions(+), 339 deletions(-) diff --git a/asm/nakamura_debug_menu.s b/asm/nakamura_debug_menu.s index 76684feef..1564cf784 100644 --- a/asm/nakamura_debug_menu.s +++ b/asm/nakamura_debug_menu.s @@ -5,345 +5,6 @@ .text - thumb_func_start debug_sub_81603B8 -debug_sub_81603B8: - push {r4, r5, r6, r7, lr} - lsl r0, r0, #0x18 - lsr r6, r0, #0x18 - mov r0, #0x5 - bl PlaySE - ldr r7, ._259 @ _nakamuraData4 - ldrb r4, [r7] - add r0, r4, #0 - mov r1, #0x6 - bl __udivsi3 - lsl r0, r0, #0x18 - lsr r5, r0, #0x18 - add r0, r4, #0 - mov r1, #0x6 - bl __umodsi3 - lsl r0, r0, #0x18 - lsr r4, r0, #0x18 - ldr r0, ._259 + 4 @ _843E5D1 - add r0, r5, r0 - ldrb r2, [r0] - lsl r3, r4, #0x1 - add r1, r3, #1 - lsl r1, r1, #0x18 - lsr r1, r1, #0x18 - add r3, r3, #0x2 - lsl r3, r3, #0x18 - lsr r3, r3, #0x18 - add r0, r2, #0 - bl Menu_BlankWindowRect - cmp r6, #0 - bne ._256 @cond_branch - cmp r4, #0 - beq ._257 @cond_branch - ldrb r0, [r7] - sub r0, r0, #0x1 - b ._258 -._260: - .align 2, 0 -._259: - .word _nakamuraData4 - .word _843E5D1 -._257: - lsl r0, r5, #0x1 - add r0, r0, r5 - lsl r0, r0, #0x1 - add r0, r0, #0x5 -._258: - strb r0, [r7] -._256: - ldr r1, ._264 @ _nakamuraData4 - cmp r6, #0x1 - bne ._261 @cond_branch - cmp r4, #0x5 - beq ._262 @cond_branch - ldrb r0, [r1] - add r0, r0, #0x1 - b ._263 -._265: - .align 2, 0 -._264: - .word _nakamuraData4 -._262: - lsl r0, r5, #0x1 - add r0, r0, r5 - lsl r0, r0, #0x1 -._263: - strb r0, [r1] -._261: - cmp r6, #0x2 - bne ._266 @cond_branch - cmp r5, #0 - beq ._267 @cond_branch - ldrb r0, [r1] - sub r0, r0, #0x6 - b ._268 -._267: - add r0, r4, #0 - add r0, r0, #0xc -._268: - strb r0, [r1] -._266: - cmp r6, #0x3 - bne ._271 @cond_branch - cmp r5, #0x2 - beq ._270 @cond_branch - ldrb r0, [r1] - add r0, r0, #0x6 - strb r0, [r1] - b ._271 -._270: - strb r4, [r1] -._271: - ldrb r4, [r1] - add r0, r4, #0 - mov r1, #0x6 - bl __udivsi3 - lsl r0, r0, #0x18 - lsr r5, r0, #0x18 - add r0, r4, #0 - mov r1, #0x6 - bl __umodsi3 - add r1, r0, #0 - lsl r1, r1, #0x18 - ldr r0, ._272 @ _843E5D1 - add r0, r5, r0 - ldrb r0, [r0] - lsr r1, r1, #0x17 - add r1, r1, #0x1 - lsl r1, r1, #0x18 - lsr r1, r1, #0x18 - mov r2, #0xff - bl PrintTriangleCursorWithPalette - pop {r4, r5, r6, r7} - pop {r0} - bx r0 -._273: - .align 2, 0 -._272: - .word _843E5D1 - - thumb_func_end debug_sub_81603B8 - - thumb_func_start debug_sub_8160498 -debug_sub_8160498: - push {r4, lr} - ldr r1, ._276 @ gMain - ldrh r2, [r1, #0x2e] - mov r0, #0x40 - and r0, r0, r2 - cmp r0, #0 - beq ._274 @cond_branch - mov r0, #0x0 - b ._281 -._277: - .align 2, 0 -._276: - .word gMain -._274: - mov r0, #0x80 - and r0, r0, r2 - cmp r0, #0 - beq ._278 @cond_branch - mov r0, #0x1 - b ._281 -._278: - mov r0, #0x20 - and r0, r0, r2 - cmp r0, #0 - beq ._280 @cond_branch - mov r0, #0x2 - b ._281 -._280: - mov r0, #0x10 - and r0, r0, r2 - cmp r0, #0 - beq ._282 @cond_branch - mov r0, #0x3 -._281: - bl debug_sub_81603B8 - mov r0, #0x0 - b ._311 -._282: - ldrh r1, [r1, #0x30] - mov r0, #0x1 - and r0, r0, r1 - cmp r0, #0 - beq ._284 @cond_branch - ldr r4, ._289 @ _nakamuraData4 - ldrb r0, [r4] - cmp r0, #0x5 - bhi ._285 @cond_branch - mov r1, #0x1 - bl debug_sub_81601C8 -._285: - ldrb r0, [r4] - sub r0, r0, #0x6 - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - cmp r0, #0x5 - bhi ._286 @cond_branch - ldrb r0, [r4] - mov r1, #0x6 - bl __umodsi3 - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - bl debug_sub_8160258 -._286: - ldrb r0, [r4] - sub r0, r0, #0xc - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - cmp r0, #0x5 - bhi ._306 @cond_branch - ldrb r0, [r4] - mov r1, #0x6 - bl __umodsi3 - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - mov r1, #0x1 - b ._300 -._290: - .align 2, 0 -._289: - .word _nakamuraData4 -._284: - mov r0, #0x2 - and r0, r0, r1 - cmp r0, #0 - beq ._291 @cond_branch - ldr r4, ._294 @ _nakamuraData4 - ldrb r0, [r4] - cmp r0, #0x5 - bhi ._304 @cond_branch - mov r1, #0x1 - neg r1, r1 - b ._293 -._295: - .align 2, 0 -._294: - .word _nakamuraData4 -._291: - mov r0, #0x80 - lsl r0, r0, #0x1 - and r0, r0, r1 - cmp r0, #0 - beq ._296 @cond_branch - ldr r4, ._301 @ _nakamuraData4 - ldrb r0, [r4] - cmp r0, #0x5 - bhi ._297 @cond_branch - mov r1, #0xa - bl debug_sub_81601C8 -._297: - ldrb r0, [r4] - sub r0, r0, #0x6 - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - cmp r0, #0x5 - bhi ._298 @cond_branch - ldrb r0, [r4] - mov r1, #0x6 - bl __umodsi3 - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - bl debug_sub_8160258 -._298: - ldrb r0, [r4] - sub r0, r0, #0xc - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - cmp r0, #0x5 - bhi ._306 @cond_branch - ldrb r0, [r4] - mov r1, #0x6 - bl __umodsi3 - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - mov r1, #0x1 - b ._300 -._302: - .align 2, 0 -._301: - .word _nakamuraData4 -._296: - mov r0, #0x80 - lsl r0, r0, #0x2 - and r0, r0, r1 - cmp r0, #0 - beq ._303 @cond_branch - ldr r4, ._308 @ _nakamuraData4 - ldrb r0, [r4] - cmp r0, #0x5 - bhi ._304 @cond_branch - mov r1, #0xa - neg r1, r1 -._293: - bl debug_sub_81601C8 -._304: - ldrb r0, [r4] - sub r0, r0, #0x6 - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - cmp r0, #0x5 - bhi ._305 @cond_branch - ldrb r0, [r4] - mov r1, #0x6 - bl __umodsi3 - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - bl debug_sub_8160258 -._305: - ldrb r0, [r4] - sub r0, r0, #0xc - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - cmp r0, #0x5 - bhi ._306 @cond_branch - ldrb r0, [r4] - mov r1, #0x6 - bl __umodsi3 - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - mov r1, #0x1 - neg r1, r1 -._300: - bl debug_sub_816027C -._306: - ldrb r0, [r4] - mov r1, #0x6 - bl __umodsi3 - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - bl debug_sub_816017C - mov r0, #0x0 - b ._311 -._309: - .align 2, 0 -._308: - .word _nakamuraData4 -._303: - mov r0, #0x8 - and r0, r0, r2 - cmp r0, #0 - bne ._310 @cond_branch - mov r0, #0x0 - b ._311 -._310: - bl debug_sub_8160308 - bl CloseMenu - mov r0, #0x1 -._311: - pop {r4} - pop {r1} - bx r1 - - thumb_func_end debug_sub_8160498 - thumb_func_start debug_sub_816062C debug_sub_816062C: push {r4, r5, r6, r7, lr} diff --git a/src/debug/nakamura_debug_menu.c b/src/debug/nakamura_debug_menu.c index 5840a5ebf..1b640f7bb 100644 --- a/src/debug/nakamura_debug_menu.c +++ b/src/debug/nakamura_debug_menu.c @@ -2,6 +2,8 @@ #include "global.h" #include "constants/items.h" #include "constants/species.h" +#include "constants/songs.h" +#include "sound.h" #include "data2.h" #include "strings.h" #include "random.h" @@ -991,4 +993,134 @@ void debug_sub_8160308(void) } } +void debug_sub_81603B8(u8 i) +{ + u8 q; + u8 r; + PlaySE(SE_SELECT); + q = _nakamuraData4 / 6; + r = _nakamuraData4 % 6; + Menu_BlankWindowRect(_843E5D1[q], r * 2 + 1, _843E5D1[q], r * 2 + 2); + + if (i == 0) + { + if (r != 0) + _nakamuraData4--; + else + _nakamuraData4 = q * 6 + 5; + } + + if (i == 1) + { + if (r != 5) + _nakamuraData4++; + else + _nakamuraData4 = q * 6; + } + + if (i == 2) + { + if (q != 0) + _nakamuraData4 -= 6; + else + _nakamuraData4 = 12 + r; + } + + if (i == 3) + { + if (q != 2) + _nakamuraData4 += 6; + else + _nakamuraData4 = r; + } + + q = _nakamuraData4 / 6; + r = _nakamuraData4 % 6; + PrintTriangleCursorWithPalette(_843E5D1[q], r * 2 + 1, 0xFF); +} + +bool8 debug_sub_8160498(void) +{ + if (gMain.newKeys & DPAD_UP) + { + debug_sub_81603B8(0); + return FALSE; + } + + if (gMain.newKeys & DPAD_DOWN) + { + debug_sub_81603B8(1); + return FALSE; + } + + if (gMain.newKeys & DPAD_LEFT) + { + debug_sub_81603B8(2); + return FALSE; + } + + if (gMain.newKeys & DPAD_RIGHT) + { + debug_sub_81603B8(3); + return FALSE; + } + + if (gMain.newAndRepeatedKeys & A_BUTTON) + { + if (_nakamuraData4 < 6) + debug_sub_81601C8(_nakamuraData4, +1); + if (_nakamuraData4 >= 6 && _nakamuraData4 < 12) + debug_sub_8160258(_nakamuraData4 % 6); + if (_nakamuraData4 >= 12 && _nakamuraData4 < 18) + debug_sub_816027C(_nakamuraData4 % 6, +1); + debug_sub_816017C(_nakamuraData4 % 6); + return FALSE; + } + + if (gMain.newAndRepeatedKeys & B_BUTTON) + { + if (_nakamuraData4 < 6) + debug_sub_81601C8(_nakamuraData4, -1); + if (_nakamuraData4 >= 6 && _nakamuraData4 < 12) + debug_sub_8160258(_nakamuraData4 % 6); + if (_nakamuraData4 >= 12 && _nakamuraData4 < 18) + debug_sub_816027C(_nakamuraData4 % 6, -1); + debug_sub_816017C(_nakamuraData4 % 6); + return FALSE; + } + + if (gMain.newAndRepeatedKeys & R_BUTTON) + { + if (_nakamuraData4 < 6) + debug_sub_81601C8(_nakamuraData4, +10); + if (_nakamuraData4 >= 6 && _nakamuraData4 < 12) + debug_sub_8160258(_nakamuraData4 % 6); + if (_nakamuraData4 >= 12 && _nakamuraData4 < 18) + debug_sub_816027C(_nakamuraData4 % 6, +1); + debug_sub_816017C(_nakamuraData4 % 6); + return FALSE; + } + + if (gMain.newAndRepeatedKeys & L_BUTTON) + { + if (_nakamuraData4 < 6) + debug_sub_81601C8(_nakamuraData4, -10); + if (_nakamuraData4 >= 6 && _nakamuraData4 < 12) + debug_sub_8160258(_nakamuraData4 % 6); + if (_nakamuraData4 >= 12 && _nakamuraData4 < 18) + debug_sub_816027C(_nakamuraData4 % 6, -1); + debug_sub_816017C(_nakamuraData4 % 6); + return FALSE; + } + + if (gMain.newKeys & START_BUTTON) + { + debug_sub_8160308(); + CloseMenu(); + return TRUE; + } + + return FALSE; +} + #endif // DEBUG -- cgit v1.2.3 From 79843a9026867842d2719bad87ad986a4bd4ce87 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 2 Apr 2018 15:59:06 -0400 Subject: through nonmatching debug_sub_8160714 --- asm/nakamura_debug_menu.s | 471 ---------------------------------- src/debug/nakamura_debug_menu.c | 555 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 552 insertions(+), 474 deletions(-) diff --git a/asm/nakamura_debug_menu.s b/asm/nakamura_debug_menu.s index 1564cf784..ad3af7e84 100644 --- a/asm/nakamura_debug_menu.s +++ b/asm/nakamura_debug_menu.s @@ -5,477 +5,6 @@ .text - thumb_func_start debug_sub_816062C -debug_sub_816062C: - push {r4, r5, r6, r7, lr} - mov r7, r9 - mov r6, r8 - push {r6, r7} - add sp, sp, #0xfffffff0 - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - mov r8, r0 - mov r0, #0x64 - mov r4, r8 - mul r4, r4, r0 - ldr r0, ._316 @ gPlayerParty - add r4, r4, r0 - add r0, r4, #0 - mov r1, #0xb - bl GetMonData - lsl r0, r0, #0x10 - lsr r7, r0, #0x10 - add r0, r4, #0 - bl GetMonGender - lsl r0, r0, #0x18 - lsr r2, r0, #0x18 - ldr r1, ._316 + 4 @ gBaseStats - lsl r0, r7, #0x3 - sub r0, r0, r7 - lsl r0, r0, #0x2 - add r0, r0, r1 - ldrb r6, [r0, #0x10] - cmp r6, #0 - beq ._313 @cond_branch - cmp r6, #0xfe - beq ._313 @cond_branch - cmp r6, #0xff - bne ._314 @cond_branch -._313: - mov r0, #0x64 - mov r1, r8 - mul r1, r1, r0 - add r0, r1, #0 - ldr r1, ._316 @ gPlayerParty - add r0, r0, r1 - bl GetMonGender - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - b ._320 -._317: - .align 2, 0 -._316: - .word gPlayerParty - .word gBaseStats -._314: - cmp r2, #0 - beq ._318 @cond_branch - cmp r2, #0xfe - beq ._319 @cond_branch - mov r0, #0x0 - b ._320 -._318: - mov r6, #0xfe - b ._321 -._319: - mov r6, #0x0 -._321: - mov r0, r8 - lsl r0, r0, #0x2 - mov r9, r0 -._322: - bl Random - lsl r0, r0, #0x10 - lsr r5, r0, #0x10 - bl Random - lsl r0, r0, #0x10 - orr r5, r5, r0 - add r0, r7, #0 - add r1, r5, #0 - bl GetGenderFromSpeciesAndPersonality - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - cmp r0, r6 - bne ._322 @cond_branch - mov r0, #0x64 - mov r4, r8 - mul r4, r4, r0 - ldr r0, ._323 @ gPlayerParty - add r4, r4, r0 - add r0, r4, #0 - mov r1, #0x42 - bl GetMonData - ldr r0, ._323 + 4 @ _nakamuraStatic0 - add r0, r0, r9 - ldrh r1, [r0] - ldrb r2, [r0, #0x2] - mov r0, #0x1 - str r0, [sp] - str r5, [sp, #0x4] - mov r0, #0x0 - str r0, [sp, #0x8] - str r0, [sp, #0xc] - add r0, r4, #0 - mov r3, #0x20 - bl CreateMon - add r0, r6, #0 -._320: - add sp, sp, #0x10 - pop {r3, r4} - mov r8, r3 - mov r9, r4 - pop {r4, r5, r6, r7} - pop {r1} - bx r1 -._324: - .align 2, 0 -._323: - .word gPlayerParty - .word _nakamuraStatic0 - - thumb_func_end debug_sub_816062C - - thumb_func_start debug_sub_8160714 -debug_sub_8160714: - push {r4, r5, r6, r7, lr} - mov r7, r9 - mov r6, r8 - push {r6, r7} - add sp, sp, #0xfffffff0 - add r6, r0, #0 - mov r9, r1 - mov r7, #0x0 - mov r0, #0x0 - mov r8, r0 - mov r2, #0x0 - mov r5, #0x0 -._329: - add r4, r5, #1 - lsl r1, r4, #0x18 - lsr r1, r1, #0x18 - mov r0, r9 - str r2, [sp, #0xc] - bl GetPokeblockData - add r1, r0, #0 - lsl r0, r5, #0x1 - add r0, r0, sp - strh r1, [r0] - ldr r2, [sp, #0xc] - cmp r5, #0x5 - beq ._328 @cond_branch - lsl r0, r1, #0x10 - asr r1, r0, #0x10 - cmp r1, #0 - ble ._326 @cond_branch - add r0, r7, #1 - lsl r0, r0, #0x18 - lsr r7, r0, #0x18 -._326: - cmp r1, #0 - bge ._327 @cond_branch - mov r0, r8 - add r0, r0, #0x1 - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - mov r8, r0 -._327: - cmp r1, #0 - bne ._328 @cond_branch - add r0, r2, #1 - lsl r0, r0, #0x18 - lsr r2, r0, #0x18 -._328: - lsl r0, r4, #0x18 - lsr r5, r0, #0x18 - cmp r5, #0x5 - bls ._329 @cond_branch - mov r0, sp - mov r1, #0x0 - ldsh r0, [r0, r1] - cmp r0, #0x31 - bgt ._333 @cond_branch - mov r0, sp - ldrh r0, [r0, #0x2] - lsl r0, r0, #0x10 - asr r0, r0, #0x10 - cmp r0, #0x31 - bgt ._333 @cond_branch - mov r0, sp - mov r4, #0x4 - ldsh r0, [r0, r4] - cmp r0, #0x31 - bgt ._333 @cond_branch - mov r0, sp - mov r1, #0x6 - ldsh r0, [r0, r1] - cmp r0, #0x31 - bgt ._333 @cond_branch - mov r0, sp - mov r4, #0x8 - ldsh r0, [r0, r4] - cmp r0, #0x31 - ble ._334 @cond_branch -._333: - ldr r1, ._336 @ ContestStatsText_GoldPokeBlock - add r0, r6, #0 - bl StringCopy - mov r0, #0xe - b ._400 -._337: - .align 2, 0 -._336: - .word ContestStatsText_GoldPokeBlock -._334: - cmp r7, #0x4 - bne ._338 @cond_branch - ldr r1, ._340 @ ContestStatsText_WhitePokeBlock - add r0, r6, #0 - bl StringCopy - mov r0, #0xd - b ._400 -._341: - .align 2, 0 -._340: - .word ContestStatsText_WhitePokeBlock -._338: - mov r3, #0x0 - mov r5, #0x0 -._343: - lsl r0, r5, #0x1 - add r0, r0, sp - mov r1, #0x0 - ldsh r0, [r0, r1] - cmp r0, #0x2 - bne ._342 @cond_branch - add r0, r3, #1 - lsl r0, r0, #0x18 - lsr r3, r0, #0x18 -._342: - add r0, r5, #1 - lsl r0, r0, #0x18 - lsr r5, r0, #0x18 - cmp r5, #0x4 - bls ._343 @cond_branch - cmp r3, #0x3 - beq ._345 @cond_branch - cmp r2, #0x5 - beq ._345 @cond_branch - mov r4, r8 - cmp r4, #0x4 - bne ._346 @cond_branch -._345: - ldr r1, ._348 @ ContestStatsText_BlackPokeBlock - add r0, r6, #0 - bl StringCopy - mov r0, #0xc - b ._400 -._349: - .align 2, 0 -._348: - .word ContestStatsText_BlackPokeBlock -._346: - cmp r7, #0x3 - bne ._350 @cond_branch - ldr r1, ._352 @ ContestStatsText_GrayPokeBlock - add r0, r6, #0 - bl StringCopy - mov r0, #0xb - b ._400 -._353: - .align 2, 0 -._352: - .word ContestStatsText_GrayPokeBlock -._350: - cmp r7, #0x2 - beq ._354 @cond_branch - mov r0, r8 - cmp r0, #0x2 - bne ._377 @cond_branch -._354: - mov r3, #0x6 - mov r2, #0x0 - mov r5, #0x0 -._359: - lsl r0, r5, #0x1 - add r0, r0, sp - mov r1, #0x0 - ldsh r0, [r0, r1] - cmp r0, #0 - beq ._358 @cond_branch - cmp r3, #0x6 - bne ._357 @cond_branch - add r3, r5, #0 - b ._358 -._357: - add r2, r5, #0 -._358: - add r0, r5, #1 - lsl r0, r0, #0x18 - lsr r5, r0, #0x18 - cmp r5, #0x4 - bls ._359 @cond_branch - lsl r0, r3, #0x1 - mov r4, sp - add r1, r4, r0 - lsl r0, r2, #0x1 - add r0, r0, sp - mov r4, #0x0 - ldsh r1, [r1, r4] - mov r4, #0x0 - ldsh r0, [r0, r4] - cmp r1, r0 - blt ._360 @cond_branch - add r2, r3, #0 -._360: - cmp r2, #0 - bne ._361 @cond_branch - ldr r1, ._363 @ ContestStatsText_PurplePokeBlock - add r0, r6, #0 - bl StringCopy - mov r0, #0x6 - b ._400 -._364: - .align 2, 0 -._363: - .word ContestStatsText_PurplePokeBlock -._361: - cmp r2, #0x1 - bne ._365 @cond_branch - ldr r1, ._367 @ ContestStatsText_IndigoPokeBlock - add r0, r6, #0 - bl StringCopy - mov r0, #0x7 - b ._400 -._368: - .align 2, 0 -._367: - .word ContestStatsText_IndigoPokeBlock -._365: - cmp r2, #0x2 - bne ._369 @cond_branch - ldr r1, ._371 @ ContestStatsText_BrownPokeBlock - add r0, r6, #0 - bl StringCopy - mov r0, #0x8 - b ._400 -._372: - .align 2, 0 -._371: - .word ContestStatsText_BrownPokeBlock -._369: - cmp r2, #0x3 - bne ._373 @cond_branch - ldr r1, ._375 @ ContestStatsText_LiteBluePokeBlock - add r0, r6, #0 - bl StringCopy - mov r0, #0x9 - b ._400 -._376: - .align 2, 0 -._375: - .word ContestStatsText_LiteBluePokeBlock -._373: - cmp r2, #0x4 - bne ._377 @cond_branch - ldr r1, ._379 @ ContestStatsText_OlivePokeBlock - add r0, r6, #0 - bl StringCopy - mov r0, #0xa - b ._400 -._380: - .align 2, 0 -._379: - .word ContestStatsText_OlivePokeBlock -._377: - cmp r7, #0x1 - beq ._381 @cond_branch - mov r0, r8 - cmp r0, #0x1 - bne ._399 @cond_branch -._381: - mov r0, sp - mov r1, #0x0 - ldsh r0, [r0, r1] - cmp r0, #0 - beq ._383 @cond_branch - ldr r1, ._385 @ ContestStatsText_RedPokeBlock - add r0, r6, #0 - bl StringCopy - mov r0, #0x1 - b ._400 -._386: - .align 2, 0 -._385: - .word ContestStatsText_RedPokeBlock -._383: - mov r0, sp - ldrh r0, [r0, #0x2] - cmp r0, #0 - beq ._387 @cond_branch - ldr r1, ._389 @ ContestStatsText_BluePokeBlock - add r0, r6, #0 - bl StringCopy - mov r0, #0x2 - b ._400 -._390: - .align 2, 0 -._389: - .word ContestStatsText_BluePokeBlock -._387: - mov r0, sp - mov r4, #0x4 - ldsh r0, [r0, r4] - cmp r0, #0 - beq ._391 @cond_branch - ldr r1, ._393 @ ContestStatsText_PinkPokeBlock - add r0, r6, #0 - bl StringCopy - mov r0, #0x3 - b ._400 -._394: - .align 2, 0 -._393: - .word ContestStatsText_PinkPokeBlock -._391: - mov r0, sp - mov r1, #0x6 - ldsh r0, [r0, r1] - cmp r0, #0 - beq ._395 @cond_branch - ldr r1, ._397 @ ContestStatsText_GreenPokeBlock - add r0, r6, #0 - bl StringCopy - mov r0, #0x4 - b ._400 -._398: - .align 2, 0 -._397: - .word ContestStatsText_GreenPokeBlock -._395: - mov r0, sp - mov r4, #0x8 - ldsh r0, [r0, r4] - cmp r0, #0 - beq ._399 @cond_branch - ldr r1, ._401 @ ContestStatsText_YellowPokeBlock - add r0, r6, #0 - bl StringCopy - mov r0, #0x5 - b ._400 -._402: - .align 2, 0 -._401: - .word ContestStatsText_YellowPokeBlock -._399: - ldr r1, ._403 @ gOtherText_FiveQuestions - add r0, r6, #0 - bl StringCopy - mov r0, #0x0 -._400: - add sp, sp, #0x10 - pop {r3, r4} - mov r8, r3 - mov r9, r4 - pop {r4, r5, r6, r7} - pop {r1} - bx r1 -._404: - .align 2, 0 -._403: - .word gOtherText_FiveQuestions - - thumb_func_end debug_sub_8160714 - thumb_func_start debug_sub_816097C debug_sub_816097C: push {r4, r5, r6, r7, lr} diff --git a/src/debug/nakamura_debug_menu.c b/src/debug/nakamura_debug_menu.c index 1b640f7bb..b1da30b27 100644 --- a/src/debug/nakamura_debug_menu.c +++ b/src/debug/nakamura_debug_menu.c @@ -23,6 +23,7 @@ #include "wild_encounter.h" #include "menu.h" #include "menu_helpers.h" +#include "pokeblock.h" typedef bool8 (*MenuFunc)(void); @@ -63,7 +64,7 @@ void debug_sub_81600D0(u8); void debug_sub_816013C(u8); void debug_sub_81603B8(u8); bool8 debug_sub_8160498(void); -void debug_sub_816062C(u8); +u8 debug_sub_816062C(u8); bool8 debug_sub_8160D98(void); const u8 Str_843E36C[] = _("Berries"); @@ -943,7 +944,7 @@ void debug_sub_81601C8(u8 i, s8 dirn) _nakamuraStatic0[i].species -= SPECIES_CHIMECHO; if (_nakamuraStatic0[i].species < 0) _nakamuraStatic0[i].species += SPECIES_CHIMECHO; - CreateMon(gPlayerParty + i, _nakamuraStatic0[i].species, _nakamuraStatic0[i].level, 0x20, 0, 0, 0, 0); + CreateMon(gPlayerParty + i, _nakamuraStatic0[i].species, _nakamuraStatic0[i].level, 0x20, FALSE, 0, FALSE, 0); _nakamuraStatic0[i].unk3 = 1; } @@ -988,7 +989,7 @@ void debug_sub_8160308(void) CalculatePlayerPartyCount(); if (gPlayerPartyCount == 0) { - CreateMon(gPlayerParty + 0, SPECIES_BULBASAUR, 10, 0x20, 0, 0, 0, 0); + CreateMon(gPlayerParty + 0, SPECIES_BULBASAUR, 10, 0x20, FALSE, 0, FALSE, 0); gPlayerPartyCount = 1; } } @@ -1123,4 +1124,552 @@ bool8 debug_sub_8160498(void) return FALSE; } +u8 debug_sub_816062C(u8 i) +{ + u16 species = GetMonData(gPlayerParty + i, MON_DATA_SPECIES); + u8 gender = GetMonGender(gPlayerParty + i); + u8 ratio = gBaseStats[species].genderRatio; + u32 personality; + + if (ratio == MON_MALE || ratio == MON_FEMALE || ratio == MON_GENDERLESS) + return GetMonGender(gPlayerParty + i); + + switch (gender) + { + default: + return MON_MALE; + case MON_MALE: + ratio = MON_FEMALE; + break; + case MON_FEMALE: + ratio = MON_MALE; + break; + } + + do + { + personality = Random(); + personality |= (Random() << 16); + } while (GetGenderFromSpeciesAndPersonality(species, personality) != ratio); + + GetMonData(gPlayerParty + i, MON_DATA_IVS); + CreateMon(gPlayerParty + i, _nakamuraStatic0[i].species, _nakamuraStatic0[i].level, 0x20, TRUE, personality, FALSE, 0); + return ratio; +} + +#ifdef NONMATCHING +u8 debug_sub_8160714(u8 * dest, struct Pokeblock * pokeblock) +{ + u8 numGoodFlavors = 0; + u8 numBadFlavors = 0; + u8 numNeutralFlavors = 0; + u8 i; + u8 numLowFlavors; + s16 pkblk[6]; + + for (i = 0; i < 6; i++) + { + pkblk[i] = GetPokeblockData(pokeblock, i + PBLOCK_SPICY); + if (i != PBLOCK_FEEL - 1) + { + if (pkblk[i] > 0) + numGoodFlavors++; + if (pkblk[i] < 0) + numBadFlavors++; + if (pkblk[i] == 0) + numNeutralFlavors++; + } + } + + if (pkblk[0] >= 50) + { + StringCopy(dest, ContestStatsText_GoldPokeBlock); + return PBLOCK_CLR_GOLD; + } + + if (pkblk[1] >= 50) + { + StringCopy(dest, ContestStatsText_GoldPokeBlock); + return PBLOCK_CLR_GOLD; + } + + if (pkblk[2] >= 50) + { + StringCopy(dest, ContestStatsText_GoldPokeBlock); + return PBLOCK_CLR_GOLD; + } + + if (pkblk[3] >= 50) + { + StringCopy(dest, ContestStatsText_GoldPokeBlock); + return PBLOCK_CLR_GOLD; + } + + if (pkblk[4] >= 50) + { + StringCopy(dest, ContestStatsText_GoldPokeBlock); + return PBLOCK_CLR_GOLD; + } + + if (numGoodFlavors == 4) + { + StringCopy(dest, ContestStatsText_WhitePokeBlock); + return PBLOCK_CLR_WHITE; + } + + numLowFlavors = 0; + for (i = 0; i < 5; i++) + { + if (pkblk[i] == 2) + numLowFlavors++; + } + if (numLowFlavors == 3 || numNeutralFlavors == 5 || numBadFlavors == 4) + { + StringCopy(dest, ContestStatsText_BlackPokeBlock); + return PBLOCK_CLR_BLACK; + } + + if (numGoodFlavors == 3) + { + StringCopy(dest, ContestStatsText_GrayPokeBlock); + return PBLOCK_CLR_GRAY; + } + + if (numGoodFlavors == 2 || numBadFlavors == 2) + { + u8 firstNonzeroFlavor = 6; + u8 lastNonzeroFlavor = 0; + for (i = 0; i < 5; i++) + { + if (pkblk[i] != 0) + { + if (firstNonzeroFlavor == 6) + firstNonzeroFlavor = i; + else + lastNonzeroFlavor = i; + } + } + if (pkblk[firstNonzeroFlavor] >= pkblk[lastNonzeroFlavor]) + lastNonzeroFlavor = firstNonzeroFlavor; + + if (lastNonzeroFlavor == 0) + { + StringCopy(dest, ContestStatsText_PurplePokeBlock); + return PBLOCK_CLR_PURPLE; + } + + if (lastNonzeroFlavor == 1) + { + StringCopy(dest, ContestStatsText_IndigoPokeBlock); + return PBLOCK_CLR_INDIGO; + } + + if (lastNonzeroFlavor == 2) + { + StringCopy(dest, ContestStatsText_BrownPokeBlock); + return PBLOCK_CLR_BROWN; + } + + if (lastNonzeroFlavor == 3) + { + StringCopy(dest, ContestStatsText_LiteBluePokeBlock); + return PBLOCK_CLR_LITEBLUE; + } + + if (lastNonzeroFlavor == 4) + { + StringCopy(dest, ContestStatsText_OlivePokeBlock); + return PBLOCK_CLR_OLIVE; + } + } + + if (numGoodFlavors == 1 || numBadFlavors == 1) + { + if (pkblk[0] != 0) + { + StringCopy(dest, ContestStatsText_RedPokeBlock); + return PBLOCK_CLR_RED; + } + + if (pkblk[1] != 0) + { + StringCopy(dest, ContestStatsText_BluePokeBlock); + return PBLOCK_CLR_BLUE; + } + + if (pkblk[2] != 0) + { + StringCopy(dest, ContestStatsText_PinkPokeBlock); + return PBLOCK_CLR_PINK; + } + + if (pkblk[3] != 0) + { + StringCopy(dest, ContestStatsText_GreenPokeBlock); + return PBLOCK_CLR_GREEN; + } + + if (pkblk[4] != 0) + { + StringCopy(dest, ContestStatsText_YellowPokeBlock); + return PBLOCK_CLR_YELLOW; + } + } + + StringCopy(dest, gOtherText_FiveQuestions); + return 0; // PBLOCK_CLR_UNKNOWN +} +#else +__attribute__((naked)) +u8 debug_sub_8160714(u8 * dest, struct Pokeblock * pokeblock) +{ + asm("\tpush\t{r4, r5, r6, r7, lr}\n" + "\tmov\tr7, r9\n" + "\tmov\tr6, r8\n" + "\tpush\t{r6, r7}\n" + "\tadd\tsp, sp, #0xfffffff0\n" + "\tadd\tr6, r0, #0\n" + "\tmov\tr9, r1\n" + "\tmov\tr7, #0x0\n" + "\tmov\tr0, #0x0\n" + "\tmov\tr8, r0\n" + "\tmov\tr2, #0x0\n" + "\tmov\tr5, #0x0\n" + "._329:\n" + "\tadd\tr4, r5, #1\n" + "\tlsl\tr1, r4, #0x18\n" + "\tlsr\tr1, r1, #0x18\n" + "\tmov\tr0, r9\n" + "\tstr\tr2, [sp, #0xc]\n" + "\tbl\tGetPokeblockData\n" + "\tadd\tr1, r0, #0\n" + "\tlsl\tr0, r5, #0x1\n" + "\tadd r0, r0, sp\n" + "\tstrh\tr1, [r0]\n" + "\tldr\tr2, [sp, #0xc]\n" + "\tcmp\tr5, #0x5\n" + "\tbeq\t._328\t@cond_branch\n" + "\tlsl\tr0, r1, #0x10\n" + "\tasr\tr1, r0, #0x10\n" + "\tcmp\tr1, #0\n" + "\tble\t._326\t@cond_branch\n" + "\tadd\tr0, r7, #1\n" + "\tlsl\tr0, r0, #0x18\n" + "\tlsr\tr7, r0, #0x18\n" + "._326:\n" + "\tcmp\tr1, #0\n" + "\tbge\t._327\t@cond_branch\n" + "\tmov\tr0, r8\n" + "\tadd\tr0, r0, #0x1\n" + "\tlsl\tr0, r0, #0x18\n" + "\tlsr\tr0, r0, #0x18\n" + "\tmov\tr8, r0\n" + "._327:\n" + "\tcmp\tr1, #0\n" + "\tbne\t._328\t@cond_branch\n" + "\tadd\tr0, r2, #1\n" + "\tlsl\tr0, r0, #0x18\n" + "\tlsr\tr2, r0, #0x18\n" + "._328:\n" + "\tlsl\tr0, r4, #0x18\n" + "\tlsr\tr5, r0, #0x18\n" + "\tcmp\tr5, #0x5\n" + "\tbls\t._329\t@cond_branch\n" + "\tmov\tr0, sp\n" + "\tmov\tr1, #0x0\n" + "\tldsh\tr0, [r0, r1]\n" + "\tcmp\tr0, #0x31\n" + "\tbgt\t._333\t@cond_branch\n" + "\tmov\tr0, sp\n" + "\tldrh\tr0, [r0, #0x2]\n" + "\tlsl\tr0, r0, #0x10\n" + "\tasr\tr0, r0, #0x10\n" + "\tcmp\tr0, #0x31\n" + "\tbgt\t._333\t@cond_branch\n" + "\tmov\tr0, sp\n" + "\tmov\tr4, #0x4\n" + "\tldsh\tr0, [r0, r4]\n" + "\tcmp\tr0, #0x31\n" + "\tbgt\t._333\t@cond_branch\n" + "\tmov\tr0, sp\n" + "\tmov\tr1, #0x6\n" + "\tldsh\tr0, [r0, r1]\n" + "\tcmp\tr0, #0x31\n" + "\tbgt\t._333\t@cond_branch\n" + "\tmov\tr0, sp\n" + "\tmov\tr4, #0x8\n" + "\tldsh\tr0, [r0, r4]\n" + "\tcmp\tr0, #0x31\n" + "\tble\t._334\t@cond_branch\n" + "._333:\n" + "\tldr\tr1, ._336 @ ContestStatsText_GoldPokeBlock\n" + "\tadd\tr0, r6, #0\n" + "\tbl\tStringCopy\n" + "\tmov\tr0, #0xe\n" + "\tb\t._400\n" + "._337:\n" + "\t.align\t2, 0\n" + "._336:\n" + "\t.word\tContestStatsText_GoldPokeBlock\n" + "._334:\n" + "\tcmp\tr7, #0x4\n" + "\tbne\t._338\t@cond_branch\n" + "\tldr\tr1, ._340 @ ContestStatsText_WhitePokeBlock\n" + "\tadd\tr0, r6, #0\n" + "\tbl\tStringCopy\n" + "\tmov\tr0, #0xd\n" + "\tb\t._400\n" + "._341:\n" + "\t.align\t2, 0\n" + "._340:\n" + "\t.word\tContestStatsText_WhitePokeBlock\n" + "._338:\n" + "\tmov\tr3, #0x0\n" + "\tmov\tr5, #0x0\n" + "._343:\n" + "\tlsl\tr0, r5, #0x1\n" + "\tadd r0, r0, sp\n" + "\tmov\tr1, #0x0\n" + "\tldsh\tr0, [r0, r1]\n" + "\tcmp\tr0, #0x2\n" + "\tbne\t._342\t@cond_branch\n" + "\tadd\tr0, r3, #1\n" + "\tlsl\tr0, r0, #0x18\n" + "\tlsr\tr3, r0, #0x18\n" + "._342:\n" + "\tadd\tr0, r5, #1\n" + "\tlsl\tr0, r0, #0x18\n" + "\tlsr\tr5, r0, #0x18\n" + "\tcmp\tr5, #0x4\n" + "\tbls\t._343\t@cond_branch\n" + "\tcmp\tr3, #0x3\n" + "\tbeq\t._345\t@cond_branch\n" + "\tcmp\tr2, #0x5\n" + "\tbeq\t._345\t@cond_branch\n" + "\tmov\tr4, r8\n" + "\tcmp\tr4, #0x4\n" + "\tbne\t._346\t@cond_branch\n" + "._345:\n" + "\tldr\tr1, ._348 @ ContestStatsText_BlackPokeBlock\n" + "\tadd\tr0, r6, #0\n" + "\tbl\tStringCopy\n" + "\tmov\tr0, #0xc\n" + "\tb\t._400\n" + "._349:\n" + "\t.align\t2, 0\n" + "._348:\n" + "\t.word\tContestStatsText_BlackPokeBlock\n" + "._346:\n" + "\tcmp\tr7, #0x3\n" + "\tbne\t._350\t@cond_branch\n" + "\tldr\tr1, ._352 @ ContestStatsText_GrayPokeBlock\n" + "\tadd\tr0, r6, #0\n" + "\tbl\tStringCopy\n" + "\tmov\tr0, #0xb\n" + "\tb\t._400\n" + "._353:\n" + "\t.align\t2, 0\n" + "._352:\n" + "\t.word\tContestStatsText_GrayPokeBlock\n" + "._350:\n" + "\tcmp\tr7, #0x2\n" + "\tbeq\t._354\t@cond_branch\n" + "\tmov\tr0, r8\n" + "\tcmp\tr0, #0x2\n" + "\tbne\t._377\t@cond_branch\n" + "._354:\n" + "\tmov\tr3, #0x6\n" + "\tmov\tr2, #0x0\n" + "\tmov\tr5, #0x0\n" + "._359:\n" + "\tlsl\tr0, r5, #0x1\n" + "\tadd r0, r0, sp\n" + "\tmov\tr1, #0x0\n" + "\tldsh\tr0, [r0, r1]\n" + "\tcmp\tr0, #0\n" + "\tbeq\t._358\t@cond_branch\n" + "\tcmp\tr3, #0x6\n" + "\tbne\t._357\t@cond_branch\n" + "\tadd\tr3, r5, #0\n" + "\tb\t._358\n" + "._357:\n" + "\tadd\tr2, r5, #0\n" + "._358:\n" + "\tadd\tr0, r5, #1\n" + "\tlsl\tr0, r0, #0x18\n" + "\tlsr\tr5, r0, #0x18\n" + "\tcmp\tr5, #0x4\n" + "\tbls\t._359\t@cond_branch\n" + "\tlsl\tr0, r3, #0x1\n" + "\tmov\tr4, sp\n" + "\tadd\tr1, r4, r0\n" + "\tlsl\tr0, r2, #0x1\n" + "\tadd r0, r0, sp\n" + "\tmov\tr4, #0x0\n" + "\tldsh\tr1, [r1, r4]\n" + "\tmov\tr4, #0x0\n" + "\tldsh\tr0, [r0, r4]\n" + "\tcmp\tr1, r0\n" + "\tblt\t._360\t@cond_branch\n" + "\tadd\tr2, r3, #0\n" + "._360:\n" + "\tcmp\tr2, #0\n" + "\tbne\t._361\t@cond_branch\n" + "\tldr\tr1, ._363 @ ContestStatsText_PurplePokeBlock\n" + "\tadd\tr0, r6, #0\n" + "\tbl\tStringCopy\n" + "\tmov\tr0, #0x6\n" + "\tb\t._400\n" + "._364:\n" + "\t.align\t2, 0\n" + "._363:\n" + "\t.word\tContestStatsText_PurplePokeBlock\n" + "._361:\n" + "\tcmp\tr2, #0x1\n" + "\tbne\t._365\t@cond_branch\n" + "\tldr\tr1, ._367 @ ContestStatsText_IndigoPokeBlock\n" + "\tadd\tr0, r6, #0\n" + "\tbl\tStringCopy\n" + "\tmov\tr0, #0x7\n" + "\tb\t._400\n" + "._368:\n" + "\t.align\t2, 0\n" + "._367:\n" + "\t.word\tContestStatsText_IndigoPokeBlock\n" + "._365:\n" + "\tcmp\tr2, #0x2\n" + "\tbne\t._369\t@cond_branch\n" + "\tldr\tr1, ._371 @ ContestStatsText_BrownPokeBlock\n" + "\tadd\tr0, r6, #0\n" + "\tbl\tStringCopy\n" + "\tmov\tr0, #0x8\n" + "\tb\t._400\n" + "._372:\n" + "\t.align\t2, 0\n" + "._371:\n" + "\t.word\tContestStatsText_BrownPokeBlock\n" + "._369:\n" + "\tcmp\tr2, #0x3\n" + "\tbne\t._373\t@cond_branch\n" + "\tldr\tr1, ._375 @ ContestStatsText_LiteBluePokeBlock\n" + "\tadd\tr0, r6, #0\n" + "\tbl\tStringCopy\n" + "\tmov\tr0, #0x9\n" + "\tb\t._400\n" + "._376:\n" + "\t.align\t2, 0\n" + "._375:\n" + "\t.word\tContestStatsText_LiteBluePokeBlock\n" + "._373:\n" + "\tcmp\tr2, #0x4\n" + "\tbne\t._377\t@cond_branch\n" + "\tldr\tr1, ._379 @ ContestStatsText_OlivePokeBlock\n" + "\tadd\tr0, r6, #0\n" + "\tbl\tStringCopy\n" + "\tmov\tr0, #0xa\n" + "\tb\t._400\n" + "._380:\n" + "\t.align\t2, 0\n" + "._379:\n" + "\t.word\tContestStatsText_OlivePokeBlock\n" + "._377:\n" + "\tcmp\tr7, #0x1\n" + "\tbeq\t._381\t@cond_branch\n" + "\tmov\tr0, r8\n" + "\tcmp\tr0, #0x1\n" + "\tbne\t._399\t@cond_branch\n" + "._381:\n" + "\tmov\tr0, sp\n" + "\tmov\tr1, #0x0\n" + "\tldsh\tr0, [r0, r1]\n" + "\tcmp\tr0, #0\n" + "\tbeq\t._383\t@cond_branch\n" + "\tldr\tr1, ._385 @ ContestStatsText_RedPokeBlock\n" + "\tadd\tr0, r6, #0\n" + "\tbl\tStringCopy\n" + "\tmov\tr0, #0x1\n" + "\tb\t._400\n" + "._386:\n" + "\t.align\t2, 0\n" + "._385:\n" + "\t.word\tContestStatsText_RedPokeBlock\n" + "._383:\n" + "\tmov\tr0, sp\n" + "\tldrh\tr0, [r0, #0x2]\n" + "\tcmp\tr0, #0\n" + "\tbeq\t._387\t@cond_branch\n" + "\tldr\tr1, ._389 @ ContestStatsText_BluePokeBlock\n" + "\tadd\tr0, r6, #0\n" + "\tbl\tStringCopy\n" + "\tmov\tr0, #0x2\n" + "\tb\t._400\n" + "._390:\n" + "\t.align\t2, 0\n" + "._389:\n" + "\t.word\tContestStatsText_BluePokeBlock\n" + "._387:\n" + "\tmov\tr0, sp\n" + "\tmov\tr4, #0x4\n" + "\tldsh\tr0, [r0, r4]\n" + "\tcmp\tr0, #0\n" + "\tbeq\t._391\t@cond_branch\n" + "\tldr\tr1, ._393 @ ContestStatsText_PinkPokeBlock\n" + "\tadd\tr0, r6, #0\n" + "\tbl\tStringCopy\n" + "\tmov\tr0, #0x3\n" + "\tb\t._400\n" + "._394:\n" + "\t.align\t2, 0\n" + "._393:\n" + "\t.word\tContestStatsText_PinkPokeBlock\n" + "._391:\n" + "\tmov\tr0, sp\n" + "\tmov\tr1, #0x6\n" + "\tldsh\tr0, [r0, r1]\n" + "\tcmp\tr0, #0\n" + "\tbeq\t._395\t@cond_branch\n" + "\tldr\tr1, ._397 @ ContestStatsText_GreenPokeBlock\n" + "\tadd\tr0, r6, #0\n" + "\tbl\tStringCopy\n" + "\tmov\tr0, #0x4\n" + "\tb\t._400\n" + "._398:\n" + "\t.align\t2, 0\n" + "._397:\n" + "\t.word\tContestStatsText_GreenPokeBlock\n" + "._395:\n" + "\tmov\tr0, sp\n" + "\tmov\tr4, #0x8\n" + "\tldsh\tr0, [r0, r4]\n" + "\tcmp\tr0, #0\n" + "\tbeq\t._399\t@cond_branch\n" + "\tldr\tr1, ._401 @ ContestStatsText_YellowPokeBlock\n" + "\tadd\tr0, r6, #0\n" + "\tbl\tStringCopy\n" + "\tmov\tr0, #0x5\n" + "\tb\t._400\n" + "._402:\n" + "\t.align\t2, 0\n" + "._401:\n" + "\t.word\tContestStatsText_YellowPokeBlock\n" + "._399:\n" + "\tldr\tr1, ._403 @ gOtherText_FiveQuestions\n" + "\tadd\tr0, r6, #0\n" + "\tbl\tStringCopy\n" + "\tmov\tr0, #0x0\n" + "._400:\n" + "\tadd\tsp, sp, #0x10\n" + "\tpop\t{r3, r4}\n" + "\tmov\tr8, r3\n" + "\tmov\tr9, r4\n" + "\tpop\t{r4, r5, r6, r7}\n" + "\tpop\t{r1}\n" + "\tbx\tr1\n" + "._404:\n" + "\t.align\t2, 0\n" + "._403:\n" + "\t.word\tgOtherText_FiveQuestions"); +} +#endif // NONMATCHING + #endif // DEBUG -- cgit v1.2.3 From a33981df888b712db43d5aeb3d1c332810a67353 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 2 Apr 2018 20:44:32 -0400 Subject: through debug_sub_8160C7C --- asm/nakamura_debug_menu.s | 476 ---------------------------------------- include/strings.h | 1 + src/debug/nakamura_debug_menu.c | 173 ++++++++++++++- 3 files changed, 171 insertions(+), 479 deletions(-) diff --git a/asm/nakamura_debug_menu.s b/asm/nakamura_debug_menu.s index ad3af7e84..6f86ee268 100644 --- a/asm/nakamura_debug_menu.s +++ b/asm/nakamura_debug_menu.s @@ -5,482 +5,6 @@ .text - thumb_func_start debug_sub_816097C -debug_sub_816097C: - push {r4, r5, r6, r7, lr} - mov r7, r8 - push {r7} - add r7, r0, #0 - lsl r1, r1, #0x10 - lsr r5, r1, #0x10 - mov r6, #0x0 - mov r1, #0x0 -._405: - add r0, r7, r6 - strb r1, [r0] - add r0, r6, #1 - lsl r0, r0, #0x18 - lsr r6, r0, #0x18 - cmp r6, #0x3 - bls ._405 @cond_branch - mov r0, #0xff - strb r0, [r7, #0x4] - lsl r0, r5, #0x10 - asr r0, r0, #0x10 - cmp r0, #0 - bne ._406 @cond_branch - mov r0, #0xa1 - strb r0, [r7, #0x3] - b ._414 -._406: - cmp r0, #0 - ble ._408 @cond_branch - mov r4, #0x64 - mov r0, #0x0 - mov r8, r0 - mov r6, #0x0 -._412: - lsl r5, r5, #0x10 - asr r0, r5, #0x10 - lsl r4, r4, #0x10 - asr r1, r4, #0x10 - bl __divsi3 - lsl r0, r0, #0x10 - lsr r2, r0, #0x10 - mov r1, r8 - cmp r1, #0 - bne ._410 @cond_branch - cmp r6, #0x2 - beq ._410 @cond_branch - cmp r2, #0 - beq ._411 @cond_branch -._410: - add r1, r6, r7 - add r0, r2, #0 - sub r0, r0, #0x5f - strb r0, [r1, #0x1] - mov r0, #0x1 - mov r8, r0 -._411: - asr r0, r5, #0x10 - asr r4, r4, #0x10 - add r1, r4, #0 - bl __modsi3 - lsl r0, r0, #0x10 - lsr r5, r0, #0x10 - add r0, r4, #0 - mov r1, #0xa - bl __divsi3 - lsl r0, r0, #0x10 - lsr r4, r0, #0x10 - add r0, r6, #1 - lsl r0, r0, #0x18 - lsr r6, r0, #0x18 - cmp r6, #0x2 - bls ._412 @cond_branch - b ._414 -._408: - cmp r0, #0 - bge ._414 @cond_branch - neg r0, r0 - lsl r0, r0, #0x10 - lsr r5, r0, #0x10 - mov r4, #0x64 - mov r1, #0x0 - mov r8, r1 - mov r6, #0x0 -._419: - lsl r5, r5, #0x10 - asr r0, r5, #0x10 - lsl r4, r4, #0x10 - asr r1, r4, #0x10 - bl __divsi3 - lsl r0, r0, #0x10 - lsr r2, r0, #0x10 - mov r1, r8 - lsl r0, r1, #0x10 - add r3, r0, #0 - cmp r3, #0 - bne ._416 @cond_branch - cmp r6, #0x2 - beq ._416 @cond_branch - cmp r2, #0 - beq ._417 @cond_branch -._416: - add r1, r6, r7 - add r0, r2, #0 - sub r0, r0, #0x5f - strb r0, [r1, #0x1] - cmp r3, #0 - bne ._418 @cond_branch - mov r0, #0xae - strb r0, [r1] -._418: - mov r0, #0x1 - mov r8, r0 -._417: - asr r0, r5, #0x10 - asr r4, r4, #0x10 - add r1, r4, #0 - bl __modsi3 - lsl r0, r0, #0x10 - lsr r5, r0, #0x10 - add r0, r4, #0 - mov r1, #0xa - bl __divsi3 - lsl r0, r0, #0x10 - lsr r4, r0, #0x10 - add r0, r6, #1 - lsl r0, r0, #0x18 - lsr r6, r0, #0x18 - cmp r6, #0x2 - bls ._419 @cond_branch -._414: - pop {r3} - mov r8, r3 - pop {r4, r5, r6, r7} - pop {r0} - bx r0 - - thumb_func_end debug_sub_816097C - - thumb_func_start debug_sub_8160A80 -debug_sub_8160A80: - push {r4, lr} - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - add r2, r0, #0 - ldr r1, ._422 @ _nakamuraStatic18 - cmp r0, #0 - bne ._420 @cond_branch - ldr r4, ._422 + 4 @ gStringVar1 - ldrb r1, [r1, #0x1] - add r0, r4, #0 - bl debug_sub_816097C - add r0, r4, #0 - mov r1, #0x8 - mov r2, #0x3 - bl Menu_PrintText - b ._440 -._423: - .align 2, 0 -._422: - .word _nakamuraStatic18 - .word gStringVar1 -._420: - cmp r0, #0x1 - bne ._424 @cond_branch - ldr r4, ._426 @ gStringVar1 - ldrb r1, [r1, #0x2] - add r0, r4, #0 - bl debug_sub_816097C - add r0, r4, #0 - mov r1, #0x8 - mov r2, #0x5 - bl Menu_PrintText - b ._440 -._427: - .align 2, 0 -._426: - .word gStringVar1 -._424: - cmp r0, #0x2 - bne ._428 @cond_branch - ldr r4, ._430 @ gStringVar1 - ldrb r1, [r1, #0x3] - add r0, r4, #0 - bl debug_sub_816097C - add r0, r4, #0 - mov r1, #0x8 - mov r2, #0x7 - bl Menu_PrintText - b ._440 -._431: - .align 2, 0 -._430: - .word gStringVar1 -._428: - cmp r0, #0x3 - bne ._432 @cond_branch - ldr r4, ._434 @ gStringVar1 - ldrb r1, [r1, #0x4] - add r0, r4, #0 - bl debug_sub_816097C - add r0, r4, #0 - mov r1, #0x8 - mov r2, #0x9 - bl Menu_PrintText - b ._440 -._435: - .align 2, 0 -._434: - .word gStringVar1 -._432: - cmp r0, #0x4 - bne ._436 @cond_branch - ldr r4, ._438 @ gStringVar1 - ldrb r1, [r1, #0x5] - add r0, r4, #0 - bl debug_sub_816097C - add r0, r4, #0 - mov r1, #0x8 - mov r2, #0xb - bl Menu_PrintText - b ._440 -._439: - .align 2, 0 -._438: - .word gStringVar1 -._436: - cmp r2, #0x5 - bne ._440 @cond_branch - ldr r4, ._441 @ gStringVar1 - ldrb r1, [r1, #0x6] - add r0, r4, #0 - bl debug_sub_816097C - add r0, r4, #0 - mov r1, #0x8 - mov r2, #0xd - bl Menu_PrintText -._440: - pop {r4} - pop {r0} - bx r0 -._442: - .align 2, 0 -._441: - .word gStringVar1 - - thumb_func_end debug_sub_8160A80 - - thumb_func_start debug_sub_8160B50 -debug_sub_8160B50: - push {r4, lr} - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - add r3, r0, #0 - lsl r1, r1, #0x18 - lsr r1, r1, #0x18 - add r4, r1, #0 - ldr r2, ._445 @ _nakamuraStatic18 - cmp r0, #0 - bne ._443 @cond_branch - ldrb r0, [r2, #0x1] - add r0, r0, r1 - strb r0, [r2, #0x1] - b ._455 -._446: - .align 2, 0 -._445: - .word _nakamuraStatic18 -._443: - cmp r0, #0x1 - bne ._447 @cond_branch - ldrb r0, [r2, #0x2] - add r0, r0, r1 - strb r0, [r2, #0x2] - b ._455 -._447: - cmp r0, #0x2 - bne ._449 @cond_branch - ldrb r0, [r2, #0x3] - add r0, r0, r1 - strb r0, [r2, #0x3] - b ._455 -._449: - cmp r0, #0x3 - bne ._451 @cond_branch - ldrb r0, [r2, #0x4] - add r0, r0, r1 - strb r0, [r2, #0x4] - b ._455 -._451: - cmp r0, #0x4 - bne ._453 @cond_branch - ldrb r0, [r2, #0x5] - add r0, r0, r1 - strb r0, [r2, #0x5] - b ._455 -._453: - cmp r3, #0x5 - bne ._455 @cond_branch - ldrb r0, [r2, #0x6] - add r0, r0, r4 - strb r0, [r2, #0x6] -._455: - pop {r4} - pop {r0} - bx r0 - - thumb_func_end debug_sub_8160B50 - - thumb_func_start debug_sub_8160BB0 -debug_sub_8160BB0: - push {r4, r5, lr} - ldr r5, ._456 @ gStringVar1 - ldr r4, ._456 + 4 @ _nakamuraStatic18 - add r0, r5, #0 - add r1, r4, #0 - bl debug_sub_8160714 - strb r0, [r4] - mov r0, #0x1 - mov r1, #0x1 - mov r2, #0x8 - mov r3, #0x2 - bl Menu_BlankWindowRect - add r0, r5, #0 - mov r1, #0x1 - mov r2, #0x1 - bl Menu_PrintText - pop {r4, r5} - pop {r0} - bx r0 -._457: - .align 2, 0 -._456: - .word gStringVar1 - .word _nakamuraStatic18 - - thumb_func_end debug_sub_8160BB0 - - thumb_func_start debug_sub_8160BE4 -debug_sub_8160BE4: - push {r4, lr} - add sp, sp, #0xfffffff8 - mov r0, #0x0 - mov r1, #0x0 - mov r2, #0xc - mov r3, #0xf - bl Menu_DrawStdWindowFrame - bl debug_sub_8160BB0 - ldr r0, ._459 @ gContestStatsText_Spicy - mov r1, #0x2 - mov r2, #0x3 - bl Menu_PrintText - ldr r0, ._459 + 4 @ gContestStatsText_Dry - mov r1, #0x2 - mov r2, #0x5 - bl Menu_PrintText - ldr r0, ._459 + 8 @ gContestStatsText_Sweet - mov r1, #0x2 - mov r2, #0x7 - bl Menu_PrintText - ldr r0, ._459 + 12 @ gContestStatsText_Bitter - mov r1, #0x2 - mov r2, #0x9 - bl Menu_PrintText - ldr r0, ._459 + 16 @ gContestStatsText_Sour - mov r1, #0x2 - mov r2, #0xb - bl Menu_PrintText - ldr r0, ._459 + 20 @ gContestStatsText_Tasty - mov r1, #0x2 - mov r2, #0xd - bl Menu_PrintText - mov r4, #0x0 -._458: - add r0, r4, #0 - bl debug_sub_8160A80 - add r0, r4, #1 - lsl r0, r0, #0x18 - lsr r4, r0, #0x18 - cmp r4, #0x5 - bls ._458 @cond_branch - mov r0, #0x0 - str r0, [sp] - mov r0, #0xb - str r0, [sp, #0x4] - mov r0, #0x0 - mov r1, #0x1 - mov r2, #0x3 - mov r3, #0x6 - bl InitMenu - add sp, sp, #0x8 - pop {r4} - pop {r0} - bx r0 -._460: - .align 2, 0 -._459: - .word gContestStatsText_Spicy - .word gContestStatsText_Dry - .word gContestStatsText_Sweet - .word gContestStatsText_Bitter - .word gContestStatsText_Sour - .word gContestStatsText_Tasty - - thumb_func_end debug_sub_8160BE4 - - thumb_func_start debug_sub_8160C7C -debug_sub_8160C7C: - push {r4, lr} - ldr r2, ._469 @ _nakamuraStatic18 - mov r1, #0x0 - ldrb r0, [r2] - cmp r0, #0xc - bne ._467 @cond_branch - ldrb r0, [r2, #0x1] - cmp r0, #0x2 - bne ._462 @cond_branch - mov r1, #0x1 -._462: - ldrb r0, [r2, #0x3] - cmp r0, #0x2 - bne ._463 @cond_branch - add r0, r1, #1 - lsl r0, r0, #0x18 - lsr r1, r0, #0x18 -._463: - ldrb r0, [r2, #0x4] - cmp r0, #0x2 - bne ._464 @cond_branch - add r0, r1, #1 - lsl r0, r0, #0x18 - lsr r1, r0, #0x18 -._464: - ldrb r0, [r2, #0x2] - cmp r0, #0x2 - bne ._465 @cond_branch - add r0, r1, #1 - lsl r0, r0, #0x18 - lsr r1, r0, #0x18 -._465: - ldrb r0, [r2, #0x5] - cmp r0, #0x2 - bne ._466 @cond_branch - add r0, r1, #1 - lsl r0, r0, #0x18 - lsr r1, r0, #0x18 -._466: - cmp r1, #0x3 - beq ._467 @cond_branch - mov r0, #0x2 - strb r0, [r2, #0x1] - strb r0, [r2, #0x3] - strb r0, [r2, #0x4] -._467: - add r0, r2, #0 - bl sub_810CA34 - bl debug_sub_8160BB0 - mov r4, #0x0 -._468: - add r0, r4, #0 - bl debug_sub_8160A80 - add r0, r4, #1 - lsl r0, r0, #0x18 - lsr r4, r0, #0x18 - cmp r4, #0x5 - bls ._468 @cond_branch - pop {r4} - pop {r0} - bx r0 -._470: - .align 2, 0 -._469: - .word _nakamuraStatic18 - - thumb_func_end debug_sub_8160C7C - thumb_func_start debug_sub_8160CF4 debug_sub_8160CF4: push {lr} diff --git a/include/strings.h b/include/strings.h index 91c5c5344..7b97ec6ef 100644 --- a/include/strings.h +++ b/include/strings.h @@ -250,6 +250,7 @@ extern const u8 gContestStatsText_Dry[]; extern const u8 gContestStatsText_Sweet[]; extern const u8 gContestStatsText_Bitter[]; extern const u8 gContestStatsText_Sour[]; +extern const u8 gContestStatsText_Tasty[]; extern const u8 gContestStatsText_StowCase[]; extern const u8 gContestStatsText_ThrowAwayPrompt[]; diff --git a/src/debug/nakamura_debug_menu.c b/src/debug/nakamura_debug_menu.c index b1da30b27..97e1d4678 100644 --- a/src/debug/nakamura_debug_menu.c +++ b/src/debug/nakamura_debug_menu.c @@ -38,13 +38,12 @@ EWRAM_DATA u16 _nakamuraData8 = 0; EWRAM_DATA u16 _nakamuraDataA = 0; EWRAM_DATA u16 _nakamuraDataC = 0; -__attribute__((unused)) static struct { +static struct { s16 species; s8 level; u8 unk3; } _nakamuraStatic0[PARTY_SIZE]; -__attribute__((unused)) static u8 _nakamuraStatic18; -__attribute__((unused)) static u8 gDebugFiller3000814[4]; +static struct Pokeblock _nakamuraStatic18; asm(".global _nakamuraStatic0"); asm(".global _nakamuraStatic18"); @@ -1672,4 +1671,172 @@ u8 debug_sub_8160714(u8 * dest, struct Pokeblock * pokeblock) } #endif // NONMATCHING +void debug_sub_816097C(u8 * buff, s16 a1) +{ + u8 i; + s16 divisor; + s16 quot; + s16 printZero; + + for (i = 0; i < 4; i++) + buff[i] = CHAR_SPACE; + buff[4] = EOS; + + if (a1 == 0) + buff[3] = CHAR_0; + else if (a1 > 0) + { + divisor = 100; + printZero = FALSE; + for (i = 0; i < 3; i++) + { + quot = a1 / divisor; + if (printZero || i == 2 || quot != 0) + { + buff[i + 1] = CHAR_0 + quot; + printZero = TRUE; + } + a1 %= divisor; + divisor /= 10; + } + } + else if (a1 < 0) + { + a1 = -a1; + divisor = 100; + printZero = FALSE; + for (i = 0; i < 3; i++) + { + quot = a1 / divisor; + if (printZero || i == 2 || quot != 0) + { + buff[i + 1] = CHAR_0 + quot; + if (!printZero) + buff[i] = CHAR_HYPHEN; + printZero = TRUE; + } + a1 %= divisor; + divisor /= 10; + } + } +} + +void debug_sub_8160A80(u8 a0) +{ + struct Pokeblock *pkblk = &_nakamuraStatic18; + + if (a0 == 0) + { + debug_sub_816097C(gStringVar1, pkblk->spicy); + Menu_PrintText(gStringVar1, 8, 3); + } + else if (a0 == 1) + { + debug_sub_816097C(gStringVar1, pkblk->dry); + Menu_PrintText(gStringVar1, 8, 5); + } + else if (a0 == 2) + { + debug_sub_816097C(gStringVar1, pkblk->sweet); + Menu_PrintText(gStringVar1, 8, 7); + } + else if (a0 == 3) + { + debug_sub_816097C(gStringVar1, pkblk->bitter); + Menu_PrintText(gStringVar1, 8, 9); + } + else if (a0 == 4) + { + debug_sub_816097C(gStringVar1, pkblk->sour); + Menu_PrintText(gStringVar1, 8, 11); + } + else if (a0 == 5) + { + debug_sub_816097C(gStringVar1, pkblk->feel); + Menu_PrintText(gStringVar1, 8, 13); + } +} + +void debug_sub_8160B50(u8 a0, s8 a1) +{ + struct Pokeblock *pkblk = &_nakamuraStatic18; + + if (a0 == 0) + pkblk->spicy += a1; + else if (a0 == 1) + pkblk->dry += a1; + else if (a0 == 2) + pkblk->sweet += a1; + else if (a0 == 3) + pkblk->bitter += a1; + else if (a0 == 4) + pkblk->sour += a1; + else if (a0 == 5) + pkblk->feel += a1; +} + +void debug_sub_8160BB0(void) +{ + _nakamuraStatic18.color = debug_sub_8160714(gStringVar1, &_nakamuraStatic18); + Menu_BlankWindowRect(1, 1, 8, 2); + Menu_PrintText(gStringVar1, 1, 1); +} + +void debug_sub_8160BE4(void) +{ + u8 i; + + Menu_DrawStdWindowFrame(0, 0, 12, 15); + debug_sub_8160BB0(); + Menu_PrintText(gContestStatsText_Spicy, 2, 3); + Menu_PrintText(gContestStatsText_Dry, 2, 5); + Menu_PrintText(gContestStatsText_Sweet, 2, 7); + Menu_PrintText(gContestStatsText_Bitter, 2, 9); + Menu_PrintText(gContestStatsText_Sour, 2, 11); + Menu_PrintText(gContestStatsText_Tasty, 2, 13); + + for (i = 0; i < 6; i++) + debug_sub_8160A80(i); + + InitMenu(0, 1, 3, 6, 0, 11); +} + +void debug_sub_8160C7C(void) +{ + struct Pokeblock * pkblk = &_nakamuraStatic18; + u8 rval = 0; + u8 i; + + if (pkblk->color == PBLOCK_CLR_BLACK) + { + if (pkblk->spicy == 2) + rval++; + + if (pkblk->sweet == 2) + rval++; + + if (pkblk->bitter == 2) + rval++; + + if (pkblk->dry == 2) + rval++; + + if (pkblk->sour == 2) + rval++; + + if (rval != 3) + { + pkblk->spicy = 2; + pkblk->sweet = 2; + pkblk->bitter = 2; + } + } + + sub_810CA34(pkblk); + debug_sub_8160BB0(); + + for (i = 0; i < 6; i++) + debug_sub_8160A80(i); +} + #endif // DEBUG -- cgit v1.2.3 From baf1430f2449fa79727109c83d39bfbecbdd00c9 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 2 Apr 2018 21:17:15 -0400 Subject: through debug_sub_8161028 --- asm/nakamura_debug_menu.s | 466 ---------------------------------------- include/strings.h | 1 + src/debug/nakamura_debug_menu.c | 159 +++++++++++++- 3 files changed, 159 insertions(+), 467 deletions(-) diff --git a/asm/nakamura_debug_menu.s b/asm/nakamura_debug_menu.s index 6f86ee268..9e4e2975b 100644 --- a/asm/nakamura_debug_menu.s +++ b/asm/nakamura_debug_menu.s @@ -5,472 +5,6 @@ .text - thumb_func_start debug_sub_8160CF4 -debug_sub_8160CF4: - push {lr} - ldr r2, ._473 @ gMain - ldrh r1, [r2, #0x30] - mov r0, #0x40 - and r0, r0, r1 - cmp r0, #0 - beq ._471 @cond_branch - mov r0, #0x1 - neg r0, r0 - b ._472 -._474: - .align 2, 0 -._473: - .word gMain -._471: - mov r0, #0x80 - and r0, r0, r1 - cmp r0, #0 - beq ._475 @cond_branch - mov r0, #0x1 -._472: - bl Menu_MoveCursor - mov r0, #0x0 - b ._484 -._475: - mov r0, #0x20 - and r0, r0, r1 - cmp r0, #0 - beq ._477 @cond_branch - bl Menu_GetCursorPos - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - mov r1, #0x1 - neg r1, r1 - b ._478 -._477: - mov r0, #0x10 - and r0, r0, r1 - cmp r0, #0 - beq ._479 @cond_branch - bl Menu_GetCursorPos - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - mov r1, #0x1 -._478: - bl debug_sub_8160B50 - bl Menu_GetCursorPos - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - bl debug_sub_8160A80 - bl debug_sub_8160BB0 - mov r0, #0x0 - b ._484 -._479: - ldrh r1, [r2, #0x2e] - mov r0, #0x1 - and r0, r0, r1 - cmp r0, #0 - beq ._481 @cond_branch - bl debug_sub_8160C7C - mov r0, #0x5 - bl PlaySE - mov r0, #0x0 - b ._484 -._481: - mov r0, #0x2 - and r0, r0, r1 - cmp r0, #0 - bne ._483 @cond_branch - mov r0, #0x0 - b ._484 -._483: - mov r0, #0x0 - mov r1, #0x0 - mov r2, #0x1d - mov r3, #0x13 - bl Menu_EraseWindowRect - bl CloseMenu - mov r0, #0x1 -._484: - pop {r1} - bx r1 - - thumb_func_end debug_sub_8160CF4 - - thumb_func_start debug_sub_8160D98 -debug_sub_8160D98: - push {lr} - mov r0, #0x0 - mov r1, #0x0 - mov r2, #0x1d - mov r3, #0x13 - bl Menu_EraseWindowRect - bl debug_sub_8160BE4 - ldr r1, ._485 @ gMenuCallback - ldr r0, ._485 + 4 @ debug_sub_8160CF4 - str r0, [r1] - mov r0, #0x0 - pop {r1} - bx r1 -._486: - .align 2, 0 -._485: - .word gMenuCallback - .word debug_sub_8160CF4+1 - - thumb_func_end debug_sub_8160D98 - - thumb_func_start debug_sub_8160DC0 -debug_sub_8160DC0: - push {lr} - mov r0, #0x0 - mov r1, #0x0 - mov r2, #0x16 - mov r3, #0x13 - bl Menu_DrawStdWindowFrame - ldr r0, ._487 @ gOtherText_Slash - mov r1, #0xb - mov r2, #0x1 - bl Menu_PrintText - ldr r0, ._487 + 4 @ Str_843E5F2 - mov r1, #0x2 - mov r2, #0x3 - bl Menu_PrintText - ldr r0, ._487 + 8 @ Str_843E5FB - mov r1, #0x2 - mov r2, #0x5 - bl Menu_PrintText - ldr r0, ._487 + 12 @ Str_843E606 - mov r1, #0x2 - mov r2, #0x7 - bl Menu_PrintText - ldr r0, ._487 + 16 @ Str_843E611 - mov r1, #0x2 - mov r2, #0x9 - bl Menu_PrintText - ldr r0, ._487 + 20 @ Str_843E61C - mov r1, #0x2 - mov r2, #0xb - bl Menu_PrintText - ldr r0, ._487 + 24 @ Str_843E627 - mov r1, #0x2 - mov r2, #0xd - bl Menu_PrintText - ldr r0, ._487 + 28 @ Str_843E637 - mov r1, #0x2 - mov r2, #0xf - bl Menu_PrintText - ldr r0, ._487 + 32 @ Str_843E632 - mov r1, #0x2 - mov r2, #0x11 - bl Menu_PrintText - pop {r0} - bx r0 -._488: - .align 2, 0 -._487: - .word gOtherText_Slash - .word Str_843E5F2 - .word Str_843E5FB - .word Str_843E606 - .word Str_843E611 - .word Str_843E61C - .word Str_843E627 - .word Str_843E637 - .word Str_843E632 - - thumb_func_end debug_sub_8160DC0 - - thumb_func_start debug_sub_8160E50 -debug_sub_8160E50: - push {r4, r5, r6, lr} - add r6, r0, #0 - mov r0, #0x1 - mov r1, #0x1 - mov r2, #0xa - mov r3, #0x2 - bl Menu_BlankWindowRect - ldr r5, ._489 @ gStringVar1 - add r0, r6, #0 - mov r1, #0x2 - add r2, r5, #0 - bl GetMonData - add r0, r5, #0 - mov r1, #0x1 - mov r2, #0x1 - bl Menu_PrintText - mov r0, #0xc - mov r1, #0x1 - mov r2, #0x15 - mov r3, #0x2 - bl Menu_BlankWindowRect - add r0, r6, #0 - mov r1, #0xb - bl GetMonData - mov r1, #0xb - mul r0, r0, r1 - ldr r1, ._489 + 4 @ gSpeciesNames - add r0, r0, r1 - mov r1, #0xc - mov r2, #0x1 - bl Menu_PrintText - add r0, r6, #0 - mov r1, #0x1a - bl GetMonData - add r4, r0, #0 - lsl r4, r4, #0x10 - lsr r4, r4, #0x10 - add r0, r5, #0 - add r1, r4, #0 - mov r2, #0x0 - mov r3, #0x5 - bl ConvertIntToDecimalStringN - mov r0, #0xd - mov r1, #0x3 - mov r2, #0x11 - mov r3, #0x4 - bl Menu_BlankWindowRect - add r0, r5, #0 - mov r1, #0xd - mov r2, #0x3 - bl Menu_PrintText - add r0, r6, #0 - mov r1, #0x1b - bl GetMonData - add r1, r0, #0 - lsl r1, r1, #0x10 - lsr r1, r1, #0x10 - add r4, r4, r1 - lsl r4, r4, #0x10 - lsr r4, r4, #0x10 - add r0, r5, #0 - mov r2, #0x0 - mov r3, #0x5 - bl ConvertIntToDecimalStringN - mov r0, #0xd - mov r1, #0x5 - mov r2, #0x11 - mov r3, #0x6 - bl Menu_BlankWindowRect - add r0, r5, #0 - mov r1, #0xd - mov r2, #0x5 - bl Menu_PrintText - add r0, r6, #0 - mov r1, #0x1c - bl GetMonData - add r1, r0, #0 - lsl r1, r1, #0x10 - lsr r1, r1, #0x10 - add r4, r4, r1 - lsl r4, r4, #0x10 - lsr r4, r4, #0x10 - add r0, r5, #0 - mov r2, #0x0 - mov r3, #0x5 - bl ConvertIntToDecimalStringN - mov r0, #0xd - mov r1, #0x7 - mov r2, #0x11 - mov r3, #0x8 - bl Menu_BlankWindowRect - add r0, r5, #0 - mov r1, #0xd - mov r2, #0x7 - bl Menu_PrintText - add r0, r6, #0 - mov r1, #0x1d - bl GetMonData - add r1, r0, #0 - lsl r1, r1, #0x10 - lsr r1, r1, #0x10 - add r4, r4, r1 - lsl r4, r4, #0x10 - lsr r4, r4, #0x10 - add r0, r5, #0 - mov r2, #0x0 - mov r3, #0x5 - bl ConvertIntToDecimalStringN - mov r0, #0xd - mov r1, #0x9 - mov r2, #0x11 - mov r3, #0xa - bl Menu_BlankWindowRect - add r0, r5, #0 - mov r1, #0xd - mov r2, #0x9 - bl Menu_PrintText - add r0, r6, #0 - mov r1, #0x1e - bl GetMonData - add r1, r0, #0 - lsl r1, r1, #0x10 - lsr r1, r1, #0x10 - add r4, r4, r1 - lsl r4, r4, #0x10 - lsr r4, r4, #0x10 - add r0, r5, #0 - mov r2, #0x0 - mov r3, #0x5 - bl ConvertIntToDecimalStringN - mov r0, #0xd - mov r1, #0xb - mov r2, #0x11 - mov r3, #0xc - bl Menu_BlankWindowRect - add r0, r5, #0 - mov r1, #0xd - mov r2, #0xb - bl Menu_PrintText - add r0, r6, #0 - mov r1, #0x1f - bl GetMonData - add r1, r0, #0 - lsl r1, r1, #0x10 - lsr r1, r1, #0x10 - add r4, r4, r1 - lsl r4, r4, #0x10 - lsr r4, r4, #0x10 - add r0, r5, #0 - mov r2, #0x0 - mov r3, #0x5 - bl ConvertIntToDecimalStringN - mov r0, #0xd - mov r1, #0xd - mov r2, #0x11 - mov r3, #0xe - bl Menu_BlankWindowRect - add r0, r5, #0 - mov r1, #0xd - mov r2, #0xd - bl Menu_PrintText - add r0, r5, #0 - add r1, r4, #0 - mov r2, #0x0 - mov r3, #0x5 - bl ConvertIntToDecimalStringN - mov r0, #0xd - mov r1, #0xf - mov r2, #0x11 - mov r3, #0x10 - bl Menu_BlankWindowRect - add r0, r5, #0 - mov r1, #0xd - mov r2, #0xf - bl Menu_PrintText - add r0, r6, #0 - mov r1, #0x20 - bl GetMonData - add r1, r0, #0 - add r0, r5, #0 - mov r2, #0x0 - mov r3, #0x5 - bl ConvertIntToDecimalStringN - mov r0, #0xd - mov r1, #0x11 - mov r2, #0x11 - mov r3, #0x12 - bl Menu_BlankWindowRect - add r0, r5, #0 - mov r1, #0xd - mov r2, #0x11 - bl Menu_PrintText - pop {r4, r5, r6} - pop {r0} - bx r0 -._490: - .align 2, 0 -._489: - .word gStringVar1 - .word gSpeciesNames - - thumb_func_end debug_sub_8160E50 - - thumb_func_start debug_sub_8161028 -debug_sub_8161028: - push {r4, r5, r6, lr} - lsl r0, r0, #0x18 - lsr r6, r0, #0x18 - asr r1, r0, #0x18 - mov r0, #0x1 - neg r0, r0 - cmp r1, r0 - bne ._491 @cond_branch - ldr r0, ._496 @ _nakamuraData5 - ldrb r0, [r0] - cmp r0, #0 - bne ._492 @cond_branch - mov r5, #0x5 -._494: - lsl r0, r5, #0x10 - asr r4, r0, #0x10 - mov r0, #0x64 - mul r0, r0, r4 - ldr r1, ._496 + 4 @ gPlayerParty - add r0, r0, r1 - mov r1, #0xb - bl GetMonData - cmp r0, #0 - bne ._493 @cond_branch - sub r0, r4, #1 - lsl r0, r0, #0x10 - lsr r5, r0, #0x10 - cmp r0, #0 - bge ._494 @cond_branch -._492: - ldr r1, ._496 @ _nakamuraData5 - ldrb r0, [r1] - add r0, r0, r6 - strb r0, [r1] - b ._506 -._497: - .align 2, 0 -._496: - .word _nakamuraData5 - .word gPlayerParty -._491: - cmp r1, #0x1 - bne ._506 @cond_branch - ldr r4, ._501 @ _nakamuraData5 - ldrb r0, [r4] - add r0, r0, r6 - strb r0, [r4] - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - cmp r0, #0x6 - bne ._499 @cond_branch - mov r0, #0x0 - b ._500 -._502: - .align 2, 0 -._501: - .word _nakamuraData5 -._493: - ldr r0, ._504 @ _nakamuraData5 - strb r5, [r0] - b ._506 -._505: - .align 2, 0 -._504: - .word _nakamuraData5 -._499: - ldrb r1, [r4] - mov r0, #0x64 - mul r0, r0, r1 - ldr r1, ._507 @ gPlayerParty - add r0, r0, r1 - mov r1, #0xb - bl GetMonData - cmp r0, #0 - bne ._506 @cond_branch -._500: - strb r0, [r4] -._506: - pop {r4, r5, r6} - pop {r0} - bx r0 -._508: - .align 2, 0 -._507: - .word gPlayerParty - - thumb_func_end debug_sub_8161028 - thumb_func_start debug_sub_81610BC debug_sub_81610BC: push {lr} diff --git a/include/strings.h b/include/strings.h index 7b97ec6ef..240e212ac 100644 --- a/include/strings.h +++ b/include/strings.h @@ -165,6 +165,7 @@ extern const u8 gOtherText_None[]; extern const u8 gOtherText_ThreeQuestions2[]; extern const u8 gOtherText_FiveQuestions[]; +extern const u8 gOtherText_Slash[]; extern const u8 gOtherText_OneDash[]; extern const u8 gOtherText_TwoDashes[]; diff --git a/src/debug/nakamura_debug_menu.c b/src/debug/nakamura_debug_menu.c index 97e1d4678..d2854e629 100644 --- a/src/debug/nakamura_debug_menu.c +++ b/src/debug/nakamura_debug_menu.c @@ -208,7 +208,6 @@ const u8 Str_843E5D4[] = _( "  Bボタン ー\n" "START けってい"); -// The following may be defined in the functions in which they are invoked const u8 Str_843E5F0[] = _("?"); const u8 Str_843E5F2[] = _("HP どりょくち"); const u8 Str_843E5FB[] = _("こうげき どりょくち"); @@ -1839,4 +1838,162 @@ void debug_sub_8160C7C(void) debug_sub_8160A80(i); } +bool8 debug_sub_8160CF4(void) +{ + if (gMain.newAndRepeatedKeys & DPAD_UP) + { + Menu_MoveCursor(-1); + return FALSE; + } + + if (gMain.newAndRepeatedKeys & DPAD_DOWN) + { + Menu_MoveCursor(+1); + return FALSE; + } + + if (gMain.newAndRepeatedKeys & DPAD_LEFT) + { + debug_sub_8160B50(Menu_GetCursorPos(), -1); + debug_sub_8160A80(Menu_GetCursorPos()); + debug_sub_8160BB0(); + return FALSE; + } + + if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + { + debug_sub_8160B50(Menu_GetCursorPos(), +1); + debug_sub_8160A80(Menu_GetCursorPos()); + debug_sub_8160BB0(); + return FALSE; + } + + if (gMain.newKeys & A_BUTTON) + { + debug_sub_8160C7C(); + PlaySE(SE_SELECT); + return FALSE; + } + + if (gMain.newKeys & B_BUTTON) + { + Menu_EraseWindowRect(0, 0, 29, 19); + CloseMenu(); + return TRUE; + } + + return FALSE; +} + +bool8 debug_sub_8160D98(void) +{ + Menu_EraseWindowRect(0, 0, 29, 19); + debug_sub_8160BE4(); + gMenuCallback = debug_sub_8160CF4; + return FALSE; +} + +void debug_sub_8160DC0(void) +{ + Menu_DrawStdWindowFrame(0, 0, 22, 19); + Menu_PrintText(gOtherText_Slash, 11, 1); + Menu_PrintText(Str_843E5F2, 2, 3); + Menu_PrintText(Str_843E5FB, 2, 5); + Menu_PrintText(Str_843E606, 2, 7); + Menu_PrintText(Str_843E611, 2, 9); + Menu_PrintText(Str_843E61C, 2, 11); + Menu_PrintText(Str_843E627, 2, 13); + Menu_PrintText(Str_843E637, 2, 15); + Menu_PrintText(Str_843E632, 2, 17); +} + +void debug_sub_8160E50(struct Pokemon *pokemon) +{ + u16 evTotal; + u16 curEv; + + Menu_BlankWindowRect(1, 1, 10, 2); + GetMonData(pokemon, MON_DATA_NICKNAME, gStringVar1); + Menu_PrintText(gStringVar1, 1, 1); + + Menu_BlankWindowRect(12, 1, 21, 2); + Menu_PrintText(gSpeciesNames[GetMonData(pokemon, MON_DATA_SPECIES)], 12, 1); + + curEv = GetMonData(pokemon, MON_DATA_HP_EV); + evTotal = curEv; + ConvertIntToDecimalStringN(gStringVar1, curEv, STR_CONV_MODE_LEFT_ALIGN, 5); + Menu_BlankWindowRect(13, 3, 17, 4); + Menu_PrintText(gStringVar1, 13, 3); + + curEv = GetMonData(pokemon, MON_DATA_ATK_EV); + evTotal += curEv; + ConvertIntToDecimalStringN(gStringVar1, curEv, STR_CONV_MODE_LEFT_ALIGN, 5); + Menu_BlankWindowRect(13, 5, 17, 6); + Menu_PrintText(gStringVar1, 13, 5); + + curEv = GetMonData(pokemon, MON_DATA_DEF_EV); + evTotal += curEv; + ConvertIntToDecimalStringN(gStringVar1, curEv, STR_CONV_MODE_LEFT_ALIGN, 5); + Menu_BlankWindowRect(13, 7, 17, 8); + Menu_PrintText(gStringVar1, 13, 7); + + curEv = GetMonData(pokemon, MON_DATA_SPEED_EV); + evTotal += curEv; + ConvertIntToDecimalStringN(gStringVar1, curEv, STR_CONV_MODE_LEFT_ALIGN, 5); + Menu_BlankWindowRect(13, 9, 17, 10); + Menu_PrintText(gStringVar1, 13, 9); + + curEv = GetMonData(pokemon, MON_DATA_SPATK_EV); + evTotal += curEv; + ConvertIntToDecimalStringN(gStringVar1, curEv, STR_CONV_MODE_LEFT_ALIGN, 5); + Menu_BlankWindowRect(13, 11, 17, 12); + Menu_PrintText(gStringVar1, 13, 11); + + curEv = GetMonData(pokemon, MON_DATA_SPDEF_EV); + evTotal += curEv; + ConvertIntToDecimalStringN(gStringVar1, curEv, STR_CONV_MODE_LEFT_ALIGN, 5); + Menu_BlankWindowRect(13, 13, 17, 14); + Menu_PrintText(gStringVar1, 13, 13); + + ConvertIntToDecimalStringN(gStringVar1, evTotal, STR_CONV_MODE_LEFT_ALIGN, 5); + Menu_BlankWindowRect(13, 15, 17, 16); + Menu_PrintText(gStringVar1, 13, 15); + + ConvertIntToDecimalStringN(gStringVar1, GetMonData(pokemon, MON_DATA_FRIENDSHIP), STR_CONV_MODE_LEFT_ALIGN, 5); + Menu_BlankWindowRect(13, 17, 17, 18); + Menu_PrintText(gStringVar1, 13, 17); +} + +void debug_sub_8161028(s8 a0) +{ + s16 i; + if (a0 == -1) + { + if (_nakamuraData5 == 0) + { + for (i = 5; i >= 0; i--) + { + if (GetMonData(gPlayerParty + i, MON_DATA_SPECIES) != SPECIES_NONE) + { + _nakamuraData5 = i; + return; + } + } + } + _nakamuraData5 += a0; + return; + } + + if (a0 == 1) + { + _nakamuraData5 += a0; + if (_nakamuraData5 == 6) + _nakamuraData5 = 0; + else if (GetMonData(gPlayerParty + _nakamuraData5, MON_DATA_SPECIES) == SPECIES_NONE) + _nakamuraData5 = 0; + } + + +} + #endif // DEBUG -- cgit v1.2.3 From 76b058ec5f01ebc114706b52f1fda066458c233b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 2 Apr 2018 21:34:41 -0400 Subject: through debug_sub_81612B8 --- asm/nakamura_debug_menu.s | 293 ---------------------------------------- src/debug/nakamura_debug_menu.c | 92 +++++++++++++ 2 files changed, 92 insertions(+), 293 deletions(-) diff --git a/asm/nakamura_debug_menu.s b/asm/nakamura_debug_menu.s index 9e4e2975b..9818e2fdf 100644 --- a/asm/nakamura_debug_menu.s +++ b/asm/nakamura_debug_menu.s @@ -5,299 +5,6 @@ .text - thumb_func_start debug_sub_81610BC -debug_sub_81610BC: - push {lr} - ldr r0, ._511 @ gMain - ldrh r1, [r0, #0x2e] - mov r0, #0x20 - and r0, r0, r1 - cmp r0, #0 - beq ._509 @cond_branch - mov r0, #0x1 - neg r0, r0 - b ._510 -._512: - .align 2, 0 -._511: - .word gMain -._509: - mov r0, #0x10 - and r0, r0, r1 - cmp r0, #0 - beq ._513 @cond_branch - mov r0, #0x1 -._510: - bl debug_sub_8161028 - ldr r0, ._515 @ _nakamuraData5 - ldrb r1, [r0] - mov r0, #0x64 - mul r0, r0, r1 - ldr r1, ._515 + 4 @ gPlayerParty - add r0, r0, r1 - bl debug_sub_8160E50 - mov r0, #0x0 - b ._518 -._516: - .align 2, 0 -._515: - .word _nakamuraData5 - .word gPlayerParty -._513: - mov r0, #0x2 - and r0, r0, r1 - cmp r0, #0 - bne ._517 @cond_branch - mov r0, #0x0 - b ._518 -._517: - mov r0, #0x0 - mov r1, #0x0 - mov r2, #0x1d - mov r3, #0x13 - bl Menu_EraseWindowRect - bl CloseMenu - mov r0, #0x1 -._518: - pop {r1} - bx r1 - - thumb_func_end debug_sub_81610BC - - thumb_func_start DebugMenu_EffortValues -DebugMenu_EffortValues: - push {lr} - mov r0, #0x0 - mov r1, #0x0 - mov r2, #0x1d - mov r3, #0x13 - bl Menu_EraseWindowRect - ldr r1, ._519 @ _nakamuraData5 - mov r0, #0x0 - strb r0, [r1] - bl debug_sub_8160DC0 - ldr r0, ._519 + 4 @ gPlayerParty - bl debug_sub_8160E50 - ldr r1, ._519 + 8 @ gMenuCallback - ldr r0, ._519 + 12 @ debug_sub_81610BC - str r0, [r1] - mov r0, #0x0 - pop {r1} - bx r1 -._520: - .align 2, 0 -._519: - .word _nakamuraData5 - .word gPlayerParty - .word gMenuCallback - .word debug_sub_81610BC+1 - - thumb_func_end DebugMenu_EffortValues - - thumb_func_start debug_sub_8161160 -debug_sub_8161160: - push {r4, r5, r6, r7, lr} - mov r7, r8 - push {r7} - mov r7, #0x0 - ldr r2, ._523 @ _nakamuraData6 - ldr r1, ._523 + 4 @ _nakamuraData8 - ldrh r0, [r2] - ldrh r3, [r1] - cmp r0, r3 - bhi ._521 @cond_branch - add r6, r0, #0 - ldrh r5, [r1] - b ._522 -._524: - .align 2, 0 -._523: - .word _nakamuraData6 - .word _nakamuraData8 -._521: - ldrh r6, [r1] - ldrh r5, [r2] -._522: - mov r4, #0x0 - ldr r0, ._529 @ _nakamuraDataA - ldrh r0, [r0] - cmp r4, r0 - bcs ._525 @cond_branch - ldr r0, ._529 + 4 @ _nakamuraDataC - mov r8, r0 -._528: - bl Random - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - mov r2, r8 - ldrh r1, [r2] - bl __umodsi3 - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - cmp r0, r6 - bcc ._527 @cond_branch - cmp r0, r5 - bhi ._527 @cond_branch - add r0, r7, #1 - lsl r0, r0, #0x10 - lsr r7, r0, #0x10 -._527: - add r4, r4, #0x1 - ldr r0, ._529 @ _nakamuraDataA - ldrh r0, [r0] - cmp r4, r0 - bcc ._528 @cond_branch -._525: - add r0, r7, #0 - pop {r3} - mov r8, r3 - pop {r4, r5, r6, r7} - pop {r1} - bx r1 -._530: - .align 2, 0 -._529: - .word _nakamuraDataA - .word _nakamuraDataC - - thumb_func_end debug_sub_8161160 - - thumb_func_start debug_sub_81611D8 -debug_sub_81611D8: - push {r4, lr} - add sp, sp, #0xfffffff8 - mov r0, #0x0 - mov r1, #0x0 - mov r2, #0xf - mov r3, #0xb - bl Menu_DrawStdWindowFrame - ldr r0, ._531 @ Str_843E642 - mov r1, #0x2 - mov r2, #0x1 - bl Menu_PrintText - ldr r0, ._531 + 4 @ Str_843E647 - mov r1, #0x2 - mov r2, #0x3 - bl Menu_PrintText - ldr r0, ._531 + 8 @ Str_843E65A - mov r1, #0x2 - mov r2, #0x5 - bl Menu_PrintText - ldr r0, ._531 + 12 @ Str_843E64C - mov r1, #0x2 - mov r2, #0x7 - bl Menu_PrintText - ldr r0, ._531 + 16 @ Str_843E651 - mov r1, #0x2 - mov r2, #0x9 - bl Menu_PrintText - ldr r0, ._531 + 20 @ Str_843E655 - mov r1, #0xd - mov r2, #0x9 - bl Menu_PrintText - ldr r4, ._531 + 24 @ Str_843E658 - add r0, r4, #0 - mov r1, #0xc - mov r2, #0x1 - bl Menu_PrintText - add r0, r4, #0 - mov r1, #0xc - mov r2, #0x3 - bl Menu_PrintText - add r0, r4, #0 - mov r1, #0xc - mov r2, #0x5 - bl Menu_PrintText - add r0, r4, #0 - mov r1, #0xc - mov r2, #0x7 - bl Menu_PrintText - add r0, r4, #0 - mov r1, #0xc - mov r2, #0x9 - bl Menu_PrintText - mov r0, #0x0 - str r0, [sp] - mov r0, #0xe - str r0, [sp, #0x4] - mov r0, #0x0 - mov r1, #0x1 - mov r2, #0x1 - mov r3, #0x4 - bl InitMenu - add sp, sp, #0x8 - pop {r4} - pop {r0} - bx r0 -._532: - .align 2, 0 -._531: - .word Str_843E642 - .word Str_843E647 - .word Str_843E65A - .word Str_843E64C - .word Str_843E651 - .word Str_843E655 - .word Str_843E658 - - thumb_func_end debug_sub_81611D8 - - thumb_func_start debug_sub_8161290 -debug_sub_8161290: - push {r4, lr} - add r1, r0, #0 - lsl r1, r1, #0x10 - lsr r1, r1, #0x10 - ldr r4, ._533 @ gStringVar1 - add r0, r4, #0 - mov r2, #0x1 - mov r3, #0x5 - bl ConvertIntToDecimalStringN - add r0, r4, #0 - mov r1, #0x8 - mov r2, #0x9 - bl Menu_PrintText - pop {r4} - pop {r0} - bx r0 -._534: - .align 2, 0 -._533: - .word gStringVar1 - - thumb_func_end debug_sub_8161290 - - thumb_func_start debug_sub_81612B8 -debug_sub_81612B8: - push {r4, r5, lr} - add r4, r2, #0 - lsl r4, r4, #0x18 - lsr r4, r4, #0x18 - lsl r1, r1, #0x18 - asr r1, r1, #0x18 - ldrh r2, [r0] - add r1, r1, r2 - strh r1, [r0] - ldr r5, ._535 @ gStringVar1 - ldrh r1, [r0] - add r0, r5, #0 - mov r2, #0x1 - mov r3, #0x5 - bl ConvertIntToDecimalStringN - add r0, r5, #0 - mov r1, #0x8 - add r2, r4, #0 - bl Menu_PrintText - pop {r4, r5} - pop {r0} - bx r0 -._536: - .align 2, 0 -._535: - .word gStringVar1 - - thumb_func_end debug_sub_81612B8 - thumb_func_start debug_sub_81612EC debug_sub_81612EC: push {r4, r5, lr} diff --git a/src/debug/nakamura_debug_menu.c b/src/debug/nakamura_debug_menu.c index d2854e629..2c4ee5413 100644 --- a/src/debug/nakamura_debug_menu.c +++ b/src/debug/nakamura_debug_menu.c @@ -1992,8 +1992,100 @@ void debug_sub_8161028(s8 a0) else if (GetMonData(gPlayerParty + _nakamuraData5, MON_DATA_SPECIES) == SPECIES_NONE) _nakamuraData5 = 0; } +} + +bool8 debug_sub_81610BC(void) +{ + if (gMain.newKeys & DPAD_LEFT) + { + debug_sub_8161028(-1); + debug_sub_8160E50(gPlayerParty + _nakamuraData5); + return FALSE; + } + + if (gMain.newKeys & DPAD_RIGHT) + { + debug_sub_8161028(+1); + debug_sub_8160E50(gPlayerParty + _nakamuraData5); + return FALSE; + } + + if (gMain.newKeys & B_BUTTON) + { + Menu_EraseWindowRect(0, 0, 29, 19); + CloseMenu(); + return TRUE; + } + + return FALSE; +} + +bool8 DebugMenu_EffortValues(void) +{ + Menu_EraseWindowRect(0, 0, 29, 19); + _nakamuraData5 = 0; + debug_sub_8160DC0(); + debug_sub_8160E50(gPlayerParty + 0); + gMenuCallback = debug_sub_81610BC; + return FALSE; +} + +u16 debug_sub_8161160(void) +{ + u16 r7 = 0; + u16 r6; + u16 r5; + u32 i; + + if (_nakamuraData6 <= _nakamuraData8) + { + r6 = _nakamuraData6; + r5 = _nakamuraData8; + } + else + { + r6 = _nakamuraData8; + r5 = _nakamuraData6; + } + + for (i = 0; i < _nakamuraDataA; i++) + { + u16 r0 = Random() % _nakamuraDataC; + if (r0 >= r6 && r0 <= r5) + r7++; + } + + return r7; +} +void debug_sub_81611D8(void) +{ + Menu_DrawStdWindowFrame(0, 0, 15, 11); + Menu_PrintText(Str_843E642, 2, 1); + Menu_PrintText(Str_843E647, 2, 3); + Menu_PrintText(Str_843E65A, 2, 5); + Menu_PrintText(Str_843E64C, 2, 7); + Menu_PrintText(Str_843E651, 2, 9); + Menu_PrintText(Str_843E655, 13, 9); + Menu_PrintText(Str_843E658, 12, 1); + Menu_PrintText(Str_843E658, 12, 3); + Menu_PrintText(Str_843E658, 12, 5); + Menu_PrintText(Str_843E658, 12, 7); + Menu_PrintText(Str_843E658, 12, 9); + InitMenu(0, 1, 1, 4, 0, 14); +} + +void debug_sub_8161290(u16 a0) +{ + ConvertIntToDecimalStringN(gStringVar1, a0, STR_CONV_MODE_RIGHT_ALIGN, 5); + Menu_PrintText(gStringVar1, 8, 9); +} +void debug_sub_81612B8(u16 * a0, s8 a1, u8 a2) +{ + *a0 += a1; + ConvertIntToDecimalStringN(gStringVar1, *a0, STR_CONV_MODE_RIGHT_ALIGN, 5); + Menu_PrintText(gStringVar1, 8, a2); } #endif // DEBUG -- cgit v1.2.3 From a47e145fa914a580875fd39eefd4a22e76587892 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Mon, 2 Apr 2018 21:47:46 -0400 Subject: Finish decompiling nakamura --- asm/nakamura_debug_menu.s | 208 ---------------------------------------- ld_script.txt | 1 - src/debug/nakamura_debug_menu.c | 77 +++++++++++++++ 3 files changed, 77 insertions(+), 209 deletions(-) delete mode 100644 asm/nakamura_debug_menu.s diff --git a/asm/nakamura_debug_menu.s b/asm/nakamura_debug_menu.s deleted file mode 100644 index 9818e2fdf..000000000 --- a/asm/nakamura_debug_menu.s +++ /dev/null @@ -1,208 +0,0 @@ -.if DEBUG - - .include "constants/gba_constants.inc" - .include "include/macros.inc" - - .text - - thumb_func_start debug_sub_81612EC -debug_sub_81612EC: - push {r4, r5, lr} - ldr r2, ._540 @ gMain - ldrh r1, [r2, #0x2c] - mov r0, #0x80 - lsl r0, r0, #0x1 - and r0, r0, r1 - mov r5, #0x1 - cmp r0, #0 - beq ._537 @cond_branch - mov r5, #0x64 -._537: - ldrh r1, [r2, #0x30] - mov r0, #0x40 - and r0, r0, r1 - cmp r0, #0 - beq ._538 @cond_branch - mov r0, #0x1 - neg r0, r0 - b ._539 -._541: - .align 2, 0 -._540: - .word gMain -._538: - mov r0, #0x80 - and r0, r0, r1 - cmp r0, #0 - beq ._542 @cond_branch - mov r0, #0x1 -._539: - bl Menu_MoveCursor -._565: - mov r0, #0x0 - b ._543 -._542: - mov r0, #0x20 - and r0, r0, r1 - cmp r0, #0 - beq ._544 @cond_branch - bl Menu_GetCursorPos - lsl r0, r0, #0x18 - asr r4, r0, #0x18 - cmp r4, #0 - bne ._545 @cond_branch - ldr r0, ._550 @ _nakamuraData6 - neg r1, r5 - mov r2, #0x1 - bl debug_sub_81612B8 -._545: - cmp r4, #0x1 - bne ._546 @cond_branch - ldr r0, ._550 + 4 @ _nakamuraData8 - neg r1, r5 - mov r2, #0x3 - bl debug_sub_81612B8 -._546: - cmp r4, #0x2 - bne ._547 @cond_branch - ldr r0, ._550 + 8 @ _nakamuraDataC - neg r1, r5 - mov r2, #0x5 - bl debug_sub_81612B8 -._547: - cmp r4, #0x3 - bne ._565 @cond_branch - ldr r0, ._550 + 12 @ _nakamuraDataA - neg r1, r5 - mov r2, #0x7 - bl debug_sub_81612B8 - b ._565 -._551: - .align 2, 0 -._550: - .word _nakamuraData6 - .word _nakamuraData8 - .word _nakamuraDataC - .word _nakamuraDataA -._544: - mov r0, #0x10 - and r0, r0, r1 - cmp r0, #0 - beq ._552 @cond_branch - bl Menu_GetCursorPos - lsl r0, r0, #0x18 - asr r4, r0, #0x18 - cmp r4, #0 - bne ._553 @cond_branch - ldr r0, ._558 @ _nakamuraData6 - add r1, r5, #0 - mov r2, #0x1 - bl debug_sub_81612B8 -._553: - cmp r4, #0x1 - bne ._554 @cond_branch - ldr r0, ._558 + 4 @ _nakamuraData8 - add r1, r5, #0 - mov r2, #0x3 - bl debug_sub_81612B8 -._554: - cmp r4, #0x2 - bne ._555 @cond_branch - ldr r0, ._558 + 8 @ _nakamuraDataC - add r1, r5, #0 - mov r2, #0x5 - bl debug_sub_81612B8 -._555: - cmp r4, #0x3 - bne ._565 @cond_branch - ldr r0, ._558 + 12 @ _nakamuraDataA - add r1, r5, #0 - mov r2, #0x7 - bl debug_sub_81612B8 - b ._565 -._559: - .align 2, 0 -._558: - .word _nakamuraData6 - .word _nakamuraData8 - .word _nakamuraDataC - .word _nakamuraDataA -._552: - ldrh r1, [r2, #0x2e] - mov r0, #0x1 - and r0, r0, r1 - cmp r0, #0 - beq ._560 @cond_branch - ldr r0, ._563 @ _nakamuraDataC - ldrh r0, [r0] - cmp r0, #0 - beq ._565 @cond_branch - mov r0, #0x5 - bl PlaySE - bl debug_sub_8161160 - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - bl debug_sub_8161290 - b ._565 -._564: - .align 2, 0 -._563: - .word _nakamuraDataC -._560: - mov r0, #0x2 - and r0, r0, r1 - cmp r0, #0 - beq ._565 @cond_branch - mov r0, #0x0 - mov r1, #0x0 - mov r2, #0x1d - mov r3, #0x13 - bl Menu_EraseWindowRect - bl CloseMenu - mov r0, #0x1 -._543: - pop {r4, r5} - pop {r1} - bx r1 - - thumb_func_end debug_sub_81612EC - - thumb_func_start DebugMenu_RandomNumberTest -DebugMenu_RandomNumberTest: - push {lr} - ldr r0, ._566 @ _nakamuraData6 - mov r1, #0x0 - strh r1, [r0] - ldr r0, ._566 + 4 @ _nakamuraData8 - strh r1, [r0] - ldr r0, ._566 + 8 @ _nakamuraDataC - strh r1, [r0] - ldr r0, ._566 + 12 @ _nakamuraDataA - strh r1, [r0] - mov r0, #0x0 - mov r1, #0x0 - mov r2, #0x1d - mov r3, #0x13 - bl Menu_EraseWindowRect - bl debug_sub_81611D8 - ldr r1, ._566 + 16 @ gMenuCallback - ldr r0, ._566 + 20 @ debug_sub_81612EC - str r0, [r1] - mov r0, #0x0 - pop {r1} - bx r1 -._567: - .align 2, 0 -._566: - .word _nakamuraData6 - .word _nakamuraData8 - .word _nakamuraDataC - .word _nakamuraDataA - .word gMenuCallback - .word debug_sub_81612EC+1 - - thumb_func_end DebugMenu_RandomNumberTest - - .align 2, 0 - -.endif diff --git a/ld_script.txt b/ld_script.txt index c7ed19a0b..c72169b68 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -394,7 +394,6 @@ SECTIONS { src/pokeblock_feed.o(.text); src/clear_save_data_menu.o(.text); src/debug/nakamura_debug_menu.o(.text); - asm/nakamura_debug_menu.o(.text); src/intro_credits_graphics.o(.text); src/evolution_graphics.o(.text); src/bard_music.o(.text); diff --git a/src/debug/nakamura_debug_menu.c b/src/debug/nakamura_debug_menu.c index 2c4ee5413..87c855514 100644 --- a/src/debug/nakamura_debug_menu.c +++ b/src/debug/nakamura_debug_menu.c @@ -2088,4 +2088,81 @@ void debug_sub_81612B8(u16 * a0, s8 a1, u8 a2) Menu_PrintText(gStringVar1, 8, a2); } +bool8 debug_sub_81612EC(void) +{ + s8 r5 = gMain.heldKeys & R_BUTTON ? 100 : 1; + s8 r4; + + if (gMain.newAndRepeatedKeys & DPAD_UP) + { + Menu_MoveCursor(-1); + return FALSE; + } + + if (gMain.newAndRepeatedKeys & DPAD_DOWN) + { + Menu_MoveCursor(+1); + return FALSE; + } + + if (gMain.newAndRepeatedKeys & DPAD_LEFT) + { + r4 = Menu_GetCursorPos(); + if (r4 == 0) + debug_sub_81612B8(&_nakamuraData6, -r5, 1); + if (r4 == 1) + debug_sub_81612B8(&_nakamuraData8, -r5, 3); + if (r4 == 2) + debug_sub_81612B8(&_nakamuraDataC, -r5, 5); + if (r4 == 3) + debug_sub_81612B8(&_nakamuraDataA, -r5, 7); + return FALSE; + } + + if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + { + r4 = Menu_GetCursorPos(); + if (r4 == 0) + debug_sub_81612B8(&_nakamuraData6, r5, 1); + if (r4 == 1) + debug_sub_81612B8(&_nakamuraData8, r5, 3); + if (r4 == 2) + debug_sub_81612B8(&_nakamuraDataC, r5, 5); + if (r4 == 3) + debug_sub_81612B8(&_nakamuraDataA, r5, 7); + return FALSE; + } + + if (gMain.newKeys & A_BUTTON) + { + if (_nakamuraDataC != 0) + { + PlaySE(SE_SELECT); + debug_sub_8161290(debug_sub_8161160()); + } + return FALSE; + } + + if (gMain.newKeys & B_BUTTON) + { + Menu_EraseWindowRect(0, 0, 29, 19); + CloseMenu(); + return TRUE; + } + + return FALSE; +} + +bool8 DebugMenu_RandomNumberTest(void) +{ + _nakamuraData6 = 0; + _nakamuraData8 = 0; + _nakamuraDataC = 0; + _nakamuraDataA = 0; + Menu_EraseWindowRect(0, 0, 29, 19); + debug_sub_81611D8(); + gMenuCallback = debug_sub_81612EC; + return FALSE; +} + #endif // DEBUG -- cgit v1.2.3 From ad19035dac9c8cb56949d0965117efa92f44bafe Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Tue, 3 Apr 2018 12:02:43 -0400 Subject: Include standard headers in global.h --- include/global.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/include/global.h b/include/global.h index faa4ace68..4437b7feb 100644 --- a/include/global.h +++ b/include/global.h @@ -1,6 +1,8 @@ #ifndef GUARD_GLOBAL_H #define GUARD_GLOBAL_H +#include +#include #include "config.h" // we need to define config before gba headers as print stuff needs the functions nulled before defines. #include "gba/gba.h" @@ -14,9 +16,6 @@ #define INCBIN_S8 {0} #define INCBIN_S16 {0} #define INCBIN_S32 {0} -void *memcpy (void *, const void *, size_t); -void *memset (void *, int, size_t); -int strcmp (const char *, const char *); #endif // Prevent cross-jump optimization. -- cgit v1.2.3 From 56d822f9e3fe9ed65377151c0b839e4eaa7caea9 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 4 Apr 2018 08:49:05 -0400 Subject: Renaming --- include/choose_party.h | 2 +- include/debug.h | 3 + include/decoration_inventory.h | 4 +- include/field_fadetransition.h | 2 +- include/menu.h | 4 +- include/overworld.h | 2 +- include/pokeblock.h | 2 +- include/pokemon.h | 2 +- include/roamer.h | 4 +- include/wild_encounter.h | 2 +- src/battle/battle_2.c | 30 +- src/berry_blender.c | 42 +- src/choose_party.c | 62 +-- src/debug/kagaya_debug_menu.c | 6 +- src/debug/matsuda_debug_menu.c | 4 +- src/debug/nakamura_debug_menu.c | 1139 ++++++++++++++++++++------------------- src/debug/start_menu_debug.c | 2 +- src/decoration_inventory.c | 6 +- src/field_fadetransition.c | 2 +- src/item_menu.c | 4 +- src/overworld.c | 4 +- src/pokeblock.c | 2 +- src/pokedex.c | 2 +- src/pokemon_1.c | 2 +- src/pokemon_menu.c | 2 +- src/pokenav_before.c | 2 +- src/region_map.c | 2 +- src/roamer.c | 4 +- src/scrcmd.c | 2 +- src/shop.c | 2 +- src/start_menu.c | 6 +- src/trader.c | 2 +- src/wild_encounter.c | 2 +- sym_ewram.txt | 2 +- 34 files changed, 707 insertions(+), 653 deletions(-) diff --git a/include/choose_party.h b/include/choose_party.h index 1f7d48f59..9aacef27d 100644 --- a/include/choose_party.h +++ b/include/choose_party.h @@ -10,7 +10,7 @@ void HandleLinkMultiBattlePartyMenu(u8 taskId); void HandleDaycarePartyMenu(u8 taskId); void sub_8123138(u8 taskId); #if DEBUG -void debug_sub_81381B4(void); +void Debug_CopyLastThreePartyMonsToMultiPartnerParty(void); #endif #endif // GUARD_CHOOSE_PARTY_H diff --git a/include/debug.h b/include/debug.h index 2136dbfb8..469560b9e 100644 --- a/include/debug.h +++ b/include/debug.h @@ -14,4 +14,7 @@ void debug_nullsub_66(void); // sound_check_menu void CB2_StartSoundCheckMenu(void); +// nakamura_debug_menu +void NakaGenderTest(void); + #endif // GUARD_DEBUG_H diff --git a/include/decoration_inventory.h b/include/decoration_inventory.h index 0772aacf6..e2e31bee9 100644 --- a/include/decoration_inventory.h +++ b/include/decoration_inventory.h @@ -4,12 +4,12 @@ void ClearDecorationInventories(void); s8 sub_8133F9C(u8); u8 sub_8133FE4(u8); -u8 IsThereStorageSpaceForDecoration(u8); +u8 GiveDecoration(u8); u8 sub_8134074(u8); s8 sub_81340A8(u8); u8 sub_8134194(u8); #if DEBUG -void debug_sub_814A3A8(void); +void Debug_GiveAllDecorations(void); #endif // DEBUG #endif // GUARD_DECORATION_INVENTORY_H diff --git a/include/field_fadetransition.h b/include/field_fadetransition.h index cd0cb6eab..64e922651 100644 --- a/include/field_fadetransition.h +++ b/include/field_fadetransition.h @@ -13,7 +13,7 @@ void sub_8080A3C(void); void sub_8080AC4(void); void mapldr_default(); void sub_8080B60(void); -void atk17_seteffectsecondary(void); +void sub_8080DEC(void); void sub_8080E28(void); void sub_8080E44(void); bool32 sub_8080E70(void); diff --git a/include/menu.h b/include/menu.h index 3295cd5c5..523037839 100644 --- a/include/menu.h +++ b/include/menu.h @@ -4,10 +4,12 @@ #include "task.h" #include "text.h" +typedef bool8 (*MenuFunc)(); + struct MenuAction { const u8 *text; - u8 (*func)(); + MenuFunc func; }; struct MenuAction2 diff --git a/include/overworld.h b/include/overworld.h index dc393cc63..b18027933 100644 --- a/include/overworld.h +++ b/include/overworld.h @@ -138,7 +138,7 @@ void c2_exit_to_overworld_2_switch(void); void c2_exit_to_overworld_2_local(void); void c2_exit_to_overworld_2_link(void); // sub_805465C -void sub_805469C(void); +void c2_exit_to_overworld_1_sub_8080DEC(void); // sub_80546B8 void c2_exit_to_overworld_1_continue_scripts_restart_music(void); void sub_80546F0(void); diff --git a/include/pokeblock.h b/include/pokeblock.h index a606a32ad..f674666ff 100644 --- a/include/pokeblock.h +++ b/include/pokeblock.h @@ -42,7 +42,7 @@ s16 PokeblockGetGain(u8, const struct Pokeblock *); u8 sub_810CB68(u8, u8*); void PokeblockCopyName(struct Pokeblock *pokeblock, u8 *dest); void CB2_PreparePokeblockFeedScene(void); -bool8 sub_810CA34(const struct Pokeblock *); +bool8 GivePokeblock(const struct Pokeblock *); #include "main.h" diff --git a/include/pokemon.h b/include/pokemon.h index c827e3cd5..842833542 100644 --- a/include/pokemon.h +++ b/include/pokemon.h @@ -632,7 +632,7 @@ void BoxMonRestorePP(struct BoxPokemon *); bool8 HealStatusConditions(struct Pokemon *mon, u32 unused, u32 healMask, u8 battleId); #if DEBUG -void debug_sub_803F55C(struct Pokemon *); +void Nakamura_NakaGenderTest_RecalcStats(struct Pokemon *); #endif // DEBUG #endif // GUARD_POKEMON_H diff --git a/include/roamer.h b/include/roamer.h index c91742d44..6f0813eb8 100644 --- a/include/roamer.h +++ b/include/roamer.h @@ -11,8 +11,8 @@ void UpdateRoamerHPStatus(struct Pokemon *mon); void SetRoamerInactive(void); #if DEBUG -void debug_sub_814A714(void); -void debug_sub_814A73C(u8 *); +void Debug_CreateRoamer(void); +void Debug_GetRoamerLocation(u8 *); #endif // DEBUG #endif // GUARD_ROAMER_H diff --git a/include/wild_encounter.h b/include/wild_encounter.h index 2846c12f5..41ca31835 100644 --- a/include/wild_encounter.h +++ b/include/wild_encounter.h @@ -36,7 +36,7 @@ u16 GetLocalWildMon(bool8 *isWaterMon); u16 GetLocalWaterMon(void); bool8 UpdateRepelCounter(void); #if DEBUG -u16 debug_sub_8092344(u8 arg0); +u16 FeebasDebug_GetTrueNumberOfWaterTilesInMapThird(u8 arg0); void FeebasSeedRng(u16 seed); u16 FeebasRandom(void); #endif // DEBUG diff --git a/src/battle/battle_2.c b/src/battle/battle_2.c index 2bbae20dc..83687298b 100644 --- a/src/battle/battle_2.c +++ b/src/battle/battle_2.c @@ -82,7 +82,7 @@ extern const u8 gUnknown_Debug_821F7F3[]; extern const u8 BattleText_YesNo[]; extern u8 gStatStageRatios[][2]; extern u8 gActionsByTurnOrder[4]; -extern struct UnknownPokemonStruct2 gUnknown_02023A00[]; +extern struct UnknownPokemonStruct2 gMultiPartnerParty[]; extern u8 gBattleBufferB[][0x200]; extern u8 gActiveBank; extern u32 gBattleExecBuffer; @@ -576,23 +576,23 @@ void sub_800F02C(void) for (i = 0; i < 3; i++) { - u8 *nickname = gUnknown_02023A00[i].nickname; + u8 *nickname = gMultiPartnerParty[i].nickname; - gUnknown_02023A00[i].species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES); - gUnknown_02023A00[i].heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); + gMultiPartnerParty[i].species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES); + gMultiPartnerParty[i].heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); GetMonData(&gPlayerParty[i], MON_DATA_NICKNAME, nickname); - gUnknown_02023A00[i].level = GetMonData(&gPlayerParty[i], MON_DATA_LEVEL); - gUnknown_02023A00[i].hp = GetMonData(&gPlayerParty[i], MON_DATA_HP); - gUnknown_02023A00[i].maxhp = GetMonData(&gPlayerParty[i], MON_DATA_MAX_HP); - gUnknown_02023A00[i].status = GetMonData(&gPlayerParty[i], MON_DATA_STATUS); - gUnknown_02023A00[i].personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY); - gUnknown_02023A00[i].gender = GetMonGender(&gPlayerParty[i]); + gMultiPartnerParty[i].level = GetMonData(&gPlayerParty[i], MON_DATA_LEVEL); + gMultiPartnerParty[i].hp = GetMonData(&gPlayerParty[i], MON_DATA_HP); + gMultiPartnerParty[i].maxhp = GetMonData(&gPlayerParty[i], MON_DATA_MAX_HP); + gMultiPartnerParty[i].status = GetMonData(&gPlayerParty[i], MON_DATA_STATUS); + gMultiPartnerParty[i].personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY); + gMultiPartnerParty[i].gender = GetMonGender(&gPlayerParty[i]); Text_StripExtCtrlCodes(nickname); - gUnknown_02023A00[i].language = GetMonData(&gPlayerParty[i], MON_DATA_LANGUAGE); - if (gUnknown_02023A00[i].language != 1) + gMultiPartnerParty[i].language = GetMonData(&gPlayerParty[i], MON_DATA_LANGUAGE); + if (gMultiPartnerParty[i].language != 1) PadNameString(nickname, 0); } - memcpy(gSharedMem, gUnknown_02023A00, 0x60); + memcpy(gSharedMem, gMultiPartnerParty, 0x60); } void sub_800F104(void) @@ -646,7 +646,7 @@ void sub_800F104(void) { if ((!(gLinkPlayers[i].lp_field_18 & 1) && !(gLinkPlayers[playerId].lp_field_18 & 1)) || ((gLinkPlayers[i].lp_field_18 & 1) && (gLinkPlayers[playerId].lp_field_18 & 1))) - memcpy(gUnknown_02023A00, gBlockRecvBuffer[i], 0x60); + memcpy(gMultiPartnerParty, gBlockRecvBuffer[i], 0x60); } } gBattleCommunication[0]++; @@ -2444,7 +2444,7 @@ void debug_sub_801174C(void) AddBagItem(ITEM_POKE_DOLL, 99); for (i = 0; i < 15; i++) - sub_810CA34(&gUnknown_Debug_821F5AC[i]); + GivePokeblock(&gUnknown_Debug_821F5AC[i]); } void debug_sub_8011D40(void) diff --git a/src/berry_blender.c b/src/berry_blender.c index bf634a49f..5d40ea321 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -1921,14 +1921,14 @@ u32 Blender_GetPokeblockColor(struct BlenderBerry* berries, s16* a1, u8 playersN r6++; } if (r6 == 5 || a3 > 3) - return 12; + return PBLOCK_CLR_BLACK; for (i = 0; i < playersNo; i++) { for (r6 = 0; r6 < playersNo; r6++) { if (berries[i].itemID == berries[r6].itemID && i != r6 && (berries[i].itemID != ITEM_ENIGMA_BERRY || sub_80502A4(berries, i, r6))) - return 12; + return PBLOCK_CLR_BLACK; } } r2 = 0; @@ -1938,24 +1938,24 @@ u32 Blender_GetPokeblockColor(struct BlenderBerry* berries, s16* a1, u8 playersN r2++; } if (r2 > 3) - return 13; + return PBLOCK_CLR_WHITE; if (r2 == 3) - return 11; + return PBLOCK_CLR_GRAY; for (i = 0; i < 5; i++) { if (vars[i] > 50) - return 14; + return PBLOCK_CLR_GOLD; } if (r2 == 1 && vars[0] > 0) - return 1; + return PBLOCK_CLR_RED; if (r2 == 1 && vars[1] > 0) - return 2; + return PBLOCK_CLR_BLUE; if (r2 == 1 && vars[2] > 0) - return 3; + return PBLOCK_CLR_PINK; if (r2 == 1 && vars[3] > 0) - return 4; + return PBLOCK_CLR_GREEN; if (r2 == 1 && vars[4] > 0) - return 5; + return PBLOCK_CLR_YELLOW; if (r2 == 2) { s32 var = 0; @@ -1967,28 +1967,28 @@ u32 Blender_GetPokeblockColor(struct BlenderBerry* berries, s16* a1, u8 playersN if (vars[gUnknown_03000520[0]] >= vars[gUnknown_03000520[1]]) { if (gUnknown_03000520[0] == 0) - return (gUnknown_03000520[1] << 16) | 6; + return (gUnknown_03000520[1] << 16) | PBLOCK_CLR_PURPLE; if (gUnknown_03000520[0] == 1) - return (gUnknown_03000520[1] << 16) | 7; + return (gUnknown_03000520[1] << 16) | PBLOCK_CLR_INDIGO; if (gUnknown_03000520[0] == 2) - return (gUnknown_03000520[1] << 16) | 8; + return (gUnknown_03000520[1] << 16) | PBLOCK_CLR_BROWN; if (gUnknown_03000520[0] == 3) - return (gUnknown_03000520[1] << 16) | 9; + return (gUnknown_03000520[1] << 16) | PBLOCK_CLR_LITEBLUE; if (gUnknown_03000520[0] == 4) - return (gUnknown_03000520[1] << 16) | 10; + return (gUnknown_03000520[1] << 16) | PBLOCK_CLR_OLIVE; } else { if (gUnknown_03000520[1] == 0) - return (gUnknown_03000520[0] << 16) | 6; + return (gUnknown_03000520[0] << 16) | PBLOCK_CLR_PURPLE; if (gUnknown_03000520[1] == 1) - return (gUnknown_03000520[0] << 16) | 7; + return (gUnknown_03000520[0] << 16) | PBLOCK_CLR_INDIGO; if (gUnknown_03000520[1] == 2) - return (gUnknown_03000520[0] << 16) | 8; + return (gUnknown_03000520[0] << 16) | PBLOCK_CLR_BROWN; if (gUnknown_03000520[1] == 3) - return (gUnknown_03000520[0] << 16) | 9; + return (gUnknown_03000520[0] << 16) | PBLOCK_CLR_LITEBLUE; if (gUnknown_03000520[1] == 4) - return (gUnknown_03000520[0] << 16) | 10; + return (gUnknown_03000520[0] << 16) | PBLOCK_CLR_OLIVE; } } return 0; @@ -3108,7 +3108,7 @@ bool8 Blender_PrintBlendingResults(void) #endif MenuPrintMessage(gBerryBlenderData->stringVar, 1, 15); RemoveBagItem(gSpecialVar_ItemId, 1); - sub_810CA34(&pokeblock); + GivePokeblock(&pokeblock); gBerryBlenderData->field_0++; break; case 6: diff --git a/src/choose_party.c b/src/choose_party.c index 4766b2fbb..b4920dedd 100644 --- a/src/choose_party.c +++ b/src/choose_party.c @@ -23,7 +23,7 @@ extern u8 gPlayerPartyCount; extern u8 gLastFieldPokeMenuOpened; extern u8 gUnknown_020384F0; -extern struct UnknownPokemonStruct2 gUnknown_02023A00[3]; +extern struct UnknownPokemonStruct2 gMultiPartnerParty[3]; extern u8 gUnknown_0202E8F6; extern struct Pokemon gUnknown_030042FC[]; extern const u16 gBattleTowerBannedSpecies[]; @@ -530,26 +530,26 @@ static void BattleTowerEntryMenuCallback_Exit(u8 taskId) #if DEBUG -void debug_sub_81381B4(void) +void Debug_CopyLastThreePartyMonsToMultiPartnerParty(void) { u8 i; - memset(gUnknown_02023A00, 0, sizeof(gUnknown_02023A00)); + memset(gMultiPartnerParty, 0, sizeof(gMultiPartnerParty)); for (i = 0; i < 3; i++) { - gUnknown_02023A00[i].species = GetMonData(&gPlayerParty[3 + i], MON_DATA_SPECIES2); - if (gUnknown_02023A00[i].species != 0) + gMultiPartnerParty[i].species = GetMonData(&gPlayerParty[3 + i], MON_DATA_SPECIES2); + if (gMultiPartnerParty[i].species != 0) { - gUnknown_02023A00[i].level = GetMonData(&gPlayerParty[3 + i], MON_DATA_LEVEL); - gUnknown_02023A00[i].hp = GetMonData(&gPlayerParty[3 + i], MON_DATA_HP); - gUnknown_02023A00[i].maxhp = GetMonData(&gPlayerParty[3 + i], MON_DATA_MAX_HP); - gUnknown_02023A00[i].status = GetMonData(&gPlayerParty[3 + i], MON_DATA_STATUS); - gUnknown_02023A00[i].heldItem = GetMonData(&gPlayerParty[3 + i], MON_DATA_HELD_ITEM); - gUnknown_02023A00[i].personality = GetMonData(&gPlayerParty[3 + i], MON_DATA_PERSONALITY); - gUnknown_02023A00[i].gender = GetMonGender(&gPlayerParty[3 + i]); - GetMonData(&gPlayerParty[3 + i], MON_DATA_NICKNAME, gUnknown_02023A00[i].nickname); - Text_StripExtCtrlCodes(gUnknown_02023A00[i].nickname); - gUnknown_02023A00[i].language = GetMonData(&gPlayerParty[3 + i], MON_DATA_LANGUAGE); + gMultiPartnerParty[i].level = GetMonData(&gPlayerParty[3 + i], MON_DATA_LEVEL); + gMultiPartnerParty[i].hp = GetMonData(&gPlayerParty[3 + i], MON_DATA_HP); + gMultiPartnerParty[i].maxhp = GetMonData(&gPlayerParty[3 + i], MON_DATA_MAX_HP); + gMultiPartnerParty[i].status = GetMonData(&gPlayerParty[3 + i], MON_DATA_STATUS); + gMultiPartnerParty[i].heldItem = GetMonData(&gPlayerParty[3 + i], MON_DATA_HELD_ITEM); + gMultiPartnerParty[i].personality = GetMonData(&gPlayerParty[3 + i], MON_DATA_PERSONALITY); + gMultiPartnerParty[i].gender = GetMonGender(&gPlayerParty[3 + i]); + GetMonData(&gPlayerParty[3 + i], MON_DATA_NICKNAME, gMultiPartnerParty[i].nickname); + Text_StripExtCtrlCodes(gMultiPartnerParty[i].nickname); + gMultiPartnerParty[i].language = GetMonData(&gPlayerParty[3 + i], MON_DATA_LANGUAGE); } } } @@ -591,9 +591,9 @@ static void sub_81228E8(u8 a) { if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != 0) CreatePartyMenuMonIcon(a, i, 3, &gPlayerParty[i]); - if (gUnknown_02023A00[i].species != 0) + if (gMultiPartnerParty[i].species != 0) { - CreateMonIcon_LinkMultiBattle(a, i + 3, 3, &gUnknown_02023A00[i]); + CreateMonIcon_LinkMultiBattle(a, i + 3, 3, &gMultiPartnerParty[i]); sub_806D50C(a, i + 3); } } @@ -611,8 +611,8 @@ static void sub_8122950(u8 a) CreateHeldItemIcon_806DCD4(a, i, item); } - if (gUnknown_02023A00[i].species != 0) - CreateHeldItemIcon_806DCD4(a, i + 3, gUnknown_02023A00[i].heldItem); + if (gMultiPartnerParty[i].species != 0) + CreateHeldItemIcon_806DCD4(a, i + 3, gMultiPartnerParty[i].heldItem); } } @@ -644,9 +644,9 @@ void HandleLinkMultiBattlePartyMenu(u8 taskId) if (!gPaletteFade.active) { gTasks[taskId].data[0] = 30; - sub_806D4AC(taskId, gUnknown_02023A00[0].species, 0); - sub_806D4AC(taskId, gUnknown_02023A00[1].species, 1); - sub_806D4AC(taskId, gUnknown_02023A00[2].species, 2); + sub_806D4AC(taskId, gMultiPartnerParty[0].species, 0); + sub_806D4AC(taskId, gMultiPartnerParty[1].species, 1); + sub_806D4AC(taskId, gMultiPartnerParty[2].species, 2); gTasks[taskId].func = sub_8122AB8; ewram1B000.unk261 = 1; } @@ -654,7 +654,7 @@ void HandleLinkMultiBattlePartyMenu(u8 taskId) static void sub_8122AB8(u8 taskId) { - sub_806D3B4(taskId, gUnknown_02023A00[1].species, gUnknown_02023A00[2].species); + sub_806D3B4(taskId, gMultiPartnerParty[1].species, gMultiPartnerParty[2].species); if (gTasks[taskId].data[0] == 0) { gTasks[taskId].func = sub_8122B10; @@ -669,25 +669,25 @@ static void sub_8122B10(u8 taskId) for (i = 0; i < 3; i++) { - if (gUnknown_02023A00[i].species != 0) + if (gMultiPartnerParty[i].species != 0) { u8 r2; - PartyMenuDoPrintHP(i + 3, 3, gUnknown_02023A00[i].hp, gUnknown_02023A00[i].maxhp); - if (gUnknown_02023A00[i].hp == 0) + PartyMenuDoPrintHP(i + 3, 3, gMultiPartnerParty[i].hp, gMultiPartnerParty[i].maxhp); + if (gMultiPartnerParty[i].hp == 0) r2 = 7; else - r2 = pokemon_ailments_get_primary(gUnknown_02023A00[i].status); + r2 = pokemon_ailments_get_primary(gMultiPartnerParty[i].status); if (r2 != 0) PartyMenuPutStatusTilemap(i + 3, 3, r2 - 1); else - PartyMenuDoPrintLevel(i + 3, 3, gUnknown_02023A00[i].level); - PartyMenuDoPrintGenderIcon(gUnknown_02023A00[i].species, gUnknown_02023A00[i].gender, 3, i + 3, gUnknown_02023A00[i].nickname); - StringCopy(gStringVar1, gUnknown_02023A00[i].nickname); + PartyMenuDoPrintLevel(i + 3, 3, gMultiPartnerParty[i].level); + PartyMenuDoPrintGenderIcon(gMultiPartnerParty[i].species, gMultiPartnerParty[i].gender, 3, i + 3, gMultiPartnerParty[i].nickname); + StringCopy(gStringVar1, gMultiPartnerParty[i].nickname); StringGetEnd10(gStringVar1); SanitizeNameString(gStringVar1); PartyMenuDoPrintMonNickname(i + 3, 3, gStringVar1); - PartyMenuDoDrawHPBar(i + 3, 3, gUnknown_02023A00[i].hp, gUnknown_02023A00[i].maxhp); + PartyMenuDoDrawHPBar(i + 3, 3, gMultiPartnerParty[i].hp, gMultiPartnerParty[i].maxhp); } } gTasks[taskId].func = sub_8122C18; diff --git a/src/debug/kagaya_debug_menu.c b/src/debug/kagaya_debug_menu.c index 3cb36ce0c..83736ba4d 100644 --- a/src/debug/kagaya_debug_menu.c +++ b/src/debug/kagaya_debug_menu.c @@ -83,7 +83,7 @@ u8 debug_sub_80B068C(void) { if (!UpdatePaletteFade()) { - debug_sub_80A0710(sub_805469C); + debug_sub_80A0710(c2_exit_to_overworld_1_sub_8080DEC); CloseMenu(); ScriptContext2_Enable(); return 1; @@ -102,7 +102,7 @@ u8 debug_sub_80B06E0(void) { if (!UpdatePaletteFade()) { - debug_sub_80A073C(sub_805469C); + debug_sub_80A073C(c2_exit_to_overworld_1_sub_8080DEC); CloseMenu(); ScriptContext2_Enable(); return 1; @@ -121,7 +121,7 @@ u8 Kagaya_80B0734(void) { if (!UpdatePaletteFade()) { - debug_sub_811609C(Random() % 6, sub_805469C); + debug_sub_811609C(Random() % 6, c2_exit_to_overworld_1_sub_8080DEC); CloseMenu(); ScriptContext2_Enable(); return 1; diff --git a/src/debug/matsuda_debug_menu.c b/src/debug/matsuda_debug_menu.c index c8f80eb50..7a66ded57 100644 --- a/src/debug/matsuda_debug_menu.c +++ b/src/debug/matsuda_debug_menu.c @@ -473,7 +473,7 @@ static void sub_80AA064(void) RunTasks(); UpdatePaletteFade(); if (gMain.newKeys == 4) - SetMainCallback2(sub_805469C); + SetMainCallback2(c2_exit_to_overworld_1_sub_8080DEC); } static void sub_80AA090(void) @@ -891,7 +891,7 @@ void sub_80AAD44(struct Sprite *sprite, s8 var2) SetDebugMonForContest(); for (i = 0; i < 4; i++) gUnknown_02038670[i] = sub_80AE770(i, gSpecialVar_ContestCategory); - SetMainCallback2(sub_805469C); + SetMainCallback2(c2_exit_to_overworld_1_sub_8080DEC); } } diff --git a/src/debug/nakamura_debug_menu.c b/src/debug/nakamura_debug_menu.c index 87c855514..3880c7b7b 100644 --- a/src/debug/nakamura_debug_menu.c +++ b/src/debug/nakamura_debug_menu.c @@ -25,222 +25,67 @@ #include "menu_helpers.h" #include "pokeblock.h" -typedef bool8 (*MenuFunc)(void); - -EWRAM_DATA u8 _nakamuraData0 = 0; -EWRAM_DATA u8 _nakamuraData1 = 0; -EWRAM_DATA u8 _nakamuraData2 = 0; -EWRAM_DATA u8 _nakamuraData3 = 0; -EWRAM_DATA u8 _nakamuraData4 = 0; -EWRAM_DATA u8 _nakamuraData5 = 0; -EWRAM_DATA u16 _nakamuraData6 = 0; -EWRAM_DATA u16 _nakamuraData8 = 0; -EWRAM_DATA u16 _nakamuraDataA = 0; -EWRAM_DATA u16 _nakamuraDataC = 0; - -static struct { - s16 species; - s8 level; - u8 unk3; -} _nakamuraStatic0[PARTY_SIZE]; -static struct Pokeblock _nakamuraStatic18; - -asm(".global _nakamuraStatic0"); -asm(".global _nakamuraStatic18"); - -bool8 debug_sub_815F214(void); -bool8 debug_sub_815F2B4(void); -bool8 debug_sub_815F2F4(void); -bool8 debug_sub_815F62C(void); -bool8 debug_sub_815FA38(void); -bool8 debug_sub_815FB1C(void); -bool8 debug_sub_815FBE8(void); -bool8 debug_sub_815FC54(void); -bool8 debug_sub_815FC94(void); -bool8 debug_sub_815FE1C(void); -void debug_sub_816009C(u8); -void debug_sub_81600D0(u8); -void debug_sub_816013C(u8); -void debug_sub_81603B8(u8); -bool8 debug_sub_8160498(void); -u8 debug_sub_816062C(u8); -bool8 debug_sub_8160D98(void); - -const u8 Str_843E36C[] = _("Berries"); -const u8 Str_843E374[] = _("Goods"); -const u8 Str_843E37A[] = _("{PKMN} list"); -const u8 Str_843E382[] = _("トラップ"); -const u8 Str_843E387[] = _("Move your base"); -const u8 Str_843E396[] = _("Moving {PKMN}"); -const u8 Str_843E3A0[] = _("Fishing points"); -const u8 Str_843E3AF[] = _("Set {POKEBLOCK}"); -const u8 Str_843E3B9[] = _("Make bases(to max)"); -const u8 Str_843E3CC[] = _("Base location"); - -const struct MenuAction _843E3DC[] = { - { Str_843E36C, debug_sub_815FC54 }, - { Str_843E37A, debug_sub_815F2B4 }, - { Str_843E374, debug_sub_815FC94 }, - { Str_843E387, debug_sub_815FB1C }, - { Str_843E3B9, debug_sub_815F2F4 }, - { Str_843E3CC, debug_sub_815F62C }, - { Str_843E396, debug_sub_815FBE8 }, - { Str_843E3A0, debug_sub_815FE1C }, - { Str_843E3AF, debug_sub_8160D98 }, -}; - -const u8 _843E424[] = { - 1, 118, 47, 14 , - 2, 125, 53, 10 , - 3, 113, 49, 8 , - 0xB, 118, 67, 6 , - 0xC, 121, 40, 11 , - 0xD, 111, 35, 1 , - 0x15, 115, 20, 53 , - 0x16, 121, 18, 13 , - 0x17, 119, 26, 81 , - 0x1F, 127, 59, 67 , - 0x20, 125, 55, 11 , - 0x21, 111, 27, 27 , - 0x29, 114, 9, 47 , - 0x2A, 115, 32, 39 , - 0x2B, 115, 23, 8 , - 0x33, 114, 30, 51 , - 0x34, 115, 26, 15 , - 0x35, 115, 32, 46 , - 0x3D, 114, 11, 62 , - 0x3E, 115, 21, 18 , - 0x3F, 115, 25, 24 , - 0x47, 114, 19, 70 , - 0x48, 115, 32, 6 , - 0x49, 114, 32, 57 , - 0x51, 116, 71, 4 , - 0x52, 123, 47, 3 , - 0x53, 123, 57, 5 , - 0x5B, 116, 79, 11 , - 0x5C, 123, 49, 3 , - 0x5D, 120, 18, 12 , - 0x65, 120, 28, 62 , - 0x66, 116, 56, 6 , - 0x67, 119, 16, 81 , - 0x6F, 120, 30, 62 , - 0x70, 116, 55, 15 , - 0x71, 119, 16, 28 , - 0x79, 111, 33, 34 , - 0x7A, 118, 29, 5 , - 0x7B, 127, 45, 24 , - 0x83, 111, 24, 36 , - 0x84, 125, 7, 25 , - 0x85, 115, 8, 30 , - 0x8D, 111, 34, 50 , - 0x8E, 127, 59, 72 , - 0x8F, 127, 61, 21 , - 0x97, 127, 67, 63 , - 0x98, 125, 24, 32 , - 0x99, 111, 35, 31 , - 0xA1, 111, 13, 19 , - 0xA2, 121, 43, 7 , - 0xA3, 118, 47, 5 , - 0xA4, 111, 14, 19 , - 0xAB, 118, 46, 5 , - 0xAC, 121, 42, 7 , - 0xAD, 119, 19, 76 , - 0xAE, 115, 7, 20 , - 0xB5, 110, 16, 25 , - 0xB6, 114, 11, 27 , - 0xB7, 115, 8, 20 , - 0xBF, 110, 17, 25 , - 0xC0, 114, 12, 27 , - 0xC1, 119, 18, 76 , - 0xC9, 119, 5, 2 , - 0xCA, 119, 4, 89 , - 0xCB, 120, 38, 54 , - 0xCC, 120, 5, 76 , - 0xD3, 119, 5, 15 , - 0xD4, 119, 7, 101 , - 0xD5, 120, 31, 23 , - 0xDD, 119, 34, 24 , - 0xDE, 120, 26, 10 , - 0xDF, 119, 4, 15 , - 0xE7, 119, 31, 73 , - 0xE8, 120, 29, 85 , - 0xE9, 119, 6, 2 , +static bool8 TopMenu_HandleJoypad(void); +static bool8 SwitchToPkmnListMenu(void); +static bool8 MakeBasesToMax(void); +static bool8 BaseLocation(void); +static bool8 MoveYourBase_JoypadAction(void); +static bool8 SwitchToMoveYourBaseSubmenu(void); +static bool8 MovingPKMN(void); +static bool8 Give999OfAllBerries(void); +static bool8 GiveAllDecorations(void); +static bool8 FishingPoints(void); +static void NakaGenderTest_PrintSpeciesName(u8); +static void NakaGenderTest_PrintSpeciesGender(u8); +static void NakaGenderTest_PrintSpeciesLevel(u8); +static void NakaGenderTest_JoypadAction(u8); +static bool8 NakaGenderTest_HandleJoypad(void); +static u8 NakaGenderTest_ForceRerollPokemon(u8); +static bool8 SetPokeblock(void); + +// ======================================================= +// TOP MENU +// ======================================================= + +static const u8 Str_843E36C[] = _("Berries"); +static const u8 Str_843E374[] = _("Goods"); +static const u8 Str_843E37A[] = _("{PKMN} list"); +static const u8 Str_843E382[] = _("トラップ"); +static const u8 Str_843E387[] = _("Move your base"); +static const u8 Str_843E396[] = _("Moving {PKMN}"); +static const u8 Str_843E3A0[] = _("Fishing points"); +static const u8 Str_843E3AF[] = _("Set {POKEBLOCK}"); +static const u8 Str_843E3B9[] = _("Make bases(to max)"); +static const u8 Str_843E3CC[] = _("Base location"); + +static const struct MenuAction sNakamuraTopMenuActions[] = { + { Str_843E36C, Give999OfAllBerries }, + { Str_843E37A, SwitchToPkmnListMenu }, + { Str_843E374, GiveAllDecorations }, + { Str_843E387, SwitchToMoveYourBaseSubmenu }, + { Str_843E3B9, MakeBasesToMax }, + { Str_843E3CC, BaseLocation }, + { Str_843E396, MovingPKMN }, + { Str_843E3A0, FishingPoints }, + { Str_843E3AF, SetPokeblock }, }; -const u8 Str_843E550[] = _("R"); -const u8 Str_843E552[] = _("X"); -const u8 Str_843E554[] = _("Y"); -const u8 Str_843E556[] = _( - "♂1\n" - "♂2\n" - "♂3\n" - "♂4\n" - "♂5\n" - "♀1\n" - "♀2\n" - "♀3\n" - "♀4\n" - "♀5"); -const u8 Str_843E574[] = _("ー"); -const u8 Str_843E576[][2] = { - _("あ"), - _("ア"), - _("A"), - _("a"), - _("0") -}; -const u8 Str_843E580[] = _( - "ADD\n" - "DEL\n" - "EXIT"); -const u8 Str_843E58D[] = _( - "Fishing location R119\n" - " Y1\n" - " Y2\n" - " Y3\n" - "Encounter location\n" - "\n" - "\n" - "front of you"); -const u8 _843E5D1[] = {0x0F, 0x16, 0x19}; -const u8 Str_843E5D4[] = _( - "Aボタン {ESCAPE}\p" - "  Bボタン ー\n" - "START けってい"); - -const u8 Str_843E5F0[] = _("?"); -const u8 Str_843E5F2[] = _("HP どりょくち"); -const u8 Str_843E5FB[] = _("こうげき どりょくち"); -const u8 Str_843E606[] = _("ぼうぎょ どりょくち"); -const u8 Str_843E611[] = _("すばやさ どりょくち"); -const u8 Str_843E61C[] = _("とくこう どりょくち"); -const u8 Str_843E627[] = _("とくぼう どりょくち"); -const u8 Str_843E632[] = _("なつきど"); -const u8 Str_843E637[] = _("どりょくち ごうけい"); -const u8 Str_843E642[] = _("ここから"); -const u8 Str_843E647[] = _("ここまで"); -const u8 Str_843E64C[] = _("かいすう"); -const u8 Str_843E651[] = _("けっか"); -const u8 Str_843E655[] = _("かい"); -const u8 Str_843E658[] = _("0"); -const u8 Str_843E65A[] = _("はんい"); - -void debug_sub_815F1B8(void) +static void DrawNakamuraDebugMenu(void) { Menu_EraseScreen(); Menu_DrawStdWindowFrame(14, 0, 29, 19); - Menu_PrintItems(16, 1, ARRAY_COUNT(_843E3DC), _843E3DC); - InitMenu(0, 15, 1, ARRAY_COUNT(_843E3DC), 0, 14); + Menu_PrintItems(16, 1, ARRAY_COUNT(sNakamuraTopMenuActions), sNakamuraTopMenuActions); + InitMenu(0, 15, 1, ARRAY_COUNT(sNakamuraTopMenuActions), 0, 14); } bool8 InitNakamuraDebugMenu(void) { - debug_sub_815F1B8(); - gMenuCallback = debug_sub_815F214; + DrawNakamuraDebugMenu(); + gMenuCallback = TopMenu_HandleJoypad; return FALSE; } -bool8 debug_sub_815F214(void) +static bool8 TopMenu_HandleJoypad(void) { if (gMain.newKeys & DPAD_UP) { @@ -254,7 +99,7 @@ bool8 debug_sub_815F214(void) if (gMain.newKeys & A_BUTTON) { - MenuFunc func = _843E3DC[Menu_GetCursorPos()].func; + MenuFunc func = sNakamuraTopMenuActions[Menu_GetCursorPos()].func; Menu_DestroyCursor(); return func(); } @@ -268,27 +113,131 @@ bool8 debug_sub_815F214(void) return FALSE; } -void debug_sub_815F284(u8 taskId) +// ======================================================= +// PKMN LIST +// ======================================================= + +static void Task_SwitchToPkmnListMenu(u8 taskId) { if (!gPaletteFade.active) { - debug_sub_81381B4(); - OpenPartyMenu(5, 0); + Debug_CopyLastThreePartyMonsToMultiPartnerParty(); + OpenPartyMenu(PARTY_MENU_TYPE_LINK_MULTI_BATTLE, 0); DestroyTask(taskId); } } -bool8 debug_sub_815F2B4(void) +static bool8 SwitchToPkmnListMenu(void) { CloseMenu(); Menu_EraseScreen(); - gMain.savedCallback = sub_805469C; - CreateTask(debug_sub_815F284, 0); + gMain.savedCallback = c2_exit_to_overworld_1_sub_8080DEC; + CreateTask(Task_SwitchToPkmnListMenu, 0); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); return TRUE; } -bool8 debug_sub_815F2F4(void) +// ======================================================= +// MAKE BASES TO MAX and BASE LOCATION +// ======================================================= + +EWRAM_DATA u8 sSecretBaseIdx = 0; + +static const u8 sSecretBaseTemplates[] = { + // ID, Route, X, Y + 0x01, 118, 47, 14 , + 0x02, 125, 53, 10 , + 0x03, 113, 49, 8 , + 0x0B, 118, 67, 6 , + 0x0C, 121, 40, 11 , + 0x0D, 111, 35, 1 , + 0x15, 115, 20, 53 , + 0x16, 121, 18, 13 , + 0x17, 119, 26, 81 , + 0x1F, 127, 59, 67 , + 0x20, 125, 55, 11 , + 0x21, 111, 27, 27 , + 0x29, 114, 9, 47 , + 0x2A, 115, 32, 39 , + 0x2B, 115, 23, 8 , + 0x33, 114, 30, 51 , + 0x34, 115, 26, 15 , + 0x35, 115, 32, 46 , + 0x3D, 114, 11, 62 , + 0x3E, 115, 21, 18 , + 0x3F, 115, 25, 24 , + 0x47, 114, 19, 70 , + 0x48, 115, 32, 6 , + 0x49, 114, 32, 57 , + 0x51, 116, 71, 4 , + 0x52, 123, 47, 3 , + 0x53, 123, 57, 5 , + 0x5B, 116, 79, 11 , + 0x5C, 123, 49, 3 , + 0x5D, 120, 18, 12 , + 0x65, 120, 28, 62 , + 0x66, 116, 56, 6 , + 0x67, 119, 16, 81 , + 0x6F, 120, 30, 62 , + 0x70, 116, 55, 15 , + 0x71, 119, 16, 28 , + 0x79, 111, 33, 34 , + 0x7A, 118, 29, 5 , + 0x7B, 127, 45, 24 , + 0x83, 111, 24, 36 , + 0x84, 125, 7, 25 , + 0x85, 115, 8, 30 , + 0x8D, 111, 34, 50 , + 0x8E, 127, 59, 72 , + 0x8F, 127, 61, 21 , + 0x97, 127, 67, 63 , + 0x98, 125, 24, 32 , + 0x99, 111, 35, 31 , + 0xA1, 111, 13, 19 , + 0xA2, 121, 43, 7 , + 0xA3, 118, 47, 5 , + 0xA4, 111, 14, 19 , + 0xAB, 118, 46, 5 , + 0xAC, 121, 42, 7 , + 0xAD, 119, 19, 76 , + 0xAE, 115, 7, 20 , + 0xB5, 110, 16, 25 , + 0xB6, 114, 11, 27 , + 0xB7, 115, 8, 20 , + 0xBF, 110, 17, 25 , + 0xC0, 114, 12, 27 , + 0xC1, 119, 18, 76 , + 0xC9, 119, 5, 2 , + 0xCA, 119, 4, 89 , + 0xCB, 120, 38, 54 , + 0xCC, 120, 5, 76 , + 0xD3, 119, 5, 15 , + 0xD4, 119, 7, 101 , + 0xD5, 120, 31, 23 , + 0xDD, 119, 34, 24 , + 0xDE, 120, 26, 10 , + 0xDF, 119, 4, 15 , + 0xE7, 119, 31, 73 , + 0xE8, 120, 29, 85 , + 0xE9, 119, 6, 2 , +}; + +static const u8 Str_843E550[] = _("R"); +static const u8 Str_843E552[] = _("X"); +static const u8 Str_843E554[] = _("Y"); +static const u8 Str_843E556[] = _( + "♂1\n" + "♂2\n" + "♂3\n" + "♂4\n" + "♂5\n" + "♀1\n" + "♀2\n" + "♀3\n" + "♀4\n" + "♀5"); + +static bool8 MakeBasesToMax(void) { u8 i; CloseMenu(); @@ -313,7 +262,7 @@ bool8 debug_sub_815F2F4(void) do { - gSaveBlock1.secretBases[i].secretBaseId = _843E424[(Random() % (ARRAY_COUNT(_843E424) / 4)) * 4]; + gSaveBlock1.secretBases[i].secretBaseId = sSecretBaseTemplates[(Random() % (ARRAY_COUNT(sSecretBaseTemplates) / 4)) * 4]; for (j = 0; j < i; j++) { @@ -342,72 +291,72 @@ bool8 debug_sub_815F2F4(void) return TRUE; } -void debug_sub_815F470(u8 * a0, u8 * a1, u8 * a2) +static void BaseLocation_GetCurSecretBaseData(u8 * R, u8 * X, u8 * Y) { u8 i; - u8 sbId = gSaveBlock1.secretBases[_nakamuraData0].secretBaseId; + u8 sbId = gSaveBlock1.secretBases[sSecretBaseIdx].secretBaseId; - for (i = 0; i < ARRAY_COUNT(_843E424) / 4; i++) + for (i = 0; i < ARRAY_COUNT(sSecretBaseTemplates) / 4; i++) { - if (_843E424[i * 4] == sbId) + if (sSecretBaseTemplates[i * 4] == sbId) { - *a0 = _843E424[i * 4 + 1]; - *a1 = _843E424[i * 4 + 2]; - *a2 = _843E424[i * 4 + 3]; + *R = sSecretBaseTemplates[i * 4 + 1]; + *X = sSecretBaseTemplates[i * 4 + 2]; + *Y = sSecretBaseTemplates[i * 4 + 3]; break; } } } -void debug_sub_815F4D8(void) +static void BaseLocation_Redraw(void) { Menu_BlankWindowRect(1, 1, 10, 10); - ConvertIntToDecimalStringN(gStringVar1, _nakamuraData0, STR_CONV_MODE_LEFT_ALIGN, 2); + ConvertIntToDecimalStringN(gStringVar1, sSecretBaseIdx, STR_CONV_MODE_LEFT_ALIGN, 2); Menu_PrintText(gStringVar1, 1, 1); - if (gSaveBlock1.secretBases[_nakamuraData0].secretBaseId != 0) + if (gSaveBlock1.secretBases[sSecretBaseIdx].secretBaseId != 0) { - u8 a0; - u8 a1; - u8 a2; - debug_sub_815F470(&a0, &a1, &a2); + u8 R; + u8 X; + u8 Y; + BaseLocation_GetCurSecretBaseData(&R, &X, &Y); - sub_80BC190(gStringVar1, _nakamuraData0); + sub_80BC190(gStringVar1, sSecretBaseIdx); Menu_PrintText(gStringVar1, 1, 3); Menu_PrintText(Str_843E550, 1, 5); - ConvertIntToDecimalStringN(gStringVar1, a0, STR_CONV_MODE_LEFT_ALIGN, 3); + ConvertIntToDecimalStringN(gStringVar1, R, STR_CONV_MODE_LEFT_ALIGN, 3); Menu_PrintText(gStringVar1, 2, 5); Menu_PrintText(Str_843E552, 1, 7); - ConvertIntToDecimalStringN(gStringVar1, a1, STR_CONV_MODE_LEFT_ALIGN, 3); + ConvertIntToDecimalStringN(gStringVar1, X, STR_CONV_MODE_LEFT_ALIGN, 3); Menu_PrintText(gStringVar1, 3, 7); Menu_PrintText(Str_843E554, 1, 9); - ConvertIntToDecimalStringN(gStringVar1, a2, STR_CONV_MODE_LEFT_ALIGN, 3); + ConvertIntToDecimalStringN(gStringVar1, Y, STR_CONV_MODE_LEFT_ALIGN, 3); Menu_PrintText(gStringVar1, 3, 9); } } -bool8 debug_sub_815F5C4(void) +static bool8 BaseLocation_HandleJoypad(void) { if (gMain.newKeys & DPAD_LEFT) { - if (_nakamuraData0 == 0) - _nakamuraData0 = 19; + if (sSecretBaseIdx == 0) + sSecretBaseIdx = 19; else - _nakamuraData0--; - debug_sub_815F4D8(); + sSecretBaseIdx--; + BaseLocation_Redraw(); return FALSE; } if (gMain.newKeys & DPAD_RIGHT) { - if (_nakamuraData0 == 19) - _nakamuraData0 = 0; + if (sSecretBaseIdx == 19) + sSecretBaseIdx = 0; else - _nakamuraData0++; - debug_sub_815F4D8(); + sSecretBaseIdx++; + BaseLocation_Redraw(); return FALSE; } @@ -420,19 +369,36 @@ bool8 debug_sub_815F5C4(void) return FALSE; } -bool8 debug_sub_815F62C(void) +static bool8 BaseLocation(void) { - _nakamuraData0 = 0; - gMenuCallback = debug_sub_815F5C4; + sSecretBaseIdx = 0; + gMenuCallback = BaseLocation_HandleJoypad; Menu_EraseWindowRect(0, 0, 29, 19); Menu_DrawStdWindowFrame(0, 0, 11, 11); - debug_sub_815F4D8(); + BaseLocation_Redraw(); return FALSE; } -void debug_sub_815F668(void) +// ======================================================= +// MOVE YOUR BASE +// ======================================================= + +EWRAM_DATA u8 sMoveYourBase_CursorPos = 0; +EWRAM_DATA u8 sMoveYourBase_XCursorPos = 0; +EWRAM_DATA u8 sSecretBaseNameCharGroup = 0; + +static const u8 Str_843E574[] = _("ー"); +static const u8 Str_843E576[][2] = { + _("あ"), + _("ア"), + _("A"), + _("a"), + _("0") +}; + +static void MoveYourBase_PrintSBOwnerID(void) { - u8 * otIdPtr = gSaveBlock1.secretBases[_nakamuraData0].trainerId; + u8 * otIdPtr = gSaveBlock1.secretBases[sSecretBaseIdx].trainerId; u32 otId = (otIdPtr[3] << 24) | (otIdPtr[2] << 16) | (otIdPtr[1] << 8) | (otIdPtr[0] << 0); ConvertIntToDecimalStringN(gStringVar1, otId / 100000, STR_CONV_MODE_LEADING_ZEROS, 5); Menu_PrintText(gStringVar1, 2, 7); @@ -440,49 +406,49 @@ void debug_sub_815F668(void) Menu_PrintText(gStringVar1, 7, 7); } -void debug_sub_815F6E4(void) +static void MoveYourBase_PrintSBOwnerName(void) { Menu_BlankWindowRect(2, 3, 11, 4); - *StringCopyN(gStringVar1, gSaveBlock1.secretBases[_nakamuraData0].playerName, 7) = EOS; + *StringCopyN(gStringVar1, gSaveBlock1.secretBases[sSecretBaseIdx].playerName, 7) = EOS; Menu_PrintText(gStringVar1, 2, 3); } -void debug_sub_815F72C(void) +static void MoveYourBase_Redraw(void) { Menu_BlankWindowRect(2, 1, 11, 10); - ConvertIntToDecimalStringN(gStringVar1, _nakamuraData0, STR_CONV_MODE_LEFT_ALIGN, 2); + ConvertIntToDecimalStringN(gStringVar1, sSecretBaseIdx, STR_CONV_MODE_LEFT_ALIGN, 2); Menu_PrintText(gStringVar1, 2, 1); - if (gSaveBlock1.secretBases[_nakamuraData0].secretBaseId != 0) + if (gSaveBlock1.secretBases[sSecretBaseIdx].secretBaseId != 0) { - debug_sub_815F6E4(); - debug_sub_815F668(); + MoveYourBase_PrintSBOwnerName(); + MoveYourBase_PrintSBOwnerID(); } } -void debug_sub_815F788(void) +static void MoveYourBase_UpdateXCursorPosition(void) { Menu_BlankWindowRect(2, 5, 11, 6); - Menu_PrintText(Str_843E574, _nakamuraData2 + 2, 5); + Menu_PrintText(Str_843E574, sMoveYourBase_XCursorPos + 2, 5); } -void debug_sub_815F7B4(void) +static void MoveYourBase_PrintCharacterSetName(void) { - if (_nakamuraData1) + if (sMoveYourBase_CursorPos) Menu_BlankWindowRect(11, 1, 11, 2); else - Menu_PrintText(Str_843E576[_nakamuraData3], 11, 1); + Menu_PrintText(Str_843E576[sSecretBaseNameCharGroup], 11, 1); } -void debug_sub_815F7F0(s8 a0) +static void MoveYourBase_EditOwnerID(s8 direction) { - u8 * otIdPtr = gSaveBlock1.secretBases[_nakamuraData0].trainerId; + u8 * otIdPtr = gSaveBlock1.secretBases[sSecretBaseIdx].trainerId; u32 otId = (otIdPtr[3] << 24) | (otIdPtr[2] << 16) | (otIdPtr[1] << 8) | (otIdPtr[0] << 0); - s8 r4; - int r1 = a0; + s8 digit; + int r1 = direction; - for (r4 = 9; r4 > _nakamuraData2; r4--) + for (digit = 9; digit > sMoveYourBase_XCursorPos; digit--) r1 *= 10; otId += r1; @@ -490,105 +456,105 @@ void debug_sub_815F7F0(s8 a0) otIdPtr[2] = (otId & 0x00FF0000) >> 16; otIdPtr[1] = (otId & 0x0000FF00) >> 8; otIdPtr[0] = (otId & 0x000000FF) >> 0; - debug_sub_815F668(); + MoveYourBase_PrintSBOwnerID(); } -void debug_sub_815F86C(s8 a0) +static void MoveYourBase_EditOwnerNameChar(s8 a0) { - u8 * namePtr = gSaveBlock1.secretBases[_nakamuraData0].playerName; + u8 * namePtr = gSaveBlock1.secretBases[sSecretBaseIdx].playerName; u8 r2 = 0; u8 r3 = 0; u8 i; if (a0 == 100) { - for (i = _nakamuraData2; i < 7; i++) + for (i = sMoveYourBase_XCursorPos; i < 7; i++) { namePtr[i] = EOS; } } else { - switch (_nakamuraData3) + switch (sSecretBaseNameCharGroup) { - case 0: + case 0: // HIRA r3 = 1; r2 = 80; break; - case 1: + case 1: // KATA r3 = 81; r2 = 160; break; - case 2: + case 2: // A-Z r3 = CHAR_A; r2 = CHAR_Z; break; - case 3: + case 3: // a-z r3 = CHAR_a; r2 = CHAR_z; break; - case 4: + case 4: // 0-9 r3 = CHAR_0; r2 = CHAR_0 + 9; break; } - namePtr[_nakamuraData2] += a0; - if (namePtr[_nakamuraData2] < r3) - namePtr[_nakamuraData2] = r2; - if (namePtr[_nakamuraData2] > r2) - namePtr[_nakamuraData2] = r3; + namePtr[sMoveYourBase_XCursorPos] += a0; + if (namePtr[sMoveYourBase_XCursorPos] < r3) + namePtr[sMoveYourBase_XCursorPos] = r2; + if (namePtr[sMoveYourBase_XCursorPos] > r2) + namePtr[sMoveYourBase_XCursorPos] = r3; } - debug_sub_815F6E4(); + MoveYourBase_PrintSBOwnerName(); } -bool8 debug_sub_815F930(void) +static bool8 MoveYourBase_HandleJoypad_2(void) { - u32 r4 = _nakamuraData1 == 0 ? 7 : 10; + u32 r4 = sMoveYourBase_CursorPos == 0 ? 7 : 10; if (gMain.newAndRepeatedKeys & DPAD_UP) { - if (_nakamuraData1) - debug_sub_815F7F0(1); + if (sMoveYourBase_CursorPos) + MoveYourBase_EditOwnerID(1); else - debug_sub_815F86C(1); + MoveYourBase_EditOwnerNameChar(1); return FALSE; } if (gMain.newAndRepeatedKeys & DPAD_DOWN) { - if (_nakamuraData1) - debug_sub_815F7F0(-1); + if (sMoveYourBase_CursorPos) + MoveYourBase_EditOwnerID(-1); else - debug_sub_815F86C(-1); + MoveYourBase_EditOwnerNameChar(-1); return FALSE; } if (gMain.newAndRepeatedKeys & DPAD_LEFT) { - if (_nakamuraData2 == 0) - _nakamuraData2 = r4 - 1; + if (sMoveYourBase_XCursorPos == 0) + sMoveYourBase_XCursorPos = r4 - 1; else - _nakamuraData2--; - debug_sub_815F788(); + sMoveYourBase_XCursorPos--; + MoveYourBase_UpdateXCursorPosition(); return FALSE; } if (gMain.newAndRepeatedKeys & DPAD_RIGHT) { - if (_nakamuraData2 == r4 - 1) - _nakamuraData2 = 0; + if (sMoveYourBase_XCursorPos == r4 - 1) + sMoveYourBase_XCursorPos = 0; else - _nakamuraData2++; - debug_sub_815F788(); + sMoveYourBase_XCursorPos++; + MoveYourBase_UpdateXCursorPosition(); return FALSE; } if (gMain.newKeys & SELECT_BUTTON) { - if (_nakamuraData1 == 0) - _nakamuraData3 = (_nakamuraData3 + 1) % 5; - debug_sub_815F7B4(); + if (sMoveYourBase_CursorPos == 0) + sSecretBaseNameCharGroup = (sSecretBaseNameCharGroup + 1) % 5; + MoveYourBase_PrintCharacterSetName(); return FALSE; } @@ -596,21 +562,21 @@ bool8 debug_sub_815F930(void) { Menu_BlankWindowRect(2, 5, 11, 6); Menu_BlankWindowRect(11, 1, 11, 2); - gMenuCallback = debug_sub_815FA38; + gMenuCallback = MoveYourBase_JoypadAction; return FALSE; } if (gMain.newKeys & B_BUTTON) { - if (_nakamuraData1 == 0) - debug_sub_815F86C(100); + if (sMoveYourBase_CursorPos == 0) + MoveYourBase_EditOwnerNameChar(100); return FALSE; } return FALSE; } -bool8 debug_sub_815FA38(void) +static bool8 MoveYourBase_JoypadAction(void) { if (gMain.newKeys & DPAD_UP) { @@ -626,33 +592,33 @@ bool8 debug_sub_815FA38(void) if (gMain.newKeys & DPAD_LEFT) { - if (_nakamuraData0 == 0) - _nakamuraData0 = 19; + if (sSecretBaseIdx == 0) + sSecretBaseIdx = 19; else - _nakamuraData0--; - debug_sub_815F72C(); + sSecretBaseIdx--; + MoveYourBase_Redraw(); return FALSE; } if (gMain.newKeys & DPAD_RIGHT) { - if (_nakamuraData0 == 19) - _nakamuraData0 = 0; + if (sSecretBaseIdx == 19) + sSecretBaseIdx = 0; else - _nakamuraData0++; - debug_sub_815F72C(); + sSecretBaseIdx++; + MoveYourBase_Redraw(); return FALSE; } if (gMain.newKeys & A_BUTTON) { - if (_nakamuraData0 != 0 && gSaveBlock1.secretBases[_nakamuraData0].secretBaseId != 0) + if (sSecretBaseIdx != 0 && gSaveBlock1.secretBases[sSecretBaseIdx].secretBaseId != 0) { - _nakamuraData1 = Menu_GetCursorPos(); - _nakamuraData2 = 0; - debug_sub_815F788(); - debug_sub_815F7B4(); - gMenuCallback = debug_sub_815F930; + sMoveYourBase_CursorPos = Menu_GetCursorPos(); + sMoveYourBase_XCursorPos = 0; + MoveYourBase_UpdateXCursorPosition(); + MoveYourBase_PrintCharacterSetName(); + gMenuCallback = MoveYourBase_HandleJoypad_2; } return FALSE; } @@ -666,19 +632,28 @@ bool8 debug_sub_815FA38(void) return FALSE; } -bool8 debug_sub_815FB1C(void) +static bool8 SwitchToMoveYourBaseSubmenu(void) { - _nakamuraData0 = 0; - _nakamuraData3 = 0; - gMenuCallback = debug_sub_815FA38; + sSecretBaseIdx = 0; + sSecretBaseNameCharGroup = 0; + gMenuCallback = MoveYourBase_JoypadAction; Menu_EraseWindowRect(0, 0, 29, 19); Menu_DrawStdWindowFrame(0, 0, 12, 11); - debug_sub_815F72C(); + MoveYourBase_Redraw(); InitMenu(0, 1, 3, 3, 0, 11); return FALSE; } -bool8 debug_sub_815FB78(void) +// ======================================================= +// MOVING PKMN (aka Roamers) +// ======================================================= + +static const u8 Str_843E580[] = _( + "ADD\n" + "DEL\n" + "EXIT"); + +static bool8 MovingPKMN_HandleJoypad(void) { if (gMain.newKeys & DPAD_UP) { @@ -698,7 +673,7 @@ bool8 debug_sub_815FB78(void) switch (Menu_GetCursorPos()) { case 0: - debug_sub_814A714(); + Debug_CreateRoamer(); break; case 1: ClearRoamerData(); @@ -717,11 +692,11 @@ bool8 debug_sub_815FB78(void) return FALSE; } -bool8 debug_sub_815FBE8(void) +static bool8 MovingPKMN(void) { - gMenuCallback = debug_sub_815FB78; + gMenuCallback = MovingPKMN_HandleJoypad; Menu_EraseWindowRect(0, 0, 29, 19); - debug_sub_814A73C(gStringVar1); + Debug_GetRoamerLocation(gStringVar1); Menu_DrawStdWindowFrame(0, 0, 11, 9); Menu_PrintText(gStringVar1, 1, 1); Menu_PrintText(Str_843E580, 2, 3); @@ -729,7 +704,11 @@ bool8 debug_sub_815FBE8(void) return FALSE; } -bool8 debug_sub_815FC54(void) +// ======================================================= +// GIVE ALL BERRIES +// ======================================================= + +static bool8 Give999OfAllBerries(void) { u16 i; @@ -743,28 +722,46 @@ bool8 debug_sub_815FC54(void) return TRUE; } -bool8 debug_sub_815FC94(void) +// ======================================================= +// GIVE ALL DECORATIONS +// ======================================================= + +static bool8 GiveAllDecorations(void) { ClearDecorationInventories(); - debug_sub_814A3A8(); + Debug_GiveAllDecorations(); Menu_EraseWindowRect(0, 0, 29, 19); CloseMenu(); return TRUE; } -u16 debug_sub_815FCB4(u8 a0) +// ======================================================= +// FISHING POINTS (Feebas) +// ======================================================= + +static const u8 Str_843E58D[] = _( + "Fishing location R119\n" + " Y1\n" + " Y2\n" + " Y3\n" + "Encounter location\n" + "\n" + "\n" + "front of you"); + +static u16 FishingPoints_CountFishingTilesInMapThird(u8 a0) { u16 retval = 0; u16 height = gMapHeader.mapData->height / 3; - u16 r6; - u16 r4; + u16 y; + u16 x; u16 start = height * a0; - for (r6 = start; r6 < start + height; r6++) + for (y = start; y < start + height; y++) { - for (r4 = 0; r4 < gMapHeader.mapData->width; r4++) + for (x = 0; x < gMapHeader.mapData->width; x++) { - if (sub_805759C(MapGridGetMetatileBehaviorAt(r4 + 7, r6 + 7)) == TRUE) + if (sub_805759C(MapGridGetMetatileBehaviorAt(x + 7, y + 7)) == TRUE) { retval++; } @@ -774,7 +771,7 @@ u16 debug_sub_815FCB4(u8 a0) return retval; } -u16 debug_sub_815FD40(void) +static u16 FishingPoints_GetIndexOfCurrentFishingSpot(void) { u16 retval = 0; s16 x; @@ -801,7 +798,7 @@ u16 debug_sub_815FD40(void) return retval + 1; } -bool8 debug_sub_815FDE4(void) +static bool8 FishingPoints_HandleJoypad(void) { if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) { @@ -813,59 +810,76 @@ bool8 debug_sub_815FDE4(void) return FALSE; } -bool8 debug_sub_815FE1C(void) +static bool8 FishingPoints(void) { - u16 r7; - u16 r5; + u16 nWaterTiles; + u16 nFeebas; Menu_EraseWindowRect(0, 0, 29, 19); Menu_DrawStdWindowFrame(0, 0, 16, 19); Menu_PrintText(Str_843E58D, 1, 1); - ConvertIntToDecimalStringN(gStringVar1, debug_sub_815FCB4(0), STR_CONV_MODE_RIGHT_ALIGN, 5); + ConvertIntToDecimalStringN(gStringVar1, FishingPoints_CountFishingTilesInMapThird(0), STR_CONV_MODE_RIGHT_ALIGN, 5); Menu_PrintText(gStringVar1, 5, 3); - ConvertIntToDecimalStringN(gStringVar1, debug_sub_815FCB4(1), STR_CONV_MODE_RIGHT_ALIGN, 5); + ConvertIntToDecimalStringN(gStringVar1, FishingPoints_CountFishingTilesInMapThird(1), STR_CONV_MODE_RIGHT_ALIGN, 5); Menu_PrintText(gStringVar1, 5, 5); - ConvertIntToDecimalStringN(gStringVar1, debug_sub_815FCB4(2), STR_CONV_MODE_RIGHT_ALIGN, 5); + ConvertIntToDecimalStringN(gStringVar1, FishingPoints_CountFishingTilesInMapThird(2), STR_CONV_MODE_RIGHT_ALIGN, 5); Menu_PrintText(gStringVar1, 5, 7); - ConvertIntToDecimalStringN(gStringVar1, debug_sub_8092344(0), STR_CONV_MODE_RIGHT_ALIGN, 5); + ConvertIntToDecimalStringN(gStringVar1, FeebasDebug_GetTrueNumberOfWaterTilesInMapThird(0), STR_CONV_MODE_RIGHT_ALIGN, 5); Menu_PrintText(gStringVar1, 11, 3); - ConvertIntToDecimalStringN(gStringVar1, debug_sub_8092344(1), STR_CONV_MODE_RIGHT_ALIGN, 5); + ConvertIntToDecimalStringN(gStringVar1, FeebasDebug_GetTrueNumberOfWaterTilesInMapThird(1), STR_CONV_MODE_RIGHT_ALIGN, 5); Menu_PrintText(gStringVar1, 11, 5); - ConvertIntToDecimalStringN(gStringVar1, debug_sub_8092344(2), STR_CONV_MODE_RIGHT_ALIGN, 5); + ConvertIntToDecimalStringN(gStringVar1, FeebasDebug_GetTrueNumberOfWaterTilesInMapThird(2), STR_CONV_MODE_RIGHT_ALIGN, 5); Menu_PrintText(gStringVar1, 11, 7); FeebasSeedRng(gSaveBlock1.easyChatPairs[0].unk2); - r7 = debug_sub_815FCB4(0) + debug_sub_815FCB4(1) + debug_sub_815FCB4(2); - r5 = 0; + nWaterTiles = FishingPoints_CountFishingTilesInMapThird(0) + FishingPoints_CountFishingTilesInMapThird(1) + FishingPoints_CountFishingTilesInMapThird(2); + nFeebas = 0; - while (r5 != 6) + while (nFeebas != 6) { - u16 r1 = FeebasRandom() % r7; - if (r1 == 0) - r1 = r7; - if (r1 == 0 || r1 > 3) + u16 randTile = FeebasRandom() % nWaterTiles; + if (randTile == 0) + randTile = nWaterTiles; + if (randTile == 0 || randTile > 3) { - ConvertIntToDecimalStringN(gStringVar1, r1, STR_CONV_MODE_RIGHT_ALIGN, 4); - Menu_PrintText(gStringVar1, (r5 % 3) * 5 + 2, (r5 / 3) * 2 + 11); - r5++; + ConvertIntToDecimalStringN(gStringVar1, randTile, STR_CONV_MODE_RIGHT_ALIGN, 4); + Menu_PrintText(gStringVar1, (nFeebas % 3) * 5 + 2, (nFeebas / 3) * 2 + 11); + nFeebas++; } } - ConvertIntToDecimalStringN(gStringVar1, debug_sub_815FD40(), STR_CONV_MODE_RIGHT_ALIGN, 4); + ConvertIntToDecimalStringN(gStringVar1, FishingPoints_GetIndexOfCurrentFishingSpot(), STR_CONV_MODE_RIGHT_ALIGN, 4); Menu_PrintText(gStringVar1, 2, 17); - gMenuCallback = debug_sub_815FDE4; + gMenuCallback = FishingPoints_HandleJoypad; return FALSE; } -void debug_sub_815FFDC(void) +// ======================================================= +// GENDER TEST? +// ======================================================= + +static struct { + s16 species; + s8 level; + u8 unk3; +} sNakaGenderTestData[PARTY_SIZE]; + +EWRAM_DATA u8 sNakaGenderTest_CursorPosition = 0; +static const u8 _843E5D1[] = {0x0F, 0x16, 0x19}; +static const u8 Str_843E5D4[] = _( + "Aボタン {ESCAPE}\p" + "  Bボタン ー\n" + "START けってい"); + +void NakaGenderTest(void) { u8 i; @@ -875,37 +889,34 @@ void debug_sub_815FFDC(void) for (i = 0; i < PARTY_SIZE; i++) { - _nakamuraStatic0[i].species = GetMonData(gPlayerParty + i, MON_DATA_SPECIES); - if (_nakamuraStatic0[i].species != SPECIES_NONE) + sNakaGenderTestData[i].species = GetMonData(gPlayerParty + i, MON_DATA_SPECIES); + if (sNakaGenderTestData[i].species != SPECIES_NONE) { - _nakamuraStatic0[i].level = GetMonData(gPlayerParty + i, MON_DATA_LEVEL); - debug_sub_816009C(i); - debug_sub_81600D0(i); - debug_sub_816013C(i); + sNakaGenderTestData[i].level = GetMonData(gPlayerParty + i, MON_DATA_LEVEL); + NakaGenderTest_PrintSpeciesName(i); + NakaGenderTest_PrintSpeciesGender(i); + NakaGenderTest_PrintSpeciesLevel(i); } else - _nakamuraStatic0[i].level = 1; - _nakamuraStatic0[i].unk3 = 0; + sNakaGenderTestData[i].level = 1; + sNakaGenderTestData[i].unk3 = 0; } - _nakamuraData4 = 0; + sNakaGenderTest_CursorPosition = 0; PrintTriangleCursorWithPalette(15, 1, 0xFF); - gMenuCallback = debug_sub_8160498; + gMenuCallback = NakaGenderTest_HandleJoypad; } -void debug_sub_816009C(u8 i) +static void NakaGenderTest_PrintSpeciesName(u8 i) { - Menu_PrintText(gSpeciesNames[_nakamuraStatic0[i].species], 16, 2 * i + 1); + Menu_PrintText(gSpeciesNames[sNakaGenderTestData[i].species], 16, 2 * i + 1); } -void debug_sub_81600D0(u8 i) +static void NakaGenderTest_PrintSpeciesGender(u8 i) { - // u8 sp0[] = _("?"); - - u8 sp0[2]; + u8 sp0[] = _("?"); u8 gender; - memcpy(sp0, Str_843E5F0, sizeof Str_843E5F0); gender = GetMonGender(gPlayerParty + i); if (gender == MON_MALE) Menu_PrintText(gOtherText_MaleSymbol2, 23, 2 * i + 1); @@ -915,58 +926,58 @@ void debug_sub_81600D0(u8 i) Menu_PrintText(sp0, 23, 2 * i + 1); } -void debug_sub_816013C(u8 i) +static void NakaGenderTest_PrintSpeciesLevel(u8 i) { - ConvertIntToDecimalStringN(gStringVar1, _nakamuraStatic0[i].level, STR_CONV_MODE_RIGHT_ALIGN, 3); + ConvertIntToDecimalStringN(gStringVar1, sNakaGenderTestData[i].level, STR_CONV_MODE_RIGHT_ALIGN, 3); Menu_PrintText(gStringVar1, 26, 2 * i + 1); } -void debug_sub_816017C(u8 i) +static void NakaGenderTest_RedrawCurrent(u8 i) { Menu_BlankWindowRect(16, 2 * i + 1, 28, 2 * i + 2); - if (_nakamuraStatic0[i].species != SPECIES_NONE) + if (sNakaGenderTestData[i].species != SPECIES_NONE) { - debug_sub_816009C(i); - debug_sub_81600D0(i); - debug_sub_816013C(i); + NakaGenderTest_PrintSpeciesName(i); + NakaGenderTest_PrintSpeciesGender(i); + NakaGenderTest_PrintSpeciesLevel(i); } - debug_sub_81603B8(5); + NakaGenderTest_JoypadAction(5); } -void debug_sub_81601C8(u8 i, s8 dirn) +static void NakaGenderTest_AdjustSpecies(u8 i, s8 dirn) { - if (_nakamuraStatic0[i].species == SPECIES_NONE && _nakamuraStatic0[i].unk3 == 0 && dirn == 1) - _nakamuraStatic0[i].species = SPECIES_TREECKO - 1; - _nakamuraStatic0[i].species += dirn; - if (_nakamuraStatic0[i].species >= SPECIES_CHIMECHO) - _nakamuraStatic0[i].species -= SPECIES_CHIMECHO; - if (_nakamuraStatic0[i].species < 0) - _nakamuraStatic0[i].species += SPECIES_CHIMECHO; - CreateMon(gPlayerParty + i, _nakamuraStatic0[i].species, _nakamuraStatic0[i].level, 0x20, FALSE, 0, FALSE, 0); - _nakamuraStatic0[i].unk3 = 1; + if (sNakaGenderTestData[i].species == SPECIES_NONE && sNakaGenderTestData[i].unk3 == 0 && dirn == 1) + sNakaGenderTestData[i].species = SPECIES_TREECKO - 1; + sNakaGenderTestData[i].species += dirn; + if (sNakaGenderTestData[i].species >= SPECIES_CHIMECHO) + sNakaGenderTestData[i].species -= SPECIES_CHIMECHO; + if (sNakaGenderTestData[i].species < 0) + sNakaGenderTestData[i].species += SPECIES_CHIMECHO; + CreateMon(gPlayerParty + i, sNakaGenderTestData[i].species, sNakaGenderTestData[i].level, 0x20, FALSE, 0, FALSE, 0); + sNakaGenderTestData[i].unk3 = 1; } -void debug_sub_8160258(u8 i) +static void NakaGenderTest_RerollPokemon(u8 i) { - if (_nakamuraStatic0[i].species != SPECIES_NONE) - debug_sub_816062C(i); + if (sNakaGenderTestData[i].species != SPECIES_NONE) + NakaGenderTest_ForceRerollPokemon(i); } -void debug_sub_816027C(u8 i, s8 dirn) +static void NakaGenderTest_AdjustLevel(u8 i, s8 dirn) { - if (_nakamuraStatic0[i].species != SPECIES_NONE) + if (sNakaGenderTestData[i].species != SPECIES_NONE) { - _nakamuraStatic0[i].level += dirn; - if (_nakamuraStatic0[i].level > 100) - _nakamuraStatic0[i].level = 1; - if (_nakamuraStatic0[i].level < 1) - _nakamuraStatic0[i].level = 100; - SetMonData(gPlayerParty + i, MON_DATA_EXP, gExperienceTables[gBaseStats[_nakamuraStatic0[i].species].growthRate] + _nakamuraStatic0[i].level); - debug_sub_803F55C(gPlayerParty + i); + sNakaGenderTestData[i].level += dirn; + if (sNakaGenderTestData[i].level > 100) + sNakaGenderTestData[i].level = 1; + if (sNakaGenderTestData[i].level < 1) + sNakaGenderTestData[i].level = 100; + SetMonData(gPlayerParty + i, MON_DATA_EXP, gExperienceTables[gBaseStats[sNakaGenderTestData[i].species].growthRate] + sNakaGenderTestData[i].level); + Nakamura_NakaGenderTest_RecalcStats(gPlayerParty + i); } } -void debug_sub_8160308(void) +static void NakaGenderTest_PartyCompactionEnsureAtLeastOne(void) { u8 i; u8 j; @@ -992,129 +1003,129 @@ void debug_sub_8160308(void) } } -void debug_sub_81603B8(u8 i) +static void NakaGenderTest_JoypadAction(u8 i) { u8 q; u8 r; PlaySE(SE_SELECT); - q = _nakamuraData4 / 6; - r = _nakamuraData4 % 6; + q = sNakaGenderTest_CursorPosition / 6; + r = sNakaGenderTest_CursorPosition % 6; Menu_BlankWindowRect(_843E5D1[q], r * 2 + 1, _843E5D1[q], r * 2 + 2); if (i == 0) { if (r != 0) - _nakamuraData4--; + sNakaGenderTest_CursorPosition--; else - _nakamuraData4 = q * 6 + 5; + sNakaGenderTest_CursorPosition = q * 6 + 5; } if (i == 1) { if (r != 5) - _nakamuraData4++; + sNakaGenderTest_CursorPosition++; else - _nakamuraData4 = q * 6; + sNakaGenderTest_CursorPosition = q * 6; } if (i == 2) { if (q != 0) - _nakamuraData4 -= 6; + sNakaGenderTest_CursorPosition -= 6; else - _nakamuraData4 = 12 + r; + sNakaGenderTest_CursorPosition = 12 + r; } if (i == 3) { if (q != 2) - _nakamuraData4 += 6; + sNakaGenderTest_CursorPosition += 6; else - _nakamuraData4 = r; + sNakaGenderTest_CursorPosition = r; } - q = _nakamuraData4 / 6; - r = _nakamuraData4 % 6; + q = sNakaGenderTest_CursorPosition / 6; + r = sNakaGenderTest_CursorPosition % 6; PrintTriangleCursorWithPalette(_843E5D1[q], r * 2 + 1, 0xFF); } -bool8 debug_sub_8160498(void) +static bool8 NakaGenderTest_HandleJoypad(void) { if (gMain.newKeys & DPAD_UP) { - debug_sub_81603B8(0); + NakaGenderTest_JoypadAction(0); return FALSE; } if (gMain.newKeys & DPAD_DOWN) { - debug_sub_81603B8(1); + NakaGenderTest_JoypadAction(1); return FALSE; } if (gMain.newKeys & DPAD_LEFT) { - debug_sub_81603B8(2); + NakaGenderTest_JoypadAction(2); return FALSE; } if (gMain.newKeys & DPAD_RIGHT) { - debug_sub_81603B8(3); + NakaGenderTest_JoypadAction(3); return FALSE; } if (gMain.newAndRepeatedKeys & A_BUTTON) { - if (_nakamuraData4 < 6) - debug_sub_81601C8(_nakamuraData4, +1); - if (_nakamuraData4 >= 6 && _nakamuraData4 < 12) - debug_sub_8160258(_nakamuraData4 % 6); - if (_nakamuraData4 >= 12 && _nakamuraData4 < 18) - debug_sub_816027C(_nakamuraData4 % 6, +1); - debug_sub_816017C(_nakamuraData4 % 6); + if (sNakaGenderTest_CursorPosition < 6) + NakaGenderTest_AdjustSpecies(sNakaGenderTest_CursorPosition, +1); + if (sNakaGenderTest_CursorPosition >= 6 && sNakaGenderTest_CursorPosition < 12) + NakaGenderTest_RerollPokemon(sNakaGenderTest_CursorPosition % 6); + if (sNakaGenderTest_CursorPosition >= 12 && sNakaGenderTest_CursorPosition < 18) + NakaGenderTest_AdjustLevel(sNakaGenderTest_CursorPosition % 6, +1); + NakaGenderTest_RedrawCurrent(sNakaGenderTest_CursorPosition % 6); return FALSE; } if (gMain.newAndRepeatedKeys & B_BUTTON) { - if (_nakamuraData4 < 6) - debug_sub_81601C8(_nakamuraData4, -1); - if (_nakamuraData4 >= 6 && _nakamuraData4 < 12) - debug_sub_8160258(_nakamuraData4 % 6); - if (_nakamuraData4 >= 12 && _nakamuraData4 < 18) - debug_sub_816027C(_nakamuraData4 % 6, -1); - debug_sub_816017C(_nakamuraData4 % 6); + if (sNakaGenderTest_CursorPosition < 6) + NakaGenderTest_AdjustSpecies(sNakaGenderTest_CursorPosition, -1); + if (sNakaGenderTest_CursorPosition >= 6 && sNakaGenderTest_CursorPosition < 12) + NakaGenderTest_RerollPokemon(sNakaGenderTest_CursorPosition % 6); + if (sNakaGenderTest_CursorPosition >= 12 && sNakaGenderTest_CursorPosition < 18) + NakaGenderTest_AdjustLevel(sNakaGenderTest_CursorPosition % 6, -1); + NakaGenderTest_RedrawCurrent(sNakaGenderTest_CursorPosition % 6); return FALSE; } if (gMain.newAndRepeatedKeys & R_BUTTON) { - if (_nakamuraData4 < 6) - debug_sub_81601C8(_nakamuraData4, +10); - if (_nakamuraData4 >= 6 && _nakamuraData4 < 12) - debug_sub_8160258(_nakamuraData4 % 6); - if (_nakamuraData4 >= 12 && _nakamuraData4 < 18) - debug_sub_816027C(_nakamuraData4 % 6, +1); - debug_sub_816017C(_nakamuraData4 % 6); + if (sNakaGenderTest_CursorPosition < 6) + NakaGenderTest_AdjustSpecies(sNakaGenderTest_CursorPosition, +10); + if (sNakaGenderTest_CursorPosition >= 6 && sNakaGenderTest_CursorPosition < 12) + NakaGenderTest_RerollPokemon(sNakaGenderTest_CursorPosition % 6); + if (sNakaGenderTest_CursorPosition >= 12 && sNakaGenderTest_CursorPosition < 18) + NakaGenderTest_AdjustLevel(sNakaGenderTest_CursorPosition % 6, +1); + NakaGenderTest_RedrawCurrent(sNakaGenderTest_CursorPosition % 6); return FALSE; } if (gMain.newAndRepeatedKeys & L_BUTTON) { - if (_nakamuraData4 < 6) - debug_sub_81601C8(_nakamuraData4, -10); - if (_nakamuraData4 >= 6 && _nakamuraData4 < 12) - debug_sub_8160258(_nakamuraData4 % 6); - if (_nakamuraData4 >= 12 && _nakamuraData4 < 18) - debug_sub_816027C(_nakamuraData4 % 6, -1); - debug_sub_816017C(_nakamuraData4 % 6); + if (sNakaGenderTest_CursorPosition < 6) + NakaGenderTest_AdjustSpecies(sNakaGenderTest_CursorPosition, -10); + if (sNakaGenderTest_CursorPosition >= 6 && sNakaGenderTest_CursorPosition < 12) + NakaGenderTest_RerollPokemon(sNakaGenderTest_CursorPosition % 6); + if (sNakaGenderTest_CursorPosition >= 12 && sNakaGenderTest_CursorPosition < 18) + NakaGenderTest_AdjustLevel(sNakaGenderTest_CursorPosition % 6, -1); + NakaGenderTest_RedrawCurrent(sNakaGenderTest_CursorPosition % 6); return FALSE; } if (gMain.newKeys & START_BUTTON) { - debug_sub_8160308(); + NakaGenderTest_PartyCompactionEnsureAtLeastOne(); CloseMenu(); return TRUE; } @@ -1122,7 +1133,7 @@ bool8 debug_sub_8160498(void) return FALSE; } -u8 debug_sub_816062C(u8 i) +static u8 NakaGenderTest_ForceRerollPokemon(u8 i) { u16 species = GetMonData(gPlayerParty + i, MON_DATA_SPECIES); u8 gender = GetMonGender(gPlayerParty + i); @@ -1151,12 +1162,18 @@ u8 debug_sub_816062C(u8 i) } while (GetGenderFromSpeciesAndPersonality(species, personality) != ratio); GetMonData(gPlayerParty + i, MON_DATA_IVS); - CreateMon(gPlayerParty + i, _nakamuraStatic0[i].species, _nakamuraStatic0[i].level, 0x20, TRUE, personality, FALSE, 0); + CreateMon(gPlayerParty + i, sNakaGenderTestData[i].species, sNakaGenderTestData[i].level, 0x20, TRUE, personality, FALSE, 0); return ratio; } +// ======================================================= +// SET POKEBLOCK +// ======================================================= + +static struct Pokeblock sPokeblock; + #ifdef NONMATCHING -u8 debug_sub_8160714(u8 * dest, struct Pokeblock * pokeblock) +static u8 SetPokeblock_CalcColor(u8 * dest, struct Pokeblock * pokeblock) { u8 numGoodFlavors = 0; u8 numBadFlavors = 0; @@ -1319,7 +1336,7 @@ u8 debug_sub_8160714(u8 * dest, struct Pokeblock * pokeblock) } #else __attribute__((naked)) -u8 debug_sub_8160714(u8 * dest, struct Pokeblock * pokeblock) +static u8 SetPokeblock_CalcColor(u8 * dest, struct Pokeblock * pokeblock) { asm("\tpush\t{r4, r5, r6, r7, lr}\n" "\tmov\tr7, r9\n" @@ -1670,7 +1687,7 @@ u8 debug_sub_8160714(u8 * dest, struct Pokeblock * pokeblock) } #endif // NONMATCHING -void debug_sub_816097C(u8 * buff, s16 a1) +static void NakaDebug_PrintNum3Chars(u8 * buff, s16 a1) { u8 i; s16 divisor; @@ -1720,45 +1737,45 @@ void debug_sub_816097C(u8 * buff, s16 a1) } } -void debug_sub_8160A80(u8 a0) +static void SetPokeblock_PrintFlavorValue(u8 a0) { - struct Pokeblock *pkblk = &_nakamuraStatic18; - + struct Pokeblock *pkblk = &sPokeblock; + if (a0 == 0) { - debug_sub_816097C(gStringVar1, pkblk->spicy); + NakaDebug_PrintNum3Chars(gStringVar1, pkblk->spicy); Menu_PrintText(gStringVar1, 8, 3); } else if (a0 == 1) { - debug_sub_816097C(gStringVar1, pkblk->dry); + NakaDebug_PrintNum3Chars(gStringVar1, pkblk->dry); Menu_PrintText(gStringVar1, 8, 5); } else if (a0 == 2) { - debug_sub_816097C(gStringVar1, pkblk->sweet); + NakaDebug_PrintNum3Chars(gStringVar1, pkblk->sweet); Menu_PrintText(gStringVar1, 8, 7); } else if (a0 == 3) { - debug_sub_816097C(gStringVar1, pkblk->bitter); + NakaDebug_PrintNum3Chars(gStringVar1, pkblk->bitter); Menu_PrintText(gStringVar1, 8, 9); } else if (a0 == 4) { - debug_sub_816097C(gStringVar1, pkblk->sour); + NakaDebug_PrintNum3Chars(gStringVar1, pkblk->sour); Menu_PrintText(gStringVar1, 8, 11); } else if (a0 == 5) { - debug_sub_816097C(gStringVar1, pkblk->feel); + NakaDebug_PrintNum3Chars(gStringVar1, pkblk->feel); Menu_PrintText(gStringVar1, 8, 13); } } -void debug_sub_8160B50(u8 a0, s8 a1) +static void SetPokeblock_AdjustFlavor(u8 a0, s8 a1) { - struct Pokeblock *pkblk = &_nakamuraStatic18; + struct Pokeblock *pkblk = &sPokeblock; if (a0 == 0) pkblk->spicy += a1; @@ -1774,19 +1791,19 @@ void debug_sub_8160B50(u8 a0, s8 a1) pkblk->feel += a1; } -void debug_sub_8160BB0(void) +static void SetPokeblock_RecomputeAndPrintColor(void) { - _nakamuraStatic18.color = debug_sub_8160714(gStringVar1, &_nakamuraStatic18); + sPokeblock.color = SetPokeblock_CalcColor(gStringVar1, &sPokeblock); Menu_BlankWindowRect(1, 1, 8, 2); Menu_PrintText(gStringVar1, 1, 1); } -void debug_sub_8160BE4(void) +static void SetPokeblock_Init(void) { u8 i; Menu_DrawStdWindowFrame(0, 0, 12, 15); - debug_sub_8160BB0(); + SetPokeblock_RecomputeAndPrintColor(); Menu_PrintText(gContestStatsText_Spicy, 2, 3); Menu_PrintText(gContestStatsText_Dry, 2, 5); Menu_PrintText(gContestStatsText_Sweet, 2, 7); @@ -1795,14 +1812,14 @@ void debug_sub_8160BE4(void) Menu_PrintText(gContestStatsText_Tasty, 2, 13); for (i = 0; i < 6; i++) - debug_sub_8160A80(i); + SetPokeblock_PrintFlavorValue(i); InitMenu(0, 1, 3, 6, 0, 11); } -void debug_sub_8160C7C(void) +static void SetPokeblock_GivePokeblock(void) { - struct Pokeblock * pkblk = &_nakamuraStatic18; + struct Pokeblock * pkblk = &sPokeblock; u8 rval = 0; u8 i; @@ -1831,14 +1848,14 @@ void debug_sub_8160C7C(void) } } - sub_810CA34(pkblk); - debug_sub_8160BB0(); + GivePokeblock(pkblk); + SetPokeblock_RecomputeAndPrintColor(); for (i = 0; i < 6; i++) - debug_sub_8160A80(i); + SetPokeblock_PrintFlavorValue(i); } -bool8 debug_sub_8160CF4(void) +static bool8 SetPokeblock_HandleJoypad(void) { if (gMain.newAndRepeatedKeys & DPAD_UP) { @@ -1854,23 +1871,23 @@ bool8 debug_sub_8160CF4(void) if (gMain.newAndRepeatedKeys & DPAD_LEFT) { - debug_sub_8160B50(Menu_GetCursorPos(), -1); - debug_sub_8160A80(Menu_GetCursorPos()); - debug_sub_8160BB0(); + SetPokeblock_AdjustFlavor(Menu_GetCursorPos(), -1); + SetPokeblock_PrintFlavorValue(Menu_GetCursorPos()); + SetPokeblock_RecomputeAndPrintColor(); return FALSE; } if (gMain.newAndRepeatedKeys & DPAD_RIGHT) { - debug_sub_8160B50(Menu_GetCursorPos(), +1); - debug_sub_8160A80(Menu_GetCursorPos()); - debug_sub_8160BB0(); + SetPokeblock_AdjustFlavor(Menu_GetCursorPos(), +1); + SetPokeblock_PrintFlavorValue(Menu_GetCursorPos()); + SetPokeblock_RecomputeAndPrintColor(); return FALSE; } if (gMain.newKeys & A_BUTTON) { - debug_sub_8160C7C(); + SetPokeblock_GivePokeblock(); PlaySE(SE_SELECT); return FALSE; } @@ -1885,15 +1902,30 @@ bool8 debug_sub_8160CF4(void) return FALSE; } -bool8 debug_sub_8160D98(void) +static bool8 SetPokeblock(void) { Menu_EraseWindowRect(0, 0, 29, 19); - debug_sub_8160BE4(); - gMenuCallback = debug_sub_8160CF4; + SetPokeblock_Init(); + gMenuCallback = SetPokeblock_HandleJoypad; return FALSE; } -void debug_sub_8160DC0(void) +// ======================================================= +// EFFORT VALUES +// ======================================================= + +EWRAM_DATA u8 sEVTest_CursorPosition = 0; + +static const u8 Str_843E5F2[] = _("HP どりょくち"); +static const u8 Str_843E5FB[] = _("こうげき どりょくち"); +static const u8 Str_843E606[] = _("ぼうぎょ どりょくち"); +static const u8 Str_843E611[] = _("すばやさ どりょくち"); +static const u8 Str_843E61C[] = _("とくこう どりょくち"); +static const u8 Str_843E627[] = _("とくぼう どりょくち"); +static const u8 Str_843E632[] = _("なつきど"); +static const u8 Str_843E637[] = _("どりょくち ごうけい"); + +static void EVTest_Init(void) { Menu_DrawStdWindowFrame(0, 0, 22, 19); Menu_PrintText(gOtherText_Slash, 11, 1); @@ -1907,7 +1939,7 @@ void debug_sub_8160DC0(void) Menu_PrintText(Str_843E632, 2, 17); } -void debug_sub_8160E50(struct Pokemon *pokemon) +static void EVTest_PrintMonData(struct Pokemon *pokemon) { u16 evTotal; u16 curEv; @@ -1964,49 +1996,49 @@ void debug_sub_8160E50(struct Pokemon *pokemon) Menu_PrintText(gStringVar1, 13, 17); } -void debug_sub_8161028(s8 a0) +static void EVTest_MovePartyCursor(s8 a0) { s16 i; if (a0 == -1) { - if (_nakamuraData5 == 0) + if (sEVTest_CursorPosition == 0) { for (i = 5; i >= 0; i--) { if (GetMonData(gPlayerParty + i, MON_DATA_SPECIES) != SPECIES_NONE) { - _nakamuraData5 = i; + sEVTest_CursorPosition = i; return; } } } - _nakamuraData5 += a0; + sEVTest_CursorPosition += a0; return; } if (a0 == 1) { - _nakamuraData5 += a0; - if (_nakamuraData5 == 6) - _nakamuraData5 = 0; - else if (GetMonData(gPlayerParty + _nakamuraData5, MON_DATA_SPECIES) == SPECIES_NONE) - _nakamuraData5 = 0; + sEVTest_CursorPosition += a0; + if (sEVTest_CursorPosition == 6) + sEVTest_CursorPosition = 0; + else if (GetMonData(gPlayerParty + sEVTest_CursorPosition, MON_DATA_SPECIES) == SPECIES_NONE) + sEVTest_CursorPosition = 0; } } -bool8 debug_sub_81610BC(void) +static bool8 EVTest_HandleJoypad(void) { if (gMain.newKeys & DPAD_LEFT) { - debug_sub_8161028(-1); - debug_sub_8160E50(gPlayerParty + _nakamuraData5); + EVTest_MovePartyCursor(-1); + EVTest_PrintMonData(gPlayerParty + sEVTest_CursorPosition); return FALSE; } if (gMain.newKeys & DPAD_RIGHT) { - debug_sub_8161028(+1); - debug_sub_8160E50(gPlayerParty + _nakamuraData5); + EVTest_MovePartyCursor(+1); + EVTest_PrintMonData(gPlayerParty + sEVTest_CursorPosition); return FALSE; } @@ -2023,42 +2055,59 @@ bool8 debug_sub_81610BC(void) bool8 DebugMenu_EffortValues(void) { Menu_EraseWindowRect(0, 0, 29, 19); - _nakamuraData5 = 0; - debug_sub_8160DC0(); - debug_sub_8160E50(gPlayerParty + 0); - gMenuCallback = debug_sub_81610BC; + sEVTest_CursorPosition = 0; + EVTest_Init(); + EVTest_PrintMonData(gPlayerParty + 0); + gMenuCallback = EVTest_HandleJoypad; return FALSE; } -u16 debug_sub_8161160(void) +// ======================================================= +// RNG Test +// ======================================================= + +EWRAM_DATA u16 sRngLeft = 0; +EWRAM_DATA u16 sRngRight = 0; +EWRAM_DATA u16 sNumSamples = 0; +EWRAM_DATA u16 sRngMax = 0; + +static const u8 Str_843E642[] = _("ここから"); +static const u8 Str_843E647[] = _("ここまで"); +static const u8 Str_843E64C[] = _("かいすう"); +static const u8 Str_843E651[] = _("けっか"); +static const u8 Str_843E655[] = _("かい"); +static const u8 Str_843E658[] = _("0"); +static const u8 Str_843E65A[] = _("はんい"); + +static u16 EVTest_GetDiscreteUniformRandomSamples(void) { - u16 r7 = 0; - u16 r6; - u16 r5; + u16 sampCount = 0; + u16 left; + u16 right; u32 i; - if (_nakamuraData6 <= _nakamuraData8) + if (sRngLeft <= sRngRight) { - r6 = _nakamuraData6; - r5 = _nakamuraData8; + left = sRngLeft; + right = sRngRight; } else { - r6 = _nakamuraData8; - r5 = _nakamuraData6; + left = sRngRight; + right = sRngLeft; } - for (i = 0; i < _nakamuraDataA; i++) + for (i = 0; i < sNumSamples; i++) { - u16 r0 = Random() % _nakamuraDataC; - if (r0 >= r6 && r0 <= r5) - r7++; + u16 r0 = Random() % sRngMax; + if (r0 >= left && r0 <= right) + sampCount++; } - return r7; + return sampCount; } -void debug_sub_81611D8(void) +static void RNGTest_Init(void) { Menu_DrawStdWindowFrame(0, 0, 15, 11); Menu_PrintText(Str_843E642, 2, 1); @@ -2075,20 +2124,20 @@ void debug_sub_81611D8(void) InitMenu(0, 1, 1, 4, 0, 14); } -void debug_sub_8161290(u16 a0) +static void RNGTest_PrintNum(u16 a0) { ConvertIntToDecimalStringN(gStringVar1, a0, STR_CONV_MODE_RIGHT_ALIGN, 5); Menu_PrintText(gStringVar1, 8, 9); } -void debug_sub_81612B8(u16 * a0, s8 a1, u8 a2) +static void RNGTest_AdjustAndPrintNumAtLine(u16 * a0, s8 a1, u8 a2) { *a0 += a1; ConvertIntToDecimalStringN(gStringVar1, *a0, STR_CONV_MODE_RIGHT_ALIGN, 5); Menu_PrintText(gStringVar1, 8, a2); } -bool8 debug_sub_81612EC(void) +static bool8 RNGTest_HandleJoypad(void) { s8 r5 = gMain.heldKeys & R_BUTTON ? 100 : 1; s8 r4; @@ -2109,13 +2158,13 @@ bool8 debug_sub_81612EC(void) { r4 = Menu_GetCursorPos(); if (r4 == 0) - debug_sub_81612B8(&_nakamuraData6, -r5, 1); + RNGTest_AdjustAndPrintNumAtLine(&sRngLeft, -r5, 1); if (r4 == 1) - debug_sub_81612B8(&_nakamuraData8, -r5, 3); + RNGTest_AdjustAndPrintNumAtLine(&sRngRight, -r5, 3); if (r4 == 2) - debug_sub_81612B8(&_nakamuraDataC, -r5, 5); + RNGTest_AdjustAndPrintNumAtLine(&sRngMax, -r5, 5); if (r4 == 3) - debug_sub_81612B8(&_nakamuraDataA, -r5, 7); + RNGTest_AdjustAndPrintNumAtLine(&sNumSamples, -r5, 7); return FALSE; } @@ -2123,22 +2172,22 @@ bool8 debug_sub_81612EC(void) { r4 = Menu_GetCursorPos(); if (r4 == 0) - debug_sub_81612B8(&_nakamuraData6, r5, 1); + RNGTest_AdjustAndPrintNumAtLine(&sRngLeft, r5, 1); if (r4 == 1) - debug_sub_81612B8(&_nakamuraData8, r5, 3); + RNGTest_AdjustAndPrintNumAtLine(&sRngRight, r5, 3); if (r4 == 2) - debug_sub_81612B8(&_nakamuraDataC, r5, 5); + RNGTest_AdjustAndPrintNumAtLine(&sRngMax, r5, 5); if (r4 == 3) - debug_sub_81612B8(&_nakamuraDataA, r5, 7); + RNGTest_AdjustAndPrintNumAtLine(&sNumSamples, r5, 7); return FALSE; } if (gMain.newKeys & A_BUTTON) { - if (_nakamuraDataC != 0) + if (sRngMax != 0) { PlaySE(SE_SELECT); - debug_sub_8161290(debug_sub_8161160()); + RNGTest_PrintNum(EVTest_GetDiscreteUniformRandomSamples()); } return FALSE; } @@ -2155,13 +2204,13 @@ bool8 debug_sub_81612EC(void) bool8 DebugMenu_RandomNumberTest(void) { - _nakamuraData6 = 0; - _nakamuraData8 = 0; - _nakamuraDataC = 0; - _nakamuraDataA = 0; + sRngLeft = 0; + sRngRight = 0; + sRngMax = 0; + sNumSamples = 0; Menu_EraseWindowRect(0, 0, 29, 19); - debug_sub_81611D8(); - gMenuCallback = debug_sub_81612EC; + RNGTest_Init(); + gMenuCallback = RNGTest_HandleJoypad; return FALSE; } diff --git a/src/debug/start_menu_debug.c b/src/debug/start_menu_debug.c index 9b12c1cc1..340ef2f17 100644 --- a/src/debug/start_menu_debug.c +++ b/src/debug/start_menu_debug.c @@ -1830,7 +1830,7 @@ u8 DebugMenu_EditPKMN() asm( " push {lr}\n" " bl Menu_EraseScreen\n" - " bl debug_sub_815FFDC\n" + " bl NakaGenderTest\n" " mov r0, #0x0\n" " pop {r1}\n" " bx r1\n" diff --git a/src/decoration_inventory.c b/src/decoration_inventory.c index 8f7f5eb92..d4ef2d589 100644 --- a/src/decoration_inventory.c +++ b/src/decoration_inventory.c @@ -64,7 +64,7 @@ bool8 sub_8133FE4(u8 decorIdx) return FALSE; } -bool8 IsThereStorageSpaceForDecoration(u8 decorIdx) +bool8 GiveDecoration(u8 decorIdx) { u8 invIdx; s8 invSlot; @@ -167,11 +167,11 @@ u8 sub_81341D4(void) #if DEBUG -void debug_sub_814A3A8(void) +void Debug_GiveAllDecorations(void) { u8 decor; for (decor = 0; decor < DECOR_COUNT; decor++) - IsThereStorageSpaceForDecoration(decor); + GiveDecoration(decor); } #endif diff --git a/src/field_fadetransition.c b/src/field_fadetransition.c index 35ea3952a..a7087be0f 100644 --- a/src/field_fadetransition.c +++ b/src/field_fadetransition.c @@ -326,7 +326,7 @@ void sub_8080DC4(u8 taskId) } } -void atk17_seteffectsecondary(void) +void sub_8080DEC(void) { pal_fill_black(); CreateStartMenuTask(sub_8080DC4); diff --git a/src/item_menu.c b/src/item_menu.c index 32b14e021..981f42282 100644 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -2616,8 +2616,8 @@ static void sub_80A5888(u8 taskId) static void OnBagClose_Field0(u8 taskId) { - gTasks[taskId].data[8] = (u32)sub_805469C >> 16; - gTasks[taskId].data[9] = (u32)sub_805469C; + gTasks[taskId].data[8] = (u32)c2_exit_to_overworld_1_sub_8080DEC >> 16; + gTasks[taskId].data[9] = (u32)c2_exit_to_overworld_1_sub_8080DEC; gLastFieldPokeMenuOpened = 0; sub_80A5AE4(taskId); } diff --git a/src/overworld.c b/src/overworld.c index 6376aa1af..e98e5a6a1 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -1415,10 +1415,10 @@ void sub_805465C(void) c2_exit_to_overworld_2_switch(); } -void sub_805469C(void) +void c2_exit_to_overworld_1_sub_8080DEC(void) { FieldClearVBlankHBlankCallbacks(); - gFieldCallback = atk17_seteffectsecondary; + gFieldCallback = sub_8080DEC; c2_exit_to_overworld_2_switch(); } diff --git a/src/pokeblock.c b/src/pokeblock.c index 6804f55d6..228d563cf 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -1070,7 +1070,7 @@ s8 GetFirstFreePokeblockSlot(void) return -1; } -bool8 sub_810CA34(const struct Pokeblock *pokeblock) +bool8 GivePokeblock(const struct Pokeblock *pokeblock) { s8 idx = GetFirstFreePokeblockSlot(); if (idx == -1) diff --git a/src/pokedex.c b/src/pokedex.c index 711dc69fa..d35e4b5d1 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -1694,7 +1694,7 @@ static void Task_ClosePokedex(u8 taskId) gSaveBlock2.pokedex.unknown1 = 0; gSaveBlock2.pokedex.order = gPokedexView->dexOrder; DestroyTask(taskId); - SetMainCallback2(sub_805469C); + SetMainCallback2(c2_exit_to_overworld_1_sub_8080DEC); m4aMPlayVolumeControl(&gMPlay_BGM, 0xFFFF, 0x100); } } diff --git a/src/pokemon_1.c b/src/pokemon_1.c index a23bb3324..0622ec614 100644 --- a/src/pokemon_1.c +++ b/src/pokemon_1.c @@ -525,7 +525,7 @@ void CalculateMonStats(struct Pokemon *mon) } #if DEBUG -void debug_sub_803F55C(struct Pokemon *mon) +void Nakamura_NakaGenderTest_RecalcStats(struct Pokemon *mon) { s32 currentHP = GetMonData(mon, MON_DATA_HP, NULL); s32 hpIV = GetMonData(mon, MON_DATA_HP_IV, NULL); diff --git a/src/pokemon_menu.c b/src/pokemon_menu.c index 532340ce4..60757b7d4 100644 --- a/src/pokemon_menu.c +++ b/src/pokemon_menu.c @@ -309,7 +309,7 @@ static void sub_8089E4C(u8 taskID) if (!gPaletteFade.active) { gLastFieldPokeMenuOpened = 0; - SetMainCallback2(sub_805469C); + SetMainCallback2(c2_exit_to_overworld_1_sub_8080DEC); DestroyTask(taskID); } } diff --git a/src/pokenav_before.c b/src/pokenav_before.c index 4f7eb66b4..55cf05790 100644 --- a/src/pokenav_before.c +++ b/src/pokenav_before.c @@ -3239,7 +3239,7 @@ void sub_80EE96C() if (!gPaletteFade.active) { sub_80F5BDC(); - sub_805469C(); + c2_exit_to_overworld_1_sub_8080DEC(); } } } diff --git a/src/region_map.c b/src/region_map.c index e40fb7752..b4ed2c558 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -1912,7 +1912,7 @@ void debug_sub_8110D84(void) break; case 3: if (!UpdatePaletteFade()) - SetMainCallback2(sub_805469C); + SetMainCallback2(c2_exit_to_overworld_1_sub_8080DEC); break; case 4: if (sub_80FAB60() != 0) diff --git a/src/roamer.c b/src/roamer.c index 6ed5b6c89..459082e42 100644 --- a/src/roamer.c +++ b/src/roamer.c @@ -228,7 +228,7 @@ void GetRoamerLocation(u8 *mapGroup, u8 *mapNum) } #if DEBUG -void debug_sub_814A714(void) +void Debug_CreateRoamer(void) { if (gSaveBlock1.location.mapGroup == 0) { @@ -238,7 +238,7 @@ void debug_sub_814A714(void) } } -void debug_sub_814A73C(u8* str) +void Debug_GetRoamerLocation(u8* str) { GetMapSectionName(str, sRoamerLocation[1], 0); } diff --git a/src/scrcmd.c b/src/scrcmd.c index e5272bc9c..29c1f982e 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -548,7 +548,7 @@ bool8 ScrCmd_givedecoration(struct ScriptContext *ctx) { u32 decoration = VarGet(ScriptReadHalfword(ctx)); - gSpecialVar_Result = IsThereStorageSpaceForDecoration(decoration); + gSpecialVar_Result = GiveDecoration(decoration); return FALSE; } diff --git a/src/shop.c b/src/shop.c index 87dbbeb97..42cda5e2e 100644 --- a/src/shop.c +++ b/src/shop.c @@ -691,7 +691,7 @@ static void Task_DoItemPurchase(u8 taskId) } else // a normal mart is only type 0, so types 1 and 2 are decoration marts. { - if (IsThereStorageSpaceForDecoration(gMartInfo.itemList[gMartInfo.choicesAbove + gMartInfo.cursor])) + if (GiveDecoration(gMartInfo.itemList[gMartInfo.choicesAbove + gMartInfo.cursor])) { if (gMartInfo.martType == MART_TYPE_1) DisplayItemMessageOnField(taskId, gOtherText_HereYouGo2, Shop_DoItemTransaction, 0xC3E1); diff --git a/src/start_menu.c b/src/start_menu.c index f2d53eb7f..f63408689 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -503,7 +503,7 @@ static u8 StartMenu_PlayerCallback(void) if (!gPaletteFade.active) { PlayRainSoundEffect(); - TrainerCard_ShowPlayerCard(sub_805469C); + TrainerCard_ShowPlayerCard(c2_exit_to_overworld_1_sub_8080DEC); return 1; } return 0; @@ -524,7 +524,7 @@ static u8 StartMenu_OptionCallback(void) { PlayRainSoundEffect(); SetMainCallback2(CB2_InitOptionMenu); - gMain.savedCallback = sub_805469C; + gMain.savedCallback = c2_exit_to_overworld_1_sub_8080DEC; return 1; } return 0; @@ -551,7 +551,7 @@ static u8 StartMenu_PlayerLinkCallback(void) if (!gPaletteFade.active) { PlayRainSoundEffect(); - TrainerCard_ShowLinkCard(gUnknown_03004860, sub_805469C); + TrainerCard_ShowLinkCard(gUnknown_03004860, c2_exit_to_overworld_1_sub_8080DEC); return 1; } return 0; diff --git a/src/trader.c b/src/trader.c index 885557d5a..e8fe743f8 100644 --- a/src/trader.c +++ b/src/trader.c @@ -249,7 +249,7 @@ void ScrSpecial_TraderDoDecorationTrade(void) struct MauvilleManTrader *trader = &gSaveBlock1.mauvilleMan.trader; sub_81340A8(gSpecialVar_0x8006); - IsThereStorageSpaceForDecoration(gSpecialVar_0x8004); + GiveDecoration(gSpecialVar_0x8004); StringCopy(trader->unk5[gSpecialVar_0x8005], gSaveBlock2.playerName); trader->unk1[gSpecialVar_0x8005] = gSpecialVar_0x8006; sub_810993C(); diff --git a/src/wild_encounter.c b/src/wild_encounter.c index 19778e29b..ddad43a56 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -3803,7 +3803,7 @@ void FeebasSeedRng(u16 seed) } #if DEBUG -u16 debug_sub_8092344(u8 arg0) +u16 FeebasDebug_GetTrueNumberOfWaterTilesInMapThird(u8 arg0) { if (arg0 == 0) return 131; diff --git a/sym_ewram.txt b/sym_ewram.txt index 52f205779..e86e33b40 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -23,7 +23,7 @@ gBattleTypeFlags = .; /* 20239F8 */ gUnknown_020239FC = .; /* 20239FC */ . += 0x4; -gUnknown_02023A00 = .; /* 2023A00 */ +gMultiPartnerParty = .; /* 2023A00 */ . += 0x4; gUnknown_02023A04 = .; /* 2023A04 */ -- cgit v1.2.3