mirror of https://github.com/stella-emu/stella.git
consider GUI_SUPPORT, rename into HighScoresManager, value formatting
This commit is contained in:
parent
59eb2d4fa8
commit
7374b24ff8
|
@ -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;
|
|
||||||
}
|
|
|
@ -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
|
|
|
@ -6,7 +6,7 @@ MODULE_OBJS := \
|
||||||
src/common/FBSurfaceSDL2.o \
|
src/common/FBSurfaceSDL2.o \
|
||||||
src/common/FrameBufferSDL2.o \
|
src/common/FrameBufferSDL2.o \
|
||||||
src/common/FSNodeZIP.o \
|
src/common/FSNodeZIP.o \
|
||||||
src/common/HighScoreManager.o \
|
src/common/HighScoresManager.o \
|
||||||
src/common/JoyMap.o \
|
src/common/JoyMap.o \
|
||||||
src/common/KeyMap.o \
|
src/common/KeyMap.o \
|
||||||
src/common/Logger.o \
|
src/common/Logger.o \
|
||||||
|
|
|
@ -35,7 +35,9 @@
|
||||||
#include "StateManager.hxx"
|
#include "StateManager.hxx"
|
||||||
#include "RewindManager.hxx"
|
#include "RewindManager.hxx"
|
||||||
#include "TimerManager.hxx"
|
#include "TimerManager.hxx"
|
||||||
#include "HighScoreManager.hxx"
|
#ifdef GUI_SUPPORT
|
||||||
|
#include "HighScoresManager.hxx"
|
||||||
|
#endif
|
||||||
#include "Switches.hxx"
|
#include "Switches.hxx"
|
||||||
#include "M6532.hxx"
|
#include "M6532.hxx"
|
||||||
#include "MouseControl.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();
|
if(pressed && !repeated) myOSystem.frameBuffer().tiaSurface().saveSnapShot();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
#ifdef GUI_SUPPORT
|
||||||
// Debug only, TODO: remove!
|
// Debug only, TODO: remove!
|
||||||
case Event::ShowScore:
|
case Event::ShowScore:
|
||||||
if (pressed)
|
if (pressed)
|
||||||
|
@ -736,6 +739,7 @@ void EventHandler::handleEvent(Event::Type event, Int32 value, bool repeated)
|
||||||
myOSystem.frameBuffer().showMessage(msg.str());
|
myOSystem.frameBuffer().showMessage(msg.str());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
#endif
|
||||||
|
|
||||||
case Event::ExitMode:
|
case Event::ExitMode:
|
||||||
// Special handling for Escape key
|
// Special handling for Escape key
|
||||||
|
|
|
@ -58,7 +58,9 @@
|
||||||
#include "Random.hxx"
|
#include "Random.hxx"
|
||||||
#include "StateManager.hxx"
|
#include "StateManager.hxx"
|
||||||
#include "TimerManager.hxx"
|
#include "TimerManager.hxx"
|
||||||
#include "HighScoreManager.hxx"
|
#ifdef GUI_SUPPORT
|
||||||
|
#include "HighScoresManager.hxx"
|
||||||
|
#endif
|
||||||
#include "Version.hxx"
|
#include "Version.hxx"
|
||||||
#include "TIA.hxx"
|
#include "TIA.hxx"
|
||||||
#include "DispatchResult.hxx"
|
#include "DispatchResult.hxx"
|
||||||
|
@ -154,7 +156,11 @@ bool OSystem::create()
|
||||||
|
|
||||||
myStateManager = make_unique<StateManager>(*this);
|
myStateManager = make_unique<StateManager>(*this);
|
||||||
myTimerManager = make_unique<TimerManager>();
|
myTimerManager = make_unique<TimerManager>();
|
||||||
myHighScoreManager = make_unique<HighScoreManager>(*this);
|
|
||||||
|
#ifdef GUI_SUPPORT
|
||||||
|
myHighScoresManager = make_unique<HighScoresManager>(*this);
|
||||||
|
#endif
|
||||||
|
|
||||||
myAudioSettings = make_unique<AudioSettings>(*mySettings);
|
myAudioSettings = make_unique<AudioSettings>(*mySettings);
|
||||||
|
|
||||||
// Create the sound object; the sound subsystem isn't actually
|
// Create the sound object; the sound subsystem isn't actually
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Random;
|
||||||
class Sound;
|
class Sound;
|
||||||
class StateManager;
|
class StateManager;
|
||||||
class TimerManager;
|
class TimerManager;
|
||||||
class HighScoreManager;
|
class HighScoresManager;
|
||||||
class EmulationWorker;
|
class EmulationWorker;
|
||||||
class AudioSettings;
|
class AudioSettings;
|
||||||
#ifdef CHEATCODE_SUPPORT
|
#ifdef CHEATCODE_SUPPORT
|
||||||
|
@ -149,12 +149,14 @@ class OSystem
|
||||||
*/
|
*/
|
||||||
AudioSettings& audioSettings() { return *myAudioSettings; }
|
AudioSettings& audioSettings() { return *myAudioSettings; }
|
||||||
|
|
||||||
|
#ifdef GUI_SUPPORT
|
||||||
/**
|
/**
|
||||||
Get the high score manager of the system.
|
Get the high score manager of the system.
|
||||||
|
|
||||||
@return The highscore manager object
|
@return The highscore manager object
|
||||||
*/
|
*/
|
||||||
HighScoreManager& highScores() const { return *myHighScoreManager; }
|
HighScoresManager& highScores() const { return *myHighScoresManager; }
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get the state manager of the system.
|
Get the state manager of the system.
|
||||||
|
@ -525,8 +527,10 @@ class OSystem
|
||||||
// Pointer to the TimerManager object
|
// Pointer to the TimerManager object
|
||||||
unique_ptr<TimerManager> myTimerManager;
|
unique_ptr<TimerManager> myTimerManager;
|
||||||
|
|
||||||
// Pointer to the HighScoreManager object
|
#ifdef GUI_SUPPORT
|
||||||
unique_ptr<HighScoreManager> myHighScoreManager;
|
// Pointer to the HighScoresManager object
|
||||||
|
unique_ptr<HighScoresManager> myHighScoresManager;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Indicates whether ROM launcher was ever opened during this run
|
// Indicates whether ROM launcher was ever opened during this run
|
||||||
bool myLauncherUsed{false};
|
bool myLauncherUsed{false};
|
||||||
|
|
|
@ -40,7 +40,6 @@
|
||||||
#include "TIA.hxx"
|
#include "TIA.hxx"
|
||||||
#include "Switches.hxx"
|
#include "Switches.hxx"
|
||||||
#include "AudioSettings.hxx"
|
#include "AudioSettings.hxx"
|
||||||
#include "HighScoreManager.hxx"
|
|
||||||
#include "bspf.hxx"
|
#include "bspf.hxx"
|
||||||
|
|
||||||
#include "GameInfoDialog.hxx"
|
#include "GameInfoDialog.hxx"
|
||||||
|
@ -377,19 +376,19 @@ GameInfoDialog::GameInfoDialog(
|
||||||
EditableWidget::TextFilter fAddr = [](char c) {
|
EditableWidget::TextFilter fAddr = [](char c) {
|
||||||
return (c >= 'a' && c <= 'f') || (c >= '0' && c <= '9');
|
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 ");
|
myPlayersAddressLabel = new StaticTextWidget(myTab, font, myPlayers->getRight() + 16, ypos + 1, "Address ");
|
||||||
myPlayersAddress = new EditTextWidget(myTab, font, myPlayersAddressLabel->getRight(), ypos - 1, awidth, lineHeight);
|
myPlayersAddress = new EditTextWidget(myTab, font, myPlayersAddressLabel->getRight(), ypos - 1, awidth, lineHeight);
|
||||||
myPlayersAddress->setTextFilter(fAddr);
|
myPlayersAddress->setTextFilter(fAddr);
|
||||||
wid.push_back(myPlayersAddress);
|
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);
|
myPlayersAddressVal->setEditable(false);
|
||||||
|
|
||||||
ypos += lineHeight + VGAP;
|
ypos += lineHeight + VGAP;
|
||||||
|
|
||||||
fwidth = font.getStringWidth("255") + 5;
|
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");
|
myVariationsLabel = new StaticTextWidget(myTab, font, xpos, ypos + 1, lwidth, fontHeight, "Variations");
|
||||||
myVariations = new EditTextWidget(myTab, font, xpos + lwidth, ypos - 1, fwidth, lineHeight);
|
myVariations = new EditTextWidget(myTab, font, xpos + lwidth, ypos - 1, fwidth, lineHeight);
|
||||||
wid.push_back(myVariations);
|
wid.push_back(myVariations);
|
||||||
|
@ -398,7 +397,7 @@ GameInfoDialog::GameInfoDialog(
|
||||||
myVarAddress = new EditTextWidget(myTab, font, myVarAddressLabel->getRight(), ypos - 1, awidth, lineHeight);
|
myVarAddress = new EditTextWidget(myTab, font, myVarAddressLabel->getRight(), ypos - 1, awidth, lineHeight);
|
||||||
myVarAddress->setTextFilter(fAddr);
|
myVarAddress->setTextFilter(fAddr);
|
||||||
wid.push_back(myVarAddress);
|
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);
|
myVarAddressVal->setEditable(false);
|
||||||
|
|
||||||
myVarBCD = new CheckboxWidget(myTab, font, myVarAddressVal->getRight() + 16, ypos + 1, "BCD", kVarFormatChanged);
|
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");
|
myScoresLabel = new StaticTextWidget(myTab, font, xpos, ypos + 1, lwidth, fontHeight, "Scores");
|
||||||
|
|
||||||
xpos += 20; ypos += lineHeight + VGAP;
|
xpos += 20; ypos += lineHeight + VGAP;
|
||||||
|
vwidth = font.getStringWidth("AB") + 4;
|
||||||
|
|
||||||
myScoreDigitsLabel = new StaticTextWidget(myTab, font, xpos, ypos + 1, "Digits ");
|
myScoreDigitsLabel = new StaticTextWidget(myTab, font, xpos, ypos + 1, "Digits ");
|
||||||
myScoreDigits = new PopUpWidget(myTab, font, myScoreDigitsLabel->getRight(), ypos, pwidth, lineHeight,
|
myScoreDigits = new PopUpWidget(myTab, font, myScoreDigitsLabel->getRight(), ypos, pwidth, lineHeight,
|
||||||
|
@ -442,22 +442,22 @@ GameInfoDialog::GameInfoDialog(
|
||||||
wid.push_back(myScoreBCD);
|
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;
|
uInt32 s_xpos = xpos;
|
||||||
ypos += lineHeight + VGAP;
|
ypos += lineHeight + VGAP;
|
||||||
|
|
||||||
myScoreAddressesLabel[p] = new StaticTextWidget(myTab, font, s_xpos, ypos + 1,
|
myScoreAddressesLabel[p] = new StaticTextWidget(myTab, font, s_xpos, ypos + 1,
|
||||||
"P" + std::to_string(p + 1) + " Addresses ");
|
"P" + std::to_string(p + 1) + " Addresses ");
|
||||||
s_xpos += myScoreAddressesLabel[p]->getRight();
|
s_xpos += myScoreAddressesLabel[p]->getWidth();
|
||||||
for (uInt32 a = 0; a < HighScoreManager::MAX_SCORE_ADDR; ++a)
|
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] = new EditTextWidget(myTab, font, s_xpos, ypos - 1, awidth, lineHeight);
|
||||||
myScoreAddress[p][a]->setTextFilter(fAddr);
|
myScoreAddress[p][a]->setTextFilter(fAddr);
|
||||||
wid.push_back(myScoreAddress[p][a]);
|
wid.push_back(myScoreAddress[p][a]);
|
||||||
s_xpos += myScoreAddress[p][a]->getWidth() + 2;
|
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);
|
myScoreAddressVal[p][a]->setEditable(false);
|
||||||
s_xpos += myScoreAddressVal[p][a]->getWidth() + 16;
|
s_xpos += myScoreAddressVal[p][a]->getWidth() + 16;
|
||||||
}
|
}
|
||||||
|
@ -656,8 +656,8 @@ void GameInfoDialog::loadCartridgeProperties(const Properties& props)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void GameInfoDialog::loadHighScoresProperties(const Properties& props)
|
void GameInfoDialog::loadHighScoresProperties(const Properties& props)
|
||||||
{
|
{
|
||||||
HighScoreManager::Formats formats;
|
HighScoresManager::Formats formats;
|
||||||
HighScoreManager::Addresses addresses;
|
HighScoresManager::Addresses addresses;
|
||||||
bool enable = instance().highScores().getFormats(formats);
|
bool enable = instance().highScores().getFormats(formats);
|
||||||
|
|
||||||
enable &= instance().highScores().getAddresses(addresses); // make compiler happy
|
enable &= instance().highScores().getAddresses(addresses); // make compiler happy
|
||||||
|
@ -942,12 +942,12 @@ void GameInfoDialog::handleHighScoresWidgets()
|
||||||
myTrailingZeroesLabel->setEnabled(enable);
|
myTrailingZeroesLabel->setEnabled(enable);
|
||||||
myTrailingZeroes->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;
|
enable &= players > p;
|
||||||
myScoreAddressesLabel[p]->setEnabled(enable);
|
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);
|
myScoreAddress[p][a]->setEnabled(enable && numAddr > a);
|
||||||
myScoreAddressVal[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())
|
if (instance().hasConsole() && valWidget->isEnabled())
|
||||||
{
|
{
|
||||||
|
@ -971,12 +971,18 @@ void GameInfoDialog::setAddressVal(const EditTextWidget* addressWidget, EditText
|
||||||
string strAddr;
|
string strAddr;
|
||||||
uInt16 addr;
|
uInt16 addr;
|
||||||
uInt8 val;
|
uInt8 val;
|
||||||
|
ostringstream ss;
|
||||||
|
|
||||||
strAddr = addressWidget->getText();
|
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;
|
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
|
else
|
||||||
valWidget->setText("");
|
valWidget->setText("");
|
||||||
|
|
|
@ -26,12 +26,11 @@ class StaticTextWidget;
|
||||||
class RadioButtonGroup;
|
class RadioButtonGroup;
|
||||||
class TabWidget;
|
class TabWidget;
|
||||||
class SliderWidget;
|
class SliderWidget;
|
||||||
class HighScoreManager;
|
|
||||||
|
|
||||||
#include "Dialog.hxx"
|
#include "Dialog.hxx"
|
||||||
#include "Command.hxx"
|
#include "Command.hxx"
|
||||||
#include "Props.hxx"
|
#include "Props.hxx"
|
||||||
#include "HighScoreManager.hxx"
|
#include "HighScoresManager.hxx"
|
||||||
|
|
||||||
class GameInfoDialog : public Dialog, public CommandSender
|
class GameInfoDialog : public Dialog, public CommandSender
|
||||||
{
|
{
|
||||||
|
@ -61,7 +60,7 @@ class GameInfoDialog : public Dialog, public CommandSender
|
||||||
void updateControllerStates();
|
void updateControllerStates();
|
||||||
void eraseEEPROM();
|
void eraseEEPROM();
|
||||||
void handleHighScoresWidgets();
|
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:
|
private:
|
||||||
TabWidget* myTab{nullptr};
|
TabWidget* myTab{nullptr};
|
||||||
|
@ -131,9 +130,9 @@ class GameInfoDialog : public Dialog, public CommandSender
|
||||||
PopUpWidget* myTrailingZeroes{nullptr};
|
PopUpWidget* myTrailingZeroes{nullptr};
|
||||||
CheckboxWidget* myScoreBCD{nullptr};
|
CheckboxWidget* myScoreBCD{nullptr};
|
||||||
|
|
||||||
StaticTextWidget* myScoreAddressesLabel[HighScoreManager::MAX_PLAYERS]{ nullptr };
|
StaticTextWidget* myScoreAddressesLabel[HighScoresManager::MAX_PLAYERS]{ nullptr };
|
||||||
EditTextWidget* myScoreAddress[HighScoreManager::MAX_PLAYERS][HighScoreManager::MAX_SCORE_ADDR]{nullptr};
|
EditTextWidget* myScoreAddress[HighScoresManager::MAX_PLAYERS][HighScoresManager::MAX_SCORE_ADDR]{nullptr};
|
||||||
EditTextWidget* myScoreAddressVal[HighScoreManager::MAX_PLAYERS][HighScoreManager::MAX_SCORE_ADDR]{nullptr};
|
EditTextWidget* myScoreAddressVal[HighScoresManager::MAX_PLAYERS][HighScoresManager::MAX_SCORE_ADDR]{nullptr};
|
||||||
|
|
||||||
/*StaticTextWidget* myP1AddressLabel{nullptr};
|
/*StaticTextWidget* myP1AddressLabel{nullptr};
|
||||||
EditTextWidget* myP1Address0{nullptr};
|
EditTextWidget* myP1Address0{nullptr};
|
||||||
|
|
|
@ -382,7 +382,7 @@
|
||||||
<ClCompile Include="..\common\FpsMeter.cxx" />
|
<ClCompile Include="..\common\FpsMeter.cxx" />
|
||||||
<ClCompile Include="..\common\FrameBufferSDL2.cxx" />
|
<ClCompile Include="..\common\FrameBufferSDL2.cxx" />
|
||||||
<ClCompile Include="..\common\FSNodeZIP.cxx" />
|
<ClCompile Include="..\common\FSNodeZIP.cxx" />
|
||||||
<ClCompile Include="..\common\HighScoreManager.cxx" />
|
<ClCompile Include="..\common\HighScoresManager.cxx" />
|
||||||
<ClCompile Include="..\common\JoyMap.cxx" />
|
<ClCompile Include="..\common\JoyMap.cxx" />
|
||||||
<ClCompile Include="..\common\KeyMap.cxx" />
|
<ClCompile Include="..\common\KeyMap.cxx" />
|
||||||
<ClCompile Include="..\common\Logger.cxx" />
|
<ClCompile Include="..\common\Logger.cxx" />
|
||||||
|
@ -1089,7 +1089,7 @@
|
||||||
<ClInclude Include="..\common\FrameBufferSDL2.hxx" />
|
<ClInclude Include="..\common\FrameBufferSDL2.hxx" />
|
||||||
<ClInclude Include="..\common\FSNodeFactory.hxx" />
|
<ClInclude Include="..\common\FSNodeFactory.hxx" />
|
||||||
<ClInclude Include="..\common\FSNodeZIP.hxx" />
|
<ClInclude Include="..\common\FSNodeZIP.hxx" />
|
||||||
<ClInclude Include="..\common\HighScoreManager.hxx" />
|
<ClInclude Include="..\common\HighScoresManager.hxx" />
|
||||||
<ClInclude Include="..\common\JoyMap.hxx" />
|
<ClInclude Include="..\common\JoyMap.hxx" />
|
||||||
<ClInclude Include="..\common\KeyMap.hxx" />
|
<ClInclude Include="..\common\KeyMap.hxx" />
|
||||||
<ClInclude Include="..\common\LinkedObjectPool.hxx" />
|
<ClInclude Include="..\common\LinkedObjectPool.hxx" />
|
||||||
|
|
|
@ -1005,7 +1005,7 @@
|
||||||
<ClCompile Include="..\gui\MessageDialog.cxx">
|
<ClCompile Include="..\gui\MessageDialog.cxx">
|
||||||
<Filter>Source Files\gui</Filter>
|
<Filter>Source Files\gui</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\common\HighScoreManager.cxx">
|
<ClCompile Include="..\common\HighScoresManager.cxx">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -2057,7 +2057,7 @@
|
||||||
<ClInclude Include="..\gui\MessageDialog.hxx">
|
<ClInclude Include="..\gui\MessageDialog.hxx">
|
||||||
<Filter>Header Files\gui</Filter>
|
<Filter>Header Files\gui</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\common\HighScoreManager.hxx">
|
<ClInclude Include="..\common\HighScoresManager.hxx">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
Loading…
Reference in New Issue