Add support for loading .msu1 packs as ROM files, if they actually contain a ROM file

This commit is contained in:
qwertymodo 2017-08-17 11:30:44 -07:00
parent 96fd5c4121
commit 9e804b4515
3 changed files with 44 additions and 25 deletions

View File

@ -209,7 +209,7 @@ bool8 LoadZip (const char *zipname, uint32 *TotalFileSize, uint8 *buffer)
if (file == NULL)
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];
uint32 filesize = 0;
int port = unzGoToFirstFile(file);
@ -241,10 +241,19 @@ bool8 LoadZip (const char *zipname, uint32 *TotalFileSize, uint8 *buffer)
break;
}
if (strncasecmp(name, "program.rom", 11) == 0)
{
strcpy(filename, name);
filesize = info.uncompressed_size;
break;
}
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);
return (FALSE);

View File

@ -1439,7 +1439,7 @@ uint32 CMemory::FileLoader (uint8 *buffer, const char *filename, uint32 maxsize)
_makepath(fname, drive, dir, name, exts);
int nFormat = FILE_DEFAULT;
if (strcasecmp(ext, "zip") == 0)
if (strcasecmp(ext, "zip") == 0 || strcasecmp(ext, "msu1") == 0)
nFormat = FILE_ZIP;
else
if (strcasecmp(ext, "jma") == 0)
@ -4258,6 +4258,8 @@ void CMemory::CheckForAnyPatch (const char *rom_filename, bool8 header, int32 &r
#ifdef UNZIP_SUPPORT
// Mercurial Magic (MSU-1 distribution pack)
if (strcasecmp(ext, "msu1") && strcasecmp(ext, ".msu1"))
{
_makepath(fname, drive, dir, name, "msu1");
unzFile msu1file = unzOpen(fname);
@ -4285,6 +4287,7 @@ void CMemory::CheckForAnyPatch (const char *rom_filename, bool8 header, int32 &r
printf(" failed!\n");
}
}
}
if (!strcasecmp(ext, "zip") || !strcasecmp(ext, ".zip"))
{

View File

@ -7020,10 +7020,17 @@ void MakeExtFile(void)
ofstream out;
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<<"bsN"<<endl;
out<<"jmaY";
out<<"jmaY"<<endl;
out.close();
SetFileAttributes(TEXT("Valid.Ext"), FILE_ATTRIBUTE_ARCHIVE|FILE_ATTRIBUTE_READONLY);
};