]> Shamusworld >> Repos - virtualjaguar/blobdiff - src/file.cpp
Virtual Jaguar 2.0.0 release.
[virtualjaguar] / src / file.cpp
index 4b389e653503f432df0524dd22017e91d5343768..7fd96ef59edaad467be216dbc7e9875928aac9c7 100644 (file)
@@ -126,9 +126,11 @@ bool JaguarLoadFile(char * path)
        EepromInit();
        jaguarRunAddress = 0x802000;                                    // For non-BIOS runs, this is true
        int fileType = ParseFileType(buffer[0], buffer[1], jaguarROMSize);
+       jaguarCartInserted = false;
 
        if (fileType == JST_ROM)
        {
+               jaguarCartInserted = true;
                memcpy(jagMemSpace + 0x800000, buffer, jaguarROMSize);
                delete[] buffer;
                return true;
@@ -186,7 +188,7 @@ bool JaguarLoadFile(char * path)
 //
 // "Alpine" file loading
 // Since the developers were coming after us with torches and pitchforks, we decided to
-// allow this kind of thing. ;-) But ONLY FOR THE DEVS, DAMMIT! O_O
+// allow this kind of thing. ;-) But ONLY FOR THE DEVS, DAMMIT! >:-U O_O
 //
 bool AlpineLoadFile(char * path)
 {
@@ -252,7 +254,15 @@ static int gzfilelength(gzFile gd)
 //
 static bool CheckExtension(const char * filename, const char * ext)
 {
+       // Sanity checking...
+       if ((filename == NULL) || (ext == NULL))
+               return false;
+
        const char * filenameExt = strrchr(filename, '.');      // Get the file's extension (if any)
+
+       if (filenameExt == NULL)
+               return false;
+
        return (strcasecmp(filenameExt, ext) == 0 ? true : false);
 }
 
@@ -361,7 +371,8 @@ uint32 ParseFileType(uint8 header1, uint8 header2, uint32 size)
 
        // If the file size is divisible by 1M, we probably have an regular ROM.
        // We can also check our CRC32 against the internal ROM database to be sure.
-       if ((size % 1048576) == 0)
+       // (We also check for the Memory Track cartridge size here as well...)
+       if ((size % 1048576) == 0 || size == 131072)
                return JST_ROM;
 
        // If the file size + 8192 bytes is divisible by 1M, we probably have an