From 7e355b532c55f1b831fea391392ce7d2b493bcc6 Mon Sep 17 00:00:00 2001 From: Morglom <40521432+Morglom@users.noreply.github.com> Date: Thu, 22 May 2025 16:47:40 +1000 Subject: [PATCH] Document sub menu cursor and rename position struct. (#511) * Document sub menu cursor and rename position struct. * Rename to grid menu cursor position * Further pull request changes. --- include/grid_menu_cursor_position.h | 27 +++ include/overlay013/battle_sub_menu_cursor.h | 32 +++ include/overlay013/ov13_02228A38.h | 21 -- include/overlay013/struct_ov13_022213F0.h | 4 +- include/overlay013/struct_ov13_02227244.h | 4 +- .../overlay013/struct_ov13_02228A50_decl.h | 6 - include/party_menu_cursor.h | 27 --- include/struct_defs/struct_0207F248.h | 4 +- platinum.us/main.lsf | 4 +- src/grid_menu_cursor_position.c | 51 +++++ src/meson.build | 4 +- src/overlay013/battle_sub_menu_cursor.c | 207 +++++++++++++++++ src/overlay013/ov13_0221FC20.c | 52 ++--- src/overlay013/ov13_02224500.c | 52 ++--- src/overlay013/ov13_022264F4.c | 22 +- src/overlay013/ov13_02227BDC.c | 28 +-- src/overlay013/ov13_02228A38.c | 216 ------------------ src/party_menu_cursor.c | 51 ----- src/unk_0207E0B8.c | 36 +-- src/unk_02082C2C.c | 4 +- 20 files changed, 424 insertions(+), 428 deletions(-) create mode 100644 include/grid_menu_cursor_position.h create mode 100644 include/overlay013/battle_sub_menu_cursor.h delete mode 100644 include/overlay013/ov13_02228A38.h delete mode 100644 include/overlay013/struct_ov13_02228A50_decl.h delete mode 100644 include/party_menu_cursor.h create mode 100644 src/grid_menu_cursor_position.c create mode 100644 src/overlay013/battle_sub_menu_cursor.c delete mode 100644 src/overlay013/ov13_02228A38.c delete mode 100644 src/party_menu_cursor.c diff --git a/include/grid_menu_cursor_position.h b/include/grid_menu_cursor_position.h new file mode 100644 index 0000000000..367b81d1a1 --- /dev/null +++ b/include/grid_menu_cursor_position.h @@ -0,0 +1,27 @@ +#ifndef POKEPLATINUM_GRID_MENU_CURSOR_POSITION_H +#define POKEPLATINUM_GRID_MENU_CURSOR_POSITION_H + +typedef struct GridMenuCursorPosition { + u8 xCoord1; + u8 yCoord1; + u8 xCoord2; + u8 yCoord2; + u8 upIndex; + u8 downIndex; + u8 leftIndex; + u8 rightIndex; +} GridMenuCursorPosition; + +enum GridMenuCursorPositionDirection { + GRID_MENU_CURSOR_POSITION_DIRECTION_UP = 0, + GRID_MENU_CURSOR_POSITION_DIRECTION_DOWN, + GRID_MENU_CURSOR_POSITION_DIRECTION_LEFT, + GRID_MENU_CURSOR_POSITION_DIRECTION_RIGHT, + GRID_MENU_CURSOR_POSITION_DIRECTION_NONE, +}; + +void GridMenuCursor_GetFirstCoords(const GridMenuCursorPosition *position, u8 *xCoord, u8 *yCoord); +void GridMenuCursor_GetSecondCoords(const GridMenuCursorPosition *position, u8 *xCoord, u8 *yCoord); +u8 GridMenuCursor_CheckNavigation(const GridMenuCursorPosition *positions, u8 *xCoord1, u8 *yCoord1, u8 *xCoord2, u8 *yCoord2, u8 currentPositionIndex, u8 directionToMove); + +#endif // POKEPLATINUM_GRID_MENU_CURSOR_POSITION_H diff --git a/include/overlay013/battle_sub_menu_cursor.h b/include/overlay013/battle_sub_menu_cursor.h new file mode 100644 index 0000000000..74d03bb2a9 --- /dev/null +++ b/include/overlay013/battle_sub_menu_cursor.h @@ -0,0 +1,32 @@ +#ifndef POKEPLATINUM_BATTLE_SUB_MENU_CURSOR_H +#define POKEPLATINUM_BATTLE_SUB_MENU_CURSOR_H + +#include "battle/struct_ov16_0226DC24_decl.h" + +#include "grid_menu_cursor_position.h" + +#define BATTLE_SUB_MENU_CURSOR_BACK_INDEX 0xfffffffe +#define BATTLE_SUB_MENU_CURSOR_NO_MOVEMENT_INDEX 0xffffffff + +typedef struct BattleSubMenuCursor { + UnkStruct_ov16_0226DC24 *sprites; + const GridMenuCursorPosition *positions; + u8 isVisible; + u8 currentPositionIndex; + u8 previousPositionIndex; + u32 enabledPositionsMask; +} BattleSubMenuCursor; + +BattleSubMenuCursor *MakeBattleSubMenuCursor(u32 heapID); +void DeleteBattleSubMenuCursor(BattleSubMenuCursor *cursor); +UnkStruct_ov16_0226DC24 *GetBattleSubMenuCursorSprites(BattleSubMenuCursor *cursor); +u8 IsBattleSubMenuCursorVisible(BattleSubMenuCursor *cursor); +void SetBattleSubMenuCursorVisibility(BattleSubMenuCursor *cursor, u8 isVisible); +void SetBattleSubMenuCursorSprites(BattleSubMenuCursor *cursor, UnkStruct_ov16_0226DC24 *sprites); +void SetBattleSubMenuCursorCurrentPosition(BattleSubMenuCursor *cursor, u8 positionIndex); +void ResetBattleSubMenuCursorCurrentPosition(BattleSubMenuCursor *cursor); +void SetBattleSubMenuCursorPositions(BattleSubMenuCursor *cursor, const GridMenuCursorPosition *positions); +void SetBattleSubMenuCursorEnabledPositionsMask(BattleSubMenuCursor *cursor, u32 mask); +u32 BattleSubMenuCursorTick(BattleSubMenuCursor *cursor); + +#endif // POKEPLATINUM_BATTLE_SUB_MENU_CURSOR_H diff --git a/include/overlay013/ov13_02228A38.h b/include/overlay013/ov13_02228A38.h deleted file mode 100644 index 0869d5b71c..0000000000 --- a/include/overlay013/ov13_02228A38.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef POKEPLATINUM_OV13_02228A38_H -#define POKEPLATINUM_OV13_02228A38_H - -#include "battle/struct_ov16_0226DC24_decl.h" -#include "overlay013/struct_ov13_02228A50_decl.h" - -#include "party_menu_cursor.h" - -UnkStruct_ov13_02228A50 *ov13_02228A38(u32 heapID); -void ov13_02228A50(UnkStruct_ov13_02228A50 *param0); -UnkStruct_ov16_0226DC24 *ov13_02228A58(UnkStruct_ov13_02228A50 *param0); -u8 ov13_02228A5C(UnkStruct_ov13_02228A50 *param0); -void ov13_02228A60(UnkStruct_ov13_02228A50 *param0, u8 param1); -void ov13_02228A64(UnkStruct_ov13_02228A50 *param0, UnkStruct_ov16_0226DC24 *param1); -void ov13_02228A68(UnkStruct_ov13_02228A50 *param0, u8 param1); -void ov13_02228A90(UnkStruct_ov13_02228A50 *param0); -void ov13_02228A9C(UnkStruct_ov13_02228A50 *param0, const PartyMenuCursor *param1); -void ov13_02228AC8(UnkStruct_ov13_02228A50 *param0, u32 param1); -u32 ov13_02228B64(UnkStruct_ov13_02228A50 *param0); - -#endif // POKEPLATINUM_OV13_02228A38_H diff --git a/include/overlay013/struct_ov13_022213F0.h b/include/overlay013/struct_ov13_022213F0.h index 0b64a225e9..26e0d0296c 100644 --- a/include/overlay013/struct_ov13_022213F0.h +++ b/include/overlay013/struct_ov13_022213F0.h @@ -3,9 +3,9 @@ #include "struct_decls/struct_0200C440_decl.h" +#include "overlay013/battle_sub_menu_cursor.h" #include "overlay013/struct_ov13_0221FC20.h" #include "overlay013/struct_ov13_02221ED0.h" -#include "overlay013/struct_ov13_02228A50_decl.h" #include "bg_window.h" #include "message.h" @@ -58,7 +58,7 @@ typedef struct { u8 unk_2079; u16 unk_207A; u16 unk_207C[4]; - UnkStruct_ov13_02228A50 *unk_2084; + BattleSubMenuCursor *unk_2084; u8 unk_2088; u8 unk_2089; u8 unk_208A; diff --git a/include/overlay013/struct_ov13_02227244.h b/include/overlay013/struct_ov13_02227244.h index 847b33d1d4..01504a6fbb 100644 --- a/include/overlay013/struct_ov13_02227244.h +++ b/include/overlay013/struct_ov13_02227244.h @@ -4,8 +4,8 @@ #include "struct_decls/struct_0200C440_decl.h" #include "battle/struct_ov16_0226DEEC_decl.h" +#include "overlay013/battle_sub_menu_cursor.h" #include "overlay013/struct_ov13_022264F4.h" -#include "overlay013/struct_ov13_02228A50_decl.h" #include "bag.h" #include "bg_window.h" @@ -28,7 +28,7 @@ typedef struct { u8 unk_30; u8 unk_31; u8 unk_32; - UnkStruct_ov13_02228A50 *unk_34; + BattleSubMenuCursor *unk_34; UnkStruct_ov16_0226DEEC *unk_38; BagItem unk_3C[5][36]; SpriteManager *unk_30C; diff --git a/include/overlay013/struct_ov13_02228A50_decl.h b/include/overlay013/struct_ov13_02228A50_decl.h deleted file mode 100644 index 24d5105ece..0000000000 --- a/include/overlay013/struct_ov13_02228A50_decl.h +++ /dev/null @@ -1,6 +0,0 @@ -#ifndef POKEPLATINUM_STRUCT_OV13_02228A50_DECL_H -#define POKEPLATINUM_STRUCT_OV13_02228A50_DECL_H - -typedef struct UnkStruct_ov13_02228A50_t UnkStruct_ov13_02228A50; - -#endif // POKEPLATINUM_STRUCT_OV13_02228A50_DECL_H diff --git a/include/party_menu_cursor.h b/include/party_menu_cursor.h deleted file mode 100644 index c961f44f9b..0000000000 --- a/include/party_menu_cursor.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef POKEPLATINUM_PARTY_MENU_CURSOR_H -#define POKEPLATINUM_PARTY_MENU_CURSOR_H - -typedef struct PartyMenuCursor { - u8 xCoord; - u8 yCoord; - u8 subXCoord; - u8 subYCoord; - u8 upIndex; - u8 downIndex; - u8 leftIndex; - u8 rightIndex; -} PartyMenuCursor; - -enum PartyMenuCursorDirection { - PARTY_MENU_CURSOR_DIRECTION_UP = 0, - PARTY_MENU_CURSOR_DIRECTION_DOWN, - PARTY_MENU_CURSOR_DIRECTION_LEFT, - PARTY_MENU_CURSOR_DIRECTION_RIGHT, - PARTY_MENU_CURSOR_DIRECTION_NONE, -}; - -void ReadPartyMenuCursorXYCoords(const PartyMenuCursor *byteFlagSet, u8 *xCoord, u8 *yCoord); -void ReadPartyMenuCursorSubXYCoords(const PartyMenuCursor *byteFlagSet, u8 *subXCoord, u8 *subYCoord); -u8 ReadPartyMenuCursorCoords(const PartyMenuCursor *byteFlagSet, u8 *xCoord, u8 *yCoord, u8 *subXCoord, u8 *subYCoord, u8 setIndex, u8 direction); - -#endif // POKEPLATINUM_PARTY_MENU_CURSOR_H diff --git a/include/struct_defs/struct_0207F248.h b/include/struct_defs/struct_0207F248.h index 31041adf7a..4f5fe48aef 100644 --- a/include/struct_defs/struct_0207F248.h +++ b/include/struct_defs/struct_0207F248.h @@ -13,9 +13,9 @@ #include "overlay118/struct_ov118_021D0FDC_decl.h" #include "bg_window.h" +#include "grid_menu_cursor_position.h" #include "menu.h" #include "message.h" -#include "party_menu_cursor.h" #include "sprite.h" #include "sprite_system.h" #include "strbuf.h" @@ -44,7 +44,7 @@ typedef struct { StringList *unk_6FC; Menu *unk_700; StrBufWrapper unk_704[6]; - const PartyMenuCursor *unk_7F4; + const GridMenuCursorPosition *unk_7F4; DualArrayShortData unk_7F8; GenericFunctionPtr unk_B00; FunctionPtrPair unk_B04; diff --git a/platinum.us/main.lsf b/platinum.us/main.lsf index 7677921840..c02f1f82a4 100644 --- a/platinum.us/main.lsf +++ b/platinum.us/main.lsf @@ -78,7 +78,7 @@ Static main Object main.nef.p/src_vram_transfer.c.o Object main.nef.p/src_cell_transfer.c.o Object main.nef.p/src_unk_0201DD00.c.o - Object main.nef.p/src_party_menu_cursor.c.o + Object main.nef.p/src_grid_menu_cursor_position.c.o Object main.nef.p/src_ascii_util.c.o Object main.nef.p/src_fx_util.c.o Object main.nef.p/src_int_distance.c.o @@ -669,7 +669,7 @@ Overlay overlay13 Object main.nef.p/src_overlay013_ov13_02227A4C.c.o Object main.nef.p/src_overlay013_ov13_02227BDC.c.o Object main.nef.p/src_overlay013_ov13_02228128.c.o - Object main.nef.p/src_overlay013_ov13_02228A38.c.o + Object main.nef.p/src_overlay013_battle_sub_menu_cursor.c.o } Overlay trainer_ai diff --git a/src/grid_menu_cursor_position.c b/src/grid_menu_cursor_position.c new file mode 100644 index 0000000000..2856d2760c --- /dev/null +++ b/src/grid_menu_cursor_position.c @@ -0,0 +1,51 @@ +#include "grid_menu_cursor_position.h" + +void GridMenuCursor_GetFirstCoords(const GridMenuCursorPosition *position, u8 *xCoord, u8 *yCoord) +{ + *xCoord = position->xCoord1; + *yCoord = position->yCoord1; +} + +void GridMenuCursor_GetSecondCoords(const GridMenuCursorPosition *position, u8 *xCoord, u8 *yCoord) +{ + *xCoord = position->xCoord2; + *yCoord = position->yCoord2; +} + +u8 GridMenuCursor_CheckNavigation(const GridMenuCursorPosition *positions, u8 *xCoord1, u8 *yCoord1, u8 *xCoord2, u8 *yCoord2, u8 currentPositionIndex, u8 directionToMove) +{ + u8 index = currentPositionIndex; + + switch (directionToMove) { + case GRID_MENU_CURSOR_POSITION_DIRECTION_UP: + index = positions[currentPositionIndex].upIndex; + break; + case GRID_MENU_CURSOR_POSITION_DIRECTION_DOWN: + index = positions[currentPositionIndex].downIndex; + break; + case GRID_MENU_CURSOR_POSITION_DIRECTION_LEFT: + index = positions[currentPositionIndex].leftIndex; + break; + case GRID_MENU_CURSOR_POSITION_DIRECTION_RIGHT: + index = positions[currentPositionIndex].rightIndex; + break; + } + + if (xCoord1 != NULL) { + *xCoord1 = positions[index].xCoord1; + } + + if (yCoord1 != NULL) { + *yCoord1 = positions[index].yCoord1; + } + + if (xCoord2 != NULL) { + *xCoord2 = positions[index].xCoord2; + } + + if (yCoord2 != NULL) { + *yCoord2 = positions[index].yCoord2; + } + + return index; +} diff --git a/src/meson.build b/src/meson.build index 366de1d0e4..53e15dc8a3 100644 --- a/src/meson.build +++ b/src/meson.build @@ -73,7 +73,7 @@ pokeplatinum_c = files( 'vram_transfer.c', 'cell_transfer.c', 'unk_0201DD00.c', - 'party_menu_cursor.c', + 'grid_menu_cursor_position.c', 'ascii_util.c', 'fx_util.c', 'int_distance.c', @@ -523,7 +523,7 @@ pokeplatinum_c = files( 'overlay013/ov13_02227A4C.c', 'overlay013/ov13_02227BDC.c', 'overlay013/ov13_02228128.c', - 'overlay013/ov13_02228A38.c', + 'overlay013/battle_sub_menu_cursor.c', 'battle/trainer_ai/trainer_ai.c', 'overlay015/ov15_dummy.c', 'battle/ov16_0223B140.c', diff --git a/src/overlay013/battle_sub_menu_cursor.c b/src/overlay013/battle_sub_menu_cursor.c new file mode 100644 index 0000000000..4ecd4dc3a0 --- /dev/null +++ b/src/overlay013/battle_sub_menu_cursor.c @@ -0,0 +1,207 @@ +#include "overlay013/battle_sub_menu_cursor.h" + +#include "battle/ov16_0226DB7C.h" + +#include "heap.h" +#include "sound_playback.h" +#include "system.h" + +#define CURSOR_STARTING_INDEX 0 +#define NULL_POSITION_INDEX 0xff +#define GO_TO_PREVIOUS_POSITION_INDEX_MASK 0x80 +#define ALL_POSITIONS_ENABLED_MASK 0xffffffff + +BattleSubMenuCursor *MakeBattleSubMenuCursor(u32 heapID) +{ + BattleSubMenuCursor *cursor = Heap_AllocFromHeap(heapID, sizeof(BattleSubMenuCursor)); + memset(cursor, 0, sizeof(BattleSubMenuCursor)); + return cursor; +} + +void DeleteBattleSubMenuCursor(BattleSubMenuCursor *cursor) +{ + Heap_FreeToHeap(cursor); +} + +UnkStruct_ov16_0226DC24 *GetBattleSubMenuCursorSprites(BattleSubMenuCursor *cursor) +{ + return cursor->sprites; +} + +u8 IsBattleSubMenuCursorVisible(BattleSubMenuCursor *cursor) +{ + return cursor->isVisible; +} + +void SetBattleSubMenuCursorVisibility(BattleSubMenuCursor *cursor, u8 isVisible) +{ + cursor->isVisible = isVisible; +} + +void SetBattleSubMenuCursorSprites(BattleSubMenuCursor *cursor, UnkStruct_ov16_0226DC24 *sprites) +{ + cursor->sprites = sprites; +} + +void SetBattleSubMenuCursorCurrentPosition(BattleSubMenuCursor *cursor, u8 positionIndex) +{ + cursor->currentPositionIndex = positionIndex; + + if (cursor->isVisible == TRUE) { + ov16_0226DD7C(cursor->sprites, cursor->positions[cursor->currentPositionIndex].xCoord1, cursor->positions[cursor->currentPositionIndex].xCoord2, cursor->positions[cursor->currentPositionIndex].yCoord1, cursor->positions[cursor->currentPositionIndex].yCoord2); + } +} + +void ResetBattleSubMenuCursorCurrentPosition(BattleSubMenuCursor *cursor) +{ + cursor->currentPositionIndex = CURSOR_STARTING_INDEX; + cursor->previousPositionIndex = NULL_POSITION_INDEX; +} + +void SetBattleSubMenuCursorPositions(BattleSubMenuCursor *cursor, const GridMenuCursorPosition *positions) +{ + ResetBattleSubMenuCursorCurrentPosition(cursor); + + cursor->positions = positions; + cursor->enabledPositionsMask = ALL_POSITIONS_ENABLED_MASK; + + if (cursor->isVisible == TRUE) { + ov16_0226DD7C(cursor->sprites, cursor->positions[CURSOR_STARTING_INDEX].xCoord1, cursor->positions[CURSOR_STARTING_INDEX].xCoord2, cursor->positions[CURSOR_STARTING_INDEX].yCoord1, cursor->positions[CURSOR_STARTING_INDEX].yCoord2); + } +} + +void SetBattleSubMenuCursorEnabledPositionsMask(BattleSubMenuCursor *cursor, u32 mask) +{ + cursor->enabledPositionsMask = mask; +} + +static u8 IsCursorVisible(BattleSubMenuCursor *cursor) +{ + if (cursor->isVisible == TRUE) { + return TRUE; + } + + if (JOY_NEW(PAD_KEY | PAD_BUTTON_B | PAD_BUTTON_A)) { + cursor->isVisible = TRUE; + + ov16_0226DD7C(cursor->sprites, cursor->positions[cursor->currentPositionIndex].xCoord1, cursor->positions[cursor->currentPositionIndex].xCoord2, cursor->positions[cursor->currentPositionIndex].yCoord1, cursor->positions[cursor->currentPositionIndex].yCoord2); + Sound_PlayEffect(SEQ_SE_CONFIRM); + } + + return FALSE; +} + +static BOOL CheckShouldStorePreviousPosition(const GridMenuCursorPosition *newPosition, u8 incomingDirection) +{ + switch (incomingDirection) { + case GRID_MENU_CURSOR_POSITION_DIRECTION_UP: + if (newPosition->downIndex & GO_TO_PREVIOUS_POSITION_INDEX_MASK) { + return TRUE; + } + break; + case GRID_MENU_CURSOR_POSITION_DIRECTION_DOWN: + if (newPosition->upIndex & GO_TO_PREVIOUS_POSITION_INDEX_MASK) { + return TRUE; + } + break; + case GRID_MENU_CURSOR_POSITION_DIRECTION_LEFT: + if (newPosition->rightIndex & GO_TO_PREVIOUS_POSITION_INDEX_MASK) { + return TRUE; + } + break; + case GRID_MENU_CURSOR_POSITION_DIRECTION_RIGHT: + if (newPosition->leftIndex & GO_TO_PREVIOUS_POSITION_INDEX_MASK) { + return TRUE; + } + break; + } + + return FALSE; +} + +u32 BattleSubMenuCursorTick(BattleSubMenuCursor *cursor) +{ + u8 nextPositionIndex; + u8 pressedDirection; + + if (IsCursorVisible(cursor) == FALSE) { + return BATTLE_SUB_MENU_CURSOR_NO_MOVEMENT_INDEX; + } + + if (JOY_NEW(PAD_KEY_UP)) { + nextPositionIndex = GridMenuCursor_CheckNavigation(cursor->positions, NULL, NULL, NULL, NULL, cursor->currentPositionIndex, GRID_MENU_CURSOR_POSITION_DIRECTION_UP); + pressedDirection = GRID_MENU_CURSOR_POSITION_DIRECTION_UP; + } else if (JOY_NEW(PAD_KEY_DOWN)) { + nextPositionIndex = GridMenuCursor_CheckNavigation(cursor->positions, NULL, NULL, NULL, NULL, cursor->currentPositionIndex, GRID_MENU_CURSOR_POSITION_DIRECTION_DOWN); + pressedDirection = GRID_MENU_CURSOR_POSITION_DIRECTION_DOWN; + } else if (JOY_NEW(PAD_KEY_LEFT)) { + nextPositionIndex = GridMenuCursor_CheckNavigation(cursor->positions, NULL, NULL, NULL, NULL, cursor->currentPositionIndex, GRID_MENU_CURSOR_POSITION_DIRECTION_LEFT); + pressedDirection = GRID_MENU_CURSOR_POSITION_DIRECTION_LEFT; + } else if (JOY_NEW(PAD_KEY_RIGHT)) { + nextPositionIndex = GridMenuCursor_CheckNavigation(cursor->positions, NULL, NULL, NULL, NULL, cursor->currentPositionIndex, GRID_MENU_CURSOR_POSITION_DIRECTION_RIGHT); + pressedDirection = GRID_MENU_CURSOR_POSITION_DIRECTION_RIGHT; + } else { + nextPositionIndex = BATTLE_SUB_MENU_CURSOR_NO_MOVEMENT_INDEX; + } + + if (nextPositionIndex != NULL_POSITION_INDEX) { + u8 nextPositionIsEnabled = TRUE; + + if (nextPositionIndex & GO_TO_PREVIOUS_POSITION_INDEX_MASK) { + if (cursor->previousPositionIndex != NULL_POSITION_INDEX) { + nextPositionIndex = cursor->previousPositionIndex; + } else { + nextPositionIndex ^= GO_TO_PREVIOUS_POSITION_INDEX_MASK; + } + } + + while (TRUE) { + u8 replacementPositionIndex; + + if (cursor->enabledPositionsMask & (1 << nextPositionIndex)) { + break; + } + + nextPositionIsEnabled = FALSE; + replacementPositionIndex = GridMenuCursor_CheckNavigation(cursor->positions, NULL, NULL, NULL, NULL, nextPositionIndex, pressedDirection) & (NULL_POSITION_INDEX ^ GO_TO_PREVIOUS_POSITION_INDEX_MASK); + + if ((replacementPositionIndex == nextPositionIndex) || (replacementPositionIndex == cursor->currentPositionIndex)) { + nextPositionIndex = cursor->currentPositionIndex; + break; + } + + nextPositionIndex = replacementPositionIndex; + } + + if (cursor->currentPositionIndex != nextPositionIndex) { + u8 x1, y1, x2, y2; + + GridMenuCursor_GetFirstCoords(&cursor->positions[nextPositionIndex], &x1, &y1); + GridMenuCursor_GetSecondCoords(&cursor->positions[nextPositionIndex], &x2, &y2); + + if ((CheckShouldStorePreviousPosition(&cursor->positions[nextPositionIndex], pressedDirection) == TRUE) && (nextPositionIsEnabled != FALSE)) { + cursor->previousPositionIndex = cursor->currentPositionIndex; + } else { + cursor->previousPositionIndex = NULL_POSITION_INDEX; + } + + cursor->currentPositionIndex = nextPositionIndex; + + ov16_0226DD7C(cursor->sprites, x1, x2, y1, y2); + Sound_PlayEffect(SEQ_SE_CONFIRM); + } + + return BATTLE_SUB_MENU_CURSOR_NO_MOVEMENT_INDEX; + } + + if (JOY_NEW(PAD_BUTTON_A)) { + return cursor->currentPositionIndex; + } + + if (JOY_NEW(PAD_BUTTON_B)) { + Sound_PlayEffect(SEQ_SE_DP_DECIDE); + return BATTLE_SUB_MENU_CURSOR_BACK_INDEX; + } + + return BATTLE_SUB_MENU_CURSOR_NO_MOVEMENT_INDEX; +} diff --git a/src/overlay013/ov13_0221FC20.c b/src/overlay013/ov13_0221FC20.c index e6159cecac..71428211d0 100644 --- a/src/overlay013/ov13_0221FC20.c +++ b/src/overlay013/ov13_0221FC20.c @@ -7,10 +7,10 @@ #include "applications/pokemon_summary_screen/main.h" #include "battle/ov16_0223DF00.h" +#include "overlay013/battle_sub_menu_cursor.h" #include "overlay013/ov13_02221A88.h" #include "overlay013/ov13_02224500.h" #include "overlay013/ov13_02225710.h" -#include "overlay013/ov13_02228A38.h" #include "overlay013/struct_ov13_0221FC20.h" #include "overlay013/struct_ov13_022213F0.h" #include "overlay013/struct_ov13_02221ED0.h" @@ -301,7 +301,7 @@ static u8 ov13_0221FE5C(UnkStruct_ov13_022213F0 *param0) v0 = 1; } - param0->unk_2084 = ov13_02228A38(param0->unk_00->heapID); + param0->unk_2084 = MakeBattleSubMenuCursor(param0->unk_00->heapID); ov13_02220F98(param0); ov13_02220C0C(param0); @@ -319,7 +319,7 @@ static u8 ov13_0221FE5C(UnkStruct_ov13_022213F0 *param0) ov13_02221BF8(param0, param0->unk_2076); if (param0->unk_00->unk_32 != 0) { - ov13_02228A60(param0->unk_2084, 1); + SetBattleSubMenuCursorVisibility(param0->unk_2084, 1); } if ((param0->unk_2076 == 0) && (ov13_022219AC(param0, 0) == 1)) { @@ -591,9 +591,9 @@ static u8 ov13_02220418(UnkStruct_ov13_022213F0 *param0) int v0 = ov13_022213E4(param0, Unk_ov13_02228E0C); if (v0 == 0xffffffff) { - v0 = ov13_02228B64(param0->unk_2084); + v0 = BattleSubMenuCursorTick(param0->unk_2084); - if (v0 == 0xfffffffe) { + if (v0 == BATTLE_SUB_MENU_CURSOR_BACK_INDEX) { v0 = 6; } } else { @@ -639,9 +639,9 @@ static u8 ov13_0222050C(UnkStruct_ov13_022213F0 *param0) int v0 = ov13_022213E4(param0, Unk_ov13_02228D14); if (v0 == 0xffffffff) { - v0 = ov13_02228B64(param0->unk_2084); + v0 = BattleSubMenuCursorTick(param0->unk_2084); - if (v0 == 0xfffffffe) { + if (v0 == BATTLE_SUB_MENU_CURSOR_BACK_INDEX) { v0 = 2; } } else { @@ -704,9 +704,9 @@ static u8 ov13_02220628(UnkStruct_ov13_022213F0 *param0) v1 = ov13_022213E4(param0, Unk_ov13_02228D64); if (v1 == 0xffffffff) { - v1 = ov13_02228B64(param0->unk_2084); + v1 = BattleSubMenuCursorTick(param0->unk_2084); - if (v1 == 0xfffffffe) { + if (v1 == BATTLE_SUB_MENU_CURSOR_BACK_INDEX) { v1 = 4; } } else { @@ -999,9 +999,9 @@ static u8 ov13_02220BA4(SysTask *param0, UnkStruct_ov13_022213F0 *param1) ov13_02221BC8(param1); ov13_02220D1C(param1->unk_1E0); - param1->unk_00->unk_32 = ov13_02228A5C(param1->unk_2084); + param1->unk_00->unk_32 = IsBattleSubMenuCursorVisible(param1->unk_2084); - ov13_02228A50(param1->unk_2084); + DeleteBattleSubMenuCursor(param1->unk_2084); Font_Free(FONT_SUBSCREEN); param1->unk_00->unk_36 = 1; @@ -1264,11 +1264,11 @@ static u8 ov13_0222124C(UnkStruct_ov13_022213F0 *param0) int v0 = ov13_022213E4(param0, Unk_ov13_02228DEC); if (v0 == 0xffffffff) { - v0 = ov13_02228B64(param0->unk_2084); + v0 = BattleSubMenuCursorTick(param0->unk_2084); - if (v0 == 0xfffffffe) { + if (v0 == BATTLE_SUB_MENU_CURSOR_BACK_INDEX) { v0 = 6; - } else if (v0 == 0xffffffff) { + } else if (v0 == BATTLE_SUB_MENU_CURSOR_NO_MOVEMENT_INDEX) { return 0; } @@ -1293,11 +1293,11 @@ static u8 ov13_022212C4(UnkStruct_ov13_022213F0 *param0) int v0 = ov13_022213E4(param0, Unk_ov13_02228D24); if (v0 == 0xffffffff) { - v0 = ov13_02228B64(param0->unk_2084); + v0 = BattleSubMenuCursorTick(param0->unk_2084); - if (v0 == 0xfffffffe) { + if (v0 == BATTLE_SUB_MENU_CURSOR_BACK_INDEX) { v0 = 3; - } else if (v0 == 0xffffffff) { + } else if (v0 == BATTLE_SUB_MENU_CURSOR_NO_MOVEMENT_INDEX) { return 0xff; } } else { @@ -1312,11 +1312,11 @@ static u8 ov13_0222130C(UnkStruct_ov13_022213F0 *param0) int v0 = ov13_022213E4(param0, Unk_ov13_02228D38); if (v0 == 0xffffffff) { - v0 = ov13_02228B64(param0->unk_2084); + v0 = BattleSubMenuCursorTick(param0->unk_2084); - if (v0 == 0xfffffffe) { + if (v0 == BATTLE_SUB_MENU_CURSOR_BACK_INDEX) { v0 = 3; - } else if (v0 == 0xffffffff) { + } else if (v0 == BATTLE_SUB_MENU_CURSOR_NO_MOVEMENT_INDEX) { return 0xff; } } else { @@ -1331,11 +1331,11 @@ static u8 ov13_02221354(UnkStruct_ov13_022213F0 *param0) int v0 = ov13_022213E4(param0, Unk_ov13_02228E2C); if (v0 == 0xffffffff) { - v0 = ov13_02228B64(param0->unk_2084); + v0 = BattleSubMenuCursorTick(param0->unk_2084); - if (v0 == 0xfffffffe) { + if (v0 == BATTLE_SUB_MENU_CURSOR_BACK_INDEX) { v0 = 7; - } else if (v0 == 0xffffffff) { + } else if (v0 == BATTLE_SUB_MENU_CURSOR_NO_MOVEMENT_INDEX) { return 0xff; } } else { @@ -1350,11 +1350,11 @@ static u8 ov13_0222139C(UnkStruct_ov13_022213F0 *param0) int v0 = ov13_022213E4(param0, Unk_ov13_02228D4C); if (v0 == 0xffffffff) { - v0 = ov13_02228B64(param0->unk_2084); + v0 = BattleSubMenuCursorTick(param0->unk_2084); - if (v0 == 0xfffffffe) { + if (v0 == BATTLE_SUB_MENU_CURSOR_BACK_INDEX) { v0 = 4; - } else if (v0 == 0xffffffff) { + } else if (v0 == BATTLE_SUB_MENU_CURSOR_NO_MOVEMENT_INDEX) { return 0xff; } } else { diff --git a/src/overlay013/ov13_02224500.c b/src/overlay013/ov13_02224500.c index e3643451fa..a36d6cf947 100644 --- a/src/overlay013/ov13_02224500.c +++ b/src/overlay013/ov13_02224500.c @@ -7,17 +7,17 @@ #include "battle/ov16_0223DF00.h" #include "battle/ov16_0226DB7C.h" #include "battle/struct_ov16_0226DC24_decl.h" -#include "overlay013/ov13_02228A38.h" +#include "overlay013/battle_sub_menu_cursor.h" #include "overlay013/struct_ov13_022213F0.h" #include "overlay013/struct_ov13_02221ED0.h" +#include "grid_menu_cursor_position.h" #include "gx_layers.h" #include "item.h" #include "move_table.h" #include "narc.h" #include "palette.h" #include "party.h" -#include "party_menu_cursor.h" #include "pokemon_icon.h" #include "sprite_system.h" #include "unk_0207C908.h" @@ -789,16 +789,16 @@ static void ov13_0222554C(UnkStruct_ov13_022213F0 *param0) ov16_0226DB7C(v0, param0->unk_1FB0, param0->unk_1E4, param0->unk_00->heapID, 45080, 45068, 45068, 45068); v1 = ov16_0226DC24(v0, param0->unk_1FB0, param0->unk_00->heapID, 45080, 45068, 45068, 45068, 0, 1); - ov13_02228A64(param0->unk_2084, v1); + SetBattleSubMenuCursorSprites(param0->unk_2084, v1); } static void ov13_022255B8(UnkStruct_ov13_022213F0 *param0) { - ov16_0226DCA8(ov13_02228A58(param0->unk_2084)); + ov16_0226DCA8(GetBattleSubMenuCursorSprites(param0->unk_2084)); ov16_0226DBFC(param0->unk_1FB0, 45080, 45068, 45068, 45068); } -static const PartyMenuCursor Unk_ov13_02229464[] = { +static const GridMenuCursorPosition Unk_ov13_02229464[] = { { 0x8, 0x8, 0x78, 0x28, 0x6, 0x2, 0x6, 0x1 }, { 0x88, 0x10, 0xF8, 0x30, 0x4, 0x3, 0x0, 0x2 }, { 0x8, 0x38, 0x78, 0x58, 0x0, 0x4, 0x1, 0x3 }, @@ -808,21 +808,21 @@ static const PartyMenuCursor Unk_ov13_02229464[] = { { 0xE0, 0xA0, 0xF8, 0xB8, 0x5, 0x0, 0x5, 0x0 } }; -static const PartyMenuCursor Unk_ov13_02229344[] = { +static const GridMenuCursorPosition Unk_ov13_02229344[] = { { 0x10, 0x10, 0xF0, 0x88, 0x0, 0x81, 0x0, 0x0 }, { 0x8, 0xA0, 0x60, 0xB8, 0x0, 0x1, 0x1, 0x2 }, { 0x70, 0xA0, 0xC8, 0xB8, 0x0, 0x2, 0x1, 0x3 }, { 0xE0, 0xA0, 0xF8, 0xB8, 0x0, 0x3, 0x2, 0x3 } }; -static const PartyMenuCursor Unk_ov13_02229304[] = { +static const GridMenuCursorPosition Unk_ov13_02229304[] = { { 0x8, 0xA0, 0x20, 0xB8, 0x0, 0x0, 0x0, 0x1 }, { 0x30, 0xA0, 0x48, 0xB8, 0x1, 0x1, 0x0, 0x2 }, { 0x68, 0xA0, 0xC0, 0xB8, 0x2, 0x2, 0x1, 0x3 }, { 0xE0, 0xA0, 0xF8, 0xB8, 0x3, 0x3, 0x2, 0x3 } }; -static const PartyMenuCursor Unk_ov13_022294D4[] = { +static const GridMenuCursorPosition Unk_ov13_022294D4[] = { { 0x8, 0x38, 0x78, 0x58, 0x0, 0x2, 0x0, 0x1 }, { 0x88, 0x38, 0xF8, 0x58, 0x1, 0x3, 0x0, 0x1 }, { 0x8, 0x68, 0x78, 0x88, 0x0, 0x84, 0x2, 0x3 }, @@ -833,7 +833,7 @@ static const PartyMenuCursor Unk_ov13_022294D4[] = { { 0xE0, 0xA0, 0xF8, 0xB8, 0x3, 0x7, 0x6, 0x7 } }; -static const PartyMenuCursor Unk_ov13_02229364[] = { +static const GridMenuCursorPosition Unk_ov13_02229364[] = { { 0x5C, 0x9D, 0x7C, 0xA5, 0x0, 0x2, 0x0, 0x1 }, { 0x84, 0x9D, 0xA4, 0xA5, 0x1, 0x3, 0x0, 0x4 }, { 0x5C, 0xAD, 0x7C, 0xB5, 0x0, 0x2, 0x2, 0x3 }, @@ -841,7 +841,7 @@ static const PartyMenuCursor Unk_ov13_02229364[] = { { 0xE0, 0xA0, 0xF8, 0xB8, 0x4, 0x4, 0x83, 0x4 } }; -static const PartyMenuCursor Unk_ov13_0222949C[] = { +static const GridMenuCursorPosition Unk_ov13_0222949C[] = { { 0x8, 0x38, 0x78, 0x58, 0x5, 0x2, 0x0, 0x1 }, { 0x88, 0x38, 0xF8, 0x58, 0x5, 0x3, 0x0, 0x1 }, { 0x8, 0x68, 0x78, 0x88, 0x0, 0x4, 0x2, 0x3 }, @@ -851,13 +851,13 @@ static const PartyMenuCursor Unk_ov13_0222949C[] = { { 0xE0, 0xA0, 0xF8, 0xB8, 0x3, 0x6, 0x4, 0x6 } }; -static const PartyMenuCursor Unk_ov13_022292D4[] = { +static const GridMenuCursorPosition Unk_ov13_022292D4[] = { { 0x8, 0xA0, 0xC8, 0xB8, 0x1, 0x0, 0x0, 0x2 }, { 0xC0, 0x8, 0xF8, 0x18, 0x1, 0x82, 0x0, 0x1 }, { 0xE0, 0xA0, 0xF8, 0xB8, 0x1, 0x2, 0x0, 0x2 } }; -static const PartyMenuCursor Unk_ov13_022293B4[] = { +static const GridMenuCursorPosition Unk_ov13_022293B4[] = { { 0x8, 0x38, 0x78, 0x58, 0x0, 0x2, 0x0, 0x1 }, { 0x88, 0x38, 0xF8, 0x58, 0x1, 0x3, 0x0, 0x1 }, { 0x8, 0x68, 0x78, 0x88, 0x0, 0x4, 0x2, 0x3 }, @@ -865,7 +865,7 @@ static const PartyMenuCursor Unk_ov13_022293B4[] = { { 0xE0, 0xA0, 0xF8, 0xB8, 0x83, 0x4, 0x4, 0x4 } }; -static const PartyMenuCursor *const Unk_ov13_0222938C[] = { +static const GridMenuCursorPosition *const Unk_ov13_0222938C[] = { Unk_ov13_02229464, Unk_ov13_02229344, Unk_ov13_02229304, @@ -881,55 +881,55 @@ static const PartyMenuCursor *const Unk_ov13_0222938C[] = { static void ov13_022255EC(UnkStruct_ov13_022213F0 *param0) { if (param0->unk_2073_4 == 0) { - ov13_02228AC8(param0->unk_2084, 0x5f); + SetBattleSubMenuCursorEnabledPositionsMask(param0->unk_2084, 0x5f); } else { - ov13_02228AC8(param0->unk_2084, 0x7f); + SetBattleSubMenuCursorEnabledPositionsMask(param0->unk_2084, 0x7f); } } static void ov13_02225614(UnkStruct_ov13_022213F0 *param0) { if (param0->unk_2073_4 == 0) { - ov13_02228AC8(param0->unk_2084, 5); + SetBattleSubMenuCursorEnabledPositionsMask(param0->unk_2084, 5); } else { - ov13_02228AC8(param0->unk_2084, 7); + SetBattleSubMenuCursorEnabledPositionsMask(param0->unk_2084, 7); } } void ov13_0222563C(UnkStruct_ov13_022213F0 *param0, u8 param1) { - ov13_02228A9C(param0->unk_2084, Unk_ov13_0222938C[param1]); + SetBattleSubMenuCursorPositions(param0->unk_2084, Unk_ov13_0222938C[param1]); switch (param1) { case 0: - ov13_02228A68(param0->unk_2084, param0->unk_00->unk_11); + SetBattleSubMenuCursorCurrentPosition(param0->unk_2084, param0->unk_00->unk_11); param0->unk_2088 = 0; param0->unk_00->unk_34 = 0; break; case 1: - ov13_02228A68(param0->unk_2084, param0->unk_2088); + SetBattleSubMenuCursorCurrentPosition(param0->unk_2084, param0->unk_2088); param0->unk_00->unk_34 = 0; break; case 3: case 4: - ov13_02228A68(param0->unk_2084, param0->unk_00->unk_34); + SetBattleSubMenuCursorCurrentPosition(param0->unk_2084, param0->unk_00->unk_34); break; case 6: case 8: ov13_022255EC(param0); - ov13_02228A68(param0->unk_2084, param0->unk_2089); + SetBattleSubMenuCursorCurrentPosition(param0->unk_2084, param0->unk_2089); break; case 7: case 9: ov13_02225614(param0); - ov13_02228A68(param0->unk_2084, param0->unk_208A); + SetBattleSubMenuCursorCurrentPosition(param0->unk_2084, param0->unk_208A); break; } } void ov13_022256E8(UnkStruct_ov13_022213F0 *param0) { - ov13_02228A60(param0->unk_2084, 0); - ov13_02228A90(param0->unk_2084); - ov16_0226DDE8(ov13_02228A58(param0->unk_2084)); + SetBattleSubMenuCursorVisibility(param0->unk_2084, 0); + ResetBattleSubMenuCursorCurrentPosition(param0->unk_2084); + ov16_0226DDE8(GetBattleSubMenuCursorSprites(param0->unk_2084)); } diff --git a/src/overlay013/ov13_022264F4.c b/src/overlay013/ov13_022264F4.c index 9d6df67507..504798bcfe 100644 --- a/src/overlay013/ov13_022264F4.c +++ b/src/overlay013/ov13_022264F4.c @@ -9,11 +9,11 @@ #include "battle/battle_lib.h" #include "battle/ov16_0223DF00.h" #include "battle/ov16_0226DE44.h" +#include "overlay013/battle_sub_menu_cursor.h" #include "overlay013/ov13_02227288.h" #include "overlay013/ov13_02227A4C.h" #include "overlay013/ov13_02227BDC.h" #include "overlay013/ov13_02228128.h" -#include "overlay013/ov13_02228A38.h" #include "overlay013/struct_ov13_022264F4.h" #include "overlay013/struct_ov13_02227244.h" @@ -190,7 +190,7 @@ static u8 ov13_0222668C(UnkStruct_ov13_02227244 *param0) { G2S_BlendNone(); - param0->unk_34 = ov13_02228A38(param0->unk_00->heapID); + param0->unk_34 = MakeBattleSubMenuCursor(param0->unk_00->heapID); ov13_02226ED0(param0); ov13_02226FC4(param0); @@ -207,7 +207,7 @@ static u8 ov13_0222668C(UnkStruct_ov13_02227244 *param0) ov13_02227E68(param0, param0->unk_114C); if (param0->unk_00->unk_25 != 0) { - ov13_02228A60(param0->unk_34, 1); + SetBattleSubMenuCursorVisibility(param0->unk_34, 1); } ov13_02228008(param0, param0->unk_114C); @@ -231,9 +231,9 @@ static u8 ov13_02226760(UnkStruct_ov13_02227244 *param0) int v0 = ov13_02227238(param0, Unk_ov13_02229A1C); if (v0 == 0xffffffff) { - v0 = ov13_02228B64(param0->unk_34); + v0 = BattleSubMenuCursorTick(param0->unk_34); - if (v0 == 0xfffffffe) { + if (v0 == BATTLE_SUB_MENU_CURSOR_BACK_INDEX) { v0 = 5; } } else { @@ -278,9 +278,9 @@ static u8 ov13_02226838(UnkStruct_ov13_02227244 *param0) int v0 = ov13_02227238(param0, Unk_ov13_02229A38); if (v0 == 0xffffffff) { - v0 = ov13_02228B64(param0->unk_34); + v0 = BattleSubMenuCursorTick(param0->unk_34); - if (v0 == 0xfffffffe) { + if (v0 == BATTLE_SUB_MENU_CURSOR_BACK_INDEX) { v0 = 8; } } else { @@ -360,9 +360,9 @@ static u8 ov13_022269C0(UnkStruct_ov13_02227244 *param0) int v0 = ov13_02227238(param0, Unk_ov13_022299AC); if (v0 == 0xffffffff) { - v0 = ov13_02228B64(param0->unk_34); + v0 = BattleSubMenuCursorTick(param0->unk_34); - if (v0 == 0xfffffffe) { + if (v0 == BATTLE_SUB_MENU_CURSOR_BACK_INDEX) { v0 = 1; } } else { @@ -546,9 +546,9 @@ static u8 ov13_02226CFC(SysTask *param0, UnkStruct_ov13_02227244 *param1) ov13_022270F8(param1); ov13_02226F9C(param1->unk_04); - param1->unk_00->unk_25 = ov13_02228A5C(param1->unk_34); + param1->unk_00->unk_25 = IsBattleSubMenuCursorVisible(param1->unk_34); - ov13_02228A50(param1->unk_34); + DeleteBattleSubMenuCursor(param1->unk_34); Font_Free(FONT_SUBSCREEN); if (param1->unk_00->unk_1C != 0) { diff --git a/src/overlay013/ov13_02227BDC.c b/src/overlay013/ov13_02227BDC.c index 36c551e2a3..c214ae5ee4 100644 --- a/src/overlay013/ov13_02227BDC.c +++ b/src/overlay013/ov13_02227BDC.c @@ -8,15 +8,15 @@ #include "battle/ov16_0226DE44.h" #include "battle/struct_ov16_0226DC24_decl.h" #include "battle/struct_ov16_0226DEEC_decl.h" +#include "overlay013/battle_sub_menu_cursor.h" #include "overlay013/ov13_02227A4C.h" -#include "overlay013/ov13_02228A38.h" #include "overlay013/struct_ov13_02227244.h" +#include "grid_menu_cursor_position.h" #include "gx_layers.h" #include "item.h" #include "narc.h" #include "palette.h" -#include "party_menu_cursor.h" #include "sprite_system.h" static void ov13_02227C08(UnkStruct_ov13_02227244 *param0); @@ -231,16 +231,16 @@ static void ov13_02227F7C(UnkStruct_ov13_02227244 *param0) ov16_0226DB7C(v0, param0->unk_30C, param0->unk_08, param0->unk_00->heapID, 46270, 46270, 46265, 46265); v1 = ov16_0226DC24(v0, param0->unk_30C, param0->unk_00->heapID, 46270, 46270, 46265, 46265, 0, 1); - ov13_02228A64(param0->unk_34, v1); + SetBattleSubMenuCursorSprites(param0->unk_34, v1); } static void ov13_02227FDC(UnkStruct_ov13_02227244 *param0) { - ov16_0226DCA8(ov13_02228A58(param0->unk_34)); + ov16_0226DCA8(GetBattleSubMenuCursorSprites(param0->unk_34)); ov16_0226DBFC(param0->unk_30C, 46270, 46270, 46265, 46265); } -static const PartyMenuCursor Unk_ov13_02229C14[] = { +static const GridMenuCursorPosition Unk_ov13_02229C14[] = { { 0x8, 0x10, 0x78, 0x48, 0x0, 0x1, 0x0, 0x2 }, { 0x8, 0x58, 0x78, 0x90, 0x0, 0x4, 0x1, 0x3 }, { 0x88, 0x10, 0xF8, 0x48, 0x2, 0x3, 0x0, 0x2 }, @@ -249,7 +249,7 @@ static const PartyMenuCursor Unk_ov13_02229C14[] = { { 0xE0, 0xA0, 0xF8, 0xB8, 0x83, 0x5, 0x4, 0x5 } }; -static const PartyMenuCursor Unk_ov13_02229C74[] = { +static const GridMenuCursorPosition Unk_ov13_02229C74[] = { { 0x8, 0x10, 0x78, 0x30, 0x0, 0x2, 0x0, 0x1 }, { 0x88, 0x10, 0xF8, 0x30, 0x1, 0x3, 0x0, 0x1 }, { 0x8, 0x40, 0x78, 0x60, 0x0, 0x4, 0x2, 0x3 }, @@ -261,12 +261,12 @@ static const PartyMenuCursor Unk_ov13_02229C74[] = { { 0xE0, 0xA0, 0xF8, 0xB8, 0x5, 0x8, 0x7, 0x8 } }; -static const PartyMenuCursor Unk_ov13_02229BD4[] = { +static const GridMenuCursorPosition Unk_ov13_02229BD4[] = { { 0x8, 0xA0, 0xC8, 0xB8, 0x0, 0x0, 0x0, 0x1 }, { 0xE0, 0xA0, 0xF8, 0xB8, 0x1, 0x1, 0x0, 0x1 } }; -static const PartyMenuCursor *const Unk_ov13_02229BC8[] = { +static const GridMenuCursorPosition *const Unk_ov13_02229BC8[] = { Unk_ov13_02229C14, Unk_ov13_02229C74, Unk_ov13_02229BD4 @@ -274,14 +274,14 @@ static const PartyMenuCursor *const Unk_ov13_02229BC8[] = { void ov13_02228008(UnkStruct_ov13_02227244 *param0, u8 param1) { - ov13_02228A9C(param0->unk_34, Unk_ov13_02229BC8[param1]); + SetBattleSubMenuCursorPositions(param0->unk_34, Unk_ov13_02229BC8[param1]); switch (param1) { case 0: - ov13_02228A68(param0->unk_34, param0->unk_114D); + SetBattleSubMenuCursorCurrentPosition(param0->unk_34, param0->unk_114D); break; case 1: - ov13_02228A68(param0->unk_34, param0->unk_00->unk_27[param0->unk_114D]); + SetBattleSubMenuCursorCurrentPosition(param0->unk_34, param0->unk_00->unk_27[param0->unk_114D]); break; case 2: break; @@ -290,9 +290,9 @@ void ov13_02228008(UnkStruct_ov13_02227244 *param0, u8 param1) void ov13_02228050(UnkStruct_ov13_02227244 *param0) { - ov13_02228A60(param0->unk_34, 0); - ov13_02228A90(param0->unk_34); - ov16_0226DDE8(ov13_02228A58(param0->unk_34)); + SetBattleSubMenuCursorVisibility(param0->unk_34, 0); + ResetBattleSubMenuCursorCurrentPosition(param0->unk_34); + ov16_0226DDE8(GetBattleSubMenuCursorSprites(param0->unk_34)); } static void ov13_02228070(UnkStruct_ov13_02227244 *param0) diff --git a/src/overlay013/ov13_02228A38.c b/src/overlay013/ov13_02228A38.c deleted file mode 100644 index 65ccec0a47..0000000000 --- a/src/overlay013/ov13_02228A38.c +++ /dev/null @@ -1,216 +0,0 @@ -#include "overlay013/ov13_02228A38.h" - -#include -#include - -#include "battle/ov16_0226DB7C.h" -#include "battle/struct_ov16_0226DC24_decl.h" -#include "overlay013/struct_ov13_02228A50_decl.h" - -#include "heap.h" -#include "party_menu_cursor.h" -#include "sound_playback.h" -#include "system.h" - -struct UnkStruct_ov13_02228A50_t { - UnkStruct_ov16_0226DC24 *unk_00; - const PartyMenuCursor *unk_04; - u8 unk_08; - u8 unk_09; - u8 unk_0A; - u32 unk_0C; -}; - -UnkStruct_ov13_02228A50 *ov13_02228A38(u32 heapID) -{ - UnkStruct_ov13_02228A50 *v0 = Heap_AllocFromHeap(heapID, sizeof(UnkStruct_ov13_02228A50)); - memset(v0, 0, sizeof(UnkStruct_ov13_02228A50)); - return v0; -} - -void ov13_02228A50(UnkStruct_ov13_02228A50 *param0) -{ - Heap_FreeToHeap(param0); -} - -UnkStruct_ov16_0226DC24 *ov13_02228A58(UnkStruct_ov13_02228A50 *param0) -{ - return param0->unk_00; -} - -u8 ov13_02228A5C(UnkStruct_ov13_02228A50 *param0) -{ - return param0->unk_08; -} - -void ov13_02228A60(UnkStruct_ov13_02228A50 *param0, u8 param1) -{ - param0->unk_08 = param1; -} - -void ov13_02228A64(UnkStruct_ov13_02228A50 *param0, UnkStruct_ov16_0226DC24 *param1) -{ - param0->unk_00 = param1; -} - -void ov13_02228A68(UnkStruct_ov13_02228A50 *param0, u8 param1) -{ - param0->unk_09 = param1; - - if (param0->unk_08 == 1) { - ov16_0226DD7C(param0->unk_00, param0->unk_04[param0->unk_09].xCoord, param0->unk_04[param0->unk_09].subXCoord, param0->unk_04[param0->unk_09].yCoord, param0->unk_04[param0->unk_09].subYCoord); - } -} - -void ov13_02228A90(UnkStruct_ov13_02228A50 *param0) -{ - param0->unk_09 = 0; - param0->unk_0A = 0xff; -} - -void ov13_02228A9C(UnkStruct_ov13_02228A50 *param0, const PartyMenuCursor *param1) -{ - ov13_02228A90(param0); - - param0->unk_04 = param1; - param0->unk_0C = 0xffffffff; - - if (param0->unk_08 == 1) { - ov16_0226DD7C(param0->unk_00, param0->unk_04[0].xCoord, param0->unk_04[0].subXCoord, param0->unk_04[0].yCoord, param0->unk_04[0].subYCoord); - } -} - -void ov13_02228AC8(UnkStruct_ov13_02228A50 *param0, u32 param1) -{ - param0->unk_0C = param1; -} - -static u8 ov13_02228ACC(UnkStruct_ov13_02228A50 *param0) -{ - if (param0->unk_08 == 1) { - return 1; - } - - if (gSystem.pressedKeys & (PAD_KEY | PAD_BUTTON_B | PAD_BUTTON_A)) { - param0->unk_08 = 1; - - ov16_0226DD7C(param0->unk_00, param0->unk_04[param0->unk_09].xCoord, param0->unk_04[param0->unk_09].subXCoord, param0->unk_04[param0->unk_09].yCoord, param0->unk_04[param0->unk_09].subYCoord); - Sound_PlayEffect(SEQ_SE_CONFIRM); - } - - return 0; -} - -static BOOL ov13_02228B18(const PartyMenuCursor *byteFlagSet, u8 direction) -{ - switch (direction) { - case PARTY_MENU_CURSOR_DIRECTION_UP: - if (byteFlagSet->downIndex & 0x80) { - return TRUE; - } - break; - case PARTY_MENU_CURSOR_DIRECTION_DOWN: - if (byteFlagSet->upIndex & 0x80) { - return TRUE; - } - break; - case PARTY_MENU_CURSOR_DIRECTION_LEFT: - if (byteFlagSet->rightIndex & 0x80) { - return TRUE; - } - break; - case PARTY_MENU_CURSOR_DIRECTION_RIGHT: - if (byteFlagSet->leftIndex & 0x80) { - return TRUE; - } - break; - } - - return FALSE; -} - -u32 ov13_02228B64(UnkStruct_ov13_02228A50 *param0) -{ - u8 v0, v1, v2, v3; - u8 v4; - u8 v5; - - if (ov13_02228ACC(param0) == 0) { - return 0xffffffff; - } - - if (gSystem.pressedKeys & PAD_KEY_UP) { - v4 = ReadPartyMenuCursorCoords(param0->unk_04, NULL, NULL, NULL, NULL, param0->unk_09, PARTY_MENU_CURSOR_DIRECTION_UP); - v5 = PARTY_MENU_CURSOR_DIRECTION_UP; - } else if (gSystem.pressedKeys & PAD_KEY_DOWN) { - v4 = ReadPartyMenuCursorCoords(param0->unk_04, NULL, NULL, NULL, NULL, param0->unk_09, PARTY_MENU_CURSOR_DIRECTION_DOWN); - v5 = PARTY_MENU_CURSOR_DIRECTION_DOWN; - } else if (gSystem.pressedKeys & PAD_KEY_LEFT) { - v4 = ReadPartyMenuCursorCoords(param0->unk_04, NULL, NULL, NULL, NULL, param0->unk_09, PARTY_MENU_CURSOR_DIRECTION_LEFT); - v5 = PARTY_MENU_CURSOR_DIRECTION_LEFT; - } else if (gSystem.pressedKeys & PAD_KEY_RIGHT) { - v4 = ReadPartyMenuCursorCoords(param0->unk_04, NULL, NULL, NULL, NULL, param0->unk_09, PARTY_MENU_CURSOR_DIRECTION_RIGHT); - v5 = PARTY_MENU_CURSOR_DIRECTION_RIGHT; - } else { - v4 = 0xffffffff; - } - - if (v4 != 0xff) { - u8 v6 = 1; - - if (v4 & 0x80) { - if (param0->unk_0A != 0xff) { - v4 = param0->unk_0A; - } else { - v4 ^= 0x80; - } - } - - while (TRUE) { - u8 v7; - - if (param0->unk_0C & (1 << v4)) { - break; - } - - v6 = 0; - v7 = ReadPartyMenuCursorCoords(param0->unk_04, NULL, NULL, NULL, NULL, v4, v5) & (0xff ^ 0x80); - - if ((v7 == v4) || (v7 == param0->unk_09)) { - v4 = param0->unk_09; - break; - } - - v4 = v7; - } - - if (param0->unk_09 != v4) { - ReadPartyMenuCursorXYCoords(¶m0->unk_04[v4], &v0, &v1); - ReadPartyMenuCursorSubXYCoords(¶m0->unk_04[v4], &v2, &v3); - - if ((ov13_02228B18(¶m0->unk_04[v4], v5) == TRUE) && (v6 != 0)) { - param0->unk_0A = param0->unk_09; - } else { - param0->unk_0A = 0xff; - } - - param0->unk_09 = v4; - - ov16_0226DD7C(param0->unk_00, v0, v2, v1, v3); - Sound_PlayEffect(SEQ_SE_CONFIRM); - } - - return 0xffffffff; - } - - if (gSystem.pressedKeys & PAD_BUTTON_A) { - return param0->unk_09; - } - - if (gSystem.pressedKeys & PAD_BUTTON_B) { - Sound_PlayEffect(SEQ_SE_DP_DECIDE); - return 0xfffffffe; - } - - return 0xffffffff; -} diff --git a/src/party_menu_cursor.c b/src/party_menu_cursor.c deleted file mode 100644 index d03c50474e..0000000000 --- a/src/party_menu_cursor.c +++ /dev/null @@ -1,51 +0,0 @@ -#include "party_menu_cursor.h" - -void ReadPartyMenuCursorXYCoords(const PartyMenuCursor *byteFlagSet, u8 *xCoord, u8 *yCoord) -{ - *xCoord = byteFlagSet->xCoord; - *yCoord = byteFlagSet->yCoord; -} - -void ReadPartyMenuCursorSubXYCoords(const PartyMenuCursor *byteFlagSet, u8 *subXCoord, u8 *subYCoord) -{ - *subXCoord = byteFlagSet->subXCoord; - *subYCoord = byteFlagSet->subYCoord; -} - -u8 ReadPartyMenuCursorCoords(const PartyMenuCursor *byteFlagSet, u8 *xCoord, u8 *yCoord, u8 *subXCoord, u8 *subYCoord, u8 setIndex, u8 direction) -{ - u8 index = setIndex; - - switch (direction) { - case PARTY_MENU_CURSOR_DIRECTION_UP: - index = byteFlagSet[setIndex].upIndex; - break; - case PARTY_MENU_CURSOR_DIRECTION_DOWN: - index = byteFlagSet[setIndex].downIndex; - break; - case PARTY_MENU_CURSOR_DIRECTION_LEFT: - index = byteFlagSet[setIndex].leftIndex; - break; - case PARTY_MENU_CURSOR_DIRECTION_RIGHT: - index = byteFlagSet[setIndex].rightIndex; - break; - } - - if (xCoord != NULL) { - *xCoord = byteFlagSet[index].xCoord; - } - - if (yCoord != NULL) { - *yCoord = byteFlagSet[index].yCoord; - } - - if (subXCoord != NULL) { - *subXCoord = byteFlagSet[index].subXCoord; - } - - if (subYCoord != NULL) { - *subYCoord = byteFlagSet[index].subYCoord; - } - - return index; -} diff --git a/src/unk_0207E0B8.c b/src/unk_0207E0B8.c index 3d60785740..bd238963ef 100644 --- a/src/unk_0207E0B8.c +++ b/src/unk_0207E0B8.c @@ -20,6 +20,7 @@ #include "game_options.h" #include "game_overlay.h" #include "graphics.h" +#include "grid_menu_cursor_position.h" #include "gx_layers.h" #include "heap.h" #include "item.h" @@ -30,7 +31,6 @@ #include "narc.h" #include "overlay_manager.h" #include "party.h" -#include "party_menu_cursor.h" #include "pokemon.h" #include "render_window.h" #include "sound.h" @@ -178,7 +178,7 @@ static const UnkStruct_020F1DF8 Unk_020F1DF8[2][6] = { }, }; -static const PartyMenuCursor Unk_020F1DB8[] = { +static const GridMenuCursorPosition Unk_020F1DB8[] = { { 0x40, 0x19, 0x0, 0x0, 0x7, 0x2, 0x7, 0x1 }, { 0xC0, 0x21, 0x0, 0x0, 0x7, 0x3, 0x0, 0x2 }, { 0x40, 0x49, 0x0, 0x0, 0x0, 0x4, 0x1, 0x3 }, @@ -189,7 +189,7 @@ static const PartyMenuCursor Unk_020F1DB8[] = { { 0xE0, 0xA8, 0x0, 0x0, 0x5, 0x1, 0x5, 0x0 }, }; -static const PartyMenuCursor Unk_020F1CF8[] = { +static const GridMenuCursorPosition Unk_020F1CF8[] = { { 0x40, 0x19, 0x0, 0x0, 0x4, 0x2, 0x1, 0x1 }, { 0xC0, 0x19, 0x0, 0x0, 0x7, 0x3, 0x0, 0x0 }, { 0x40, 0x49, 0x0, 0x0, 0x0, 0x4, 0x3, 0x3 }, @@ -200,7 +200,7 @@ static const PartyMenuCursor Unk_020F1CF8[] = { { 0xE0, 0xA8, 0x0, 0x0, 0x5, 0x1, 0xFF, 0xFF }, }; -static const PartyMenuCursor Unk_020F1D38[] = { +static const GridMenuCursorPosition Unk_020F1D38[] = { { 0x40, 0x19, 0x0, 0x0, 0x7, 0x2, 0x7, 0x1 }, { 0xC0, 0x21, 0x0, 0x0, 0x7, 0x3, 0x0, 0x2 }, { 0x40, 0x49, 0x0, 0x0, 0x0, 0x4, 0x1, 0x3 }, @@ -211,7 +211,7 @@ static const PartyMenuCursor Unk_020F1D38[] = { { 0xE0, 0xB8, 0x0, 0x0, 0x6, 0x1, 0x6, 0x0 }, }; -static const PartyMenuCursor Unk_020F1D78[] = { +static const GridMenuCursorPosition Unk_020F1D78[] = { { 0x40, 0x19, 0x0, 0x0, 0x5, 0x2, 0x5, 0x1 }, { 0xC0, 0x21, 0x0, 0x0, 0x5, 0x3, 0x0, 0x2 }, { 0x40, 0x49, 0x0, 0x0, 0x0, 0x4, 0x1, 0x3 }, @@ -1375,7 +1375,7 @@ static void sub_0207F9A0(GameWindowLayout *param0) { u8 v0, v1; - ReadPartyMenuCursorCoords(param0->unk_7F4, &v0, &v1, NULL, NULL, param0->unk_B11, PARTY_MENU_CURSOR_DIRECTION_NONE); + GridMenuCursor_CheckNavigation(param0->unk_7F4, &v0, &v1, NULL, NULL, param0->unk_B11, GRID_MENU_CURSOR_POSITION_DIRECTION_NONE); Sprite_SetAnim(param0->unk_5B0[6], sub_020805D0(param0->unk_5A4->unk_21, param0->unk_B11)); Sprite_SetPositionXY(param0->unk_5B0[6], v0, v1); } @@ -1406,26 +1406,26 @@ static u8 sub_0207FA24(GameWindowLayout *param0) u8 v1; u8 v2, v3; - v1 = PARTY_MENU_CURSOR_DIRECTION_NONE; + v1 = GRID_MENU_CURSOR_POSITION_DIRECTION_NONE; if (gSystem.pressedKeysRepeatable & PAD_KEY_UP) { - v1 = PARTY_MENU_CURSOR_DIRECTION_UP; + v1 = GRID_MENU_CURSOR_POSITION_DIRECTION_UP; } else if (gSystem.pressedKeysRepeatable & PAD_KEY_DOWN) { - v1 = PARTY_MENU_CURSOR_DIRECTION_DOWN; + v1 = GRID_MENU_CURSOR_POSITION_DIRECTION_DOWN; } else if (gSystem.pressedKeysRepeatable & PAD_KEY_LEFT) { - v1 = PARTY_MENU_CURSOR_DIRECTION_LEFT; + v1 = GRID_MENU_CURSOR_POSITION_DIRECTION_LEFT; } else if (gSystem.pressedKeysRepeatable & PAD_KEY_RIGHT) { - v1 = PARTY_MENU_CURSOR_DIRECTION_RIGHT; + v1 = GRID_MENU_CURSOR_POSITION_DIRECTION_RIGHT; } - if (v1 == PARTY_MENU_CURSOR_DIRECTION_NONE) { + if (v1 == GRID_MENU_CURSOR_POSITION_DIRECTION_NONE) { return 0; } v0 = param0->unk_B11; if (v0 == 6) { - if (v1 == PARTY_MENU_CURSOR_DIRECTION_UP) { + if (v1 == GRID_MENU_CURSOR_POSITION_DIRECTION_UP) { v0 = sub_0207FC30(param0, &v2, &v3, Unk_020F1BD4[2 + (param0->unk_B12 & 1)]); } else { v0 = sub_0207FBE0(param0, &v2, &v3, v1); @@ -1480,7 +1480,7 @@ static u8 sub_0207FBE0(GameWindowLayout *param0, u8 *param1, u8 *param2, u8 para u8 v0 = param0->unk_B11; while (TRUE) { - v0 = ReadPartyMenuCursorCoords(param0->unk_7F4, param1, param2, NULL, NULL, v0, param3); + v0 = GridMenuCursor_CheckNavigation(param0->unk_7F4, param1, param2, NULL, NULL, v0, param3); if ((v0 == 6) || (v0 == 7) || (v0 == 0xff)) { break; @@ -1504,14 +1504,14 @@ static u8 sub_0207FC30(GameWindowLayout *param0, u8 *param1, u8 *param2, const u } if (sub_0207EF04(param0, param3[v0]) != 0) { - ReadPartyMenuCursorCoords(param0->unk_7F4, param1, param2, NULL, NULL, param3[v0], PARTY_MENU_CURSOR_DIRECTION_NONE); + GridMenuCursor_CheckNavigation(param0->unk_7F4, param1, param2, NULL, NULL, param3[v0], GRID_MENU_CURSOR_POSITION_DIRECTION_NONE); return param3[v0]; } v0++; } - ReadPartyMenuCursorCoords(param0->unk_7F4, param1, param2, NULL, NULL, 0, PARTY_MENU_CURSOR_DIRECTION_NONE); + GridMenuCursor_CheckNavigation(param0->unk_7F4, param1, param2, NULL, NULL, 0, GRID_MENU_CURSOR_POSITION_DIRECTION_NONE); return 0; } @@ -1533,7 +1533,7 @@ static u8 sub_0207FC94(GameWindowLayout *param0) UpdateWindowLayout(param0, v3, 0); } - ReadPartyMenuCursorCoords(param0->unk_7F4, &v1, &v2, NULL, NULL, param0->unk_B11, PARTY_MENU_CURSOR_DIRECTION_NONE); + GridMenuCursor_CheckNavigation(param0->unk_7F4, &v1, &v2, NULL, NULL, param0->unk_B11, GRID_MENU_CURSOR_POSITION_DIRECTION_NONE); Sprite_SetAnim(param0->unk_5B0[6], sub_020805D0(param0->unk_5A4->unk_21, param0->unk_B11)); Sprite_SetDrawFlag(param0->unk_5B0[6], 1); Sprite_SetPositionXY(param0->unk_5B0[6], v1, v2); @@ -1560,7 +1560,7 @@ void sub_0207FD68(GameWindowLayout *param0, u8 param1) } else { u8 v0, v1; - ReadPartyMenuCursorCoords(param0->unk_7F4, &v0, &v1, NULL, NULL, param0->unk_B11, PARTY_MENU_CURSOR_DIRECTION_NONE); + GridMenuCursor_CheckNavigation(param0->unk_7F4, &v0, &v1, NULL, NULL, param0->unk_B11, GRID_MENU_CURSOR_POSITION_DIRECTION_NONE); Sprite_SetAnim(param0->unk_5B0[6], sub_020805D0(param0->unk_5A4->unk_21, param1)); Sprite_SetDrawFlag(param0->unk_5B0[6], 1); Sprite_SetPositionXY(param0->unk_5B0[6], v0, v1); diff --git a/src/unk_02082C2C.c b/src/unk_02082C2C.c index 4cc398dca4..0bf03acbae 100644 --- a/src/unk_02082C2C.c +++ b/src/unk_02082C2C.c @@ -7,12 +7,12 @@ #include "struct_defs/struct_020831B4.h" #include "graphics.h" +#include "grid_menu_cursor_position.h" #include "gx_layers.h" #include "heap.h" #include "item.h" #include "narc.h" #include "party.h" -#include "party_menu_cursor.h" #include "pokemon.h" #include "pokemon_icon.h" #include "sprite.h" @@ -344,7 +344,7 @@ void sub_0208327C(GameWindowLayout *param0, u8 param1, u8 param2) { u8 v0, v1; - ReadPartyMenuCursorXYCoords(¶m0->unk_7F4[param1], &v0, &v1); + GridMenuCursor_GetFirstCoords(¶m0->unk_7F4[param1], &v0, &v1); Sprite_SetAnim(param0->unk_5B0[6], sub_020805D0(param0->unk_5A4->unk_21, param1)); Sprite_SetDrawFlag(param0->unk_5B0[6], 1); Sprite_SetPositionXY(param0->unk_5B0[6], v0, v1);