mirror of https://github.com/stella-emu/stella.git
Refactoring: remove dependency of TIA and M6532 on Console.
This commit is contained in:
parent
806045cb1c
commit
85acaef8cd
|
@ -49,8 +49,8 @@ const DebuggerState& TIADebug::getState()
|
|||
myState.coluRegs.push_back(coluBK());
|
||||
|
||||
// Debug Colors
|
||||
int timing = myTIA.consoleTiming() == ConsoleTiming::ntsc ? 0
|
||||
: myTIA.consoleTiming() == ConsoleTiming::pal ? 1 : 2;
|
||||
int timing = myConsole.timing() == ConsoleTiming::ntsc ? 0
|
||||
: myConsole.timing() == ConsoleTiming::pal ? 1 : 2;
|
||||
|
||||
myState.fixedCols.clear();
|
||||
myState.fixedCols.push_back(myTIA.myFixedColorPalette[timing][TIA::P0]);
|
||||
|
@ -1003,8 +1003,8 @@ string TIADebug::debugColors() const
|
|||
{
|
||||
ostringstream buf;
|
||||
|
||||
int timing = myTIA.consoleTiming() == ConsoleTiming::ntsc ? 0
|
||||
: myTIA.consoleTiming() == ConsoleTiming::pal ? 1 : 2;
|
||||
int timing = myConsole.timing() == ConsoleTiming::ntsc ? 0
|
||||
: myConsole.timing() == ConsoleTiming::pal ? 1 : 2;
|
||||
|
||||
buf << " " << myTIA.myFixedColorNames[TIA::P0] << " " << colorSwatch(myTIA.myFixedColorPalette[timing][TIA::P0])
|
||||
<< " Player 0\n"
|
||||
|
|
|
@ -99,7 +99,7 @@ Console::Console(OSystem& osystem, unique_ptr<Cartridge>& cart,
|
|||
// Create subsystems for the console
|
||||
my6502 = make_unique<M6502>(myOSystem.settings());
|
||||
myRiot = make_unique<M6532>(*this, myOSystem.settings());
|
||||
myTIA = make_unique<TIA>(*this, myOSystem.settings());
|
||||
myTIA = make_unique<TIA>(*this, [this]() { return timing(); }, myOSystem.settings());
|
||||
myFrameManager = make_unique<FrameManager>();
|
||||
mySwitches = make_unique<Switches>(myEvent, myProperties, myOSystem.settings());
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ class AudioQueue;
|
|||
class AudioSettings;
|
||||
|
||||
#include "bspf.hxx"
|
||||
#include "ConsoleIO.hxx"
|
||||
#include "Control.hxx"
|
||||
#include "Props.hxx"
|
||||
#include "TIAConstants.hxx"
|
||||
|
@ -60,7 +61,7 @@ struct ConsoleInfo
|
|||
|
||||
@author Bradford W. Mott
|
||||
*/
|
||||
class Console : public Serializable
|
||||
class Console : public Serializable, public ConsoleIO
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
@ -85,11 +86,8 @@ class Console : public Serializable
|
|||
|
||||
@return The specified controller
|
||||
*/
|
||||
Controller& leftController() const { return *myLeftControl; }
|
||||
Controller& rightController() const { return *myRightControl; }
|
||||
Controller& controller(Controller::Jack jack) const {
|
||||
return jack == Controller::Left ? leftController() : rightController();
|
||||
}
|
||||
Controller& leftController() const override { return *myLeftControl; }
|
||||
Controller& rightController() const override { return *myRightControl; }
|
||||
|
||||
/**
|
||||
Get the TIA for this console
|
||||
|
@ -110,7 +108,7 @@ class Console : public Serializable
|
|||
|
||||
@return The console switches
|
||||
*/
|
||||
Switches& switches() const { return *mySwitches; }
|
||||
Switches& switches() const override { return *mySwitches; }
|
||||
|
||||
/**
|
||||
Get the 6502 based system used by the console to emulate the game
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
//============================================================================
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// Copyright (c) 1995-2019 by Bradford W. Mott, Stephen Anthony
|
||||
// and the Stella Team
|
||||
//
|
||||
// See the file "License.txt" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//============================================================================
|
||||
|
||||
#include "Control.hxx"
|
||||
#include "Switches.hxx"
|
||||
|
||||
#ifndef CONSOLE_IO_HXX
|
||||
#define CONSOLE_IO_HXX
|
||||
|
||||
class ConsoleIO {
|
||||
public:
|
||||
|
||||
/**
|
||||
Get the controller plugged into the specified jack
|
||||
|
||||
@return The specified controller
|
||||
*/
|
||||
virtual Controller& leftController() const = 0;
|
||||
|
||||
virtual Controller& rightController() const = 0;
|
||||
|
||||
Controller& controller(Controller::Jack jack) const {
|
||||
return jack == Controller::Left ? leftController() : rightController();
|
||||
}
|
||||
|
||||
/**
|
||||
Get the console switches
|
||||
|
||||
@return The console switches
|
||||
*/
|
||||
virtual Switches& switches() const = 0;
|
||||
|
||||
virtual ~ConsoleIO() = default;
|
||||
|
||||
};
|
||||
|
||||
#endif // CONSOLE_IO_HXX
|
|
@ -28,7 +28,7 @@
|
|||
#include "M6532.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
M6532::M6532(const Console& console, const Settings& settings)
|
||||
M6532::M6532(const ConsoleIO& console, const Settings& settings)
|
||||
: myConsole(console),
|
||||
mySettings(settings),
|
||||
myTimer(0), mySubTimer(0), myDivider(1),
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#ifndef M6532_HXX
|
||||
#define M6532_HXX
|
||||
|
||||
class Console;
|
||||
class ConsoleIO;
|
||||
class RiotDebug;
|
||||
class System;
|
||||
class Settings;
|
||||
|
@ -51,7 +51,7 @@ class M6532 : public Device
|
|||
@param console The console the 6532 is associated with
|
||||
@param settings The settings used by the system
|
||||
*/
|
||||
M6532(const Console& console, const Settings& settings);
|
||||
M6532(const ConsoleIO& console, const Settings& settings);
|
||||
virtual ~M6532() = default;
|
||||
|
||||
public:
|
||||
|
@ -163,7 +163,7 @@ class M6532 : public Device
|
|||
};
|
||||
|
||||
// Reference to the console
|
||||
const Console& myConsole;
|
||||
const ConsoleIO& myConsole;
|
||||
|
||||
// Reference to the settings
|
||||
const Settings& mySettings;
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
#include "TIA.hxx"
|
||||
#include "M6502.hxx"
|
||||
#include "Console.hxx"
|
||||
#include "Control.hxx"
|
||||
#include "Paddles.hxx"
|
||||
#include "DelayQueueIteratorImpl.hxx"
|
||||
|
@ -67,8 +66,9 @@ enum ResxCounter: uInt8 {
|
|||
static constexpr uInt8 resxLateHblankThreshold = TIA::H_CYCLES - 3;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
TIA::TIA(Console& console, Settings& settings)
|
||||
TIA::TIA(ConsoleIO& console, ConsoleTimingProvider timingProvider, Settings& settings)
|
||||
: myConsole(console),
|
||||
myTimingProvider(timingProvider),
|
||||
mySettings(settings),
|
||||
myFrameManager(nullptr),
|
||||
myPlayfield(~CollisionMask::playfield & 0x7FFF),
|
||||
|
@ -895,7 +895,7 @@ void TIA::update(uInt64 maxCycles)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool TIA::enableColorLoss(bool enabled)
|
||||
{
|
||||
bool allowColorLoss = consoleTiming() == ConsoleTiming::pal;
|
||||
bool allowColorLoss = myTimingProvider() == ConsoleTiming::pal;
|
||||
|
||||
if(allowColorLoss && enabled)
|
||||
{
|
||||
|
@ -1010,8 +1010,8 @@ bool TIA::toggleCollisions()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool TIA::enableFixedColors(bool enable)
|
||||
{
|
||||
int timing = consoleTiming() == ConsoleTiming::ntsc ? 0
|
||||
: consoleTiming() == ConsoleTiming::pal ? 1 : 2;
|
||||
int timing = myTimingProvider() == ConsoleTiming::ntsc ? 0
|
||||
: myTimingProvider() == ConsoleTiming::pal ? 1 : 2;
|
||||
|
||||
myMissile0.setDebugColor(myFixedColorPalette[timing][FixedObject::M0]);
|
||||
myMissile1.setDebugColor(myFixedColorPalette[timing][FixedObject::M1]);
|
||||
|
@ -1692,7 +1692,7 @@ void TIA::updatePaddle(uInt8 idx)
|
|||
myPaddleReaders[idx].update(
|
||||
(resistance == Controller::MAX_RESISTANCE) ? -1 : (double(resistance) / Paddles::MAX_RESISTANCE),
|
||||
myTimestamp,
|
||||
consoleTiming()
|
||||
myTimingProvider()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,11 @@
|
|||
#ifndef TIA_TIA
|
||||
#define TIA_TIA
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "bspf.hxx"
|
||||
#include "Console.hxx"
|
||||
#include "ConsoleIO.hxx"
|
||||
#include "ConsoleTiming.hxx"
|
||||
#include "Settings.hxx"
|
||||
#include "Device.hxx"
|
||||
#include "Serializer.hxx"
|
||||
|
@ -105,6 +108,8 @@ class TIA : public Device
|
|||
H_CLOCKS = H_CYCLES * CYCLE_CLOCKS, // = 228
|
||||
H_BLANK_CLOCKS = H_CLOCKS - H_PIXEL; // = 68
|
||||
|
||||
using ConsoleTimingProvider = std::function<ConsoleTiming()>;
|
||||
|
||||
public:
|
||||
friend class TIADebug;
|
||||
friend class RiotDebug;
|
||||
|
@ -115,7 +120,7 @@ class TIA : public Device
|
|||
@param console The console the TIA is associated with
|
||||
@param settings The settings object for this TIA device
|
||||
*/
|
||||
TIA(Console& console, Settings& settings);
|
||||
TIA(ConsoleIO& console, ConsoleTimingProvider timingProvider, Settings& settings);
|
||||
|
||||
virtual ~TIA() = default;
|
||||
|
||||
|
@ -260,11 +265,6 @@ class TIA : public Device
|
|||
void setLayout(FrameLayout layout) { myFrameManager->setLayout(layout); }
|
||||
FrameLayout frameLayout() const { return myFrameManager->layout(); }
|
||||
|
||||
/**
|
||||
Answers the timing of the console currently in use.
|
||||
*/
|
||||
ConsoleTiming consoleTiming() const { return myConsole.timing(); }
|
||||
|
||||
/**
|
||||
Enables/disables color-loss for PAL modes only.
|
||||
|
||||
|
@ -690,7 +690,8 @@ class TIA : public Device
|
|||
|
||||
private:
|
||||
|
||||
Console& myConsole;
|
||||
ConsoleIO& myConsole;
|
||||
ConsoleTimingProvider myTimingProvider;
|
||||
Settings& mySettings;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1362,8 +1362,8 @@ void DeveloperDialog::handleDebugColours(int idx, int color)
|
|||
}
|
||||
};
|
||||
|
||||
int timing = instance().console().tia().consoleTiming() == ConsoleTiming::ntsc ? 0
|
||||
: instance().console().tia().consoleTiming() == ConsoleTiming::pal ? 1 : 2;
|
||||
int timing = instance().console().timing() == ConsoleTiming::ntsc ? 0
|
||||
: instance().console().timing() == ConsoleTiming::pal ? 1 : 2;
|
||||
|
||||
myDbgColourSwatch[idx]->setColor(dbg_color[timing][color]);
|
||||
myDbgColour[idx]->setSelectedIndex(color);
|
||||
|
|
Loading…
Reference in New Issue