diff --git a/Changes.txt b/Changes.txt index 31e2254ef..eb495b099 100644 --- a/Changes.txt +++ b/Changes.txt @@ -37,6 +37,8 @@ are no longer corrupted/cut off. This includes properly supporting the 2600-daptor II, which is flashable to an AVox-USB converter. + * Added QuadTari controller support for josticks (TODO: doc, settings etc.) + * Added option to select the audio device. * Added option to display detected settings info when a ROM is loaded. diff --git a/src/emucore/Control.cxx b/src/emucore/Control.cxx index 0dfdc79d3..fb57b6278 100644 --- a/src/emucore/Control.cxx +++ b/src/emucore/Control.cxx @@ -110,7 +110,7 @@ string Controller::getName(const Type type) "AmigaMouse", "AtariMouse", "AtariVox", "BoosterGrip", "CompuMate", "Driving", "Sega Genesis", "Joystick", "Keyboard", "KidVid", "MindLink", "Paddles", "Paddles_IAxis", "Paddles_IAxDr", "SaveKey", "TrakBall", - "Lightgun" + "Lightgun", "QuadTari" }; return NAMES[int(type)]; diff --git a/src/emucore/ControllerDetector.cxx b/src/emucore/ControllerDetector.cxx index 622f59ca1..2e21d8586 100644 --- a/src/emucore/ControllerDetector.cxx +++ b/src/emucore/ControllerDetector.cxx @@ -62,6 +62,10 @@ Controller::Type ControllerDetector::autodetectPort( if(isProbablySaveKey(image, size, port)) type = Controller::Type::SaveKey; + else if(isProbablyQuadTari(image, size, port)) + { + type = Controller::Type::QuadTari; + } else if(usesJoystickButton(image, size, port)) { if(isProbablyTrakBall(image, size)) @@ -693,3 +697,21 @@ bool ControllerDetector::isProbablyLightGun(const ByteBuffer& image, size_t size return false; } + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool ControllerDetector::isProbablyQuadTari(const ByteBuffer& image, size_t size, + Controller::Jack port) +{ + if(port == Controller::Jack::Left) + { + uInt8 signature[] = { 'Q', 'U', 'A', 'D', 'L' }; + + return searchForBytes(image, size, signature, 5); + } + else if(port == Controller::Jack::Right) + { + uInt8 signature[] = { 'Q', 'U', 'A', 'D', 'R' }; + + return searchForBytes(image, size, signature, 5); + } +} diff --git a/src/emucore/QuadTari.cxx b/src/emucore/QuadTari.cxx index 55adf8c53..c75c28f76 100644 --- a/src/emucore/QuadTari.cxx +++ b/src/emucore/QuadTari.cxx @@ -16,6 +16,9 @@ //============================================================================ #include "Event.hxx" +#include "System.hxx" +#include "TIA.hxx" +#include "FrameBuffer.hxx" #include "Joystick.hxx" #include "QuadTari.hxx" @@ -23,7 +26,7 @@ QuadTari::QuadTari(Jack jack, const Event& event, const System& system) : Controller(jack, event, system, Controller::Type::QuadTari) { - // TODO: allow multiple controller types + // TODO: support multiple controller types if(myJack == Jack::Left) { myFirstController = make_unique(Jack::Left, event, system); @@ -34,6 +37,9 @@ QuadTari::QuadTari(Jack jack, const Event& event, const System& system) myFirstController = make_unique(Jack::Right, event, system); mySecondController = make_unique(Jack::Left, event, system); // TODO: use P3 mapping } + // QuadTari auto detection setting + setPin(AnalogPin::Five, MIN_RESISTANCE); + setPin(AnalogPin::Nine, MAX_RESISTANCE); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -43,8 +49,11 @@ 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) - if(true) // TODO handle controller switch + // If bit 7 of VBlank is not set, read first, else second controller + if(!(mySystem.tia().registerValue(VBLANK) & 0x80)) return myFirstController->read(pin); + else + return mySecondController->read(pin); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -54,20 +63,25 @@ void QuadTari::update() mySecondController->update(); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string QuadTari::name() const +{ + return "QuadTari (" + myFirstController->name() + "/" + mySecondController->name() + ")"; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool QuadTari::isAnalog() const { - // TODO: does this work? - return myFirstController->isAnalog() || mySecondController->isAnalog(); + // For now, use mouse for first controller only + return myFirstController->isAnalog(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool QuadTari::setMouseControl( Controller::Type xtype, int xid, Controller::Type ytype, int yid) { - // TODO: does this work? - myFirstController->setMouseControl(xtype, xid, ytype, yid); - mySecondController->setMouseControl(xtype, xid, ytype, yid); + // Use mouse for first controller only (TODO: support multiple controller types) + myFirstController->setMouseControl(Controller::Type::Joystick, xid, Controller::Type::Joystick, yid); return true; } diff --git a/src/emucore/QuadTari.hxx b/src/emucore/QuadTari.hxx index 2499c5c2a..215ee0796 100644 --- a/src/emucore/QuadTari.hxx +++ b/src/emucore/QuadTari.hxx @@ -57,9 +57,8 @@ class QuadTari: public Controller /** Returns the name of this controller. - // TODO: Or the names of the attached controllers? */ - string name() const override { return "QuadTari"; } + string name() const override; /** Answers whether the controller is intrinsically an analog controller.