From bd757e7d2f055ed7f536a544b83706726b3896a6 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Wed, 5 Jun 2024 15:27:41 +0200 Subject: [PATCH] Added JANE bankswitching (for Tarzan prototype) --- Changes.txt | 4 ++ docs/index.html | 1 + src/debugger/gui/CartJANEWidget.cxx | 52 ++++++++++++++++ src/debugger/gui/CartJANEWidget.hxx | 50 ++++++++++++++++ src/debugger/gui/module.mk | 11 ++-- src/emucore/Bankswitch.cxx | 5 ++ src/emucore/Bankswitch.hxx | 16 ++--- src/emucore/CartCreator.cxx | 2 + src/emucore/CartDetector.cxx | 18 ++++-- src/emucore/CartDetector.hxx | 5 ++ src/emucore/CartJANE.cxx | 58 ++++++++++++++++++ src/emucore/CartJANE.hxx | 86 +++++++++++++++++++++++++++ src/emucore/module.mk | 1 + src/os/windows/Stella.vcxproj | 4 ++ src/os/windows/Stella.vcxproj.filters | 15 ++++- 15 files changed, 308 insertions(+), 20 deletions(-) create mode 100644 src/debugger/gui/CartJANEWidget.cxx create mode 100644 src/debugger/gui/CartJANEWidget.hxx create mode 100644 src/emucore/CartJANE.cxx create mode 100644 src/emucore/CartJANE.hxx diff --git a/Changes.txt b/Changes.txt index a89b30d1a..69e54fcd4 100644 --- a/Changes.txt +++ b/Changes.txt @@ -50,6 +50,10 @@ * Added 03E0 bankswitching for Brazilian Parker Bros ROMs. + * Added WF8 bankswitching used by some certain Coleco white carts + + * Added JANE bankswitching used by Coleco's Tarzan prototype + * Added BUS bankswitching support for some older demos. * Fixed broken 7800 pause key support. diff --git a/docs/index.html b/docs/index.html index f172bcbd9..030ebfb43 100644 --- a/docs/index.html +++ b/docs/index.html @@ -5071,6 +5071,7 @@ Ms Pac-Man (Stella extended codes): FC Amiga Power Play Aracde 16/32K .FC FE 8K Activision (aka SCABS).FE GL ²4 or 6K GameLine Master Module.GL + JANE 16K Coleco (Tarzan) .JAN, .JANE MDM Menu Driven Megacart .MDM MVC Movie Cart.MVC SB 128-256K SUPERbanking .SB diff --git a/src/debugger/gui/CartJANEWidget.cxx b/src/debugger/gui/CartJANEWidget.cxx new file mode 100644 index 000000000..52dd406b0 --- /dev/null +++ b/src/debugger/gui/CartJANEWidget.cxx @@ -0,0 +1,52 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony +// and the Stella Team +// +// See the file "License.txt" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +//============================================================================ + +#include "CartJANE.hxx" +#include "CartJANEWidget.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +CartridgeJANEWidget::CartridgeJANEWidget( + GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, + int x, int y, int w, int h, CartridgeJANE& cart) + : CartridgeEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart) +{ + initialize(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string CartridgeJANEWidget::description() +{ + ostringstream info; + + info << "Tarzan cartridge, four 4K banks\n" + << CartridgeEnhancedWidget::description(); + + return info.str(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +string CartridgeJANEWidget::hotspotStr(int bank, int, bool prefix) +{ + ostringstream info; + const uInt16 hotspot = myCart.hotspot() | ADDR_BASE; + + info << (prefix ? "(hotspot " : "(") + << "$" << Common::Base::HEX1 << (hotspot + (bank < 2 ? bank : bank + 6)) + << (prefix ? ")" : ")"); + + return info.str(); +} diff --git a/src/debugger/gui/CartJANEWidget.hxx b/src/debugger/gui/CartJANEWidget.hxx new file mode 100644 index 000000000..b281f8bd9 --- /dev/null +++ b/src/debugger/gui/CartJANEWidget.hxx @@ -0,0 +1,50 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony +// and the Stella Team +// +// See the file "License.txt" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +//============================================================================ + +#ifndef CARTRIDGEJANE_WIDGET_HXX +#define CARTRIDGEJANE_WIDGET_HXX + +class CartridgeJANE; + +#include "CartEnhancedWidget.hxx" + +class CartridgeJANEWidget : public CartridgeEnhancedWidget +{ + public: + CartridgeJANEWidget(GuiObject* boss, const GUI::Font& lfont, + const GUI::Font& nfont, + int x, int y, int w, int h, + CartridgeJANE& cart); + ~CartridgeJANEWidget() override = default; + + private: + string manufacturer() override { return "Coleco"; } + + string description() override; + + string hotspotStr(int bank, int seg = 0, bool prefix = false) override; + + private: + // Following constructors and assignment operators not supported + CartridgeJANEWidget() = delete; + CartridgeJANEWidget(const CartridgeJANEWidget&) = delete; + CartridgeJANEWidget(CartridgeJANEWidget&&) = delete; + CartridgeJANEWidget& operator=(const CartridgeJANEWidget&) = delete; + CartridgeJANEWidget& operator=(CartridgeJANEWidget&&) = delete; +}; + +#endif diff --git a/src/debugger/gui/module.mk b/src/debugger/gui/module.mk index 2e02f0181..d52f9ecbe 100644 --- a/src/debugger/gui/module.mk +++ b/src/debugger/gui/module.mk @@ -6,9 +6,9 @@ MODULE_OBJS := \ src/debugger/gui/AtariVoxWidget.o \ src/debugger/gui/AudioWidget.o \ src/debugger/gui/BoosterWidget.o \ - src/debugger/gui/Cart03E0Widget.o \ + src/debugger/gui/Cart03E0Widget.o \ src/debugger/gui/Cart0840Widget.o \ - src/debugger/gui/Cart0FA0Widget.o \ + src/debugger/gui/Cart0FA0Widget.o \ src/debugger/gui/Cart2KWidget.o \ src/debugger/gui/Cart3EPlusWidget.o \ src/debugger/gui/Cart3EWidget.o \ @@ -47,7 +47,8 @@ MODULE_OBJS := \ src/debugger/gui/CartFAWidget.o \ src/debugger/gui/CartFCWidget.o \ src/debugger/gui/CartFEWidget.o \ - src/debugger/gui/CartGLWidget.o \ + src/debugger/gui/CartGLWidget.o \ + src/debugger/gui/CartJANEWidget.o \ src/debugger/gui/CartMDMWidget.o \ src/debugger/gui/CartRamWidget.o \ src/debugger/gui/CartSBWidget.o \ @@ -59,14 +60,14 @@ MODULE_OBJS := \ src/debugger/gui/CartDebugWidget.o \ src/debugger/gui/CpuWidget.o \ src/debugger/gui/DataGridOpsWidget.o \ - src/debugger/gui/DataGridRamWidget.o \ + src/debugger/gui/DataGridRamWidget.o \ src/debugger/gui/DataGridWidget.o \ src/debugger/gui/DebuggerDialog.o \ src/debugger/gui/DelayQueueWidget.o \ src/debugger/gui/DrivingWidget.o \ src/debugger/gui/FlashWidget.o \ src/debugger/gui/GenesisWidget.o \ - src/debugger/gui/Joy2BPlusWidget.o \ + src/debugger/gui/Joy2BPlusWidget.o \ src/debugger/gui/JoystickWidget.o \ src/debugger/gui/KeyboardWidget.o \ src/debugger/gui/PaddleWidget.o \ diff --git a/src/emucore/Bankswitch.cxx b/src/emucore/Bankswitch.cxx index 4fd27cee3..b5c0da75f 100644 --- a/src/emucore/Bankswitch.cxx +++ b/src/emucore/Bankswitch.cxx @@ -121,6 +121,7 @@ Bankswitch::BSList = {{ { "FC" , "FC (32K Amiga)" }, { "FE" , "FE (8K Activision)" }, { "GL" , "GL (GameLine Master Module)" }, + { "JANE" , "JANE (16K Tarzan prototype)" }, { "MDM" , "MDM (Menu Driven Megacart)" }, { "MVC" , "MVC (Movie Cart)" }, { "SB" , "SB (128-256K SUPERbank)" }, @@ -186,6 +187,7 @@ Bankswitch::Sizes = {{ { 32_KB, 32_KB }, // _FC { 8_KB, 8_KB }, // _FE { 4_KB, 6_KB }, // _GL + { 16_KB, 16_KB }, // _JANE { 8_KB, Bankswitch::any_KB }, // _MDM { 1024_KB, Bankswitch::any_KB }, // _MVC { 128_KB, 256_KB }, // _SB @@ -279,6 +281,8 @@ Bankswitch::ExtensionMap Bankswitch::ourExtensions = { { "FC" , Bankswitch::Type::_FC }, { "FE" , Bankswitch::Type::_FE }, { "GL" , Bankswitch::Type::_GL }, + { "JAN" , Bankswitch::Type::_JANE }, + { "JANE" , Bankswitch::Type::_JANE }, { "MDM" , Bankswitch::Type::_MDM }, { "MVC" , Bankswitch::Type::_MVC }, { "SB" , Bankswitch::Type::_SB }, @@ -341,6 +345,7 @@ Bankswitch::NameToTypeMap Bankswitch::ourNameToTypes = { { "FC" , Bankswitch::Type::_FC }, { "FE" , Bankswitch::Type::_FE }, { "GL" , Bankswitch::Type::_GL }, + { "JANE" , Bankswitch::Type::_JANE }, { "MDM" , Bankswitch::Type::_MDM }, { "MVC" , Bankswitch::Type::_MVC }, { "SB" , Bankswitch::Type::_SB }, diff --git a/src/emucore/Bankswitch.hxx b/src/emucore/Bankswitch.hxx index 2da2c5397..45427410e 100644 --- a/src/emucore/Bankswitch.hxx +++ b/src/emucore/Bankswitch.hxx @@ -38,14 +38,14 @@ class Bankswitch public: // Currently supported bankswitch schemes enum class Type { - _AUTO, _03E0, _0840, _0FA0, _2IN1, _4IN1, _8IN1, _16IN1, - _32IN1, _64IN1, _128IN1, _2K, _3E, _3EX, _3EP, _3F, - _4A50, _4K, _4KSC, _AR, _BF, _BFSC, _BUS, _CDF, - _CM, _CTY, _CV, _DF, _DFSC, _DPC, _DPCP, _E0, - _E7, _EF, _EFSC, _F0, _F4, _F4SC, _F6, _F6SC, - _F8, _F8SC, _FA, _FA2, _FC, _FE, _GL, _MDM, - _MVC, _SB, _TVBOY, _UA, _UASW, _WD, _WDSW, _WF8, - _X07, + _AUTO, _03E0, _0840, _0FA0, _2IN1, _4IN1, _8IN1, _16IN1, + _32IN1, _64IN1, _128IN1, _2K, _3E, _3EX, _3EP, _3F, + _4A50, _4K, _4KSC, _AR, _BF, _BFSC, _BUS, _CDF, + _CM, _CTY, _CV, _DF, _DFSC, _DPC, _DPCP, _E0, + _E7, _EF, _EFSC, _F0, _F4, _F4SC, _F6, _F6SC, + _F8, _F8SC, _FA, _FA2, _FC, _FE, _GL, _JANE, + _MDM, _MVC, _SB, _TVBOY, _UA, _UASW, _WD, _WDSW, + _WF8, _X07, #ifdef CUSTOM_ARM _CUSTOM, #endif diff --git a/src/emucore/CartCreator.cxx b/src/emucore/CartCreator.cxx index 4cd591c22..df6180c04 100644 --- a/src/emucore/CartCreator.cxx +++ b/src/emucore/CartCreator.cxx @@ -56,6 +56,7 @@ #include "CartFC.hxx" #include "CartFE.hxx" #include "CartGL.hxx" +#include "CartJANE.hxx" #include "CartMDM.hxx" #include "CartMVC.hxx" #include "CartSB.hxx" @@ -273,6 +274,7 @@ CartCreator::createFromImage(const ByteBuffer& image, size_t size, case _FC: return make_unique(image, size, md5, settings); case _FE: return make_unique(image, size, md5, settings, size); case _GL: return make_unique(image, size, md5, settings); + case _JANE: return make_unique(image, size, md5, settings); case _MDM: return make_unique(image, size, md5, settings); case _UA: return make_unique(image, size, md5, settings); case _UASW: return make_unique(image, size, md5, settings, true); diff --git a/src/emucore/CartDetector.cxx b/src/emucore/CartDetector.cxx index 73165d12b..dfff762c2 100755 --- a/src/emucore/CartDetector.cxx +++ b/src/emucore/CartDetector.cxx @@ -110,20 +110,22 @@ Bankswitch::Type CartDetector::autodetectType(const ByteBuffer& image, size_t si } else if(size == 16_KB) { - if(isProbablySC(image, size)) + if (isProbablySC(image, size)) type = Bankswitch::Type::_F6SC; - else if(isProbablyE7(image, size)) + else if (isProbablyE7(image, size)) type = Bankswitch::Type::_E7; else if (isProbablyFC(image, size)) type = Bankswitch::Type::_FC; - else if(isProbably3EX(image, size)) + else if (isProbably3EX(image, size)) type = Bankswitch::Type::_3EX; - else if(isProbably3E(image, size)) + else if (isProbably3E(image, size)) type = Bankswitch::Type::_3E; /* no known 16K 3F ROMS else if(isProbably3F(image, size)) type = Bankswitch::Type::_3F; */ + else if (isProbablyJANE(image, size)) + type = Bankswitch::Type::_JANE; else type = Bankswitch::Type::_F6; } @@ -724,6 +726,14 @@ bool CartDetector::isProbablyFE(const ByteBuffer& image, size_t size) return false; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartDetector::isProbablyJANE(const ByteBuffer& image, size_t size) +{ + static constexpr uInt8 signature[] = { 0xad, 0xf1, 0xff, 0x60 }; // LDA $0CB8 + + return searchForBytes(image, size, signature, sizeof(signature)); +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bool CartDetector::isProbablyGL(const ByteBuffer& image, size_t size) { diff --git a/src/emucore/CartDetector.hxx b/src/emucore/CartDetector.hxx index ff5db3d16..47cc1cc69 100644 --- a/src/emucore/CartDetector.hxx +++ b/src/emucore/CartDetector.hxx @@ -206,6 +206,11 @@ class CartDetector */ static bool isProbablyFE(const ByteBuffer& image, size_t size); + /** + Returns true if the image is probably a JANE cartridge (Tarzan) + */ + static bool isProbablyJANE(const ByteBuffer& image, size_t size); + /** Returns true if the image is probably a GameLine cartridge */ diff --git a/src/emucore/CartJANE.cxx b/src/emucore/CartJANE.cxx new file mode 100644 index 000000000..35d436187 --- /dev/null +++ b/src/emucore/CartJANE.cxx @@ -0,0 +1,58 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony +// and the Stella Team +// +// See the file "License.txt" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +//============================================================================ + +#include "CartJANE.hxx" + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +CartridgeJANE::CartridgeJANE(const ByteBuffer& image, size_t size, + string_view md5, const Settings& settings, + size_t bsSize) + : CartridgeEnhanced(image, size, md5, settings, bsSize) +{ +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool CartridgeJANE::checkSwitchBank(uInt16 address, uInt8) +{ + // Switch banks if necessary + switch (address) + { + case 0x1FF0: + // Set the current bank to the 1st 4k bank + bank(0); + return true; + + case 0x1FF1: + // Set the current bank to the 2nd 4k bank + bank(1); + return true; + + case 0x1FF8: + // Set the current bank to the 3rd 4k bank + bank(2); + return true; + + case 0x1FF9: + // Set the current bank to the 4th 4k bank + bank(3); + return true; + + default: + break; + } + return false; +} diff --git a/src/emucore/CartJANE.hxx b/src/emucore/CartJANE.hxx new file mode 100644 index 000000000..dbc48e0cc --- /dev/null +++ b/src/emucore/CartJANE.hxx @@ -0,0 +1,86 @@ +//============================================================================ +// +// SSSS tt lll lll +// SS SS tt ll ll +// SS tttttt eeee ll ll aaaa +// SSSS tt ee ee ll ll aa +// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" +// SS SS tt ee ll ll aa aa +// SSSS ttt eeeee llll llll aaaaa +// +// Copyright (c) 1995-2024 by Bradford W. Mott, Stephen Anthony +// and the Stella Team +// +// See the file "License.txt" for information on usage and redistribution of +// this file, and for a DISCLAIMER OF ALL WARRANTIES. +//============================================================================ + +#ifndef CARTRIDGEJANE_HXX +#define CARTRIDGEJANE_HXX + +#include "CartEnhanced.hxx" +#ifdef DEBUGGER_SUPPORT +#include "CartJANEWidget.hxx" +#endif + +/** + Cartridge class used for the Tarzan prototype. There are four 4K banks, + accessible by read at $1FF0/1/8/9. + + @author Thomas Jentzsch +*/ +class CartridgeJANE : public CartridgeEnhanced +{ + friend class CartridgeJANEWidget; + +public: + /** + Create a new cartridge using the specified image + + @param image Pointer to the ROM image + @param size The size of the ROM image + @param md5 The md5sum of the ROM image + @param settings A reference to the various settings (read-only) + @param bsSize The size specified by the bankswitching scheme + */ + CartridgeJANE(const ByteBuffer& image, size_t size, string_view md5, + const Settings& settings, size_t bsSize = 16_KB); + ~CartridgeJANE() override = default; + +public: + /** + Get a descriptor for the device name (used in error checking). + + @return The name of the object + */ + string name() const override { return "CartridgeJANE"; } + +#ifdef DEBUGGER_SUPPORT + /** + Get debugger widget responsible for accessing the inner workings + of the cart. + */ + CartDebugWidget* debugWidget(GuiObject* boss, const GUI::Font& lfont, + const GUI::Font& nfont, int x, int y, int w, int h) override + { + return new CartridgeJANEWidget(boss, lfont, nfont, x, y, w, h, *this); + } +#endif + +private: + bool checkSwitchBank(uInt16 address, uInt8 value) override; + + uInt16 hotspot() const override { return 0x1FF0; } + + uInt16 getStartBank() const override { return 1; } + +private: + // Following constructors and assignment operators not supported + CartridgeJANE() = delete; + CartridgeJANE(const CartridgeJANE&) = delete; + CartridgeJANE(CartridgeJANE&&) = delete; + CartridgeJANE& operator=(const CartridgeJANE&) = delete; + CartridgeJANE& operator=(CartridgeJANE&&) = delete; +}; + +#endif diff --git a/src/emucore/module.mk b/src/emucore/module.mk index eec76bdbd..534ebdf58 100644 --- a/src/emucore/module.mk +++ b/src/emucore/module.mk @@ -48,6 +48,7 @@ MODULE_OBJS := \ src/emucore/CartFC.o \ src/emucore/CartFE.o \ src/emucore/CartGL.o \ + src/emucore/CartJANE.o \ src/emucore/CartMDM.o \ src/emucore/CartMVC.o \ src/emucore/CartSB.o \ diff --git a/src/os/windows/Stella.vcxproj b/src/os/windows/Stella.vcxproj index 170d18b3c..bbae9af79 100755 --- a/src/os/windows/Stella.vcxproj +++ b/src/os/windows/Stella.vcxproj @@ -586,6 +586,7 @@ true + true @@ -681,6 +682,7 @@ + @@ -1546,6 +1548,7 @@ true + true @@ -1645,6 +1648,7 @@ + diff --git a/src/os/windows/Stella.vcxproj.filters b/src/os/windows/Stella.vcxproj.filters index 36e2eff2f..7e7f17ec2 100644 --- a/src/os/windows/Stella.vcxproj.filters +++ b/src/os/windows/Stella.vcxproj.filters @@ -1230,6 +1230,12 @@ Source Files\debugger\gui + + Source Files\emucore + + + Source Files\debugger\gui + @@ -2489,15 +2495,18 @@ Header Files\os - - Header Files\common - Header Files\emucore Header Files\debugger\gui + + Header Files\emucore + + + Header Files\debugger\gui +