Yet another tweak to the RIOT emulation. This one concerns the timer

behaviour after wraparound, which isn't sufficiently defined in any of
the documentation I've read.  The new code works with all the ROMs I've
tested, but I still have the feeling it's a bit of a hack.  More
research is definitely required.


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1487 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2008-04-28 20:59:39 +00:00
parent 2f34d50c39
commit f91bf67995
1 changed files with 13 additions and 2 deletions

View File

@ -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.21 2008-04-23 16:51:11 stephena Exp $
// $Id: M6532.cxx,v 1.22 2008-04-28 20:59:39 stephena Exp $
//============================================================================
#include <assert.h>
@ -172,7 +172,18 @@ uInt8 M6532::peek(uInt16 addr)
if(timer != -1)
myInterruptTriggered = true;
return (uInt8)(timer >= -256 ? timer : 0);
// According to the M6532 documentation, the timer continues to count
// down to -256 timer clocks after wraparound. However, it isn't
// entirely clear what happens *after* if reaches -256. If we go
// to zero at that time, Solaris fails to load correctly.
// However, if the count goes on forever, HERO fails to load
// correctly.
// So we use the approach of z26, and let the counter continue
// downward (after wraparound) for the maximum number of clocks
// (256 * 1024) = 0x40000. I suspect this is a hack that works
// for all the ROMs we've tested; it would be nice to determine
// what really happens in hardware.
return (uInt8)(timer >= -0x40000 ? timer : 0);
}
}