]> Shamusworld >> Repos - virtualjaguar/commitdiff
Fixed 24BPP mode (used R twice instead of B), fixed problem with Object
authorShamus Hammons <jlhamm@acm.org>
Thu, 7 Jul 2011 01:39:57 +0000 (01:39 +0000)
committerShamus Hammons <jlhamm@acm.org>
Thu, 7 Jul 2011 01:39:57 +0000 (01:39 +0000)
Processor not running correctly (should be from VC=0), added some keys to the
cartridge dialog to allow dismissing and running using ESC & Return.

Makefile
src/gui/filelistmodel.cpp
src/gui/filepicker.cpp
src/gui/filepicker.h
src/gui/mainwin.cpp
src/objectp.cpp
src/tom.cpp

index 4b6b4ea024bcf1b381258ddf6d575aed8616e49c..ac749dba8551d18ef7414cb4de0333d0c579c49e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -39,11 +39,11 @@ makefile-qt: virtualjaguar.pro
 libs: obj/libmusashi.a obj/libjaguarcore.a
        @echo -e "\033[01;33m***\033[00;32m Libraries successfully made.\033[00m"
 
-obj/libmusashi.a: musashi.mak
+obj/libmusashi.a: musashi.mak sources
        @echo -e "\033[01;33m***\033[00;32m Making Musashi...\033[00m"
        $(MAKE) -f musashi.mak
 
-obj/libjaguarcore.a: jaguarcore.mak
+obj/libjaguarcore.a: jaguarcore.mak sources
        @echo -e "\033[01;33m***\033[00;32m Making Virtual Jaguar core...\033[00m"
        $(MAKE) -f jaguarcore.mak
 
index 626b296d9b637af178649f089da61cb4d164e421..097514c851ca18958bbaa2d40b3b3cad335147f9 100644 (file)
@@ -1,5 +1,5 @@
 //
-// filepicker.cpp - A ROM chooser
+// filelistmodel.cpp - A ROM chooser
 //
 // by James L. Hammons
 // (C) 2010 Underground Software
@@ -9,6 +9,7 @@
 // Who  When        What
 // ---  ----------  -------------------------------------------------------------
 // JLH  02/01/2010  Created this file
+// JLH  07/05/2011  Fixed model to not reset itself with each new row insertion
 //
 
 // Note that we have to put in convenience functions to the model for adding data
@@ -26,29 +27,11 @@ FileListModel::FileListModel(QObject * parent/*= 0*/): QAbstractListModel(parent
 
 int FileListModel::rowCount(const QModelIndex & parent/*= QModelIndex()*/) const
 {
-//     return pixList.size();
-//     return dbIndex.size();
        return list.size();
 }
 
 QVariant FileListModel::data(const QModelIndex & index, int role) const
 {
-//     return QVariant();
-//     return pixList.at(index.row());
-//     return (uint)dbIndex.at(index.row());
-//It could be that this is fucking things up...
-#if 0
-       if (role == Qt::DecorationRole)
-               return list.at(index.row()).label;
-       else if (role == Qt::DisplayRole)
-               return (uint)list.at(index.row()).dbIndex;
-       else if (role == Qt::EditRole)
-               return list.at(index.row()).filename;
-       else if (role == Qt::WhatsThisRole)
-               return (uint)list.at(index.row()).fileSize;
-       else
-               return QVariant();
-#else
        if (role == FLM_LABEL)
                return list.at(index.row()).label;
        else if (role == FLM_INDEX)
@@ -65,44 +48,17 @@ QVariant FileListModel::data(const QModelIndex & index, int role) const
                return (uint)list.at(index.row()).crc;
 
        return QVariant();
-#endif
 }
 
 QVariant FileListModel::headerData(int/* section*/, Qt::Orientation/* orientation*/, int role/*= Qt::DisplayRole*/) const
 {
-#if 0
-       // Not sure that this is necessary for our purposes...
-       // Especially since this model would never make use of this info...
-       if (role != Qt::DisplayRole)
-               return QVariant();
-
-       if (orientation == Qt::Horizontal)
-               return QString("Column %1").arg(section);
-       else
-               return QString("Row %1").arg(section);
-#else
        // This seems more like what we want...
        if (role == Qt::SizeHintRole)
                return QSize(1, 1);
 
        return QVariant();
-#endif
 }
 
-/*
-void FileListModel::AddData(QIcon pix)
-{
-       pixList.push_back(pix);
-       reset();
-}
-
-void FileListModel::AddData(unsigned long index)
-{
-       dbIndex.push_back(index);
-       reset();
-}
-*/
-
 void FileListModel::AddData(unsigned long index, QString str, QImage img, unsigned long size)
 {
        // Assuming that both QString and QImage have copy constructors, this should work.
@@ -113,8 +69,10 @@ void FileListModel::AddData(unsigned long index, QString str, QImage img, unsign
        data.filename = str;
        data.label = img;
 
+       // Let's try this:
+       beginInsertRows(QModelIndex(), list.size(), list.size());
        list.push_back(data);
-       reset();
+       endInsertRows();
 }
 
 void FileListModel::AddData(unsigned long index, QString str, QImage img, unsigned long size, bool univHdr, uint32_t type, uint32_t fileCrc)
@@ -130,11 +88,10 @@ void FileListModel::AddData(unsigned long index, QString str, QImage img, unsign
        data.fileType = type;
        data.crc = fileCrc;
 
+       // Let's try this:
+       beginInsertRows(QModelIndex(), list.size(), list.size());
        list.push_back(data);
-//This is probably not the best way to do this, it prevents the user from using the
-//list while it populates.
-#warning "!!! AddData calls reset() for every addition, this is bad !!!"
-       reset();
+       endInsertRows();
 }
 
 void FileListModel::ClearData(void)
@@ -151,65 +108,3 @@ void FileListModel::ClearData(void)
 //{
 //     return list.at(index.row());
 //}
-
-#if 0
-
-class StringListModel : public QAbstractListModel
-{
-       Q_OBJECT
-
-       public:
-               StringListModel(const QStringList &strings, QObject *parent = 0)
-                       : QAbstractListModel(parent), stringList(strings) {}
-
-               int rowCount(const QModelIndex &parent = QModelIndex()) const;
-               QVariant data(const QModelIndex &index, int role) const;
-               QVariant headerData(int section, Qt::Orientation orientation,
-                                                       int role = Qt::DisplayRole) const;
-
-       private:
-               QStringList stringList;
-};
-
-int StringListModel::rowCount(const QModelIndex &parent) const
-{
-       return stringList.count();
-}
-
-QVariant StringListModel::data(const QModelIndex &index, int role) const
-{
-       if (!index.isValid())
-               return QVariant();
-
-       if (index.row() >= stringList.size())
-               return QVariant();
-
-       if (role == Qt::DisplayRole)
-               return stringList.at(index.row());
-       else
-               return QVariant();
-}
-
-
-QVariant StringListModel::headerData(int section, Qt::Orientation orientation, int role) const
-{
-       if (role != Qt::DisplayRole)
-               return QVariant();
-
-       if (orientation == Qt::Horizontal)
-               return QString("Column %1").arg(section);
-       else
-               return QString("Row %1").arg(section);
-}
-
-
-
- void ImageModel::setImage(const QImage &image)
- {
-     modelImage = image;
-     reset();
- }
-
-The QAbstractItemModel::reset() call tells the view(s) that the model has changed.
-
-#endif
index 06e517d0e2d5235c4a014d6c46f5c46aa0c39c5f..288605274d0dc47d6978dc6eb3b2414b093f5ff8 100644 (file)
@@ -89,11 +89,30 @@ printf("VSB size: %u, %u\n", sbSize3.width(), sbSize3.height());
        printf("VSB size width: %u\n", sbWidth);
        int sbWidth2 = vsb->sizeHint().width();
        printf("VSB sizeHint width: %u\n", sbWidth2);
+       int sbWidth3 = vsb->minimumSize().width();
+       printf("VSB minimum width: %u\n", sbWidth3);
+       int sbWidth4 = vsb->frameSize().width();
+       printf("VSB frame width: %u\n", sbWidth4);
        delete vsb;
 
+//     fileList->setFixedWidth((488/4) + 4);
+       int sbWidth5 = fileList->frameWidth();
+       printf("List frame width: %u, (diff=%d)\n", sbWidth5, sbWidth5 - ((488/4) + 4));
+       int sbWidth6 = fileList->sizeHint().width();
+       printf("List sizeHint width: %u\n", sbWidth6);
+       int sbWidth7 = fileList->minimumSize().width();
+       printf("List minimum width: %u\n", sbWidth7);
+       int sbWidth8 = fileList->minimumSizeHint().width();
+       printf("List minimum hint width: %u\n", sbWidth8);
 //     fileList->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
 //     fileList->verticalScrollBar()->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
+       // (488/4) + 4 is the width of the object in the filelistmodel. Dunno why the QListView
+       // isn't picking that up. :-(
        fileList->setFixedWidth((488/4) + 4 + sbWidth);//ick
+//     fileList->setFixedWidth((488/4) + 4 + 17 + 4);//sbWidth);//ick
+
+//     fileList->setSpacing(4);
+       fileList->setUniformItemSizes(true);
 #endif
 
 //     QVBoxLayout * layout = new QVBoxLayout;
@@ -181,6 +200,14 @@ New sizes: 373x172 (label), 420x340 (cart)
        connect(insertCart, SIGNAL(clicked()), this, SLOT(LoadButtonPressed()));
 }
 
+void FilePickerWindow::keyPressEvent(QKeyEvent * e)
+{
+       if (e->key() == Qt::Key_Escape)
+               hide();
+       else if (e->key() == Qt::Key_Return)
+               LoadButtonPressed();
+}
+
 QString FilePickerWindow::GetSelectedPrettyName(void)
 {
        return prettyFilename;
@@ -222,8 +249,8 @@ if (index != 0xFFFFFFFF)
 
 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 (index != 0xFFFFFFFF)
+//     printf("FilePickerWindow(3): Found match [%s]...\n", romList[index].name);
 
        if (img)
        {
@@ -239,7 +266,7 @@ void FilePickerWindow::LoadButtonPressed(void)
 {
        // TODO: Get the text of the current selection, call the MainWin slot for loading
        emit(RequestLoad(currentFile));
-       this->hide();
+       hide();
 }
 
 //
index 64a9e23592a2ee5f82dec3b741bde0f143ec405c..a0e7e0663d174bf3f5d3f8bd1141276401fff14d 100644 (file)
@@ -32,6 +32,7 @@ class FilePickerWindow: public QWidget
                void RequestLoad(QString);
 
        protected:
+               void keyPressEvent(QKeyEvent *);
 //             void PopulateList(void);
 
        private:
index 70812d27d6ea607cd93e5b7135c2460e0793e579..75b4bc385ae734ca09a6e89ce7a5c849ddfbceaa 100644 (file)
@@ -14,6 +14,7 @@
 
 // FIXED:
 //
+// - Add dbl click/enter to select in cart list, ESC to dimiss [DONE]
 //
 // STILL TO BE DONE:
 //
@@ -21,7 +22,6 @@
 // - 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)
-// - Add dbl click/enter to select in cart list, ESC to dimiss
 //
 
 /*
@@ -479,6 +479,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
+               TOMReset();
        }
        else
        {
index 38631648d250d048c38384bc175e46b39c184d8a..5e2c9850d8f73e6066af07b9a010aa231a7163f0 100644 (file)
@@ -359,9 +359,12 @@ else
                uint64 p0 = OPLoadPhrase(op_pointer);
 //WriteLog("\t%08X type %i\n", op_pointer, (uint8)p0 & 0x07);
                op_pointer += 8;
+
+#if 1
 if (scanline == TOMGetVDB() && op_start_log)
 //if (scanline == 215 && op_start_log)
 //if (scanline == 28 && op_start_log)
+//if (scanline == 0)
 {
 WriteLog("%08X --> phrase %08X %08X", op_pointer - 8, (int)(p0>>32), (int)(p0&0xFFFFFFFF));
 if ((p0 & 0x07) == OBJECT_TYPE_BITMAP)
@@ -425,8 +428,9 @@ for(int k=0; k<8; k++)
 WriteLog("\n");
 }
 if ((p0 & 0x07) == OBJECT_TYPE_STOP)
-WriteLog("    --> List end\n");
-}//*/
+WriteLog("    --> List end\n\n");
+}
+#endif
 
                switch ((uint8)p0 & 0x07)
                {
@@ -443,8 +447,15 @@ WriteLog("    --> List end\n");
 
 //No, the reason this was needed is that the OP code before was wrong. Any value
 //less than VDB will get written to the top line of the display!
-//                     if (ypos == 0)
-//                             ypos = TOMReadWord(0xF00046, OP) / 2;                   // Get the VDB value
+#if 0
+// Not so sure... Let's see what happens here...
+// No change...
+                       if (ypos == 0)
+                               ypos = TOMReadWord(0xF00046, OP) / 2;                   // Get the VDB value
+#endif
+// Actually, no. Any item less than VDB will get only the lines that hang over VDB displayed.
+// So we need to fix this somehow...
+
                        uint32 height = (p0 & 0xFFC000) >> 14;
                        uint32 oldOPP = op_pointer - 8;
 // *** BEGIN OP PROCESSOR TESTING ONLY ***
@@ -504,6 +515,7 @@ if (!inhibit)       // For OP testing only!
                        uint16 ypos = (p0 >> 3) & 0x7FF;
                        uint32 height = (p0 & 0xFFC000) >> 14;
                        uint32 oldOPP = op_pointer - 8;
+//WriteLog("OP: Scaled Object (ypos=%04X, height=%04X", ypos, height);
 // *** BEGIN OP PROCESSOR TESTING ONLY ***
 if (inhibit && op_start_log)
 {
@@ -524,7 +536,8 @@ if (!inhibit)       // For OP testing only!
 
                                // OP write-backs
 
-                               uint8 remainder = p2 >> 16, vscale = p2 >> 8;
+                               uint16 remainder = (p2 >> 16) & 0xFF;//, vscale = p2 >> 8;
+                               uint8 /*remainder = p2 >> 16,*/ vscale = p2 >> 8;
 //Actually, we should skip this object if it has a vscale of zero.
 //Or do we? Not sure... Atari Karts has a few lines that look like:
 // (SCALED BITMAP)
@@ -532,6 +545,7 @@ if (!inhibit)       // For OP testing only!
 //    [7 (0) x 1 @ (13, 0) (8 bpp), l: 000E82A0, p: 000E0FC0 fp: 00, fl:RELEASE, idx:00, pt:01]
 //    [hsc: 9A, vsc: 00, rem: 00]
 // Could it be the vscale is overridden if the DWIDTH is zero? Hmm...
+//WriteLog("OP: Scaled bitmap processing (rem=%02X, vscale=%02X)...\n", remainder, vscale);//*/
 
                                if (vscale == 0)
                                        vscale = 0x20;                                  // OP bug??? Nope, it isn't...! Or is it?
@@ -580,7 +594,9 @@ OP: Scaled bitmap 4x? 4bpp at 34,? hscale=80 fpix=0 data=000756E8 pitch 1 hflipp
 //                             if ((remainder - 1) >= 0xE0)            // I.e., it's <= 0
 //                             if ((remainder >= 0xE1) || remainder == 0)// I.e., it's <= 0
 //                             if ((remainder >= 0xE1 && remainder <= 0xFF) || remainder == 0)// I.e., it's <= 0
-                               if (remainder <= 0x20)                          // I.e., it's <= 0
+//                             if (remainder <= 0x20)                          // I.e., it's <= 1.0
+                               // I.e., it's < 1.0f -> means it'll go negative when we subtract 1.0f.
+                               if (remainder < 0x20)
                                {
                                        uint64 data = (p0 & 0xFFFFF80000000000LL) >> 40;
                                        uint64 dwidth = (p1 & 0xFFC0000) >> 15;
@@ -590,7 +606,8 @@ OP: Scaled bitmap 4x? 4bpp at 34,? hscale=80 fpix=0 data=000756E8 pitch 1 hflipp
 //                                     while ((remainder - 1) >= 0xE0)
 //                                     while ((remainder >= 0xE1) || remainder == 0)
 //                                     while ((remainder >= 0xE1 && remainder <= 0xFF) || remainder == 0)
-                                       while (remainder <= 0x20)
+//                                     while (remainder <= 0x20)
+                                       while (remainder < 0x20)
                                        {
                                                remainder += vscale;
 
@@ -615,10 +632,11 @@ OP: Scaled bitmap 4x? 4bpp at 34,? hscale=80 fpix=0 data=000756E8 pitch 1 hflipp
                                p2 &= ~0x0000000000FF0000LL;
                                p2 |= (uint64)remainder << 16;
 //WriteLog("%08X%08X]\n", (uint32)(p2>>32), (uint32)(p2&0xFFFFFFFF));
-                               OPStorePhrase(oldOPP+16, p2);
+                               OPStorePhrase(oldOPP + 16, p2);
 //remainder = (uint8)(p2 >> 16), vscale = (uint8)(p2 >> 8);
 //WriteLog(" [after]: rem=%02X, vscale=%02X\n", remainder, vscale);
                        }
+
                        op_pointer = (p0 & 0x000007FFFF000000LL) >> 21;
                        break;
                }
index cdf47979451ec617e799fb5f372a121d056eeb83..3f56c8fba1b87961261d75e70dde24dbddb38c44 100644 (file)
@@ -696,7 +696,7 @@ void tom_render_24bpp_scanline(uint32 * backbuffer)
                current_line_buffer++;
                uint32 b = *current_line_buffer++;
 //hm.          *backbuffer++ = 0xFF000000 | (b << 16) | (g << 8) | r;
-               *backbuffer++ = 0x000000FF | (r << 24) | (g << 16) | (r << 8);
+               *backbuffer++ = 0x000000FF | (r << 24) | (g << 16) | (b << 8);
                width--;
        }
 }
@@ -770,6 +770,10 @@ void TOMExecScanline(uint16 scanline, bool render)
        if (scanline & 0x01)                                                    // Execute OP only on even lines (non-interlaced only!)
                return;
 
+//Hm, it seems that the OP needs to execute from zero, so let's try it:
+// And it works! But need to do some optimizations in the OP to keep it from attempting
+// to do a scanline render in the non-display area... [DONE]
+#if 0
        if (scanline >= (uint16)GET16(tomRam8, VDB) && scanline < (uint16)GET16(tomRam8, VDE))
        {
                if (render)
@@ -787,6 +791,29 @@ void TOMExecScanline(uint16 scanline, bool render)
        }
        else
                inActiveDisplayArea = false;
+#else
+       inActiveDisplayArea =
+               (scanline >= (uint16)GET16(tomRam8, VDB) && scanline < (uint16)GET16(tomRam8, VDE)
+                       ? true : false);
+
+       if (scanline < (uint16)GET16(tomRam8, VDE))
+       {
+               if (render)//With JaguarExecuteNew() this is always true...
+               {
+                       uint8 * current_line_buffer = (uint8 *)&tomRam8[0x1800];
+                       uint8 bgHI = tomRam8[BG], bgLO = tomRam8[BG + 1];
+
+                       // Clear line buffer with BG
+                       if (GET16(tomRam8, VMODE) & BGEN) // && (CRY or RGB16)...
+                               for(uint32 i=0; i<720; i++)
+                                       *current_line_buffer++ = bgHI, *current_line_buffer++ = bgLO;
+
+//                     OPProcessList(scanline, render);
+//This seems to take care of it...
+                       OPProcessList(scanline, inActiveDisplayArea);
+               }
+       }
+#endif
 
        // Try to take PAL into account...