mirror of https://github.com/stella-emu/stella.git
Make all Bankswitch types detectable with specific ROM filename extensions.
Use a map instead of linear search in Bankswitch class.
This commit is contained in:
parent
09b3d980f3
commit
dce16d6f7c
|
@ -26,11 +26,11 @@ string Bankswitch::typeToName(Bankswitch::Type type)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Bankswitch::Type Bankswitch::nameToType(const string& name)
|
||||
{
|
||||
for(int i = 0; i < int(Bankswitch::Type::NumSchemes); ++i)
|
||||
if(BSPF::equalsIgnoreCase(BSList[i].name, name))
|
||||
return Bankswitch::Type(i);
|
||||
auto it = ourNameToTypes.find(name);
|
||||
if(it != ourNameToTypes.end())
|
||||
return it->second;
|
||||
|
||||
return Bankswitch::Type::_AUTO;
|
||||
return Bankswitch::Type::_AUTO;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -141,46 +141,108 @@ Bankswitch::ExtensionMap Bankswitch::ourExtensions = {
|
|||
{ "zip", Bankswitch::Type::_AUTO },
|
||||
{ "cu", Bankswitch::Type::_AUTO },
|
||||
|
||||
// Types from UnoCart and HarmonyCart
|
||||
{ "084", Bankswitch::Type::_0840 },
|
||||
{ "2K", Bankswitch::Type::_2K },
|
||||
{ "3E", Bankswitch::Type::_3E },
|
||||
{ "3EP", Bankswitch::Type::_3EP },
|
||||
{ "3F", Bankswitch::Type::_3F },
|
||||
{ "4A5", Bankswitch::Type::_4A50 },
|
||||
{ "4K", Bankswitch::Type::_4K },
|
||||
{ "4KS", Bankswitch::Type::_4KSC },
|
||||
{ "AR", Bankswitch::Type::_AR },
|
||||
{ "BF", Bankswitch::Type::_BF },
|
||||
{ "BFS", Bankswitch::Type::_BFSC },
|
||||
{ "BUS", Bankswitch::Type::_BUS },
|
||||
{ "CDF", Bankswitch::Type::_CDF },
|
||||
{ "CM", Bankswitch::Type::_CM },
|
||||
{ "CTY", Bankswitch::Type::_CTY },
|
||||
{ "CV", Bankswitch::Type::_CV },
|
||||
{ "CVP", Bankswitch::Type::_CVP },
|
||||
{ "DAS", Bankswitch::Type::_DASH },
|
||||
{ "DF", Bankswitch::Type::_DF },
|
||||
{ "DFS", Bankswitch::Type::_DFSC },
|
||||
{ "DPC", Bankswitch::Type::_DPC },
|
||||
{ "DPP", Bankswitch::Type::_DPCP },
|
||||
{ "E0", Bankswitch::Type::_E0 },
|
||||
{ "E7", Bankswitch::Type::_E7 },
|
||||
{ "E78", Bankswitch::Type::_E78K },
|
||||
{ "EF", Bankswitch::Type::_EF },
|
||||
{ "EFS", Bankswitch::Type::_EFSC },
|
||||
{ "F0", Bankswitch::Type::_F0 },
|
||||
{ "F4", Bankswitch::Type::_F4 },
|
||||
{ "F4S", Bankswitch::Type::_F4SC },
|
||||
{ "F6", Bankswitch::Type::_F6 },
|
||||
{ "F6S", Bankswitch::Type::_F6SC },
|
||||
{ "F8", Bankswitch::Type::_F8 },
|
||||
{ "F8S", Bankswitch::Type::_F8SC },
|
||||
{ "FA", Bankswitch::Type::_FA },
|
||||
{ "FA2", Bankswitch::Type::_FA2 },
|
||||
{ "FE", Bankswitch::Type::_FE },
|
||||
{ "MDM", Bankswitch::Type::_MDM },
|
||||
{ "SB", Bankswitch::Type::_SB },
|
||||
{ "UA", Bankswitch::Type::_UA },
|
||||
{ "WD", Bankswitch::Type::_WD }
|
||||
// All bankswitch types (tose that UnoCart and HarmonyCart support have the same name)
|
||||
{ "084", Bankswitch::Type::_0840 },
|
||||
{ "2N1", Bankswitch::Type::_2IN1 },
|
||||
{ "4N1", Bankswitch::Type::_4IN1 },
|
||||
{ "8N1", Bankswitch::Type::_8IN1 },
|
||||
{ "16N", Bankswitch::Type::_16IN1 },
|
||||
{ "32N", Bankswitch::Type::_32IN1 },
|
||||
{ "64N", Bankswitch::Type::_64IN1 },
|
||||
{ "128", Bankswitch::Type::_128IN1 },
|
||||
{ "2K", Bankswitch::Type::_2K },
|
||||
{ "3E", Bankswitch::Type::_3E },
|
||||
{ "3EP", Bankswitch::Type::_3EP },
|
||||
{ "3F", Bankswitch::Type::_3F },
|
||||
{ "4A5", Bankswitch::Type::_4A50 },
|
||||
{ "4K", Bankswitch::Type::_4K },
|
||||
{ "4KS", Bankswitch::Type::_4KSC },
|
||||
{ "AR", Bankswitch::Type::_AR },
|
||||
{ "BF", Bankswitch::Type::_BF },
|
||||
{ "BFS", Bankswitch::Type::_BFSC },
|
||||
{ "BUS", Bankswitch::Type::_BUS },
|
||||
{ "CDF", Bankswitch::Type::_CDF },
|
||||
{ "CM", Bankswitch::Type::_CM },
|
||||
{ "CTY", Bankswitch::Type::_CTY },
|
||||
{ "CV", Bankswitch::Type::_CV },
|
||||
{ "CVP", Bankswitch::Type::_CVP },
|
||||
{ "DAS", Bankswitch::Type::_DASH },
|
||||
{ "DF", Bankswitch::Type::_DF },
|
||||
{ "DFS", Bankswitch::Type::_DFSC },
|
||||
{ "DPC", Bankswitch::Type::_DPC },
|
||||
{ "DPP", Bankswitch::Type::_DPCP },
|
||||
{ "E0", Bankswitch::Type::_E0 },
|
||||
{ "E7", Bankswitch::Type::_E7 },
|
||||
{ "E78", Bankswitch::Type::_E78K },
|
||||
{ "EF", Bankswitch::Type::_EF },
|
||||
{ "EFS", Bankswitch::Type::_EFSC },
|
||||
{ "F0", Bankswitch::Type::_F0 },
|
||||
{ "F4", Bankswitch::Type::_F4 },
|
||||
{ "F4S", Bankswitch::Type::_F4SC },
|
||||
{ "F6", Bankswitch::Type::_F6 },
|
||||
{ "F6S", Bankswitch::Type::_F6SC },
|
||||
{ "F8", Bankswitch::Type::_F8 },
|
||||
{ "F8S", Bankswitch::Type::_F8SC },
|
||||
{ "FA", Bankswitch::Type::_FA },
|
||||
{ "FA2", Bankswitch::Type::_FA2 },
|
||||
{ "FE", Bankswitch::Type::_FE },
|
||||
{ "MDM", Bankswitch::Type::_MDM },
|
||||
{ "SB", Bankswitch::Type::_SB },
|
||||
{ "UA", Bankswitch::Type::_UA },
|
||||
{ "WD", Bankswitch::Type::_WD },
|
||||
{ "X07", Bankswitch::Type::_X07 }
|
||||
};
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Bankswitch::NameToTypeMap Bankswitch::ourNameToTypes = {
|
||||
{ "AUTO", Bankswitch::Type::_AUTO },
|
||||
{ "0840", Bankswitch::Type::_0840 },
|
||||
{ "2IN1", Bankswitch::Type::_2IN1 },
|
||||
{ "4IN1", Bankswitch::Type::_4IN1 },
|
||||
{ "8IN1", Bankswitch::Type::_8IN1 },
|
||||
{ "16IN1", Bankswitch::Type::_16IN1 },
|
||||
{ "32IN1", Bankswitch::Type::_32IN1 },
|
||||
{ "64IN1", Bankswitch::Type::_64IN1 },
|
||||
{ "128IN1", Bankswitch::Type::_128IN1 },
|
||||
{ "2K", Bankswitch::Type::_2K },
|
||||
{ "3E", Bankswitch::Type::_3E },
|
||||
{ "3E+", Bankswitch::Type::_3EP },
|
||||
{ "3F", Bankswitch::Type::_3F },
|
||||
{ "4A50", Bankswitch::Type::_4A50 },
|
||||
{ "4K", Bankswitch::Type::_4K },
|
||||
{ "4KSC", Bankswitch::Type::_4KSC },
|
||||
{ "AR", Bankswitch::Type::_AR },
|
||||
{ "BF", Bankswitch::Type::_BF },
|
||||
{ "BFSC", Bankswitch::Type::_BFSC },
|
||||
{ "BUS", Bankswitch::Type::_BUS },
|
||||
{ "CDF", Bankswitch::Type::_CDF },
|
||||
{ "CM", Bankswitch::Type::_CM },
|
||||
{ "CTY", Bankswitch::Type::_CTY },
|
||||
{ "CV", Bankswitch::Type::_CV },
|
||||
{ "CV+", Bankswitch::Type::_CVP },
|
||||
{ "DASH", Bankswitch::Type::_DASH },
|
||||
{ "DF", Bankswitch::Type::_DF },
|
||||
{ "DFSC", Bankswitch::Type::_DFSC },
|
||||
{ "DPC", Bankswitch::Type::_DPC },
|
||||
{ "DPC+", Bankswitch::Type::_DPCP },
|
||||
{ "E0", Bankswitch::Type::_E0 },
|
||||
{ "E7", Bankswitch::Type::_E7 },
|
||||
{ "E78K", Bankswitch::Type::_E78K },
|
||||
{ "EF", Bankswitch::Type::_EF },
|
||||
{ "EFSC", Bankswitch::Type::_EFSC },
|
||||
{ "F0", Bankswitch::Type::_F0 },
|
||||
{ "F4", Bankswitch::Type::_F4 },
|
||||
{ "F4SC", Bankswitch::Type::_F4SC },
|
||||
{ "F6", Bankswitch::Type::_F6 },
|
||||
{ "F6SC", Bankswitch::Type::_F6SC },
|
||||
{ "F8", Bankswitch::Type::_F8 },
|
||||
{ "F8SC", Bankswitch::Type::_F8SC },
|
||||
{ "FA", Bankswitch::Type::_FA },
|
||||
{ "FA2", Bankswitch::Type::_FA2 },
|
||||
{ "FE", Bankswitch::Type::_FE },
|
||||
{ "MDM", Bankswitch::Type::_MDM },
|
||||
{ "SB", Bankswitch::Type::_SB },
|
||||
{ "UA", Bankswitch::Type::_UA },
|
||||
{ "WD", Bankswitch::Type::_WD },
|
||||
{ "X07", Bankswitch::Type::_X07 }
|
||||
};
|
||||
|
|
|
@ -91,9 +91,11 @@ class Bankswitch
|
|||
}
|
||||
};
|
||||
using ExtensionMap = std::map<string, Bankswitch::Type, TypeComparator>;
|
||||
|
||||
static ExtensionMap ourExtensions;
|
||||
|
||||
using NameToTypeMap = std::map<string, Bankswitch::Type, TypeComparator>;
|
||||
static NameToTypeMap ourNameToTypes;
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
Bankswitch() = delete;
|
||||
|
|
Loading…
Reference in New Issue