From cf0ae01a8681bb4a65f7feb23e790d0bd90addfe Mon Sep 17 00:00:00 2001 From: Eebit Date: Sat, 21 Oct 2023 19:03:57 -0400 Subject: [PATCH] Extract data for cursor/spinning arrow and rename --- asm/unitlistscreen.s | 8 +-- data/data_59E8E0.s | 8 +-- data/data_A195B0.s | 8 +-- data/data_A2077C.s | 54 ---------------- include/functions.h | 32 ++++----- include/prepscreen.h | 4 +- include/variables.h | 16 ++--- ldscript.txt | 2 + src/bmshop.c | 2 +- src/bonusclaim.c | 4 +- src/cursor_hand.c | 102 ++++++++++++++++++----------- src/prep_itemlist.c | 16 ++--- src/prep_itemscreen.c | 24 +++---- src/prep_itemsupply.c | 18 +++--- src/prep_itemtrade.c | 4 +- src/prep_itemuse.c | 4 +- src/prep_unitselect.c | 4 +- src/prep_wm_sell.c | 4 +- src/spinning_arrow.c | 147 +++++++++++++++++++++++++----------------- 19 files changed, 232 insertions(+), 229 deletions(-) diff --git a/asm/unitlistscreen.s b/asm/unitlistscreen.s index 9bccb53b0..e57a7d02f 100644 --- a/asm/unitlistscreen.s +++ b/asm/unitlistscreen.s @@ -821,7 +821,7 @@ sub_80906F8: @ 0x080906F8 strh r1, [r0] subs r0, #2 strh r1, [r0] - ldr r0, _0809077C @ gUnknown_08A1C7D8 + ldr r0, _0809077C @ gImg_UiSpinningArrow_Horizontal ldr r1, _08090780 @ 0x06010280 bl Decompress pop {r4, r5} @@ -829,7 +829,7 @@ sub_80906F8: @ 0x080906F8 bx r0 .align 2, 0 _08090778: .4byte gUnknown_0200F158 -_0809077C: .4byte gUnknown_08A1C7D8 +_0809077C: .4byte gImg_UiSpinningArrow_Horizontal _08090780: .4byte 0x06010280 THUMB_FUNC_END sub_80906F8 @@ -2009,7 +2009,7 @@ _0809104E: movs r1, #3 orrs r0, r1 strb r0, [r7, #0x18] - ldr r0, _08091170 @ gUnknown_08A1C7D8 + ldr r0, _08091170 @ gImg_UiSpinningArrow_Horizontal ldr r1, _08091174 @ gBG1TilemapBuffer+0x500 bl Decompress ldr r0, _08091178 @ gUnknown_08A1A084 @@ -2044,7 +2044,7 @@ _0809104E: _08091164: .4byte gBG0TilemapBuffer _08091168: .4byte gUnknown_0200F158 _0809116C: .4byte gLCDControlBuffer -_08091170: .4byte gUnknown_08A1C7D8 +_08091170: .4byte gImg_UiSpinningArrow_Horizontal _08091174: .4byte gBG1TilemapBuffer+0x500 _08091178: .4byte gUnknown_08A1A084 _0809117C: .4byte ProcScr_bmview diff --git a/data/data_59E8E0.s b/data/data_59E8E0.s index bf83d26c4..f26a24f19 100644 --- a/data/data_59E8E0.s +++ b/data/data_59E8E0.s @@ -8,12 +8,12 @@ gGfx_MiscUiGraphics: @ 0x0859E8E0 gPal_MiscUiGraphics: @ 0x0859ED70 .incbin "baserom.gba", 0x59ED70, 0x40 - .global gUnknown_0859EDB0 -gUnknown_0859EDB0: @ 0x0859EDB0 + .global gImg_UiCursorHandTop +gImg_UiCursorHandTop: @ 0x0859EDB0 .incbin "baserom.gba", 0x59EDB0, 0x3C - .global gUnknown_0859EDEC -gUnknown_0859EDEC: @ 0x0859EDEC + .global gImg_UiCursorHandBottom +gImg_UiCursorHandBottom: @ 0x0859EDEC .incbin "baserom.gba", 0x59EDEC, 0x34 .global gPal_MapSprite diff --git a/data/data_A195B0.s b/data/data_A195B0.s index f4d511bae..1a4d03395 100644 --- a/data/data_A195B0.s +++ b/data/data_A195B0.s @@ -144,12 +144,12 @@ gUnknown_08A1BD40: @ 0x08A1BD40 gUnknown_08A1BD60: @ 0x08A1BD60 .incbin "baserom.gba", 0xA1BD60, 0x9A4 - .global gUnknown_08A1C704 -gUnknown_08A1C704: @ 0x08A1C704 + .global gImg_UiSpinningArrow_Vertical +gImg_UiSpinningArrow_Vertical: @ 0x08A1C704 .incbin "baserom.gba", 0xA1C704, 0xD4 - .global gUnknown_08A1C7D8 -gUnknown_08A1C7D8: @ 0x08A1C7D8 + .global gImg_UiSpinningArrow_Horizontal +gImg_UiSpinningArrow_Horizontal: @ 0x08A1C7D8 .incbin "baserom.gba", 0xA1C7D8, 0xDC .global gUnknown_08A1C8B4 diff --git a/data/data_A2077C.s b/data/data_A2077C.s index 789df6608..fd30b828d 100644 --- a/data/data_A2077C.s +++ b/data/data_A2077C.s @@ -1,59 +1,5 @@ .section .data - .global gUnknown_08A20B3C -gUnknown_08A20B3C: @ 0x08A20B3C - .incbin "baserom.gba", 0xA20B3C, 0x8 - - .global gUnknown_08A20B44 -gUnknown_08A20B44: @ 0x08A20B44 - .incbin "baserom.gba", 0xA20B44, 0x8 - - .global gUnknown_08A20B4C -gUnknown_08A20B4C: @ 0x08A20B4C - @ PROC_CALL - .short 0x2, 0x0 - .word sub_80AC904 - @ PROC_LABEL - .short 0xb, 0x0 - .word 0x0 - @ PROC_REPEAT - .short 0x3, 0x0 - .word sub_80AC930 - @ PROC_LABEL - .short 0xb, 0x1 - .word 0x0 - @ PROC_BLOCK - .short 0x10, 0x0 - .word 0x0 - @ PROC_END - .short 0x0, 0x0 - .word 0x0 - - - .global gUnknown_08A20B7C -gUnknown_08A20B7C: @ 0x08A20B7C - .incbin "baserom.gba", 0xA20B7C, 0xE - - .global gUnknown_08A20B8A -gUnknown_08A20B8A: @ 0x08A20B8A - .incbin "baserom.gba", 0xA20B8A, 0xA - - .global gUnknown_08A20B94 -gUnknown_08A20B94: @ 0x08A20B94 - @ PROC_CALL - .short 0x2, 0x0 - .word sub_80ACB14 - @ PROC_YIELD - .short 0xe, 0x0 - .word 0x0 - @ PROC_REPEAT - .short 0x3, 0x0 - .word sub_80ACB34 - @ PROC_END - .short 0x0, 0x0 - .word 0x0 - - .global ProcScr_ParallelFiniteLoop ProcScr_ParallelFiniteLoop: @ 0x08A20BB4 @ PROC_YIELD diff --git a/include/functions.h b/include/functions.h index 0910539a0..803c36bdc 100644 --- a/include/functions.h +++ b/include/functions.h @@ -1213,24 +1213,24 @@ void StartSupportScreen(ProcPtr); // ??? sub_80AC6AC(???); // ??? sub_80AC784(???); void sub_80AC844(u16 *, int, int, int, int, int, int, int); -// ??? sub_80AC904(???); -// ??? sub_80AC930(???); -ProcPtr sub_80AC9C0(ProcPtr); -void sub_80AC9D4(int, int, int, u8); -void sub_80ACA4C(int, int, int, int, int); +// ??? UiCursorHand_Init(???); +// ??? UiCursorHand_Loop(???); +ProcPtr StartUiCursorHand(ProcPtr); +void SetUiCursorHandConfig(int, int, int, u8); +void UiCursorHand_80ACA4C(int, int, int, int, int); void sub_80ACA84(u32 a); void sub_80ACAA4(void); -void sub_80ACAC8(void); -void sub_80ACAE4(void); -void sub_80ACB00(void); -// ??? sub_80ACB14(???); -// ??? sub_80ACB34(???); -ProcPtr sub_80ACCE0(ProcPtr); -ProcPtr sub_80ACCF4(int, int, int); -void sub_80ACD60(int mask); -void sub_80ACD7C(int, int, int, int); -void sub_80ACDA4(int); -void sub_80ACDDC(void); +void BlockUiCursorHand(void); +void UnblockUiCursorHand(void); +void EndUiCursorHand(void); +// ??? UiSpinningArrows_Init(???); +// ??? UiSpinningArrows_Loop(???); +ProcPtr StartUiSpinningArrows(ProcPtr); +ProcPtr LoadUiSpinningArrowGfx(int, int, int); +void SetUiSpinningArrowConfig(int mask); +void SetUiSpinningArrowPositions(int, int, int, int); +void SetUiSpinningArrowFastMaybe(int); +void EndUiSpinningArrows(void); // ??? sub_80ACDF0(???); // ??? sub_80ACDF8(???); void StartParallelFiniteLoop(void *func, int cnt, u32 args); diff --git a/include/prepscreen.h b/include/prepscreen.h index 6ab7f1cde..ef284d359 100644 --- a/include/prepscreen.h +++ b/include/prepscreen.h @@ -329,8 +329,8 @@ extern u8 gUnknown_08A1BBD0[]; // tsa? // extern ??? gUnknown_08A1BD00 // extern ??? gUnknown_08A1BD40 // extern ??? gUnknown_08A1BD60 -extern u8 gUnknown_08A1C704[]; // arrow gfx -extern u8 gUnknown_08A1C7D8[]; +extern u8 gImg_UiSpinningArrow_Vertical[]; // arrow gfx +extern u8 gImg_UiSpinningArrow_Horizontal[]; // extern ??? gUnknown_08A1C8B4 // extern ??? gUnknown_08A1CD68 // extern ??? gUnknown_08A1CDC4 diff --git a/include/variables.h b/include/variables.h index 7d0c1de0c..991aaa222 100644 --- a/include/variables.h +++ b/include/variables.h @@ -610,8 +610,8 @@ extern struct ProcCmd CONST_DATA gProcScr_UpdateTraps[]; // extern ??? gUnknown_0859DBA0 extern u16 gGfx_MiscUiGraphics[]; extern u16 gPal_MiscUiGraphics[]; -extern u8 gUnknown_0859EDB0[]; -extern u8 gUnknown_0859EDEC[]; +extern u8 gImg_UiCursorHandTop[]; +extern u8 gImg_UiCursorHandBottom[]; // extern ??? gUnknown_0859EE20 // extern ??? gUnknown_0859EE40 // extern ??? gUnknown_0859EE60 @@ -1193,12 +1193,12 @@ extern u16* gUnknown_08A209F0[]; // extern ??? gSpriteArray_08A20B08 // extern ??? gUnknown_08A20B14 // extern ??? gProcScr_DrawDifficultyMenuSprites -// extern ??? gUnknown_08A20B3C -// extern ??? gUnknown_08A20B44 -// extern ??? gUnknown_08A20B4C -// extern ??? gUnknown_08A20B7C -// extern ??? gUnknown_08A20B8A -// extern ??? gUnknown_08A20B94 +// extern ??? gSprite_UiCursorHand_08A20B3C +// extern ??? gSprite_UiCursorHand_08A20B44 +// extern ??? gProcScr_UiCursorHand +// extern ??? gSprite_UiSpinningArrows_Horizontal +// extern ??? gSprite_UiSpinningArrows_Vertical +// extern ??? gProcScr_UiSpinningArrows // extern ??? ProcScr_ParallelFiniteLoop // extern ??? gUnknown_08A20BD4 // extern ??? ProcScr_ParallelWorker diff --git a/ldscript.txt b/ldscript.txt index f64ae86a9..8aad35d9f 100644 --- a/ldscript.txt +++ b/ldscript.txt @@ -732,6 +732,8 @@ SECTIONS . = ALIGN(4); src/savedrawcursor.o(.data); . = ALIGN(4); src/savemenu_data.o(.data); . = ALIGN(4); src/difficultymenu.o(.data); + . = ALIGN(4); src/cursor_hand.o(.data); + . = ALIGN(4); src/spinning_arrow.o(.data); . = ALIGN(4); data/data_A2077C.o(.data); . = ALIGN(4); src/soundroom.o(.data); . = ALIGN(4); src/extramenu_unk.o(.data); diff --git a/src/bmshop.c b/src/bmshop.c index 2bdc09c1c..f80c9b2b1 100644 --- a/src/bmshop.c +++ b/src/bmshop.c @@ -1465,7 +1465,7 @@ void DisplayShopUiArrows(void) { } void UnpackUiVArrowGfx(int index, int palIdx) { - Decompress(gUnknown_08A1C704, (void *)((0x3FF & index) * 0x20 + 0x06010000)); + Decompress(gImg_UiSpinningArrow_Vertical, (void *)((0x3FF & index) * 0x20 + 0x06010000)); ApplyPalette(gUnknown_08A1A084, palIdx + 0x10); return; diff --git a/src/bonusclaim.c b/src/bonusclaim.c index 8306a396f..cd6ef8cdf 100644 --- a/src/bonusclaim.c +++ b/src/bonusclaim.c @@ -439,7 +439,7 @@ void BonusClaim_Init(struct BonusClaimProc* proc) { UpdateMenuScrollBarConfig(8, proc->unk_2c, *gpBonusClaimItemCount, 5); - sub_80AC9C0(proc); + StartUiCursorHand(proc); SetupBonusClaimTargets(proc); @@ -622,7 +622,7 @@ void BonusClaim_StartSelectTargetSubMenu(struct BonusClaimProc* proc) { gLCDControlBuffer.win0_right = 200; gLCDControlBuffer.win0_bottom = (tmp + 7) * 8; - sub_80AC9D4(0, 40, proc->menuIndex * 16 + 56 - proc->unk_2c, 1); + SetUiCursorHandConfig(0, 40, proc->menuIndex * 16 + 56 - proc->unk_2c, 1); ShowPrepScreenHandCursor(92, proc->submenuIndex * 16 + 48, 12, 0x800); diff --git a/src/cursor_hand.c b/src/cursor_hand.c index d829d8299..8b1ae8a43 100644 --- a/src/cursor_hand.c +++ b/src/cursor_hand.c @@ -17,13 +17,26 @@ struct CursorHandProc /* 00 */ PROC_HEADER; /* 29 */ STRUCT_PAD(0x29, 0x2c); /* 2C */ struct Unk2C unk_2c[4]; - /* 3C */ u8 unk_3c[4]; - /* 40 */ s16 unk_40[4]; - /* 48 */ s16 unk_48[4]; + /* 3C */ u8 flags[4]; + /* 40 */ s16 x[4]; + /* 48 */ s16 y[4]; }; -extern u16 gUnknown_08A20B3C[]; -extern u16 gUnknown_08A20B44[]; +// clang-format off + +u16 CONST_DATA gSprite_UiCursorHand_08A20B3C[] = +{ + 1, + OAM0_SHAPE_16x16 + OAM0_Y(2), OAM1_SIZE_16x16, 0, +}; + +u16 CONST_DATA gSprite_UiCursorHand_08A20B44[] = +{ + 1, + OAM0_SHAPE_16x16 + OAM0_Y(2), OAM1_SIZE_16x16, OAM2_CHR(0x6), +}; + +// clang-format on //! FE8U = 0x080AC844 void sub_80AC844(u16 * buf, int xBase, int yBase, int bgIndex, int xOffset, int yOffset, int xMax, int yMax) @@ -60,13 +73,13 @@ void sub_80AC844(u16 * buf, int xBase, int yBase, int bgIndex, int xOffset, int } //! FE8U = 0x080AC904 -void sub_80AC904(struct CursorHandProc * proc) +void UiCursorHand_Init(struct CursorHandProc * proc) { int i; for (i = 0; i < 4; i++) { - proc->unk_3c[i] = 0; + proc->flags[i] = 0; proc->unk_2c[i].a = 0; proc->unk_2c[i].b = 0; @@ -78,7 +91,7 @@ void sub_80AC904(struct CursorHandProc * proc) } //! FE8U = 0x080AC930 -void sub_80AC930(struct CursorHandProc * proc) +void UiCursorHand_Loop(struct CursorHandProc * proc) { int i; @@ -87,13 +100,13 @@ void sub_80AC930(struct CursorHandProc * proc) int x; int y; - if (!(proc->unk_3c[i] & 1)) + if (!(proc->flags[i] & 1)) { continue; } - x = proc->unk_40[i]; - y = proc->unk_48[i]; + x = proc->x[i]; + y = proc->y[i]; if (x < proc->unk_2c[i].a || x >= proc->unk_2c[i].c) { @@ -105,43 +118,58 @@ void sub_80AC930(struct CursorHandProc * proc) continue; } - if (proc->unk_3c[i] & 2) + if (proc->flags[i] & 2) { - PutSprite(3, proc->unk_40[i] - 12, proc->unk_48[i], gUnknown_08A20B44, 0); + PutSprite(3, proc->x[i] - 12, proc->y[i], gSprite_UiCursorHand_08A20B44, 0); } else { - PutSprite(3, proc->unk_40[i] - 12, proc->unk_48[i], gUnknown_08A20B3C, 0); + PutSprite(3, proc->x[i] - 12, proc->y[i], gSprite_UiCursorHand_08A20B3C, 0); } } return; } -extern struct ProcCmd gUnknown_08A20B4C[]; +// clang-format off + +struct ProcCmd CONST_DATA gProcScr_UiCursorHand[] = +{ + PROC_CALL(UiCursorHand_Init), + +PROC_LABEL(0), + PROC_REPEAT(UiCursorHand_Loop), + +PROC_LABEL(1), + PROC_BLOCK, + + PROC_END, +}; + +// clang-format on //! FE8U = 0x080AC9C0 -ProcPtr sub_80AC9C0(ProcPtr parent) +ProcPtr StartUiCursorHand(ProcPtr parent) { - return Proc_Start(gUnknown_08A20B4C, parent); + return Proc_Start(gProcScr_UiCursorHand, parent); } //! FE8U = 0x080AC9D4 -void sub_80AC9D4(int index, int x, int y, u8 flags) +void SetUiCursorHandConfig(int index, int x, int y, u8 flags) { - struct CursorHandProc * proc = Proc_Find(gUnknown_08A20B4C); + struct CursorHandProc * proc = Proc_Find(gProcScr_UiCursorHand); if (proc != NULL) { - proc->unk_3c[index] = 1; - proc->unk_40[index] = x; - proc->unk_48[index] = y; - proc->unk_3c[index] = flags | 1; + proc->flags[index] = 1; + proc->x[index] = x; + proc->y[index] = y; + proc->flags[index] = flags | 1; if (flags & 2) { - Decompress(gUnknown_0859EDB0, (void *)0x060100C0); - Decompress(gUnknown_0859EDEC, (void *)0x060104C0); + Decompress(gImg_UiCursorHandTop, (void *)0x060100C0); + Decompress(gImg_UiCursorHandBottom, (void *)0x060104C0); } } @@ -149,9 +177,9 @@ void sub_80AC9D4(int index, int x, int y, u8 flags) } //! FE8U = 0x080ACA4C -void sub_80ACA4C(int index, int a, int b, int c, int d) +void UiCursorHand_80ACA4C(int index, int a, int b, int c, int d) { - struct CursorHandProc * proc = Proc_Find(gUnknown_08A20B4C); + struct CursorHandProc * proc = Proc_Find(gProcScr_UiCursorHand); if (proc != NULL) { @@ -167,11 +195,11 @@ void sub_80ACA4C(int index, int a, int b, int c, int d) //! FE8U = 0x080ACA84 void sub_80ACA84(u32 index) { - struct CursorHandProc * proc = Proc_Find(gUnknown_08A20B4C); + struct CursorHandProc * proc = Proc_Find(gProcScr_UiCursorHand); if (proc != NULL) { - proc->unk_3c[index] = 0; + proc->flags[index] = 0; } return; @@ -180,7 +208,7 @@ void sub_80ACA84(u32 index) //! FE8U = 0x080ACAA4 void sub_80ACAA4(void) { - struct CursorHandProc * proc = Proc_Find(gUnknown_08A20B4C); + struct CursorHandProc * proc = Proc_Find(gProcScr_UiCursorHand); if (proc != NULL) { @@ -188,7 +216,7 @@ void sub_80ACAA4(void) for (i = 0; i < 8; i++) { - proc->unk_3c[i] = 0; + proc->flags[i] = 0; } } @@ -196,9 +224,9 @@ void sub_80ACAA4(void) } //! FE8U = 0x080ACAC8 -void sub_80ACAC8(void) +void BlockUiCursorHand(void) { - struct CursorHandProc * proc = Proc_Find(gUnknown_08A20B4C); + struct CursorHandProc * proc = Proc_Find(gProcScr_UiCursorHand); if (proc != NULL) { @@ -209,9 +237,9 @@ void sub_80ACAC8(void) } //! FE8U = 0x080ACAE4 -void sub_80ACAE4(void) +void UnblockUiCursorHand(void) { - struct CursorHandProc * proc = Proc_Find(gUnknown_08A20B4C); + struct CursorHandProc * proc = Proc_Find(gProcScr_UiCursorHand); if (proc != NULL) { @@ -222,8 +250,8 @@ void sub_80ACAE4(void) } //! FE8U = 0x080ACB00 -void sub_80ACB00(void) +void EndUiCursorHand(void) { - Proc_End(Proc_Find(gUnknown_08A20B4C)); + Proc_End(Proc_Find(gProcScr_UiCursorHand)); return; } diff --git a/src/prep_itemlist.c b/src/prep_itemlist.c index 9d1e87f4f..eec015042 100644 --- a/src/prep_itemlist.c +++ b/src/prep_itemlist.c @@ -182,7 +182,7 @@ void PrepItemList_InitGfx(struct PrepItemListProc* proc) { BG_EnableSyncByMask(7); - sub_80AC9C0(proc); + StartUiCursorHand(proc); ResetPrepScreenHandCursor(proc); sub_80AD4A0(0x600, 1); @@ -249,10 +249,10 @@ void PrepItemList_InitGfx(struct PrepItemListProc* proc) { DrawPrepScreenItems(gBG0TilemapBuffer + 0x6F + 0xb3, gUnknown_02013660 + 2, proc->unit, 0); sub_809EBF0(); - sub_80ACCE0(proc); - sub_80ACCF4(0, 0x280, 2); - sub_80ACD7C(0x78, 0x18, 0xe9, 0x18); - sub_80ACD60(3); + StartUiSpinningArrows(proc); + LoadUiSpinningArrowGfx(0, 0x280, 2); + SetUiSpinningArrowPositions(0x78, 0x18, 0xe9, 0x18); + SetUiSpinningArrowConfig(3); StartParallelWorker(List_PutHighlightedCategorySprites, proc); @@ -559,7 +559,7 @@ void PrepItemList_Loop_MainKeyHandler(struct PrepItemListProc* proc) { } if (gPrepScreenItemList[idx].pid == 0) { - sub_80AC9D4( + SetUiCursorHandConfig( 0, 0x80, proc->idxPerPage[proc->currentPage] * 16 + 40 - proc->yOffsetPerPage[proc->currentPage], @@ -590,7 +590,7 @@ void PrepItemList_Loop_MainKeyHandler(struct PrepItemListProc* proc) { } if (gKeyStatusPtr->repeatedKeys & DPAD_LEFT) { - sub_80ACDA4(0); + SetUiSpinningArrowFastMaybe(0); PlaySoundEffect(0x67); Proc_Goto(proc, 3); proc->unk_32 = 0; @@ -599,7 +599,7 @@ void PrepItemList_Loop_MainKeyHandler(struct PrepItemListProc* proc) { } if (gKeyStatusPtr->repeatedKeys & DPAD_RIGHT) { - sub_80ACDA4(1); + SetUiSpinningArrowFastMaybe(1); PlaySoundEffect(0x67); Proc_Goto(proc, 4); proc->unk_32 = 0; diff --git a/src/prep_itemscreen.c b/src/prep_itemscreen.c index 858519207..58f7e01c0 100644 --- a/src/prep_itemscreen.c +++ b/src/prep_itemscreen.c @@ -333,7 +333,7 @@ void PrepItemScreen_SetupGfx(struct PrepItemScreenProc* proc) { ResetPrepScreenHandCursor(proc); StartParallelWorker(sub_809A274, proc); - sub_80AC9C0(proc); + StartUiCursorHand(proc); SetPrimaryHBlankHandler(NULL); @@ -385,13 +385,13 @@ void PrepItemScreen_SetupGfx(struct PrepItemScreenProc* proc) { ForceSyncUnitSpriteSheet(); Decompress(Img_PrepTextShadow, (void *)0x06013E00); - sub_80ACA4C(0, 0, 0, 0xd0, 0x3c); + UiCursorHand_80ACA4C(0, 0, 0, 0xd0, 0x3c); sub_80AD4A0(0x600, 1); RestartMuralBackground(); if (proc->selectedUnitIdx != 0xff) { - sub_80AC9D4( + SetUiCursorHandConfig( 0, ((proc->selectedUnitIdx % 3) * 64) + 24, ((proc->selectedUnitIdx / 3) * 16) + 4 - proc->unk_34, @@ -426,7 +426,7 @@ void PrepItemScreen_OnEnd(struct PrepItemScreenProc* proc) { EndAllParallelWorkers(); EndPrepScreenHandCursor(); - sub_80ACB00(); + EndUiCursorHand(); EndPrepItemScreenFace(0); EndPrepItemScreenFace(1); @@ -611,7 +611,7 @@ void sub_8098CC0(struct PrepItemScreenProc* proc) { ); sub_809A504(proc, 0); - sub_80ACAE4(); + UnblockUiCursorHand(); sub_80ACAA4(); StartHelpPromptSprite(120, 140, 9, proc); @@ -703,7 +703,7 @@ void sub_8098FAC(struct PrepItemScreenProc* proc) { proc->unk_34 += proc->scrollAmount; BG_SetPosition(2, -40, (proc->unk_34 - 4) & 0xff); if (proc->selectedUnitIdx != 0xFF) { - sub_80AC9D4( + SetUiCursorHandConfig( 0, ((proc->selectedUnitIdx % 3) * 64) + 24, ((proc->selectedUnitIdx / 3) * 16) + 4 - proc->unk_34, @@ -717,7 +717,7 @@ void sub_8098FAC(struct PrepItemScreenProc* proc) { proc->unk_34 -= proc->scrollAmount; BG_SetPosition(2, -40, (proc->unk_34 - 4) & 0xff); if (proc->selectedUnitIdx != 0xFF) { - sub_80AC9D4( + SetUiCursorHandConfig( 0, ((proc->selectedUnitIdx % 3) * 64) + 24, ((proc->selectedUnitIdx / 3) * 16) + 4 - proc->unk_34, @@ -798,7 +798,7 @@ void sub_8099120(struct PrepItemScreenProc* proc) { } } - sub_80AC9D4( + SetUiCursorHandConfig( 0, ((proc->selectedUnitIdx % 3) * 64) + 24, (proc->selectedUnitIdx / 3) * 16 + 4 - proc->unk_34, @@ -922,9 +922,9 @@ void sub_80995D4(struct PrepItemScreenProc* proc) { ); if (unk != 0) { - sub_80ACAC8(); + BlockUiCursorHand(); } else { - sub_80ACAE4(); + UnblockUiCursorHand(); } sub_8098BE8(); @@ -1203,7 +1203,7 @@ void sub_8099AF8(struct PrepItemScreenProc* proc) { UpdatePrepItemScreenFace(0, GetUnitFromPrepList(proc->selectedUnitIdx), 60, 76, 0x0503); UpdatePrepItemScreenFace(1, GetUnitFromPrepList(proc->hoverUnitIdx), 180, 76, 0x0502); - sub_80AC9D4( + SetUiCursorHandConfig( 0, ((proc->selectedUnitIdx % 3) * 64) + 24, ((proc->selectedUnitIdx / 3) * 16) + 4 - proc->unk_34, @@ -1212,7 +1212,7 @@ void sub_8099AF8(struct PrepItemScreenProc* proc) { StartParallelFiniteLoop(sub_8099AA0, 1, (u32)proc); - sub_80ACAE4(); + UnblockUiCursorHand(); HideUnitInfoBgSprites(); EndHelpPromptSprite(); diff --git a/src/prep_itemsupply.c b/src/prep_itemsupply.c index 56506a817..83967c471 100644 --- a/src/prep_itemsupply.c +++ b/src/prep_itemsupply.c @@ -427,7 +427,7 @@ void PrepItemSupply_InitGfx(struct PrepItemSupplyProc* proc) { StartSmallBrownNameBoxes(0xd, 0xe00, 0xf, 0xc00, 0, proc); SmallBrownNameBoxDoSomeConfig(0, 0x90, 6, 2); GetStringFromIndex(proc->unit->pCharacterData->nameTextId); - sub_80AC9C0(proc); + StartUiCursorHand(proc); ResetPrepScreenHandCursor(proc); sub_80AD4A0(0x600, 1); @@ -495,10 +495,10 @@ void PrepItemSupply_InitGfx(struct PrepItemSupplyProc* proc) { DrawPrepScreenItems(gBG0TilemapBuffer + 0x6F + 0xb3, &gUnknown_02013648.th[2], proc->unit, 0); sub_809D6CC(); - sub_80ACCE0(proc); - sub_80ACCF4(0, 0x280, 2); - sub_80ACD7C(0x78, 0x18, 0xe9, 0x18); - sub_80ACD60(3); + StartUiSpinningArrows(proc); + LoadUiSpinningArrowGfx(0, 0x280, 2); + SetUiSpinningArrowPositions(0x78, 0x18, 0xe9, 0x18); + SetUiSpinningArrowConfig(3); StartParallelWorker(Supply_PutHighlightedCategorySprites, proc); return; @@ -531,7 +531,7 @@ void PrepItemSupply_Loop_GiveTakeKeyHandler(struct PrepItemSupplyProc* proc) { switch (idx) { case 0: if ((GetConvoyItemCount_() < CONVOY_ITEM_COUNT) && (GetUnitItemCount(proc->unit) > 0)) { - sub_80AC9D4(0, 68, proc->unk_33 * 16 + 36, 2); + SetUiCursorHandConfig(0, 68, proc->unk_33 * 16 + 36, 2); Proc_End(GetParallelWorker(PutGiveTakeBoxSprites)); StartParallelWorker(PutGiveSprites, proc); sub_809D278(1, proc); @@ -544,7 +544,7 @@ void PrepItemSupply_Loop_GiveTakeKeyHandler(struct PrepItemSupplyProc* proc) { break; case 1: if (GetUnitItemCount(proc->unit) < UNIT_ITEM_COUNT) { - sub_80AC9D4(0, 68, proc->unk_33 * 16 + 36, 2); + SetUiCursorHandConfig(0, 68, proc->unk_33 * 16 + 36, 2); Proc_End(GetParallelWorker(PutGiveTakeBoxSprites)); StartParallelWorker(PutTakeSprites, proc); sub_809D278(2, proc); @@ -880,7 +880,7 @@ void sub_809E420(struct PrepItemSupplyProc* proc) { } if (gKeyStatusPtr->repeatedKeys & DPAD_LEFT) { - sub_80ACDA4(0); + SetUiSpinningArrowFastMaybe(0); PlaySoundEffect(0x67); Proc_Goto(proc, 5); proc->unk_34 = 0; @@ -889,7 +889,7 @@ void sub_809E420(struct PrepItemSupplyProc* proc) { } if (gKeyStatusPtr->repeatedKeys & DPAD_RIGHT) { - sub_80ACDA4(1); + SetUiSpinningArrowFastMaybe(1); PlaySoundEffect(0x67); Proc_Goto(proc, 6); proc->unk_34 = 0; diff --git a/src/prep_itemtrade.c b/src/prep_itemtrade.c index 5d7bb4a13..adb8268d6 100644 --- a/src/prep_itemtrade.c +++ b/src/prep_itemtrade.c @@ -277,7 +277,7 @@ void PrepItemTrade_Init(struct PrepMenuTradeProc* proc) { DrawPrepScreenItems(gBG0TilemapBuffer + 0x122, gPrepItemScreenTexts + 0, proc->units[0], 0); DrawPrepScreenItems(gBG0TilemapBuffer + 0x130, gPrepItemScreenTexts + 5, proc->units[1], 0); - sub_80AC9C0(proc); + StartUiCursorHand(proc); ResetPrepScreenHandCursor(proc); sub_80AD4A0(0x600, 1); @@ -375,7 +375,7 @@ void PrepItemTrade_Loop_MainKeyHandler(struct PrepMenuTradeProc* proc) { if (gKeyStatusPtr->newKeys & A_BUTTON) { int itemCount = GetUnitItemCount(proc->units[((proc->cursorItemSlot >> 3) + 1) & 1]); proc->selectedItemSlot = proc->cursorItemSlot; - sub_80AC9D4(0, (proc->cursorItemSlot >> 3) * 0x70 + 0x10, (proc->cursorItemSlot & 7) * 0x10 + 0x48, 0); + SetUiCursorHandConfig(0, (proc->cursorItemSlot >> 3) * 0x70 + 0x10, (proc->cursorItemSlot & 7) * 0x10 + 0x48, 0); if (itemCount < 5) { proc->cursorItemSlot = ((proc->cursorItemSlot + 8) & 8) + itemCount; } else { diff --git a/src/prep_itemuse.c b/src/prep_itemuse.c index f5a3c3bc4..8aaacf40e 100644 --- a/src/prep_itemuse.c +++ b/src/prep_itemuse.c @@ -431,7 +431,7 @@ void PrepItemUse_InitDisplay(struct ProcPrepItemUse *proc) ); /* Some hand obj API */ - sub_80AC9C0(proc); + StartUiCursorHand(proc); ResetPrepScreenHandCursor(proc); sub_80AD4A0(0x600, 1); @@ -490,7 +490,7 @@ void PrepItemUse_CtrlLoop(struct ProcPrepItemUse *proc) if (CanUnitUseItemPrepScreen(proc->unit, proc->unit->items[proc->slot]) != false) { proc->unk34 = proc->slot; - sub_80AC9D4(0, 0x10, 0x10 * proc->slot + 72, 0); + SetUiCursorHandConfig(0, 0x10, 0x10 * proc->slot + 72, 0); proc->pos_subbox = 1; PlaySoundEffect(0x6A); Proc_Goto(proc, PROC_LABEL_PREPITEMUSE_CONFIRM); diff --git a/src/prep_unitselect.c b/src/prep_unitselect.c index 8d17f9d99..b730ddedf 100644 --- a/src/prep_unitselect.c +++ b/src/prep_unitselect.c @@ -411,7 +411,7 @@ void sub_809AE10(struct ProcPrepUnit *proc) if ((dif + 5) < amt) msk |= 2; - sub_80ACD60(msk); + SetUiSpinningArrowConfig(msk); } void ProcPrepUnit_OnInit(struct ProcPrepUnit *proc) @@ -483,7 +483,7 @@ void sub_809B014() sub_80AD2D4(); EndPrepScreenHandCursor(); EndHelpPromptSprite(); - sub_80ACDDC(); + EndUiSpinningArrows(); EndMuralBackground_(); } diff --git a/src/prep_wm_sell.c b/src/prep_wm_sell.c index 29970ca66..fe5993437 100644 --- a/src/prep_wm_sell.c +++ b/src/prep_wm_sell.c @@ -238,7 +238,7 @@ void WmSell_Setup(struct WmSellProc* proc) { 72, FACE_DISP_KIND(FACE_96x80_FLIPPED) | FACE_DISP_HLAYER(FACE_HLAYER_2) | FACE_DISP_BLEND ); - sub_80AC9C0(proc); + StartUiCursorHand(proc); ResetPrepScreenHandCursor(proc); sub_80AD4A0(0x600, 1); @@ -418,7 +418,7 @@ void sub_80A0570(struct WmSellProc* proc) { StartParallelWorker(WmSell_DrawSellOptionSpriteText, proc); - sub_80AC9D4(0, 16, proc->unk_30 * 16 + 72, 2); + SetUiCursorHandConfig(0, 16, proc->unk_30 * 16 + 72, 2); ShowPrepScreenHandCursor(proc->unk_31 * 32 + 164, 111, 0, 0x400); sub_809FDD4(1, proc); diff --git a/src/spinning_arrow.c b/src/spinning_arrow.c index a8fd64062..f9e5b26cc 100644 --- a/src/spinning_arrow.c +++ b/src/spinning_arrow.c @@ -8,49 +8,63 @@ struct SpinningArrowProc { /* 00 */ PROC_HEADER; - /* 2C */ int unk_2c; - /* 30 */ int unk_30; - /* 34 */ int unk_34[2]; - /* 3C */ int unk_3c[2]; - /* 44 */ int unk_44[2]; - /* 4C */ int unk_4c[2]; - /* 54 */ u16 unk_54; + /* 2C */ int kind; + /* 30 */ int flags; + /* 34 */ int x[2]; + /* 3C */ int y[2]; + /* 44 */ int unk_44[2]; // first arrow current frame? + /* 4C */ int unk_4c[2]; // second arrow current frame? + /* 54 */ u16 oam2; }; //! FE8U = 0x080ACB14 -void sub_80ACB14(struct SpinningArrowProc * proc) +void UiSpinningArrows_Init(struct SpinningArrowProc * proc) { - proc->unk_2c = 0; - proc->unk_54 = 0; + proc->kind = 0; + proc->oam2 = 0; proc->unk_4c[0] = 0; proc->unk_44[0] = 0; - proc->unk_3c[0] = 0; - proc->unk_34[0] = 0; + proc->y[0] = 0; + proc->x[0] = 0; proc->unk_4c[1] = 0; proc->unk_44[1] = 0; - proc->unk_3c[1] = 0; - proc->unk_34[1] = 0; + proc->y[1] = 0; + proc->x[1] = 0; - proc->unk_30 = 0; + proc->flags = 0; return; } -extern u16 gUnknown_08A20B7C[]; -extern u16 gUnknown_08A20B8A[]; +// clang-format off + +u16 CONST_DATA gSprite_UiSpinningArrows_Horizontal[] = +{ + 2, + OAM0_SHAPE_8x8, OAM1_SIZE_8x8, 0, + OAM0_SHAPE_8x8 + OAM0_Y(8), OAM1_SIZE_8x8, OAM2_CHR(0x6), +}; + +u16 CONST_DATA gSprite_UiSpinningArrows_Vertical[] = +{ + 1, + OAM0_SHAPE_16x8, OAM1_SIZE_16x8, 0, +}; + +// clang-format on //! FE8U = 0x080ACB34 -void sub_80ACB34(struct SpinningArrowProc * proc) +void UiSpinningArrows_Loop(struct SpinningArrowProc * proc) { int i; - int xOam1_a = proc->unk_34[0]; - int yOam0_a = proc->unk_3c[0]; + int xOam1_a = proc->x[0]; + int yOam0_a = proc->y[0]; - int xOam1_b = proc->unk_34[1]; - int yOam0_b = proc->unk_3c[1]; + int xOam1_b = proc->x[1]; + int yOam0_b = proc->y[1]; proc->unk_44[0]++; proc->unk_44[1]++; @@ -69,12 +83,12 @@ void sub_80ACB34(struct SpinningArrowProc * proc) } } - if (proc->unk_2c == 0) + if (proc->kind == 0) { if (proc->unk_4c[0] != 0) { int r1 = (proc->unk_4c[0] >> 3) - 4; - xOam1_a = proc->unk_34[0] + r1; + xOam1_a = proc->x[0] + r1; if ((proc->unk_4c[0] >> 3) == 4) { proc->unk_4c[0] = 0; @@ -84,33 +98,34 @@ void sub_80ACB34(struct SpinningArrowProc * proc) if (proc->unk_4c[1] != 0) { int r1 = (proc->unk_4c[1] >> 3) - 4; - xOam1_b = proc->unk_34[1] - r1; + xOam1_b = proc->x[1] - r1; if ((proc->unk_4c[1] >> 3) == 4) { proc->unk_4c[1] = 0; } } - if ((proc->unk_30 & 1) != 0) + if (proc->flags & 1) { PutSpriteExt( - 0xd, OAM1_X(xOam1_a), OAM0_Y(yOam0_a), gUnknown_08A20B7C, proc->unk_54 + (proc->unk_44[0] >> 3)); + 0xd, OAM1_X(xOam1_a), OAM0_Y(yOam0_a), gSprite_UiSpinningArrows_Horizontal, + proc->oam2 + (proc->unk_44[0] >> 3)); } - if ((proc->unk_30 & 2) != 0) + if (proc->flags & 2) { PutSpriteExt( - 0xd, OAM1_X(xOam1_b) + OAM1_HFLIP, OAM0_Y(yOam0_b), gUnknown_08A20B7C, - proc->unk_54 + (proc->unk_44[1] >> 3)); + 0xd, OAM1_X(xOam1_b) + OAM1_HFLIP, OAM0_Y(yOam0_b), gSprite_UiSpinningArrows_Horizontal, + proc->oam2 + (proc->unk_44[1] >> 3)); } } - if (proc->unk_2c == 1) + if (proc->kind == 1) { if (proc->unk_4c[0] != 0) { int r1 = (proc->unk_4c[0] >> 3) - 4; - yOam0_a = proc->unk_3c[0] + r1; + yOam0_a = proc->y[0] + r1; if ((proc->unk_4c[0] >> 3) == 4) { proc->unk_4c[0] = 0; @@ -120,45 +135,57 @@ void sub_80ACB34(struct SpinningArrowProc * proc) if (proc->unk_4c[1] != 0) { int r1 = (proc->unk_4c[1] >> 3) - 4; - yOam0_b = proc->unk_3c[1] - r1; + yOam0_b = proc->y[1] - r1; if ((proc->unk_4c[1] >> 3) == 4) { proc->unk_4c[1] = 0; } } - if (proc->unk_30 & 1) + if (proc->flags & 1) { PutSpriteExt( - 0xd, OAM1_X(xOam1_a), OAM0_Y(yOam0_a), gUnknown_08A20B8A, proc->unk_54 + (proc->unk_44[0] >> 3) * 2); + 0xd, OAM1_X(xOam1_a), OAM0_Y(yOam0_a), gSprite_UiSpinningArrows_Vertical, + proc->oam2 + (proc->unk_44[0] >> 3) * 2); } - if (proc->unk_30 & 2) + if (proc->flags & 2) { PutSpriteExt( - 0xd, OAM1_X(xOam1_b) + OAM1_VFLIP, OAM0_Y(yOam0_b), gUnknown_08A20B8A, - proc->unk_54 + (proc->unk_44[1] >> 3) * 2); + 0xd, OAM1_X(xOam1_b) + OAM1_VFLIP, OAM0_Y(yOam0_b), gSprite_UiSpinningArrows_Vertical, + proc->oam2 + (proc->unk_44[1] >> 3) * 2); } } return; } -extern struct ProcCmd gUnknown_08A20B94[]; +// clang-format off + +struct ProcCmd CONST_DATA gProcScr_UiSpinningArrows[] = +{ + PROC_CALL(UiSpinningArrows_Init), + PROC_YIELD, + PROC_REPEAT(UiSpinningArrows_Loop), + + PROC_END, +}; + +// clang-format on //! FE8U = 0x080ACCE0 -ProcPtr sub_80ACCE0(ProcPtr parent) +ProcPtr StartUiSpinningArrows(ProcPtr parent) { - return Proc_Start(gUnknown_08A20B94, parent); + return Proc_Start(gProcScr_UiSpinningArrows, parent); } //! FE8U = 0x080ACCF4 -ProcPtr sub_80ACCF4(int kind, int chr, int palId) +ProcPtr LoadUiSpinningArrowGfx(int kind, int chr, int palId) { int oam2Chr; int oam2Pal; - struct SpinningArrowProc * proc = Proc_Find(gUnknown_08A20B94); + struct SpinningArrowProc * proc = Proc_Find(gProcScr_UiSpinningArrows); if (proc != NULL) { @@ -166,58 +193,58 @@ ProcPtr sub_80ACCF4(int kind, int chr, int palId) if (kind == 0) { - Decompress(gUnknown_08A1C7D8, (void *)(chr + 0x06010000)); + Decompress(gImg_UiSpinningArrow_Horizontal, (void *)(chr + 0x06010000)); } if (kind == 1) { - Decompress(gUnknown_08A1C704, (void *)(chr + 0x06010000)); + Decompress(gImg_UiSpinningArrow_Vertical, (void *)(chr + 0x06010000)); } oam2Chr = chr >> 5; oam2Pal = OAM2_PAL(palId); - proc->unk_54 = oam2Chr + oam2Pal; + proc->oam2 = oam2Chr + oam2Pal; - proc->unk_2c = kind; + proc->kind = kind; } // return proc; } //! FE8U = 0x080ACD60 -void sub_80ACD60(int flags) +void SetUiSpinningArrowConfig(int flags) { - struct SpinningArrowProc * proc = Proc_Find(gUnknown_08A20B94); + struct SpinningArrowProc * proc = Proc_Find(gProcScr_UiSpinningArrows); if (proc != NULL) { - proc->unk_30 = flags; + proc->flags = flags; } return; } //! FE8U = 0x080ACD7C -void sub_80ACD7C(int x1, int y1, int x2, int y2) +void SetUiSpinningArrowPositions(int x1, int y1, int x2, int y2) { - struct SpinningArrowProc * proc = Proc_Find(gUnknown_08A20B94); + struct SpinningArrowProc * proc = Proc_Find(gProcScr_UiSpinningArrows); if (proc != NULL) { - proc->unk_34[0] = x1; - proc->unk_3c[0] = y1; + proc->x[0] = x1; + proc->y[0] = y1; - proc->unk_34[1] = x2; - proc->unk_3c[1] = y2; + proc->x[1] = x2; + proc->y[1] = y2; } return; } //! FE8U = 0x080ACDA4 -void sub_80ACDA4(int kind) +void SetUiSpinningArrowFastMaybe(int kind) { - struct SpinningArrowProc * proc = Proc_Find(gUnknown_08A20B94); + struct SpinningArrowProc * proc = Proc_Find(gProcScr_UiSpinningArrows); if (proc != NULL) { @@ -246,8 +273,8 @@ void sub_80ACDA4(int kind) } //! FE8U = 0x080ACDDC -void sub_80ACDDC(void) +void EndUiSpinningArrows(void) { - Proc_End(Proc_Find(gUnknown_08A20B94)); + Proc_End(Proc_Find(gProcScr_UiSpinningArrows)); return; }