first pass on cheat menu

This commit is contained in:
tmaul 2021-04-08 21:50:32 +01:00
parent a5bf64ed23
commit bfacc33a3b
2 changed files with 52 additions and 13 deletions

View File

@ -36,7 +36,7 @@ char videofiltering[3];
#ifdef BUILD_SDL2
SDL_Window* sdlWindow = NULL;
static char* szSDLeepromPath = NULL;
static char* szSDLhiscorePath = NULL;
static char* szSDLHDDPath = NULL;
@ -64,7 +64,7 @@ int parseSwitches(int argc, char* argv[])
if (strcmp(argv[i] + 1, "menu") == 0)
{
set_commandline_option_not_config(usemenu, 1)
}
if (strcmp(argv[i] + 1, "novsync") == 0)
@ -225,6 +225,7 @@ void generateDats()
void DoGame(int gameToRun)
{
if (!DrvInit(gameToRun, 0))
{
MediaInit();
@ -332,7 +333,7 @@ int main(int argc, char* argv[])
}
// Do these bits before override via ConfigAppLoad
bCheatsAllowed = false;
bCheatsAllowed = 1;
nAudDSPModule[0] = 0;
EnableHiscores = 1;

View File

@ -41,11 +41,17 @@ struct MenuItem
#define LOADSTATE 4
#define SCREENSHOT 5
#define RESET 6
#define CHEATMENU 7
// menu item tracking
static UINT16 current_menu = MAINMENU;
static UINT16 current_selected_item = 0;
static INT32 cheatcount = 0;
struct MenuItem cheatMenu[255];
int QuickSave()
{
QuickState(1);
@ -65,6 +71,32 @@ int MainMenuSelected()
return 0;
}
int CheatMenuSelected()
{
current_selected_item = 0;
current_menu = CHEATMENU;
cheatcount = 0;
int i = 0;
CheatInfo* pCurrentCheat = pCheatInfo;
while (pCurrentCheat) {
pCurrentCheat = pCurrentCheat->pNext;
i++;
}
int c = 0;
pCurrentCheat = pCheatInfo;
while (pCurrentCheat)
{
cheatMenu[c] = {pCurrentCheat->szCheatName, MainMenuSelected, NULL};
pCurrentCheat = pCurrentCheat->pNext;
c++;
}
i++;
cheatMenu[i] = {"BACK \0", MainMenuSelected, NULL};
cheatcount = i;
return 0;
}
int ControllerMenuSelected()
{
current_selected_item = 0;
@ -86,12 +118,13 @@ int BackToGameSelected()
return 1;
}
#define MAINMENU_COUNT 6
#define MAINMENU_COUNT 7
struct MenuItem mainMenu[MAINMENU_COUNT] =
{
{"DIP Switches\0", DIPMenuSelected, NULL},
{"Controller Options\0", ControllerMenuSelected, NULL},
{"Cheats\0", CheatMenuSelected, NULL},
{"Save State\0", QuickSave, NULL},
{"Load State\0", QuickLoad, NULL},
{"Save Screenshot\0", MakeScreenShot, NULL},
@ -119,6 +152,7 @@ static UINT16 current_item_count = MAINMENU_COUNT;
void ingame_gui_init()
{
AudSoundStop();
cheatcount = 0;
}
void ingame_gui_exit()
@ -143,14 +177,18 @@ void ingame_gui_render()
current_item_count = MAINMENU_COUNT;
current_menu_items = mainMenu;
break;
case DIPMENU:
current_item_count = DIPMENU_COUNT;
current_menu_items = dipMenu;
break;
case CONTROLLERMENU:
current_item_count = CONTROLLERMENU_COUNT;
current_menu_items = controllerMenu;
break;
case DIPMENU:
current_item_count = DIPMENU_COUNT;
current_menu_items = dipMenu;
break;
case CONTROLLERMENU:
current_item_count = CONTROLLERMENU_COUNT;
current_menu_items = controllerMenu;
break;
case CHEATMENU:
current_item_count = cheatcount;
current_menu_items = cheatMenu;
break;
}
for(int i=0; i < current_item_count; i ++)
@ -239,7 +277,7 @@ void ingame_gui_start(SDL_Renderer* renderer)
while (!finished)
{
starting_stick = SDL_GetTicks();
starting_stick = SDL_GetTicks();
finished = ingame_gui_process();
ingame_gui_render();