]> Shamusworld >> Repos - virtualjaguar/commitdiff
Preliminary support for alternate file types.
authorShamus Hammons <jlhamm@acm.org>
Thu, 30 Jun 2011 20:39:27 +0000 (20:39 +0000)
committerShamus Hammons <jlhamm@acm.org>
Thu, 30 Jun 2011 20:39:27 +0000 (20:39 +0000)
15 files changed:
src/eeprom.cpp
src/filedb.cpp
src/filedb.h
src/gui/filelistmodel.cpp
src/gui/filelistmodel.h
src/gui/filepicker.cpp
src/gui/filepicker.h
src/gui/filethread.cpp
src/gui/filethread.h
src/gui/generaltab.cpp
src/gui/generaltab.h
src/gui/imagedelegate.cpp
src/gui/imagedelegate.h
src/gui/mainwin.cpp
src/gui/mainwin.h

index 266a11ae19f170f726c47fdd02b4b3b92b80b84d..4b8dda8981ef31e0b77d68c64b2993a5d059f1ed 100644 (file)
@@ -200,6 +200,7 @@ static void eeprom_set_di(uint32 data)
                if (jerry_writes_enabled)
                        for(int i=0; i<64; i++)
                                eeprom_ram[i] = jerry_ee_data;
+
                EEPROMSave();                                                           // Save it NOW!
                //else
                //      WriteLog("eeprom: not writing because read only\n");
@@ -238,6 +239,7 @@ static void eeprom_set_di(uint32 data)
                //WriteLog("eeprom: writing 0x%.4x at 0x%.2x\n",jerry_ee_data,jerry_ee_address_data);
                if (jerry_writes_enabled)
                        eeprom_ram[jerry_ee_address_data] = jerry_ee_data;
+
                EEPROMSave();                                                           // Save it NOW!
                jerry_ee_state = EE_STATE_BUSY;
                break;
@@ -260,6 +262,7 @@ static void eeprom_set_di(uint32 data)
                //WriteLog("eeprom: erasing 0x%.2x\n",jerry_ee_address_data);
                if (jerry_writes_enabled)
                        eeprom_ram[jerry_ee_address_data] = 0xFFFF;
+
                jerry_ee_state = EE_STATE_BUSY;
                break;
        case EE_READ_DATA:
@@ -267,9 +270,11 @@ static void eeprom_set_di(uint32 data)
                jerry_ee_data <<= 1;
                jerry_ee_data |= data;
                jerry_ee_data_cnt--;
+
                if (!jerry_ee_data_cnt)
                {
                        jerry_ee_state = jerry_ee_rstate;
+
                        if (jerry_ee_direct_jump)
                                eeprom_set_di(data);
                }
@@ -279,10 +284,12 @@ static void eeprom_set_di(uint32 data)
                jerry_ee_address_data |= data;
                jerry_ee_address_cnt--;
 //             WriteLog("eeprom:\t%i bits remaining\n",jerry_ee_address_cnt);
+
                if (!jerry_ee_address_cnt)
                {
                        jerry_ee_state = jerry_ee_rstate;
                        //WriteLog("eeprom:\t\tread address 0x%.2x\n",jerry_ee_address_data);
+
                        if (jerry_ee_direct_jump)
                                eeprom_set_di(data);
                }
@@ -321,6 +328,7 @@ static uint32 eeprom_get_do(void)
        case EE_STATE_2_0:
                jerry_ee_data_cnt--;
                data = (eeprom_ram[jerry_ee_address_data] & (1 << jerry_ee_data_cnt)) >> jerry_ee_data_cnt;
+
                if (!jerry_ee_data_cnt)
                {
                        //WriteLog("eeprom: read 0x%.4x at 0x%.2x cpu %i pc=0x%.8x\n",eeprom_ram[jerry_ee_address_data],jerry_ee_address_data,jaguar_cpu_in_exec,s68000readPC());
index 54f04adb065fdf374e8deece3d1ba9b1eae51135..8dc4fa2aa1c0efbe25047ea0494427580754aae0 100644 (file)
@@ -19,85 +19,114 @@ struct RomIdentifier
 {
        const uint32 crc32;
        const char name[128];
-//     const char file[128];
+//     const uint8 compatibility;
        const uint32 flags;
 };
 
-enum FileFlags { FF_ROM=1, FF_ALPINE=2, FF_BIOS=4, FF_REQ_DSP=8, FF_REQ_BIOS=16, FF_NON_WORKING=32, FF_BAD_DUMP=64 };
+enum FileFlags { FF_ROM=1, FF_ALPINE=2, FF_BIOS=4, FF_REQ_DSP=8, FF_REQ_BIOS=16, FF_NON_WORKING=32, FF_BAD_DUMP=64, FF_VERIFIED=128 };
 #endif
 
 // Should have another flag for whether or not it requires DSP, BIOS,
 // whether it's a .rom, it's a BIOS, etc...
 // ... And now we do! :-D
 
+// How the CRCs work:
+// If the cart has an RSA signature, we do a CRC on the whole file.
+// If the cart has a universal header, we do a CRC on the file minus the UH.
+// This is to ensure that we can detect something properly (like an Alpine ROM)
+// that somebody slapped a universal header on.
+
 RomIdentifier romList[] = {
-       { 0x0509C85E, "Raiden (World)", FF_ROM },
-       { 0x08F15576, "Iron Soldier (World) (v1.04)", FF_ROM },
-       { 0x0957A072, "Kasumi Ninja (World)", FF_ROM },
-       { 0x0AC83D77, "NBA Jam T.E. (World)", FF_ROM },
-       { 0x0EC5369D, "Evolution - Dino Dudes (World)", FF_ROM },
-       { 0x0F6A1C2C, "Ultra Vortek (World)", FF_ROM },
-       { 0x14915F20, "White Men Can't Jump (World)", FF_ROM },
-       { 0x1660F070, "Power Drive Rally (World)", FF_ROM },
-       { 0x1E451446, "Trevor McFur in the Crescent Galaxy (World)", FF_ROM },
-//     { 0x20DBFF9F, "Breakout 2000", FF_ROM },
-       { 0x27594C6A, "Defender 2000 (World)", FF_ROM },
-       { 0x2E17D5DA, "Bubsy in Fractured Furry Tales (World)", FF_ROM },
-       { 0x348E6449, "Double Dragon V - The Shadow Falls (World)", FF_ROM },
-       { 0x3615AF6A, "Fever Pitch Soccer (World) (En,Fr,De,Es,It)", FF_ROM },
-       { 0x38A130ED, "Troy Aikman NFL Football (World)", FF_ROM },
-       { 0x3C044941, "Skyhammer (World)", FF_ROM },
-       { 0x40E1A1D0, "Air Cars (World)", FF_ROM },
-       { 0x42A13EC5, "Soccer Kid (World)", FF_ROM },
-       { 0x45AA46BA, "Space War 2000 (World)", FF_ROM },
-       { 0x47EBC158, "Theme Park (World)", FF_ROM },
-       { 0x4899628F, "Hover Strike (World)", FF_ROM },
-       { 0x53DF6440, "Space War 2000 (World) (OVERDUMP)", FF_ROM },
+       { 0x0509C85E, "Raiden (World) (alt)", FF_ROM },
+       { 0x08849D0F, "Hyper Force (World)", FF_ALPINE | FF_VERIFIED },
+       { 0x08F15576, "Iron Soldier (World) (v1.04)", FF_ROM | FF_VERIFIED },
+       { 0x0957A072, "Kasumi Ninja (World)", FF_ROM | FF_VERIFIED },
+       { 0x0AC83D77, "NBA Jam T.E. (World)", FF_ROM | FF_VERIFIED },
+       { 0x0EC5369D, "Evolution - Dino Dudes (World)", FF_ROM | FF_VERIFIED },
+       { 0x0F6A1C2C, "Ultra Vortek (World)", FF_ROM | FF_VERIFIED },
+       { 0x14915F20, "White Men Can't Jump (World)", FF_ROM | FF_VERIFIED },
+       { 0x1660F070, "Power Drive Rally (World)", FF_ROM | FF_VERIFIED },
+       { 0x1A20C5C4, "Protector (World)", FF_ROM | FF_VERIFIED | FF_REQ_DSP },
+       { 0x1E451446, "Trevor McFur in the Crescent Galaxy (World)", FF_ROM | FF_VERIFIED },
+       { 0x20936557, "Space War 2000", FF_ALPINE | FF_VERIFIED },
+       { 0x27594C6A, "Defender 2000 (World)", FF_ROM | FF_VERIFIED },
+       { 0x2BAA92A1, "Space War 2000 (World) (OVERDUMP)", FF_ALPINE },
+       { 0x2E17D5DA, "Bubsy in Fractured Furry Tales (World)", FF_ROM | FF_VERIFIED },
+       { 0x31812799, "Raiden (World)", FF_ROM | FF_VERIFIED },
+       { 0x3241AB6A, "Towers II", FF_ALPINE },
+       { 0x348E6449, "Double Dragon V - The Shadow Falls (World)", FF_ROM | FF_VERIFIED },
+       { 0x3615AF6A, "Fever Pitch Soccer (World) (En,Fr,De,Es,It)", FF_ROM | FF_VERIFIED },
+       { 0x38A130ED, "Troy Aikman NFL Football (World)", FF_ROM | FF_VERIFIED },
+       { 0x40E1A1D0, "Air Cars (World)", FF_ROM | FF_VERIFIED },
+       { 0x4471BFA0, "Skyhammer (World)", FF_ALPINE | FF_VERIFIED },
+       { 0x47EBC158, "Theme Park (World)", FF_ROM | FF_VERIFIED },
+       { 0x4899628F, "Hover Strike (World)", FF_ROM | FF_VERIFIED },
        { 0x55A0669C, "[BIOS] Atari Jaguar Developer CD (World)", FF_BIOS },
-       { 0x58272540, "Syndicate (World)", FF_ROM },
-       { 0x5A101212, "Sensible Soccer - International Edition (World)", FF_ROM },
-       { 0x5B6BB205, "Ruiner Pinball (World)", FF_ROM },
-       { 0x5CFF14AB, "Pinball Fantasies (World)", FF_ROM },
-       { 0x5E2CDBC0, "Doom (World)", FF_ROM },
-       { 0x61C7EEC0, "Zero 5 (World)", FF_ROM },
+       { 0x58272540, "Syndicate (World)", FF_ROM | FF_VERIFIED },
+       { 0x5A101212, "Sensible Soccer - International Edition (World)", FF_ROM | FF_VERIFIED },
+       { 0x5B6BB205, "Ruiner Pinball (World)", FF_ROM | FF_VERIFIED },
+       { 0x5CFF14AB, "Pinball Fantasies (World)", FF_ROM | FF_VERIFIED },
+       { 0x5DDF9724, "Protector - Special Edition (World)", FF_ALPINE | FF_VERIFIED },
+       { 0x5E2CDBC0, "Doom (World)", FF_ROM | FF_VERIFIED | FF_REQ_DSP },
+       { 0x5F2C2774, "Battlesphere (World)", FF_ROM | FF_VERIFIED },
+       { 0x61C7EEC0, "Zero 5 (World)", FF_ROM | FF_VERIFIED },
+       { 0x61EE6B62, "Arena Football '95", FF_ALPINE | FF_VERIFIED },
        { 0x67F9AB3A, "Battle Sphere Gold (World)", FF_ROM },
        { 0x687068D5, "[BIOS] Atari Jaguar CD (World)", FF_BIOS },
-       { 0x6B2B95AD, "Tempest 2000 (World)", FF_ROM },
-       { 0x6EB774EB, "Worms (World)", FF_ROM },
-       { 0x6F8B2547, "Super Burnout (World)", FF_ROM },
-       { 0x817A2273, "Pitfall - The Mayan Adventure (World)", FF_ROM },
-       { 0x8975F48B, "Zool 2 (World)", FF_ROM },
+       { 0x6B2B95AD, "Tempest 2000 (World)", FF_ROM | FF_VERIFIED },
+       { 0x6EB774EB, "Worms (World)", FF_ROM | FF_VERIFIED },
+       { 0x6F8B2547, "Super Burnout (World)", FF_ROM | FF_VERIFIED },
+       { 0x732FFAB6, "Soccer Kid (World)", FF_ROM | FF_VERIFIED },
+       { 0x817A2273, "Pitfall - The Mayan Adventure (World)", FF_ROM | FF_VERIFIED },
+       { 0x83A3FB5D, "Towers II", FF_ROM | FF_VERIFIED },
+       { 0x892BC67C, "Flip Out! (World)", FF_ROM | FF_VERIFIED },
+       { 0x8975F48B, "Zool 2 (World)", FF_ROM | FF_VERIFIED },
+       { 0x89DA21FF, "Phase Zero", FF_ALPINE | FF_VERIFIED },
        { 0x8D15DBC6, "[BIOS] Atari Jaguar Stubulator '94 (World)", FF_BIOS },
-       { 0x8FEA5AB0, "Dragon - The Bruce Lee Story (World)", FF_ROM },
-       { 0x97EB4651, "I-War (World)", FF_ROM },
+       { 0x8FEA5AB0, "Dragon - The Bruce Lee Story (World)", FF_ROM | FF_VERIFIED },
+       { 0x91095DD3, "Brett Hull Hockey", FF_ROM | FF_VERIFIED },
+       { 0x95143668, "Trevor McFur in the Crescent Galaxy (World) (alt)", FF_ROM | FF_VERIFIED },
+       { 0x97EB4651, "I-War (World)", FF_ROM | FF_VERIFIED },
+       { 0xA0A25A67, "Missile Command VR", FF_ALPINE },
        { 0xA27823D8, "Ultra Vortek (World) (v0.94) (Beta)", FF_ROM },
-       { 0xA56D0798, "Protector - Special Edition (World)", FF_ROM },
-       { 0xA9F8A00E, "Rayman (World)", FF_ROM },
-       { 0xB14C4753, "Fight for Life (World)", FF_ROM },
-       { 0xBCB1A4BF, "Brutal Sports Football (World)", FF_ROM },
-       { 0xBDA405C6, "Cannon Fodder (World)", FF_ROM },
-       { 0xBDE67498, "Cybermorph (World) (Rev 1)", FF_ROM },
-       { 0xC5562581, "Zoop! (World)", FF_ROM },
-       { 0xC654681B, "Total Carnage (World)", FF_ROM },
-       { 0xC6C7BA62, "Fight for Life (World) (Alt)", FF_ROM | FF_BAD_DUMP },
-       { 0xC9608717, "Val d'Isere Skiing and Snowboarding (World)", FF_ROM },
-       { 0xCAF33BD6, "Towers II", FF_ROM },
-       { 0xCD5BF827, "Attack of the Mutant Penguins (World)", FF_ROM | FF_REQ_DSP },
-       { 0xD6C19E34, "Iron Soldier 2 (World)", FF_ROM },
-       { 0xD8696F23, "Breakout 2000", FF_ALPINE },
-       { 0xDA9C4162, "Missile Command 3D (World)", FF_ROM },
-       { 0xDC187F82, "Alien vs Predator (World)", FF_ROM },
+       { 0xA7E01FEF, "Mad Bodies (2008)", FF_ROM | FF_NON_WORKING },
+       { 0xA9F8A00E, "Rayman (World)", FF_ROM | FF_VERIFIED },
+       { 0xAEA9D831, "Barkley Shut Up & Jam", FF_ROM | FF_VERIFIED },
+       { 0xB14C4753, "Fight for Life (World)", FF_ROM | FF_VERIFIED },
+       { 0xB5604D40, "Breakout 2000", FF_ROM | FF_VERIFIED },
+       { 0xBA13AE79, "Soccer Kid (World) (alt)", FF_ALPINE },
+       { 0xBCB1A4BF, "Brutal Sports Football (World)", FF_ROM | FF_VERIFIED },
+       { 0xBD18D606, "Space War 2000 (World) (alt)", FF_ALPINE },
+       { 0xBDA405C6, "Cannon Fodder (World)", FF_ROM | FF_VERIFIED },
+       { 0xBDE67498, "Cybermorph (World) (Rev 1)", FF_ROM | FF_VERIFIED },
+       { 0xC2898F6E, "Barkley Shut Up & Jam (alt)", FF_ALPINE },
+       { 0xC36E935E, "Beebris (World)", FF_ALPINE | FF_VERIFIED },
+       { 0xC5562581, "Zoop! (World)", FF_ROM | FF_VERIFIED },
+       { 0xC654681B, "Total Carnage (World)", FF_ROM | FF_VERIFIED },
+       { 0xC6C7BA62, "Fight for Life (World) (alt)", FF_ROM | FF_BAD_DUMP },
+       { 0xC9608717, "Val d'Isere Skiing and Snowboarding (World)", FF_ROM | FF_VERIFIED },
+       { 0xCBFD822A, "Air Cars (World) (alt)", FF_ROM },
+       { 0xCD5BF827, "Attack of the Mutant Penguins (World)", FF_ROM | FF_VERIFIED | FF_REQ_DSP },
+       { 0xD6C19E34, "Iron Soldier 2 (World)", FF_ROM | FF_VERIFIED },
+       { 0xD8696F23, "Breakout 2000 (alt)", FF_ALPINE },
+       { 0xDA9C4162, "Missile Command 3D (World)", FF_ROM | FF_VERIFIED },
+       { 0xDC187F82, "Alien vs Predator (World)", FF_ROM | FF_VERIFIED },
+       { 0xDCCDEF05, "Brett Hull Hockey", FF_ALPINE },
        { 0xDDFF49F5, "Rayman (Prototype)", FF_ALPINE },
-       { 0xDE55DCC7, "Flashback - The Quest for Identity (World) (En,Fr)", FF_ROM },
-       { 0xE28756DE, "Atari Karts (World)", FF_ROM },
+       { 0xDE55DCC7, "Flashback - The Quest for Identity (World) (En,Fr)", FF_ROM | FF_VERIFIED },
+       { 0xE28756DE, "Atari Karts (World)", FF_ROM | FF_VERIFIED },
        { 0xE60277BB, "[BIOS] Atari Jaguar Stubulator '93 (World)", FF_BIOS },
-       { 0xE91BD644, "Wolfenstein 3D (World)", FF_ROM },
-       { 0xEC22F572, "SuperCross 3D (World)", FF_ROM },
+       { 0xE91BD644, "Wolfenstein 3D (World)", FF_ROM | FF_VERIFIED },
+       { 0xEA9B3FA7, "Phase Zero", FF_ROM },
+       { 0xEC22F572, "SuperCross 3D (World)", FF_ROM | FF_VERIFIED },
        { 0xECF854E7, "Cybermorph (World) (Rev 2)", FF_ROM },
-       { 0xEEE8D61D, "Club Drive (World)", FF_ROM },
-       { 0xF0360DB3, "Hyper Force (World)", FF_ROM },
-       { 0xFA7775AE, "Checkered Flag (World)", FF_ROM },
-       { 0xFAE31DD0, "Flip Out! (World)", FF_ROM },
+       { 0xEEE8D61D, "Club Drive (World)", FF_ROM | FF_VERIFIED },
+       { 0xF4ACBB04, "Tiny Toon Adventures (World)", FF_ROM | FF_VERIFIED },
+       { 0xFA7775AE, "Checkered Flag (World)", FF_ROM | FF_VERIFIED },
+       { 0xFAE31DD0, "Flip Out! (World) (alt)", FF_ROM },
        { 0xFB731AAA, "[BIOS] Atari Jaguar (World)", FF_BIOS },
+// is this really a BIOS???
+// No, it's really a cart, complete with RSA header. So need to fix so it can load.
+       { 0xFDF37F47, "Memory Track Cartridge (World)", FF_ROM | FF_VERIFIED },
        { 0xFFFFFFFF, "***END***", 0 }
 };
index 801b5014647a1a0a13f6e9c25b4ab7d922038db1..d6630aa867f2f4415129175808e9abec25c22dc1 100644 (file)
@@ -9,7 +9,7 @@
 
 // Useful enumerations
 
-enum FileFlags { FF_ROM=1, FF_ALPINE=2, FF_BIOS=4, FF_REQ_DSP=8, FF_REQ_BIOS=16, FF_NON_WORKING=32, FF_BAD_DUMP=64 };
+enum FileFlags { FF_ROM=0x01, FF_ALPINE=0x02, FF_BIOS=0x04, FF_REQ_DSP=0x08, FF_REQ_BIOS=0x10, FF_NON_WORKING=0x20, FF_BAD_DUMP=0x40, FF_VERIFIED=0x80 };
 
 // Useful structs
 
@@ -17,7 +17,7 @@ struct RomIdentifier
 {
        const uint32 crc32;
        const char name[128];
-//     const char file[128];
+//     const uint8 compatibility;
        const uint32 flags;
 };
 
index 09389b86289043e5afd7b2d93af51bc2a4794aa9..8308c5c946123c3511c1eb07f7b776e8519c1123 100644 (file)
@@ -57,6 +57,12 @@ QVariant FileListModel::data(const QModelIndex & index, int role) const
                return list.at(index.row()).filename;
        else if (role == FLM_FILESIZE)
                return (uint)list.at(index.row()).fileSize;
+       else if (role == FLM_UNIVERSALHDR)
+               return (uint)list.at(index.row()).hasUniversalHeader;
+       else if (role == FLM_FILETYPE)
+               return (uint)list.at(index.row()).fileType;
+       else if (role == FLM_CRC)
+               return (uint)list.at(index.row()).crc;
 
        return QVariant();
 #endif
@@ -111,6 +117,33 @@ void FileListModel::AddData(unsigned long index, QString str, QImage img, unsign
        reset();
 }
 
+void FileListModel::AddData(unsigned long index, QString str, QImage img, unsigned long size, bool univHdr, uint32_t type, uint32_t fileCrc)
+{
+       // Assuming that both QString and QImage have copy constructors, this should work.
+       FileListData data;
+
+       data.dbIndex = index;
+       data.fileSize = size;
+       data.filename = str;
+       data.label = img;
+       data.hasUniversalHeader = univHdr;
+       data.fileType = type;
+       data.crc = fileCrc;
+
+       list.push_back(data);
+       reset();
+}
+
+void FileListModel::ClearData(void)
+{
+       if (list.size() == 0)
+               return;
+
+       beginResetModel();
+       list.clear();
+       endResetModel();
+}
+
 //FileListData FileListModel::GetData(const QModelIndex & index) const
 //{
 //     return list.at(index.row());
index 78d73e92c91fd2c8d72f6bd94da7258303939045..a3ab66077b710fb66f72b4ca65f9d83198566bd3 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <QtGui>
 #include <vector>
+#include <stdint.h>
 
 struct FileListData
 {
@@ -20,13 +21,19 @@ struct FileListData
        unsigned long fileSize;
        QString filename;
        QImage label;
+       bool hasUniversalHeader;
+       uint32_t fileType;
+       uint32_t crc;
 };
 
 //hm.
-#define FLM_INDEX              (Qt::UserRole + 1)
-#define FLM_FILESIZE   (Qt::UserRole + 2)
-#define FLM_FILENAME   (Qt::UserRole + 3)
-#define FLM_LABEL              (Qt::UserRole + 4)
+#define FLM_INDEX                      (Qt::UserRole + 1)
+#define FLM_FILESIZE           (Qt::UserRole + 2)
+#define FLM_FILENAME           (Qt::UserRole + 3)
+#define FLM_LABEL                      (Qt::UserRole + 4)
+#define FLM_UNIVERSALHDR       (Qt::UserRole + 5)
+#define FLM_FILETYPE           (Qt::UserRole + 6)
+#define FLM_CRC                                (Qt::UserRole + 7)
 
 class FileListModel: public QAbstractListModel
 {
@@ -40,14 +47,13 @@ class FileListModel: public QAbstractListModel
 //             void AddData(QIcon pix);
 //             void AddData(unsigned long);
                void AddData(unsigned long, QString, QImage, unsigned long);
+               void AddData(unsigned long, QString, QImage, unsigned long, bool, uint32_t, uint32_t);
+               void ClearData(void);
 
 //             FileListData GetData(const QModelIndex & index) const;
 
        private:
-//             std::vector<QIcon> pixList;
-//             std::vector<unsigned long> dbIndex;
                std::vector<FileListData> list;
-//             std::vector<unsigned long> size;
 };
 
 #endif // __FILELISTMODEL_H__
index 73ec88b35b72756fe0728a5706a782acdfb2c993..06e517d0e2d5235c4a014d6c46f5c46aa0c39c5f 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "filepicker.h"
 
+#include "file.h"
 #include "filedb.h"
 #include "filelistmodel.h"
 #include "filethread.h"
@@ -132,10 +133,10 @@ printf("VSB size: %u, %u\n", sbSize3.width(), sbSize3.height());
        labels->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
        dataLayout->addWidget(labels);
        data = new QLabel(QString(tr(
-               "4MB Cartridge<br>"
-               "FEDCBA98<br>"
-               "DOES NOT WORK<br>"
-               "Universal Header detected; Requires DSP"
+               "?MB Cartridge<br>"
+               "????????<br>"
+               "???<br>"
+               "???"
        )));
        data->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
        dataLayout->addWidget(data);
@@ -161,8 +162,14 @@ printf("VSB size: %u, %u\n", sbSize3.width(), sbSize3.height());
 
        fileThread = new FileThread(this);
 //     connect(fileThread, SIGNAL(FoundAFile(unsigned long)), this, SLOT(AddFileToList(unsigned long)));
-       connect(fileThread, SIGNAL(FoundAFile2(unsigned long, QString, QImage *, unsigned long)), this, SLOT(AddFileToList2(unsigned long, QString, QImage *, unsigned long)));
-       fileThread->Go();
+//     connect(fileThread, SIGNAL(FoundAFile2(unsigned long, QString, QImage *, unsigned long)), this, SLOT(AddFileToList2(unsigned long, QString, QImage *, unsigned long)));
+       connect(fileThread, SIGNAL(FoundAFile3(unsigned long, QString, QImage *,
+               unsigned long, bool, unsigned long, unsigned long)), this,
+               SLOT(AddFileToList3(unsigned long, QString, QImage *, unsigned long,
+               bool, unsigned long, unsigned long)));
+
+// Let's defer this to the main window, so we can have some control over when this is done.
+//     fileThread->Go();
 /*
 New sizes: 373x172 (label), 420x340 (cart)
 */
@@ -179,6 +186,13 @@ QString FilePickerWindow::GetSelectedPrettyName(void)
        return prettyFilename;
 }
 
+void FilePickerWindow::ScanSoftwareFolder(bool allow/*= false*/)
+{
+       // "allow" is whether or not to allow scanning for unknown software.
+       model->ClearData();
+       fileThread->Go(allow);
+}
+
 //
 // This slot gets called by the FileThread's run() function when it finds a
 // match in the filesystem to a ROM on our CRC list.
@@ -193,7 +207,9 @@ printf("FilePickerWindow: Found match [%s]...\n", romList[index].name);
 
 void FilePickerWindow::AddFileToList2(unsigned long index, QString str, QImage * img, unsigned long size)
 {
-printf("FilePickerWindow(2): Found match [%s]...\n", romList[index].name);
+if (index != 0xFFFFFFFF)
+       printf("FilePickerWindow(2): Found match [%s]...\n", romList[index].name);
+
        if (img)
        {
                model->AddData(index, str, *img, size);
@@ -204,6 +220,21 @@ printf("FilePickerWindow(2): Found match [%s]...\n", romList[index].name);
                model->AddData(index, str, QImage(), size);
 }
 
+void FilePickerWindow::AddFileToList3(unsigned long index, QString str, QImage * img, unsigned long size, bool haveUniversalHeader, unsigned long fileType, unsigned long crc)
+{
+if (index != 0xFFFFFFFF)
+       printf("FilePickerWindow(3): Found match [%s]...\n", romList[index].name);
+
+       if (img)
+       {
+               model->AddData(index, str, *img, size, haveUniversalHeader, fileType, crc);
+//It would be better to pass the pointer into the model though...
+               delete img;
+       }
+       else
+               model->AddData(index, str, QImage(), size, haveUniversalHeader, fileType, crc);
+}
+
 void FilePickerWindow::LoadButtonPressed(void)
 {
        // TODO: Get the text of the current selection, call the MainWin slot for loading
@@ -229,9 +260,15 @@ void FilePickerWindow::UpdateSelection(const QModelIndex & current, const QModel
        unsigned long i = current.model()->data(current, FLM_INDEX).toUInt();
        QImage label = current.model()->data(current, FLM_LABEL).value<QImage>();
        unsigned long fileSize = current.model()->data(current, FLM_FILESIZE).toUInt();
+       bool haveUniversalHeader = current.model()->data(current, FLM_UNIVERSALHDR).toBool();
+       unsigned long fileType = current.model()->data(current, FLM_FILETYPE).toUInt();
+       uint32 crc = (uint32)current.model()->data(current, FLM_CRC).toUInt();
 //     printf("FPW: %s\n", s.toAscii().data());
+       bool haveUnknown = (i == 0xFFFFFFFF ? true : false);
 #endif
 
+       // Disallow loading completely unknown files, but allow all others.
+       insertCart->setEnabled(haveUnknown && (fileType == JST_NONE) ? false : true);
 //hm.
 //currentFile = s;
 
@@ -268,54 +305,101 @@ void FilePickerWindow::UpdateSelection(const QModelIndex & current, const QModel
                // We should try to be intelligent with our updates here, and only redraw when
                // we're going from a selection with a label to a selection without. Now, we
                // redraw regardless.
-#if 0
-               QImage cart(":/res/cart-blank.png");
-               QPainter painter(&cart);
-//             painter.drawPixmap(23, 87, QPixmap::fromImage(QImage(":/res/label-blank.png")));
-               painter.drawPixmap(27, 89, QPixmap::fromImage(QImage(":/res/label-blank.png")));
-               painter.end();
-#else
                QImage cart;
 
-               if (romList[i].flags & FF_ROM)
+// We now have to sources of data for the passed in files:
+// - The file DB
+// - The file type detection
+// This means we have to be mindful of what's passed back by that stuff.
+// We can assume that if it wasn't found in the DB, then the fileType
+// should be valid.
+// The DB takes precedence over the fileType.
+               if ((!haveUnknown && (romList[i].flags & FF_ROM))
+                       || (haveUnknown && (fileType == JST_ROM)))
                {
                        cart = QImage(":/res/cart-blank.png");
                        QPainter painter(&cart);
                        painter.drawPixmap(27, 89, QPixmap::fromImage(QImage(":/res/label-blank.png")));
                        painter.end();
                }
-               else if (romList[i].flags & FF_ALPINE)
+               else if ((!haveUnknown && (romList[i].flags & FF_ALPINE))
+                       || (haveUnknown && (fileType == JST_ALPINE)))
                {
                        cart = QImage(":/res/alpine-file.png");
                }
+               else if (haveUnknown && (fileType == JST_ABS_TYPE1 || fileType == JST_ABS_TYPE2 || fileType == JST_JAGSERVER))
+               {
+                       cart = QImage(":/res/homebrew-file.png");
+               }
                else
                        cart = QImage(":/res/unknown-file.png");
-#endif
+
                cartImage->setPixmap(QPixmap::fromImage(cart));
        }
 
 //1048576
 //2097152
 //4194304
-       prettyFilename = romList[i].name;
-       title->setText(QString("<h2>%1</h2>").arg(romList[i].name));
+       if (!haveUnknown)
+               prettyFilename = romList[i].name;
+       else
+       {
+               int lastSlashPos = currentFile.lastIndexOf('/');
+               prettyFilename = "\"" + currentFile.mid(lastSlashPos + 1) + "\"";
+       }
+
+       title->setText(QString("<h2>%1</h2>").arg(prettyFilename));
+
 //Kludge for now, we'll have to fix this later...
 // So let's fix it now!
-       QString fileType;
+       QString fileTypeString, crcString, notes, compatibility;
 
-       if (romList[i].flags & FF_ROM)
-               fileType = QString(tr("%1MB Cartridge")).arg(fileSize / 1048576);
-       else if (romList[i].flags & FF_ALPINE)
-               fileType = QString(tr("%1MB Alpine ROM")).arg(fileSize / 1048576);
+#if 0
+       if (!haveUnknown)
+       {
+               if (romList[i].flags & FF_ROM)
+                       fileTypeString = QString(tr("%1MB Cartridge")).arg(fileSize / 1048576);
+               else if (romList[i].flags & FF_ALPINE)
+                       fileTypeString = QString(tr("%1MB Alpine ROM")).arg(fileSize / 1048576);
+               else
+                       fileTypeString = QString(tr("*** UNKNOWN *** (%1 bytes)")).arg(fileSize);
+       }
+#else
+       if ((!haveUnknown && (romList[i].flags & FF_ROM)) || (haveUnknown && (fileType == JST_ROM)))
+               fileTypeString = QString(tr("%1MB Cartridge")).arg(fileSize / 1048576);
+       else if ((!haveUnknown && (romList[i].flags & FF_ALPINE)) || (haveUnknown && (fileType == JST_ALPINE)))
+               fileTypeString = QString(tr("%1MB Alpine ROM")).arg(fileSize / 1048576);
+       else if (haveUnknown && (fileType == JST_ABS_TYPE1 || fileType == JST_ABS_TYPE2))
+               fileTypeString = QString(tr("ABS/COF Executable (%1 bytes)")).arg(fileSize);
+       else if (haveUnknown && (fileType == JST_JAGSERVER))
+               fileTypeString = QString(tr("Jaguar Server Executable (%1 bytes)")).arg(fileSize);
+       else
+               fileTypeString = QString(tr("*** UNKNOWN *** (%1 bytes)")).arg(fileSize);
+#endif
+
+//     crcString = QString("%1").arg(romList[i].crc32, 8, 16, QChar('0')).toUpper();
+       crcString = QString("%1").arg(crc, 8, 16, QChar('0')).toUpper();
+
+       if (!haveUnknown && (romList[i].flags & FF_NON_WORKING))
+               compatibility = "DOES NOT WORK";
        else
-               fileType = QString(tr("*** UNKNOWN *** (%1 bytes)")).arg(fileSize);
-//     QString fileType = QString(romList[i].flags & FF_ROM ? "%1MB Cartridge" : "%1*** UNKNOWN ***")
-//             .arg(fileSize / 1048576);
-       QString crcString = QString("%1").arg(romList[i].crc32, 8, 16, QChar('0')).toUpper();
-       QString notes =
-/*     (romList[i].flags & FF_ROM ? "Jaguar ROM " : "")*/
-               QString(romList[i].flags & FF_BAD_DUMP ? "<b>BAD DUMP</b>" : "");
-       data->setText(QString("%1<br>%2<br>%3<br>%4").arg(fileType).arg(crcString).arg("???%").arg(notes));
+               compatibility = "Unknown";
+
+       // This is going to need some formatting love before long...
+       if (!haveUnknown && (romList[i].flags & FF_BAD_DUMP))
+               notes = "<b>BAD DUMP</b>";
+
+       if (haveUniversalHeader)
+               notes += " Universal Header detected";
+
+       if (!haveUnknown && (romList[i].flags & FF_REQ_DSP))
+               notes += " Requires DSP";
+
+       if (!haveUnknown && (romList[i].flags & FF_VERIFIED))
+               notes += " <i>(Verified)</i>";
+
+       data->setText(QString("%1<br>%2<br>%3<br>%4")
+               .arg(fileTypeString).arg(crcString).arg(compatibility).arg(notes));
 }
 
 /*
index 5ffafded0f254d24eeab2c2d107d0f91fc205d6c..64a9e23592a2ee5f82dec3b741bde0f143ec405c 100644 (file)
@@ -19,10 +19,12 @@ class FilePickerWindow: public QWidget
        public:
                FilePickerWindow(QWidget * parent = 0);
                QString GetSelectedPrettyName(void);
+               void ScanSoftwareFolder(bool allow = false);
 
        public slots:
                void AddFileToList(unsigned long index);
                void AddFileToList2(unsigned long index, QString, QImage *, unsigned long size);
+               void AddFileToList3(unsigned long index, QString, QImage *, unsigned long size, bool, unsigned long, unsigned long);
                void UpdateSelection(const QModelIndex &, const QModelIndex &);
                void LoadButtonPressed(void);
 
index 90bee21229cad767e9dd6403bed875d528e43ed5..28d7389cb3156fe68e49c09019a86b275f09cb13 100644 (file)
@@ -39,8 +39,9 @@ FileThread::~FileThread()
        wait();
 }
 
-void FileThread::Go(void)
+void FileThread::Go(bool allowUnknown/*= false*/)
 {
+       allowUnknownSoftware = allowUnknown;
        QMutexLocker locker(&mutex);
        start();
 }
@@ -138,8 +139,16 @@ void FileThread::HandleFile(QFileInfo fileInfo)
        uint32 index = FindCRCIndexInFileList(crc);
        delete[] buffer;
 
-       if ((index == 0xFFFFFFFF) || (romList[index].flags & FF_BIOS))
-               return;                                                                 // CRC wasn't found, so bail...
+       // Here we filter out files *not* in the DB (if configured that way) and
+       // BIOS files.
+       if (index == 0xFFFFFFFF)
+       {
+               // If we allow unknown software, we pass the (-1) index on, otherwise...
+               if (!allowUnknownSoftware)
+                       return;                                                         // CRC wasn't found, so bail...
+       }
+       else if (romList[index].flags & FF_BIOS)
+               return;
 
 //Here's a little problem. When we create the image here and pass it off to FilePicker,
 //we can clobber this image before we have a chance to copy it out in the FilePicker function
@@ -165,7 +174,8 @@ void FileThread::HandleFile(QFileInfo fileInfo)
 //printf("FileThread: Attempted to load image. Size: %u x %u...\n", img.width(), img.height());
        }
 
-       emit FoundAFile2(index, fileInfo.canonicalFilePath(), img, fileSize);
+//     emit FoundAFile2(index, fileInfo.canonicalFilePath(), img, fileSize);
+       emit FoundAFile3(index, fileInfo.canonicalFilePath(), img, fileSize, foundUniversalHeader, fileType, crc);
 }
 
 //
index 14c1ea748d53832654b38f3b5e0d203598324e45..92b773d23b8d6d1a4bb0d5c2997c7924a79e9ef4 100644 (file)
@@ -15,11 +15,12 @@ class FileThread: public QThread
        public:
                FileThread(QObject * parent = 0);
                ~FileThread();
-               void Go(void);
+               void Go(bool allowUnknown = false);
 
        signals:
                void FoundAFile(unsigned long index);
                void FoundAFile2(unsigned long index, QString filename, QImage * label, unsigned long);
+               void FoundAFile3(unsigned long index, QString filename, QImage * label, unsigned long, bool, unsigned long, unsigned long);
 
        protected:
                void run(void);
@@ -30,6 +31,7 @@ class FileThread: public QThread
                QMutex mutex;
                QWaitCondition condition;
                bool abort;
+               bool allowUnknownSoftware;
 };
 
 #endif // __FILETHREAD_H__
index 21304b5a5ac8e947cdbcea26a9d822693da8db10..1a3414ff858038c951f6733ef2c8eabd256b33f4 100644 (file)
@@ -54,11 +54,13 @@ GeneralTab::GeneralTab(QWidget * parent/*= 0*/): QWidget(parent)
        layout4->addLayout(layout3);
 
        // Checkboxes...
-       useBIOS = new QCheckBox(tr("Enable Jaguar BIOS"));
-       useDSP  = new QCheckBox(tr("Enable DSP"));
+       useBIOS            = new QCheckBox(tr("Enable Jaguar BIOS"));
+       useDSP             = new QCheckBox(tr("Enable DSP"));
+       useUnknownSoftware = new QCheckBox(tr("Allow unknown software in file chooser"));
 
        layout4->addWidget(useBIOS);
        layout4->addWidget(useDSP);
+       layout4->addWidget(useUnknownSoftware);
 
        setLayout(layout4);
 }
index 8584b7b745a7fa019a8b2e97d3b8dc6710e32135..d10b10eb405eefc07a44cc3614f0725e8238fa50 100644 (file)
@@ -19,6 +19,7 @@ class GeneralTab: public QWidget
 
                QCheckBox * useBIOS;
                QCheckBox * useDSP;
+               QCheckBox * useUnknownSoftware;
 };
 
 #endif // __GENERALTAB_H__
index e9069dad698ab4057cdc99e0f13e3ce5a4d60b7e..875f1f7ee88a7d9a02d938da97889265ec668dd1 100644 (file)
@@ -98,7 +98,15 @@ The foreground of the item (the circle representing a pixel) must be rendered us
        QString filename = index.model()->data(index, FLM_FILENAME).toString();
        QImage label = index.model()->data(index, FLM_LABEL).value<QImage>();
 #endif
+       QString nameToDraw;
 
+       if (i == 0xFFFFFFFF)    // Not found...
+       {
+               int lastSlashPos = filename.lastIndexOf('/');
+               nameToDraw = "\"" + filename.mid(lastSlashPos + 1) + "\"";
+       }
+       else
+               nameToDraw = romList[i].name;
 #if 0
        if (role == Qt::DecorationRole)
                return list.at(index.row()).label;
@@ -119,7 +127,8 @@ The foreground of the item (the circle representing a pixel) must be rendered us
 //     painter->setPen(Qt::white);
                painter->setPen(QColor(255, 128, 0, 255));
 //     painter->drawText(QRect(option.rect.x()+20, option.rect.y()+73, 196, 70), Qt::TextWordWrap | Qt::AlignHCenter, QString(romList[i].name));
-               painter->drawText(QRect(option.rect.x()+10, option.rect.y()+36, 196/2, 70/2), Qt::TextWordWrap | Qt::AlignHCenter, QString(romList[i].name));
+               painter->drawText(QRect(option.rect.x()+10, option.rect.y()+36, 196/2, 70/2),
+                       Qt::TextWordWrap | Qt::AlignHCenter, nameToDraw);
        }
        else
        {
index 3c77ff30bbec2b441a31174c0b89e4014e865b30..8ba69dc5195aaaaca14915745ff6d6f669bdc47e 100644 (file)
@@ -15,8 +15,8 @@ class ImageDelegate: public QAbstractItemDelegate
 //             ImageDelegate(QObject * parent = 0);
                ImageDelegate();
 
-               void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const;
-               QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index ) const;
+               void paint(QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index) const;
+               QSize sizeHint(const QStyleOptionViewItem & option, const QModelIndex & index) const;
 
 //     public slots:
 //             void setPixelSize(int size);
index 5193b695f5871d0d07e31572023ca042ab81eba4..c700976d798c4ff8498286dc7f3df52d5b75b24c 100644 (file)
@@ -31,6 +31,7 @@
 #include "settings.h"
 #include "filepicker.h"
 #include "configdialog.h"
+#include "generaltab.h"
 #include "version.h"
 
 #include "jaguar.h"
@@ -80,7 +81,6 @@ MainWin::MainWin(): running(false), powerButtonOn(false), showUntunedTankCircuit
     videoWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
     setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
 
-       ReadSettings();
        setUnifiedTitleAndToolBarOnMac(true);
 
        // Create actions
@@ -184,6 +184,8 @@ MainWin::MainWin(): running(false), powerButtonOn(false), showUntunedTankCircuit
        //      Create status bar
        statusBar()->showMessage(tr("Ready"));
 
+       ReadSettings();
+
        // Set toolbar buttons/menus based on settings read in (sync the UI)...
        blurAct->setChecked(vjs.glFilter);
        x1Act->setChecked(zoomLevel == 1);
@@ -222,6 +224,8 @@ MainWin::MainWin(): running(false), powerButtonOn(false), showUntunedTankCircuit
        CDBIOSLoaded = (JaguarLoadROM(jaguarCDBootROM, vjs.CDBootPath) == 0x40000 ? true : false);
        WriteLog("VJ: CD BIOS is %savailable...\n", (CDBIOSLoaded ? "" : "not "));
 #endif
+
+       filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
 }
 
 void MainWin::closeEvent(QCloseEvent * event)
@@ -279,11 +283,27 @@ void MainWin::Configure(void)
 {
        // Call the configuration dialog and update settings
        ConfigDialog dlg(this);
+       //ick.
+       dlg.generalTab->useUnknownSoftware->setChecked(allowUnknownSoftware);
 
        if (dlg.exec() == false)
                return;
 
+       QString before = vjs.ROMPath;
        dlg.UpdateVJSettings();
+       QString after = vjs.ROMPath;
+
+       bool allowOld = allowUnknownSoftware;
+       //ick.
+       allowUnknownSoftware = dlg.generalTab->useUnknownSoftware->isChecked();
+
+       // We rescan the "software" folder if the user either changed the path or
+       // checked/unchecked the "Allow unknown files" option in the config dialog.
+       if ((before != after) || (allowOld != allowUnknownSoftware))
+               filePickWin->ScanSoftwareFolder(allowUnknownSoftware);
+
+       // Just in case we crash before a clean exit...
+       WriteSettings();
 }
 
 //
@@ -572,6 +592,7 @@ void MainWin::ReadSettings(void)
        filePickWin->move(pos);
 
        zoomLevel = settings.value("zoom", 1).toInt();
+       allowUnknownSoftware = settings.value("showUnknownSoftware", false).toBool();
 
        vjs.useJoystick      = settings.value("useJoystick", false).toBool();
        vjs.joyport          = settings.value("joyport", 0).toInt();
@@ -648,6 +669,7 @@ void MainWin::WriteSettings(void)
        settings.setValue("cartLoadPos", filePickWin->pos());
 
        settings.setValue("zoom", zoomLevel);
+       settings.setValue("showUnknownSoftware", allowUnknownSoftware);
 
        settings.setValue("useJoystick", vjs.useJoystick);
        settings.setValue("joyport", vjs.joyport);
index 52ae4cbc2a15e19f0a4af3334fc596f8e74b4ba8..9149c554803a6f05ed32052c2c0b1d1232e99b20 100644 (file)
@@ -61,6 +61,7 @@ class MainWin: public QMainWindow
                bool powerButtonOn;
                bool showUntunedTankCircuit;
                bool cartridgeLoaded;
+               bool allowUnknownSoftware;
 
                QMenu * fileMenu;
                QMenu * helpMenu;