]> Shamusworld >> Repos - virtualjaguar/commitdiff
Various UI enhancements, like keyboard list searching in cart dialog.
authorShamus Hammons <jlhamm@acm.org>
Fri, 8 Jul 2011 13:07:35 +0000 (13:07 +0000)
committerShamus Hammons <jlhamm@acm.org>
Fri, 8 Jul 2011 13:07:35 +0000 (13:07 +0000)
src/gui/filelistmodel.cpp
src/gui/filepicker.cpp
src/gui/filepicker.h
src/gui/filethread.cpp
src/gui/filethread.h
src/gui/imagedelegate.cpp
src/gui/mainwin.cpp
src/memory.cpp
src/memory.h

index 097514c851ca18958bbaa2d40b3b3cad335147f9..00bb0bbed8fcd48ee830882257ba33c2b5612f85 100644 (file)
@@ -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
 
 #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();
 }
index 288605274d0dc47d6978dc6eb3b2414b093f5ff8..86fbe55b410d25cb62cc1776099a5aed63c06a78 100644 (file)
@@ -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;
index a0e7e0663d174bf3f5d3f8bd1141276401fff14d..8003aa8fc2b3d4690c95734e3f03afe9caad2af4 100644 (file)
@@ -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);
index 28d7389cb3156fe68e49c09019a86b275f09cb13..db9c44febab4aa2135af0194469c52696020e68c 100644 (file)
@@ -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
index 92b773d23b8d6d1a4bb0d5c2997c7924a79e9ef4..dba38a3a3cce5049b25af1e03f3e6eb9b19f091e 100644 (file)
@@ -25,6 +25,7 @@ class FileThread: public QThread
        protected:
                void run(void);
                void HandleFile(QFileInfo);
+               void HandleBIOSFile(uint8 *, uint32);
                uint32 FindCRCIndexInFileList(uint32);
 
        private:
index 875f1f7ee88a7d9a02d938da97889265ec668dd1..122196f3571afbea486da22ddd08e5822a0885e8 100644 (file)
@@ -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();
index 75b4bc385ae734ca09a6e89ce7a5c849ddfbceaa..809b916eaa5c3f461dfc8e8ce4a3d6f2e50192bf 100644 (file)
 // 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);
index f37168ba9db9cb04bdecc06cbc8fb0a9079aeef8..f3ac769adf8aabec318493490e9cd859ebeed837 100644 (file)
@@ -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
index 75a9e18de7b228a86f1818fabb119f08e59b597d..74e8d5bd36aaf2fe866a2fbed04c5f926b09362b 100644 (file)
@@ -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