From 9dfd0ec905b1155c9166a1ed54acde43371d3cdf Mon Sep 17 00:00:00 2001 From: Bobby Lovell Date: Thu, 16 Nov 2023 21:11:31 -0500 Subject: [PATCH 1/3] Add the main unlock hacks --- src/game/gamefile.c | 54 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/game/gamefile.c b/src/game/gamefile.c index d8d36474e..fba27901a 100644 --- a/src/game/gamefile.c +++ b/src/game/gamefile.c @@ -567,3 +567,57 @@ void gamefileGetOverview(char *arg0, char *name, u8 *stage, u8 *difficulty, u32 *difficulty = savebufferReadBits(&buffer, 2); } + +#ifndef PLATFORM_N64 +// Unlock all of the unlockables. +// These hacks are taken from the original debug mode. +void gamefileUnlockEverything(void) +{ + s32 i, j; + + // unlock all challenges + for (i = 0; i < ARRAYCOUNT(g_MpChallenges); ++i) { + for (j = 0; j < MAX_PLAYERS; ++j) { + g_MpChallenges[i].completions[j] = 0x0f; + } + } + challengeDetermineUnlockedFeatures(); + + // complete all missions in coop + for (i = 0; i < ARRAYCOUNT(g_GameFile.coopcompletions); ++i) { + g_GameFile.coopcompletions[i] = 0x1fffff; + } + + // unlock all guns + for (i = 0; i < ARRAYCOUNT(g_GameFile.weaponsfound); ++i) { + g_GameFile.weaponsfound[i] = 0xff; + } + + // unlock all campaign levels + for (i = 0; i < NUM_SOLOSTAGES; i++) { + for (j = 0; j < 3; j++) { + g_GameFile.besttimes[i][j] = 7; + } + } + + // unlock alternate intro sequence + g_AltTitleUnlocked = true; + + // unlock all firing range challenges + for (i = 0; i < ARRAYCOUNT(g_GameFile.firingrangescores); ++i) { + g_GameFile.firingrangescores[i] = 0xff; + } + + // unlock all device training + gamefileSetFlag(GAMEFILEFLAG_CI_CLOAK_DONE); + gamefileSetFlag(GAMEFILEFLAG_CI_DISGUISE_DONE); + gamefileSetFlag(GAMEFILEFLAG_CI_XRAY_DONE); + gamefileSetFlag(GAMEFILEFLAG_CI_IR_DONE); + gamefileSetFlag(GAMEFILEFLAG_CI_RTRACKER_DONE); + gamefileSetFlag(GAMEFILEFLAG_CI_DOORDECODER_DONE); + gamefileSetFlag(GAMEFILEFLAG_CI_NIGHTVISION_DONE); + gamefileSetFlag(GAMEFILEFLAG_CI_CAMSPY_DONE); + gamefileSetFlag(GAMEFILEFLAG_CI_ECMMINE_DONE); + gamefileSetFlag(GAMEFILEFLAG_CI_UPLINK_DONE); +} +#endif From 27e36ca24ecfc44f1fe992ff5fb13c0120b109e1 Mon Sep 17 00:00:00 2001 From: Bobby Lovell Date: Fri, 17 Nov 2023 09:23:00 -0500 Subject: [PATCH 2/3] Add prototype. --- src/include/game/gamefile.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/include/game/gamefile.h b/src/include/game/gamefile.h index 62fa97830..e3f8c6431 100644 --- a/src/include/game/gamefile.h +++ b/src/include/game/gamefile.h @@ -13,5 +13,6 @@ void gamefileLoadDefaults(struct gamefile *file); s32 gamefileLoad(s32 device); s32 gamefileSave(s32 device, s32 filenum, u16 deviceserial); void gamefileGetOverview(char *arg0, char *name, u8 *stage, u8 *difficulty, u32 *time); +void gamefileUnlockEverything(void); #endif From 99da0586ea4b5ce3a5daafa32e9f82b261e1c2cf Mon Sep 17 00:00:00 2001 From: Bobby Lovell Date: Fri, 17 Nov 2023 09:28:43 -0500 Subject: [PATCH 3/3] Add menu and confirmation prompt. --- port/src/optionsmenu.c | 86 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/port/src/optionsmenu.c b/port/src/optionsmenu.c index 4e428071c..a67fae0bb 100644 --- a/port/src/optionsmenu.c +++ b/port/src/optionsmenu.c @@ -7,6 +7,7 @@ #include "types.h" #include "game/mainmenu.h" #include "game/menu.h" +#include "game/gamefile.h" #include "video.h" #include "input.h" #include "config.h" @@ -1060,6 +1061,83 @@ static MenuItemHandlerResult menuhandlerOpenBindsMenu(s32 operation, struct menu return 0; } +static MenuItemHandlerResult menuhandlerUnlockEverything(s32 operation, struct menuitem *item, union handlerdata *data) +{ + if (operation == MENUOP_SET) { + gamefileUnlockEverything(); + } + return 0; +} + +struct menuitem g_ConfirmUnlockMenuItems[] = { + { + MENUITEMTYPE_LABEL, + 0, + MENUITEMFLAG_LITERAL_TEXT, + (uintptr_t)"Are you sure?\n\nThis will overwrite any progress\nsaved to the current profile.\n", + 0, + NULL, + }, + { + MENUITEMTYPE_SEPARATOR, + 0, + 0, + 0x00000082, + 0, + NULL, + }, + { + MENUITEMTYPE_MARQUEE, + 0, + MENUITEMFLAG_SMALLFONT | MENUITEMFLAG_MARQUEE_FADEBOTHSIDES | MENUITEMFLAG_LITERAL_TEXT, + (uintptr_t)"Unlocks all cheats, weapons, missions, challenges and combat simulator items.\n", + 0, + NULL, + }, + { + MENUITEMTYPE_SEPARATOR, + 0, + 0, + 0x00000082, + 0, + NULL, + }, + { + MENUITEMTYPE_SELECTABLE, + 0, + MENUITEMFLAG_SELECTABLE_CENTRE | MENUITEMFLAG_SELECTABLE_CLOSESDIALOG, + L_OPTIONS_191, // "No" + 0, + NULL, + }, + { + MENUITEMTYPE_SELECTABLE, + 0, + MENUITEMFLAG_SELECTABLE_CENTRE | MENUITEMFLAG_SELECTABLE_CLOSESDIALOG, + L_OPTIONS_190, // "Yes" + 0, + menuhandlerUnlockEverything, + }, + { MENUITEMTYPE_END }, +}; + +struct menudialogdef g_ConfirmUnlockMenuDialog = { + MENUDIALOGTYPE_DANGER, + L_OPTIONS_188, // "Warning" + g_ConfirmUnlockMenuItems, + NULL, + 0, + NULL, +}; + +static MenuItemHandlerResult menuhandlerUnlockEverythingPrompt(s32 operation, struct menuitem *item, union handlerdata *data) +{ + if (operation == MENUOP_SET) { + menuPushDialog(&g_ConfirmUnlockMenuDialog); + } + return 0; +} + struct menuitem g_ExtendedMenuItems[] = { { MENUITEMTYPE_SELECTABLE, @@ -1101,6 +1179,14 @@ struct menuitem g_ExtendedMenuItems[] = { 0, menuhandlerOpenBindsMenu, }, + { + MENUITEMTYPE_SELECTABLE, + 0, + MENUITEMFLAG_LITERAL_TEXT, + (uintptr_t)"Unlock Everything\n", + 0, + menuhandlerUnlockEverythingPrompt, + }, { MENUITEMTYPE_SEPARATOR, 0,