From 83fce768d2c1e0e16691c092ea02d64e2b280fad Mon Sep 17 00:00:00 2001 From: Shamus Hammons Date: Sun, 3 Feb 2013 22:34:12 -0600 Subject: [PATCH] Fixed fullscreen mode, shrunk screen width. Full screeen mode now correctly centers the image on wide screen monitors. In addition, the virtual screen width has been reduced in size back to what you would see on a TV with a modest amount of overscan. Assuming all is well with this commit, this will be our 2.1.0 release. Yes, there are still some regressions in a few games that we are aware of, but the improvements over the last official release are too great to hold this back any longer. :-) --- .gitignore | 2 ++ src/gui/about.cpp | 4 +++- src/gui/debug/m68kdasmbrowser.cpp | 12 +++++------ src/gui/glwidget.cpp | 34 +++++++++++++++++++++++++++---- src/gui/glwidget.h | 3 +++ src/gui/mainwin.cpp | 9 +++++++- src/tom.cpp | 9 ++++++-- src/tom.h | 3 ++- 8 files changed, 61 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index 9d442ad..e98ddc5 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,6 @@ src/*~ src/m68000/*~ eeproms/*.eep software/ +build/ +regression-test/ *~ diff --git a/src/gui/about.cpp b/src/gui/about.cpp index 14ccfd8..e56c165 100644 --- a/src/gui/about.cpp +++ b/src/gui/about.cpp @@ -20,6 +20,7 @@ #include "about.h" #include "version.h" + AboutWindow::AboutWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog) { setWindowTitle(tr("About Virtual Jaguar...")); @@ -37,7 +38,7 @@ AboutWindow::AboutWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog) "" "Coders: James Hammons (shamus)
Niels Wagenaar (nwagenaar)
Carwin Jones (Caz)
Adam Green" "Testers: Cyrano Jones, LinkoVitch, neo-rg, Robert R,
TheUMan, Dissection, overridex, geormetal" - "Build Team: ggn (win32)
LinkoVitch, goldenegg (MacOS)" + "Build Team: shamus (win32)
goldenegg (MacOS)" "Homepage: http://icculus.org/virtualjaguar/" "" "

" @@ -58,6 +59,7 @@ AboutWindow::AboutWindow(QWidget * parent/*= 0*/): QWidget(parent, Qt::Dialog) layout->addWidget(text); } + void AboutWindow::keyPressEvent(QKeyEvent * e) { if (e->key() == Qt::Key_Escape || e->key() == Qt::Key_Return) diff --git a/src/gui/debug/m68kdasmbrowser.cpp b/src/gui/debug/m68kdasmbrowser.cpp index 0d94aa3..af21b9e 100644 --- a/src/gui/debug/m68kdasmbrowser.cpp +++ b/src/gui/debug/m68kdasmbrowser.cpp @@ -99,7 +99,7 @@ void M68KDasmBrowserWindow::keyPressEvent(QKeyEvent * e) #if 1 else if (e->key() == Qt::Key_PageUp) { - memBase -= 480; + memBase -= 64; if (memBase < 0) memBase = 0; @@ -108,10 +108,10 @@ void M68KDasmBrowserWindow::keyPressEvent(QKeyEvent * e) } else if (e->key() == Qt::Key_PageDown) { - memBase += 480; + memBase += 64; - if (memBase > (0x200000 - 480)) - memBase = 0x200000 - 480; + if (memBase > (0xF00000 - 64)) + memBase = 0xF00000 - 64; RefreshContents(); } @@ -128,8 +128,8 @@ void M68KDasmBrowserWindow::keyPressEvent(QKeyEvent * e) { memBase += 16; - if (memBase > (0x200000 - 480)) - memBase = 0x200000 - 480; + if (memBase > (0xF00000 - 64)) + memBase = 0xF00000 - 64; RefreshContents(); } diff --git a/src/gui/glwidget.cpp b/src/gui/glwidget.cpp index 56fcd0e..af51f47 100644 --- a/src/gui/glwidget.cpp +++ b/src/gui/glwidget.cpp @@ -9,6 +9,7 @@ // Who When What // --- ---------- ------------------------------------------------------------- // JLH 01/14/2010 Created this file +// JLH 02/03/2013 Added "centered" fullscreen mode with correct aspect ratio // #include "glwidget.h" @@ -22,18 +23,23 @@ #include #endif + GLWidget::GLWidget(QWidget * parent/*= 0*/): QGLWidget(parent), texture(0), - textureWidth(0), textureHeight(0), buffer(0), rasterWidth(340), rasterHeight(240) + textureWidth(0), textureHeight(0), buffer(0), rasterWidth(340), rasterHeight(240), + offset(0) { // Screen pitch has to be the texture width (in 32-bit pixels)... JaguarSetScreenPitch(1024); } + GLWidget::~GLWidget() { -// free(backbuffer); + if (buffer) + delete[] buffer; } + void GLWidget::initializeGL() { format().setDoubleBuffer(true); @@ -49,18 +55,29 @@ void GLWidget::initializeGL() glClearColor(0.0, 0.0, 0.0, 0.0); } + void GLWidget::paintGL() { //kludge rasterHeight = (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL); - unsigned outputWidth = width(); + // If we're in fullscreen mode, we take the value of the screen width as + // set by MainWin, since it may be wider than what our aspect ratio allows. + // In that case, we adjust the viewport over so that it's centered on the + // screen. Otherwise, we simply take the width from our width() funtion + // which will always be correct in windowed mode. + +// unsigned outputWidth = width(); + if (!fullscreen) + outputWidth = width(); + unsigned outputHeight = height(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, outputWidth, 0, outputHeight, -1.0, 1.0); - glViewport(0, 0, outputWidth, outputHeight); +// glViewport(0, 0, outputWidth, outputHeight); + glViewport(0 + offset, 0, outputWidth, outputHeight); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); @@ -79,13 +96,21 @@ rasterHeight = (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCRE unsigned v = outputHeight; glBegin(GL_TRIANGLE_STRIP); +#if 1 glTexCoord2f(0, 0); glVertex3i(0, v, 0); glTexCoord2f(w, 0); glVertex3i(u, v, 0); glTexCoord2f(0, h); glVertex3i(0, 0, 0); glTexCoord2f(w, h); glVertex3i(u, 0, 0); +#else + glTexCoord2f(0, 0); glVertex3i(0 + offset, v, 0); + glTexCoord2f(w, 0); glVertex3i(u + offset, v, 0); + glTexCoord2f(0, h); glVertex3i(0 + offset, 0, 0); + glTexCoord2f(w, h); glVertex3i(u + offset, 0, 0); +#endif glEnd(); } + void GLWidget::resizeGL(int width, int height) { if (width > textureWidth || height > textureHeight) @@ -118,6 +143,7 @@ memset(buffer, 0xFF, textureWidth * textureHeight * sizeof(uint32_t)); } } + #if 0 class RubyGLWidget: public QGLWidget { diff --git a/src/gui/glwidget.h b/src/gui/glwidget.h index 39ed181..1b00079 100644 --- a/src/gui/glwidget.h +++ b/src/gui/glwidget.h @@ -38,6 +38,9 @@ class GLWidget: public QGLWidget bool synchronize; unsigned filter; + int offset; + bool fullscreen; + int outputWidth; }; #endif // __GLWIDGET_H__ diff --git a/src/gui/mainwin.cpp b/src/gui/mainwin.cpp index 88b4d19..1c990fa 100644 --- a/src/gui/mainwin.cpp +++ b/src/gui/mainwin.cpp @@ -874,12 +874,19 @@ void MainWin::SetFullScreen(bool state/*= true*/) // NOTE: Really should check here to see which dimension constrains the other. // Right now, we assume that height is the constraint. int newWidth = (int)(aspectRatio * (double)r.height()); + videoWidget->offset = (r.width() - newWidth) / 2; + videoWidget->fullscreen = true; + videoWidget->outputWidth = newWidth; - videoWidget->setFixedSize(newWidth, r.height()); +// videoWidget->setFixedSize(newWidth, r.height()); + videoWidget->setFixedSize(r.width(), r.height()); showFullScreen(); } else { + // Reset the video widget to windowed mode + videoWidget->offset = 0; + videoWidget->fullscreen = false; menuBar()->show(); statusBar()->show(); showNormal(); diff --git a/src/tom.cpp b/src/tom.cpp index db3f277..845f155 100644 --- a/src/tom.cpp +++ b/src/tom.cpp @@ -323,7 +323,10 @@ // Split the difference? (Seems to be OK for the most part...) // (-10 +10)*4 is for opening up the display by 16 pixels (may go to 20). Need to change VIRTUAL_SCREEN_WIDTH to match this as well (went from 320 to 340; this is 4 HCs per one of those pixels). -#define LEFT_VISIBLE_HC (208 - 16 - (8 * 4)) +//NB: Went back to 330. May shrink more. :-) +//#define LEFT_VISIBLE_HC (208 - 16 - (8 * 4)) +//#define LEFT_VISIBLE_HC (208 - 16 - (3 * 4)) +#define LEFT_VISIBLE_HC (208 - 16 - (1 * 4)) //#define RIGHT_VISIBLE_HC (1488 - 16 + (10 * 4)) #define RIGHT_VISIBLE_HC (LEFT_VISIBLE_HC + (VIRTUAL_SCREEN_WIDTH * 4)) //#define TOP_VISIBLE_VC 25 @@ -334,7 +337,9 @@ //Are these PAL horizontals correct? //They seem to be for the most part, but there are some games that seem to be //shifted over to the right from this "window". -#define LEFT_VISIBLE_HC_PAL (208 - 16 - (4 * 4)) +//#define LEFT_VISIBLE_HC_PAL (208 - 16 - (4 * 4)) +//#define LEFT_VISIBLE_HC_PAL (208 - 16 - (-1 * 4)) +#define LEFT_VISIBLE_HC_PAL (208 - 16 - (-3 * 4)) //#define RIGHT_VISIBLE_HC_PAL (1488 - 16 + (10 * 4)) #define RIGHT_VISIBLE_HC_PAL (LEFT_VISIBLE_HC_PAL + (VIRTUAL_SCREEN_WIDTH * 4)) #define TOP_VISIBLE_VC_PAL 67 diff --git a/src/tom.h b/src/tom.h index 8b95a75..7252148 100644 --- a/src/tom.h +++ b/src/tom.h @@ -16,7 +16,8 @@ // NB: This virtual width is for PWIDTH = 4 //#define VIRTUAL_SCREEN_WIDTH 320 -#define VIRTUAL_SCREEN_WIDTH 340 +//was:340, 330 +#define VIRTUAL_SCREEN_WIDTH 326 #define VIRTUAL_SCREEN_HEIGHT_NTSC 240 #define VIRTUAL_SCREEN_HEIGHT_PAL 256 -- 2.37.2