From 7374b24ff84a18c43259fa99ba014720e9a0b5c0 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Mon, 10 Feb 2020 11:22:31 +0100 Subject: [PATCH] consider GUI_SUPPORT, rename into HighScoresManager, value formatting --- src/common/HighScoreManager.cxx | 317 ----------------------------- src/common/HighScoreManager.hxx | 95 --------- src/common/module.mk | 2 +- src/emucore/EventHandler.cxx | 6 +- src/emucore/OSystem.cxx | 10 +- src/emucore/OSystem.hxx | 12 +- src/gui/GameInfoDialog.cxx | 40 ++-- src/gui/GameInfoDialog.hxx | 11 +- src/windows/Stella.vcxproj | 4 +- src/windows/Stella.vcxproj.filters | 4 +- 10 files changed, 54 insertions(+), 447 deletions(-) delete mode 100644 src/common/HighScoreManager.cxx delete mode 100644 src/common/HighScoreManager.hxx diff --git a/src/common/HighScoreManager.cxx b/src/common/HighScoreManager.cxx deleted file mode 100644 index ba4f04a5c..000000000 --- a/src/common/HighScoreManager.cxx +++ /dev/null @@ -1,317 +0,0 @@ -//============================================================================ -// -// 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 "OSystem.hxx" -//#include "Props.hxx" -#include "PropsSet.hxx" -#include "Console.hxx" -#include "Launcher.hxx" -#include "System.hxx" - -#include "HighScoreManager.hxx" - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -HighScoreManager::HighScoreManager(OSystem& osystem) - : myOSystem(osystem) -{ -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Int16 HighScoreManager::peek(uInt16 addr) -{ - if (myOSystem.hasConsole()) - { - System& system = myOSystem.console().system(); - return system.peek(addr); - } - return -1; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Properties& HighScoreManager::properties(Properties& props) const -{ - if (myOSystem.hasConsole()) - { - props = myOSystem.console().properties(); - } - else - { - const string& md5 = myOSystem.launcher().selectedRomMD5(); - myOSystem.propSet().getMD5(md5, props); - } - return props; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -string HighScoreManager::getPropIdx(PropType type, uInt32 idx) const -{ - Properties props; - string property = properties(props).get(type); - std::replace(property.begin(), property.end(), ',', ' '); - std::replace(property.begin(), property.end(), '|', ' '); - istringstream buf(property); - string result; - - for (uInt32 i = 0; i <= idx; ++i) - if(!(buf >> result)) - return ""; - - return result; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt32 HighScoreManager::numPlayers() const -{ - string numPlayers = getPropIdx(PropType::Cart_Players); - - return (numPlayers == EmptyString) ? 1 : std::min(BSPF::stringToInt(numPlayers), 4); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt32 HighScoreManager::numVariations() const -{ - string numVariations = getPropIdx(PropType::Cart_Variations); - - return (numVariations == EmptyString) ? 1 : std::min(BSPF::stringToInt(numVariations), 256); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool HighScoreManager::getFormats(Formats& formats) const -{ - formats.numDigits = numDigits(); - formats.trailingZeroes = trailingZeroes(); - formats.scoreBCD = scoreBCD(); - formats.varBCD = varBCD(); - formats.varZeroBased = varZeroBased(); - - return true; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt32 HighScoreManager::numDigits() const -{ - string digits = getPropIdx(PropType::Cart_Formats, 0); - - return digits == EmptyString ? 4 : stoi(digits); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt32 HighScoreManager::trailingZeroes() const -{ - string trailing = getPropIdx(PropType::Cart_Formats, 1); - - return trailing == EmptyString ? 0 : stoi(trailing);} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool HighScoreManager::scoreBCD() const -{ - string bcd = getPropIdx(PropType::Cart_Formats, 2); - - return bcd == EmptyString ? true : bcd == "B"; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool HighScoreManager::varBCD() const -{ - string bcd = getPropIdx(PropType::Cart_Formats, 3); - - return bcd == EmptyString ? true : bcd == "B"; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool HighScoreManager::varZeroBased() const -{ - string zeroBased = getPropIdx(PropType::Cart_Formats, 4); - - return zeroBased == EmptyString ? true : zeroBased != "0"; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool HighScoreManager::getAddresses(Addresses& addresses) const -{ - addresses.playerAddr = playerAddress(); - addresses.varAddr = varAddress(); - for (int p = 0; p < numPlayers(); ++p) - { - for (int a = 0; a < numAddrBytes(); ++a) - { - uInt32 idx = p * numAddrBytes() + a; - string addr = getPropIdx(PropType::Cart_Addresses, idx); - - addresses.scoreAddr[p][a] = (addr == EmptyString ? 0 : stoi(addr, nullptr, 16)); - } - } - - return true; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt16 HighScoreManager::playerAddress() const -{ - uInt32 idx = numAddrBytes() * numPlayers() + 1; - string addr = getPropIdx(PropType::Cart_Addresses, idx); - - return addr == EmptyString ? 0 : stoi(addr, nullptr, 16); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt16 HighScoreManager::varAddress() const -{ - uInt32 idx = numAddrBytes() * numPlayers(); - string addr = getPropIdx(PropType::Cart_Addresses, idx); - - return addr == EmptyString ? 0 : stoi(addr, nullptr, 16); -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -uInt32 HighScoreManager::numAddrBytes(Int32 digits, Int32 trailing) const -{ - return ((digits < 0 ? numDigits() : digits) - (trailing < 0 ? trailingZeroes() : trailing) + 1) / 2; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -bool HighScoreManager::parseAddresses(uInt32& variation, uInt32& player, uInt32 scores[]) -{ - variation = 1; player = 0; scores[0] = 0; - - if (!myOSystem.hasConsole()) - return false; - - System& system = myOSystem.console().system(); - - // Formats (all optional): - // 2, ; score addresses per player - // 1, ; score multiplier - // B, ; score format (BCD, HEX) - // B, ; variation format (BCD, HEX) - // 0, ; add to variation - // Addresses (in hex): - // n*p-times xx, ; score addresses for each player, high to low - // xx, ; variation address (if more than 1 variation) - // xx, ; player address (if more than 1 player) - // TODO: - // - variation bits (Centipede) - // - player bits (Asteroids, Space Invaders) - // - score swaps (Asteroids) - Properties props; - string formats = properties(props).get(PropType::Cart_Formats); - string addresses = properties(props).get(PropType::Cart_Addresses); - char scoreFormat; - char varFormat; - Int16 addr; - Int32 varAdd, numScoreAddr, scoreMult; - - // Since istringstream swallows whitespace, we have to make the - // delimiters be spaces - std::replace(formats.begin(), formats.end(), ',', ' '); - std::replace(formats.begin(), formats.end(), '|', ' '); - std::replace(addresses.begin(), addresses.end(), ',', ' '); - std::replace(addresses.begin(), addresses.end(), '|', ' '); - istringstream addrBuf(addresses); - istringstream formatBuf(formats); - - // 1. retrieve formats - if (!(formatBuf >> numScoreAddr)) - numScoreAddr = 2; - if (!(formatBuf >> scoreMult)) - scoreMult = 1; - if (!(formatBuf >> scoreFormat)) - scoreFormat = 'B'; - if (!(formatBuf >> varFormat)) - varFormat = 'B'; - if (!(formatBuf >> varAdd)) - varAdd = 0; - - // 2. retrieve current scores for all players - for (uInt32 i = 0; i < numPlayers(); ++i) - { - Int32 totalScore = 0; - - for (int j = 0; j < numScoreAddr; ++j) - { - Int32 score; - - if (!(addrBuf >> std::hex >> addr)) - return false; - - totalScore *= (scoreFormat == 'B') ? 100 : 256; - - score = system.peek(addr); - if (scoreFormat == 'B') - score = (score >> 4) * 10 + score % 16; - totalScore += score; - } - scores[i] = totalScore * scoreMult; - } - - // 3. retrieve current variation (0..255) - if (numVariations() == 1) - return true; - - if (!(addrBuf >> std::hex >> addr)) - return false; - variation = system.peek(addr); - if (varFormat == 'B') - variation = (variation >> 4) * 10 + variation % 16; - variation += varAdd; - variation = std::min(variation, numVariations()); - - // 4. retrieve current player (0..3) - if (numPlayers() == 1) - return true; - - if (!(addrBuf >> std::hex >> addr)) - return false; - - player = system.peek(addr); - player = std::min(player, numPlayers() - 1); - - return true; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Int32 HighScoreManager::variation() -{ - uInt32 variation, player, scores[4]; - - if (parseAddresses(variation, player, scores)) - return variation; - - return -1; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Int32 HighScoreManager::player() -{ - uInt32 variation, player, scores[4]; - - if (parseAddresses(variation, player, scores)) - return player; - - return -1; -} - -// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Int32 HighScoreManager::score() -{ - uInt32 variation, player, scores[4]; - - if (parseAddresses(variation, player, scores)) - return scores[std::min(player, uInt32(MAX_PLAYERS))]; - - return -1; -} diff --git a/src/common/HighScoreManager.hxx b/src/common/HighScoreManager.hxx deleted file mode 100644 index 597b538b4..000000000 --- a/src/common/HighScoreManager.hxx +++ /dev/null @@ -1,95 +0,0 @@ -//============================================================================ -// -// 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 HIGHSCORE_MANAGER_HXX -#define HIGHSCORE_MANAGER_HXX - -//#include "bspf.hxx" - -class OSystem; - -class HighScoreManager -{ - -public: - - static const uInt32 MAX_PLAYERS = 4; - static const uInt32 MAX_SCORE_ADDR = 3; - - struct Formats { - uInt32 numDigits; - uInt32 trailingZeroes; - bool scoreBCD; - bool varBCD; - bool varZeroBased; - }; - - - struct Addresses { - uInt16 scoreAddr[HighScoreManager::MAX_PLAYERS][HighScoreManager::MAX_SCORE_ADDR]; - uInt16 varAddr; - uInt16 playerAddr; - }; - - HighScoreManager(OSystem& osystem); - virtual ~HighScoreManager() = default; - - /* - Methods for returning high score related variables - Return -1 if undefined - */ - uInt32 numVariations() const; - uInt32 numPlayers() const; - - bool getFormats(Formats& formats) const; - bool getAddresses(Addresses& addresses) const; - - uInt32 numDigits() const; - uInt32 trailingZeroes() const; - bool scoreBCD() const; - bool varBCD() const; - bool varZeroBased() const; - - uInt16 varAddress() const; - uInt16 playerAddress() const; - - uInt32 numAddrBytes(Int32 digits = -1, Int32 trailing = -1) const; - - // current values - Int32 player(); - Int32 variation(); - Int32 score(); - -private: - Properties& properties(Properties& props) const; - string getPropIdx(PropType type, uInt32 idx = 0) const; - Int16 peek(uInt16 addr); - bool parseAddresses(uInt32& variation, uInt32& player, uInt32 scores[]); - -private: - // Reference to the osystem object - OSystem& myOSystem; - -private: - // Following constructors and assignment operators not supported - HighScoreManager() = delete; - HighScoreManager(const HighScoreManager&) = delete; - HighScoreManager(HighScoreManager&&) = delete; - HighScoreManager& operator=(const HighScoreManager&) = delete; - HighScoreManager& operator=(HighScoreManager&&) = delete; -}; -#endif diff --git a/src/common/module.mk b/src/common/module.mk index e1f804b3f..71511cbae 100644 --- a/src/common/module.mk +++ b/src/common/module.mk @@ -6,7 +6,7 @@ MODULE_OBJS := \ src/common/FBSurfaceSDL2.o \ src/common/FrameBufferSDL2.o \ src/common/FSNodeZIP.o \ - src/common/HighScoreManager.o \ + src/common/HighScoresManager.o \ src/common/JoyMap.o \ src/common/KeyMap.o \ src/common/Logger.o \ diff --git a/src/emucore/EventHandler.cxx b/src/emucore/EventHandler.cxx index 762c8f94f..b8a081ac6 100644 --- a/src/emucore/EventHandler.cxx +++ b/src/emucore/EventHandler.cxx @@ -35,7 +35,9 @@ #include "StateManager.hxx" #include "RewindManager.hxx" #include "TimerManager.hxx" -#include "HighScoreManager.hxx" +#ifdef GUI_SUPPORT +#include "HighScoresManager.hxx" +#endif #include "Switches.hxx" #include "M6532.hxx" #include "MouseControl.hxx" @@ -718,6 +720,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) if(pressed && !repeated) myOSystem.frameBuffer().tiaSurface().saveSnapShot(); return; + #ifdef GUI_SUPPORT // Debug only, TODO: remove! case Event::ShowScore: if (pressed) @@ -736,6 +739,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated) myOSystem.frameBuffer().showMessage(msg.str()); } return; + #endif case Event::ExitMode: // Special handling for Escape key diff --git a/src/emucore/OSystem.cxx b/src/emucore/OSystem.cxx index 69a9e9468..d98827b47 100644 --- a/src/emucore/OSystem.cxx +++ b/src/emucore/OSystem.cxx @@ -58,7 +58,9 @@ #include "Random.hxx" #include "StateManager.hxx" #include "TimerManager.hxx" -#include "HighScoreManager.hxx" +#ifdef GUI_SUPPORT +#include "HighScoresManager.hxx" +#endif #include "Version.hxx" #include "TIA.hxx" #include "DispatchResult.hxx" @@ -154,7 +156,11 @@ bool OSystem::create() myStateManager = make_unique(*this); myTimerManager = make_unique(); - myHighScoreManager = make_unique(*this); + +#ifdef GUI_SUPPORT + myHighScoresManager = make_unique(*this); +#endif + myAudioSettings = make_unique(*mySettings); // Create the sound object; the sound subsystem isn't actually diff --git a/src/emucore/OSystem.hxx b/src/emucore/OSystem.hxx index 2524d5acc..0377f6539 100644 --- a/src/emucore/OSystem.hxx +++ b/src/emucore/OSystem.hxx @@ -27,7 +27,7 @@ class Random; class Sound; class StateManager; class TimerManager; -class HighScoreManager; +class HighScoresManager; class EmulationWorker; class AudioSettings; #ifdef CHEATCODE_SUPPORT @@ -149,12 +149,14 @@ class OSystem */ AudioSettings& audioSettings() { return *myAudioSettings; } + #ifdef GUI_SUPPORT /** Get the high score manager of the system. @return The highscore manager object */ - HighScoreManager& highScores() const { return *myHighScoreManager; } + HighScoresManager& highScores() const { return *myHighScoresManager; } + #endif /** Get the state manager of the system. @@ -525,8 +527,10 @@ class OSystem // Pointer to the TimerManager object unique_ptr myTimerManager; - // Pointer to the HighScoreManager object - unique_ptr myHighScoreManager; + #ifdef GUI_SUPPORT + // Pointer to the HighScoresManager object + unique_ptr myHighScoresManager; + #endif // Indicates whether ROM launcher was ever opened during this run bool myLauncherUsed{false}; diff --git a/src/gui/GameInfoDialog.cxx b/src/gui/GameInfoDialog.cxx index 10c991ada..05f4cb2ce 100644 --- a/src/gui/GameInfoDialog.cxx +++ b/src/gui/GameInfoDialog.cxx @@ -40,7 +40,6 @@ #include "TIA.hxx" #include "Switches.hxx" #include "AudioSettings.hxx" -#include "HighScoreManager.hxx" #include "bspf.hxx" #include "GameInfoDialog.hxx" @@ -377,19 +376,19 @@ GameInfoDialog::GameInfoDialog( EditableWidget::TextFilter fAddr = [](char c) { return (c >= 'a' && c <= 'f') || (c >= '0' && c <= '9'); }; - int rwidth = font.getStringWidth("123") + 4; + int vwidth = font.getStringWidth("123") + 4; myPlayersAddressLabel = new StaticTextWidget(myTab, font, myPlayers->getRight() + 16, ypos + 1, "Address "); myPlayersAddress = new EditTextWidget(myTab, font, myPlayersAddressLabel->getRight(), ypos - 1, awidth, lineHeight); myPlayersAddress->setTextFilter(fAddr); wid.push_back(myPlayersAddress); - myPlayersAddressVal = new EditTextWidget(myTab, font, myPlayersAddress->getRight() + 2, ypos - 1, rwidth, lineHeight); + myPlayersAddressVal = new EditTextWidget(myTab, font, myPlayersAddress->getRight() + 2, ypos - 1, vwidth, lineHeight); myPlayersAddressVal->setEditable(false); ypos += lineHeight + VGAP; fwidth = font.getStringWidth("255") + 5; - rwidth = font.getStringWidth("123") + 4; + vwidth = font.getStringWidth("123") + 4; myVariationsLabel = new StaticTextWidget(myTab, font, xpos, ypos + 1, lwidth, fontHeight, "Variations"); myVariations = new EditTextWidget(myTab, font, xpos + lwidth, ypos - 1, fwidth, lineHeight); wid.push_back(myVariations); @@ -398,7 +397,7 @@ GameInfoDialog::GameInfoDialog( myVarAddress = new EditTextWidget(myTab, font, myVarAddressLabel->getRight(), ypos - 1, awidth, lineHeight); myVarAddress->setTextFilter(fAddr); wid.push_back(myVarAddress); - myVarAddressVal = new EditTextWidget(myTab, font, myVarAddress->getRight() + 2, ypos - 1, rwidth, lineHeight); + myVarAddressVal = new EditTextWidget(myTab, font, myVarAddress->getRight() + 2, ypos - 1, vwidth, lineHeight); myVarAddressVal->setEditable(false); myVarBCD = new CheckboxWidget(myTab, font, myVarAddressVal->getRight() + 16, ypos + 1, "BCD", kVarFormatChanged); @@ -420,6 +419,7 @@ GameInfoDialog::GameInfoDialog( myScoresLabel = new StaticTextWidget(myTab, font, xpos, ypos + 1, lwidth, fontHeight, "Scores"); xpos += 20; ypos += lineHeight + VGAP; + vwidth = font.getStringWidth("AB") + 4; myScoreDigitsLabel = new StaticTextWidget(myTab, font, xpos, ypos + 1, "Digits "); myScoreDigits = new PopUpWidget(myTab, font, myScoreDigitsLabel->getRight(), ypos, pwidth, lineHeight, @@ -442,22 +442,22 @@ GameInfoDialog::GameInfoDialog( wid.push_back(myScoreBCD); - for (uInt32 p = 0; p < HighScoreManager::MAX_PLAYERS; ++p) + for (uInt32 p = 0; p < HighScoresManager::MAX_PLAYERS; ++p) { uInt32 s_xpos = xpos; ypos += lineHeight + VGAP; myScoreAddressesLabel[p] = new StaticTextWidget(myTab, font, s_xpos, ypos + 1, "P" + std::to_string(p + 1) + " Addresses "); - s_xpos += myScoreAddressesLabel[p]->getRight(); - for (uInt32 a = 0; a < HighScoreManager::MAX_SCORE_ADDR; ++a) + s_xpos += myScoreAddressesLabel[p]->getWidth(); + for (uInt32 a = 0; a < HighScoresManager::MAX_SCORE_ADDR; ++a) { myScoreAddress[p][a] = new EditTextWidget(myTab, font, s_xpos, ypos - 1, awidth, lineHeight); myScoreAddress[p][a]->setTextFilter(fAddr); wid.push_back(myScoreAddress[p][a]); s_xpos += myScoreAddress[p][a]->getWidth() + 2; - myScoreAddressVal[p][a] = new EditTextWidget(myTab, font, myScoreAddress[p][a]->getRight() + 2, ypos - 1, rwidth, lineHeight); + myScoreAddressVal[p][a] = new EditTextWidget(myTab, font, myScoreAddress[p][a]->getRight() + 2, ypos - 1, vwidth, lineHeight); myScoreAddressVal[p][a]->setEditable(false); s_xpos += myScoreAddressVal[p][a]->getWidth() + 16; } @@ -656,8 +656,8 @@ void GameInfoDialog::loadCartridgeProperties(const Properties& props) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void GameInfoDialog::loadHighScoresProperties(const Properties& props) { - HighScoreManager::Formats formats; - HighScoreManager::Addresses addresses; + HighScoresManager::Formats formats; + HighScoresManager::Addresses addresses; bool enable = instance().highScores().getFormats(formats); enable &= instance().highScores().getAddresses(addresses); // make compiler happy @@ -942,12 +942,12 @@ void GameInfoDialog::handleHighScoresWidgets() myTrailingZeroesLabel->setEnabled(enable); myTrailingZeroes->setEnabled(enable); - for (uInt32 p = 0; p < HighScoreManager::MAX_PLAYERS; ++p) + for (uInt32 p = 0; p < HighScoresManager::MAX_PLAYERS; ++p) { enable &= players > p; myScoreAddressesLabel[p]->setEnabled(enable); - for (uInt32 a = 0; a < HighScoreManager::MAX_SCORE_ADDR; ++a) + for (uInt32 a = 0; a < HighScoresManager::MAX_SCORE_ADDR; ++a) { myScoreAddress[p][a]->setEnabled(enable && numAddr > a); myScoreAddressVal[p][a]->setEnabled(enable && numAddr > a); @@ -963,7 +963,7 @@ void GameInfoDialog::handleHighScoresWidgets() } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -void GameInfoDialog::setAddressVal(const EditTextWidget* addressWidget, EditTextWidget* valWidget, bool isBCD, uInt16 incVal) +void GameInfoDialog::setAddressVal(const EditTextWidget* addressWidget, EditTextWidget* valWidget, bool isBCD, uInt8 incVal) { if (instance().hasConsole() && valWidget->isEnabled()) { @@ -971,12 +971,18 @@ void GameInfoDialog::setAddressVal(const EditTextWidget* addressWidget, EditText string strAddr; uInt16 addr; uInt8 val; + ostringstream ss; strAddr = addressWidget->getText(); - addr = strAddr == EmptyString ? 0 : stoi(strAddr, nullptr, isBCD ? 10 : 16); + addr = strAddr == EmptyString ? 0 : stoi(strAddr, nullptr, 16); val = system.peek(addr) + incVal; - valWidget->setText(std::to_string(val)); - cerr << strAddr << ": " << addr << ", " << val << endl; + + if (isBCD) + ss << std::hex << std::right << std::setw(2) << std::setfill('0'); + else + ss << std::dec; + ss << uInt16(val); + valWidget->setText(ss.str()); } else valWidget->setText(""); diff --git a/src/gui/GameInfoDialog.hxx b/src/gui/GameInfoDialog.hxx index 27cdb9e4d..7c4200d11 100644 --- a/src/gui/GameInfoDialog.hxx +++ b/src/gui/GameInfoDialog.hxx @@ -26,12 +26,11 @@ class StaticTextWidget; class RadioButtonGroup; class TabWidget; class SliderWidget; -class HighScoreManager; #include "Dialog.hxx" #include "Command.hxx" #include "Props.hxx" -#include "HighScoreManager.hxx" +#include "HighScoresManager.hxx" class GameInfoDialog : public Dialog, public CommandSender { @@ -61,7 +60,7 @@ class GameInfoDialog : public Dialog, public CommandSender void updateControllerStates(); void eraseEEPROM(); void handleHighScoresWidgets(); - void setAddressVal(const EditTextWidget* address, EditTextWidget* val, bool isBCD = false, uInt16 incVal = 0); + void setAddressVal(const EditTextWidget* address, EditTextWidget* val, bool isBCD = false, uInt8 incVal = 0); private: TabWidget* myTab{nullptr}; @@ -131,9 +130,9 @@ class GameInfoDialog : public Dialog, public CommandSender PopUpWidget* myTrailingZeroes{nullptr}; CheckboxWidget* myScoreBCD{nullptr}; - StaticTextWidget* myScoreAddressesLabel[HighScoreManager::MAX_PLAYERS]{ nullptr }; - EditTextWidget* myScoreAddress[HighScoreManager::MAX_PLAYERS][HighScoreManager::MAX_SCORE_ADDR]{nullptr}; - EditTextWidget* myScoreAddressVal[HighScoreManager::MAX_PLAYERS][HighScoreManager::MAX_SCORE_ADDR]{nullptr}; + StaticTextWidget* myScoreAddressesLabel[HighScoresManager::MAX_PLAYERS]{ nullptr }; + EditTextWidget* myScoreAddress[HighScoresManager::MAX_PLAYERS][HighScoresManager::MAX_SCORE_ADDR]{nullptr}; + EditTextWidget* myScoreAddressVal[HighScoresManager::MAX_PLAYERS][HighScoresManager::MAX_SCORE_ADDR]{nullptr}; /*StaticTextWidget* myP1AddressLabel{nullptr}; EditTextWidget* myP1Address0{nullptr}; diff --git a/src/windows/Stella.vcxproj b/src/windows/Stella.vcxproj index 91b64d36b..146e77234 100644 --- a/src/windows/Stella.vcxproj +++ b/src/windows/Stella.vcxproj @@ -382,7 +382,7 @@ - + @@ -1089,7 +1089,7 @@ - + diff --git a/src/windows/Stella.vcxproj.filters b/src/windows/Stella.vcxproj.filters index 4535ca61d..d9cc94dd4 100644 --- a/src/windows/Stella.vcxproj.filters +++ b/src/windows/Stella.vcxproj.filters @@ -1005,7 +1005,7 @@ Source Files\gui - + Source Files @@ -2057,7 +2057,7 @@ Header Files\gui - + Header Files