mirror of https://github.com/stella-emu/stella.git
Changed Switches::update() to not evaluate settings on every call.
Basically, removed determination of whether we're in 2600 or 7800 mode from the hot path, and moved it to a method that is called only when it changes (currently that method doesn't seem to be called at all, since it seems like 'console' setting cannot be changed dynamically).
This commit is contained in:
parent
a91bcbadc9
commit
1f43539f10
|
@ -95,7 +95,7 @@ Console::Console(OSystem& osystem, unique_ptr<Cartridge>& cart,
|
|||
myRiot = make_unique<M6532>(*this, myOSystem.settings());
|
||||
myTIA = make_unique<TIA>(*this, myOSystem.sound(), myOSystem.settings());
|
||||
myFrameManager = make_unique<FrameManager>();
|
||||
mySwitches = make_unique<Switches>(myEvent, myProperties);
|
||||
mySwitches = make_unique<Switches>(myEvent, myProperties, myOSystem.settings());
|
||||
|
||||
myTIA->setFrameManager(myFrameManager.get());
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ EventHandler::EventHandler(OSystem& osystem)
|
|||
myFryingFlag(false),
|
||||
myUseCtrlKeyFlag(true),
|
||||
mySkipMouseMotion(true),
|
||||
myIs7800(false),
|
||||
myAltKeyCounter(0),
|
||||
myContSnapshotInterval(0),
|
||||
myContSnapshotCounter(0)
|
||||
|
@ -117,6 +118,9 @@ void EventHandler::initialize()
|
|||
// Default phosphor blend
|
||||
Properties::setDefault(Display_PPBlend,
|
||||
myOSystem.settings().getString("tv.phosblend"));
|
||||
|
||||
// Toggle 7800 mode
|
||||
set7800Mode();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -192,6 +196,15 @@ void EventHandler::toggleSAPortOrder()
|
|||
#endif
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::set7800Mode()
|
||||
{
|
||||
if(myOSystem.hasConsole())
|
||||
myIs7800 = myOSystem.console().switches().toggle7800Mode(myOSystem.settings());
|
||||
else
|
||||
myIs7800 = false;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void EventHandler::poll(uInt64 time)
|
||||
{
|
||||
|
@ -900,9 +913,6 @@ void EventHandler::handleEvent(Event::Type event, int state)
|
|||
{
|
||||
// Take care of special events that aren't part of the emulation core
|
||||
// or need to be preprocessed before passing them on
|
||||
bool devSettings = myOSystem.settings().getBool("dev.settings");
|
||||
bool is7800 = (myOSystem.settings().getString(devSettings ? "dev.console" : "plr.console") == "7800");
|
||||
|
||||
switch(event)
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
@ -1026,21 +1036,21 @@ void EventHandler::handleEvent(Event::Type event, int state)
|
|||
////////////////////////////////////////////////////////////////////////
|
||||
// Events which relate to switches()
|
||||
case Event::ConsoleColor:
|
||||
if(state && !is7800)
|
||||
if(state && !myIs7800)
|
||||
{
|
||||
myEvent.set(Event::ConsoleBlackWhite, 0);
|
||||
myOSystem.frameBuffer().showMessage("Color Mode");
|
||||
}
|
||||
break;
|
||||
case Event::ConsoleBlackWhite:
|
||||
if(state && !is7800)
|
||||
if(state && !myIs7800)
|
||||
{
|
||||
myEvent.set(Event::ConsoleColor, 0);
|
||||
myOSystem.frameBuffer().showMessage("BW Mode");
|
||||
}
|
||||
break;
|
||||
case Event::ConsoleColorToggle:
|
||||
if(state && !is7800)
|
||||
if(state && !myIs7800)
|
||||
{
|
||||
if(myOSystem.console().switches().tvColor())
|
||||
{
|
||||
|
@ -1054,7 +1064,7 @@ void EventHandler::handleEvent(Event::Type event, int state)
|
|||
myEvent.set(Event::ConsoleColor, 1);
|
||||
myOSystem.frameBuffer().showMessage("Color Mode");
|
||||
}
|
||||
myOSystem.console().switches().update(myOSystem.settings());
|
||||
myOSystem.console().switches().update();
|
||||
}
|
||||
return;
|
||||
|
||||
|
@ -1087,7 +1097,7 @@ void EventHandler::handleEvent(Event::Type event, int state)
|
|||
myEvent.set(Event::ConsoleLeftDiffB, 0);
|
||||
myOSystem.frameBuffer().showMessage("Left Difficulty A");
|
||||
}
|
||||
myOSystem.console().switches().update(myOSystem.settings());
|
||||
myOSystem.console().switches().update();
|
||||
}
|
||||
return;
|
||||
|
||||
|
@ -1120,7 +1130,7 @@ void EventHandler::handleEvent(Event::Type event, int state)
|
|||
myEvent.set(Event::ConsoleRightDiffB, 0);
|
||||
myOSystem.frameBuffer().showMessage("Right Difficulty A");
|
||||
}
|
||||
myOSystem.console().switches().update(myOSystem.settings());
|
||||
myOSystem.console().switches().update();
|
||||
}
|
||||
return;
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -91,6 +91,13 @@ class EventHandler
|
|||
*/
|
||||
void toggleSAPortOrder();
|
||||
|
||||
/**
|
||||
Toggle whether the console is in 2600 or 7800 mode.
|
||||
Note that for now, this only affects whether the 7800 pause button is
|
||||
supported; there is no further emulation of the 7800 itself.
|
||||
*/
|
||||
void set7800Mode();
|
||||
|
||||
/**
|
||||
Collects and dispatches any pending events. This method should be
|
||||
called regularly (at X times per second, where X is the game framerate).
|
||||
|
@ -558,6 +565,10 @@ class EventHandler
|
|||
// state change; we detect when this happens and discard the event
|
||||
bool mySkipMouseMotion;
|
||||
|
||||
// Whether the currently enabled console is emulating certain aspects
|
||||
// of the 7800 (for now, only the switches are notified)
|
||||
bool myIs7800;
|
||||
|
||||
// Sometimes key combos with the Alt key become 'stuck' after the
|
||||
// window changes state, and we want to ignore that event
|
||||
// For example, press Alt-Tab and then upon re-entering the window,
|
||||
|
|
|
@ -106,7 +106,7 @@ void M6532::update()
|
|||
// Update entire port state
|
||||
port0.update();
|
||||
port1.update();
|
||||
myConsole.switches().update(mySettings);
|
||||
myConsole.switches().update();
|
||||
|
||||
// Get new PA7 state
|
||||
bool currPA7 = port0.myDigitalPinState[Controller::Four];
|
||||
|
|
|
@ -17,12 +17,15 @@
|
|||
|
||||
#include "Event.hxx"
|
||||
#include "Props.hxx"
|
||||
#include "Settings.hxx"
|
||||
#include "Switches.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Switches::Switches(const Event& event, const Properties& properties)
|
||||
Switches::Switches(const Event& event, const Properties& properties,
|
||||
const Settings& settings)
|
||||
: myEvent(event),
|
||||
mySwitches(0xFF)
|
||||
mySwitches(0xFF),
|
||||
myIs7800(false)
|
||||
{
|
||||
if(properties.get(Console_RightDifficulty) == "B")
|
||||
{
|
||||
|
@ -50,15 +53,14 @@ Switches::Switches(const Event& event, const Properties& properties)
|
|||
{
|
||||
mySwitches &= ~0x08;
|
||||
}
|
||||
|
||||
toggle7800Mode(settings);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Switches::update(const Settings& settings)
|
||||
void Switches::update()
|
||||
{
|
||||
bool devSettings = settings.getBool("dev.settings");
|
||||
bool is7800 = devSettings && (settings.getString("dev.console") == "7800");
|
||||
|
||||
if(is7800)
|
||||
if(myIs7800)
|
||||
{
|
||||
if(myEvent.get(Event::Console7800Pause) != 0)
|
||||
{
|
||||
|
@ -147,3 +149,12 @@ bool Switches::load(Serializer& in)
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Switches::toggle7800Mode(const Settings& settings)
|
||||
{
|
||||
bool devSettings = settings.getBool("dev.settings");
|
||||
myIs7800 = devSettings && (settings.getString("dev.console") == "7800");
|
||||
|
||||
return myIs7800;
|
||||
}
|
||||
|
|
|
@ -20,10 +20,10 @@
|
|||
|
||||
class Event;
|
||||
class Properties;
|
||||
class Settings;
|
||||
|
||||
#include "Serializable.hxx"
|
||||
#include "bspf.hxx"
|
||||
#include "Settings.hxx"
|
||||
|
||||
/**
|
||||
This class represents the console switches of the game console.
|
||||
|
@ -40,25 +40,27 @@ class Switches : public Serializable
|
|||
public:
|
||||
/**
|
||||
Create a new set of switches using the specified events and
|
||||
properties
|
||||
properties.
|
||||
|
||||
@param event The event object to use for events
|
||||
@param props The ROM properties to use for the currently enabled ROM
|
||||
@param settings The settings used by the system
|
||||
*/
|
||||
Switches(const Event& event, const Properties& properties);
|
||||
Switches(const Event& event, const Properties& props, const Settings& settings);
|
||||
virtual ~Switches() = default;
|
||||
|
||||
public:
|
||||
/**
|
||||
Get the value of the console switches
|
||||
Get the value of the console switches.
|
||||
|
||||
@return The 8 bits which represent the state of the console switches
|
||||
*/
|
||||
uInt8 read() const { return mySwitches; }
|
||||
|
||||
/**
|
||||
Update the switches variable
|
||||
Update the switches variable.
|
||||
*/
|
||||
void update(const Settings& settings);
|
||||
void update();
|
||||
|
||||
/**
|
||||
Save the current state of the switches to the given Serializer.
|
||||
|
@ -104,6 +106,13 @@ class Switches : public Serializable
|
|||
*/
|
||||
bool rightDifficultyA() const { return mySwitches & 0x80; }
|
||||
|
||||
/**
|
||||
Toggle between 2600 and 7800 mode depending on settings.
|
||||
|
||||
@return True if 7800 mode enabled, else false
|
||||
*/
|
||||
bool toggle7800Mode(const Settings& settings);
|
||||
|
||||
private:
|
||||
// Reference to the event object to use
|
||||
const Event& myEvent;
|
||||
|
@ -111,6 +120,9 @@ class Switches : public Serializable
|
|||
// State of the console switches
|
||||
uInt8 mySwitches;
|
||||
|
||||
// Are we in 7800 or 2600 mode?
|
||||
bool myIs7800;
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
Switches() = delete;
|
||||
|
|
|
@ -184,7 +184,7 @@ void CommandDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
{
|
||||
instance().eventHandler().leaveMenuMode();
|
||||
instance().eventHandler().handleEvent(event, 1);
|
||||
instance().console().switches().update(instance().settings());
|
||||
instance().console().switches().update();
|
||||
instance().console().tia().update();
|
||||
instance().eventHandler().handleEvent(event, 0);
|
||||
}
|
||||
|
|
|
@ -671,6 +671,7 @@ void DeveloperDialog::saveConfig()
|
|||
#endif
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void DeveloperDialog::setDefaults()
|
||||
{
|
||||
bool devSettings = mySettingsGroup0->getSelected() == 1;
|
||||
|
|
Loading…
Reference in New Issue