diff --git a/src/emucore/CartDetector.cxx b/src/emucore/CartDetector.cxx index 73165d12b..49d797579 100755 --- a/src/emucore/CartDetector.cxx +++ b/src/emucore/CartDetector.cxx @@ -90,6 +90,8 @@ Bankswitch::Type CartDetector::autodetectType(const ByteBuffer& image, size_t si type = Bankswitch::Type::_FC; else if(isProbably03E0(image, size)) type = Bankswitch::Type::_03E0; + else if (isProbablyWF8(image, size)) + type = Bankswitch::Type::_WF8; else type = Bankswitch::Type::_F8; } @@ -826,6 +828,20 @@ bool CartDetector::isProbablyWD(const ByteBuffer& image, size_t size) return searchForBytes(image, size, signature[0], 3); } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartDetector::isProbablyWF8(const ByteBuffer& image, size_t size) +{ + // WF8 cart bankswitching for certain Coleco white lable ROMs, switches to + // - bank 0 by writing D3 = 0 + // - bank 1 by writing D3 = 1 + // into 0xfff8 + static constexpr uInt8 sig[] = { + 0xa9, 0x04, 0x8d, 0xf8, 0xff + }; + + return searchForBytes(image, size, sig, sizeof(sig)); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartDetector::isProbablyX07(const ByteBuffer& image, size_t size) { diff --git a/src/emucore/CartDetector.hxx b/src/emucore/CartDetector.hxx index ff5db3d16..6c471eced 100644 --- a/src/emucore/CartDetector.hxx +++ b/src/emucore/CartDetector.hxx @@ -241,6 +241,11 @@ class CartDetector */ static bool isProbablyWD(const ByteBuffer& image, size_t size); + /** + Returns true if the image is probably a Coleco (white label) WF8 bankswitching cartridge + */ + static bool isProbablyWF8(const ByteBuffer& image, size_t size); + /** Returns true if the image is probably an X07 bankswitching cartridge */ diff --git a/test/roms/bankswitching/WF8/Smurf - Rescue in Gargamel's Castle (WF8).bin b/test/roms/bankswitching/WF8/Smurf - Rescue in Gargamel's Castle (WF8).bin new file mode 100644 index 000000000..5bf4e858e Binary files /dev/null and b/test/roms/bankswitching/WF8/Smurf - Rescue in Gargamel's Castle (WF8).bin differ diff --git a/test/roms/bankswitching/WF8/Zaxxon (WF8).bin b/test/roms/bankswitching/WF8/Zaxxon (WF8).bin new file mode 100644 index 000000000..330cb825f Binary files /dev/null and b/test/roms/bankswitching/WF8/Zaxxon (WF8).bin differ