added PlusROM detection display

simplified PlusROM id generation logic
shortened QuadTari.name()
This commit is contained in:
Thomas Jentzsch 2021-10-01 17:00:10 +02:00
parent 793b554f53
commit 208e7e3075
6 changed files with 36 additions and 23 deletions

View File

@ -807,3 +807,12 @@ bool CartDetector::isProbablyX07(const ByteBuffer& image, size_t size)
return false; return false;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartDetector::isProbablyPlusROM(const ByteBuffer& image, size_t size)
{
// PlusCart uses this pattern to detect a PlusROM
uInt8 signature[3] = {0x8d, 0xf0, 0x1f}; // STA $1FF0
return searchForBytes(image, size, signature, 3);
}

View File

@ -47,6 +47,11 @@ class CartDetector
*/ */
static size_t isProbablyMVC(const FilesystemNode& rom); static size_t isProbablyMVC(const FilesystemNode& rom);
/**
Returns true if the image is probably a HSC PlusROM
*/
static bool isProbablyPlusROM(const ByteBuffer& image, size_t size);
private: private:
/** /**
Search the image for the specified byte signature Search the image for the specified byte signature

View File

@ -505,6 +505,7 @@ string OSystem::createConsole(const FilesystemNode& rom, const string& md5sum,
msg << myConsole->leftController().name() << "/" << myConsole->rightController().name() msg << myConsole->leftController().name() << "/" << myConsole->rightController().name()
<< " - " << myConsole->cartridge().detectedType() << " - " << myConsole->cartridge().detectedType()
<< (myConsole->cartridge().isPlusROM() ? " PlusROM " : "")
<< " - " << myConsole->getFormatString(); << " - " << myConsole->getFormatString();
myFrameBuffer->showTextMessage(msg.str()); myFrameBuffer->showTextMessage(msg.str());
} }

View File

@ -152,7 +152,7 @@ void QuadTari::update()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string QuadTari::name() const string QuadTari::name() const
{ {
return "QuadTari (" + myFirstController->name() + "/" + mySecondController->name() + ")"; return "QT(" + myFirstController->name() + "/" + mySecondController->name() + ")";
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -39,45 +39,9 @@ PlusRomsSetupDialog::PlusRomsSetupDialog(OSystem& osystem, DialogContainer& pare
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PlusRomsSetupDialog::loadConfig() void PlusRomsSetupDialog::loadConfig()
{ {
setText(instance().settings().getString("plusroms.nick"), 0); setText(instance().settings().getString("plusroms.nick"));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PlusRomsSetupDialog::saveConfig()
{
instance().settings().setValue("plusroms.nick", getResult(0));
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PlusRomsSetupDialog::handleCommand(CommandSender* sender, int cmd,
int data, int id)
{
bool exit = false;
switch(cmd)
{
case GuiObject::kOKCmd:
case EditableWidget::kAcceptCmd:
saveConfig();
instance().eventHandler().leaveMenuMode();
exit = true;
break;
case kCloseCmd:
instance().eventHandler().leaveMenuMode();
exit = true;
break;
case EditableWidget::kCancelCmd:
break;
default:
InputTextDialog::handleCommand(sender, cmd, data, id);
break;
}
// Make sure there always is an id // Make sure there always is an id
if(exit)
{
if(instance().settings().getString("plusroms.id") == EmptyString) if(instance().settings().getString("plusroms.id") == EmptyString)
{ {
const char* HEX_DIGITS = "0123456789ABCDEF"; const char* HEX_DIGITS = "0123456789ABCDEF";
@ -90,5 +54,35 @@ void PlusRomsSetupDialog::handleCommand(CommandSender* sender, int cmd,
std::string id_str(id_chr, ID_LEN); std::string id_str(id_chr, ID_LEN);
instance().settings().setValue("plusroms.id", id_str); instance().settings().setValue("plusroms.id", id_str);
} }
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PlusRomsSetupDialog::saveConfig()
{
instance().settings().setValue("plusroms.nick", getResult());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PlusRomsSetupDialog::handleCommand(CommandSender* sender, int cmd,
int data, int id)
{
switch(cmd)
{
case GuiObject::kOKCmd:
case EditableWidget::kAcceptCmd:
saveConfig();
instance().eventHandler().leaveMenuMode();
break;
case kCloseCmd:
instance().eventHandler().leaveMenuMode();
break;
case EditableWidget::kCancelCmd:
break;
default:
InputTextDialog::handleCommand(sender, cmd, data, id);
break;
} }
} }

View File

@ -150,6 +150,7 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node)
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); string bsDetected = myProperties.get(PropType::Cart_Type);
bool isPlusCart = false;
size_t size = 0; size_t size = 0;
try try
{ {
@ -168,6 +169,8 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node)
instance().settings()); instance().settings());
if (bsDetected == "AUTO") if (bsDetected == "AUTO")
bsDetected = Bankswitch::typeToName(CartDetector::autodetectType(image, size)); bsDetected = Bankswitch::typeToName(CartDetector::autodetectType(image, size));
isPlusCart = CartDetector::isProbablyPlusROM(image, size);
} }
} }
catch(const runtime_error&) catch(const runtime_error&)
@ -193,6 +196,7 @@ void RomInfoWidget::parseProperties(const FilesystemNode& node)
buf << (std::round(size / float(1_KB))) << "K"; buf << (std::round(size / float(1_KB))) << "K";
} }
myRomInfo.push_back("Type: " + Bankswitch::typeToDesc(Bankswitch::nameToType(bsDetected)) myRomInfo.push_back("Type: " + Bankswitch::typeToDesc(Bankswitch::nameToType(bsDetected))
+ (isPlusCart ? " - PlusROM" : "")
+ buf.str()); + buf.str());
} }
setDirty(); setDirty();