From 6b4cc11b0334179c0f1f1fe460e31a5590340508 Mon Sep 17 00:00:00 2001 From: stephena Date: Thu, 16 Jul 2009 12:17:42 +0000 Subject: [PATCH] First partial commit of the new TIA code. This ones fixes collision detection being done outside the displayable area. Originally, areas above 'YStart' scanline were not processed as all, as an optimization. However, several ROMs can do collision detection above ystart, so we now process the entire frame (but only display the stuff below ystart). Bumped version number. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1839 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- src/common/Version.hxx | 2 +- src/emucore/TIA.cxx | 20 +++++++++++--------- src/emucore/TIA.hxx | 10 ++++++++-- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/common/Version.hxx b/src/common/Version.hxx index 9d457cd96..4269bc09e 100644 --- a/src/common/Version.hxx +++ b/src/common/Version.hxx @@ -19,7 +19,7 @@ #ifndef VERSION_HXX #define VERSION_HXX -#define STELLA_BASE_VERSION "2.8.5_svn" +#define STELLA_BASE_VERSION "3.0_svn" #ifdef NIGHTLY_BUILD #define STELLA_VERSION STELLA_BASE_VERSION "pre-" NIGHTLY_BUILD diff --git a/src/emucore/TIA.cxx b/src/emucore/TIA.cxx index 3946fdcee..c3bebb646 100644 --- a/src/emucore/TIA.cxx +++ b/src/emucore/TIA.cxx @@ -56,8 +56,8 @@ TIA::TIA(Console& console, Sound& sound, Settings& settings) myFrameCounter(0) { // Allocate buffers for two frame buffers - myCurrentFrameBuffer = new uInt8[160 * 300]; - myPreviousFrameBuffer = new uInt8[160 * 300]; + myCurrentFrameBuffer = new uInt8[160 * 320]; + myPreviousFrameBuffer = new uInt8[160 * 320]; // Make sure all TIA bits are enabled enableBits(true); @@ -206,9 +206,13 @@ void TIA::frameReset() if(myFrameHeight < 210) myFrameHeight = 210; if(myFrameHeight > 256) myFrameHeight = 256; - // Calculate color clock offsets for starting and stoping frame drawing - myStartDisplayOffset = 228 * myFrameYStart; - myStopDisplayOffset = myStartDisplayOffset + 228 * myFrameHeight; + myFramePointerOffset = 160 * myFrameYStart; + + // Calculate color clock offsets for starting and stopping frame drawing + // Note that although we always start drawing at scanline zero, the + // framebuffer that is exposed outside the class actually starts at 'ystart' + myStartDisplayOffset = 0; + myStopDisplayOffset = 228 * (myFrameYStart + myFrameHeight); // Reasonable values to start and stop the current frame drawing myClockWhenFrameStarted = mySystem->cycles() * 3; @@ -217,8 +221,6 @@ void TIA::frameReset() myClockAtLastUpdate = myClockWhenFrameStarted; myClocksToEndOfScanLine = 228; myVSYNCFinishClock = 0x7FFFFFFF; - myScanlineCountForLastFrame = 0; - myCurrentScanline = 0; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1424,8 +1426,8 @@ void TIA::greyOutFrame() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void TIA::clearBuffers() { - memset(myCurrentFrameBuffer, 0, 160 * 300); - memset(myPreviousFrameBuffer, 0, 160 * 300); + memset(myCurrentFrameBuffer, 0, 160 * 320); + memset(myPreviousFrameBuffer, 0, 160 * 320); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/TIA.hxx b/src/emucore/TIA.hxx index 5ca036821..5da6c29c7 100644 --- a/src/emucore/TIA.hxx +++ b/src/emucore/TIA.hxx @@ -147,14 +147,16 @@ class TIA : public Device @return Pointer to the current frame buffer */ - uInt8* currentFrameBuffer() const { return myCurrentFrameBuffer; } + uInt8* currentFrameBuffer() const + { return myCurrentFrameBuffer + myFramePointerOffset; } /** Answers the previous frame buffer @return Pointer to the previous frame buffer */ - uInt8* previousFrameBuffer() const { return myPreviousFrameBuffer; } + uInt8* previousFrameBuffer() const + { return myPreviousFrameBuffer + myFramePointerOffset; } /** Answers the width and height of the frame buffer @@ -283,6 +285,10 @@ class TIA : public Device // Pointer to the next pixel that will be drawn in the current frame buffer uInt8* myFramePointer; + // Indicates offset used by the exported frame buffer + // (the exported frame buffer is a vertical 'sliding window' of the actual buffer) + uInt32 myFramePointerOffset; + // Indicates the width of the visible scanline uInt32 myFrameWidth;