You've already forked Microtransactions64
mirror of
https://github.com/Print-and-Panic/Microtransactions64.git
synced 2026-01-21 10:17:19 -08:00
Improve debug level select controls
This commit is contained in:
@@ -84,63 +84,68 @@ s32 run_level_id_or_demo(s32 level) {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
u8 gLevelSelectHoldKeyIndex = 0;
|
||||
u8 gLevelSelectHoldKeyTimer = 0;
|
||||
|
||||
/**
|
||||
* Level select intro function, updates the selected stage
|
||||
* count if an input was received. signals the stage to be started
|
||||
* or the level select to be exited if start or the quit combo is pressed.
|
||||
*/
|
||||
s16 intro_level_select(void) { //! this function runs and crashes on save+quit even if level select is disabled
|
||||
s32 stageChanged = FALSE;
|
||||
|
||||
// perform the ID updates per each button press.
|
||||
// runs into a loop so after a button is pressed
|
||||
// stageChanged goes back to FALSE
|
||||
if (gPlayer1Controller->buttonPressed & A_BUTTON) {
|
||||
++gCurrLevelNum, stageChanged = TRUE;
|
||||
s16 intro_level_select(void) {
|
||||
u32 index = 0;
|
||||
if ((gPlayer1Controller->rawStickY < -60)
|
||||
|| (gPlayer1Controller->rawStickX < -60)
|
||||
|| (gPlayer1Controller->buttonDown & (D_CBUTTONS | D_JPAD | L_CBUTTONS | L_JPAD))) index++;
|
||||
if ((gPlayer1Controller->rawStickY > 60)
|
||||
|| (gPlayer1Controller->rawStickX > 60)
|
||||
|| (gPlayer1Controller->buttonDown & (U_CBUTTONS | U_JPAD | R_CBUTTONS | R_JPAD))) index += 2;
|
||||
if (((index ^ gLevelSelectHoldKeyIndex) & index) == 2) {
|
||||
if (gCurrLevelNum > LEVEL_MAX) {
|
||||
gCurrLevelNum = LEVEL_MIN;
|
||||
} else if (gPlayer3Controller->buttonDown & B_BUTTON) {
|
||||
play_sound(SOUND_GENERAL_LEVEL_SELECT_CHANGE, gGlobalSoundSource);
|
||||
gCurrLevelNum += 10;
|
||||
} else {
|
||||
play_sound(SOUND_GENERAL_LEVEL_SELECT_CHANGE, gGlobalSoundSource);
|
||||
gCurrLevelNum++;
|
||||
}
|
||||
}
|
||||
if (gPlayer1Controller->buttonPressed & B_BUTTON) {
|
||||
--gCurrLevelNum, stageChanged = TRUE;
|
||||
if (((index ^ gLevelSelectHoldKeyIndex) & index) == 1) {
|
||||
if (gCurrLevelNum < LEVEL_MIN) {
|
||||
// Same applies to here as above
|
||||
gCurrLevelNum = LEVEL_MAX;
|
||||
} else if (gPlayer3Controller->buttonDown & B_BUTTON) {
|
||||
play_sound(SOUND_GENERAL_LEVEL_SELECT_CHANGE, gGlobalSoundSource);
|
||||
gCurrLevelNum -= 10;
|
||||
} else {
|
||||
play_sound(SOUND_GENERAL_LEVEL_SELECT_CHANGE, gGlobalSoundSource);
|
||||
gCurrLevelNum--;
|
||||
}
|
||||
}
|
||||
if (gPlayer1Controller->buttonPressed & U_JPAD) {
|
||||
--gCurrLevelNum, stageChanged = TRUE;
|
||||
if (gLevelSelectHoldKeyTimer == 10) {
|
||||
gLevelSelectHoldKeyTimer = 8;
|
||||
gLevelSelectHoldKeyIndex = 0;
|
||||
} else {
|
||||
gLevelSelectHoldKeyTimer++;
|
||||
gLevelSelectHoldKeyIndex = index;
|
||||
}
|
||||
if (gPlayer1Controller->buttonPressed & D_JPAD) {
|
||||
++gCurrLevelNum, stageChanged = TRUE;
|
||||
}
|
||||
if (gPlayer1Controller->buttonPressed & L_JPAD) {
|
||||
gCurrLevelNum -= 10, stageChanged = TRUE;
|
||||
}
|
||||
if (gPlayer1Controller->buttonPressed & R_JPAD) {
|
||||
gCurrLevelNum += 10, stageChanged = TRUE;
|
||||
}
|
||||
|
||||
// if the stage was changed, play the sound for changing a stage.
|
||||
if (stageChanged) {
|
||||
play_sound(SOUND_GENERAL_LEVEL_SELECT_CHANGE, gGlobalSoundSource);
|
||||
}
|
||||
|
||||
if (gCurrLevelNum > LEVEL_MAX) {
|
||||
gCurrLevelNum = LEVEL_MIN; // exceeded max. set to min.
|
||||
}
|
||||
|
||||
if (gCurrLevelNum < LEVEL_MIN) {
|
||||
gCurrLevelNum = LEVEL_MAX; // exceeded min. set to max.
|
||||
}
|
||||
|
||||
if ((index & 0x3) == 0) gLevelSelectHoldKeyTimer = 0;
|
||||
if (gCurrLevelNum > LEVEL_MAX) gCurrLevelNum = LEVEL_MIN; // exceeded max. set to min.
|
||||
if (gCurrLevelNum < LEVEL_MIN) gCurrLevelNum = LEVEL_MAX; // exceeded min. set to max.
|
||||
// Use file 4 and last act as a test
|
||||
gCurrSaveFileNum = 4;
|
||||
gCurrActNum = 6;
|
||||
|
||||
gCurrActNum = 6;
|
||||
print_text_centered(160, 80, "SELECT STAGE");
|
||||
print_text_centered(160, 30, "PRESS START BUTTON");
|
||||
print_text_fmt_int(40, 60, "%2d", gCurrLevelNum);
|
||||
print_text(80, 60, sLevelSelectStageNames[gCurrLevelNum - 1]); // print stage name
|
||||
|
||||
// start being pressed signals the stage to be started. that is, unless...
|
||||
if (gPlayer1Controller->buttonPressed & START_BUTTON) {
|
||||
if (gPlayer1Controller->buttonPressed & (START_BUTTON | A_BUTTON)) {
|
||||
// ... the level select quit combo is being pressed, which uses START. If this
|
||||
// is the case, quit the menu instead.
|
||||
if (gPlayer1Controller->buttonDown == (Z_TRIG | START_BUTTON | L_CBUTTONS | R_CBUTTONS)) {
|
||||
if (gPlayer1Controller->buttonDown == (Z_TRIG | START_BUTTON | L_CBUTTONS)) { // quit level select
|
||||
gDebugLevelSelect = FALSE;
|
||||
return LEVEL_RESTART_GAME;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user