Skip to content

Commit

Permalink
added 03E0 bankswitching for Brazilian Parker Bros ROMs (resolves #887)
Browse files Browse the repository at this point in the history
  • Loading branch information
thrust26 committed Aug 5, 2023
1 parent 8d68620 commit cbe0ba8
Show file tree
Hide file tree
Showing 22 changed files with 444 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

* Added limited GameLine Master Module bankswitching support.

* Added 03E0 bankswitching for Brazilian Parker Bros ROMs.

* Added BUS bankswitching support for some older demos.

* Fixed broken 7800 pause key support.
Expand Down
1 change: 1 addition & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4888,6 +4888,7 @@ <h3><a name="EmulationProps"><b>Emulation Properties</b></a></h3>
Note: If 'Filter' is checked, only the bankswitching types matching the ROM size are listed.
<table cellpadding="2" border="1">
<tr><th>&nbsp;Type&nbsp;</th><th>Description</th><th>File Extension<br>(to force type)</th></tr>
<tr><td>03e0 </td><td>8K Brazilian Parker Bros</td><td>.03e, .03e0</td></tr>
<tr><td>0840 </td><td>8K EconoBanking</td><td>.084, .0840</td></tr>
<tr><td>0FA0 </td><td>8K Fotomania</td><td>.0FA, .0FA0</td></tr>
<tr><td>2IN1 &#185;</td><td>4-64K Multicart (2 games)</td><td>.2N1 </td></tr>
Expand Down
74 changes: 74 additions & 0 deletions src/debugger/gui/Cart03E0Widget.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//============================================================================
//
// 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-2023 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 "Cart03E0.hxx"
#include "Cart03E0Widget.hxx"

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge03E0Widget::Cartridge03E0Widget(
GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont,
int x, int y, int w, int h, Cartridge03E0& cart)
: CartridgeEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart)
{
initialize();
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Cartridge03E0Widget::description()
{
ostringstream info;

info << "03E0 cartridge,\n eight 1K banks mapped into four segments\n"
<< CartridgeEnhancedWidget::description();

return info.str();
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Cartridge03E0Widget::romDescription()
{
ostringstream info;

for(int seg = 0; seg < 4; ++seg)
{
const uInt16 segmentOffset = seg << 10; // myCart.myBankShift;

info << "Segment #" << seg << " accessible @ $"
<< Common::Base::HEX4 << (ADDR_BASE | segmentOffset)
<< " - $" << (ADDR_BASE | (segmentOffset + /*myCart.myBankSize - 1*/ 0x3FF)) << ",\n";
if (seg < 3)
info << " Hotspots " << hotspotStr(0, seg, true) << " - " << hotspotStr(7, seg, true) << "\n";
else
info << " Always points to last 1K bank of ROM\n";
}
info << "Startup banks = 4 / 5 / 6 or undetermined";

return info.str();
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Cartridge03E0Widget::hotspotStr(int bank, int segment, bool noBrackets)
{
static constexpr uInt16 hotspots[3] = {0x03E0, 0x03D0, 0x03B0};
ostringstream info;

info << (noBrackets ? "" : "(")
<< "$" << Common::Base::HEX1 << ( hotspots[segment] + bank)
<< (noBrackets ? "" : ")");

return info.str();
}
54 changes: 54 additions & 0 deletions src/debugger/gui/Cart03E0Widget.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
//============================================================================
//
// 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-2023 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 CARTRIDGE03E0_WIDGET_HXX
#define CARTRIDGE03E0_WIDGET_HXX

class Cartridge03E0;

#include "CartEnhancedWidget.hxx"

class Cartridge03E0Widget : public CartridgeEnhancedWidget
{
public:
Cartridge03E0Widget(GuiObject* boss, const GUI::Font& lfont,
const GUI::Font& nfont,
int x, int y, int w, int h,
Cartridge03E0& cart);
~Cartridge03E0Widget() override = default;

private:
string manufacturer() override { return "Parker Brothers (Brazil Pirate)"; }

string description() override;

string romDescription() override;

string hotspotStr(int bank, int segment, bool noBrackets = false) override;

uInt16 bankSegs() override { return 3; }

private:
// Following constructors and assignment operators not supported
Cartridge03E0Widget() = delete;
Cartridge03E0Widget(const Cartridge03E0Widget&) = delete;
Cartridge03E0Widget(Cartridge03E0Widget&&) = delete;
Cartridge03E0Widget& operator=(const Cartridge03E0Widget&) = delete;
Cartridge03E0Widget& operator=(Cartridge03E0Widget&&) = delete;
};

#endif
2 changes: 1 addition & 1 deletion src/debugger/gui/CartEnhancedWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ string CartridgeEnhancedWidget::bankState()

//if(hotspot >= 0x100)
if(hotspot != 0 && myHotspotDelta > 0)
buf << " " << hotspotStr(bank, 0, bankSegs() < 3);
buf << " " << hotspotStr(bank, seg, bankSegs() < 3);
}
}
else
Expand Down
1 change: 1 addition & 0 deletions src/debugger/gui/module.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ 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/Cart0840Widget.o \
src/debugger/gui/Cart0FA0Widget.o \
src/debugger/gui/Cart2KWidget.o \
Expand Down
5 changes: 5 additions & 0 deletions src/emucore/Bankswitch.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ bool Bankswitch::isValidRomName(string_view name, string& ext)
constexpr std::array<Bankswitch::Description, static_cast<uInt32>(Bankswitch::Type::NumSchemes)>
Bankswitch::BSList = {{
{ "AUTO" , "Auto-detect" },
{ "03E0" , "03E0 (8K Braz. Parker Bros)" },
{ "0840" , "0840 (8K EconoBanking)" },
{ "0FA0" , "0FA0 (8K Fotomania)" },
{ "2IN1" , "2in1 Multicart (4-64K)" },
Expand Down Expand Up @@ -138,6 +139,7 @@ Bankswitch::BSList = {{
const std::array<Bankswitch::SizesType, static_cast<uInt32>(Bankswitch::Type::NumSchemes)>
Bankswitch::Sizes = {{
{ Bankswitch::any_KB, Bankswitch::any_KB }, // _AUTO
{ 8_KB, 8_KB }, // _03E0
{ 8_KB, 8_KB }, // _0840
{ 8_KB, 8_KB }, // _0FA0
{ 4_KB, 64_KB }, // _2IN1
Expand Down Expand Up @@ -210,6 +212,8 @@ Bankswitch::ExtensionMap Bankswitch::ourExtensions = {
{ "cu" , Bankswitch::Type::_AUTO },

// All bankswitch types (those that UnoCart and HarmonyCart support have the same name)
{ "03E" , Bankswitch::Type::_03E0 },
{ "03E0" , Bankswitch::Type::_03E0 },
{ "084" , Bankswitch::Type::_0840 },
{ "0840" , Bankswitch::Type::_0840 },
{ "0FA" , Bankswitch::Type::_0FA0 },
Expand Down Expand Up @@ -288,6 +292,7 @@ Bankswitch::ExtensionMap Bankswitch::ourExtensions = {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Bankswitch::NameToTypeMap Bankswitch::ourNameToTypes = {
{ "AUTO" , Bankswitch::Type::_AUTO },
{ "03E0" , Bankswitch::Type::_03E0 },
{ "0840" , Bankswitch::Type::_0840 },
{ "0FA0" , Bankswitch::Type::_0FA0 },
{ "2IN1" , Bankswitch::Type::_2IN1 },
Expand Down
14 changes: 7 additions & 7 deletions src/emucore/Bankswitch.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ class Bankswitch
public:
// Currently supported bankswitch schemes
enum class Type {
_AUTO, _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, _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, _MDM,
_MVC, _SB, _TVBOY, _UA, _UASW, _WD, _WDSW, _X07,
#ifdef CUSTOM_ARM
_CUSTOM,
#endif
Expand Down
113 changes: 113 additions & 0 deletions src/emucore/Cart03E0.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
//============================================================================
//
// 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-2023 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 "System.hxx"
#include "Cart03E0.hxx"

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Cartridge03E0::Cartridge03E0(const ByteBuffer& image, size_t size,
string_view md5, const Settings& settings,
size_t bsSize)
: CartridgeEnhanced(image, size, md5, settings, bsSize)
{
myBankShift = BANK_SHIFT;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge03E0::install(System& system)
{
CartridgeEnhanced::install(system);

// Get the page accessing methods for the hot spots since they overlap
// areas within the TIA we'll need to forward requests to the TIA
myHotSpotPageAccess[0] = mySystem->getPageAccess(0x0380);
myHotSpotPageAccess[1] = mySystem->getPageAccess(0x03c0);

// Set the page accessing methods for the hot spots
const System::PageAccess access(this, System::PageAccessType::READ);
for(uInt16 addr = 0x0380; addr < 0x03FF; addr += System::PAGE_SIZE)
mySystem->setPageAccess(addr, access);
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge03E0::reset()
{
// Setup segments to some default banks
if(randomStartBank())
{
bank(mySystem->randGenerator().next() % 8, 0);
bank(mySystem->randGenerator().next() % 8, 1);
bank(mySystem->randGenerator().next() % 8, 2);
}
else
{
bank(4, 0);
bank(5, 1);
bank(6, 2);
}
myBankChanged = true;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge03E0::checkSwitchBank(uInt16 address, uInt8)
{
bool switched = false;

if((address & 0x10) == 0)
{
bank(address & 0x0007, 0);
switched = true;
}
if((address & 0x20) == 0)
{
bank(address & 0x0007, 1);
switched = true;
}
if((address & 0x40) == 0)
{
bank(address & 0x0007, 2);
switched = true;
}
return switched;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 Cartridge03E0::peek(uInt16 address)
{
checkSwitchBank(address, 0);

// Because of the way we've set up accessing above, we can only
// get here when the addresses are from 0x380 - 0x3FF
const int hotspot = ((address & 0x40) >> 6);
return myHotSpotPageAccess[hotspot].device->peek(address);
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Cartridge03E0::poke(uInt16 address, uInt8 value)
{
// Because of the way accessing is set up, we will may get here by
// doing a write to 0x380 - 0x3FF or cart; we ignore the cart write
if(!(address & 0x1000))
{
checkSwitchBank(address, 0);

const int hotspot = ((address & 0x40) >> 6);
myHotSpotPageAccess[hotspot].device->poke(address, value);
}

return false;
}
Loading

0 comments on commit cbe0ba8

Please sign in to comment.