From aa7657a82a108321d5112f0ad195132e2c6e6c99 Mon Sep 17 00:00:00 2001 From: Phlosioneer Date: Wed, 6 Mar 2019 22:58:05 -0500 Subject: [PATCH] Move constants into C Also figured out what one of the graphics files is for. --- data/menu_unknown.s | 28 +---- .../{8625660.png => pokeball_placeholder.png} | Bin src/menu_unknown.c | 98 ++++++++++++++++-- 3 files changed, 93 insertions(+), 33 deletions(-) rename graphics/pokenav/{8625660.png => pokeball_placeholder.png} (100%) diff --git a/data/menu_unknown.s b/data/menu_unknown.s index fc8bf47b9..e88a68fcc 100644 --- a/data/menu_unknown.s +++ b/data/menu_unknown.s @@ -2,38 +2,12 @@ .include "constants/constants.inc" .section .rodata - -@gUnknown_08625410:: @ 8625410 -@ .byte 4, 5, 6, 7, 8, 9, 9, 0xA, 0xA, 0xB, 0xB, 0xC, 0xC, 0xD, 0xD, 0xD, 0xD, 0xE, 0xE, 0xE, 0xE, 0xF, 0xF, 0xF, 0xF, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x23 - -gMoveRelearnerWindowTemplates:: @ 8625510s - window_template 1, 1, 1, 16, 12, 0xF, 0x000A - window_template 1, 1, 1, 16, 12, 0xF, 0x00CA - window_template 1, 19, 1, 10, 12, 0xF, 0x018A - window_template 1, 4, 15, 22, 4, 0xF, 0x0202 - window_template 0, 22, 8, 5, 4, 0xF, 0x025A - null_window_template - -gMoveRelearnerYesNoMenuTemplate:: @ 8625540 - window_template 0, 22, 8, 5, 4, 0xF, 0x025A - -gMoveRelearnerMovesListTemplate:: @ 8625548 struct ListMenuTemplate - .4byte NULL - .4byte MoveRelearnerCursorCallback - .4byte NULL - .2byte 0 - .2byte 0 - .byte 2 - .byte 0 - .byte 8 - .byte 0 - .4byte 0x1003121 gUnknown_08625560:: @ 8625560 .incbin "graphics/pokenav/pokeball.4bpp" gUnknown_08625660:: @ 8625660 - .incbin "graphics/pokenav/8625660.4bpp" + .incbin "graphics/pokenav/pokeball_placeholder.4bpp" gUnknown_08625680:: @ 8625680 .incbin "graphics/pokenav/sparkle.gbapal" diff --git a/graphics/pokenav/8625660.png b/graphics/pokenav/pokeball_placeholder.png similarity index 100% rename from graphics/pokenav/8625660.png rename to graphics/pokenav/pokeball_placeholder.png diff --git a/src/menu_unknown.c b/src/menu_unknown.c index dc8351d92..9a8ea5906 100644 --- a/src/menu_unknown.c +++ b/src/menu_unknown.c @@ -24,6 +24,7 @@ EWRAM_DATA static struct ListMenuItem *sUnknown_0203CF4C = NULL; void sub_81D1E7C(s32 itemIndex, bool8 onInit, struct ListMenu *list); void sub_81D24A4(struct UnknownStruct_81D1ED4 *a0); void sub_81D2634(struct UnknownStruct_81D1ED4 *a0); +void MoveRelearnerCursorCallback(s32 itemIndex, bool8 onInit, struct ListMenu *list); static const struct WindowTemplate sUnknown_086253E8[] = { @@ -72,7 +73,7 @@ static const struct ScanlineEffectParams sUnknown_08625404 = }; -const u8 gUnknown_08625410[] = +static const u8 sUnknown_08625410[] = { 4, 5, @@ -109,6 +110,91 @@ const u8 gUnknown_08625410[] = 0x23 }; + +const struct WindowTemplate gMoveRelearnerWindowTemplates[] = +{ + { + .bg = 1, + .tilemapLeft = 1, + .tilemapTop = 1, + .width = 16, + .height = 12, + .paletteNum = 0xF, + .baseBlock = 0xA + }, + { + .bg = 1, + .tilemapLeft = 1, + .tilemapTop = 1, + .width = 16, + .height = 12, + .paletteNum = 0xF, + .baseBlock = 0xCA + }, + { + .bg = 1, + .tilemapLeft = 19, + .tilemapTop = 1, + .width = 10, + .height = 12, + .paletteNum = 0xF, + .baseBlock = 0x18A + }, + { + .bg = 1, + .tilemapLeft = 4, + .tilemapTop = 15, + .width = 22, + .height = 4, + .paletteNum = 0xF, + .baseBlock = 0x202 + }, + { + .bg = 0, + .tilemapLeft = 22, + .tilemapTop = 8, + .width = 5, + .height = 4, + .paletteNum = 0xF, + .baseBlock = 0x25A + }, + DUMMY_WIN_TEMPLATE +}; + +const struct WindowTemplate gMoveRelearnerYesNoMenuTemplate = +{ + .bg = 0, + .tilemapLeft = 22, + .tilemapTop = 8, + .width = 5, + .height = 4, + .paletteNum = 0xF, + .baseBlock = 0x25A +}; + + +const struct ListMenuTemplate gMoveRelearnerMovesListTemplate = +{ + .items = NULL, + .moveCursorFunc = MoveRelearnerCursorCallback, + .itemPrintFunc = NULL, + .totalItems = 0, + .maxShowed = 0, + .windowId = 2, + .header_X = 0, + .item_X = 8, + .cursor_X = 0, + .upText_Y = 1, + .cursorPal = 2, + .fillValue = 1, + .cursorShadowPal = 3, + .lettersSpacing = 0, + .itemVerticalPadding = 0, + .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, + .fontId = 1, + .cursorKind = 0 +}; + bool8 sub_81D1C44(u8 count) { u32 i; @@ -1353,7 +1439,7 @@ NAKED void sub_81D2754(struct UnknownStruct_81D1ED4 *arg0, struct UnknownSubStruct_81D1ED4 *arg1) { // There are some register-renaming issues here. The cause of the problem seems to be that - // GCC tries to save gUnknown_08625410 in a register, instead of loading the constant repeatedly. + // GCC tries to save sUnknown_08625410 in a register, instead of loading the constant repeatedly. // But this is one too many things to keep track of, so GCC is forced to use the stack. #ifdef NONMATCHING u8* v1; @@ -1363,7 +1449,7 @@ void sub_81D2754(struct UnknownStruct_81D1ED4 *arg0, struct UnknownSubStruct_81D u16 v5; v1 = arg0->unk0[0]; - v2 = gUnknown_08625410[*v1]; + v2 = sUnknown_08625410[*v1]; v1++; arg1[0].unk0 = 0x9B; arg1[0].unk2 = 0x5B - v2; @@ -1380,7 +1466,7 @@ void sub_81D2754(struct UnknownStruct_81D1ED4 *arg0, struct UnknownSubStruct_81D v3++; } - v2 = gUnknown_08625410[*v1]; + v2 = sUnknown_08625410[*v1]; v1++; arg1[v4].unk0 = ((gSineTable[v3 + 0x40] * v2) >> 8) + 0x9B; arg1[v4].unk2 = ((gSineTable[v3] * v2) >> 8) - 0x5B; @@ -1398,7 +1484,7 @@ void sub_81D2754(struct UnknownStruct_81D1ED4 *arg0, struct UnknownSubStruct_81D push {r5-r7}\n\ adds r6, r0, 0\n\ mov r8, r1\n\ - ldr r1, =gUnknown_08625410\n\ + ldr r1, =sUnknown_08625410\n\ ldrb r0, [r6]\n\ adds r0, r1\n\ ldrb r2, [r0]\n\ @@ -1443,7 +1529,7 @@ _081D27A4:\n\ lsrs r7, r0, 24\n\ _081D27B4:\n\ ldrb r0, [r6]\n\ - ldr r2, =gUnknown_08625410\n\ + ldr r2, =sUnknown_08625410\n\ adds r0, r2\n\ ldrb r2, [r0]\n\ adds r6, 0x1\n\