diff options
-rw-r--r-- | asm/watanabe_debug_menu.s | 336 | ||||
-rw-r--r-- | include/battle_bg.h | 6 | ||||
-rw-r--r-- | src/debug/watanabe_debug_menu.c | 109 |
3 files changed, 110 insertions, 341 deletions
diff --git a/asm/watanabe_debug_menu.s b/asm/watanabe_debug_menu.s index bcc85ff17..83e4c5f10 100644 --- a/asm/watanabe_debug_menu.s +++ b/asm/watanabe_debug_menu.s @@ -5,342 +5,6 @@ .text - thumb_func_start debug_80C5038 -debug_80C5038: - push {r4, lr} - add sp, sp, #0xfffffffc - add r4, r0, #0 - lsl r4, r4, #0x18 - lsr r4, r4, #0x18 - ldr r0, ._322 @ gUnknown_Debug_2038A0C - ldrb r0, [r0, #0x8] - lsl r0, r0, #0x19 - mov r1, #0xc0 - lsl r1, r1, #0x12 - add r0, r0, r1 - lsr r0, r0, #0x18 - mov r1, #0x1 - str r1, [sp] - mov r2, #0x1 - mov r3, #0xe - bl debug_80C38E4 - ldr r1, ._322 + 4 @ 0x4000042 - ldr r2, ._322 + 8 @ 0x177 - add r0, r2, #0 - strh r0, [r1] - add r1, r1, #0x4 - add r2, r2, #0x8 - add r0, r2, #0 - strh r0, [r1] - ldr r1, ._322 + 12 @ gTasks - lsl r0, r4, #0x2 - add r0, r0, r4 - lsl r0, r0, #0x3 - add r0, r0, r1 - ldr r1, ._322 + 16 @ debug_80C5098 - str r1, [r0] - add sp, sp, #0x4 - pop {r4} - pop {r0} - bx r0 -._323: - .align 2, 0 -._322: - .word gUnknown_Debug_2038A0C - .word 0x4000042 - .word 0x177 - .word gTasks - .word debug_80C5098+1 - - thumb_func_end debug_80C5038 - - thumb_func_start debug_80C5098 -debug_80C5098: - push {r4, lr} - lsl r0, r0, #0x18 - lsr r4, r0, #0x18 - ldr r1, ._326 @ gMain - ldrh r2, [r1, #0x2e] - mov r0, #0x2 - and r0, r0, r2 - add r3, r1, #0 - cmp r0, #0 - beq ._324 @cond_branch - ldr r0, ._326 + 4 @ gTasks - lsl r1, r4, #0x2 - add r1, r1, r4 - lsl r1, r1, #0x3 - add r1, r1, r0 - ldr r0, ._326 + 8 @ debug_80C47BC - str r0, [r1] - b ._339 -._327: - .align 2, 0 -._326: - .word gMain - .word gTasks - .word debug_80C47BC+1 -._324: - mov r0, #0x8 - and r0, r0, r2 - cmp r0, #0 - bne ._328 @cond_branch - mov r0, #0x1 - and r0, r0, r2 - cmp r0, #0 - beq ._329 @cond_branch -._328: - mov r0, #0x5 - bl PlaySE - ldr r1, ._331 @ gSaveBlock2 - ldr r0, ._331 + 4 @ gUnknown_Debug_2038A0C - ldrb r0, [r0, #0x8] - strb r0, [r1, #0x8] - ldr r1, ._331 + 8 @ gTasks - lsl r0, r4, #0x2 - add r0, r0, r4 - lsl r0, r0, #0x3 - add r0, r0, r1 - ldr r1, ._331 + 12 @ debug_80C42B8 - b ._330 -._332: - .align 2, 0 -._331: - .word gSaveBlock2 - .word gUnknown_Debug_2038A0C - .word gTasks - .word debug_80C42B8+1 -._329: - ldrh r1, [r3, #0x30] - mov r0, #0x40 - and r0, r0, r1 - cmp r0, #0 - beq ._334 @cond_branch - ldr r1, ._336 @ gUnknown_Debug_2038A0C - ldrb r0, [r1, #0x8] - cmp r0, #0 - beq ._334 @cond_branch - sub r0, r0, #0x1 - b ._335 -._337: - .align 2, 0 -._336: - .word gUnknown_Debug_2038A0C -._334: - ldrh r1, [r3, #0x30] - mov r0, #0x80 - and r0, r0, r1 - cmp r0, #0 - beq ._339 @cond_branch - ldr r1, ._340 @ gUnknown_Debug_2038A0C - ldrb r0, [r1, #0x8] - cmp r0, #0 - bne ._339 @cond_branch - add r0, r0, #0x1 -._335: - strb r0, [r1, #0x8] - ldr r1, ._340 + 4 @ gTasks - lsl r0, r4, #0x2 - add r0, r0, r4 - lsl r0, r0, #0x3 - add r0, r0, r1 - ldr r1, ._340 + 8 @ debug_80C5038 -._330: - str r1, [r0] -._339: - pop {r4} - pop {r0} - bx r0 -._341: - .align 2, 0 -._340: - .word gUnknown_Debug_2038A0C - .word gTasks - .word debug_80C5038+1 - - thumb_func_end debug_80C5098 - - thumb_func_start debug_80C5158 -debug_80C5158: - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - ldr r2, ._342 @ gTasks - lsl r1, r0, #0x2 - add r1, r1, r0 - lsl r1, r1, #0x3 - add r1, r1, r2 - ldr r0, ._342 + 4 @ debug_80C5174 - str r0, [r1] - bx lr -._343: - .align 2, 0 -._342: - .word gTasks - .word debug_80C5174+1 - - thumb_func_end debug_80C5158 - - thumb_func_start debug_80C5174 -debug_80C5174: - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - ldr r2, ._344 @ gTasks - lsl r1, r0, #0x2 - add r1, r1, r0 - lsl r1, r1, #0x3 - add r1, r1, r2 - ldr r0, ._344 + 4 @ debug_80C5190 - str r0, [r1] - bx lr -._345: - .align 2, 0 -._344: - .word gTasks - .word debug_80C5190+1 - - thumb_func_end debug_80C5174 - - thumb_func_start debug_80C5190 -debug_80C5190: - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - ldr r2, ._346 @ gTasks - lsl r1, r0, #0x2 - add r1, r1, r0 - lsl r1, r1, #0x3 - add r1, r1, r2 - ldr r0, ._346 + 4 @ debug_80C51AC - str r0, [r1] - bx lr -._347: - .align 2, 0 -._346: - .word gTasks - .word debug_80C51AC+1 - - thumb_func_end debug_80C5190 - - thumb_func_start debug_80C51AC -debug_80C51AC: - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - ldr r2, ._348 @ gTasks - lsl r1, r0, #0x2 - add r1, r1, r0 - lsl r1, r1, #0x3 - add r1, r1, r2 - ldr r0, ._348 + 4 @ debug_80C51C8 - str r0, [r1] - bx lr -._349: - .align 2, 0 -._348: - .word gTasks - .word debug_80C51C8+1 - - thumb_func_end debug_80C51AC - - thumb_func_start debug_80C51C8 -debug_80C51C8: - lsl r0, r0, #0x18 - lsr r0, r0, #0x18 - ldr r2, ._350 @ gTasks - lsl r1, r0, #0x2 - add r1, r1, r0 - lsl r1, r1, #0x3 - add r1, r1, r2 - ldr r0, ._350 + 4 @ debug_80C51E4 - str r0, [r1] - bx lr -._351: - .align 2, 0 -._350: - .word gTasks - .word debug_80C51E4+1 - - thumb_func_end debug_80C51C8 - - thumb_func_start debug_80C51E4 -debug_80C51E4: - push {lr} - bl sub_80408BC - ldr r0, ._352 @ gMain - ldr r1, ._352 + 4 @ debug_80C41A8 - str r1, [r0, #0x8] - ldr r0, ._352 + 8 @ unref_sub_800D684 - bl SetMainCallback2 - pop {r0} - bx r0 -._353: - .align 2, 0 -._352: - .word gMain - .word debug_80C41A8+1 - .word unref_sub_800D684+1 - - thumb_func_end debug_80C51E4 - - thumb_func_start debug_80C5208 -debug_80C5208: - push {r4, r5, r6, lr} - ldr r1, ._355 @ gUnknown_Debug_2038A1C - ldr r0, ._355 + 4 @ 0x2018000 - str r0, [r1] - mov r3, #0x0 - add r6, r1, #0 - ldr r4, ._355 + 8 @ gSaveBlock2 - add r5, r6, #0 - mov r2, #0x0 -._354: - ldr r0, [r5] - lsl r1, r3, #0x2 - add r0, r0, #0x64 - add r0, r0, r1 - str r2, [r0] - add r0, r3, #1 - lsl r0, r0, #0x10 - lsr r3, r0, #0x10 - cmp r3, #0x3f - bls ._354 @cond_branch - ldr r2, [r6] - mov r0, #0xfc - str r0, [r2, #0x64] - ldrb r1, [r4, #0xa] - ldrb r0, [r4, #0xb] - lsl r0, r0, #0x8 - orr r1, r1, r0 - ldrb r0, [r4, #0xc] - lsl r0, r0, #0x10 - orr r1, r1, r0 - ldrb r0, [r4, #0xd] - lsl r0, r0, #0x18 - orr r1, r1, r0 - str r1, [r2, #0x70] - bl Random - add r4, r0, #0 - bl Random - ldr r1, [r6] - lsl r4, r4, #0x10 - lsl r0, r0, #0x10 - lsr r0, r0, #0x10 - orr r4, r4, r0 - str r4, [r1, #0x74] - mov r0, #0x1 - str r0, [r1, #0x68] - str r0, [r1, #0x6c] - bl debug_80C5C94 - pop {r4, r5, r6} - pop {r0} - bx r0 -._356: - .align 2, 0 -._355: - .word gUnknown_Debug_2038A1C - .word 0x2018000 - .word gSaveBlock2 - - thumb_func_end debug_80C5208 - thumb_func_start debug_80C527C debug_80C527C: push {r4, r5, r6, r7, lr} diff --git a/include/battle_bg.h b/include/battle_bg.h new file mode 100644 index 000000000..88f040cb0 --- /dev/null +++ b/include/battle_bg.h @@ -0,0 +1,6 @@ +#ifndef GUARD_BATTLE_BG_H +#define GUARD_BATTLE_BG_H + +void unref_sub_800D684(void); + +#endif //GUARD_BATTLE_BG_H diff --git a/src/debug/watanabe_debug_menu.c b/src/debug/watanabe_debug_menu.c index a4002e325..b435c4558 100644 --- a/src/debug/watanabe_debug_menu.c +++ b/src/debug/watanabe_debug_menu.c @@ -1,6 +1,7 @@ #if DEBUG #include "global.h" #include "ewram.h" +#include "random.h" #include "gba/flash_internal.h" #include "constants/species.h" #include "constants/songs.h" @@ -22,11 +23,7 @@ #include "load_save.h" #include "pokemon_storage_system.h" #include "battle.h" - -EWRAM_DATA u8 gUnknown_Debug_20389EC[0x20] = { 0 }; -EWRAM_DATA u8 gUnknown_Debug_2038A0C[0x10] = { 0 }; -EWRAM_DATA u8 gUnknown_Debug_2038A1C[4] = { 0 }; -EWRAM_DATA u8 gUnknown_Debug_2038A20[4] = { 0 }; +#include "battle_bg.h" struct WatanabeDebugMenuItem { const u8 * text; @@ -37,6 +34,18 @@ struct WatanabeDebugMenuItem { } data; }; +struct WatanabeEwram18000 { + u8 filler_00[0x64]; + u32 unk64[0x40]; +}; + +#define eWatanabe18000 (*(struct WatanabeEwram18000 *)(gSharedMem + 0x18000)) + +EWRAM_DATA u8 gUnknown_Debug_20389EC[0x20] = { 0 }; +EWRAM_DATA u8 gUnknown_Debug_2038A0C[0x10] = { 0 }; +EWRAM_DATA struct WatanabeEwram18000 * gUnknown_Debug_2038A1C = NULL; +EWRAM_DATA u8 gUnknown_Debug_2038A20[4] = { 0 }; + u32 byte_3005E30; void debug_80C3A50(u8 taskId); @@ -62,7 +71,14 @@ void debug_80C4E18(u8 taskId); void debug_80C4F00(u8); void debug_80C4F48(u8 taskId); void debug_80C5038(u8 taskId); +void debug_80C5098(u8 taskId); void debug_80C5158(u8 taskId); +void debug_80C5174(u8 taskId); +void debug_80C5190(u8 taskId); +void debug_80C51AC(u8 taskId); +void debug_80C51C8(u8 taskId); +void debug_80C51E4(u8 taskId); +void debug_80C5C94(void); void debug_80C68CC(u16, u8, u8, u8); void debug_80C7584(struct Sprite *); @@ -1479,6 +1495,89 @@ void debug_80C4F48(u8 taskId) gTasks[taskId].func = debug_80C5038; } +void debug_80C5038(u8 taskId) +{ + debug_80C38E4(gUnknown_Debug_2038A0C[8] * 2 + 3, 1, 1, 14, 1); + REG_WIN1H = 0x0177; + REG_WIN1V = 0x017F; + gTasks[taskId].func = debug_80C5098; +} + +void debug_80C5098(u8 taskId) +{ + if (gMain.newKeys & B_BUTTON) + { + gTasks[taskId].func = debug_80C47BC; + } + else if (gMain.newKeys & START_BUTTON || gMain.newKeys & A_BUTTON) + { + PlaySE(SE_SELECT); + gSaveBlock2.playerGender = gUnknown_Debug_2038A0C[8]; + gTasks[taskId].func = debug_80C42B8; + } + else if (gMain.newAndRepeatedKeys & DPAD_UP && gUnknown_Debug_2038A0C[8] > 0) + { + gUnknown_Debug_2038A0C[8]--; + gTasks[taskId].func = debug_80C5038; + } + else if (gMain.newAndRepeatedKeys & DPAD_DOWN && gUnknown_Debug_2038A0C[8] < 1) + { + gUnknown_Debug_2038A0C[8]++; + gTasks[taskId].func = debug_80C5038; + } +} + +void debug_80C5158(u8 taskId) +{ + gTasks[taskId].func = debug_80C5174; +} + +void debug_80C5174(u8 taskId) +{ + gTasks[taskId].func = debug_80C5190; +} + +void debug_80C5190(u8 taskId) +{ + gTasks[taskId].func = debug_80C51AC; +} + +void debug_80C51AC(u8 taskId) +{ + gTasks[taskId].func = debug_80C51C8; +} + +void debug_80C51C8(u8 taskId) +{ + gTasks[taskId].func = debug_80C51E4; +} + +void debug_80C51E4(u8 taskId) +{ + sub_80408BC(); + gMain.savedCallback = debug_80C41A8; + SetMainCallback2(unref_sub_800D684); +} + +void debug_80C5208(void) +{ + u16 i; + + gUnknown_Debug_2038A1C = &eWatanabe18000; + + for (i = 0; i < 64; i++) + { + gUnknown_Debug_2038A1C->unk64[i] = 0; + } + + gUnknown_Debug_2038A1C->unk64[0] = 0xfc; + gUnknown_Debug_2038A1C->unk64[3] = gSaveBlock2.playerTrainerId[0] | (gSaveBlock2.playerTrainerId[1] << 8) | (gSaveBlock2.playerTrainerId[2] << 16) | (gSaveBlock2.playerTrainerId[3] << 24); + gUnknown_Debug_2038A1C->unk64[4] = (Random() << 16) | Random(); + gUnknown_Debug_2038A1C->unk64[1] = 1; + gUnknown_Debug_2038A1C->unk64[2] = 1; + debug_80C5C94(); +} + u16 word_83F888C[] = INCBIN_U16("graphics/debug/sprite_browser.gbapal"); u8 byte_83F88EC[] = INCBIN_U8("graphics/debug/sprite_browser.4bpp"); |