mirror of https://github.com/stella-emu/stella.git
refactored CartFA(2), CartFC and CartFE widget classes
This commit is contained in:
parent
2e2471db68
commit
20c6998e71
|
@ -31,12 +31,14 @@ CartEnhancedWidget::CartEnhancedWidget(GuiObject* boss, const GUI::Font& lfont,
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CartEnhancedWidget::initialize()
|
||||
int CartEnhancedWidget::initialize()
|
||||
{
|
||||
int ypos = addBaseInformation(size(), manufacturer(), description(), descriptionLines())
|
||||
+ myLineHeight;
|
||||
|
||||
bankSelect(ypos);
|
||||
|
||||
return ypos;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -64,7 +66,7 @@ string CartEnhancedWidget::description()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
int CartEnhancedWidget::descriptionLines()
|
||||
{
|
||||
return 20; // should be enough for almost all types
|
||||
return 18; // should be enough for almost all types
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -101,7 +103,12 @@ string CartEnhancedWidget::romDescription()
|
|||
info << "Bank " << hash << std::dec << bank << " @ $"
|
||||
<< Common::Base::HEX4 << (start + myCart.myRomOffset) << " - $" << (start + 0xFFF);
|
||||
if(myCart.hotspot() != 0)
|
||||
info << " " << hotspotStr(bank, 0, true);
|
||||
{
|
||||
string hs = hotspotStr(bank, 0, true);
|
||||
if(hs.length() > 22)
|
||||
info << "\n ";
|
||||
info << " " << hs;
|
||||
}
|
||||
info << "\n";
|
||||
}
|
||||
info << "Startup bank = #" << std::dec << myCart.startBank() << " or undetermined\n";
|
||||
|
|
|
@ -37,7 +37,7 @@ class CartEnhancedWidget : public CartDebugWidget
|
|||
virtual ~CartEnhancedWidget() = default;
|
||||
|
||||
protected:
|
||||
void initialize();
|
||||
int initialize();
|
||||
|
||||
virtual size_t size();
|
||||
|
||||
|
|
|
@ -15,65 +15,25 @@
|
|||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//============================================================================
|
||||
|
||||
#include "Debugger.hxx"
|
||||
#include "CartDebug.hxx"
|
||||
#include "CartFA2.hxx"
|
||||
#include "PopUpWidget.hxx"
|
||||
#include "CartFA2Widget.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
CartridgeFA2Widget::CartridgeFA2Widget(
|
||||
GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont,
|
||||
int x, int y, int w, int h, CartridgeFA2& cart)
|
||||
: CartDebugWidget(boss, lfont, nfont, x, y, w, h),
|
||||
myCart(cart)
|
||||
: CartEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart)
|
||||
{
|
||||
size_t size = cart.mySize;
|
||||
|
||||
ostringstream info;
|
||||
info << "Modified FA RAM+, six or seven 4K banks\n"
|
||||
<< "256 bytes RAM @ $F000 - $F1FF\n"
|
||||
<< " $F100 - $F1FF (R), $F000 - $F0FF (W)\n"
|
||||
<< "RAM can be loaded/saved to Harmony flash by accessing $FFF4\n"
|
||||
<< "Startup bank = " << cart.startBank() << " or undetermined\n";
|
||||
|
||||
// Eventually, we should query this from the debugger/disassembler
|
||||
for(uInt32 i = 0, offset = 0xFFC, spot = 0xFF5; i < cart.romBankCount();
|
||||
++i, offset += 0x1000)
|
||||
{
|
||||
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
|
||||
start -= start % 0x1000;
|
||||
info << "Bank " << i << " @ $" << Common::Base::HEX4 << (start + 0x200) << " - "
|
||||
<< "$" << (start + 0xFFF) << " (hotspot = $F" << (spot+i) << ")\n";
|
||||
}
|
||||
|
||||
int xpos = 2,
|
||||
ypos = addBaseInformation(size, "Chris D. Walton (Star Castle 2600)",
|
||||
info.str(), 15) + myLineHeight;
|
||||
ypos = initialize();
|
||||
|
||||
VariantList items;
|
||||
VarList::push_back(items, "0 ($FFF5)");
|
||||
VarList::push_back(items, "1 ($FFF6)");
|
||||
VarList::push_back(items, "2 ($FFF7)");
|
||||
VarList::push_back(items, "3 ($FFF8)");
|
||||
VarList::push_back(items, "4 ($FFF9)");
|
||||
VarList::push_back(items, "5 ($FFFA)");
|
||||
if(cart.romBankCount() == 7)
|
||||
VarList::push_back(items, "6 ($FFFB)");
|
||||
|
||||
myBank =
|
||||
new PopUpWidget(boss, _font, xpos, ypos-2, _font.getStringWidth("0 ($FFFx)"),
|
||||
myLineHeight, items, "Set bank ",
|
||||
0, kBankChanged);
|
||||
myBank->setTarget(this);
|
||||
addFocusWidget(myBank);
|
||||
ypos += myLineHeight + 20;
|
||||
ypos += 12;
|
||||
|
||||
const int bwidth = _font.getStringWidth("Erase") + 20;
|
||||
|
||||
StaticTextWidget* t = new StaticTextWidget(boss, _font, xpos, ypos,
|
||||
_font.getStringWidth("Harmony Flash "),
|
||||
myFontHeight, "Harmony Flash ", TextAlign::Left);
|
||||
_font.getStringWidth("Harmony flash memory "),
|
||||
myFontHeight, "Harmony flash memory ", TextAlign::Left);
|
||||
|
||||
xpos += t->getWidth() + 4;
|
||||
myFlashErase =
|
||||
|
@ -98,123 +58,39 @@ CartridgeFA2Widget::CartridgeFA2Widget(
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CartridgeFA2Widget::saveOldState()
|
||||
string CartridgeFA2Widget::description()
|
||||
{
|
||||
myOldState.internalram.clear();
|
||||
ostringstream info;
|
||||
|
||||
for(uInt32 i = 0; i < internalRamSize(); ++i)
|
||||
myOldState.internalram.push_back(myCart.myRAM[i]);
|
||||
info << "Modified FA RAM+, six or seven 4K banks\n";
|
||||
info << "RAM+ can be loaded/saved to Harmony flash memory by accessing $"
|
||||
<< Common::Base::HEX4 << 0xFFF4 << "\n";
|
||||
info << CartEnhancedWidget::description();
|
||||
|
||||
myOldState.bank = myCart.getBank();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CartridgeFA2Widget::loadConfig()
|
||||
{
|
||||
myBank->setSelectedIndex(myCart.getBank(), myCart.getBank() != myOldState.bank);
|
||||
|
||||
CartDebugWidget::loadConfig();
|
||||
return info.str();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CartridgeFA2Widget::handleCommand(CommandSender* sender,
|
||||
int cmd, int data, int id)
|
||||
{
|
||||
CartridgeFA2& cart = dynamic_cast<CartridgeFA2&>(myCart);
|
||||
|
||||
switch(cmd)
|
||||
{
|
||||
case kBankChanged:
|
||||
myCart.unlockBank();
|
||||
myCart.bank(myBank->getSelected());
|
||||
myCart.lockBank();
|
||||
invalidate();
|
||||
break;
|
||||
|
||||
case kFlashErase:
|
||||
myCart.flash(0);
|
||||
cart.flash(0);
|
||||
break;
|
||||
|
||||
case kFlashLoad:
|
||||
myCart.flash(1);
|
||||
cart.flash(1);
|
||||
break;
|
||||
|
||||
case kFlashSave:
|
||||
myCart.flash(2);
|
||||
cart.flash(2);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
CartEnhancedWidget::handleCommand(sender, cmd, data, id);
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string CartridgeFA2Widget::bankState()
|
||||
{
|
||||
ostringstream& buf = buffer();
|
||||
|
||||
static constexpr std::array<const char*, 7> spot = {
|
||||
"$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB"
|
||||
};
|
||||
buf << "Bank = " << std::dec << myCart.getBank()
|
||||
<< ", hotspot = " << spot[myCart.getBank()];
|
||||
|
||||
return buf.str();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 CartridgeFA2Widget::internalRamSize()
|
||||
{
|
||||
return 256;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 CartridgeFA2Widget::internalRamRPort(int start)
|
||||
{
|
||||
return 0xF100 + start;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string CartridgeFA2Widget::internalRamDescription()
|
||||
{
|
||||
ostringstream desc;
|
||||
desc << "$F000 - $F0FF used for Write Access\n"
|
||||
<< "$F100 - $F1FF used for Read Access";
|
||||
|
||||
return desc.str();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const ByteArray& CartridgeFA2Widget::internalRamOld(int start, int count)
|
||||
{
|
||||
myRamOld.clear();
|
||||
for(int i = 0; i < count; i++)
|
||||
myRamOld.push_back(myOldState.internalram[start + i]);
|
||||
return myRamOld;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const ByteArray& CartridgeFA2Widget::internalRamCurrent(int start, int count)
|
||||
{
|
||||
myRamCurrent.clear();
|
||||
for(int i = 0; i < count; i++)
|
||||
myRamCurrent.push_back(myCart.myRAM[start + i]);
|
||||
return myRamCurrent;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CartridgeFA2Widget::internalRamSetValue(int addr, uInt8 value)
|
||||
{
|
||||
myCart.myRAM[addr] = value;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt8 CartridgeFA2Widget::internalRamGetValue(int addr)
|
||||
{
|
||||
return myCart.myRAM[addr];
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string CartridgeFA2Widget::internalRamLabel(int addr)
|
||||
{
|
||||
CartDebug& dbg = instance().debugger().cartDebug();
|
||||
return dbg.getLabel(addr + 0xF100, false);
|
||||
}
|
||||
|
|
|
@ -20,11 +20,10 @@
|
|||
|
||||
class CartridgeFA2;
|
||||
class ButtonWidget;
|
||||
class PopUpWidget;
|
||||
|
||||
#include "CartDebugWidget.hxx"
|
||||
#include "CartEnhancedWidget.hxx"
|
||||
|
||||
class CartridgeFA2Widget : public CartDebugWidget
|
||||
class CartridgeFA2Widget : public CartEnhancedWidget
|
||||
{
|
||||
public:
|
||||
CartridgeFA2Widget(GuiObject* boss, const GUI::Font& lfont,
|
||||
|
@ -34,41 +33,22 @@ class CartridgeFA2Widget : public CartDebugWidget
|
|||
virtual ~CartridgeFA2Widget() = default;
|
||||
|
||||
private:
|
||||
CartridgeFA2& myCart;
|
||||
PopUpWidget* myBank{nullptr};
|
||||
string manufacturer() override { return "Chris D. Walton (Star Castle 2600 Arcade)"; }
|
||||
|
||||
string description() override;
|
||||
|
||||
ButtonWidget *myFlashErase{nullptr}, *myFlashLoad{nullptr}, *myFlashSave{nullptr};
|
||||
|
||||
struct CartState {
|
||||
ByteArray internalram;
|
||||
uInt16 bank{0};
|
||||
};
|
||||
CartState myOldState;
|
||||
|
||||
enum {
|
||||
kBankChanged = 'bkCH',
|
||||
kFlashErase = 'flER',
|
||||
kFlashLoad = 'flLD',
|
||||
kFlashSave = 'flSV'
|
||||
};
|
||||
|
||||
private:
|
||||
void saveOldState() override;
|
||||
void loadConfig() override;
|
||||
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
|
||||
|
||||
string bankState() override;
|
||||
|
||||
// start of functions for Cartridge RAM tab
|
||||
uInt32 internalRamSize() override;
|
||||
uInt32 internalRamRPort(int start) override;
|
||||
string internalRamDescription() override;
|
||||
const ByteArray& internalRamOld(int start, int count) override;
|
||||
const ByteArray& internalRamCurrent(int start, int count) override;
|
||||
void internalRamSetValue(int addr, uInt8 value) override;
|
||||
uInt8 internalRamGetValue(int addr) override;
|
||||
string internalRamLabel(int addr) override;
|
||||
// end of functions for Cartridge RAM tab
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
CartridgeFA2Widget() = delete;
|
||||
CartridgeFA2Widget(const CartridgeFA2Widget&) = delete;
|
||||
|
|
|
@ -15,150 +15,25 @@
|
|||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//============================================================================
|
||||
|
||||
#include "Debugger.hxx"
|
||||
#include "CartDebug.hxx"
|
||||
#include "CartFA.hxx"
|
||||
#include "PopUpWidget.hxx"
|
||||
#include "CartFAWidget.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
CartridgeFAWidget::CartridgeFAWidget(
|
||||
GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont,
|
||||
int x, int y, int w, int h, CartridgeFA& cart)
|
||||
: CartDebugWidget(boss, lfont, nfont, x, y, w, h),
|
||||
myCart(cart)
|
||||
: CartEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart)
|
||||
{
|
||||
uInt16 size = 3 * 4096;
|
||||
initialize();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string CartridgeFAWidget::description()
|
||||
{
|
||||
ostringstream info;
|
||||
info << "CBS RAM+ FA cartridge, three 4K banks\n"
|
||||
<< "256 bytes RAM @ $F000 - $F1FF\n"
|
||||
<< " $F100 - $F1FF (R), $F000 - $F0FF (W)\n"
|
||||
<< "Startup bank = " << cart.startBank() << " or undetermined\n";
|
||||
|
||||
// Eventually, we should query this from the debugger/disassembler
|
||||
for(uInt32 i = 0, offset = 0xFFC, spot = 0xFF8; i < 3; ++i, offset += 0x1000)
|
||||
{
|
||||
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
|
||||
start -= start % 0x1000;
|
||||
info << "Bank " << i << " @ $" << Common::Base::HEX4 << (start + 0x200) << " - "
|
||||
<< "$" << (start + 0xFFF) << " (hotspot = $F" << (spot+i) << ")\n";
|
||||
}
|
||||
info << "CBS RAM+ FA cartridge, three 4K banks\n";
|
||||
info << CartEnhancedWidget::description();
|
||||
|
||||
int xpos = 2,
|
||||
ypos = addBaseInformation(size, "CBS", info.str()) + myLineHeight;
|
||||
|
||||
VariantList items;
|
||||
VarList::push_back(items, "0 ($FFF8)");
|
||||
VarList::push_back(items, "1 ($FFF9)");
|
||||
VarList::push_back(items, "2 ($FFFA)");
|
||||
myBank =
|
||||
new PopUpWidget(boss, _font, xpos, ypos-2, _font.getStringWidth("0 ($FFFx)"),
|
||||
myLineHeight, items, "Set bank ",
|
||||
0, kBankChanged);
|
||||
myBank->setTarget(this);
|
||||
addFocusWidget(myBank);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CartridgeFAWidget::saveOldState()
|
||||
{
|
||||
myOldState.internalram.clear();
|
||||
|
||||
for(uInt32 i = 0; i < internalRamSize(); ++i)
|
||||
myOldState.internalram.push_back(myCart.myRAM[i]);
|
||||
|
||||
myOldState.bank = myCart.getBank();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CartridgeFAWidget::loadConfig()
|
||||
{
|
||||
myBank->setSelectedIndex(myCart.getBank(), myCart.getBank() != myOldState.bank);
|
||||
|
||||
CartDebugWidget::loadConfig();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CartridgeFAWidget::handleCommand(CommandSender* sender,
|
||||
int cmd, int data, int id)
|
||||
{
|
||||
if(cmd == kBankChanged)
|
||||
{
|
||||
myCart.unlockBank();
|
||||
myCart.bank(myBank->getSelected());
|
||||
myCart.lockBank();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string CartridgeFAWidget::bankState()
|
||||
{
|
||||
ostringstream& buf = buffer();
|
||||
|
||||
static constexpr std::array<const char*, 3> spot = { "$FFF8", "$FFF9", "$FFFA" };
|
||||
buf << "Bank = " << std::dec << myCart.getBank()
|
||||
<< ", hotspot = " << spot[myCart.getBank()];
|
||||
|
||||
return buf.str();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 CartridgeFAWidget::internalRamSize()
|
||||
{
|
||||
return 256;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 CartridgeFAWidget::internalRamRPort(int start)
|
||||
{
|
||||
return 0xF100 + start;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string CartridgeFAWidget::internalRamDescription()
|
||||
{
|
||||
ostringstream desc;
|
||||
desc << "$F000 - $F0FF used for Write Access\n"
|
||||
<< "$F100 - $F1FF used for Read Access";
|
||||
|
||||
return desc.str();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const ByteArray& CartridgeFAWidget::internalRamOld(int start, int count)
|
||||
{
|
||||
myRamOld.clear();
|
||||
for(int i = 0; i < count; i++)
|
||||
myRamOld.push_back(myOldState.internalram[start + i]);
|
||||
return myRamOld;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const ByteArray& CartridgeFAWidget::internalRamCurrent(int start, int count)
|
||||
{
|
||||
myRamCurrent.clear();
|
||||
for(int i = 0; i < count; i++)
|
||||
myRamCurrent.push_back(myCart.myRAM[start + i]);
|
||||
return myRamCurrent;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CartridgeFAWidget::internalRamSetValue(int addr, uInt8 value)
|
||||
{
|
||||
myCart.myRAM[addr] = value;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt8 CartridgeFAWidget::internalRamGetValue(int addr)
|
||||
{
|
||||
return myCart.myRAM[addr];
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string CartridgeFAWidget::internalRamLabel(int addr)
|
||||
{
|
||||
CartDebug& dbg = instance().debugger().cartDebug();
|
||||
return dbg.getLabel(addr + 0xF100, false);
|
||||
return info.str();
|
||||
}
|
||||
|
|
|
@ -19,11 +19,10 @@
|
|||
#define CARTRIDGEFA_WIDGET_HXX
|
||||
|
||||
class CartridgeFA;
|
||||
class PopUpWidget;
|
||||
|
||||
#include "CartDebugWidget.hxx"
|
||||
#include "CartEnhancedWidget.hxx"
|
||||
|
||||
class CartridgeFAWidget : public CartDebugWidget
|
||||
class CartridgeFAWidget : public CartEnhancedWidget
|
||||
{
|
||||
public:
|
||||
CartridgeFAWidget(GuiObject* boss, const GUI::Font& lfont,
|
||||
|
@ -33,35 +32,11 @@ class CartridgeFAWidget : public CartDebugWidget
|
|||
virtual ~CartridgeFAWidget() = default;
|
||||
|
||||
private:
|
||||
CartridgeFA& myCart;
|
||||
PopUpWidget* myBank{nullptr};
|
||||
string manufacturer() override { return "CBS"; }
|
||||
|
||||
struct CartState {
|
||||
ByteArray internalram;
|
||||
uInt16 bank{0};
|
||||
};
|
||||
CartState myOldState;
|
||||
|
||||
enum { kBankChanged = 'bkCH' };
|
||||
string description() override;
|
||||
|
||||
private:
|
||||
void saveOldState() override;
|
||||
void loadConfig() override;
|
||||
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
|
||||
|
||||
string bankState() override;
|
||||
|
||||
// start of functions for Cartridge RAM tab
|
||||
uInt32 internalRamSize() override;
|
||||
uInt32 internalRamRPort(int start) override;
|
||||
string internalRamDescription() override;
|
||||
const ByteArray& internalRamOld(int start, int count) override;
|
||||
const ByteArray& internalRamCurrent(int start, int count) override;
|
||||
void internalRamSetValue(int addr, uInt8 value) override;
|
||||
uInt8 internalRamGetValue(int addr) override;
|
||||
string internalRamLabel(int addr) override;
|
||||
// end of functions for Cartridge RAM tab
|
||||
|
||||
// Following constructors and assignment operators not supported
|
||||
CartridgeFAWidget() = delete;
|
||||
CartridgeFAWidget(const CartridgeFAWidget&) = delete;
|
||||
|
|
|
@ -16,80 +16,44 @@
|
|||
//============================================================================
|
||||
|
||||
#include "CartFC.hxx"
|
||||
#include "PopUpWidget.hxx"
|
||||
#include "CartFCWidget.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
CartridgeFCWidget::CartridgeFCWidget(
|
||||
GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont,
|
||||
int x, int y, int w, int h, CartridgeFC& cart)
|
||||
: CartDebugWidget(boss, lfont, nfont, x, y, w, h),
|
||||
myCart(cart)
|
||||
: CartEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart)
|
||||
{
|
||||
uInt16 size = cart.romBankCount() * 4096;
|
||||
initialize();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string CartridgeFCWidget::description()
|
||||
{
|
||||
ostringstream info;
|
||||
info << "FC cartridge, up to eight 4K banks\n"
|
||||
<< "Startup bank = " << cart.startBank() << " or undetermined\n";
|
||||
uInt16 hotspot = myCart.hotspot() | ADDR_BASE;
|
||||
|
||||
// Eventually, we should query this from the debugger/disassembler
|
||||
info << "FC cartridge, up to eight 4K banks\n";
|
||||
info << "Bank selected by hotspots\n"
|
||||
<< " $FFF8 (defines low 2 bits)\n"
|
||||
<< " $FFF9 (defines high bits)\n"
|
||||
<< " $FFFC (triggers bank switch)";
|
||||
<< " $" << Common::Base::HEX4 << hotspot << " (defines low 2 bits)\n"
|
||||
<< " $" << Common::Base::HEX4 << (hotspot + 1) << " (defines high bits)\n"
|
||||
<< " $" << Common::Base::HEX4 << (hotspot + 4) << " (triggers bank switch)\n";
|
||||
|
||||
int xpos = 2,
|
||||
ypos = addBaseInformation(size, "Amiga Corp.", info.str()) + myLineHeight;
|
||||
info << CartEnhancedWidget::description();
|
||||
|
||||
VariantList items;
|
||||
for (uInt16 i = 0; i < cart.romBankCount(); ++i)
|
||||
VarList::push_back(items, Variant(i).toString() +
|
||||
" ($FFF8 = " + Variant(i & 0b11).toString() +
|
||||
"/$FFF9 = " + Variant(i >> 2).toString() +")");
|
||||
|
||||
myBank = new PopUpWidget(boss, _font, xpos, ypos - 2,
|
||||
_font.getStringWidth("7 ($FFF8 = 3/$FFF9 = 1)"),
|
||||
myLineHeight, items, "Set bank ",
|
||||
0, kBankChanged);
|
||||
myBank->setTarget(this);
|
||||
addFocusWidget(myBank);
|
||||
return info.str();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CartridgeFCWidget::loadConfig()
|
||||
string CartridgeFCWidget::hotspotStr(int bank, int, bool prefix)
|
||||
{
|
||||
Debugger& dbg = instance().debugger();
|
||||
CartDebug& cart = dbg.cartDebug();
|
||||
const CartState& state = static_cast<const CartState&>(cart.getState());
|
||||
const CartState& oldstate = static_cast<const CartState&>(cart.getOldState());
|
||||
ostringstream info;
|
||||
uInt16 hotspot = myCart.hotspot() | ADDR_BASE;
|
||||
|
||||
myBank->setSelectedIndex(myCart.getBank(), state.bank != oldstate.bank);
|
||||
info << "(" << (prefix ? "hotspots " : "");
|
||||
info << "$" << Common::Base::HEX4 << hotspot << " = " << (bank & 0b11);
|
||||
info << ", $" << Common::Base::HEX4 << (hotspot + 1) << " = " << (bank >> 2);
|
||||
info << ")";
|
||||
|
||||
CartDebugWidget::loadConfig();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CartridgeFCWidget::handleCommand(CommandSender* sender,
|
||||
int cmd, int data, int id)
|
||||
{
|
||||
if (cmd == kBankChanged)
|
||||
{
|
||||
myCart.unlockBank();
|
||||
myCart.bank(myBank->getSelected());
|
||||
myCart.lockBank();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string CartridgeFCWidget::bankState()
|
||||
{
|
||||
ostringstream& buf = buffer();
|
||||
uInt16 bank = myCart.getBank();
|
||||
|
||||
buf << "Bank = #" << std::dec << bank
|
||||
<< ", hotspots $FFF8 = " << (bank & 0b11)
|
||||
<< "/$FF99 = " << (bank >> 2);
|
||||
|
||||
return buf.str();
|
||||
return info.str();
|
||||
}
|
||||
|
|
|
@ -19,11 +19,10 @@
|
|||
#define CARTRIDGEFC_WIDGET_HXX
|
||||
|
||||
class CartridgeFC;
|
||||
class PopUpWidget;
|
||||
|
||||
#include "CartDebugWidget.hxx"
|
||||
#include "CartEnhancedWidget.hxx"
|
||||
|
||||
class CartridgeFCWidget : public CartDebugWidget
|
||||
class CartridgeFCWidget : public CartEnhancedWidget
|
||||
{
|
||||
public:
|
||||
CartridgeFCWidget(GuiObject* boss, const GUI::Font& lfont,
|
||||
|
@ -33,17 +32,13 @@ class CartridgeFCWidget : public CartDebugWidget
|
|||
virtual ~CartridgeFCWidget() = default;
|
||||
|
||||
private:
|
||||
CartridgeFC& myCart;
|
||||
PopUpWidget* myBank{nullptr};
|
||||
string manufacturer() override { return "Amiga Corp."; }
|
||||
|
||||
enum { kBankChanged = 'bkCH' };
|
||||
string description() override;
|
||||
|
||||
string hotspotStr(int bank, int seg = 0, bool prefix = false) override;
|
||||
|
||||
private:
|
||||
void loadConfig() override;
|
||||
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
|
||||
|
||||
string bankState() override;
|
||||
|
||||
// Following constructors and assignment operators not supported
|
||||
CartridgeFCWidget() = delete;
|
||||
CartridgeFCWidget(const CartridgeFCWidget&) = delete;
|
||||
|
|
|
@ -16,72 +16,36 @@
|
|||
//============================================================================
|
||||
|
||||
#include "CartFE.hxx"
|
||||
#include "PopUpWidget.hxx"
|
||||
#include "CartFEWidget.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
CartridgeFEWidget::CartridgeFEWidget(
|
||||
GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont,
|
||||
int x, int y, int w, int h, CartridgeFE& cart)
|
||||
: CartDebugWidget(boss, lfont, nfont, x, y, w, h),
|
||||
myCart(cart)
|
||||
: CartEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart)
|
||||
{
|
||||
string info =
|
||||
"FE cartridge, two 4K banks\n"
|
||||
"Monitors access to hotspot $01FE, and uses "
|
||||
"upper 3 bits of databus for bank number:\n"
|
||||
"Bank 0 @ $F000 - $FFFF (DATA = 111, D5 = 1)\n"
|
||||
"Bank 1 @ $D000 - $DFFF (DATA = 110, D5 = 0)\n";
|
||||
|
||||
int xpos = 2,
|
||||
ypos = addBaseInformation(2 * 4096, "Activision", info) + myLineHeight;
|
||||
|
||||
VariantList items;
|
||||
VarList::push_back(items, "0 ($01FE, D5=1)");
|
||||
VarList::push_back(items, "1 ($01FE, D5=0)");
|
||||
myBank =
|
||||
new PopUpWidget(boss, _font, xpos, ypos-2,
|
||||
_font.getStringWidth("0 ($01FE, D5=1)"),
|
||||
myLineHeight, items, "Set bank ",
|
||||
0, kBankChanged);
|
||||
myBank->setTarget(this);
|
||||
addFocusWidget(myBank);
|
||||
initialize();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CartridgeFEWidget::loadConfig()
|
||||
string CartridgeFEWidget::description()
|
||||
{
|
||||
Debugger& dbg = instance().debugger();
|
||||
CartDebug& cart = dbg.cartDebug();
|
||||
const CartState& state = static_cast<const CartState&>(cart.getState());
|
||||
const CartState& oldstate = static_cast<const CartState&>(cart.getOldState());
|
||||
ostringstream info;
|
||||
|
||||
myBank->setSelectedIndex(myCart.getBank(), state.bank != oldstate.bank);
|
||||
info << "FE cartridge, two 4K banks\n"
|
||||
<< "Monitors access to hotspot $01FE, and uses "
|
||||
<< "upper 3 bits of databus for bank number:\n";
|
||||
info << CartEnhancedWidget::description();
|
||||
|
||||
CartDebugWidget::loadConfig();
|
||||
return info.str();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CartridgeFEWidget::handleCommand(CommandSender* sender,
|
||||
int cmd, int data, int id)
|
||||
string CartridgeFEWidget::hotspotStr(int bank, int, bool)
|
||||
{
|
||||
if(cmd == kBankChanged)
|
||||
{
|
||||
myCart.unlockBank();
|
||||
myCart.bank(myBank->getSelected());
|
||||
myCart.lockBank();
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string CartridgeFEWidget::bankState()
|
||||
{
|
||||
ostringstream& buf = buffer();
|
||||
|
||||
static constexpr std::array<const char*, 2> range = { "$F000", "$D000" };
|
||||
buf << "Bank = " << std::dec << myCart.getBank()
|
||||
<< ", address range = " << range[myCart.getBank()];
|
||||
|
||||
return buf.str();
|
||||
ostringstream info;
|
||||
|
||||
info << "(DATA = 11" << !bank << ", D5 = " << !bank << ")";
|
||||
|
||||
return info.str();
|
||||
}
|
||||
|
|
|
@ -19,11 +19,10 @@
|
|||
#define CARTRIDGEFE_WIDGET_HXX
|
||||
|
||||
class CartridgeFE;
|
||||
class PopUpWidget;
|
||||
|
||||
#include "CartDebugWidget.hxx"
|
||||
#include "CartEnhancedWidget.hxx"
|
||||
|
||||
class CartridgeFEWidget : public CartDebugWidget
|
||||
class CartridgeFEWidget : public CartEnhancedWidget
|
||||
{
|
||||
public:
|
||||
CartridgeFEWidget(GuiObject* boss, const GUI::Font& lfont,
|
||||
|
@ -33,18 +32,13 @@ class CartridgeFEWidget : public CartDebugWidget
|
|||
virtual ~CartridgeFEWidget() = default;
|
||||
|
||||
private:
|
||||
CartridgeFE& myCart;
|
||||
PopUpWidget* myBank{nullptr};
|
||||
string manufacturer() override { return "Activision"; }
|
||||
|
||||
enum { kBankChanged = 'bkCH' };
|
||||
string description() override;
|
||||
|
||||
string hotspotStr(int bank, int, bool) override;
|
||||
|
||||
private:
|
||||
// No implementation for non-bankswitched ROMs
|
||||
void loadConfig() override;
|
||||
void handleCommand(CommandSender* sender, int cmd, int data, int id) override;
|
||||
|
||||
string bankState() override;
|
||||
|
||||
// Following constructors and assignment operators not supported
|
||||
CartridgeFEWidget() = delete;
|
||||
CartridgeFEWidget(const CartridgeFEWidget&) = delete;
|
||||
|
|
|
@ -110,7 +110,7 @@ class CartridgeFA2 : public CartridgeFA
|
|||
private:
|
||||
bool checkSwitchBank(uInt16 address, uInt8 value = 0) override;
|
||||
|
||||
uInt16 hotspot() const override { return 0x1FF4; }
|
||||
uInt16 hotspot() const override { return 0x1FF5; }
|
||||
|
||||
uInt16 getStartBank() const override { return 0; }
|
||||
|
||||
|
|
|
@ -165,6 +165,8 @@ class CartridgeFE : public CartridgeEnhanced
|
|||
*/
|
||||
bool checkSwitchBank(uInt16 address, uInt8 value) override;
|
||||
|
||||
uInt16 hotspot() const override { return 0x01FE; }
|
||||
|
||||
private:
|
||||
// Whether previous address by peek/poke equals $01FE (hotspot)
|
||||
bool myLastAccessWasFE{false};
|
||||
|
|
Loading…
Reference in New Issue