From 1ab8226f0d7cf45b5609c8c36c66154fcf37ba76 Mon Sep 17 00:00:00 2001 From: tmaul Date: Thu, 8 Apr 2021 21:09:19 +0100 Subject: [PATCH] SDL2: Fix up cheats (still missing UI --- src/burner/conc.cpp | 16 ++++++++++++++-- src/burner/sdl/config.cpp | 14 +++++++------- src/burner/sdl/drv.cpp | 2 +- src/burner/sdl/sdl2_gui_ingame.cpp | 14 +++++++------- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/burner/conc.cpp b/src/burner/conc.cpp index 10b585970..e07e94c15 100644 --- a/src/burner/conc.cpp +++ b/src/burner/conc.cpp @@ -35,6 +35,20 @@ static void CheatError(TCHAR* pszFilename, INT32 nLineNumber, CheatInfo* pCheat, } FBAPopupDisplay(PUF_TYPE_ERROR); +#elseif defined(BUILD_SDL2) + printf("Cheat file %s is malformed.\nPlease remove or repair the file.\n\n", pszFilename); + if (pCheat) { + printf("Parse error at line %i, in cheat \"%s\".\n", nLineNumber, pCheat->szCheatName); + } else { + printf("Parse error at line %i.\n", nLineNumber); + } + + if (pszInfo) { + printf("Problem:\t%s.\n", pszInfo); + } + if (pszLine) { + printf("Text:\t%s\n", pszLine); + } #endif } @@ -671,5 +685,3 @@ INT32 ConfigCheatLoad() return 0; } - - diff --git a/src/burner/sdl/config.cpp b/src/burner/sdl/config.cpp index 4062bf7b9..9bb9a62b4 100644 --- a/src/burner/sdl/config.cpp +++ b/src/burner/sdl/config.cpp @@ -9,7 +9,7 @@ static char* szSDLconfigPath = NULL; static void CreateConfigName(char* szConfig) { -#if defined(BUILD_SDL2) && !defined(SDL_WINDOWS) +#if defined(BUILD_SDL2) && !defined(SDL_WINDOWS) char cfgdir[MAX_PATH] = { 0 }; if (szSDLconfigPath == NULL) @@ -19,7 +19,7 @@ static void CreateConfigName(char* szConfig) snprintf(cfgdir, MAX_PATH, "%sfbneo.ini", szSDLconfigPath); memcpy(szConfig, cfgdir, sizeof(cfgdir)); -#else +#else _stprintf(szConfig, _T("fbneo.ini")); #endif @@ -64,9 +64,9 @@ int ConfigAppLoad() VAR(nVidSelect); // video mode select VAR(bVidFullStretch); VAR(nAutoFireRate); - VAR(bAlwaysMenu); - VAR(nGameSelect); - VAR(nFilterSelect); + VAR(bAlwaysMenu); + VAR(nGameSelect); + VAR(nFilterSelect); VAR(bShowAvailableOnly); VAR(bShowClones); VAR(gameSelectedFromFilter); @@ -125,7 +125,7 @@ int ConfigAppLoad() STR(szAppListsPath); STR(szAppDatListsPath); STR(szAppArchivesPath); - + #undef STR #undef FLT #undef VAR @@ -219,7 +219,7 @@ int ConfigAppSave() STR(szAppPreviewsPath); fprintf(f, "\n// Path to titlescreen images for use on the menu (include trailing slash)\n"); STR(szAppTitlesPath); - fprintf(f, "\n// UNUSED CURRENTLY (include trailing slash)\n"); + fprintf(f, "\n// Cheat files path (include trailing slash)\n"); STR(szAppCheatsPath); fprintf(f, "\n// Hiscore save path (include trailing slash)\n"); STR(szAppHiscorePath); diff --git a/src/burner/sdl/drv.cpp b/src/burner/sdl/drv.cpp index 914a50f27..4d6cae02c 100644 --- a/src/burner/sdl/drv.cpp +++ b/src/burner/sdl/drv.cpp @@ -127,7 +127,7 @@ int DrvInit(int nDrvNum, bool bRestore) bSaveRAM = false; nBurnLayer = 0xFF; // show all layers - + ConfigCheatLoad(); // Reset the speed throttling code, so we don't 'jump' after the load RunReset(); VidExit(); diff --git a/src/burner/sdl/sdl2_gui_ingame.cpp b/src/burner/sdl/sdl2_gui_ingame.cpp index 62be64ddb..307f8c019 100644 --- a/src/burner/sdl/sdl2_gui_ingame.cpp +++ b/src/burner/sdl/sdl2_gui_ingame.cpp @@ -239,15 +239,15 @@ void ingame_gui_start(SDL_Renderer* renderer) while (!finished) { - starting_stick = SDL_GetTicks(); - + starting_stick = SDL_GetTicks(); + finished = ingame_gui_process(); ingame_gui_render(); - - // limit 5 FPS (free CPU usage) - if ( ( 1000 / 5 ) > SDL_GetTicks() - starting_stick) { - SDL_Delay( 1000 / 5 - ( SDL_GetTicks() - starting_stick ) ); - } + // limit 5 FPS (free CPU usage) + if ( ( 1000 / 5 ) > SDL_GetTicks() - starting_stick) + { + SDL_Delay( 1000 / 5 - ( SDL_GetTicks() - starting_stick ) ); + } } ingame_gui_exit();