From 80871c4045dd1aa9b60e03b9cc92e7d2835a2387 Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Wed, 12 Oct 2011 13:25:59 +0000 Subject: [PATCH] Virtual Jaguar 2.0.0 release. --- Makefile | 8 +- docs/WHATSNEW | 2 +- jaguarcore.mak | 2 +- musashi.mak | 2 +- res/help.html | 243 ++++++++++++++++++++++++++++++++++++++++++- src/file.cpp | 5 +- src/gui/about.cpp | 11 +- src/gui/about.h | 3 + src/gui/app.cpp | 7 ++ src/gui/glwidget.cpp | 36 ++----- src/gui/help.cpp | 37 +------ src/gui/help.h | 5 +- src/gui/mainwin.cpp | 165 ++++------------------------- src/jaguar.cpp | 163 ++++++----------------------- src/jaguar.h | 6 +- src/op.cpp | 7 +- src/tom.cpp | 26 ++--- src/tom.h | 9 +- virtualjaguar.pro | 2 +- 19 files changed, 364 insertions(+), 375 deletions(-) diff --git a/Makefile b/Makefile index ac749db..4061bb1 100644 --- a/Makefile +++ b/Makefile @@ -23,10 +23,10 @@ all: prepare virtualjaguar prepare: @echo -e "\033[01;33m***\033[00;32m Preparing to compile Virtual Jaguar...\033[00m" -# @echo "#define VJ_RELEASE_VERSION \"v2.0.0\"" > src/version.h -# @echo "#define VJ_RELEASE_SUBVERSION \"Final\"" >> src/version.h - @echo "#define VJ_RELEASE_VERSION \"SVN `svn info | grep -i revision`\"" > src/version.h - @echo "#define VJ_RELEASE_SUBVERSION \"2.0.0 Prerelease\"" >> src/version.h + @echo "#define VJ_RELEASE_VERSION \"v2.0.0\"" > src/version.h + @echo "#define VJ_RELEASE_SUBVERSION \"Final\"" >> src/version.h +# @echo "#define VJ_RELEASE_VERSION \"SVN `svn info | grep -i revision`\"" > src/version.h +# @echo "#define VJ_RELEASE_SUBVERSION \"2.0.0 Prerelease\"" >> src/version.h virtualjaguar: sources libs makefile-qt @echo -e "\033[01;33m***\033[00;32m Making Virtual Jaguar GUI...\033[00m" diff --git a/docs/WHATSNEW b/docs/WHATSNEW index bb53efa..4a6c48f 100644 --- a/docs/WHATSNEW +++ b/docs/WHATSNEW @@ -4,7 +4,7 @@ Virtual Jaguar v2.0.0 GCC/Qt * Switched GUI to Qt. And there was much rejoicing. ;-) [Shamus] * Added detection code to fish out files from inside ZIP archives. What this means is that now you can have other goodies inside of your ROM ZIP like - labels, box art, and overlays. See README for details. [Shamus] + labels, box art, and overlays. See built-in help for details. [Shamus] * Various usability improvements, too many to list here. ;-) [Shamus] * Various compatibility improvements to the Jaguar core, too many to list here. ;-) [Shamus] diff --git a/jaguarcore.mak b/jaguarcore.mak index 85fbcca..7d0ef6f 100644 --- a/jaguarcore.mak +++ b/jaguarcore.mak @@ -18,7 +18,7 @@ SDLLIBTYPE := --libs else ifeq "$(findstring Darwin,$(OSTYPE))" "Darwin" # Should catch both 'darwin' and 'darwin7.0' -SYSTYPE := __GCCUNIX__ -D_OSX_ +SYSTYPE := __GCCUNIX__ -D__THINK_STUPID__ SDLLIBTYPE := --static-libs else ifeq "$(findstring Linux,$(OSTYPE))" "Linux" # Linux diff --git a/musashi.mak b/musashi.mak index 1e0d3eb..869b19b 100644 --- a/musashi.mak +++ b/musashi.mak @@ -3,7 +3,7 @@ # # by James L. Hammons # -# This software is licensed under the GPL v3 or any later version. See the +# This makefile is licensed under the GPL v3 or any later version. See the # file GPLv3 for details. ;-) # diff --git a/res/help.html b/res/help.html index c9bd8cc..5ae288f 100644 --- a/res/help.html +++ b/res/help.html @@ -7,7 +7,248 @@

Virtual Jaguar: The Documentation

-Coming Soon! +

Virtual Jaguar Quick Start

+ +

Welcome to Virtual Jaguar! If this is your first time using Virtual Jaguar, you can get a feel for what it is and does by doing the following: + +

+ +

To play, use the left and right keys (mapped to Z and C on your keyboard) and the the B button (mapped to K on your keyboard). You can pause Virtual Jaguar by selecting “Pause” from the “Jaguar” menu, pressing the “Pause” toolbar button, or by pressing the Esc key on your keyboard. You can quit Virtual Jaguar by selecting “Exit” from the “Jaguar” menu, or by pressing Ctrl + Q on your keyboard.

+ +

System Requirements

+ +

Virtual Jaguar should be able to run on most late model computers equipped with an OpenGL compliant video card. It requires a lot of raw oomph in it’s present form to run well; do not be surprised if it doesn’t run at 100% speed with all the options, such as sound and DSP, turned on. Certain subsystems of the Jaguar are not optimized yet and as such take more time than they would if they were optimized. To run Virtual Jaguar at full speed with all options on, we recommend using liquid nitrogen. At least until we get it properly optimized. ;-)

+ +

Virtual Jaguar In Depth

+ +

This version of Virtual Jaguar has been redesigned with a modern GUI and as such should be fairly easy to use and understand. However, some options may not do what you expect: What follows is an exhaustive look at what the various toolbar buttons and menu options do.

+ +

The Toolbar

+ +

The main Virtual Jaguar toolbar contains the following buttons:

+ + + +

Here’s what they do.

+ +

Power

+ +

This toolbar button acts just like the power switch on a real Jaguar, complete with untuned tank circuit noise showing on the screen when the emulated Jaguar is turned off. Some options only take effect after the power has been cycled, such as the NTSC/PAL switches, or the “Use Jaguar BIOS” option in the Configuration dialog.

+ +

Pause

+ +

Pressing the Pause toolbar button will pause execution of the emulated Jaguar. Note that most games have a pause feature that is built into the game; this feature is separate from and will override any built-in game pause feature. Also, the emulator will go into pause mode if the power is on when you activate the “Insert Cartridge” dialog. Pressing the Esc key will also activate this option. Selecting this option in any of the ways listed above, while in pause mode, will take it out of pause mode.

+ +

Insert Cartridge

+ +

Pressing the Insert Cartridge button will bring up the Insert Cartridge dialog; it can also be launched by pressing Ctrl + I on your keyboard. On the left side of the dialog will be a list of software that Virtual Jaguar recognizes from the directory you tell it to look into (see the “Configure” menu option and the “General” tab, “Software” item for more information). Selecting an item in the list will bring up some information about the software on the right side of the dialog, if Virtual Jaguar knows about it. Pressing the icon in the lower right hand side of the dialog will then cause Virtual Jaguar to attempt to run the selected item. Virtual Jaguar cycles the power when it attempts to run the software you select.

+ +

There are also some keyboard shortcuts that come with the Insert Cartridge dialog: Pressing a letter key will highlight the nearest item in the list that starts with that letter. Pressing more than one letter key in quick succession will narrow in on the item that matches those letter keys pressed. Pressing the Esc key will dismiss the dialog without attempting to load anything, and pressing the Enter key is the same as pressing the icon in the lower right hand side of the dialog.

+ +

Use CD Unit

+ +

Pressing this toolbar button will virtually plug in a Jaguar CD unit into the emulated Jaguar. It will not take effect until the power has been cycled.

+ +

As of the release date for this emulator, this option DOES NOT WORK 100% the way it’s intended to: When it’s working correctly, selecting this option will allow you to insert a Jaguar CD game into your computer’s CD/DVD drive and play it as if it were on a real Jaguar. For now, you can see the CD BIOS make pretty patterns on your screen if you use it.

+ +

Note that once this is working as it should, the DSP will be required to be enabled for it to work properly. It WILL NOT WORK properly without the DSP.

+ +

Scale x1

+ +

Selecting this toolbar button will cause the screen to be displayed with pixels that are sized 1 to 1 with your display; this will give you a very small display.

+ +

Scale x2

+ +

This will cause the screen to be displayed with pixels that are sized 2 to 1 with your display.

+ +

Scale x3

+ +

This will cause the screen to be displayed with pixels that are sized 3 to 1 with your display; this should yield a fairly large display.

+ +

NTSC

+ +

Selecting this item will cause the emulated Jaguar to behave as if it were an NTSC type Jaguar, running at 60 Hz. This option will shrink the screen immediately but will not take effect until the emulated Jaguar has been power cycled.

+ +

PAL

+ +

Selecting this item will cause the emulated Jaguar to behave as if it were an PAL type Jaguar, running at 50 Hz. As an added bonus, you also get a few extra scan lines as compared with NTSC mode; some games will even utilize this extra screen real estate. This option will enlarge the screen immediately but will not take effect until the emulated Jaguar has been power cycled.

+ +

Blur

+ +

Normally, the emulated Jaguar’s display shows pixels that are razor sharp and is what you would likely see if the Jaguar was hooked up to a high quality monitor. Selecting this item will cause the emulated Jaguar’s display to be averaged, resulting in a screen that looks slightly blurry—more like what you would expect to see if the Jaguar was hooked up to a television. This is an aesthetic option that some people prefer; you may or may not like it.

+ + +

Jaguar Menu

+ +

This menu has the following options:

+ + + +

Power does the same as the toolbar button; see the “Power” toolbar button description for details.

+ +

Pause does the same as the toolbar button; see the “Pause” toolbar button description for details.

+ +

Insert Cartridge... does the same as the toolbar button; see the “Insert Cartridge” toolbar button description for details.

+ +

Use CD Unit does the same as the toolbar button; see the “Use CD Unit” toolbar button description for details.

+ +

Configure launches the Configure dialog. A full description is given in the “Configure Dialog” section below.

+ +

Exit quits Virtual Jaguar immediately. You can also quit Virtual Jaguar by pressing Ctrl + Q on your keyboard.

+ +

Help Menu

+ +

This menu has the following options:

+ + + +

The Contents is what you’re reading right now. The voice you are hearing in your head is probably your own, though we can’t guarantee that. ;-) This dialog can be dismissed by clicking on the “X” in the upper corner of the dialog, or by pressing the Esc key on your keyboard.

+ +

The About option shows a credits dialog. It can be dismissed by clicking on the “X” in the upper corner of the dialog, or by pressing the Esc key on your keyboard.

+ +

The Configure Dialog

+ +

The Configure dialog has the following tabs:

+ + + +

General Tab

+ +

Under the General tab, there are the following options:

+ + + +

Here’s what they do.

+ +

EEPROMs

+ +

This field holds the location on your filesystem where your EEPROM files will live (see the “EEPROMs” section below for details). The path can be either absolute or relative; if relative, it will be relative to where the Virtual Jaguar executable is located on your filesystem.

+ +

Software

+ +

This field holds the location on your filesystem where your Jaguar software files will live (see the “Software” section below for details). The path can be either absolute or relative; if relative, it will be relative to where the Virtual Jaguar executable is located on your filesystem.

+ +

Enable Jaguar BIOS

+ +

Checking this option will cause the emulated Jaguar to run with the built-in system BIOS upon powering on. This is usually not necessary, but some games will not run correctly without it. Note that this option will only affect cartridge images; it has no effect on Alpine ROMs or homebrew files.

+ +

Enable GPU

+ +

The GPU is one of the three main processors in the Jaguar, and checking this option enables it. Most software will not work without this.

+ +

Enable DSP

+ +

The DSP is one of the three main processors in the Jaguar, and checking this option enables it. Much software will work without it, however, there is some software that will not.

+ +

Enable audio playback

+ +

Checking this option will allow Virtual Jaguar to attempt to output sound to your sound card. It will not output any sound without the DSP being enabled.

+ +

Show all files in file chooser

+ +

Normally the “Insert Cartridge...” dialog will ignore any files it encounters that it doesn’t know how to deal with. You can override this behavior by checking this option. However, this will not cause Virtual Jaguar to be able to load such files.

+ +

Controller Tab

+ +

Under the Controller tab, there are the following options:

+ + + +

Hovering over a letter on the picture of the Jaguar controller will highlight it; clicking on the letter will let you redefine that key. If you prefer, you can define all the keys at once by clicking on the “Define All Keys” button. It will then step through each button on the controller, one at a time, and wait for you to press the key that you wish to set it to. You can exit the key redefinition process at any time by pressing the Esc key on your keyboard.

+ +

EEPROMs

+ +

EEPROMs (Electrically Erasable Programmable Read Only Memory) were typically installed on Jaguar cartridges to save high scores and the like, and Virtual Jaguar emulates this. The EEPROMs are keyed to specific games by making a CRC32 checksum of the game and using this as a filename. If an EEPROM file does not exist, it is created when the emulated Jaguar writes to it. The EEPROM files are stored in the location specified by the “EEPROMs” field of the Configuration dialog, under the “General” tab.

+ +

Software

+ +

Software can be either uncompressed or stored in a ZIP file. Virtual Jaguar looks for software in the location specified by the “Software” field in the Configuration dialog, under the “General” tab.

+ +

Virtual Jaguar is a bit picky about file formats, but tries its best to figure out what you’re trying to feed it. In general, if the file is a ROM image, or an Alpine image, Virtual Jaguar will recognize and utilize it. If it’s a file meant to load into the emulated Jaguar’s RAM space, Virtual Jaguar will load and run it as long as the file contains proper headers. A headerless file of this kind (as opposed to a cartridge or Alpine ROM image) is useless; it contains no information to help Virtual Jaguar know how to load and run it. There is no excuse for this kind of file to exist other than programmer laziness: So, if a file is not recognized by Virtual Jaguar, complain to the author and ask politely for a file with headers. :-)

+ +

Some Issues You May Encounter

+ +

Most of the time Virtual Jaguar tries to do the right thing with what you tell it to do. There are some options, however, that would be more annoying to use if Virtual Jaguar got in the way and forced you to do the right thing, so, in those places where it’s possible to tell Virtual Jaguar to do bad things, it will willingly oblige.

+ +

One of these areas is the NTSC/PAL switch: If you toggle it while the Jaguar is running, most likely it will not do what you want. For the NTSC/PAL switch to have any real effect, you need to power cycle the Jaguar to see it.

+ +

Also, some cartridge based games will not work without either the DSP enabled, the BIOS enabled, or both. Virtual Jaguar will let you attempt to run those games with those options disabled, but the result probably won’t be what you want.

+ +

Jaguar Programmer’s Zone

+ +

Virtual Jaguar has a mode available that makes it more convenient for developers to use. In order to use this mode, you must start Virtual Jaguar with the --alpine option.

+ +

When started in this mode, an Alpine tab is made available in the configuration dialog which gives you the following options:

+ + + +

ROM to load is the path to a Jaguar executable file that will be loaded into the Jaguar’s cartridge memory space at $800000 (Alpine ROM images will load at $802000). As a convenience to coders, this file can be of any length, as long as it fits into the cartridge memory space (a file of this type is treated as an Alpine ROM and is loaded at $802000). The file thus loaded into memory will not be executed.

+ +

ABS to load is the path to a Jaguar executable file that will be loaded in the Jaguar’s main RAM. This file must have valid headers, otherwise Virtual Jaguar won’t be able to load it. Assuming the file exists and has the correct headers in it, it will be loaded and run when Virtual Jaguar is first run.

+ +

The aforementioned options will only work when Virtual Jaguar is run in Alpine mode, that is, when the --alpine flag is passed in. If you do not pass in the --alpine flag, Virtual Jaguar will run as it normally does, i.e., as a stock Jaguar, and nothing will be loaded by default.

+ +

For The Curious

+ +

If you’re wondering why some cartridges have labels in the “Insert Cartridge...” dialog and some don’t, read on...

+ +

Virtual Jaguar looks at your ZIP file as a container—if it finds what it expects in the ZIP, it will use it. For example, label images: If you put an image file of a cartridge label in the ZIP file with your ROM image, Virtual Jaguar will use that image in the “Insert Cartridge...” dialog—assuming it’s a valid image file. The image should be 365 x 168 for it to show up on the big cartridge image without any scaling; any bigger is just a waste of space and Virtual Jaguar will scale it down to 365 x 168 anyway.

+ +

Using the ZIP file as a container this way opens up some exciting possibilities: Box art, overlays and documentation can be included and future versions of Virtual Jaguar will be able to utilize them.

+ +

Legal Nigglings

+ +

Or, as it’s more commonly known, the disclaimer: “O liability, I do disclaim thee!”

+ +

Trademarks used in Virtual Jaguar and/or this documentation are the property of their respective owners. The user(s) of Virtual Jaguar assumes all risk associated with using the software; the authors are not responsible for anything the user(s) does with said software or what happens to the user(s) as a result of using this software.

+ +

Virtual Jaguar is Free (as in Libre) software and is licensed under the GPL version 3. You should have recieved a copy of the license with this software; if you did not, you may view a copy at http://www.gnu.org/licenses. A copy of the source code is available at http://icculus.org/virtualjaguar.

+ +

Downfall is © 2011 Reboot, All Rights Reserved. Distribution of Downfall with Virtual Jaguar has been graciously authorized by Reboot, and may not be distributed as part of any other package.

diff --git a/src/file.cpp b/src/file.cpp index 22f3c8f..7fd96ef 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -126,9 +126,11 @@ bool JaguarLoadFile(char * path) EepromInit(); jaguarRunAddress = 0x802000; // For non-BIOS runs, this is true int fileType = ParseFileType(buffer[0], buffer[1], jaguarROMSize); + jaguarCartInserted = false; if (fileType == JST_ROM) { + jaguarCartInserted = true; memcpy(jagMemSpace + 0x800000, buffer, jaguarROMSize); delete[] buffer; return true; @@ -369,7 +371,8 @@ uint32 ParseFileType(uint8 header1, uint8 header2, uint32 size) // If the file size is divisible by 1M, we probably have an regular ROM. // We can also check our CRC32 against the internal ROM database to be sure. - if ((size % 1048576) == 0) + // (We also check for the Memory Track cartridge size here as well...) + if ((size % 1048576) == 0 || size == 131072) return JST_ROM; // If the file size + 8192 bytes is divisible by 1M, we probably have an diff --git a/src/gui/about.cpp b/src/gui/about.cpp index d964ed5..db688f4 100644 --- a/src/gui/about.cpp +++ b/src/gui/about.cpp @@ -11,6 +11,7 @@ // JLH 01/21/2010 Created this file // JLH 01/22/2010 Fleshed out the credits a bit more // JLH 01/22/2010 Fixed centering and decorating of window +// JLH 10/08/2011 Updated credits, added Esc & Return as exit keys // // STILL TO DO: @@ -32,7 +33,6 @@ AboutWindow::AboutWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog) image->setPixmap(QPixmap(":/res/vj_title_small.png")); layout->addWidget(image); -// QString s = QString(tr("SVN %1
")).arg(__DATE__); QString s;// = QString(""); s.append(tr( "" @@ -40,7 +40,8 @@ AboutWindow::AboutWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog) VJ_RELEASE_VERSION " (" VJ_RELEASE_SUBVERSION ")" "" "" - "" + "" + "" "" "
Coders: James L. Hammons (shamus)
Niels Wagenaar (nwagenaar)
Carwin Jones (Caz)
Adam Green
Testers: Guruma
Testers: Cyrano Jones, Robert R, TheUMan, Dissection,
overridex, geormetal
Build Team: ggn (win32)
goldenegg (MacOS)
Homepage: http://icculus.org/virtualjaguar/
" "

" @@ -60,3 +61,9 @@ AboutWindow::AboutWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog) text = new QLabel(s); layout->addWidget(text); } + +void AboutWindow::keyPressEvent(QKeyEvent * e) +{ + if (e->key() == Qt::Key_Escape || e->key() == Qt::Key_Return) + hide(); +} diff --git a/src/gui/about.h b/src/gui/about.h index 854ebc8..e8e5771 100644 --- a/src/gui/about.h +++ b/src/gui/about.h @@ -15,6 +15,9 @@ class AboutWindow: public QWidget public: AboutWindow(QWidget * parent = 0); + protected: + void keyPressEvent(QKeyEvent *); + private: QVBoxLayout * layout; QLabel * text; diff --git a/src/gui/app.cpp b/src/gui/app.cpp index f3481e9..aad90fe 100644 --- a/src/gui/app.cpp +++ b/src/gui/app.cpp @@ -44,6 +44,13 @@ int main(int argc, char * argv[]) "enough demand for it. :-)\n"); return 0; } + if (strcmp(argv[1], "--yarrr") == 0) + { + printf("\n"); + printf("Shiver me timbers!\n"); + printf("\n"); + return 0; + } if ((strcmp(argv[1], "--alpine") == 0) || (strcmp(argv[1], "-a") == 0)) { printf("Alpine Mode enabled.\n"); diff --git a/src/gui/glwidget.cpp b/src/gui/glwidget.cpp index 65ccd57..e09ebd2 100644 --- a/src/gui/glwidget.cpp +++ b/src/gui/glwidget.cpp @@ -25,21 +25,13 @@ GLWidget::GLWidget(QWidget * parent/*= 0*/): QGLWidget(parent), texture(0), textureWidth(0), textureHeight(0), buffer(0), rasterWidth(320), rasterHeight(240) { -// tomDeviceWidth = rasterWidth; - tomDeviceWidth = 1024; // It has to be the texture width... - - // Set up the backbuffer - // To be safe, this should be 1280 * 625 * 2... - backbuffer = (uint32_t *)malloc(1280 * 625 * sizeof(uint32_t)); -// memset(backbuffer, 0x44, rasterWidth * - memset(backbuffer, 0xFF, 1024 * - (vjs.hardwareTypeNTSC ? rasterHeight : VIRTUAL_SCREEN_HEIGHT_PAL) - * sizeof(uint32_t)); + // Screen pitch has to be the texture width (in 32-bit pixels)... + JaguarSetScreenPitch(1024); } GLWidget::~GLWidget() { - free(backbuffer); +// free(backbuffer); } void GLWidget::initializeGL() @@ -98,13 +90,9 @@ void GLWidget::resizeGL(int width, int height) { if (width > textureWidth || height > textureHeight) { -// textureWidth = max(width, textureWidth); -// textureHeight = max(height, textureHeight); -// Seems that power of 2 sizes are still mandatory... - textureWidth = 1024;//(width > textureWidth ? width : textureWidth); - textureHeight = 512;//(height > textureHeight ? height : textureHeight); -// textureWidth = (width > textureWidth ? width : textureWidth); -// textureHeight = (height > textureHeight ? height : textureHeight); + // Seems that power of 2 sizes are still mandatory... + textureWidth = 1024; + textureHeight = 512; #if 0 printf("Resizing: new texture width/height = %i x %i\n", textureWidth, textureHeight); printf("Resizing: new raster width/height = %i x %i\n", rasterWidth, rasterHeight); @@ -117,23 +105,15 @@ printf("Resizing: new raster width/height = %i x %i\n", rasterWidth, rasterHeigh } buffer = new uint32_t[textureWidth * textureHeight]; -#warning "!!! Remove all backbuffer stuff, since it's unneeded !!!" -/* -We do this here just as a quick 'n' dirty shortcut. We don't need a backbuffer, -as OpenGL takes care of all that crap for us. This means we also have to fix the -Jaguar core, giving it a setup function for setting things like the video buffer, -etc. -*/ - backbuffer = buffer; + JaguarSetScreenBuffer(buffer); //??? -memset(buffer, 0x00, textureWidth * textureHeight * sizeof(uint32_t)); +memset(buffer, 0xFF, textureWidth * textureHeight * sizeof(uint32_t)); glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glPixelStorei(GL_UNPACK_ROW_LENGTH, textureWidth); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); -// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, textureWidth, textureHeight, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, textureWidth, textureHeight, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, NULL); } } diff --git a/src/gui/help.cpp b/src/gui/help.cpp index 8c8c98d..da29009 100644 --- a/src/gui/help.cpp +++ b/src/gui/help.cpp @@ -9,6 +9,7 @@ // Who When What // --- ---------- ------------------------------------------------------------- // JLH 08/01/2011 Created this file +// JLH 10/08/2011 Added Esc & Return as exit keys // // STILL TO DO: @@ -28,41 +29,13 @@ HelpWindow::HelpWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog) // layout->setSizeConstraint(QLayout::SetFixedSize); setLayout(layout); -// image = new QLabel(); -// image->setAlignment(Qt::AlignRight); -// image->setPixmap(QPixmap(":/res/vj_title_small.png")); -// layout->addWidget(image); - text = new QTextBrowser; text->setSource(QUrl("qrc:/res/help.html")); layout->addWidget(text); } -#if 0 -label size is 365x168 -scaled(365, 168 - -#include "htmlviewer.moc" -HtmlViewerWindow *htmlViewerWindow; - -HtmlViewerWindow::HtmlViewerWindow() { - setObjectName("html-window"); - resize(560, 480); - setGeometryString(&config().geometry.htmlViewerWindow); - application.windowList.add(this); - - layout = new QVBoxLayout; - layout->setMargin(Style::WindowMargin); - layout->setSpacing(0); - setLayout(layout); - - document = new QTextBrowser; - layout->addWidget(document); -} - -void HtmlViewerWindow::show(const char *title, const char *htmlData) { - document->setHtml(string() << htmlData); - setWindowTitle(title); - Window::show(); +void HelpWindow::keyPressEvent(QKeyEvent * e) +{ + if (e->key() == Qt::Key_Escape || e->key() == Qt::Key_Return) + hide(); } -#endif diff --git a/src/gui/help.h b/src/gui/help.h index 7b4b48e..23aa947 100644 --- a/src/gui/help.h +++ b/src/gui/help.h @@ -15,11 +15,12 @@ class HelpWindow: public QWidget public: HelpWindow(QWidget * parent = 0); + protected: + void keyPressEvent(QKeyEvent *); + private: QVBoxLayout * layout; QTextBrowser * text; -// QLabel * text; -// QLabel * image; }; #endif // __HELP_H__ diff --git a/src/gui/mainwin.cpp b/src/gui/mainwin.cpp index 08693d0..aab146c 100644 --- a/src/gui/mainwin.cpp +++ b/src/gui/mainwin.cpp @@ -24,6 +24,7 @@ // - Remove SDL dependencies (sound, mainly) from Jaguar core lib // - Fix inconsistency with trailing slashes in paths (eeproms needs one, software doesn't) // +// SFDX CODE: 9XF9TUHFM2359 // Uncomment this for debugging... //#define DEBUG @@ -57,16 +58,6 @@ #include #endif -// Uncomment this to use built-in BIOS/CD-ROM BIOS -// You'll need a copy of jagboot.h & jagcd.h for this to work...! -// Creating those is left as an exercise for the reader. ;-) -//#define USE_BUILT_IN_BIOS - -//#ifdef USE_BUILT_IN_BIOS -//#include "jagboot.h" -//#include "jagcd.h" -//#endif - // The way BSNES controls things is by setting a timer with a zero // timeout, sleeping if not emulating anything. Seems there has to be a // better way. @@ -86,7 +77,6 @@ MainWin::MainWin(): running(true), powerButtonOn(false), showUntunedTankCircuit( videoWidget = new GLWidget(this); setCentralWidget(videoWidget); setWindowIcon(QIcon(":/res/vj-icon.png")); -// setWindowTitle("Virtual Jaguar v2.0.0"); QString title = QString(tr("Virtual Jaguar " VJ_RELEASE_VERSION )); @@ -238,29 +228,13 @@ MainWin::MainWin(): running(true), powerButtonOn(false), showUntunedTankCircuit( connect(timer, SIGNAL(timeout()), this, SLOT(Timer())); timer->start(20); + // We set this initially, to make VJ behave somewhat as it would if no + // cart were inserted and the BIOS was set as active... + jaguarCartInserted = true; WriteLog("Virtual Jaguar %s (Last full build was on %s %s)\n", VJ_RELEASE_VERSION, __DATE__, __TIME__); WriteLog("VJ: Initializing jaguar subsystem...\n"); JaguarInit(); - // Get the BIOS ROM -#ifdef USE_BUILT_IN_BIOS -// WriteLog("VJ: Using built in BIOS/CD BIOS...\n"); -// memcpy(jaguarBootROM, jagBootROM, 0x20000); -// memcpy(jaguarCDBootROM, jagCDROM, 0x40000); -//// 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"); -//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 ")); -#endif - filePickWin->ScanSoftwareFolder(allowUnknownSoftware); // Load up the default ROM if in Alpine mode: @@ -280,6 +254,7 @@ MainWin::MainWin(): running(true), powerButtonOn(false), showUntunedTankCircuit( // Attempt to load/run the ABS file... LoadSoftware(vjs.absROMPath); + memcpy(jagMemSpace + 0xE00000, jaguarDevBootROM2, 0x20000); // Use the stub BIOS } else memcpy(jagMemSpace + 0xE00000, jaguarBootROM, 0x20000); // Otherwise, use the stock BIOS @@ -449,8 +424,8 @@ void MainWin::Timer(void) { for(uint32_t y=0; yrasterHeight; y++) { - videoWidget->buffer[(y * videoWidget->textureWidth) + x] = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24;// | (rand() & 0xFF);//0x000000FF; - // buffer[(y * textureWidth) + x] = x*y; + videoWidget->buffer[(y * videoWidget->textureWidth) + x] + = (rand() & 0xFF) << 8 | (rand() & 0xFF) << 16 | (rand() & 0xFF) << 24; } } } @@ -458,10 +433,6 @@ void MainWin::Timer(void) { // Otherwise, run the Jaguar simulation JaguarExecuteNew(); -//// memcpy(videoWidget->buffer, backbuffer, videoWidget->rasterHeight * videoWidget->rasterWidth); -//No longer needed--see glwidget.cpp for details! -// memcpy(videoWidget->buffer, backbuffer, videoWidget->rasterHeight * videoWidget->textureWidth * sizeof(uint32_t)); -//// memcpy(surface->pixels, backbuffer, TOMGetVideoModeWidth() * TOMGetVideoModeHeight() * 4); } videoWidget->updateGL(); @@ -470,47 +441,40 @@ void MainWin::Timer(void) void MainWin::TogglePowerState(void) { powerButtonOn = !powerButtonOn; + running = true; // With the power off, we simulate white noise on the screen. :-) if (!powerButtonOn) { + useCDAct->setDisabled(false); pauseAct->setChecked(false); 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, // so the untuned tank sim doesn't look wrong. :-) TOMReset(); } else { -//NOTE: Low hanging fruit: We can simplify this a lot... + useCDAct->setDisabled(true); + pauseAct->setChecked(false); + pauseAct->setDisabled(false); + showUntunedTankCircuit = false; + // Otherwise, we prepare for running regular software... - if (!CDActive) - { - showUntunedTankCircuit = false;//(cartridgeLoaded ? false : true); - pauseAct->setChecked(false); - pauseAct->setDisabled(false);//!cartridgeLoaded); - } - // Or, set up for the Jaguar CD - else + if (CDActive) { // Should check for cartridgeLoaded here as well...! // We can clear it when toggling CDActive on, so that when we power cycle it does the // expected thing. Otherwise, if we use the file picker to insert a cart, we expect // to run the cart! Maybe have a RemoveCart function that only works if the CD unit // is active? - showUntunedTankCircuit = false; - pauseAct->setChecked(false); - pauseAct->setDisabled(false); - memcpy(jagMemSpace + 0x800000, jaguarCDBootROM, 0x40000); setWindowTitle(QString("Virtual Jaguar " VJ_RELEASE_VERSION " - Now playing: Jaguar CD")); } WriteLog("GUI: Resetting Jaguar...\n"); JaguarReset(); - running = true; } } @@ -522,14 +486,12 @@ void MainWin::ToggleRunState(void) { for(uint32_t i=0; i<(uint32_t)(videoWidget->textureWidth * 256); i++) { - uint32_t pixel = backbuffer[i]; + uint32_t pixel = videoWidget->buffer[i]; uint8_t r = (pixel >> 24) & 0xFF, g = (pixel >> 16) & 0xFF, b = (pixel >> 8) & 0xFF; pixel = ((r + g + b) / 3) & 0x00FF; - backbuffer[i] = 0x000000FF | (pixel << 16) | (pixel << 8); + videoWidget->buffer[i] = 0x000000FF | (pixel << 16) | (pixel << 8); } - memcpy(videoWidget->buffer, backbuffer, videoWidget->rasterHeight * videoWidget->textureWidth * sizeof(uint32_t)); - videoWidget->updateGL(); } } @@ -642,6 +604,12 @@ void MainWin::ToggleCDUsage(void) { powerAct->setDisabled(true); } +#else + // Set up the Jaguar CD for execution, otherwise, clear memory + if (CDActive) + memcpy(jagMemSpace + 0x800000, jaguarCDBootROM, 0x40000); + else + memset(jagMemSpace + 0x800000, 0xFF, 0x40000); #endif } @@ -820,90 +788,3 @@ void MainWin::WriteSettings(void) settings.setValue("p2k_pound", vjs.p2KeyBindings[BUTTON_d]); settings.setValue("p2k_star", vjs.p2KeyBindings[BUTTON_s]); } - -// Here's how Byuu does it... -// I think I have it working now... :-) -#if 0 -void Utility::resizeMainWindow() -{ - unsigned region = config().video.context->region; - unsigned multiplier = config().video.context->multiplier; - unsigned width = 256 * multiplier; - unsigned height = (region == 0 ? 224 : 239) * multiplier; - - if(config().video.context->correctAspectRatio) - { - if(region == 0) - { - width = (double)width * config().video.ntscAspectRatio + 0.5; //NTSC adjust - } - else - { - width = (double)width * config().video.palAspectRatio + 0.5; //PAL adjust - } - } - - if(config().video.isFullscreen == false) - { - //get effective desktop work area region (ignore Windows taskbar, OS X dock, etc.) - QRect deskRect = QApplication::desktop()->availableGeometry(mainWindow); - - //ensure window size will not be larger than viewable desktop area - constrainSize(height, width, deskRect.height()); //- frameHeight); - constrainSize(width, height, deskRect.width()); //- frameWidth ); - - mainWindow->canvas->setFixedSize(width, height); - mainWindow->show(); - } - else - { - for(unsigned i = 0; i < 2; i++) - { - unsigned iWidth = width, iHeight = height; - - constrainSize(iHeight, iWidth, mainWindow->canvasContainer->size().height()); - constrainSize(iWidth, iHeight, mainWindow->canvasContainer->size().width()); - - //center canvas onscreen; ensure it is not larger than viewable area - mainWindow->canvas->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - mainWindow->canvas->setFixedSize(iWidth, iHeight); - mainWindow->canvas->setMinimumSize(0, 0); - - usleep(2000); - QApplication::processEvents(); - } - } - - //workaround for Qt/Xlib bug: - //if window resize occurs with cursor over it, Qt shows Qt::Size*DiagCursor; - //so force it to show Qt::ArrowCursor, as expected - mainWindow->setCursor(Qt::ArrowCursor); - mainWindow->canvasContainer->setCursor(Qt::ArrowCursor); - mainWindow->canvas->setCursor(Qt::ArrowCursor); - - //workaround for DirectSound(?) bug: - //window resizing sometimes breaks audio sync, this call re-initializes it - updateAvSync(); -} - -void Utility::setScale(unsigned scale) -{ - config().video.context->multiplier = scale; - resizeMainWindow(); - mainWindow->shrink(); - mainWindow->syncUi(); -} - -void QbWindow::shrink() -{ - if(config().video.isFullscreen == false) - { - for(unsigned i = 0; i < 2; i++) - { - resize(0, 0); - usleep(2000); - QApplication::processEvents(); - } - } -} -#endif diff --git a/src/jaguar.cpp b/src/jaguar.cpp index d6e75db..268befd 100644 --- a/src/jaguar.cpp +++ b/src/jaguar.cpp @@ -67,11 +67,7 @@ extern uint8 jagMemSpace[]; uint32 jaguar_active_memory_dumps = 0; uint32 jaguarMainROMCRC32, jaguarROMSize, jaguarRunAddress; - -bool BIOSLoaded = false; -bool CDBIOSLoaded = false; - -uint32 * backbuffer; +bool jaguarCartInserted = false; #ifdef CPU_DEBUG_MEMORY uint8 writeMemMax[0x400000], writeMemMin[0x400000]; @@ -114,7 +110,7 @@ void M68KInstructionHook(void) WriteLog("M68K: Top of stack: %08X. Stack trace:\n", JaguarReadLong(topOfStack)); for(int i=0; i<10; i++) WriteLog("%06X: %08X\n", topOfStack - (i * 4), JaguarReadLong(topOfStack - (i * 4))); - WriteLog("Jaguar: VBL interrupt is %s\n", ((TOMIRQEnabled(IRQ_VBLANK)) && (JaguarInterruptHandlerIsValid(64))) ? "enabled" : "disabled"); + WriteLog("Jaguar: VBL interrupt is %s\n", ((TOMIRQEnabled(IRQ_VIDEO)) && (JaguarInterruptHandlerIsValid(64))) ? "enabled" : "disabled"); M68K_show_context(); LogDone(); exit(0); @@ -350,7 +346,7 @@ CD_switch:: -> $306C WriteLog("M68K: Top of stack: %08X. Stack trace:\n", JaguarReadLong(topOfStack)); for(int i=0; i<10; i++) WriteLog("%06X: %08X\n", topOfStack - (i * 4), JaguarReadLong(topOfStack - (i * 4))); - WriteLog("Jaguar: VBL interrupt is %s\n", ((TOMIRQEnabled(IRQ_VBLANK)) && (JaguarInterruptHandlerIsValid(64))) ? "enabled" : "disabled"); + WriteLog("Jaguar: VBL interrupt is %s\n", ((TOMIRQEnabled(IRQ_VIDEO)) && (JaguarInterruptHandlerIsValid(64))) ? "enabled" : "disabled"); M68K_show_context(); //temp @@ -1205,7 +1201,7 @@ void M68K_show_context(void) WriteLog("..................\n"); - if (TOMIRQEnabled(IRQ_VBLANK)) + if (TOMIRQEnabled(IRQ_VIDEO)) { WriteLog("video int: enabled\n"); JaguarDasm(JaguarGetHandler(64), 0x200); @@ -1587,6 +1583,18 @@ void JaguarWriteLong(uint32 offset, uint32 data, uint32 who/*=UNKNOWN*/) JaguarWriteWord(offset+2, data & 0xFFFF, who); } +void JaguarSetScreenBuffer(uint32 * buffer) +{ + // This is in TOM, but we set it here... + screenBuffer = buffer; +} + +void JaguarSetScreenPitch(uint32 pitch) +{ + // This is in TOM, but we set it here... + screenPitch = pitch; +} + // // Jaguar console initialization // @@ -1617,14 +1625,14 @@ void JaguarInit(void) //New timer based code stuffola... void ScanlineCallback(void); void RenderCallback(void); -//extern uint32 * backbuffer; void JaguarReset(void) { //Need to change this so it uses the single RAM space and load the BIOS //into it somewhere... //Also, have to change this here and in JaguarReadXX() currently // Only use the system BIOS if it's available...! (it's always available now!) - if (vjs.useJaguarBIOS && !vjs.hardwareTypeAlpine) + // AND only if a jaguar cartridge has been inserted. + if (vjs.useJaguarBIOS && jaguarCartInserted && !vjs.hardwareTypeAlpine) memcpy(jaguarMainRAM, jagMemSpace + 0xE00000, 8); else SET32(jaguarMainRAM, 4, jaguarRunAddress); @@ -1640,7 +1648,6 @@ void JaguarReset(void) // New timer base code stuffola... InitializeEventList(); - TOMResetBackbuffer(backbuffer); // SetCallbackTime(ScanlineCallback, 63.5555); SetCallbackTime(ScanlineCallback, 31.77775); // SetCallbackTime(RenderCallback, 33303.082); // # Scanlines * scanline time @@ -1722,7 +1729,7 @@ void JaguarDone(void) // WriteLog("Jaguar: CD BIOS version %04X\n", JaguarReadWord(0x3004)); WriteLog("Jaguar: Interrupt enable = $%02X\n", TOMReadByte(0xF000E1, JAGUAR) & 0x1F); - WriteLog("Jaguar: Video interrupt is %s (line=%u)\n", ((TOMIRQEnabled(IRQ_VBLANK)) + WriteLog("Jaguar: Video interrupt is %s (line=%u)\n", ((TOMIRQEnabled(IRQ_VIDEO)) && (JaguarInterruptHandlerIsValid(64))) ? "enabled" : "disabled", TOMReadWord(0xF0004E, JAGUAR)); M68K_show_context(); //#endif @@ -1770,6 +1777,9 @@ void JaguarDone(void) JaguarDasm(0x802000, 6000); WriteLog("\n");//*/ #endif +/* WriteLog("\n\nM68000 disassembly at $080000...\n"); + JaguarDasm(0x080000, 10000); + WriteLog("\n");//*/ } // @@ -1799,7 +1809,6 @@ void JaguarExecute(uint32 * backbuffer, bool render) uint32 M68KCyclesPerScanline = m68kClockRate / (vp * refreshRate); uint32 RISCCyclesPerScanline = m68kClockRate / (vp * refreshRate); - TOMResetBackbuffer(backbuffer); /*extern int effect_start; if (effect_start) WriteLog("JagExe: VP=%u, VI=%u, CPU CPS=%u, GPU CPS=%u\n", vp, vi, M68KCyclesPerScanline, RISCCyclesPerScanline);//*/ @@ -1809,14 +1818,12 @@ if (effect_start) { // Increment the horizontal count (why? RNG? Besides which, this is *NOT* cycle accurate!) TOMWriteWord(0xF00004, (TOMReadWord(0xF00004, JAGUAR) + 1) & 0x7FF, JAGUAR); - TOMWriteWord(0xF00006, i, JAGUAR); // Write the VC -// if (i == vi) // Time for Vertical Interrupt? //Not sure if this is correct... //Seems to be, kinda. According to the JTRM, this should only fire on odd lines in non-interlace mode... //Which means that it normally wouldn't go when it's zero. - if (i == vi && i > 0 && TOMIRQEnabled(IRQ_VBLANK)) // Time for Vertical Interrupt? + if (i == vi && i > 0 && TOMIRQEnabled(IRQ_VIDEO)) // Time for Vertical Interrupt? { // We don't have to worry about autovectors & whatnot because the Jaguar // tells you through its HW registers who sent the interrupt... @@ -1877,112 +1884,11 @@ uint8 * GetRamPtr(void) // // New Jaguar execution stack +// This executes 1 frame's worth of code. // - -#if 0 - -void JaguarExecuteNew(void) -{ - extern bool finished, showGUI; - extern bool debounceRunKey; - // Pass a message to the "joystick" code to debounce the ESC key... - debounceRunKey = true; - finished = false; -/* InitializeEventList(); - TOMResetBackbuffer(backbuffer); -// SetCallbackTime(ScanlineCallback, 63.5555); - SetCallbackTime(ScanlineCallback, 31.77775); -// SetCallbackTime(RenderCallback, 33303.082); // # Scanlines * scanline time -// SetCallbackTime(RenderCallback, 16651.541); // # Scanlines * scanline time//*/ -// uint8 * keystate = SDL_GetKeyState(NULL); - - do - { - double timeToNextEvent = GetTimeToNextEvent(); -//WriteLog("JEN: Time to next event (%u) is %f usec (%u RISC cycles)...\n", nextEvent, timeToNextEvent, USEC_TO_RISC_CYCLES(timeToNextEvent)); - - m68k_execute(USEC_TO_M68K_CYCLES(timeToNextEvent)); - gpu_exec(USEC_TO_RISC_CYCLES(timeToNextEvent)); - - if (vjs.DSPEnabled) - { - if (vjs.usePipelinedDSP) - DSPExecP2(USEC_TO_RISC_CYCLES(timeToNextEvent)); // Pipelined DSP execution (3 stage)... - else - DSPExec(USEC_TO_RISC_CYCLES(timeToNextEvent)); // Ordinary non-pipelined DSP - } - - HandleNextEvent(); - -// if (keystate[SDLK_ESCAPE]) -// break; - -// SDL_PumpEvents(); // Needed to keep the keystate current... - } - while (!finished); -} - -void ScanlineCallback(void) -{ - uint16 vc = TOMReadWord(0xF00006, JAGUAR); - uint16 vp = TOMReadWord(0xF0003E, JAGUAR) + 1; - uint16 vi = TOMReadWord(0xF0004E, JAGUAR); -// uint16 vbb = TOMReadWord(0xF00040, JAGUAR); - vc++; - - if (vc >= vp) - vc = 0; - -//WriteLog("SLC: Currently on line %u (VP=%u)...\n", vc, vp); - TOMWriteWord(0xF00006, vc, JAGUAR); - -//This is a crappy kludge, but maybe it'll work for now... -//Maybe it's not so bad, since the IRQ happens on a scanline boundary... - if (vc == vi && vc > 0 && tom_irq_enabled(IRQ_VBLANK)) // Time for Vertical Interrupt? - { - // We don't have to worry about autovectors & whatnot because the Jaguar - // tells you through its HW registers who sent the interrupt... - tom_set_pending_video_int(); - m68k_set_irq(2); - } - - TOMExecScanline(vc, true); - -//Change this to VBB??? -//Doesn't seem to matter (at least for Flip Out & I-War) - if (vc == 0) -// if (vc == vbb) - { -joystick_exec(); - - RenderBackbuffer(); - TOMResetBackbuffer(backbuffer); - }//*/ - -// if (vc == 0) -// TOMResetBackbuffer(backbuffer); - -// SetCallbackTime(ScanlineCallback, 63.5555); - SetCallbackTime(ScanlineCallback, 31.77775); -} - -#else - bool frameDone; void JaguarExecuteNew(void) { -// extern bool finished, showGUI; -// extern bool debounceRunKey; - // Pass a message to the "joystick" code to debounce the ESC key... -// debounceRunKey = true; -// finished = false; -/* InitializeEventList(); - TOMResetBackbuffer(backbuffer); -// SetCallbackTime(ScanlineCallback, 63.5555); - SetCallbackTime(ScanlineCallback, 31.77775); -// SetCallbackTime(RenderCallback, 33303.082); // # Scanlines * scanline time -// SetCallbackTime(RenderCallback, 16651.541); // # Scanlines * scanline time//*/ -// uint8 * keystate = SDL_GetKeyState(NULL); frameDone = false; do @@ -2004,11 +1910,6 @@ void JaguarExecuteNew(void) } HandleNextEvent(); - -// if (keystate[SDLK_ESCAPE]) -// break; - -// SDL_PumpEvents(); // Needed to keep the keystate current... } while (!frameDone); } @@ -2029,7 +1930,7 @@ void ScanlineCallback(void) //This is a crappy kludge, but maybe it'll work for now... //Maybe it's not so bad, since the IRQ happens on a scanline boundary... - if (vc == vi && vc > 0 && TOMIRQEnabled(IRQ_VBLANK)) // Time for Vertical Interrupt? + if (vc == vi && vc > 0 && TOMIRQEnabled(IRQ_VIDEO)) // Time for Vertical Interrupt? { // We don't have to worry about autovectors & whatnot because the Jaguar // tells you through its HW registers who sent the interrupt... @@ -2045,26 +1946,20 @@ void ScanlineCallback(void) // if (vc == vbb) { JoystickExec(); -//We comment this out so that the GUI can manage this instead. Which is how it should be anyway. -// RenderBackbuffer(); - TOMResetBackbuffer(backbuffer); frameDone = true; }//*/ -// if (vc == 0) -// TOMResetBackbuffer(backbuffer); - // SetCallbackTime(ScanlineCallback, 63.5555); SetCallbackTime(ScanlineCallback, 31.77775); } -#endif - // This isn't currently used, but maybe it should be... +/* +Nah, the scanline based code is good enough, and runs in 1 frame. The GUI +handles all the rest, so this isn't needed. :-P +*/ void RenderCallback(void) { -// RenderBackbuffer(); - TOMResetBackbuffer(backbuffer); // SetCallbackTime(RenderCallback, 33303.082); // # Scanlines * scanline time SetCallbackTime(RenderCallback, 16651.541); // # Scanlines * scanline time } diff --git a/src/jaguar.h b/src/jaguar.h index 6342d45..4d33afc 100644 --- a/src/jaguar.h +++ b/src/jaguar.h @@ -4,6 +4,8 @@ #include "types.h" #include "memory.h" // For "UNKNOWN" enum +void JaguarSetScreenBuffer(uint32 * buffer); +void JaguarSetScreenPitch(uint32 pitch); void JaguarInit(void); void JaguarReset(void); void JaguarDone(void); @@ -24,12 +26,10 @@ void JaguarExecuteNew(void); // Exports from JAGUAR.CPP -extern bool BIOSLoaded; -extern bool CDBIOSLoaded; extern int32 jaguarCPUInExec; extern uint32 jaguarMainROMCRC32, jaguarROMSize, jaguarRunAddress; extern char * jaguarEepromsPath; -extern uint32 * backbuffer; +extern bool jaguarCartInserted; // Various clock rates diff --git a/src/op.cpp b/src/op.cpp index 2978c6d..9da791b 100644 --- a/src/op.cpp +++ b/src/op.cpp @@ -318,8 +318,6 @@ void DumpFixedObject(uint64 p0, uint64 p1) // // Object Processor main routine // -//Need to fix this so that when an GPU object IRQ happens, we can pick up OP processing -//where we left off. !!! FIX !!! #warning "Need to fix this so that when an GPU object IRQ happens, we can pick up OP processing where we left off. !!! FIX !!!" void OPProcessList(int scanline, bool render) { @@ -342,7 +340,7 @@ bool inhibit; int bitmapCounter = 0; // *** END OP PROCESSOR TESTING ONLY *** - uint32 opCyclesToRun = 10000; // This is a pulled-out-of-the-air value (will need to be fixed, obviously!) + uint32 opCyclesToRun = 30000; // This is a pulled-out-of-the-air value (will need to be fixed, obviously!) // if (op_pointer) WriteLog(" new op list at 0x%.8x scanline %i\n",op_pointer,scanline); while (op_pointer) @@ -454,7 +452,8 @@ WriteLog(" --> List end\n\n"); 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... (and it has... in tom.cpp :-P) +// Actually, this is incorrect. It seems that VDB value is wrong somewhere and that's +// what's causing things to fuck up. Still no idea why. uint32 height = (p0 & 0xFFC000) >> 14; uint32 oldOPP = op_pointer - 8; diff --git a/src/tom.cpp b/src/tom.cpp index ed47bf8..08832a8 100644 --- a/src/tom.cpp +++ b/src/tom.cpp @@ -332,7 +332,11 @@ uint32 tomTimerDivider; int32 tomTimerCounter; uint16 tom_jerry_int_pending, tom_timer_int_pending, tom_object_int_pending, tom_gpu_int_pending, tom_video_int_pending; -uint32 * TOMBackbuffer; + +// These are set by the "user" of the Jaguar core lib, since these are +// OS/system dependent. +uint32 * screenBuffer; +uint32 screenPitch; static const char * videoMode_to_str[8] = { "16 BPP CRY", "24 BPP RGB", "16 BPP DIRECT", "16 BPP RGB", @@ -755,22 +759,20 @@ void tom_render_16bpp_rgb_scanline(uint32 * backbuffer) } -void TOMResetBackbuffer(uint32 * backbuffer) +/*void TOMResetBackbuffer(uint32 * backbuffer) { TOMBackbuffer = backbuffer; -} +}*/ // // Process a single scanline // -uint32 tomDeviceWidth;//kludge void TOMExecScanline(uint16 scanline, bool render) { bool inActiveDisplayArea = true; //Interlacing is still not handled correctly here... !!! FIX !!! if (scanline & 0x01) // Execute OP only on even lines (non-interlaced only!) -// 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: @@ -779,7 +781,9 @@ void TOMExecScanline(uint16 scanline, bool render) //this seems to cause a regression in certain games, like rayman //which means I have to dig thru the asic nets to see what's wrong... #if 1 +// 16 isn't enough, and neither is 32 for raptgun. 32 fucks up Rayman if (scanline >= (uint16)GET16(tomRam8, VDB) && scanline < (uint16)GET16(tomRam8, VDE)) +// if (scanline >= ((uint16)GET16(tomRam8, VDB) - 32) && scanline < (uint16)GET16(tomRam8, VDE)) { if (render) { @@ -820,10 +824,11 @@ void TOMExecScanline(uint16 scanline, bool render) } #endif - // Try to take PAL into account... + // Try to take PAL into account... [We do now!] uint16 topVisible = (vjs.hardwareTypeNTSC ? TOP_VISIBLE_VC : TOP_VISIBLE_VC_PAL), bottomVisible = (vjs.hardwareTypeNTSC ? BOTTOM_VISIBLE_VC : BOTTOM_VISIBLE_VC_PAL); + uint32 * TOMCurrentLine = &(screenBuffer[((scanline - topVisible) / 2) * screenPitch]); // Here's our virtualized scanline code... @@ -834,7 +839,8 @@ void TOMExecScanline(uint16 scanline, bool render) //NOTE: The following doesn't put BORDER color on the sides... !!! FIX !!! #warning "The following doesn't put BORDER color on the sides... !!! FIX !!!" if (vjs.renderType == RT_NORMAL) - scanline_render[TOMGetVideoMode()](TOMBackbuffer); +// scanline_render[TOMGetVideoMode()](TOMBackbuffer); + scanline_render[TOMGetVideoMode()](TOMCurrentLine); else//TV type render { /* @@ -898,7 +904,7 @@ void tom_render_24bpp_scanline(uint32 * backbuffer) else { // If outside of VDB & VDE, then display the border color - uint32 * currentLineBuffer = TOMBackbuffer; + uint32 * currentLineBuffer = TOMCurrentLine; uint8 g = tomRam8[BORD1], r = tomRam8[BORD1 + 1], b = tomRam8[BORD2 + 1]; //Hm. uint32 pixel = 0xFF000000 | (b << 16) | (g << 8) | r; uint32 pixel = 0x000000FF | (r << 24) | (g << 16) | (b << 8); @@ -906,10 +912,6 @@ void tom_render_24bpp_scanline(uint32 * backbuffer) for(uint32 i=0; i