mirror of https://github.com/stella-emu/stella.git
added missing write method to QuadTari (fixes #832, SaveKey not working in QT)
This commit is contained in:
parent
72f5f17011
commit
7c8f426a1b
|
@ -171,7 +171,7 @@ void Properties::print() const
|
|||
<< get(PropType::Controller_Left2) << "|"
|
||||
<< get(PropType::Controller_Right) << "|"
|
||||
<< get(PropType::Controller_Right1) << "|"
|
||||
<< get(PropType::Controller_Right2) << "|"
|
||||
<< get(PropType::Controller_Right2) << "|"
|
||||
<< get(PropType::Controller_SwapPaddles) << "|"
|
||||
<< get(PropType::Controller_PaddlesXCenter) << "|"
|
||||
<< get(PropType::Controller_PaddlesYCenter) << "|"
|
||||
|
|
|
@ -107,6 +107,19 @@ unique_ptr<Controller> QuadTari::addController(const Controller::Type type, bool
|
|||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool QuadTari::isFirst()
|
||||
{
|
||||
constexpr int MIN_CYCLES = 76; // minimal cycles required for stable input switch (just to be safe)
|
||||
|
||||
if(mySystem.tia().dumpPortsCycles() < MIN_CYCLES)
|
||||
// Random controller if read too soon after dump ports changed
|
||||
return mySystem.randGenerator().next() % 2;
|
||||
else
|
||||
// If bit 7 of VBlank is not set, read first, else second controller
|
||||
return !(mySystem.tia().registerValue(VBLANK) & 0x80);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool QuadTari::read(DigitalPin pin)
|
||||
{
|
||||
|
@ -114,22 +127,21 @@ bool QuadTari::read(DigitalPin pin)
|
|||
// can switch the controller multiple times per frame
|
||||
// (we can't just read 60 times per second in the ::update() method)
|
||||
|
||||
constexpr int MIN_CYCLES = 76; // minimal cycles required for stable input switch (just to be safe)
|
||||
bool readFirst;
|
||||
|
||||
if(mySystem.tia().dumpPortsCycles() < MIN_CYCLES)
|
||||
// Random controller if read too soon after dump ports changed
|
||||
readFirst = mySystem.randGenerator().next() % 2;
|
||||
else
|
||||
// If bit 7 of VBlank is not set, read first, else second controller
|
||||
readFirst = !(mySystem.tia().registerValue(VBLANK) & 0x80);
|
||||
|
||||
if(readFirst)
|
||||
if(isFirst())
|
||||
return myFirstController->read(pin);
|
||||
else
|
||||
return mySecondController->read(pin);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void QuadTari::write(DigitalPin pin, bool value)
|
||||
{
|
||||
if(isFirst())
|
||||
return myFirstController->write(pin, value);
|
||||
else
|
||||
return mySecondController->write(pin, value);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void QuadTari::update()
|
||||
{
|
||||
|
|
|
@ -59,6 +59,16 @@ class QuadTari : public Controller
|
|||
*/
|
||||
bool read(DigitalPin pin) override;
|
||||
|
||||
/**
|
||||
Write the given value to the specified digital pin for this
|
||||
controller. Writing is only allowed to the pins associated
|
||||
with the PIA. Therefore you cannot write to pin six.
|
||||
|
||||
@param pin The pin of the controller jack to write to
|
||||
@param value The value to write to the pin
|
||||
*/
|
||||
void write(DigitalPin pin, bool value) override;
|
||||
|
||||
/**
|
||||
Update the entire digital and analog pin state according to the
|
||||
events currently set.
|
||||
|
@ -96,6 +106,9 @@ class QuadTari : public Controller
|
|||
Controller::Type xtype, int xid, Controller::Type ytype, int yid) override;
|
||||
|
||||
private:
|
||||
// determine which controller is active
|
||||
bool isFirst();
|
||||
|
||||
unique_ptr<Controller> addController(const Controller::Type type, bool second);
|
||||
|
||||
const OSystem& myOSystem;
|
||||
|
|
Loading…
Reference in New Issue