Update menus.c (#629)

This commit is contained in:
MegaMech 2024-04-23 13:41:43 -06:00 committed by GitHub
parent a33325212f
commit 21de29c7e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 91 additions and 77 deletions

View File

@ -1510,163 +1510,177 @@ bool is_character_spot_free(s32 gridId) {
// grid positions are from right to left, then top to bottom
// nonmatching: the gCharacterGridSelections pointer is not promoted to $s0
void player_select_menu_act(struct Controller *controller, u16 arg1) {
u16 btnAndStick; // sp36
s8 *bar;
s8 selected;
s8 i;
s8 saved_selection;
u16 btnAndStick;
btnAndStick = (controller->buttonPressed) | (controller->stickPressed);
if (!gEnableDebugMode && btnAndStick & START_BUTTON) {
btnAndStick |= A_BUTTON;
if (!gEnableDebugMode && btnAndStick & CONT_START) {
btnAndStick |= CONT_A;
}
if (!func_800B4520()) {
switch (D_8018EDEE) {
case 1:
case 1:
{
if (gCharacterGridSelections[arg1] == 0) {
if (btnAndStick & B_BUTTON) {
saved_selection = gCharacterGridSelections[arg1];
if (saved_selection == 0) {
if (btnAndStick & CONT_B) {
func_8009E208();
play_sound2(SOUND_MENU_GO_BACK);
play_sound2(0x49008002);
}
return;
}
// L800B3630
if (btnAndStick & B_BUTTON) {
if (btnAndStick & CONT_B) {
if (D_8018EDE8[arg1]) {
D_8018EDE8[arg1] = FALSE;
play_sound2(SOUND_MENU_GO_BACK);
play_sound2(0x49008002);
} else {
func_8009E208();
play_sound2(SOUND_MENU_GO_BACK);
play_sound2(0x49008002);
}
}
// L800B3684
if ((btnAndStick & A_BUTTON) && !D_8018EDE8[arg1]) {
if ((btnAndStick & CONT_A) && (D_8018EDE8[arg1] == 0)) {
D_8018EDE8[arg1] = TRUE;
func_800C90F4(
arg1,
(((uintptr_t)D_800F2BAC[gCharacterGridSelections[arg1] - 1]) << 4) + 0x2900800EU
);
i = D_800F2BAC[gCharacterGridSelections[arg1] - 1];
func_800C90F4(arg1, 0x2900800e + (i << 4));
}
// L800B36F4
selected = FALSE;
for (i = 0; i < ARRAY_COUNT(gCharacterGridSelections); i++) {
if (gCharacterGridSelections[i] && D_8018EDE8[i]) {
for (i = 0; i < 4; i++) { // for (i = 0; i < ARRAY_COUNT(gCharacterGridSelections); i++) {
if ((gCharacterGridSelections[i] != 0) && (D_8018EDE8[i] == 0)) { //(gCharacterGridSelections[i] && D_8018EDE8[i]) {
selected = TRUE;
break;
}
}
// L800B3738
if (!selected) {
D_8018EDEE = 2;
func_800B44AC();
gMenuTimingCounter = 0;
}
// L800B3768
if (D_8018EDE8[arg1]) {
if ((btnAndStick & R_JPAD) && (btnAndStick & D_JPAD)) {
if (gCharacterGridSelections[arg1] == 1 || gCharacterGridSelections[arg1] == 2 || gCharacterGridSelections[arg1] == 3) {
if (D_8018EDE8[arg1] == 0) {
if ((btnAndStick & CONT_RIGHT) && (btnAndStick & CONT_DOWN)) {
if (saved_selection == 1 || saved_selection == 2 || saved_selection == 3) {
// L800B37B0
if (is_character_spot_free(gCharacterGridSelections[arg1] + 5)) {
gCharacterGridSelections[arg1] += 5;
play_sound2(SOUND_MENU_CURSOR_MOVE);
saved_selection += 5;
if (is_character_spot_free(saved_selection)) {
gCharacterGridSelections[arg1] = saved_selection;
play_sound2(0x49008000);
}
}
return;
}
// L800B37E4
if ((btnAndStick & L_JPAD) && (btnAndStick & D_JPAD)) {
if (gCharacterGridSelections[arg1] == 2 || gCharacterGridSelections[arg1] == 3 || gCharacterGridSelections[arg1] == 4) {
if (is_character_spot_free(gCharacterGridSelections[arg1] + 3)) {
gCharacterGridSelections[arg1] += 3;
play_sound2(SOUND_MENU_CURSOR_MOVE);
if ((btnAndStick & CONT_LEFT) && (btnAndStick & CONT_DOWN)) {
if (saved_selection == 2 || saved_selection == 3 || saved_selection == 4) {
saved_selection += 3;
if (is_character_spot_free(saved_selection)) {
gCharacterGridSelections[arg1] = saved_selection;
play_sound2(0x49008000);
}
}
return;
}
// L800B3844
if ((btnAndStick & R_JPAD) && (btnAndStick & U_JPAD)) {
if (gCharacterGridSelections[arg1] == 5 || gCharacterGridSelections[arg1] == 6 || gCharacterGridSelections[arg1] == 7) {
if (is_character_spot_free(gCharacterGridSelections[arg1] - 3)) {
gCharacterGridSelections[arg1] -= 3;
play_sound2(SOUND_MENU_CURSOR_MOVE);
if ((btnAndStick & CONT_RIGHT) && (btnAndStick & CONT_UP)) {
if (saved_selection == 5 || saved_selection == 6 || saved_selection == 7) {
saved_selection -= 3;
if (is_character_spot_free(saved_selection)) {
gCharacterGridSelections[arg1] = saved_selection;
play_sound2(0x49008000);
}
}
return;
}
// L800B38A0
if ((btnAndStick & L_JPAD) && (btnAndStick & U_JPAD)) {
if (gCharacterGridSelections[arg1] == 6 || gCharacterGridSelections[arg1] == 7 || gCharacterGridSelections[arg1] == 8) {
if (is_character_spot_free(gCharacterGridSelections[arg1] - 5)) {
gCharacterGridSelections[arg1] -= 5;
play_sound2(SOUND_MENU_CURSOR_MOVE);
if ((btnAndStick & CONT_LEFT) && (btnAndStick & CONT_UP)) {
if (saved_selection == 6 || saved_selection == 7 || saved_selection == 8) {
saved_selection -= 5;
if (is_character_spot_free(saved_selection)) {
gCharacterGridSelections[arg1] = saved_selection;
play_sound2(0x49008000);
}
}
return;
}
// L800B38FC
if (btnAndStick & R_JPAD) {
if (gCharacterGridSelections[arg1] != 4 && gCharacterGridSelections[arg1] != 8) {
do {
// L800B391C
if (is_character_spot_free(gCharacterGridSelections[arg1] + 1)) {
gCharacterGridSelections[arg1] += 1;
play_sound2(SOUND_MENU_CURSOR_MOVE);
break;
}
gCharacterGridSelections[arg1] += 1;
} while (gCharacterGridSelections[arg1] != 5 && gCharacterGridSelections[arg1] != 9 && gCharacterGridSelections[arg1] <= 10);
}
if (btnAndStick & CONT_RIGHT) {
if (saved_selection == 4 || saved_selection == 8) return;
saved_selection += 1;
do {
// L800B391C
if (is_character_spot_free(saved_selection)) {
gCharacterGridSelections[arg1] = saved_selection;
play_sound2(0x49008000); // play_sound2(0x49008000);
break;
}
saved_selection += 1;
if ((saved_selection == 5) || (saved_selection == 9)) return;
} while (saved_selection < 10);
return;
}
// L800B3978
if (btnAndStick & L_JPAD) {
if (gCharacterGridSelections[arg1] != 1 && gCharacterGridSelections[arg1] != 5) {
do {
if (is_character_spot_free(gCharacterGridSelections[arg1] - 1)) {
gCharacterGridSelections[arg1] -= 1;
play_sound2(SOUND_MENU_CURSOR_MOVE);
break;
}
gCharacterGridSelections[arg1] -= 1;
} while (gCharacterGridSelections[arg1] != 0 && gCharacterGridSelections[arg1] != 4 && gCharacterGridSelections[arg1] >= 0);
}
if (btnAndStick & CONT_LEFT) {
if (saved_selection == 1 || saved_selection == 5) return;
saved_selection -= 1;
do {
if (is_character_spot_free(saved_selection)) {
gCharacterGridSelections[arg1] = saved_selection;
play_sound2(0x49008000);
break;
}
saved_selection -= 1;
if ((saved_selection == 0) || (saved_selection == 4)) return;
} while (saved_selection >= 0);
return;
}
// L800B39F4
if ((btnAndStick & U_JPAD) && (gCharacterGridSelections[arg1] >= 5)) {
gCharacterGridSelections[arg1] -= 4;
if ((btnAndStick & CONT_UP) && (saved_selection >= 5)) {
saved_selection = saved_selection - 4;
}
if ((btnAndStick & D_JPAD) && (gCharacterGridSelections[arg1] < 5)) {
gCharacterGridSelections[arg1] += 4;
if ((btnAndStick & CONT_DOWN) && (saved_selection < 5)) {
saved_selection = saved_selection + 4;
}
// L800B3A30
if (is_character_spot_free(gCharacterGridSelections[arg1])) {
play_sound2(SOUND_MENU_CURSOR_MOVE);
if (is_character_spot_free(saved_selection)) {
gCharacterGridSelections[arg1] = saved_selection;
play_sound2(0x49008000);
}
}
break;
}
case 2:
case 3:
{
if (!arg1 && (++gMenuTimingCounter == 60 || gMenuSelection % 300 == 0)) {
// L800B3A94
play_sound2(SOUND_MENU_OK);
if (arg1 == 0) {
gMenuTimingCounter++;
if ((gMenuTimingCounter == 60) || ((gMenuTimingCounter % 300) == 0)) {
// L800B3A94
play_sound2(0x4900900F);
}
}
// L800B3AA4
if (btnAndStick & B_BUTTON) {
if (btnAndStick & CONT_B) {
D_8018EDEE = 1;
D_8018EDE8[arg1] = FALSE;
play_sound2(SOUND_MENU_GO_BACK);
} else if (btnAndStick & A_BUTTON) {
play_sound2(0x49008002);
break;
}
if (btnAndStick & CONT_A) {
func_8009E1C0();
play_sound2(SOUND_MENU_OK_CLICKED);
play_sound2(0x49008016);
func_8000F124();
}
break;
}
default:
break;
}
// L800B3B24
if (gCharacterGridSelections[arg1] != 0) {