diff --git a/docs/index.html b/docs/index.html index 3998489af..a6d56c954 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2498,6 +2498,11 @@ Same as using -bs. + +
-startbank <bank>
+ Set "Cartridge.StartBank" property. + +
-channels <Mono|Stereo>
Set "Cartridge.Sound" property. diff --git a/src/emucore/CartDetector.hxx b/src/emucore/CartDetector.hxx index 2c2c3bd90..f11f94da7 100644 --- a/src/emucore/CartDetector.hxx +++ b/src/emucore/CartDetector.hxx @@ -49,6 +49,16 @@ class CartDetector const ByteBuffer& image, uInt32 size, string& md5, const string& dtype, Settings& settings); + /** + Try to auto-detect the bankswitching type of the cartridge + + @param image A pointer to the ROM image + @param size The size of the ROM image + + @return The "best guess" for the cartridge type + */ + static Bankswitch::Type autodetectType(const ByteBuffer& image, uInt32 size); + private: /** Create a cartridge from a multi-cart image pointer; internally this @@ -84,16 +94,6 @@ class CartDetector createFromImage(const ByteBuffer& image, uInt32 size, Bankswitch::Type type, const string& md5, Settings& settings); - /** - Try to auto-detect the bankswitching type of the cartridge - - @param image A pointer to the ROM image - @param size The size of the ROM image - - @return The "best guess" for the cartridge type - */ - static Bankswitch::Type autodetectType(const ByteBuffer& image, uInt32 size); - /** Search the image for the specified byte signature diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index df15cfdab..9006a2ae5 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -538,6 +538,7 @@ unique_ptr OSystem::openConsole(const FilesystemNode& romfile, string& CMDLINE_PROPS_UPDATE("bs", PropType::Cart_Type); CMDLINE_PROPS_UPDATE("type", PropType::Cart_Type); + CMDLINE_PROPS_UPDATE("startbank", PropType::Cart_StartBank); // Now create the cartridge string cartmd5 = md5; diff --git a/src/emucore/Settings.cxx b/src/emucore/Settings.cxx index 3d1747322..ce9c160a0 100644 --- a/src/emucore/Settings.cxx +++ b/src/emucore/Settings.cxx @@ -532,6 +532,7 @@ void Settings::usage() const << endl << " -bs Sets the 'Cartridge.Type' (bankswitch) property\n" << " -type Same as using -bs\n" + << " -startbank Sets the ROM's startup bank\n" << " -channels Sets the 'Cartridge.Sound' property\n" << " -ld Sets the 'Console.LeftDifficulty' property\n" << " -rd Sets the 'Console.RightDifficulty' property\n" diff --git a/src/gui/GameInfoDialog.cxx b/src/gui/GameInfoDialog.cxx index 543355864..285007388 100644 --- a/src/gui/GameInfoDialog.cxx +++ b/src/gui/GameInfoDialog.cxx @@ -25,6 +25,7 @@ #include "RadioButtonWidget.hxx" #include "Launcher.hxx" #include "OSystem.hxx" +#include "CartDetector.hxx" #include "ControllerDetector.hxx" #include "PopUpWidget.hxx" #include "Props.hxx" @@ -373,19 +374,36 @@ void GameInfoDialog::loadConfig() // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void GameInfoDialog::loadEmulationProperties(const Properties& props) { - myBSType->setSelected(props.get(PropType::Cart_Type), "AUTO"); + string bsDetected = ""; - if(instance().hasConsole() && myBSType->getSelectedTag().toString() == "AUTO") + myBSType->setSelected(props.get(PropType::Cart_Type), "AUTO"); + if(myBSType->getSelectedTag().toString() == "AUTO") { - string bs = instance().console().about().BankSwitch; - size_t pos = bs.find_first_of('*'); - // remove '*': - if(pos != string::npos) - bs = bs.substr(0, pos) + bs.substr(pos + 1); - myTypeDetected->setLabel(bs + "detected"); + if(instance().hasConsole()) + { + string bs = instance().console().about().BankSwitch; + size_t pos = bs.find_first_of('*'); + // remove '*': + if(pos != string::npos) + bs = bs.substr(0, pos) + bs.substr(pos + 1); + bsDetected = bs + "detected"; + } + else + { + const FilesystemNode& node = FilesystemNode(instance().launcher().selectedRom()); + ByteBuffer image; + string md5 = props.get(PropType::Cart_MD5); + uInt32 size = 0; + + // try to load the image for auto detection + if(!instance().hasConsole() && + node.exists() && !node.isDirectory() && (image = instance().openROM(node, md5, size)) != nullptr) + { + bsDetected = Bankswitch::typeToName(CartDetector::autodetectType(image, size)) + " detected"; + } + } } - else - myTypeDetected->setLabel(""); + myTypeDetected->setLabel(bsDetected); // Start bank VariantList items; @@ -454,13 +472,14 @@ void GameInfoDialog::loadControllerProperties(const Properties& props) ByteBuffer image; string md5 = props.get(PropType::Cart_MD5); uInt32 size = 0; - const FilesystemNode& node = FilesystemNode(instance().launcher().selectedRom()); // try to load the image for auto detection - if(!instance().hasConsole() && - node.exists() && !node.isDirectory() && (image = instance().openROM(node, md5, size)) != nullptr) - autoDetect = true; + if(!instance().hasConsole()) + { + const FilesystemNode& node = FilesystemNode(instance().launcher().selectedRom()); + autoDetect = node.exists() && !node.isDirectory() && (image = instance().openROM(node, md5, size)) != nullptr; + } string label = ""; string controller = props.get(PropType::Controller_Left);