refactored CartDF(SC)Widget and CartEF(SC)Widget classes

This commit is contained in:
thrust26 2020-04-20 21:06:16 +02:00
parent abeac8877e
commit faaf83b4ab
8 changed files with 52 additions and 582 deletions

View File

@ -15,185 +15,25 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================ //============================================================================
#include "Debugger.hxx"
#include "CartDebug.hxx"
#include "CartDFSC.hxx" #include "CartDFSC.hxx"
#include "PopUpWidget.hxx"
#include "CartDFSCWidget.hxx" #include "CartDFSCWidget.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeDFSCWidget::CartridgeDFSCWidget( CartridgeDFSCWidget::CartridgeDFSCWidget(
GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont,
int x, int y, int w, int h, CartridgeDFSC& cart) int x, int y, int w, int h, CartridgeDFSC& cart)
: CartDebugWidget(boss, lfont, nfont, x, y, w, h), : CartEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart)
myCart(cart)
{ {
uInt32 size = 32 * 4096; initialize();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string CartridgeDFSCWidget::description()
{
ostringstream info; ostringstream info;
info << "128K DFSC + RAM, 32 4K banks\n"
<< "128 bytes RAM @ $F000 - $F0FF\n"
<< " $F080 - $F0FF (R), $F000 - $F07F (W)\n"
<< "Startup bank = " << cart.startBank() << "\n";
// Eventually, we should query this from the debugger/disassembler info << "128K DFSC + RAM, 32 4K banks\n";
for(uInt32 i = 0, offset = 0xFFC, spot = 0xFC0; i < 32; ++i, offset += 0x1000) info << CartEnhancedWidget::description();
{
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
start -= start % 0x1000;
info << "Bank " << std::dec << i << " @ $" << Common::Base::HEX4 << (start + 0x100)
<< " - " << "$" << (start + 0xFFF) << " (hotspot = $F" << (spot+i) << ")\n";
}
int xpos = 2, return info.str();
ypos = addBaseInformation(size, "CPUWIZ", info.str()) + myLineHeight;
VariantList items;
VarList::push_back(items, " 0 ($FFC0)");
VarList::push_back(items, " 1 ($FFC1)");
VarList::push_back(items, " 2 ($FFC2)");
VarList::push_back(items, " 3 ($FFC3)");
VarList::push_back(items, " 4 ($FFC4)");
VarList::push_back(items, " 5 ($FFC5)");
VarList::push_back(items, " 6 ($FFC6)");
VarList::push_back(items, " 7 ($FFC7)");
VarList::push_back(items, " 8 ($FFC8)");
VarList::push_back(items, " 9 ($FFC9)");
VarList::push_back(items, "10 ($FFCA)");
VarList::push_back(items, "11 ($FFCB)");
VarList::push_back(items, "12 ($FFCC)");
VarList::push_back(items, "13 ($FFCD)");
VarList::push_back(items, "14 ($FFCE)");
VarList::push_back(items, "15 ($FFCF)");
VarList::push_back(items, "16 ($FFD0)");
VarList::push_back(items, "17 ($FFD1)");
VarList::push_back(items, "18 ($FFD2)");
VarList::push_back(items, "19 ($FFD3)");
VarList::push_back(items, "20 ($FFD4)");
VarList::push_back(items, "21 ($FFD5)");
VarList::push_back(items, "22 ($FFD6)");
VarList::push_back(items, "23 ($FFD7)");
VarList::push_back(items, "24 ($FFD8)");
VarList::push_back(items, "25 ($FFD9)");
VarList::push_back(items, "26 ($FFDA)");
VarList::push_back(items, "27 ($FFDB)");
VarList::push_back(items, "28 ($FFDC)");
VarList::push_back(items, "29 ($FFDD)");
VarList::push_back(items, "30 ($FFDE)");
VarList::push_back(items, "31 ($FFDF)");
myBank =
new PopUpWidget(boss, _font, xpos, ypos-2, _font.getStringWidth("31 ($FFE0)"),
myLineHeight, items, "Set bank ",
0, kBankChanged);
myBank->setTarget(this);
addFocusWidget(myBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeDFSCWidget::saveOldState()
{
myOldState.internalram.clear();
for(uInt32 i = 0; i < internalRamSize(); ++i)
myOldState.internalram.push_back(myCart.myRAM[i]);
myOldState.bank = myCart.getBank();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeDFSCWidget::loadConfig()
{
myBank->setSelectedIndex(myCart.getBank(), myCart.getBank() != myOldState.bank);
CartDebugWidget::loadConfig();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeDFSCWidget::handleCommand(CommandSender* sender,
int cmd, int data, int id)
{
if(cmd == kBankChanged)
{
myCart.unlockBank();
myCart.bank(myBank->getSelected());
myCart.lockBank();
invalidate();
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string CartridgeDFSCWidget::bankState()
{
ostringstream& buf = buffer();
static constexpr std::array<const char*, 32> spot = {
"$FFC0", "$FFC1", "$FFC2", "$FFC3", "$FFC4", "$FFC5", "$FFC6", "$FFC7",
"$FFC8", "$FFC9", "$FFCA", "$FFCB", "$FFCC", "$FFCD", "$FFCE", "$FFCF",
"$FFD0", "$FFD1", "$FFD2", "$FFD3", "$FFD4", "$FFD5", "$FFD6", "$FFE7",
"$FFD8", "$FFD9", "$FFDA", "$FFDB", "$FFDC", "$FFDD", "$FFDE", "$FFDF"
};
buf << "Bank = " << std::dec << myCart.getBank()
<< ", hotspot = " << spot[myCart.getBank()];
return buf.str();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeDFSCWidget::internalRamSize()
{
return 128;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeDFSCWidget::internalRamRPort(int start)
{
return 0xF080 + start;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string CartridgeDFSCWidget::internalRamDescription()
{
ostringstream desc;
desc << "$F000 - $F07F used for Write Access\n"
<< "$F080 - $F0FF used for Read Access";
return desc.str();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const ByteArray& CartridgeDFSCWidget::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& CartridgeDFSCWidget::internalRamCurrent(int start, int count)
{
myRamCurrent.clear();
for(int i = 0; i < count; i++)
myRamCurrent.push_back(myCart.myRAM[start + i]);
return myRamCurrent;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeDFSCWidget::internalRamSetValue(int addr, uInt8 value)
{
myCart.myRAM[addr] = value;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 CartridgeDFSCWidget::internalRamGetValue(int addr)
{
return myCart.myRAM[addr];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string CartridgeDFSCWidget::internalRamLabel(int addr)
{
CartDebug& dbg = instance().debugger().cartDebug();
return dbg.getLabel(addr + 0xF080, false);
} }

View File

@ -19,11 +19,10 @@
#define CARTRIDGEDFSC_WIDGET_HXX #define CARTRIDGEDFSC_WIDGET_HXX
class CartridgeDFSC; class CartridgeDFSC;
class PopUpWidget;
#include "CartDebugWidget.hxx" #include "CartEnhancedWidget.hxx"
class CartridgeDFSCWidget : public CartDebugWidget class CartridgeDFSCWidget : public CartEnhancedWidget
{ {
public: public:
CartridgeDFSCWidget(GuiObject* boss, const GUI::Font& lfont, CartridgeDFSCWidget(GuiObject* boss, const GUI::Font& lfont,
@ -33,35 +32,11 @@ class CartridgeDFSCWidget : public CartDebugWidget
virtual ~CartridgeDFSCWidget() = default; virtual ~CartridgeDFSCWidget() = default;
private: private:
CartridgeDFSC& myCart; string manufacturer() override { return "CPUWIZ"; }
PopUpWidget* myBank{nullptr};
struct CartState { string description() override;
ByteArray internalram;
uInt16 bank{0};
};
CartState myOldState;
enum { kBankChanged = 'bkCH' };
private: 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 // Following constructors and assignment operators not supported
CartridgeDFSCWidget() = delete; CartridgeDFSCWidget() = delete;
CartridgeDFSCWidget(const CartridgeDFSCWidget&) = delete; CartridgeDFSCWidget(const CartridgeDFSCWidget&) = delete;

View File

@ -16,115 +16,24 @@
//============================================================================ //============================================================================
#include "CartDF.hxx" #include "CartDF.hxx"
#include "PopUpWidget.hxx"
#include "CartDFWidget.hxx" #include "CartDFWidget.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeDFWidget::CartridgeDFWidget( CartridgeDFWidget::CartridgeDFWidget(
GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont,
int x, int y, int w, int h, CartridgeDF& cart) int x, int y, int w, int h, CartridgeDF& cart)
: CartDebugWidget(boss, lfont, nfont, x, y, w, h), : CartEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart)
myCart(cart)
{ {
uInt32 size = 32 * 4096; initialize();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string CartridgeDFWidget::description()
{
ostringstream info; ostringstream info;
info << "EF 2 cartridge, 32 4K banks\n"
<< "Startup bank = " << cart.startBank() << "\n";
// Eventually, we should query this from the debugger/disassembler info << "128K DF, 32 4K banks\n";
for(uInt32 i = 0, offset = 0xFFC, spot = 0xFD0; i < 32; ++i, offset += 0x1000) info << CartEnhancedWidget::description();
{
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
start -= start % 0x1000;
info << "Bank " << std::dec << i << " @ $" << Common::Base::HEX4 << start << " - "
<< "$" << (start + 0xFFF) << " (hotspot = $F" << (spot+i) << ")\n";
}
int xpos = 2, return info.str();
ypos = addBaseInformation(size, "CPUWIZ", info.str()) + myLineHeight;
VariantList items;
VarList::push_back(items, " 0 ($FFC0)");
VarList::push_back(items, " 1 ($FFC1)");
VarList::push_back(items, " 2 ($FFC2)");
VarList::push_back(items, " 3 ($FFC3)");
VarList::push_back(items, " 4 ($FFC4)");
VarList::push_back(items, " 5 ($FFC5)");
VarList::push_back(items, " 6 ($FFC6)");
VarList::push_back(items, " 7 ($FFC7)");
VarList::push_back(items, " 8 ($FFC8)");
VarList::push_back(items, " 9 ($FFC9)");
VarList::push_back(items, "10 ($FFCA)");
VarList::push_back(items, "11 ($FFCB)");
VarList::push_back(items, "12 ($FFCC)");
VarList::push_back(items, "13 ($FFCD)");
VarList::push_back(items, "14 ($FFCE)");
VarList::push_back(items, "15 ($FFCF)");
VarList::push_back(items, "16 ($FFD0)");
VarList::push_back(items, "17 ($FFD1)");
VarList::push_back(items, "18 ($FFD2)");
VarList::push_back(items, "19 ($FFD3)");
VarList::push_back(items, "20 ($FFD4)");
VarList::push_back(items, "21 ($FFD5)");
VarList::push_back(items, "22 ($FFD6)");
VarList::push_back(items, "23 ($FFD7)");
VarList::push_back(items, "24 ($FFD8)");
VarList::push_back(items, "25 ($FFD9)");
VarList::push_back(items, "26 ($FFDA)");
VarList::push_back(items, "27 ($FFDB)");
VarList::push_back(items, "28 ($FFDC)");
VarList::push_back(items, "29 ($FFDD)");
VarList::push_back(items, "30 ($FFDE)");
VarList::push_back(items, "31 ($FFDF)");
myBank =
new PopUpWidget(boss, _font, xpos, ypos-2, _font.getStringWidth("31 ($FFDF)"),
myLineHeight, items, "Set bank ",
0, kBankChanged);
myBank->setTarget(this);
addFocusWidget(myBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeDFWidget::loadConfig()
{
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());
myBank->setSelectedIndex(myCart.getBank(), state.bank != oldstate.bank);
CartDebugWidget::loadConfig();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeDFWidget::handleCommand(CommandSender* sender,
int cmd, int data, int id)
{
if(cmd == kBankChanged)
{
myCart.unlockBank();
myCart.bank(myBank->getSelected());
myCart.lockBank();
invalidate();
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string CartridgeDFWidget::bankState()
{
ostringstream& buf = buffer();
static constexpr std::array<const char*, 32> spot = {
"$FFC0", "$FFC1", "$FFC2", "$FFC3", "$FFC4", "$FFC5", "$FFC6", "$FFC7",
"$FFC8", "$FFC9", "$FFCA", "$FFCB", "$FFCC", "$FFCD", "$FFCE", "$FFCF",
"$FFD0", "$FFD1", "$FFD2", "$FFD3", "$FFD4", "$FFD5", "$FFD6", "$FFD7",
"$FFD8", "$FFD9", "$FFDA", "$FFDB", "$FFDC", "$FFDD", "$FFDE", "$FFDF"
};
buf << "Bank = " << std::dec << myCart.getBank()
<< ", hotspot = " << spot[myCart.getBank()];
return buf.str();
} }

View File

@ -19,11 +19,10 @@
#define CARTRIDGEDF_WIDGET_HXX #define CARTRIDGEDF_WIDGET_HXX
class CartridgeDF; class CartridgeDF;
class PopUpWidget;
#include "CartDebugWidget.hxx" #include "CartEnhancedWidget.hxx"
class CartridgeDFWidget : public CartDebugWidget class CartridgeDFWidget : public CartEnhancedWidget
{ {
public: public:
CartridgeDFWidget(GuiObject* boss, const GUI::Font& lfont, CartridgeDFWidget(GuiObject* boss, const GUI::Font& lfont,
@ -33,17 +32,11 @@ class CartridgeDFWidget : public CartDebugWidget
virtual ~CartridgeDFWidget() = default; virtual ~CartridgeDFWidget() = default;
private: private:
CartridgeDF& myCart; string manufacturer() override { return "CPUWIZ"; }
PopUpWidget* myBank{nullptr};
enum { kBankChanged = 'bkCH' }; string description() override;
private: 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 // Following constructors and assignment operators not supported
CartridgeDFWidget() = delete; CartridgeDFWidget() = delete;
CartridgeDFWidget(const CartridgeDFWidget&) = delete; CartridgeDFWidget(const CartridgeDFWidget&) = delete;

View File

@ -15,167 +15,25 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================ //============================================================================
#include "Debugger.hxx"
#include "CartDebug.hxx"
#include "CartEFSC.hxx" #include "CartEFSC.hxx"
#include "PopUpWidget.hxx"
#include "CartEFSCWidget.hxx" #include "CartEFSCWidget.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeEFSCWidget::CartridgeEFSCWidget( CartridgeEFSCWidget::CartridgeEFSCWidget(
GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont,
int x, int y, int w, int h, CartridgeEFSC& cart) int x, int y, int w, int h, CartridgeEFSC& cart)
: CartDebugWidget(boss, lfont, nfont, x, y, w, h), : CartEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart)
myCart(cart)
{ {
uInt32 size = 16 * 4096; initialize();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string CartridgeEFSCWidget::description()
{
ostringstream info; ostringstream info;
info << "64K H. Runner EFSC + RAM, 16 4K banks\n"
<< "128 bytes RAM @ $F000 - $F0FF\n"
<< " $F080 - $F0FF (R), $F000 - $F07F (W)\n"
<< "Startup bank = " << cart.startBank() << "\n";
// Eventually, we should query this from the debugger/disassembler info << "64K H. Runner EFSC + RAM, 16 4K banks\n";
for(uInt32 i = 0, offset = 0xFFC, spot = 0xFE0; i < 16; ++i, offset += 0x1000) info << CartEnhancedWidget::description();
{
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
start -= start % 0x1000;
info << "Bank " << std::dec << i << " @ $" << Common::Base::HEX4 << (start + 0x100)
<< " - " << "$" << (start + 0xFFF) << " (hotspot = $F" << (spot+i) << ")\n";
}
int xpos = 2, return info.str();
ypos = addBaseInformation(size, "Paul Slocum / Homestar Runner",
info.str()) + myLineHeight;
VariantList items;
VarList::push_back(items, " 0 ($FFE0)");
VarList::push_back(items, " 1 ($FFE1)");
VarList::push_back(items, " 2 ($FFE2)");
VarList::push_back(items, " 3 ($FFE3)");
VarList::push_back(items, " 4 ($FFE4)");
VarList::push_back(items, " 5 ($FFE5)");
VarList::push_back(items, " 6 ($FFE6)");
VarList::push_back(items, " 7 ($FFE7)");
VarList::push_back(items, " 8 ($FFE8)");
VarList::push_back(items, " 9 ($FFE9)");
VarList::push_back(items, "10 ($FFEA)");
VarList::push_back(items, "11 ($FFEB)");
VarList::push_back(items, "12 ($FFEC)");
VarList::push_back(items, "13 ($FFED)");
VarList::push_back(items, "14 ($FFEE)");
VarList::push_back(items, "15 ($FFEF)");
myBank =
new PopUpWidget(boss, _font, xpos, ypos-2, _font.getStringWidth("15 ($FFE0)"),
myLineHeight, items, "Set bank ",
0, kBankChanged);
myBank->setTarget(this);
addFocusWidget(myBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeEFSCWidget::saveOldState()
{
myOldState.internalram.clear();
for(uInt32 i = 0; i < internalRamSize(); ++i)
myOldState.internalram.push_back(myCart.myRAM[i]);
myOldState.bank = myCart.getBank();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeEFSCWidget::loadConfig()
{
myBank->setSelectedIndex(myCart.getBank(), myCart.getBank() != myOldState.bank);
CartDebugWidget::loadConfig();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeEFSCWidget::handleCommand(CommandSender* sender,
int cmd, int data, int id)
{
if(cmd == kBankChanged)
{
myCart.unlockBank();
myCart.bank(myBank->getSelected());
myCart.lockBank();
invalidate();
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string CartridgeEFSCWidget::bankState()
{
ostringstream& buf = buffer();
static constexpr std::array<const char*, 16> spot = {
"$FFE0", "$FFE1", "$FFE2", "$FFE3", "$FFE4", "$FFE5", "$FFE6", "$FFE7",
"$FFE8", "$FFE9", "$FFEA", "$FFEB", "$FFEC", "$FFED", "$FFEE", "$FFEF"
};
buf << "Bank = " << std::dec << myCart.getBank()
<< ", hotspot = " << spot[myCart.getBank()];
return buf.str();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeEFSCWidget::internalRamSize()
{
return 128;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeEFSCWidget::internalRamRPort(int start)
{
return 0xF080 + start;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string CartridgeEFSCWidget::internalRamDescription()
{
ostringstream desc;
desc << "$F000 - $F07F used for Write Access\n"
<< "$F080 - $F0FF used for Read Access";
return desc.str();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const ByteArray& CartridgeEFSCWidget::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& CartridgeEFSCWidget::internalRamCurrent(int start, int count)
{
myRamCurrent.clear();
for(int i = 0; i < count; i++)
myRamCurrent.push_back(myCart.myRAM[start + i]);
return myRamCurrent;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeEFSCWidget::internalRamSetValue(int addr, uInt8 value)
{
myCart.myRAM[addr] = value;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt8 CartridgeEFSCWidget::internalRamGetValue(int addr)
{
return myCart.myRAM[addr];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string CartridgeEFSCWidget::internalRamLabel(int addr)
{
CartDebug& dbg = instance().debugger().cartDebug();
return dbg.getLabel(addr + 0xF080, false);
} }

View File

@ -19,11 +19,10 @@
#define CARTRIDGEEFSC_WIDGET_HXX #define CARTRIDGEEFSC_WIDGET_HXX
class CartridgeEFSC; class CartridgeEFSC;
class PopUpWidget;
#include "CartDebugWidget.hxx" #include "CartEnhancedWidget.hxx"
class CartridgeEFSCWidget : public CartDebugWidget class CartridgeEFSCWidget : public CartEnhancedWidget
{ {
public: public:
CartridgeEFSCWidget(GuiObject* boss, const GUI::Font& lfont, CartridgeEFSCWidget(GuiObject* boss, const GUI::Font& lfont,
@ -33,35 +32,11 @@ class CartridgeEFSCWidget : public CartDebugWidget
virtual ~CartridgeEFSCWidget() = default; virtual ~CartridgeEFSCWidget() = default;
private: private:
CartridgeEFSC& myCart; string manufacturer() override { return "Paul Slocum / Homestar Runner"; }
PopUpWidget* myBank{nullptr};
struct CartState { string description() override;
ByteArray internalram;
uInt16 bank{0};
};
CartState myOldState;
enum { kBankChanged = 'bkCH' };
private: 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 // Following constructors and assignment operators not supported
CartridgeEFSCWidget() = delete; CartridgeEFSCWidget() = delete;
CartridgeEFSCWidget(const CartridgeEFSCWidget&) = delete; CartridgeEFSCWidget(const CartridgeEFSCWidget&) = delete;

View File

@ -16,97 +16,24 @@
//============================================================================ //============================================================================
#include "CartEF.hxx" #include "CartEF.hxx"
#include "PopUpWidget.hxx"
#include "CartEFWidget.hxx" #include "CartEFWidget.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeEFWidget::CartridgeEFWidget( CartridgeEFWidget::CartridgeEFWidget(
GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont, GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont,
int x, int y, int w, int h, CartridgeEF& cart) int x, int y, int w, int h, CartridgeEF& cart)
: CartDebugWidget(boss, lfont, nfont, x, y, w, h), : CartEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart)
myCart(cart)
{ {
uInt32 size = 16 * 4096; initialize();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string CartridgeEFWidget::description()
{
ostringstream info; ostringstream info;
info << "64K H. Runner EF cartridge, 16 4K banks\n"
<< "Startup bank = " << cart.startBank() << "\n";
// Eventually, we should query this from the debugger/disassembler info << "64K H. Runner EF cartridge, 16 4K banks\n";
for(uInt32 i = 0, offset = 0xFFC, spot = 0xFE0; i < 16; ++i, offset += 0x1000) info << CartEnhancedWidget::description();
{
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
start -= start % 0x1000;
info << "Bank " << std::dec << i << " @ $" << Common::Base::HEX4 << start << " - "
<< "$" << (start + 0xFFF) << " (hotspot = $F" << (spot+i) << ")\n";
}
int xpos = 2, return info.str();
ypos = addBaseInformation(size, "Paul Slocum / Homestar Runner",
info.str()) + myLineHeight;
VariantList items;
VarList::push_back(items, " 0 ($FFE0)");
VarList::push_back(items, " 1 ($FFE1)");
VarList::push_back(items, " 2 ($FFE2)");
VarList::push_back(items, " 3 ($FFE3)");
VarList::push_back(items, " 4 ($FFE4)");
VarList::push_back(items, " 5 ($FFE5)");
VarList::push_back(items, " 6 ($FFE6)");
VarList::push_back(items, " 7 ($FFE7)");
VarList::push_back(items, " 8 ($FFE8)");
VarList::push_back(items, " 9 ($FFE9)");
VarList::push_back(items, "10 ($FFEA)");
VarList::push_back(items, "11 ($FFEB)");
VarList::push_back(items, "12 ($FFEC)");
VarList::push_back(items, "13 ($FFED)");
VarList::push_back(items, "14 ($FFEE)");
VarList::push_back(items, "15 ($FFEF)");
myBank =
new PopUpWidget(boss, _font, xpos, ypos-2, _font.getStringWidth("15 ($FFE0)"),
myLineHeight, items, "Set bank ",
0, kBankChanged);
myBank->setTarget(this);
addFocusWidget(myBank);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeEFWidget::loadConfig()
{
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());
myBank->setSelectedIndex(myCart.getBank(), state.bank != oldstate.bank);
CartDebugWidget::loadConfig();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeEFWidget::handleCommand(CommandSender* sender,
int cmd, int data, int id)
{
if(cmd == kBankChanged)
{
myCart.unlockBank();
myCart.bank(myBank->getSelected());
myCart.lockBank();
invalidate();
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string CartridgeEFWidget::bankState()
{
ostringstream& buf = buffer();
static constexpr std::array<const char*, 16> spot = {
"$FFE0", "$FFE1", "$FFE2", "$FFE3", "$FFE4", "$FFE5", "$FFE6", "$FFE7",
"$FFE8", "$FFE9", "$FFEA", "$FFEB", "$FFEC", "$FFED", "$FFEE", "$FFEF"
};
buf << "Bank = " << std::dec << myCart.getBank()
<< ", hotspot = " << spot[myCart.getBank()];
return buf.str();
} }

View File

@ -19,11 +19,10 @@
#define CARTRIDGEEF_WIDGET_HXX #define CARTRIDGEEF_WIDGET_HXX
class CartridgeEF; class CartridgeEF;
class PopUpWidget;
#include "CartDebugWidget.hxx" #include "CartEnhancedWidget.hxx"
class CartridgeEFWidget : public CartDebugWidget class CartridgeEFWidget : public CartEnhancedWidget
{ {
public: public:
CartridgeEFWidget(GuiObject* boss, const GUI::Font& lfont, CartridgeEFWidget(GuiObject* boss, const GUI::Font& lfont,
@ -33,17 +32,11 @@ class CartridgeEFWidget : public CartDebugWidget
virtual ~CartridgeEFWidget() = default; virtual ~CartridgeEFWidget() = default;
private: private:
CartridgeEF& myCart; string manufacturer() override { return "Paul Slocum / Homestar Runner"; }
PopUpWidget* myBank{nullptr};
enum { kBankChanged = 'bkCH' }; string description() override;
private: 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 // Following constructors and assignment operators not supported
CartridgeEFWidget() = delete; CartridgeEFWidget() = delete;
CartridgeEFWidget(const CartridgeEFWidget&) = delete; CartridgeEFWidget(const CartridgeEFWidget&) = delete;