From: Shamus Hammons Date: Thu, 7 Jul 2011 01:39:57 +0000 (+0000) Subject: Fixed 24BPP mode (used R twice instead of B), fixed problem with Object X-Git-Tag: 2.0.0~32 X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=417c77735e5e76ab8803694511b465206d64bf97;p=virtualjaguar Fixed 24BPP mode (used R twice instead of B), fixed problem with Object Processor not running correctly (should be from VC=0), added some keys to the cartridge dialog to allow dismissing and running using ESC & Return. --- diff --git a/Makefile b/Makefile index 4b6b4ea..ac749db 100644 --- 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 diff --git a/src/gui/filelistmodel.cpp b/src/gui/filelistmodel.cpp index 626b296..097514c 100644 --- a/src/gui/filelistmodel.cpp +++ b/src/gui/filelistmodel.cpp @@ -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 diff --git a/src/gui/filepicker.cpp b/src/gui/filepicker.cpp index 06e517d..2886052 100644 --- a/src/gui/filepicker.cpp +++ b/src/gui/filepicker.cpp @@ -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(); } // diff --git a/src/gui/filepicker.h b/src/gui/filepicker.h index 64a9e23..a0e7e06 100644 --- a/src/gui/filepicker.h +++ b/src/gui/filepicker.h @@ -32,6 +32,7 @@ class FilePickerWindow: public QWidget void RequestLoad(QString); protected: + void keyPressEvent(QKeyEvent *); // void PopulateList(void); private: diff --git a/src/gui/mainwin.cpp b/src/gui/mainwin.cpp index 70812d2..75b4bc3 100644 --- a/src/gui/mainwin.cpp +++ b/src/gui/mainwin.cpp @@ -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 { diff --git a/src/objectp.cpp b/src/objectp.cpp index 3863164..5e2c985 100644 --- a/src/objectp.cpp +++ b/src/objectp.cpp @@ -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; } diff --git a/src/tom.cpp b/src/tom.cpp index cdf4797..3f56c8f 100644 --- a/src/tom.cpp +++ b/src/tom.cpp @@ -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...