improved QuadTari auto detection and setup

This commit is contained in:
thrust26 2024-05-07 17:14:40 +02:00
parent c713f4f3fa
commit 4aba8a1955
9 changed files with 74 additions and 46 deletions

View File

@ -34,12 +34,16 @@
* Added Joy2B+ controller support.
* Added auto detection for QuadTari attached controllers
* Enhanced Kid Vid support to play tape audio.
* Added port selection, used for controller default mapping.
* Added missing PlusROM support for E7 bankswitching.
* Enhanced movie cart (MVC) support
* Accelerated emulation up to ~15% (ARM).
* Added limited GameLine Master Module bankswitching support.

View File

@ -500,21 +500,22 @@ void PhysicalJoystickHandler::setDefaultMapping(Event::Type event, EventMode mod
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalJoystickHandler::defineControllerMappings(const Controller::Type type, Controller::Jack port,
const Properties& properties)
void PhysicalJoystickHandler::defineControllerMappings(
const Controller::Type type, Controller::Jack port, const Properties& properties,
Controller::Type qtType1, Controller::Type qtType2)
{
// Determine controller events to use
if(type == Controller::Type::QuadTari)
{
if(port == Controller::Jack::Left)
{
myLeftMode = getMode(properties, PropType::Controller_Left1);
myLeft2ndMode = getMode(properties, PropType::Controller_Left2);
myLeftMode = getMode(qtType1);
myLeft2ndMode = getMode(qtType2);
}
else
{
myRightMode = getMode(properties, PropType::Controller_Right1);
myRight2ndMode = getMode(properties, PropType::Controller_Right2);
myRightMode = getMode(qtType1);
myRight2ndMode = getMode(qtType2);
}
}
else

View File

@ -93,7 +93,9 @@ class PhysicalJoystickHandler
/** define mappings for current controllers */
void defineControllerMappings(const Controller::Type type, Controller::Jack port,
const Properties& properties);
const Properties& properties,
Controller::Type qtType1 = Controller::Type::Unknown,
Controller::Type qtType2 = Controller::Type::Unknown);
/** enable mappings for emulation mode */
void enableEmulationMappings();

View File

@ -235,20 +235,21 @@ void PhysicalKeyboardHandler::setDefaultMapping(Event::Type event, EventMode mod
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalKeyboardHandler::defineControllerMappings(
const Controller::Type type, Controller::Jack port, const Properties& properties)
const Controller::Type type, Controller::Jack port, const Properties& properties,
Controller::Type qtType1, Controller::Type qtType2)
{
// Determine controller events to use
if(type == Controller::Type::QuadTari)
{
if(port == Controller::Jack::Left)
{
myLeftMode = getMode(properties, PropType::Controller_Left1);
myLeft2ndMode = getMode(properties, PropType::Controller_Left2);
myLeftMode = getMode(qtType1);
myLeft2ndMode = getMode(qtType2);
}
else
{
myRightMode = getMode(properties, PropType::Controller_Right1);
myRight2ndMode = getMode(properties, PropType::Controller_Right2);
myRightMode = getMode(qtType1);
myRight2ndMode = getMode(qtType2);
}
}
else

View File

@ -54,7 +54,9 @@ class PhysicalKeyboardHandler
/** define mappings for current controllers */
void defineControllerMappings(const Controller::Type type,
Controller::Jack port,
const Properties& properties);
const Properties& properties,
Controller::Type qtType1 = Controller::Type::Unknown,
Controller::Type qtType2 = Controller::Type::Unknown);
/** enable mappings for emulation mode */
void enableEmulationMappings();

View File

@ -1005,8 +1005,11 @@ unique_ptr<Controller> Console::getControllerPort(
{
unique_ptr<Controller> controller;
myOSystem.eventHandler().defineKeyControllerMappings(type, port, myProperties);
myOSystem.eventHandler().defineJoyControllerMappings(type, port, myProperties);
if(type != Controller::Type::QuadTari)
{
myOSystem.eventHandler().defineKeyControllerMappings(type, port, myProperties);
myOSystem.eventHandler().defineJoyControllerMappings(type, port, myProperties);
}
switch(type)
{
@ -1061,11 +1064,11 @@ unique_ptr<Controller> Console::getControllerPort(
nvramfile /= "atarivox_eeprom.dat";
const Controller::onMessageCallback callback = [&os = myOSystem]
(string_view msg)
{
const bool devSettings = os.settings().getBool("dev.settings");
if(os.settings().getBool(devSettings ? "dev.extaccess" : "plr.extaccess"))
os.frameBuffer().showTextMessage(msg);
};
{
const bool devSettings = os.settings().getBool("dev.settings");
if(os.settings().getBool(devSettings ? "dev.extaccess" : "plr.extaccess"))
os.frameBuffer().showTextMessage(msg);
};
controller = make_unique<AtariVox>(port, myEvent, *mySystem,
myOSystem.settings().getString("avoxport"), nvramfile, callback);
break;
@ -1076,11 +1079,11 @@ unique_ptr<Controller> Console::getControllerPort(
nvramfile /= "savekey_eeprom.dat";
const Controller::onMessageCallback callback = [&os = myOSystem]
(string_view msg)
{
const bool devSettings = os.settings().getBool("dev.settings");
if(os.settings().getBool(devSettings ? "dev.extaccess" : "plr.extaccess"))
os.frameBuffer().showTextMessage(msg);
};
{
const bool devSettings = os.settings().getBool("dev.settings");
if(os.settings().getBool(devSettings ? "dev.extaccess" : "plr.extaccess"))
os.frameBuffer().showTextMessage(msg);
};
controller = make_unique<SaveKey>(port, myEvent, *mySystem, nvramfile, callback);
break;
}
@ -1095,7 +1098,7 @@ unique_ptr<Controller> Console::getControllerPort(
const bool devSettings = os.settings().getBool("dev.settings");
if(force || os.settings().getBool(devSettings ? "dev.extaccess" : "plr.extaccess"))
os.frameBuffer().showTextMessage(msg);
};
};
controller = make_unique<KidVid>
(port, myEvent, myOSystem, *mySystem, romMd5, callback);
break;
@ -1111,9 +1114,16 @@ unique_ptr<Controller> Console::getControllerPort(
break;
case Controller::Type::QuadTari:
controller = make_unique<QuadTari>(port, myOSystem, *mySystem, myProperties, *myCart);
break;
{
unique_ptr<QuadTari> quadTari = make_unique<QuadTari>(port, myOSystem, *mySystem, myProperties, *myCart);
myOSystem.eventHandler().defineKeyControllerMappings(type, port, myProperties,
quadTari->firstController().type(), quadTari->secondController().type());
myOSystem.eventHandler().defineJoyControllerMappings(type, port, myProperties,
quadTari->firstController().type(), quadTari->secondController().type());
controller = std::move(quadTari);
break;
}
case Controller::Type::Joy2BPlus:
controller = make_unique<Joy2BPlus>(port, myEvent, *mySystem);
break;

View File

@ -737,10 +737,11 @@ bool ControllerDetector::isProbablyQuadTari(const ByteBuffer& image, size_t size
Controller::Jack port)
{
{
static constexpr int NUM_SIGS = 2;
static constexpr int NUM_SIGS = 3;
static constexpr int SIG_SIZE = 8;
static constexpr uInt8 signatureBoth[NUM_SIGS][SIG_SIZE] = {
{ 0x1B, 0x1F, 0x0B, 0x0E, 0x1E, 0x0B, 0x1C, 0x13 },
{ 0x1B, 0x1F, 0x0B, 0x0E, 0x1E, 0x0B, 0x1C, 0x13 }, // Champ Games
{ 0x1c, 0x20, 0x0C, 0x0F, 0x1F, 0x0C, 0x1D, 0x14 }, // RobotWar-2684
{ 'Q', 'U', 'A', 'D', 'T', 'A', 'R', 'I' }
}; // "QUADTARI"

View File

@ -231,8 +231,10 @@ class EventHandler
Enable controller specific keyboard event mappings.
*/
void defineKeyControllerMappings(const Controller::Type type, Controller::Jack port,
const Properties& properties) {
myPKeyHandler->defineControllerMappings(type, port, properties);
const Properties& properties,
Controller::Type qtType1 = Controller::Type::Unknown,
Controller::Type qtType2 = Controller::Type::Unknown) {
myPKeyHandler->defineControllerMappings(type, port, properties, qtType1, qtType2);
}
/**
@ -283,8 +285,10 @@ class EventHandler
Enable controller specific keyboard event mappings.
*/
void defineJoyControllerMappings(const Controller::Type type, Controller::Jack port,
const Properties& properties) {
myPJoyHandler->defineControllerMappings(type, port, properties);
const Properties& properties,
Controller::Type qtType1 = Controller::Type::Unknown,
Controller::Type qtType2 = Controller::Type::Unknown) {
myPJoyHandler->defineControllerMappings(type, port, properties, qtType1, qtType2);
}
/**

View File

@ -78,7 +78,7 @@ QuadTariDialog::QuadTariDialog(GuiObject* boss, const GUI::Font& font, int max_w
ypos += lineHeight + VGAP;
myLeft1PortDetected = new StaticTextWidget(this, ifont,
myLeft1Port->getLeft() + fontWidth * 3, ypos, "AtariVox detected");
myLeft1Port->getLeft() + fontWidth * 3, ypos, " ");
ypos += lineHeight + VGAP;
myLeft2Port = new PopUpWidget(this, font, xpos, ypos,
@ -87,7 +87,7 @@ QuadTariDialog::QuadTariDialog(GuiObject* boss, const GUI::Font& font, int max_w
ypos += lineHeight + VGAP;
myLeft2PortDetected = new StaticTextWidget(this, ifont,
myLeft2Port->getLeft() + fontWidth * 3, ypos, "AtariVox detected");
myLeft2Port->getLeft() + fontWidth * 3, ypos, " ");
xpos = _w - HBORDER - myLeft1Port->getWidth(); // aligned right
ypos = myLeftPortLabel->getTop() - 1;
@ -100,7 +100,7 @@ QuadTariDialog::QuadTariDialog(GuiObject* boss, const GUI::Font& font, int max_w
ypos += lineHeight + VGAP;
myRight1PortDetected = new StaticTextWidget(this, ifont,
myRight1Port->getLeft() + fontWidth * 3, ypos, "AtariVox detected");
myRight1Port->getLeft() + fontWidth * 3, ypos, " ");
ypos += lineHeight + VGAP;
//ypos += lineHeight + VGAP * 2;
@ -110,7 +110,7 @@ QuadTariDialog::QuadTariDialog(GuiObject* boss, const GUI::Font& font, int max_w
ypos += lineHeight + VGAP;
myRight2PortDetected = new StaticTextWidget(this, ifont,
myRight2Port->getLeft() + fontWidth * 3, ypos, "AtariVox detected");
myRight2Port->getLeft() + fontWidth * 3, ypos, " ");
addDefaultsOKCancelBGroup(wid, _font);
addBGroupToFocusList(wid);
@ -160,8 +160,8 @@ void QuadTariDialog::defineController(const Properties& props, PropType key,
ByteBuffer image;
size_t size = 0;
string controller = props.get(key);
popupWidget->setSelected(controller, "AUTO");
string controllerName = props.get(key);
popupWidget->setSelected(controllerName, "AUTO");
// try to load the image for auto detection
if(!instance().hasConsole())
@ -179,15 +179,18 @@ void QuadTariDialog::defineController(const Properties& props, PropType key,
{
if(instance().hasConsole())
{
const QuadTari* qt = dynamic_cast<QuadTari*>(
jack == Controller::Jack::Left
? &instance().console().leftController()
: &instance().console().rightController());
if(qt != nullptr)
Controller& controller = (jack == Controller::Jack::Left
? instance().console().leftController()
: instance().console().rightController());
if(BSPF::startsWithIgnoreCase(controller.name(), "QT"))
{
const QuadTari* qt = static_cast<QuadTari*>(&controller);
label = (first
? qt->firstController().name()
: qt->secondController().name())
+ " detected";
+ " detected";
}
else
label = "nothing detected";
}