From: Shamus Hammons Date: Sun, 17 Jul 2011 23:15:33 +0000 (+0000) Subject: Added more developer friendly stuff to Alpine mode. X-Git-Tag: 2.0.0~19 X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4333fdb4f2f297db8272d2ebc8323028df8c105f;p=virtualjaguar Added more developer friendly stuff to Alpine mode. --- diff --git a/src/file.cpp b/src/file.cpp index 1319dc8..4b389e6 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -103,35 +103,28 @@ uint32 JaguarLoadROM(uint8 * &rom, char * path) } // -// 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) @@ -143,10 +136,7 @@ bool JaguarLoadFile(char * path) 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; @@ -161,58 +151,28 @@ bool JaguarLoadFile(char * path) 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; @@ -220,10 +180,47 @@ bool JaguarLoadFile(char * path) } // 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 // diff --git a/src/file.h b/src/file.h index 08d0b21..a7342fc 100644 --- a/src/file.h +++ b/src/file.h @@ -19,6 +19,7 @@ enum { JST_NONE = 0, JST_ROM, JST_ALPINE, JST_ABS_TYPE1, JST_ABS_TYPE2, JST_JAGS 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); diff --git a/src/gui/alpinetab.cpp b/src/gui/alpinetab.cpp index 8611418..9a17338 100644 --- a/src/gui/alpinetab.cpp +++ b/src/gui/alpinetab.cpp @@ -16,33 +16,29 @@ 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); diff --git a/src/gui/alpinetab.h b/src/gui/alpinetab.h index b2f33b7..5826ac6 100644 --- a/src/gui/alpinetab.h +++ b/src/gui/alpinetab.h @@ -13,7 +13,7 @@ class AlpineTab: public QWidget public: QLineEdit * edit1; -// QLineEdit * edit2; + QLineEdit * edit2; // QLineEdit * edit3; // QLineEdit * edit4; diff --git a/src/gui/configdialog.cpp b/src/gui/configdialog.cpp index 3ee9a92..2613412 100644 --- a/src/gui/configdialog.cpp +++ b/src/gui/configdialog.cpp @@ -68,6 +68,7 @@ void ConfigDialog::LoadDialogFromSettings(void) if (vjs.hardwareTypeAlpine) { alpineTab->edit1->setText(vjs.alpineROMPath); + alpineTab->edit2->setText(vjs.absROMPath); alpineTab->writeROM->setChecked(vjs.allowWritesToROM); } } @@ -86,6 +87,7 @@ void ConfigDialog::UpdateVJSettings(void) if (vjs.hardwareTypeAlpine) { strcpy(vjs.alpineROMPath, alpineTab->edit1->text().toAscii().data()); + strcpy(vjs.absROMPath, alpineTab->edit2->text().toAscii().data()); vjs.allowWritesToROM = alpineTab->writeROM->isChecked(); } } diff --git a/src/gui/mainwin.cpp b/src/gui/mainwin.cpp index 7067ab9..ea44c70 100644 --- a/src/gui/mainwin.cpp +++ b/src/gui/mainwin.cpp @@ -76,7 +76,7 @@ // 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); @@ -218,17 +218,6 @@ MainWin::MainWin(): running(false), powerButtonOn(false), showUntunedTankCircuit 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(); @@ -261,6 +250,25 @@ MainWin::MainWin(): running(false), powerButtonOn(false), showUntunedTankCircuit #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) @@ -327,10 +335,12 @@ void MainWin::Configure(void) 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; @@ -345,7 +355,7 @@ void MainWin::Configure(void) // 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; @@ -355,6 +365,19 @@ void MainWin::Configure(void) } } + // 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) { @@ -526,7 +549,7 @@ void MainWin::TogglePowerState(void) { if (!CDActive) { - showUntunedTankCircuit = (cartridgeLoaded ? false : true); + showUntunedTankCircuit = false;//(cartridgeLoaded ? false : true); pauseAct->setChecked(false); pauseAct->setDisabled(!cartridgeLoaded); } @@ -713,11 +736,14 @@ void MainWin::ReadSettings(void) 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(); @@ -793,6 +819,7 @@ void MainWin::WriteSettings(void) 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]); diff --git a/src/gui/mainwin.h b/src/gui/mainwin.h index 5576668..fa1e976 100644 --- a/src/gui/mainwin.h +++ b/src/gui/mainwin.h @@ -64,6 +64,7 @@ class MainWin: public QMainWindow bool cartridgeLoaded; bool allowUnknownSoftware; bool CDActive; +// bool alpineLoadSuccessful; QMenu * fileMenu; QMenu * helpMenu; diff --git a/src/settings.h b/src/settings.h index 26b18e9..a8f5aa3 100644 --- a/src/settings.h +++ b/src/settings.h @@ -45,6 +45,7 @@ struct VJSettings char CDBootPath[MAX_PATH]; char EEPROMPath[MAX_PATH]; char alpineROMPath[MAX_PATH]; + char absROMPath[MAX_PATH]; }; // Render types