From 28ef2fb774bf596a3e7f81055453304e0d2ce066 Mon Sep 17 00:00:00 2001 From: PokeCodec <67983839+PokeCodec@users.noreply.github.com> Date: Fri, 4 Sep 2020 21:11:55 -0400 Subject: [PATCH] Switch to button macros --- gflib/text.c | 8 +- src/apprentice.c | 4 +- src/battle_controller_player.c | 74 +++++++-------- src/battle_controller_safari.c | 10 +- src/battle_dome.c | 24 ++--- src/battle_factory_screen.c | 54 +++++------ src/battle_main.c | 10 +- src/battle_pyramid_bag.c | 26 +++--- src/battle_records.c | 2 +- src/battle_script_commands.c | 32 +++---- src/berry_crush.c | 8 +- src/berry_fix_program.c | 8 +- src/berry_tag_screen.c | 4 +- src/cable_club.c | 10 +- src/contest.c | 4 +- src/contest_painting.c | 2 +- src/credits.c | 2 +- src/daycare.c | 4 +- src/decoration.c | 27 +++--- src/diploma.c | 2 +- src/dodrio_berry_picking.c | 20 ++-- src/easy_chat.c | 64 ++++++------- src/ereader_screen.c | 10 +- src/evolution_scene.c | 8 +- src/field_player_avatar.c | 4 +- src/field_special_scene.c | 2 +- src/frontier_pass.c | 18 ++-- src/hall_of_fame.c | 12 +-- src/item_menu.c | 42 ++++----- src/item_use.c | 4 +- src/link.c | 16 ++-- src/list_menu.c | 20 ++-- src/mail.c | 2 +- src/main.c | 4 +- src/main_menu.c | 16 ++-- src/match_call.c | 4 +- src/menu.c | 80 ++++++++-------- src/menu_helpers.c | 16 ++-- src/mon_markings.c | 8 +- src/move_relearner.c | 4 +- src/mystery_event_menu.c | 10 +- src/mystery_gift.c | 10 +- src/option_menu.c | 26 +++--- src/overworld.c | 17 ++-- src/party_menu.c | 18 ++-- src/player_pc.c | 14 +-- src/pokeblock.c | 8 +- src/pokedex.c | 106 ++++++++++----------- src/pokedex_area_screen.c | 4 +- src/pokemon_jump.c | 6 +- src/pokemon_storage_system.c | 163 +++++++++++++++++---------------- src/pokemon_summary_screen.c | 50 +++++----- src/pokenav_conditions_1.c | 8 +- src/pokenav_conditions_3.c | 12 +-- src/pokenav_match_call_1.c | 28 +++--- src/pokenav_match_call_2.c | 2 +- src/pokenav_menu_handler_1.c | 26 +++--- src/pokenav_region_map.c | 2 +- src/pokenav_ribbons_1.c | 12 +-- src/pokenav_ribbons_2.c | 18 ++-- src/region_map.c | 24 ++--- src/reset_rtc_screen.c | 16 ++-- src/save_failed_screen.c | 4 +- src/scrcmd.c | 4 +- src/script_menu.c | 2 +- src/shop.c | 8 +- src/slot_machine.c | 2 +- src/start_menu.c | 14 +-- src/title_screen.c | 8 +- src/trade.c | 20 ++-- src/trainer_card.c | 8 +- src/union_room.c | 22 ++--- src/union_room_chat.c | 24 ++--- src/unk_text_util_2.c | 4 +- src/wallclock.c | 8 +- 75 files changed, 689 insertions(+), 688 deletions(-) diff --git a/gflib/text.c b/gflib/text.c index 274ceadee..169f625bc 100644 --- a/gflib/text.c +++ b/gflib/text.c @@ -786,7 +786,7 @@ bool16 TextPrinterWaitWithDownArrow(struct TextPrinter *textPrinter) else { TextPrinterDrawDownArrow(textPrinter); - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { result = TRUE; PlaySE(SE_SELECT); @@ -802,7 +802,7 @@ bool16 TextPrinterWait(struct TextPrinter *textPrinter) { result = TextPrinterWaitAutoMode(textPrinter); } - else if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + else if (JOY_NEW(A_BUTTON | B_BUTTON)) { result = TRUE; PlaySE(SE_SELECT); @@ -862,13 +862,13 @@ u16 RenderText(struct TextPrinter *textPrinter) switch (textPrinter->state) { case 0: - if ((gMain.heldKeys & (A_BUTTON | B_BUTTON)) && subStruct->hasPrintBeenSpedUp) + if ((JOY_HELD(A_BUTTON | B_BUTTON)) && subStruct->hasPrintBeenSpedUp) textPrinter->delayCounter = 0; if (textPrinter->delayCounter && textPrinter->textSpeed) { textPrinter->delayCounter--; - if (gTextFlags.canABSpeedUpPrint && (gMain.newKeys & (A_BUTTON | B_BUTTON))) + if (gTextFlags.canABSpeedUpPrint && (JOY_NEW(A_BUTTON | B_BUTTON))) { subStruct->hasPrintBeenSpedUp = TRUE; textPrinter->delayCounter = 0; diff --git a/src/apprentice.c b/src/apprentice.c index 7f493a136..3dc33cad4 100644 --- a/src/apprentice.c +++ b/src/apprentice.c @@ -1297,13 +1297,13 @@ const u8 *GetApprenticeNameInLanguage(u32 apprenticeId, s32 language) // Functionally unused static void Task_SwitchToFollowupFuncAfterButtonPress(u8 taskId) { - if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) SwitchTaskToFollowupFunc(taskId); } static void Task_ExecuteFuncAfterButtonPress(u8 taskId) { - if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { gApprenticeFunc = (void*)(u32)(((u16)gTasks[taskId].data[0] | (gTasks[taskId].data[1] << 16))); gApprenticeFunc(); diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index d8005e808..7c34efd44 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -240,12 +240,12 @@ static void HandleInputChooseAction(void) DoBounceEffect(gActiveBattler, BOUNCE_HEALTHBOX, 7, 1); DoBounceEffect(gActiveBattler, BOUNCE_MON, 7, 1); - if (gMain.newAndRepeatedKeys & DPAD_ANY && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A) + if (JOY_REPEAT(DPAD_ANY) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A) gPlayerDpadHoldFrames++; else gPlayerDpadHoldFrames = 0; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); @@ -266,7 +266,7 @@ static void HandleInputChooseAction(void) } PlayerBufferExecCompleted(); } - else if (gMain.newKeys & DPAD_LEFT) + else if (JOY_NEW(DPAD_LEFT)) { if (gActionSelectionCursor[gActiveBattler] & 1) // if is B_ACTION_USE_ITEM or B_ACTION_RUN { @@ -276,7 +276,7 @@ static void HandleInputChooseAction(void) ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); } } - else if (gMain.newKeys & DPAD_RIGHT) + else if (JOY_NEW(DPAD_RIGHT)) { if (!(gActionSelectionCursor[gActiveBattler] & 1)) // if is B_ACTION_USE_MOVE or B_ACTION_SWITCH { @@ -286,7 +286,7 @@ static void HandleInputChooseAction(void) ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); } } - else if (gMain.newKeys & DPAD_UP) + else if (JOY_NEW(DPAD_UP)) { if (gActionSelectionCursor[gActiveBattler] & 2) // if is B_ACTION_SWITCH or B_ACTION_RUN { @@ -296,7 +296,7 @@ static void HandleInputChooseAction(void) ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); } } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { if (!(gActionSelectionCursor[gActiveBattler] & 2)) // if is B_ACTION_USE_MOVE or B_ACTION_USE_ITEM { @@ -306,7 +306,7 @@ static void HandleInputChooseAction(void) ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); } } - else if (gMain.newKeys & B_BUTTON || gPlayerDpadHoldFrames > 59) + else if (JOY_NEW(B_BUTTON) || gPlayerDpadHoldFrames > 59) { if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_RIGHT @@ -326,7 +326,7 @@ static void HandleInputChooseAction(void) PlayerBufferExecCompleted(); } } - else if (gMain.newKeys & START_BUTTON) + else if (JOY_NEW(START_BUTTON)) { SwapHpBarsWithHpText(); } @@ -359,12 +359,12 @@ static void HandleInputChooseTarget(void) } while (i < gBattlersCount); } - if (gMain.heldKeys & DPAD_ANY && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A) + if (JOY_HELD(DPAD_ANY) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A) gPlayerDpadHoldFrames++; else gPlayerDpadHoldFrames = 0; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); gSprites[gBattlerSpriteIds[gMultiUsePlayerCursor]].callback = SpriteCb_HideAsMoveTarget; @@ -372,7 +372,7 @@ static void HandleInputChooseTarget(void) EndBounceEffect(gMultiUsePlayerCursor, BOUNCE_HEALTHBOX); PlayerBufferExecCompleted(); } - else if (gMain.newKeys & B_BUTTON || gPlayerDpadHoldFrames > 59) + else if (JOY_NEW(B_BUTTON) || gPlayerDpadHoldFrames > 59) { PlaySE(SE_SELECT); gSprites[gBattlerSpriteIds[gMultiUsePlayerCursor]].callback = SpriteCb_HideAsMoveTarget; @@ -381,7 +381,7 @@ static void HandleInputChooseTarget(void) DoBounceEffect(gActiveBattler, BOUNCE_MON, 7, 1); EndBounceEffect(gMultiUsePlayerCursor, BOUNCE_HEALTHBOX); } - else if (gMain.newKeys & (DPAD_LEFT | DPAD_UP)) + else if (JOY_NEW(DPAD_LEFT | DPAD_UP)) { PlaySE(SE_SELECT); gSprites[gBattlerSpriteIds[gMultiUsePlayerCursor]].callback = SpriteCb_HideAsMoveTarget; @@ -423,7 +423,7 @@ static void HandleInputChooseTarget(void) } while (i == 0); gSprites[gBattlerSpriteIds[gMultiUsePlayerCursor]].callback = SpriteCb_ShowAsMoveTarget; } - else if (gMain.newKeys & (DPAD_RIGHT | DPAD_DOWN)) + else if (JOY_NEW(DPAD_RIGHT | DPAD_DOWN)) { PlaySE(SE_SELECT); gSprites[gBattlerSpriteIds[gMultiUsePlayerCursor]].callback = SpriteCb_HideAsMoveTarget; @@ -472,12 +472,12 @@ static void HandleInputChooseMove(void) bool32 canSelectTarget = FALSE; struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]); - if (gMain.heldKeys & DPAD_ANY && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A) + if (JOY_HELD(DPAD_ANY) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A) gPlayerDpadHoldFrames++; else gPlayerDpadHoldFrames = 0; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { u8 moveTarget; @@ -539,13 +539,13 @@ static void HandleInputChooseMove(void) gSprites[gBattlerSpriteIds[gMultiUsePlayerCursor]].callback = SpriteCb_ShowAsMoveTarget; } } - else if (gMain.newKeys & B_BUTTON || gPlayerDpadHoldFrames > 59) + else if (JOY_NEW(B_BUTTON) || gPlayerDpadHoldFrames > 59) { PlaySE(SE_SELECT); BtlController_EmitTwoReturnValues(1, 10, 0xFFFF); PlayerBufferExecCompleted(); } - else if (gMain.newKeys & DPAD_LEFT) + else if (JOY_NEW(DPAD_LEFT)) { if (gMoveSelectionCursor[gActiveBattler] & 1) { @@ -557,7 +557,7 @@ static void HandleInputChooseMove(void) MoveSelectionDisplayMoveType(); } } - else if (gMain.newKeys & DPAD_RIGHT) + else if (JOY_NEW(DPAD_RIGHT)) { if (!(gMoveSelectionCursor[gActiveBattler] & 1) && (gMoveSelectionCursor[gActiveBattler] ^ 1) < gNumberOfMovesToChoose) @@ -570,7 +570,7 @@ static void HandleInputChooseMove(void) MoveSelectionDisplayMoveType(); } } - else if (gMain.newKeys & DPAD_UP) + else if (JOY_NEW(DPAD_UP)) { if (gMoveSelectionCursor[gActiveBattler] & 2) { @@ -582,7 +582,7 @@ static void HandleInputChooseMove(void) MoveSelectionDisplayMoveType(); } } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { if (!(gMoveSelectionCursor[gActiveBattler] & 2) && (gMoveSelectionCursor[gActiveBattler] ^ 2) < gNumberOfMovesToChoose) @@ -595,7 +595,7 @@ static void HandleInputChooseMove(void) MoveSelectionDisplayMoveType(); } } - else if (gMain.newKeys & SELECT_BUTTON) + else if (JOY_NEW(SELECT_BUTTON)) { if (gNumberOfMovesToChoose > 1 && !(gBattleTypeFlags & BATTLE_TYPE_LINK)) { @@ -617,26 +617,26 @@ u32 sub_8057FBC(void) // unused { u32 var = 0; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); var = 1; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); gBattle_BG0_X = 0; gBattle_BG0_Y = 0x140; var = 0xFF; } - if (gMain.newKeys & DPAD_LEFT && gMoveSelectionCursor[gActiveBattler] & 1) + if (JOY_NEW(DPAD_LEFT) && gMoveSelectionCursor[gActiveBattler] & 1) { MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBattler]); gMoveSelectionCursor[gActiveBattler] ^= 1; PlaySE(SE_SELECT); MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 0); } - if (gMain.newKeys & DPAD_RIGHT && !(gMoveSelectionCursor[gActiveBattler] & 1) + if (JOY_NEW(DPAD_RIGHT) && !(gMoveSelectionCursor[gActiveBattler] & 1) && (gMoveSelectionCursor[gActiveBattler] ^ 1) < gNumberOfMovesToChoose) { MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBattler]); @@ -644,14 +644,14 @@ u32 sub_8057FBC(void) // unused PlaySE(SE_SELECT); MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 0); } - if (gMain.newKeys & DPAD_UP && gMoveSelectionCursor[gActiveBattler] & 2) + if (JOY_NEW(DPAD_UP) && gMoveSelectionCursor[gActiveBattler] & 2) { MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBattler]); gMoveSelectionCursor[gActiveBattler] ^= 2; PlaySE(SE_SELECT); MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 0); } - if (gMain.newKeys & DPAD_DOWN && !(gMoveSelectionCursor[gActiveBattler] & 2) + if (JOY_NEW(DPAD_DOWN) && !(gMoveSelectionCursor[gActiveBattler] & 2) && (gMoveSelectionCursor[gActiveBattler] ^ 2) < gNumberOfMovesToChoose) { MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBattler]); @@ -669,7 +669,7 @@ static void HandleMoveSwitching(void) struct ChooseMoveStruct moveStruct; u8 totalPPBonuses; - if (gMain.newKeys & (A_BUTTON | SELECT_BUTTON)) + if (JOY_NEW(A_BUTTON | SELECT_BUTTON)) { PlaySE(SE_SELECT); @@ -763,7 +763,7 @@ static void HandleMoveSwitching(void) MoveSelectionDisplayPpNumber(); MoveSelectionDisplayMoveType(); } - else if (gMain.newKeys & (B_BUTTON | SELECT_BUTTON)) + else if (JOY_NEW(B_BUTTON | SELECT_BUTTON)) { PlaySE(SE_SELECT); MoveSelectionDestroyCursorAt(gMultiUsePlayerCursor); @@ -773,7 +773,7 @@ static void HandleMoveSwitching(void) MoveSelectionDisplayPpNumber(); MoveSelectionDisplayMoveType(); } - else if (gMain.newKeys & DPAD_LEFT) + else if (JOY_NEW(DPAD_LEFT)) { if (gMultiUsePlayerCursor & 1) { @@ -791,7 +791,7 @@ static void HandleMoveSwitching(void) MoveSelectionCreateCursorAt(gMultiUsePlayerCursor, 27); } } - else if (gMain.newKeys & DPAD_RIGHT) + else if (JOY_NEW(DPAD_RIGHT)) { if (!(gMultiUsePlayerCursor & 1) && (gMultiUsePlayerCursor ^ 1) < gNumberOfMovesToChoose) { @@ -809,7 +809,7 @@ static void HandleMoveSwitching(void) MoveSelectionCreateCursorAt(gMultiUsePlayerCursor, 27); } } - else if (gMain.newKeys & DPAD_UP) + else if (JOY_NEW(DPAD_UP)) { if (gMultiUsePlayerCursor & 2) { @@ -827,7 +827,7 @@ static void HandleMoveSwitching(void) MoveSelectionCreateCursorAt(gMultiUsePlayerCursor, 27); } } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { if (!(gMultiUsePlayerCursor & 2) && (gMultiUsePlayerCursor ^ 2) < gNumberOfMovesToChoose) { @@ -1402,21 +1402,21 @@ static void DoHitAnimBlinkSpriteEffect(void) static void PlayerHandleUnknownYesNoInput(void) { - if (gMain.newKeys & DPAD_UP && gMultiUsePlayerCursor != 0) + if (JOY_NEW(DPAD_UP) && gMultiUsePlayerCursor != 0) { PlaySE(SE_SELECT); BattleDestroyYesNoCursorAt(gMultiUsePlayerCursor); gMultiUsePlayerCursor = 0; BattleCreateYesNoCursorAt(0); } - if (gMain.newKeys & DPAD_DOWN && gMultiUsePlayerCursor == 0) + if (JOY_NEW(DPAD_DOWN) && gMultiUsePlayerCursor == 0) { PlaySE(SE_SELECT); BattleDestroyYesNoCursorAt(gMultiUsePlayerCursor); gMultiUsePlayerCursor = 1; BattleCreateYesNoCursorAt(1); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { HandleBattleWindow(0x18, 8, 0x1D, 0xD, WINDOW_CLEAR); PlaySE(SE_SELECT); @@ -1428,7 +1428,7 @@ static void PlayerHandleUnknownYesNoInput(void) PlayerBufferExecCompleted(); } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { HandleBattleWindow(0x18, 8, 0x1D, 0xD, WINDOW_CLEAR); PlaySE(SE_SELECT); diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c index 70e41cf8d..9cb427e12 100644 --- a/src/battle_controller_safari.c +++ b/src/battle_controller_safari.c @@ -170,7 +170,7 @@ static void SafariBufferRunCommand(void) static void HandleInputChooseAction(void) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); @@ -191,7 +191,7 @@ static void HandleInputChooseAction(void) } SafariBufferExecCompleted(); } - else if (gMain.newKeys & DPAD_LEFT) + else if (JOY_NEW(DPAD_LEFT)) { if (gActionSelectionCursor[gActiveBattler] & 1) { @@ -201,7 +201,7 @@ static void HandleInputChooseAction(void) ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); } } - else if (gMain.newKeys & DPAD_RIGHT) + else if (JOY_NEW(DPAD_RIGHT)) { if (!(gActionSelectionCursor[gActiveBattler] & 1)) { @@ -211,7 +211,7 @@ static void HandleInputChooseAction(void) ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); } } - else if (gMain.newKeys & DPAD_UP) + else if (JOY_NEW(DPAD_UP)) { if (gActionSelectionCursor[gActiveBattler] & 2) { @@ -221,7 +221,7 @@ static void HandleInputChooseAction(void) ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); } } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { if (!(gActionSelectionCursor[gActiveBattler] & 2)) { diff --git a/src/battle_dome.c b/src/battle_dome.c index 7b0311661..2f6df5dca 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -4111,7 +4111,7 @@ static u8 Task_GetInfoCardInput(u8 taskId) u8 tourneyId = sTourneyTreeTrainerIds[position]; u16 roundId = gSaveBlock2Ptr->frontier.curChallengeBattleNum; - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) input = INFOCARD_INPUT_AB; // Next opponent card cant scroll @@ -4122,7 +4122,7 @@ static u8 Task_GetInfoCardInput(u8 taskId) { // For trainer info cards, pos is 0 when on a trainer info card (not viewing that trainer's match progression) // Scrolling up/down from a trainer info card goes to other trainer info cards - if (gMain.newKeys & DPAD_UP && sInfoCard->pos == 0) + if (JOY_NEW(DPAD_UP) && sInfoCard->pos == 0) { if (position == 0) position = DOME_TOURNAMENT_TRAINERS_COUNT - 1; @@ -4130,7 +4130,7 @@ static u8 Task_GetInfoCardInput(u8 taskId) position--; input = TRAINERCARD_INPUT_UP; } - else if (gMain.newKeys & DPAD_DOWN && sInfoCard->pos == 0) + else if (JOY_NEW(DPAD_DOWN) && sInfoCard->pos == 0) { if (position == DOME_TOURNAMENT_TRAINERS_COUNT - 1) position = 0; @@ -4139,13 +4139,13 @@ static u8 Task_GetInfoCardInput(u8 taskId) input = TRAINERCARD_INPUT_DOWN; } // Scrolling left can only be done after scrolling right - else if (gMain.newKeys & DPAD_LEFT && sInfoCard->pos != 0) + else if (JOY_NEW(DPAD_LEFT) && sInfoCard->pos != 0) { sInfoCard->pos--; input = TRAINERCARD_INPUT_LEFT; } // Scrolling right from a trainer info card shows their match progression - else if (gMain.newKeys & DPAD_RIGHT) + else if (JOY_NEW(DPAD_RIGHT)) { // Can only scroll right from a trainer card until the round they were eliminated if (DOME_TRAINERS[tourneyId].isEliminated && sInfoCard->pos - 1 < DOME_TRAINERS[tourneyId].eliminatedAt) @@ -4173,7 +4173,7 @@ static u8 Task_GetInfoCardInput(u8 taskId) { // For match info cards, pos is 1 when on the match card, 0 when on the left trainer, and 1 when on the right trainer // Scrolling up/down from a match info card goes to the next/previous match - if (gMain.newKeys & DPAD_UP && sInfoCard->pos == 1) + if (JOY_NEW(DPAD_UP) && sInfoCard->pos == 1) { if (position == DOME_TOURNAMENT_TRAINERS_COUNT) position = sLastMatchCardNum[roundId]; @@ -4181,7 +4181,7 @@ static u8 Task_GetInfoCardInput(u8 taskId) position--; input = MATCHCARD_INPUT_UP; } - else if (gMain.newKeys & DPAD_DOWN && sInfoCard->pos == 1) + else if (JOY_NEW(DPAD_DOWN) && sInfoCard->pos == 1) { if (position == sLastMatchCardNum[roundId]) position = DOME_TOURNAMENT_TRAINERS_COUNT; @@ -4190,12 +4190,12 @@ static u8 Task_GetInfoCardInput(u8 taskId) input = MATCHCARD_INPUT_DOWN; } // Scrolling left/right from a match info card shows the trainer info card of the competitors for that match - else if (gMain.newKeys & DPAD_LEFT && sInfoCard->pos != 0) + else if (JOY_NEW(DPAD_LEFT) && sInfoCard->pos != 0) { input = MATCHCARD_INPUT_LEFT; sInfoCard->pos--; } - else if (gMain.newKeys & DPAD_RIGHT && (sInfoCard->pos == 0 || sInfoCard->pos == 1)) + else if (JOY_NEW(DPAD_RIGHT) && (sInfoCard->pos == 0 || sInfoCard->pos == 1)) { input = MATCHCARD_INPUT_RIGHT; sInfoCard->pos++; @@ -5043,12 +5043,12 @@ static u8 UpdateTourneyTreeCursor(u8 taskId) int tourneyTreeCursorSpriteId = gTasks[taskId].data[1]; int roundId = gSaveBlock2Ptr->frontier.curChallengeBattleNum; - if (gMain.newKeys == B_BUTTON || (gMain.newKeys & A_BUTTON && tourneyTreeCursorSpriteId == TOURNEY_TREE_CLOSE_BUTTON)) + if (gMain.newKeys == B_BUTTON || (JOY_NEW(A_BUTTON) && tourneyTreeCursorSpriteId == TOURNEY_TREE_CLOSE_BUTTON)) { PlaySE(SE_SELECT); selection = TOURNEY_TREE_SELECTED_CLOSE; } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { if (tourneyTreeCursorSpriteId < DOME_TOURNAMENT_TRAINERS_COUNT) { @@ -5552,7 +5552,7 @@ static void Task_HandleStaticTourneyTreeInput(u8 taskId) gTasks[taskId].tState = STATE_WAIT_FOR_INPUT; break; case STATE_WAIT_FOR_INPUT: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gTasks[taskId].tState = STATE_CLOSE_TOURNEY_TREE; diff --git a/src/battle_factory_screen.c b/src/battle_factory_screen.c index 388881a1c..a3fa275c5 100644 --- a/src/battle_factory_screen.c +++ b/src/battle_factory_screen.c @@ -1478,7 +1478,7 @@ static void Task_HandleSelectionScreenYesNo(u8 taskId) gTasks[taskId].data[0] = 5; break; case 5: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (sFactorySelectScreen->yesNoCursorPos == 0) @@ -1496,7 +1496,7 @@ static void Task_HandleSelectionScreenYesNo(u8 taskId) gTasks[taskId].func = Task_HandleSelectionScreenChooseMons; } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sub_819B958(4); @@ -1505,12 +1505,12 @@ static void Task_HandleSelectionScreenYesNo(u8 taskId) gTasks[taskId].data[0] = 1; gTasks[taskId].func = Task_HandleSelectionScreenChooseMons; } - else if (gMain.newAndRepeatedKeys & DPAD_UP) + else if (JOY_REPEAT(DPAD_UP)) { PlaySE(SE_SELECT); Select_UpdateYesNoCursorPosition(-1); } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPEAT(DPAD_DOWN)) { PlaySE(SE_SELECT); Select_UpdateYesNoCursorPosition(1); @@ -1538,7 +1538,7 @@ static void Task_HandleSelectionScreenMenu(u8 taskId) } break; case 3: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { u8 retVal; PlaySE(SE_SELECT); @@ -1565,7 +1565,7 @@ static void Task_HandleSelectionScreenMenu(u8 taskId) gTasks[taskId].func = Task_FromSelectScreenToSummaryScreen; } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sub_819F3F8(sFactorySelectScreen->unk294[1], &sFactorySelectScreen->unk2A0, FALSE); @@ -1574,12 +1574,12 @@ static void Task_HandleSelectionScreenMenu(u8 taskId) gTasks[taskId].data[0] = 1; gTasks[taskId].func = Task_HandleSelectionScreenChooseMons; } - else if (gMain.newAndRepeatedKeys & DPAD_UP) + else if (JOY_REPEAT(DPAD_UP)) { PlaySE(SE_SELECT); Select_UpdateMenuCursorPosition(-1); } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPEAT(DPAD_DOWN)) { PlaySE(SE_SELECT); Select_UpdateMenuCursorPosition(1); @@ -1618,21 +1618,21 @@ static void Task_HandleSelectionScreenChooseMons(u8 taskId) } break; case 1: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); sFactorySelectScreen->unk2A2 = FALSE; gTasks[taskId].data[0] = 2; gTasks[taskId].func = Task_HandleSelectionScreenMenu; } - else if (gMain.newAndRepeatedKeys & DPAD_LEFT) + else if (JOY_REPEAT(DPAD_LEFT)) { PlaySE(SE_SELECT); Select_UpdateBallCursorPosition(-1); Select_PrintMonCategory(); Select_PrintMonSpecies(); } - else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + else if (JOY_REPEAT(DPAD_RIGHT)) { PlaySE(SE_SELECT); Select_UpdateBallCursorPosition(1); @@ -1641,7 +1641,7 @@ static void Task_HandleSelectionScreenChooseMons(u8 taskId) } break; case 11: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); sub_819F3F8(sFactorySelectScreen->unk294[1], &sFactorySelectScreen->unk2A0, FALSE); @@ -2361,7 +2361,7 @@ static void Task_HandleSwapScreenYesNo(u8 taskId) gTasks[taskId].data[0] = 5; break; case 5: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (sFactorySwapScreen->yesNoCursorPos == 0) @@ -2380,7 +2380,7 @@ static void Task_HandleSwapScreenYesNo(u8 taskId) gTasks[taskId].func = (void*)((hiPtr << 16) | loPtr); } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); gTasks[taskId].data[1] = 0; @@ -2389,12 +2389,12 @@ static void Task_HandleSwapScreenYesNo(u8 taskId) loPtr = gTasks[taskId].data[7]; gTasks[taskId].func = (void*)((hiPtr << 16) | loPtr); } - else if (gMain.newAndRepeatedKeys & DPAD_UP) + else if (JOY_REPEAT(DPAD_UP)) { PlaySE(SE_SELECT); Swap_UpdateYesNoCursorPosition(-1); } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPEAT(DPAD_DOWN)) { PlaySE(SE_SELECT); Swap_UpdateYesNoCursorPosition(1); @@ -2485,12 +2485,12 @@ static void Task_HandleSwapScreenMenu(u8 taskId) case 3: if (sFactorySwapScreen->unk30 != TRUE) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); Swap_RunMenuOptionFunc(taskId); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sub_819F3F8(sFactorySwapScreen->unk2C, &sFactorySwapScreen->unk30, TRUE); @@ -2501,11 +2501,11 @@ static void Task_HandleSwapScreenMenu(u8 taskId) gTasks[taskId].data[5] = 1; gTasks[taskId].func = sub_819D770; } - else if (gMain.newAndRepeatedKeys & DPAD_UP) + else if (JOY_REPEAT(DPAD_UP)) { Swap_UpdateMenuCursorPosition(-1); } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPEAT(DPAD_DOWN)) { Swap_UpdateMenuCursorPosition(1); } @@ -2526,7 +2526,7 @@ static void Task_HandleSwapScreenChooseMons(u8 taskId) } break; case 1: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); sFactorySwapScreen->unk22 = FALSE; @@ -2534,7 +2534,7 @@ static void Task_HandleSwapScreenChooseMons(u8 taskId) sub_819EAC0(); Swap_RunActionFunc(taskId); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sFactorySwapScreen->unk22 = FALSE; @@ -2546,25 +2546,25 @@ static void Task_HandleSwapScreenChooseMons(u8 taskId) gTasks[taskId].data[5] = 0; gTasks[taskId].func = sub_819D588; } - else if (gMain.newAndRepeatedKeys & DPAD_LEFT) + else if (JOY_REPEAT(DPAD_LEFT)) { Swap_UpdateBallCursorPosition(-1); Swap_PrintMonCategory(); Swap_PrintMonSpecies(); } - else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + else if (JOY_REPEAT(DPAD_RIGHT)) { Swap_UpdateBallCursorPosition(1); Swap_PrintMonCategory(); Swap_PrintMonSpecies(); } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPEAT(DPAD_DOWN)) { Swap_UpdateActionCursorPosition(1); Swap_PrintMonCategory(); Swap_PrintMonSpecies(); } - else if (gMain.newAndRepeatedKeys & DPAD_UP) + else if (JOY_REPEAT(DPAD_UP)) { Swap_UpdateActionCursorPosition(-1); Swap_PrintMonCategory(); @@ -3929,7 +3929,7 @@ static void Task_SwapCantHaveSameMons(u8 taskId) gTasks[taskId].data[0]++; break; case 1: - if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sub_819F3F8(sFactorySwapScreen->unk2C, &sFactorySwapScreen->unk30, TRUE); diff --git a/src/battle_main.c b/src/battle_main.c index 2c3df2e34..193fffaf2 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -1854,7 +1854,7 @@ void BattleMainCB2(void) UpdatePaletteFade(); RunTasks(); - if (gMain.heldKeys & B_BUTTON && gBattleTypeFlags & BATTLE_TYPE_RECORDED && sub_8186450()) + if (JOY_HELD(B_BUTTON) && gBattleTypeFlags & BATTLE_TYPE_RECORDED && sub_8186450()) { gSpecialVar_Result = gBattleOutcome = B_OUTCOME_PLAYER_TELEPORTED; ResetPaletteFadeControl(); @@ -2510,7 +2510,7 @@ static void sub_803939C(void) } break; case 5: - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { if (gBattleCommunication[CURSOR_POSITION] != 0) { @@ -2520,7 +2520,7 @@ static void sub_803939C(void) BattleCreateYesNoCursorAt(0); } } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { if (gBattleCommunication[CURSOR_POSITION] == 0) { @@ -2530,7 +2530,7 @@ static void sub_803939C(void) BattleCreateYesNoCursorAt(1); } } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (gBattleCommunication[CURSOR_POSITION] == 0) @@ -2544,7 +2544,7 @@ static void sub_803939C(void) gBattleCommunication[MULTIUSE_STATE]++; } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); gBattleCommunication[MULTIUSE_STATE]++; diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c index e038e71e1..8fee57855 100644 --- a/src/battle_pyramid_bag.c +++ b/src/battle_pyramid_bag.c @@ -839,7 +839,7 @@ static void Task_HandlePyramidBagInput(u8 taskId) s16 *data = gTasks[taskId].data; if (MenuHelpers_CallLinkSomething() != TRUE && !gPaletteFade.active) { - if (gMain.newKeys & SELECT_BUTTON) + if (JOY_NEW(SELECT_BUTTON)) { if (gPyramidBagCursorData.unk4 != 2) { @@ -965,7 +965,7 @@ static void HandleMenuActionInput(u8 taskId) if (MenuHelpers_CallLinkSomething() != TRUE) { s8 id = Menu_GetCursorPos(); - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { if (id > 0 && IsValidMenuAction(id - 2)) { @@ -973,7 +973,7 @@ static void HandleMenuActionInput(u8 taskId) ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP); } } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { if (id < gPyramidBagResources->menuActionsCount - 2 && IsValidMenuAction(id + 2)) { @@ -981,7 +981,7 @@ static void HandleMenuActionInput(u8 taskId) ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN); } } - else if (gMain.newKeys & DPAD_LEFT || GetLRKeysPressed() == MENU_L_PRESSED) + else if (JOY_NEW(DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED) { if (id & 1 && IsValidMenuAction(id - 1)) { @@ -989,7 +989,7 @@ static void HandleMenuActionInput(u8 taskId) ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE); } } - else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysPressed() == MENU_R_PRESSED) + else if (JOY_NEW(DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED) { if (!(id & 1) && IsValidMenuAction(id + 1)) { @@ -997,13 +997,13 @@ static void HandleMenuActionInput(u8 taskId) ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE); } } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (sMenuActions[gPyramidBagResources->menuActionIds[id]].func.void_u8 != NULL) sMenuActions[gPyramidBagResources->menuActionIds[id]].func.void_u8(taskId); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sMenuActions[ACTION_CANCEL].func.void_u8(taskId); @@ -1143,7 +1143,7 @@ static void sub_81C64B4(u8 taskId) { sub_81C645C(data[8]); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); ClearStdWindowAndFrameToTransparent(3, 0); @@ -1151,7 +1151,7 @@ static void sub_81C64B4(u8 taskId) ScheduleBgCopyTilemapToVram(1); sub_81C6350(taskId); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); ClearStdWindowAndFrameToTransparent(3, 0); @@ -1179,7 +1179,7 @@ static void sub_81C65CC(u8 taskId) u16 *scrollOffset = &gPyramidBagCursorData.scrollPosition; u16 *selectedRow = &gPyramidBagCursorData.cursorPosition; - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { PlaySE(SE_SELECT); RemovePyramidBagItem(gSpecialVar_ItemId, data[8]); @@ -1220,7 +1220,7 @@ static void sub_81C66AC(u8 taskId) static void sub_81C66EC(u8 taskId) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); Task_CloseBattlePyramidBagMessage(taskId); @@ -1277,7 +1277,7 @@ static void Task_ItemSwapHandleInput(u8 taskId) s16 *data = gTasks[taskId].data; if (MenuHelpers_CallLinkSomething() != TRUE) { - if (gMain.newKeys & SELECT_BUTTON) + if (JOY_NEW(SELECT_BUTTON)) { PlaySE(SE_SELECT); ListMenuGetScrollAndRow(data[0], &gPyramidBagCursorData.scrollPosition, &gPyramidBagCursorData.cursorPosition); @@ -1295,7 +1295,7 @@ static void Task_ItemSwapHandleInput(u8 taskId) break; case LIST_CANCEL: PlaySE(SE_SELECT); - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) PerformItemSwap(taskId); else sub_81C6A14(taskId); diff --git a/src/battle_records.c b/src/battle_records.c index 680733527..a8b9ead14 100644 --- a/src/battle_records.c +++ b/src/battle_records.c @@ -356,7 +356,7 @@ static void Task_CloseTrainerHillRecordsOnButton(u8 taskId) { struct Task *task = &gTasks[taskId]; - if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); task->func = Task_BeginPaletteFade; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 9ff5e8fc6..7ded6fcd8 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -5360,21 +5360,21 @@ static void Cmd_yesnoboxlearnmove(void) BattleCreateYesNoCursorAt(0); break; case 1: - if (gMain.newKeys & DPAD_UP && gBattleCommunication[CURSOR_POSITION] != 0) + if (JOY_NEW(DPAD_UP) && gBattleCommunication[CURSOR_POSITION] != 0) { PlaySE(SE_SELECT); BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]); gBattleCommunication[CURSOR_POSITION] = 0; BattleCreateYesNoCursorAt(0); } - if (gMain.newKeys & DPAD_DOWN && gBattleCommunication[CURSOR_POSITION] == 0) + if (JOY_NEW(DPAD_DOWN) && gBattleCommunication[CURSOR_POSITION] == 0) { PlaySE(SE_SELECT); BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]); gBattleCommunication[CURSOR_POSITION] = 1; BattleCreateYesNoCursorAt(1); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (gBattleCommunication[1] == 0) @@ -5388,7 +5388,7 @@ static void Cmd_yesnoboxlearnmove(void) gBattleScripting.learnMoveState = 5; } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); gBattleScripting.learnMoveState = 5; @@ -5477,21 +5477,21 @@ static void Cmd_yesnoboxstoplearningmove(void) BattleCreateYesNoCursorAt(0); break; case 1: - if (gMain.newKeys & DPAD_UP && gBattleCommunication[CURSOR_POSITION] != 0) + if (JOY_NEW(DPAD_UP) && gBattleCommunication[CURSOR_POSITION] != 0) { PlaySE(SE_SELECT); BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]); gBattleCommunication[CURSOR_POSITION] = 0; BattleCreateYesNoCursorAt(0); } - if (gMain.newKeys & DPAD_DOWN && gBattleCommunication[CURSOR_POSITION] == 0) + if (JOY_NEW(DPAD_DOWN) && gBattleCommunication[CURSOR_POSITION] == 0) { PlaySE(SE_SELECT); BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]); gBattleCommunication[CURSOR_POSITION] = 1; BattleCreateYesNoCursorAt(1); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); @@ -5502,7 +5502,7 @@ static void Cmd_yesnoboxstoplearningmove(void) HandleBattleWindow(0x18, 0x8, 0x1D, 0xD, WINDOW_CLEAR); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); @@ -5772,28 +5772,28 @@ static void Cmd_yesnobox(void) BattleCreateYesNoCursorAt(0); break; case 1: - if (gMain.newKeys & DPAD_UP && gBattleCommunication[CURSOR_POSITION] != 0) + if (JOY_NEW(DPAD_UP) && gBattleCommunication[CURSOR_POSITION] != 0) { PlaySE(SE_SELECT); BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]); gBattleCommunication[CURSOR_POSITION] = 0; BattleCreateYesNoCursorAt(0); } - if (gMain.newKeys & DPAD_DOWN && gBattleCommunication[CURSOR_POSITION] == 0) + if (JOY_NEW(DPAD_DOWN) && gBattleCommunication[CURSOR_POSITION] == 0) { PlaySE(SE_SELECT); BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]); gBattleCommunication[CURSOR_POSITION] = 1; BattleCreateYesNoCursorAt(1); } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { gBattleCommunication[CURSOR_POSITION] = 1; PlaySE(SE_SELECT); HandleBattleWindow(0x18, 8, 0x1D, 0xD, WINDOW_CLEAR); gBattlescriptCurrInstr++; } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); HandleBattleWindow(0x18, 8, 0x1D, 0xD, WINDOW_CLEAR); @@ -10076,21 +10076,21 @@ static void Cmd_trygivecaughtmonnick(void) BattleCreateYesNoCursorAt(0); break; case 1: - if (gMain.newKeys & DPAD_UP && gBattleCommunication[CURSOR_POSITION] != 0) + if (JOY_NEW(DPAD_UP) && gBattleCommunication[CURSOR_POSITION] != 0) { PlaySE(SE_SELECT); BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]); gBattleCommunication[CURSOR_POSITION] = 0; BattleCreateYesNoCursorAt(0); } - if (gMain.newKeys & DPAD_DOWN && gBattleCommunication[CURSOR_POSITION] == 0) + if (JOY_NEW(DPAD_DOWN) && gBattleCommunication[CURSOR_POSITION] == 0) { PlaySE(SE_SELECT); BattleDestroyYesNoCursorAt(gBattleCommunication[CURSOR_POSITION]); gBattleCommunication[CURSOR_POSITION] = 1; BattleCreateYesNoCursorAt(1); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (gBattleCommunication[CURSOR_POSITION] == 0) @@ -10103,7 +10103,7 @@ static void Cmd_trygivecaughtmonnick(void) gBattleCommunication[MULTIUSE_STATE] = 4; } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); gBattleCommunication[MULTIUSE_STATE] = 4; diff --git a/src/berry_crush.c b/src/berry_crush.c index d753e603c..dbbbd20fc 100755 --- a/src/berry_crush.c +++ b/src/berry_crush.c @@ -1665,7 +1665,7 @@ static void Task_ShowBerryCrushRankings(u8 taskId) CopyWindowToVram(data[1], 3); break; case 2: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) break; else return; @@ -2498,9 +2498,9 @@ void sub_8023558(struct BerryCrushGame *r3) void sub_80236B8(struct BerryCrushGame *r5) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) r5->unk5C.unk02_2 = 1; - if (gMain.heldKeys & A_BUTTON) + if (JOY_HELD(A_BUTTON)) { if (r5->unk68.as_four_players.others[r5->unk8].unk4.as_hwords[5] < r5->unk28) ++r5->unk68.as_four_players.others[r5->unk8].unk4.as_hwords[5]; @@ -2966,7 +2966,7 @@ static u32 sub_8024048(struct BerryCrushGame *r5, u8 *r6) --r5->unk138.unk0; return 0; } - if (!(gMain.newKeys & A_BUTTON)) + if (!(JOY_NEW(A_BUTTON))) return 0; PlaySE(SE_SELECT); sub_802222C(r5); diff --git a/src/berry_fix_program.c b/src/berry_fix_program.c index dcc21d036..4c4a010b2 100644 --- a/src/berry_fix_program.c +++ b/src/berry_fix_program.c @@ -190,13 +190,13 @@ static void berry_fix_main(void) berry_fix_mb_manager->state = 1; break; case 1: - if (berry_fix_text_update(5) == 5 && (gMain.newKeys & A_BUTTON)) + if (berry_fix_text_update(5) == 5 && (JOY_NEW(A_BUTTON))) { berry_fix_mb_manager->state = 2; } break; case 2: - if (berry_fix_text_update(0) == 0 && (gMain.newKeys & A_BUTTON)) + if (berry_fix_text_update(0) == 0 && (JOY_NEW(A_BUTTON))) { berry_fix_mb_manager->state = 3; } @@ -235,13 +235,13 @@ static void berry_fix_main(void) } break; case 6: - if (berry_fix_text_update(3) == 3 && gMain.newKeys & A_BUTTON) + if (berry_fix_text_update(3) == 3 && JOY_NEW(A_BUTTON)) { DoSoftReset(); } break; case 7: - if (berry_fix_text_update(4) == 4 && gMain.newKeys & A_BUTTON) + if (berry_fix_text_update(4) == 4 && JOY_NEW(A_BUTTON)) { berry_fix_mb_manager->state = 1; } diff --git a/src/berry_tag_screen.c b/src/berry_tag_screen.c index e5c89bdb7..089228b17 100644 --- a/src/berry_tag_screen.c +++ b/src/berry_tag_screen.c @@ -536,12 +536,12 @@ static void Task_HandleInput(u8 taskId) { if (!gPaletteFade.active) { - u16 arrowKeys = gMain.newAndRepeatedKeys & DPAD_ANY; + u16 arrowKeys = JOY_REPEAT(DPAD_ANY); if (arrowKeys == DPAD_UP) TryChangeDisplayedBerry(taskId, -1); else if (arrowKeys == DPAD_DOWN) TryChangeDisplayedBerry(taskId, 1); - else if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + else if (JOY_NEW(A_BUTTON | B_BUTTON)) PrepareToCloseBerryTagScreen(taskId); } } diff --git a/src/cable_club.c b/src/cable_club.c index 93f87ec9b..f02683c9d 100644 --- a/src/cable_club.c +++ b/src/cable_club.c @@ -163,7 +163,7 @@ static bool32 CheckLinkErrored(u8 taskId) static bool32 CheckLinkCanceledBeforeConnection(u8 taskId) { - if ((gMain.newKeys & B_BUTTON) + if ((JOY_NEW(B_BUTTON)) && IsLinkConnectionEstablished() == FALSE) { gLinkType = 0; @@ -178,7 +178,7 @@ static bool32 CheckLinkCanceled(u8 taskId) if (IsLinkConnectionEstablished()) SetSuppressLinkErrorMessage(TRUE); - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { gLinkType = 0; gTasks[taskId].func = Task_LinkupFailed; @@ -277,7 +277,7 @@ static void Task_LinkupAwaitConfirmation(u8 taskId) UpdateLinkPlayerCountDisplay(taskId, linkPlayerCount); - if (!(gMain.newKeys & A_BUTTON)) + if (!(JOY_NEW(A_BUTTON))) return; if (linkPlayerCount < tMinPlayers) @@ -304,12 +304,12 @@ static void Task_LinkupTryConfirmation(u8 taskId) ShowFieldAutoScrollMessage(gText_ConfirmLinkWhenPlayersReady); gTasks[taskId].func = Task_LinkupConfirmWhenReady; } - else if (gMain.heldKeys & B_BUTTON) + else if (JOY_HELD(B_BUTTON)) { ShowFieldAutoScrollMessage(gText_ConfirmLinkWhenPlayersReady); gTasks[taskId].func = Task_LinkupConfirmWhenReady; } - else if (gMain.heldKeys & A_BUTTON) + else if (JOY_HELD(A_BUTTON)) { PlaySE(SE_SELECT); CheckShouldAdvanceLinkState(); diff --git a/src/contest.c b/src/contest.c index a2f5b6f99..612d79562 100644 --- a/src/contest.c +++ b/src/contest.c @@ -1493,7 +1493,7 @@ static void Task_DisplayAppealNumberText(u8 taskId) static void Task_TryShowMoveSelectScreen(u8 taskId) { // Wait for button press to show move select screen - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys == B_BUTTON)) + if ((JOY_NEW(A_BUTTON)) || (gMain.newKeys == B_BUTTON)) { PlaySE(SE_SELECT); if (!Contest_IsMonsTurnDisabled(gContestPlayerMonIndex)) @@ -1559,7 +1559,7 @@ static void Task_HandleMoveSelectInput(u8 taskId) numMoves++; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); gTasks[taskId].func = Task_SelectedMove; diff --git a/src/contest_painting.c b/src/contest_painting.c index a0c39dfc7..292b11bf4 100644 --- a/src/contest_painting.c +++ b/src/contest_painting.c @@ -248,7 +248,7 @@ static void HoldContestPainting(void) gContestPaintingFadeCounter--; break; case 1: - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))) { gContestPaintingState++; BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); diff --git a/src/credits.c b/src/credits.c index 5f331097b..86a659d5a 100644 --- a/src/credits.c +++ b/src/credits.c @@ -1143,7 +1143,7 @@ static void CB2_RunCreditsSequence(void) RunTasks(); AnimateSprites(); - if ((gMain.heldKeys & B_BUTTON) + if ((JOY_HELD(B_BUTTON)) && gHasHallOfFameRecords != 0 && gTasks[gUnknown_0203BCE2].func == Task_ProgressCreditTasks) { diff --git a/src/daycare.c b/src/daycare.c index b87c326e9..69043a513 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -1237,7 +1237,7 @@ static void Task_HandleDaycareLevelMenuInput(u8 taskId) { u32 input = ListMenu_ProcessInput(gTasks[taskId].tMenuListTaskId); - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { switch (input) { @@ -1255,7 +1255,7 @@ static void Task_HandleDaycareLevelMenuInput(u8 taskId) DestroyTask(taskId); EnableBothScriptContexts(); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { gSpecialVar_Result = DAYCARE_EXITED_LEVEL_MENU; DestroyListMenuTask(gTasks[taskId].tMenuListTaskId, NULL, NULL); diff --git a/src/decoration.c b/src/decoration.c index 40cccbe5e..22ae327f9 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -1147,7 +1147,7 @@ static void DontTossDecoration(u8 taskId) static void ReturnToDecorationItemsAfterInvalidSelection(u8 taskId) { - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { ClearDialogWindowAndFrame(0, 0); AddDecorationWindow(WINDOW_DECORATION_CATEGORIES); @@ -1803,7 +1803,7 @@ static bool8 ApplyCursorMovement_IsInvalid(u8 taskId) static bool8 IsHoldingDirection(void) { - u16 heldKeys = gMain.heldKeys & DPAD_ANY; + u16 heldKeys = JOY_HELD(DPAD_ANY); if (heldKeys != DPAD_UP && heldKeys != DPAD_DOWN && heldKeys != DPAD_LEFT && heldKeys != DPAD_RIGHT) return FALSE; @@ -1827,13 +1827,14 @@ static void Task_SelectLocation(u8 taskId) sPlacePutAwayYesNoFunctions[tDecorationItemsMenuCommand].yesFunc(taskId); return; } - else if (tButton == B_BUTTON) + + if (tButton == B_BUTTON) { sPlacePutAwayYesNoFunctions[tDecorationItemsMenuCommand].noFunc(taskId); return; } - if ((gMain.heldKeys & DPAD_ANY) == DPAD_UP) + if ((JOY_HELD(DPAD_ANY)) == DPAD_UP) { sDecorationLastDirectionMoved = DIR_SOUTH; gSprites[sDecor_CameraSpriteObjectIdx1].data[2] = 0; @@ -1841,7 +1842,7 @@ static void Task_SelectLocation(u8 taskId) tCursorY--; } - if ((gMain.heldKeys & DPAD_ANY) == DPAD_DOWN) + if ((JOY_HELD(DPAD_ANY)) == DPAD_DOWN) { sDecorationLastDirectionMoved = DIR_NORTH; gSprites[sDecor_CameraSpriteObjectIdx1].data[2] = 0; @@ -1849,7 +1850,7 @@ static void Task_SelectLocation(u8 taskId) tCursorY++; } - if ((gMain.heldKeys & DPAD_ANY) == DPAD_LEFT) + if ((JOY_HELD(DPAD_ANY)) == DPAD_LEFT) { sDecorationLastDirectionMoved = DIR_WEST; gSprites[sDecor_CameraSpriteObjectIdx1].data[2] = -2; @@ -1857,7 +1858,7 @@ static void Task_SelectLocation(u8 taskId) tCursorX--; } - if ((gMain.heldKeys & DPAD_ANY) == DPAD_RIGHT) + if ((JOY_HELD(DPAD_ANY)) == DPAD_RIGHT) { sDecorationLastDirectionMoved = DIR_EAST; gSprites[sDecor_CameraSpriteObjectIdx1].data[2] = 2; @@ -1877,10 +1878,10 @@ static void Task_SelectLocation(u8 taskId) if (!tButton) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) tButton = A_BUTTON; - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) tButton = B_BUTTON; } } @@ -1895,7 +1896,7 @@ static void ContinueDecorating(u8 taskId) static void CantPlaceDecorationPrompt(u8 taskId) { - if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) ContinueDecorating(taskId); } @@ -1928,7 +1929,7 @@ static void CopyTile(u8 *dest, u16 tile) case BG_TILE_H_FLIP(0) >> 10: for (i = 0; i < 8; i++) { - dest[4 * i] = (buffer[4 * (i + 1) - 1] >> 4) + ((buffer[4 * (i + 1) - 1] & 0x0F) << 4); + dest[4 * i + 0] = (buffer[4 * (i + 1) - 1] >> 4) + ((buffer[4 * (i + 1) - 1] & 0x0F) << 4); dest[4 * i + 1] = (buffer[4 * (i + 1) - 2] >> 4) + ((buffer[4 * (i + 1) - 2] & 0x0F) << 4); dest[4 * i + 2] = (buffer[4 * (i + 1) - 3] >> 4) + ((buffer[4 * (i + 1) - 3] & 0x0F) << 4); dest[4 * i + 3] = (buffer[4 * (i + 1) - 4] >> 4) + ((buffer[4 * (i + 1) - 4] & 0x0F) << 4); @@ -1937,7 +1938,7 @@ static void CopyTile(u8 *dest, u16 tile) case BG_TILE_V_FLIP(0) >> 10: for (i = 0; i < 8; i++) { - dest[4 * i] = buffer[4 * (7 - i)]; + dest[4 * i + 0] = buffer[4 * (7 - i) + 0]; dest[4 * i + 1] = buffer[4 * (7 - i) + 1]; dest[4 * i + 2] = buffer[4 * (7 - i) + 2]; dest[4 * i + 3] = buffer[4 * (7 - i) + 3]; @@ -2386,7 +2387,7 @@ static void AttemptPutAwayDecoration_(u8 taskId) static void ContinuePuttingAwayDecorationsPrompt(u8 taskId) { - if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) ContinuePuttingAwayDecorations(taskId); } diff --git a/src/diploma.c b/src/diploma.c index 7eb3b0e81..f243d09f9 100644 --- a/src/diploma.c +++ b/src/diploma.c @@ -107,7 +107,7 @@ static void Task_DiplomaFadeIn(u8 taskId) static void Task_DiplomaWaitForKeyPress(u8 taskId) { - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); gTasks[taskId].func = Task_DiplomaFadeOut; diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index 34f73126b..9cbc73c73 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -2355,19 +2355,19 @@ static void sub_8027554(void) { if (gUnknown_02022C98->unkB0[gUnknown_02022C98->multiplayerId] == 0) { - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { gUnknown_02022C98->unk31A0[gUnknown_02022C98->multiplayerId].unk2C.unk0 = 2; gUnknown_02022C98->unkB0[gUnknown_02022C98->multiplayerId] = 6; PlaySE(SE_M_CHARM); } - else if (gMain.newKeys & DPAD_LEFT) + else if (JOY_NEW(DPAD_LEFT)) { gUnknown_02022C98->unk31A0[gUnknown_02022C98->multiplayerId].unk2C.unk0 = 3; gUnknown_02022C98->unkB0[gUnknown_02022C98->multiplayerId] = 6; PlaySE(SE_M_CHARM); } - else if (gMain.newKeys & DPAD_RIGHT) + else if (JOY_NEW(DPAD_RIGHT)) { gUnknown_02022C98->unk31A0[gUnknown_02022C98->multiplayerId].unk2C.unk0 = 1; gUnknown_02022C98->unkB0[gUnknown_02022C98->multiplayerId] = 6; @@ -2653,7 +2653,7 @@ static void Task_ShowDodrioBerryPickingRecords(u8 taskId) data[0]++; break; case 2: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { rbox_fill_rectangle(data[1]); CopyWindowToVram(data[1], 1); @@ -4266,7 +4266,7 @@ static void sub_802988C(void) gUnknown_02022CF8->state++; break; case 4: - if (++gUnknown_02022CF8->unk301C >= 30 && gMain.newKeys & A_BUTTON) + if (++gUnknown_02022CF8->unk301C >= 30 && JOY_NEW(A_BUTTON)) { gUnknown_02022CF8->unk301C = 0; PlaySE(SE_SELECT); @@ -4298,7 +4298,7 @@ static void sub_802988C(void) gUnknown_02022CF8->state++; break; case 8: - if (++gUnknown_02022CF8->unk301C >= 30 && gMain.newKeys & A_BUTTON) + if (++gUnknown_02022CF8->unk301C >= 30 && JOY_NEW(A_BUTTON)) { gUnknown_02022CF8->unk301C = 0; PlaySE(SE_SELECT); @@ -4358,7 +4358,7 @@ static void sub_802988C(void) gUnknown_02022CF8->state++; break; case 11: - if (++gUnknown_02022CF8->unk301C >= 30 && gMain.newKeys & A_BUTTON) + if (++gUnknown_02022CF8->unk301C >= 30 && JOY_NEW(A_BUTTON)) { gUnknown_02022CF8->unk301C = 0; PlaySE(SE_SELECT); @@ -4424,14 +4424,14 @@ static void sub_802A010(void) AddTextPrinterParameterized(gUnknown_02022CF8->unk3008[1], 1, gText_SelectorArrow2, 0, ((y - 1) * 16) + 1, -1, NULL); CopyWindowToVram(gUnknown_02022CF8->unk3008[1], 3); // Increment state only if A or B button have been pressed. - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (gUnknown_02022CF8->unk3020 == 0) gUnknown_02022CF8->unk3020 = 1; gUnknown_02022CF8->state++; } - else if (gMain.newKeys & (DPAD_UP | DPAD_DOWN)) + else if (JOY_NEW(DPAD_UP | DPAD_DOWN)) { PlaySE(SE_SELECT); switch (gUnknown_02022CF8->unk3020) @@ -4447,7 +4447,7 @@ static void sub_802A010(void) break; } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); gUnknown_02022CF8->unk3020 = 2; diff --git a/src/easy_chat.c b/src/easy_chat.c index 8e1044591..0ec4d32fd 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -1523,7 +1523,7 @@ static u16 sub_811AB68(void) { do { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { sub_811BF78(); sEasyChatScreen->state = 2; @@ -1532,30 +1532,30 @@ static u16 sub_811AB68(void) sEasyChatScreen->unk_0c = 0; return 9; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { return sub_811B150(); } - else if (gMain.newKeys & START_BUTTON) + else if (JOY_NEW(START_BUTTON)) { return sub_811B1B4(); } - else if (gMain.newKeys & DPAD_UP) + else if (JOY_NEW(DPAD_UP)) { sEasyChatScreen->mainCursorRow--; break; } - else if (gMain.newKeys & DPAD_LEFT) + else if (JOY_NEW(DPAD_LEFT)) { sEasyChatScreen->mainCursorColumn--; break; } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { sEasyChatScreen->mainCursorRow++; break; } - else if (gMain.newKeys & DPAD_RIGHT) + else if (JOY_NEW(DPAD_RIGHT)) { sEasyChatScreen->mainCursorColumn++; break; @@ -1595,7 +1595,7 @@ static u16 sub_811ACDC(void) { do { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { switch (sEasyChatScreen->mainCursorColumn) { @@ -1610,30 +1610,30 @@ static u16 sub_811ACDC(void) } } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { return sub_811B150(); } - else if (gMain.newKeys & START_BUTTON) + else if (JOY_NEW(START_BUTTON)) { return sub_811B1B4(); } - else if (gMain.newKeys & DPAD_UP) + else if (JOY_NEW(DPAD_UP)) { sEasyChatScreen->mainCursorRow--; break; } - else if (gMain.newKeys & DPAD_LEFT) + else if (JOY_NEW(DPAD_LEFT)) { sEasyChatScreen->mainCursorColumn--; break; } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { sEasyChatScreen->mainCursorRow = 0; break; } - else if (gMain.newKeys & DPAD_RIGHT) + else if (JOY_NEW(DPAD_RIGHT)) { sEasyChatScreen->mainCursorColumn++; break; @@ -1666,10 +1666,10 @@ static u16 sub_811ACDC(void) static u16 sub_811AE44(void) { - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) return sub_811B32C(); - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (sEasyChatScreen->unk_0a != -1) return sub_811B2B0(); @@ -1685,19 +1685,19 @@ static u16 sub_811AE44(void) } } - if (gMain.newKeys & SELECT_BUTTON) + if (JOY_NEW(SELECT_BUTTON)) return sub_811B33C(); - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPEAT(DPAD_UP)) return sub_811B528(2); - if (gMain.newAndRepeatedKeys & DPAD_DOWN) + if (JOY_REPEAT(DPAD_DOWN)) return sub_811B528(3); - if (gMain.newAndRepeatedKeys & DPAD_LEFT) + if (JOY_REPEAT(DPAD_LEFT)) return sub_811B528(1); - if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + if (JOY_REPEAT(DPAD_RIGHT)) return sub_811B528(0); return 0; @@ -1705,31 +1705,31 @@ static u16 sub_811AE44(void) static u16 sub_811AF00(void) { - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { sEasyChatScreen->state = 2; return 14; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) return sub_811B394(); - if (gMain.newKeys & START_BUTTON) + if (JOY_NEW(START_BUTTON)) return sub_811B794(4); - if (gMain.newKeys & SELECT_BUTTON) + if (JOY_NEW(SELECT_BUTTON)) return sub_811B794(5); - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPEAT(DPAD_UP)) return sub_811B794(2); - if (gMain.newAndRepeatedKeys & DPAD_DOWN) + if (JOY_REPEAT(DPAD_DOWN)) return sub_811B794(3); - if (gMain.newAndRepeatedKeys & DPAD_LEFT) + if (JOY_REPEAT(DPAD_LEFT)) return sub_811B794(1); - if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + if (JOY_REPEAT(DPAD_RIGHT)) return sub_811B794(0); return 0; @@ -1794,10 +1794,10 @@ static u16 sub_811B040(void) static u16 sub_811B08C(void) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) return 26; - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) return sub_811B150(); return 0; @@ -1805,7 +1805,7 @@ static u16 sub_811B08C(void) static u16 sub_811B0BC(void) { - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { sEasyChatScreen->state = sub_811B2A4(); return 7; diff --git a/src/ereader_screen.c b/src/ereader_screen.c index b4a9164b3..3f2cf3217 100755 --- a/src/ereader_screen.c +++ b/src/ereader_screen.c @@ -137,7 +137,7 @@ static u32 sub_81D4EE4(u8 *arg0, u16 *arg1) { *arg0 = 1; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { *arg0 = 0; return 1; @@ -158,7 +158,7 @@ static u32 sub_81D4EE4(u8 *arg0, u16 *arg1) *arg1 = 0; *arg0 = 3; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { *arg0 = 0; return 1; @@ -288,7 +288,7 @@ static void sub_81D5084(u8 taskId) OpenEReaderLink(); data->unk8 = 6; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { sub_81D505C(&data->unk0); PlaySE(SE_SELECT); @@ -296,7 +296,7 @@ static void sub_81D5084(u8 taskId) } break; case 6: - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); CloseLink(); @@ -436,7 +436,7 @@ static void sub_81D5084(u8 taskId) } break; case 19: - if (IsFanfareTaskInactive() && (gMain.newKeys & (A_BUTTON | B_BUTTON))) + if (IsFanfareTaskInactive() && (JOY_NEW(A_BUTTON | B_BUTTON))) data->unk8 = 26; break; case 23: diff --git a/src/evolution_scene.c b/src/evolution_scene.c index 41d4900f7..61065367c 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -859,21 +859,21 @@ static void Task_EvolutionScene(u8 taskID) } break; case 4: - if (gMain.newKeys & DPAD_UP && sEvoCursorPos != 0) + if (JOY_NEW(DPAD_UP) && sEvoCursorPos != 0) { PlaySE(SE_SELECT); BattleDestroyYesNoCursorAt(sEvoCursorPos); sEvoCursorPos = 0; BattleCreateYesNoCursorAt(0); } - if (gMain.newKeys & DPAD_DOWN && sEvoCursorPos == 0) + if (JOY_NEW(DPAD_DOWN) && sEvoCursorPos == 0) { PlaySE(SE_SELECT); BattleDestroyYesNoCursorAt(sEvoCursorPos); sEvoCursorPos = 1; BattleCreateYesNoCursorAt(1); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { HandleBattleWindow(0x18, 8, 0x1D, 0xD, WINDOW_CLEAR); PlaySE(SE_SELECT); @@ -889,7 +889,7 @@ static void Task_EvolutionScene(u8 taskID) BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); } } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { HandleBattleWindow(0x18, 8, 0x1D, 0xD, WINDOW_CLEAR); PlaySE(SE_SELECT); diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 5fab2489b..e907af5b9 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -1789,7 +1789,7 @@ static bool8 Fishing_ShowDots(struct Task *task) AlignFishingAnimationFrames(); task->tFrameCounter++; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { task->tStep = FISHING_NO_BITE; if (task->tRoundsPlayed != 0) @@ -1878,7 +1878,7 @@ static bool8 Fishing_WaitForA(struct Task *task) task->tFrameCounter++; if (task->tFrameCounter >= reelTimeouts[task->tFishingRod]) task->tStep = FISHING_GOT_AWAY; - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) task->tStep++; return FALSE; } diff --git a/src/field_special_scene.c b/src/field_special_scene.c index bd6c833af..6b41c5423 100644 --- a/src/field_special_scene.c +++ b/src/field_special_scene.c @@ -280,7 +280,7 @@ void Task_HandlePorthole(u8 taskId) } break; case IDLE_CHECK: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) data[1] = 1; if (!ScriptMovement_IsObjectMovementFinished(OBJ_EVENT_ID_PLAYER, location->mapNum, location->mapGroup)) return; diff --git a/src/frontier_pass.c b/src/frontier_pass.c index 702f6c098..1178cdbb4 100644 --- a/src/frontier_pass.c +++ b/src/frontier_pass.c @@ -937,14 +937,14 @@ static void Task_HandleFrontierPassInput(u8 taskId) { u8 var = FALSE; // Reused, first informs whether the cursor moves, then used as the new cursor area. - if (gMain.heldKeys & DPAD_UP && sPassGfx->cursorSprite->pos1.y >= 9) + if (JOY_HELD(DPAD_UP) && sPassGfx->cursorSprite->pos1.y >= 9) { sPassGfx->cursorSprite->pos1.y -= 2; if (sPassGfx->cursorSprite->pos1.y <= 7) sPassGfx->cursorSprite->pos1.y = 2; var = TRUE; } - if (gMain.heldKeys & DPAD_DOWN && sPassGfx->cursorSprite->pos1.y <= 135) + if (JOY_HELD(DPAD_DOWN) && sPassGfx->cursorSprite->pos1.y <= 135) { sPassGfx->cursorSprite->pos1.y += 2; if (sPassGfx->cursorSprite->pos1.y >= 137) @@ -952,14 +952,14 @@ static void Task_HandleFrontierPassInput(u8 taskId) var = TRUE; } - if (gMain.heldKeys & DPAD_LEFT && sPassGfx->cursorSprite->pos1.x >= 6) + if (JOY_HELD(DPAD_LEFT) && sPassGfx->cursorSprite->pos1.x >= 6) { sPassGfx->cursorSprite->pos1.x -= 2; if (sPassGfx->cursorSprite->pos1.x <= 4) sPassGfx->cursorSprite->pos1.x = 5; var = TRUE; } - if (gMain.heldKeys & DPAD_RIGHT && sPassGfx->cursorSprite->pos1.x <= 231) + if (JOY_HELD(DPAD_RIGHT) && sPassGfx->cursorSprite->pos1.x <= 231) { sPassGfx->cursorSprite->pos1.x += 2; if (sPassGfx->cursorSprite->pos1.x >= 233) @@ -969,7 +969,7 @@ static void Task_HandleFrontierPassInput(u8 taskId) if (!var) // Cursor did not change. { - if (sPassData->cursorArea != CURSOR_AREA_NOTHING && gMain.newKeys & A_BUTTON) + if (sPassData->cursorArea != CURSOR_AREA_NOTHING && JOY_NEW(A_BUTTON)) { if (sPassData->cursorArea <= CURSOR_AREA_RECORD) // Map, Card, Record { @@ -986,7 +986,7 @@ static void Task_HandleFrontierPassInput(u8 taskId) } } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_PC_OFF); SetMainCallback2(CB2_HideFrontierPass); @@ -1471,19 +1471,19 @@ static void Task_HandleFrontierMap(u8 taskId) break; return; case 1: - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_PC_OFF); data[0] = 4; } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { if (sMapData->cursorPos >= NUM_FRONTIER_FACILITIES - 1) HandleFrontierMapCursorMove(0); else data[0] = 2; } - else if (gMain.newKeys & DPAD_UP) + else if (JOY_NEW(DPAD_UP)) { if (sMapData->cursorPos == 0) HandleFrontierMapCursorMove(1); diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 2b548dea2..a13543d6a 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -730,7 +730,7 @@ static void Task_Hof_WaitAndPrintPlayerInfo(u8 taskId) static void Task_Hof_ExitOnKeyPressed(u8 taskId) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { FadeOutBGM(4); gTasks[taskId].func = Task_Hof_HandlePaletteOnExit; @@ -992,7 +992,7 @@ static void Task_HofPC_HandleInput(u8 taskId) { u16 i; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (gTasks[taskId].tCurrTeamNo != 0) // prepare another team to view { @@ -1020,7 +1020,7 @@ static void Task_HofPC_HandleInput(u8 taskId) gTasks[taskId].func = Task_HofPC_HandlePaletteOnExit; } } - else if (gMain.newKeys & B_BUTTON) // turn off hall of fame PC + else if (JOY_NEW(B_BUTTON)) // turn off hall of fame PC { if (IsCryPlayingOrClearCrySongs()) { @@ -1029,12 +1029,12 @@ static void Task_HofPC_HandleInput(u8 taskId) } gTasks[taskId].func = Task_HofPC_HandlePaletteOnExit; } - else if (gMain.newKeys & DPAD_UP && gTasks[taskId].tCurrMonId != 0) // change mon -1 + else if (JOY_NEW(DPAD_UP) && gTasks[taskId].tCurrMonId != 0) // change mon -1 { gTasks[taskId].tCurrMonId--; gTasks[taskId].func = Task_HofPC_PrintMonInfo; } - else if (gMain.newKeys & DPAD_DOWN && gTasks[taskId].tCurrMonId < gTasks[taskId].tMonNo - 1) // change mon +1 + else if (JOY_NEW(DPAD_DOWN) && gTasks[taskId].tCurrMonId < gTasks[taskId].tMonNo - 1) // change mon +1 { gTasks[taskId].tCurrMonId++; gTasks[taskId].func = Task_HofPC_PrintMonInfo; @@ -1098,7 +1098,7 @@ static void Task_HofPC_PrintDataIsCorrupted(u8 taskId) static void Task_HofPC_ExitOnButtonPress(u8 taskId) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) gTasks[taskId].func = Task_HofPC_HandlePaletteOnExit; } diff --git a/src/item_menu.c b/src/item_menu.c index ace2fd11e..e1ab5d0fa 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -1167,7 +1167,7 @@ void Task_BagMenu_HandleInput(u8 taskId) SwitchBagPocket(taskId, MENU_CURSOR_DELTA_RIGHT, 0); return; default: - if (gMain.newKeys & SELECT_BUTTON) + if (JOY_NEW(SELECT_BUTTON)) { if (CanSwapItems() == TRUE) { @@ -1229,12 +1229,12 @@ static u8 GetSwitchBagPocketDirection(void) if (gBagMenu->pocketSwitchDisabled) return SWITCH_POCKET_NONE; LRKeys = GetLRKeysPressed(); - if ((gMain.newKeys & DPAD_LEFT) || LRKeys == MENU_L_PRESSED) + if ((JOY_NEW(DPAD_LEFT)) || LRKeys == MENU_L_PRESSED) { PlaySE(SE_SELECT); return SWITCH_POCKET_LEFT; } - if ((gMain.newKeys & DPAD_RIGHT) || LRKeys == MENU_R_PRESSED) + if ((JOY_NEW(DPAD_RIGHT)) || LRKeys == MENU_R_PRESSED) { PlaySE(SE_SELECT); return SWITCH_POCKET_RIGHT; @@ -1388,7 +1388,7 @@ static void Task_HandleSwappingItemsInput(u8 taskId) if (MenuHelpers_CallLinkSomething() != TRUE) { - if (gMain.newKeys & SELECT_BUTTON) + if (JOY_NEW(SELECT_BUTTON)) { PlaySE(SE_SELECT); ListMenuGetScrollAndRow(data[0], &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket], &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]); @@ -1406,7 +1406,7 @@ static void Task_HandleSwappingItemsInput(u8 taskId) break; case LIST_CANCEL: PlaySE(SE_SELECT); - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) sub_81AC498(taskId); else sub_81AC590(taskId); @@ -1645,7 +1645,7 @@ void Task_HandleOutOfBattleItemMenuInput(u8 taskId) if (MenuHelpers_CallLinkSomething() != TRUE) { s8 cursorPos = Menu_GetCursorPos(); - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { if (cursorPos > 0 && sub_81ACDFC(cursorPos - 2)) { @@ -1653,7 +1653,7 @@ void Task_HandleOutOfBattleItemMenuInput(u8 taskId) ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP); } } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { if (cursorPos < (gBagMenu->contextMenuNumItems - 2) && sub_81ACDFC(cursorPos + 2)) { @@ -1661,7 +1661,7 @@ void Task_HandleOutOfBattleItemMenuInput(u8 taskId) ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN); } } - else if ((gMain.newKeys & DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED) + else if ((JOY_NEW(DPAD_LEFT)) || GetLRKeysPressed() == MENU_L_PRESSED) { if ((cursorPos & 1) && sub_81ACDFC(cursorPos - 1)) { @@ -1669,7 +1669,7 @@ void Task_HandleOutOfBattleItemMenuInput(u8 taskId) ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE); } } - else if ((gMain.newKeys & DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED) + else if ((JOY_NEW(DPAD_RIGHT)) || GetLRKeysPressed() == MENU_R_PRESSED) { if (!(cursorPos & 1) && sub_81ACDFC(cursorPos + 1)) { @@ -1677,12 +1677,12 @@ void Task_HandleOutOfBattleItemMenuInput(u8 taskId) ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE); } } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); sItemMenuActions[gBagMenu->contextMenuItemsPtr[cursorPos]].func.void_u8(taskId); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sItemMenuActions[ITEMMENUACTION_CANCEL].func.void_u8(taskId); @@ -1786,13 +1786,13 @@ void Task_ChooseHowManyToToss(u8 taskId) { PrintItemDepositAmount(gBagMenu->windowPointers[7], tItemCount); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); BagMenu_RemoveWindow(7); BagMenu_TossItems(taskId); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); BagMenu_RemoveWindow(7); @@ -1818,7 +1818,7 @@ void Task_ActuallyToss(u8 taskId) u16* scrollPos = &gBagPositionStruct.scrollPosition[gBagPositionStruct.pocket]; u16* cursorPos = &gBagPositionStruct.cursorPosition[gBagPositionStruct.pocket]; - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { PlaySE(SE_SELECT); RemoveBagItem(gSpecialVar_ItemId, tItemCount); @@ -1886,7 +1886,7 @@ static void BagMenu_PrintItemCantBeHeld(u8 taskId) void sub_81AD350(u8 taskId) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); BagMenu_InitListsMenu(taskId); @@ -2060,13 +2060,13 @@ static void Task_SellHowManyDialogueHandleInput(u8 taskId) { PrintItemSoldAmount(gBagMenu->windowPointers[8], tItemCount, (ItemId_GetPrice(gSpecialVar_ItemId) / 2) * tItemCount); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); BagMenu_RemoveWindow(8); DisplaySellItemPriceAndConfirm(taskId); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); BagMenu_PrintCursor_(data[0], 0); @@ -2108,7 +2108,7 @@ static void BagMenu_Sell_UpdateItemListAndMoney(u8 taskId) static void BagMenu_Sell_WaitForABPress(u8 taskId) { - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { PlaySE(SE_SELECT); RemoveMoneyWindow(); @@ -2144,13 +2144,13 @@ static void Task_ChooseHowManyToDeposit(u8 taskId) { PrintItemDepositAmount(gBagMenu->windowPointers[7], tItemCount); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); BagMenu_RemoveWindow(7); BagMenu_TryDepositItem(taskId); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); BagMenu_PrintDescription(data[1]); @@ -2189,7 +2189,7 @@ static void BagMenu_Deposit_WaitForABPress(u8 taskId) { s16* data = gTasks[taskId].data; - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { PlaySE(SE_SELECT); BagMenu_PrintDescription(data[1]); diff --git a/src/item_use.c b/src/item_use.c index a9132ae5e..f9d1ff824 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -792,7 +792,7 @@ static void BootUpSoundTMHM(u8 taskId) static void Task_ShowTMHMContainedMessage(u8 taskId) { - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { StringCopy(gStringVar1, gMoveNames[ItemIdToBattleMoveId(gSpecialVar_ItemId)]); StringExpandPlaceholders(gStringVar4, gText_TMHMContainedVar1); @@ -956,7 +956,7 @@ void ItemUseInBattle_PokeBall(u8 taskId) static void Task_CloseStatIncreaseMessage(u8 taskId) { - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { if (!InBattlePyramid()) Task_FadeAndCloseBagMenu(taskId); diff --git a/src/link.c b/src/link.c index cdaf58469..9fd35a10b 100644 --- a/src/link.c +++ b/src/link.c @@ -445,27 +445,27 @@ static void TestBlockTransfer(u8 nothing, u8 is, u8 used) static void LinkTestProcessKeyInput(void) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { gShouldAdvanceLinkState = 1; } - if (gMain.heldKeys & B_BUTTON) + if (JOY_HELD(B_BUTTON)) { InitBlockSend(gHeap + 0x4000, 0x00002004); } - if (gMain.newKeys & L_BUTTON) + if (JOY_NEW(L_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB(2, 0, 0)); } - if (gMain.newKeys & START_BUTTON) + if (JOY_NEW(START_BUTTON)) { SetSuppressLinkErrorMessage(TRUE); } - if (gMain.newKeys & R_BUTTON) + if (JOY_NEW(R_BUTTON)) { TrySavingData(SAVE_LINK); } - if (gMain.newKeys & SELECT_BUTTON) + if (JOY_NEW(SELECT_BUTTON)) { SetCloseLinkCallback(); } @@ -1754,7 +1754,7 @@ static void CB2_PrintErrorMessage(void) { if (gWirelessCommType == 1) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_PIN); gWirelessCommType = 0; @@ -1764,7 +1764,7 @@ static void CB2_PrintErrorMessage(void) } else if (gWirelessCommType == 2) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { rfu_REQ_stopMode(); rfu_waitREQComplete(); diff --git a/src/list_menu.c b/src/list_menu.c index 1e549a34a..7784dd338 100644 --- a/src/list_menu.c +++ b/src/list_menu.c @@ -335,11 +335,11 @@ u32 DoMysteryGiftListMenu(const struct WindowTemplate *windowTemplate, const str break; case 1: sMysteryGiftLinkMenu.currItemId = ListMenu_ProcessInput(sMysteryGiftLinkMenu.listTaskId); - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { sMysteryGiftLinkMenu.state = 2; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { sMysteryGiftLinkMenu.currItemId = LIST_CANCEL; sMysteryGiftLinkMenu.state = 2; @@ -410,20 +410,20 @@ s32 ListMenu_ProcessInput(u8 listTaskId) { struct ListMenu *list = (void*) gTasks[listTaskId].data; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { return list->template.items[list->scrollOffset + list->selectedRow].id; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { return LIST_CANCEL; } - else if (gMain.newAndRepeatedKeys & DPAD_UP) + else if (JOY_REPEAT(DPAD_UP)) { ListMenuChangeSelection(list, TRUE, 1, FALSE); return LIST_NOTHING_CHOSEN; } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPEAT(DPAD_DOWN)) { ListMenuChangeSelection(list, TRUE, 1, TRUE); return LIST_NOTHING_CHOSEN; @@ -439,12 +439,12 @@ s32 ListMenu_ProcessInput(u8 listTaskId) rightButton = FALSE; break; case LIST_MULTIPLE_SCROLL_DPAD: - leftButton = gMain.newAndRepeatedKeys & DPAD_LEFT; - rightButton = gMain.newAndRepeatedKeys & DPAD_RIGHT; + leftButton = JOY_REPEAT(DPAD_LEFT); + rightButton = JOY_REPEAT(DPAD_RIGHT); break; case LIST_MULTIPLE_SCROLL_L_R: - leftButton = gMain.newAndRepeatedKeys & L_BUTTON; - rightButton = gMain.newAndRepeatedKeys & R_BUTTON; + leftButton = JOY_REPEAT(L_BUTTON); + rightButton = JOY_REPEAT(R_BUTTON); break; } diff --git a/src/mail.c b/src/mail.c index 0fc62678a..55bc9ed00 100644 --- a/src/mail.c +++ b/src/mail.c @@ -525,7 +525,7 @@ static void CB2_WaitForPaletteExitOnKeyPress(void) static void CB2_ExitOnKeyPress(void) { - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); sMailRead->callback2 = CB2_ExitMailReadFreeVars; diff --git a/src/main.c b/src/main.c index 238bd8243..b3b76b1fb 100644 --- a/src/main.c +++ b/src/main.c @@ -280,10 +280,10 @@ static void ReadKeys(void) // Remap L to A if the L=A option is enabled. if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A) { - if (gMain.newKeys & L_BUTTON) + if (JOY_NEW(L_BUTTON)) gMain.newKeys |= A_BUTTON; - if (gMain.heldKeys & L_BUTTON) + if (JOY_HELD(L_BUTTON)) gMain.heldKeys |= A_BUTTON; } diff --git a/src/main_menu.c b/src/main_menu.c index f4bf37ce1..e8403cdb1 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -696,7 +696,7 @@ static void Task_MainMenuCheckSaveFile(u8 taskId) static void Task_WaitForSaveFileErrorWindow(u8 taskId) { RunTextPrinters(); - if (!IsTextPrinterActive(7) && (gMain.newKeys & A_BUTTON)) + if (!IsTextPrinterActive(7) && (JOY_NEW(A_BUTTON))) { ClearWindowTilemap(7); ClearMainMenuWindowTilemap(&sWindowTemplates_MainMenu[7]); @@ -731,7 +731,7 @@ static void Task_MainMenuCheckBattery(u8 taskId) static void Task_WaitForBatteryDryErrorWindow(u8 taskId) { RunTextPrinters(); - if (!IsTextPrinterActive(7) && (gMain.newKeys & A_BUTTON)) + if (!IsTextPrinterActive(7) && (JOY_NEW(A_BUTTON))) { ClearWindowTilemap(7); ClearMainMenuWindowTilemap(&sWindowTemplates_MainMenu[7]); @@ -887,14 +887,14 @@ static bool8 HandleMainMenuInput(u8 taskId) { s16* data = gTasks[taskId].data; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); IsWirelessAdapterConnected(); // why bother calling this here? debug? Task_HandleMainMenuAPressed will check too BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gTasks[taskId].func = Task_HandleMainMenuAPressed; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_WHITEALPHA); @@ -902,7 +902,7 @@ static bool8 HandleMainMenuInput(u8 taskId) SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(0, 160)); gTasks[taskId].func = Task_HandleMainMenuBPressed; } - else if ((gMain.newKeys & DPAD_UP) && tCurrItem > 0) + else if ((JOY_NEW(DPAD_UP)) && tCurrItem > 0) { if (tMenuType == HAS_MYSTERY_EVENTS && tIsScrolled == TRUE && tCurrItem == 1) { @@ -914,7 +914,7 @@ static bool8 HandleMainMenuInput(u8 taskId) sCurrItemAndOptionMenuCheck = tCurrItem; return TRUE; } - else if ((gMain.newKeys & DPAD_DOWN) && tCurrItem < tItemCount - 1) + else if ((JOY_NEW(DPAD_DOWN)) && tCurrItem < tItemCount - 1) { if (tMenuType == HAS_MYSTERY_EVENTS && tCurrItem == 3 && tIsScrolled == FALSE) { @@ -1151,7 +1151,7 @@ static void Task_DisplayMainMenuInvalidActionError(u8 taskId) gTasks[taskId].tCurrItem++; break; case 3: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { PlaySE(SE_SELECT); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); @@ -1594,7 +1594,7 @@ static void Task_NewGameBirchSpeech_WaitForWhatsYourNameToPrint(u8 taskId) static void Task_NewGameBirchSpeech_WaitPressBeforeNameChoice(u8 taskId) { - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); gTasks[taskId].func = Task_NewGameBirchSpeech_StartNamingScreen; diff --git a/src/match_call.c b/src/match_call.c index c02cc6c39..1899eabf0 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -1253,7 +1253,7 @@ static bool32 sub_81962D8(u8 taskId) static bool32 sub_8196330(u8 taskId) { s16 *taskData = gTasks[taskId].data; - if (!ExecuteMatchCallTextPrinter(taskData[2]) && !IsSEPlaying() && gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (!ExecuteMatchCallTextPrinter(taskData[2]) && !IsSEPlaying() && JOY_NEW(A_BUTTON | B_BUTTON)) { FillWindowPixelBuffer(taskData[2], PIXEL_FILL(8)); CopyWindowToVram(taskData[2], 2); @@ -1346,7 +1346,7 @@ static void InitMatchCallTextPrinter(int windowId, const u8 *str) static bool32 ExecuteMatchCallTextPrinter(int windowId) { - if (gMain.heldKeys & A_BUTTON) + if (JOY_HELD(A_BUTTON)) gTextFlags.canABSpeedUpPrint = 1; else gTextFlags.canABSpeedUpPrint = 0; diff --git a/src/menu.c b/src/menu.c index 85275b6bc..ca87113be 100644 --- a/src/menu.c +++ b/src/menu.c @@ -981,23 +981,23 @@ u8 Menu_GetCursorPos(void) s8 Menu_ProcessInput(void) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (!sMenu.APressMuted) PlaySE(SE_SELECT); return sMenu.cursorPos; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { return MENU_B_PRESSED; } - else if (gMain.newKeys & DPAD_UP) + else if (JOY_NEW(DPAD_UP)) { PlaySE(SE_SELECT); Menu_MoveCursor(-1); return MENU_NOTHING_CHOSEN; } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { PlaySE(SE_SELECT); Menu_MoveCursor(1); @@ -1011,23 +1011,23 @@ s8 Menu_ProcessInputNoWrap(void) { u8 oldPos = sMenu.cursorPos; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (!sMenu.APressMuted) PlaySE(SE_SELECT); return sMenu.cursorPos; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { return MENU_B_PRESSED; } - else if (gMain.newKeys & DPAD_UP) + else if (JOY_NEW(DPAD_UP)) { if (oldPos != Menu_MoveCursorNoWrapAround(-1)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { if (oldPos != Menu_MoveCursorNoWrapAround(1)) PlaySE(SE_SELECT); @@ -1039,23 +1039,23 @@ s8 Menu_ProcessInputNoWrap(void) s8 ProcessMenuInput_other(void) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (!sMenu.APressMuted) PlaySE(SE_SELECT); return sMenu.cursorPos; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { return MENU_B_PRESSED; } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) + else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_UP) { PlaySE(SE_SELECT); Menu_MoveCursor(-1); return MENU_NOTHING_CHOSEN; } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) + else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_DOWN) { PlaySE(SE_SELECT); Menu_MoveCursor(1); @@ -1069,23 +1069,23 @@ s8 Menu_ProcessInputNoWrapAround_other(void) { u8 oldPos = sMenu.cursorPos; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (!sMenu.APressMuted) PlaySE(SE_SELECT); return sMenu.cursorPos; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { return MENU_B_PRESSED; } - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) + if ((JOY_REPEAT(DPAD_ANY)) == DPAD_UP) { if (oldPos != Menu_MoveCursorNoWrapAround(-1)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) + if ((JOY_REPEAT(DPAD_ANY)) == DPAD_DOWN) { if (oldPos != Menu_MoveCursorNoWrapAround(1)) PlaySE(SE_SELECT); @@ -1407,34 +1407,34 @@ u8 ChangeGridMenuCursorPosition(s8 deltaX, s8 deltaY) s8 sub_8199284(void) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); return sMenu.cursorPos; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { return MENU_B_PRESSED; } - else if (gMain.newKeys & DPAD_UP) + else if (JOY_NEW(DPAD_UP)) { PlaySE(SE_SELECT); ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP); return MENU_NOTHING_CHOSEN; } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { PlaySE(SE_SELECT); ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN); return MENU_NOTHING_CHOSEN; } - else if (gMain.newKeys & DPAD_LEFT || GetLRKeysPressed() == MENU_L_PRESSED) + else if (JOY_NEW(DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED) { PlaySE(SE_SELECT); ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE); return MENU_NOTHING_CHOSEN; } - else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysPressed() == MENU_R_PRESSED) + else if (JOY_NEW(DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED) { PlaySE(SE_SELECT); ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE); @@ -1448,34 +1448,34 @@ s8 Menu_ProcessInputGridLayout(void) { u8 oldPos = sMenu.cursorPos; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); return sMenu.cursorPos; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { return MENU_B_PRESSED; } - else if (gMain.newKeys & DPAD_UP) + else if (JOY_NEW(DPAD_UP)) { if (oldPos != ChangeGridMenuCursorPosition(0, -1)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { if (oldPos != ChangeGridMenuCursorPosition(0, 1)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } - else if (gMain.newKeys & DPAD_LEFT || GetLRKeysPressed() == MENU_L_PRESSED) + else if (JOY_NEW(DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED) { if (oldPos != ChangeGridMenuCursorPosition(-1, 0)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } - else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysPressed() == MENU_R_PRESSED) + else if (JOY_NEW(DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED) { if (oldPos != ChangeGridMenuCursorPosition(1, 0)) PlaySE(SE_SELECT); @@ -1487,34 +1487,34 @@ s8 Menu_ProcessInputGridLayout(void) s8 sub_81993D8(void) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); return sMenu.cursorPos; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { return MENU_B_PRESSED; } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) + else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_UP) { PlaySE(SE_SELECT); ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP); return MENU_NOTHING_CHOSEN; } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) + else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_DOWN) { PlaySE(SE_SELECT); ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN); return MENU_NOTHING_CHOSEN; } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT || GetLRKeysPressedAndHeld() == MENU_L_PRESSED) + else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_LEFT || GetLRKeysPressedAndHeld() == MENU_L_PRESSED) { PlaySE(SE_SELECT); ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE); return MENU_NOTHING_CHOSEN; } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT || GetLRKeysPressedAndHeld() == MENU_R_PRESSED) + else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_RIGHT || GetLRKeysPressedAndHeld() == MENU_R_PRESSED) { PlaySE(SE_SELECT); ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE); @@ -1529,34 +1529,34 @@ s8 sub_8199484(void) { u8 oldPos = sMenu.cursorPos; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); return sMenu.cursorPos; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { return MENU_B_PRESSED; } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) + else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_UP) { if (oldPos != ChangeGridMenuCursorPosition(0, -1)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) + else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_DOWN) { if (oldPos != ChangeGridMenuCursorPosition(0, 1)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT || GetLRKeysPressedAndHeld() == MENU_L_PRESSED) + else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_LEFT || GetLRKeysPressedAndHeld() == MENU_L_PRESSED) { if (oldPos != ChangeGridMenuCursorPosition(-1, 0)) PlaySE(SE_SELECT); return MENU_NOTHING_CHOSEN; } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT || GetLRKeysPressedAndHeld() == MENU_R_PRESSED) + else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_RIGHT || GetLRKeysPressedAndHeld() == MENU_R_PRESSED) { if (oldPos != ChangeGridMenuCursorPosition(1, 0)) PlaySE(SE_SELECT); diff --git a/src/menu_helpers.c b/src/menu_helpers.c index 69443d309..b31d84a1e 100644 --- a/src/menu_helpers.c +++ b/src/menu_helpers.c @@ -183,7 +183,7 @@ bool8 AdjustQuantityAccordingToDPadInput(s16 *arg0, u16 arg1) { s16 valBefore = (*arg0); - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) + if ((JOY_REPEAT(DPAD_ANY)) == DPAD_UP) { (*arg0)++; if ((*arg0) > arg1) @@ -199,7 +199,7 @@ bool8 AdjustQuantityAccordingToDPadInput(s16 *arg0, u16 arg1) return TRUE; } } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) + else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_DOWN) { (*arg0)--; if ((*arg0) <= 0) @@ -215,7 +215,7 @@ bool8 AdjustQuantityAccordingToDPadInput(s16 *arg0, u16 arg1) return TRUE; } } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT) + else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_RIGHT) { (*arg0) += 10; if ((*arg0) > arg1) @@ -231,7 +231,7 @@ bool8 AdjustQuantityAccordingToDPadInput(s16 *arg0, u16 arg1) return TRUE; } } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT) + else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_LEFT) { (*arg0) -= 10; if ((*arg0) <= 0) @@ -255,9 +255,9 @@ u8 GetLRKeysPressed(void) { if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR) { - if (gMain.newKeys & L_BUTTON) + if (JOY_NEW(L_BUTTON)) return MENU_L_PRESSED; - if (gMain.newKeys & R_BUTTON) + if (JOY_NEW(R_BUTTON)) return MENU_R_PRESSED; } @@ -268,9 +268,9 @@ u8 GetLRKeysPressedAndHeld(void) { if (gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR) { - if (gMain.newAndRepeatedKeys & L_BUTTON) + if (JOY_REPEAT(L_BUTTON)) return MENU_L_PRESSED; - if (gMain.newAndRepeatedKeys & R_BUTTON) + if (JOY_REPEAT(R_BUTTON)) return MENU_R_PRESSED; } diff --git a/src/mon_markings.c b/src/mon_markings.c index db5df07e8..c2afdda83 100644 --- a/src/mon_markings.c +++ b/src/mon_markings.c @@ -394,7 +394,7 @@ bool8 sub_811FBA4(void) { u16 i; - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { s8 pos; PlaySE(SE_SELECT); @@ -404,7 +404,7 @@ bool8 sub_811FBA4(void) return TRUE; } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { s8 pos; PlaySE(SE_SELECT); @@ -414,7 +414,7 @@ bool8 sub_811FBA4(void) return TRUE; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); @@ -433,7 +433,7 @@ bool8 sub_811FBA4(void) return TRUE; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); return FALSE; diff --git a/src/move_relearner.c b/src/move_relearner.c index 3e7caf133..cd4da5835 100644 --- a/src/move_relearner.c +++ b/src/move_relearner.c @@ -732,7 +732,7 @@ static void DoMoveRelearnerMain(void) } break; case MENU_STATE_WAIT_FOR_A_BUTTON: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); sMoveRelearnerStruct->state = MENU_STATE_FADE_AND_RETURN; @@ -778,7 +778,7 @@ static void HandleInput(bool8 showContest) switch (itemId) { case LIST_NOTHING_CHOSEN: - if (!(gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT)) && !GetLRKeysPressed()) + if (!(JOY_NEW(DPAD_LEFT | DPAD_RIGHT)) && !GetLRKeysPressed()) { break; } diff --git a/src/mystery_event_menu.c b/src/mystery_event_menu.c index 032cc3340..00dcbf0e3 100644 --- a/src/mystery_event_menu.c +++ b/src/mystery_event_menu.c @@ -163,7 +163,7 @@ static void CB2_MysteryEventMenu(void) PrintMysteryMenuText(0, gText_PressAToLoadEvent, 1, 2, 1); gMain.state++; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); CloseLink(); @@ -177,7 +177,7 @@ static void CB2_MysteryEventMenu(void) case 5: if (GetLinkPlayerCount_2() == 2) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); CheckShouldAdvanceLinkState(); @@ -187,7 +187,7 @@ static void CB2_MysteryEventMenu(void) CopyWindowToVram(1, 3); gMain.state++; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); CloseLink(); @@ -227,7 +227,7 @@ static void CB2_MysteryEventMenu(void) } } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); CloseLink(); @@ -274,7 +274,7 @@ static void CB2_MysteryEventMenu(void) } break; case 14: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); gMain.state++; diff --git a/src/mystery_gift.c b/src/mystery_gift.c index ca5ab1baf..a23f159b2 100644 --- a/src/mystery_gift.c +++ b/src/mystery_gift.c @@ -561,7 +561,7 @@ bool32 MG_PrintTextOnWindow1AndWaitButton(u8 *textState, const u8 *str) goto inc; case 1: DrawDownArrow(1, 0xD0, 0x14, 1, FALSE, &sDownArrowCounterAndYCoordIdx[0], &sDownArrowCounterAndYCoordIdx[1]); - if (({gMain.newKeys & (A_BUTTON | B_BUTTON);})) + if (({JOY_NEW(A_BUTTON | B_BUTTON);})) { inc: (*textState)++; @@ -595,7 +595,7 @@ bool32 unref_HideDownArrowAndWaitButton(u8 * textState) { case 0: HideDownArrow(); - if (({gMain.newKeys & (A_BUTTON | B_BUTTON);})) + if (({JOY_NEW(A_BUTTON | B_BUTTON);})) { (*textState)++; } @@ -930,7 +930,7 @@ static bool32 mevent_save_game(u8 * state) (*state)++; break; case 3: - if (({gMain.newKeys & (A_BUTTON | B_BUTTON);})) + if (({JOY_NEW(A_BUTTON | B_BUTTON);})) { (*state)++; } @@ -1458,11 +1458,11 @@ void task00_mystery_gift(u8 taskId) case 20: if (data->IsCardOrNews == 0) { - if (({gMain.newKeys & A_BUTTON;})) + if (({JOY_NEW(A_BUTTON);})) { data->state = 21; } - if (({gMain.newKeys & B_BUTTON;})) + if (({JOY_NEW(B_BUTTON);})) { data->state = 27; } diff --git a/src/option_menu.c b/src/option_menu.c index 1cf0bad2e..b6440a89c 100644 --- a/src/option_menu.c +++ b/src/option_menu.c @@ -271,16 +271,16 @@ static void Task_OptionMenuFadeIn(u8 taskId) static void Task_OptionMenuProcessInput(u8 taskId) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (gTasks[taskId].data[TD_MENUSELECTION] == MENUITEM_CANCEL) gTasks[taskId].func = Task_OptionMenuSave; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { gTasks[taskId].func = Task_OptionMenuSave; } - else if (gMain.newKeys & DPAD_UP) + else if (JOY_NEW(DPAD_UP)) { if (gTasks[taskId].data[TD_MENUSELECTION] > 0) gTasks[taskId].data[TD_MENUSELECTION]--; @@ -288,7 +288,7 @@ static void Task_OptionMenuProcessInput(u8 taskId) gTasks[taskId].data[TD_MENUSELECTION] = MENUITEM_CANCEL; HighlightOptionMenuItem(gTasks[taskId].data[TD_MENUSELECTION]); } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { if (gTasks[taskId].data[TD_MENUSELECTION] < MENUITEM_CANCEL) gTasks[taskId].data[TD_MENUSELECTION]++; @@ -405,7 +405,7 @@ static void DrawOptionMenuChoice(const u8 *text, u8 x, u8 y, u8 style) static u8 TextSpeed_ProcessInput(u8 selection) { - if (gMain.newKeys & DPAD_RIGHT) + if (JOY_NEW(DPAD_RIGHT)) { if (selection <= 1) selection++; @@ -414,7 +414,7 @@ static u8 TextSpeed_ProcessInput(u8 selection) sArrowPressed = TRUE; } - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { if (selection != 0) selection--; @@ -451,7 +451,7 @@ static void TextSpeed_DrawChoices(u8 selection) static u8 BattleScene_ProcessInput(u8 selection) { - if (gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT)) + if (JOY_NEW(DPAD_LEFT | DPAD_RIGHT)) { selection ^= 1; sArrowPressed = TRUE; @@ -474,7 +474,7 @@ static void BattleScene_DrawChoices(u8 selection) static u8 BattleStyle_ProcessInput(u8 selection) { - if (gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT)) + if (JOY_NEW(DPAD_LEFT | DPAD_RIGHT)) { selection ^= 1; sArrowPressed = TRUE; @@ -497,7 +497,7 @@ static void BattleStyle_DrawChoices(u8 selection) static u8 Sound_ProcessInput(u8 selection) { - if (gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT)) + if (JOY_NEW(DPAD_LEFT | DPAD_RIGHT)) { selection ^= 1; SetPokemonCryStereo(selection); @@ -521,7 +521,7 @@ static void Sound_DrawChoices(u8 selection) static u8 FrameType_ProcessInput(u8 selection) { - if (gMain.newKeys & DPAD_RIGHT) + if (JOY_NEW(DPAD_RIGHT)) { if (selection < WINDOW_FRAMES_COUNT - 1) selection++; @@ -532,7 +532,7 @@ static u8 FrameType_ProcessInput(u8 selection) LoadPalette(GetWindowFrameTilesPal(selection)->pal, 0x70, 0x20); sArrowPressed = TRUE; } - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { if (selection != 0) selection--; @@ -579,7 +579,7 @@ static void FrameType_DrawChoices(u8 selection) static u8 ButtonMode_ProcessInput(u8 selection) { - if (gMain.newKeys & DPAD_RIGHT) + if (JOY_NEW(DPAD_RIGHT)) { if (selection <= 1) selection++; @@ -588,7 +588,7 @@ static u8 ButtonMode_ProcessInput(u8 selection) sArrowPressed = TRUE; } - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { if (selection != 0) selection--; diff --git a/src/overworld.c b/src/overworld.c index d18e3d3bc..2d798f2ec 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -2454,20 +2454,19 @@ static void UpdateHeldKeyCode(u16 key) static u16 KeyInterCB_ReadButtons(u32 key) { - if (gMain.heldKeys & DPAD_UP) + if (JOY_HELD(DPAD_UP)) return LINK_KEY_CODE_DPAD_UP; - else if (gMain.heldKeys & DPAD_DOWN) + if (JOY_HELD(DPAD_DOWN)) return LINK_KEY_CODE_DPAD_DOWN; - else if (gMain.heldKeys & DPAD_LEFT) + if (JOY_HELD(DPAD_LEFT)) return LINK_KEY_CODE_DPAD_LEFT; - else if (gMain.heldKeys & DPAD_RIGHT) + if (JOY_HELD(DPAD_RIGHT)) return LINK_KEY_CODE_DPAD_RIGHT; - else if (gMain.newKeys & START_BUTTON) + if (JOY_NEW(START_BUTTON)) return LINK_KEY_CODE_START_BUTTON; - else if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) return LINK_KEY_CODE_A_BUTTON; - else - return LINK_KEY_CODE_EMPTY; + return LINK_KEY_CODE_EMPTY; } static u16 GetDirectionForDpadKey(u16 a1) @@ -2574,7 +2573,7 @@ static u16 sub_8087170(u32 keyOrPlayerId) { if (sPlayerTradingStates[keyOrPlayerId] == PLAYER_TRADING_STATE_UNK_2) { - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { SetKeyInterceptCallback(KeyInterCB_DoNothingAndKeepAlive); return LINK_KEY_CODE_UNK_7; diff --git a/src/party_menu.c b/src/party_menu.c index 7514cf545..e509ef6e0 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -1411,7 +1411,7 @@ static u16 PartyMenuButtonHandler(s8 *slotPtr) break; } - if (gMain.newKeys & START_BUTTON) + if (JOY_NEW(START_BUTTON)) return 8; if (movementDir) @@ -1421,10 +1421,10 @@ static u16 PartyMenuButtonHandler(s8 *slotPtr) } // Pressed Cancel - if ((gMain.newKeys & A_BUTTON) && *slotPtr == PARTY_SIZE + 1) + if ((JOY_NEW(A_BUTTON)) && *slotPtr == PARTY_SIZE + 1) return 2; - return gMain.newKeys & (A_BUTTON | B_BUTTON); + return JOY_NEW(A_BUTTON | B_BUTTON); } static void UpdateCurrentPartySelection(s8 *slotPtr, s8 movementDir) @@ -3765,7 +3765,7 @@ static u16 GetFieldMoveMonSpecies(void) static void Task_CancelAfterAorBPress(u8 taskId) { - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))) CursorCb_Cancel1(taskId); } @@ -4722,7 +4722,7 @@ static void Task_DoLearnedMoveFanfareAfterText(u8 taskId) static void Task_LearnNextMoveOrClosePartyMenu(u8 taskId) { - if (IsFanfareTaskInactive() && ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))) + if (IsFanfareTaskInactive() && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))) { if (gPartyMenu.learnMoveState == 1) Task_TryLearningNextMove(taskId); @@ -4931,7 +4931,7 @@ static void UpdateMonDisplayInfoAfterRareCandy(u8 slot, struct Pokemon *mon) static void Task_DisplayLevelUpStatsPg1(u8 taskId) { - if (WaitFanfare(FALSE) && IsPartyMenuTextPrinterActive() != TRUE && ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))) + if (WaitFanfare(FALSE) && IsPartyMenuTextPrinterActive() != TRUE && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))) { PlaySE(SE_SELECT); DisplayLevelUpStatsPg1(taskId); @@ -4941,7 +4941,7 @@ static void Task_DisplayLevelUpStatsPg1(u8 taskId) static void Task_DisplayLevelUpStatsPg2(u8 taskId) { - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))) { PlaySE(SE_SELECT); DisplayLevelUpStatsPg2(taskId); @@ -4972,7 +4972,7 @@ static void Task_TryLearnNewMoves(u8 taskId) { u16 learnMove; - if (WaitFanfare(0) && ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON))) + if (WaitFanfare(0) && ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON)))) { RemoveLevelUpStatsWindow(); learnMove = MonTryLearningNewMove(&gPlayerParty[gPartyMenu.slotId], TRUE); @@ -5609,7 +5609,7 @@ static void Task_ValidateChosenHalfParty(u8 taskId) static void Task_ContinueChoosingHalfParty(u8 taskId) { - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))) { PlaySE(SE_SELECT); DisplayPartyMenuStdMessage(PARTY_MSG_CHOOSE_MON); diff --git a/src/player_pc.c b/src/player_pc.c index 2010d84f8..238424ee3 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -1134,7 +1134,7 @@ static void ItemStorage_ProcessInput(u8 taskId) s32 id; data = gTasks[taskId].data; - if (gMain.newKeys & SELECT_BUTTON) + if (JOY_NEW(SELECT_BUTTON)) { ListMenuGetScrollAndRow(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos)); if ((playerPCItemPageInfo.itemsAbove + playerPCItemPageInfo.cursorPos) != (playerPCItemPageInfo.count - 1)) @@ -1212,7 +1212,7 @@ static void sub_816C4FC(u8 taskId) s32 id; data = gTasks[taskId].data; - if (gMain.newKeys & SELECT_BUTTON) + if (JOY_NEW(SELECT_BUTTON)) { ListMenuGetScrollAndRow(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos)); ItemStorage_DoItemSwap(taskId, FALSE); @@ -1227,7 +1227,7 @@ static void sub_816C4FC(u8 taskId) case LIST_NOTHING_CHOSEN: break; case LIST_CANCEL: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { ItemStorage_DoItemSwap(taskId, FALSE); } @@ -1332,7 +1332,7 @@ static void ItemStorage_HandleQuantityRolling(u8 taskId) sub_816C6BC(sub_816BC7C(4), data[2], STR_CONV_MODE_LEADING_ZEROS, 8, 1, 3); else { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); sub_816BCC4(4); @@ -1341,7 +1341,7 @@ static void ItemStorage_HandleQuantityRolling(u8 taskId) else ItemStorage_DoItemToss(taskId); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sub_816BCC4(4); @@ -1412,7 +1412,7 @@ static void ItemStorage_HandleRemoveItem(u8 taskId) s16 *data; data = gTasks[taskId].data; - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { RemovePCItem((playerPCItemPageInfo.cursorPos + playerPCItemPageInfo.itemsAbove), data[2]); DestroyListMenuTask(data[5], &(playerPCItemPageInfo.itemsAbove), &(playerPCItemPageInfo.cursorPos)); @@ -1429,7 +1429,7 @@ static void ItemStorage_WaitPressHandleResumeProcessInput(u8 taskId) s16 *data; data = gTasks[taskId].data; - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { ItemStorage_PrintItemPcResponse(ItemStorage_GetItemPcResponse(gSaveBlock1Ptr->pcItems[(playerPCItemPageInfo.itemsAbove + playerPCItemPageInfo.cursorPos)].itemId)); ItemStorage_StartScrollIndicatorAndProcessInput(taskId); diff --git a/src/pokeblock.c b/src/pokeblock.c index fc5451b0a..b44112b88 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -984,7 +984,7 @@ static void Task_HandlePokeblockMenuInput(u8 taskId) if (!gPaletteFade.active && MenuHelpers_CallLinkSomething() != TRUE) { - if (gMain.newKeys & SELECT_BUTTON) + if (JOY_NEW(SELECT_BUTTON)) { ListMenuGetScrollAndRow(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos); if (sSavedPokeblockData.lastItemPage + sSavedPokeblockData.lastItemPos != sPokeblockMenu->itemsNo - 1) @@ -1035,7 +1035,7 @@ static void Task_HandlePokeblocksSwapInput(u8 taskId) if (MenuHelpers_CallLinkSomething() == TRUE) return; - if (gMain.newKeys & SELECT_BUTTON) + if (JOY_NEW(SELECT_BUTTON)) { PlaySE(SE_SELECT); ListMenuGetScrollAndRow(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos); @@ -1069,7 +1069,7 @@ static void Task_HandlePokeblocksSwapInput(u8 taskId) break; case LIST_CANCEL: // same id as STOW CASE field PlaySE(SE_SELECT); - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) HandlePokeblocksSwap(taskId, FALSE); else HandlePokeblocksSwap(taskId, TRUE); @@ -1193,7 +1193,7 @@ static void TossPokeblockChoice_Yes(u8 taskId) static void HandleErasePokeblock(u8 taskId) { - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { s16 *data; u16 *lastPage, *lastPos; diff --git a/src/pokedex.c b/src/pokedex.c index c9fa2f691..e21048ce6 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -1673,7 +1673,7 @@ static void Task_HandlePokedexInput(u8 taskId) } else { - if ((gMain.newKeys & A_BUTTON) && sPokedexView->pokedexList[sPokedexView->selectedPokemon].seen) + if ((JOY_NEW(A_BUTTON)) && sPokedexView->pokedexList[sPokedexView->selectedPokemon].seen) { UpdateSelectedMonSpriteId(); BeginNormalPaletteFade(~(1 << (gSprites[sPokedexView->selectedMonSpriteId].oam.paletteNum + 16)), 0, 0, 0x10, RGB_BLACK); @@ -1682,7 +1682,7 @@ static void Task_HandlePokedexInput(u8 taskId) PlaySE(SE_PIN); FreeWindowAndBgBuffers(); } - else if (gMain.newKeys & START_BUTTON) + else if (JOY_NEW(START_BUTTON)) { sPokedexView->menuY = 0; sPokedexView->menuIsOpen = TRUE; @@ -1690,7 +1690,7 @@ static void Task_HandlePokedexInput(u8 taskId) gTasks[taskId].func = Task_HandlePokedexStartMenuInput; PlaySE(SE_SELECT); } - else if (gMain.newKeys & SELECT_BUTTON) + else if (JOY_NEW(SELECT_BUTTON)) { PlaySE(SE_SELECT); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); @@ -1704,7 +1704,7 @@ static void Task_HandlePokedexInput(u8 taskId) PlaySE(SE_PC_LOGIN); FreeWindowAndBgBuffers(); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gTasks[taskId].func = Task_ClosePokedex; @@ -1737,7 +1737,7 @@ static void Task_HandlePokedexStartMenuInput(u8 taskId) } else { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { switch (sPokedexView->menuCursorPos) { @@ -1768,18 +1768,18 @@ static void Task_HandlePokedexStartMenuInput(u8 taskId) } //Exit menu when Start or B is pressed - if (gMain.newKeys & (START_BUTTON | B_BUTTON)) + if (JOY_NEW(START_BUTTON | B_BUTTON)) { sPokedexView->menuIsOpen = FALSE; gTasks[taskId].func = Task_HandlePokedexInput; PlaySE(SE_SELECT); } - else if ((gMain.newAndRepeatedKeys & DPAD_UP) && sPokedexView->menuCursorPos != 0) + else if ((JOY_REPEAT(DPAD_UP)) && sPokedexView->menuCursorPos != 0) { sPokedexView->menuCursorPos--; PlaySE(SE_SELECT); } - else if ((gMain.newAndRepeatedKeys & DPAD_DOWN) && sPokedexView->menuCursorPos < 3) + else if ((JOY_REPEAT(DPAD_DOWN)) && sPokedexView->menuCursorPos < 3) { sPokedexView->menuCursorPos++; PlaySE(SE_SELECT); @@ -1873,7 +1873,7 @@ static void Task_HandleSearchResultsInput(u8 taskId) } else { - if ((gMain.newKeys & A_BUTTON) && sPokedexView->pokedexList[sPokedexView->selectedPokemon].seen) + if ((JOY_NEW(A_BUTTON)) && sPokedexView->pokedexList[sPokedexView->selectedPokemon].seen) { u32 a; @@ -1885,7 +1885,7 @@ static void Task_HandleSearchResultsInput(u8 taskId) PlaySE(SE_PIN); FreeWindowAndBgBuffers(); } - else if (gMain.newKeys & START_BUTTON) + else if (JOY_NEW(START_BUTTON)) { sPokedexView->menuY = 0; sPokedexView->menuIsOpen = TRUE; @@ -1893,7 +1893,7 @@ static void Task_HandleSearchResultsInput(u8 taskId) gTasks[taskId].func = Task_HandleSearchResultsStartMenuInput; PlaySE(SE_SELECT); } - else if (gMain.newKeys & SELECT_BUTTON) + else if (JOY_NEW(SELECT_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gTasks[taskId].tTaskId = LoadSearchMenu(); @@ -1902,7 +1902,7 @@ static void Task_HandleSearchResultsInput(u8 taskId) PlaySE(SE_PC_LOGIN); FreeWindowAndBgBuffers(); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); gTasks[taskId].func = Task_ReturnToPokedexFromSearchResults; @@ -1934,7 +1934,7 @@ static void Task_HandleSearchResultsStartMenuInput(u8 taskId) } else { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { switch (sPokedexView->menuCursorPos) { @@ -1970,18 +1970,18 @@ static void Task_HandleSearchResultsStartMenuInput(u8 taskId) } //Exit menu when Start or B is pressed - if (gMain.newKeys & (START_BUTTON | B_BUTTON)) + if (JOY_NEW(START_BUTTON | B_BUTTON)) { sPokedexView->menuIsOpen = FALSE; gTasks[taskId].func = Task_HandleSearchResultsInput; PlaySE(SE_SELECT); } - else if ((gMain.newAndRepeatedKeys & DPAD_UP) && sPokedexView->menuCursorPos) + else if ((JOY_REPEAT(DPAD_UP)) && sPokedexView->menuCursorPos) { sPokedexView->menuCursorPos--; PlaySE(SE_SELECT); } - else if ((gMain.newAndRepeatedKeys & DPAD_DOWN) && sPokedexView->menuCursorPos < 4) + else if ((JOY_REPEAT(DPAD_DOWN)) && sPokedexView->menuCursorPos < 4) { sPokedexView->menuCursorPos++; PlaySE(SE_SELECT); @@ -2590,7 +2590,7 @@ static u16 TryDoPokedexScroll(u16 selectedMon, u16 ignored) u16 startingPos; u8 scrollDir = 0; - if ((gMain.heldKeys & DPAD_UP) && (selectedMon > 0)) + if ((JOY_HELD(DPAD_UP)) && (selectedMon > 0)) { scrollDir = 1; selectedMon = GetNextPosition(1, selectedMon, 0, sPokedexView->pokemonListCount - 1); @@ -2598,7 +2598,7 @@ static u16 TryDoPokedexScroll(u16 selectedMon, u16 ignored) CreateMonListEntry(1, selectedMon, ignored); PlaySE(SE_DEX_SCROLL); } - else if ((gMain.heldKeys & DPAD_DOWN) && (selectedMon < sPokedexView->pokemonListCount - 1)) + else if ((JOY_HELD(DPAD_DOWN)) && (selectedMon < sPokedexView->pokemonListCount - 1)) { scrollDir = 2; selectedMon = GetNextPosition(0, selectedMon, 0, sPokedexView->pokemonListCount - 1); @@ -2606,7 +2606,7 @@ static u16 TryDoPokedexScroll(u16 selectedMon, u16 ignored) CreateMonListEntry(2, selectedMon, ignored); PlaySE(SE_DEX_SCROLL); } - else if ((gMain.newKeys & DPAD_LEFT) && (selectedMon > 0)) + else if ((JOY_NEW(DPAD_LEFT)) && (selectedMon > 0)) { startingPos = selectedMon; @@ -2617,7 +2617,7 @@ static u16 TryDoPokedexScroll(u16 selectedMon, u16 ignored) CreateMonSpritesAtPos(selectedMon, 0xE); PlaySE(SE_DEX_PAGE); } - else if ((gMain.newKeys & DPAD_RIGHT) && (selectedMon < sPokedexView->pokemonListCount - 1)) + else if ((JOY_NEW(DPAD_RIGHT)) && (selectedMon < sPokedexView->pokemonListCount - 1)) { startingPos = selectedMon; for (i = 0; i < 7; i++) @@ -2666,7 +2666,7 @@ static bool8 TryDoInfoScreenScroll(void) u16 nextPokemon; u16 selectedPokemon = sPokedexView->selectedPokemon; - if ((gMain.newKeys & DPAD_UP) && selectedPokemon) + if ((JOY_NEW(DPAD_UP)) && selectedPokemon) { nextPokemon = selectedPokemon; while (nextPokemon != 0) @@ -2689,7 +2689,7 @@ static bool8 TryDoInfoScreenScroll(void) return TRUE; } } - else if ((gMain.newKeys & DPAD_DOWN) && selectedPokemon < sPokedexView->pokemonListCount - 1) + else if ((JOY_NEW(DPAD_DOWN)) && selectedPokemon < sPokedexView->pokemonListCount - 1) { nextPokemon = selectedPokemon; while (nextPokemon < sPokedexView->pokemonListCount - 1) @@ -3356,14 +3356,14 @@ static void Task_HandleInfoScreenInput(u8 taskId) PlaySE(SE_DEX_SCROLL); return; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); gTasks[taskId].func = Task_ExitInfoScreen; PlaySE(SE_PC_OFF); return; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { switch (sPokedexView->selectedScreen) { @@ -3400,8 +3400,8 @@ static void Task_HandleInfoScreenInput(u8 taskId) } return; } - if (((gMain.newKeys & DPAD_LEFT) - || ((gMain.newKeys & L_BUTTON) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) + if (((JOY_NEW(DPAD_LEFT)) + || ((JOY_NEW(L_BUTTON)) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) && sPokedexView->selectedScreen > 0) { sPokedexView->selectedScreen--; @@ -3409,8 +3409,8 @@ static void Task_HandleInfoScreenInput(u8 taskId) PlaySE(SE_DEX_PAGE); return; } - if (((gMain.newKeys & DPAD_RIGHT) - || ((gMain.newKeys & R_BUTTON) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) + if (((JOY_NEW(DPAD_RIGHT)) + || ((JOY_NEW(R_BUTTON)) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) && sPokedexView->selectedScreen < CANCEL_SCREEN) { sPokedexView->selectedScreen++; @@ -3630,7 +3630,7 @@ static void Task_HandleCryScreenInput(u8 taskId) else LoadPlayArrowPalette(FALSE); - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { LoadPlayArrowPalette(TRUE); CryScreenPlayButton(NationalPokedexNumToSpecies(sPokedexListItem->dexNum)); @@ -3638,7 +3638,7 @@ static void Task_HandleCryScreenInput(u8 taskId) } else if (!gPaletteFade.active) { - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK); m4aMPlayContinue(&gMPlayInfo_BGM); @@ -3647,8 +3647,8 @@ static void Task_HandleCryScreenInput(u8 taskId) PlaySE(SE_PC_OFF); return; } - if ((gMain.newKeys & DPAD_LEFT) - || ((gMain.newKeys & L_BUTTON) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) + if ((JOY_NEW(DPAD_LEFT)) + || ((JOY_NEW(L_BUTTON)) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) { BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK); m4aMPlayContinue(&gMPlayInfo_BGM); @@ -3657,8 +3657,8 @@ static void Task_HandleCryScreenInput(u8 taskId) PlaySE(SE_DEX_PAGE); return; } - if ((gMain.newKeys & DPAD_RIGHT) - || ((gMain.newKeys & R_BUTTON) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) + if ((JOY_NEW(DPAD_RIGHT)) + || ((JOY_NEW(R_BUTTON)) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) { if (!sPokedexListItem->owned) { @@ -3810,15 +3810,15 @@ static void Task_LoadSizeScreen(u8 taskId) static void Task_HandleSizeScreenInput(u8 taskId) { - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK); sPokedexView->screenSwitchState = 1; gTasks[taskId].func = Task_SwitchScreensFromSizeScreen; PlaySE(SE_PC_OFF); } - else if ((gMain.newKeys & DPAD_LEFT) - || ((gMain.newKeys & L_BUTTON) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) + else if ((JOY_NEW(DPAD_LEFT)) + || ((JOY_NEW(L_BUTTON)) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) { BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 0x10, RGB_BLACK); sPokedexView->screenSwitchState = 2; @@ -4010,7 +4010,7 @@ static void Task_DisplayCaughtMonDexPage(u8 taskId) static void Task_HandleCaughtMonPageInput(u8 taskId) { - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { BeginNormalPaletteFade(0x0000FFFF, 0, 0, 16, RGB_BLACK); gSprites[gTasks[taskId].tMonSpriteId].callback = SpriteCB_SlideCaughtMonToCenter; @@ -4907,13 +4907,13 @@ static void Task_SwitchToSearchMenuTopBar(u8 taskId) static void Task_HandleSearchTopBarInput(u8 taskId) { - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_PC_OFF); gTasks[taskId].func = Task_ExitSearch; return; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { switch (gTasks[taskId].tTopBarItem) { @@ -4934,7 +4934,7 @@ static void Task_HandleSearchTopBarInput(u8 taskId) } return; } - if ((gMain.newKeys & DPAD_LEFT) && gTasks[taskId].tTopBarItem > SEARCH_TOPBAR_SEARCH) + if ((JOY_NEW(DPAD_LEFT)) && gTasks[taskId].tTopBarItem > SEARCH_TOPBAR_SEARCH) { PlaySE(SE_DEX_PAGE); gTasks[taskId].tTopBarItem--; @@ -4942,7 +4942,7 @@ static void Task_HandleSearchTopBarInput(u8 taskId) CopyWindowToVram(0, 2); CopyBgTilemapBufferToVram(3); } - if ((gMain.newKeys & DPAD_RIGHT) && gTasks[taskId].tTopBarItem < SEARCH_TOPBAR_CANCEL) + if ((JOY_NEW(DPAD_RIGHT)) && gTasks[taskId].tTopBarItem < SEARCH_TOPBAR_CANCEL) { PlaySE(SE_DEX_PAGE); gTasks[taskId].tTopBarItem++; @@ -4981,14 +4981,14 @@ static void Task_HandleSearchMenuInput(u8 taskId) movementMap = sSearchMovementMap_SearchNatDex; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_BALL); SetDefaultSearchModeAndOrder(taskId); gTasks[taskId].func = Task_SwitchToSearchMenuTopBar; return; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (gTasks[taskId].tMenuItem == SEARCH_OK) { @@ -5023,7 +5023,7 @@ static void Task_HandleSearchMenuInput(u8 taskId) return; } - if ((gMain.newKeys & DPAD_LEFT) && movementMap[gTasks[taskId].tMenuItem][0] != 0xFF) + if ((JOY_NEW(DPAD_LEFT)) && movementMap[gTasks[taskId].tMenuItem][0] != 0xFF) { PlaySE(SE_SELECT); gTasks[taskId].tMenuItem = movementMap[gTasks[taskId].tMenuItem][0]; @@ -5031,7 +5031,7 @@ static void Task_HandleSearchMenuInput(u8 taskId) CopyWindowToVram(0, 2); CopyBgTilemapBufferToVram(3); } - if ((gMain.newKeys & DPAD_RIGHT) && movementMap[gTasks[taskId].tMenuItem][1] != 0xFF) + if ((JOY_NEW(DPAD_RIGHT)) && movementMap[gTasks[taskId].tMenuItem][1] != 0xFF) { PlaySE(SE_SELECT); gTasks[taskId].tMenuItem = movementMap[gTasks[taskId].tMenuItem][1]; @@ -5039,7 +5039,7 @@ static void Task_HandleSearchMenuInput(u8 taskId) CopyWindowToVram(0, 2); CopyBgTilemapBufferToVram(3); } - if ((gMain.newKeys & DPAD_UP) && movementMap[gTasks[taskId].tMenuItem][2] != 0xFF) + if ((JOY_NEW(DPAD_UP)) && movementMap[gTasks[taskId].tMenuItem][2] != 0xFF) { PlaySE(SE_SELECT); gTasks[taskId].tMenuItem = movementMap[gTasks[taskId].tMenuItem][2]; @@ -5047,7 +5047,7 @@ static void Task_HandleSearchMenuInput(u8 taskId) CopyWindowToVram(0, 2); CopyBgTilemapBufferToVram(3); } - if ((gMain.newKeys & DPAD_DOWN) && movementMap[gTasks[taskId].tMenuItem][3] != 0xFF) + if ((JOY_NEW(DPAD_DOWN)) && movementMap[gTasks[taskId].tMenuItem][3] != 0xFF) { PlaySE(SE_SELECT); gTasks[taskId].tMenuItem = movementMap[gTasks[taskId].tMenuItem][3]; @@ -5091,7 +5091,7 @@ static void Task_WaitAndCompleteSearch(u8 taskId) static void Task_SearchCompleteWaitForInput(u8 taskId) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (sPokedexView->pokemonListCount != 0) { @@ -5144,7 +5144,7 @@ static void Task_HandleSearchParameterInput(u8 taskId) cursorPos = &gTasks[taskId].data[sSearchOptions[menuItem].taskDataCursorPos]; scrollOffset = &gTasks[taskId].data[sSearchOptions[menuItem].taskDataScrollOffset]; maxOption = sSearchOptions[menuItem].numOptions - 1; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_PIN); ClearSearchParameterBoxText(); @@ -5154,7 +5154,7 @@ static void Task_HandleSearchParameterInput(u8 taskId) CopyBgTilemapBufferToVram(3); return; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_BALL); ClearSearchParameterBoxText(); @@ -5167,7 +5167,7 @@ static void Task_HandleSearchParameterInput(u8 taskId) return; } moved = FALSE; - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPEAT(DPAD_UP)) { if (*cursorPos != 0) { @@ -5193,7 +5193,7 @@ static void Task_HandleSearchParameterInput(u8 taskId) } return; } - if (gMain.newAndRepeatedKeys & DPAD_DOWN) + if (JOY_REPEAT(DPAD_DOWN)) { if (*cursorPos < MAX_SEARCH_PARAM_CURSOR_POS && *cursorPos < maxOption) { diff --git a/src/pokedex_area_screen.c b/src/pokedex_area_screen.c index 8450f8530..fdbd2f40c 100755 --- a/src/pokedex_area_screen.c +++ b/src/pokedex_area_screen.c @@ -724,12 +724,12 @@ static void Task_HandlePokedexAreaScreenInput(u8 taskId) return; break; case 1: - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { gTasks[taskId].data[1] = 1; PlaySE(SE_PC_OFF); } - else if (gMain.newKeys & DPAD_RIGHT || (gMain.newKeys & R_BUTTON && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) + else if (JOY_NEW(DPAD_RIGHT) || (JOY_NEW(R_BUTTON) && gSaveBlock2Ptr->optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) { gTasks[taskId].data[1] = 2; PlaySE(SE_DEX_PAGE); diff --git a/src/pokemon_jump.c b/src/pokemon_jump.c index 07f6bc54b..84d869a1a 100755 --- a/src/pokemon_jump.c +++ b/src/pokemon_jump.c @@ -1245,7 +1245,7 @@ static bool32 sub_802B8CC(void) break; // fall through case 1: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { sub_802C164(); sub_802AE14(3); @@ -1336,7 +1336,7 @@ static bool32 sub_802BA58(void) case 2: case 5: gUnknown_02022CFC->unk3C++; - if (gMain.newKeys & (A_BUTTON | B_BUTTON) || gUnknown_02022CFC->unk3C > 180) + if (JOY_NEW(A_BUTTON | B_BUTTON) || gUnknown_02022CFC->unk3C > 180) { sub_802DA14(); gUnknown_02022CFC->unkA++; @@ -3922,7 +3922,7 @@ static void Task_ShowPokemonJumpRecords(u8 taskId) data[0]++; break; case 2: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { rbox_fill_rectangle(data[1]); CopyWindowToVram(data[1], 1); diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index fcca744c2..ae334504e 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -1756,10 +1756,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 +1798,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 +1814,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 +1976,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 +2393,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 +2615,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 +2632,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 +2858,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 +2943,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 +3034,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 +3095,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 +3134,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 +3157,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); @@ -3257,7 +3257,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 +3296,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 +3309,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 +3349,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 +3388,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 +3438,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 +3494,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 +3759,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 +3820,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 +5462,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; @@ -6940,7 +6940,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 +6954,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 +6968,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 +6982,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 +6996,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 +7004,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 +7038,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 +7067,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 +7081,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 +7093,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 +7105,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 +7142,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 +7154,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 +7166,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 +7178,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 +7190,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 +7203,7 @@ static u8 InBoxInput_MovingMultiple(void) return 24; } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { return 24; } @@ -7211,9 +7211,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 +7238,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 +7246,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 +7254,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 +7277,7 @@ static u8 HandleInput_InParty(void) break; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (sBoxCursorPosition == PARTY_SIZE) { @@ -7313,7 +7313,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 +7327,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 +7356,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 +7364,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 +7372,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 +7429,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 +7441,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 +7451,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 +7466,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 +7920,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); diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index d016c455c..9b8e4ef9e 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -1497,23 +1497,23 @@ static void Task_HandleInput(u8 taskId) { if (MenuHelpers_CallLinkSomething() != TRUE && !gPaletteFade.active) { - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { ChangeSummaryPokemon(taskId, -1); } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { ChangeSummaryPokemon(taskId, 1); } - else if ((gMain.newKeys & DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED) + else if ((JOY_NEW(DPAD_LEFT)) || GetLRKeysPressed() == MENU_L_PRESSED) { ChangePage(taskId, -1); } - else if ((gMain.newKeys & DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED) + else if ((JOY_NEW(DPAD_RIGHT)) || GetLRKeysPressed() == MENU_R_PRESSED) { ChangePage(taskId, 1); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { if (sMonSummaryScreen->currPageIndex != PSS_PAGE_SKILLS) { @@ -1530,7 +1530,7 @@ static void Task_HandleInput(u8 taskId) } } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { StopPokemonAnimations(); PlaySE(SE_SELECT); @@ -1878,17 +1878,17 @@ static void Task_HandleInput_MoveSelect(u8 taskId) if (MenuHelpers_CallLinkSomething() != 1) { - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { data[0] = 4; ChangeSelectedMove(data, -1, &sMonSummaryScreen->firstMoveIndex); } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { data[0] = 4; ChangeSelectedMove(data, 1, &sMonSummaryScreen->firstMoveIndex); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { if (sMonSummaryScreen->lockMovesFlag == TRUE || (sMonSummaryScreen->newMove == MOVE_NONE && sMonSummaryScreen->firstMoveIndex == MAX_MON_MOVES)) @@ -1906,7 +1906,7 @@ static void Task_HandleInput_MoveSelect(u8 taskId) PlaySE(SE_FAILURE); } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); CloseMoveSelectMode(taskId); @@ -2018,24 +2018,24 @@ static void Task_HandleInput_MovePositionSwitch(u8 taskId) if (MenuHelpers_CallLinkSomething() != TRUE) { - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { data[0] = 3; ChangeSelectedMove(&data[0], -1, &sMonSummaryScreen->secondMoveIndex); } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { data[0] = 3; ChangeSelectedMove(&data[0], 1, &sMonSummaryScreen->secondMoveIndex); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { if (sMonSummaryScreen->firstMoveIndex == sMonSummaryScreen->secondMoveIndex) ExitMovePositionSwitchMode(taskId, FALSE); else ExitMovePositionSwitchMode(taskId, TRUE); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { ExitMovePositionSwitchMode(taskId, FALSE); } @@ -2161,25 +2161,25 @@ static void Task_HandleReplaceMoveInput(u8 taskId) { if (gPaletteFade.active != TRUE) { - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { data[0] = 4; ChangeSelectedMove(data, -1, &sMonSummaryScreen->firstMoveIndex); } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { data[0] = 4; ChangeSelectedMove(data, 1, &sMonSummaryScreen->firstMoveIndex); } - else if (gMain.newKeys & DPAD_LEFT || GetLRKeysPressed() == MENU_L_PRESSED) + else if (JOY_NEW(DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED) { ChangePage(taskId, -1); } - else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysPressed() == MENU_R_PRESSED) + else if (JOY_NEW(DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED) { ChangePage(taskId, 1); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { if (CanReplaceMove() == TRUE) { @@ -2195,7 +2195,7 @@ static void Task_HandleReplaceMoveInput(u8 taskId) ShowCantForgetHMsWindow(taskId); } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { StopPokemonAnimations(); PlaySE(SE_SELECT); @@ -2235,7 +2235,7 @@ static void Task_HandleInputCantForgetHMsMoves(u8 taskId) u16 move; if (FuncIsActiveTask(Task_ShowPowerAccWindow) != 1) { - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { data[1] = 1; data[0] = 4; @@ -2243,7 +2243,7 @@ static void Task_HandleInputCantForgetHMsMoves(u8 taskId) data[1] = 0; gTasks[taskId].func = Task_HandleReplaceMoveInput; } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { data[1] = 1; data[0] = 4; @@ -2251,7 +2251,7 @@ static void Task_HandleInputCantForgetHMsMoves(u8 taskId) data[1] = 0; gTasks[taskId].func = Task_HandleReplaceMoveInput; } - else if (gMain.newKeys & DPAD_LEFT || GetLRKeysPressed() == MENU_L_PRESSED) + else if (JOY_NEW(DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED) { if (sMonSummaryScreen->currPageIndex != PSS_PAGE_BATTLE_MOVES) { @@ -2265,7 +2265,7 @@ static void Task_HandleInputCantForgetHMsMoves(u8 taskId) HandleAppealJamTilemap(9, -2, move); } } - else if (gMain.newKeys & DPAD_RIGHT || GetLRKeysPressed() == MENU_R_PRESSED) + else if (JOY_NEW(DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED) { if (sMonSummaryScreen->currPageIndex != PSS_PAGE_CONTEST_MOVES) { @@ -2279,7 +2279,7 @@ static void Task_HandleInputCantForgetHMsMoves(u8 taskId) HandleAppealJamTilemap(9, -2, move); } } - else if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + else if (JOY_NEW(A_BUTTON | B_BUTTON)) { ClearWindowTilemap(PSS_LABEL_WINDOW_PORTRAIT_SPECIES); if (!gSprites[sMonSummaryScreen->spriteIds[SPRITE_ARR_ID_STATUS]].invisible) diff --git a/src/pokenav_conditions_1.c b/src/pokenav_conditions_1.c index 1c7573a44..488d40d13 100644 --- a/src/pokenav_conditions_1.c +++ b/src/pokenav_conditions_1.c @@ -89,13 +89,13 @@ u32 sub_81CD08C(struct PokenavSub11 *structPtr) if (ret == 0) { - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); structPtr->unk6304 = sub_81CD19C; ret = 2; } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { if (structPtr->unk6300 == 0) { @@ -166,7 +166,7 @@ u8 sub_81CD1E4(struct PokenavSub11 *structPtr) struct PokenavSub18 *unkPtr = GetSubstructPtr(18); u8 ret = 0; - if (gMain.heldKeys & DPAD_UP) + if (JOY_HELD(DPAD_UP)) { if (structPtr->unk6300 == 0 || unkPtr->unk2 != 0) { @@ -174,7 +174,7 @@ u8 sub_81CD1E4(struct PokenavSub11 *structPtr) ret = sub_81CD258(1); } } - else if (gMain.heldKeys & DPAD_DOWN) + else if (JOY_HELD(DPAD_DOWN)) { if (structPtr->unk6300 == 0 || unkPtr->unk2 < unkPtr->unk0 - 1) { diff --git a/src/pokenav_conditions_3.c b/src/pokenav_conditions_3.c index eea4aa397..0c1fb08d2 100644 --- a/src/pokenav_conditions_3.c +++ b/src/pokenav_conditions_3.c @@ -170,21 +170,21 @@ static bool32 sub_81CF010(struct PokenavSub7 *structPtr) static u32 sub_81CF030(struct PokenavSub7 *structPtr) { - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPEAT(DPAD_UP)) return 1; - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPEAT(DPAD_DOWN)) return 2; - else if (gMain.newKeys & DPAD_LEFT) + else if (JOY_NEW(DPAD_LEFT)) return 3; - else if (gMain.newKeys & DPAD_RIGHT) + else if (JOY_NEW(DPAD_RIGHT)) return 4; - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { structPtr->unk1C = 0; structPtr->unk0 = sub_81CF0B0; return 5; } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { structPtr->unkPtr->unk2 = GetSelectedMatchCall(); structPtr->unk1C = 1; diff --git a/src/pokenav_match_call_1.c b/src/pokenav_match_call_1.c index 265259394..d919a4dbf 100755 --- a/src/pokenav_match_call_1.c +++ b/src/pokenav_match_call_1.c @@ -79,16 +79,16 @@ static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state) { int selection; - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPEAT(DPAD_UP)) return POKENAV_MC_FUNC_UP; - if (gMain.newAndRepeatedKeys & DPAD_DOWN) + if (JOY_REPEAT(DPAD_DOWN)) return POKENAV_MC_FUNC_DOWN; - if (gMain.newAndRepeatedKeys & DPAD_LEFT) + if (JOY_REPEAT(DPAD_LEFT)) return POKENAV_MC_FUNC_PG_UP; - if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + if (JOY_REPEAT(DPAD_RIGHT)) return POKENAV_MC_FUNC_PG_DOWN; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { state->callback = CB2_HandleMatchCallOptionsInput; state->optionCursorPos = 0; @@ -108,7 +108,7 @@ static u32 CB2_HandleMatchCallInput(struct Pokenav3Struct *state) return POKENAV_MC_FUNC_SELECT; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { if (GetPokenavMode() != POKENAV_MODE_FORCE_CALL_READY) { @@ -132,19 +132,19 @@ static u32 GetExitMatchCallMenuId(struct Pokenav3Struct *state) static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav3Struct *state) { - if ((gMain.newKeys & DPAD_UP) && state->optionCursorPos) + if ((JOY_NEW(DPAD_UP)) && state->optionCursorPos) { state->optionCursorPos--; return POKENAV_MC_FUNC_MOVE_OPTIONS_CURSOR; } - if ((gMain.newKeys & DPAD_DOWN) && state->optionCursorPos < state->maxOptionId) + if ((JOY_NEW(DPAD_DOWN)) && state->optionCursorPos < state->maxOptionId) { state->optionCursorPos++; return POKENAV_MC_FUNC_MOVE_OPTIONS_CURSOR; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { switch (state->matchCallOptions[state->optionCursorPos]) { @@ -166,7 +166,7 @@ static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav3Struct *state) } } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { state->callback = CB2_HandleMatchCallInput; return POKENAV_MC_FUNC_CANCEL; @@ -177,12 +177,12 @@ static u32 CB2_HandleMatchCallOptionsInput(struct Pokenav3Struct *state) static u32 CB2_HandleCheckPageInput(struct Pokenav3Struct *state) { - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPEAT(DPAD_UP)) return POKENAV_MC_FUNC_CHECK_PAGE_UP; - if (gMain.newAndRepeatedKeys & DPAD_DOWN) + if (JOY_REPEAT(DPAD_DOWN)) return POKENAV_MC_FUNC_CHECK_PAGE_DOWN; - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { state->callback = CB2_HandleMatchCallInput; return POKENAV_MC_FUNC_EXIT_CHECK_PAGE; @@ -193,7 +193,7 @@ static u32 CB2_HandleCheckPageInput(struct Pokenav3Struct *state) static u32 CB2_HandleCallInput(struct Pokenav3Struct *state) { - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { state->callback = CB2_HandleMatchCallInput; return POKENAV_MC_FUNC_10; diff --git a/src/pokenav_match_call_2.c b/src/pokenav_match_call_2.c index 60091577e..424882670 100755 --- a/src/pokenav_match_call_2.c +++ b/src/pokenav_match_call_2.c @@ -1126,7 +1126,7 @@ static void PrintMatchCallMessage(struct Pokenav4Struct *state) static bool32 WaitForMatchCallMessageText(struct Pokenav4Struct *state) { - if (gMain.heldKeys & A_BUTTON) + if (JOY_HELD(A_BUTTON)) gTextFlags.canABSpeedUpPrint = 1; else gTextFlags.canABSpeedUpPrint = 0; diff --git a/src/pokenav_menu_handler_1.c b/src/pokenav_menu_handler_1.c index d8d8e1509..6002d731b 100644 --- a/src/pokenav_menu_handler_1.c +++ b/src/pokenav_menu_handler_1.c @@ -216,7 +216,7 @@ static u32 HandleMainMenuInput(struct Pokenav1Struct *state) if (UpdateMenuCursorPos(state)) return POKENAV_MENU_FUNC_MOVE_CURSOR; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { switch (sMenuItems[state->menuType][state->cursorPos]) { @@ -251,7 +251,7 @@ static u32 HandleMainMenuInput(struct Pokenav1Struct *state) } } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) return -1; return POKENAV_MENU_FUNC_NONE; @@ -263,7 +263,7 @@ static u32 HandleMainMenuInputTutorial(struct Pokenav1Struct *state) if (UpdateMenuCursorPos(state)) return POKENAV_MENU_FUNC_MOVE_CURSOR; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (sMenuItems[state->menuType][state->cursorPos] == POKENAV_MENUITEM_MATCH_CALL) { @@ -278,7 +278,7 @@ static u32 HandleMainMenuInputTutorial(struct Pokenav1Struct *state) } } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_FAILURE); return POKENAV_MENU_FUNC_NONE; @@ -293,7 +293,7 @@ static u32 HandleMainMenuInputEndTutorial(struct Pokenav1Struct *state) if (UpdateMenuCursorPos(state)) return POKENAV_MENU_FUNC_MOVE_CURSOR; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { u32 menuItem = sMenuItems[state->menuType][state->cursorPos]; if (menuItem != POKENAV_MENUITEM_MATCH_CALL && menuItem != POKENAV_MENUITEM_SWITCH_OFF) @@ -312,7 +312,7 @@ static u32 HandleMainMenuInputEndTutorial(struct Pokenav1Struct *state) return -1; } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { return -1; } @@ -329,7 +329,7 @@ static u32 HandleCantOpenRibbonsInput(struct Pokenav1Struct *state) return POKENAV_MENU_FUNC_MOVE_CURSOR; } - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { state->callback = GetMainMenuInputHandler(); return POKENAV_MENU_FUNC_RESHOW_DESCRIPTION; @@ -343,7 +343,7 @@ static u32 HandleConditionMenuInput(struct Pokenav1Struct *state) if (UpdateMenuCursorPos(state)) return POKENAV_MENU_FUNC_MOVE_CURSOR; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { switch (sMenuItems[state->menuType][state->cursorPos]) { @@ -363,7 +363,7 @@ static u32 HandleConditionMenuInput(struct Pokenav1Struct *state) return POKENAV_MENU_FUNC_RETURN_TO_MAIN; } } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { if (state->cursorPos != sLastCursorPositions[state->menuType]) { @@ -387,7 +387,7 @@ static u32 HandleConditionSearchMenuInput(struct Pokenav1Struct *state) if (UpdateMenuCursorPos(state)) return POKENAV_MENU_FUNC_MOVE_CURSOR; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { u8 menuItem = sMenuItems[state->menuType][state->cursorPos]; if (menuItem != POKENAV_MENUITEM_CONDITION_SEARCH_CANCEL) @@ -404,7 +404,7 @@ static u32 HandleConditionSearchMenuInput(struct Pokenav1Struct *state) return POKENAV_MENU_FUNC_RETURN_TO_CONDITION; } } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { if (state->cursorPos != sLastCursorPositions[state->menuType]) { @@ -463,7 +463,7 @@ static void ReturnToConditionMenu(struct Pokenav1Struct *state) static bool32 UpdateMenuCursorPos(struct Pokenav1Struct *state) { - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { if (--state->cursorPos < 0) state->cursorPos = sLastCursorPositions[state->menuType]; @@ -471,7 +471,7 @@ static bool32 UpdateMenuCursorPos(struct Pokenav1Struct *state) state->currMenuItem = sMenuItems[state->menuType][state->cursorPos]; return TRUE; } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { state->cursorPos++; if (state->cursorPos > sLastCursorPositions[state->menuType]) diff --git a/src/pokenav_region_map.c b/src/pokenav_region_map.c index e858fad4a..394b40907 100755 --- a/src/pokenav_region_map.c +++ b/src/pokenav_region_map.c @@ -219,7 +219,7 @@ static u32 HandleRegionMapInput(struct Pokenav5Struct *state) static u32 HandleRegionMapInputZoomDisabled(struct Pokenav5Struct *state) { - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { state->callback = GetExitRegionMapMenuId; return POKENAV_MAP_FUNC_EXIT; diff --git a/src/pokenav_ribbons_1.c b/src/pokenav_ribbons_1.c index aad0053a8..fd47b27ad 100644 --- a/src/pokenav_ribbons_1.c +++ b/src/pokenav_ribbons_1.c @@ -162,21 +162,21 @@ static u32 sub_81CFA68(struct PokenavSub9 *structPtr) static u32 sub_81CFA88(struct PokenavSub9 *structPtr) { - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPEAT(DPAD_UP)) return 1; - if (gMain.newAndRepeatedKeys & DPAD_DOWN) + if (JOY_REPEAT(DPAD_DOWN)) return 2; - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) return 3; - if (gMain.newKeys & DPAD_RIGHT) + if (JOY_NEW(DPAD_RIGHT)) return 4; - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { structPtr->unk18 = 0; structPtr->unk0 = sub_81CFB08; return 5; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { structPtr->unk1C->unk2 = GetSelectedMatchCall(); structPtr->unk18 = 1; diff --git a/src/pokenav_ribbons_2.c b/src/pokenav_ribbons_2.c index 9717acbac..6eabc9b33 100644 --- a/src/pokenav_ribbons_2.c +++ b/src/pokenav_ribbons_2.c @@ -188,26 +188,26 @@ void sub_81D04B8(void) u32 sub_81D04C4(struct PokenavSub13 *structPtr) { - if (gMain.newAndRepeatedKeys & DPAD_UP && structPtr->field_8->unk2 != 0) + if (JOY_REPEAT(DPAD_UP) && structPtr->field_8->unk2 != 0) { structPtr->field_8->unk2--; structPtr->field_C = 0; sub_81D0814(structPtr); return 1; } - if (gMain.newAndRepeatedKeys & DPAD_DOWN && structPtr->field_8->unk2 < structPtr->field_8->unk0 - 1) + if (JOY_REPEAT(DPAD_DOWN) && structPtr->field_8->unk2 < structPtr->field_8->unk0 - 1) { structPtr->field_8->unk2++; structPtr->field_C = 0; sub_81D0814(structPtr); return 1; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { structPtr->field_98 = sub_81D0548; return 2; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { structPtr->field_98 = sub_81D05D4; return 5; @@ -217,15 +217,15 @@ u32 sub_81D04C4(struct PokenavSub13 *structPtr) u32 sub_81D0548(struct PokenavSub13 *structPtr) { - if (gMain.newAndRepeatedKeys & DPAD_UP && sub_81D05DC(structPtr)) + if (JOY_REPEAT(DPAD_UP) && sub_81D05DC(structPtr)) return 3; - if (gMain.newAndRepeatedKeys & DPAD_DOWN && sub_81D061C(structPtr)) + if (JOY_REPEAT(DPAD_DOWN) && sub_81D061C(structPtr)) return 3; - if (gMain.newAndRepeatedKeys & DPAD_LEFT && sub_81D0664(structPtr)) + if (JOY_REPEAT(DPAD_LEFT) && sub_81D0664(structPtr)) return 3; - if (gMain.newAndRepeatedKeys & DPAD_RIGHT && sub_81D0688(structPtr)) + if (JOY_REPEAT(DPAD_RIGHT) && sub_81D0688(structPtr)) return 3; - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { structPtr->field_98 = sub_81D04C4; return 4; diff --git a/src/region_map.c b/src/region_map.c index 3438ea3ed..49b21be07 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -651,31 +651,31 @@ static u8 ProcessRegionMapInput_Full(void) input = MAP_INPUT_NONE; gRegionMap->cursorDeltaX = 0; gRegionMap->cursorDeltaY = 0; - if (gMain.heldKeys & DPAD_UP && gRegionMap->cursorPosY > MAPCURSOR_Y_MIN) + if (JOY_HELD(DPAD_UP) && gRegionMap->cursorPosY > MAPCURSOR_Y_MIN) { gRegionMap->cursorDeltaY = -1; input = MAP_INPUT_MOVE_START; } - if (gMain.heldKeys & DPAD_DOWN && gRegionMap->cursorPosY < MAPCURSOR_Y_MAX) + if (JOY_HELD(DPAD_DOWN) && gRegionMap->cursorPosY < MAPCURSOR_Y_MAX) { gRegionMap->cursorDeltaY = +1; input = MAP_INPUT_MOVE_START; } - if (gMain.heldKeys & DPAD_LEFT && gRegionMap->cursorPosX > MAPCURSOR_X_MIN) + if (JOY_HELD(DPAD_LEFT) && gRegionMap->cursorPosX > MAPCURSOR_X_MIN) { gRegionMap->cursorDeltaX = -1; input = MAP_INPUT_MOVE_START; } - if (gMain.heldKeys & DPAD_RIGHT && gRegionMap->cursorPosX < MAPCURSOR_X_MAX) + if (JOY_HELD(DPAD_RIGHT) && gRegionMap->cursorPosX < MAPCURSOR_X_MAX) { gRegionMap->cursorDeltaX = +1; input = MAP_INPUT_MOVE_START; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { input = MAP_INPUT_A_BUTTON; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { input = MAP_INPUT_B_BUTTON; } @@ -730,31 +730,31 @@ static u8 ProcessRegionMapInput_Zoomed(void) input = MAP_INPUT_NONE; gRegionMap->zoomedCursorDeltaX = 0; gRegionMap->zoomedCursorDeltaY = 0; - if (gMain.heldKeys & DPAD_UP && gRegionMap->scrollY > -0x34) + if (JOY_HELD(DPAD_UP) && gRegionMap->scrollY > -0x34) { gRegionMap->zoomedCursorDeltaY = -1; input = MAP_INPUT_MOVE_START; } - if (gMain.heldKeys & DPAD_DOWN && gRegionMap->scrollY < 0x3c) + if (JOY_HELD(DPAD_DOWN) && gRegionMap->scrollY < 0x3c) { gRegionMap->zoomedCursorDeltaY = +1; input = MAP_INPUT_MOVE_START; } - if (gMain.heldKeys & DPAD_LEFT && gRegionMap->scrollX > -0x2c) + if (JOY_HELD(DPAD_LEFT) && gRegionMap->scrollX > -0x2c) { gRegionMap->zoomedCursorDeltaX = -1; input = MAP_INPUT_MOVE_START; } - if (gMain.heldKeys & DPAD_RIGHT && gRegionMap->scrollX < 0xac) + if (JOY_HELD(DPAD_RIGHT) && gRegionMap->scrollX < 0xac) { gRegionMap->zoomedCursorDeltaX = +1; input = MAP_INPUT_MOVE_START; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { input = MAP_INPUT_A_BUTTON; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { input = MAP_INPUT_B_BUTTON; } diff --git a/src/reset_rtc_screen.c b/src/reset_rtc_screen.c index 204eb6733..d0e815816 100644 --- a/src/reset_rtc_screen.c +++ b/src/reset_rtc_screen.c @@ -380,7 +380,7 @@ static void Task_ResetRtc_1(u8 taskId) u8 selection = data[2]; const struct ResetRtcStruct *selectionInfo = &sUnknown_08510428[selection - 1]; - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { gTasks[taskId].func = Task_ResetRtc_2; data[1] = 0; @@ -389,7 +389,7 @@ static void Task_ResetRtc_1(u8 taskId) return; } - if (gMain.newKeys & DPAD_RIGHT) + if (JOY_NEW(DPAD_RIGHT)) { if (selectionInfo->right) { @@ -399,7 +399,7 @@ static void Task_ResetRtc_1(u8 taskId) } } - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { if (selectionInfo->left) { @@ -411,7 +411,7 @@ static void Task_ResetRtc_1(u8 taskId) if (selection == 5) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { gLocalTime.days = data[3]; gLocalTime.hours = data[4]; @@ -423,7 +423,7 @@ static void Task_ResetRtc_1(u8 taskId) data[2] = 6; } } - else if (MoveTimeUpDown(&data[selectionInfo->dataIndex], selectionInfo->minVal, selectionInfo->maxVal, gMain.newAndRepeatedKeys & (DPAD_UP | DPAD_DOWN))) + else if (MoveTimeUpDown(&data[selectionInfo->dataIndex], selectionInfo->minVal, selectionInfo->maxVal, JOY_REPEAT(DPAD_UP | DPAD_DOWN))) { PlaySE(SE_SELECT); PrintTime(data[8], 0, 1, data[3], data[4], data[5], data[6]); @@ -532,12 +532,12 @@ static void Task_ShowResetRtcPrompt(u8 taskId) ScheduleBgCopyTilemapToVram(0); data[0]++; case 1: - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { DestroyTask(taskId); DoSoftReset(); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); DestroyTask(taskId); @@ -620,7 +620,7 @@ static void Task_ResetRtcScreen(u8 taskId) } data[0] = 5; case 5: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFFF, 1, 0, 0x10, RGB_WHITEALPHA); data[0] = 6; diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c index 7c824e82d..9bf0e7ed4 100644 --- a/src/save_failed_screen.c +++ b/src/save_failed_screen.c @@ -306,7 +306,7 @@ static void CB2_GameplayCannotBeContinued(void) { gSaveFailedClockInfo[CLOCK_RUNNING] = FALSE; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { FillWindowPixelBuffer(gSaveFailedWindowIds[TEXT_WIN_ID], PIXEL_FILL(1)); SaveFailedScreenTextPrint(gText_GamePlayCannotBeContinued, 1, 0); @@ -319,7 +319,7 @@ static void CB2_FadeAndReturnToTitleScreen(void) { gSaveFailedClockInfo[CLOCK_RUNNING] = FALSE; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); SetVBlankCallback(VBlankCB); diff --git a/src/scrcmd.c b/src/scrcmd.c index d2ebcbb85..578e357fa 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -1325,9 +1325,9 @@ bool8 ScrCmd_closemessage(struct ScriptContext *ctx) static bool8 WaitForAorBPress(void) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) return TRUE; - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) return TRUE; return FALSE; } diff --git a/src/script_menu.c b/src/script_menu.c index 2b135e301..425cdc251 100644 --- a/src/script_menu.c +++ b/src/script_menu.c @@ -170,7 +170,7 @@ static void Task_HandleMultichoiceInput(u8 taskId) else selection = Menu_ProcessInput(); - if (gMain.newKeys & (DPAD_UP | DPAD_DOWN)) + if (JOY_NEW(DPAD_UP | DPAD_DOWN)) { DrawLinkServicesMultichoiceMenu(tMultichoiceId); } diff --git a/src/shop.c b/src/shop.c index 5cba2767d..6e2e82a52 100755 --- a/src/shop.c +++ b/src/shop.c @@ -1017,7 +1017,7 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId) } else { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); ClearStdWindowAndFrameToTransparent(4, 0); @@ -1030,7 +1030,7 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId) ConvertIntToDecimalStringN(gStringVar3, gShopDataPtr->totalCost, STR_CONV_MODE_LEFT_ALIGN, 6); BuyMenuDisplayMessage(taskId, gText_Var1AndYouWantedVar2, BuyMenuConfirmPurchase); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); ClearStdWindowAndFrameToTransparent(4, 0); @@ -1106,7 +1106,7 @@ static void Task_ReturnToItemListAfterItemPurchase(u8 taskId) { s16 *data = gTasks[taskId].data; - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { PlaySE(SE_SELECT); if (tItemId == ITEM_POKE_BALL && tItemCount > 9 && AddBagItem(ITEM_PREMIER_BALL, 1) == TRUE) @@ -1122,7 +1122,7 @@ static void Task_ReturnToItemListAfterItemPurchase(u8 taskId) static void Task_ReturnToItemListAfterDecorationPurchase(u8 taskId) { - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { PlaySE(SE_SELECT); BuyMenuReturnToItemList(taskId); diff --git a/src/slot_machine.c b/src/slot_machine.c index 29051fe29..cc001bcc9 100644 --- a/src/slot_machine.c +++ b/src/slot_machine.c @@ -1942,7 +1942,7 @@ static bool8 AwardPayoutAction_GivePayoutToPlayer(struct Task *task) if (sSlotMachine->coins < MAX_COINS) sSlotMachine->coins++; task->data[1] = 8; - if (gMain.heldKeys & A_BUTTON) + if (JOY_HELD(A_BUTTON)) task->data[1] = 4; } if (IsFanfareTaskInactive() && JOY_NEW(START_BUTTON)) diff --git a/src/start_menu.c b/src/start_menu.c index f470a58b2..fa51766e8 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -550,19 +550,19 @@ void ShowStartMenu(void) static bool8 HandleStartMenuInput(void) { - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { PlaySE(SE_SELECT); sStartMenuCursorPos = Menu_MoveCursor(-1); } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { PlaySE(SE_SELECT); sStartMenuCursorPos = Menu_MoveCursor(1); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (sStartMenuItems[sCurrentStartMenuActions[sStartMenuCursorPos]].func.u8_void == StartMenuPokedexCallback) @@ -584,7 +584,7 @@ static bool8 HandleStartMenuInput(void) return FALSE; } - if (gMain.newKeys & (START_BUTTON | B_BUTTON)) + if (JOY_NEW(START_BUTTON | B_BUTTON)) { RemoveExtraStartMenuWindows(); HideStartMenu(); @@ -906,12 +906,12 @@ static bool8 SaveSuccesTimer(void) { sSaveDialogTimer--; - if (gMain.heldKeys & A_BUTTON) + if (JOY_HELD(A_BUTTON)) { PlaySE(SE_SELECT); return TRUE; } - else if (sSaveDialogTimer == 0) + if (sSaveDialogTimer == 0) { return TRUE; } @@ -925,7 +925,7 @@ static bool8 SaveErrorTimer(void) { sSaveDialogTimer--; } - else if (gMain.heldKeys & A_BUTTON) + else if (JOY_HELD(A_BUTTON)) { return TRUE; } diff --git a/src/title_screen.c b/src/title_screen.c index 108601685..1d6f90d74 100644 --- a/src/title_screen.c +++ b/src/title_screen.c @@ -727,24 +727,24 @@ static void Task_TitleScreenPhase2(u8 taskId) // Show Rayquaza silhouette and process main title screen input static void Task_TitleScreenPhase3(u8 taskId) { - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & START_BUTTON)) + if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(START_BUTTON))) { FadeOutBGM(4); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_WHITEALPHA); SetMainCallback2(CB2_GoToMainMenu); } - else if ((gMain.heldKeys & CLEAR_SAVE_BUTTON_COMBO) == CLEAR_SAVE_BUTTON_COMBO) + else if (JOY_HELD(CLEAR_SAVE_BUTTON_COMBO) == CLEAR_SAVE_BUTTON_COMBO) { SetMainCallback2(CB2_GoToClearSaveDataScreen); } - else if ((gMain.heldKeys & RESET_RTC_BUTTON_COMBO) == RESET_RTC_BUTTON_COMBO + else if (JOY_HELD(RESET_RTC_BUTTON_COMBO) == RESET_RTC_BUTTON_COMBO && CanResetRTC() == TRUE) { FadeOutBGM(4); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); SetMainCallback2(CB2_GoToResetRtcScreen); } - else if ((gMain.heldKeys & BERRY_UPDATE_BUTTON_COMBO) == BERRY_UPDATE_BUTTON_COMBO) + else if (JOY_HELD(BERRY_UPDATE_BUTTON_COMBO) == BERRY_UPDATE_BUTTON_COMBO) { FadeOutBGM(4); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK); diff --git a/src/trade.c b/src/trade.c index 3072b8585..17aaba565 100644 --- a/src/trade.c +++ b/src/trade.c @@ -1353,24 +1353,24 @@ static void SetReadyToTrade(void) static void TradeMenuProcessInput(void) { - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPEAT(DPAD_UP)) { TradeMenuMoveCursor(&sTradeMenuData->cursorPosition, 0); } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPEAT(DPAD_DOWN)) { TradeMenuMoveCursor(&sTradeMenuData->cursorPosition, 1); } - else if (gMain.newAndRepeatedKeys & DPAD_LEFT) + else if (JOY_REPEAT(DPAD_LEFT)) { TradeMenuMoveCursor(&sTradeMenuData->cursorPosition, 2); } - else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + else if (JOY_REPEAT(DPAD_RIGHT)) { TradeMenuMoveCursor(&sTradeMenuData->cursorPosition, 3); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); @@ -1451,7 +1451,7 @@ static void TradeMenuProcessInput_SelectedMon(void) static void ChooseMonAfterButtonPress(void) { - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if ((JOY_NEW(A_BUTTON)) || (JOY_NEW(B_BUTTON))) { PlaySE(SE_SELECT); TradeMenuChooseMon(); @@ -1626,7 +1626,7 @@ static void RedrawTradeMenuAfterPressA(void) { int i; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); rbox_fill_rectangle(0); @@ -1698,7 +1698,7 @@ static void LinkTradeWaitForQueue(void) static void PartnersMonWasInvalid(void) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { SetLinkData(LINKCMD_READY_CANCEL_TRADE, 0); sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_STANDBY; @@ -3728,7 +3728,7 @@ static bool8 AnimateTradeSequenceCable(void) { return TRUE; } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { sTradeData->state++; } @@ -4243,7 +4243,7 @@ static bool8 AnimateTradeSequenceWireless(void) { return TRUE; } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { sTradeData->state++; } diff --git a/src/trainer_card.c b/src/trainer_card.c index 9d6838176..2d9ec2b09 100755 --- a/src/trainer_card.c +++ b/src/trainer_card.c @@ -438,13 +438,13 @@ static void Task_TrainerCard(u8 taskId) DrawTrainerCardWindow(1); sData->timeColonNeedDraw = FALSE; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { FlipTrainerCard(); PlaySE(SE_RG_CARD_FLIP); sData->mainState = STATE_WAIT_FLIP_TO_BACK; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { if (gReceivedRemoteLinkPlayers && sData->isLink && InUnionRoom() == TRUE) { @@ -465,7 +465,7 @@ static void Task_TrainerCard(u8 taskId) } break; case STATE_HANDLE_INPUT_BACK: - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { if (gReceivedRemoteLinkPlayers && sData->isLink && InUnionRoom() == TRUE) { @@ -483,7 +483,7 @@ static void Task_TrainerCard(u8 taskId) PlaySE(SE_RG_CARD_FLIP); } } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { if (gReceivedRemoteLinkPlayers && sData->isLink && InUnionRoom() == TRUE) { diff --git a/src/union_room.c b/src/union_room.c index f886d0383..05bd8cfb0 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -445,7 +445,7 @@ static void Task_TryBecomeLinkLeader(u8 taskId) break; case LL_STATE_AWAIT_PLAYERS: Leader_SetStateIfMemberListChanged(data, LL_STATE_ACCEPT_NEW_MEMBER_PROMPT, LL_STATE_MEMBER_LEFT); - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { if (data->playerCount == 1) data->state = LL_STATE_SHUTDOWN_AND_FAIL; @@ -458,7 +458,7 @@ static void Task_TryBecomeLinkLeader(u8 taskId) && data->playerCount > GROUP_MIN(sPlayerActivityGroupSize) - 1 && GROUP_MAX(sPlayerActivityGroupSize) != 0 && sub_8012240() - && gMain.newKeys & START_BUTTON) + && JOY_NEW(START_BUTTON)) { data->state = LL_STATE_MEMBERS_OK_PROMPT; LinkRfu_StopManagerAndFinalizeSlots(); @@ -1005,7 +1005,7 @@ static void Task_TryJoinLinkGroup(u8 taskId) break; case 0: id = ListMenu_ProcessInput(data->listTaskId); - if (gMain.newKeys & A_BUTTON && id != -1) + if (JOY_NEW(A_BUTTON) && id != -1) { // this unused variable along with the assignment is needed to match u32 activity = data->field_0->arr[id].gname_uname.gname.activity; @@ -1032,7 +1032,7 @@ static void Task_TryJoinLinkGroup(u8 taskId) PlaySE(SE_WALL_HIT); } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { data->state = LG_STATE_CANCEL_CHOOSE_LEADER; } @@ -1135,7 +1135,7 @@ static void Task_TryJoinLinkGroup(u8 taskId) break; } - if (RfuGetStatus() == RFU_STATUS_OK && gMain.newKeys & B_BUTTON) + if (RfuGetStatus() == RFU_STATUS_OK && JOY_NEW(B_BUTTON)) data->state = LG_STATE_ASK_LEAVE_GROUP; break; case LG_STATE_ASK_LEAVE_GROUP: @@ -1889,7 +1889,7 @@ static void Task_MEvent_Leader(u8 taskId) break; case 4: Leader_SetStateIfMemberListChanged(data, 5, 6); - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { data->state = 13; DestroyWirelessStatusIndicatorSprite(); @@ -2104,7 +2104,7 @@ static void Task_CardOrNewsWithFriend(u8 taskId) break; case 0: id = ListMenu_ProcessInput(data->listTaskId); - if (gMain.newKeys & A_BUTTON && id != -1) + if (JOY_NEW(A_BUTTON) && id != -1) { // this unused variable along with the assignment is needed to match u32 unusedVar; @@ -2126,7 +2126,7 @@ static void Task_CardOrNewsWithFriend(u8 taskId) PlaySE(SE_WALL_HIT); } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { data->state = 6; } @@ -2289,7 +2289,7 @@ static void Task_CardOrNewsOverWireless(u8 taskId) } } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { data->state = 6; data->refreshTimer = 0; @@ -2547,7 +2547,7 @@ static void Task_RunUnionRoom(u8 taskId) } else if (ScriptContext2_IsEnabled() != TRUE) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (TryInteractWithUnionRoomMember(uroom->field_0, &taskData[0], &taskData[1], uroom->spriteIds)) { @@ -2881,7 +2881,7 @@ static void Task_RunUnionRoom(u8 taskId) break; case UR_STATE_HANDLE_CONTACT_DATA: ReceiveUnionRoomActivityPacket(uroom); - if (UnionRoom_HandleContactFromOtherPlayer(uroom) && gMain.newKeys & B_BUTTON) + if (UnionRoom_HandleContactFromOtherPlayer(uroom) && JOY_NEW(B_BUTTON)) { sub_8011DE0(1); StringCopy(gStringVar4, sText_ChatEnded); diff --git a/src/union_room_chat.c b/src/union_room_chat.c index a7df14dd7..ed39d3acf 100755 --- a/src/union_room_chat.c +++ b/src/union_room_chat.c @@ -1017,12 +1017,12 @@ static void Chat_HandleInput(void) switch (sChat->funcState) { case 0: - if (gMain.newKeys & START_BUTTON) + if (JOY_NEW(START_BUTTON)) { if (sChat->bufferCursorPos) SetChatFunction(CHAT_FUNC_SEND); } - else if (gMain.newKeys & SELECT_BUTTON) + else if (JOY_NEW(SELECT_BUTTON)) { SetChatFunction(CHAT_FUNC_SWITCH); } @@ -1039,14 +1039,14 @@ static void Chat_HandleInput(void) SetChatFunction(CHAT_FUNC_ASK_QUIT); } } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { AppendTextToMessage(); StartDisplaySubtask(CHATDISPLAY_FUNC_UPDATE_MSG, 0); StartDisplaySubtask(CHATDISPLAY_FUNC_CURSOR_BLINK, 1); sChat->funcState = 1; } - else if (gMain.newKeys & R_BUTTON) + else if (JOY_NEW(R_BUTTON)) { if (sChat->currentPage != UNION_ROOM_KB_PAGE_REGISTER) { @@ -1100,7 +1100,7 @@ static void Chat_Switch(void) shouldSwitchPages = FALSE; break; case MENU_NOTHING_CHOSEN: - if (gMain.newKeys & SELECT_BUTTON) + if (JOY_NEW(SELECT_BUTTON)) { PlaySE(SE_SELECT); Menu_MoveCursor(1); @@ -1420,13 +1420,13 @@ static void Chat_Register(void) } break; case 1: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { RegisterTextAtRow(); StartDisplaySubtask(CHATDISPLAY_FUNC_RETURN_TO_KB, 0); sChat->funcState = 3; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { StartDisplaySubtask(CHATDISPLAY_FUNC_CANCEL_REGISTER, 0); sChat->funcState = 4; @@ -1457,7 +1457,7 @@ static void Chat_Register(void) sChat->funcState = 6; break; case 6: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { StartDisplaySubtask(CHATDISPLAY_FUNC_DESTROY_YESNO, 0); sChat->funcState = 4; @@ -1591,7 +1591,7 @@ static bool32 HandleDPadInput(void) { do { - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPEAT(DPAD_UP)) { if (sChat->currentRow > 0) sChat->currentRow--; @@ -1599,7 +1599,7 @@ static bool32 HandleDPadInput(void) sChat->currentRow = sKeyboardPageMaxRow[sChat->currentPage]; break; } - if (gMain.newAndRepeatedKeys & DPAD_DOWN) + if (JOY_REPEAT(DPAD_DOWN)) { if (sChat->currentRow < sKeyboardPageMaxRow[sChat->currentPage]) sChat->currentRow++; @@ -1609,7 +1609,7 @@ static bool32 HandleDPadInput(void) } if (sChat->currentPage != UNION_ROOM_KB_PAGE_REGISTER) { - if (gMain.newAndRepeatedKeys & DPAD_LEFT) + if (JOY_REPEAT(DPAD_LEFT)) { if (sChat->currentCol > 0) sChat->currentCol--; @@ -1617,7 +1617,7 @@ static bool32 HandleDPadInput(void) sChat->currentCol = 4; break; } - else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + else if (JOY_REPEAT(DPAD_RIGHT)) { if (sChat->currentCol < 4) sChat->currentCol++; diff --git a/src/unk_text_util_2.c b/src/unk_text_util_2.c index 22db293e9..b92b34fbd 100644 --- a/src/unk_text_util_2.c +++ b/src/unk_text_util_2.c @@ -19,14 +19,14 @@ u16 Font6Func(struct TextPrinter *textPrinter) switch (textPrinter->state) { case 0: - if (gMain.heldKeys & (A_BUTTON | B_BUTTON) && subStruct->hasPrintBeenSpedUp) + if (JOY_HELD(A_BUTTON | B_BUTTON) && subStruct->hasPrintBeenSpedUp) { textPrinter->delayCounter = 0; } if (textPrinter->delayCounter && textPrinter->textSpeed) { textPrinter->delayCounter --; - if (gTextFlags.canABSpeedUpPrint && gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (gTextFlags.canABSpeedUpPrint && JOY_NEW(A_BUTTON | B_BUTTON)) { subStruct->hasPrintBeenSpedUp = TRUE; textPrinter->delayCounter = 0; diff --git a/src/wallclock.c b/src/wallclock.c index bed04928e..c38dd99e3 100644 --- a/src/wallclock.c +++ b/src/wallclock.c @@ -795,7 +795,7 @@ static void Task_SetClock_HandleInput(u8 taskId) { gTasks[taskId].tMinuteHandAngle = gTasks[taskId].tMinutes * 6; gTasks[taskId].tHourHandAngle = (gTasks[taskId].tHours % 12) * 30 + (gTasks[taskId].tMinutes / 10) * 5; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { gTasks[taskId].func = Task_SetClock_AskConfirm; } @@ -803,10 +803,10 @@ static void Task_SetClock_HandleInput(u8 taskId) { gTasks[taskId].tMoveDir = MOVE_NONE; - if (gMain.heldKeys & DPAD_LEFT) + if (JOY_HELD(DPAD_LEFT)) gTasks[taskId].tMoveDir = MOVE_BACKWARD; - if (gMain.heldKeys & DPAD_RIGHT) + if (JOY_HELD(DPAD_RIGHT)) gTasks[taskId].tMoveDir = MOVE_FORWARD; if (gTasks[taskId].tMoveDir != MOVE_NONE) @@ -878,7 +878,7 @@ static void Task_ViewClock_WaitFadeIn(u8 taskId) static void Task_ViewClock_HandleInput(u8 taskId) { InitClockWithRtc(taskId); - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) gTasks[taskId].func = Task_ViewClock_FadeOut; }