From 37c1f354dde7fc39f7f4b32b37555807bee4f964 Mon Sep 17 00:00:00 2001 From: stephena Date: Thu, 22 May 2008 17:54:54 +0000 Subject: [PATCH] Made TIA auto-frame detection kick in every 32 frames instead of 64. Further tweaking to the RIOT timer values. I reverted to the z26 '0x40000' number, even though I'm not entirely clear why it's being used. Without it, several PAL ROMs fail in an infinite loop of reading from INTIM and checking for zero. I really hope that's the last of the RIOT stuff, since I've been looking at it for the past two months (the AVox and SaveKey issues started there as well). git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1531 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/emucore/M6532.cxx | 15 ++++++++++----- stella/src/emucore/TIA.cxx | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/stella/src/emucore/M6532.cxx b/stella/src/emucore/M6532.cxx index 481924869..db6c75434 100644 --- a/stella/src/emucore/M6532.cxx +++ b/stella/src/emucore/M6532.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: M6532.cxx,v 1.26 2008-05-19 02:53:57 stephena Exp $ +// $Id: M6532.cxx,v 1.27 2008-05-22 17:54:54 stephena Exp $ //============================================================================ #include @@ -171,9 +171,14 @@ uInt8 M6532::peek(uInt16 addr) myInterruptTriggered = false; Int32 timer = timerClocks(); - if(timer >= 0) + // See if the timer has expired yet? + // Note that this constant comes from z26, and corresponds to + // 256 intervals of T1024T (ie, the maximum that the timer should hold) + // I'm not sure why this is required, but quite a few PAL ROMs fail + // if we just check >= 0. + if(!(timer & 0x40000)) { - return (uInt8)(timer >> myIntervalShift); + return (timer >> myIntervalShift) & 0xff; } else { @@ -183,8 +188,8 @@ uInt8 M6532::peek(uInt16 addr) // According to the M6532 documentation, the timer continues to count // down to -255 timer clocks after wraparound. However, it isn't // entirely clear what happens *after* if reaches -255. - // For now, we'll set it to 0. - return (uInt8)(timer >= -255 ? timer : 0); + // For now, we'll let it continuously wrap around. + return timer & 0xff; } } diff --git a/stella/src/emucore/TIA.cxx b/stella/src/emucore/TIA.cxx index 79cb2ee39..030af5b3f 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.93 2008-05-21 14:01:30 stephena Exp $ +// $Id: TIA.cxx,v 1.94 2008-05-22 17:54:54 stephena Exp $ //============================================================================ //#define DEBUG_HMOVE @@ -597,7 +597,7 @@ inline void TIA::endFrame() myFrameCounter++; // Recalculate framerate. attempting to auto-correct for scanline 'jumps' - if(myFrameCounter % 64 == 0 && myAutoFrameEnabled) + if(myFrameCounter % 32 == 0 && myAutoFrameEnabled) { float framerate = (myScanlineCountForLastFrame > 285 ? 15600.0 : 15720.0) /