mirror of https://github.com/stella-emu/stella.git
Cleaned up accessing the TIA from System class. Brian, I'm not sure
if this is needed for anything other than 3E type, but since it doesn't cause any overhead, I went ahead and did it anyway (after reading your messages on Stella list). Please test to make sure it still works, but I don't think there'll be any problems. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@628 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
9f354edb8a
commit
3fabe0ece8
|
@ -13,13 +13,14 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: Cart3E.cxx,v 1.4 2005-07-09 00:59:12 urchlay Exp $
|
||||
// $Id: Cart3E.cxx,v 1.5 2005-07-09 12:52:46 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <assert.h>
|
||||
#include "Cart3E.hxx"
|
||||
#include "Random.hxx"
|
||||
#include "System.hxx"
|
||||
#include "TIA.hxx"
|
||||
#include "Serializer.hxx"
|
||||
#include "Deserializer.hxx"
|
||||
#include <iostream>
|
||||
|
@ -133,12 +134,11 @@ void Cartridge3E::poke(uInt16 address, uInt8 value)
|
|||
bank(value + 256);
|
||||
}
|
||||
|
||||
// Dirty hack alert!
|
||||
// Pass the poke through to the TIA. In a real Atari, both the cart and the
|
||||
// TIA see the address lines, and both react accordingly. In Stella, each
|
||||
// 64-byte chunk of address space is "owned" by only one device. If we
|
||||
// don't chain the poke to the TIA, then the TIA can't see it...
|
||||
mySystem->tiaPoke(address, value);
|
||||
mySystem->tia().poke(address, value);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -13,12 +13,13 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: Cart3F.cxx,v 1.8 2005-07-09 00:59:12 urchlay Exp $
|
||||
// $Id: Cart3F.cxx,v 1.9 2005-07-09 12:52:46 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <assert.h>
|
||||
#include "Cart3F.hxx"
|
||||
#include "System.hxx"
|
||||
#include "TIA.hxx"
|
||||
#include "Serializer.hxx"
|
||||
#include "Deserializer.hxx"
|
||||
#include <iostream>
|
||||
|
@ -118,9 +119,7 @@ void Cartridge3F::poke(uInt16 address, uInt8 value)
|
|||
bank(value);
|
||||
}
|
||||
|
||||
// pass pokes through to the TIA. This uses a DIRTY HACK which will
|
||||
// (probably) go away in the future. See System.cxx for details.
|
||||
mySystem->tiaPoke(address, value);
|
||||
mySystem->tia().poke(address, value);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -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: System.cxx,v 1.11 2005-07-09 00:59:13 urchlay Exp $
|
||||
// $Id: System.cxx,v 1.12 2005-07-09 12:52:46 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <assert.h>
|
||||
|
@ -21,7 +21,7 @@
|
|||
|
||||
#include "Device.hxx"
|
||||
#include "M6502.hxx"
|
||||
#include "TIA.hxx" // FIXME: this is a hack
|
||||
#include "TIA.hxx"
|
||||
#include "System.hxx"
|
||||
#include "Serializer.hxx"
|
||||
#include "Deserializer.hxx"
|
||||
|
@ -34,6 +34,7 @@ System::System(uInt16 n, uInt16 m)
|
|||
myNumberOfPages(1 << (n - m)),
|
||||
myNumberOfDevices(0),
|
||||
myM6502(0),
|
||||
myTIA(0),
|
||||
myCycles(0),
|
||||
myDataBusState(0)
|
||||
{
|
||||
|
@ -121,6 +122,13 @@ void System::attach(M6502* m6502)
|
|||
myM6502->install(*this);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void System::attach(TIA* tia)
|
||||
{
|
||||
myTIA = tia;
|
||||
attach((Device*) tia);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool System::save(Serializer& out)
|
||||
{
|
||||
|
@ -350,23 +358,3 @@ void System::poke(uInt16 addr, uInt8 value)
|
|||
|
||||
myDataBusState = value;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// FIXME: dirty hack! This only exists for Cart3E and Cart3F to use, and
|
||||
// then only until I come up a cleaner way to implement it. Call this method
|
||||
// at your own peril!
|
||||
|
||||
// Note that in some compilers (VC++?) you need to enable RTTI to make the
|
||||
// dynamic_cast work. In g++, RTTI seems to be on by default. Do not
|
||||
// compile Stella with -fno-rtti!
|
||||
|
||||
// Sorry about the mess. -- B.
|
||||
void System::tiaPoke(uInt16 addr, uInt8 value)
|
||||
{
|
||||
TIA *t;
|
||||
for(uInt32 i = 0; i < myNumberOfDevices; ++i)
|
||||
{
|
||||
if( (t = dynamic_cast<TIA*>(myDevices[i])) )
|
||||
t->poke(addr, value);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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: System.hxx,v 1.8 2005-07-09 00:59:13 urchlay Exp $
|
||||
// $Id: System.hxx,v 1.9 2005-07-09 12:52:46 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef SYSTEM_HXX
|
||||
|
@ -21,6 +21,7 @@
|
|||
|
||||
class Device;
|
||||
class M6502;
|
||||
class TIA;
|
||||
class NullDevice;
|
||||
class Serializer;
|
||||
class Deserializer;
|
||||
|
@ -47,7 +48,7 @@ class Deserializer;
|
|||
dynamic code for that page of memory.
|
||||
|
||||
@author Bradford W. Mott
|
||||
@version $Id: System.hxx,v 1.8 2005-07-09 00:59:13 urchlay Exp $
|
||||
@version $Id: System.hxx,v 1.9 2005-07-09 12:52:46 stephena Exp $
|
||||
*/
|
||||
class System
|
||||
{
|
||||
|
@ -106,6 +107,14 @@ class System
|
|||
*/
|
||||
void attach(M6502* m6502);
|
||||
|
||||
/**
|
||||
Attach the specified TIA device and claim ownership of it. The device
|
||||
will be asked to install itself.
|
||||
|
||||
@param tia The TIA device to attach to the system
|
||||
*/
|
||||
void attach(TIA* tia);
|
||||
|
||||
/**
|
||||
Saves the current state of Stella to the given file. Calls
|
||||
save on every device and CPU attached to this system.
|
||||
|
@ -142,6 +151,16 @@ class System
|
|||
return *myM6502;
|
||||
}
|
||||
|
||||
/**
|
||||
Answer the TIA device attached to the system.
|
||||
|
||||
@return The attached TIA device
|
||||
*/
|
||||
TIA& tia()
|
||||
{
|
||||
return *myTIA;
|
||||
}
|
||||
|
||||
/**
|
||||
Get the null device associated with the system. Every system
|
||||
has a null device associated with it that's used by pages which
|
||||
|
@ -242,18 +261,6 @@ class System
|
|||
*/
|
||||
void poke(uInt16 address, uInt8 value);
|
||||
|
||||
/**
|
||||
Force a poke to the TIA, bypassing the normal device selection.
|
||||
This is used by the 3E and 3F bankswitch schemes, which attach
|
||||
themselves to the address space at $00-$3F and need a way to
|
||||
pass a poke there through to the TIA.
|
||||
|
||||
I don't know what the correct way to do this is, but I'm pretty
|
||||
certain this ain't it. As soon as I do know, this method goes away.
|
||||
-- B.
|
||||
*/
|
||||
void System::tiaPoke(uInt16 addr, uInt8 value);
|
||||
|
||||
public:
|
||||
/**
|
||||
Structure used to specify access methods for a page
|
||||
|
@ -324,6 +331,9 @@ class System
|
|||
// 6502 processor attached to the system or the null pointer
|
||||
M6502* myM6502;
|
||||
|
||||
// TIA device attached to the system or the null pointer
|
||||
TIA* myTIA;
|
||||
|
||||
// Number of system cycles executed since the last reset
|
||||
uInt32 myCycles;
|
||||
|
||||
|
|
Loading…
Reference in New Issue