2001-12-27 19:54:36 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
|
|
|
// SSSS tt ee ee ll ll aa
|
|
|
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
|
|
|
// SS SS tt ee ll ll aa aa
|
|
|
|
// SSSS ttt eeeee llll llll aaaaa
|
|
|
|
//
|
2009-01-01 18:13:40 +00:00
|
|
|
// Copyright (c) 1995-2009 by Bradford W. Mott and the Stella team
|
2001-12-27 19:54:36 +00:00
|
|
|
//
|
|
|
|
// See the file "license" for information on usage and redistribution of
|
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//
|
2009-05-13 13:55:40 +00:00
|
|
|
// $Id$
|
2001-12-27 19:54:36 +00:00
|
|
|
//============================================================================
|
|
|
|
|
2009-01-26 21:08:07 +00:00
|
|
|
#include <cassert>
|
|
|
|
#include <iostream>
|
|
|
|
|
2001-12-27 19:54:36 +00:00
|
|
|
#include "Console.hxx"
|
|
|
|
#include "Random.hxx"
|
|
|
|
#include "Switches.hxx"
|
|
|
|
#include "System.hxx"
|
2002-05-13 19:17:32 +00:00
|
|
|
#include "Serializer.hxx"
|
|
|
|
#include "Deserializer.hxx"
|
2009-01-26 21:08:07 +00:00
|
|
|
|
|
|
|
#include "M6532.hxx"
|
2001-12-27 19:54:36 +00:00
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
M6532::M6532(const Console& console)
|
2008-03-29 19:15:57 +00:00
|
|
|
: myConsole(console)
|
2001-12-27 19:54:36 +00:00
|
|
|
{
|
|
|
|
reset();
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
M6532::~M6532()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void M6532::reset()
|
|
|
|
{
|
2005-10-09 17:31:47 +00:00
|
|
|
class Random random;
|
2002-12-15 04:58:14 +00:00
|
|
|
|
2008-08-01 12:16:00 +00:00
|
|
|
// Randomize the 128 bytes of memory
|
|
|
|
for(uInt32 t = 0; t < 128; ++t)
|
|
|
|
myRAM[t] = random.next();
|
|
|
|
|
2008-05-16 23:56:31 +00:00
|
|
|
// The timer absolutely cannot be initialized to zero; some games will
|
|
|
|
// loop or hang (notably Solaris and H.E.R.O.)
|
|
|
|
myTimer = (0xff - (random.next() % 0xfe)) << 10;
|
|
|
|
myIntervalShift = 10;
|
2001-12-27 19:54:36 +00:00
|
|
|
myCyclesWhenTimerSet = 0;
|
2008-04-23 16:51:11 +00:00
|
|
|
myInterruptEnabled = false;
|
|
|
|
myInterruptTriggered = false;
|
2001-12-27 19:54:36 +00:00
|
|
|
|
|
|
|
// Zero the I/O registers
|
2008-04-23 16:51:11 +00:00
|
|
|
myDDRA = myDDRB = myOutA = 0x00;
|
Added RiotDebug class, which for now only duplicates the previous
functionality of the Debugger::riotState() method. It will become
more useful when I add a RIOT tab to the debugger. Also, added
change tracking infrastructure.
Fixed long-standing bug with viewing the contents of TIM{1, 8, 64, 1024}T
registers. Apparently, the output generated by the 'riot' debugger
command showed either INTIM or TIMINT for those registers, and not the
actual value written to those registers.
Added INTIM, TIMINT, and TIMCLKS to the riot output, which show the
current values of the timer, the timer interrupt, and the number of
'timer clocks' resulting from writing to a timer register.
Cleaned up some of the debugger API, removing pointers and using
references instead.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1479 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2008-04-19 21:11:52 +00:00
|
|
|
|
|
|
|
// Zero the timer registers
|
2008-04-23 16:51:11 +00:00
|
|
|
myOutTimer[0] = myOutTimer[1] = myOutTimer[2] = myOutTimer[3] = 0x00;
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void M6532::systemCyclesReset()
|
|
|
|
{
|
|
|
|
// System cycles are being reset to zero so we need to adjust
|
|
|
|
// the cycle count we remembered when the timer was last set
|
|
|
|
myCyclesWhenTimerSet -= mySystem->cycles();
|
2008-05-19 02:53:58 +00:00
|
|
|
|
|
|
|
// We should also inform any 'smart' controllers as well
|
|
|
|
myConsole.controller(Controller::Left).systemCyclesReset();
|
|
|
|
myConsole.controller(Controller::Right).systemCyclesReset();
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void M6532::install(System& system)
|
2008-02-19 12:33:07 +00:00
|
|
|
{
|
|
|
|
install(system, *this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void M6532::install(System& system, Device& device)
|
2001-12-27 19:54:36 +00:00
|
|
|
{
|
|
|
|
// Remember which system I'm installed in
|
|
|
|
mySystem = &system;
|
|
|
|
|
|
|
|
uInt16 shift = mySystem->pageShift();
|
|
|
|
uInt16 mask = mySystem->pageMask();
|
|
|
|
|
|
|
|
// Make sure the system we're being installed in has a page size that'll work
|
|
|
|
assert((0x1080 & mask) == 0);
|
|
|
|
|
2008-02-19 12:33:07 +00:00
|
|
|
// All accesses are to the given device
|
2001-12-27 19:54:36 +00:00
|
|
|
System::PageAccess access;
|
2008-02-19 12:33:07 +00:00
|
|
|
access.device = &device;
|
2001-12-27 19:54:36 +00:00
|
|
|
|
|
|
|
// We're installing in a 2600 system
|
|
|
|
for(int address = 0; address < 8192; address += (1 << shift))
|
|
|
|
{
|
|
|
|
if((address & 0x1080) == 0x0080)
|
|
|
|
{
|
2008-02-19 12:33:07 +00:00
|
|
|
access.directPeekBase = 0;
|
|
|
|
access.directPokeBase = 0;
|
|
|
|
mySystem->setPageAccess(address >> shift, access);
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
uInt8 M6532::peek(uInt16 addr)
|
|
|
|
{
|
2008-02-19 12:33:07 +00:00
|
|
|
// Access RAM directly. Originally, accesses to RAM could bypass
|
|
|
|
// this method and its pages could be installed directly into the
|
|
|
|
// system. However, certain cartridges (notably 4A50) can mirror
|
|
|
|
// the RAM address space, making it necessary to chain accesses.
|
|
|
|
if((addr & 0x1080) == 0x0080 && (addr & 0x0200) == 0x0000)
|
|
|
|
{
|
|
|
|
return myRAM[addr & 0x007f];
|
|
|
|
}
|
|
|
|
|
2001-12-27 19:54:36 +00:00
|
|
|
switch(addr & 0x07)
|
|
|
|
{
|
|
|
|
case 0x00: // Port A I/O Register (Joystick)
|
|
|
|
{
|
|
|
|
uInt8 value = 0x00;
|
|
|
|
|
2008-04-20 19:52:33 +00:00
|
|
|
Controller& port0 = myConsole.controller(Controller::Left);
|
|
|
|
if(port0.read(Controller::One)) value |= 0x10;
|
|
|
|
if(port0.read(Controller::Two)) value |= 0x20;
|
|
|
|
if(port0.read(Controller::Three)) value |= 0x40;
|
|
|
|
if(port0.read(Controller::Four)) value |= 0x80;
|
|
|
|
|
|
|
|
Controller& port1 = myConsole.controller(Controller::Right);
|
|
|
|
if(port1.read(Controller::One)) value |= 0x01;
|
|
|
|
if(port1.read(Controller::Two)) value |= 0x02;
|
|
|
|
if(port1.read(Controller::Three)) value |= 0x04;
|
|
|
|
if(port1.read(Controller::Four)) value |= 0x08;
|
2001-12-27 19:54:36 +00:00
|
|
|
|
2008-05-06 16:39:12 +00:00
|
|
|
// Each pin is high (1) by default and will only go low (0) if either
|
|
|
|
// (a) External device drives the pin low
|
|
|
|
// (b) Corresponding bit in SWACNT = 1 and SWCHA = 0
|
|
|
|
// Thanks to A. Herbert for this info
|
|
|
|
return (myOutA | ~myDDRA) & value;
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case 0x01: // Port A Data Direction Register
|
|
|
|
{
|
|
|
|
return myDDRA;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 0x02: // Port B I/O Register (Console switches)
|
|
|
|
{
|
|
|
|
return myConsole.switches().read();
|
|
|
|
}
|
|
|
|
|
|
|
|
case 0x03: // Port B Data Direction Register
|
|
|
|
{
|
|
|
|
return myDDRB;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 0x04: // Timer Output
|
|
|
|
case 0x06:
|
|
|
|
{
|
2008-04-23 16:51:11 +00:00
|
|
|
myInterruptTriggered = false;
|
|
|
|
Int32 timer = timerClocks();
|
2001-12-27 19:54:36 +00:00
|
|
|
|
2008-05-22 17:54:54 +00:00
|
|
|
// 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))
|
2001-12-27 19:54:36 +00:00
|
|
|
{
|
2008-05-22 17:54:54 +00:00
|
|
|
return (timer >> myIntervalShift) & 0xff;
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-23 16:51:11 +00:00
|
|
|
if(timer != -1)
|
|
|
|
myInterruptTriggered = true;
|
|
|
|
|
2008-04-28 20:59:39 +00:00
|
|
|
// According to the M6532 documentation, the timer continues to count
|
2008-04-28 21:31:40 +00:00
|
|
|
// down to -255 timer clocks after wraparound. However, it isn't
|
2008-05-16 23:56:31 +00:00
|
|
|
// entirely clear what happens *after* if reaches -255.
|
2008-05-22 17:54:54 +00:00
|
|
|
// For now, we'll let it continuously wrap around.
|
|
|
|
return timer & 0xff;
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case 0x05: // Interrupt Flag
|
|
|
|
case 0x07:
|
|
|
|
{
|
2008-11-02 16:46:05 +00:00
|
|
|
if((timerClocks() >= 0) || (myInterruptEnabled && myInterruptTriggered))
|
2001-12-27 19:54:36 +00:00
|
|
|
return 0x00;
|
|
|
|
else
|
|
|
|
return 0x80;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_ACCESSES
|
|
|
|
cerr << "BAD M6532 Peek: " << hex << addr << endl;
|
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void M6532::poke(uInt16 addr, uInt8 value)
|
|
|
|
{
|
2008-02-19 12:33:07 +00:00
|
|
|
// Access RAM directly. Originally, accesses to RAM could bypass
|
|
|
|
// this method and its pages could be installed directly into the
|
|
|
|
// system. However, certain cartridges (notably 4A50) can mirror
|
|
|
|
// the RAM address space, making it necessary to chain accesses.
|
|
|
|
if((addr & 0x1080) == 0x0080 && (addr & 0x0200) == 0x0000)
|
|
|
|
{
|
|
|
|
myRAM[addr & 0x007f] = value;
|
2008-04-23 16:51:11 +00:00
|
|
|
return;
|
2008-02-19 12:33:07 +00:00
|
|
|
}
|
2008-04-23 16:51:11 +00:00
|
|
|
|
2008-04-28 21:31:40 +00:00
|
|
|
// A2 distinguishes I/O registers from the timer
|
2008-04-23 16:51:11 +00:00
|
|
|
if((addr & 0x04) != 0)
|
2001-12-27 19:54:36 +00:00
|
|
|
{
|
2008-04-23 16:51:11 +00:00
|
|
|
if((addr & 0x10) != 0)
|
|
|
|
{
|
|
|
|
myInterruptEnabled = (addr & 0x08);
|
|
|
|
setTimerRegister(value, addr & 0x03);
|
|
|
|
}
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-04-23 16:51:11 +00:00
|
|
|
switch(addr & 0x03)
|
|
|
|
{
|
|
|
|
case 0: // Port A I/O Register (Joystick)
|
|
|
|
{
|
|
|
|
myOutA = value;
|
2008-05-16 23:56:31 +00:00
|
|
|
setPinState();
|
2008-04-23 16:51:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 1: // Port A Data Direction Register
|
|
|
|
{
|
|
|
|
myDDRA = value;
|
2008-05-16 23:56:31 +00:00
|
|
|
setPinState();
|
2008-04-23 16:51:11 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default: // Port B I/O & DDR Registers (Console switches)
|
|
|
|
break; // hardwired as read-only
|
2008-05-06 16:39:12 +00:00
|
|
|
}
|
2001-12-27 19:54:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-23 16:51:11 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void M6532::setTimerRegister(uInt8 value, uInt8 interval)
|
|
|
|
{
|
|
|
|
static const uInt8 shift[] = { 0, 3, 6, 10 };
|
|
|
|
|
|
|
|
myInterruptTriggered = false;
|
|
|
|
myIntervalShift = shift[interval];
|
|
|
|
myOutTimer[interval] = value;
|
|
|
|
myTimer = value << myIntervalShift;
|
|
|
|
myCyclesWhenTimerSet = mySystem->cycles();
|
|
|
|
}
|
|
|
|
|
2008-05-06 16:39:12 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2008-05-16 23:56:31 +00:00
|
|
|
void M6532::setPinState()
|
2008-05-06 16:39:12 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
When a bit in the DDR is set as input, +5V is placed on its output
|
|
|
|
pin. When it's set as output, either +5V or 0V (depending on the
|
|
|
|
contents of SWCHA) will be placed on the output pin.
|
2008-05-16 23:56:31 +00:00
|
|
|
The standard macros for the AtariVox and SaveKey use this fact to
|
|
|
|
send data to the port. This is represented by the following algorithm:
|
2008-05-06 16:39:12 +00:00
|
|
|
|
|
|
|
if(DDR bit is input) set output as 1
|
|
|
|
else if(DDR bit is output) set output as bit in ORA
|
|
|
|
*/
|
|
|
|
uInt8 a = myOutA | ~myDDRA;
|
|
|
|
|
|
|
|
Controller& port0 = myConsole.controller(Controller::Left);
|
|
|
|
port0.write(Controller::One, a & 0x10);
|
|
|
|
port0.write(Controller::Two, a & 0x20);
|
|
|
|
port0.write(Controller::Three, a & 0x40);
|
|
|
|
port0.write(Controller::Four, a & 0x80);
|
|
|
|
|
|
|
|
Controller& port1 = myConsole.controller(Controller::Right);
|
|
|
|
port1.write(Controller::One, a & 0x01);
|
|
|
|
port1.write(Controller::Two, a & 0x02);
|
|
|
|
port1.write(Controller::Three, a & 0x04);
|
|
|
|
port1.write(Controller::Four, a & 0x08);
|
|
|
|
}
|
|
|
|
|
2002-05-13 19:17:32 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
bool M6532::save(Serializer& out) const
|
2002-05-13 19:17:32 +00:00
|
|
|
{
|
|
|
|
string device = name();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
out.putString(device);
|
|
|
|
|
|
|
|
// Output the RAM
|
2005-12-17 01:23:07 +00:00
|
|
|
out.putInt(128);
|
2002-05-13 19:17:32 +00:00
|
|
|
for(uInt32 t = 0; t < 128; ++t)
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
out.putByte((char)myRAM[t]);
|
2002-05-13 19:17:32 +00:00
|
|
|
|
2005-12-17 01:23:07 +00:00
|
|
|
out.putInt(myTimer);
|
|
|
|
out.putInt(myIntervalShift);
|
|
|
|
out.putInt(myCyclesWhenTimerSet);
|
2008-04-23 16:51:11 +00:00
|
|
|
out.putBool(myInterruptEnabled);
|
|
|
|
out.putBool(myInterruptTriggered);
|
|
|
|
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
out.putByte((char)myDDRA);
|
|
|
|
out.putByte((char)myDDRB);
|
2008-04-23 16:51:11 +00:00
|
|
|
out.putByte((char)myOutA);
|
Added RiotDebug class, which for now only duplicates the previous
functionality of the Debugger::riotState() method. It will become
more useful when I add a RIOT tab to the debugger. Also, added
change tracking infrastructure.
Fixed long-standing bug with viewing the contents of TIM{1, 8, 64, 1024}T
registers. Apparently, the output generated by the 'riot' debugger
command showed either INTIM or TIMINT for those registers, and not the
actual value written to those registers.
Added INTIM, TIMINT, and TIMCLKS to the riot output, which show the
current values of the timer, the timer interrupt, and the number of
'timer clocks' resulting from writing to a timer register.
Cleaned up some of the debugger API, removing pointers and using
references instead.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1479 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2008-04-19 21:11:52 +00:00
|
|
|
out.putByte((char)myOutTimer[0]);
|
|
|
|
out.putByte((char)myOutTimer[1]);
|
|
|
|
out.putByte((char)myOutTimer[2]);
|
|
|
|
out.putByte((char)myOutTimer[3]);
|
2002-05-13 19:17:32 +00:00
|
|
|
}
|
|
|
|
catch(char *msg)
|
|
|
|
{
|
|
|
|
cerr << msg << endl;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
cerr << "Unknown error in save state for " << device << endl;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
bool M6532::load(Deserializer& in)
|
|
|
|
{
|
|
|
|
string device = name();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if(in.getString() != device)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// Input the RAM
|
2005-12-17 01:23:07 +00:00
|
|
|
uInt32 limit = (uInt32) in.getInt();
|
2002-05-13 19:17:32 +00:00
|
|
|
for(uInt32 t = 0; t < limit; ++t)
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
myRAM[t] = (uInt8) in.getByte();
|
2002-05-13 19:17:32 +00:00
|
|
|
|
2005-12-17 01:23:07 +00:00
|
|
|
myTimer = (uInt32) in.getInt();
|
|
|
|
myIntervalShift = (uInt32) in.getInt();
|
|
|
|
myCyclesWhenTimerSet = (uInt32) in.getInt();
|
2008-04-23 16:51:11 +00:00
|
|
|
myInterruptEnabled = in.getBool();
|
|
|
|
myInterruptTriggered = in.getBool();
|
2002-05-13 19:17:32 +00:00
|
|
|
|
OK, another huge commit. I need to commit this now, because things are
starting to go out of sync on my development machines. OK, where to
begin ...
Changed state file format, so older state files will no longer work. The
changes aren't finalized yet, so expect more breakage.
Added getByte() and putByte() methods to serialized data, resulting in
smaller state files (previously, 1-byte values were stored as 4-byte ints).
Totally reworked controller handling code. Controller state is now
explicitly set with an ::update() method, making it easier to serialize.
Some work is still required on the serialization stuff for more advanced
controllers.
Added a 'Serializable' interface to all carts, device, controllers, etc
that can be (de)serialized. This fixes a long-standing design issue
which I personally caused many years ago.
Console switches state (SWCHB register) is now saved to state files.
Added beginnings of movie support. Basically, this saves an initial
state file, and thereafter continuously saves controller and console
switches state. Support is still somewhat rough and there's no UI for
it, but it does successfully save and later load/play state movies.
Removed specific events for driving controllers, and have them use
joystick events instead. This has the nice side effect that
joystick direction remapping 'just works' for driving controllers too.
Fixed issues with paddle emulation seen in 'Night Driver' ROM. Related
to this, removed a hack wrt paddles when grabmouse is enabled. There's
still some work to do when using the mouse to emulate paddles, but the
Stelladaptor and real paddles work fine.
Added beginnings of TrackBall CX-22 controller emulation. It doesn't
actually do anything yet, but the class is there :)
Probably some other stuff that I'm forgetting ...
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1385 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2007-10-03 21:41:19 +00:00
|
|
|
myDDRA = (uInt8) in.getByte();
|
|
|
|
myDDRB = (uInt8) in.getByte();
|
2008-04-23 16:51:11 +00:00
|
|
|
myOutA = (uInt8) in.getByte();
|
Added RiotDebug class, which for now only duplicates the previous
functionality of the Debugger::riotState() method. It will become
more useful when I add a RIOT tab to the debugger. Also, added
change tracking infrastructure.
Fixed long-standing bug with viewing the contents of TIM{1, 8, 64, 1024}T
registers. Apparently, the output generated by the 'riot' debugger
command showed either INTIM or TIMINT for those registers, and not the
actual value written to those registers.
Added INTIM, TIMINT, and TIMCLKS to the riot output, which show the
current values of the timer, the timer interrupt, and the number of
'timer clocks' resulting from writing to a timer register.
Cleaned up some of the debugger API, removing pointers and using
references instead.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1479 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2008-04-19 21:11:52 +00:00
|
|
|
myOutTimer[0] = (uInt8) in.getByte();
|
|
|
|
myOutTimer[1] = (uInt8) in.getByte();
|
|
|
|
myOutTimer[2] = (uInt8) in.getByte();
|
|
|
|
myOutTimer[3] = (uInt8) in.getByte();
|
2002-05-13 19:17:32 +00:00
|
|
|
}
|
|
|
|
catch(char *msg)
|
|
|
|
{
|
|
|
|
cerr << msg << endl;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
catch(...)
|
|
|
|
{
|
|
|
|
cerr << "Unknown error in load state for " << device << endl;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2001-12-27 19:54:36 +00:00
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
M6532::M6532(const M6532& c)
|
2008-03-29 19:15:57 +00:00
|
|
|
: myConsole(c.myConsole)
|
2001-12-27 19:54:36 +00:00
|
|
|
{
|
|
|
|
assert(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
M6532& M6532::operator = (const M6532&)
|
|
|
|
{
|
|
|
|
assert(false);
|
|
|
|
return *this;
|
|
|
|
}
|