}
//
-// Jaguar file loading (second stab at it...)
+// Jaguar file loading
// We do a more intelligent file analysis here instead of relying on (possible false)
// file extensions which people don't seem to give two shits about anyway. :-(
//
bool JaguarLoadFile(char * path)
{
-// NOTE: We can further clean this up by fixing JaguarLoadROM to load to a buffer
-// instead of assuming it goes into our ROM space. (Now, we do! :-)
uint8 * buffer = NULL;
jaguarROMSize = JaguarLoadROM(buffer, path);
-// jaguarROMSize = JaguarLoadROM(jaguarMainROM, path);
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);
-#warning "!!! Need error dialog here !!!"
-// Need to do something else here, like throw up an error dialog instead of aborting. !!! FIX !!!
- return false; // This is a start...
+ // It's up to the GUI to report errors, not us. :-)
+ WriteLog("FILE: Could not load ROM from file \"%s\"...\nAborting load!\n", path);
+ return false;
}
-// jaguarMainROMCRC32 = crc32_calcCheckSum(jaguarMainROM, jaguarROMSize);
jaguarMainROMCRC32 = crc32_calcCheckSum(buffer, jaguarROMSize);
WriteLog("CRC: %08X\n", (unsigned int)jaguarMainROMCRC32);
// TODO: Check for EEPROM file in ZIP file. If there is no EEPROM in the user's EEPROM
// directory, copy the one from the ZIP file, if it exists.
EepromInit();
jaguarRunAddress = 0x802000; // For non-BIOS runs, this is true
-// int fileType = ParseFileType(jaguarMainROM[0], jaguarMainROM[1], jaguarROMSize);
int fileType = ParseFileType(buffer[0], buffer[1], jaguarROMSize);
if (fileType == JST_ROM)
else if (fileType == JST_ALPINE)
{
// File extension ".ROM": Alpine image that loads/runs at $802000
- WriteLog("GUI: Setting up Alpine ROM... Run address: 00802000, length: %08X\n", jaguarROMSize);
-
-// for(int i=jaguarROMSize-1; i>=0; i--)
-// jaguarMainROM[0x2000 + i] = jaguarMainROM[i];
+ WriteLog("FILE: Setting up Alpine ROM... Run address: 00802000, length: %08X\n", jaguarROMSize);
memset(jagMemSpace + 0x800000, 0xFF, 0x2000);
memcpy(jagMemSpace + 0x802000, buffer, jaguarROMSize);
delete[] buffer;
else if (fileType == JST_ABS_TYPE1)
{
// For ABS type 1, run address == load address
-// uint32 loadAddress = GET32(jaguarMainROM, 0x16),
-// codeSize = GET32(jaguarMainROM, 0x02) + GET32(jaguarMainROM, 0x06);
uint32 loadAddress = GET32(buffer, 0x16),
codeSize = GET32(buffer, 0x02) + GET32(buffer, 0x06);
- WriteLog("GUI: Setting up homebrew (ABS-1)... Run address: %08X, length: %08X\n", loadAddress, codeSize);
-
-#if 0
- 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];
- }
-#else
+ WriteLog("FILE: Setting up homebrew (ABS-1)... Run address: %08X, length: %08X\n", loadAddress, codeSize);
memcpy(jagMemSpace + loadAddress, buffer + 0x24, codeSize);
delete[] buffer;
-#endif
-
jaguarRunAddress = loadAddress;
return true;
}
else if (fileType == JST_ABS_TYPE2)
{
-// uint32 loadAddress = GET32(jaguarMainROM, 0x28), runAddress = GET32(jaguarMainROM, 0x24),
-// codeSize = GET32(jaguarMainROM, 0x18) + GET32(jaguarMainROM, 0x1C);
uint32 loadAddress = GET32(buffer, 0x28), runAddress = GET32(buffer, 0x24),
codeSize = GET32(buffer, 0x18) + GET32(buffer, 0x1C);
- WriteLog("GUI: Setting up homebrew (ABS-2)... Run address: %08X, length: %08X\n", runAddress, codeSize);
-
-#if 0
- 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];
- }
-#else
+ WriteLog("FILE: Setting up homebrew (ABS-2)... Run address: %08X, length: %08X\n", runAddress, codeSize);
memcpy(jagMemSpace + loadAddress, buffer + 0xA8, codeSize);
delete[] buffer;
-#endif
-
jaguarRunAddress = runAddress;
return true;
}
else if (fileType == JST_JAGSERVER)
{
-// uint32 loadAddress = GET32(jaguarMainROM, 0x22), runAddress = GET32(jaguarMainROM, 0x2A);
uint32 loadAddress = GET32(buffer, 0x22), runAddress = GET32(buffer, 0x2A);
- WriteLog("GUI: Setting up homebrew (Jag Server)... Run address: %08X, length: %08X\n", runAddress, jaguarROMSize - 0x2E);
-// memcpy(jaguarMainRAM + loadAddress, jaguarMainROM + 0x2E, jaguarROMSize - 0x2E);
+ WriteLog("FILE: Setting up homebrew (Jag Server)... Run address: %08X, length: %08X\n", runAddress, jaguarROMSize - 0x2E);
memcpy(jagMemSpace + loadAddress, buffer + 0x2E, jaguarROMSize - 0x2E);
delete[] buffer;
jaguarRunAddress = runAddress;
}
// We can assume we have JST_NONE at this point. :-P
- // TODO: Add a dialog box that tells the user that they're trying to feed VJ a bogus file.
return false;
}
+//
+// "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
+//
+bool AlpineLoadFile(char * path)
+{
+ uint8 * buffer = NULL;
+ jaguarROMSize = JaguarLoadROM(buffer, path);
+
+ if (jaguarROMSize == 0)
+ {
+ // It's up to the GUI to deal with failure, not us. ;-)
+ WriteLog("FILE: Could not load Alpine from file \"%s\"...\nAborting load!\n", path);
+ return false;
+ }
+
+ jaguarMainROMCRC32 = crc32_calcCheckSum(buffer, jaguarROMSize);
+ WriteLog("CRC: %08X\n", (unsigned int)jaguarMainROMCRC32);
+ EepromInit();
+
+ jaguarRunAddress = 0x802000;
+
+ WriteLog("FILE: Setting up Alpine ROM with non-standard length... Run address: 00802000, length: %08X\n", jaguarROMSize);
+
+ memset(jagMemSpace + 0x800000, 0xFF, 0x2000);
+ memcpy(jagMemSpace + 0x802000, buffer, jaguarROMSize);
+ delete[] buffer;
+
+// Maybe instead of this, we could try requiring the STUBULATOR ROM? Just a thought...
+ // 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
+
+ return true;
+}
+
//
// Get the length of a (possibly) gzipped file
//
uint32 JaguarLoadROM(uint8 * &rom, char * path);
bool JaguarLoadFile(char * path);
+bool AlpineLoadFile(char * path);
uint32 GetFileFromZIP(const char * zipFile, FileType type, uint8 * &buffer);
uint32 ParseFileType(uint8 header1, uint8 header2, uint32 size);
bool HasUniversalHeader(uint8 * rom, uint32 romSize);
AlpineTab::AlpineTab(QWidget * parent/*= 0*/): QWidget(parent)
{
-// antialiasChk = new QCheckBox(tr("Use Qt's built-in antialiasing"));
-
-// I'm thinking we should scan the bios folder for the 5 known BIOSes, and
-// just present a radio button to choose between them...
QLabel * label1 = new QLabel("ROM to load:");
-// QLabel * label2 = new QLabel("CD Boot ROM:");
+ QLabel * label2 = new QLabel("ABS to load:");
// QLabel * label3 = new QLabel("EEPROMs:");
// QLabel * label4 = new QLabel("Software:");
edit1 = new QLineEdit("");
-// edit2 = new QLineEdit("");
+ edit2 = new QLineEdit("");
// edit3 = new QLineEdit("");
// edit4 = new QLineEdit("");
edit1->setPlaceholderText("ROM to load when Virtual Jaguar loads");
-// edit2->setPlaceholderText("CD Boot ROM location");
+ edit2->setPlaceholderText("ABS to load when Virtual Jaguar loads");
// edit3->setPlaceholderText("EEPROM path");
// edit4->setPlaceholderText("Software path");
QVBoxLayout * layout1 = new QVBoxLayout;
layout1->addWidget(label1);
-// layout1->addWidget(label2);
+ layout1->addWidget(label2);
// layout1->addWidget(label3);
// layout1->addWidget(label4);
QVBoxLayout * layout2 = new QVBoxLayout;
layout2->addWidget(edit1);
-// layout2->addWidget(edit2);
+ layout2->addWidget(edit2);
// layout2->addWidget(edit3);
// layout2->addWidget(edit4);
public:
QLineEdit * edit1;
-// QLineEdit * edit2;
+ QLineEdit * edit2;
// QLineEdit * edit3;
// QLineEdit * edit4;
if (vjs.hardwareTypeAlpine)
{
alpineTab->edit1->setText(vjs.alpineROMPath);
+ alpineTab->edit2->setText(vjs.absROMPath);
alpineTab->writeROM->setChecked(vjs.allowWritesToROM);
}
}
if (vjs.hardwareTypeAlpine)
{
strcpy(vjs.alpineROMPath, alpineTab->edit1->text().toAscii().data());
+ strcpy(vjs.absROMPath, alpineTab->edit2->text().toAscii().data());
vjs.allowWritesToROM = alpineTab->writeROM->isChecked();
}
}
// use, we can drop it in anywhere and use it as-is.
MainWin::MainWin(): running(false), powerButtonOn(false), showUntunedTankCircuit(true),
- cartridgeLoaded(false), CDActive(false)
+ cartridgeLoaded(false), CDActive(false)//, alpineLoadSuccessful(false)
{
videoWidget = new GLWidget(this);
setCentralWidget(videoWidget);
ntscAct->setChecked(vjs.hardwareTypeNTSC);
palAct->setChecked(!vjs.hardwareTypeNTSC);
- // Load up the default ROM if in Alpine mode:
- if (vjs.hardwareTypeAlpine)
- {
- bool romLoaded = (JaguarLoadFile(vjs.alpineROMPath) ? true : false);
-
- if (romLoaded)
- WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs.alpineROMPath);
- else
- WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs.alpineROMPath);
- }
-
// Do this in case original size isn't correct (mostly for the first-run case)
ResizeMainWindow();
#endif
filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
+
+ // Load up the default ROM if in Alpine mode:
+ if (vjs.hardwareTypeAlpine)
+ {
+ bool romLoaded = JaguarLoadFile(vjs.alpineROMPath);
+
+ // If regular load failed, try just a straight file load
+ // (Dev only! I don't want people to start getting lazy with their releases again! :-P)
+ if (!romLoaded)
+ romLoaded = AlpineLoadFile(vjs.alpineROMPath);
+
+ if (romLoaded)
+ WriteLog("Alpine Mode: Successfully loaded file \"%s\".\n", vjs.alpineROMPath);
+ else
+ WriteLog("Alpine Mode: Unable to load file \"%s\"!\n", vjs.alpineROMPath);
+
+ // Attempt to load/run the ABS file...
+ LoadSoftware(vjs.absROMPath);
+ }
}
void MainWin::closeEvent(QCloseEvent * event)
QString before = vjs.ROMPath;
QString alpineBefore = vjs.alpineROMPath;
+ QString absBefore = vjs.absROMPath;
bool audioBefore = vjs.audioEnabled;
dlg.UpdateVJSettings();
QString after = vjs.ROMPath;
QString alpineAfter = vjs.alpineROMPath;
+ QString absAfter = vjs.absROMPath;
bool audioAfter = vjs.audioEnabled;
bool allowOld = allowUnknownSoftware;
// If the "Alpine" ROM is changed, then let's load it...
if (alpineBefore != alpineAfter)
{
- if (!JaguarLoadFile(vjs.alpineROMPath))
+ if (!JaguarLoadFile(vjs.alpineROMPath) || !AlpineLoadFile(vjs.alpineROMPath))
{
// Oh crap, we couldn't get the file! Alert the media!
QMessageBox msg;
}
}
+ // If the "ABS" ROM is changed, then let's load it...
+ if (absBefore != absAfter)
+ {
+ if (!JaguarLoadFile(vjs.absROMPath))
+ {
+ // Oh crap, we couldn't get the file! Alert the media!
+ QMessageBox msg;
+ msg.setText(QString(tr("Could not load file \"%1\"!")).arg(vjs.absROMPath));
+ msg.setIcon(QMessageBox::Warning);
+ msg.exec();
+ }
+ }
+
// If the "Enable audio" checkbox changed, then we have to re-init the DAC...
if (audioBefore != audioAfter)
{
{
if (!CDActive)
{
- showUntunedTankCircuit = (cartridgeLoaded ? false : true);
+ showUntunedTankCircuit = false;//(cartridgeLoaded ? false : true);
pauseAct->setChecked(false);
pauseAct->setDisabled(!cartridgeLoaded);
}
strcpy(vjs.EEPROMPath, settings.value("EEPROMs", "./eeproms/").toString().toAscii().data());
strcpy(vjs.ROMPath, settings.value("ROMs", "./software/").toString().toAscii().data());
strcpy(vjs.alpineROMPath, settings.value("DefaultROM", "").toString().toAscii().data());
+ strcpy(vjs.absROMPath, settings.value("DefaultABS", "").toString().toAscii().data());
WriteLog("MainWin: Paths\n");
//WriteLog(" jagBootPath = \"%s\"\n", vjs.jagBootPath);
//WriteLog(" CDBootPath = \"%s\"\n", vjs.CDBootPath);
-WriteLog(" EEPROMPath = \"%s\"\n", vjs.EEPROMPath);
-WriteLog(" ROMPath = \"%s\"\n", vjs.ROMPath);
+WriteLog(" EEPROMPath = \"%s\"\n", vjs.EEPROMPath);
+WriteLog(" ROMPath = \"%s\"\n", vjs.ROMPath);
+WriteLog("AlpineROMPath = \"%s\"\n", vjs.alpineROMPath);
+WriteLog(" absROMPath = \"%s\"\n", vjs.absROMPath);
// Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
vjs.p1KeyBindings[BUTTON_U] = settings.value("p1k_up", Qt::Key_Up).toInt();
settings.setValue("EEPROMs", vjs.EEPROMPath);
settings.setValue("ROMs", vjs.ROMPath);
settings.setValue("DefaultROM", vjs.alpineROMPath);
+ settings.setValue("DefaultABS", vjs.absROMPath);
settings.setValue("p1k_up", vjs.p1KeyBindings[BUTTON_U]);
settings.setValue("p1k_down", vjs.p1KeyBindings[BUTTON_D]);
bool cartridgeLoaded;
bool allowUnknownSoftware;
bool CDActive;
+// bool alpineLoadSuccessful;
QMenu * fileMenu;
QMenu * helpMenu;
char CDBootPath[MAX_PATH];
char EEPROMPath[MAX_PATH];
char alpineROMPath[MAX_PATH];
+ char absROMPath[MAX_PATH];
};
// Render types