From c12a2e6043a31df046f107e72d5b32f248a9b07c Mon Sep 17 00:00:00 2001 From: stephena Date: Wed, 10 Feb 2010 22:55:08 +0000 Subject: [PATCH] Checks are now performed when attempting to open a window smaller than 320x240 (the minimum that Stella supports). On 'small' systems using 1x video mode, this means most NTSC games will open in a window of size of 320x240, even though the native size is normally 320x210 (or so). In these cases, the image will be centered vertically. Added FrameBuffer::invalidate(), used to signal that the complete framebuffer can be trashed and entirely written over. This is only active in software mode for now, where it fixes 'overdraw' problems with 320x240 dialogs drawn underneath 320x210 TIA images. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1937 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/common/FrameBufferGL.cxx | 6 ++++++ src/common/FrameBufferGL.hxx | 7 +++++++ src/common/FrameBufferSoft.cxx | 9 ++++++++- src/common/FrameBufferSoft.hxx | 7 +++++++ src/emucore/FrameBuffer.cxx | 16 +++++++++++++--- src/emucore/FrameBuffer.hxx | 7 +++++++ 6 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/common/FrameBufferGL.cxx b/src/common/FrameBufferGL.cxx index c60246ae3..7a7aea04c 100644 --- a/src/common/FrameBufferGL.cxx +++ b/src/common/FrameBufferGL.cxx @@ -450,6 +450,12 @@ cerr << "dimensions: " << (fullScreen() ? "(full)" : "") << endl return true; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FrameBufferGL::invalidate() +{ +// TODO - add code for this +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBufferGL::drawTIA(bool fullRedraw) { diff --git a/src/common/FrameBufferGL.hxx b/src/common/FrameBufferGL.hxx index 46569c9ec..26763c050 100644 --- a/src/common/FrameBufferGL.hxx +++ b/src/common/FrameBufferGL.hxx @@ -145,6 +145,13 @@ class FrameBufferGL : public FrameBuffer */ bool setVidMode(VideoMode& mode); + /** + This method is called to invalidate the contents of the entire + framebuffer (ie, mark the current content as invalid, and erase it on + the next drawing pass). + */ + void invalidate(); + /** This method is called to create a surface compatible with the one currently in use, but having the given dimensions. diff --git a/src/common/FrameBufferSoft.cxx b/src/common/FrameBufferSoft.cxx index a94ed869b..8ed898d17 100644 --- a/src/common/FrameBufferSoft.cxx +++ b/src/common/FrameBufferSoft.cxx @@ -138,6 +138,13 @@ bool FrameBufferSoft::setVidMode(VideoMode& mode) return true; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void FrameBufferSoft::invalidate() +{ + if(myScreen) + SDL_FillRect(myScreen, NULL, 0); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBufferSoft::drawTIA(bool fullRedraw) { @@ -330,7 +337,7 @@ void FrameBufferSoft::drawTIA(bool fullRedraw) uInt8 v = currentFrame[bufofs]; uInt8 w = previousFrame[bufofs]; uInt8 a, b, c; - uInt32 pixel = myAvgPalette[v][w]; + uInt32 pixel = myAvgPalette[v][w]; if(SDL_BYTEORDER == SDL_LIL_ENDIAN) { a = (pixel & myFormat->Bmask) >> myFormat->Bshift; diff --git a/src/common/FrameBufferSoft.hxx b/src/common/FrameBufferSoft.hxx index 6e59fe3e9..10104ffda 100644 --- a/src/common/FrameBufferSoft.hxx +++ b/src/common/FrameBufferSoft.hxx @@ -115,6 +115,13 @@ class FrameBufferSoft : public FrameBuffer */ bool setVidMode(VideoMode& mode); + /** + This method is called to invalidate the contents of the entire + framebuffer (ie, mark the current content as invalid, and erase it on + the next drawing pass). + */ + void invalidate(); + /** This method is called to create a surface compatible with the one currently in use, but having the given dimensions. diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index 334397e99..e459a3210 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -417,6 +417,7 @@ void FrameBuffer::refresh() // This method is in essence a FULL refresh, putting all rendering // buffers in a known, fully redrawn state + invalidate(); bool doubleBuffered = (type() == kGLBuffer); switch(myOSystem->eventHandler().state()) { @@ -913,8 +914,17 @@ void FrameBuffer::setAvailableVidModes(uInt32 baseWidth, uInt32 baseHeight) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FrameBuffer::addVidMode(VideoMode& mode) { + // The are minimum size requirements on a screen, no matter is in fullscreen + // or windowed mode + // Various part of the UI system depend on having at least 320x240 pixels + // available, so we must enforce it here + // Windowed modes can be sized exactly as required, since there's normally - // no restriction on window size (up the maximum size) + // no restriction on window size (between the minimum and maximum size) + mode.screen_w = BSPF_max(mode.screen_w, 320u); + mode.screen_h = BSPF_max(mode.screen_h, 240u); + mode.image_x = (mode.screen_w - mode.image_w) >> 1; + mode.image_y = (mode.screen_h - mode.image_h) >> 1; myWindowedModeList.add(mode); // There are often stricter requirements on fullscreen modes, and they're @@ -928,8 +938,8 @@ void FrameBuffer::addVidMode(VideoMode& mode) { // Auto-calculate 'smart' centering; platform-specific framebuffers are // free to ignore or augment it - mode.screen_w = res[i].width; - mode.screen_h = res[i].height; + mode.screen_w = BSPF_max(res[i].width, 320u); + mode.screen_h = BSPF_max(res[i].height, 240u); mode.image_x = (mode.screen_w - mode.image_w) >> 1; mode.image_y = (mode.screen_h - mode.image_h) >> 1; break; diff --git a/src/emucore/FrameBuffer.hxx b/src/emucore/FrameBuffer.hxx index 12e0f805b..3f34dfe1d 100644 --- a/src/emucore/FrameBuffer.hxx +++ b/src/emucore/FrameBuffer.hxx @@ -380,6 +380,13 @@ class FrameBuffer */ virtual bool setVidMode(VideoMode& mode) = 0; + /** + This method is called to invalidate the contents of the entire + framebuffer (ie, mark the current content as invalid, and erase it on + the next drawing pass). + */ + virtual void invalidate() = 0; + /** This method is called to create a surface compatible with the one currently in use, but having the given dimensions.