diff options
author | zeromus <zeromus@users.noreply.github.com> | 2022-08-28 11:33:38 +0300 |
---|---|---|
committer | zeromus <zeromus@users.noreply.github.com> | 2022-08-28 11:33:38 +0300 |
commit | 60f7b875f80958248e7def8f200efd4ba60dd003 (patch) | |
tree | 2ca1f278866c8060edd4c0730e88afb7c350b832 | |
parent | 20d03d4434ca2a473dcb33e61ce6a3da4fddcc19 (diff) |
winport - support loading ips files on top of already loaded roms. I guess this could be factored to an FCEUI_TestFileIsPatch and an FCEUI_ReloadWithPatch?? well, that's for whoever does this on other platforms to do.
-rw-r--r-- | src/drivers/win/window.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/drivers/win/window.cpp b/src/drivers/win/window.cpp index 3effd90d..82c845b5 100644 --- a/src/drivers/win/window.cpp +++ b/src/drivers/win/window.cpp @@ -38,6 +38,9 @@ #include "video.h" #include "input.h" #include "fceu.h" +#include "types.h" +#include "cart.h" +#include "ines.h" #include "cheat.h" #include "ram_search.h" @@ -1075,6 +1078,37 @@ void CloseGame() bool ALoad(const char *nameo, char* innerFilename, bool silent) { + FCEUFILE* patchTrial = FCEU_fopen(nameo,nullptr,"rb",nullptr,-1); + if(patchTrial) + { + char sig[10] = {0}; + FCEU_fread(sig,1,5,patchTrial); + FCEU_fclose(patchTrial); + if(!strcmp(sig,"PATCH")) + { + //assuming it's a patch: + + //if nothing's loaded, we can't load this + if(!LoadedRomFName[0]) + return false; + + //ok, set this as a patch and load it + //use a temp std::string to avoid problems copying from LoadedRomFName, to LoadedRomFName + //pass nullptr as innerFilename -- see, it's not used here anyway + strcpy(LoadedRomFNamePatchToUse,nameo); + std::string tmp_LoadedRomFName = LoadedRomFName; + bool ret = ALoad(tmp_LoadedRomFName.c_str(),nullptr,silent); + + //clear the patch file. FCEUX doesn't seem to ever reload the roms (?) so it can't need to reuse it + //and if it does.. well.. it won't be patched. + //there's only so much we can do with this old framework + LoadedRomFNamePatchToUse[0] = 0; + + return ret; + } + } + + int oldPaused = EmulationPaused; // loading is not started yet, so the game can continue; |