diff --git a/src/common/Base.hxx b/src/common/Base.hxx index dd92a81a9..5260b1a10 100644 --- a/src/common/Base.hxx +++ b/src/common/Base.hxx @@ -71,6 +71,11 @@ class Base os.flags(myHexflags); return os << std::setw(2) << std::setfill('0'); } + static inline std::ostream& HEX3(std::ostream& os) + { + os.flags(myHexflags); + return os << std::setw(3) << std::setfill('0'); + } static inline std::ostream& HEX4(std::ostream& os) { os.flags(myHexflags); return os << std::setw(4) << std::setfill('0'); diff --git a/src/debugger/gui/AtariVoxWidget.cxx b/src/debugger/gui/AtariVoxWidget.cxx index d3fe6e063..74bdeaf25 100644 --- a/src/debugger/gui/AtariVoxWidget.cxx +++ b/src/debugger/gui/AtariVoxWidget.cxx @@ -44,9 +44,17 @@ void AtariVoxWidget::eraseAll() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool AtariVoxWidget::isPageDetected() +bool AtariVoxWidget::isUseDetected() { AtariVox& avox = static_cast(myController); - return avox.myEEPROM->isPageDetected(); + return avox.myEEPROM->isUseDetected(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool AtariVoxWidget::isPageUsed(int page) +{ + AtariVox& avox = static_cast(myController); + + return avox.myEEPROM->isPageUsed(page); } \ No newline at end of file diff --git a/src/debugger/gui/AtariVoxWidget.hxx b/src/debugger/gui/AtariVoxWidget.hxx index bf5fbaba1..25825a497 100644 --- a/src/debugger/gui/AtariVoxWidget.hxx +++ b/src/debugger/gui/AtariVoxWidget.hxx @@ -31,13 +31,10 @@ class AtariVoxWidget : public FlashWidget private: void loadConfig() override { } - string getName() - { - return "AtariVox"; - } void eraseCurrent(); void eraseAll(); - bool isPageDetected(); + bool isUseDetected(); + bool isPageUsed(int page); // Following constructors and assignment operators not supported AtariVoxWidget() = delete; diff --git a/src/debugger/gui/DrivingWidget.cxx b/src/debugger/gui/DrivingWidget.cxx index 447b4196c..cbfda65bd 100644 --- a/src/debugger/gui/DrivingWidget.cxx +++ b/src/debugger/gui/DrivingWidget.cxx @@ -22,13 +22,13 @@ DrivingWidget::DrivingWidget(GuiObject* boss, const GUI::Font& font, int x, int y, Controller& controller) : ControllerWidget(boss, font, x, y, controller), - myGreyIndex(0) + myGrayIndex(0) { bool leftport = myController.jack() == Controller::Left; const string& label = leftport ? "Left (Driving)" : "Right (Driving)"; const int fontHeight = font.getFontHeight(), - bwidth = font.getStringWidth("Grey code +") + 10, + bwidth = font.getStringWidth("Gray code +") + 10, bheight = font.getLineHeight() + 4; int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Driving)"); StaticTextWidget* t; @@ -37,22 +37,22 @@ DrivingWidget::DrivingWidget(GuiObject* boss, const GUI::Font& font, fontHeight, label, kTextAlignLeft); ypos += t->getHeight() + 20; - myGreyUp = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, - "Grey code +", kGreyUpCmd); - myGreyUp->setTarget(this); + myGrayUp = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, + "Gray code +", kGrayUpCmd); + myGrayUp->setTarget(this); - ypos += myGreyUp->getHeight() + 5; - myGreyDown = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, - "Grey code -", kGreyDownCmd); - myGreyDown->setTarget(this); + ypos += myGrayUp->getHeight() + 5; + myGrayDown = new ButtonWidget(boss, font, xpos, ypos, bwidth, bheight, + "Gray code -", kGrayDownCmd); + myGrayDown->setTarget(this); - xpos += myGreyDown->getWidth() + 10; ypos -= 10; - myGreyValue = new DataGridWidget(boss, font, xpos, ypos, + xpos += myGrayDown->getWidth() + 10; ypos -= 10; + myGrayValue = new DataGridWidget(boss, font, xpos, ypos, 1, 1, 2, 8, Common::Base::F_16); - myGreyValue->setTarget(this); - myGreyValue->setEditable(false); + myGrayValue->setTarget(this); + myGrayValue->setEditable(false); - xpos = x + 30; ypos += myGreyDown->getHeight() + 20; + xpos = x + 30; ypos += myGrayDown->getHeight() + 20; myFire = new CheckboxWidget(boss, font, xpos, ypos, "Fire", kFireCmd); myFire->setTarget(this); } @@ -60,16 +60,16 @@ DrivingWidget::DrivingWidget(GuiObject* boss, const GUI::Font& font, // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void DrivingWidget::loadConfig() { - uInt8 grey = 0; - if(myController.read(Controller::One)) grey += 1; - if(myController.read(Controller::Two)) grey += 2; + uInt8 gray = 0; + if(myController.read(Controller::One)) gray += 1; + if(myController.read(Controller::Two)) gray += 2; - for(myGreyIndex = 0; myGreyIndex < 4; ++myGreyIndex) - if(ourGreyTable[myGreyIndex] == grey) + for(myGrayIndex = 0; myGrayIndex < 4; ++myGrayIndex) + if(ourGrayTable[myGrayIndex] == gray) break; myFire->setState(!myController.read(Controller::Six)); - myGreyValue->setList(0, grey); + myGrayValue->setList(0, gray); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -78,17 +78,17 @@ void DrivingWidget::handleCommand( { switch(cmd) { - case kGreyUpCmd: - myGreyIndex = (myGreyIndex + 1) % 4; - myController.set(Controller::One, (ourGreyTable[myGreyIndex] & 0x1) != 0); - myController.set(Controller::Two, (ourGreyTable[myGreyIndex] & 0x2) != 0); - myGreyValue->setList(0, ourGreyTable[myGreyIndex]); + case kGrayUpCmd: + myGrayIndex = (myGrayIndex + 1) % 4; + myController.set(Controller::One, (ourGrayTable[myGrayIndex] & 0x1) != 0); + myController.set(Controller::Two, (ourGrayTable[myGrayIndex] & 0x2) != 0); + myGrayValue->setList(0, ourGrayTable[myGrayIndex]); break; - case kGreyDownCmd: - myGreyIndex = myGreyIndex == 0 ? 3 : myGreyIndex - 1; - myController.set(Controller::One, (ourGreyTable[myGreyIndex] & 0x1) != 0); - myController.set(Controller::Two, (ourGreyTable[myGreyIndex] & 0x2) != 0); - myGreyValue->setList(0, ourGreyTable[myGreyIndex]); + case kGrayDownCmd: + myGrayIndex = myGrayIndex == 0 ? 3 : myGrayIndex - 1; + myController.set(Controller::One, (ourGrayTable[myGrayIndex] & 0x1) != 0); + myController.set(Controller::Two, (ourGrayTable[myGrayIndex] & 0x2) != 0); + myGrayValue->setList(0, ourGrayTable[myGrayIndex]); break; case kFireCmd: myController.set(Controller::Six, !myFire->getState()); @@ -97,4 +97,4 @@ void DrivingWidget::handleCommand( } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt8 DrivingWidget::ourGreyTable[4] = { 0x03, 0x01, 0x00, 0x02 }; +uInt8 DrivingWidget::ourGrayTable[4] = { 0x03, 0x01, 0x00, 0x02 }; diff --git a/src/debugger/gui/DrivingWidget.hxx b/src/debugger/gui/DrivingWidget.hxx index 202438366..b744bc13e 100644 --- a/src/debugger/gui/DrivingWidget.hxx +++ b/src/debugger/gui/DrivingWidget.hxx @@ -35,17 +35,17 @@ class DrivingWidget : public ControllerWidget private: enum { - kGreyUpCmd = 'DWup', - kGreyDownCmd = 'DWdn', + kGrayUpCmd = 'DWup', + kGrayDownCmd = 'DWdn', kFireCmd = 'DWfr' }; - ButtonWidget *myGreyUp, *myGreyDown; - DataGridWidget* myGreyValue; + ButtonWidget *myGrayUp, *myGrayDown; + DataGridWidget* myGrayValue; CheckboxWidget* myFire; - int myGreyIndex; + int myGrayIndex; - static uInt8 ourGreyTable[4]; + static uInt8 ourGrayTable[4]; private: void loadConfig() override; diff --git a/src/debugger/gui/RiotWidget.cxx b/src/debugger/gui/RiotWidget.cxx index f7d425775..a4d014f3d 100644 --- a/src/debugger/gui/RiotWidget.cxx +++ b/src/debugger/gui/RiotWidget.cxx @@ -35,6 +35,7 @@ #include "KeyboardWidget.hxx" #include "AtariVoxWidget.hxx" #include "SaveKeyWidget.hxx" +#include "AmigaMouseWidget.hxx" #include "RiotWidget.hxx" @@ -437,7 +438,8 @@ ControllerWidget* RiotWidget::addControlWidget(GuiObject* boss, const GUI::Font& switch(controller.type()) { case Controller::AmigaMouse: // TODO - implement this - return new NullControlWidget(boss, font, x, y, controller); + //return new NullControlWidget(boss, font, x, y, controller); + return new AmigaMouseWidget(boss, font, x, y, controller); case Controller::AtariMouse: // TODO - implement this return new NullControlWidget(boss, font, x, y, controller); case Controller::AtariVox: diff --git a/src/debugger/gui/SaveKeyWidget.cxx b/src/debugger/gui/SaveKeyWidget.cxx index 0e505e699..16d462d60 100644 --- a/src/debugger/gui/SaveKeyWidget.cxx +++ b/src/debugger/gui/SaveKeyWidget.cxx @@ -44,9 +44,17 @@ void SaveKeyWidget::eraseAll() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool SaveKeyWidget::isPageDetected() +bool SaveKeyWidget::isUseDetected() { SaveKey& skey = static_cast(myController); - return skey.myEEPROM->isPageDetected(); + return skey.myEEPROM->isUseDetected(); +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool SaveKeyWidget::isPageUsed(int page) +{ + SaveKey& skey = static_cast(myController); + + return skey.myEEPROM->isPageUsed(page); } \ No newline at end of file diff --git a/src/debugger/gui/SaveKeyWidget.hxx b/src/debugger/gui/SaveKeyWidget.hxx index ab35e17b7..53a4dc134 100644 --- a/src/debugger/gui/SaveKeyWidget.hxx +++ b/src/debugger/gui/SaveKeyWidget.hxx @@ -31,13 +31,10 @@ class SaveKeyWidget : public FlashWidget private: void loadConfig() override { } - string getName() - { - return "SaveKey"; - } void eraseCurrent(); void eraseAll(); - bool isPageDetected(); + bool isUseDetected(); + bool isPageUsed(int page); // Following constructors and assignment operators not supported SaveKeyWidget() = delete; diff --git a/src/emucore/AmigaMouse.hxx b/src/emucore/AmigaMouse.hxx index 7ed9d1aca..e706e76fd 100644 --- a/src/emucore/AmigaMouse.hxx +++ b/src/emucore/AmigaMouse.hxx @@ -38,8 +38,8 @@ class AmigaMouse : public PointingDevice protected: uInt8 ioPortA(uInt8 countH, uInt8 countV, uInt8, uInt8) override { - static constexpr uInt32 ourTableH[4] = { 0x00, 0x80, 0xa0, 0x20 }; - static constexpr uInt32 ourTableV[4] = { 0x00, 0x10, 0x50, 0x40 }; + static constexpr uInt32 ourTableH[4] = { 0b0000, 0b1000, 0b1010, 0b0010 }; + static constexpr uInt32 ourTableV[4] = { 0b0000, 0b0001, 0b0101, 0b0100 }; return ourTableH[countH] | ourTableV[countV]; } diff --git a/src/emucore/AtariMouse.hxx b/src/emucore/AtariMouse.hxx index 255ecbb7b..5b6a1402f 100644 --- a/src/emucore/AtariMouse.hxx +++ b/src/emucore/AtariMouse.hxx @@ -38,8 +38,8 @@ class AtariMouse : public PointingDevice protected: uInt8 ioPortA(uInt8 countH, uInt8 countV, uInt8, uInt8) override { - static constexpr uInt32 ourTableH[4] = { 0x00, 0x10, 0x30, 0x20 }; - static constexpr uInt32 ourTableV[4] = { 0x00, 0x80, 0xc0, 0x40 }; + static constexpr uInt32 ourTableH[4] = { 0b0000, 0b0001, 0b0011, 0b0010 }; + static constexpr uInt32 ourTableV[4] = { 0b0000, 0b1000, 0b1100, 0b0100 }; return ourTableH[countH] | ourTableV[countV]; } diff --git a/src/emucore/MT24LC256.cxx b/src/emucore/MT24LC256.cxx index 919195957..ada6e26e2 100644 --- a/src/emucore/MT24LC256.cxx +++ b/src/emucore/MT24LC256.cxx @@ -55,7 +55,7 @@ MT24LC256::MT24LC256(const string& filename, const System& system) myDataFile(filename), myDataFileExists(false), myDataChanged(false), - myPageDetected(false), + myUseDetected(false), jpee_mdat(0), jpee_sdat(0), jpee_mclk(0), @@ -151,7 +151,7 @@ void MT24LC256::systemReset() myCyclesWhenSDASet = myCyclesWhenSCLSet = myCyclesWhenTimerSet = mySystem.cycles(); - myPageDetected = false; + myUseDetected = false; memset(myPageHit, false, sizeof(myPageHit)); } @@ -175,6 +175,15 @@ void MT24LC256::eraseCurrent() } } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +bool MT24LC256::isPageUsed(int page) const +{ + if(page < PAGE_NUM) + return myPageHit[page]; + else + return false; +} + // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void MT24LC256::jpee_init() { @@ -243,7 +252,7 @@ void MT24LC256::jpee_data_stop() for (int i=3; i> 4); + return portA; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/emucore/PointingDevice.hxx b/src/emucore/PointingDevice.hxx index 6a6f5880d..b2a8bdcde 100644 --- a/src/emucore/PointingDevice.hxx +++ b/src/emucore/PointingDevice.hxx @@ -21,6 +21,7 @@ class Controller; class Event; +#include "Control.hxx" #include "bspf.hxx" /** @@ -31,6 +32,8 @@ class Event; */ class PointingDevice : public Controller { + friend class TrackBallWidget; + public: PointingDevice(Jack jack, const Event& event, const System& system, Controller::Type type, diff --git a/src/emucore/TrakBall.hxx b/src/emucore/TrakBall.hxx index ef51b2361..3920b770e 100644 --- a/src/emucore/TrakBall.hxx +++ b/src/emucore/TrakBall.hxx @@ -38,8 +38,10 @@ class TrakBall : public PointingDevice protected: uInt8 ioPortA(uInt8 countH, uInt8 countV, uInt8 left, uInt8 down) override { - static constexpr uInt32 ourTableH[2][2] = {{ 0x00, 0x10 }, { 0x20, 0x30 }}; - static constexpr uInt32 ourTableV[2][2] = {{ 0x40, 0x00 }, { 0xc0, 0x80 }}; + //static constexpr uInt32 ourTableH[2][2] = {{ 0x00, 0x10 }, { 0x20, 0x30 }}; + //static constexpr uInt32 ourTableV[2][2] = {{ 0x40, 0x00 }, { 0xc0, 0x80 }}; + static constexpr uInt32 ourTableH[2][2] = { { 0b00, 0b01 },{ 0b10, 0b11 } }; + static constexpr uInt32 ourTableV[2][2] = { { 0b0100, 0b0000 },{ 0b1100, 0b1000 } }; return ourTableH[countH & 0x01][left] | ourTableV[countV & 0x01][down]; } diff --git a/src/windows/FlashWidget.cxx b/src/windows/FlashWidget.cxx index c7c2d08d3..d93c809b4 100644 --- a/src/windows/FlashWidget.cxx +++ b/src/windows/FlashWidget.cxx @@ -16,6 +16,8 @@ //============================================================================ #include "FlashWidget.hxx" +#include "MT24LC256.hxx" +#include "Base.hxx" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - FlashWidget::FlashWidget(GuiObject* boss, const GUI::Font& font, @@ -31,11 +33,23 @@ void FlashWidget::init(GuiObject* boss, const GUI::Font& font, int x, int y) int xpos = x, ypos = y; bool leftport = myController.jack() == Controller::Left; - new StaticTextWidget(boss, font, xpos, ypos + 2, (leftport ? "Left (" : "Right (") + getName() + ")"); + new StaticTextWidget(boss, font, xpos, ypos + 2, (leftport ? "Left (" : "Right (") + myController.name() + ")"); - ypos += lineHeight + 8; + ypos += lineHeight + 6; - myEEPROMEraseCurrent = new ButtonWidget(boss, font, xpos, ypos, + new StaticTextWidget(boss, ifont, xpos, ypos, "Pages/Ranges used:"); + + ypos += lineHeight + 2; + xpos += 8; + + for(int page = 0; page < MAX_PAGES; page++) + { + myPage[page] = new StaticTextWidget(boss, ifont, xpos, ypos, + page ? " " : "none "); + ypos += lineHeight; + } + + /*myEEPROMEraseCurrent = new ButtonWidget(boss, font, xpos, ypos, "Erase EEPROM range", kEEPROMEraseCurrent); myEEPROMEraseCurrent->setTarget(this); ypos += lineHeight + 8; @@ -54,7 +68,7 @@ void FlashWidget::init(GuiObject* boss, const GUI::Font& font, int x, int y) ypos += iLineHeight; new StaticTextWidget(boss, ifont, xpos, ypos, "all EEPROM data!"); - updateButtonState(); + updateButtonState();*/ } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -71,11 +85,44 @@ void FlashWidget::handleCommand(CommandSender*, int cmd, int, int) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FlashWidget::drawWidget(bool hilite) { - updateButtonState(); + int useCount = 0, startPage = -1; + for(int page = 0; page < MT24LC256::PAGE_NUM; page++) + { + if(isPageUsed(page)/* || page == 0x21 || page == 0x22*/) + { + if (startPage == -1) + startPage = page; + } + else + { + if(startPage != -1) + { + int from = startPage * MT24LC256::PAGE_SIZE; + int to = page * MT24LC256::PAGE_SIZE - 1; + ostringstream label; + + label.str(""); + label << Common::Base::HEX3 << startPage; + + if(page -1 != startPage) + label << "-" << Common::Base::HEX3 << page - 1; + else + label << " "; + label << ": " << Common::Base::HEX4 << from << "-" << Common::Base::HEX4 << to; + + myPage[useCount]->setLabel(label.str()); + + startPage = -1; + if(++useCount == MAX_PAGES) + break; + } + } + } + //updateButtonState(); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void FlashWidget::updateButtonState() { - myEEPROMEraseCurrent->setEnabled(isPageDetected()); + //myEEPROMEraseCurrent->setEnabled(isUseDetected()); } \ No newline at end of file diff --git a/src/windows/FlashWidget.hxx b/src/windows/FlashWidget.hxx index c9b72a037..9124063f6 100644 --- a/src/windows/FlashWidget.hxx +++ b/src/windows/FlashWidget.hxx @@ -43,15 +43,18 @@ private: kEEPROMEraseCurrent = 'eeEC' }; + static constexpr uInt32 MAX_PAGES = 7; + StaticTextWidget* myPage[MAX_PAGES]; + private: void loadConfig() override {} void handleCommand(CommandSender* sender, int cmd, int data, int id) override; void updateButtonState(); - virtual string getName() = 0; virtual void eraseCurrent() = 0; virtual void eraseAll() = 0; - virtual bool isPageDetected() = 0; + virtual bool isUseDetected() = 0; + virtual bool isPageUsed(int page) = 0; // Following constructors and assignment operators not supported FlashWidget() = delete; diff --git a/src/windows/Stella.vcxproj b/src/windows/Stella.vcxproj index 15170444b..625946db4 100644 --- a/src/windows/Stella.vcxproj +++ b/src/windows/Stella.vcxproj @@ -331,6 +331,7 @@ + @@ -491,6 +492,7 @@ + @@ -621,6 +623,7 @@ + @@ -786,6 +789,7 @@ + diff --git a/src/windows/Stella.vcxproj.filters b/src/windows/Stella.vcxproj.filters index a0d426f29..b58f40043 100644 --- a/src/windows/Stella.vcxproj.filters +++ b/src/windows/Stella.vcxproj.filters @@ -843,8 +843,14 @@ Source Files + + Source Files\debugger + - Source Files + Source Files\debugger + + + Source Files\debugger @@ -1725,7 +1731,13 @@ Header Files - Header Files + Header Files\debugger + + + Header Files\debugger + + + Header Files\debugger