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,33 +39,43 @@ 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"));
// Make sure there always is an id
if(instance().settings().getString("plusroms.id") == EmptyString)
{
const char* HEX_DIGITS = "0123456789ABCDEF";
char id_chr[ID_LEN];
srand(time(NULL));
for(int i = 0; i < ID_LEN; i++)
id_chr[i] = HEX_DIGITS[(rand() % 16)];
std::string id_str(id_chr, ID_LEN);
instance().settings().setValue("plusroms.id", id_str);
}
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PlusRomsSetupDialog::saveConfig() void PlusRomsSetupDialog::saveConfig()
{ {
instance().settings().setValue("plusroms.nick", getResult(0)); instance().settings().setValue("plusroms.nick", getResult());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PlusRomsSetupDialog::handleCommand(CommandSender* sender, int cmd, void PlusRomsSetupDialog::handleCommand(CommandSender* sender, int cmd,
int data, int id) int data, int id)
{ {
bool exit = false;
switch(cmd) switch(cmd)
{ {
case GuiObject::kOKCmd: case GuiObject::kOKCmd:
case EditableWidget::kAcceptCmd: case EditableWidget::kAcceptCmd:
saveConfig(); saveConfig();
instance().eventHandler().leaveMenuMode(); instance().eventHandler().leaveMenuMode();
exit = true;
break; break;
case kCloseCmd: case kCloseCmd:
instance().eventHandler().leaveMenuMode(); instance().eventHandler().leaveMenuMode();
exit = true;
break; break;
case EditableWidget::kCancelCmd: case EditableWidget::kCancelCmd:
@ -75,20 +85,4 @@ void PlusRomsSetupDialog::handleCommand(CommandSender* sender, int cmd,
InputTextDialog::handleCommand(sender, cmd, data, id); InputTextDialog::handleCommand(sender, cmd, data, id);
break; break;
} }
// Make sure there always is an id
if(exit)
{
if(instance().settings().getString("plusroms.id") == EmptyString)
{
const char* HEX_DIGITS = "0123456789ABCDEF";
char id_chr[ID_LEN];
srand(time(NULL));
for(int i = 0; i < ID_LEN; i++)
id_chr[i] = HEX_DIGITS[(rand() % 16)];
std::string id_str(id_chr, ID_LEN);
instance().settings().setValue("plusroms.id", id_str);
}
}
} }

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();