From 3b794dcce90543c2203ca2006eb77a41af49c05e Mon Sep 17 00:00:00 2001 From: Jed Grabman Date: Sun, 8 Mar 2026 23:01:24 -0400 Subject: [PATCH] Use button names (#758) Use button names instead of bit flags --- src/actors/fake_item_box/update.inc.c | 2 +- src/cpu_vehicles_camera_path.c | 4 +- src/main.c | 2 +- src/menu_items.c | 66 +++++++++++++-------------- src/profiler.c | 2 +- src/racing/race_logic.c | 2 +- src/update_objects.c | 2 +- 7 files changed, 40 insertions(+), 40 deletions(-) diff --git a/src/actors/fake_item_box/update.inc.c b/src/actors/fake_item_box/update.inc.c index 5313f7b7b..f86e35a5d 100644 --- a/src/actors/fake_item_box/update.inc.c +++ b/src/actors/fake_item_box/update.inc.c @@ -43,7 +43,7 @@ void update_actor_fake_item_box(struct FakeItemBox* fake_item_box) { if ((temp_v0_4->type & PLAYER_HUMAN) != 0) { if ((temp_v1_3->buttonDepressed & Z_TRIG) != 0) { - temp_v1_3->buttonDepressed &= 0xDFFF; + temp_v1_3->buttonDepressed &= ~Z_TRIG; func_802A1064(fake_item_box); temp_v0_4->triggers &= ~DRAG_ITEM_EFFECT; func_800C9060((u8) (temp_v0_4 - gPlayerOne), SOUND_ARG_LOAD(0x19, 0x00, 0x80, 0x12)); diff --git a/src/cpu_vehicles_camera_path.c b/src/cpu_vehicles_camera_path.c index 0e410e9cf..5774acdac 100644 --- a/src/cpu_vehicles_camera_path.c +++ b/src/cpu_vehicles_camera_path.c @@ -4582,11 +4582,11 @@ void render_bomb_karts_wrap(s32 cameraId) { UNUSED void func_8001C42C(void) { if (D_800DDB20 == 0) { - if ((gControllerThree->buttonPressed & 0x20) != 0) { + if ((gControllerThree->buttonPressed & L_TRIG) != 0) { D_800DDB20 = 1; } } else { - if ((gControllerThree->buttonPressed & 0x20) != 0) { + if ((gControllerThree->buttonPressed & L_TRIG) != 0) { D_800DDB20 = 0; } func_80057C60(); diff --git a/src/main.c b/src/main.c index 044cc235f..60a4cc66d 100644 --- a/src/main.c +++ b/src/main.c @@ -320,7 +320,7 @@ void update_controller(s32 index) { controller->rawStickX = gControllerPads[index].stick_x; controller->rawStickY = gControllerPads[index].stick_y; - if ((gControllerPads[index].button & 4) != 0) { + if ((gControllerPads[index].button & D_CBUTTONS) != 0) { gControllerPads[index].button |= Z_TRIG; } controller->buttonPressed = gControllerPads[index].button & (gControllerPads[index].button ^ controller->button); diff --git a/src/menu_items.c b/src/menu_items.c index 927763fb1..c8e9e7a4b 100644 --- a/src/menu_items.c +++ b/src/menu_items.c @@ -10893,7 +10893,7 @@ void func_800ACA14(MenuItem* arg0) { break; } - if ((gControllerFive->buttonPressed | gControllerFive->stickPressed) & 0x800) { + if ((gControllerFive->buttonPressed | gControllerFive->stickPressed) & U_JPAD) { if (arg0->state >= 0xC) { arg0->state--; play_sound2(SOUND_MENU_CURSOR_MOVE); @@ -10903,7 +10903,7 @@ void func_800ACA14(MenuItem* arg0) { arg0->subState = -1; } } - if ((gControllerFive->buttonPressed | gControllerFive->stickPressed) & 0x400) { + if ((gControllerFive->buttonPressed | gControllerFive->stickPressed) & D_JPAD) { if (arg0->state < 0xC) { arg0->state++; play_sound2(SOUND_MENU_CURSOR_MOVE); @@ -10913,7 +10913,7 @@ void func_800ACA14(MenuItem* arg0) { arg0->subState = 1; } } - if (gControllerFive->buttonPressed & 0x9000) { + if (gControllerFive->buttonPressed & (A_BUTTON | START_BUTTON)) { func_8009DFE0(0x0000001E); func_800CA330(0x19U); play_sound2(SOUND_ACTION_CONTINUE_UNKNOWN); @@ -10965,7 +10965,7 @@ void func_800ACC50(MenuItem* arg0) { case 12: case 13: if (is_screen_being_faded() == 0) { - if ((gControllerFive->buttonPressed | gControllerFive->stickPressed) & 0x800) { + if ((gControllerFive->buttonPressed | gControllerFive->stickPressed) & U_JPAD) { if (arg0->state >= 0xB) { arg0->state--; play_sound2(SOUND_MENU_CURSOR_MOVE); @@ -10975,7 +10975,7 @@ void func_800ACC50(MenuItem* arg0) { arg0->subState = -1; } } - if ((gControllerFive->buttonPressed | gControllerFive->stickPressed) & 0x400) { + if ((gControllerFive->buttonPressed | gControllerFive->stickPressed) & D_JPAD) { if (arg0->state < 0xD) { arg0->state++; play_sound2(SOUND_MENU_CURSOR_MOVE); @@ -10985,7 +10985,7 @@ void func_800ACC50(MenuItem* arg0) { arg0->subState = 1; } } - if (gControllerFive->buttonPressed & 0x9000) { + if (gControllerFive->buttonPressed & (START_BUTTON | A_BUTTON)) { func_8009DFE0(0x0000001E); play_sound2(SOUND_MENU_OK_CLICKED); if (gModeSelection == VERSUS) { @@ -11158,7 +11158,7 @@ void func_800AD2E8(MenuItem* arg0) { case 9: /* switch 3 */ case 10: /* switch 3 */ if (is_screen_being_faded() == 0) { - if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & 0x800) { + if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & U_JPAD) { if (arg0->state >= 6) { arg0->state--; if ((gPostTimeTrialReplayCannotSave == 1) && (arg0->state == 9)) { @@ -11171,7 +11171,7 @@ void func_800AD2E8(MenuItem* arg0) { arg0->subState = -1; } } - if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & 0x400) { + if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & D_JPAD) { if (arg0->state < 0xA) { arg0->state++; if ((gPostTimeTrialReplayCannotSave == 1) && (arg0->state == 9)) { @@ -11188,7 +11188,7 @@ void func_800AD2E8(MenuItem* arg0) { } } } - if (gControllerOne->buttonPressed & 0x9000) { + if (gControllerOne->buttonPressed & (START_BUTTON | A_BUTTON)) { if (arg0->state == 0x0000000A) { var_v1 = 0; if (arg0->paramf < 4.2) { @@ -11288,7 +11288,7 @@ void func_800AD2E8(MenuItem* arg0) { case 15: case 16: case 26: - if (gControllerOne->buttonPressed & 0xD000) { + if (gControllerOne->buttonPressed & (A_BUTTON | B_BUTTON | START_BUTTON)) { arg0->state = 0x0000000A; play_sound2(SOUND_MENU_GO_BACK); if (arg0->paramf < 4.2) { @@ -11300,7 +11300,7 @@ void func_800AD2E8(MenuItem* arg0) { case 18: arg0->param2 = arg0->state - 0x11; if (func_800B639C((gCupSelection * 4) + gCourseIndexInCup) != arg0->param2) { - if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & 0x800) { + if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & U_JPAD) { if (arg0->state >= 0x12) { arg0->state--; play_sound2(SOUND_MENU_CURSOR_MOVE); @@ -11310,7 +11310,7 @@ void func_800AD2E8(MenuItem* arg0) { arg0->subState = -1; } } - if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & 0x400) { + if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & D_JPAD) { if (arg0->state < 0x12) { arg0->state++; play_sound2(SOUND_MENU_CURSOR_MOVE); @@ -11321,12 +11321,12 @@ void func_800AD2E8(MenuItem* arg0) { } } } - if (gControllerOne->buttonPressed & 0x4000) { + if (gControllerOne->buttonPressed & B_BUTTON) { arg0->state = 0x0000000A; play_sound2(SOUND_MENU_GO_BACK); return; } - if (gControllerOne->buttonPressed & 0x9000) { + if (gControllerOne->buttonPressed & (START_BUTTON | A_BUTTON)) { thing = &D_8018EE10[arg0->param2]; if (thing->ghostDataSaved == 0) { arg0->state = 0x00000019; @@ -11355,7 +11355,7 @@ void func_800AD2E8(MenuItem* arg0) { break; case 20: case 21: - if (((gControllerOne->buttonPressed | gControllerOne->stickPressed) & 0x800) && (arg0->state >= 0x15)) { + if (((gControllerOne->buttonPressed | gControllerOne->stickPressed) & U_JPAD) && (arg0->state >= 0x15)) { arg0->state--; play_sound2(SOUND_MENU_CURSOR_MOVE); if (arg0->paramf < 4.2) { @@ -11363,7 +11363,7 @@ void func_800AD2E8(MenuItem* arg0) { } arg0->subState = -1; } - if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & 0x400) { + if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & D_JPAD) { if (arg0->state < 0x15) { arg0->state++; play_sound2(SOUND_MENU_CURSOR_MOVE); @@ -11373,12 +11373,12 @@ void func_800AD2E8(MenuItem* arg0) { arg0->subState = 1; } } - if (gControllerOne->buttonPressed & 0x4000) { + if (gControllerOne->buttonPressed & B_BUTTON) { arg0->state = arg0->param2 + 0x11; play_sound2(SOUND_MENU_GO_BACK); return; } - if (gControllerOne->buttonPressed & 0x9000) { + if (gControllerOne->buttonPressed & (START_BUTTON | A_BUTTON)) { if (arg0->state == 0x00000015) { arg0->state = 0x00000019; arg0->param1 = 0; @@ -11485,7 +11485,7 @@ void func_800ADF48(MenuItem* arg0) { case 44: if (is_screen_being_faded() == 0) { controller = &gControllers[gIsGamePaused - 1]; - if ((controller->buttonPressed | controller->stickPressed) & 0x800) { + if ((controller->buttonPressed | controller->stickPressed) & U_JPAD) { if (D_800F0B50[gModeSelection] < arg0->state) { arg0->state--; play_sound2(SOUND_MENU_CURSOR_MOVE); @@ -11495,7 +11495,7 @@ void func_800ADF48(MenuItem* arg0) { arg0->subState = -1; } } - if ((controller->buttonPressed | controller->stickPressed) & 0x400) { + if ((controller->buttonPressed | controller->stickPressed) & D_JPAD) { if (arg0->state < D_800F0B54[gModeSelection]) { arg0->state++; play_sound2(SOUND_MENU_CURSOR_MOVE); @@ -11549,7 +11549,7 @@ void func_800AE218(MenuItem* arg0) { if (arg0->param1 < 0x1E) { arg0->param1++; } - if (gControllerOne->buttonPressed & 0x1000) { + if (gControllerOne->buttonPressed & START_BUTTON) { arg0->state = 0x0000000F; play_sound2(SOUND_ACTION_GO_BACK_2); } else if (playerHUD[PLAYER_ONE].raceCompleteBool != 0) { @@ -11572,7 +11572,7 @@ void func_800AE218(MenuItem* arg0) { case 15: case 16: if (is_screen_being_faded() == 0) { - if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & 0x800) { + if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & U_JPAD) { if (arg0->state >= 0xC) { arg0->state--; play_sound2(SOUND_MENU_CURSOR_MOVE); @@ -11582,7 +11582,7 @@ void func_800AE218(MenuItem* arg0) { arg0->subState = -1; } } - if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & 0x400) { + if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & D_JPAD) { if (arg0->state < 0x10) { arg0->state++; play_sound2(SOUND_MENU_CURSOR_MOVE); @@ -11592,7 +11592,7 @@ void func_800AE218(MenuItem* arg0) { arg0->subState = 1; } } - if (gControllerOne->buttonPressed & 0x9000) { + if (gControllerOne->buttonPressed & (START_BUTTON | A_BUTTON)) { if (arg0->state == 0x00000010) { var_v1 = 0; if (arg0->paramf < 4.2) { @@ -11690,7 +11690,7 @@ void func_800AE218(MenuItem* arg0) { case 25: case 26: case 41: - if (gControllerOne->buttonPressed & 0xD000) { + if (gControllerOne->buttonPressed & (A_BUTTON | B_BUTTON | START_BUTTON)) { arg0->state = 0x00000010; play_sound2(SOUND_MENU_GO_BACK); if (arg0->paramf < 4.2) { @@ -11702,7 +11702,7 @@ void func_800AE218(MenuItem* arg0) { case 31: arg0->param2 = (u32) arg0->state - 0x1E; if (func_800B639C((gCupSelection * 4) + gCourseIndexInCup) != arg0->param2) { - if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & 0x800) { + if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & U_JPAD) { if (arg0->state >= 0x1F) { arg0->state--; play_sound2(SOUND_MENU_CURSOR_MOVE); @@ -11712,7 +11712,7 @@ void func_800AE218(MenuItem* arg0) { arg0->subState = -1; } } - if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & 0x400) { + if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & D_JPAD) { if (arg0->state < 0x1F) { arg0->state++; play_sound2(SOUND_MENU_CURSOR_MOVE); @@ -11723,10 +11723,10 @@ void func_800AE218(MenuItem* arg0) { } } } - if (gControllerOne->buttonPressed & 0x4000) { + if (gControllerOne->buttonPressed & B_BUTTON) { arg0->state = 0x00000010; play_sound2(SOUND_MENU_GO_BACK); - } else if (gControllerOne->buttonPressed & 0x9000) { + } else if (gControllerOne->buttonPressed & (START_BUTTON | A_BUTTON)) { thing = &D_8018EE10[arg0->param2]; if (thing->ghostDataSaved == 0) { arg0->state = 0x00000028; @@ -11754,7 +11754,7 @@ void func_800AE218(MenuItem* arg0) { break; case 35: case 36: - if (((gControllerOne->buttonPressed | gControllerOne->stickPressed) & 0x800) && + if (((gControllerOne->buttonPressed | gControllerOne->stickPressed) & U_JPAD) && ((s32) (u32) arg0->state >= 0x24)) { arg0->state--; play_sound2(SOUND_MENU_CURSOR_MOVE); @@ -11763,7 +11763,7 @@ void func_800AE218(MenuItem* arg0) { } arg0->subState = -1; } - if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & 0x400) { + if ((gControllerOne->buttonPressed | gControllerOne->stickPressed) & D_JPAD) { if (arg0->state < 0x24) { arg0->state++; play_sound2(SOUND_MENU_CURSOR_MOVE); @@ -11773,10 +11773,10 @@ void func_800AE218(MenuItem* arg0) { arg0->subState = 1; } } - if (gControllerOne->buttonPressed & 0x4000) { + if (gControllerOne->buttonPressed & B_BUTTON) { arg0->state = arg0->param2 + 0x1E; play_sound2(SOUND_MENU_GO_BACK); - } else if (gControllerOne->buttonPressed & 0x9000) { + } else if (gControllerOne->buttonPressed & (START_BUTTON | A_BUTTON)) { if (arg0->state == 0x00000024) { arg0->state = 0x00000028; arg0->param1 = 0; diff --git a/src/profiler.c b/src/profiler.c index eca4e9a71..de0fd59a0 100644 --- a/src/profiler.c +++ b/src/profiler.c @@ -224,7 +224,7 @@ void resource_display(void) { gDPSetCycleType(gDisplayListHead++, G_CYC_FILL); gDPSetFillColor(gDisplayListHead++, GPACK_RGBA5551(0, 0, 0, 0) << 16 | GPACK_RGBA5551(0, 0, 0, 0)); - if ((gControllerOne->buttonPressed & 0x20) != 0) { + if ((gControllerOne->buttonPressed & L_TRIG) != 0) { D_800DC664 ^= 1; } draw_profiler_mode_0(); diff --git a/src/racing/race_logic.c b/src/racing/race_logic.c index 43c7048d3..c209d2e9a 100644 --- a/src/racing/race_logic.c +++ b/src/racing/race_logic.c @@ -815,7 +815,7 @@ void func_8028F970(void) { if (gActiveScreenMode != SCREEN_MODE_3P_4P_SPLITSCREEN) { if ((controller->buttonPressed & L_TRIG) && !(controller->button & R_TRIG)) { - controller->buttonPressed &= 0xFFDF; + controller->buttonPressed &= ~L_TRIG; D_800DC5A8++; if (D_800DC5A8 >= 3) { diff --git a/src/update_objects.c b/src/update_objects.c index 4df9d6374..929c49d0f 100644 --- a/src/update_objects.c +++ b/src/update_objects.c @@ -3819,7 +3819,7 @@ void func_8007B34C(s32 playerId) { sp38 = &gPlayerOne[playerId]; sp40 = 0; new_var = &gControllerOne[playerId]; - if (new_var->buttonPressed & 0x2000) { + if (new_var->buttonPressed & Z_TRIG) { sp40 = 1; } if (D_80165888 != 0) {