diff --git a/stella/src/emucore/Console.cxx b/stella/src/emucore/Console.cxx index e9beee7c5..3387c404e 100644 --- a/stella/src/emucore/Console.cxx +++ b/stella/src/emucore/Console.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: Console.cxx,v 1.120 2007-01-06 16:21:29 stephena Exp $ +// $Id: Console.cxx,v 1.121 2007-01-06 21:13:29 stephena Exp $ //============================================================================ #include @@ -483,7 +483,7 @@ void Console::changeXStart(int direction) strval << xstart; myProperties.set(Display_XStart, strval.str()); - ((TIA*)myMediaSource)->recalc(); + ((TIA*)myMediaSource)->frameReset(); myOSystem->frameBuffer().refresh(); message = "XStart "; @@ -521,7 +521,7 @@ void Console::changeYStart(int direction) strval << ystart; myProperties.set(Display_YStart, strval.str()); - ((TIA*)myMediaSource)->recalc(); + ((TIA*)myMediaSource)->frameReset(); myOSystem->frameBuffer().refresh(); message = "YStart "; @@ -565,7 +565,7 @@ void Console::changeWidth(int direction) strval << width; myProperties.set(Display_Width, strval.str()); - ((TIA*)myMediaSource)->recalc(); + ((TIA*)myMediaSource)->frameReset(); initializeVideo(); // takes care of refreshing the screen message = "Width "; @@ -603,7 +603,7 @@ void Console::changeHeight(int direction) strval << height; myProperties.set(Display_Height, strval.str()); - ((TIA*)myMediaSource)->recalc(); + ((TIA*)myMediaSource)->frameReset(); initializeVideo(); // takes care of refreshing the screen message = "Height "; diff --git a/stella/src/emucore/TIA.cxx b/stella/src/emucore/TIA.cxx index da406a400..bf36f4db2 100644 --- a/stella/src/emucore/TIA.cxx +++ b/stella/src/emucore/TIA.cxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: TIA.cxx,v 1.77 2007-01-06 16:21:31 stephena Exp $ +// $Id: TIA.cxx,v 1.78 2007-01-06 21:13:29 stephena Exp $ //============================================================================ #include @@ -131,60 +131,6 @@ void TIA::reset() // Reset the sound device mySound->reset(); - // Recalculate the size of the display - recalc(); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void TIA::systemCyclesReset() -{ - // Get the current system cycle - uInt32 cycles = mySystem->cycles(); - - // Adjust the sound cycle indicator - mySound->adjustCycleCounter(-1 * cycles); - - // Adjust the dump cycle - myDumpDisabledCycle -= cycles; - - // Get the current color clock the system is using - uInt32 clocks = cycles * 3; - - // Adjust the clocks by this amount since we're reseting the clock to zero - myClockWhenFrameStarted -= clocks; - myClockStartDisplay -= clocks; - myClockStopDisplay -= clocks; - myClockAtLastUpdate -= clocks; - myVSYNCFinishClock -= clocks; - myLastHMOVEClock -= clocks; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void TIA::recalc() -{ - // Clear frame buffers - clearBuffers(); - - // Reset pixel pointer and drawing flag - myFramePointer = myCurrentFrameBuffer; - - myYStart = atoi(myConsole.properties().get(Display_YStart).c_str()); - myHeight = atoi(myConsole.properties().get(Display_Height).c_str()); - - // Calculate color clock offsets for starting and stoping frame drawing - myStartDisplayOffset = 228 * myYStart; - myStopDisplayOffset = myStartDisplayOffset + 228 * myHeight; - - // Reasonable values to start and stop the current frame drawing - myClockWhenFrameStarted = mySystem->cycles() * 3; - myClockStartDisplay = myClockWhenFrameStarted + myStartDisplayOffset; - myClockStopDisplay = myClockWhenFrameStarted + myStopDisplayOffset; - myClockAtLastUpdate = myClockWhenFrameStarted; - myClocksToEndOfScanLine = 228; - myVSYNCFinishClock = 0x7FFFFFFF; - myScanlineCountForLastFrame = 0; - myCurrentScanline = 0; - // Currently no objects are enabled myEnabledObjects = 0; @@ -250,6 +196,47 @@ void TIA::recalc() myAllowHMOVEBlanks = (myConsole.properties().get(Emulation_HmoveBlanks) == "YES"); + if(myConsole.getFormat().compare(0, 3, "PAL") == 0) + { + myColorLossEnabled = true; + myMaximumNumberOfScanlines = 342; + } + else // NTSC + { + myColorLossEnabled = false; + myMaximumNumberOfScanlines = 290; + } + + // Recalculate the size of the display + frameReset(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void TIA::frameReset() +{ + // Clear frame buffers + clearBuffers(); + + // Reset pixel pointer and drawing flag + myFramePointer = myCurrentFrameBuffer; + + myYStart = atoi(myConsole.properties().get(Display_YStart).c_str()); + myHeight = atoi(myConsole.properties().get(Display_Height).c_str()); + + // Calculate color clock offsets for starting and stoping frame drawing + myStartDisplayOffset = 228 * myYStart; + myStopDisplayOffset = myStartDisplayOffset + 228 * myHeight; + + // Reasonable values to start and stop the current frame drawing + myClockWhenFrameStarted = mySystem->cycles() * 3; + myClockStartDisplay = myClockWhenFrameStarted + myStartDisplayOffset; + myClockStopDisplay = myClockWhenFrameStarted + myStopDisplayOffset; + myClockAtLastUpdate = myClockWhenFrameStarted; + myClocksToEndOfScanLine = 228; + myVSYNCFinishClock = 0x7FFFFFFF; + myScanlineCountForLastFrame = 0; + myCurrentScanline = 0; + myFrameXStart = atoi(myConsole.properties().get(Display_XStart).c_str()); myFrameWidth = atoi(myConsole.properties().get(Display_Width).c_str()); myFrameYStart = atoi(myConsole.properties().get(Display_YStart).c_str()); @@ -270,19 +257,32 @@ void TIA::recalc() // Values are illegal so reset to default values myFrameHeight = 200; } - - if(myConsole.getFormat().compare(0, 3, "PAL") == 0) - { - myColorLossEnabled = true; - myMaximumNumberOfScanlines = 342; - } - else // NTSC - { - myColorLossEnabled = false; - myMaximumNumberOfScanlines = 290; - } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +void TIA::systemCyclesReset() +{ + // Get the current system cycle + uInt32 cycles = mySystem->cycles(); + + // Adjust the sound cycle indicator + mySound->adjustCycleCounter(-1 * cycles); + + // Adjust the dump cycle + myDumpDisabledCycle -= cycles; + + // Get the current color clock the system is using + uInt32 clocks = cycles * 3; + + // Adjust the clocks by this amount since we're reseting the clock to zero + myClockWhenFrameStarted -= clocks; + myClockStartDisplay -= clocks; + myClockStopDisplay -= clocks; + myClockAtLastUpdate -= clocks; + myVSYNCFinishClock -= clocks; + myLastHMOVEClock -= clocks; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TIA::install(System& system) { diff --git a/stella/src/emucore/TIA.hxx b/stella/src/emucore/TIA.hxx index ff4e4528d..152daae18 100644 --- a/stella/src/emucore/TIA.hxx +++ b/stella/src/emucore/TIA.hxx @@ -13,7 +13,7 @@ // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // -// $Id: TIA.hxx,v 1.40 2007-01-06 16:21:31 stephena Exp $ +// $Id: TIA.hxx,v 1.41 2007-01-06 21:13:29 stephena Exp $ //============================================================================ #ifndef TIA_HXX @@ -42,7 +42,7 @@ class Settings; be displayed on screen. @author Bradford W. Mott - @version $Id: TIA.hxx,v 1.40 2007-01-06 16:21:31 stephena Exp $ + @version $Id: TIA.hxx,v 1.41 2007-01-06 21:13:29 stephena Exp $ */ class TIA : public Device , public MediaSource { @@ -75,6 +75,11 @@ class TIA : public Device , public MediaSource */ virtual void reset(); + /** + Reset frame to change XStart/YStart/Width/Height properties + */ + virtual void frameReset(); + /** Notification method invoked by the system right before the system resets its cycle counter to zero. It may be necessary @@ -82,11 +87,6 @@ class TIA : public Device , public MediaSource */ virtual void systemCyclesReset(); - /** - Recalculate set XStart/YStart/Width/Height properties - */ - virtual void recalc(); - /** Install TIA in the specified system. Invoked by the system when the TIA is attached to it.