- if (jaguarMainRom[0] == 0x60 && jaguarMainRom[1] == 0x1B)
- {
- uint32 loadAddress = GET32(jaguarMainRom, 0x16), //runAddress = GET32(jaguar_mainRom, 0x2A),
- codeSize = GET32(jaguarMainRom, 0x02) + GET32(jaguarMainRom, 0x06);
- WriteLog("GUI: Setting up homebrew (ABS-1)... Run address: %08X, length: %08X\n", loadAddress, codeSize);
-
- if (loadAddress < 0x800000)
- memcpy(jaguarMainRam + loadAddress, jaguarMainRom + 0x24, codeSize);
- else
- {
- for(int i=codeSize-1; i>=0; i--)
- jaguarMainRom[(loadAddress - 0x800000) + i] = jaguarMainRom[i + 0x24];
-/* memcpy(jaguar_mainRam, jaguar_mainRom + 0x24, codeSize);
- memset(jaguar_mainRom, 0xFF, 0x600000);
- memcpy(jaguar_mainRom + (loadAddress - 0x800000), jaguar_mainRam, codeSize);
- memset(jaguar_mainRam, 0x00, 0x400000);*/
- }
-
- jaguarRunAddress = loadAddress;
- }
- else if (jaguarMainRom[0] == 0x01 && jaguarMainRom[1] == 0x50)
- {
- uint32 loadAddress = GET32(jaguarMainRom, 0x28), runAddress = GET32(jaguarMainRom, 0x24),
- codeSize = GET32(jaguarMainRom, 0x18) + GET32(jaguarMainRom, 0x1C);
- WriteLog("GUI: Setting up homebrew (ABS-2)... Run address: %08X, length: %08X\n", runAddress, codeSize);
-
- if (loadAddress < 0x800000)
- memcpy(jaguarMainRam + loadAddress, jaguarMainRom + 0xA8, codeSize);
- else
- {
- for(int i=codeSize-1; i>=0; i--)
- jaguarMainRom[(loadAddress - 0x800000) + i] = jaguarMainRom[i + 0xA8];
-/* memcpy(jaguar_mainRam, jaguar_mainRom + 0xA8, codeSize);
- memset(jaguar_mainRom, 0xFF, 0x600000);
- memcpy(jaguar_mainRom + (loadAddress - 0x800000), jaguar_mainRam, codeSize);
- memset(jaguar_mainRam, 0x00, 0x400000);*/
- }
-
- jaguarRunAddress = runAddress;
- }
- else
- {
- WriteLog("GUI: Couldn't find correct ABS format: %02X %02X\n", jaguarMainRom[0], jaguarMainRom[1]);
- return false;
- }
- }
- else if (strcasecmp(ext, ".jag") == 0)
- {
- // File extension ".JAG": Atari server file with header
-//NOTE: The bytes 'JAGR' should also be at position $1C...
-// Also, there's *always* a $601A header at position $00...
- if (jaguarMainRom[0] == 0x60 && jaguarMainRom[1] == 0x1A)
- {
- uint32 loadAddress = GET32(jaguarMainRom, 0x22), runAddress = GET32(jaguarMainRom, 0x2A);
-//This is not always right! Especially when converted via bin2jag1!!!
-//We should have access to the length of the furshlumiger file that was loaded anyway!
-//Now, we do! ;-)
-// uint32 progLength = GET32(jaguar_mainRom, 0x02);
-//jaguarRomSize
-//jaguarRunAddress
-// WriteLog("Jaguar: Setting up PD ROM... Run address: %08X, length: %08X\n", runAddress, progLength);
-// memcpy(jaguar_mainRam + loadAddress, jaguar_mainRom + 0x2E, progLength);
- WriteLog("GUI: Setting up homebrew (JAG)... Run address: %08X, length: %08X\n", runAddress, jaguarRomSize - 0x2E);
- memcpy(jaguarMainRam + loadAddress, jaguarMainRom + 0x2E, jaguarRomSize - 0x2E);
-// SET32(jaguar_mainRam, 4, runAddress);
- jaguarRunAddress = runAddress;
- }
- else
- return false;
- }
- // .J64 (Jaguar cartridge ROM image) is implied by the FileList object...
-
- return true;
-}
-
-//
-// Get the length of a (possibly) gzipped file
-//
-static int gzfilelength(gzFile gd)
-{
- int size = 0, length = 0;
- unsigned char buffer[0x10000];
-
- gzrewind(gd);
-
- do
- {
- // Read in chunks until EOF
- size = gzread(gd, buffer, 0x10000);
-
- if (size <= 0)
- break;
-
- length += size;
- }
- while (!gzeof(gd));
-
- gzrewind(gd);
- return length;
-}