From: Shamus Hammons Date: Fri, 8 Jul 2011 13:07:35 +0000 (+0000) Subject: Various UI enhancements, like keyboard list searching in cart dialog. X-Git-Tag: 2.0.0~30 X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=54f5867e394981dd72548990064238454a6e2395;p=virtualjaguar Various UI enhancements, like keyboard list searching in cart dialog. --- diff --git a/src/gui/filelistmodel.cpp b/src/gui/filelistmodel.cpp index 097514c..00bb0bb 100644 --- a/src/gui/filelistmodel.cpp +++ b/src/gui/filelistmodel.cpp @@ -10,6 +10,8 @@ // --- ---------- ------------------------------------------------------------- // JLH 02/01/2010 Created this file // JLH 07/05/2011 Fixed model to not reset itself with each new row insertion +// JLH 07/07/2011 Added code to help the built-in keyboard based auto-search +// of the QListView class // // Note that we have to put in convenience functions to the model for adding data @@ -20,12 +22,14 @@ #include "filelistmodel.h" +#include "filedb.h" + FileListModel::FileListModel(QObject * parent/*= 0*/): QAbstractListModel(parent) { } -int FileListModel::rowCount(const QModelIndex & parent/*= QModelIndex()*/) const +int FileListModel::rowCount(const QModelIndex & /*parent = QModelIndex()*/) const { return list.size(); } @@ -46,6 +50,25 @@ QVariant FileListModel::data(const QModelIndex & index, int role) const return (uint)list.at(index.row()).fileType; else if (role == FLM_CRC) return (uint)list.at(index.row()).crc; + else if (role == Qt::DisplayRole) + { + // The QListView uses this role to do keyboard based searching, + // so we help it along by giving it what it needs to do the job. :-) + unsigned long dbIndex = list.at(index.row()).dbIndex; + QString filename = list.at(index.row()).filename; + QString nameToMatch; + + // Pull name from file DB, otherwise, use the filename... + if (dbIndex != 0xFFFFFFFF) + nameToMatch = romList[dbIndex].name; + else + { + int lastSlashPos = filename.lastIndexOf('/'); + nameToMatch = filename.mid(lastSlashPos + 1); + } + + return nameToMatch; + } return QVariant(); } diff --git a/src/gui/filepicker.cpp b/src/gui/filepicker.cpp index 2886052..86fbe55 100644 --- a/src/gui/filepicker.cpp +++ b/src/gui/filepicker.cpp @@ -198,6 +198,12 @@ New sizes: 373x172 (label), 420x340 (cart) connect(fileList->selectionModel(), SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &)), this, SLOT(UpdateSelection(const QModelIndex &, const QModelIndex &))); connect(insertCart, SIGNAL(clicked()), this, SLOT(LoadButtonPressed())); + + connect(fileList, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(CatchDoubleClick(const QModelIndex &))); + +// connect(fileList, SIGNAL(doubleClicked()), this, SLOT(LoadButtonPressed())); +// This returns: +// Object::connect: No such signal QListView::QAbstractItemView::doubleClicked() in src/gui/filepicker.cpp:203 } void FilePickerWindow::keyPressEvent(QKeyEvent * e) @@ -208,6 +214,11 @@ void FilePickerWindow::keyPressEvent(QKeyEvent * e) LoadButtonPressed(); } +void FilePickerWindow::CatchDoubleClick(const QModelIndex &) +{ + LoadButtonPressed(); +} + QString FilePickerWindow::GetSelectedPrettyName(void) { return prettyFilename; diff --git a/src/gui/filepicker.h b/src/gui/filepicker.h index a0e7e06..8003aa8 100644 --- a/src/gui/filepicker.h +++ b/src/gui/filepicker.h @@ -27,6 +27,7 @@ class FilePickerWindow: public QWidget void AddFileToList3(unsigned long index, QString, QImage *, unsigned long size, bool, unsigned long, unsigned long); void UpdateSelection(const QModelIndex &, const QModelIndex &); void LoadButtonPressed(void); + void CatchDoubleClick(const QModelIndex &); signals: void RequestLoad(QString); diff --git a/src/gui/filethread.cpp b/src/gui/filethread.cpp index 28d7389..db9c44f 100644 --- a/src/gui/filethread.cpp +++ b/src/gui/filethread.cpp @@ -21,6 +21,7 @@ #include "crc32.h" #include "file.h" #include "filedb.h" +#include "memory.h" #include "settings.h" #define VERBOSE_LOGGING @@ -137,6 +138,10 @@ void FileThread::HandleFile(QFileInfo fileInfo) crc = crc32_calcCheckSum(buffer, fileSize); uint32 index = FindCRCIndexInFileList(crc); + + if ((index != 0xFFFFFFFF) && (romList[index].flags & FF_BIOS)) + HandleBIOSFile(buffer, crc); + delete[] buffer; // Here we filter out files *not* in the DB (if configured that way) and @@ -178,6 +183,54 @@ void FileThread::HandleFile(QFileInfo fileInfo) emit FoundAFile3(index, fileInfo.canonicalFilePath(), img, fileSize, foundUniversalHeader, fileType, crc); } +// +// Handle checking/copying BIOS files into Jaguar core memory +// +void FileThread::HandleBIOSFile(uint8 * buffer, uint32 crc) +{ +/* + { 0x55A0669C, "[BIOS] Atari Jaguar Developer CD (World)", FF_BIOS }, + { 0x687068D5, "[BIOS] Atari Jaguar CD (World)", FF_BIOS }, + { 0x8D15DBC6, "[BIOS] Atari Jaguar Stubulator '94 (World)", FF_BIOS }, + { 0xE60277BB, "[BIOS] Atari Jaguar Stubulator '93 (World)", FF_BIOS }, + { 0xFB731AAA, "[BIOS] Atari Jaguar (World)", FF_BIOS }, + +uint8 jaguarBootROM[0x040000]; // 68K CPU BIOS ROM--uses only half of this! +uint8 jaguarCDBootROM[0x040000]; // 68K CPU CD BIOS ROM (256K) +uint8 jaguarDevBootROM1[0x040000]; // 68K CPU Stubulator 1 ROM--uses only half of this! +uint8 jaguarDevBootROM2[0x040000]; // 68K CPU Stubulator 2 ROM--uses only half of this! +uint8 jaguarDevCDBootROM[0x040000]; // 68K CPU Dev CD BIOS ROM (256K) + +enum { BIOS_NORMAL=0x01, BIOS_CD=0x02, BIOS_STUB1=0x04, BIOS_STUB2=0x08, BIOS_DEV_CD=0x10 }; +extern int biosAvailable; +*/ + if (crc == 0xFB731AAA && !(biosAvailable & BIOS_NORMAL)) + { + memcpy(jaguarBootROM, buffer, 0x20000); + biosAvailable |= BIOS_NORMAL; + } + else if (crc == 0x687068D5 && !(biosAvailable & BIOS_CD)) + { + memcpy(jaguarCDBootROM, buffer, 0x40000); + biosAvailable |= BIOS_CD; + } + else if (crc == 0x8D15DBC6 && !(biosAvailable & BIOS_STUB1)) + { + memcpy(jaguarDevBootROM1, buffer, 0x20000); + biosAvailable |= BIOS_STUB1; + } + else if (crc == 0xE60277BB && !(biosAvailable & BIOS_STUB2)) + { + memcpy(jaguarDevBootROM2, buffer, 0x20000); + biosAvailable |= BIOS_STUB2; + } + else if (crc == 0x55A0669C && !(biosAvailable & BIOS_DEV_CD)) + { + memcpy(jaguarDevCDBootROM, buffer, 0x40000); + biosAvailable |= BIOS_DEV_CD; + } +} + // // Find a CRC in the ROM list (simple brute force algorithm). // If it's there, return the index, otherwise return $FFFFFFFF diff --git a/src/gui/filethread.h b/src/gui/filethread.h index 92b773d..dba38a3 100644 --- a/src/gui/filethread.h +++ b/src/gui/filethread.h @@ -25,6 +25,7 @@ class FileThread: public QThread protected: void run(void); void HandleFile(QFileInfo); + void HandleBIOSFile(uint8 *, uint32); uint32 FindCRCIndexInFileList(uint32); private: diff --git a/src/gui/imagedelegate.cpp b/src/gui/imagedelegate.cpp index 875f1f7..122196f 100644 --- a/src/gui/imagedelegate.cpp +++ b/src/gui/imagedelegate.cpp @@ -87,7 +87,10 @@ The foreground of the item (the circle representing a pixel) must be rendered us // This is crappy. We really should have a properly scaled image ready to go so we // don't get Qt's default ugly looking fast scaling... + #warning "!!! FIX !!! Need to create properly scaled down cart/label images!" +//We've got the carts, now just need to do the labels... + // unsigned long i = index.model()->data(index, Qt::DisplayRole).toUInt(); #if 0 unsigned long i = index.model()->data(index, Qt::DisplayRole).toUInt(); diff --git a/src/gui/mainwin.cpp b/src/gui/mainwin.cpp index 75b4bc3..809b916 100644 --- a/src/gui/mainwin.cpp +++ b/src/gui/mainwin.cpp @@ -15,21 +15,16 @@ // FIXED: // // - Add dbl click/enter to select in cart list, ESC to dimiss [DONE] +// - Autoscan/autoload all available BIOS from 'software' folder [DONE] +// - Add 1 key jumping in cartridge list (press 'R', jumps to carts starting with 'R', etc) [DONE] // // STILL TO BE DONE: // -// - Autoscan/autoload all available BIOS from 'software' folder // - Controller configuration // - Remove SDL dependencies (sound, mainly) from Jaguar core lib -// - Add 1 key jumping in cartridge list (press 'R', jumps to carts starting with 'R', etc) +// - Fix inconsistency with trailing slashes in paths (eeproms needs one, software doesn't) // -/* -For BIOS autoscan, infrastructure is already there in filethread.cpp; just need to figure out -if we want to scan every time, or stuff filenames found into the config file, or what. -Should filethread emit signal that's intercepted here? Maybe... -*/ - // Uncomment this for debugging... //#define DEBUG //#define DEBUGFOO // Various tool debugging... @@ -233,17 +228,18 @@ MainWin::MainWin(): running(false), powerButtonOn(false), showUntunedTankCircuit WriteLog("VJ: Using built in BIOS/CD BIOS...\n"); memcpy(jaguarBootROM, jagBootROM, 0x20000); memcpy(jaguarCDBootROM, jagCDROM, 0x40000); - BIOSLoaded = CDBIOSLoaded = true; +// BIOSLoaded = CDBIOSLoaded = true; + biosAvailable |= (BIOS_NORMAL | BIOS_CD); #else // What would be nice here would be a way to check if the BIOS was loaded so that we // could disable the pushbutton on the Misc Options menu... !!! FIX !!! [DONE here, but needs to be fixed in GUI as well!] - WriteLog("VJ: About to attempt to load BIOSes...\n"); +// WriteLog("VJ: About to attempt to load BIOSes...\n"); //This is short-circuiting the file finding thread... ??? WHY ??? //Not anymore. Was related to a QImage object creation/corruption bug elsewhere. - BIOSLoaded = (JaguarLoadROM(jaguarBootROM, vjs.jagBootPath) == 0x20000 ? true : false); - WriteLog("VJ: BIOS is %savailable...\n", (BIOSLoaded ? "" : "not ")); - CDBIOSLoaded = (JaguarLoadROM(jaguarCDBootROM, vjs.CDBootPath) == 0x40000 ? true : false); - WriteLog("VJ: CD BIOS is %savailable...\n", (CDBIOSLoaded ? "" : "not ")); +// BIOSLoaded = (JaguarLoadROM(jaguarBootROM, vjs.jagBootPath) == 0x20000 ? true : false); +// WriteLog("VJ: BIOS is %savailable...\n", (BIOSLoaded ? "" : "not ")); +// CDBIOSLoaded = (JaguarLoadROM(jaguarCDBootROM, vjs.CDBootPath) == 0x40000 ? true : false); +// WriteLog("VJ: CD BIOS is %savailable...\n", (CDBIOSLoaded ? "" : "not ")); #endif filePickWin->ScanSoftwareFolder(allowUnknownSoftware); @@ -479,7 +475,8 @@ void MainWin::TogglePowerState(void) pauseAct->setDisabled(true); showUntunedTankCircuit = true; running = true; - // This is just in case the ROM we were playing was in a narrow or wide field mode + // This is just in case the ROM we were playing was in a narrow or wide field mode, + // so the untuned tank sim doesn't look wrong. :-) TOMReset(); } else @@ -501,6 +498,8 @@ void MainWin::TogglePowerState(void) pauseAct->setChecked(false); pauseAct->setDisabled(false); memcpy(jagMemSpace + 0x800000, jaguarCDBootROM, 0x40000); + setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION + " - Now playing: Jaguar CD")); } //(Err, what's so crappy about this? It seems to do what it's supposed to...) @@ -659,8 +658,8 @@ void MainWin::ReadSettings(void) vjs.renderType = settings.value("renderType", 0).toInt(); strcpy(vjs.jagBootPath, settings.value("JagBootROM", "./bios/[BIOS] Atari Jaguar (USA, Europe).zip").toString().toAscii().data()); strcpy(vjs.CDBootPath, settings.value("CDBootROM", "./bios/jagcd.rom").toString().toAscii().data()); - strcpy(vjs.EEPROMPath, settings.value("EEPROMs", "./eeproms").toString().toAscii().data()); - strcpy(vjs.ROMPath, settings.value("ROMs", "./software").toString().toAscii().data()); + strcpy(vjs.EEPROMPath, settings.value("EEPROMs", "./eeproms/").toString().toAscii().data()); + strcpy(vjs.ROMPath, settings.value("ROMs", "./software/").toString().toAscii().data()); WriteLog("MainWin: Paths\n"); WriteLog(" jagBootPath = \"%s\"\n", vjs.jagBootPath); WriteLog(" CDBootPath = \"%s\"\n", vjs.CDBootPath); diff --git a/src/memory.cpp b/src/memory.cpp index f37168b..f3ac769 100644 --- a/src/memory.cpp +++ b/src/memory.cpp @@ -41,6 +41,8 @@ uint8 jaguarDevBootROM1[0x040000]; // 68K CPU Stubulator 1 ROM--uses only hal uint8 jaguarDevBootROM2[0x040000]; // 68K CPU Stubulator 2 ROM--uses only half of this! uint8 jaguarDevCDBootROM[0x040000]; // 68K CPU Dev CD BIOS ROM (256K) +// This is an ORed value showing which BIOSes having been loaded into memory. +int biosAvailable = 0; #if 0 union Word diff --git a/src/memory.h b/src/memory.h index 75a9e18..74e8d5b 100644 --- a/src/memory.h +++ b/src/memory.h @@ -73,6 +73,11 @@ uint32 & smode = *((uint32 *)&jagMemSpace[0xF1A154]); enum { UNKNOWN, JAGUAR, DSP, GPU, TOM, JERRY, M68K, BLITTER, OP }; extern const char * whoName[9]; +// BIOS identification enum + +enum { BIOS_NORMAL=0x01, BIOS_CD=0x02, BIOS_STUB1=0x04, BIOS_STUB2=0x08, BIOS_DEV_CD=0x10 }; +extern int biosAvailable; + // Some handy macros to help converting native endian to big endian (jaguar native) // & vice versa