diff options
Diffstat (limited to 'src/pokemon_storage_system.c')
-rw-r--r-- | src/pokemon_storage_system.c | 192 |
1 files changed, 99 insertions, 93 deletions
diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index 546f50dce..4be1cf729 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -41,7 +41,6 @@ #include "constants/moves.h" #include "constants/rgb.h" #include "constants/songs.h" -#include "constants/species.h" struct WallpaperTable { @@ -1756,10 +1755,10 @@ static void Task_PokemonStorageSystemPC(u8 taskId) { case MENU_NOTHING_CHOSEN: task->data[3] = task->data[1]; - if (gMain.newKeys & DPAD_UP && --task->data[3] < 0) + if (JOY_NEW(DPAD_UP) && --task->data[3] < 0) task->data[3] = 4; - if (gMain.newKeys & DPAD_DOWN && ++task->data[3] > 4) + if (JOY_NEW(DPAD_DOWN) && ++task->data[3] > 4) task->data[3] = 0; if (task->data[1] != task->data[3]) { @@ -1798,13 +1797,13 @@ static void Task_PokemonStorageSystemPC(u8 taskId) } break; case 3: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { FillWindowPixelBuffer(0, PIXEL_FILL(1)); AddTextPrinterParameterized2(0, 1, gUnknown_085716C0[task->data[1]].desc, 0, NULL, 2, 1, 3); task->data[0] = 2; } - else if (gMain.newKeys & DPAD_UP) + else if (JOY_NEW(DPAD_UP)) { if (--task->data[1] < 0) task->data[1] = 4; @@ -1814,7 +1813,7 @@ static void Task_PokemonStorageSystemPC(u8 taskId) AddTextPrinterParameterized2(0, 1, gUnknown_085716C0[task->data[1]].desc, 0, NULL, 2, 1, 3); task->data[0] = 2; } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { if (++task->data[1] > 3) task->data[1] = 0; @@ -1976,22 +1975,22 @@ static void sub_80C78E4(void) static u8 HandleBoxChooseSelectionInput(void) { - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); return 201; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); return gUnknown_02039D04->curBox; } - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { PlaySE(SE_SELECT); sub_80C7BB4(); } - else if (gMain.newKeys & DPAD_RIGHT) + else if (JOY_NEW(DPAD_RIGHT)) { PlaySE(SE_SELECT); sub_80C7B80(); @@ -2393,7 +2392,7 @@ static void Cb_ReshowPSS(u8 taskId) } break; case 2: - if (!IsDma3ManagerBusyWithBgCopy() && gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (!IsDma3ManagerBusyWithBgCopy() && JOY_NEW(A_BUTTON | B_BUTTON)) { ClearBottomWindow(); sPSSData->state++; @@ -2615,7 +2614,7 @@ static void Cb_MainPSS(u8 taskId) } break; case 3: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); sPSSData->state = 0; @@ -2632,7 +2631,7 @@ static void Cb_MainPSS(u8 taskId) sPSSData->state = 6; break; case 6: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); SetPSSCallback(Cb_MainPSS); @@ -2858,7 +2857,7 @@ static void Cb_OnSelectedMon(u8 taskId) sPSSData->state = 6; break; case 6: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); SetPSSCallback(Cb_MainPSS); @@ -2943,7 +2942,7 @@ static void Cb_WithdrawMon(u8 taskId) } break; case 1: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); SetPSSCallback(Cb_MainPSS); @@ -3034,7 +3033,7 @@ static void Cb_DepositMenu(u8 taskId) } break; case 4: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX); sPSSData->state = 1; @@ -3095,14 +3094,14 @@ static void Cb_ReleaseMon(u8 taskId) sPSSData->state++; break; case 4: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { PrintStorageActionText(PC_TEXT_BYE_BYE); sPSSData->state++; } break; case 5: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); if (sInPartyMenu) @@ -3134,14 +3133,14 @@ static void Cb_ReleaseMon(u8 taskId) sPSSData->state++; break; case 9: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { PrintStorageActionText(PC_TEXT_SURPRISE); sPSSData->state++; } break; case 10: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); sub_80CC064(); @@ -3157,14 +3156,14 @@ static void Cb_ReleaseMon(u8 taskId) } break; case 12: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { PrintStorageActionText(PC_TEXT_WORRIED); sPSSData->state++; } break; case 13: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); SetPSSCallback(Cb_MainPSS); @@ -3184,7 +3183,7 @@ static void Cb_ShowMarkMenu(u8 taskId) sPSSData->state++; break; case 1: - if (!sub_811FBA4()) + if (!MonMarkingsMenuHandleInput()) { sub_811FAF8(); ClearBottomWindow(); @@ -3257,7 +3256,7 @@ static void Cb_GiveMovingItemToMon(u8 taskId) } break; case 3: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); sPSSData->state++; @@ -3296,7 +3295,7 @@ static void Cb_ItemToBag(u8 taskId) } break; case 2: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); sub_80CE00C(); @@ -3309,7 +3308,7 @@ static void Cb_ItemToBag(u8 taskId) SetPSSCallback(Cb_MainPSS); break; case 3: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); SetPSSCallback(Cb_MainPSS); @@ -3349,7 +3348,7 @@ static void Cb_SwitchSelectedItem(u8 taskId) } break; case 3: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); sPSSData->state++; @@ -3388,7 +3387,7 @@ static void Cb_ShowItemInfo(u8 taskId) sPSSData->state++; break; case 4: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { PlaySE(SE_WIN_OPEN); sPSSData->state++; @@ -3438,7 +3437,7 @@ static void Cb_CloseBoxWhileHoldingItem(u8 taskId) } break; case 2: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); sPSSData->state = 5; @@ -3494,7 +3493,7 @@ static void Cb_PrintCantStoreMail(u8 taskId) sPSSData->state++; break; case 2: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); sPSSData->state++; @@ -3759,7 +3758,7 @@ static void Cb_OnCloseBoxPressed(u8 taskId) } break; case 1: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); SetPSSCallback(Cb_MainPSS); @@ -3820,7 +3819,7 @@ static void Cb_OnBPressed(u8 taskId) } break; case 1: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { ClearBottomWindow(); SetPSSCallback(Cb_MainPSS); @@ -5462,7 +5461,7 @@ static void sub_80CCA3C(const void *tilemap, s8 direction, u8 arg2) if (direction == 0) return; - else if (direction > 0) + if (direction > 0) x *= 1, x += 0x14; // x * 1 is needed to match, but can be safely removed as it makes no functional difference else x -= 4; @@ -6778,11 +6777,11 @@ static void SetCursorMonData(void *pokemon, u8 mode) { u8 *txtPtr; u16 gender; - bool8 sanityIsBagEgg; + bool8 sanityIsBadEgg; sPSSData->cursorMonItem = 0; gender = MON_MALE; - sanityIsBagEgg = FALSE; + sanityIsBadEgg = FALSE; if (mode == MODE_PARTY) { struct Pokemon *mon = (struct Pokemon *)pokemon; @@ -6790,8 +6789,8 @@ static void SetCursorMonData(void *pokemon, u8 mode) sPSSData->cursorMonSpecies = GetMonData(mon, MON_DATA_SPECIES2); if (sPSSData->cursorMonSpecies != SPECIES_NONE) { - sanityIsBagEgg = GetMonData(mon, MON_DATA_SANITY_IS_BAD_EGG); - if (sanityIsBagEgg) + sanityIsBadEgg = GetMonData(mon, MON_DATA_SANITY_IS_BAD_EGG); + if (sanityIsBadEgg) sPSSData->cursorMonIsEgg = TRUE; else sPSSData->cursorMonIsEgg = GetMonData(mon, MON_DATA_IS_EGG); @@ -6814,8 +6813,8 @@ static void SetCursorMonData(void *pokemon, u8 mode) if (sPSSData->cursorMonSpecies != SPECIES_NONE) { u32 otId = GetBoxMonData(boxMon, MON_DATA_OT_ID); - sanityIsBagEgg = GetBoxMonData(boxMon, MON_DATA_SANITY_IS_BAD_EGG); - if (sanityIsBagEgg) + sanityIsBadEgg = GetBoxMonData(boxMon, MON_DATA_SANITY_IS_BAD_EGG); + if (sanityIsBadEgg) sPSSData->cursorMonIsEgg = TRUE; else sPSSData->cursorMonIsEgg = GetBoxMonData(boxMon, MON_DATA_IS_EGG); @@ -6847,7 +6846,7 @@ static void SetCursorMonData(void *pokemon, u8 mode) } else if (sPSSData->cursorMonIsEgg) { - if (sanityIsBagEgg) + if (sanityIsBadEgg) StringCopyPadded(sPSSData->cursorMonNickText, sPSSData->cursorMonNick, CHAR_SPACE, 5); else StringCopyPadded(sPSSData->cursorMonNickText, gText_EggNickname, CHAR_SPACE, 8); @@ -6940,7 +6939,7 @@ static u8 InBoxInput_Normal(void) sPSSData->field_CD3 = 0; sPSSData->field_CD7 = 0; - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPEAT(DPAD_UP)) { retVal = TRUE; if (sBoxCursorPosition >= IN_BOX_ROWS) @@ -6954,7 +6953,7 @@ static u8 InBoxInput_Normal(void) } break; } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPEAT(DPAD_DOWN)) { retVal = TRUE; cursorPosition += IN_BOX_ROWS; @@ -6968,7 +6967,7 @@ static u8 InBoxInput_Normal(void) } break; } - else if (gMain.newAndRepeatedKeys & DPAD_LEFT) + else if (JOY_REPEAT(DPAD_LEFT)) { retVal = TRUE; if (sBoxCursorPosition % IN_BOX_ROWS != 0) @@ -6982,7 +6981,7 @@ static u8 InBoxInput_Normal(void) } break; } - else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + else if (JOY_REPEAT(DPAD_RIGHT)) { retVal = TRUE; if ((sBoxCursorPosition + 1) % IN_BOX_ROWS != 0) @@ -6996,7 +6995,7 @@ static u8 InBoxInput_Normal(void) } break; } - else if (gMain.newKeys & START_BUTTON) + else if (JOY_NEW(START_BUTTON)) { retVal = TRUE; cursorArea = CURSOR_AREA_BOX; @@ -7004,7 +7003,7 @@ static u8 InBoxInput_Normal(void) break; } - if ((gMain.newKeys & A_BUTTON) && sub_80CFA5C()) + if ((JOY_NEW(A_BUTTON)) && sub_80CFA5C()) { if (!sCanOnlyMove) return 8; @@ -7038,18 +7037,18 @@ static u8 InBoxInput_Normal(void) } } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) return 19; if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR) { - if (gMain.heldKeys & L_BUTTON) + if (JOY_HELD(L_BUTTON)) return 10; - if (gMain.heldKeys & R_BUTTON) + if (JOY_HELD(R_BUTTON)) return 9; } - if (gMain.newKeys & SELECT_BUTTON) + if (JOY_NEW(SELECT_BUTTON)) { sub_80CFDC4(); return 0; @@ -7067,9 +7066,9 @@ static u8 InBoxInput_Normal(void) static u8 InBoxInput_GrabbingMultiple(void) { - if (gMain.heldKeys & A_BUTTON) + if (JOY_HELD(A_BUTTON)) { - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPEAT(DPAD_UP)) { if (sBoxCursorPosition / IN_BOX_ROWS != 0) { @@ -7081,7 +7080,7 @@ static u8 InBoxInput_GrabbingMultiple(void) return 24; } } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPEAT(DPAD_DOWN)) { if (sBoxCursorPosition + IN_BOX_ROWS < IN_BOX_COUNT) { @@ -7093,7 +7092,7 @@ static u8 InBoxInput_GrabbingMultiple(void) return 24; } } - else if (gMain.newAndRepeatedKeys & DPAD_LEFT) + else if (JOY_REPEAT(DPAD_LEFT)) { if (sBoxCursorPosition % IN_BOX_ROWS != 0) { @@ -7105,7 +7104,7 @@ static u8 InBoxInput_GrabbingMultiple(void) return 24; } } - else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + else if (JOY_REPEAT(DPAD_RIGHT)) { if ((sBoxCursorPosition + 1) % IN_BOX_ROWS != 0) { @@ -7142,7 +7141,7 @@ static u8 InBoxInput_GrabbingMultiple(void) static u8 InBoxInput_MovingMultiple(void) { - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPEAT(DPAD_UP)) { if (sub_80D0580(0)) { @@ -7154,7 +7153,7 @@ static u8 InBoxInput_MovingMultiple(void) return 24; } } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPEAT(DPAD_DOWN)) { if (sub_80D0580(1)) { @@ -7166,7 +7165,7 @@ static u8 InBoxInput_MovingMultiple(void) return 24; } } - else if (gMain.newAndRepeatedKeys & DPAD_LEFT) + else if (JOY_REPEAT(DPAD_LEFT)) { if (sub_80D0580(2)) { @@ -7178,7 +7177,7 @@ static u8 InBoxInput_MovingMultiple(void) return 10; } } - else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + else if (JOY_REPEAT(DPAD_RIGHT)) { if (sub_80D0580(3)) { @@ -7190,7 +7189,7 @@ static u8 InBoxInput_MovingMultiple(void) return 9; } } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { if (sub_80D0BC0()) { @@ -7203,7 +7202,7 @@ static u8 InBoxInput_MovingMultiple(void) return 24; } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { return 24; } @@ -7211,9 +7210,9 @@ static u8 InBoxInput_MovingMultiple(void) { if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR) { - if (gMain.heldKeys & L_BUTTON) + if (JOY_HELD(L_BUTTON)) return 10; - if (gMain.heldKeys & R_BUTTON) + if (JOY_HELD(R_BUTTON)) return 9; } @@ -7238,7 +7237,7 @@ static u8 HandleInput_InParty(void) gotoBox = FALSE; retVal = 0; - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPEAT(DPAD_UP)) { if (--cursorPosition < 0) cursorPosition = PARTY_SIZE; @@ -7246,7 +7245,7 @@ static u8 HandleInput_InParty(void) retVal = 1; break; } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPEAT(DPAD_DOWN)) { if (++cursorPosition > PARTY_SIZE) cursorPosition = 0; @@ -7254,14 +7253,14 @@ static u8 HandleInput_InParty(void) retVal = 1; break; } - else if (gMain.newAndRepeatedKeys & DPAD_LEFT && sBoxCursorPosition != 0) + else if (JOY_REPEAT(DPAD_LEFT) && sBoxCursorPosition != 0) { retVal = 1; sPSSData->field_CD6 = sBoxCursorPosition; cursorPosition = 0; break; } - else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + else if (JOY_REPEAT(DPAD_RIGHT)) { if (sBoxCursorPosition == 0) { @@ -7277,7 +7276,7 @@ static u8 HandleInput_InParty(void) break; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (sBoxCursorPosition == PARTY_SIZE) { @@ -7313,7 +7312,7 @@ static u8 HandleInput_InParty(void) } } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { if (sPSSData->boxOption == BOX_OPTION_DEPOSIT) return 19; @@ -7327,7 +7326,7 @@ static u8 HandleInput_InParty(void) cursorArea = CURSOR_AREA_IN_BOX; cursorPosition = 0; } - else if (gMain.newKeys & SELECT_BUTTON) + else if (JOY_NEW(SELECT_BUTTON)) { sub_80CFDC4(); return 0; @@ -7356,7 +7355,7 @@ static u8 HandleInput_OnBox(void) sPSSData->field_CD2 = 0; sPSSData->field_CD7 = 0; - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPEAT(DPAD_UP)) { retVal = 1; cursorArea = CURSOR_AREA_BUTTONS; @@ -7364,7 +7363,7 @@ static u8 HandleInput_OnBox(void) sPSSData->field_CD7 = 1; break; } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPEAT(DPAD_DOWN)) { retVal = 1; cursorArea = CURSOR_AREA_IN_BOX; @@ -7372,30 +7371,30 @@ static u8 HandleInput_OnBox(void) break; } - if (gMain.heldKeys & DPAD_LEFT) + if (JOY_HELD(DPAD_LEFT)) return 10; - if (gMain.heldKeys & DPAD_RIGHT) + if (JOY_HELD(DPAD_RIGHT)) return 9; if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR) { - if (gMain.heldKeys & L_BUTTON) + if (JOY_HELD(L_BUTTON)) return 10; - if (gMain.heldKeys & R_BUTTON) + if (JOY_HELD(R_BUTTON)) return 9; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { sub_80CD1A8(FALSE); AddBoxMenu(); return 7; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) return 19; - if (gMain.newKeys & SELECT_BUTTON) + if (JOY_NEW(SELECT_BUTTON)) { sub_80CFDC4(); return 0; @@ -7429,7 +7428,7 @@ static u8 HandleInput_OnButtons(void) sPSSData->field_CD2 = 0; sPSSData->field_CD7 = 0; - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPEAT(DPAD_UP)) { retVal = 1; cursorArea = CURSOR_AREA_IN_BOX; @@ -7441,7 +7440,8 @@ static u8 HandleInput_OnButtons(void) sPSSData->field_CD7 = 1; break; } - else if (gMain.newAndRepeatedKeys & (DPAD_DOWN | START_BUTTON)) + + if (JOY_REPEAT(DPAD_DOWN | START_BUTTON)) { retVal = 1; cursorArea = CURSOR_AREA_BOX; @@ -7450,14 +7450,14 @@ static u8 HandleInput_OnButtons(void) break; } - if (gMain.newAndRepeatedKeys & DPAD_LEFT) + if (JOY_REPEAT(DPAD_LEFT)) { retVal = 1; if (--cursorPosition < 0) cursorPosition = 1; break; } - else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + else if (JOY_REPEAT(DPAD_RIGHT)) { retVal = 1; if (++cursorPosition > 1) @@ -7465,12 +7465,12 @@ static u8 HandleInput_OnButtons(void) break; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) return (cursorPosition == 0) ? 5 : 4; - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) return 19; - if (gMain.newKeys & SELECT_BUTTON) + if (JOY_NEW(SELECT_BUTTON)) { sub_80CFDC4(); return 0; @@ -7919,23 +7919,23 @@ static s16 sub_80D00AC(void) do { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { textId = Menu_GetCursorPos(); break; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); textId = -1; } - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { PlaySE(SE_SELECT); Menu_MoveCursor(-1); } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { PlaySE(SE_SELECT); Menu_MoveCursor(1); @@ -8408,8 +8408,13 @@ static void sub_80D08CC(void) for (j = sMoveMonsPtr->minRow; j < rowCount; j++) { struct BoxPokemon *boxMon = GetBoxedMonPtr(boxId, boxPosition); - + // UB: possible null dereference +#ifdef UBFIX + if (boxMon != NULL) + sMoveMonsPtr->boxMons[monArrayId] = *boxMon; +#else sMoveMonsPtr->boxMons[monArrayId] = *boxMon; +#endif monArrayId++; boxPosition++; } @@ -9329,10 +9334,11 @@ u32 GetBoxMonLevelAt(u8 boxId, u8 boxPosition) { u32 lvl; - // BUG: Missed 'else' statement. if (boxId < TOTAL_BOXES_COUNT && boxPosition < IN_BOX_COUNT && GetBoxMonData(&gPokemonStoragePtr->boxes[boxId][boxPosition], MON_DATA_SANITY_HAS_SPECIES)) lvl = GetLevelFromBoxMonExp(&gPokemonStoragePtr->boxes[boxId][boxPosition]); - // else + #ifdef BUGFIX + else + #endif lvl = 0; return lvl; |