mirror of https://github.com/stella-emu/stella.git
More refactoring: remove dependency of System on OSystem.
This commit is contained in:
parent
b93c95e041
commit
05260ca006
|
@ -17,13 +17,14 @@
|
||||||
|
|
||||||
#include "SerialPort.hxx"
|
#include "SerialPort.hxx"
|
||||||
#include "System.hxx"
|
#include "System.hxx"
|
||||||
|
#include "OSystem.hxx"
|
||||||
#include "AtariVox.hxx"
|
#include "AtariVox.hxx"
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
AtariVox::AtariVox(Jack jack, const Event& event, const System& system,
|
AtariVox::AtariVox(Jack jack, const Event& event, const System& system, const OSystem& osystem,
|
||||||
const SerialPort& port, const string& portname,
|
const SerialPort& port, const string& portname,
|
||||||
const string& eepromfile)
|
const string& eepromfile)
|
||||||
: SaveKey(jack, event, system, eepromfile, Controller::AtariVox),
|
: SaveKey(jack, event, system, osystem, eepromfile, Controller::AtariVox),
|
||||||
mySerialPort(const_cast<SerialPort&>(port)),
|
mySerialPort(const_cast<SerialPort&>(port)),
|
||||||
myShiftCount(0),
|
myShiftCount(0),
|
||||||
myShiftRegister(0),
|
myShiftRegister(0),
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#define ATARIVOX_HXX
|
#define ATARIVOX_HXX
|
||||||
|
|
||||||
class SerialPort;
|
class SerialPort;
|
||||||
|
class OSystem;
|
||||||
|
|
||||||
#include "Control.hxx"
|
#include "Control.hxx"
|
||||||
#include "SaveKey.hxx"
|
#include "SaveKey.hxx"
|
||||||
|
@ -41,11 +42,12 @@ class AtariVox : public SaveKey
|
||||||
@param jack The jack the controller is plugged into
|
@param jack The jack the controller is plugged into
|
||||||
@param event The event object to use for events
|
@param event The event object to use for events
|
||||||
@param system The system using this controller
|
@param system The system using this controller
|
||||||
|
@param osystem The OSystem abstraction
|
||||||
@param port The serial port object
|
@param port The serial port object
|
||||||
@param portname Name of the port used for reading and writing
|
@param portname Name of the port used for reading and writing
|
||||||
@param eepromfile The file containing the EEPROM data
|
@param eepromfile The file containing the EEPROM data
|
||||||
*/
|
*/
|
||||||
AtariVox(Jack jack, const Event& event, const System& system,
|
AtariVox(Jack jack, const Event& event, const System& system, const OSystem& osystem,
|
||||||
const SerialPort& port, const string& portname,
|
const SerialPort& port, const string& portname,
|
||||||
const string& eepromfile);
|
const string& eepromfile);
|
||||||
virtual ~AtariVox() = default;
|
virtual ~AtariVox() = default;
|
||||||
|
|
|
@ -105,8 +105,11 @@ Console::Console(OSystem& osystem, unique_ptr<Cartridge>& cart,
|
||||||
|
|
||||||
myTIA->setFrameManager(myFrameManager.get());
|
myTIA->setFrameManager(myFrameManager.get());
|
||||||
|
|
||||||
|
// Reinitialize the RNG
|
||||||
|
myOSystem.random().initSeed(static_cast<uInt32>(myOSystem.getTicks()));
|
||||||
|
|
||||||
// Construct the system and components
|
// Construct the system and components
|
||||||
mySystem = make_unique<System>(osystem, *my6502, *myRiot, *myTIA, *myCart);
|
mySystem = make_unique<System>(myOSystem.random(), *my6502, *myRiot, *myTIA, *myCart);
|
||||||
|
|
||||||
// The real controllers for this console will be added later
|
// The real controllers for this console will be added later
|
||||||
// For now, we just add dummy joystick controllers, since autodetection
|
// For now, we just add dummy joystick controllers, since autodetection
|
||||||
|
@ -933,13 +936,13 @@ unique_ptr<Controller> Console::getControllerPort(const string& rommd5,
|
||||||
{
|
{
|
||||||
const string& nvramfile = myOSystem.nvramDir() + "atarivox_eeprom.dat";
|
const string& nvramfile = myOSystem.nvramDir() + "atarivox_eeprom.dat";
|
||||||
controller = make_unique<AtariVox>(port, myEvent,
|
controller = make_unique<AtariVox>(port, myEvent,
|
||||||
*mySystem, myOSystem.serialPort(),
|
*mySystem, myOSystem, myOSystem.serialPort(),
|
||||||
myOSystem.settings().getString("avoxport"), nvramfile);
|
myOSystem.settings().getString("avoxport"), nvramfile);
|
||||||
}
|
}
|
||||||
else if(controllerName == "SAVEKEY")
|
else if(controllerName == "SAVEKEY")
|
||||||
{
|
{
|
||||||
const string& nvramfile = myOSystem.nvramDir() + "savekey_eeprom.dat";
|
const string& nvramfile = myOSystem.nvramDir() + "savekey_eeprom.dat";
|
||||||
controller = make_unique<SaveKey>(port, myEvent, *mySystem,
|
controller = make_unique<SaveKey>(port, myEvent, *mySystem, myOSystem,
|
||||||
nvramfile);
|
nvramfile);
|
||||||
}
|
}
|
||||||
else if(controllerName == "GENESIS")
|
else if(controllerName == "GENESIS")
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
#include "System.hxx"
|
#include "System.hxx"
|
||||||
|
|
||||||
|
#include "OSystem.hxx"
|
||||||
|
|
||||||
#include "Settings.hxx"
|
#include "Settings.hxx"
|
||||||
|
|
||||||
#include "MT24LC256.hxx"
|
#include "MT24LC256.hxx"
|
||||||
|
@ -46,8 +48,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
MT24LC256::MT24LC256(const string& filename, const System& system)
|
MT24LC256::MT24LC256(const string& filename, const System& system, const OSystem& osystem)
|
||||||
: mySystem(system),
|
: mySystem(system),
|
||||||
|
myOSystem(osystem),
|
||||||
mySDA(false),
|
mySDA(false),
|
||||||
mySCL(false),
|
mySCL(false),
|
||||||
myTimerActive(false),
|
myTimerActive(false),
|
||||||
|
@ -252,9 +255,9 @@ void MT24LC256::jpee_data_stop()
|
||||||
{
|
{
|
||||||
myDataChanged = true;
|
myDataChanged = true;
|
||||||
myPageHit[jpee_address / PAGE_SIZE] = true;
|
myPageHit[jpee_address / PAGE_SIZE] = true;
|
||||||
bool devSettings = mySystem.oSystem().settings().getBool("dev.settings");
|
bool devSettings = myOSystem.settings().getBool("dev.settings");
|
||||||
if(mySystem.oSystem().settings().getBool(devSettings ? "dev.eepromaccess" : "plr.eepromaccess"))
|
if(myOSystem.settings().getBool(devSettings ? "dev.eepromaccess" : "plr.eepromaccess"))
|
||||||
mySystem.oSystem().frameBuffer().showMessage("AtariVox/SaveKey EEPROM write");
|
myOSystem.frameBuffer().showMessage("AtariVox/SaveKey EEPROM write");
|
||||||
myData[(jpee_address++) & jpee_sizemask] = jpee_packet[i];
|
myData[(jpee_address++) & jpee_sizemask] = jpee_packet[i];
|
||||||
if (!(jpee_address & jpee_pagemask))
|
if (!(jpee_address & jpee_pagemask))
|
||||||
break; /* Writes can't cross page boundary! */
|
break; /* Writes can't cross page boundary! */
|
||||||
|
@ -354,9 +357,9 @@ void MT24LC256::jpee_clock_fall()
|
||||||
myPageHit[jpee_address / PAGE_SIZE] = true;
|
myPageHit[jpee_address / PAGE_SIZE] = true;
|
||||||
|
|
||||||
{
|
{
|
||||||
bool devSettings = mySystem.oSystem().settings().getBool("dev.settings");
|
bool devSettings = myOSystem.settings().getBool("dev.settings");
|
||||||
if(mySystem.oSystem().settings().getBool(devSettings ? "dev.eepromaccess" : "plr.eepromaccess"))
|
if(myOSystem.settings().getBool(devSettings ? "dev.eepromaccess" : "plr.eepromaccess"))
|
||||||
mySystem.oSystem().frameBuffer().showMessage("AtariVox/SaveKey EEPROM read");
|
myOSystem.frameBuffer().showMessage("AtariVox/SaveKey EEPROM read");
|
||||||
}
|
}
|
||||||
jpee_nb = (myData[jpee_address & jpee_sizemask] << 1) | 1; /* Fall through */
|
jpee_nb = (myData[jpee_address & jpee_sizemask] << 1) | 1; /* Fall through */
|
||||||
JPEE_LOG2("I2C_READ(%04X=%02X)",jpee_address,jpee_nb/2);
|
JPEE_LOG2("I2C_READ(%04X=%02X)",jpee_address,jpee_nb/2);
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
class Controller;
|
class Controller;
|
||||||
class System;
|
class System;
|
||||||
|
class OSystem;
|
||||||
|
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
|
|
||||||
|
@ -38,8 +39,9 @@ class MT24LC256
|
||||||
|
|
||||||
@param filename Data file containing the EEPROM data
|
@param filename Data file containing the EEPROM data
|
||||||
@param system The system using the controller of this device
|
@param system The system using the controller of this device
|
||||||
|
@param osystem The OSystem abstraction
|
||||||
*/
|
*/
|
||||||
MT24LC256(const string& filename, const System& system);
|
MT24LC256(const string& filename, const System& system, const OSystem& osystem);
|
||||||
~MT24LC256();
|
~MT24LC256();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -87,6 +89,9 @@ class MT24LC256
|
||||||
// The system of the parent controller
|
// The system of the parent controller
|
||||||
const System& mySystem;
|
const System& mySystem;
|
||||||
|
|
||||||
|
// The OSystem abstraction
|
||||||
|
const OSystem& myOSystem;
|
||||||
|
|
||||||
// The EEPROM data
|
// The EEPROM data
|
||||||
uInt8 myData[FLASH_SIZE];
|
uInt8 myData[FLASH_SIZE];
|
||||||
|
|
||||||
|
|
|
@ -16,23 +16,24 @@
|
||||||
//============================================================================
|
//============================================================================
|
||||||
|
|
||||||
#include "MT24LC256.hxx"
|
#include "MT24LC256.hxx"
|
||||||
|
#include "OSystem.hxx"
|
||||||
#include "System.hxx"
|
#include "System.hxx"
|
||||||
#include "SaveKey.hxx"
|
#include "SaveKey.hxx"
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
SaveKey::SaveKey(Jack jack, const Event& event, const System& system,
|
SaveKey::SaveKey(Jack jack, const Event& event, const System& system, const OSystem& osystem,
|
||||||
const string& eepromfile, Type type)
|
const string& eepromfile, Type type)
|
||||||
: Controller(jack, event, system, type)
|
: Controller(jack, event, system, type)
|
||||||
{
|
{
|
||||||
myEEPROM = make_unique<MT24LC256>(eepromfile, system);
|
myEEPROM = make_unique<MT24LC256>(eepromfile, system, osystem);
|
||||||
|
|
||||||
myDigitalPinState[One] = myDigitalPinState[Two] = true;
|
myDigitalPinState[One] = myDigitalPinState[Two] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
SaveKey::SaveKey(Jack jack, const Event& event, const System& system,
|
SaveKey::SaveKey(Jack jack, const Event& event, const System& system, const OSystem& osystem,
|
||||||
const string& eepromfile)
|
const string& eepromfile)
|
||||||
: SaveKey(jack, event, system, eepromfile, Controller::SaveKey)
|
: SaveKey(jack, event, system, osystem, eepromfile, Controller::SaveKey)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#define SAVEKEY_HXX
|
#define SAVEKEY_HXX
|
||||||
|
|
||||||
class MT24LC256;
|
class MT24LC256;
|
||||||
|
class OSystem;
|
||||||
|
|
||||||
#include "Control.hxx"
|
#include "Control.hxx"
|
||||||
|
|
||||||
|
@ -40,9 +41,10 @@ class SaveKey : public Controller
|
||||||
@param jack The jack the controller is plugged into
|
@param jack The jack the controller is plugged into
|
||||||
@param event The event object to use for events
|
@param event The event object to use for events
|
||||||
@param system The system using this controller
|
@param system The system using this controller
|
||||||
|
@param osystem The OSystem abstraction
|
||||||
@param eepromfile The file containing the EEPROM data
|
@param eepromfile The file containing the EEPROM data
|
||||||
*/
|
*/
|
||||||
SaveKey(Jack jack, const Event& event, const System& system,
|
SaveKey(Jack jack, const Event& event, const System& system, const OSystem& osystem,
|
||||||
const string& eepromfile);
|
const string& eepromfile);
|
||||||
virtual ~SaveKey();
|
virtual ~SaveKey();
|
||||||
|
|
||||||
|
@ -51,7 +53,7 @@ class SaveKey : public Controller
|
||||||
Delegating constructor currently used by both this class and classes
|
Delegating constructor currently used by both this class and classes
|
||||||
that inherit from SaveKey (currently, AtariVox)
|
that inherit from SaveKey (currently, AtariVox)
|
||||||
*/
|
*/
|
||||||
SaveKey(Jack jack, const Event& event, const System& system,
|
SaveKey(Jack jack, const Event& event, const System& system, const OSystem& osystem,
|
||||||
const string& eepromfile, Type type);
|
const string& eepromfile, Type type);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -27,9 +27,9 @@
|
||||||
#include "System.hxx"
|
#include "System.hxx"
|
||||||
|
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
System::System(const OSystem& osystem, M6502& m6502, M6532& m6532,
|
System::System(Random& random, M6502& m6502, M6532& m6532,
|
||||||
TIA& mTIA, Cartridge& mCart)
|
TIA& mTIA, Cartridge& mCart)
|
||||||
: myOSystem(osystem),
|
: myRandom(random),
|
||||||
myM6502(m6502),
|
myM6502(m6502),
|
||||||
myM6532(m6532),
|
myM6532(m6532),
|
||||||
myTIA(mTIA),
|
myTIA(mTIA),
|
||||||
|
@ -39,9 +39,6 @@ System::System(const OSystem& osystem, M6502& m6502, M6532& m6532,
|
||||||
myDataBusLocked(false),
|
myDataBusLocked(false),
|
||||||
mySystemInAutodetect(false)
|
mySystemInAutodetect(false)
|
||||||
{
|
{
|
||||||
// Re-initialize random generator
|
|
||||||
randGenerator().initSeed(uInt32(TimerManager::getTicks()));
|
|
||||||
|
|
||||||
// Initialize page access table
|
// Initialize page access table
|
||||||
PageAccess access(&myNullDevice, System::PA_READ);
|
PageAccess access(&myNullDevice, System::PA_READ);
|
||||||
for(int page = 0; page < NUM_PAGES; ++page)
|
for(int page = 0; page < NUM_PAGES; ++page)
|
||||||
|
|
|
@ -27,7 +27,6 @@ class NullDevice;
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
#include "Device.hxx"
|
#include "Device.hxx"
|
||||||
#include "NullDev.hxx"
|
#include "NullDev.hxx"
|
||||||
#include "OSystem.hxx"
|
|
||||||
#include "Random.hxx"
|
#include "Random.hxx"
|
||||||
#include "Serializable.hxx"
|
#include "Serializable.hxx"
|
||||||
|
|
||||||
|
@ -50,7 +49,7 @@ class System : public Serializable
|
||||||
Create a new system with an addressing space of 2^13 bytes and
|
Create a new system with an addressing space of 2^13 bytes and
|
||||||
pages of 2^6 bytes.
|
pages of 2^6 bytes.
|
||||||
*/
|
*/
|
||||||
System(const OSystem& osystem, M6502& m6502, M6532& m6532,
|
System(Random& random, M6502& m6502, M6532& m6532,
|
||||||
TIA& mTIA, Cartridge& mCart);
|
TIA& mTIA, Cartridge& mCart);
|
||||||
virtual ~System() = default;
|
virtual ~System() = default;
|
||||||
|
|
||||||
|
@ -89,13 +88,6 @@ class System : public Serializable
|
||||||
void reset(bool autodetect = false);
|
void reset(bool autodetect = false);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
|
||||||
Answer the OSystem attached to the system.
|
|
||||||
|
|
||||||
@return The attached OSystem
|
|
||||||
*/
|
|
||||||
const OSystem& oSystem() const { return myOSystem; }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Answer the 6502 microprocessor attached to the system. If a
|
Answer the 6502 microprocessor attached to the system. If a
|
||||||
processor has not been attached calling this function will fail.
|
processor has not been attached calling this function will fail.
|
||||||
|
@ -131,7 +123,7 @@ class System : public Serializable
|
||||||
|
|
||||||
@return The random generator
|
@return The random generator
|
||||||
*/
|
*/
|
||||||
Random& randGenerator() const { return myOSystem.random(); }
|
Random& randGenerator() const { return myRandom; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the null device associated with the system. Every system
|
Get the null device associated with the system. Every system
|
||||||
|
@ -385,7 +377,8 @@ class System : public Serializable
|
||||||
bool load(Serializer& in) override;
|
bool load(Serializer& in) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const OSystem& myOSystem;
|
// The system RNG
|
||||||
|
Random& myRandom;
|
||||||
|
|
||||||
// 6502 processor attached to the system
|
// 6502 processor attached to the system
|
||||||
M6502& myM6502;
|
M6502& myM6502;
|
||||||
|
|
Loading…
Reference in New Issue