improved logging and display of auto detected controllers and bankswitching types

This commit is contained in:
thrust26 2019-12-15 17:19:08 +01:00
parent b6122f136f
commit ebbfc258a6
7 changed files with 37 additions and 12 deletions

View File

@ -33,6 +33,12 @@ Bankswitch::Type Bankswitch::nameToType(const string& name)
return Bankswitch::Type::_AUTO; return Bankswitch::Type::_AUTO;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Bankswitch::typeToDesc(Bankswitch::Type type)
{
return BSList[int(type)].desc;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Bankswitch::Type Bankswitch::typeFromExtension(const FilesystemNode& file) Bankswitch::Type Bankswitch::typeFromExtension(const FilesystemNode& file)
{ {
@ -100,35 +106,35 @@ Bankswitch::Description Bankswitch::BSList[int(Bankswitch::Type::NumSchemes)] =
{ "3E" , "3E (32K Tigervision)" }, { "3E" , "3E (32K Tigervision)" },
{ "3E+" , "3E+ (TJ modified DASH)" }, { "3E+" , "3E+ (TJ modified DASH)" },
{ "3F" , "3F (512K Tigervision)" }, { "3F" , "3F (512K Tigervision)" },
{ "4A50" , "4A50 (64K 4A50 + ram)" }, { "4A50" , "4A50 (64K 4A50 + RAM)" },
{ "4K" , "4K (4K Atari)" }, { "4K" , "4K (4K Atari)" },
{ "4KSC" , "4KSC (CPUWIZ 4K + ram)" }, { "4KSC" , "4KSC (CPUWIZ 4K + RAM)" },
{ "AR" , "AR (Supercharger)" }, { "AR" , "AR (Supercharger)" },
{ "BF" , "BF (CPUWIZ 256K)" }, { "BF" , "BF (CPUWIZ 256K)" },
{ "BFSC" , "BFSC (CPUWIZ 256K + ram)" }, { "BFSC" , "BFSC (CPUWIZ 256K + RAM)" },
{ "BUS" , "BUS (Experimental)" }, { "BUS" , "BUS (Experimental)" },
{ "CDF" , "CDF (Chris, Darrell, Fred)" }, { "CDF" , "CDF (Chris, Darrell, Fred)" },
{ "CM" , "CM (SpectraVideo CompuMate)" }, { "CM" , "CM (SpectraVideo CompuMate)" },
{ "CTY" , "CTY (CDW - Chetiry)" }, { "CTY" , "CTY (CDW - Chetiry)" },
{ "CV" , "CV (Commavid extra ram)" }, { "CV" , "CV (Commavid extra RAM)" },
{ "CV+" , "CV+ (Extended Commavid)" }, { "CV+" , "CV+ (Extended Commavid)" },
{ "DASH" , "DASH (Experimental)" }, { "DASH" , "DASH (Experimental)" },
{ "DF" , "DF (CPUWIZ 128K)" }, { "DF" , "DF (CPUWIZ 128K)" },
{ "DFSC" , "DFSC (CPUWIZ 128K + ram)" }, { "DFSC" , "DFSC (CPUWIZ 128K + RAM)" },
{ "DPC" , "DPC (Pitfall II)" }, { "DPC" , "DPC (Pitfall II)" },
{ "DPC+" , "DPC+ (Enhanced DPC)" }, { "DPC+" , "DPC+ (Enhanced DPC)" },
{ "E0" , "E0 (8K Parker Bros)" }, { "E0" , "E0 (8K Parker Bros)" },
{ "E7" , "E7 (16K M-network)" }, { "E7" , "E7 (16K M-network)" },
{ "E78K" , "E78K (8K M-network)" }, { "E78K" , "E78K (8K M-network)" },
{ "EF" , "EF (64K H. Runner)" }, { "EF" , "EF (64K H. Runner)" },
{ "EFSC" , "EFSC (64K H. Runner + ram)" }, { "EFSC" , "EFSC (64K H. Runner + RAM)" },
{ "F0" , "F0 (Dynacom Megaboy)" }, { "F0" , "F0 (Dynacom Megaboy)" },
{ "F4" , "F4 (32K Atari)" }, { "F4" , "F4 (32K Atari)" },
{ "F4SC" , "F4SC (32K Atari + ram)" }, { "F4SC" , "F4SC (32K Atari + RAM)" },
{ "F6" , "F6 (16K Atari)" }, { "F6" , "F6 (16K Atari)" },
{ "F6SC" , "F6SC (16K Atari + ram)" }, { "F6SC" , "F6SC (16K Atari + RAM)" },
{ "F8" , "F8 (8K Atari)" }, { "F8" , "F8 (8K Atari)" },
{ "F8SC" , "F8SC (8K Atari + ram)" }, { "F8SC" , "F8SC (8K Atari + RAM)" },
{ "FA" , "FA (CBS RAM Plus)" }, { "FA" , "FA (CBS RAM Plus)" },
{ "FA2" , "FA2 (CBS RAM Plus 24/28K)" }, { "FA2" , "FA2 (CBS RAM Plus 24/28K)" },
{ "FC" , "FC (32K Amiga)" }, { "FC" , "FC (32K Amiga)" },

View File

@ -67,6 +67,9 @@ class Bankswitch
// Convert string to BSType enum // Convert string to BSType enum
static Bankswitch::Type nameToType(const string& name); static Bankswitch::Type nameToType(const string& name);
// Convert BSType enum to description string
static string typeToDesc(Bankswitch::Type type);
// Determine bankswitch type by filename extension // Determine bankswitch type by filename extension
// Use '_AUTO' if unknown // Use '_AUTO' if unknown
static Bankswitch::Type typeFromExtension(const FilesystemNode& file); static Bankswitch::Type typeFromExtension(const FilesystemNode& file);

View File

@ -62,6 +62,7 @@
#include "CartX07.hxx" #include "CartX07.hxx"
#include "MD5.hxx" #include "MD5.hxx"
#include "Props.hxx" #include "Props.hxx"
#include "Logger.hxx"
#include "CartDetector.hxx" #include "CartDetector.hxx"
@ -535,6 +536,11 @@ Bankswitch::Type CartDetector::autodetectType(const ByteBuffer& image, size_t si
else if(isProbablyMDM(image, size)) else if(isProbablyMDM(image, size))
type = Bankswitch::Type::_MDM; type = Bankswitch::Type::_MDM;
ostringstream ss;
ss << "Bankswitching type '" << Bankswitch::typeToDesc(type) << "' detected";
Logger::debug(ss.str());
return type; return type;
} }

View File

@ -824,6 +824,7 @@ void Console::setControllers(const string& romMd5)
// Try to detect controllers // Try to detect controllers
if(image != nullptr && size != 0) if(image != nullptr && size != 0)
{ {
Logger::debug(myProperties.get(PropType::Cart_Name) + ":");
leftType = ControllerDetector::detectType(image, size, leftType, leftType = ControllerDetector::detectType(image, size, leftType,
!swappedPorts ? Controller::Jack::Left : Controller::Jack::Right, myOSystem.settings()); !swappedPorts ? Controller::Jack::Left : Controller::Jack::Right, myOSystem.settings());
rightType = ControllerDetector::detectType(image, size, rightType, rightType = ControllerDetector::detectType(image, size, rightType,

View File

@ -34,7 +34,7 @@ Controller::Type ControllerDetector::detectType(const uInt8* image, size_t size,
cerr << "Controller auto-detection not consistent: " cerr << "Controller auto-detection not consistent: "
<< Controller::getName(type) << ", " << Controller::getName(detectedType) << endl; << Controller::getName(type) << ", " << Controller::getName(detectedType) << endl;
} }
Logger::debug(Controller::getName(detectedType) + " detected for " + Logger::debug("'" + Controller::getName(detectedType) + "' detected for " +
(port == Controller::Jack::Left ? "left" : "right") + " port"); (port == Controller::Jack::Left ? "left" : "right") + " port");
return detectedType; return detectedType;
} }

View File

@ -394,7 +394,7 @@ void GameInfoDialog::loadEmulationProperties(const Properties& props)
if(!instance().hasConsole() && if(!instance().hasConsole() &&
node.exists() && !node.isDirectory() && (image = instance().openROM(node, md5, size)) != nullptr) node.exists() && !node.isDirectory() && (image = instance().openROM(node, md5, size)) != nullptr)
{ {
bsDetected = Bankswitch::typeToName(CartDetector::autodetectType(image, size)) + " detected"; bsDetected = Bankswitch::typeToDesc(CartDetector::autodetectType(image, size)) + " detected";
} }
} }
} }

View File

@ -22,6 +22,9 @@
#include "Font.hxx" #include "Font.hxx"
#include "OSystem.hxx" #include "OSystem.hxx"
#include "ControllerDetector.hxx" #include "ControllerDetector.hxx"
#include "Bankswitch.hxx"
#include "CartDetector.hxx"
#include "Logger.hxx"
#include "Props.hxx" #include "Props.hxx"
#include "PNGLibrary.hxx" #include "PNGLibrary.hxx"
#include "Rect.hxx" #include "Rect.hxx"
@ -132,11 +135,12 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node)
myRomInfo.push_back("Note: " + myProperties.get(PropType::Cart_Note)); myRomInfo.push_back("Note: " + myProperties.get(PropType::Cart_Note));
bool swappedPorts = myProperties.get(PropType::Console_SwapPorts) == "YES"; bool swappedPorts = myProperties.get(PropType::Console_SwapPorts) == "YES";
// Load the image for controller auto detection // Load the image for controller and bankswitch type auto detection
string left = myProperties.get(PropType::Controller_Left); string left = myProperties.get(PropType::Controller_Left);
string right = myProperties.get(PropType::Controller_Right); string right = myProperties.get(PropType::Controller_Right);
Controller::Type leftType = Controller::getType(left); Controller::Type leftType = Controller::getType(left);
Controller::Type rightType = Controller::getType(right); Controller::Type rightType = Controller::getType(right);
string bsDetected = myProperties.get(PropType::Cart_Type);
try try
{ {
ByteBuffer image; ByteBuffer image;
@ -146,12 +150,15 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node)
if(node.exists() && !node.isDirectory() && if(node.exists() && !node.isDirectory() &&
(image = instance().openROM(node, md5, size)) != nullptr) (image = instance().openROM(node, md5, size)) != nullptr)
{ {
Logger::debug(myProperties.get(PropType::Cart_Name) + ":");
left = ControllerDetector::detectName(image.get(), size, leftType, left = ControllerDetector::detectName(image.get(), size, leftType,
!swappedPorts ? Controller::Jack::Left : Controller::Jack::Right, !swappedPorts ? Controller::Jack::Left : Controller::Jack::Right,
instance().settings()); instance().settings());
right = ControllerDetector::detectName(image.get(), size, rightType, right = ControllerDetector::detectName(image.get(), size, rightType,
!swappedPorts ? Controller::Jack::Right : Controller::Jack::Left, !swappedPorts ? Controller::Jack::Right : Controller::Jack::Left,
instance().settings()); instance().settings());
if (bsDetected == "AUTO")
bsDetected = Bankswitch::typeToName(CartDetector::autodetectType(image, size));
} }
} }
catch(const runtime_error&) catch(const runtime_error&)
@ -162,6 +169,8 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node)
} }
if(left != "" && right != "") if(left != "" && right != "")
myRomInfo.push_back("Controllers: " + (left + " (left), " + right + " (right)")); myRomInfo.push_back("Controllers: " + (left + " (left), " + right + " (right)"));
if (bsDetected != "")
myRomInfo.push_back("Type: " + Bankswitch::typeToDesc(Bankswitch::nameToType(bsDetected)));
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -