From 28fc53c2079799f3138e3b7b9867dbbf2f428b43 Mon Sep 17 00:00:00 2001 From: Daniel Date: Sun, 17 May 2020 22:56:06 +0100 Subject: [PATCH 1/2] Enabled a Cheat menu Enabled a cheat menu. It includes 4 cheats, and all of them rely on the global "Enable cheats" option so the user can quickly turn all the selected cheats off and back on. --- include/text_strings.h.in | 9 ++++++++- src/game/mario.c | 27 +++++++++++++++++++++++++-- src/game/options_menu.c | 22 ++++++++++++++++++++++ src/pc/configfile.c | 8 ++++++++ src/pc/configfile.h | 5 +++++ 5 files changed, 68 insertions(+), 3 deletions(-) diff --git a/include/text_strings.h.in b/include/text_strings.h.in index 3246699e..01f7ff86 100644 --- a/include/text_strings.h.in +++ b/include/text_strings.h.in @@ -1,4 +1,4 @@ -#ifndef TEXT_STRINGS_H + #ifndef TEXT_STRINGS_H #define TEXT_STRINGS_H #include "text_menu_strings.h" @@ -45,6 +45,13 @@ #define TEXT_BIND_LEFT _("Stick Left") #define TEXT_BIND_RIGHT _("Stick Right") +#define TEXT_OPT_CHEATS _("CHEATS") +#define TEXT_OPT_CHEAT1 _("Enable cheats") +#define TEXT_OPT_CHEAT2 _("Moonjump (Press L)") +#define TEXT_OPT_CHEAT3 _("Invincible Mario") +#define TEXT_OPT_CHEAT4 _("Infinite lives") +#define TEXT_OPT_CHEAT5 _("Super speed") + /** * Global Symbols */ diff --git a/src/game/mario.c b/src/game/mario.c index 164f92f5..1edaa835 100644 --- a/src/game/mario.c +++ b/src/game/mario.c @@ -31,6 +31,7 @@ #include "engine/surface_collision.h" #include "level_table.h" #include "thread6.h" +#include "pc/configfile.h" #ifdef BETTERCAMERA #include "bettercamera.h" #endif @@ -1396,7 +1397,12 @@ void update_mario_inputs(struct MarioState *m) { update_mario_geometry_inputs(m); debug_print_speed_action_normal(m); - + /* Moonjump cheat */ + while (cheatMoonjump == true && cheatEnablecheats == true && m->controller->buttonDown & L_TRIG ){ + m->vel[1] = 25; + break; + } + /*End of moonjump cheat */ if (gCameraMovementFlags & CAM_MOVE_C_UP_MODE) { if (m->action & ACT_FLAG_ALLOW_FIRST_PERSON) { m->input |= INPUT_FIRST_PERSON; @@ -1717,7 +1723,24 @@ void func_sh_8025574C(void) { */ s32 execute_mario_action(UNUSED struct Object *o) { s32 inLoop = TRUE; - + /** + * Cheat stuff + */ + while (cheatGodmode == true && cheatEnablecheats == true){ + gMarioState->health = 0x880; + break; + } + while (cheatInfinitelives == true && cheatEnablecheats == true && gMarioState->numLives < 99){ + gMarioState->numLives += 1; + break; + } + while (cheatSuperspeed == true && cheatEnablecheats == true && gMarioState->forwardVel > 0 ){ + gMarioState->forwardVel += 100; + break; + } + /** + * End of cheat stuff + */ if (gMarioState->action) { gMarioState->marioObj->header.gfx.node.flags &= ~GRAPH_RENDER_INVISIBLE; mario_reset_bodystate(gMarioState); diff --git a/src/game/options_menu.c b/src/game/options_menu.c index 752a5396..01a0817e 100644 --- a/src/game/options_menu.c +++ b/src/game/options_menu.c @@ -50,6 +50,8 @@ static const u8 menuStr[][32] = { { TEXT_OPT_VIDEO }, { TEXT_OPT_AUDIO }, { TEXT_EXIT_GAME }, + { TEXT_OPT_CHEATS }, + }; static const u8 optsCameraStr[][32] = { @@ -75,6 +77,14 @@ static const u8 optsAudioStr[][32] = { { TEXT_OPT_MVOLUME }, }; +static const u8 optsCheatsStr[][64] = { + { TEXT_OPT_CHEAT1 }, + { TEXT_OPT_CHEAT2 }, + { TEXT_OPT_CHEAT3 }, + { TEXT_OPT_CHEAT4 }, + { TEXT_OPT_CHEAT5 }, +}; + static const u8 bindStr[][32] = { { TEXT_OPT_UNBOUND }, { TEXT_OPT_PRESSKEY }, @@ -207,6 +217,15 @@ static struct Option optsAudio[] = { DEF_OPT_SCROLL( optsAudioStr[0], &configMasterVolume, 0, MAX_VOLUME, 1 ), }; +static struct Option optsCheats[] = { + DEF_OPT_TOGGLE( optsCheatsStr[0], &cheatEnablecheats ), + DEF_OPT_TOGGLE( optsCheatsStr[1], &cheatMoonjump ), + DEF_OPT_TOGGLE( optsCheatsStr[2], &cheatGodmode ), + DEF_OPT_TOGGLE( optsCheatsStr[3], &cheatInfinitelives ), + DEF_OPT_TOGGLE( optsCheatsStr[4], &cheatSuperspeed), + +}; + /* submenu definitions */ #ifdef BETTERCAMERA @@ -215,6 +234,7 @@ static struct SubMenu menuCamera = DEF_SUBMENU( menuStr[4], optsCamera ); static struct SubMenu menuControls = DEF_SUBMENU( menuStr[5], optsControls ); static struct SubMenu menuVideo = DEF_SUBMENU( menuStr[6], optsVideo ); static struct SubMenu menuAudio = DEF_SUBMENU( menuStr[7], optsAudio ); +static struct SubMenu menuCheats = DEF_SUBMENU( menuStr[9], optsCheats ); /* main options menu definition */ @@ -226,6 +246,8 @@ static struct Option optsMain[] = { DEF_OPT_SUBMENU( menuStr[6], &menuVideo ), DEF_OPT_SUBMENU( menuStr[7], &menuAudio ), DEF_OPT_BUTTON ( menuStr[8], optmenu_act_exit ), + DEF_OPT_SUBMENU( menuStr[9], &menuCheats ), + }; static struct SubMenu menuMain = DEF_SUBMENU( menuStr[3], optsMain ); diff --git a/src/pc/configfile.c b/src/pc/configfile.c index 3c2735c2..c9d025c9 100644 --- a/src/pc/configfile.c +++ b/src/pc/configfile.c @@ -37,6 +37,14 @@ bool configFullscreen = false; unsigned int configFiltering = 1; // 0=force nearest, 1=linear, (TODO) 2=three-point unsigned int configMasterVolume = MAX_VOLUME; // 0 - MAX_VOLUME +// Cheat stuff +bool cheatEnablecheats = false; +bool cheatMoonjump = false; +bool cheatGodmode = false; +bool cheatInfinitelives = false; +bool cheatSuperspeed = false; + + // Keyboard mappings (VK_ values, by default keyboard/gamepad/mouse) unsigned int configKeyA[MAX_BINDS] = { 0x0026, 0x1000, 0x1103 }; unsigned int configKeyB[MAX_BINDS] = { 0x0033, 0x1002, 0x1101 }; diff --git a/src/pc/configfile.h b/src/pc/configfile.h index 49b48b93..42ee7a62 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -24,6 +24,11 @@ extern unsigned int configKeyStickUp[]; extern unsigned int configKeyStickDown[]; extern unsigned int configKeyStickLeft[]; extern unsigned int configKeyStickRight[]; +extern bool cheatMoonjump; +extern bool cheatGodmode; +extern bool cheatEnablecheats; +extern bool cheatInfinitelives; +extern bool cheatSuperspeed; #ifdef BETTERCAMERA extern unsigned int configCameraXSens; extern unsigned int configCameraYSens; From 1a9c8dbe477af5cde8adaad4c3802e48b27ee839 Mon Sep 17 00:00:00 2001 From: Leon422 Date: Sun, 17 May 2020 23:27:40 +0100 Subject: [PATCH 2/2] Fixed tabs/spaces --- src/pc/configfile.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/pc/configfile.h b/src/pc/configfile.h index 42ee7a62..7911f6b9 100644 --- a/src/pc/configfile.h +++ b/src/pc/configfile.h @@ -24,11 +24,12 @@ extern unsigned int configKeyStickUp[]; extern unsigned int configKeyStickDown[]; extern unsigned int configKeyStickLeft[]; extern unsigned int configKeyStickRight[]; -extern bool cheatMoonjump; -extern bool cheatGodmode; -extern bool cheatEnablecheats; -extern bool cheatInfinitelives; -extern bool cheatSuperspeed; +extern bool cheatMoonjump; +extern bool cheatGodmode; +extern bool cheatEnablecheats; +extern bool cheatInfinitelives; +extern bool cheatSuperspeed; + #ifdef BETTERCAMERA extern unsigned int configCameraXSens; extern unsigned int configCameraYSens;