From afcbea1f17d8c68b1aad22ab5ab1768cb5cf36d5 Mon Sep 17 00:00:00 2001 From: Eduardo Quezada Date: Sat, 14 Feb 2026 04:33:00 -0300 Subject: [PATCH] Use `JOY_NEW`, `JOY_HELD` and `JOY_REPT` across the repo (#885) --- include/global.h | 2 +- src/battle_controller_player.c | 50 +++++----- src/battle_controller_safari.c | 14 +-- src/battle_main.c | 58 +++++------ src/battle_party_menu.c | 8 +- src/battle_script_commands.c | 32 +++--- src/berry_blender.c | 36 +++---- src/berry_tag_screen.c | 6 +- src/braille_puzzles.c | 2 +- src/cable_club.c | 10 +- src/choose_party.c | 20 ++-- src/contest.c | 4 +- src/contest_link_util.c | 2 +- src/contest_painting.c | 2 +- src/credits.c | 2 +- src/daycare.c | 8 +- src/debug/matsuda_debug_menu.c | 4 +- src/debug/mori_debug_menu.c | 2 +- src/debug/nakamura_debug_menu.c | 100 +++++++++---------- src/debug/nohara_debug_menu.c | 28 +++--- src/debug/sound_check_menu.c | 62 ++++++------ src/debug/start_menu_debug.c | 108 ++++++++++---------- src/debug/taya_debug_window.c | 38 +++---- src/debug/tomomichi_debug_menu.c | 120 +++++++++++----------- src/debug/watanabe_debug_menu.c | 166 +++++++++++++++---------------- src/decoration.c | 44 ++++---- src/diploma.c | 2 +- src/easy_chat_1.c | 58 +++++------ src/evolution_scene.c | 16 +-- src/field_player_avatar.c | 8 +- src/field_special_scene.c | 2 +- src/field_specials.c | 8 +- src/field_weather.c | 6 +- src/hall_of_fame.c | 12 +-- src/item_menu.c | 78 +++++++-------- src/item_use.c | 8 +- src/link.c | 12 +-- src/mail.c | 22 ++-- src/main.c | 6 +- src/main_menu.c | 12 +-- src/menu.c | 36 +++---- src/menu_helpers.c | 8 +- src/mon_markings.c | 8 +- src/move_tutor_menu.c | 18 ++-- src/mystery_event_menu.c | 26 ++--- src/naming_screen.c | 16 +-- src/option_menu.c | 26 ++--- src/overworld.c | 18 ++-- src/party_menu.c | 28 +++--- src/player_pc.c | 58 +++++------ src/pokeblock.c | 28 +++--- src/pokedex.c | 108 ++++++++++---------- src/pokedex_area_screen.c | 8 +- src/pokemon_menu.c | 20 ++-- src/pokemon_storage_system.c | 18 ++-- src/pokemon_storage_system_2.c | 26 ++--- src/pokemon_storage_system_4.c | 8 +- src/pokemon_summary_screen.c | 50 +++++----- src/pokenav.c | 16 +-- src/pokenav_before.c | 58 +++++------ src/region_map.c | 28 +++--- src/reset_rtc_screen.c | 18 ++-- src/roulette.c | 30 +++--- src/save_failed_screen.c | 4 +- src/scrcmd.c | 4 +- src/secret_base.c | 16 +-- src/shop.c | 22 ++-- src/slot_machine.c | 50 +++++----- src/start_menu.c | 14 +-- src/starter_choose.c | 6 +- src/text.c | 6 +- src/title_screen.c | 10 +- src/trade.c | 42 ++++---- src/trader.c | 8 +- src/trainer_card.c | 6 +- src/use_pokeblock.c | 14 +-- src/wallclock.c | 10 +- 77 files changed, 1024 insertions(+), 1024 deletions(-) diff --git a/include/global.h b/include/global.h index 4858b9d8c..faa9c9a52 100644 --- a/include/global.h +++ b/include/global.h @@ -123,7 +123,7 @@ enum f; \ }) -#define TEST_BUTTON(value, button) ({(value) & (button);}) +#define TEST_BUTTON(value, button) ((value) & (button)) #define JOY_NEW(button) (TEST_BUTTON(gMain.newKeys, button)) #define JOY_HELD(button) (TEST_BUTTON(gMain.heldKeys, button)) #define JOY_REPT(button) (TEST_BUTTON(gMain.newAndRepeatedKeys, button)) diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 6f429c301..0c408b264 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -367,7 +367,7 @@ void sub_802C098(void) dp11b_obj_instanciate(gActiveBattler, 1, 7, 1); dp11b_obj_instanciate(gActiveBattler, 0, 7, 1); - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); DestroyMenuCursor(); @@ -390,7 +390,7 @@ void sub_802C098(void) } PlayerBufferExecCompleted(); } - else if (gMain.newKeys & DPAD_LEFT) + else if (JOY_NEW(DPAD_LEFT)) { if (gActionSelectionCursor[gActiveBattler] & 1) { @@ -400,7 +400,7 @@ void sub_802C098(void) sub_802E3E4(gActionSelectionCursor[gActiveBattler], 0); } } - else if (gMain.newKeys & DPAD_RIGHT) + else if (JOY_NEW(DPAD_RIGHT)) { if (!(gActionSelectionCursor[gActiveBattler] & 1)) { @@ -410,7 +410,7 @@ void sub_802C098(void) sub_802E3E4(gActionSelectionCursor[gActiveBattler], 0); } } - else if (gMain.newKeys & DPAD_UP) + else if (JOY_NEW(DPAD_UP)) { if (gActionSelectionCursor[gActiveBattler] & 2) { @@ -420,7 +420,7 @@ void sub_802C098(void) sub_802E3E4(gActionSelectionCursor[gActiveBattler], 0); } } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { if (!(gActionSelectionCursor[gActiveBattler] & 2)) { @@ -430,7 +430,7 @@ void sub_802C098(void) sub_802E3E4(gActionSelectionCursor[gActiveBattler], 0); } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && GetBattlerPosition(gActiveBattler) == 2 @@ -451,7 +451,7 @@ void sub_802C098(void) DestroyMenuCursor(); } } - else if (gMain.newKeys & START_BUTTON) + else if (JOY_NEW(START_BUTTON)) { sub_804454C(); } @@ -481,7 +481,7 @@ void sub_802C2EC(void) i++; } while (i < gBattlersCount); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { DestroyMenuCursor(); PlaySE(SE_SELECT); @@ -491,7 +491,7 @@ void sub_802C2EC(void) PlayerBufferExecCompleted(); } //_0802C3A8 - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); gSprites[gBattlerSpriteIds[gUnknown_03004344]].callback = sub_8010574; @@ -500,7 +500,7 @@ void sub_802C2EC(void) dp11b_obj_instanciate(gActiveBattler, 0, 7, 1); dp11b_obj_free(gUnknown_03004344, 1); } - else if (gMain.newKeys & 0x60) + else if (JOY_NEW(DPAD_LEFT | DPAD_UP)) { PlaySE(SE_SELECT); gSprites[gBattlerSpriteIds[gUnknown_03004344]].callback = sub_8010574; @@ -547,7 +547,7 @@ void sub_802C2EC(void) gSprites[gBattlerSpriteIds[gUnknown_03004344]].callback = sub_8010520; } //_0802C540 - else if (gMain.newKeys & 0x90) + else if (JOY_NEW(DPAD_RIGHT | DPAD_DOWN)) { PlaySE(SE_SELECT); gSprites[gBattlerSpriteIds[gUnknown_03004344]].callback = sub_8010574; @@ -606,7 +606,7 @@ static void HandleAction_ChooseMove(void) #endif struct ChooseMoveStruct *r6 = (struct ChooseMoveStruct *)(gBattleBufferA[gActiveBattler] + 4); - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { u32 r4; @@ -664,7 +664,7 @@ static void HandleAction_ChooseMove(void) gSprites[gBattlerSpriteIds[gUnknown_03004344]].callback = sub_8010520; } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { DestroyMenuCursor(); PlaySE(SE_SELECT); @@ -673,7 +673,7 @@ static void HandleAction_ChooseMove(void) BtlController_EmitTwoReturnValues(1, 10, 0xFFFF); PlayerBufferExecCompleted(); } - else if (gMain.newKeys & DPAD_LEFT) + else if (JOY_NEW(DPAD_LEFT)) { if (gMoveSelectionCursor[gActiveBattler] & 1) { @@ -685,7 +685,7 @@ static void HandleAction_ChooseMove(void) sub_802E2D4(); } } - else if (gMain.newKeys & DPAD_RIGHT) + else if (JOY_NEW(DPAD_RIGHT)) { if (!(gMoveSelectionCursor[gActiveBattler] & 1) && (gMoveSelectionCursor[gActiveBattler] ^ 1) < gUnknown_03004348) @@ -698,7 +698,7 @@ static void HandleAction_ChooseMove(void) sub_802E2D4(); } } - else if (gMain.newKeys & DPAD_UP) + else if (JOY_NEW(DPAD_UP)) { if (gMoveSelectionCursor[gActiveBattler] & 2) { @@ -710,7 +710,7 @@ static void HandleAction_ChooseMove(void) sub_802E2D4(); } } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { if (!(gMoveSelectionCursor[gActiveBattler] & 2) && (gMoveSelectionCursor[gActiveBattler] ^ 2) < gUnknown_03004348) @@ -723,7 +723,7 @@ static void HandleAction_ChooseMove(void) sub_802E2D4(); } } - else if (gMain.newKeys & SELECT_BUTTON) + else if (JOY_NEW(SELECT_BUTTON)) { if (gUnknown_03004348 > 1 && !(gBattleTypeFlags & BATTLE_TYPE_LINK)) { @@ -740,7 +740,7 @@ static void HandleAction_ChooseMove(void) } } #if DEBUG - else if (gUnknown_020297ED == 1 && (gMain.newKeys & START_BUTTON)) + else if (gUnknown_020297ED == 1 && JOY_NEW(START_BUTTON)) { const u8 *moveName; s32 i; @@ -792,7 +792,7 @@ void sub_802CA60(void) //struct ChooseMoveStruct sp0; u8 totalPPBonuses; - if (gMain.newKeys & (A_BUTTON | SELECT_BUTTON)) + if (JOY_NEW(A_BUTTON | SELECT_BUTTON)) { PlaySE(SE_SELECT); if (gMoveSelectionCursor[gActiveBattler] != gUnknown_03004344) @@ -885,7 +885,7 @@ void sub_802CA60(void) sub_802E220(); sub_802E2D4(); } - if (gMain.newKeys & (B_BUTTON | SELECT_BUTTON)) + if (JOY_NEW(B_BUTTON | SELECT_BUTTON)) { PlaySE(SE_SELECT); nullsub_7(gUnknown_03004344); @@ -898,7 +898,7 @@ void sub_802CA60(void) sub_802E220(); sub_802E2D4(); } - if ((gMain.newKeys & DPAD_LEFT) && (gUnknown_03004344 & 1)) + if (JOY_NEW(DPAD_LEFT) && (gUnknown_03004344 & 1)) { if (gUnknown_03004344 == gMoveSelectionCursor[gActiveBattler]) sub_802E3B4(gMoveSelectionCursor[gActiveBattler], 0x1D); @@ -911,7 +911,7 @@ void sub_802CA60(void) else sub_802E3B4(gUnknown_03004344, 0x1B); } - if ((gMain.newKeys & DPAD_RIGHT) && !(gUnknown_03004344 & 1) && (gUnknown_03004344 ^ 1) < gUnknown_03004348) + if (JOY_NEW(DPAD_RIGHT) && !(gUnknown_03004344 & 1) && (gUnknown_03004344 ^ 1) < gUnknown_03004348) { if (gUnknown_03004344 == gMoveSelectionCursor[gActiveBattler]) sub_802E3B4(gMoveSelectionCursor[gActiveBattler], 0x1D); @@ -924,7 +924,7 @@ void sub_802CA60(void) else sub_802E3B4(gUnknown_03004344, 0x1B); } - if ((gMain.newKeys & DPAD_UP) && (gUnknown_03004344 & 2)) + if (JOY_NEW(DPAD_UP) && (gUnknown_03004344 & 2)) { if (gUnknown_03004344 == gMoveSelectionCursor[gActiveBattler]) sub_802E3B4(gMoveSelectionCursor[gActiveBattler], 0x1D); @@ -937,7 +937,7 @@ void sub_802CA60(void) else sub_802E3B4(gUnknown_03004344, 0x1B); } - if ((gMain.newKeys & DPAD_DOWN) && !(gUnknown_03004344 & 2) && (gUnknown_03004344 ^ 2) < gUnknown_03004348) + if (JOY_NEW(DPAD_DOWN) && !(gUnknown_03004344 & 2) && (gUnknown_03004344 ^ 2) < gUnknown_03004348) { if (gUnknown_03004344 == gMoveSelectionCursor[gActiveBattler]) sub_802E3B4(gMoveSelectionCursor[gActiveBattler], 0x1D); diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c index cf09ef164..678f49909 100644 --- a/src/battle_controller_safari.c +++ b/src/battle_controller_safari.c @@ -206,7 +206,7 @@ void SafariBufferRunCommand(void) void bx_battle_menu_t6_2(void) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); DestroyMenuCursor(); @@ -229,7 +229,7 @@ void bx_battle_menu_t6_2(void) } SafariBufferExecCompleted(); } - else if (gMain.newKeys & DPAD_LEFT) + else if (JOY_NEW(DPAD_LEFT)) { if (gActionSelectionCursor[gActiveBattler] & 1) { @@ -239,7 +239,7 @@ void bx_battle_menu_t6_2(void) sub_802E3E4(gActionSelectionCursor[gActiveBattler], 0); } } - else if (gMain.newKeys & DPAD_RIGHT) + else if (JOY_NEW(DPAD_RIGHT)) { if (!(gActionSelectionCursor[gActiveBattler] & 1)) { @@ -249,7 +249,7 @@ void bx_battle_menu_t6_2(void) sub_802E3E4(gActionSelectionCursor[gActiveBattler], 0); } } - else if (gMain.newKeys & DPAD_UP) + else if (JOY_NEW(DPAD_UP)) { if (gActionSelectionCursor[gActiveBattler] & 2) { @@ -259,7 +259,7 @@ void bx_battle_menu_t6_2(void) sub_802E3E4(gActionSelectionCursor[gActiveBattler], 0); } } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { if (!(gActionSelectionCursor[gActiveBattler] & 2)) { @@ -270,12 +270,12 @@ void bx_battle_menu_t6_2(void) } } #if DEBUG - else if (gMain.newKeys & R_BUTTON) + else if (JOY_NEW(R_BUTTON)) { if (!ewram17810[gActiveBattler].unk0_5) move_anim_start_t3(gActiveBattler, gActiveBattler, gActiveBattler, 4, 0); } - else if (gMain.newKeys & START_BUTTON) + else if (JOY_NEW(START_BUTTON)) { sub_804454C(); } diff --git a/src/battle_main.c b/src/battle_main.c index d846f6562..4c374cb70 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -967,7 +967,7 @@ void BattleMainCB2(void) BuildOamBuffer(); #if DEBUG - if ((gMain.heldKeys & (R_BUTTON | SELECT_BUTTON)) == ((R_BUTTON | SELECT_BUTTON))) + if (JOY_HELD(R_BUTTON | SELECT_BUTTON) == ((R_BUTTON | SELECT_BUTTON))) { gSpecialVar_Result = gBattleOutcome = 1; gMain.inBattle = FALSE; @@ -1685,7 +1685,7 @@ void debug_sub_8010CAC(void) } debug_sub_80125A0(); } - if (gMain.newAndRepeatedKeys & B_BUTTON) + if (JOY_REPT(B_BUTTON)) { switch (gUnknown_Debug_030043A0 + gUnknown_Debug_030043A4 * 5) { @@ -1746,7 +1746,7 @@ void debug_sub_8010CAC(void) break; } } - if (gMain.newAndRepeatedKeys & A_BUTTON) + if (JOY_REPT(A_BUTTON)) { switch (gUnknown_Debug_030043A0 + gUnknown_Debug_030043A4 * 5) { @@ -1807,7 +1807,7 @@ void debug_sub_8010CAC(void) break; } } - if (gMain.newAndRepeatedKeys & L_BUTTON) + if (JOY_REPT(L_BUTTON)) { if (gUnknown_Debug_030043A0 == 4 && gUnknown_Debug_030043A4 < 6) { @@ -1834,7 +1834,7 @@ void debug_sub_8010CAC(void) debug_sub_8011EA0(gUnknown_Debug_030043A4 * 5 + gUnknown_Debug_030043A0); debug_sub_80123D8(gUnknown_Debug_030043A4 * 5); } - if (gMain.newAndRepeatedKeys & R_BUTTON) + if (JOY_REPT(R_BUTTON)) { if (gUnknown_Debug_030043A0 == 4 && gUnknown_Debug_030043A4 < 6) { @@ -1892,28 +1892,28 @@ void debug_sub_8011498(void) gUnknown_Debug_030043A8 ^= 1; debug_sub_8012628(); } - if (gMain.newAndRepeatedKeys & B_BUTTON) + if (JOY_REPT(B_BUTTON)) { gUnknown_Debug_2023B02[gUnknown_Debug_03004360][r9 / 5][gUnknown_Debug_030043A8]--; if (gUnknown_Debug_2023B02[gUnknown_Debug_03004360][r9 / 5][gUnknown_Debug_030043A8] < gUnknown_Debug_821F564[gUnknown_Debug_030043A8][4]) gUnknown_Debug_2023B02[gUnknown_Debug_03004360][r9 / 5][gUnknown_Debug_030043A8] = gUnknown_Debug_821F564[gUnknown_Debug_030043A8][3]; debug_sub_8012294(); } - if (gMain.newAndRepeatedKeys & A_BUTTON) + if (JOY_REPT(A_BUTTON)) { gUnknown_Debug_2023B02[gUnknown_Debug_03004360][r9 / 5][gUnknown_Debug_030043A8]++; if (gUnknown_Debug_2023B02[gUnknown_Debug_03004360][r9 / 5][gUnknown_Debug_030043A8] > gUnknown_Debug_821F564[gUnknown_Debug_030043A8][3]) gUnknown_Debug_2023B02[gUnknown_Debug_03004360][r9 / 5][gUnknown_Debug_030043A8] = gUnknown_Debug_821F564[gUnknown_Debug_030043A8][4]; debug_sub_8012294(); } - if (gMain.newAndRepeatedKeys & L_BUTTON) + if (JOY_REPT(L_BUTTON)) { gUnknown_Debug_2023B02[gUnknown_Debug_03004360][r9 / 5][gUnknown_Debug_030043A8] -= 10; while (gUnknown_Debug_2023B02[gUnknown_Debug_03004360][r9 / 5][gUnknown_Debug_030043A8] < gUnknown_Debug_821F564[gUnknown_Debug_030043A8][4]) gUnknown_Debug_2023B02[gUnknown_Debug_03004360][r9 / 5][gUnknown_Debug_030043A8] += gUnknown_Debug_821F564[gUnknown_Debug_030043A8][3]; debug_sub_8012294(); } - if (gMain.newAndRepeatedKeys & R_BUTTON) + if (JOY_REPT(R_BUTTON)) { gUnknown_Debug_2023B02[gUnknown_Debug_03004360][r9 / 5][gUnknown_Debug_030043A8] += 10; while (gUnknown_Debug_2023B02[gUnknown_Debug_03004360][r9 / 5][gUnknown_Debug_030043A8] > gUnknown_Debug_821F564[gUnknown_Debug_030043A8][3]) @@ -2779,35 +2779,35 @@ void debug_sub_8012D10(u8 taskId) sub_802E3E4(gTasks[taskId].data[2], 0); break; case 1: - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { PlaySE(SE_SELECT); nullsub_8(gTasks[taskId].data[2]); gTasks[taskId].data[2] &= ~2; sub_802E3E4(gTasks[taskId].data[2], 0); } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { PlaySE(SE_SELECT); nullsub_8(gTasks[taskId].data[2]); gTasks[taskId].data[2] |= 2; sub_802E3E4(gTasks[taskId].data[2], 0); } - else if (gMain.newKeys & DPAD_LEFT) + else if (JOY_NEW(DPAD_LEFT)) { PlaySE(SE_SELECT); nullsub_8(gTasks[taskId].data[2]); gTasks[taskId].data[2] &= ~1; sub_802E3E4(gTasks[taskId].data[2], 0); } - else if (gMain.newKeys & DPAD_RIGHT) + else if (JOY_NEW(DPAD_RIGHT)) { PlaySE(SE_SELECT); nullsub_8(gTasks[taskId].data[2]); gTasks[taskId].data[2] |= 1; sub_802E3E4(gTasks[taskId].data[2], 0); } - else if (gMain.newAndRepeatedKeys & A_BUTTON) + else if (JOY_REPT(A_BUTTON)) { PlaySE(SE_SELECT); switch (gTasks[taskId].data[2]) @@ -2836,7 +2836,7 @@ void debug_sub_8012D10(u8 taskId) break; } } - else if (gMain.newAndRepeatedKeys & B_BUTTON) + else if (JOY_REPT(B_BUTTON)) { PlaySE(SE_SELECT); switch (gTasks[taskId].data[2]) @@ -2865,7 +2865,7 @@ void debug_sub_8012D10(u8 taskId) break; } } - else if (gMain.newAndRepeatedKeys & R_BUTTON) + else if (JOY_REPT(R_BUTTON)) { PlaySE(SE_SELECT); switch (gTasks[taskId].data[2]) @@ -2896,7 +2896,7 @@ void debug_sub_8012D10(u8 taskId) break; } } - else if (gMain.newAndRepeatedKeys & L_BUTTON) + else if (JOY_REPT(L_BUTTON)) { PlaySE(SE_SELECT); switch (gTasks[taskId].data[2]) @@ -2930,26 +2930,26 @@ void debug_sub_8012D10(u8 taskId) } break; case 2: - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { PlaySE(SE_SELECT); debug_sub_8012B4C(gTasks[taskId].data[3]); gTasks[taskId].data[3] = 0; debug_sub_8012B2C(0); } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { PlaySE(SE_SELECT); debug_sub_8012B4C(gTasks[taskId].data[3]); gTasks[taskId].data[3] = 1; debug_sub_8012B2C(1); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); debug_sub_8012C08(taskId, gTasks[taskId].data[3]); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); asm(""); @@ -2957,56 +2957,56 @@ void debug_sub_8012D10(u8 taskId) } return; case 3: - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { PlaySE(SE_SELECT); debug_sub_8012B4C(gTasks[taskId].data[3]); gTasks[taskId].data[3] = 0; debug_sub_8012B2C(0); } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { PlaySE(SE_SELECT); debug_sub_8012B4C(gTasks[taskId].data[3]); gTasks[taskId].data[3] = 1; debug_sub_8012B2C(1); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (gTasks[taskId].data[3] == 0) debug_sub_80132C8(31, gUnknown_Debug_2023B62, 411); debug_sub_8012B70(taskId, 1); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); debug_sub_8012B70(taskId, 1); } break; case 4: - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { PlaySE(SE_SELECT); debug_sub_8012B4C(gTasks[taskId].data[3]); gTasks[taskId].data[3] = 0; debug_sub_8012B2C(0); } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { PlaySE(SE_SELECT); debug_sub_8012B4C(gTasks[taskId].data[3]); gTasks[taskId].data[3] = 1; debug_sub_8012B2C(1); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (gTasks[taskId].data[3] == 0) debug_sub_8013294(31, gUnknown_Debug_2023B62, 411); debug_sub_8012B70(taskId, 1); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); debug_sub_8012B70(taskId, 1); diff --git a/src/battle_party_menu.c b/src/battle_party_menu.c index a1389ddff..d02155eab 100644 --- a/src/battle_party_menu.c +++ b/src/battle_party_menu.c @@ -584,19 +584,19 @@ static void Task_HandlePopupMenuInput(u8 taskId) if (!gPaletteFade.active) { - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { PlaySE(SE_SELECT); Menu_MoveCursor(-1); return; } - if (gMain.newAndRepeatedKeys & DPAD_DOWN) + if (JOY_REPT(DPAD_DOWN)) { PlaySE(SE_SELECT); Menu_MoveCursor(1); return; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); func = PartyMenuGetPopupMenuFunc(gTasks[taskId].data[4], @@ -606,7 +606,7 @@ static void Task_HandlePopupMenuInput(u8 taskId) func(taskId); return; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); Task_BattlePartyMenuCancel(taskId); diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 46000157c..8787dd896 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -5294,21 +5294,21 @@ static void atk5A_yesnoboxlearnmove(void) sub_802BC6C(); break; case 1: - if (gMain.newKeys & DPAD_UP && gBattleCommunication[1] != 0) + if (JOY_NEW(DPAD_UP) && gBattleCommunication[1] != 0) { PlaySE(SE_SELECT); nullsub_6(); gBattleCommunication[1] = 0; sub_802BC6C(); } - if (gMain.newKeys & DPAD_DOWN && gBattleCommunication[1] == 0) + if (JOY_NEW(DPAD_DOWN) && gBattleCommunication[1] == 0) { PlaySE(SE_SELECT); nullsub_6(); gBattleCommunication[1] = 1; sub_802BC6C(); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (gBattleCommunication[1] == 0) @@ -5320,7 +5320,7 @@ static void atk5A_yesnoboxlearnmove(void) } goto state_tracker_4; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); state_tracker_4: @@ -5406,21 +5406,21 @@ static void atk5B_yesnoboxstoplearningmove(void) sub_802BC6C(); break; case 1: - if (gMain.newKeys & DPAD_UP && gBattleCommunication[1] != 0) + if (JOY_NEW(DPAD_UP) && gBattleCommunication[1] != 0) { PlaySE(SE_SELECT); nullsub_6(); gBattleCommunication[1] = 0; sub_802BC6C(); } - if (gMain.newKeys & DPAD_DOWN && gBattleCommunication[1] == 0) + if (JOY_NEW(DPAD_DOWN) && gBattleCommunication[1] == 0) { PlaySE(SE_SELECT); nullsub_6(); gBattleCommunication[1] = 1; sub_802BC6C(); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (gBattleCommunication[1] != 0) @@ -5429,7 +5429,7 @@ static void atk5B_yesnoboxstoplearningmove(void) gBattlescriptCurrInstr += 5; sub_8023AD8(); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); @@ -5664,28 +5664,28 @@ static void atk67_yesnobox(void) sub_802BC6C(); break; case 1: - if (gMain.newKeys & DPAD_UP && gBattleCommunication[1] != 0) + if (JOY_NEW(DPAD_UP) && gBattleCommunication[1] != 0) { PlaySE(SE_SELECT); nullsub_6(); gBattleCommunication[1] = 0; sub_802BC6C(); } - if (gMain.newKeys & DPAD_DOWN && gBattleCommunication[1] == 0) + if (JOY_NEW(DPAD_DOWN) && gBattleCommunication[1] == 0) { PlaySE(SE_SELECT); nullsub_6(); gBattleCommunication[1] = 1; sub_802BC6C(); } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { gBattleCommunication[1] = 1; PlaySE(SE_SELECT); sub_8023AD8(); gBattlescriptCurrInstr++; } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); sub_8023AD8(); @@ -9633,21 +9633,21 @@ static void atkF3_trygivecaughtmonnick(void) sub_802BC6C(); break; case 1: - if (gMain.newKeys & DPAD_UP && gBattleCommunication[1] != 0) + if (JOY_NEW(DPAD_UP) && gBattleCommunication[1] != 0) { PlaySE(SE_SELECT); nullsub_6(); gBattleCommunication[1] = 0; sub_802BC6C(); } - if (gMain.newKeys & DPAD_DOWN && gBattleCommunication[1] == 0) + if (JOY_NEW(DPAD_DOWN) && gBattleCommunication[1] == 0) { PlaySE(SE_SELECT); nullsub_6(); gBattleCommunication[1] = 1; sub_802BC6C(); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (gBattleCommunication[1] == 0) @@ -9658,7 +9658,7 @@ static void atkF3_trygivecaughtmonnick(void) else gBattleCommunication[0] = 4; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); gBattleCommunication[0] = 4; diff --git a/src/berry_blender.c b/src/berry_blender.c index 35c5a473d..5b305f621 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -1815,9 +1815,9 @@ static void sub_80500A8(void) u8 var2 = gBerryBlenderData->field_A2[GetMultiplayerId()]; if (gBerryBlenderData->field_6F == 0) { - if (gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A && gMain.newKeys & A_BUTTON) + if (gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A && JOY_NEW(A_BUTTON)) A_pressed = ((gMain.heldKeysRaw & (A_BUTTON | L_BUTTON)) != (A_BUTTON | L_BUTTON)); - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) A_pressed = 1; if (A_pressed) { @@ -1838,7 +1838,7 @@ static void sub_80500A8(void) gBerryBlenderData->field_56--; gBerryBlenderData->field_7E = 0; } - if (gUnknown_020297ED && gMain.newKeys & L_BUTTON) + if (gUnknown_020297ED && JOY_NEW(L_BUTTON)) gBerryBlenderData->field_14B ^= 1; } @@ -2240,24 +2240,24 @@ static void sub_8050954(void) gBerryBlenderData->field_6F++; break; case 10: - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { if (gBerryBlenderData->field_AA != 0) PlaySE(SE_SELECT); sub_80508D4(0); } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { if (gBerryBlenderData->field_AA != 1) PlaySE(SE_SELECT); sub_80508D4(1); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); gBerryBlenderData->field_6F++; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); gBerryBlenderData->field_6F++; @@ -2742,7 +2742,7 @@ void unref_sub_80516F8(u8 taskID) Menu_PrintText(gOtherText_PressAToStart, 1, 15); } } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { sub_8007E4C(); DestroyTask(taskID); @@ -3067,7 +3067,7 @@ bool8 Blender_PrintBlendingResults(void) } break; case 4: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) gBerryBlenderData->field_0++; break; case 5: @@ -3242,7 +3242,7 @@ static bool8 Blender_PrintBlendingRanking(void) gBerryBlenderData->field_0++; break; case 5: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); gBerryBlenderData->field_0++; @@ -3412,47 +3412,47 @@ static void sub_80527BC(void) static void sub_8052918(void) { - if (gMain.newKeys & R_BUTTON) + if (JOY_NEW(R_BUTTON)) { sBlenderDebug.BPM += 1000; if (sBlenderDebug.BPM > 30000) sBlenderDebug.BPM = 1000; sBlenderDebug.field_10++; } - if (gMain.newKeys & L_BUTTON) + if (JOY_NEW(L_BUTTON)) { sBlenderDebug.BPM -= 1000; if (sBlenderDebug.BPM < 0) sBlenderDebug.BPM = 30000; sBlenderDebug.field_10++; } - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { sBlenderDebug.cursorPos -= 1; if (sBlenderDebug.cursorPos < 0) sBlenderDebug.cursorPos = 3; sBlenderDebug.field_10++; } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { sBlenderDebug.cursorPos += 1; if (sBlenderDebug.cursorPos > 3) sBlenderDebug.cursorPos = 0; sBlenderDebug.field_10++; } - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { if (--sBlenderDebug.berries[sBlenderDebug.cursorPos] < 0) sBlenderDebug.berries[sBlenderDebug.cursorPos] = 42; sBlenderDebug.field_10++; } - if (gMain.newKeys & DPAD_RIGHT) + if (JOY_NEW(DPAD_RIGHT)) { if (++sBlenderDebug.berries[sBlenderDebug.cursorPos] > 42) sBlenderDebug.berries[sBlenderDebug.cursorPos] = 0; sBlenderDebug.field_10++; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { u16 berryIDs[4]; struct BlenderBerry berries[4]; @@ -3482,7 +3482,7 @@ static void sub_8052918(void) BlenderDebug_PrintBerryData(); sBlenderDebug.field_10 = 0; } - if (gMain.newKeys & SELECT_BUTTON && gUnknown_020297DC == 0) + if (JOY_NEW(SELECT_BUTTON) && gUnknown_020297DC == 0) { gUnknown_020297DC++; gUnknown_020297E0 = 0; diff --git a/src/berry_tag_screen.c b/src/berry_tag_screen.c index 2a2ff6ae2..9343b0fb3 100644 --- a/src/berry_tag_screen.c +++ b/src/berry_tag_screen.c @@ -253,11 +253,11 @@ static void sub_8146480(u8 taskid) { if (!gPaletteFade.active) { - if ((gMain.newAndRepeatedKeys & (DPAD_RIGHT | DPAD_LEFT | DPAD_UP | DPAD_DOWN)) == DPAD_UP) + if (JOY_REPT(DPAD_ANY) == DPAD_UP) sub_81466E8(taskid, -1); - if ((gMain.newAndRepeatedKeys & (DPAD_RIGHT | DPAD_LEFT | DPAD_UP | DPAD_DOWN)) == DPAD_DOWN) + if (JOY_REPT(DPAD_ANY) == DPAD_DOWN) sub_81466E8(taskid, 1); - if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) sub_8146440(taskid); } } diff --git a/src/braille_puzzles.c b/src/braille_puzzles.c index 7218bc32d..6b09e3333 100644 --- a/src/braille_puzzles.c +++ b/src/braille_puzzles.c @@ -212,7 +212,7 @@ bool32 BrailleWait_CheckButtonPress(void) if (gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_L_EQUALS_A) keyMask |= L_BUTTON; - if (gMain.newKeys & keyMask) + if (JOY_NEW(keyMask)) return TRUE; else return FALSE; diff --git a/src/cable_club.c b/src/cable_club.c index 961ab739f..346c2af94 100644 --- a/src/cable_club.c +++ b/src/cable_club.c @@ -227,7 +227,7 @@ static bool32 sub_8082DF4(u8 taskId) static bool32 sub_8082E28(u8 taskId) { - if ((gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON) && IsLinkConnectionEstablished() == FALSE) { gTasks[taskId].func = sub_80833EC; @@ -241,7 +241,7 @@ static bool32 sub_8082E6C(u8 taskId) if (IsLinkConnectionEstablished()) SetSuppressLinkErrorMessage(TRUE); - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { gTasks[taskId].func = sub_80833EC; return TRUE; @@ -337,7 +337,7 @@ static void sub_808303C(u8 taskId) sub_8082D60(taskId, linkPlayerCount); - if (!(gMain.newKeys & A_BUTTON)) + if (!JOY_NEW(A_BUTTON)) return; #if ENGLISH @@ -376,12 +376,12 @@ static void sub_80830E4(u8 taskId) ShowFieldAutoScrollMessage(gUnknown_081A4932); gTasks[taskId].func = sub_8082FEC; } - else if (gMain.heldKeys & B_BUTTON) + else if (JOY_HELD(B_BUTTON)) { ShowFieldAutoScrollMessage(gUnknown_081A4932); gTasks[taskId].func = sub_8082FEC; } - else if (gMain.heldKeys & A_BUTTON) + else if (JOY_HELD(A_BUTTON)) { PlaySE(SE_SELECT); sub_8007F4C(); diff --git a/src/choose_party.c b/src/choose_party.c index ded31efbd..3b2f6dea7 100644 --- a/src/choose_party.c +++ b/src/choose_party.c @@ -318,7 +318,7 @@ static void sub_812238C(u8 taskId) { if (!gPaletteFade.active) { - if (gMain.newAndRepeatedKeys & 0x40) + if (JOY_REPT(0x40)) { if (Menu_GetCursorPos() != 0) { @@ -327,7 +327,7 @@ static void sub_812238C(u8 taskId) } return; } - if (gMain.newAndRepeatedKeys & 0x80) + if (JOY_REPT(0x80)) { if (Menu_GetCursorPos() != 3) { @@ -336,7 +336,7 @@ static void sub_812238C(u8 taskId) } return; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { TaskFunc popupMenuFunc; @@ -349,7 +349,7 @@ static void sub_812238C(u8 taskId) popupMenuFunc(taskId); return; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { BattleTowerEntryMenuCallback_Exit(taskId); return; @@ -370,7 +370,7 @@ static void sub_8122450(u8 taskId) // Wait for A or B press static void sub_8122480(u8 taskId) { - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) BattleTowerEntryMenuCallback_Exit(taskId); } @@ -475,7 +475,7 @@ static void sub_8122728(u8 taskId) if (gPartyMenuMessage_IsPrinting == 1) return; - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { Menu_EraseWindowRect(0, 14, 29, 19); Menu_DestroyCursor(); @@ -836,7 +836,7 @@ static void Task_DaycareStorageMenu8122EAC(u8 taskId) { if (!gPaletteFade.active) { - if (gMain.newAndRepeatedKeys & 0x40) + if (JOY_REPT(0x40)) { if (Menu_GetCursorPos() != 0) { @@ -845,7 +845,7 @@ static void Task_DaycareStorageMenu8122EAC(u8 taskId) } return; } - if (gMain.newAndRepeatedKeys & 0x80) + if (JOY_REPT(0x80)) { if (Menu_GetCursorPos() != 3) { @@ -854,7 +854,7 @@ static void Task_DaycareStorageMenu8122EAC(u8 taskId) } return; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { TaskFunc popupMenuFunc; @@ -867,7 +867,7 @@ static void Task_DaycareStorageMenu8122EAC(u8 taskId) popupMenuFunc(taskId); return; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { DaycareStorageMenuCallback_Exit(taskId); return; diff --git a/src/contest.c b/src/contest.c index 820ae326a..c01fa15f0 100644 --- a/src/contest.c +++ b/src/contest.c @@ -461,7 +461,7 @@ void sub_80ABC3C(u8 taskId) void Task_TryShowMoveSelectScreen(u8 taskId) { - 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)) @@ -544,7 +544,7 @@ void Task_HandleMoveSelectInput(u8 taskId) numMoves++; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { DestroyMenuCursor(); PlaySE(SE_SELECT); diff --git a/src/contest_link_util.c b/src/contest_link_util.c index e8f27ed57..448c07265 100644 --- a/src/contest_link_util.c +++ b/src/contest_link_util.c @@ -684,7 +684,7 @@ static void sub_80C2D1C(u8 taskId) { int i; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (!(gIsLinkContest & 1)) { diff --git a/src/contest_painting.c b/src/contest_painting.c index 1f127f760..6d8de0d2b 100644 --- a/src/contest_painting.c +++ b/src/contest_painting.c @@ -194,7 +194,7 @@ static void HoldContestPainting(void) sFrameCounter--; break; case 1: - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { sHoldState++; BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); diff --git a/src/credits.c b/src/credits.c index 49bbf80bd..69e4adefa 100644 --- a/src/credits.c +++ b/src/credits.c @@ -436,7 +436,7 @@ static void CB2_Credits(void) BuildOamBuffer(); UpdatePaletteFade(); - if ((gMain.heldKeys & B_BUTTON) + if (JOY_HELD(B_BUTTON) && gHasHallOfFameRecords != 0 && gTasks[sSavedTaskId].func == Task_CreditsMain) { diff --git a/src/daycare.c b/src/daycare.c index 616b1dd22..02eb5cd82 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -1019,7 +1019,7 @@ static void GetDaycareLevelMenuLevelText(struct DayCare *daycare, u8 *dest) static void HandleDaycareLevelMenuInput(u8 taskId) { - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { if (gTasks[taskId].data[0] != 0) { @@ -1028,7 +1028,7 @@ static void HandleDaycareLevelMenuInput(u8 taskId) PlaySE(SE_SELECT); } } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { if (gTasks[taskId].data[0] != 2) { @@ -1037,7 +1037,7 @@ static void HandleDaycareLevelMenuInput(u8 taskId) PlaySE(SE_SELECT); } } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { Menu_DestroyCursor(); PlaySE(SE_SELECT); @@ -1046,7 +1046,7 @@ static void HandleDaycareLevelMenuInput(u8 taskId) Menu_EraseWindowRect(15, 6, 29, 13); EnableBothScriptContexts(); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { Menu_DestroyCursor(); gLastFieldPokeMenuOpened = gSpecialVar_Result = 2; diff --git a/src/debug/matsuda_debug_menu.c b/src/debug/matsuda_debug_menu.c index 086b20abd..0fd0d8a36 100644 --- a/src/debug/matsuda_debug_menu.c +++ b/src/debug/matsuda_debug_menu.c @@ -201,7 +201,7 @@ static void sub_80A9DD8(u8 taskId) static void sub_80A9E04(u8 taskId) { - if (gMain.newKeys == 2) + if (gMain.newKeys == B_BUTTON) gTasks[(u8)gTasks[taskId].data[10]].func = sub_80A9D30; } @@ -464,7 +464,7 @@ static void sub_80AA064(void) BuildOamBuffer(); RunTasks(); UpdatePaletteFade(); - if (gMain.newKeys == 4) + if (gMain.newKeys == SELECT_BUTTON) SetMainCallback2(c2_exit_to_overworld_1_sub_8080DEC); } diff --git a/src/debug/mori_debug_menu.c b/src/debug/mori_debug_menu.c index d5cae8352..86994e5b8 100644 --- a/src/debug/mori_debug_menu.c +++ b/src/debug/mori_debug_menu.c @@ -74,7 +74,7 @@ void unref_sub_8083CF0(void) bool8 sub_8083D4C(void) { - if ( gMain.newKeys & A_BUTTON ) + if (JOY_NEW(A_BUTTON)) { CloseMenu(); return TRUE; diff --git a/src/debug/nakamura_debug_menu.c b/src/debug/nakamura_debug_menu.c index e8f40f08e..c8f2bf49e 100644 --- a/src/debug/nakamura_debug_menu.c +++ b/src/debug/nakamura_debug_menu.c @@ -87,17 +87,17 @@ bool8 InitNakamuraDebugMenu(void) static bool8 TopMenu_HandleJoypad(void) { - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { Menu_MoveCursor(-1); } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { Menu_MoveCursor(+1); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { MenuFunc func = sNakamuraTopMenuActions[Menu_GetCursorPos()].func; #if !(ENGLISH && REVISION == 0) @@ -106,7 +106,7 @@ static bool8 TopMenu_HandleJoypad(void) return func(); } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { CloseMenu(); return TRUE; @@ -342,7 +342,7 @@ static void BaseLocation_Redraw(void) static bool8 BaseLocation_HandleJoypad(void) { - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { if (sSecretBaseIdx == 0) sSecretBaseIdx = 19; @@ -352,7 +352,7 @@ static bool8 BaseLocation_HandleJoypad(void) return FALSE; } - if (gMain.newKeys & DPAD_RIGHT) + if (JOY_NEW(DPAD_RIGHT)) { if (sSecretBaseIdx == 19) sSecretBaseIdx = 0; @@ -362,7 +362,7 @@ static bool8 BaseLocation_HandleJoypad(void) return FALSE; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { CloseMenu(); return TRUE; @@ -514,7 +514,7 @@ static bool8 MoveYourBase_HandleJoypad_2(void) { u32 r4 = sMoveYourBase_CursorPos == 0 ? 7 : 10; - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { if (sMoveYourBase_CursorPos) MoveYourBase_EditOwnerID(1); @@ -523,7 +523,7 @@ static bool8 MoveYourBase_HandleJoypad_2(void) return FALSE; } - if (gMain.newAndRepeatedKeys & DPAD_DOWN) + if (JOY_REPT(DPAD_DOWN)) { if (sMoveYourBase_CursorPos) MoveYourBase_EditOwnerID(-1); @@ -532,7 +532,7 @@ static bool8 MoveYourBase_HandleJoypad_2(void) return FALSE; } - if (gMain.newAndRepeatedKeys & DPAD_LEFT) + if (JOY_REPT(DPAD_LEFT)) { if (sMoveYourBase_XCursorPos == 0) sMoveYourBase_XCursorPos = r4 - 1; @@ -542,7 +542,7 @@ static bool8 MoveYourBase_HandleJoypad_2(void) return FALSE; } - if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + if (JOY_REPT(DPAD_RIGHT)) { if (sMoveYourBase_XCursorPos == r4 - 1) sMoveYourBase_XCursorPos = 0; @@ -552,7 +552,7 @@ static bool8 MoveYourBase_HandleJoypad_2(void) return FALSE; } - if (gMain.newKeys & SELECT_BUTTON) + if (JOY_NEW(SELECT_BUTTON)) { if (sMoveYourBase_CursorPos == 0) sSecretBaseNameCharGroup = (sSecretBaseNameCharGroup + 1) % 5; @@ -560,7 +560,7 @@ static bool8 MoveYourBase_HandleJoypad_2(void) return FALSE; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { Menu_BlankWindowRect(2, 5, 11, 6); Menu_BlankWindowRect(11, 1, 11, 2); @@ -568,7 +568,7 @@ static bool8 MoveYourBase_HandleJoypad_2(void) return FALSE; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { if (sMoveYourBase_CursorPos == 0) MoveYourBase_EditOwnerNameChar(100); @@ -580,19 +580,19 @@ static bool8 MoveYourBase_HandleJoypad_2(void) static bool8 MoveYourBase_JoypadAction(void) { - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { Menu_MoveCursor(-2); return FALSE; } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { Menu_MoveCursor(+2); return FALSE; } - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { if (sSecretBaseIdx == 0) sSecretBaseIdx = 19; @@ -602,7 +602,7 @@ static bool8 MoveYourBase_JoypadAction(void) return FALSE; } - if (gMain.newKeys & DPAD_RIGHT) + if (JOY_NEW(DPAD_RIGHT)) { if (sSecretBaseIdx == 19) sSecretBaseIdx = 0; @@ -612,7 +612,7 @@ static bool8 MoveYourBase_JoypadAction(void) return FALSE; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (sSecretBaseIdx != 0 && gSaveBlock1.secretBases[sSecretBaseIdx].secretBaseId != 0) { @@ -625,7 +625,7 @@ static bool8 MoveYourBase_JoypadAction(void) return FALSE; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { CloseMenu(); return TRUE; @@ -657,19 +657,19 @@ static const u8 Str_843E580[] = _( static bool8 MovingPKMN_HandleJoypad(void) { - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { Menu_MoveCursor(-1); return FALSE; } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { Menu_MoveCursor(+1); return FALSE; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { CloseMenu(); switch (Menu_GetCursorPos()) @@ -685,7 +685,7 @@ static bool8 MovingPKMN_HandleJoypad(void) return TRUE; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { CloseMenu(); return TRUE; @@ -814,7 +814,7 @@ static u16 FishingPoints_GetIndexOfCurrentFishingSpot(void) static bool8 FishingPoints_HandleJoypad(void) { - if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { Menu_EraseWindowRect(0, 0, 29, 19); CloseMenu(); @@ -1072,31 +1072,31 @@ static void NakaGenderTest_JoypadAction(u8 i) static bool8 NakaGenderTest_HandleJoypad(void) { - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { NakaGenderTest_JoypadAction(0); return FALSE; } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { NakaGenderTest_JoypadAction(1); return FALSE; } - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { NakaGenderTest_JoypadAction(2); return FALSE; } - if (gMain.newKeys & DPAD_RIGHT) + if (JOY_NEW(DPAD_RIGHT)) { NakaGenderTest_JoypadAction(3); return FALSE; } - if (gMain.newAndRepeatedKeys & A_BUTTON) + if (JOY_REPT(A_BUTTON)) { if (sNakaGenderTest_CursorPosition < 6) NakaGenderTest_AdjustSpecies(sNakaGenderTest_CursorPosition, +1); @@ -1108,7 +1108,7 @@ static bool8 NakaGenderTest_HandleJoypad(void) return FALSE; } - if (gMain.newAndRepeatedKeys & B_BUTTON) + if (JOY_REPT(B_BUTTON)) { if (sNakaGenderTest_CursorPosition < 6) NakaGenderTest_AdjustSpecies(sNakaGenderTest_CursorPosition, -1); @@ -1120,7 +1120,7 @@ static bool8 NakaGenderTest_HandleJoypad(void) return FALSE; } - if (gMain.newAndRepeatedKeys & R_BUTTON) + if (JOY_REPT(R_BUTTON)) { if (sNakaGenderTest_CursorPosition < 6) NakaGenderTest_AdjustSpecies(sNakaGenderTest_CursorPosition, +10); @@ -1132,7 +1132,7 @@ static bool8 NakaGenderTest_HandleJoypad(void) return FALSE; } - if (gMain.newAndRepeatedKeys & L_BUTTON) + if (JOY_REPT(L_BUTTON)) { if (sNakaGenderTest_CursorPosition < 6) NakaGenderTest_AdjustSpecies(sNakaGenderTest_CursorPosition, -10); @@ -1144,7 +1144,7 @@ static bool8 NakaGenderTest_HandleJoypad(void) return FALSE; } - if (gMain.newKeys & START_BUTTON) + if (JOY_NEW(START_BUTTON)) { NakaGenderTest_PartyCompactionEnsureAtLeastOne(); CloseMenu(); @@ -1879,19 +1879,19 @@ static void SetPokeblock_GivePokeblock(void) static bool8 SetPokeblock_HandleJoypad(void) { - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { Menu_MoveCursor(-1); return FALSE; } - if (gMain.newAndRepeatedKeys & DPAD_DOWN) + if (JOY_REPT(DPAD_DOWN)) { Menu_MoveCursor(+1); return FALSE; } - if (gMain.newAndRepeatedKeys & DPAD_LEFT) + if (JOY_REPT(DPAD_LEFT)) { SetPokeblock_AdjustFlavor(Menu_GetCursorPos(), -1); SetPokeblock_PrintFlavorValue(Menu_GetCursorPos()); @@ -1899,7 +1899,7 @@ static bool8 SetPokeblock_HandleJoypad(void) return FALSE; } - if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + if (JOY_REPT(DPAD_RIGHT)) { SetPokeblock_AdjustFlavor(Menu_GetCursorPos(), +1); SetPokeblock_PrintFlavorValue(Menu_GetCursorPos()); @@ -1907,14 +1907,14 @@ static bool8 SetPokeblock_HandleJoypad(void) return FALSE; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { SetPokeblock_GivePokeblock(); PlaySE(SE_SELECT); return FALSE; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { Menu_EraseWindowRect(0, 0, 29, 19); CloseMenu(); @@ -2050,21 +2050,21 @@ static void EVTest_MovePartyCursor(s8 a0) static bool8 EVTest_HandleJoypad(void) { - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { EVTest_MovePartyCursor(-1); EVTest_PrintMonData(gPlayerParty + sEVTest_CursorPosition); return FALSE; } - if (gMain.newKeys & DPAD_RIGHT) + if (JOY_NEW(DPAD_RIGHT)) { EVTest_MovePartyCursor(+1); EVTest_PrintMonData(gPlayerParty + sEVTest_CursorPosition); return FALSE; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { Menu_EraseWindowRect(0, 0, 29, 19); CloseMenu(); @@ -2161,22 +2161,22 @@ static void RNGTest_AdjustAndPrintNumAtLine(u16 * a0, s8 a1, u8 a2) static bool8 RNGTest_HandleJoypad(void) { - s8 r5 = gMain.heldKeys & R_BUTTON ? 100 : 1; + s8 r5 = JOY_HELD(R_BUTTON) ? 100 : 1; s8 r4; - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { Menu_MoveCursor(-1); return FALSE; } - if (gMain.newAndRepeatedKeys & DPAD_DOWN) + if (JOY_REPT(DPAD_DOWN)) { Menu_MoveCursor(+1); return FALSE; } - if (gMain.newAndRepeatedKeys & DPAD_LEFT) + if (JOY_REPT(DPAD_LEFT)) { r4 = Menu_GetCursorPos(); if (r4 == 0) @@ -2190,7 +2190,7 @@ static bool8 RNGTest_HandleJoypad(void) return FALSE; } - if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + if (JOY_REPT(DPAD_RIGHT)) { r4 = Menu_GetCursorPos(); if (r4 == 0) @@ -2204,7 +2204,7 @@ static bool8 RNGTest_HandleJoypad(void) return FALSE; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (sRngMax != 0) { @@ -2214,7 +2214,7 @@ static bool8 RNGTest_HandleJoypad(void) return FALSE; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { Menu_EraseWindowRect(0, 0, 29, 19); CloseMenu(); diff --git a/src/debug/nohara_debug_menu.c b/src/debug/nohara_debug_menu.c index 80527ad42..63a031a32 100644 --- a/src/debug/nohara_debug_menu.c +++ b/src/debug/nohara_debug_menu.c @@ -306,7 +306,7 @@ bool8 debug_sub_808F5D8(void) bool8 debug_sub_808F648(void) { - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { Menu_EraseWindowRect(10, 0, 29, 13); gDebug_03000726 ^= 1; @@ -415,7 +415,7 @@ void debug_sub_808F8CC(void) bool8 debug_sub_808F93C(void) { bool8 updateDisplay = FALSE; - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { gDebug_03000725++; if (gDebug_03000725 == 24) @@ -423,7 +423,7 @@ bool8 debug_sub_808F93C(void) PlaySE(SE_SELECT); updateDisplay = TRUE; } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { if (gDebug_03000725 == 0) gDebug_03000725 = 24; @@ -431,7 +431,7 @@ bool8 debug_sub_808F93C(void) PlaySE(SE_SELECT); updateDisplay = TRUE; } - if (gMain.newKeys & DPAD_RIGHT) + if (JOY_NEW(DPAD_RIGHT)) { gDebug_03000724++; if (gDebug_03000724 == 12) @@ -439,7 +439,7 @@ bool8 debug_sub_808F93C(void) PlaySE(SE_SELECT); updateDisplay = TRUE; } - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { if (gDebug_03000724 == 0) gDebug_03000724 = 12; @@ -455,12 +455,12 @@ bool8 debug_sub_808F93C(void) ConvertIntToDecimalStringN(gStringVar1, gDebug_03000725, STR_CONV_MODE_LEFT_ALIGN, 2); Menu_PrintText(gStringVar1, 23, 1); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_PIN); debug_sub_808FA88(gDebug_03000725, gUnknown_Debug_083C4ABD[gDebug_03000724]); } - if (gMain.newKeys & (B_BUTTON | START_BUTTON)) + if (JOY_NEW(B_BUTTON | START_BUTTON)) { sub_80BF588(gSaveBlock1.tvShows); CloseMenu(); @@ -764,7 +764,7 @@ bool8 debug_sub_808FF3C(void) { bool8 updateDisplay = FALSE; - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { gDebug_03000725++; if (gDebug_03000725 == 16) @@ -773,7 +773,7 @@ bool8 debug_sub_808FF3C(void) updateDisplay = TRUE; } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { if (gDebug_03000725 == 0) gDebug_03000725 = 16; @@ -782,7 +782,7 @@ bool8 debug_sub_808FF3C(void) updateDisplay = TRUE; } - if (gMain.newKeys & DPAD_RIGHT) + if (JOY_NEW(DPAD_RIGHT)) { gDebug_03000724++; if (gDebug_03000724 == 3) @@ -791,7 +791,7 @@ bool8 debug_sub_808FF3C(void) updateDisplay = TRUE; } - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { if (gDebug_03000724 == 0) gDebug_03000724 = 3; @@ -809,13 +809,13 @@ bool8 debug_sub_808FF3C(void) Menu_PrintText(gStringVar1, 23, 1); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_PIN); debug_sub_8090080(gDebug_03000725, gUnknown_Debug_083C4B20[gDebug_03000724]); } - if (gMain.newKeys & (B_BUTTON | START_BUTTON)) + if (JOY_NEW(B_BUTTON | START_BUTTON)) { sub_80BEC40(); CloseMenu(); @@ -963,7 +963,7 @@ bool8 debug_sub_8090238(void) bool8 debug_sub_8090278(void) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { CloseMenu(); return TRUE; diff --git a/src/debug/sound_check_menu.c b/src/debug/sound_check_menu.c index 6f6ee58dd..b18823326 100644 --- a/src/debug/sound_check_menu.c +++ b/src/debug/sound_check_menu.c @@ -199,19 +199,19 @@ void sub_80BA384(u8 taskId) // Task_HandleDrawingSoundCheckMenuText bool8 Task_ProcessSoundCheckMenuInput(u8 taskId) { - if (gMain.newKeys & R_BUTTON) // driver test + if (JOY_NEW(R_BUTTON)) // driver test { gTasks[taskId].func = Task_DrawDriverTestMenu; } - else if (gMain.newKeys & L_BUTTON) + else if (JOY_NEW(L_BUTTON)) { gTasks[taskId].func = sub_80BAF84; } - else if (gMain.newKeys & START_BUTTON) + else if (JOY_NEW(START_BUTTON)) { gTasks[taskId].func = Task_InitCryTest; } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { if (gTasks[taskId].tWindowSelected != 0) // is playing? { @@ -258,23 +258,23 @@ bool8 Task_ProcessSoundCheckMenuInput(u8 taskId) } } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { m4aSongNumStart(SE_SELECT); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); gTasks[taskId].func = sub_80BA68C; } - else if (gMain.newAndRepeatedKeys & DPAD_UP) + else if (JOY_REPT(DPAD_UP)) { gTasks[taskId].tWindowSelected ^= 1; return TRUE; } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { gTasks[taskId].tWindowSelected ^= 1; return TRUE; } - else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + else if (JOY_REPT(DPAD_RIGHT)) { if (gTasks[taskId].tWindowSelected != 0) { @@ -292,7 +292,7 @@ bool8 Task_ProcessSoundCheckMenuInput(u8 taskId) } return TRUE; } - else if (gMain.newAndRepeatedKeys & DPAD_LEFT) + else if (JOY_REPT(DPAD_LEFT)) { if (gTasks[taskId].tWindowSelected != 0) { @@ -310,7 +310,7 @@ bool8 Task_ProcessSoundCheckMenuInput(u8 taskId) } return TRUE; } - else if (gMain.heldKeys & SELECT_BUTTON) + else if (JOY_HELD(SELECT_BUTTON)) { gUnknown_020387B0 = 1; } @@ -454,7 +454,7 @@ void Task_DrawDriverTestMenu(u8 taskId) // Task_DrawDriverTestMenu void Task_ProcessDriverTestInput(u8 taskId) { - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { REG_DISPCNT = 0x7140; REG_WIN0H = WIN_RANGE(17, 223); @@ -463,7 +463,7 @@ void Task_ProcessDriverTestInput(u8 taskId) gTasks[taskId].func = Task_InitSoundCheckMenu; return; } - if (gMain.newAndRepeatedKeys & DPAD_UP) // _080BAAA8 + if (JOY_REPT(DPAD_UP)) // _080BAAA8 { u8 old = sDriverTestSelection; @@ -472,7 +472,7 @@ void Task_ProcessDriverTestInput(u8 taskId) sub_80BAE10(old, sDriverTestSelection); return; } - if (gMain.newAndRepeatedKeys & DPAD_DOWN) // _080BAAD0 + if (JOY_REPT(DPAD_DOWN)) // _080BAAD0 { u8 old = sDriverTestSelection; @@ -481,44 +481,44 @@ void Task_ProcessDriverTestInput(u8 taskId) sub_80BAE10(old, sDriverTestSelection); return; } - if (gMain.newKeys & START_BUTTON) // _080BAAF8 + if (JOY_NEW(START_BUTTON)) // _080BAAF8 { gUnknown_020387D8 ^= 1; PrintDriverTestMenuText(); return; } - if (gMain.newKeys & SELECT_BUTTON) // _080BAB14 + if (JOY_NEW(SELECT_BUTTON)) // _080BAB14 { gUnknown_020387D9 ^= 1; PrintDriverTestMenuText(); SetPokemonCryStereo(gUnknown_020387D9); return; } - if (gMain.newAndRepeatedKeys & R_BUTTON) // _080BAB38 + if (JOY_REPT(R_BUTTON)) // _080BAB38 { AdjustSelectedDriverParam(10); PrintDriverTestMenuText(); return; } - if (gMain.newAndRepeatedKeys & L_BUTTON) // _080BAB46 + if (JOY_REPT(L_BUTTON)) // _080BAB46 { AdjustSelectedDriverParam(-10); PrintDriverTestMenuText(); return; } - if (gMain.newAndRepeatedKeys & DPAD_LEFT) // _080BAB56 + if (JOY_REPT(DPAD_LEFT)) // _080BAB56 { AdjustSelectedDriverParam(-1); PrintDriverTestMenuText(); return; } - if (gMain.newAndRepeatedKeys & DPAD_RIGHT) // _080BAB64 + if (JOY_REPT(DPAD_RIGHT)) // _080BAB64 { AdjustSelectedDriverParam(1); PrintDriverTestMenuText(); return; } - if (gMain.newKeys & A_BUTTON) // _080BAB78 + if (JOY_NEW(A_BUTTON)) // _080BAB78 { u8 divide, remaining; @@ -728,7 +728,7 @@ void sub_80BB038(u8 taskId) } } // _080BB0A2 - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { REG_DISPCNT = 0x7140; REG_WIN0H = WIN_RANGE(17, 223); @@ -737,7 +737,7 @@ void sub_80BB038(u8 taskId) gTasks[taskId].func = Task_InitSoundCheckMenu; return; } - if (gMain.newKeys & A_BUTTON) // _080BB104 + if (JOY_NEW(A_BUTTON)) // _080BB104 { s8 panpot = gUnknown_083D03F8[sSoundTestParams[CRY_TEST_PANPOT]]; if (panpot != -128) @@ -764,25 +764,25 @@ void sub_80BB038(u8 taskId) sSoundTestParams[CRY_TEST_PROGRESS] = 0; return; } - if (gMain.newKeys & L_BUTTON) // _080BB15E + if (JOY_NEW(L_BUTTON)) // _080BB15E { sSoundTestParams[CRY_TEST_PANPOT]++; if (sSoundTestParams[CRY_TEST_PANPOT] > 4) sSoundTestParams[CRY_TEST_PANPOT] = 0; } - if (gMain.newKeys & R_BUTTON) // _080BB176 + if (JOY_NEW(R_BUTTON)) // _080BB176 { sSoundTestParams[CRY_TEST_PANPOT]--; if (sSoundTestParams[CRY_TEST_PANPOT] < 0) sSoundTestParams[CRY_TEST_PANPOT] = 4; } - if (gMain.newAndRepeatedKeys & DPAD_RIGHT) // _080BB192 + if (JOY_REPT(DPAD_RIGHT)) // _080BB192 { sSoundTestParams[CRY_TEST_VOICE]++; if (sSoundTestParams[CRY_TEST_VOICE] > 247) sSoundTestParams[CRY_TEST_VOICE] = 0; } - else if (gMain.newAndRepeatedKeys & DPAD_LEFT) // _080BB1B0 + else if (JOY_REPT(DPAD_LEFT)) // _080BB1B0 { sSoundTestParams[CRY_TEST_VOICE]--; if (sSoundTestParams[CRY_TEST_VOICE] < 0) @@ -1257,27 +1257,27 @@ void Task_ProcessCryTestInput(u8 taskId) { UpdateCryWaveformWindow(3); - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { CryScreenPlayButton(gSoundTestCryNum); } - if (gMain.newKeys & R_BUTTON) + if (JOY_NEW(R_BUTTON)) { StopCryAndClearCrySongs(); } - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { if(--gSoundTestCryNum == 0) gSoundTestCryNum = 384; // total species PrintCryNumber(); } - if (gMain.newAndRepeatedKeys & DPAD_DOWN) + if (JOY_REPT(DPAD_DOWN)) { if(++gSoundTestCryNum > 384) gSoundTestCryNum = 1; PrintCryNumber(); } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { REG_DISPCNT = 0x7140; REG_WIN0H = WIN_RANGE(17, 223); diff --git a/src/debug/start_menu_debug.c b/src/debug/start_menu_debug.c index ec1e6527a..36ebf4aba 100644 --- a/src/debug/start_menu_debug.c +++ b/src/debug/start_menu_debug.c @@ -445,7 +445,7 @@ void debug_sub_8076BB4(u8 taskId) gDebug_TestMenuItems[gUnknown_030006C4[cursorPos]].func(); break; case -2: - if (gMain.newKeys & 0x20) + if (JOY_NEW(DPAD_LEFT)) { if (data[0] == 0) data[0] = 1; @@ -454,7 +454,7 @@ void debug_sub_8076BB4(u8 taskId) debug_sub_8076AC8(data[0]); PlaySE(SE_SELECT); } - else if (gMain.newKeys & 0x10) + else if (JOY_NEW(DPAD_RIGHT)) { if (data[0] == 1) data[0] = 0; @@ -574,7 +574,7 @@ void DebugMenu_8076D6C(u8 taskId) data[0]++; break; case 1: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { Menu_DisplayDialogueFrame(); Menu_PrintText(Str_839BD4C, 2, 15); @@ -582,14 +582,14 @@ void DebugMenu_8076D6C(u8 taskId) RtcReset(); data[0]++; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { DestroyTask(taskId); DoSoftReset(); } break; case 2: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { DestroyTask(taskId); DoSoftReset(); @@ -617,7 +617,7 @@ void DebugMenu_8076E30(u8 taskId) data[0]++; break; case 1: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { Menu_DisplayDialogueFrame(); sub_813B79C(); @@ -625,14 +625,14 @@ void DebugMenu_8076E30(u8 taskId) PlaySE(SE_DING_DONG); data[0]++; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { DestroyTask(taskId); DoSoftReset(); // noreturn } break; case 2: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { DestroyTask(taskId); DoSoftReset(); // noreturn @@ -757,17 +757,17 @@ u8 DebugMenu_807709C(void) { u8 actionRet; - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { PlaySE(SE_SELECT); gUnknown_030006C0 = Menu_MoveCursor(-1); } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { PlaySE(SE_SELECT); gUnknown_030006C0 = Menu_MoveCursor(+1); } - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { PlaySE(SE_SELECT); if (gUnknown_030006C1 == 0) @@ -777,7 +777,7 @@ u8 DebugMenu_807709C(void) DebugMenu_8077004(); DebugMenu_807719C(); } - if (gMain.newKeys & DPAD_RIGHT) + if (JOY_NEW(DPAD_RIGHT)) { PlaySE(SE_SELECT); if (gUnknown_030006C1 == 7) @@ -787,7 +787,7 @@ u8 DebugMenu_807709C(void) DebugMenu_8077004(); DebugMenu_807719C(); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); actionRet = gDebug0x839B9BC[gUnknown_030006C4[gUnknown_030006C0]].func(); @@ -798,7 +798,7 @@ u8 DebugMenu_807709C(void) #endif return actionRet; } - if (gMain.newKeys & (B_BUTTON | START_BUTTON)) + if (JOY_NEW(B_BUTTON | START_BUTTON)) { CloseMenu(); // TODO: see if this is in rev1+ @@ -1131,7 +1131,7 @@ void DebugMenu_8077704(void) u8 DebugMenu_8077760(void) { - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { PlaySE(SE_SELECT); Menu_MoveCursor(-1); @@ -1140,7 +1140,7 @@ u8 DebugMenu_8077760(void) else gUnknown_030006B8 = 3; } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { PlaySE(SE_SELECT); Menu_MoveCursor(+1); @@ -1149,13 +1149,13 @@ u8 DebugMenu_8077760(void) else gUnknown_030006B8 = 0; } - if (gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT)) + if (JOY_NEW(DPAD_LEFT | DPAD_RIGHT)) { PlaySE(SE_SELECT); gUnknown_030006C8 ^= (1 << Menu_GetCursorPos()); DebugMenu_80776B4(Menu_GetCursorPos()); } - if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { REG_DISPCNT = (REG_DISPCNT & 0xF0FF) + (gUnknown_030006C8 << 8); CloseMenu(); @@ -1184,13 +1184,13 @@ void DebugMenu_807786C(u8 a0) u8 DebugMenu_80778A8(void) { - if (gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT)) + if (JOY_NEW(DPAD_LEFT | DPAD_RIGHT)) { PlaySE(SE_SELECT); gWildEncountersDisabled ^= 1; DebugMenu_807786C(gWildEncountersDisabled); } - if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { CloseMenu(); return TRUE; @@ -1554,7 +1554,7 @@ u8 DebugMenu_8077D78(const struct MenuAction *menuActions) bool8 DebugMenu_8077DB4(void) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { CloseMenu(); return TRUE; @@ -1595,12 +1595,12 @@ bool32 DebugMenu_8077DD8(s16 * a0, s32 a1, s32 a2, u16 a3) int DebugMenu_8077E40(int flag) { - if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { CloseMenu(); return -1; } - if (gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT)) + if (JOY_NEW(DPAD_LEFT | DPAD_RIGHT)) { PlaySE(SE_SELECT); if (flag) @@ -1659,14 +1659,14 @@ const u8 Str_839C014[] = _("How many?"); void DebugMenu_8077F7C(u8 taskId) { struct Task *task = gTasks + taskId; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { Menu_DisplayDialogueFrame(); Menu_PrintText(Str_839C014, 2, 15); DebugMenu_8077EE0(task->data[1], task->data[2]); task->func = DebugMenu_8077FFC; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { task->func = DebugMenu_807806C; } @@ -1679,13 +1679,13 @@ void DebugMenu_8077F7C(u8 taskId) void DebugMenu_8077FFC(u8 taskId) { struct Task *task = gTasks + taskId; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (AddBagItem(task->data[1], task->data[2]) == TRUE) PlaySE(SE_SELECT); task->func = DebugMenu_8077F40; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { task->func = DebugMenu_8077F40; } @@ -1755,7 +1755,7 @@ void DebugMenu_807808C(u32 a0) void DebugMenu_807817C(u8 taskId) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { Menu_EraseScreen(); DestroyTask(taskId); @@ -1769,13 +1769,13 @@ void DebugMenu_80781A8(u8 taskId) if (task->data[0] == 0) task->data[0]++; - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { DebugMenu_807808C(task->data[0]); task->func = DebugMenu_807817C; return; } - else if (!DebugMenu_8077DD8(task->data + 0, 1, 13, gMain.newAndRepeatedKeys & (DPAD_UP | DPAD_DOWN))) + else if (!DebugMenu_8077DD8(task->data + 0, 1, 13, JOY_REPT(DPAD_UP | DPAD_DOWN))) return; Menu_BlankWindowRect(4, 17, 22, 18); ConvertIntToDecimalStringN(gStringVar1, task->data[0], STR_CONV_MODE_RIGHT_ALIGN, 3); @@ -1846,7 +1846,7 @@ void DebugMenu_8078310(u8 taskId) data[0]++; break; case 1: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_DING_DONG); *GetVarPointer(VAR_MIRAGE_RND_H) = data[1]; @@ -1854,7 +1854,7 @@ void DebugMenu_8078310(u8 taskId) DestroyTask(taskId); ScriptContext2_Disable(); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { Menu_EraseScreen(); DestroyTask(taskId); @@ -1876,7 +1876,7 @@ u8 DebugMenu_MiragaIslandRND(void) bool8 DebugMenu_80783C8(void) { - if (gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT)) + if (JOY_NEW(DPAD_LEFT | DPAD_RIGHT)) { PlaySE(SE_SELECT); if (!FlagGet(FLAG_SYS_GAME_CLEAR)) @@ -1890,7 +1890,7 @@ bool8 DebugMenu_80783C8(void) DebugMenu_807786C(1); } } - if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { CloseMenu(); return TRUE; @@ -2101,23 +2101,23 @@ bool32 DebugMenu_807860C(u8 taskId) data[0]++; return FALSE; case 1: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { data[0]--; return TRUE; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { data[0]++; return FALSE; } - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { data[1]++; if (data[1] == NUM_GAME_STATS) data[1] = 0; } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { data[1]--; if (data[1] < 0) @@ -2240,7 +2240,7 @@ void DebugMenu_8078880(u8 taskId) gTasks[taskId].data[0]++; break; case 2: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { Menu_EraseScreen(); ScriptContext2_Disable(); @@ -2309,18 +2309,18 @@ void DebugMenu_80789CC(u8 taskId) void DebugMenu_8078A14(u8 taskId) { s16 * data = gTasks[taskId].data; - if (gMain.newKeys & (DPAD_UP | DPAD_DOWN)) + if (JOY_NEW(DPAD_UP | DPAD_DOWN)) { data[0] = data[0] == 0 ? 1 : 0; DebugMenu_8078968(data[0]); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { data[1] = gSaveBlock2.battleTower.curStreakChallengesNum[data[0]]; DebugMenu_80789A4(data[1]); gTasks[taskId].func = DebugMenu_8078AA4; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { gTasks[taskId].func = DebugMenu_8078B38; } @@ -2333,13 +2333,13 @@ void DebugMenu_8078AA4(u8 taskId) { DebugMenu_80789A4(data[1]); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { gSaveBlock2.battleTower.curStreakChallengesNum[data[0]] = data[1]; PlaySE(SE_DING_DONG); gTasks[taskId].func = DebugMenu_8078B38; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { DebugMenu_8078950(); DebugMenu_8078968(data[0]); @@ -2433,7 +2433,7 @@ void DebugMenu_8078BD4(u8 taskId) data[0]++; break; case 1: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_DING_DONG); Menu_EraseScreen(); @@ -2441,7 +2441,7 @@ void DebugMenu_8078BD4(u8 taskId) ScriptContext2_Disable(); DebugMenu_8078B94(); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { Menu_EraseScreen(); DestroyTask(taskId); @@ -2484,12 +2484,12 @@ bool8 DebugMenu_8078C80(void) bool8 DebugMenu_8078CA8(void) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { gMenuCallback = DebugMenu_8078CE4; return FALSE; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { CloseMenu(); return TRUE; @@ -2537,7 +2537,7 @@ bool8 DebugMenu_8078D7C(void) bool8 DebugMenu_8078DA4(void) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { CloseMenu(); return TRUE; @@ -2637,7 +2637,7 @@ void DebugMenu_8078F68(u8 taskId) { s16 * data = gTasks[taskId].data; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { gSaveBlock2.playTimeHours = data[1]; gSaveBlock2.playTimeMinutes = data[2]; @@ -2645,11 +2645,11 @@ void DebugMenu_8078F68(u8 taskId) PlaySE(SE_DING_DONG); gTasks[taskId].func = DebugMenu_8079020; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { gTasks[taskId].func = DebugMenu_8079020; } - else if (gMain.newKeys & DPAD_LEFT) + else if (JOY_NEW(DPAD_LEFT)) { if ((u16)data[0] > 0) { @@ -2657,7 +2657,7 @@ void DebugMenu_8078F68(u8 taskId) DebugMenu_8078E80(data); } } - else if (gMain.newKeys & DPAD_RIGHT) + else if (JOY_NEW(DPAD_RIGHT)) { if ((u16)data[0] < 2) { @@ -2767,7 +2767,7 @@ void DebugMenu_8079110(u8 taskId) gTasks[taskId].data[0]++; break; case 2: - if (Menu_UpdateWindowText() && gMain.newKeys & A_BUTTON) + if (Menu_UpdateWindowText() && JOY_NEW(A_BUTTON)) { Menu_EraseScreen(); ScriptContext2_Disable(); diff --git a/src/debug/taya_debug_window.c b/src/debug/taya_debug_window.c index 9a997a566..995b92fec 100644 --- a/src/debug/taya_debug_window.c +++ b/src/debug/taya_debug_window.c @@ -231,7 +231,7 @@ bool8 TayaDebugMenu_Trend(void) bool8 debug_sub_8090808(void) { - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { Menu_EraseScreen(); CloseMenu(); @@ -445,17 +445,17 @@ bool8 debug_sub_8090C88(void) do { - if (gMain.newKeys & DPAD_LEFT && eTayaLuckyNumber.digit != 0) + if (JOY_NEW(DPAD_LEFT) && eTayaLuckyNumber.digit != 0) { eTayaLuckyNumber.digit--; break; } - if (gMain.newKeys & DPAD_RIGHT && eTayaLuckyNumber.digit < 4) + if (JOY_NEW(DPAD_RIGHT) && eTayaLuckyNumber.digit < 4) { eTayaLuckyNumber.digit++; break; } - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { u8 r4; @@ -472,7 +472,7 @@ bool8 debug_sub_8090C88(void) break; } } - if (gMain.newAndRepeatedKeys & DPAD_DOWN) + if (JOY_REPT(DPAD_DOWN)) { u8 r4; @@ -489,12 +489,12 @@ bool8 debug_sub_8090C88(void) break; } } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { CloseMenu(); return TRUE; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { SetLotteryNumber16_Unused(eTayaLuckyNumber.curLuckyId); CloseMenu(); @@ -658,14 +658,14 @@ bool8 TayaDebugMenu_8091190(void) return FALSE; case -2: r4 = sTayaTopMenuPage; - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { sTayaTopMenuPage--; if (sTayaTopMenuPage < 0) sTayaTopMenuPage = 1; } - if (gMain.newKeys & DPAD_RIGHT) + if (JOY_NEW(DPAD_RIGHT)) { sTayaTopMenuPage++; if ((u8)sTayaTopMenuPage > 1) @@ -729,7 +729,7 @@ void debug_sub_8091334(void) { case 0: eTayaMonData.redraw = 0; - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { if (eTayaMonData.y != 0) { @@ -737,7 +737,7 @@ void debug_sub_8091334(void) eTayaMonData.redraw = 1; } } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { if (eTayaMonData.x != 2) { @@ -756,7 +756,7 @@ void debug_sub_8091334(void) } } } - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { if (eTayaMonData.x != 0) { @@ -764,7 +764,7 @@ void debug_sub_8091334(void) eTayaMonData.redraw = 1; } } - if (gMain.newKeys & DPAD_RIGHT) + if (JOY_NEW(DPAD_RIGHT)) { if (eTayaMonData.y != 5) { @@ -787,7 +787,7 @@ void debug_sub_8091334(void) { debug_sub_80916AC(); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { u16 param = gUnknown_Debug_083C50EC[eTayaMonData.y][eTayaMonData.x].param; if (param >= MON_DATA_COOL_RIBBON && param <= MON_DATA_TOUGH_RIBBON) @@ -796,7 +796,7 @@ void debug_sub_8091334(void) eTayaMonData.maxVal = 1; eTayaMonData.state = 1; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { BlendPalettes(0xFFFFFFFF, 16, RGB(0, 0, 0)); SetMainCallback2(sub_80546F0); @@ -804,7 +804,7 @@ void debug_sub_8091334(void) break; case 1: eTayaMonData.redraw = 0; - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { if (eTayaMonData.data[eTayaMonData.y][eTayaMonData.x] < eTayaMonData.maxVal) { @@ -812,7 +812,7 @@ void debug_sub_8091334(void) eTayaMonData.redraw = 1; } } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { if (eTayaMonData.data[eTayaMonData.y][eTayaMonData.x] != 0) { @@ -826,13 +826,13 @@ void debug_sub_8091334(void) } else { - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { eTayaMonData.data[eTayaMonData.y][eTayaMonData.x] = GetMonData(gPlayerParty, gUnknown_Debug_083C50EC[eTayaMonData.y][eTayaMonData.x].param); debug_sub_80916AC(); eTayaMonData.state = 0; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (gUnknown_Debug_083C50EC[eTayaMonData.y][eTayaMonData.x].param) SetMonData(gPlayerParty, gUnknown_Debug_083C50EC[eTayaMonData.y][eTayaMonData.x].param, &eTayaMonData.data[eTayaMonData.y][eTayaMonData.x]); diff --git a/src/debug/tomomichi_debug_menu.c b/src/debug/tomomichi_debug_menu.c index cc0c89c71..6b217e287 100644 --- a/src/debug/tomomichi_debug_menu.c +++ b/src/debug/tomomichi_debug_menu.c @@ -1961,22 +1961,22 @@ static bool8 InitDebugWindow(void) static bool8 TopMenu_HandleInput(void) { - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { PlaySE(SE_SELECT); sTopMenuCursorPos = Menu_MoveCursor(-1); } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { PlaySE(SE_SELECT); sTopMenuCursorPos = Menu_MoveCursor(+1); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); return sMenuActions_TopMenu[sTopMenuCursorPos].func(); } - if (gMain.newKeys & (B_BUTTON | START_BUTTON)) + if (JOY_NEW(B_BUTTON | START_BUTTON)) { CloseMenu(); return TRUE; @@ -2171,22 +2171,22 @@ static bool8 PreviewData_HandleInput(void) static bool8 TrickHouse_HandleInput(void) { - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { PlaySE(SE_SELECT); sTrickRelatedMenuCursorPos = Menu_MoveCursor(-1); } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { PlaySE(SE_SELECT); sTrickRelatedMenuCursorPos = Menu_MoveCursor(+1); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); return sMenuActions_TrickRelated[sTrickRelatedMenuCursorPos].func(); } - if (gMain.newKeys & (B_BUTTON | START_BUTTON)) + if (JOY_NEW(B_BUTTON | START_BUTTON)) { CloseMenu(); return TRUE; @@ -2196,22 +2196,22 @@ static bool8 TrickHouse_HandleInput(void) static bool8 ControlEvents_HandleInput(void) { - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { PlaySE(SE_SELECT); sControlEventsCursorPos = Menu_MoveCursor(-1); } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { PlaySE(SE_SELECT); sControlEventsCursorPos = Menu_MoveCursor(+1); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); return sMenuActions_ControlEvents[sControlEventsCursorPos].func(); } - if (gMain.newKeys & (B_BUTTON | START_BUTTON)) + if (JOY_NEW(B_BUTTON | START_BUTTON)) { CloseMenu(); return TRUE; @@ -2221,22 +2221,22 @@ static bool8 ControlEvents_HandleInput(void) static bool8 ControlFlags_HandleInput(void) { - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { PlaySE(SE_SELECT); sControlFlagsCursorPos = Menu_MoveCursor(-1); } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { PlaySE(SE_SELECT); sControlFlagsCursorPos = Menu_MoveCursor(+1); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); return sMenuActions_ControlFlags[sControlFlagsCursorPos].func(); } - if (gMain.newKeys & (B_BUTTON | START_BUTTON)) + if (JOY_NEW(B_BUTTON | START_BUTTON)) { CloseMenu(); return TRUE; @@ -2246,22 +2246,22 @@ static bool8 ControlFlags_HandleInput(void) static bool8 ControlWorks_HandleInput(void) { - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { PlaySE(SE_SELECT); sControlWORKCursorPos = Menu_MoveCursor(-1); } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { PlaySE(SE_SELECT); sControlWORKCursorPos = Menu_MoveCursor(+1); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); return sMenuActions_ControlWorks[sControlWORKCursorPos].func(); } - if (gMain.newKeys & (B_BUTTON | START_BUTTON)) + if (JOY_NEW(B_BUTTON | START_BUTTON)) { CloseMenu(); return TRUE; @@ -2607,7 +2607,7 @@ static bool8 debug_sub_808C6C8(void) static void debug_sub_808C714(u8 whichMenu, u8 cursorPos) { - if (gMain.newKeys & R_BUTTON) + if (JOY_NEW(R_BUTTON)) { if (!FlagGet(gUnknown_Debug_83C31E6[whichMenu][cursorPos])) FlagSet(gUnknown_Debug_83C31E6[whichMenu][cursorPos]); @@ -2769,7 +2769,7 @@ static bool8 debug_sub_808CB74(void) static void debug_sub_808CBC0(u8 whichMenu, u8 cursorPos) { - if (gMain.newKeys & R_BUTTON) + if (JOY_NEW(R_BUTTON)) { if (!FlagGet(gUnknown_Debug_083C271A[whichMenu][cursorPos])) FlagSet(gUnknown_Debug_083C271A[whichMenu][cursorPos]); @@ -2865,7 +2865,7 @@ static bool8 debug_sub_808CE10(void) static void debug_sub_808CE5C(u8 whichMenu, u8 cursorPos) { - if (gMain.newKeys & R_BUTTON) + if (JOY_NEW(R_BUTTON)) { if (!FlagGet(gUnknown_Debug_083C1C38[whichMenu][cursorPos])) FlagSet(gUnknown_Debug_083C1C38[whichMenu][cursorPos]); @@ -3027,7 +3027,7 @@ static bool8 debug_sub_808D2BC(void) static void debug_sub_808D308(u8 whichMenu, u8 cursorPos) { - if (gMain.newKeys & R_BUTTON) + if (JOY_NEW(R_BUTTON)) { if (!FlagGet(gUnknown_Debug_083C19C6[whichMenu][cursorPos])) FlagSet(gUnknown_Debug_083C19C6[whichMenu][cursorPos]); @@ -3112,7 +3112,7 @@ static bool8 ControlFlags_FH_OBJ_Subsubmenu_HandleInput(void) static void ControlFlags_FH_OBJ_FlagToggle(u8 whichMenu, u8 cursorPos) { - if (gMain.newKeys & R_BUTTON) + if (JOY_NEW(R_BUTTON)) { if (!FlagGet(sControlFlags_FH_OBJ_FlagsArrays[whichMenu][cursorPos])) FlagSet(sControlFlags_FH_OBJ_FlagsArrays[whichMenu][cursorPos]); @@ -3197,7 +3197,7 @@ static bool8 debug_sub_808D744(void) static void debug_sub_808D790(u8 whichMenu, u8 cursorPos) { - if (gMain.newKeys & R_BUTTON) + if (JOY_NEW(R_BUTTON)) { if (!FlagGet(gUnknown_Debug_083C12D2[whichMenu][cursorPos])) FlagSet(gUnknown_Debug_083C12D2[whichMenu][cursorPos]); @@ -3271,7 +3271,7 @@ static bool8 debug_sub_808D930(void) static void debug_sub_808D97C(u8 whichMenu, u8 cursorPos) { - if (gMain.newKeys & R_BUTTON) + if (JOY_NEW(R_BUTTON)) { if (!FlagGet(gUnknown_Debug_083C1AAE[whichMenu][cursorPos])) FlagSet(gUnknown_Debug_083C1AAE[whichMenu][cursorPos]); @@ -3326,11 +3326,11 @@ static void ControlWorks_AnsWork_AdjustRESULT(void) { u16 delta; - if (gMain.newKeys & R_BUTTON) + if (JOY_NEW(R_BUTTON)) { delta = +1; } - else if (gMain.newKeys & L_BUTTON) + else if (JOY_NEW(L_BUTTON)) { delta = -1; } @@ -3494,9 +3494,9 @@ static void debug_sub_808DF64(u8 whichMenu, u8 cursorPos) { u16 delta; - if (gMain.newKeys & R_BUTTON) + if (JOY_NEW(R_BUTTON)) delta = +1; - else if (gMain.newKeys & L_BUTTON) + else if (JOY_NEW(L_BUTTON)) delta = -1; else return; @@ -3625,9 +3625,9 @@ static void debug_sub_808E310(u8 whichMenu, u8 cursorPos) { u16 delta; - if (gMain.newKeys & R_BUTTON) + if (JOY_NEW(R_BUTTON)) delta = +1; - else if (gMain.newKeys & L_BUTTON) + else if (JOY_NEW(L_BUTTON)) delta = -1; else return; @@ -3735,9 +3735,9 @@ static void debug_sub_808E604(u8 whichMenu, u8 cursorPos) { u16 delta; - if (gMain.newAndRepeatedKeys & R_BUTTON) + if (JOY_REPT(R_BUTTON)) delta = +1; - else if (gMain.newAndRepeatedKeys & L_BUTTON) + else if (JOY_REPT(L_BUTTON)) delta = -1; else return; @@ -3822,9 +3822,9 @@ static void debug_sub_808E850(u8 whichMenu, u8 cursorPos) { u16 delta; - if (gMain.newKeys & R_BUTTON) + if (JOY_NEW(R_BUTTON)) delta = +1; - else if (gMain.newKeys & L_BUTTON) + else if (JOY_NEW(L_BUTTON)) delta = -1; else return; @@ -3919,9 +3919,9 @@ static void debug_sub_808EAFC(u8 whichMenu, u8 cursorPos) { u16 delta; - if (gMain.newKeys & R_BUTTON) + if (JOY_NEW(R_BUTTON)) delta = +1; - else if (gMain.newKeys & L_BUTTON) + else if (JOY_NEW(L_BUTTON)) delta = -1; else return; @@ -4013,24 +4013,24 @@ static bool8 DummyMenuAction(void) static void PicTest_SelectPokemon(void) { - if (gMain.newAndRepeatedKeys & DPAD_LEFT) + if (JOY_REPT(DPAD_LEFT)) { if (sPicTest_Species != SPECIES_BULBASAUR) sPicTest_Species--; } - if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + if (JOY_REPT(DPAD_RIGHT)) { if (sPicTest_Species != SPECIES_CHIMECHO) sPicTest_Species++; } - if (gMain.newAndRepeatedKeys & L_BUTTON) + if (JOY_REPT(L_BUTTON)) { if (sPicTest_Species >= SPECIES_BULBASAUR + 10) sPicTest_Species -= 10; else sPicTest_Species = SPECIES_BULBASAUR; } - if (gMain.newAndRepeatedKeys & R_BUTTON) + if (JOY_REPT(R_BUTTON)) { if (sPicTest_Species <= SPECIES_CHIMECHO - 10) sPicTest_Species += 10; @@ -4041,31 +4041,31 @@ static void PicTest_SelectPokemon(void) static void PicTest_SelectPersonality(void) { - if (gMain.newAndRepeatedKeys & DPAD_LEFT) + if (JOY_REPT(DPAD_LEFT)) { if (sPicTest_Personality != 0) sPicTest_Personality--; } - if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + if (JOY_REPT(DPAD_RIGHT)) { if (sPicTest_Personality != UINT32_MAX) sPicTest_Personality++; } - if (gMain.newAndRepeatedKeys & L_BUTTON) + if (JOY_REPT(L_BUTTON)) { if (sPicTest_Personality >= 0x10) sPicTest_Personality -= 0x10; else sPicTest_Personality = 0; } - if (gMain.newAndRepeatedKeys & R_BUTTON) + if (JOY_REPT(R_BUTTON)) { if (sPicTest_Personality <= UINT32_MAX - 0x10) sPicTest_Personality += 0x10; else sPicTest_Personality = UINT32_MAX; } - if ((gMain.newKeys & (L_BUTTON | R_BUTTON)) == (L_BUTTON | R_BUTTON)) + if (JOY_NEW(L_BUTTON | R_BUTTON) == (L_BUTTON | R_BUTTON)) { sPicTest_Personality = UINT32_MAX; } @@ -4073,42 +4073,42 @@ static void PicTest_SelectPersonality(void) static void ContestPicTest_SelectContestType(void) { - if (gMain.newAndRepeatedKeys & DPAD_LEFT) + if (JOY_REPT(DPAD_LEFT)) { if (sPicTest_ContestType != CONTEST_COOL + 1) sPicTest_ContestType--; } - if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + if (JOY_REPT(DPAD_RIGHT)) { if (sPicTest_ContestType != CONTEST_TOUGH + 1) sPicTest_ContestType++; } - if (gMain.newAndRepeatedKeys & L_BUTTON) + if (JOY_REPT(L_BUTTON)) sPicTest_ContestType = CONTEST_COOL + 1; - if (gMain.newAndRepeatedKeys & R_BUTTON) + if (JOY_REPT(R_BUTTON)) sPicTest_ContestType = CONTEST_TOUGH + 1; } static void MuseumArtPicTest_SelectTitleType(void) { - if (gMain.newAndRepeatedKeys & DPAD_LEFT) + if (JOY_REPT(DPAD_LEFT)) { if (sPicTest_MuseumArtTitleType != 1) sPicTest_MuseumArtTitleType--; } - if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + if (JOY_REPT(DPAD_RIGHT)) { if (sPicTest_MuseumArtTitleType != 15) sPicTest_MuseumArtTitleType++; } - if (gMain.newAndRepeatedKeys & L_BUTTON) + if (JOY_REPT(L_BUTTON)) { if (sPicTest_MuseumArtTitleType >= 11) sPicTest_MuseumArtTitleType -= 10; else sPicTest_MuseumArtTitleType = 0; // Causes underflow when pressing left on the dpad shortly thereafter. } - if (gMain.newAndRepeatedKeys & R_BUTTON) + if (JOY_REPT(R_BUTTON)) { if (sPicTest_MuseumArtTitleType <= 5) sPicTest_MuseumArtTitleType += 10; @@ -4119,24 +4119,24 @@ static void MuseumArtPicTest_SelectTitleType(void) static void PreviewPicTest_SelectType(void) { - if (gMain.newAndRepeatedKeys & DPAD_LEFT) + if (JOY_REPT(DPAD_LEFT)) { if (sPicTest_PreviewType != 1) sPicTest_PreviewType--; } - if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + if (JOY_REPT(DPAD_RIGHT)) { if (sPicTest_PreviewType != 15) sPicTest_PreviewType++; } - if (gMain.newAndRepeatedKeys & L_BUTTON) + if (JOY_REPT(L_BUTTON)) { if (sPicTest_PreviewType >= 11) sPicTest_PreviewType -= 10; else sPicTest_PreviewType = 0; // Causes underflow when pressing left on the dpad shortly thereafter. } - if (gMain.newAndRepeatedKeys & R_BUTTON) + if (JOY_REPT(R_BUTTON)) { if (sPicTest_PreviewType <= 5) sPicTest_PreviewType += 10; diff --git a/src/debug/watanabe_debug_menu.c b/src/debug/watanabe_debug_menu.c index aefd85bb2..df8b1eec0 100644 --- a/src/debug/watanabe_debug_menu.c +++ b/src/debug/watanabe_debug_menu.c @@ -809,23 +809,23 @@ NAKED void debug_80C3A50(u8 taskId) void debug_80C3D2C(u8 taskId) { - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); SetMainCallback2(debug_80C370C); gTasks[taskId].func = debug_80C373C; } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); gTasks[taskId].data[8] ^= 1; } - else if (gMain.newAndRepeatedKeys & DPAD_LEFT) + else if (JOY_REPT(DPAD_LEFT)) { if (gTasks[taskId].data[8]) { - if (gMain.heldKeys & R_BUTTON) + if (JOY_HELD(R_BUTTON)) gTasks[taskId].data[6] += 16; else gTasks[taskId].data[6] += 1; @@ -834,7 +834,7 @@ void debug_80C3D2C(u8 taskId) } else { - if (gMain.heldKeys & R_BUTTON) + if (JOY_HELD(R_BUTTON)) gTasks[taskId].data[7] += 16; else gTasks[taskId].data[7] += 1; @@ -842,11 +842,11 @@ void debug_80C3D2C(u8 taskId) gTasks[taskId].data[7] = 0x8000; } } - else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + else if (JOY_REPT(DPAD_RIGHT)) { if (gTasks[taskId].data[8]) { - if (gMain.heldKeys & R_BUTTON) + if (JOY_HELD(R_BUTTON)) gTasks[taskId].data[6] -= 16; else gTasks[taskId].data[6] -= 1; @@ -855,7 +855,7 @@ void debug_80C3D2C(u8 taskId) } else { - if (gMain.heldKeys & R_BUTTON) + if (JOY_HELD(R_BUTTON)) gTasks[taskId].data[7] -= 16; else gTasks[taskId].data[7] -= 1; @@ -863,7 +863,7 @@ void debug_80C3D2C(u8 taskId) gTasks[taskId].data[7] = 0x100; } } - else if (gMain.newAndRepeatedKeys & DPAD_UP) + else if (JOY_REPT(DPAD_UP)) { if (gTasks[taskId].data[8]) { @@ -874,7 +874,7 @@ void debug_80C3D2C(u8 taskId) gTasks[taskId].data[5]--; } } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { if (gTasks[taskId].data[8]) { @@ -885,7 +885,7 @@ void debug_80C3D2C(u8 taskId) gTasks[taskId].data[5]++; } } - else if (gMain.newAndRepeatedKeys & START_BUTTON) + else if (JOY_REPT(START_BUTTON)) { if (gTasks[taskId].data[0] < 0x182) gTasks[taskId].data[0]++; @@ -895,7 +895,7 @@ void debug_80C3D2C(u8 taskId) DestroySprite(gSprites + gTasks[taskId].data[3]); gTasks[taskId].func = debug_80C3A50; } - else if (gMain.newAndRepeatedKeys & SELECT_BUTTON) + else if (JOY_REPT(SELECT_BUTTON)) { if (gTasks[taskId].data[0] > 1) gTasks[taskId].data[0]--; @@ -1133,17 +1133,17 @@ void debug_80C4348(u8 taskId) void debug_80C43A8(u8 taskId) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); debug_sub_80A433C(gPlayerParty + gUnknown_Debug_2038A0C[1], debug_80C41D4); DestroyTask(taskId); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { gTasks[taskId].func = debug_80C4F48; } - else if (gMain.newKeys & START_BUTTON) + else if (JOY_NEW(START_BUTTON)) { if (debug_80C4774()) { @@ -1153,17 +1153,17 @@ void debug_80C43A8(u8 taskId) gTasks[taskId].func = debug_80C4D14; } } - else if (gMain.newKeys & (R_BUTTON | DPAD_RIGHT)) + else if (JOY_NEW(R_BUTTON | DPAD_RIGHT)) { debug_80C38E4(0, 1, 1, 14, 0); gTasks[taskId].func = debug_80C44EC; } - else if (gMain.newAndRepeatedKeys & DPAD_UP && gUnknown_Debug_2038A0C[1] != 0) + else if (JOY_REPT(DPAD_UP) && gUnknown_Debug_2038A0C[1] != 0) { gUnknown_Debug_2038A0C[1]--; gTasks[taskId].func = debug_80C4348; } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN && gUnknown_Debug_2038A0C[1] < 5 && GetMonData(gPlayerParty + gUnknown_Debug_2038A0C[1], MON_DATA_SPECIES) != SPECIES_NONE) + else if (JOY_REPT(DPAD_DOWN) && gUnknown_Debug_2038A0C[1] < 5 && GetMonData(gPlayerParty + gUnknown_Debug_2038A0C[1], MON_DATA_SPECIES) != SPECIES_NONE) { gUnknown_Debug_2038A0C[1]++; gTasks[taskId].func = debug_80C4348; @@ -1180,17 +1180,17 @@ void debug_80C44EC(u8 taskId) void debug_80C4550(u8 taskId) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); debug_sub_80A433C(gEnemyParty + gUnknown_Debug_2038A0C[2], debug_80C41F4); DestroyTask(taskId); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { gTasks[taskId].func = debug_80C4F48; } - else if (gMain.newKeys & START_BUTTON) + else if (JOY_NEW(START_BUTTON)) { if (debug_80C4774()) { @@ -1200,17 +1200,17 @@ void debug_80C4550(u8 taskId) gTasks[taskId].func = debug_80C4D14; } } - else if (gMain.newKeys & (L_BUTTON | DPAD_LEFT)) + else if (JOY_NEW(L_BUTTON | DPAD_LEFT)) { debug_80C38E4(0, 16, 1, 14, 0); gTasks[taskId].func = debug_80C4348; } - else if (gMain.newAndRepeatedKeys & DPAD_UP && gUnknown_Debug_2038A0C[2] != 0) + else if (JOY_REPT(DPAD_UP) && gUnknown_Debug_2038A0C[2] != 0) { gUnknown_Debug_2038A0C[2]--; gTasks[taskId].func = debug_80C44EC; } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN && gUnknown_Debug_2038A0C[2] < 5 && GetMonData(gEnemyParty + gUnknown_Debug_2038A0C[2], MON_DATA_SPECIES) != SPECIES_NONE) + else if (JOY_REPT(DPAD_DOWN) && gUnknown_Debug_2038A0C[2] < 5 && GetMonData(gEnemyParty + gUnknown_Debug_2038A0C[2], MON_DATA_SPECIES) != SPECIES_NONE) { gUnknown_Debug_2038A0C[2]++; gTasks[taskId].func = debug_80C44EC; @@ -1291,7 +1291,7 @@ void debug_80C48A0(u8 taskId) void debug_80C4900(u8 taskId) { - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); @@ -1302,7 +1302,7 @@ void debug_80C4900(u8 taskId) gUnknown_02023A14_50 = 0; gTasks[taskId].func = debug_80C373C; } - else if (gMain.newKeys & START_BUTTON || gMain.newKeys & A_BUTTON) + else if (JOY_NEW(START_BUTTON) || JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); gBattleTypeFlags = gUnknown_Debug_083F8068[gUnknown_Debug_2038A0C[3]].data.type1[0]; @@ -1318,12 +1318,12 @@ void debug_80C4900(u8 taskId) gTasks[taskId].func = debug_80C4F48; } } - else if (gMain.newAndRepeatedKeys & DPAD_UP && gUnknown_Debug_2038A0C[3] > 0) + else if (JOY_REPT(DPAD_UP) && gUnknown_Debug_2038A0C[3] > 0) { gUnknown_Debug_2038A0C[3]--; gTasks[taskId].func = debug_80C48A0; } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN && gUnknown_Debug_2038A0C[3] < 2) + else if (JOY_REPT(DPAD_DOWN) && gUnknown_Debug_2038A0C[3] < 2) { gUnknown_Debug_2038A0C[3]++; gTasks[taskId].func = debug_80C48A0; @@ -1342,7 +1342,7 @@ void debug_80C4AC4(u8 taskId) { u8 r1 = gUnknown_Debug_2038A0C[4] + gUnknown_Debug_2038A0C[5]; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { u32 mask = gUnknown_Debug_083F80D8[r1].data.type2; if (byte_3005E30 & mask) @@ -1352,12 +1352,12 @@ void debug_80C4AC4(u8 taskId) debug_80C4C44(gUnknown_Debug_2038A0C[4]); gTasks[taskId].func = debug_80C4A60; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { debug_80C38E4(0, 16, 1, 14, 0); gTasks[taskId].func = debug_80C48A0; } - else if (gMain.newKeys & START_BUTTON) + else if (JOY_NEW(START_BUTTON)) { PlaySE(SE_SELECT); gTrainerBattleOpponent = SECRET_BASE_OPPONENT; @@ -1370,7 +1370,7 @@ void debug_80C4AC4(u8 taskId) eWatanabe17000.contestant = 0; gTasks[taskId].func = debug_80C4F48; } - else if (gMain.newAndRepeatedKeys & DPAD_UP) + else if (JOY_REPT(DPAD_UP)) { if (gUnknown_Debug_2038A0C[5] > 0) gUnknown_Debug_2038A0C[5]--; @@ -1381,7 +1381,7 @@ void debug_80C4AC4(u8 taskId) } gTasks[taskId].func = debug_80C4A60; } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN && gUnknown_Debug_2038A0C[5] < 9) + else if (JOY_REPT(DPAD_DOWN) && gUnknown_Debug_2038A0C[5] < 9) { if (gUnknown_Debug_2038A0C[5] < 5) gUnknown_Debug_2038A0C[5]++; @@ -1453,17 +1453,17 @@ void debug_80C4DB8(u8 taskId) void debug_80C4E18(u8 taskId) { u8 r6 = gUnknown_Debug_2038A0C[6] + gUnknown_Debug_2038A0C[7]; - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { gTasks[taskId].func = debug_80C42B8; } - else if (gMain.newKeys & START_BUTTON || gMain.newKeys & A_BUTTON) + else if (JOY_NEW(START_BUTTON) || JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); gBattleTerrain = gUnknown_Debug_083F814C[r6].data.type3; gTasks[taskId].func = debug_80C5158; } - else if (gMain.newAndRepeatedKeys & DPAD_UP) + else if (JOY_REPT(DPAD_UP)) { if (gUnknown_Debug_2038A0C[7] > 0) gUnknown_Debug_2038A0C[7]--; @@ -1474,7 +1474,7 @@ void debug_80C4E18(u8 taskId) } gTasks[taskId].func = debug_80C4DB8; } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN && gUnknown_Debug_2038A0C[7] < 8) + else if (JOY_REPT(DPAD_DOWN) && gUnknown_Debug_2038A0C[7] < 8) { if (gUnknown_Debug_2038A0C[7] < 5) gUnknown_Debug_2038A0C[7]++; @@ -1533,22 +1533,22 @@ void debug_80C5038(u8 taskId) void debug_80C5098(u8 taskId) { - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { gTasks[taskId].func = debug_80C47BC; } - else if (gMain.newKeys & START_BUTTON || gMain.newKeys & A_BUTTON) + else if (JOY_NEW(START_BUTTON) || JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); gSaveBlock2.playerGender = gUnknown_Debug_2038A0C[8]; gTasks[taskId].func = debug_80C42B8; } - else if (gMain.newAndRepeatedKeys & DPAD_UP && gUnknown_Debug_2038A0C[8] > 0) + else if (JOY_REPT(DPAD_UP) && gUnknown_Debug_2038A0C[8] > 0) { gUnknown_Debug_2038A0C[8]--; gTasks[taskId].func = debug_80C5038; } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN && gUnknown_Debug_2038A0C[8] < 1) + else if (JOY_REPT(DPAD_DOWN) && gUnknown_Debug_2038A0C[8] < 1) { gUnknown_Debug_2038A0C[8]++; gTasks[taskId].func = debug_80C5038; @@ -1892,20 +1892,20 @@ void debug_80C53C0(u8 taskId) void debug_80C53F0(u8 taskId) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { gUnknown_Debug_2038A1C->unk164 = gUnknown_Debug_2038A1C->unk64[gUnknown_Debug_083F8698[gUnknown_Debug_2038A1C->unk168].text[gUnknown_Debug_2038A1C->unk169]]; gUnknown_Debug_2038A1C->unk16a = 0; debug_80C643C(); gTasks[taskId].func = debug_80C55E4; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); SetMainCallback2(debug_80C370C); gTasks[taskId].func = debug_80C373C; } - else if (gMain.newKeys & START_BUTTON) + else if (JOY_NEW(START_BUTTON)) { bool8 r4; PlaySE(SE_SELECT); @@ -1918,28 +1918,28 @@ void debug_80C53F0(u8 taskId) Menu_PrintText(gUnknown_Debug_083F8720, 4, 9); gTasks[taskId].func = debug_80C5708; } - else if (gMain.newKeys & SELECT_BUTTON) + else if (JOY_NEW(SELECT_BUTTON)) { u32 r4 = gUnknown_Debug_2038A1C->unk64[0]; GetSetPokedexFlag(r4, 2); GetSetPokedexFlag(r4, 3); PlaySE(SE_SELECT); } - else if (gMain.newKeys & DPAD_UP) + else if (JOY_NEW(DPAD_UP)) { debug_80C627C(2); } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { debug_80C627C(1); } - else if (gMain.newKeys & L_BUTTON && gUnknown_Debug_2038A1C->unk168 > 0) + else if (JOY_NEW(L_BUTTON) && gUnknown_Debug_2038A1C->unk168 > 0) { gUnknown_Debug_2038A1C->unk168--; gUnknown_Debug_2038A1C->unk169 = 0; gTasks[taskId].func = debug_80C53C0; } - else if (gMain.newKeys & R_BUTTON && gUnknown_Debug_2038A1C->unk168 < 5) + else if (JOY_NEW(R_BUTTON) && gUnknown_Debug_2038A1C->unk168 < 5) { gUnknown_Debug_2038A1C->unk168++; gUnknown_Debug_2038A1C->unk169 = 0; @@ -1950,33 +1950,33 @@ void debug_80C53F0(u8 taskId) void debug_80C55E4(u8 taskId) { u8 r7 = gUnknown_Debug_083F8698[gUnknown_Debug_2038A1C->unk168].text[gUnknown_Debug_2038A1C->unk169]; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { gTasks[taskId].func = debug_80C53C0; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { gUnknown_Debug_2038A1C->unk64[r7] = gUnknown_Debug_2038A1C->unk164; gTasks[taskId].func = debug_80C53C0; } - else if (gMain.newAndRepeatedKeys & DPAD_UP) + else if (JOY_REPT(DPAD_UP)) { debug_80C6544(1); debug_80C643C(); } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { debug_80C6544(2); debug_80C643C(); } else if (gUnknown_Debug_083F8554[r7].data.type4->unk9 != 0xFF) { - if (gMain.newKeys & DPAD_LEFT && gUnknown_Debug_2038A1C->unk16a < gUnknown_Debug_083F8554[r7].data.type4->unk9 - 1) + if (JOY_NEW(DPAD_LEFT) && gUnknown_Debug_2038A1C->unk16a < gUnknown_Debug_083F8554[r7].data.type4->unk9 - 1) { gUnknown_Debug_2038A1C->unk16a++; debug_80C643C(); } - else if (gMain.newKeys & DPAD_RIGHT && gUnknown_Debug_2038A1C->unk16a > 0) + else if (JOY_NEW(DPAD_RIGHT) && gUnknown_Debug_2038A1C->unk16a > 0) { gUnknown_Debug_2038A1C->unk16a--; debug_80C643C(); @@ -1986,7 +1986,7 @@ void debug_80C55E4(u8 taskId) void debug_80C5708(u8 taskId) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { gTasks[taskId].func = debug_80C53C0; } @@ -2725,45 +2725,45 @@ void debug_80C6EE8(u8 taskId) #ifdef NONMATCHING void debug_80C6FA8(u8 taskId) { - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); SetMainCallback2(debug_80C370C); gTasks[taskId].func = debug_80C373C; } - else if (gMain.newAndRepeatedKeys & R_BUTTON) + else if (JOY_REPT(R_BUTTON)) { gUnknown_Debug_2038A20->totalPoints = debug_80C3878(0, gUnknown_Debug_2038A20->totalPoints); gTasks[taskId].func = debug_80C71FC; } - else if (gMain.newAndRepeatedKeys & L_BUTTON) + else if (JOY_REPT(L_BUTTON)) { gUnknown_Debug_2038A20->totalPoints = debug_80C3878(1, gUnknown_Debug_2038A20->totalPoints); gTasks[taskId].func = debug_80C71FC; } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { gUnknown_Debug_2038A20->contestant = 1; REG_WIN0H = 0x51EF; REG_WIN0V = 0x4167; gTasks[taskId].func = debug_80C7294; } - else if (gMain.newAndRepeatedKeys & DPAD_RIGHT && gUnknown_Debug_2038A20->unk7 < 14) + else if (JOY_REPT(DPAD_RIGHT) && gUnknown_Debug_2038A20->unk7 < 14) { ((u16 *)PLTT)[0x81 + gUnknown_Debug_2038A20->unk7] = 0; do; while(0); gUnknown_Debug_2038A20->unk7++; gTasks[taskId].func = debug_80C6EE8; } - else if (gMain.newAndRepeatedKeys & DPAD_LEFT && gUnknown_Debug_2038A20->unk7 > 0) + else if (JOY_REPT(DPAD_LEFT) && gUnknown_Debug_2038A20->unk7 > 0) { ((u16 *)PLTT)[0x81 + gUnknown_Debug_2038A20->unk7] = 0; do; while(0); gUnknown_Debug_2038A20->unk7--; gTasks[taskId].func = debug_80C6EE8; } - else if (gMain.newKeys & START_BUTTON) + else if (JOY_NEW(START_BUTTON)) { gUnknown_Debug_2038A20->unk9 ^= 1; if (gUnknown_Debug_2038A20->unk9) @@ -2776,7 +2776,7 @@ void debug_80C6FA8(u8 taskId) } else { - if (gMain.newKeys & SELECT_BUTTON) + if (JOY_NEW(SELECT_BUTTON)) { StopCryAndClearCrySongs(); PlayCry1(gUnknown_Debug_2038A20->totalPoints, 0); @@ -3098,14 +3098,14 @@ void debug_80C71FC(u8 taskId) void debug_80C7294(u8 taskId) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { gUnknown_Debug_2038A20->contestant = 0; REG_WIN0H = 0x51EF; REG_WIN0V = 0x699F; gTasks[taskId].func = debug_80C6EE8; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { gUnknown_Debug_2038A20->contestant = 0; REG_WIN0H = 0x51EF; @@ -3116,15 +3116,15 @@ void debug_80C7294(u8 taskId) CpuCopy16(gUnknown_Debug_2038A20->personality2, gPlttBufferFaded + 0x100 + gUnknown_Debug_2038A20->unk6 * 16, 32); gTasks[taskId].func = debug_80C6EE8; } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN && gUnknown_Debug_2038A20->unkA < 2) + else if (JOY_REPT(DPAD_DOWN) && gUnknown_Debug_2038A20->unkA < 2) { gUnknown_Debug_2038A20->unkA++; } - else if (gMain.newAndRepeatedKeys & DPAD_UP && gUnknown_Debug_2038A20->unkA > 0) + else if (JOY_REPT(DPAD_UP) && gUnknown_Debug_2038A20->unkA > 0) { gUnknown_Debug_2038A20->unkA--; } - else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + else if (JOY_REPT(DPAD_RIGHT)) { switch (gUnknown_Debug_2038A20->unkA) { @@ -3145,7 +3145,7 @@ void debug_80C7294(u8 taskId) break; } } - else if (gMain.newAndRepeatedKeys & DPAD_LEFT) + else if (JOY_REPT(DPAD_LEFT)) { switch (gUnknown_Debug_2038A20->unkA) { @@ -3333,45 +3333,45 @@ void debug_80C7A54(u8 taskId) #ifdef NONMATCHING void debug_80C7B14(u8 taskId) { - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); SetMainCallback2(debug_80C370C); gTasks[taskId].func = debug_80C373C; } - else if (gMain.newAndRepeatedKeys & R_BUTTON) + else if (JOY_REPT(R_BUTTON)) { gUnknown_Debug_2038A20->totalPoints = debug_80C38B4(0, gUnknown_Debug_2038A20->totalPoints); gTasks[taskId].func = debug_80C7D44; } - else if (gMain.newAndRepeatedKeys & L_BUTTON) + else if (JOY_REPT(L_BUTTON)) { gUnknown_Debug_2038A20->totalPoints = debug_80C38B4(1, gUnknown_Debug_2038A20->totalPoints); gTasks[taskId].func = debug_80C7D44; } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { gUnknown_Debug_2038A20->contestant = 1; REG_WIN0H = 0x51EF; REG_WIN0V = 0x4167; gTasks[taskId].func = debug_80C7DDC; } - else if (gMain.newAndRepeatedKeys & DPAD_RIGHT && gUnknown_Debug_2038A20->unk7 < 14) + else if (JOY_REPT(DPAD_RIGHT) && gUnknown_Debug_2038A20->unk7 < 14) { ((u16 *)PLTT)[0x81 + gUnknown_Debug_2038A20->unk7] = 0; do; while (0); // this matches the asm here... gUnknown_Debug_2038A20->unk7++; gTasks[taskId].func = debug_80C7A54; } - else if (gMain.newAndRepeatedKeys & DPAD_LEFT && gUnknown_Debug_2038A20->unk7 > 0) + else if (JOY_REPT(DPAD_LEFT) && gUnknown_Debug_2038A20->unk7 > 0) { ((u16 *)PLTT)[0x81 + gUnknown_Debug_2038A20->unk7] = 0; do; while (0); // ... but not here gUnknown_Debug_2038A20->unk7--; gTasks[taskId].func = debug_80C7A54; } - else if (gMain.newKeys & START_BUTTON) + else if (JOY_NEW(START_BUTTON)) { gUnknown_Debug_2038A20->unk9 ^= 1; if (gUnknown_Debug_2038A20->unk9) @@ -3689,14 +3689,14 @@ void debug_80C7D44(u8 taskId) void debug_80C7DDC(u8 taskId) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { gUnknown_Debug_2038A20->contestant = 0; REG_WIN0H = 0x51EF; REG_WIN0V = 0x699F; gTasks[taskId].func = debug_80C7A54; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { gUnknown_Debug_2038A20->contestant = 0; REG_WIN0H = 0x51EF; @@ -3707,15 +3707,15 @@ void debug_80C7DDC(u8 taskId) CpuCopy16(gUnknown_Debug_2038A20->personality2, gPlttBufferFaded + 0x100 + gUnknown_Debug_2038A20->unk6 * 16, 32); gTasks[taskId].func = debug_80C7A54; } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN && gUnknown_Debug_2038A20->unkA < 2) + else if (JOY_REPT(DPAD_DOWN) && gUnknown_Debug_2038A20->unkA < 2) { gUnknown_Debug_2038A20->unkA++; } - else if (gMain.newAndRepeatedKeys & DPAD_UP && gUnknown_Debug_2038A20->unkA > 0) + else if (JOY_REPT(DPAD_UP) && gUnknown_Debug_2038A20->unkA > 0) { gUnknown_Debug_2038A20->unkA--; } - else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + else if (JOY_REPT(DPAD_RIGHT)) { switch (gUnknown_Debug_2038A20->unkA) { @@ -3736,7 +3736,7 @@ void debug_80C7DDC(u8 taskId) break; } } - else if (gMain.newAndRepeatedKeys & DPAD_LEFT) + else if (JOY_REPT(DPAD_LEFT)) { switch (gUnknown_Debug_2038A20->unkA) { diff --git a/src/decoration.c b/src/decoration.c index a957abf39..81d6b13dc 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -1486,23 +1486,23 @@ void Task_DecorationPCProcessMenuInput(u8 taskId) { if (!gPaletteFade.active) { - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { PlaySE(SE_SELECT); gUnknown_020388D4 = Menu_MoveCursor(-1); sub_80FE394(); } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { PlaySE(SE_SELECT); gUnknown_020388D4 = Menu_MoveCursor(1); sub_80FE394(); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); gUnknown_083EC604[gUnknown_020388D4].func(taskId); - } else if (gMain.newKeys & B_BUTTON) + } else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); gpu_pal_decompress_alloc_tag_and_upload(taskId); @@ -1596,15 +1596,15 @@ void sub_80FE604(u8 taskId) { if (!gPaletteFade.active) { - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { PlaySE(SE_SELECT); Menu_MoveCursor(-1); - } else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + } else if (JOY_REPT(DPAD_DOWN)) { PlaySE(SE_SELECT); Menu_MoveCursor(1); - } else if (gMain.newKeys & A_BUTTON) + } else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); gUnknown_020388F6 = Menu_GetCursorPos(); @@ -1630,7 +1630,7 @@ void sub_80FE604(u8 taskId) { sub_80FE728(taskId); } - } else if (gMain.newKeys & B_BUTTON) + } else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sub_80FE728(taskId); @@ -1737,7 +1737,7 @@ void sub_80FE948(u8 taskId) { if (!gPaletteFade.active) { - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) + if (JOY_REPT(DPAD_ANY) == DPAD_UP) { if (gUnknown_020388F2 != 0) { @@ -1747,7 +1747,7 @@ void sub_80FE948(u8 taskId) sub_80FE894(taskId, 0, -1); } } - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) + if (JOY_REPT(DPAD_ANY) == DPAD_DOWN) { if (gUnknown_020388F2 != gUnknown_020388F3) { @@ -1757,7 +1757,7 @@ void sub_80FE948(u8 taskId) sub_80FE894(taskId, 0, 1); } } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { Menu_DestroyCursor(); PlaySE(SE_SELECT); @@ -1769,7 +1769,7 @@ void sub_80FE948(u8 taskId) { gUnknown_083EC634[gTasks[taskId].data[11]].yesFunc(taskId); } - } else if (gMain.newKeys & B_BUTTON) + } else if (JOY_NEW(B_BUTTON)) { Menu_DestroyCursor(); PlaySE(SE_SELECT); @@ -1993,7 +1993,7 @@ bool8 sub_80FEFA4(void) void sub_80FEFF4(u8 taskId) { - if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { LoadScrollIndicatorPalette(); gTasks[taskId].func = sub_80FE868; @@ -2688,7 +2688,7 @@ bool8 sub_810038C(u8 taskId) bool8 sub_8100430(void) { - if ((gMain.heldKeys & DPAD_ANY) != DPAD_UP && (gMain.heldKeys & DPAD_ANY) != DPAD_DOWN && (gMain.heldKeys & DPAD_ANY) != DPAD_LEFT && (gMain.heldKeys & DPAD_ANY) != DPAD_RIGHT) + if (JOY_HELD(DPAD_ANY) != DPAD_UP && JOY_HELD(DPAD_ANY) != DPAD_DOWN && JOY_HELD(DPAD_ANY) != DPAD_LEFT && JOY_HELD(DPAD_ANY) != DPAD_RIGHT) { return FALSE; } @@ -2715,28 +2715,28 @@ void sub_8100494(u8 taskId) gUnknown_083EC96C[gTasks[taskId].data[12]].noFunc(taskId); return; } - if ((gMain.heldKeys & DPAD_ANY) == DPAD_UP) + if (JOY_HELD(DPAD_ANY) == DPAD_UP) { gUnknown_020391AA = DIR_SOUTH; gSprites[gUnknown_020391A8].data[2] = 0; gSprites[gUnknown_020391A8].data[3] = -2; gTasks[taskId].data[1]--; } - if ((gMain.heldKeys & DPAD_ANY) == DPAD_DOWN) + if (JOY_HELD(DPAD_ANY) == DPAD_DOWN) { gUnknown_020391AA = DIR_NORTH; gSprites[gUnknown_020391A8].data[2] = 0; gSprites[gUnknown_020391A8].data[3] = 2; gTasks[taskId].data[1]++; } - if ((gMain.heldKeys & DPAD_ANY) == DPAD_LEFT) + if (JOY_HELD(DPAD_ANY) == DPAD_LEFT) { gUnknown_020391AA = DIR_WEST; gSprites[gUnknown_020391A8].data[2] = -2; gSprites[gUnknown_020391A8].data[3] = 0; gTasks[taskId].data[0]--; } - if ((gMain.heldKeys & DPAD_ANY) == DPAD_RIGHT) + if (JOY_HELD(DPAD_ANY) == DPAD_RIGHT) { gUnknown_020391AA = DIR_EAST; gSprites[gUnknown_020391A8].data[2] = 2; @@ -2755,11 +2755,11 @@ void sub_8100494(u8 taskId) } if (!gTasks[taskId].data[10]) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { gTasks[taskId].data[10] = A_BUTTON; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { gTasks[taskId].data[10] = B_BUTTON; } @@ -2776,7 +2776,7 @@ void sub_810065C(u8 taskId) void sub_81006A8(u8 taskId) { - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { sub_810065C(taskId); } @@ -3288,7 +3288,7 @@ void sub_8101024(u8 taskId) void sub_81010F0(u8 taskId) { - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { sub_8100EEC(taskId); } diff --git a/src/diploma.c b/src/diploma.c index c92491cc6..cd5503f4f 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(0, 0, 0)); gTasks[taskId].func = Task_DiplomaFadeOut; diff --git a/src/easy_chat_1.c b/src/easy_chat_1.c index ba2fded16..b86a8417b 100644 --- a/src/easy_chat_1.c +++ b/src/easy_chat_1.c @@ -685,7 +685,7 @@ void sub_80E6AE4(void) gEasyChatStruct->unk87 = sub_80E75D8(); if (gEasyChatStruct->unk87) PlaySE(SE_SELECT); - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (gEasyChatStruct->unk86 == gEasyChatStruct->unk84) @@ -711,7 +711,7 @@ void sub_80E6AE4(void) return; } } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { sub_80E682C(sub_80E6C84); } @@ -756,7 +756,7 @@ void sub_80E6BC0(void) sub_80E682C(sub_80E6AC4); break; case 100: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) sub_80E682C(sub_80E6AC4); break; } @@ -898,7 +898,7 @@ void sub_80E6D7C(void) } break; case 10: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) sub_80E682C(sub_80E6AC4); break; case 100: @@ -906,7 +906,7 @@ void sub_80E6D7C(void) gEasyChatStruct->unk24++; // fall through case 101: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) gEasyChatStruct->unk24++; break; case 102: @@ -954,7 +954,7 @@ void sub_80E6FC8(void) { if (gEasyChatStruct->unk96) PlaySE(SE_SELECT); - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (gEasyChatStruct->unk1B7 != 0) { @@ -988,11 +988,11 @@ void sub_80E6FC8(void) } } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { sub_80E682C(sub_80E7114); } - else if (gMain.newKeys & SELECT_BUTTON) + else if (JOY_NEW(SELECT_BUTTON)) { sub_80E682C(sub_80E718C); } @@ -1105,12 +1105,12 @@ void sub_80E7294(void) { if (gEasyChatStruct->unk1B9) PlaySE(SE_SELECT); - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); sub_80E682C(sub_80E7324); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { sub_80E682C(sub_80E73D0); } @@ -1253,21 +1253,21 @@ bool8 sub_80E75D8(void) bool8 pressedUpDown = FALSE; u8 r0; - if (gMain.newKeys & START_BUTTON) + if (JOY_NEW(START_BUTTON)) { gEasyChatStruct->unk86 = gEasyChatStruct->unk84; gEasyChatStruct->unk85 = 2; return TRUE; } - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { gEasyChatStruct->unk86--; if (gEasyChatStruct->unk86 < 0) gEasyChatStruct->unk86 = gEasyChatStruct->unk84; pressedUpDown = TRUE; } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { gEasyChatStruct->unk86++; if (gEasyChatStruct->unk86 > gEasyChatStruct->unk84) @@ -1300,7 +1300,7 @@ bool8 sub_80E75D8(void) } else { - if (gMain.newAndRepeatedKeys & DPAD_LEFT) + if (JOY_REPT(DPAD_LEFT)) { if (--gEasyChatStruct->unk85 < 0) { @@ -1318,7 +1318,7 @@ bool8 sub_80E75D8(void) } return TRUE; } - if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + if (JOY_REPT(DPAD_RIGHT)) { if (gEasyChatStruct->unk86 == gEasyChatStruct->unk84) { @@ -1346,14 +1346,14 @@ bool8 sub_80E77C8(void) if (gEasyChatStruct->unk1B7 != 0) { - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { gEasyChatStruct->unk1A8--; if (gEasyChatStruct->unk1A8 < 1) gEasyChatStruct->unk1A8 = 3; return TRUE; } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { gEasyChatStruct->unk1A8++; if (gEasyChatStruct->unk1A8 > 3) @@ -1367,14 +1367,14 @@ bool8 sub_80E77C8(void) { pressedUpDown = FALSE; - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { gEasyChatStruct->unk1A8--; if (gEasyChatStruct->unk1A8 < 0) gEasyChatStruct->unk1A8 = 3; pressedUpDown = TRUE; } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { gEasyChatStruct->unk1A8++; if (gEasyChatStruct->unk1A8 > 3) @@ -1393,7 +1393,7 @@ bool8 sub_80E77C8(void) pressedUpDown = FALSE; gEasyChatStruct->unk1C0 = 0; - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { if (gEasyChatStruct->unk1A8 == 0) return FALSE; @@ -1402,7 +1402,7 @@ bool8 sub_80E77C8(void) gEasyChatStruct->unk1C0 = -1; pressedUpDown = TRUE; } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { if (gEasyChatStruct->unk1A8 >= gEasyChatStruct->unk1B6 - 1) return FALSE; @@ -1424,7 +1424,7 @@ bool8 sub_80E77C8(void) } } - if (gMain.newAndRepeatedKeys & DPAD_LEFT) + if (JOY_REPT(DPAD_LEFT)) { if (gEasyChatStruct->unk1A9 != 0) gEasyChatStruct->unk1A9--; @@ -1432,7 +1432,7 @@ bool8 sub_80E77C8(void) gEasyChatStruct->unk1A9 = gEasyChatStruct->unk1AA[gEasyChatStruct->unk1A8]; pressedLeftRight = TRUE; } - else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + else if (JOY_REPT(DPAD_RIGHT)) { if (gEasyChatStruct->unk1B7 != 0 || gEasyChatStruct->unk1A9 == gEasyChatStruct->unk1AA[gEasyChatStruct->unk1A8]) @@ -1487,7 +1487,7 @@ bool8 sub_80E7B40(void) bool8 pressedUpDown = FALSE; gEasyChatStruct->unk1C0 = 0; - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { if (gEasyChatStruct->unk99A4 == 0) return FALSE; @@ -1499,7 +1499,7 @@ bool8 sub_80E7B40(void) } pressedUpDown = TRUE; } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { if (gEasyChatStruct->unk99A4 >= gEasyChatStruct->unk9A28 - 1) return FALSE; @@ -1518,14 +1518,14 @@ bool8 sub_80E7B40(void) return TRUE; } - if (gMain.newAndRepeatedKeys & DPAD_LEFT) + if (JOY_REPT(DPAD_LEFT)) { gEasyChatStruct->unk99A5--; if (gEasyChatStruct->unk99A5 < 0) gEasyChatStruct->unk99A5 = gEasyChatStruct->unk99A6[gEasyChatStruct->unk99A4] - 1; return TRUE; } - else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + else if (JOY_REPT(DPAD_RIGHT)) { gEasyChatStruct->unk99A5++; if (gEasyChatStruct->unk99A5 >= gEasyChatStruct->unk99A6[gEasyChatStruct->unk99A4]) @@ -1533,7 +1533,7 @@ bool8 sub_80E7B40(void) return TRUE; } - if (gMain.newKeys & START_BUTTON) + if (JOY_NEW(START_BUTTON)) { if (gEasyChatStruct->unk9A29 != 0) { @@ -1544,7 +1544,7 @@ bool8 sub_80E7B40(void) gEasyChatStruct->unk99A4 += gEasyChatStruct->unk1C0; gEasyChatStruct->unk1BE = 4; } - else if (gMain.newKeys & SELECT_BUTTON) + else if (JOY_NEW(SELECT_BUTTON)) { if (gEasyChatStruct->unk9A29 < gEasyChatStruct->unk9A28 - 4) { diff --git a/src/evolution_scene.c b/src/evolution_scene.c index ac30d2c3f..405ab9fe4 100644 --- a/src/evolution_scene.c +++ b/src/evolution_scene.c @@ -767,21 +767,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); nullsub_6(); sEvoCursorPos = 0; sub_802BC6C(); } - if (gMain.newKeys & DPAD_DOWN && sEvoCursorPos == 0) + if (JOY_NEW(DPAD_DOWN) && sEvoCursorPos == 0) { PlaySE(SE_SELECT); nullsub_6(); sEvoCursorPos = 1; sub_802BC6C(); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { sub_8023AD8(); BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[292]); @@ -796,7 +796,7 @@ static void Task_EvolutionScene(u8 taskID) BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); } } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { sub_8023AD8(); BattleStringExpandPlaceholdersToDisplayedString(gBattleStringsTable[292]); @@ -1121,21 +1121,21 @@ static void Task_TradeEvolutionScene(u8 taskID) } break; case 4: - if (gMain.newKeys & DPAD_UP && sEvoCursorPos != 0) + if (JOY_NEW(DPAD_UP) && sEvoCursorPos != 0) { PlaySE(SE_SELECT); EvoDummyFunc2(); sEvoCursorPos = 0; sub_81150D8(); } - if (gMain.newKeys & DPAD_DOWN && sEvoCursorPos == 0) + if (JOY_NEW(DPAD_DOWN) && sEvoCursorPos == 0) { PlaySE(SE_SELECT); EvoDummyFunc2(); sEvoCursorPos = 1; sub_81150D8(); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { Text_EraseWindowRect(&gUnknown_03004828->window, 0x18, 8, 0x1D, 0xD); DestroyMenuCursor(); @@ -1155,7 +1155,7 @@ static void Task_TradeEvolutionScene(u8 taskID) BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); } } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { Text_EraseWindowRect(&gUnknown_03004828->window, 0x18, 8, 0x1D, 0xD); DestroyMenuCursor(); diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 33fd33196..bbb2ad563 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -330,7 +330,7 @@ static void PlayerAllowForcedMovementIfMovingSameDirection(void) static bool8 TryDoMetatileBehaviorForcedMovement(void) { #if DEBUG - if (gUnknown_020297ED != 0 && (gMain.heldKeys & R_BUTTON)) + if (gUnknown_020297ED != 0 && JOY_HELD(R_BUTTON)) return 0; #endif return sForcedMovementFuncs[GetForcedMovementByMetatileBehavior()](); @@ -1586,7 +1586,7 @@ static bool8 Fishing5(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) @@ -1646,7 +1646,7 @@ static bool8 Fishing8(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; } @@ -1826,7 +1826,7 @@ static void AlignFishingAnimationFrames(void) u8 debug_sub_805F2B0(u8 a) { - if (gMain.heldKeys & 0x100) + if (JOY_HELD(R_BUTTON)) return debug_sub_805F2DC(a); else return 0; diff --git a/src/field_special_scene.c b/src/field_special_scene.c index 4342d477e..9d9e9d6d8 100644 --- a/src/field_special_scene.c +++ b/src/field_special_scene.c @@ -306,7 +306,7 @@ void Task_HandlePorthole(u8 taskId) } break; case IDLE_CHECK: // idle and move. - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) data[1] = 1; if (!ScriptMovement_IsObjectMovementFinished(LOCALID_PLAYER, location->mapNum, location->mapGroup)) return; diff --git a/src/field_specials.c b/src/field_specials.c index defe435e8..c7e167c50 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -1120,7 +1120,7 @@ void sub_810E984(u8 taskId) Menu_MoveCursorNoWrap(+1); sub_810EAC8(curMenuPos, DPAD_DOWN); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { saved_warp2_set_2(0, gUnknown_03000760[gUnknown_0203925B].var1, gUnknown_03000760[gUnknown_0203925B].var2, -1, 2, 1); if (gSpecialVar_0x8005 == gUnknown_0203925B) @@ -1141,7 +1141,7 @@ void sub_810E984(u8 taskId) DestroyTask(taskId); } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { gSpecialVar_Result = 0; PlaySE(SE_SELECT); @@ -1489,7 +1489,7 @@ void sub_810F118(u8 taskId) Menu_MoveCursorNoWrap(1); sub_810F1F4(prevCursorPos, DPAD_DOWN); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { Menu_DestroyCursor(); gSpecialVar_Result = gUnknown_0203925B; @@ -1498,7 +1498,7 @@ void sub_810F118(u8 taskId) Menu_EraseWindowRect(0, 0, 29, 12); sub_810EC9C(taskId); } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { Menu_DestroyCursor(); gSpecialVar_Result = 0x7f; diff --git a/src/field_weather.c b/src/field_weather.c index c05fa3d3b..92cf4e550 100644 --- a/src/field_weather.c +++ b/src/field_weather.c @@ -1266,14 +1266,14 @@ bool8 debug_sub_8085564(void) { bool8 changed = FALSE; - if (gMain.newKeys & R_BUTTON) + if (JOY_NEW(R_BUTTON)) { sSelectedDebugWeather++; if (sSelectedDebugWeather == 15) sSelectedDebugWeather = 0; changed = TRUE; } - if (gMain.newKeys & L_BUTTON) + if (JOY_NEW(L_BUTTON)) { if (sSelectedDebugWeather != 0) sSelectedDebugWeather--; @@ -1288,7 +1288,7 @@ bool8 debug_sub_8085564(void) Menu_PrintText(sDebugText_Weather[sSelectedDebugWeather], 23, 1); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { ChangeWeather(sSelectedDebugWeather); CloseMenu(); diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 96012dc0e..50e969a04 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -737,7 +737,7 @@ static void sub_8142794(u8 taskID) static void sub_8142818(u8 taskID) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { FadeOutBGM(4); gTasks[taskID].func = sub_8142850; @@ -960,7 +960,7 @@ static void sub_8142CC8(u8 taskID) static void sub_8142DF4(u8 taskID) { u16 i; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (gTasks[taskID].tCurrTeamNo != 0) // prepare another team to view { @@ -988,7 +988,7 @@ static void sub_8142DF4(u8 taskID) gTasks[taskID].func = sub_8142F78; } } - 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()) { @@ -997,12 +997,12 @@ static void sub_8142DF4(u8 taskID) } gTasks[taskID].func = sub_8142F78; } - else if (gMain.newKeys & DPAD_UP && gTasks[taskID].tCurrPokeID != 0) // change poke -1 + else if (JOY_NEW(DPAD_UP) && gTasks[taskID].tCurrPokeID != 0) // change poke -1 { gTasks[taskID].tCurrPokeID--; gTasks[taskID].func = sub_8142CC8; } - else if (gMain.newKeys & DPAD_DOWN && gTasks[taskID].tCurrPokeID < gTasks[taskID].tPokesNo - 1) // change poke +1 + else if (JOY_NEW(DPAD_DOWN) && gTasks[taskID].tCurrPokeID < gTasks[taskID].tPokesNo - 1) // change poke +1 { gTasks[taskID].tCurrPokeID++; gTasks[taskID].func = sub_8142CC8; @@ -1035,7 +1035,7 @@ static void sub_8142FEC(u8 taskID) static void sub_814302C(u8 taskID) { - if (Menu_UpdateWindowText() && gMain.newKeys & A_BUTTON) + if (Menu_UpdateWindowText() && JOY_NEW(A_BUTTON)) gTasks[taskID].func = sub_8142F78; } diff --git a/src/item_menu.c b/src/item_menu.c index 33b4e1243..0852ce015 100644 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -1552,7 +1552,7 @@ static bool8 sub_80A4F74(u8 a) { bool8 retVal = FALSE; - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) + if (JOY_REPT(DPAD_ANY) == DPAD_UP) { if (gBagPocketScrollStates[sCurrentBagPocket].cursorPos != 0) sub_80A4B58(-1, a); @@ -1562,7 +1562,7 @@ static bool8 sub_80A4F74(u8 a) gMain.keyRepeatCounter = 11; retVal = TRUE; } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) + else if (JOY_REPT(DPAD_ANY) == DPAD_DOWN) { if (sReturnLocation != RETURN_TO_FIELD_5) { @@ -1618,7 +1618,7 @@ static void sub_80A50C8(u8 taskId) return; } - if ((gMain.newKeys & SELECT_BUTTON) + if (JOY_NEW(SELECT_BUTTON) && !(sCurrentBagPocket == BAG_POCKET_BERRIES || sCurrentBagPocket == BAG_POCKET_TMs_HMs) && (sReturnLocation == RETURN_TO_FIELD_0 || sReturnLocation == RETURN_TO_BATTLE)) { @@ -1647,7 +1647,7 @@ static void sub_80A50C8(u8 taskId) return; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (gBagPocketScrollStates[sCurrentBagPocket].scrollTop + gBagPocketScrollStates[sCurrentBagPocket].cursorPos == gBagPocketScrollStates[sCurrentBagPocket].numSlots) { @@ -1685,7 +1685,7 @@ static void sub_80A50C8(u8 taskId) return; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { if (taskData[10] == 0) { @@ -1709,7 +1709,7 @@ bool8 SellMenu_QuantityRoller(u8 taskId, u16 b) { s16 *taskData = gTasks[taskId].data; - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) + if (JOY_REPT(DPAD_ANY) == DPAD_UP) { if (taskData[1] != b) taskData[1]++; @@ -1718,7 +1718,7 @@ bool8 SellMenu_QuantityRoller(u8 taskId, u16 b) return TRUE; } - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) + if (JOY_REPT(DPAD_ANY) == DPAD_DOWN) { if (taskData[1] != 1) taskData[1]--; @@ -1727,7 +1727,7 @@ bool8 SellMenu_QuantityRoller(u8 taskId, u16 b) return TRUE; } - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT) + if (JOY_REPT(DPAD_ANY) == DPAD_RIGHT) { if (taskData[1] + 10 < b) taskData[1] += 10; @@ -1736,7 +1736,7 @@ bool8 SellMenu_QuantityRoller(u8 taskId, u16 b) return TRUE; } - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT) + if (JOY_REPT(DPAD_ANY) == DPAD_LEFT) { if (taskData[1] > 10) taskData[1] -= 10; @@ -1786,7 +1786,7 @@ static void sub_80A5414(u8 taskId) { while (1) { - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) + if (JOY_REPT(DPAD_ANY) == DPAD_UP) { if ((sPopupMenuSelection & 1) && sPopupMenuActionList[sPopupMenuSelection - 1] != 8) { @@ -1795,7 +1795,7 @@ static void sub_80A5414(u8 taskId) } break; } - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) + if (JOY_REPT(DPAD_ANY) == DPAD_DOWN) { if ((!(sPopupMenuSelection & 1)) && sPopupMenuActionList[sPopupMenuSelection + 1] != 8) { @@ -1804,7 +1804,7 @@ static void sub_80A5414(u8 taskId) } break; } - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT) + if (JOY_REPT(DPAD_ANY) == DPAD_LEFT) { if ((sPopupMenuSelection >= 2) && sPopupMenuActionList[sPopupMenuSelection - 2] != 8) { @@ -1813,7 +1813,7 @@ static void sub_80A5414(u8 taskId) } break; } - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT) + if (JOY_REPT(DPAD_ANY) == DPAD_RIGHT) { if ((sPopupMenuSelection < 2) && sPopupMenuActionList[sPopupMenuSelection + 2] != 8) { @@ -1822,7 +1822,7 @@ static void sub_80A5414(u8 taskId) } break; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { gTasks[taskId].data[10] = 0; sub_80A4DA4(gBGTilemapBuffers[1]); @@ -1830,7 +1830,7 @@ static void sub_80A5414(u8 taskId) r5(taskId); break; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { gTasks[taskId].data[10] = 0; sub_80A48E8(taskId, gBagPocketScrollStates[sCurrentBagPocket].cursorPos, gBagPocketScrollStates[sCurrentBagPocket].cursorPos); @@ -1869,7 +1869,7 @@ static void sub_80A5600(u8 taskId) while (1) { - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) + if (JOY_REPT(DPAD_ANY) == DPAD_UP) { if (sPopupMenuSelection != 0 && sPopupMenuActionList[sPopupMenuSelection - 1] != 8) { @@ -1878,7 +1878,7 @@ static void sub_80A5600(u8 taskId) } break; } - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) + if (JOY_REPT(DPAD_ANY) == DPAD_DOWN) { if (sPopupMenuSelection != gUnknown_02038564 - 1 && sPopupMenuSelection != 2 && sPopupMenuActionList[sPopupMenuSelection + 1] != 8) { @@ -1887,7 +1887,7 @@ static void sub_80A5600(u8 taskId) } break; } - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_LEFT) + if (JOY_REPT(DPAD_ANY) == DPAD_LEFT) { if ((sPopupMenuSelection >= 3) && sPopupMenuActionList[sPopupMenuSelection - 3] != 8) { @@ -1896,7 +1896,7 @@ static void sub_80A5600(u8 taskId) } break; } - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_RIGHT) + if (JOY_REPT(DPAD_ANY) == DPAD_RIGHT) { if ((sPopupMenuSelection < 3) && sPopupMenuActionList[sPopupMenuSelection + 3] != 8) { @@ -1905,7 +1905,7 @@ static void sub_80A5600(u8 taskId) } break; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { gTasks[taskId].data[10] = 0; sub_80A4DA4(gBGTilemapBuffers[1]); @@ -1913,7 +1913,7 @@ static void sub_80A5600(u8 taskId) r5(taskId); break; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { gTasks[taskId].data[10] = 0; sub_80A48E8(taskId, gBagPocketScrollStates[sCurrentBagPocket].cursorPos, gBagPocketScrollStates[sCurrentBagPocket].cursorPos); @@ -1972,7 +1972,7 @@ static void sub_80A5888(u8 taskId) { if (sub_80A78A0() != 0) { - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { if (sPopupMenuSelection != 0) { @@ -1980,7 +1980,7 @@ static void sub_80A5888(u8 taskId) sPopupMenuSelection = Menu_MoveCursor(-1); } } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { if (sPopupMenuSelection != gUnknown_02038564 - 1) { @@ -1988,14 +1988,14 @@ static void sub_80A5888(u8 taskId) sPopupMenuSelection = Menu_MoveCursor(1); } } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { gTasks[taskId].data[10] = 0; sub_80A48E8(taskId, gBagPocketScrollStates[sCurrentBagPocket].cursorPos, gBagPocketScrollStates[sCurrentBagPocket].cursorPos); sub_80A4DA4(gBGTilemapBuffers[1]); sItemPopupMenuActions[sPopupMenuActionList[sPopupMenuSelection]].func(taskId); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { gTasks[taskId].data[10] = 0; sub_80A4DA4(gBGTilemapBuffers[1]); @@ -2190,7 +2190,7 @@ static void sub_80A5DF8(void) static void sub_80A5E1C(u8 taskId) { - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { gTasks[taskId].data[10] = 0; sub_80A41D4(taskId); @@ -2214,13 +2214,13 @@ static void sub_80A5EA0(u8 taskId) { if (sub_80A5350(taskId) == TRUE) return; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); sub_80A5DA0(gSpecialVar_ItemId, gTasks[taskId].data[1]); DoYesNoFuncWithChoice(taskId, &gUnknown_083C16F4); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sub_80A5D38(taskId); @@ -2278,7 +2278,7 @@ static void sub_80A6000(u8 taskId) static void sub_80A6024(u8 taskId) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { sub_80A36B8(gBGTilemapBuffers[1], 0, 0, 31, 31); Menu_EraseWindowRect(0, 14, 29, 19); @@ -2455,7 +2455,7 @@ static void sub_80A648C(u8 taskId) static void sub_80A6520(u8 taskId) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); BuyMenuPrintItemQuantityAndPrice(taskId); @@ -2505,7 +2505,7 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId) Menu_EraseWindowRect(6, 11, 12, 11); BuyMenuDisplayMessage(gSpecialVar_ItemId, gTasks[taskId].data[1]); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); Menu_EraseWindowRect(0, 10, 13, 13); @@ -2514,7 +2514,7 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId) StringExpandPlaceholders(gStringVar4, gOtherText_CanPay); DisplayCannotUseItemMessage(taskId, gStringVar4, sub_80A6650, 1); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); BuyMenuPrintItemQuantityAndPrice(taskId); @@ -2661,7 +2661,7 @@ static void sub_80A6A84(u8 taskId) static void sub_80A6B00(u8 taskId) { - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { gTasks[taskId].data[10] = 0; sub_80A48E8(taskId, gBagPocketScrollStates[sCurrentBagPocket].cursorPos, gBagPocketScrollStates[sCurrentBagPocket].cursorPos); @@ -2697,13 +2697,13 @@ static void sub_80A6BE0(u8 taskId) { if (sub_80A5350(taskId) == TRUE) return; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); sub_80A4DA4(gBGTilemapBuffers[1]); sub_80A6B64(taskId); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { gTasks[taskId].data[10] = 0; sub_80A48E8(taskId, gBagPocketScrollStates[sCurrentBagPocket].cursorPos, gBagPocketScrollStates[sCurrentBagPocket].cursorPos); @@ -2802,7 +2802,7 @@ static void sub_80A6DF0(u16 *a) static void sub_80A6EB8(u8 taskId) { - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) + if (JOY_REPT(DPAD_ANY) == DPAD_UP) { if (sPopupMenuSelection == 1) { @@ -2810,7 +2810,7 @@ static void sub_80A6EB8(u8 taskId) sPopupMenuSelection = Menu_MoveCursor(-1); } } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) + else if (JOY_REPT(DPAD_ANY) == DPAD_DOWN) { if (sPopupMenuSelection + 1 < gUnknown_02038564) { @@ -2818,14 +2818,14 @@ static void sub_80A6EB8(u8 taskId) sPopupMenuSelection = Menu_MoveCursor(1); } } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { gTasks[taskId].data[10] = 0; sub_80A48E8(taskId, gBagPocketScrollStates[sCurrentBagPocket].cursorPos, gBagPocketScrollStates[sCurrentBagPocket].cursorPos); sub_80A4DA4(gBGTilemapBuffers[1]); sItemPopupMenuActions[sPopupMenuActionList[sPopupMenuSelection]].func(taskId); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { gTasks[taskId].data[10] = 0; sub_80A48E8(taskId, gBagPocketScrollStates[sCurrentBagPocket].cursorPos, gBagPocketScrollStates[sCurrentBagPocket].cursorPos); diff --git a/src/item_use.c b/src/item_use.c index c15483a2d..6fd6f5c33 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -615,13 +615,13 @@ void ItemUseOutOfBattle_CoinCase(u8 taskId) static void SSTicketWaitForAButtonPress(u8 taskId) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) CleanUpItemMenuMessage(taskId); } static void SSTicketWaitForAButtonPress2(u8 taskId) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) CleanUpOverworldMessage(taskId); } @@ -751,7 +751,7 @@ static void BootTMHM(u8 taskId) static void WaitButtonPressAndDisplayTMHMInfo(u8 taskId) { - if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { StringCopy(gStringVar1, gMoveNames[ItemIdToBattleMoveId(gSpecialVar_ItemId)]); StringExpandPlaceholders(gStringVar4, gOtherText_ContainsMove); @@ -889,7 +889,7 @@ void ItemUseInBattle_PokeBall(u8 taskId) void sub_80CA294(u8 taskId) { - if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) sub_80A7094(taskId); } diff --git a/src/link.c b/src/link.c index 2c79cdf13..a066f5e5c 100644 --- a/src/link.c +++ b/src/link.c @@ -403,17 +403,17 @@ static void TestBlockTransfer(u32 a1, u32 a2, u32 a3) 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(gSharedMem + 0x4000, 0x2004); - 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)) Save_WriteData(SAVE_LINK); - if (gMain.newKeys & SELECT_BUTTON) + if (JOY_NEW(SELECT_BUTTON)) SetCloseLinkCallback(); if (gLinkTestDebugValuesEnabled) { diff --git a/src/mail.c b/src/mail.c index c6ca4aaec..ee3aa12df 100644 --- a/src/mail.c +++ b/src/mail.c @@ -637,7 +637,7 @@ static void sub_80F8F58(void) static void sub_80F8F78(void) { - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); sSharedMemPtr->varF0 = sub_80F8FB4; @@ -687,24 +687,24 @@ void debug_sub_810C910(u8 taskId) void debug_sub_810C990(u8 taskId) { - if (gMain.newKeys & (DPAD_LEFT | DPAD_DOWN)) + if (JOY_NEW(DPAD_LEFT | DPAD_DOWN)) { gSpecialVar_0x8006 = (gSpecialVar_0x8006 + 11) % 12; Menu_DrawStdWindowFrame(1, 1, 10, 4); Menu_PrintText(_84115C4[gSpecialVar_0x8006], 2, 2); } - else if (gMain.newKeys & (DPAD_UP | DPAD_RIGHT)) + else if (JOY_NEW(DPAD_UP | DPAD_RIGHT)) { gSpecialVar_0x8006 = (gSpecialVar_0x8006 + 1) % 12; Menu_DrawStdWindowFrame(1, 1, 10, 4); Menu_PrintText(_84115C4[gSpecialVar_0x8006], 2, 2); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); gTasks[taskId].func = debug_sub_810C910; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { Menu_DisplayDialogueFrame(); Menu_PrintText(Str_8411540, 4, 15); @@ -715,12 +715,12 @@ void debug_sub_810C990(u8 taskId) void debug_sub_810CA7C(u8 taskId) { - if (gMain.newKeys & 0xF0) + if (JOY_NEW(DPAD_ANY)) { gSpecialVar_0x8004 ^= 1; Menu_PrintText(_8411560[gSpecialVar_0x8004], 2, 2); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { if (gMain.watchedKeysPressed) { @@ -747,7 +747,7 @@ void debug_sub_810CB50(u8 taskId) u8 sp8[] = DTR("メール{STR_VAR_1} {STR_VAR_2}", "MAIL{STR_VAR_1} {STR_VAR_2}"); bool8 r2 = FALSE; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { ConvertIntToDecimalStringN(gStringVar1, gSpecialVar_0x8005, 2, 1); StringCopy(gStringVar2, gSpeciesNames[gTasks[taskId].data[0]]); @@ -760,7 +760,7 @@ void debug_sub_810CB50(u8 taskId) debug_sub_810D340(); return; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { DestroyTask(taskId); Menu_EraseScreen(); @@ -768,12 +768,12 @@ void debug_sub_810CB50(u8 taskId) debug_sub_810D340(); return; } - else if (gMain.newKeys & (DPAD_LEFT | DPAD_DOWN)) + else if (JOY_NEW(DPAD_LEFT | DPAD_DOWN)) { gTasks[taskId].data[0] = (gTasks[taskId].data[0] + 0x19B) % 0x19C; r2 = TRUE; } - else if (gMain.newKeys & (DPAD_UP | DPAD_RIGHT)) + else if (JOY_NEW(DPAD_UP | DPAD_RIGHT)) { gTasks[taskId].data[0] = (gTasks[taskId].data[0] + 1) % 0x19C; r2 = TRUE; diff --git a/src/main.c b/src/main.c index d8779b90c..33b560c73 100644 --- a/src/main.c +++ b/src/main.c @@ -250,14 +250,14 @@ static void ReadKeys(void) // Remap L to A if the L=A option is enabled. if (gSaveBlock2.optionsButtonMode == 2) { - 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; } - if (gMain.newKeys & gMain.watchedKeysMask) + if (JOY_NEW(gMain.watchedKeysMask)) gMain.watchedKeysPressed = TRUE; } diff --git a/src/main_menu.c b/src/main_menu.c index 93eb6fbbe..a224efe3b 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -323,7 +323,7 @@ void Task_MainMenuWaitForSaveErrorAck(u8 taskId) { if (Menu_UpdateWindowText()) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { Menu_EraseWindowRect(2, 14, 27, 19); gTasks[taskId].func = Task_MainMenuCheckRtc; @@ -362,7 +362,7 @@ void Task_MainMenuWaitForRtcErrorAck(u8 taskId) { if (Menu_UpdateWindowText()) { - if ( gMain.newKeys & 1 ) + if (JOY_NEW(A_BUTTON)) { Menu_EraseWindowRect(2, 14, 27, 19); gTasks[taskId].func = Task_MainMenuDraw; @@ -441,13 +441,13 @@ void Task_MainMenuHighlight(u8 taskId) bool8 MainMenuProcessKeyInput(u8 taskId) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); gTasks[taskId].func = Task_MainMenuPressedA; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, FADE_COLOR_WHITE); @@ -473,7 +473,7 @@ bool8 MainMenuProcessKeyInput(u8 taskId) break; } - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { if (gTasks[taskId].tMenuSelection > 0) { @@ -481,7 +481,7 @@ bool8 MainMenuProcessKeyInput(u8 taskId) return TRUE; } } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { if (gTasks[taskId].tMenuSelection < menuItemCount - 1) { diff --git a/src/menu.c b/src/menu.c index 6fabef96b..aae5a7434 100644 --- a/src/menu.c +++ b/src/menu.c @@ -269,7 +269,7 @@ u8 Menu_GetCursorPos(void) s8 Menu_ProcessInput(void) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (gMenu.menu_field_7) @@ -277,20 +277,20 @@ s8 Menu_ProcessInput(void) return gMenu.cursorPos; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { if (gMenu.menu_field_7) Menu_DestroyCursor(); return -1; } - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { PlaySE(SE_SELECT); Menu_MoveCursor(-1); return -2; } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { PlaySE(SE_SELECT); Menu_MoveCursor(1); @@ -304,7 +304,7 @@ s8 Menu_ProcessInputNoWrap(void) { u8 cursorPos = gMenu.cursorPos; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (gMenu.menu_field_7) @@ -312,20 +312,20 @@ s8 Menu_ProcessInputNoWrap(void) return gMenu.cursorPos; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { if (gMenu.menu_field_7) Menu_DestroyCursor(); return -1; } - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { if (cursorPos != Menu_MoveCursorNoWrap(-1)) PlaySE(SE_SELECT); return -2; } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { if (cursorPos != Menu_MoveCursorNoWrap(1)) PlaySE(SE_SELECT); @@ -385,19 +385,19 @@ static u8 MoveMenuCursorGridLayout(s8 delta) // Returns TRUE if the cursor is on an edge and cannot move in the pressed direction static bool8 IsGridCursorMovementClamped(void) { - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { // is cursor on first row? if (gMenu.cursorPos < gMenu.width) return TRUE; } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { // is cursor on last row? if (gMenu.cursorPos >= gMenu.maxCursorPos + 1 - gMenu.width) return TRUE; } - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { // is cursor on first column? if ((gMenu.cursorPos - gMenu.cursorPos % gMenu.width) % gMenu.width == 1 // always false @@ -405,7 +405,7 @@ static bool8 IsGridCursorMovementClamped(void) || gMenu.cursorPos % gMenu.width == 0) return TRUE; } - if (gMain.newKeys & DPAD_RIGHT) + if (JOY_NEW(DPAD_RIGHT)) { // is cursor on last column? if (gMenu.cursorPos % gMenu.width == gMenu.width - 1) @@ -531,7 +531,7 @@ void sub_807274C(u8 left, u8 top, u8 menuItemCount, u8 a4, const struct MenuActi s8 Menu_ProcessInputGridLayout(void) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (gMenu.menu_field_7) Menu_DestroyCursor(); @@ -539,34 +539,34 @@ s8 Menu_ProcessInputGridLayout(void) return Menu_GetCursorPos(); } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { if (gMenu.menu_field_7) Menu_DestroyCursor(); return -1; } - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { PlaySE(SE_SELECT); // Move up one whole row MoveMenuCursorGridLayout(-gMenu.width); return -2; } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { PlaySE(SE_SELECT); // Move down one whole column MoveMenuCursorGridLayout(gMenu.width); return -2; } - else if (gMain.newKeys & DPAD_LEFT) + else if (JOY_NEW(DPAD_LEFT)) { PlaySE(SE_SELECT); MoveMenuCursorGridLayout(-1); return -2; } - else if (gMain.newKeys & DPAD_RIGHT) + else if (JOY_NEW(DPAD_RIGHT)) { PlaySE(SE_SELECT); MoveMenuCursorGridLayout(1); diff --git a/src/menu_helpers.c b/src/menu_helpers.c index 893b20231..14f84885b 100644 --- a/src/menu_helpers.c +++ b/src/menu_helpers.c @@ -224,11 +224,11 @@ u8 sub_80F9284(void) { if (gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR) { - if (gMain.newKeys & L_BUTTON) + if (JOY_NEW(L_BUTTON)) { return 1; } - if (gMain.newKeys & R_BUTTON) + if (JOY_NEW(R_BUTTON)) { return 2; } @@ -241,11 +241,11 @@ u8 sub_80F92BC(void) { if (gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR) { - if (gMain.newAndRepeatedKeys & L_BUTTON) + if (JOY_REPT(L_BUTTON)) { return 1; } - if (gMain.newAndRepeatedKeys & R_BUTTON) + if (JOY_REPT(R_BUTTON)) { return 2; } diff --git a/src/mon_markings.c b/src/mon_markings.c index 7b4055421..31f415fce 100644 --- a/src/mon_markings.c +++ b/src/mon_markings.c @@ -408,7 +408,7 @@ bool8 sub_80F7500(void) sMenu->spriteSheetLoadRequired = FALSE; } - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { s8 pos; PlaySE(SE_SELECT); @@ -418,7 +418,7 @@ bool8 sub_80F7500(void) return TRUE; } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { s8 pos; PlaySE(SE_SELECT); @@ -428,7 +428,7 @@ bool8 sub_80F7500(void) return TRUE; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); @@ -447,7 +447,7 @@ bool8 sub_80F7500(void) return TRUE; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); return FALSE; diff --git a/src/move_tutor_menu.c b/src/move_tutor_menu.c index 50dcb4f5e..c1948dadd 100644 --- a/src/move_tutor_menu.c +++ b/src/move_tutor_menu.c @@ -617,7 +617,7 @@ static void MoveTutorMain(void) sMoveTutorMenu->state = 33; break; case 33: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); sMoveTutorMenu->state = 14; @@ -664,10 +664,10 @@ static void DrawBattleMoveInfoHeaders(bool8 noTeachMoveText) static u8 ChangeToContestMoveInfoWindow(void) { - u32 result = (gMain.newKeys & DPAD_LEFT) || (gMain.newKeys & DPAD_RIGHT); + u32 result = JOY_NEW(DPAD_LEFT) || JOY_NEW(DPAD_RIGHT); if (gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR - && ((gMain.newKeys & L_BUTTON) || (gMain.newKeys & R_BUTTON))) + && (JOY_NEW(L_BUTTON) || JOY_NEW(R_BUTTON))) result++; if (result != 0) @@ -710,10 +710,10 @@ static void DrawContestMoveInfoHeaders(bool8 noTeachMoveText) static u8 ChangeToBattleMoveInfoWindow(void) { - u32 result = (gMain.newKeys & DPAD_LEFT) || (gMain.newKeys & DPAD_RIGHT); + u32 result = JOY_NEW(DPAD_LEFT) || JOY_NEW(DPAD_RIGHT); if (gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR - && ((gMain.newKeys & L_BUTTON) || (gMain.newKeys & R_BUTTON))) + && (JOY_NEW(L_BUTTON) || JOY_NEW(R_BUTTON))) result++; if (result != 0) @@ -826,7 +826,7 @@ static void MoveCursorPos(s8 delta) static void HandleMoveTutorMenuInput(void) { - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { if (sMoveTutorMenu->menuSelection != 0) { @@ -844,7 +844,7 @@ static void HandleMoveTutorMenuInput(void) } } } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { if (sMoveTutorMenu->menuSelection < sMoveTutorMenu->numMenuChoices - 1) { @@ -862,7 +862,7 @@ static void HandleMoveTutorMenuInput(void) } } } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (sMoveTutorMenu->menuSelection != sMoveTutorMenu->numMenuChoices - 1) @@ -879,7 +879,7 @@ static void HandleMoveTutorMenuInput(void) sMoveTutorMenu->state = 12; } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sMoveTutorMenu->state = 12; diff --git a/src/mystery_event_menu.c b/src/mystery_event_menu.c index 987249f50..b1e161f85 100644 --- a/src/mystery_event_menu.c +++ b/src/mystery_event_menu.c @@ -113,7 +113,7 @@ static void CB2_MysteryEventMenu(void) MenuPrintMessageDefaultCoords(gSystemText_LoadEventPressA); gMain.state++; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); CloseLink(); @@ -133,7 +133,7 @@ static void CB2_MysteryEventMenu(void) gMain.state = 13; break; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); sub_8007F4C(); @@ -141,7 +141,7 @@ static void CB2_MysteryEventMenu(void) Menu_PrintText(gSystemText_LoadingEvent, 7, 6); gMain.state++; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); CloseLink(); @@ -179,7 +179,7 @@ static void CB2_MysteryEventMenu(void) break; } } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); CloseLink(); @@ -193,7 +193,7 @@ static void CB2_MysteryEventMenu(void) { goto label; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); sub_8007F4C(); @@ -201,7 +201,7 @@ static void CB2_MysteryEventMenu(void) Menu_PrintText(gSystemText_LoadingEvent, 7, 6); gMain.state++; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); CloseLink(); @@ -258,7 +258,7 @@ static void CB2_MysteryEventMenu(void) } break; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); CloseLink(); @@ -307,7 +307,7 @@ static void CB2_MysteryEventMenu(void) } break; case 14: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); gMain.state++; @@ -360,7 +360,7 @@ void debug_sub_815D04C(u8 taskId) gTasks[taskId].data[0]++; } - if (gMain.newKeys & 0x20) + if (JOY_NEW(DPAD_LEFT)) { if (gTasks[taskId].data[1] == 0) gTasks[taskId].data[1] = gUnknown_Debug_842E350 - 1; @@ -368,7 +368,7 @@ void debug_sub_815D04C(u8 taskId) gTasks[taskId].data[1]--; gTasks[taskId].data[0] = 0; } - if (gMain.newKeys & 0x10) + if (JOY_NEW(DPAD_RIGHT)) { if (gTasks[taskId].data[1] == gUnknown_Debug_842E350 - 1) gTasks[taskId].data[1] = 0; @@ -376,7 +376,7 @@ void debug_sub_815D04C(u8 taskId) gTasks[taskId].data[1]++; gTasks[taskId].data[0] = 0; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { // TODO: fix this s32 var = gTasks[taskId].data[1]; @@ -422,7 +422,7 @@ void debug_sub_815D1D8(void) case 1: if (!gPaletteFade.active) { - if (gMain.heldKeys & 0x100) + if (JOY_HELD(R_BUTTON)) gUnknown_Debug_30030E0++; MenuPrintMessage(Str_843DA70, 4, 15); gMain.state++; @@ -473,7 +473,7 @@ void debug_sub_815D1D8(void) } break; case 10: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); gMain.state++; diff --git a/src/naming_screen.c b/src/naming_screen.c index a1297d3ad..f3860017b 100644 --- a/src/naming_screen.c +++ b/src/naming_screen.c @@ -663,22 +663,22 @@ static void InputState_Disabled(struct Task *task) static void InputState_Enabled(struct Task *task) { task->tKeyboardEvent = 0; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { task->tKeyboardEvent = KBEVENT_PRESSED_A; return; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { task->tKeyboardEvent = KBEVENT_PRESSED_B; return; } - if (gMain.newKeys & SELECT_BUTTON) + if (JOY_NEW(SELECT_BUTTON)) { task->tKeyboardEvent = KBEVENT_PRESSED_SELECT; return; } - if (gMain.newKeys & START_BUTTON) + if (JOY_NEW(START_BUTTON)) { task->tKeyboardEvent = KBEVENT_PRESSED_START; MoveCursorToOKButton(); @@ -717,13 +717,13 @@ static void HandleDpadMovement(struct Task *task) GetCursorPos(&cursorX, &cursorY); dpadDir = 0; - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) dpadDir = 1; - if (gMain.newAndRepeatedKeys & DPAD_DOWN) + if (JOY_REPT(DPAD_DOWN)) dpadDir = 2; - if (gMain.newAndRepeatedKeys & DPAD_LEFT) + if (JOY_REPT(DPAD_LEFT)) dpadDir = 3; - if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + if (JOY_REPT(DPAD_RIGHT)) dpadDir = 4; //Get new cursor position diff --git a/src/option_menu.c b/src/option_menu.c index 9362a776b..69cdc1473 100644 --- a/src/option_menu.c +++ b/src/option_menu.c @@ -197,16 +197,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].tMenuSelection == 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].tMenuSelection > 0) gTasks[taskId].tMenuSelection--; @@ -214,7 +214,7 @@ static void Task_OptionMenuProcessInput(u8 taskId) gTasks[taskId].tMenuSelection = 6; HighlightOptionMenuItem(gTasks[taskId].tMenuSelection); } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { if (gTasks[taskId].tMenuSelection < 6) gTasks[taskId].tMenuSelection++; @@ -300,14 +300,14 @@ 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 < 2) selection++; else selection = 0; } - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { if (selection > 0) selection--; @@ -344,7 +344,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; return selection; } @@ -363,7 +363,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; return selection; } @@ -390,7 +390,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); @@ -412,7 +412,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 < 19) selection++; @@ -420,7 +420,7 @@ static u8 FrameType_ProcessInput(u8 selection) selection = 0; Menu_LoadStdFrameGraphicsOverrideStyle(selection); } - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { if (selection > 0) selection--; @@ -485,14 +485,14 @@ static void FrameType_DrawChoices(u8 selection) static u8 ButtonMode_ProcessInput(u8 selection) { - if (gMain.newKeys & DPAD_RIGHT) + if (JOY_NEW(DPAD_RIGHT)) { if (selection < 2) selection++; else selection = 0; } - 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 99c1c03f6..212eb7236 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -1298,7 +1298,7 @@ void debug_sub_8058C00(void) ScriptContext1_Init(); ScriptContext2_Disable(); - if (gMain.heldKeys & R_BUTTON) + if (JOY_HELD(R_BUTTON)) gFieldCallback = ExecuteTruckSequence; else gFieldCallback = sub_8080B60; @@ -1467,7 +1467,7 @@ void CB2_ContinueSavedGame(void) FieldClearVBlankHBlankCallbacks(); StopMapMusic(); #if DEBUG - if (gMain.heldKeys & R_BUTTON) + if (JOY_HELD(R_BUTTON)) gUnknown_020297ED = TRUE; #endif ResetSafariZoneFlag_(); @@ -2075,27 +2075,27 @@ void sub_8055280(u16 a1) u16 sub_80552B0(u32 a1) { - if (gMain.heldKeys & DPAD_UP) + if (JOY_HELD(DPAD_UP)) { return 19; } - else if (gMain.heldKeys & DPAD_DOWN) + else if (JOY_HELD(DPAD_DOWN)) { return 18; } - else if (gMain.heldKeys & DPAD_LEFT) + else if (JOY_HELD(DPAD_LEFT)) { return 20; } - else if (gMain.heldKeys & DPAD_RIGHT) + else if (JOY_HELD(DPAD_RIGHT)) { return 21; } - else if (gMain.newKeys & START_BUTTON) + else if (JOY_NEW(START_BUTTON)) { return 24; } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { return 25; } @@ -2207,7 +2207,7 @@ u16 sub_8055468(u32 a1) u16 sub_805546C(u32 linkPlayerId) { - if (gUnknown_03000580[linkPlayerId] == 0x82 && (gMain.newKeys & B_BUTTON)) + if (gUnknown_03000580[linkPlayerId] == 0x82 && JOY_NEW(B_BUTTON)) { sub_80543DC(sub_8055468); return 29; diff --git a/src/party_menu.c b/src/party_menu.c index c326073ae..fe825d009 100644 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -1225,14 +1225,14 @@ u16 HandleDefaultPartyMenuInput(u8 taskId) ChangePartyMenuSelection(taskId, menuDirectionPressed); return gMain.newAndRepeatedKeys; } - else if ((gMain.newKeys & A_BUTTON) && gSprites[sub_806CA00(taskId)].data[0] == 7) + else if (JOY_NEW(A_BUTTON) && gSprites[sub_806CA00(taskId)].data[0] == 7) { // Selected "CANCEL" return B_BUTTON; } else { - return gMain.newKeys & (A_BUTTON | B_BUTTON); + return JOY_NEW(A_BUTTON | B_BUTTON); } } @@ -1269,7 +1269,7 @@ u16 HandleBattleTowerPartyMenuInput(u8 taskId) } } - if (gMain.newKeys & START_BUTTON) + if (JOY_NEW(START_BUTTON)) { SelectBattleTowerOKButton(taskId); return START_BUTTON; @@ -1284,7 +1284,7 @@ u16 HandleBattleTowerPartyMenuInput(u8 taskId) } else { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (gSprites[sub_806CA00(taskId)].data[0] == 7) return B_BUTTON; @@ -1292,7 +1292,7 @@ u16 HandleBattleTowerPartyMenuInput(u8 taskId) } } - return gMain.newKeys & (A_BUTTON | B_BUTTON); + return JOY_NEW(A_BUTTON | B_BUTTON); } void task_pc_turn_off(const u8 *a, u8 b) @@ -1836,7 +1836,7 @@ void HandlePartyMenuSwitchPokemonInput(u8 taskId) break; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(5); gTasks[taskId].func = ePartyMenu.unkC; @@ -3285,7 +3285,7 @@ void Task_TeamMonTMMove4(u8 taskId) { if (IsFanfareTaskInactive()) { - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { SetHeldItemIconVisibility(gPartyMenu.unk4, gPartyMenu.primarySelectedMonIndex); if (ePartyMenu2.pmUnk282 == 1) @@ -3866,21 +3866,21 @@ void CreateItemUseMoveMenu(u8 partyMonIndex) void Task_HandleItemUseMoveMenuInput(u8 taskId) { - 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); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { gUnknown_08376B54[0](taskId); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); gUnknown_08376B54[1](taskId); @@ -4044,7 +4044,7 @@ void Task_RareCandy1(u8 taskId) { if (WaitFanfare(0) && gPartyMenuMessage_IsPrinting == 0) { - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); PrintStatGrowthsInLevelUpWindow(taskId); @@ -4055,7 +4055,7 @@ void Task_RareCandy1(u8 taskId) void Task_RareCandy2(u8 taskId) { - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); PrintNewStatsInLevelUpWindow(taskId); @@ -4161,7 +4161,7 @@ void Task_RareCandy3(u8 taskId) { if (WaitFanfare(0)) { - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { u16 learnedMove; u16 evolutionSpecies; diff --git a/src/player_pc.c b/src/player_pc.c index f7c2379cd..c4d922c77 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -225,23 +225,23 @@ static void InitPlayerPCMenu(u8 taskId) static void PlayerPCProcessMenuInput(u8 taskId) { - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { PlaySE(SE_SELECT); Menu_MoveCursor(-1); } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { PlaySE(SE_SELECT); Menu_MoveCursor(1); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { Menu_DestroyCursor(); PlaySE(SE_SELECT); sPlayerPCMenuActions[gPcItemMenuOptionOrder[Menu_GetCursorPos()]].func(taskId); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { Menu_DestroyCursor(); PlaySE(SE_SELECT); @@ -320,24 +320,24 @@ static void ItemStorageMenuPrint(const u8 *textPtr) static void ItemStorageMenuProcessInput(u8 var) { - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { PlaySE(SE_SELECT); Menu_MoveCursor(-1); ItemStorageMenuPrint(gPCText_OptionDescList[Menu_GetCursorPos()]); } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { PlaySE(SE_SELECT); Menu_MoveCursor(1); ItemStorageMenuPrint(gPCText_OptionDescList[Menu_GetCursorPos()]); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); gPCText_ItemPCOptionsText[Menu_GetCursorPos()].func(var); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { Menu_DestroyCursor(); PlaySE(SE_SELECT); @@ -445,7 +445,7 @@ static void ItemStorage_ProcessInput(u8 taskId) s16 *data = TASK.data; s16 trueIndex; - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { if(PAGE_INDEX != 0) // did the cursor move physically upwards? { @@ -477,7 +477,7 @@ static void ItemStorage_ProcessInput(u8 taskId) Menu_MoveCursor(0); // don't move the cursor. it's at the top of the page index, but not the true index. } } - else if(gMain.newAndRepeatedKeys & DPAD_DOWN) // _0813A306 + else if (JOY_REPT(DPAD_DOWN)) // _0813A306 { if(PAGE_INDEX != NUM_PAGE_ITEMS - 1) { @@ -503,7 +503,7 @@ static void ItemStorage_ProcessInput(u8 taskId) Menu_MoveCursor(0); } } - else if(gMain.newKeys & SELECT_BUTTON) // _0813A3A0 + else if (JOY_NEW(SELECT_BUTTON)) // _0813A3A0 { if (SWITCH_MODE_ACTIVE == FALSE) { @@ -524,7 +524,7 @@ static void ItemStorage_ProcessInput(u8 taskId) ItemStorage_DrawBothListAndDescription(taskId); } } - else if(gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if(SWITCH_MODE_ACTIVE == FALSE) @@ -544,7 +544,7 @@ static void ItemStorage_ProcessInput(u8 taskId) ItemStorage_DrawBothListAndDescription(taskId); } } - else if(gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); if(SWITCH_MODE_ACTIVE == FALSE) @@ -613,7 +613,7 @@ static void ItemStorage_HandleQuantityRolling(u8 taskId) s16 *data = TASK.data; u8 trueIndex = PAGE_INDEX + ITEMS_ABOVE_TOP; - if(gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { if(NUM_QUANTITY_ROLLER != gSaveBlock1.pcItems[trueIndex].quantity) NUM_QUANTITY_ROLLER++; @@ -622,7 +622,7 @@ static void ItemStorage_HandleQuantityRolling(u8 taskId) sub_80A418C(NUM_QUANTITY_ROLLER, STR_CONV_MODE_RIGHT_ALIGN, 8, 9, 3); // print quantity? } - else if(gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { if(NUM_QUANTITY_ROLLER != 1) NUM_QUANTITY_ROLLER--; @@ -631,7 +631,7 @@ static void ItemStorage_HandleQuantityRolling(u8 taskId) sub_80A418C(NUM_QUANTITY_ROLLER, STR_CONV_MODE_RIGHT_ALIGN, 8, 9, 3); // print quantity? } - else if(gMain.newAndRepeatedKeys & DPAD_LEFT) // reduce by 10. + else if (JOY_REPT(DPAD_LEFT)) // reduce by 10. { NUM_QUANTITY_ROLLER -= 10; @@ -640,7 +640,7 @@ static void ItemStorage_HandleQuantityRolling(u8 taskId) sub_80A418C(NUM_QUANTITY_ROLLER, STR_CONV_MODE_RIGHT_ALIGN, 8, 9, 3); // print quantity? } - else if(gMain.newAndRepeatedKeys & DPAD_RIGHT) // add 10. + else if (JOY_REPT(DPAD_RIGHT)) // add 10. { NUM_QUANTITY_ROLLER += 10; @@ -649,7 +649,7 @@ static void ItemStorage_HandleQuantityRolling(u8 taskId) sub_80A418C(NUM_QUANTITY_ROLLER, STR_CONV_MODE_RIGHT_ALIGN, 8, 9, 3); // print quantity? } - else if(gMain.newKeys & A_BUTTON) // confirm quantity. + else if (JOY_NEW(A_BUTTON)) // confirm quantity. { PlaySE(SE_SELECT); Menu_EraseWindowRect(6, 6, 0xD, 0xB); @@ -659,7 +659,7 @@ static void ItemStorage_HandleQuantityRolling(u8 taskId) else ItemStorage_DoItemToss(taskId); } - else if(gMain.newKeys & B_BUTTON) // cancel quantity. + else if (JOY_NEW(B_BUTTON)) // cancel quantity. { PlaySE(SE_SELECT); Menu_EraseWindowRect(6, 6, 0xD, 0xB); @@ -735,7 +735,7 @@ static void ItemStorage_HandleRemoveItem(u8 taskId) s16 *data = TASK.data; s16 oldNumItems; - if(gMain.newKeys & A_BUTTON || gMain.newKeys == B_BUTTON) + if (JOY_NEW(A_BUTTON) || gMain.newKeys == B_BUTTON) { RemovePCItem(PAGE_INDEX + ITEMS_ABOVE_TOP, NUM_QUANTITY_ROLLER); oldNumItems = NUM_ITEMS; @@ -754,7 +754,7 @@ static void ItemStorage_WaitPressHandleResumeProcessInput(u8 taskId) { s16 *data = TASK.data; - if(gMain.newKeys & A_BUTTON || gMain.newKeys == B_BUTTON) + if (JOY_NEW(A_BUTTON) || gMain.newKeys == B_BUTTON) { ItemStorage_PrintItemPcResponse(gSaveBlock1.pcItems[ITEMS_ABOVE_TOP + PAGE_INDEX].itemId); StartVerticalScrollIndicators(TOP_ARROW); @@ -1082,7 +1082,7 @@ static void Mailbox_ProcessInput(u8 taskId) { if(!gPaletteFade.active) { - if(gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { if(eMailboxInfo.cursorPos != 0) { @@ -1096,7 +1096,7 @@ static void Mailbox_ProcessInput(u8 taskId) Mailbox_DrawMailList(taskId); } } - else if(gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { if(eMailboxInfo.cursorPos != eMailboxInfo.pageItems - 1) { @@ -1110,7 +1110,7 @@ static void Mailbox_ProcessInput(u8 taskId) Mailbox_DrawMailList(taskId); } } - else if(gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { Menu_DestroyCursor(); PlaySE(SE_SELECT); @@ -1125,7 +1125,7 @@ static void Mailbox_ProcessInput(u8 taskId) TASK.FUNC = Mailbox_PrintWhatToDoWithPlayerMailText; } } - else if(gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { Menu_DestroyCursor(); PlaySE(SE_SELECT); @@ -1172,22 +1172,22 @@ static void Mailbox_PrintMailOptions(u8 taskId) // Mailbox_PrintMailOptions static void Mailbox_MailOptionsProcessInput(u8 taskId) { - if(gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { PlaySE(SE_SELECT); Menu_MoveCursor(-1); } - else if(gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { PlaySE(SE_SELECT); Menu_MoveCursor(1); } - else if(gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); gMailboxMailOptions[Menu_GetCursorPos()].func(taskId); } - else if(gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); Mailbox_Cancel(taskId); diff --git a/src/pokeblock.c b/src/pokeblock.c index 5a0ea0810..cad0a211b 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -635,7 +635,7 @@ static void sub_810BF7C(u8 taskId) { if (!gPaletteFade.active) { - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { if (gUnknown_02039248.unk0 != 0) { @@ -650,7 +650,7 @@ static void sub_810BF7C(u8 taskId) sub_810BF38(FALSE); } } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { if (gUnknown_02039248.unk0 != gUnknown_02039248.unk3) { @@ -665,7 +665,7 @@ static void sub_810BF7C(u8 taskId) sub_810BF38(FALSE); } } - else if (gMain.newKeys & SELECT_BUTTON) + else if (JOY_NEW(SELECT_BUTTON)) { if (gUnknown_02039248.unk1 + gUnknown_02039248.unk0 != gUnknown_02039248.unk2) { @@ -675,7 +675,7 @@ static void sub_810BF7C(u8 taskId) gTasks[taskId].func = sub_810C0C8; } } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (gUnknown_02039248.unk1 + gUnknown_02039248.unk0 == gUnknown_02039248.unk2) @@ -688,7 +688,7 @@ static void sub_810BF7C(u8 taskId) sub_810C368(taskId); } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); gSpecialVar_Result = 0xffff; @@ -699,7 +699,7 @@ static void sub_810BF7C(u8 taskId) static void sub_810C0C8(u8 taskId) { - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { if (gUnknown_02039248.unk0 != 0) { @@ -717,7 +717,7 @@ static void sub_810C0C8(u8 taskId) sub_810C1C8(taskId, 1); } } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { if (gUnknown_02039248.unk0 != gUnknown_02039248.unk3) { @@ -735,14 +735,14 @@ static void sub_810C0C8(u8 taskId) sub_810C1C8(taskId, 1); } } - else if (gMain.newKeys & A_BUTTON || gMain.newKeys & SELECT_BUTTON) + else if (JOY_NEW(A_BUTTON) || JOY_NEW(SELECT_BUTTON)) { PlaySE(SE_SELECT); sub_810C1C8(taskId, 0); sub_810C23C(taskId); gTasks[taskId].func = sub_810BF7C; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sub_810C1C8(taskId, 0); @@ -838,7 +838,7 @@ static void sub_810C368(u8 taskId) static void sub_810C40C(u8 taskId) { - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { if (Menu_GetCursorPos()) { @@ -846,7 +846,7 @@ static void sub_810C40C(u8 taskId) Menu_MoveCursor(-1); } } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { if (Menu_GetCursorPos() != gUnknown_0203924C - 1) { @@ -854,12 +854,12 @@ static void sub_810C40C(u8 taskId) Menu_MoveCursor(+1); } } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); gUnknown_083F7EF4[gUnknown_03000758[Menu_GetCursorPos()]].func(taskId); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sub_810C748(taskId); @@ -930,7 +930,7 @@ static void sub_810C668(u8 taskId) static void sub_810C6DC(u8 taskId) { - if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { sub_810C668(taskId); } diff --git a/src/pokedex.c b/src/pokedex.c index 105a1a2cf..a0270b5b2 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -1510,7 +1510,7 @@ void Task_PokedexMainScreen(u8 taskId) gPokedexView->menuY -= 8; else { - if ((gMain.newKeys & A_BUTTON) && gPokedexView->pokedexList[gPokedexView->selectedPokemon].seen) + if (JOY_NEW(A_BUTTON) && gPokedexView->pokedexList[gPokedexView->selectedPokemon].seen) { UpdateSelectedMonSpriteId(); BeginNormalPaletteFade( @@ -1520,7 +1520,7 @@ void Task_PokedexMainScreen(u8 taskId) gTasks[taskId].func = Task_OpenInfoScreenAfterMonMovement; PlaySE(SE_PIN); } - else if (gMain.newKeys & START_BUTTON) + else if (JOY_NEW(START_BUTTON)) { //Open menu gPokedexView->menuY = 0; @@ -1529,7 +1529,7 @@ void Task_PokedexMainScreen(u8 taskId) gTasks[taskId].func = Task_PokedexMainScreenMenu; PlaySE(SE_SELECT); } - else if (gMain.newKeys & SELECT_BUTTON) + else if (JOY_NEW(SELECT_BUTTON)) { PlaySE(SE_SELECT); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); @@ -1542,7 +1542,7 @@ void Task_PokedexMainScreen(u8 taskId) gTasks[taskId].func = Task_WaitForExitSearch; PlaySE(SE_PC_LOGIN); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); gTasks[taskId].func = Task_ClosePokedex; @@ -1576,7 +1576,7 @@ static void Task_PokedexMainScreenMenu(u8 taskId) gPokedexView->menuY += 8; else { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { switch (gPokedexView->menuCursorPos) { @@ -1607,18 +1607,18 @@ static void Task_PokedexMainScreenMenu(u8 taskId) } //Exit menu when Start or B is pressed - if (gMain.newKeys & (START_BUTTON | B_BUTTON)) + if (JOY_NEW(START_BUTTON | B_BUTTON)) { gPokedexView->menuIsOpen = 0; gTasks[taskId].func = Task_PokedexMainScreen; PlaySE(SE_SELECT); } - else if ((gMain.newAndRepeatedKeys & DPAD_UP) && gPokedexView->menuCursorPos != 0) + else if (JOY_REPT(DPAD_UP) && gPokedexView->menuCursorPos != 0) { gPokedexView->menuCursorPos--; PlaySE(SE_SELECT); } - else if ((gMain.newAndRepeatedKeys & DPAD_DOWN) && gPokedexView->menuCursorPos <= 2) + else if (JOY_REPT(DPAD_DOWN) && gPokedexView->menuCursorPos <= 2) { gPokedexView->menuCursorPos++; PlaySE(SE_SELECT); @@ -1708,7 +1708,7 @@ static void Task_PokedexResultsScreen(u8 taskId) } else { - if ((gMain.newKeys & A_BUTTON) && gPokedexView->pokedexList[gPokedexView->selectedPokemon].seen) + if (JOY_NEW(A_BUTTON) && gPokedexView->pokedexList[gPokedexView->selectedPokemon].seen) { u32 excludedPalettes; @@ -1719,7 +1719,7 @@ static void Task_PokedexResultsScreen(u8 taskId) gTasks[taskId].func = Task_OpenSearchResultsInfoScreenAfterMonMovement; PlaySE(SE_PIN); } - else if (gMain.newKeys & START_BUTTON) + else if (JOY_NEW(START_BUTTON)) { gPokedexView->menuY = 0; gPokedexView->menuIsOpen = 1; @@ -1727,7 +1727,7 @@ static void Task_PokedexResultsScreen(u8 taskId) gTasks[taskId].func = Task_PokedexResultsScreenMenu; PlaySE(SE_SELECT); } - else if (gMain.newKeys & SELECT_BUTTON) + else if (JOY_NEW(SELECT_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); gTasks[taskId].data[0] = LoadSearchMenu(); @@ -1735,7 +1735,7 @@ static void Task_PokedexResultsScreen(u8 taskId) gTasks[taskId].func = Task_WaitForExitSearch; PlaySE(SE_PC_LOGIN); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); gTasks[taskId].func = Task_PokedexResultsScreenReturnToMainScreen; @@ -1769,7 +1769,7 @@ static void Task_PokedexResultsScreenMenu(u8 taskId) } else { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { switch (gPokedexView->menuCursorPos) { @@ -1805,18 +1805,18 @@ static void Task_PokedexResultsScreenMenu(u8 taskId) } //Exit menu when Start or B is pressed - if (gMain.newKeys & (START_BUTTON | B_BUTTON)) + if (JOY_NEW(START_BUTTON | B_BUTTON)) { gPokedexView->menuIsOpen = 0; gTasks[taskId].func = Task_PokedexResultsScreen; PlaySE(SE_SELECT); } - else if ((gMain.newAndRepeatedKeys & DPAD_UP) && gPokedexView->menuCursorPos) + else if (JOY_REPT(DPAD_UP) && gPokedexView->menuCursorPos) { gPokedexView->menuCursorPos--; PlaySE(SE_SELECT); } - else if ((gMain.newAndRepeatedKeys & DPAD_DOWN) && gPokedexView->menuCursorPos <= 3) + else if (JOY_REPT(DPAD_DOWN) && gPokedexView->menuCursorPos <= 3) { gPokedexView->menuCursorPos++; PlaySE(SE_SELECT); @@ -2397,13 +2397,13 @@ static u16 TryDoPokedexScroll(u16 a, u16 b) u16 r6; u8 r10 = 0; - if (!((gMain.heldKeys & 0x40) && (a > 0))) + if (!(JOY_HELD(DPAD_UP) && (a > 0))) { //_0808E4B6 - if (!((gMain.heldKeys & 0x80) && (a < gPokedexView->pokemonListCount - 1))) + if (!(JOY_HELD(DPAD_DOWN) && (a < gPokedexView->pokemonListCount - 1))) //_0808E4CE { - if ((gMain.newKeys & 0x20) && (a > 0)) + if (JOY_NEW(DPAD_LEFT) && (a > 0)) { r6 = a; //_0808E4E0 @@ -2415,7 +2415,7 @@ static u16 TryDoPokedexScroll(u16 a, u16 b) PlaySE(0x6D); } //_0808E53C - else if ((gMain.newKeys & 0x10) && (a < gPokedexView->pokemonListCount - 1)) + else if (JOY_NEW(DPAD_RIGHT) && (a < gPokedexView->pokemonListCount - 1)) { r6 = a; for (i = 0; i < 7; i++) @@ -2489,7 +2489,7 @@ static u8 TryDoInfoScreenScroll(void) u16 r2; u16 r4 = gPokedexView->selectedPokemon; - if ((gMain.newKeys & DPAD_UP) && r4) + if (JOY_NEW(DPAD_UP) && r4) { r2 = r4; while (r2 != 0) @@ -2512,7 +2512,7 @@ static u8 TryDoInfoScreenScroll(void) return 1; } } - else if ((gMain.newKeys & DPAD_DOWN) && r4 < gPokedexView->pokemonListCount - 1) + else if (JOY_NEW(DPAD_DOWN) && r4 < gPokedexView->pokemonListCount - 1) { r2 = r4; while (r2 < gPokedexView->pokemonListCount - 1) @@ -3023,14 +3023,14 @@ static void Task_PageScreenProcessInput(u8 taskId) PlaySE(SE_DEX_SCROLL); return; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); gTasks[taskId].func = Task_ClosePageScreen; PlaySE(SE_PC_OFF); return; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { switch (gPokedexView->selectedScreen) { @@ -3062,8 +3062,8 @@ static void Task_PageScreenProcessInput(u8 taskId) } return; } - if (((gMain.newKeys & DPAD_LEFT) - || ((gMain.newKeys & L_BUTTON) && gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) + if ((JOY_NEW(DPAD_LEFT) + || (JOY_NEW(L_BUTTON) && gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) && gPokedexView->selectedScreen > 0) { gPokedexView->selectedScreen--; @@ -3071,8 +3071,8 @@ static void Task_PageScreenProcessInput(u8 taskId) PlaySE(SE_DEX_PAGE); return; } - if (((gMain.newKeys & DPAD_RIGHT) - || ((gMain.newKeys & R_BUTTON) && gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) + if ((JOY_NEW(DPAD_RIGHT) + || (JOY_NEW(R_BUTTON) && gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) && gPokedexView->selectedScreen < 3) { gPokedexView->selectedScreen++; @@ -3258,7 +3258,7 @@ static void Task_CryScreenProcessInput(u8 taskId) else LoadPlayArrowPalette(0); - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { LoadPlayArrowPalette(1); CryScreenPlayButton(NationalPokedexNumToSpecies(sPokedexListItem->dexNum)); @@ -3266,7 +3266,7 @@ static void Task_CryScreenProcessInput(u8 taskId) } else if (!gPaletteFade.active) { - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 16, RGB(0, 0, 0)); m4aMPlayContinue(&gMPlayInfo_BGM); @@ -3275,8 +3275,8 @@ static void Task_CryScreenProcessInput(u8 taskId) PlaySE(SE_PC_OFF); return; } - if ((gMain.newKeys & DPAD_LEFT) - || ((gMain.newKeys & L_BUTTON) && gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) + if (JOY_NEW(DPAD_LEFT) + || (JOY_NEW(L_BUTTON) && gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) { BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 16, RGB(0, 0, 0)); m4aMPlayContinue(&gMPlayInfo_BGM); @@ -3285,8 +3285,8 @@ static void Task_CryScreenProcessInput(u8 taskId) PlaySE(SE_DEX_PAGE); return; } - if ((gMain.newKeys & DPAD_RIGHT) - || ((gMain.newKeys & R_BUTTON) && gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) + if (JOY_NEW(DPAD_RIGHT) + || (JOY_NEW(R_BUTTON) && gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) { if (!sPokedexListItem->owned) { @@ -3430,15 +3430,15 @@ static void Task_InitSizeScreenMultistep(u8 taskId) static void Task_SizeScreenProcessInput(u8 taskId) { - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 16, RGB(0, 0, 0)); gPokedexView->screenSwitchState = 1; gTasks[taskId].func = Task_SwitchScreensFromSizeScreen; PlaySE(SE_PC_OFF); } - else if ((gMain.newKeys & DPAD_LEFT) - || ((gMain.newKeys & L_BUTTON) && gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) + else if (JOY_NEW(DPAD_LEFT) + || (JOY_NEW(L_BUTTON) && gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) { BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 16, RGB(0, 0, 0)); gPokedexView->screenSwitchState = 2; @@ -3869,14 +3869,14 @@ static void sub_8090750(u8 taskId) static void sub_8090A3C(u8 taskId) { - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { BeginNormalPaletteFade(0xFFFC, 0, 0, 16, RGB(0, 0, 0)); gSprites[gTasks[taskId].data[3]].callback = sub_8090C28; gTasks[taskId].func = sub_8090B8C; return; } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { if (gTasks[taskId].data[4] == 0) { @@ -4788,13 +4788,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].data[0]) { @@ -4815,13 +4815,13 @@ static void Task_HandleSearchTopBarInput(u8 taskId) } return; } - if ((gMain.newKeys & DPAD_LEFT) && gTasks[taskId].data[0] > 0) + if (JOY_NEW(DPAD_LEFT) && gTasks[taskId].data[0] > 0) { PlaySE(SE_DEX_PAGE); gTasks[taskId].data[0]--; HighlightSelectedSearchTopBarItem(gTasks[taskId].data[0]); } - if ((gMain.newKeys & DPAD_RIGHT) && gTasks[taskId].data[0] < 2) + if (JOY_NEW(DPAD_RIGHT) && gTasks[taskId].data[0] < 2) { PlaySE(SE_DEX_PAGE); gTasks[taskId].data[0]++; @@ -4855,14 +4855,14 @@ static void Task_HandleSearchMenuInput(u8 taskId) r6 = 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].data[1] == 6) { @@ -4896,25 +4896,25 @@ static void Task_HandleSearchMenuInput(u8 taskId) return; } - if ((gMain.newKeys & DPAD_LEFT) && r6[gTasks[taskId].data[1]][0] != 0xFF) + if (JOY_NEW(DPAD_LEFT) && r6[gTasks[taskId].data[1]][0] != 0xFF) { PlaySE(SE_SELECT); gTasks[taskId].data[1] = r6[gTasks[taskId].data[1]][0]; HighlightSelectedSearchMenuItem(gTasks[taskId].data[0], gTasks[taskId].data[1]); } - if ((gMain.newKeys & DPAD_RIGHT) && r6[gTasks[taskId].data[1]][1] != 0xFF) + if (JOY_NEW(DPAD_RIGHT) && r6[gTasks[taskId].data[1]][1] != 0xFF) { PlaySE(SE_SELECT); gTasks[taskId].data[1] = r6[gTasks[taskId].data[1]][1]; HighlightSelectedSearchMenuItem(gTasks[taskId].data[0], gTasks[taskId].data[1]); } - if ((gMain.newKeys & DPAD_UP) && r6[gTasks[taskId].data[1]][2] != 0xFF) + if (JOY_NEW(DPAD_UP) && r6[gTasks[taskId].data[1]][2] != 0xFF) { PlaySE(SE_SELECT); gTasks[taskId].data[1] = r6[gTasks[taskId].data[1]][2]; HighlightSelectedSearchMenuItem(gTasks[taskId].data[0], gTasks[taskId].data[1]); } - if ((gMain.newKeys & DPAD_DOWN) && r6[gTasks[taskId].data[1]][3] != 0xFF) + if (JOY_NEW(DPAD_DOWN) && r6[gTasks[taskId].data[1]][3] != 0xFF) { PlaySE(SE_SELECT); gTasks[taskId].data[1] = r6[gTasks[taskId].data[1]][3]; @@ -4955,7 +4955,7 @@ static void Task_WaitAndCompleteSearch(u8 taskId) static void Task_SearchCompleteWaitForInput(u8 taskId) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if (gPokedexView->pokemonListCount != 0) { @@ -5010,7 +5010,7 @@ static void Task_HandleSearchParameterInput(u8 taskId) p1 = (u16 *)&gTasks[taskId].data[sSearchOptions[r1].taskDataCursorPos]; p2 = (u16 *)&gTasks[taskId].data[sSearchOptions[r1].taskDataScrollOffset]; r2 = sSearchOptions[r1].numOptions - 1; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { sub_814ADC8(); PlaySE(SE_PIN); @@ -5019,7 +5019,7 @@ static void Task_HandleSearchParameterInput(u8 taskId) gTasks[taskId].func = Task_SwitchToSearchMenu; return; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { sub_814ADC8(); PlaySE(SE_BALL); @@ -5031,7 +5031,7 @@ static void Task_HandleSearchParameterInput(u8 taskId) return; } r3 = FALSE; - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { if (*p1 != 0) { @@ -5054,7 +5054,7 @@ static void Task_HandleSearchParameterInput(u8 taskId) } return; } - if (gMain.newAndRepeatedKeys & DPAD_DOWN) + if (JOY_REPT(DPAD_DOWN)) { if (*p1 < 5 && *p1 < r2) { diff --git a/src/pokedex_area_screen.c b/src/pokedex_area_screen.c index 0caad300d..abae23102 100644 --- a/src/pokedex_area_screen.c +++ b/src/pokedex_area_screen.c @@ -1142,11 +1142,11 @@ static void DebugCB_WaitButton(void) switch (gPokedexAreaScreenPtr->state) { case 0: - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { SetCallback(DebugCB_GoBack); } - else if (gMain.newKeys & DPAD_RIGHT || (gMain.newKeys & R_BUTTON && gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) + else if (JOY_NEW(DPAD_RIGHT) || (JOY_NEW(R_BUTTON) && gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) { SetCallback(DebugCB_GoNext); } @@ -1277,12 +1277,12 @@ static void Task_PokedexAreaScreen_1(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 && gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) + else if (JOY_NEW(DPAD_RIGHT) || (JOY_NEW(R_BUTTON) && gSaveBlock2.optionsButtonMode == OPTIONS_BUTTON_MODE_LR)) { gTasks[taskId].data[1] = 2; PlaySE(SE_DEX_PAGE); diff --git a/src/pokemon_menu.c b/src/pokemon_menu.c index 1beace421..f1633fded 100644 --- a/src/pokemon_menu.c +++ b/src/pokemon_menu.c @@ -279,25 +279,25 @@ static void sub_8089D94(u8 taskID) { if (!gPaletteFade.active) { - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) + if (JOY_REPT(DPAD_ANY) == DPAD_UP) { PlaySE(SE_SELECT); sPokeMenuCursorPos = Menu_MoveCursor(-1); sub_808B5B4(taskID); } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) + else if (JOY_REPT(DPAD_ANY) == DPAD_DOWN) { PlaySE(SE_SELECT); sPokeMenuCursorPos = Menu_MoveCursor(1); sub_808B5B4(taskID); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); sPokemonMenuActions[sPokeMenuOptionsOrder[sPokeMenuCursorPos]].func(taskID); sub_808B5B4(taskID); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PokemonMenu_Cancel(taskID); sub_808B5B4(taskID); @@ -389,12 +389,12 @@ static void sub_808A060(u8 taskID) sPokeMenuCursorPos = Menu_MoveCursor(1); PlaySE(SE_SELECT); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); PartyMenuGetPopupMenuFunc(0, &sUnknown_0839F578, sPokemonMenuActions, sPokeMenuCursorPos)(taskID); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { ClosePartyPopupMenu(0, &sUnknown_0839F578); PokemonMenu_CancelSubmenu(taskID); @@ -644,12 +644,12 @@ static void sub_808A73C(u8 taskID) else sPokeMenuCursorPos = Menu_MoveCursor(1); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); PartyMenuGetPopupMenuFunc(0, &sUnknown_0839F584, sPokemonMenuActions, sPokeMenuCursorPos)(taskID); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { ClosePartyPopupMenu(0, &sUnknown_0839F584); PokemonMenu_Cancel(taskID); @@ -760,7 +760,7 @@ static void PokemonMenu_FieldMove(u8 taskID) static void sub_808AAF0(u8 taskID) { - if (gPartyMenuMessage_IsPrinting != 1 && (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON)) + if (gPartyMenuMessage_IsPrinting != 1 && (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON))) { Menu_EraseWindowRect(0, 14, 29, 19); PokemonMenu_Cancel(taskID); @@ -799,7 +799,7 @@ static void FieldCallback_AfterFadeInFromMenu(u8 taskID) static void sub_808ABF4(u8 taskID) { - if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { Menu_EraseWindowRect(1, 17, 28, 18); PokemonMenu_Cancel(taskID); diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index a2f384406..3bcaac984 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -268,10 +268,10 @@ void Task_PokemonStorageSystem(u8 taskId) { case -2: 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] = 3; - if (gMain.newKeys & DPAD_DOWN && ++task->data[3] > 3) + if (JOY_NEW(DPAD_DOWN) && ++task->data[3] > 3) task->data[3] = 0; if (task->data[1] != task->data[3]) { @@ -310,13 +310,13 @@ void Task_PokemonStorageSystem(u8 taskId) } break; case 3: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { StorageSystemClearMessageWindow(); Menu_PrintText(gUnknown_083B600C[task->data[1]].desc, 2, 15); task->data[0] = 2; } - else if (gMain.newKeys & DPAD_UP) + else if (JOY_NEW(DPAD_UP)) { if (--task->data[1] < 0) task->data[1] = 3; @@ -326,7 +326,7 @@ void Task_PokemonStorageSystem(u8 taskId) Menu_PrintText(gUnknown_083B600C[task->data[1]].desc, 2, 15); 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; @@ -612,22 +612,22 @@ void sub_809635C(void) u8 sub_8096368(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_02038478->curBox; } - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { PlaySE(SE_SELECT); sub_809662C(); } - else if (gMain.newKeys & DPAD_RIGHT) + else if (JOY_NEW(DPAD_RIGHT)) { PlaySE(SE_SELECT); sub_80965F8(); diff --git a/src/pokemon_storage_system_2.c b/src/pokemon_storage_system_2.c index 4ba25dd30..d19331904 100644 --- a/src/pokemon_storage_system_2.c +++ b/src/pokemon_storage_system_2.c @@ -579,7 +579,7 @@ void sub_8096C84(void) } break; case 3: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { sub_8098A5C(); gPokemonStorageSystemPtr->unk_0004 = 0; @@ -596,7 +596,7 @@ void sub_8096C84(void) gPokemonStorageSystemPtr->unk_0004 = 6; break; case 6: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { sub_8098A5C(); SetPSSCallback(sub_8096C84); @@ -766,7 +766,7 @@ void sub_8097078(void) gPokemonStorageSystemPtr->unk_0004 = 5; break; case 5: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { sub_8098A5C(); SetPSSCallback(sub_8096C84); @@ -851,7 +851,7 @@ void sub_8097390(void) } break; case 1: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { sub_8098A5C(); SetPSSCallback(sub_8096C84); @@ -938,7 +938,7 @@ void sub_809746C(void) } break; case 4: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { PrintStorageActionText(PC_TEXT_DEPOSIT_IN_WHICH_BOX); gPokemonStorageSystemPtr->unk_0004 = 1; @@ -999,14 +999,14 @@ void sub_8097594(void) gPokemonStorageSystemPtr->unk_0004++; break; case 4: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { PrintStorageActionText(PC_TEXT_BYE_BYE); gPokemonStorageSystemPtr->unk_0004++; } break; case 5: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { sub_8098A5C(); if (gUnknown_0203847C) @@ -1038,14 +1038,14 @@ void sub_8097594(void) gPokemonStorageSystemPtr->unk_0004++; break; case 9: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { PrintStorageActionText(PC_TEXT_SURPRISE); gPokemonStorageSystemPtr->unk_0004++; } break; case 10: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { sub_8098A5C(); sub_8099958(); @@ -1061,14 +1061,14 @@ void sub_8097594(void) } break; case 12: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { PrintStorageActionText(PC_TEXT_WORRIED); gPokemonStorageSystemPtr->unk_0004++; } break; case 13: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { sub_8098A5C(); SetPSSCallback(sub_8096C84); @@ -1318,7 +1318,7 @@ void sub_8097BA0(void) } break; case 1: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { sub_8098A5C(); SetPSSCallback(sub_8096C84); @@ -1377,7 +1377,7 @@ void sub_8097CC0(void) } break; case 1: - if (gMain.newKeys & (A_BUTTON | B_BUTTON | DPAD_ANY)) + if (JOY_NEW(A_BUTTON | B_BUTTON | DPAD_ANY)) { sub_8098A5C(); SetPSSCallback(sub_8096C84); diff --git a/src/pokemon_storage_system_4.c b/src/pokemon_storage_system_4.c index 48fdf425a..27c5bd1c5 100644 --- a/src/pokemon_storage_system_4.c +++ b/src/pokemon_storage_system_4.c @@ -2103,16 +2103,16 @@ u8 sub_809C85C(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 (gSaveBlock2.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; } diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index 3abdbb70d..3b88f03be 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -942,30 +942,30 @@ static void SummaryScreenHandleKeyInput(u8 taskId) if (gPaletteFade.active) return; - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { SummaryScreenHandleUpDownInput(taskId, -1); } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { SummaryScreenHandleUpDownInput(taskId, 1); } - else if ((gMain.newKeys & DPAD_LEFT) || sub_80F9284() == 1) + else if (JOY_NEW(DPAD_LEFT) || sub_80F9284() == 1) { SummaryScreenHandleLeftRightInput(taskId, -1); } - else if ((gMain.newKeys & DPAD_RIGHT) || sub_80F9284() == 2) + else if (JOY_NEW(DPAD_RIGHT) || sub_80F9284() == 2) { SummaryScreenHandleLeftRightInput(taskId, 1); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { if (pssData.page >= PSS_PAGE_BATTLE_MOVES) SummaryScreenHandleAButton(taskId); if (pssData.page == PSS_PAGE_INFO) SummaryScreenExit(taskId); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { SummaryScreenExit(taskId); } @@ -976,23 +976,23 @@ static void sub_809E260(u8 taskId) if (gPaletteFade.active) return; - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { gTasks[taskId].data[0] = 4; sub_809E8F0(taskId, -1, &pssData.selectedMoveIndex); } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { gTasks[taskId].data[0] = 4; sub_809E8F0(taskId, 1, &pssData.selectedMoveIndex); } - else if ((gMain.newKeys & DPAD_LEFT) || sub_80F9284() == 1) + else if (JOY_NEW(DPAD_LEFT) || sub_80F9284() == 1) { if (pssData.page == PSS_PAGE_CONTEST_MOVES && (pssData.selectedMoveIndex != 4 || pssData.moveToLearn != 0)) Menu_EraseWindowRect(0, 14, 9, 18); SummaryScreenHandleLeftRightInput(taskId, -1); } - else if ((gMain.newKeys & DPAD_RIGHT) || sub_80F9284() == 2) + else if (JOY_NEW(DPAD_RIGHT) || sub_80F9284() == 2) { if (pssData.page != pssData.lastPage) { @@ -1001,7 +1001,7 @@ static void sub_809E260(u8 taskId) SummaryScreenHandleLeftRightInput(taskId, 1); } } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { if (SummaryScreen_CanForgetSelectedMove(taskId) == TRUE || pssData.selectedMoveIndex == 4) { @@ -1015,7 +1015,7 @@ static void sub_809E260(u8 taskId) sub_809F9D0(taskId, pssData.selectedMoveIndex); } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { pssData.switchMoveIndex = 4; gSpecialVar_0x8005 = pssData.switchMoveIndex; @@ -1028,17 +1028,17 @@ static void SummaryScreen_MoveSelect_HandleInput(u8 taskId) if (gPaletteFade.active) return; - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { gTasks[taskId].data[0] = 4; sub_809E8F0(taskId, -1, &pssData.selectedMoveIndex); } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { gTasks[taskId].data[0] = 4; sub_809E8F0(taskId, 1, &pssData.selectedMoveIndex); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { if (pssData.selectedMoveIndex != 4 && !pssData.disableMoveOrderEditing) { @@ -1063,7 +1063,7 @@ static void SummaryScreen_MoveSelect_HandleInput(u8 taskId) SummaryScreen_MoveSelect_Cancel(taskId); } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); SummaryScreen_MoveSelect_Cancel(taskId); @@ -1086,21 +1086,21 @@ static bool8 MonKnowsMultipleMoves(struct Pokemon *mon) static void sub_809E534(u8 taskId) { - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { gTasks[taskId].data[0] = 3; sub_809E8F0(taskId, -1, &pssData.switchMoveIndex); } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { gTasks[taskId].data[0] = 3; sub_809E8F0(taskId, 1, &pssData.switchMoveIndex); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { sub_809E83C(taskId, 1); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { sub_809E83C(taskId, -1); } @@ -1908,7 +1908,7 @@ void sub_809F814(u8 taskId) { taskData[14]++; } - else if (gMain.newKeys & DPAD_UP) + else if (JOY_NEW(DPAD_UP)) { gTasks[taskId].func = sub_809E260; taskData[0] = 4; @@ -1916,7 +1916,7 @@ void sub_809F814(u8 taskId) pssData.selectedMoveIndex = taskData[15]; sub_809E8F0(taskId, -1, &pssData.selectedMoveIndex); } - else if (gMain.newKeys & DPAD_DOWN) + else if (JOY_NEW(DPAD_DOWN)) { gTasks[taskId].func = sub_809E260; taskData[0] = 4; @@ -1924,7 +1924,7 @@ void sub_809F814(u8 taskId) pssData.selectedMoveIndex = taskData[15]; sub_809E8F0(taskId, 1, &pssData.selectedMoveIndex); } - else if ((gMain.newKeys & DPAD_LEFT) || sub_80F9284() == 1) + else if (JOY_NEW(DPAD_LEFT) || sub_80F9284() == 1) { if (pssData.page != PSS_PAGE_BATTLE_MOVES) { @@ -1938,7 +1938,7 @@ void sub_809F814(u8 taskId) sub_80A1654(1, taskData[15]); } } - else if ((gMain.newKeys & DPAD_RIGHT) || sub_80F9284() == 2) + else if (JOY_NEW(DPAD_RIGHT) || sub_80F9284() == 2) { if (pssData.page != pssData.lastPage) { @@ -1952,7 +1952,7 @@ void sub_809F814(u8 taskId) sub_80A1654(1, taskData[15]); } } - else if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + else if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { sub_80A1488(2, taskData[15]); sub_80A1654(2, taskData[15]); diff --git a/src/pokenav.c b/src/pokenav.c index 77b8f57ef..a26019ffe 100644 --- a/src/pokenav.c +++ b/src/pokenav.c @@ -4483,19 +4483,19 @@ void sub_80F5CDC(u8 a0) u8 sub_80F5DD4(void) { - if (({gMain.newAndRepeatedKeys & DPAD_UP;})) + if (JOY_REPT(DPAD_UP)) { return sub_80F5E20(); } - else if (({gMain.newAndRepeatedKeys & DPAD_DOWN;})) + else if (JOY_REPT(DPAD_DOWN)) { return sub_80F5EE4(); } - else if (({gMain.newAndRepeatedKeys & DPAD_LEFT;})) + else if (JOY_REPT(DPAD_LEFT)) { return sub_80F5FB4(); } - else if (({gMain.newAndRepeatedKeys & DPAD_RIGHT;})) + else if (JOY_REPT(DPAD_RIGHT)) { return sub_80F6010(); } @@ -4952,7 +4952,7 @@ u8 sub_80F68E8(void) s8 r12 = 1; do { - if (({gMain.newAndRepeatedKeys & DPAD_UP;}) && r4 > 0) + if (JOY_REPT(DPAD_UP) && r4 > 0) { while (r4 > 0) { @@ -4968,7 +4968,7 @@ u8 sub_80F68E8(void) } r4 = gPokenavStructPtr->unkBC91; } - if (({gMain.newAndRepeatedKeys & DPAD_DOWN;}) && r4 < 3) + if (JOY_REPT(DPAD_DOWN) && r4 < 3) { while (r4 < 3) { @@ -4984,7 +4984,7 @@ u8 sub_80F68E8(void) } r4 = gPokenavStructPtr->unkBC91; } - if (({gMain.newAndRepeatedKeys & DPAD_LEFT;})) + if (JOY_REPT(DPAD_LEFT)) { if (r5 > 0) { @@ -4992,7 +4992,7 @@ u8 sub_80F68E8(void) break; } } - if (({gMain.newAndRepeatedKeys & DPAD_RIGHT;})) + if (JOY_REPT(DPAD_RIGHT)) { if (r5 < gPokenavStructPtr->unkBC96[r4] - 1) { diff --git a/src/pokenav_before.c b/src/pokenav_before.c index 806b91d94..d0a5dc484 100644 --- a/src/pokenav_before.c +++ b/src/pokenav_before.c @@ -1485,7 +1485,7 @@ void sub_80EC268() } else { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { gPokenavStructPtr->unk6DDC = gPokenavStructPtr->unk6DAD; switch (gPokenavStructPtr->unk6DB2[gPokenavStructPtr->unk6DDC] - 1) @@ -1509,7 +1509,7 @@ void sub_80EC268() break; } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { gPokenavStructPtr->unk304 = 1; } @@ -1565,7 +1565,7 @@ void sub_80EC268() gPokenavStructPtr->unk304 = 0; sub_80EED9C(); } - else if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + else if (JOY_NEW(A_BUTTON | B_BUTTON)) { sub_80EF428(0, gPokenavStructPtr->unk6DAD); gPokenavStructPtr->unk304 = var1; @@ -1766,7 +1766,7 @@ void sub_80EC86C() sub_80EF428(1, gPokenavStructPtr->unk6DAD); sub_80EED9C(); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); gPokenavStructPtr->unk6DF0 = gPokenavStructPtr->unk6DAD; @@ -1783,7 +1783,7 @@ void sub_80EC86C() break; } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); gPokenavStructPtr->unk6DF0 = 0x2; @@ -1919,7 +1919,7 @@ void sub_80ECC08() sub_80EF428(2, gPokenavStructPtr->unk6DAD); sub_80EED9C(); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); switch ((s8)gPokenavStructPtr->unk6DAD) @@ -1948,7 +1948,7 @@ void sub_80ECC08() gPokenavStructPtr->unk76AA = 1; sub_80EBDBC(&sub_80ED01C); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); gPokenavStructPtr->unk6DAD = 0x5; @@ -2204,13 +2204,13 @@ void sub_80ED31C() gPokenavStructPtr->unk304++; return; default: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); sub_80EBDBC(&sub_80ED4D8); return; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sub_80EBDBC(&sub_80ECD80); @@ -2478,7 +2478,7 @@ void sub_80ED858(void) } break; case 4: - if (({gMain.heldKeys & DPAD_UP;})) + if (JOY_HELD(DPAD_UP)) { if (gPokenavStructPtr->unk87CB && ( gPokenavStructPtr->unk76AA == 0 @@ -2492,7 +2492,7 @@ void sub_80ED858(void) break; } } - if (({gMain.heldKeys & DPAD_DOWN;})) + if (JOY_HELD(DPAD_DOWN)) { if (gPokenavStructPtr->unk87CB && ( gPokenavStructPtr->unk76AA == 0 @@ -2506,7 +2506,7 @@ void sub_80ED858(void) break; } } - if (({gMain.newKeys & B_BUTTON;})) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sub_80F4FDC(); @@ -2514,7 +2514,7 @@ void sub_80ED858(void) gPokenavStructPtr->unk304 = 9; break; } - if (({gMain.newKeys & A_BUTTON;})) + if (JOY_NEW(A_BUTTON)) { if (gPokenavStructPtr->unk76AA == 0) { @@ -2708,13 +2708,13 @@ void sub_80EDDBC() gPokenavStructPtr->unk304++; return; default: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); sub_80EBDBC(&sub_80EDEE4); return; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sub_80EBDBC(&sub_80EDE70); @@ -2836,25 +2836,25 @@ void sub_80EE06C() gPokenavStructPtr->unk304++; break; case 1: - if ((gMain.newAndRepeatedKeys & 0x40) && (gPokenavStructPtr->unk87DC)) + if (JOY_REPT(0x40) && (gPokenavStructPtr->unk87DC)) { PlaySE(SE_SELECT); sub_80F6A4C(-1); gPokenavStructPtr->unk304++; } - else if ((gMain.newAndRepeatedKeys & 0x80) && gPokenavStructPtr->unk87DC < gPokenavStructPtr->unk8774) + else if (JOY_REPT(0x80) && gPokenavStructPtr->unk87DC < gPokenavStructPtr->unk8774) { PlaySE(SE_SELECT); sub_80F6A4C(1); gPokenavStructPtr->unk304++; } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); sub_80EEFBC(0xB); gPokenavStructPtr->unk304 = 0x4; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sub_80EBDBC(&sub_80EE294); @@ -2890,7 +2890,7 @@ void sub_80EE06C() return; default: case 0: - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sub_80F3B94(); @@ -3068,13 +3068,13 @@ void sub_80EE58C() gPokenavStructPtr->unk304++; return; default: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); sub_80EBDBC(&sub_80EE658); return; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sub_80EBDBC(&sub_80EE8F4); @@ -3144,19 +3144,19 @@ void sub_80EE658() gPokenavStructPtr->unk304++; break; case 8: - if ((gMain.heldKeys & 0x40) && gPokenavStructPtr->unk87DC) + if (JOY_HELD(0x40) && gPokenavStructPtr->unk87DC) { PlaySE(SE_SELECT); sub_80F708C(-1); gPokenavStructPtr->unk304 = 0x10; } - else if ((gMain.heldKeys & 0x80) && gPokenavStructPtr->unk87DC < gPokenavStructPtr->unk8774) + else if (JOY_HELD(0x80) && gPokenavStructPtr->unk87DC < gPokenavStructPtr->unk8774) { PlaySE(SE_SELECT); sub_80F708C(1); gPokenavStructPtr->unk304 = 0x10; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sub_80F4394(); @@ -3337,7 +3337,7 @@ bool8 sub_80EEA0C(void) // var6dad and var6dae must be s8 in this func bool8 sub_80EEC10() { - if (gMain.newKeys & 0x40) + if (JOY_NEW(DPAD_UP)) { do { @@ -3346,7 +3346,7 @@ bool8 sub_80EEC10() } while (!gPokenavStructPtr->unk6DB2[gPokenavStructPtr->unk6DAD]); return TRUE; } - if (gMain.newKeys & 0x80) + if (JOY_NEW(DPAD_DOWN)) { do { @@ -3364,13 +3364,13 @@ bool8 sub_80EEC10() bool8 sub_80EEC90() { - if (gMain.newKeys & 0x40) + if (JOY_NEW(DPAD_UP)) { if (--gPokenavStructPtr->unk6DAD < 0) gPokenavStructPtr->unk6DAD = gPokenavStructPtr->unk6DAE - 1; return TRUE; } - if (gMain.newKeys & 0x80) + if (JOY_NEW(DPAD_DOWN)) { if (++gPokenavStructPtr->unk6DAD >= gPokenavStructPtr->unk6DAE) gPokenavStructPtr->unk6DAD = 0; diff --git a/src/region_map.c b/src/region_map.c index 5cd65432a..b0ba059b6 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -211,30 +211,30 @@ static u8 sub_80FAB78(void) 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; event = INPUT_EVENT_DPAD; } - if ((gMain.heldKeys & DPAD_DOWN) && gRegionMap->cursorPosY < MAPCURSOR_Y_MAX) + if (JOY_HELD(DPAD_DOWN) && gRegionMap->cursorPosY < MAPCURSOR_Y_MAX) { gRegionMap->cursorDeltaY = 1; event = INPUT_EVENT_DPAD; } - if ((gMain.heldKeys & DPAD_LEFT) && gRegionMap->cursorPosX > MAPCURSOR_X_MIN) + if (JOY_HELD(DPAD_LEFT) && gRegionMap->cursorPosX > MAPCURSOR_X_MIN) { gRegionMap->cursorDeltaX = -1; event = INPUT_EVENT_DPAD; } - if ((gMain.heldKeys & DPAD_RIGHT) && gRegionMap->cursorPosX < MAPCURSOR_X_MAX) + if (JOY_HELD(DPAD_RIGHT) && gRegionMap->cursorPosX < MAPCURSOR_X_MAX) { gRegionMap->cursorDeltaX = 1; event = INPUT_EVENT_DPAD; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) event = INPUT_EVENT_A_BUTTON; - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) event = INPUT_EVENT_B_BUTTON; if (event == INPUT_EVENT_DPAD) @@ -282,30 +282,30 @@ static u8 sub_80FAD04(void) gRegionMap->unk6A = 0; gRegionMap->unk68 = 0; - if ((gMain.heldKeys & DPAD_UP) && gRegionMap->scrollY > -52) + if (JOY_HELD(DPAD_UP) && gRegionMap->scrollY > -52) { gRegionMap->unk68 = -1; event = INPUT_EVENT_DPAD; } - if ((gMain.heldKeys & DPAD_DOWN) && gRegionMap->scrollY < 60) + if (JOY_HELD(DPAD_DOWN) && gRegionMap->scrollY < 60) { gRegionMap->unk68 = 1; event = INPUT_EVENT_DPAD; } - if ((gMain.heldKeys & DPAD_LEFT) && gRegionMap->scrollX > -44) + if (JOY_HELD(DPAD_LEFT) && gRegionMap->scrollX > -44) { gRegionMap->unk6A = -1; event = INPUT_EVENT_DPAD; } - if ((gMain.heldKeys & DPAD_RIGHT) && gRegionMap->scrollX < 172) + if (JOY_HELD(DPAD_RIGHT) && gRegionMap->scrollX < 172) { gRegionMap->unk6A = 1; event = INPUT_EVENT_DPAD; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) event = INPUT_EVENT_A_BUTTON; - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) event = INPUT_EVENT_B_BUTTON; if (event == INPUT_EVENT_DPAD) @@ -1724,7 +1724,7 @@ void debug_sub_8110D84(void) { debug_sub_8110CCC(); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { sub_80FBCA0(); sub_80FAEC4(); @@ -1743,7 +1743,7 @@ void debug_sub_8110D84(void) { debug_sub_8110CCC(); } - if (gMain.newKeys & A_BUTTON) // no "else if" like above? + if (JOY_NEW(A_BUTTON)) // no "else if" like above? { sub_80FBCA0(); sub_80FAEC4(); diff --git a/src/reset_rtc_screen.c b/src/reset_rtc_screen.c index ee207582b..9328a28ad 100644 --- a/src/reset_rtc_screen.c +++ b/src/reset_rtc_screen.c @@ -349,7 +349,7 @@ void Task_ResetRtc_1(u8 taskId) u8 selection = data[2]; const struct ResetRtcStruct *selectionInfo = &gUnknown_08376420[selection - 1]; - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { gTasks[taskId].func = Task_ResetRtc_2; data[1] = 0; @@ -358,7 +358,7 @@ void Task_ResetRtc_1(u8 taskId) return; } - if (gMain.newKeys & DPAD_RIGHT) + if (JOY_NEW(DPAD_RIGHT)) { if (selectionInfo->right) { @@ -368,7 +368,7 @@ void Task_ResetRtc_1(u8 taskId) } } - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { if (selectionInfo->left) { @@ -380,7 +380,7 @@ 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]; @@ -392,7 +392,7 @@ void Task_ResetRtc_1(u8 taskId) data[2] = 6; } } - else if (ResetRtcScreen_MoveTimeUpDown(&data[selectionInfo->dataIndex], selectionInfo->minVal, selectionInfo->maxVal, gMain.newAndRepeatedKeys & (DPAD_UP | DPAD_DOWN))) + else if (ResetRtcScreen_MoveTimeUpDown(&data[selectionInfo->dataIndex], selectionInfo->minVal, selectionInfo->maxVal, JOY_REPT(DPAD_UP | DPAD_DOWN))) { PlaySE(SE_SELECT); ResetRtcScreen_PrintTime(4, 9, data[3], data[4], data[5], data[6]); @@ -483,12 +483,12 @@ void Task_ShowResetRtcPrompt(u8 taskId) ResetRtcScreen_ShowMessage(gSystemText_ResetRTCPrompt); 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); @@ -572,7 +572,7 @@ void Task_ResetRtcScreen(u8 taskId) data[0] = 5; // fall through case 5: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFFF, 1, 0, 16, FADE_COLOR_WHITE); data[0] = 6; @@ -679,7 +679,7 @@ void debug_sub_806F9E4(u8 taskId) } else { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { Menu_EraseScreen(); DestroyTask(taskId); diff --git a/src/roulette.c b/src/roulette.c index 34f0fa7b6..8178ba3ae 100644 --- a/src/roulette.c +++ b/src/roulette.c @@ -541,7 +541,7 @@ void sub_8115634(u8 taskId) eRoulette->var2C.b = sin; eRoulette->var2C.c = -sin; #if DEBUG - if (unk_203955C[0] != 0 && (gMain.newKeys & START_BUTTON)) + if (unk_203955C[0] != 0 && JOY_NEW(START_BUTTON)) { gTasks[eRoulette->varA4].func = sub_81157AC; m4aMPlayStop(&gMPlayInfo_SE1); @@ -701,25 +701,25 @@ void sub_8115B58(u8 r0) { u8 z = 0; bool8 var0 = FALSE; - if (gMain.newKeys & DPAD_UP) + if (JOY_NEW(DPAD_UP)) { var0 = TRUE; if (!sub_8115A94(&gTasks[r0].data[4], 0)) return; } - if (gMain.newKeys & DPAD_DOWN) + if (JOY_NEW(DPAD_DOWN)) { var0 = TRUE; if (!sub_8115A94(&gTasks[r0].data[4], 1)) return; } - if (gMain.newKeys & DPAD_LEFT) + if (JOY_NEW(DPAD_LEFT)) { var0 = TRUE; if (!sub_8115A94(&gTasks[r0].data[4], 2)) return; } - if (gMain.newKeys & DPAD_RIGHT) + if (JOY_NEW(DPAD_RIGHT)) { var0 = TRUE; if (!sub_8115A94(&gTasks[r0].data[4], 3)) @@ -795,7 +795,7 @@ void sub_8115E14(u8 taskid) default: gTasks[taskid].data[1]++; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { if ((eRoulette->var08 & gUnknown_083F8C00[gTasks[taskid].data[4]].var08)) PlaySE(SE_BOO); @@ -1010,7 +1010,7 @@ void sub_811637C(u8 taskid) } if (gTasks[taskid].data[1] < 61) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) gTasks[taskid].data[1] = 60; gTasks[taskid].data[1]++; } @@ -1274,7 +1274,7 @@ void sub_8116B40(u8 taskId) // end roulette ? void sub_8116BC0(u8 taskid) { - if (eRoulette->varA8 == 0 || gMain.newKeys & eRoulette->varAA) + if (eRoulette->varA8 == 0 || JOY_NEW(eRoulette->varAA)) { gTasks[taskid].func = eRoulette->varAC; if (eRoulette->varAA > 0) @@ -1605,7 +1605,7 @@ void sub_81175C0(u8 taskid) void sub_81175DC(u8 taskid) { gTasks[taskid].data[0]++; - if (!(gMain.newKeys & (A_BUTTON | B_BUTTON)) && gTasks[taskid].data[0] < 61) + if (!JOY_NEW(A_BUTTON | B_BUTTON) && gTasks[taskid].data[0] < 61) return; gSpecialVar_0x8004 = 1; Menu_EraseScreen(); @@ -1673,7 +1673,7 @@ void debug_sub_812CDE4(u8 taskId) u8 coinText[] = {0xFD, 0x02, 0xFF}; #endif - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { gTasks[taskId].data[13]++; if (gTasks[taskId].data[13] == 10000) @@ -1687,7 +1687,7 @@ void debug_sub_812CDE4(u8 taskId) MenuPrint_RightAligned(gStringVar4, 9, 1); #endif } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { gTasks[taskId].data[13]--; if (gTasks[taskId].data[13] == -1) @@ -1701,7 +1701,7 @@ void debug_sub_812CDE4(u8 taskId) MenuPrint_RightAligned(gStringVar4, 9, 1); #endif } - else if (gMain.newKeys & R_BUTTON) + else if (JOY_NEW(R_BUTTON)) { gTasks[taskId].data[13] += 10; if (gTasks[taskId].data[13] > 9999) @@ -1715,7 +1715,7 @@ void debug_sub_812CDE4(u8 taskId) MenuPrint_RightAligned(gStringVar4, 9, 1); #endif } - else if (gMain.newKeys & L_BUTTON) + else if (JOY_NEW(L_BUTTON)) { gTasks[taskId].data[13] -= 10; if (gTasks[taskId].data[13] < 0) @@ -1729,7 +1729,7 @@ void debug_sub_812CDE4(u8 taskId) MenuPrint_RightAligned(gStringVar4, 9, 1); #endif } - else if (gMain.newKeys & START_BUTTON) + else if (JOY_NEW(START_BUTTON)) { gSaveBlock1.coins = gTasks[taskId].data[13]; gTasks[taskId].func = Task_Roulette_0; @@ -1743,7 +1743,7 @@ void debug_sub_812CDE4(u8 taskId) #endif unk_2039560 = 0; } - else if (gMain.newKeys & SELECT_BUTTON) + else if (JOY_NEW(SELECT_BUTTON)) { gSaveBlock1.coins = gTasks[taskId].data[13]; gTasks[taskId].func = Task_Roulette_0; diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c index 9ef5f541c..3eff4b6af 100644 --- a/src/save_failed_screen.c +++ b/src/save_failed_screen.c @@ -209,7 +209,7 @@ static void CB2_GameplayCannotBeContinued(void) { gSaveFailedClockInfo[0] = FALSE; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { Menu_DrawStdWindowFrame(1, MSG_WIN_TOP, 28, 19); Menu_PrintText(gSystemText_GameplayEnded, 2, MSG_WIN_TOP + 1); @@ -222,7 +222,7 @@ static void CB2_FadeAndReturnToTitleScreen(void) { gSaveFailedClockInfo[0] = FALSE; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); SetVBlankCallback(VBlankCB); diff --git a/src/scrcmd.c b/src/scrcmd.c index b369c49b0..417695503 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -1261,9 +1261,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/secret_base.c b/src/secret_base.c index e5781e218..754e2e925 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -902,7 +902,7 @@ void sub_80BC824(u8 taskId) { s16 *taskData = gTasks[taskId].data; - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { if (taskData[1]) { @@ -916,7 +916,7 @@ void sub_80BC824(u8 taskId) sub_80BC6B0(taskId); } } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { if (taskData[1] == taskData[3]) { @@ -933,7 +933,7 @@ void sub_80BC824(u8 taskId) taskData[1] = Menu_MoveCursor(1); } } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (taskData[1] + taskData[2] == taskData[0]) @@ -949,7 +949,7 @@ void sub_80BC824(u8 taskId) sub_80BC980(taskId); } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); Menu_DestroyCursor(); @@ -991,7 +991,7 @@ void sub_80BC980(u8 taskId) void sub_80BC9E4(u8 taskId) { - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { if (Menu_GetCursorPos()) { @@ -999,7 +999,7 @@ void sub_80BC9E4(u8 taskId) Menu_MoveCursor(-1); } } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { if (Menu_GetCursorPos() != 1) { @@ -1007,12 +1007,12 @@ void sub_80BC9E4(u8 taskId) Menu_MoveCursor(1); } } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); gUnknown_083D13D4[Menu_GetCursorPos()].func(taskId); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sub_80BCBF8(taskId); diff --git a/src/shop.c b/src/shop.c index 34086958e..1f9658a23 100644 --- a/src/shop.c +++ b/src/shop.c @@ -133,7 +133,7 @@ static void Task_DoBuySellMenu(u8 taskId) { const u8 taskIdConst = taskId; // why is a local const needed to match? - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { if (gMartInfo.cursor) // can move cursor up? { @@ -141,7 +141,7 @@ static void Task_DoBuySellMenu(u8 taskId) gMartInfo.cursor = Menu_MoveCursor(-1); } } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { if (gMartInfo.cursor != gMartInfo.numChoices) // can move cursor down? { @@ -149,7 +149,7 @@ static void Task_DoBuySellMenu(u8 taskId) gMartInfo.cursor = Menu_MoveCursor(1); } } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (gMartInfo.martType == MART_TYPE_0) @@ -157,7 +157,7 @@ static void Task_DoBuySellMenu(u8 taskId) else sBuySellQuitMenuActions[gMartBuyNoSellOptionList[gMartInfo.cursor]].func(taskIdConst); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); Task_HandleShopMenuQuit(taskIdConst); @@ -622,7 +622,7 @@ static void Shop_PrintItemDescText(void) static void Shop_DoPremierBallCheck(u8 taskId) { - if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { Shop_DisplayPriceInList(gMartInfo.cursor, gMartInfo.cursor, 0); PlaySE(SE_SELECT); @@ -712,7 +712,7 @@ static void Shop_PrintPrice(u8 taskId) if (SellMenu_QuantityRoller(taskId, gMartInfo.curItemCount) == TRUE) Shop_DisplayPriceInCheckoutWindow(taskId); - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { gMartTotalCost = (ItemId_GetPrice(gMartInfo.itemList[gMartInfo.choicesAbove + gMartInfo.cursor]) >> GetPriceReduction(1)) * gTasks[taskId].tItemCount; // set total cost of your purchase. Menu_EraseWindowRect(0, 0xA, 0xD, 0xD); @@ -725,7 +725,7 @@ static void Shop_PrintPrice(u8 taskId) StringExpandPlaceholders(gStringVar4, gOtherText_ThatWillBe); DisplayItemMessageOnField(taskId, gStringVar4, Shop_DoYesNoPurchase, 0xC3E1); } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { Shop_DisplayPriceInList(gMartInfo.cursor, gMartInfo.cursor, 0); Task_ReturnToBuyMenu(taskId); @@ -1029,7 +1029,7 @@ static void Shop_DoCursorAction(u8 taskId) { if (!gPaletteFade.active) { - if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) // only up can be pressed + if (JOY_REPT(DPAD_ANY) == DPAD_UP) // only up can be pressed { if (gMartInfo.cursor == 0) { @@ -1050,7 +1050,7 @@ static void Shop_DoCursorAction(u8 taskId) Shop_PrintItemDescText(); } } - else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) // only down can be pressed + else if (JOY_REPT(DPAD_ANY) == DPAD_DOWN) // only down can be pressed { if (gMartInfo.cursor == 7) // are you at the bottom of the menu? { @@ -1071,7 +1071,7 @@ static void Shop_DoCursorAction(u8 taskId) Shop_PrintItemDescText(); } } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); @@ -1124,7 +1124,7 @@ static void Shop_DoCursorAction(u8 taskId) Task_ExitBuyMenu(taskId); } } - else if (gMain.newKeys & B_BUTTON) // go back to buy/sell/exit menu + else if (JOY_NEW(B_BUTTON)) // go back to buy/sell/exit menu { PlaySE(SE_SELECT); Task_ExitBuyMenu(taskId); diff --git a/src/slot_machine.c b/src/slot_machine.c index 41b9c42a5..ab590d555 100644 --- a/src/slot_machine.c +++ b/src/slot_machine.c @@ -672,7 +672,7 @@ static bool8 sub_8101E3C(struct Task *task) #if DEBUG if (unk_debug_bss_1_1 != 0 && unk_debug_bss_1_4 != 0) { - if (sSlotMachine->coins <= 3 || (gMain.heldKeys & B_BUTTON)) + if (sSlotMachine->coins <= 3 || JOY_HELD(B_BUTTON)) { unk_debug_bss_1_4 = 0; } @@ -687,7 +687,7 @@ static bool8 sub_8101E3C(struct Task *task) return 0; } } - if (unk_debug_bss_1_1 != 0 && (gMain.newKeys & 8)) + if (unk_debug_bss_1_1 != 0 && JOY_NEW(START_BUTTON)) { debug_sub_811B620(); sSlotMachine->state = 29; @@ -695,12 +695,12 @@ static bool8 sub_8101E3C(struct Task *task) } #endif - if (gMain.newKeys & SELECT_BUTTON) + if (JOY_NEW(SELECT_BUTTON)) { sub_8104AB8(0); sSlotMachine->state = 8; } - else if (gMain.newKeys & R_BUTTON) + else if (JOY_NEW(R_BUTTON)) { if (sSlotMachine->coins - (3 - sSlotMachine->bet) >= 0) { @@ -718,16 +718,16 @@ static bool8 sub_8101E3C(struct Task *task) } else { - if (gMain.newKeys & DPAD_DOWN && sSlotMachine->coins != 0) + if (JOY_NEW(DPAD_DOWN) && sSlotMachine->coins != 0) { PlaySE(SE_SHOP); sub_8103D50(sSlotMachine->bet); sSlotMachine->coins--; sSlotMachine->bet++; } - if (sSlotMachine->bet >= 3 || (sSlotMachine->bet != 0 && gMain.newKeys & A_BUTTON)) + if (sSlotMachine->bet >= 3 || (sSlotMachine->bet != 0 && JOY_NEW(A_BUTTON))) sSlotMachine->state = 9; - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) sSlotMachine->state = 21; } return FALSE; @@ -748,7 +748,7 @@ static bool8 sub_8101F44(struct Task *task) static bool8 sub_8101F60(struct Task *task) { - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { Menu_EraseScreen(); sSlotMachine->state = 5; @@ -834,7 +834,7 @@ static bool8 sub_8102058(struct Task *task) } #endif - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_CONTEST_PLACE); sub_8102E1C(sSlotMachine->unk18); @@ -1088,7 +1088,7 @@ static bool8 sub_810239C(struct Task *task) static bool8 sub_81023B8(struct Task *task) { - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { Menu_EraseScreen(); sSlotMachine->state = 5; @@ -1105,7 +1105,7 @@ static bool8 sub_81023E0(struct Task *task) static bool8 sub_81023FC(struct Task *task) { - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { Menu_EraseScreen(); sSlotMachine->state = 27; @@ -1543,10 +1543,10 @@ static bool8 sub_8102AD0(struct Task *task) if (sSlotMachine->coins < 9999) sSlotMachine->coins++; task->data[1] = 8; - if (gMain.heldKeys & A_BUTTON) + if (JOY_HELD(A_BUTTON)) task->data[1] = 4; } - if (IsFanfareTaskInactive() && gMain.newKeys & START_BUTTON) + if (IsFanfareTaskInactive() && JOY_NEW(START_BUTTON)) { PlaySE(SE_PIN); sSlotMachine->coins += sSlotMachine->payout; @@ -3035,7 +3035,7 @@ static void sub_8104B80(struct Task *task) static void sub_8104BC8(struct Task *task) { - if (gMain.newKeys & (B_BUTTON | SELECT_BUTTON)) + if (JOY_NEW(B_BUTTON | SELECT_BUTTON)) { BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB(0, 0, 0)); task->data[0]++; @@ -5797,13 +5797,13 @@ static void debug_sub_811B654(u8 taskId) task->data[0]++; break; case 1: - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { Menu_EraseScreen(); DestroyTask(taskId); break; } - if (gMain.newKeys & 0x20) + if (JOY_NEW(DPAD_LEFT)) { sSlotMachine->unk01--; if ((s8)sSlotMachine->unk01 < 0) // Why? It's unsigned @@ -5811,7 +5811,7 @@ static void debug_sub_811B654(u8 taskId) debug_sub_811B2E8(); break; } - if (gMain.newKeys & 0x10) + if (JOY_NEW(DPAD_RIGHT)) { sSlotMachine->unk01++; if (sSlotMachine->unk01 > 5) @@ -5819,7 +5819,7 @@ static void debug_sub_811B654(u8 taskId) debug_sub_811B2E8(); break; } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { task->data[0] = 3; Menu_EraseScreen(); @@ -5828,7 +5828,7 @@ static void debug_sub_811B654(u8 taskId) Menu_PrintText(Str_841B264, 1, 3); break; } - if (gMain.newKeys & 4) + if (JOY_NEW(SELECT_BUTTON)) { unk_debug_bss_1_2 = 0; unk_debug_bss_1_3 = 0; @@ -5839,7 +5839,7 @@ static void debug_sub_811B654(u8 taskId) InitMenu(0, 1, 3, 8, 0, 9); task->data[0]++; } - if (gMain.newKeys & 8) + if (JOY_NEW(START_BUTTON)) { unk_debug_bss_1_4 = 1; Menu_EraseScreen(); @@ -5859,35 +5859,35 @@ static void debug_sub_811B654(u8 taskId) DestroyTask(taskId); break; case 3: - if (gMain.newAndRepeatedKeys & 0x80) + if (JOY_REPT(0x80)) { sSlotMachine->coins += 100; if (sSlotMachine->coins > 9999) sSlotMachine->coins = 9999; break; } - if (gMain.newAndRepeatedKeys & 0x40) + if (JOY_REPT(0x40)) { sSlotMachine->coins -= 100; if (sSlotMachine->coins <= 0) sSlotMachine->coins = 9999; break; } - if (gMain.newAndRepeatedKeys & 0x20) + if (JOY_REPT(0x20)) { sSlotMachine->coins -= 1000; if (sSlotMachine->coins <= 0) sSlotMachine->coins = 9999; break; } - if (gMain.newAndRepeatedKeys & 0x10) + if (JOY_REPT(0x10)) { sSlotMachine->coins += 1000; if (sSlotMachine->coins > 9999) sSlotMachine->coins = 9999; break; } - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { Menu_EraseScreen(); DestroyTask(taskId); diff --git a/src/start_menu.c b/src/start_menu.c index 6dc024c1b..a2082a1d9 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -195,7 +195,7 @@ void debug_sub_8075C40(u8 taskId) data[0]++; break; case 3: - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { Menu_EraseScreen(); ScriptContext2_Disable(); @@ -415,17 +415,17 @@ void sub_8071310(void) static u8 StartMenu_InputProcessCallback(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 == StartMenu_PokedexCallback) @@ -440,7 +440,7 @@ static u8 StartMenu_InputProcessCallback(void) FadeScreen(1, 0); return 0; } - if (gMain.newKeys & (START_BUTTON | B_BUTTON)) + if (JOY_NEW(START_BUTTON | B_BUTTON)) { CloseMenu(); return 1; @@ -666,7 +666,7 @@ static void SaveDialogStartTimeout(void) static bool8 SaveDialogCheckForTimeoutOrKeypress(void) { saveDialogTimer--; - if (gMain.heldKeys & A_BUTTON) + if (JOY_HELD(A_BUTTON)) { PlaySE(SE_SELECT); return TRUE; @@ -680,7 +680,7 @@ static bool8 SaveDialogCheckForTimeoutAndKeypress(void) { if (saveDialogTimer != 0) saveDialogTimer--; - else if (gMain.heldKeys & A_BUTTON) + else if (JOY_HELD(A_BUTTON)) return TRUE; return FALSE; } diff --git a/src/starter_choose.c b/src/starter_choose.c index 9cdd26f09..eb10294f5 100644 --- a/src/starter_choose.c +++ b/src/starter_choose.c @@ -364,7 +364,7 @@ static void Task_StarterChoose2(u8 taskId) { u8 selection = gTasks[taskId].tStarterSelection; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { u8 spriteId; @@ -398,12 +398,12 @@ static void Task_StarterChoose2(u8 taskId) } else { - if ((gMain.newKeys & DPAD_LEFT) && selection > 0) + if (JOY_NEW(DPAD_LEFT) && selection > 0) { gTasks[taskId].tStarterSelection--; CreateStarterPokemonLabel(selection, gTasks[taskId].tStarterSelection); } - else if ((gMain.newKeys & DPAD_RIGHT) && selection < 2) + else if (JOY_NEW(DPAD_RIGHT) && selection < 2) { gTasks[taskId].tStarterSelection++; CreateStarterPokemonLabel(selection, gTasks[taskId].tStarterSelection); diff --git a/src/text.c b/src/text.c index 8b4d17d78..b952475af 100644 --- a/src/text.c +++ b/src/text.c @@ -2409,7 +2409,7 @@ static u8 UpdateWindowText(struct Window *win) case WIN_STATE_WAIT_BUTTON: if (PlayerCanInterruptDelay(win)) { - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { PlaySE(SE_SELECT); } @@ -2429,7 +2429,7 @@ static u8 UpdateWindowText(struct Window *win) case WIN_STATE_CHAR_DELAY: // Allow the player to speed up text by holding a button if (PlayerCanInterruptDelay(win) - && (gMain.heldKeys & (A_BUTTON | B_BUTTON)) + && JOY_HELD(A_BUTTON | B_BUTTON) && gMain.watchedKeysPressed == TRUE) { win->delayCounter = 0; @@ -3247,7 +3247,7 @@ static u8 WaitWithDownArrow(struct Window *win) } else { - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { PlaySE(SE_SELECT); TryEraseDownArrow(win); diff --git a/src/title_screen.c b/src/title_screen.c index c686c8d89..11719a30b 100644 --- a/src/title_screen.c +++ b/src/title_screen.c @@ -637,7 +637,7 @@ static void MainCB2(void) static void Task_TitleScreenPhase1(u8 taskId) { //Skip to next phase when A, B, Start, or Select is pressed - if ((gMain.newKeys & A_B_START_SELECT) || gTasks[taskId].data[1] != 0) + if (JOY_NEW(A_B_START_SELECT) || gTasks[taskId].data[1] != 0) { gTasks[taskId].tSkipToNext = TRUE; gTasks[taskId].tCounter = 0; @@ -682,7 +682,7 @@ static void Task_TitleScreenPhase1(u8 taskId) static void Task_TitleScreenPhase2(u8 taskId) { //Skip to next phase when A, B, Start, or Select is pressed - if ((gMain.newKeys & A_B_START_SELECT) || gTasks[taskId].tSkipToNext) + if (JOY_NEW(A_B_START_SELECT) || gTasks[taskId].tSkipToNext) { gTasks[taskId].tSkipToNext = TRUE; gTasks[taskId].tCounter = 0; @@ -719,7 +719,7 @@ static void Task_TitleScreenPhase3(u8 taskId) REG_BLDALPHA = 0x1F0F; REG_BLDY = 0; - if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & START_BUTTON)) + if (JOY_NEW(A_BUTTON) || JOY_NEW(START_BUTTON)) { FadeOutBGM(4); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, FADE_COLOR_WHITE); @@ -727,9 +727,9 @@ static void Task_TitleScreenPhase3(u8 taskId) } else { - if ((gMain.heldKeys & CLEAR_SAVE_BUTTON_COMBO) == CLEAR_SAVE_BUTTON_COMBO) + if (JOY_HELD(CLEAR_SAVE_BUTTON_COMBO) == CLEAR_SAVE_BUTTON_COMBO) SetMainCallback2(CB2_GoToClearSaveDataScreen); - if ((gMain.heldKeys & RESET_RTC_BUTTON_COMBO) == RESET_RTC_BUTTON_COMBO + if (JOY_HELD(RESET_RTC_BUTTON_COMBO) == RESET_RTC_BUTTON_COMBO && CanResetRTC() == 1) { FadeOutBGM(4); diff --git a/src/trade.c b/src/trade.c index 8433d087f..b3a714da5 100644 --- a/src/trade.c +++ b/src/trade.c @@ -1873,23 +1873,23 @@ static void sub_8049620(void) static void sub_8049680(void) { int i; - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { TradeMenuMoveCursor(&gUnknown_03004824->tradeMenuCursorPosition, 0); } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { TradeMenuMoveCursor(&gUnknown_03004824->tradeMenuCursorPosition, 1); } - else if (gMain.newAndRepeatedKeys & DPAD_LEFT) + else if (JOY_REPT(DPAD_LEFT)) { TradeMenuMoveCursor(&gUnknown_03004824->tradeMenuCursorPosition, 2); } - else if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + else if (JOY_REPT(DPAD_RIGHT)) { TradeMenuMoveCursor(&gUnknown_03004824->tradeMenuCursorPosition, 3); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (gUnknown_03004824->tradeMenuCursorPosition < PARTY_SIZE) @@ -1912,7 +1912,7 @@ static void sub_8049680(void) sub_804ACD8(gUnknown_0820C14C[4], BG_CHAR_ADDR(4) + 32 * gUnknown_03004824->unk_007e, 20); } } - if (gMain.newKeys & R_BUTTON) + if (JOY_NEW(R_BUTTON)) { for (i = 0; i < 10; i ++) { @@ -1933,17 +1933,17 @@ static void sub_8049804(void) static void sub_8049860(void) { - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { PlaySE(SE_SELECT); gUnknown_03004824->unk_007c = Menu_MoveCursor(-1); } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { PlaySE(SE_SELECT); gUnknown_03004824->unk_007c = Menu_MoveCursor(+1); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (Menu_GetCursorPos() == 0) @@ -1962,7 +1962,7 @@ static void sub_8049860(void) gSprites[gUnknown_03004824->tradeMenuCursorSpriteIdx].invisible = TRUE; } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sub_8049804(); @@ -1971,7 +1971,7 @@ static void sub_8049860(void) static void sub_8049954(void) { - if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) + if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sub_8049804(); @@ -2034,17 +2034,17 @@ static void sub_8049A20(void) static void sub_8049AC0(void) { - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { PlaySE(SE_SELECT); gUnknown_03004824->unk_007c = Menu_MoveCursor(-1); } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { PlaySE(SE_SELECT); gUnknown_03004824->unk_007c = Menu_MoveCursor(+1); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (Menu_GetCursorPos() == 0) @@ -2062,7 +2062,7 @@ static void sub_8049AC0(void) } gUnknown_03004824->unk_007b = 100; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { sub_804AADC(3, 1); if (Menu_GetCursorPos() == 0) @@ -2077,17 +2077,17 @@ static void sub_8049AC0(void) static void sub_8049BC0(void) { - if (gMain.newAndRepeatedKeys & DPAD_UP) + if (JOY_REPT(DPAD_UP)) { PlaySE(SE_SELECT); gUnknown_03004824->unk_007c = Menu_MoveCursor(-1); } - else if (gMain.newAndRepeatedKeys & DPAD_DOWN) + else if (JOY_REPT(DPAD_DOWN)) { PlaySE(SE_SELECT); gUnknown_03004824->unk_007c = Menu_MoveCursor(+1); } - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (Menu_GetCursorPos() == 0) @@ -2104,7 +2104,7 @@ static void sub_8049BC0(void) sub_8049804(); } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sub_8049804(); @@ -2144,7 +2144,7 @@ static void DisplayMessageAndContinueTask(void) static void sub_8049D44(void) { - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); sub_804A840(0); @@ -4765,7 +4765,7 @@ static bool8 sub_804C29C(void) { return TRUE; } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { gUnknown_03004828->unk_00c4 ++; } diff --git a/src/trader.c b/src/trader.c index 5403f53eb..7b14c99ce 100644 --- a/src/trader.c +++ b/src/trader.c @@ -145,17 +145,17 @@ void Task_HandleGetDecorationMenuInput(u8 taskId) { struct MauvilleManTrader *trader = &gSaveBlock1.mauvilleMan.trader; - 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); } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); gSpecialVar_0x8005 = Menu_GetCursorPos(); @@ -169,7 +169,7 @@ void Task_HandleGetDecorationMenuInput(u8 taskId) sub_8109B34(taskId, trader->unk1[gSpecialVar_0x8005]); } } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); sub_8109B34(taskId, 0); diff --git a/src/trainer_card.c b/src/trainer_card.c index afd7a8d03..8caf463cd 100644 --- a/src/trainer_card.c +++ b/src/trainer_card.c @@ -687,12 +687,12 @@ bool8 TrainerCard_WaitForFadeInToFinish(struct Task *task) bool8 TrainerCard_WaitForKeys(struct Task *task) { - if (gMain.newKeys & B_BUTTON) + if (JOY_NEW(B_BUTTON)) { gTrainerCardPtr->current_state = 5; /* Jump to fadeout state */ return TRUE; } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { /* It appears that it was previously possible to return the the front side after viewing the back side. This was probably removed due to being @@ -709,7 +709,7 @@ bool8 TrainerCard_WaitForKeys(struct Task *task) return TRUE; } #if DEBUG - else if (gDebug_03000748 && gMain.newKeys & R_BUTTON) + else if (gDebug_03000748 && JOY_NEW(R_BUTTON)) { gTrainerCardPtr->starCount++; gTrainerCardPtr->starCount %= 5; diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index 78b5db4a8..22b31aab0 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -374,26 +374,26 @@ static void sub_8136638(void) switch (gUnknown_02039304->unk50) { case 0: - if (gMain.heldKeys & DPAD_UP) + if (JOY_HELD(DPAD_UP)) { PlaySE(SE_SELECT); sub_80F5060(TRUE); move_anim_execute(); gUnknown_02039304->unk50 = 1; } - else if (gMain.heldKeys & DPAD_DOWN) + else if (JOY_HELD(DPAD_DOWN)) { PlaySE(SE_SELECT); sub_80F5060(FALSE); move_anim_execute(); gUnknown_02039304->unk50 = 1; } - else if (gMain.newKeys & B_BUTTON) + else if (JOY_NEW(B_BUTTON)) { PlaySE(SE_SELECT); gUnknown_02039304->unk50 = 3; } - else if (gMain.newKeys & A_BUTTON) + else if (JOY_NEW(A_BUTTON)) { PlaySE(SE_SELECT); if (gPokenavStructPtr->unk87DC == gPokenavStructPtr->unk87DA - 1) @@ -450,7 +450,7 @@ static void sub_8136638(void) } break; case 7: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) { sub_8136D8C(); gUnknown_02039304->unk50 = 0; @@ -544,7 +544,7 @@ static void sub_81369CC(void) gUnknown_02039304->unk50++; break; case 1: - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) gUnknown_02039304->unk50++; break; case 2: @@ -571,7 +571,7 @@ static void sub_81369CC(void) } break; case 5: - if (gMain.newKeys & (A_BUTTON | B_BUTTON) && !sub_8136D00()) + if (JOY_NEW(A_BUTTON | B_BUTTON) && !sub_8136D00()) { PokeblockClearIfExists((u8)gSpecialVar_ItemId); launch_c3_walk_stairs_and_run_once(sub_8136B44); diff --git a/src/wallclock.c b/src/wallclock.c index 85f9f1419..82f1992ac 100644 --- a/src/wallclock.c +++ b/src/wallclock.c @@ -737,17 +737,17 @@ static void Task_SetClock2(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_SetClock3; return; } else { - gTasks[taskId].tMvmtDir = gMain.newKeys & A_BUTTON; - if (gMain.heldKeys & DPAD_LEFT) + gTasks[taskId].tMvmtDir = JOY_NEW(A_BUTTON); + if (JOY_HELD(DPAD_LEFT)) gTasks[taskId].tMvmtDir = MVMT_BACKWARD; - if (gMain.heldKeys & DPAD_RIGHT) + if (JOY_HELD(DPAD_RIGHT)) gTasks[taskId].tMvmtDir = MVMT_FORWARD; if (gTasks[taskId].tMvmtDir) { @@ -821,7 +821,7 @@ static void Task_ViewClock1(u8 taskId) static void Task_ViewClock2(u8 taskId) { InitClockWithRtc(taskId); - if (gMain.newKeys & (A_BUTTON | B_BUTTON)) + if (JOY_NEW(A_BUTTON | B_BUTTON)) gTasks[taskId].func = Task_ViewClock3; }