From 616ce6039a9ca5247ff089ed6e1c012f5140e0bc Mon Sep 17 00:00:00 2001 From: stephena Date: Wed, 9 Sep 2009 14:02:23 +0000 Subject: [PATCH] Added toggling of HMOVE blanks to the TIA, accessed with the Alt-m key. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1872 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- docs/index.html | 6 ++++++ src/emucore/Console.cxx | 9 +++++++++ src/emucore/Console.hxx | 1 + src/emucore/EventHandler.cxx | 4 ++++ src/emucore/TIA.cxx | 27 +++++++++++++++++---------- src/emucore/TIA.hxx | 8 ++++++++ 6 files changed, 45 insertions(+), 10 deletions(-) diff --git a/docs/index.html b/docs/index.html index 54f3c81c9..16ba0e21c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1853,6 +1853,12 @@ Shift-Cmd + n + + Toggle TIA HMOVE blanks + Alt + m + Shift-Cmd + m + + Toggle TIA 'Fixed Debug Colors' mode Alt + Comma diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index a4b3f8775..385b0210b 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -794,6 +794,15 @@ void Console::toggleTIABit(TIABit bit, const string& bitname, bool show) const myOSystem->frameBuffer().showMessage(message); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void Console::toggleHMOVE() const +{ + if(myTIA->toggleHMOVEBlank()) + myOSystem->frameBuffer().showMessage("HMOVE blanking enabled"); + else + myOSystem->frameBuffer().showMessage("HMOVE blanking disabled"); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Console::enableBits(bool enable) const { diff --git a/src/emucore/Console.hxx b/src/emucore/Console.hxx index 54fb027b4..4eb131bfc 100644 --- a/src/emucore/Console.hxx +++ b/src/emucore/Console.hxx @@ -262,6 +262,7 @@ class Console : public Serializable void toggleM1Bit() const { toggleTIABit(M1Bit, "M1"); } void toggleBLBit() const { toggleTIABit(BLBit, "BL"); } void togglePFBit() const { toggleTIABit(PFBit, "PF"); } + void toggleHMOVE() const; void enableBits(bool enable) const; /** diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 05be3622b..da5cade39 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -392,6 +392,10 @@ void EventHandler::poll(uInt64 time) myOSystem->console().togglePFBit(); break; + case SDLK_m: + myOSystem->console().toggleHMOVE(); + break; + case SDLK_COMMA: myOSystem->console().toggleFixedColors(); break; diff --git a/src/emucore/TIA.cxx b/src/emucore/TIA.cxx index 016eebc92..0b165d186 100644 --- a/src/emucore/TIA.cxx +++ b/src/emucore/TIA.cxx @@ -126,6 +126,7 @@ void TIA::reset() // Currently no objects are enabled or selectively disabled myEnabledObjects = 0; myDisabledObjects = 0; + myAllowHMOVEBlanks = true; // Some default values for the registers myColorPtr = myColor; @@ -509,8 +510,8 @@ bool TIA::load(Serializer& in) mySound.load(in); // Reset TIA bits to be on -// TODO - should we enable this, or leave it to the user? -// enableBits(true); + enableBits(true); + myAllowHMOVEBlanks = true; myColorPtr = myColor; } catch(const char* msg) @@ -741,6 +742,13 @@ bool TIA::toggleBit(TIABit b, uInt8 mode) return on; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool TIA::toggleHMOVEBlank() +{ + myAllowHMOVEBlanks = myAllowHMOVEBlanks ? false : true; + return myAllowHMOVEBlanks; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool TIA::toggleFixedColors(uInt8 mode) { @@ -953,9 +961,10 @@ void TIA::updateFrame(Int32 clock) // TODO - 08-27-2009: Simulate the weird effects of Cosmic Ark and // Stay Frosty. The movement itself is well understood, but there // also seems to be some widening and blanking occurring as well. - // This doesn't properly emulate the effect, but it does give a - // fair approximation. More testing is required to figure out - // what's really going on here. + // This doesn't properly emulate the effect at a low level; it only + // simulates the behaviour as visually seen in the aforementioned + // ROMs. Other ROMs may break this simulation; more testing is + // required to figure out what's really going on here. if(myHMM0mmr && myPOSM0 % 4 == 3) { // Stretch this missle so it's 4 pixels wide, with the 3rd pixel @@ -1026,7 +1035,7 @@ void TIA::updateFrame(Int32 clock) // TODO - 01-21-99: These should be reset right after the first copy // of the player has passed. However, for now we'll just reset at the - // end of the scanline since the other way would be to slow. + // end of the scanline since the other way would be too slow. mySuppressP0 = mySuppressP1 = 0; } } @@ -1838,11 +1847,9 @@ void TIA::poke(uInt16 addr, uInt8 value) int hpos = (clock - myClockWhenFrameStarted) % 228 - HBLANK; myCurrentHMOVEPos = hpos; - // Figure out what cycle we're at - Int32 x = ((clock - myClockWhenFrameStarted) % 228) / 3; - // See if we need to enable the HMOVE blank bug - myHMOVEBlankEnabled = TIATables::HMOVEBlankEnableCycles[x]; + myHMOVEBlankEnabled = myAllowHMOVEBlanks ? + TIATables::HMOVEBlankEnableCycles[((clock - myClockWhenFrameStarted) % 228) / 3] : false; #ifdef USE_MMR_LATCHES // Do we have to undo some of the already applied cycles from an diff --git a/src/emucore/TIA.hxx b/src/emucore/TIA.hxx index 626e8b31e..c34fe3a48 100644 --- a/src/emucore/TIA.hxx +++ b/src/emucore/TIA.hxx @@ -265,6 +265,13 @@ class TIA : public Device */ bool toggleBit(TIABit b, uInt8 mode = 2); + /** + Toggle the display of HMOVE blanks. + + @return Whether the HMOVE blanking was enabled or disabled + */ + bool toggleHMOVEBlank(); + /** Enables/disable/toggle 'fixed debug colors' mode. @@ -525,6 +532,7 @@ class TIA : public Device Int32 myCurrentHMOVEPos; Int32 myPreviousHMOVEPos; bool myHMOVEBlankEnabled; + bool myAllowHMOVEBlanks; // Indicates if unused TIA pins are floating on a peek bool myFloatTIAOutputPins;