* A couple of fixes which deal with "multiple ROMs in a single archive" case. The loading procedure now takes into account actual ROM name when loading ROM from an archive containing multiple files. This affects PAL/NTSC detection (in case there were ROMs of different regions inside a single zip). Also, "auto-resume play" now loads actual ROM on startup (instead of prompting a list of archived files to choose). Also, NL files (symbolic debug) are named correctly when debugging a ROM from such an archive, etc.

This commit is contained in:
ansstuff 2013-06-08 15:01:00 +00:00
parent c61bc9d104
commit f07e49b270
6 changed files with 37 additions and 29 deletions

View File

@ -1385,7 +1385,8 @@ BOOL CALLBACK IDC_DEBUGGER_DISASSEMBLY_WndProc(HWND hwndDlg, UINT uMsg, WPARAM w
if (i >= 0x8000) if (i >= 0x8000)
{ {
dotdot[0] = 0; dotdot[0] = 0;
if (!(ptr = iNesShortFName())) ptr = iNesShortFName();
if (!ptr)
ptr = "..."; ptr = "...";
if (strlen(ptr) > 60) if (strlen(ptr) > 60)
strcpy(dotdot, "..."); strcpy(dotdot, "...");

View File

@ -19,6 +19,7 @@
*/ */
#include "common.h" #include "common.h"
#include "utils/xstring.h"
#include "debuggersp.h" #include "debuggersp.h"
#include "debugger.h" #include "debugger.h"
#include "../../fceu.h" #include "../../fceu.h"
@ -549,7 +550,7 @@ void loadNameFiles()
free(ramBankNames); free(ramBankNames);
// The NL file for the RAM addresses has the name nesrom.nes.ram.nl // The NL file for the RAM addresses has the name nesrom.nes.ram.nl
strcpy(NLfilename, LoadedRomFName); strcpy(NLfilename, mass_replace(LoadedRomFName, "|", ".").c_str());
strcat(NLfilename, ".ram.nl"); strcat(NLfilename, ".ram.nl");
// Load the address descriptions for the RAM addresses // Load the address descriptions for the RAM addresses
@ -568,7 +569,7 @@ void loadNameFiles()
lastBank = cb; lastBank = cb;
// Get the name of the NL file // Get the name of the NL file
sprintf(NLfilename, "%s.%X.nl", LoadedRomFName, lastBank); sprintf(NLfilename, "%s.%X.nl", mass_replace(LoadedRomFName, "|", ".").c_str(), lastBank);
if (lastBankNames) if (lastBankNames)
freeList(lastBankNames); freeList(lastBankNames);
@ -591,7 +592,7 @@ void loadNameFiles()
loadedBank = cb; loadedBank = cb;
// Get the name of the NL file // Get the name of the NL file
sprintf(NLfilename, "%s.%X.nl", LoadedRomFName, loadedBank); sprintf(NLfilename, "%s.%X.nl", mass_replace(LoadedRomFName, "|", ".").c_str(), loadedBank);
if (loadedBankNames) if (loadedBankNames)
freeList(loadedBankNames); freeList(loadedBankNames);

View File

@ -157,7 +157,7 @@ int storeHexPreferences(FILE* f)
* @param romname Name of the ROM * @param romname Name of the ROM
* @return 0 on success or an error code. * @return 0 on success or an error code.
**/ **/
int storePreferences(char* romname) int storePreferences(const char* romname)
{ {
if (debuggerSaveLoadDEBFiles == false) { if (debuggerSaveLoadDEBFiles == false) {
@ -197,7 +197,7 @@ int storePreferences(char* romname)
*/ */
filename = (char*)malloc(strlen(romname) + 5); filename = (char*)malloc(strlen(romname) + 5);
strcpy(filename, mass_replace(romname, "|", ".").c_str()); //convert | to . for archive filenames strcpy(filename, romname);
strcat(filename, ".deb"); strcat(filename, ".deb");
f = fopen(filename, "wb"); f = fopen(filename, "wb");
@ -380,7 +380,7 @@ int loadHexPreferences(FILE* f)
* @param romname Name of the active ROM file * @param romname Name of the active ROM file
* @return 0 or an error code. * @return 0 or an error code.
**/ **/
int loadPreferences(char* romname) int loadPreferences(const char* romname)
{ {
if (debuggerSaveLoadDEBFiles == false) { if (debuggerSaveLoadDEBFiles == false) {
return 0; return 0;
@ -394,7 +394,7 @@ int loadPreferences(char* romname)
// Get the name of the preferences file // Get the name of the preferences file
char* filename = (char*)malloc(strlen(romname) + 5); char* filename = (char*)malloc(strlen(romname) + 5);
strcpy(filename, mass_replace(romname, "|", ".").c_str()); //convert | to . for archive filenames strcpy(filename, romname);
strcat(filename, ".deb"); strcat(filename, ".deb");
f = fopen(filename, "rb"); f = fopen(filename, "rb");

View File

@ -23,6 +23,6 @@
extern int myNumWPs; extern int myNumWPs;
extern bool inDebugger; extern bool inDebugger;
int storePreferences(char* romname); int storePreferences(const char* romname);
int loadPreferences(char* romname); int loadPreferences(const char* romname);
void DoDebuggerDataReload(); void DoDebuggerDataReload();

View File

@ -45,6 +45,7 @@
#include "ines.h" #include "ines.h"
#ifdef WIN32 #ifdef WIN32
#include "drivers/win/pref.h" #include "drivers/win/pref.h"
#include "utils/xstring.h"
extern void CDLoggerROMClosed(); extern void CDLoggerROMClosed();
extern void CDLoggerROMChanged(); extern void CDLoggerROMChanged();
@ -155,10 +156,8 @@ static void FCEU_CloseGame(void)
#ifdef WIN32 #ifdef WIN32
extern char LoadedRomFName[2048]; extern char LoadedRomFName[2048];
if (storePreferences(LoadedRomFName)) if (storePreferences(mass_replace(LoadedRomFName, "|", ".").c_str()))
{
FCEUD_PrintError("Couldn't store debugging data"); FCEUD_PrintError("Couldn't store debugging data");
}
CDLoggerROMClosed(); CDLoggerROMClosed();
#endif #endif
@ -396,8 +395,7 @@ FCEUGI *FCEUI_LoadGameVirtual(const char *name, int OverwriteVidMode, bool silen
//---------- //----------
//attempt to open the files //attempt to open the files
FCEUFILE *fp; FCEUFILE *fp;
char fullname[2048]; // this name contains both archive name and ROM file name
FCEU_printf("Loading %s...\n\n", name);
const char* romextensions[] = { "nes", "fds", 0 }; const char* romextensions[] = { "nes", "fds", 0 };
fp = FCEU_fopen(name, 0, "rb", 0, -1, romextensions); fp = FCEU_fopen(name, 0, "rb", 0, -1, romextensions);
@ -407,16 +405,21 @@ FCEUGI *FCEUI_LoadGameVirtual(const char *name, int OverwriteVidMode, bool silen
if (!silent) if (!silent)
FCEU_PrintError("Error opening \"%s\"!", name); FCEU_PrintError("Error opening \"%s\"!", name);
return 0; return 0;
} else if (fp->archiveFilename != "")
{
strcpy(fullname, fp->archiveFilename.c_str());
strcat(fullname, "|");
strcat(fullname, fp->filename.c_str());
} else
{
strcpy(fullname, name);
} }
GetFileBase(fp->filename.c_str());
//---------
//file opened ok. start loading. //file opened ok. start loading.
FCEU_printf("Loading %s...\n\n", fullname);
GetFileBase(fp->filename.c_str());
ResetGameLoaded(); ResetGameLoaded();
//reset parameters so they're cleared just in case a format's loader doesn't know to do the clearing
//reset parameters so theyre cleared just in case a format's loader doesnt know to do the clearing
MasterRomInfoParams = TMasterRomInfoParams(); MasterRomInfoParams = TMasterRomInfoParams();
if (!AutosaveStatus) if (!AutosaveStatus)
@ -429,7 +432,8 @@ FCEUGI *FCEUI_LoadGameVirtual(const char *name, int OverwriteVidMode, bool silen
memset(GameInfo, 0, sizeof(FCEUGI)); memset(GameInfo, 0, sizeof(FCEUGI));
GameInfo->filename = strdup(fp->filename.c_str()); GameInfo->filename = strdup(fp->filename.c_str());
if (fp->archiveFilename != "") GameInfo->archiveFilename = strdup(fp->archiveFilename.c_str()); if (fp->archiveFilename != "")
GameInfo->archiveFilename = strdup(fp->archiveFilename.c_str());
GameInfo->archiveCount = fp->archiveCount; GameInfo->archiveCount = fp->archiveCount;
GameInfo->soundchan = 0; GameInfo->soundchan = 0;
@ -445,13 +449,13 @@ FCEUGI *FCEUI_LoadGameVirtual(const char *name, int OverwriteVidMode, bool silen
bool FCEUXLoad(const char *name, FCEUFILE * fp); bool FCEUXLoad(const char *name, FCEUFILE * fp);
/*if(FCEUXLoad(name,fp)) /*if(FCEUXLoad(name,fp))
goto endlseq;*/ goto endlseq;*/
if (iNESLoad(name, fp, OverwriteVidMode)) if (iNESLoad(fullname, fp, OverwriteVidMode))
goto endlseq; goto endlseq;
if (NSFLoad(name, fp)) if (NSFLoad(fullname, fp))
goto endlseq; goto endlseq;
if (UNIFLoad(name, fp)) if (UNIFLoad(fullname, fp))
goto endlseq; goto endlseq;
if (FDSLoad(name, fp)) if (FDSLoad(fullname, fp))
goto endlseq; goto endlseq;
if (!silent) if (!silent)
@ -472,7 +476,7 @@ FCEUGI *FCEUI_LoadGameVirtual(const char *name, int OverwriteVidMode, bool silen
extern char LoadedRomFName[2048]; extern char LoadedRomFName[2048];
extern int loadDebugDataFailed; extern int loadDebugDataFailed;
if ((loadDebugDataFailed = loadPreferences(LoadedRomFName))) if ((loadDebugDataFailed = loadPreferences(mass_replace(LoadedRomFName, "|", ".").c_str())))
if (!silent) if (!silent)
FCEU_printf("Couldn't load debugging data.\n"); FCEU_printf("Couldn't load debugging data.\n");

View File

@ -949,8 +949,10 @@ int iNesSaveAs(char* name)
char *iNesShortFName() { char *iNesShortFName() {
char *ret; char *ret;
if (!(ret = strrchr(LoadedRomFName, '\\'))) { if (!(ret = strrchr(LoadedRomFName, '\\')))
if (!(ret = strrchr(LoadedRomFName, '/'))) return 0; {
if (!(ret = strrchr(LoadedRomFName, '/')))
return 0;
} }
return ret + 1; return ret + 1;
} }