add 3EX bankswitching type (addresses #619) (TODO: debugger details)

This commit is contained in:
thrust26 2020-04-22 10:08:36 +02:00
parent e502be6048
commit 4a6e14d306
25 changed files with 190 additions and 34 deletions

View File

@ -169,7 +169,7 @@ string Cartridge3EWidget::bankState()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 Cartridge3EWidget::internalRamSize()
{
return 32*1024;
return uInt32(myCart.myRamSize);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -296,7 +296,7 @@ void CartridgeEnhancedWidget::handleCommand(CommandSender* sender,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeEnhancedWidget::internalRamSize()
{
return myCart.myRamSize;
return uInt32(myCart.myRamSize);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -104,7 +104,8 @@ Bankswitch::BSList = {{
{ "64IN1" , "64IN1 Multicart (128/256K)" },
{ "128IN1" , "128IN1 Multicart (256/512K)" },
{ "2K" , "2K (32-2048 bytes Atari)" },
{ "3E" , "3E (32K Tigervision)" },
{ "3E" , "3E (Tigervision, 32K RAM)" },
{ "3EX" , "3EX (Tigervision, 256K RAM)" },
{ "3E+" , "3E+ (TJ modified 3E)" },
{ "3F" , "3F (512K Tigervision)" },
{ "4A50" , "4A50 (64K 4A50 + RAM)" },
@ -178,6 +179,7 @@ Bankswitch::ExtensionMap Bankswitch::ourExtensions = {
{ "128N1" , Bankswitch::Type::_128IN1 },
{ "2K" , Bankswitch::Type::_2K },
{ "3E" , Bankswitch::Type::_3E },
{ "3EX" , Bankswitch::Type::_3EX },
{ "3EP" , Bankswitch::Type::_3EP },
{ "3E+" , Bankswitch::Type::_3EP },
{ "3F" , Bankswitch::Type::_3F },
@ -245,6 +247,7 @@ Bankswitch::NameToTypeMap Bankswitch::ourNameToTypes = {
{ "2K" , Bankswitch::Type::_2K },
{ "3E" , Bankswitch::Type::_3E },
{ "3E+" , Bankswitch::Type::_3EP },
{ "3EX" , Bankswitch::Type::_3EX },
{ "3F" , Bankswitch::Type::_3F },
{ "4A50" , Bankswitch::Type::_4A50 },
{ "4K" , Bankswitch::Type::_4K },

View File

@ -38,14 +38,14 @@ class Bankswitch
public:
// Currently supported bankswitch schemes
enum class Type {
_AUTO, _0840, _2IN1, _4IN1, _8IN1, _16IN1, _32IN1,
_64IN1, _128IN1, _2K, _3E, _3EP, _3F, _4A50,
_4K, _4KSC, _AR, _BF, _BFSC, _BUS, _CDF,
_CM, _CTY, _CV, _DF, _DFSC, _DPC, _DPCP,
_E0, _E7, _E78K, _EF, _EFSC, _F0, _F4,
_F4SC, _F6, _F6SC, _F8, _F8SC, _FA, _FA2,
_FC, _FE, _MDM, _SB, _UA, _UASW, _WD,
_WDSW, _X07,
_AUTO, _0840, _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, _E78K, _EF, _EFSC, _F0,
_F4, _F4SC, _F6, _F6SC, _F8, _F8SC, _FA,
_FA2, _FC, _FE, _MDM, _SB, _UA, _UASW,
_WD, _WDSW, _X07,
#ifdef CUSTOM_ARM
_CUSTOM,
#endif

View File

@ -116,15 +116,15 @@ class Cartridge3E : public CartridgeEnhanced
private:
bool checkSwitchBank(uInt16 address, uInt8 value) override;
private:
protected:
// log(ROM bank segment size) / log(2)
static constexpr uInt16 BANK_SHIFT = 11; // = 2K = 0x0800
// The size of extra RAM in ROM address space
// The number of RAM banks
static constexpr uInt16 RAM_BANKS = 32;
// RAM size
static constexpr uInt16 RAM_SIZE = RAM_BANKS << (BANK_SHIFT - 1); // = 32K = 0x4000;
static constexpr size_t RAM_SIZE = RAM_BANKS << (BANK_SHIFT - 1); // = 32K = 0x8000;
// Write port for extra RAM is at high address
static constexpr bool RAM_HIGH_WP = true;

View File

@ -165,7 +165,7 @@ class Cartridge3EPlus: public CartridgeEnhanced
static constexpr uInt16 RAM_BANKS = 64;
// RAM size
static constexpr uInt16 RAM_SIZE = RAM_BANKS << (BANK_SHIFT - 1); // = 32K = 0x4000;
static constexpr size_t RAM_SIZE = RAM_BANKS << (BANK_SHIFT - 1); // = 32K = 0x4000;
// Write port for extra RAM is at high address
static constexpr bool RAM_HIGH_WP = true;

27
src/emucore/Cart3EX.cxx Normal file
View File

@ -0,0 +1,27 @@
//============================================================================
//
// 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-2020 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 "Cart3EX.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge3EX::Cartridge3EX(const ByteBuffer& image, size_t size,
const string& md5, const Settings& settings)
: Cartridge3E(image, size, md5, settings)
{
myRamSize = RAM_SIZE;
myRamBankCount = RAM_BANKS;
}

87
src/emucore/Cart3EX.hxx Normal file
View File

@ -0,0 +1,87 @@
//============================================================================
//
// 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-2020 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 CARTRIDGE3EX_HXX
#define CARTRIDGE3EX_HXX
class System;
#include "Cart3E.hxx"
#ifdef DEBUGGER_SUPPORT
//#include "Cart3EXWidget.hxx"
#endif
/**
This is an enhanced version of 3E which supports up to 256KB RAM.
@author Thomas Jentzsch
*/
class Cartridge3EX : public Cartridge3E
{
//friend class Cartridge3EXWidget;
public:
/**
Create a new cartridge using the specified image and size
@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)
*/
Cartridge3EX(const ByteBuffer& image, size_t size, const string& md5,
const Settings& settings);
virtual ~Cartridge3EX() = default;
public:
/**
Get a descriptor for the device name (used in error checking).
@return The name of the object
*/
string name() const override { return "Cartridge3EX"; }
#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 Cartridge3EXWidget(boss, lfont, nfont, x, y, w, h, *this);
//}
#endif
private:
// The number of RAM banks
static constexpr uInt16 RAM_BANKS = 256;
// RAM size
static constexpr size_t RAM_SIZE = RAM_BANKS << (BANK_SHIFT - 1); // = 256K = 0x40000;
private:
// Following constructors and assignment operators not supported
Cartridge3EX() = delete;
Cartridge3EX(const Cartridge3EX&) = delete;
Cartridge3EX(Cartridge3EX&&) = delete;
Cartridge3EX& operator=(const Cartridge3EX&) = delete;
Cartridge3EX& operator=(Cartridge3EX&&) = delete;
};
#endif

View File

@ -72,7 +72,7 @@ class Cartridge4KSC : public Cartridge4K
private:
// RAM size
static constexpr uInt16 RAM_SIZE = 0x80;
static constexpr size_t RAM_SIZE = 0x80;
private:
// Following constructors and assignment operators not supported

View File

@ -74,7 +74,7 @@ class CartridgeBFSC : public CartridgeBF
private:
// RAM size
static constexpr uInt16 RAM_SIZE = 0x80;
static constexpr uInt32 RAM_SIZE = 0x80;
private:
// Following constructors and assignment operators not supported

View File

@ -89,7 +89,7 @@ class CartridgeCV : public CartridgeEnhanced
static constexpr uInt16 BANK_SHIFT = 11; // 2K
// RAM size
static constexpr uInt16 RAM_SIZE = 0x400; // 1K
static constexpr uInt32 RAM_SIZE = 0x400; // 1K
// Write port for extra RAM is at high address
static constexpr bool RAM_HIGH_WP = true;

View File

@ -72,7 +72,7 @@ class CartridgeDFSC : public CartridgeDF
private:
// RAM size
static constexpr uInt16 RAM_SIZE = 0x80;
static constexpr size_t RAM_SIZE = 0x80;
private:
// Following constructors and assignment operators not supported

View File

@ -20,6 +20,7 @@
#include "Cart0840.hxx"
#include "Cart2K.hxx"
#include "Cart3E.hxx"
#include "Cart3EX.hxx"
#include "Cart3EPlus.hxx"
#include "Cart3F.hxx"
#include "Cart4A50.hxx"
@ -250,6 +251,8 @@ CartDetector::createFromImage(const ByteBuffer& image, size_t size, Bankswitch::
return make_unique<Cartridge2K>(image, size, md5, settings);
case Bankswitch::Type::_3E:
return make_unique<Cartridge3E>(image, size, md5, settings);
case Bankswitch::Type::_3EX:
return make_unique<Cartridge3EX>(image, size, md5, settings);
case Bankswitch::Type::_3EP:
return make_unique<Cartridge3EPlus>(image, size, md5, settings);
case Bankswitch::Type::_3F:
@ -380,6 +383,8 @@ Bankswitch::Type CartDetector::autodetectType(const ByteBuffer& image, size_t si
type = Bankswitch::Type::_4K;
else if(isProbablyE0(image, size))
type = Bankswitch::Type::_E0;
else if(isProbably3EX(image, size))
type = Bankswitch::Type::_3EX;
else if(isProbably3E(image, size))
type = Bankswitch::Type::_3E;
else if(isProbably3F(image, size))
@ -419,6 +424,8 @@ Bankswitch::Type CartDetector::autodetectType(const ByteBuffer& image, size_t si
type = Bankswitch::Type::_E7;
else if (isProbablyFC(image, size))
type = Bankswitch::Type::_FC;
else if(isProbably3EX(image, size))
type = Bankswitch::Type::_3EX;
else if(isProbably3E(image, size))
type = Bankswitch::Type::_3E;
/* no known 16K 3F ROMS
@ -445,6 +452,8 @@ Bankswitch::Type CartDetector::autodetectType(const ByteBuffer& image, size_t si
type = Bankswitch::Type::_CTY;
else if(isProbablySC(image, size))
type = Bankswitch::Type::_F4SC;
else if(isProbably3EX(image, size))
type = Bankswitch::Type::_3EX;
else if(isProbably3E(image, size))
type = Bankswitch::Type::_3E;
else if(isProbably3F(image, size))
@ -471,7 +480,9 @@ Bankswitch::Type CartDetector::autodetectType(const ByteBuffer& image, size_t si
}
else if(size == 64_KB)
{
if(isProbably3E(image, size))
if(isProbably3EX(image, size))
type = Bankswitch::Type::_3EX;
else if(isProbably3E(image, size))
type = Bankswitch::Type::_3E;
else if(isProbably3F(image, size))
type = Bankswitch::Type::_3F;
@ -486,7 +497,9 @@ Bankswitch::Type CartDetector::autodetectType(const ByteBuffer& image, size_t si
}
else if(size == 128_KB)
{
if(isProbably3E(image, size))
if(isProbably3EX(image, size))
type = Bankswitch::Type::_3EX;
else if(isProbably3E(image, size))
type = Bankswitch::Type::_3E;
else if(isProbablyDF(image, size, type))
; // type has been set directly in the function
@ -499,7 +512,9 @@ Bankswitch::Type CartDetector::autodetectType(const ByteBuffer& image, size_t si
}
else if(size == 256_KB)
{
if(isProbably3E(image, size))
if(isProbably3EX(image, size))
type = Bankswitch::Type::_3EX;
else if(isProbably3E(image, size))
type = Bankswitch::Type::_3E;
else if(isProbablyBF(image, size, type))
; // type has been set directly in the function
@ -510,7 +525,9 @@ Bankswitch::Type CartDetector::autodetectType(const ByteBuffer& image, size_t si
}
else // what else can we do?
{
if(isProbably3E(image, size))
if(isProbably3EX(image, size))
type = Bankswitch::Type::_3EX;
else if(isProbably3E(image, size))
type = Bankswitch::Type::_3E;
else if(isProbably3F(image, size))
type = Bankswitch::Type::_3F;
@ -632,6 +649,14 @@ bool CartDetector::isProbably3E(const ByteBuffer& image, size_t size)
&& searchForBytes(image.get(), size, signature2, 2, 2);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartDetector::isProbably3EX(const ByteBuffer& image, size_t size)
{
// 3EX cart have at least 2 occurrences of the string "3EX"
uInt8 _3EX[] = { '3', 'E', 'X'};
return searchForBytes(image.get(), size, _3EX, 3, 2);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CartDetector::isProbably3EPlus(const ByteBuffer& image, size_t size)
{

View File

@ -130,6 +130,11 @@ class CartDetector
*/
static bool isProbably3E(const ByteBuffer& image, size_t size);
/**
Returns true if the image is probably a 3EX bankswitching cartridge
*/
static bool isProbably3EX(const ByteBuffer& image, size_t size);
/**
Returns true if the image is probably a 3E+ bankswitching cartridge
*/

View File

@ -76,7 +76,7 @@ class CartridgeEFSC : public CartridgeEF
private:
// RAM size
static constexpr uInt16 RAM_SIZE = 0x80;
static constexpr size_t RAM_SIZE = 0x80;
private:
// Following constructors and assignment operators not supported

View File

@ -35,13 +35,13 @@ CartridgeEnhanced::CartridgeEnhanced(const ByteBuffer& image, size_t size,
void CartridgeEnhanced::install(System& system)
{
// limit banked RAM size to the size of one RAM bank
uInt16 ramSize = myRamBankCount > 0 ? 1 << (myBankShift - 1) : myRamSize;
uInt32 ramSize = myRamBankCount > 0 ? 1 << (myBankShift - 1) : uInt32(myRamSize);
// calculate bank switching and RAM sizes and masks
myBankSize = 1 << myBankShift; // e.g. = 2 ^ 12 = 4K = 0x1000
myBankMask = myBankSize - 1; // e.g. = 0x0FFF
myBankSegs = 1 << (MAX_BANK_SHIFT - myBankShift); // e.g. = 1
myRomOffset = myRamBankCount > 0 ? 0 : myRamSize * 2;
myRomOffset = myRamBankCount > 0 ? 0 : uInt32(myRamSize) * 2;
myRamMask = ramSize - 1; // e.g. = 0xFFFF (doesn't matter for RAM size 0)
myWriteOffset = myRamWpHigh ? ramSize : 0; // e.g. = 0x0000
myReadOffset = myRamWpHigh ? 0 : ramSize; // e.g. = 0x0080

View File

@ -183,7 +183,7 @@ class CartridgeEnhanced : public Cartridge
protected:
// The extra RAM size
uInt16 myRamSize{RAM_SIZE}; // default 0
size_t myRamSize{RAM_SIZE}; // default 0
// The number of RAM banks
uInt16 myRamBankCount{RAM_BANKS}; // default 0
@ -246,9 +246,9 @@ class CartridgeEnhanced : public Cartridge
static constexpr uInt16 BANK_SHIFT = 12; // default = 4K
// The size of extra RAM in ROM address space
static constexpr uInt16 RAM_SIZE = 0; // default = none
static constexpr size_t RAM_SIZE = 0; // default = none
// The size of extra RAM in ROM address space
// The number of RAM banks
static constexpr uInt16 RAM_BANKS = 0;
// Write port for extra RAM is at low address by default

View File

@ -69,7 +69,7 @@ class CartridgeF4SC : public CartridgeF4
private:
// RAM size
static constexpr uInt16 RAM_SIZE = 0x80;
static constexpr size_t RAM_SIZE = 0x80;
// RAM mask
static constexpr uInt16 RAM_MASK = RAM_SIZE - 1;

View File

@ -69,7 +69,7 @@ class CartridgeF6SC : public CartridgeF6
private:
// RAM size
static constexpr uInt16 RAM_SIZE = 0x80;
static constexpr size_t RAM_SIZE = 0x80;
// RAM mask
static constexpr uInt16 RAM_MASK = RAM_SIZE - 1;

View File

@ -69,7 +69,7 @@ class CartridgeF8SC : public CartridgeF8
private:
// RAM size
static constexpr uInt16 RAM_SIZE = 0x80;
static constexpr size_t RAM_SIZE = 0x80;
private:
// Following constructors and assignment operators not supported

View File

@ -79,7 +79,7 @@ class CartridgeFA : public CartridgeEnhanced
private:
// RAM size
static constexpr uInt16 RAM_SIZE = 0x100;
static constexpr size_t RAM_SIZE = 0x100;
private:
// Following constructors and assignment operators not supported

View File

@ -176,7 +176,7 @@ class CartridgeWD : public CartridgeEnhanced
static constexpr uInt16 BANK_SHIFT = 10; // = 1K = 0x0400
// RAM size
static constexpr uInt16 RAM_SIZE = 0x40;
static constexpr size_t RAM_SIZE = 0x40;
// Write port for extra RAM is at low address by default
static constexpr bool RAM_HIGH_WP = true;

View File

@ -11,6 +11,7 @@ MODULE_OBJS := \
src/emucore/Cart2K.o \
src/emucore/Cart3E.o \
src/emucore/Cart3EPlus.o \
src/emucore/Cart3EX.o \
src/emucore/Cart3F.o \
src/emucore/Cart4A50.o \
src/emucore/Cart4K.o \

View File

@ -711,6 +711,7 @@
</ClCompile>
<ClCompile Include="..\emucore\Bankswitch.cxx" />
<ClCompile Include="..\emucore\Cart3EPlus.cxx" />
<ClCompile Include="..\emucore\Cart3EX.cxx" />
<ClCompile Include="..\emucore\Cart4KSC.cxx" />
<ClCompile Include="..\emucore\CartEnhanced.cxx" />
<ClCompile Include="..\emucore\CartBF.cxx" />
@ -1727,6 +1728,7 @@
<ClInclude Include="..\emucore\Bankswitch.hxx" />
<ClInclude Include="..\emucore\BSType.hxx" />
<ClInclude Include="..\emucore\Cart3EPlus.hxx" />
<ClInclude Include="..\emucore\Cart3EX.hxx" />
<ClInclude Include="..\emucore\Cart4KSC.hxx" />
<ClInclude Include="..\emucore\CartEnhanced.hxx" />
<ClInclude Include="..\emucore\CartBF.hxx" />

View File

@ -999,6 +999,9 @@
<ClCompile Include="..\debugger\gui\CartEnhancedWidget.cxx">
<Filter>Source Files\debugger</Filter>
</ClCompile>
<ClCompile Include="..\emucore\Cart3EX.cxx">
<Filter>Source Files\emucore</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\common\bspf.hxx">
@ -2051,6 +2054,9 @@
<ClInclude Include="..\debugger\gui\CartEnhancedWidget.hxx">
<Filter>Header Files\debugger</Filter>
</ClInclude>
<ClInclude Include="..\emucore\Cart3EX.hxx">
<Filter>Header Files\emucore</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="stella.ico">