mirror of https://github.com/snes9xgit/snes9x.git
Add support for loading .msu1 packs as ROM files, if they actually contain a ROM file
This commit is contained in:
parent
96fd5c4121
commit
9e804b4515
13
loadzip.cpp
13
loadzip.cpp
|
@ -209,7 +209,7 @@ bool8 LoadZip (const char *zipname, uint32 *TotalFileSize, uint8 *buffer)
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
|
|
||||||
// find largest file in zip file (under MAX_ROM_SIZE) or a file with extension .1
|
// find largest file in zip file (under MAX_ROM_SIZE) or a file with extension .1, or a file named program.rom
|
||||||
char filename[132];
|
char filename[132];
|
||||||
uint32 filesize = 0;
|
uint32 filesize = 0;
|
||||||
int port = unzGoToFirstFile(file);
|
int port = unzGoToFirstFile(file);
|
||||||
|
@ -241,10 +241,19 @@ bool8 LoadZip (const char *zipname, uint32 *TotalFileSize, uint8 *buffer)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strncasecmp(name, "program.rom", 11) == 0)
|
||||||
|
{
|
||||||
|
strcpy(filename, name);
|
||||||
|
filesize = info.uncompressed_size;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
port = unzGoToNextFile(file);
|
port = unzGoToNextFile(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(port == UNZ_END_OF_LIST_OF_FILE || port == UNZ_OK) || filesize == 0)
|
int len = strlen(zipname);
|
||||||
|
if (!(port == UNZ_END_OF_LIST_OF_FILE || port == UNZ_OK) || filesize == 0 ||
|
||||||
|
(len > 5 && strcasecmp(zipname + len - 5, ".msu1") == 0 && strcasecmp(filename, "program.rom") != 0))
|
||||||
{
|
{
|
||||||
assert(unzClose(file) == UNZ_OK);
|
assert(unzClose(file) == UNZ_OK);
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
|
|
45
memmap.cpp
45
memmap.cpp
|
@ -1439,7 +1439,7 @@ uint32 CMemory::FileLoader (uint8 *buffer, const char *filename, uint32 maxsize)
|
||||||
_makepath(fname, drive, dir, name, exts);
|
_makepath(fname, drive, dir, name, exts);
|
||||||
|
|
||||||
int nFormat = FILE_DEFAULT;
|
int nFormat = FILE_DEFAULT;
|
||||||
if (strcasecmp(ext, "zip") == 0)
|
if (strcasecmp(ext, "zip") == 0 || strcasecmp(ext, "msu1") == 0)
|
||||||
nFormat = FILE_ZIP;
|
nFormat = FILE_ZIP;
|
||||||
else
|
else
|
||||||
if (strcasecmp(ext, "jma") == 0)
|
if (strcasecmp(ext, "jma") == 0)
|
||||||
|
@ -4258,31 +4258,34 @@ void CMemory::CheckForAnyPatch (const char *rom_filename, bool8 header, int32 &r
|
||||||
|
|
||||||
#ifdef UNZIP_SUPPORT
|
#ifdef UNZIP_SUPPORT
|
||||||
// Mercurial Magic (MSU-1 distribution pack)
|
// Mercurial Magic (MSU-1 distribution pack)
|
||||||
_makepath(fname, drive, dir, name, "msu1");
|
if (strcasecmp(ext, "msu1") && strcasecmp(ext, ".msu1"))
|
||||||
unzFile msu1file = unzOpen(fname);
|
|
||||||
|
|
||||||
if (!msu1file)
|
|
||||||
{
|
{
|
||||||
_snprintf(fname, sizeof(fname), "%s" SLASH_STR "%s%s",
|
_makepath(fname, drive, dir, name, "msu1");
|
||||||
S9xGetDirectory(IPS_DIR), name, ".msu1");
|
unzFile msu1file = unzOpen(fname);
|
||||||
msu1file = unzOpen(fname);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msu1file)
|
if (!msu1file)
|
||||||
{
|
|
||||||
int port = unzFindExtension(msu1file, "bps");
|
|
||||||
if (port == UNZ_OK)
|
|
||||||
{
|
{
|
||||||
printf(" in %s", fname);
|
_snprintf(fname, sizeof(fname), "%s" SLASH_STR "%s%s",
|
||||||
|
S9xGetDirectory(IPS_DIR), name, ".msu1");
|
||||||
|
msu1file = unzOpen(fname);
|
||||||
|
}
|
||||||
|
|
||||||
Stream *s = new unzStream(msu1file);
|
if (msu1file)
|
||||||
ret = ReadBPSPatch(s, offset, rom_size);
|
{
|
||||||
s->closeStream();
|
int port = unzFindExtension(msu1file, "bps");
|
||||||
|
if (port == UNZ_OK)
|
||||||
|
{
|
||||||
|
printf(" in %s", fname);
|
||||||
|
|
||||||
if (ret)
|
Stream *s = new unzStream(msu1file);
|
||||||
printf("!\n");
|
ret = ReadBPSPatch(s, offset, rom_size);
|
||||||
else
|
s->closeStream();
|
||||||
printf(" failed!\n");
|
|
||||||
|
if (ret)
|
||||||
|
printf("!\n");
|
||||||
|
else
|
||||||
|
printf(" failed!\n");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7020,10 +7020,17 @@ void MakeExtFile(void)
|
||||||
ofstream out;
|
ofstream out;
|
||||||
out.open("Valid.Ext");
|
out.open("Valid.Ext");
|
||||||
|
|
||||||
out<<"smcN"<<endl<<"zipY"<<endl<<"gzY" <<endl<<"swcN"<<endl<<"figN"<<endl;
|
out<<"smcN"<<endl;
|
||||||
|
#ifdef UNZIP_SUPPORT
|
||||||
|
out<<"zipY"<<endl;
|
||||||
|
out<<"msu1Y"<<endl;
|
||||||
|
#endif
|
||||||
|
out<<"gzY"<<endl;
|
||||||
|
out<<"swcN"<<endl;
|
||||||
|
out<<"figN"<<endl;
|
||||||
out<<"sfcN"<<endl;
|
out<<"sfcN"<<endl;
|
||||||
out<<"bsN"<<endl;
|
out<<"bsN"<<endl;
|
||||||
out<<"jmaY";
|
out<<"jmaY"<<endl;
|
||||||
out.close();
|
out.close();
|
||||||
SetFileAttributes(TEXT("Valid.Ext"), FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY);
|
SetFileAttributes(TEXT("Valid.Ext"), FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue