//
// File support
// by James L. Hammons
+// (C) 2010 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// Who When What
+// --- ---------- -------------------------------------------------------------
+// JLH 01/16/2010 Created this log ;-)
//
#include "file.h"
#include "eeprom.h"
#include "jaguar.h"
#include "log.h"
+#include "memory.h"
#include "unzip.h"
#include "zlib.h"
bool JaguarLoadFile(char * path)
{
// jaguarRomSize = JaguarLoadROM(mem, path);
- jaguarRomSize = JaguarLoadROM(jaguarMainRom, path);
+ jaguarROMSize = JaguarLoadROM(jaguarMainROM, path);
/*//This is not *nix friendly for some reason...
// if (!UserSelectFile(path, newPath))
exit(0);
}*/
- if (jaguarRomSize == 0)
+ if (jaguarROMSize == 0)
{
// WriteLog("VJ: Could not load ROM from file \"%s\"...\nAborting!\n", newPath);
WriteLog("GUI: Could not load ROM from file \"%s\"...\nAborting load!\n", path);
return false; // This is a start...
}
- jaguarMainRomCRC32 = crc32_calcCheckSum(jaguarMainRom, jaguarRomSize);
- WriteLog("CRC: %08X\n", (unsigned int)jaguarMainRomCRC32);
+ jaguarMainROMCRC32 = crc32_calcCheckSum(jaguarMainROM, jaguarROMSize);
+ WriteLog("CRC: %08X\n", (unsigned int)jaguarMainROMCRC32);
EepromInit();
jaguarRunAddress = 0x802000;
if (strcasecmp(ext, ".rom") == 0)
{
// File extension ".ROM": Alpine image that loads/runs at $802000
- WriteLog("GUI: Setting up homebrew (ROM)... Run address: 00802000, length: %08X\n", jaguarRomSize);
+ WriteLog("GUI: Setting up homebrew (ROM)... Run address: 00802000, length: %08X\n", jaguarROMSize);
- for(int i=jaguarRomSize-1; i>=0; i--)
- jaguarMainRom[0x2000 + i] = jaguarMainRom[i];
+ for(int i=jaguarROMSize-1; i>=0; i--)
+ jaguarMainROM[0x2000 + i] = jaguarMainROM[i];
- memset(jaguarMainRom, 0xFF, 0x2000);
+ memset(jaguarMainROM, 0xFF, 0x2000);
/* memcpy(jaguar_mainRam, jaguar_mainRom, jaguarRomSize);
memset(jaguar_mainRom, 0xFF, 0x600000);
memcpy(jaguar_mainRom + 0x2000, jaguar_mainRam, jaguarRomSize);
// Try setting the vector to say, $1000 and putting an instruction there that loops forever:
// This kludge works! Yeah!
- SET32(jaguarMainRam, 0x10, 0x00001000);
- SET16(jaguarMainRam, 0x1000, 0x60FE); // Here: bra Here
+ SET32(jaguarMainRAM, 0x10, 0x00001000);
+ SET16(jaguarMainRAM, 0x1000, 0x60FE); // Here: bra Here
}
else if (strcasecmp(ext, ".abs") == 0)
{
Start of Text Segment = 0x00802000
Start of Data Segment = 0x00803dd0
*/
- if (jaguarMainRom[0] == 0x60 && jaguarMainRom[1] == 0x1B)
+ if (jaguarMainROM[0] == 0x60 && jaguarMainROM[1] == 0x1B)
{
- uint32 loadAddress = GET32(jaguarMainRom, 0x16), //runAddress = GET32(jaguar_mainRom, 0x2A),
- codeSize = GET32(jaguarMainRom, 0x02) + GET32(jaguarMainRom, 0x06);
+ 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);
+ memcpy(jaguarMainRAM + loadAddress, jaguarMainROM + 0x24, codeSize);
else
{
for(int i=codeSize-1; i>=0; i--)
- jaguarMainRom[(loadAddress - 0x800000) + i] = jaguarMainRom[i + 0x24];
+ 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);
jaguarRunAddress = loadAddress;
}
- else if (jaguarMainRom[0] == 0x01 && jaguarMainRom[1] == 0x50)
+ else if (jaguarMainROM[0] == 0x01 && jaguarMainROM[1] == 0x50)
{
- uint32 loadAddress = GET32(jaguarMainRom, 0x28), runAddress = GET32(jaguarMainRom, 0x24),
- codeSize = GET32(jaguarMainRom, 0x18) + GET32(jaguarMainRom, 0x1C);
+ 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);
+ memcpy(jaguarMainRAM + loadAddress, jaguarMainROM + 0xA8, codeSize);
else
{
for(int i=codeSize-1; i>=0; i--)
- jaguarMainRom[(loadAddress - 0x800000) + i] = jaguarMainRom[i + 0xA8];
+ 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);
}
else
{
- WriteLog("GUI: Couldn't find correct ABS format: %02X %02X\n", jaguarMainRom[0], jaguarMainRom[1]);
+ WriteLog("GUI: Couldn't find correct ABS format: %02X %02X\n", jaguarMainROM[0], jaguarMainROM[1]);
return false;
}
}
// 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)
+ if (jaguarMainROM[0] == 0x60 && jaguarMainROM[1] == 0x1A)
{
- uint32 loadAddress = GET32(jaguarMainRom, 0x22), runAddress = GET32(jaguarMainRom, 0x2A);
+ 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! ;-)
//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);
+ 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;
}