Merge branch 'master' into feature/filesystem

This commit is contained in:
Stephen Anthony 2022-08-21 21:32:04 -02:30
commit a35dfc0906
314 changed files with 2079 additions and 1889 deletions

2
.gitignore vendored
View File

@ -18,7 +18,7 @@ project.xcworkspace/
xcuserdata/ xcuserdata/
.DS_Store .DS_Store
build/ build/
src/macosx/M6502.ins src/os/macos/M6502.ins
*.dSYM *.dSYM
.vscode/c_cpp_properties.json .vscode/c_cpp_properties.json
.vscode/settings.json .vscode/settings.json

View File

@ -1017,6 +1017,7 @@ clearSaveStateIfs - Clear all saveState points
scanLine - Advance emulation by <xx> scanlines (default=1) scanLine - Advance emulation by <xx> scanlines (default=1)
step - Single step CPU [with count xx] step - Single step CPU [with count xx]
stepWhile - Single step CPU while <condition> is true stepWhile - Single step CPU while <condition> is true
swchb - Set SWCHB to value xx
tia - Show TIA state tia - Show TIA state
trace - Single step CPU over subroutines [with count xx] trace - Single step CPU over subroutines [with count xx]
trap - Trap read/write access to address(es) xx [yy] trap - Trap read/write access to address(es) xx [yy]

View File

@ -111,7 +111,7 @@ CheatCodeDialog::CheatCodeDialog(OSystem& osystem, DialogContainer& parent,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CheatCodeDialog::~CheatCodeDialog() CheatCodeDialog::~CheatCodeDialog() // NOLINT (we need an empty d'tor)
{ {
} }
@ -128,14 +128,14 @@ void CheatCodeDialog::loadConfig()
for(const auto& c: list) for(const auto& c: list)
{ {
l.push_back(c->name()); l.push_back(c->name());
b.push_back(bool(c->enabled())); b.push_back(c->enabled());
} }
myCheatList->setList(l, b); myCheatList->setList(l, b);
// Redraw the list, auto-selecting the first item if possible // Redraw the list, auto-selecting the first item if possible
myCheatList->setSelected(l.size() > 0 ? 0 : -1); myCheatList->setSelected(!l.empty() ? 0 : -1);
const bool enabled = (list.size() > 0); const bool enabled = !list.empty();
myEditButton->setEnabled(enabled); myEditButton->setEnabled(enabled);
myRemoveButton->setEnabled(enabled); myRemoveButton->setEnabled(enabled);
} }
@ -233,7 +233,7 @@ void CheatCodeDialog::handleCommand(CommandSender* sender, int cmd,
{ {
const string& name = myCheatInput->getResult(0); const string& name = myCheatInput->getResult(0);
const string& code = myCheatInput->getResult(1); const string& code = myCheatInput->getResult(1);
if(instance().cheat().isValidCode(code)) if(CheatManager::isValidCode(code))
{ {
myCheatInput->close(); myCheatInput->close();
instance().cheat().add(name, code); instance().cheat().add(name, code);
@ -250,7 +250,7 @@ void CheatCodeDialog::handleCommand(CommandSender* sender, int cmd,
const string& code = myCheatInput->getResult(1); const string& code = myCheatInput->getResult(1);
const bool enable = myCheatList->getSelectedState(); const bool enable = myCheatList->getSelectedState();
const int idx = myCheatList->getSelected(); const int idx = myCheatList->getSelected();
if(instance().cheat().isValidCode(code)) if(CheatManager::isValidCode(code))
{ {
myCheatInput->close(); myCheatInput->close();
instance().cheat().add(name, code, enable, idx); instance().cheat().add(name, code, enable, idx);
@ -273,7 +273,7 @@ void CheatCodeDialog::handleCommand(CommandSender* sender, int cmd,
{ {
const string& name = myCheatInput->getResult(0); const string& name = myCheatInput->getResult(0);
const string& code = myCheatInput->getResult(1); const string& code = myCheatInput->getResult(1);
if(instance().cheat().isValidCode(code)) if(CheatManager::isValidCode(code))
{ {
myCheatInput->close(); myCheatInput->close();
instance().cheat().addOneShot(name, code); instance().cheat().addOneShot(name, code);

View File

@ -93,8 +93,8 @@ void CheatManager::addPerFrame(const string& name, const string& code, bool enab
} }
// Make sure there are no duplicates // Make sure there are no duplicates
bool found = false; bool found{false};
uInt32 i; uInt32 i{0};
for(i = 0; i < myPerFrameList.size(); ++i) for(i = 0; i < myPerFrameList.size(); ++i)
{ {
if(myPerFrameList[i]->code() == cheat->code()) if(myPerFrameList[i]->code() == cheat->code())
@ -272,11 +272,11 @@ void CheatManager::loadCheats(const string& md5sum)
// Set up any cheatcodes that was on the command line // Set up any cheatcodes that was on the command line
// (and remove the key from the settings, so they won't get set again) // (and remove the key from the settings, so they won't get set again)
const string& cheats = myOSystem.settings().getString("cheat"); const string& cheats = myOSystem.settings().getString("cheat");
if(cheats != "") if(!cheats.empty())
myOSystem.settings().setValue("cheat", ""); myOSystem.settings().setValue("cheat", "");
const auto& iter = myCheatMap.find(md5sum); const auto& iter = myCheatMap.find(md5sum);
if(iter == myCheatMap.end() && cheats == "") if(iter == myCheatMap.end() && cheats.empty())
return; return;
// Remember the cheats for this ROM // Remember the cheats for this ROM
@ -311,7 +311,7 @@ void CheatManager::saveCheats(const string& md5sum)
myCheatMap.erase(iter); myCheatMap.erase(iter);
// Add new entry only if there are any cheats defined // Add new entry only if there are any cheats defined
if(cheats.str() != "") if(!cheats.str().empty())
myCheatMap.emplace(md5sum, cheats.str()); myCheatMap.emplace(md5sum, cheats.str());
} }
@ -322,7 +322,7 @@ void CheatManager::saveCheats(const string& md5sum)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CheatManager::isValidCode(const string& code) const bool CheatManager::isValidCode(const string& code)
{ {
for(const auto c: code) for(const auto c: code)
if(!isxdigit(c)) if(!isxdigit(c))

View File

@ -121,7 +121,7 @@ class CheatManager
/** /**
Checks if a code is valid. Checks if a code is valid.
*/ */
bool isValidCode(const string& code) const; static bool isValidCode(const string& code);
private: private:
/** /**

View File

@ -29,16 +29,20 @@ AudioQueue::AudioQueue(uInt32 fragmentSize, uInt32 capacity, bool isStereo)
{ {
const uInt8 sampleSize = myIsStereo ? 2 : 1; const uInt8 sampleSize = myIsStereo ? 2 : 1;
myFragmentBuffer = make_unique<Int16[]>(myFragmentSize * sampleSize * (capacity + 2)); myFragmentBuffer = make_unique<Int16[]>(
static_cast<size_t>(myFragmentSize) * sampleSize * (capacity + 2));
for (uInt32 i = 0; i < capacity; ++i) for (uInt32 i = 0; i < capacity; ++i)
myFragmentQueue[i] = myAllFragments[i] = myFragmentBuffer.get() + i * sampleSize * myFragmentSize; myFragmentQueue[i] = myAllFragments[i] = myFragmentBuffer.get() +
static_cast<size_t>(myFragmentSize) * sampleSize * i;
myAllFragments[capacity] = myFirstFragmentForEnqueue = myAllFragments[capacity] = myFirstFragmentForEnqueue =
myFragmentBuffer.get() + capacity * sampleSize * myFragmentSize; myFragmentBuffer.get() + static_cast<size_t>(myFragmentSize) * sampleSize *
capacity;
myAllFragments[capacity + 1] = myFirstFragmentForDequeue = myAllFragments[capacity + 1] = myFirstFragmentForDequeue =
myFragmentBuffer.get() + (capacity + 1) * sampleSize * myFragmentSize; myFragmentBuffer.get() + static_cast<size_t>(myFragmentSize) * sampleSize *
(capacity + 1);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -83,7 +87,7 @@ Int16* AudioQueue::enqueue(Int16* fragment)
return newFragment; return newFragment;
} }
const uInt8 capacity = static_cast<uInt8>(myFragmentQueue.size()); const auto capacity = static_cast<uInt8>(myFragmentQueue.size());
const uInt8 fragmentIndex = (myNextFragment + mySize) % capacity; const uInt8 fragmentIndex = (myNextFragment + mySize) % capacity;
newFragment = myFragmentQueue.at(fragmentIndex); newFragment = myFragmentQueue.at(fragmentIndex);

View File

@ -39,7 +39,7 @@ namespace {
numericResamplingQuality <= static_cast<int>(AudioSettings::ResamplingQuality::lanczos_3) numericResamplingQuality <= static_cast<int>(AudioSettings::ResamplingQuality::lanczos_3)
) ? static_cast<AudioSettings::ResamplingQuality>(numericResamplingQuality) : AudioSettings::DEFAULT_RESAMPLING_QUALITY; ) ? static_cast<AudioSettings::ResamplingQuality>(numericResamplingQuality) : AudioSettings::DEFAULT_RESAMPLING_QUALITY;
} }
} } // namespace
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AudioSettings::AudioSettings(Settings& settings) AudioSettings::AudioSettings(Settings& settings)

View File

@ -47,74 +47,83 @@ string Base::toString(int value, Common::Base::Fmt outputBase)
case Base::Fmt::_10: // base 10: 3 or 5 bytes (depending on value) case Base::Fmt::_10: // base 10: 3 or 5 bytes (depending on value)
if(value > -0x100 && value < 0x100) if(value > -0x100 && value < 0x100)
std::snprintf(vToS_buf, 5, "%3d", static_cast<Int16>(value)); std::ignore = std::snprintf(vToS_buf, 5, "%3d", static_cast<Int16>(value));
else else
std::snprintf(vToS_buf, 6, "%5d", value); std::ignore = std::snprintf(vToS_buf, 6, "%5d", value);
break; break;
case Base::Fmt::_10_02: // base 10: 2 digits (with leading zero) case Base::Fmt::_10_02: // base 10: 2 digits (with leading zero)
std::snprintf(vToS_buf, 3, "%02d", value); std::ignore = std::snprintf(vToS_buf, 3, "%02d", value);
break; break;
case Base::Fmt::_10_3: // base 10: 3 digits case Base::Fmt::_10_3: // base 10: 3 digits
std::snprintf(vToS_buf, 4, "%3d", value); std::ignore = std::snprintf(vToS_buf, 4, "%3d", value);
break; break;
case Base::Fmt::_10_4: // base 10: 4 digits case Base::Fmt::_10_4: // base 10: 4 digits
std::snprintf(vToS_buf, 5, "%4d", value); std::ignore = std::snprintf(vToS_buf, 5, "%4d", value);
break; break;
case Base::Fmt::_10_5: // base 10: 5 digits case Base::Fmt::_10_5: // base 10: 5 digits
std::snprintf(vToS_buf, 6, "%5d", value); std::ignore = std::snprintf(vToS_buf, 6, "%5d", value);
break; break;
case Base::Fmt::_10_6: // base 10: 6 digits case Base::Fmt::_10_6: // base 10: 6 digits
std::snprintf(vToS_buf, 7, "%6d", value); std::ignore = std::snprintf(vToS_buf, 7, "%6d", value);
break; break;
case Base::Fmt::_10_8: // base 10: 8 digits case Base::Fmt::_10_8: // base 10: 8 digits
std::snprintf(vToS_buf, 9, "%8d", value); std::ignore = std::snprintf(vToS_buf, 9, "%8d", value);
break; break;
case Base::Fmt::_16_1: // base 16: 1 byte wide case Base::Fmt::_16_1: // base 16: 1 byte wide
std::snprintf(vToS_buf, 2, hexUppercase() ? "%1X" : "%1x", value); std::ignore = std::snprintf(
vToS_buf, 2, hexUppercase() ? "%1X" : "%1x", value);
break; break;
case Base::Fmt::_16_2: // base 16: 2 bytes wide case Base::Fmt::_16_2: // base 16: 2 bytes wide
std::snprintf(vToS_buf, 3, hexUppercase() ? "%02X" : "%02x", value); std::ignore = std::snprintf(
vToS_buf, 3, hexUppercase() ? "%02X" : "%02x", value);
break; break;
case Base::Fmt::_16_2_2: case Base::Fmt::_16_2_2:
std::snprintf(vToS_buf, 6, hexUppercase() ? "%02X.%02X" : "%02x.%02x", std::ignore = std::snprintf(
vToS_buf, 6, hexUppercase() ? "%02X.%02X" : "%02x.%02x",
value >> 8, value & 0xff ); value >> 8, value & 0xff );
break; break;
case Base::Fmt::_16_3_2: case Base::Fmt::_16_3_2:
std::snprintf(vToS_buf, 7, hexUppercase() ? "%03X.%02X" : "%03x.%02x", std::ignore = std::snprintf(
vToS_buf, 7, hexUppercase() ? "%03X.%02X" : "%03x.%02x",
value >> 8, value & 0xff ); value >> 8, value & 0xff );
break; break;
case Base::Fmt::_16_4: // base 16: 4 bytes wide case Base::Fmt::_16_4: // base 16: 4 bytes wide
std::snprintf(vToS_buf, 5, hexUppercase() ? "%04X" : "%04x", value); std::ignore = std::snprintf(
vToS_buf, 5, hexUppercase() ? "%04X" : "%04x", value);
break; break;
case Base::Fmt::_16_8: // base 16: 8 bytes wide case Base::Fmt::_16_8: // base 16: 8 bytes wide
std::snprintf(vToS_buf, 9, hexUppercase() ? "%08X" : "%08x", value); std::ignore = std::snprintf(
vToS_buf, 9, hexUppercase() ? "%08X" : "%08x", value);
break; break;
case Base::Fmt::_16: // base 16: 2, 4, 8 bytes (depending on value) case Base::Fmt::_16: // base 16: 2, 4, 8 bytes (depending on value)
default: default:
if(value < 0x100) if(value < 0x100)
std::snprintf(vToS_buf, 3, hexUppercase() ? "%02X" : "%02x", value); std::ignore = std::snprintf(
vToS_buf, 3, hexUppercase() ? "%02X" : "%02x", value);
else if(value < 0x10000) else if(value < 0x10000)
std::snprintf(vToS_buf, 5, hexUppercase() ? "%04X" : "%04x", value); std::ignore = std::snprintf(
vToS_buf, 5, hexUppercase() ? "%04X" : "%04x", value);
else else
std::snprintf(vToS_buf, 9, hexUppercase() ? "%08X" : "%08x", value); std::ignore = std::snprintf(
vToS_buf, 9, hexUppercase() ? "%08X" : "%08x", value);
break; break;
} }
return string(vToS_buf); return {vToS_buf};
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Base::Fmt Base::myDefaultBase = Base::Fmt::_16; Base::Fmt Base::myDefaultBase = Base::Fmt::_16;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
std::ios_base::fmtflags Base::myHexflags = std::ios_base::hex; std::ios_base::fmtflags Base::myHexflags = std::ios_base::hex; // NOLINT
} // Namespace Common } // namespace Common

View File

@ -30,7 +30,8 @@ EventHandlerSDL2::EventHandlerSDL2(OSystem& osystem)
#ifdef GUI_SUPPORT #ifdef GUI_SUPPORT
{ {
ostringstream buf; ostringstream buf;
myQwertz = int{'y'} == static_cast<int>(SDL_GetKeyFromScancode(SDL_Scancode(KBDK_Z))); myQwertz = int{'y'} == static_cast<int>
(SDL_GetKeyFromScancode(static_cast<SDL_Scancode>(KBDK_Z)));
buf << "Keyboard: " << (myQwertz ? "QWERTZ" : "QWERTY"); buf << "Keyboard: " << (myQwertz ? "QWERTZ" : "QWERTY");
Logger::debug(buf.str()); Logger::debug(buf.str());
} }
@ -141,7 +142,7 @@ void EventHandlerSDL2::pollEvent()
case SDL_MOUSEWHEEL: case SDL_MOUSEWHEEL:
{ {
int x, y; int x{0}, y{0};
SDL_GetMouseState(&x, &y); // we need mouse position too SDL_GetMouseState(&x, &y); // we need mouse position too
if(myEvent.wheel.y < 0) if(myEvent.wheel.y < 0)
handleMouseButtonEvent(MouseButton::WHEELDOWN, true, x, y); handleMouseButtonEvent(MouseButton::WHEELDOWN, true, x, y);

View File

@ -97,8 +97,7 @@ void FBBackendSDL2::queryHardware(vector<Common::Size>& fullscreenRes,
s << "Supported video modes (" << numModes << ") for display " << i s << "Supported video modes (" << numModes << ") for display " << i
<< " (" << SDL_GetDisplayName(i) << "):"; << " (" << SDL_GetDisplayName(i) << "):";
string lastRes = ""; string lastRes;
for(int m = 0; m < numModes; ++m) for(int m = 0; m < numModes; ++m)
{ {
SDL_DisplayMode mode; SDL_DisplayMode mode;
@ -174,11 +173,11 @@ void FBBackendSDL2::queryHardware(vector<Common::Size>& fullscreenRes,
{ {
// Map SDL names into nicer Stella names (if available) // Map SDL names into nicer Stella names (if available)
bool found = false; bool found = false;
for(size_t j = 0; j < RENDERER_NAMES.size(); ++j) for(const auto& render: RENDERER_NAMES)
{ {
if(RENDERER_NAMES[j].sdlName == info.name) if(render.sdlName == info.name)
{ {
VarList::push_back(renderers, RENDERER_NAMES[j].stellaName, info.name); VarList::push_back(renderers, render.stellaName, info.name);
found = true; found = true;
break; break;
} }
@ -284,7 +283,7 @@ bool FBBackendSDL2::setVideoMode(const VideoModeHandler::Mode& mode,
if(myWindow) if(myWindow)
{ {
const int d = SDL_GetWindowDisplayIndex(myWindow); const int d = SDL_GetWindowDisplayIndex(myWindow);
int w, h; int w{0}, h{0};
SDL_GetWindowSize(myWindow, &w, &h); SDL_GetWindowSize(myWindow, &w, &h);
if(d != displayIndex || static_cast<uInt32>(w) != mode.screenS.w || if(d != displayIndex || static_cast<uInt32>(w) != mode.screenS.w ||
@ -358,8 +357,8 @@ bool FBBackendSDL2::adaptRefreshRate(Int32 displayIndex,
const int wantedRefreshRate = const int wantedRefreshRate =
myOSystem.hasConsole() ? myOSystem.console().gameRefreshRate() : 0; myOSystem.hasConsole() ? myOSystem.console().gameRefreshRate() : 0;
// Take care of rounded refresh rates (e.g. 59.94 Hz) // Take care of rounded refresh rates (e.g. 59.94 Hz)
float factor = std::min(float(currentRefreshRate) / wantedRefreshRate, float factor = std::min(
float(currentRefreshRate) / (wantedRefreshRate - 1)); static_cast<float>(currentRefreshRate) / wantedRefreshRate, static_cast<float>(currentRefreshRate) / (wantedRefreshRate - 1));
// Calculate difference taking care of integer factors (e.g. 100/120) // Calculate difference taking care of integer factors (e.g. 100/120)
float bestDiff = std::abs(factor - std::round(factor)) / factor; float bestDiff = std::abs(factor - std::round(factor)) / factor;
bool adapt = false; bool adapt = false;
@ -378,8 +377,9 @@ bool FBBackendSDL2::adaptRefreshRate(Int32 displayIndex,
Logger::error("ERROR: Closest display mode could not be retrieved"); Logger::error("ERROR: Closest display mode could not be retrieved");
return adapt; return adapt;
} }
factor = std::min(float(sdlMode.refresh_rate) / sdlMode.refresh_rate, factor = std::min(
float(sdlMode.refresh_rate) / (sdlMode.refresh_rate - 1)); static_cast<float>(sdlMode.refresh_rate) / sdlMode.refresh_rate,
static_cast<float>(sdlMode.refresh_rate) / (sdlMode.refresh_rate - 1));
const float diff = std::abs(factor - std::round(factor)) / factor; const float diff = std::abs(factor - std::round(factor)) / factor;
if(diff < bestDiff) if(diff < bestDiff)
{ {
@ -428,7 +428,7 @@ bool FBBackendSDL2::createRenderer()
if(myRenderer) if(myRenderer)
SDL_DestroyRenderer(myRenderer); SDL_DestroyRenderer(myRenderer);
if(video != "") if(!video.empty())
SDL_SetHint(SDL_HINT_RENDER_DRIVER, video.c_str()); SDL_SetHint(SDL_HINT_RENDER_DRIVER, video.c_str());
myRenderer = SDL_CreateRenderer(myWindow, -1, renderFlags); myRenderer = SDL_CreateRenderer(myWindow, -1, renderFlags);
@ -567,7 +567,7 @@ unique_ptr<FBSurface> FBBackendSDL2::createSurface(
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void FBBackendSDL2::readPixels(uInt8* pixels, uInt32 pitch, void FBBackendSDL2::readPixels(uInt8* buffer, size_t pitch,
const Common::Rect& rect) const const Common::Rect& rect) const
{ {
ASSERT_MAIN_THREAD; ASSERT_MAIN_THREAD;
@ -576,7 +576,7 @@ void FBBackendSDL2::readPixels(uInt8* pixels, uInt32 pitch,
r.x = rect.x(); r.y = rect.y(); r.x = rect.x(); r.y = rect.y();
r.w = rect.w(); r.h = rect.h(); r.w = rect.w(); r.h = rect.h();
SDL_RenderReadPixels(myRenderer, &r, 0, pixels, pitch); SDL_RenderReadPixels(myRenderer, &r, 0, buffer, static_cast<int>(pitch));
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -121,7 +121,7 @@ class FBBackendSDL2 : public FBBackend
@param pitch The pitch (in bytes) for the pixel data @param pitch The pitch (in bytes) for the pixel data
@param rect The bounding rectangle for the buffer @param rect The bounding rectangle for the buffer
*/ */
void readPixels(uInt8* buffer, uInt32 pitch, void readPixels(uInt8* buffer, size_t pitch,
const Common::Rect& rect) const override; const Common::Rect& rect) const override;
/** /**

View File

@ -38,7 +38,7 @@ namespace {
throw runtime_error("unreachable"); throw runtime_error("unreachable");
} }
} }
} } // namespace
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FBSurfaceSDL2::FBSurfaceSDL2(FBBackendSDL2& backend, FBSurfaceSDL2::FBSurfaceSDL2(FBBackendSDL2& backend,
@ -249,9 +249,10 @@ void FBSurfaceSDL2::createSurface(uInt32 width, uInt32 height,
myIsStatic = data != nullptr; myIsStatic = data != nullptr;
if(myIsStatic) if(myIsStatic)
SDL_memcpy(mySurface->pixels, data, mySurface->w * mySurface->h * 4); SDL_memcpy(mySurface->pixels, data,
static_cast<size_t>(mySurface->w) * mySurface->h * 4);
reload(); reload(); // NOLINT
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -38,7 +38,7 @@ FSNodeZIP::FSNodeZIP(const string& p)
// Expand '~' to the users 'home' directory // Expand '~' to the users 'home' directory
if (_zipFile[0] == '~') if (_zipFile[0] == '~')
{ {
const char* home = std::getenv("HOME"); const char* home = std::getenv("HOME"); // NOLINT (not thread safe)
if (home != nullptr) if (home != nullptr)
_zipFile.replace(0, 1, home); _zipFile.replace(0, 1, home);
} }
@ -127,7 +127,7 @@ void FSNodeZIP::setFlags(const string& zipfile, const string& virtualpath,
_shortPath = _realNode->getShortPath(); _shortPath = _realNode->getShortPath();
// Is a file component present? // Is a file component present?
if(_virtualPath.size() != 0) if(!_virtualPath.empty())
{ {
_path += ("/" + _virtualPath); _path += ("/" + _virtualPath);
_shortPath += ("/" + _virtualPath); _shortPath += ("/" + _virtualPath);
@ -186,7 +186,7 @@ bool FSNodeZIP::getChildren(AbstractFSList& myList, ListMode mode) const
{ {
// First strip off the leading directory // First strip off the leading directory
const string& curr = name.substr( const string& curr = name.substr(
_virtualPath == "" ? 0 : _virtualPath.size()+1); _virtualPath.empty() ? 0 : _virtualPath.size()+1);
// cerr << " curr: " << curr << endl; // cerr << " curr: " << curr << endl;
// Only add sub-directory entries once // Only add sub-directory entries once
const auto pos = curr.find_first_of("/\\"); const auto pos = curr.find_first_of("/\\");
@ -199,7 +199,7 @@ bool FSNodeZIP::getChildren(AbstractFSList& myList, ListMode mode) const
for(const auto& dir: dirs) for(const auto& dir: dirs)
{ {
// Prepend previous path // Prepend previous path
const string& vpath = _virtualPath != "" ? _virtualPath + "/" + dir : dir; const string& vpath = !_virtualPath.empty() ? _virtualPath + "/" + dir : dir;
myList.emplace_back(new FSNodeZIP(_zipFile, vpath, _realNode, 0, true)); myList.emplace_back(new FSNodeZIP(_zipFile, vpath, _realNode, 0, true));
} }
@ -211,7 +211,7 @@ bool FSNodeZIP::getChildren(AbstractFSList& myList, ListMode mode) const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
size_t FSNodeZIP::read(ByteBuffer& image, size_t) const size_t FSNodeZIP::read(ByteBuffer& buffer, size_t) const
{ {
switch(_error) switch(_error)
{ {
@ -230,24 +230,24 @@ size_t FSNodeZIP::read(ByteBuffer& image, size_t) const
found = name == _virtualPath; found = name == _virtualPath;
} }
return found ? myZipHandler->decompress(image) : 0; return found ? myZipHandler->decompress(buffer) : 0;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
size_t FSNodeZIP::read(stringstream& image) const size_t FSNodeZIP::read(stringstream& buffer) const
{ {
// For now, we just read into a buffer and store in the stream // For now, we just read into a buffer and store in the stream
// TODO: maybe there's a more efficient way to do this? // TODO: maybe there's a more efficient way to do this?
ByteBuffer buffer; ByteBuffer read_buf;
const size_t size = read(buffer, 0); const size_t size = read(read_buf, 0);
if(size > 0) if(size > 0)
image.write(reinterpret_cast<char*>(buffer.get()), size); buffer.write(reinterpret_cast<char*>(read_buf.get()), size);
return size; return size;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
size_t FSNodeZIP::write(const ByteBuffer& buffer, size_t size) const size_t FSNodeZIP::write(const ByteBuffer& buffer, size_t) const
{ {
// TODO: Not yet implemented // TODO: Not yet implemented
throw runtime_error("ZIP file not writable"); throw runtime_error("ZIP file not writable");
@ -263,7 +263,7 @@ size_t FSNodeZIP::write(const stringstream& buffer) const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AbstractFSNodePtr FSNodeZIP::getParent() const AbstractFSNodePtr FSNodeZIP::getParent() const
{ {
if(_virtualPath == "") if(_virtualPath.empty())
return _realNode ? _realNode->getParent() : nullptr; return _realNode ? _realNode->getParent() : nullptr;
const char* start = _path.c_str(); const char* start = _path.c_str();

View File

@ -63,9 +63,9 @@ class FSNodeZIP : public AbstractFSNode
bool getChildren(AbstractFSList& list, ListMode mode) const override; bool getChildren(AbstractFSList& list, ListMode mode) const override;
AbstractFSNodePtr getParent() const override; AbstractFSNodePtr getParent() const override;
size_t read(ByteBuffer& buffer, size_t size) const override; size_t read(ByteBuffer& buffer, size_t) const override;
size_t read(stringstream& buffer) const override; size_t read(stringstream& buffer) const override;
size_t write(const ByteBuffer& buffer, size_t size) const override; size_t write(const ByteBuffer& buffer, size_t) const override;
size_t write(const stringstream& buffer) const override; size_t write(const stringstream& buffer) const override;
private: private:

View File

@ -65,9 +65,10 @@ HighScoresManager::HighScoresManager(OSystem& osystem)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void HighScoresManager::setRepository(shared_ptr<CompositeKeyValueRepositoryAtomic> repo) void HighScoresManager::setRepository(
shared_ptr<CompositeKeyValueRepositoryAtomic> repo)
{ {
myHighscoreRepository = repo; myHighscoreRepository = std::move(repo);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -84,7 +85,7 @@ Int16 HighScoresManager::peek(uInt16 addr) const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const json HighScoresManager::properties(const Properties& props) const json HighScoresManager::properties(const Properties& props)
{ {
const string& property = props.get(PropType::Cart_Highscore); const string& property = props.get(PropType::Cart_Highscore);
@ -94,7 +95,6 @@ const json HighScoresManager::properties(const Properties& props) const
return json::parse(property); return json::parse(property);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
json HighScoresManager::properties(json& jprops) const json HighScoresManager::properties(json& jprops) const
{ {
@ -113,7 +113,6 @@ json HighScoresManager::properties(json& jprops) const
return jprops = properties(props); return jprops = properties(props);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool HighScoresManager::enabled() const bool HighScoresManager::enabled() const
{ {
@ -123,12 +122,11 @@ bool HighScoresManager::enabled() const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 HighScoresManager::numVariations(const json& jprops) const uInt32 HighScoresManager::numVariations(const json& jprops)
{ {
return min(getPropInt(jprops, VARIATIONS_COUNT, DEFAULT_VARIATION), MAX_VARIATIONS); return min(getPropInt(jprops, VARIATIONS_COUNT, DEFAULT_VARIATION), MAX_VARIATIONS);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool HighScoresManager::get(const Properties& props, uInt32& numVariationsR, bool HighScoresManager::get(const Properties& props, uInt32& numVariationsR,
ScoresProps& info) const ScoresProps& info) const
@ -158,7 +156,7 @@ bool HighScoresManager::get(const Properties& props, uInt32& numVariationsR,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void HighScoresManager::set(Properties& props, uInt32 numVariations, void HighScoresManager::set(Properties& props, uInt32 numVariations,
const ScoresProps& info) const const ScoresProps& info)
{ {
json jprops = json::object(); json jprops = json::object();
@ -206,85 +204,79 @@ void HighScoresManager::set(Properties& props, uInt32 numVariations,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 HighScoresManager::numDigits(const json& jprops) const uInt32 HighScoresManager::numDigits(const json& jprops)
{ {
return min(getPropInt(jprops, SCORE_DIGITS, DEFAULT_DIGITS), MAX_SCORE_DIGITS); return min(getPropInt(jprops, SCORE_DIGITS, DEFAULT_DIGITS), MAX_SCORE_DIGITS);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 HighScoresManager::trailingZeroes(const json& jprops) const uInt32 HighScoresManager::trailingZeroes(const json& jprops)
{ {
return min(getPropInt(jprops, SCORE_TRAILING_ZEROES, DEFAULT_TRAILING), MAX_TRAILING); return min(getPropInt(jprops, SCORE_TRAILING_ZEROES, DEFAULT_TRAILING), MAX_TRAILING);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool HighScoresManager::scoreBCD(const json& jprops) const bool HighScoresManager::scoreBCD(const json& jprops)
{ {
return getPropBool(jprops, SCORE_BCD, DEFAULT_SCORE_BCD); return getPropBool(jprops, SCORE_BCD, DEFAULT_SCORE_BCD);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool HighScoresManager::scoreInvert(const json& jprops) const bool HighScoresManager::scoreInvert(const json& jprops)
{ {
return getPropBool(jprops, SCORE_INVERTED, DEFAULT_SCORE_REVERSED); return getPropBool(jprops, SCORE_INVERTED, DEFAULT_SCORE_REVERSED);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool HighScoresManager::varBCD(const json& jprops) const bool HighScoresManager::varBCD(const json& jprops)
{ {
return getPropBool(jprops, VARIATIONS_BCD, DEFAULT_VARS_BCD); return getPropBool(jprops, VARIATIONS_BCD, DEFAULT_VARS_BCD);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool HighScoresManager::varZeroBased(const json& jprops) const bool HighScoresManager::varZeroBased(const json& jprops)
{ {
return getPropBool(jprops, VARIATIONS_ZERO_BASED, DEFAULT_VARS_ZERO_BASED); return getPropBool(jprops, VARIATIONS_ZERO_BASED, DEFAULT_VARS_ZERO_BASED);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string HighScoresManager::specialLabel(const json& jprops) const string HighScoresManager::specialLabel(const json& jprops)
{ {
return getPropStr(jprops, SPECIAL_LABEL); return getPropStr(jprops, SPECIAL_LABEL);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool HighScoresManager::specialBCD(const json& jprops) const bool HighScoresManager::specialBCD(const json& jprops)
{ {
return getPropBool(jprops, SPECIAL_BCD, DEFAULT_SPECIAL_BCD); return getPropBool(jprops, SPECIAL_BCD, DEFAULT_SPECIAL_BCD);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool HighScoresManager::specialZeroBased(const json& jprops) const bool HighScoresManager::specialZeroBased(const json& jprops)
{ {
return getPropBool(jprops, SPECIAL_ZERO_BASED, DEFAULT_SPECIAL_ZERO_BASED); return getPropBool(jprops, SPECIAL_ZERO_BASED, DEFAULT_SPECIAL_ZERO_BASED);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string HighScoresManager::notes(const json& jprops) const string HighScoresManager::notes(const json& jprops)
{ {
return getPropStr(jprops, NOTES); return getPropStr(jprops, NOTES);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 HighScoresManager::varAddress(const json& jprops) const uInt16 HighScoresManager::varAddress(const json& jprops)
{ {
return getPropAddr(jprops, VARIATIONS_ADDRESS, DEFAULT_ADDRESS); return getPropAddr(jprops, VARIATIONS_ADDRESS, DEFAULT_ADDRESS);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 HighScoresManager::specialAddress(const json& jprops) const uInt16 HighScoresManager::specialAddress(const json& jprops)
{ {
return getPropAddr(jprops, SPECIAL_ADDRESS, DEFAULT_ADDRESS); return getPropAddr(jprops, SPECIAL_ADDRESS, DEFAULT_ADDRESS);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 HighScoresManager::numAddrBytes(Int32 digits, Int32 trailing) const uInt32 HighScoresManager::numAddrBytes(const json& jprops)
{
return (digits - trailing + 1) / 2;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 HighScoresManager::numAddrBytes(const json& jprops) const
{ {
return numAddrBytes(numDigits(jprops), trailingZeroes(jprops)); return numAddrBytes(numDigits(jprops), trailingZeroes(jprops));
} }
@ -298,7 +290,7 @@ Int32 HighScoresManager::numVariations() const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string HighScoresManager::specialLabel() const string HighScoresManager::specialLabel() const
{ {
json jprops; json jprops;
@ -378,7 +370,7 @@ Int32 HighScoresManager::score() const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string HighScoresManager::formattedScore(Int32 score, Int32 width) const string HighScoresManager::formattedScore(Int32 score, Int32 width) const
{ {
if(score <= 0) if(score <= 0)
return ""; return "";
@ -402,6 +394,7 @@ const string HighScoresManager::formattedScore(Int32 score, Int32 width) const
return buf.str(); return buf.str();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string HighScoresManager::md5Props() const string HighScoresManager::md5Props() const
{ {
json jprops; json jprops;
@ -424,6 +417,7 @@ string HighScoresManager::md5Props() const
return MD5::hash(buf.str()); return MD5::hash(buf.str());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool HighScoresManager::scoreInvert() const bool HighScoresManager::scoreInvert() const
{ {
json jprops; json jprops;
@ -454,7 +448,7 @@ Int32 HighScoresManager::special() const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string HighScoresManager::notes() const string HighScoresManager::notes() const
{ {
json jprops; json jprops;
@ -462,7 +456,8 @@ const string HighScoresManager::notes() const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Int32 HighScoresManager::convert(Int32 val, uInt32 maxVal, bool isBCD, bool zeroBased) const Int32 HighScoresManager::convert(Int32 val, uInt32 maxVal, bool isBCD,
bool zeroBased)
{ {
//maxVal += zeroBased ? 0 : 1; //maxVal += zeroBased ? 0 : 1;
maxVal -= zeroBased ? 1 : 0; maxVal -= zeroBased ? 1 : 0;
@ -486,29 +481,28 @@ Int32 HighScoresManager::convert(Int32 val, uInt32 maxVal, bool isBCD, bool zero
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool HighScoresManager::getPropBool(const json& jprops, const string& key, bool HighScoresManager::getPropBool(const json& jprops, const string& key,
bool defVal) const bool defVal)
{ {
return jprops.contains(key) ? jprops.at(key).get<bool>() : defVal; return jprops.contains(key) ? jprops.at(key).get<bool>() : defVal;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 HighScoresManager::getPropInt(const json& jprops, const string& key, uInt32 HighScoresManager::getPropInt(const json& jprops, const string& key,
uInt32 defVal) const uInt32 defVal)
{ {
return jprops.contains(key) ? jprops.at(key).get<uInt32>() : defVal; return jprops.contains(key) ? jprops.at(key).get<uInt32>() : defVal;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string HighScoresManager::getPropStr(const json& jprops, const string& key, string HighScoresManager::getPropStr(const json& jprops, const string& key,
const string& defVal) const const string& defVal)
{ {
return jprops.contains(key) ? jprops.at(key).get<string>() : defVal; return jprops.contains(key) ? jprops.at(key).get<string>() : defVal;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 HighScoresManager::getPropAddr(const json& jprops, const string& key, uInt16 HighScoresManager::getPropAddr(const json& jprops, const string& key,
uInt16 defVal) const uInt16 defVal)
{ {
const string str = getPropStr(jprops, key); const string str = getPropStr(jprops, key);
@ -516,7 +510,7 @@ uInt16 HighScoresManager::getPropAddr(const json& jprops, const string& key,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const HSM::ScoreAddresses HighScoresManager::getPropScoreAddr(const json& jprops) const HSM::ScoreAddresses HighScoresManager::getPropScoreAddr(const json& jprops)
{ {
ScoreAddresses scoreAddr{}; ScoreAddresses scoreAddr{};
@ -543,7 +537,7 @@ const HSM::ScoreAddresses HighScoresManager::getPropScoreAddr(const json& jprops
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 HighScoresManager::fromHexStr(const string& addr) const uInt16 HighScoresManager::fromHexStr(const string& addr)
{ {
string naked = addr; string naked = addr;
@ -554,7 +548,7 @@ uInt16 HighScoresManager::fromHexStr(const string& addr) const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Int32 HighScoresManager::fromBCD(uInt8 bcd) const Int32 HighScoresManager::fromBCD(uInt8 bcd)
{ {
// verify if score is legit // verify if score is legit
if ((bcd & 0xF0) >= 0xA0 || (bcd & 0xF) >= 0xA) if ((bcd & 0xF0) >= 0xA0 || (bcd & 0xF) >= 0xA)
@ -701,12 +695,12 @@ bool HighScoresManager::load(const json& hsData, ScoresData& data)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void HighScoresManager::clearHighScores(ScoresData& data) void HighScoresManager::clearHighScores(ScoresData& data)
{ {
for(uInt32 r = 0; r < NUM_RANKS; ++r) for(auto& s: data.scores)
{ {
data.scores[r].score = 0; s.score = 0;
data.scores[r].special = 0; s.special = 0;
data.scores[r].name = ""; s.name = "";
data.scores[r].date = ""; s.date = "";
} }
} }

View File

@ -112,8 +112,8 @@ class HighScoresManager
/** /**
Set the highscore data of game's properties Set the highscore data of game's properties
*/ */
void set(Properties& props, uInt32 numVariations, static void set(Properties& props, uInt32 numVariations,
const HSM::ScoresProps& info) const; const HSM::ScoresProps& info);
/** /**
Calculate the score from given parameters Calculate the score from given parameters
@ -125,24 +125,26 @@ class HighScoresManager
// Convert the given value, using only the maximum bits required by maxVal // Convert the given value, using only the maximum bits required by maxVal
// and adjusted for BCD and zero based data // and adjusted for BCD and zero based data
Int32 convert(Int32 val, uInt32 maxVal, bool isBCD, bool zeroBased) const; static Int32 convert(Int32 val, uInt32 maxVal, bool isBCD, bool zeroBased);
/** /**
Calculate the number of bytes for one player's score from given parameters Calculate the number of bytes for one player's score from given parameters
@return The number of score address bytes @return The number of score address bytes
*/ */
uInt32 numAddrBytes(Int32 digits, Int32 trailing) const; static uInt32 numAddrBytes(Int32 digits, Int32 trailing) {
return (digits - trailing + 1) / 2;
}
// Retrieve current values (using game's properties) // Retrieve current values (using game's properties)
Int32 numVariations() const; Int32 numVariations() const;
const string specialLabel() const; string specialLabel() const;
Int32 variation() const; Int32 variation() const;
Int32 score() const; Int32 score() const;
const string formattedScore(Int32 score, Int32 width = -1) const; string formattedScore(Int32 score, Int32 width = -1) const;
bool scoreInvert() const; bool scoreInvert() const;
Int32 special() const; Int32 special() const;
const string notes() const; string notes() const;
// Get md5 property definition checksum // Get md5 property definition checksum
string md5Props() const; string md5Props() const;
@ -150,8 +152,8 @@ class HighScoresManager
// Peek into memory // Peek into memory
Int16 peek(uInt16 addr) const; Int16 peek(uInt16 addr) const;
void loadHighScores(HSM::ScoresData& scores); void loadHighScores(HSM::ScoresData& data);
void saveHighScores(HSM::ScoresData& scores) const; void saveHighScores(HSM::ScoresData& data) const;
private: private:
static const string VARIATIONS_COUNT; static const string VARIATIONS_COUNT;
@ -198,53 +200,53 @@ class HighScoresManager
Int32 variation(uInt16 addr, bool varBCD, bool zeroBased, uInt32 numVariations) const; Int32 variation(uInt16 addr, bool varBCD, bool zeroBased, uInt32 numVariations) const;
// Get individual highscore info from properties // Get individual highscore info from properties
uInt32 numVariations(const json& jprops) const; static uInt32 numVariations(const json& jprops);
uInt16 varAddress(const json& jprops) const; static uInt16 varAddress(const json& jprops);
uInt16 specialAddress(const json& jprops) const; static uInt16 specialAddress(const json& jprops);
uInt32 numDigits(const json& jprops) const; static uInt32 numDigits(const json& jprops);
uInt32 trailingZeroes(const json& jprops) const; static uInt32 trailingZeroes(const json& jprops);
bool scoreBCD(const json& jprops) const; static bool scoreBCD(const json& jprops);
bool scoreInvert(const json& jprops) const; static bool scoreInvert(const json& jprops);
bool varBCD(const json& jprops) const; static bool varBCD(const json& jprops);
bool varZeroBased(const json& jprops) const; static bool varZeroBased(const json& jprops);
const string specialLabel(const json& jprops) const; static string specialLabel(const json& jprops);
bool specialBCD(const json& jprops) const; static bool specialBCD(const json& jprops);
bool specialZeroBased(const json& jprops) const; static bool specialZeroBased(const json& jprops);
const string notes(const json& jprops) const; static string notes(const json& jprops);
// Calculate the number of bytes for one player's score from property parameters // Calculate the number of bytes for one player's score from property parameters
uInt32 numAddrBytes(const json& jprops) const; static uInt32 numAddrBytes(const json& jprops);
// Get properties // Get properties
const json properties(const Properties& props) const; static json properties(const Properties& props);
json properties(json& jprops) const; json properties(json& jprops) const;
// Get value from highscore properties for given key // Get value from highscore properties for given key
bool getPropBool(const json& jprops, const string& key, static bool getPropBool(const json& jprops, const string& key,
bool defVal = false) const; bool defVal = false);
uInt32 getPropInt(const json& jprops, const string& key, static uInt32 getPropInt(const json& jprops, const string& key,
uInt32 defVal = 0) const; uInt32 defVal = 0);
const string getPropStr(const json& jprops, const string& key, static string getPropStr(const json& jprops, const string& key,
const string& defVal = "") const; const string& defVal = "");
uInt16 getPropAddr(const json& jprops, const string& key, static uInt16 getPropAddr(const json& jprops, const string& key,
uInt16 defVal = 0) const; uInt16 defVal = 0);
const HSM::ScoreAddresses getPropScoreAddr(const json& jprops) const; static HSM::ScoreAddresses getPropScoreAddr(const json& jprops);
uInt16 fromHexStr(const string& addr) const; static uInt16 fromHexStr(const string& addr);
Int32 fromBCD(uInt8 bcd) const; static Int32 fromBCD(uInt8 bcd);
string hash(const HSM::ScoresData& data) const; string hash(const HSM::ScoresData& data) const;
/** /**
Loads the current high scores for this game and variation from the given JSON object. Loads the current high scores for this game and variation from the given JSON object.
@param hsData The JSON to parse @param hsData The JSON to parse
@param scores The loaded high score data @param data The loaded high score data
@return The result of the load. True on success, false on failure. @return The result of the load. True on success, false on failure.
*/ */
bool load(const json& hsData, HSM::ScoresData& scores); static bool load(const json& hsData, HSM::ScoresData& data);
void clearHighScores(HSM::ScoresData& data); static void clearHighScores(HSM::ScoresData& data);
private: private:
// Reference to the osystem object // Reference to the osystem object
@ -261,4 +263,5 @@ class HighScoresManager
HighScoresManager& operator=(const HighScoresManager&) = delete; HighScoresManager& operator=(const HighScoresManager&) = delete;
HighScoresManager& operator=(HighScoresManager&&) = delete; HighScoresManager& operator=(HighScoresManager&&) = delete;
}; };
#endif #endif

View File

@ -87,7 +87,7 @@ void JPGLibrary::loadImagetoSurface(FBSurface& surface)
surface.setSrcSize(iw, ih); surface.setSrcSize(iw, ih);
// Convert RGB triples into pixels and store in the surface // Convert RGB triples into pixels and store in the surface
uInt32* s_buf, s_pitch; uInt32 *s_buf{nullptr}, s_pitch{0};
surface.basePtr(s_buf, s_pitch); surface.basePtr(s_buf, s_pitch);
const uInt8* i_buf = myReadInfo.buffer; const uInt8* i_buf = myReadInfo.buffer;
const uInt32 i_pitch = myReadInfo.pitch; const uInt32 i_pitch = myReadInfo.pitch;

View File

@ -46,7 +46,8 @@ class JPGLibrary
runtime_error is thrown containing a more detailed runtime_error is thrown containing a more detailed
error message. error message.
*/ */
void loadImage(const string& filename, FBSurface& surface, VariantList& metaData); void loadImage(const string& filename, FBSurface& surface,
VariantList& metaData);
private: private:
// Global OSystem object // Global OSystem object
@ -76,7 +77,7 @@ class JPGLibrary
@param filename The filename to load the JPG image @param filename The filename to load the JPG image
@param metaData The meta data of the JPG image @param metaData The meta data of the JPG image
*/ */
void readMetaData(const string& filename, VariantList& metaData); static void readMetaData(const string& filename, VariantList& metaData);
private: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported

View File

@ -112,7 +112,7 @@ bool JoyMap::check(const EventMode mode, const int button,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string JoyMap::getDesc(const Event::Type event, const JoyMapping& mapping) const string JoyMap::getDesc(const Event::Type event, const JoyMapping& mapping)
{ {
ostringstream buf; ostringstream buf;
@ -166,7 +166,7 @@ string JoyMap::getEventMappingDesc(int stick, const Event::Type event, const Eve
{ {
if (_event == event && _mapping.mode == mode) if (_event == event && _mapping.mode == mode)
{ {
if(buf.str() != "") if(!buf.str().empty())
buf << ", "; buf << ", ";
buf << "C" << stick << getDesc(event, _mapping); buf << "C" << stick << getDesc(event, _mapping);
} }
@ -298,18 +298,18 @@ json JoyMap::convertLegacyMapping(string list)
{ {
json eventMapping = json::object(); json eventMapping = json::object();
eventMapping["event"] = Event::Type(event); eventMapping["event"] = static_cast<Event::Type>(event);
if(button != JOY_CTRL_NONE) eventMapping["button"] = button; if(button != JOY_CTRL_NONE) eventMapping["button"] = button;
if(static_cast<JoyAxis>(axis) != JoyAxis::NONE) { if(static_cast<JoyAxis>(axis) != JoyAxis::NONE) {
eventMapping["axis"] = JoyAxis(axis); eventMapping["axis"] = static_cast<JoyAxis>(axis);
eventMapping["axisDirection"] = JoyDir(adir); eventMapping["axisDirection"] = static_cast<JoyDir>(adir);
} }
if(hat != -1) { if(hat != -1) {
eventMapping["hat"] = hat; eventMapping["hat"] = hat;
eventMapping["hatDirection"] = JoyHatDir(hdir); eventMapping["hatDirection"] = static_cast<JoyHatDir>(hdir);
} }
eventMappings.push_back(eventMapping); eventMappings.push_back(eventMapping);

View File

@ -122,10 +122,10 @@ class JoyMap
void eraseEvent(const Event::Type event, const EventMode mode); void eraseEvent(const Event::Type event, const EventMode mode);
/** clear all mappings for a modes */ /** clear all mappings for a modes */
// void clear() { myMap.clear(); } // void clear() { myMap.clear(); }
size_t size() { return myMap.size(); } size_t size() const { return myMap.size(); }
private: private:
string getDesc(const Event::Type event, const JoyMapping& mapping) const; static string getDesc(const Event::Type event, const JoyMapping& mapping);
struct JoyHash { struct JoyHash {
size_t operator()(const JoyMapping& m)const { size_t operator()(const JoyMapping& m)const {

View File

@ -25,7 +25,7 @@ using json = nlohmann::json;
namespace { namespace {
json serializeModkeyMask(int mask) json serializeModkeyMask(int mask)
{ {
if(mask == StellaMod::KBDM_NONE) return json(nullptr); if(mask == StellaMod::KBDM_NONE) return {};
json serializedMask = json::array(); json serializedMask = json::array();
@ -66,7 +66,7 @@ namespace {
return mask; return mask;
} }
} } // namespace
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void KeyMap::add(const Event::Type event, const Mapping& mapping) void KeyMap::add(const Event::Type event, const Mapping& mapping)
@ -135,7 +135,7 @@ bool KeyMap::check(const EventMode mode, const int key, const int mod) const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string KeyMap::getDesc(const Mapping& mapping) const string KeyMap::getDesc(const Mapping& mapping)
{ {
ostringstream buf; ostringstream buf;
#if defined(BSPF_MACOS) || defined(MACOS_KEYS) #if defined(BSPF_MACOS) || defined(MACOS_KEYS)
@ -184,7 +184,7 @@ string KeyMap::getDesc(const Mapping& mapping) const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string KeyMap::getDesc(const EventMode mode, const int key, const int mod) const string KeyMap::getDesc(const EventMode mode, const int key, const int mod)
{ {
return getDesc(Mapping(mode, key, mod)); return getDesc(Mapping(mode, key, mod));
} }
@ -198,7 +198,7 @@ string KeyMap::getEventMappingDesc(const Event::Type event, const EventMode mode
{ {
if (_event == event && _mapping.mode == mode) if (_event == event && _mapping.mode == mode)
{ {
if(buf.str() != "") if(!buf.str().empty())
buf << ", "; buf << ", ";
buf << getDesc(_mapping); buf << getDesc(_mapping);
} }
@ -301,11 +301,11 @@ json KeyMap::convertLegacyMapping(string list)
{ {
json mapping = json::object(); json mapping = json::object();
mapping["event"] = Event::Type(event); mapping["event"] = static_cast<Event::Type>(event);
mapping["key"] = StellaKey(key); mapping["key"] = static_cast<StellaKey>(key);
if(StellaMod(mod) != StellaMod::KBDM_NONE) if(static_cast<StellaMod>(mod) != StellaMod::KBDM_NONE)
mapping["mod"] = serializeModkeyMask(StellaMod(mod)); mapping["mod"] = serializeModkeyMask(static_cast<StellaMod>(mod));
convertedMapping.push_back(mapping); convertedMapping.push_back(mapping);
} }
@ -336,7 +336,7 @@ void KeyMap::eraseEvent(const Event::Type event, const EventMode mode)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
KeyMap::Mapping KeyMap::convertMod(const Mapping& mapping) const KeyMap::Mapping KeyMap::convertMod(const Mapping& mapping)
{ {
Mapping m = mapping; Mapping m = mapping;

View File

@ -79,8 +79,8 @@ class KeyMap
bool check(const EventMode mode, const int key, const int mod) const; bool check(const EventMode mode, const int key, const int mod) const;
/** Get mapping description */ /** Get mapping description */
string getDesc(const Mapping& mapping) const; static string getDesc(const Mapping& mapping);
string getDesc(const EventMode mode, const int key, const int mod) const; static string getDesc(const EventMode mode, const int key, const int mod);
/** Get the mapping description(s) for given event and mode */ /** Get the mapping description(s) for given event and mode */
string getEventMappingDesc(const Event::Type event, const EventMode mode) const; string getEventMappingDesc(const Event::Type event, const EventMode mode) const;
@ -104,7 +104,7 @@ class KeyMap
private: private:
//** Convert modifiers */ //** Convert modifiers */
Mapping convertMod(const Mapping& mapping) const; static Mapping convertMod(const Mapping& mapping);
struct KeyHash { struct KeyHash {
size_t operator()(const Mapping& m) const { size_t operator()(const Mapping& m) const {

View File

@ -287,6 +287,6 @@ class LinkedObjectPool
LinkedObjectPool& operator=(LinkedObjectPool&&) = delete; LinkedObjectPool& operator=(LinkedObjectPool&&) = delete;
}; };
} // Namespace Common } // namespace Common
#endif #endif

View File

@ -41,8 +41,10 @@ MouseControl::MouseControl(Console& console, const string& mode)
m_mode[0] >= '0' && m_mode[0] <= '8' && m_mode[0] >= '0' && m_mode[0] <= '8' &&
m_mode[1] >= '0' && m_mode[1] <= '8') m_mode[1] >= '0' && m_mode[1] <= '8')
{ {
const MouseControl::Type xaxis = static_cast<MouseControl::Type>(static_cast<int>(m_mode[0]) - '0'); const auto xaxis = static_cast<MouseControl::Type>
const MouseControl::Type yaxis = static_cast<MouseControl::Type>(static_cast<int>(m_mode[1]) - '0'); (static_cast<int>(m_mode[0]) - '0');
const auto yaxis = static_cast<MouseControl::Type>
(static_cast<int>(m_mode[1]) - '0');
ostringstream msg; ostringstream msg;
Controller::Type xtype = Controller::Type::Joystick, ytype = Controller::Type::Joystick; Controller::Type xtype = Controller::Type::Joystick, ytype = Controller::Type::Joystick;
int xid = -1, yid = -1; int xid = -1, yid = -1;
@ -127,7 +129,7 @@ MouseControl::MouseControl(Console& console, const string& mode)
Paddles::setDigitalPaddleRange(m_range); Paddles::setDigitalPaddleRange(m_range);
// If the mouse isn't used at all, we still need one item in the list // If the mouse isn't used at all, we still need one item in the list
if(myModeList.size() == 0) if(myModeList.empty())
myModeList.emplace_back("Mouse not used for current controllers"); myModeList.emplace_back("Mouse not used for current controllers");
#if 0 #if 0

View File

@ -73,7 +73,7 @@ class MouseControl
void addLeftControllerModes(bool noswap); void addLeftControllerModes(bool noswap);
void addRightControllerModes(bool noswap); void addRightControllerModes(bool noswap);
void addPaddleModes(int lport, int rport, int lname, int rname); void addPaddleModes(int lport, int rport, int lname, int rname);
bool controllerSupportsMouse(Controller& controller); static bool controllerSupportsMouse(Controller& controller);
private: private:
const Properties& myProps; const Properties& myProps;

View File

@ -15,7 +15,6 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
//============================================================================ //============================================================================
#include "Logger.hxx"
#include "OSystem.hxx" #include "OSystem.hxx"
#include "Console.hxx" #include "Console.hxx"
#include "Joystick.hxx" #include "Joystick.hxx"
@ -149,11 +148,9 @@ int PhysicalJoystickHandler::add(const PhysicalJoystickPtr& stick)
// We're potentially swapping out an input device behind the back of // We're potentially swapping out an input device behind the back of
// the Event system, so we make sure all Stelladaptor-generated events // the Event system, so we make sure all Stelladaptor-generated events
// are reset // are reset
for(int port = 0; port < NUM_PORTS; ++port) for(int port = 0; port < NUM_PORTS; ++port) // NOLINT
{ for(int axis = 0; axis < NUM_SA_AXIS; ++axis) // NOLINT
for(int axis = 0; axis < NUM_SA_AXIS; ++axis)
myEvent.set(SA_Axis[port][axis], 0); myEvent.set(SA_Axis[port][axis], 0);
}
return stick->ID; return stick->ID;
} }
@ -300,7 +297,7 @@ bool PhysicalJoystickHandler::mapStelladaptors(const string& saport, int ID)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalJoystickHandler::hasStelladaptors() const bool PhysicalJoystickHandler::hasStelladaptors() const
{ {
for(auto& [_id, _joyptr] : mySticks) for(const auto& [_id, _joyptr] : mySticks)
{ {
// remove previously added emulated ports // remove previously added emulated ports
const size_t pos = _joyptr->name.find(" (emulates "); const size_t pos = _joyptr->name.find(" (emulates ");
@ -334,7 +331,7 @@ void PhysicalJoystickHandler::setDefaultAction(int stick,
{ {
// if there is no existing mapping for the event and // if there is no existing mapping for the event and
// the default mapping for the event is unused, set default key for event // the default mapping for the event is unused, set default key for event
if(j->joyMap.getEventMapping(map.event, mode).size() == 0 && if(j->joyMap.getEventMapping(map.event, mode).empty() &&
!j->joyMap.check(mode, map.button, map.axis, map.adir, map.hat, map.hdir)) !j->joyMap.check(mode, map.button, map.axis, map.adir, map.hat, map.hdir))
{ {
if (map.hat == JOY_CTRL_NONE) if (map.hat == JOY_CTRL_NONE)
@ -355,8 +352,8 @@ void PhysicalJoystickHandler::setDefaultAction(int stick,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalJoystickHandler::setStickDefaultMapping(int stick, Event::Type event, void PhysicalJoystickHandler::setStickDefaultMapping(
EventMode mode, bool updateDefaults) int stick, Event::Type event, EventMode mode, bool updateDefaults)
{ {
const PhysicalJoystickPtr j = joy(stick); const PhysicalJoystickPtr j = joy(stick);
@ -588,7 +585,7 @@ void PhysicalJoystickHandler::enableCommonMappings()
{ {
for (int i = Event::NoType + 1; i < Event::LastType; i++) for (int i = Event::NoType + 1; i < Event::LastType; i++)
{ {
const Event::Type event = static_cast<Event::Type>(i); const auto event = static_cast<Event::Type>(i);
if(isCommonEvent(event)) if(isCommonEvent(event))
enableMapping(event, EventMode::kCommonMode); enableMapping(event, EventMode::kCommonMode);
@ -619,7 +616,8 @@ void PhysicalJoystickHandler::enableMapping(const Event::Type event, EventMode m
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventMode PhysicalJoystickHandler::getEventMode(const Event::Type event, const EventMode mode) const EventMode PhysicalJoystickHandler::getEventMode(const Event::Type event,
const EventMode mode)
{ {
if(mode == EventMode::kEmulationMode) if(mode == EventMode::kEmulationMode)
{ {
@ -643,35 +641,35 @@ EventMode PhysicalJoystickHandler::getEventMode(const Event::Type event, const E
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalJoystickHandler::isJoystickEvent(const Event::Type event) const bool PhysicalJoystickHandler::isJoystickEvent(const Event::Type event)
{ {
return LeftJoystickEvents.find(event) != LeftJoystickEvents.end() return LeftJoystickEvents.find(event) != LeftJoystickEvents.end()
|| RightJoystickEvents.find(event) != RightJoystickEvents.end(); || RightJoystickEvents.find(event) != RightJoystickEvents.end();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalJoystickHandler::isPaddleEvent(const Event::Type event) const bool PhysicalJoystickHandler::isPaddleEvent(const Event::Type event)
{ {
return LeftPaddlesEvents.find(event) != LeftPaddlesEvents.end() return LeftPaddlesEvents.find(event) != LeftPaddlesEvents.end()
|| RightPaddlesEvents.find(event) != RightPaddlesEvents.end(); || RightPaddlesEvents.find(event) != RightPaddlesEvents.end();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalJoystickHandler::isKeyboardEvent(const Event::Type event) const bool PhysicalJoystickHandler::isKeyboardEvent(const Event::Type event)
{ {
return LeftKeyboardEvents.find(event) != LeftKeyboardEvents.end() return LeftKeyboardEvents.find(event) != LeftKeyboardEvents.end()
|| RightKeyboardEvents.find(event) != RightKeyboardEvents.end(); || RightKeyboardEvents.find(event) != RightKeyboardEvents.end();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalJoystickHandler::isDrivingEvent(const Event::Type event) const bool PhysicalJoystickHandler::isDrivingEvent(const Event::Type event)
{ {
return LeftDrivingEvents.find(event) != LeftDrivingEvents.end() return LeftDrivingEvents.find(event) != LeftDrivingEvents.end()
|| RightDrivingEvents.find(event) != RightDrivingEvents.end(); || RightDrivingEvents.find(event) != RightDrivingEvents.end();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalJoystickHandler::isCommonEvent(const Event::Type event) const bool PhysicalJoystickHandler::isCommonEvent(const Event::Type event)
{ {
return !(isJoystickEvent(event) || isPaddleEvent(event) || isKeyboardEvent(event) || isDrivingEvent(event)); return !(isJoystickEvent(event) || isPaddleEvent(event) || isKeyboardEvent(event) || isDrivingEvent(event));
} }
@ -734,9 +732,9 @@ string PhysicalJoystickHandler::getMappingDesc(Event::Type event, EventMode mode
if(_joyptr) if(_joyptr)
{ {
//Joystick mapping / labeling //Joystick mapping / labeling
if(_joyptr->joyMap.getEventMapping(event, evMode).size()) if(!_joyptr->joyMap.getEventMapping(event, evMode).empty())
{ {
if(buf.str() != "") if(!buf.str().empty())
buf << ", "; buf << ", ";
buf << _joyptr->joyMap.getEventMappingDesc(_id, event, evMode); buf << _joyptr->joyMap.getEventMappingDesc(_id, event, evMode);
} }

View File

@ -76,7 +76,7 @@ class PhysicalJoystickHandler
bool remove(const string& name); bool remove(const string& name);
bool mapStelladaptors(const string& saport, int ID = -1); bool mapStelladaptors(const string& saport, int ID = -1);
bool hasStelladaptors() const; bool hasStelladaptors() const;
void setDefaultMapping(Event::Type type, EventMode mode); void setDefaultMapping(Event::Type event, EventMode mode);
/** define mappings for current controllers */ /** define mappings for current controllers */
void defineControllerMappings(const Controller::Type type, Controller::Jack port); void defineControllerMappings(const Controller::Type type, Controller::Jack port);
@ -150,7 +150,7 @@ class PhysicalJoystickHandler
void addToDatabase(const PhysicalJoystickPtr& stick); void addToDatabase(const PhysicalJoystickPtr& stick);
// Set default mapping for given joystick when no mappings already exist // Set default mapping for given joystick when no mappings already exist
void setStickDefaultMapping(int stick, Event::Type type, EventMode mode, void setStickDefaultMapping(int stick, Event::Type event, EventMode mode,
bool updateDefaults = false); bool updateDefaults = false);
friend ostream& operator<<(ostream& os, const PhysicalJoystickHandler& jh); friend ostream& operator<<(ostream& os, const PhysicalJoystickHandler& jh);
@ -180,13 +180,13 @@ class PhysicalJoystickHandler
bool updateDefaults = false); bool updateDefaults = false);
/** returns the event's controller mode */ /** returns the event's controller mode */
EventMode getEventMode(const Event::Type event, const EventMode mode) const; static EventMode getEventMode(const Event::Type event, const EventMode mode);
/** Checks event type. */ /** Checks event type. */
bool isJoystickEvent(const Event::Type event) const; static bool isJoystickEvent(const Event::Type event);
bool isPaddleEvent(const Event::Type event) const; static bool isPaddleEvent(const Event::Type event);
bool isKeyboardEvent(const Event::Type event) const; static bool isKeyboardEvent(const Event::Type event);
bool isDrivingEvent(const Event::Type event) const; static bool isDrivingEvent(const Event::Type event);
bool isCommonEvent(const Event::Type event) const; static bool isCommonEvent(const Event::Type event);
void enableCommonMappings(); void enableCommonMappings();

View File

@ -145,7 +145,7 @@ void PhysicalKeyboardHandler::setDefaultKey(EventMapping map, Event::Type event,
{ {
// if there is no existing mapping for the event and // if there is no existing mapping for the event and
// the default mapping for the event is unused, set default key for event // the default mapping for the event is unused, set default key for event
if (myKeyMap.getEventMapping(map.event, mode).size() == 0 && if (myKeyMap.getEventMapping(map.event, mode).empty() &&
!isMappingUsed(mode, map)) !isMappingUsed(mode, map))
{ {
addMapping(map.event, mode, map.key, static_cast<StellaMod>(map.mod)); addMapping(map.event, mode, map.key, static_cast<StellaMod>(map.mod));
@ -219,10 +219,8 @@ void PhysicalKeyboardHandler::setDefaultMapping(Event::Type event, EventMode mod
void PhysicalKeyboardHandler::defineControllerMappings( void PhysicalKeyboardHandler::defineControllerMappings(
const Controller::Type type, Controller::Jack port, const Properties& properties) const Controller::Type type, Controller::Jack port, const Properties& properties)
{ {
// Determine controller events to use
//const string& test = myOSystem.settings().getString("aq"); switch(type) // NOLINT (could be written as IF/ELSE)
// determine controller events to use
switch(type)
{ {
case Controller::Type::QuadTari: case Controller::Type::QuadTari:
if(port == Controller::Jack::Left) if(port == Controller::Jack::Left)
@ -251,7 +249,8 @@ void PhysicalKeyboardHandler::defineControllerMappings(
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventMode PhysicalKeyboardHandler::getMode(const Properties& properties, const PropType propType) EventMode PhysicalKeyboardHandler::getMode(const Properties& properties,
const PropType propType)
{ {
const string& propName = properties.get(propType); const string& propName = properties.get(propType);
@ -377,7 +376,7 @@ void PhysicalKeyboardHandler::enableCommonMappings()
{ {
for (int i = Event::NoType + 1; i < Event::LastType; i++) for (int i = Event::NoType + 1; i < Event::LastType; i++)
{ {
const Event::Type event = static_cast<Event::Type>(i); const auto event = static_cast<Event::Type>(i);
if (isCommonEvent(event)) if (isCommonEvent(event))
enableMapping(event, EventMode::kCommonMode); enableMapping(event, EventMode::kCommonMode);
@ -405,7 +404,7 @@ void PhysicalKeyboardHandler::enableMapping(const Event::Type event,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
EventMode PhysicalKeyboardHandler::getEventMode(const Event::Type event, EventMode PhysicalKeyboardHandler::getEventMode(const Event::Type event,
const EventMode mode) const const EventMode mode)
{ {
if (mode == EventMode::kEmulationMode) if (mode == EventMode::kEmulationMode)
{ {
@ -429,7 +428,7 @@ EventMode PhysicalKeyboardHandler::getEventMode(const Event::Type event,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalKeyboardHandler::isJoystickEvent(const Event::Type event) const bool PhysicalKeyboardHandler::isJoystickEvent(const Event::Type event)
{ {
return LeftJoystickEvents.find(event) != LeftJoystickEvents.end() return LeftJoystickEvents.find(event) != LeftJoystickEvents.end()
|| QTJoystick3Events.find(event) != QTJoystick3Events.end() || QTJoystick3Events.find(event) != QTJoystick3Events.end()
@ -438,7 +437,7 @@ bool PhysicalKeyboardHandler::isJoystickEvent(const Event::Type event) const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalKeyboardHandler::isPaddleEvent(const Event::Type event) const bool PhysicalKeyboardHandler::isPaddleEvent(const Event::Type event)
{ {
return LeftPaddlesEvents.find(event) != LeftPaddlesEvents.end() return LeftPaddlesEvents.find(event) != LeftPaddlesEvents.end()
|| QTPaddles3Events.find(event) != QTPaddles3Events.end() || QTPaddles3Events.find(event) != QTPaddles3Events.end()
@ -447,21 +446,21 @@ bool PhysicalKeyboardHandler::isPaddleEvent(const Event::Type event) const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalKeyboardHandler::isDrivingEvent(const Event::Type event) const bool PhysicalKeyboardHandler::isDrivingEvent(const Event::Type event)
{ {
return LeftDrivingEvents.find(event) != LeftDrivingEvents.end() return LeftDrivingEvents.find(event) != LeftDrivingEvents.end()
|| RightDrivingEvents.find(event) != RightDrivingEvents.end(); || RightDrivingEvents.find(event) != RightDrivingEvents.end();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalKeyboardHandler::isKeyboardEvent(const Event::Type event) const bool PhysicalKeyboardHandler::isKeyboardEvent(const Event::Type event)
{ {
return LeftKeyboardEvents.find(event) != LeftKeyboardEvents.end() return LeftKeyboardEvents.find(event) != LeftKeyboardEvents.end()
|| RightKeyboardEvents.find(event) != RightKeyboardEvents.end(); || RightKeyboardEvents.find(event) != RightKeyboardEvents.end();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalKeyboardHandler::isCommonEvent(const Event::Type event) const bool PhysicalKeyboardHandler::isCommonEvent(const Event::Type event)
{ {
return !(isJoystickEvent(event) || isPaddleEvent(event) || isKeyboardEvent(event)); return !(isJoystickEvent(event) || isPaddleEvent(event) || isKeyboardEvent(event));
} }

View File

@ -48,10 +48,12 @@ class PhysicalKeyboardHandler
void loadSerializedMappings(const string& serializedMappings, EventMode mode); void loadSerializedMappings(const string& serializedMappings, EventMode mode);
void setDefaultMapping(Event::Type type, EventMode mode, bool updateDefaults = false); void setDefaultMapping(Event::Type event, EventMode mode,
bool updateDefaults = false);
/** define mappings for current controllers */ /** define mappings for current controllers */
void defineControllerMappings(const Controller::Type type, Controller::Jack port, void defineControllerMappings(const Controller::Type type,
Controller::Jack port,
const Properties& properties); const Properties& properties);
/** enable mappings for emulation mode */ /** enable mappings for emulation mode */
void enableEmulationMappings(); void enableEmulationMappings();
@ -100,13 +102,13 @@ class PhysicalKeyboardHandler
EventMode mode = EventMode::kEmulationMode, bool updateDefaults = false); EventMode mode = EventMode::kEmulationMode, bool updateDefaults = false);
/** returns the event's controller mode */ /** returns the event's controller mode */
EventMode getEventMode(const Event::Type event, const EventMode mode) const; static EventMode getEventMode(const Event::Type event, const EventMode mode);
/** Checks event type. */ /** Checks event type. */
bool isJoystickEvent(const Event::Type event) const; static bool isJoystickEvent(const Event::Type event);
bool isPaddleEvent(const Event::Type event) const; static bool isPaddleEvent(const Event::Type event);
bool isKeyboardEvent(const Event::Type event) const; static bool isKeyboardEvent(const Event::Type event);
bool isDrivingEvent(const Event::Type event) const; static bool isDrivingEvent(const Event::Type event);
bool isCommonEvent(const Event::Type event) const; static bool isCommonEvent(const Event::Type event);
void enableCommonMappings(); void enableCommonMappings();
@ -114,9 +116,9 @@ class PhysicalKeyboardHandler
void enableMapping(const Event::Type event, EventMode mode); void enableMapping(const Event::Type event, EventMode mode);
/** return event mode for given property */ /** return event mode for given property */
EventMode getMode(const Properties& properties, const PropType propType); static EventMode getMode(const Properties& properties, const PropType propType);
/** return event mode for given controller type */ /** return event mode for given controller type */
EventMode getMode(const Controller::Type type); static EventMode getMode(const Controller::Type type);
private: private:
OSystem& myOSystem; OSystem& myOSystem;

View File

@ -135,7 +135,7 @@ void PNGLibrary::saveImage(const string& filename, const VariantList& metaData)
fb.scaleX(rectUnscaled.w()), fb.scaleY(rectUnscaled.h()) fb.scaleX(rectUnscaled.w()), fb.scaleY(rectUnscaled.h())
); );
const png_uint_32 width = rect.w(), height = rect.h(); const size_t width = rect.w(), height = rect.h();
// Get framebuffer pixel data (we get ABGR format) // Get framebuffer pixel data (we get ABGR format)
vector<png_byte> buffer(width * height * 4); vector<png_byte> buffer(width * height * 4);
@ -143,7 +143,7 @@ void PNGLibrary::saveImage(const string& filename, const VariantList& metaData)
// Set up pointers into "buffer" byte array // Set up pointers into "buffer" byte array
vector<png_bytep> rows(height); vector<png_bytep> rows(height);
for(png_uint_32 k = 0; k < height; ++k) for(size_t k = 0; k < height; ++k)
rows[k] = buffer.data() + k * width * 4; rows[k] = buffer.data() + k * width * 4;
// And save the image // And save the image
@ -159,7 +159,7 @@ void PNGLibrary::saveImage(const string& filename, const FBSurface& surface,
throw runtime_error("ERROR: Couldn't create snapshot file"); throw runtime_error("ERROR: Couldn't create snapshot file");
// Do we want the entire surface or just a section? // Do we want the entire surface or just a section?
png_uint_32 width = rect.w(), height = rect.h(); size_t width = rect.w(), height = rect.h();
if(rect.empty()) if(rect.empty())
{ {
width = surface.width(); width = surface.width();
@ -168,11 +168,11 @@ void PNGLibrary::saveImage(const string& filename, const FBSurface& surface,
// Get the surface pixel data (we get ABGR format) // Get the surface pixel data (we get ABGR format)
vector<png_byte> buffer(width * height * 4); vector<png_byte> buffer(width * height * 4);
surface.readPixels(buffer.data(), width, rect); surface.readPixels(buffer.data(), static_cast<uInt32>(width), rect);
// Set up pointers into "buffer" byte array // Set up pointers into "buffer" byte array
vector<png_bytep> rows(height); vector<png_bytep> rows(height);
for(png_uint_32 k = 0; k < height; ++k) for(size_t k = 0; k < height; ++k)
rows[k] = buffer.data() + k * width * 4; rows[k] = buffer.data() + k * width * 4;
// And save the image // And save the image
@ -181,10 +181,10 @@ void PNGLibrary::saveImage(const string& filename, const FBSurface& surface,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PNGLibrary::saveImageToDisk(std::ofstream& out, const vector<png_bytep>& rows, void PNGLibrary::saveImageToDisk(std::ofstream& out, const vector<png_bytep>& rows,
png_uint_32 width, png_uint_32 height, const VariantList& metaData) size_t width, size_t height, const VariantList& metaData)
{ {
png_structp png_ptr = nullptr; png_structp png_ptr{nullptr};
png_infop info_ptr = nullptr; png_infop info_ptr{nullptr};
const auto saveImageERROR = [&](const char* s) { const auto saveImageERROR = [&](const char* s) {
if(png_ptr) if(png_ptr)
@ -208,7 +208,8 @@ void PNGLibrary::saveImageToDisk(std::ofstream& out, const vector<png_bytep>& ro
png_set_write_fn(png_ptr, &out, png_write_data, png_io_flush); png_set_write_fn(png_ptr, &out, png_write_data, png_io_flush);
// Write PNG header info // Write PNG header info
png_set_IHDR(png_ptr, info_ptr, width, height, 8, png_set_IHDR(png_ptr, info_ptr,
static_cast<png_uint_32>(width), static_cast<png_uint_32>(height), 8,
PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT); PNG_FILTER_TYPE_DEFAULT);
@ -381,20 +382,20 @@ void PNGLibrary::takeSnapshot(uInt32 number)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PNGLibrary::allocateStorage(png_uint_32 w, png_uint_32 h) bool PNGLibrary::allocateStorage(size_t width, size_t height)
{ {
// Create space for the entire image (3 bytes per pixel in RGB format) // Create space for the entire image (3 bytes per pixel in RGB format)
const size_t req_buffer_size = w * h * 3; const size_t req_buffer_size = width * height * 3;
if(req_buffer_size > ReadInfo.buffer.capacity()) if(req_buffer_size > ReadInfo.buffer.capacity())
ReadInfo.buffer.reserve(req_buffer_size * 1.5); ReadInfo.buffer.reserve(req_buffer_size * 1.5);
const size_t req_row_size = h; const size_t req_row_size = height;
if(req_row_size > ReadInfo.row_pointers.capacity()) if(req_row_size > ReadInfo.row_pointers.capacity())
ReadInfo.row_pointers.reserve(req_row_size * 1.5); ReadInfo.row_pointers.reserve(req_row_size * 1.5);
ReadInfo.width = w; ReadInfo.width = static_cast<png_uint_32>(width);
ReadInfo.height = h; ReadInfo.height = static_cast<png_uint_32>(height);
ReadInfo.pitch = w * 3; ReadInfo.pitch = static_cast<png_uint_32>(width * 3);
return true; return true;
} }
@ -413,7 +414,7 @@ void PNGLibrary::loadImagetoSurface(FBSurface& surface)
surface.setSrcSize(iw, ih); surface.setSrcSize(iw, ih);
// Convert RGB triples into pixels and store in the surface // Convert RGB triples into pixels and store in the surface
uInt32 *s_buf, s_pitch; uInt32 *s_buf{nullptr}, s_pitch{0};
surface.basePtr(s_buf, s_pitch); surface.basePtr(s_buf, s_pitch);
const uInt8* i_buf = ReadInfo.buffer.data(); const uInt8* i_buf = ReadInfo.buffer.data();
const uInt32 i_pitch = ReadInfo.pitch; const uInt32 i_pitch = ReadInfo.pitch;
@ -429,30 +430,32 @@ void PNGLibrary::loadImagetoSurface(FBSurface& surface)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PNGLibrary::writeMetaData(const png_structp png_ptr, png_infop info_ptr, void PNGLibrary::writeMetaData(
const png_structp png_ptr, png_infop info_ptr, // NOLINT
const VariantList& metaData) const VariantList& metaData)
{ {
const uInt32 numMetaData = static_cast<uInt32>(metaData.size()); const size_t numMetaData = metaData.size();
if(numMetaData == 0) if(numMetaData == 0)
return; return;
vector<png_text> text_ptr(numMetaData); vector<png_text> text_ptr(numMetaData);
for(uInt32 i = 0; i < numMetaData; ++i) for(size_t i = 0; i < numMetaData; ++i)
{ {
text_ptr[i].key = const_cast<char*>(metaData[i].first.c_str()); text_ptr[i].key = const_cast<char*>(metaData[i].first.c_str());
text_ptr[i].text = const_cast<char*>(metaData[i].second.toCString()); text_ptr[i].text = const_cast<char*>(metaData[i].second.toCString());
text_ptr[i].compression = PNG_TEXT_COMPRESSION_NONE; text_ptr[i].compression = PNG_TEXT_COMPRESSION_NONE;
text_ptr[i].text_length = 0; text_ptr[i].text_length = 0;
} }
png_set_text(png_ptr, info_ptr, text_ptr.data(), numMetaData); png_set_text(png_ptr, info_ptr, text_ptr.data(), static_cast<int>(numMetaData));
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PNGLibrary::readMetaData(const png_structp png_ptr, png_infop info_ptr, void PNGLibrary::readMetaData(
const png_structp png_ptr, png_infop info_ptr, // NOLINT
VariantList& metaData) VariantList& metaData)
{ {
png_textp text_ptr; png_textp text_ptr{nullptr};
int numMetaData = 0; int numMetaData{0};
png_get_text(png_ptr, info_ptr, &text_ptr, &numMetaData); png_get_text(png_ptr, info_ptr, &text_ptr, &numMetaData);
@ -464,33 +467,37 @@ void PNGLibrary::readMetaData(const png_structp png_ptr, png_infop info_ptr,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PNGLibrary::png_read_data(const png_structp ctx, png_bytep area, png_size_t size) void PNGLibrary::png_read_data(const png_structp ctx, // NOLINT
png_bytep area, png_size_t size)
{ {
(static_cast<std::ifstream*>(png_get_io_ptr(ctx)))->read( (static_cast<std::ifstream*>(png_get_io_ptr(ctx)))->read(
reinterpret_cast<char *>(area), size); reinterpret_cast<char *>(area), size);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PNGLibrary::png_write_data(const png_structp ctx, png_bytep area, png_size_t size) void PNGLibrary::png_write_data(const png_structp ctx, // NOLINT
png_bytep area, png_size_t size)
{ {
(static_cast<std::ofstream*>(png_get_io_ptr(ctx)))->write( (static_cast<std::ofstream*>(png_get_io_ptr(ctx)))->write(
reinterpret_cast<const char *>(area), size); reinterpret_cast<const char *>(area), size);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PNGLibrary::png_io_flush(const png_structp ctx) void PNGLibrary::png_io_flush(const png_structp ctx) // NOLINT
{ {
(static_cast<std::ofstream*>(png_get_io_ptr(ctx)))->flush(); (static_cast<std::ofstream*>(png_get_io_ptr(ctx)))->flush();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PNGLibrary::png_user_warn(const png_structp ctx, png_const_charp str) void PNGLibrary::png_user_warn(const png_structp ctx, // NOLINT
png_const_charp str)
{ {
throw runtime_error(string("PNGLibrary warning: ") + str); throw runtime_error(string("PNGLibrary warning: ") + str);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PNGLibrary::png_user_error(const png_structp ctx, png_const_charp str) void PNGLibrary::png_user_error(const png_structp ctx, // NOLINT
png_const_charp str)
{ {
throw runtime_error(string("PNGLibrary error: ") + str); throw runtime_error(string("PNGLibrary error: ") + str);
} }

View File

@ -49,7 +49,8 @@ class PNGLibrary
runtime_error is thrown containing a more detailed runtime_error is thrown containing a more detailed
error message. error message.
*/ */
void loadImage(const string& filename, FBSurface& surface, VariantList& metaData); void loadImage(const string& filename, FBSurface& surface,
VariantList& metaData);
/** /**
Save the current FrameBuffer image to a PNG file. Note that in most Save the current FrameBuffer image to a PNG file. Note that in most
@ -78,7 +79,7 @@ class PNGLibrary
otherwise a runtime_error is thrown containing a otherwise a runtime_error is thrown containing a
more detailed error message. more detailed error message.
*/ */
void saveImage(const string& filename, const FBSurface& surface, static void saveImage(const string& filename, const FBSurface& surface,
const Common::Rect& rect = Common::Rect{}, const Common::Rect& rect = Common::Rect{},
const VariantList& metaData = VariantList{}); const VariantList& metaData = VariantList{});
@ -149,10 +150,10 @@ class PNGLibrary
dependent on the given dimensions. If memory has been previously dependent on the given dimensions. If memory has been previously
allocated and it can accommodate the given dimensions, it is used directly. allocated and it can accommodate the given dimensions, it is used directly.
@param iwidth The width of the PNG image @param width The width of the PNG image
@param iheight The height of the PNG image @param height The height of the PNG image
*/ */
bool allocateStorage(png_uint_32 iwidth, png_uint_32 iheight); static bool allocateStorage(size_t width, size_t height);
/** The actual method which saves a PNG image. /** The actual method which saves a PNG image.
@ -162,8 +163,8 @@ class PNGLibrary
@param height The height of the PNG image @param height The height of the PNG image
@param metaData The meta data to add to the PNG image @param metaData The meta data to add to the PNG image
*/ */
void saveImageToDisk(std::ofstream& out, const vector<png_bytep>& rows, static void saveImageToDisk(std::ofstream& out, const vector<png_bytep>& rows,
png_uint_32 width, png_uint_32 height, size_t width, size_t height,
const VariantList& metaData); const VariantList& metaData);
/** /**
@ -177,21 +178,25 @@ class PNGLibrary
/** /**
Write PNG tEXt chunks to the image. Write PNG tEXt chunks to the image.
*/ */
void writeMetaData(const png_structp png_ptr, png_infop info_ptr, static void writeMetaData(const png_structp png_ptr, png_infop info_ptr,
const VariantList& metaData); const VariantList& metaData);
/** /**
Read PNG tEXt chunks from the image. Read PNG tEXt chunks from the image.
*/ */
void readMetaData(const png_structp png_ptr, png_infop info_ptr, static void readMetaData(const png_structp png_ptr, png_infop info_ptr,
VariantList& metaData); VariantList& metaData);
/** PNG library callback functions */ /** PNG library callback functions */
static void png_read_data(const png_structp ctx, png_bytep area, png_size_t size); static void png_read_data(const png_structp ctx, png_bytep area,
static void png_write_data(const png_structp ctx, png_bytep area, png_size_t size); png_size_t size);
static void png_write_data(const png_structp ctx, png_bytep area,
png_size_t size);
static void png_io_flush(const png_structp ctx); static void png_io_flush(const png_structp ctx);
[[noreturn]] static void png_user_warn(const png_structp ctx, png_const_charp str); [[noreturn]] static void png_user_warn(const png_structp ctx,
[[noreturn]] static void png_user_error(const png_structp ctx, png_const_charp str); png_const_charp str);
[[noreturn]] static void png_user_error(const png_structp ctx,
png_const_charp str);
private: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported

View File

@ -44,9 +44,9 @@ PaletteHandler::PaletteType PaletteHandler::toPaletteType(const string& name) co
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string PaletteHandler::toPaletteName(PaletteType type) const string PaletteHandler::toPaletteName(PaletteType type)
{ {
const string SETTING_NAMES[int(PaletteType::NumTypes)] = { const string SETTING_NAMES[static_cast<int>(PaletteType::NumTypes)] = {
SETTING_STANDARD, SETTING_Z26, SETTING_USER, SETTING_CUSTOM SETTING_STANDARD, SETTING_Z26, SETTING_USER, SETTING_CUSTOM
}; };
@ -321,7 +321,8 @@ void PaletteHandler::setPalette()
// Look at all the palettes, since we don't know which one is // Look at all the palettes, since we don't know which one is
// currently active // currently active
static constexpr BSPF::array2D<const PaletteArray*, PaletteType::NumTypes, int(ConsoleTiming::numTimings)> palettes = {{ static constexpr BSPF::array2D<const PaletteArray*, PaletteType::NumTypes,
static_cast<int>(ConsoleTiming::numTimings)> palettes = {{
{ &ourNTSCPalette, &ourPALPalette, &ourSECAMPalette }, { &ourNTSCPalette, &ourPALPalette, &ourSECAMPalette },
{ &ourNTSCPaletteZ26, &ourPALPaletteZ26, &ourSECAMPaletteZ26 }, { &ourNTSCPaletteZ26, &ourPALPaletteZ26, &ourSECAMPaletteZ26 },
{ &ourUserNTSCPalette, &ourUserPALPalette, &ourUserSECAMPalette }, { &ourUserNTSCPalette, &ourUserPALPalette, &ourUserSECAMPalette },
@ -341,7 +342,7 @@ void PaletteHandler::setPalette()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PaletteArray PaletteHandler::adjustedPalette(const PaletteArray& palette) PaletteArray PaletteHandler::adjustedPalette(const PaletteArray& palette) const
{ {
PaletteArray destPalette{0}; PaletteArray destPalette{0};
// Constants for saturation and gray scale calculation // Constants for saturation and gray scale calculation
@ -389,7 +390,7 @@ PaletteArray PaletteHandler::adjustedPalette(const PaletteArray& palette)
// Fill the odd numbered palette entries with gray values (calculated // Fill the odd numbered palette entries with gray values (calculated
// using the standard RGB -> grayscale conversion formula) // using the standard RGB -> grayscale conversion formula)
// Used for PAL color-loss data and 'greying out' the frame in the debugger. // Used for PAL color-loss data and 'greying out' the frame in the debugger.
const uInt8 lum = static_cast<uInt8>((r * PR) + (g * PG) + (b * PB)); const auto lum = static_cast<uInt8>((r * PR) + (g * PG) + (b * PB));
destPalette[i + 1] = (lum << 16) + (lum << 8) + lum; destPalette[i + 1] = (lum << 16) + (lum << 8) + lum;
} }
@ -443,7 +444,7 @@ void PaletteHandler::loadUserPalette()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PaletteHandler::generateCustomPalette(ConsoleTiming timing) void PaletteHandler::generateCustomPalette(ConsoleTiming timing) const
{ {
constexpr int NUM_CHROMA = 16; constexpr int NUM_CHROMA = 16;
constexpr int NUM_LUMA = 8; constexpr int NUM_LUMA = 8;
@ -572,7 +573,8 @@ void PaletteHandler::adjustHueSaturation(int& R, int& G, int& B, float H, float
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PaletteHandler::vector2d PaletteHandler::rotate(const PaletteHandler::vector2d& vec, float angle) const PaletteHandler::vector2d
PaletteHandler::rotate(const PaletteHandler::vector2d& vec, float angle)
{ {
const float r = angle * BSPF::PI_f / 180; const float r = angle * BSPF::PI_f / 180;
@ -581,14 +583,15 @@ PaletteHandler::vector2d PaletteHandler::rotate(const PaletteHandler::vector2d&
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PaletteHandler::vector2d PaletteHandler::scale(const PaletteHandler::vector2d& vec, float factor) const PaletteHandler::vector2d
PaletteHandler::scale(const PaletteHandler::vector2d& vec, float factor)
{ {
return PaletteHandler::vector2d(vec.x * factor, vec.y * factor); return PaletteHandler::vector2d(vec.x * factor, vec.y * factor);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
float PaletteHandler::dotProduct(const PaletteHandler::vector2d& vec1, float PaletteHandler::dotProduct(const PaletteHandler::vector2d& vec1,
const PaletteHandler::vector2d& vec2) const const PaletteHandler::vector2d& vec2)
{ {
return vec1.x * vec2.x + vec1.y * vec2.y; return vec1.x * vec2.x + vec1.y * vec2.y;
} }

View File

@ -187,7 +187,7 @@ class PaletteHandler
@return The palette's settings name @return The palette's settings name
*/ */
string toPaletteName(PaletteType type) const; static string toPaletteName(PaletteType type);
/** /**
Display current adjustable with gauge bar message Display current adjustable with gauge bar message
@ -208,16 +208,16 @@ class PaletteHandler
@param timing Use NTSC or PAL phase shift and generate according palette @param timing Use NTSC or PAL phase shift and generate according palette
*/ */
void generateCustomPalette(ConsoleTiming timing); void generateCustomPalette(ConsoleTiming timing) const;
/** /**
Create new palette by applying palette adjustments on given palette. Create new palette by applying palette adjustments on given palette.
@param source The palette which should be adjusted @param palette The palette which should be adjusted
@return An adjusted palette @return An adjusted palette
*/ */
PaletteArray adjustedPalette(const PaletteArray& source); PaletteArray adjustedPalette(const PaletteArray& palette) const;
/** /**
Adjust hue and saturation for given RGB values. Adjust hue and saturation for given RGB values.
@ -228,22 +228,22 @@ class PaletteHandler
@param H The hue adjustment value @param H The hue adjustment value
@param S The saturation @param S The saturation
*/ */
void adjustHueSaturation(int& R, int& G, int& B, float H, float S); static void adjustHueSaturation(int& R, int& G, int& B, float H, float S);
/** /**
Rotate a 2D vector. Rotate a 2D vector.
*/ */
vector2d rotate(const vector2d& vec, float angle) const; static vector2d rotate(const vector2d& vec, float angle);
/** /**
Scale a 2D vector. Scale a 2D vector.
*/ */
vector2d scale(const vector2d& vec, float factor) const; static vector2d scale(const vector2d& vec, float factor);
/** /**
Get the dot product of two 2D vectors. Get the dot product of two 2D vectors.
*/ */
float dotProduct(const vector2d& vec1, const vector2d& vec2) const; static float dotProduct(const vector2d& vec1, const vector2d& vec2);
/** /**
Loads a user-defined palette file (from OSystem::paletteFile), filling the Loads a user-defined palette file (from OSystem::paletteFile), filling the

View File

@ -33,13 +33,13 @@ namespace {
} }
EventMode eventModeFromJsonName(const string& name) { EventMode eventModeFromJsonName(const string& name) {
EventMode result; EventMode result{};
from_json(json(name), result); from_json(json(name), result);
return result; return result;
} }
} } // namespace
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalJoystick::initialize(int index, const string& desc, void PhysicalJoystick::initialize(int index, const string& desc,
@ -70,9 +70,8 @@ json PhysicalJoystick::getMap() const
mapping["name"] = name; mapping["name"] = name;
for (auto& mode: { for (const auto& mode: {
EventMode::kMenuMode, EventMode::kJoystickMode, EventMode::kPaddlesMode, EventMode::kKeyboardMode, EventMode::kMenuMode, EventMode::kJoystickMode, EventMode::kPaddlesMode, EventMode::kKeyboardMode, EventMode::kDrivingMode, EventMode::kCommonMode
EventMode::kDrivingMode, EventMode::kCommonMode
}) })
mapping[jsonName(mode)] = joyMap.saveMapping(mode); mapping[jsonName(mode)] = joyMap.saveMapping(mode);
@ -120,7 +119,7 @@ json PhysicalJoystick::convertLegacyMapping(const string& mapping, const string&
while (getline(buf, map, MODE_DELIM)) while (getline(buf, map, MODE_DELIM))
{ {
int mode; int mode{0};
// Get event mode // Get event mode
std::replace(map.begin(), map.end(), '|', ' '); std::replace(map.begin(), map.end(), '|', ' ');
@ -153,12 +152,12 @@ void PhysicalJoystick::eraseEvent(Event::Type event, EventMode mode)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalJoystick::getValues(const string& list, IntArray& map) const void PhysicalJoystick::getValues(const string& list, IntArray& map)
{ {
map.clear(); map.clear();
istringstream buf(list); istringstream buf(list);
int value; int value{0};
buf >> value; // we don't need to know the # of items at this point buf >> value; // we don't need to know the # of items at this point
while(buf >> value) while(buf >> value)
map.push_back(value); map.push_back(value);

View File

@ -76,7 +76,7 @@ class PhysicalJoystick
JoyMap joyMap; JoyMap joyMap;
private: private:
void getValues(const string& list, IntArray& map) const; static void getValues(const string& list, IntArray& map);
friend ostream& operator<<(ostream& os, const PhysicalJoystick& s) { friend ostream& operator<<(ostream& os, const PhysicalJoystick& s) {
os << " ID: " << s.ID << ", name: " << s.name << ", numaxis: " << s.numAxes os << " ID: " << s.ID << ", name: " << s.name << ", numaxis: " << s.numAxes

View File

@ -186,6 +186,6 @@ public:
} }
}; };
} // End of namespace Common } // namespace Common
#endif #endif

View File

@ -146,7 +146,7 @@ bool RewindManager::addState(const string& message, bool timeMachine)
uInt32 RewindManager::rewindStates(uInt32 numStates) uInt32 RewindManager::rewindStates(uInt32 numStates)
{ {
const uInt64 startCycles = myOSystem.console().tia().cycles(); const uInt64 startCycles = myOSystem.console().tia().cycles();
uInt32 i; uInt32 i{0};
string message; string message;
for(i = 0; i < numStates; ++i) for(i = 0; i < numStates; ++i)
@ -186,7 +186,7 @@ uInt32 RewindManager::rewindStates(uInt32 numStates)
uInt32 RewindManager::unwindStates(uInt32 numStates) uInt32 RewindManager::unwindStates(uInt32 numStates)
{ {
const uInt64 startCycles = myOSystem.console().tia().cycles(); const uInt64 startCycles = myOSystem.console().tia().cycles();
uInt32 i; uInt32 i{0};
string message; string message;
for(i = 0; i < numStates; ++i) for(i = 0; i < numStates; ++i)
@ -256,7 +256,7 @@ string RewindManager::saveAllStates()
{ {
RewindState& state = myStateList.current(); RewindState& state = myStateList.current();
Serializer& s = state.data; Serializer& s = state.data;
const uInt32 stateSize = static_cast<uInt32>(s.size()); const auto stateSize = static_cast<uInt32>(s.size());
out.putInt(stateSize); out.putInt(stateSize);
@ -354,7 +354,7 @@ void RewindManager::compressStates()
double maxError = 1.5; double maxError = 1.5;
uInt32 idx = myStateList.size() - 2; uInt32 idx = myStateList.size() - 2;
// in case maxError is <= 1.5 remove first state by default: // in case maxError is <= 1.5 remove first state by default:
Common::LinkedObjectPool<RewindState>::const_iter removeIter = myStateList.first(); auto removeIter = myStateList.first();
/*if(myUncompressed < mySize) /*if(myUncompressed < mySize)
// if compression is enabled, the first but one state is removed by default: // if compression is enabled, the first but one state is removed by default:
removeIter++;*/ removeIter++;*/
@ -406,35 +406,35 @@ string RewindManager::loadState(Int64 startCycles, uInt32 numStates)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string RewindManager::getUnitString(Int64 cycles) string RewindManager::getUnitString(Int64 cycles)
{ {
constexpr Int32 NTSC_FREQ = 1193182; // ~76*262*60 constexpr size_t NTSC_FREQ = 1193182; // ~76*262*60
constexpr Int32 PAL_FREQ = 1182298; // ~76*312*50 constexpr size_t PAL_FREQ = 1182298; // ~76*312*50
const Int32 scanlines = std::max<Int32>( const size_t scanlines = std::max<size_t>(
myOSystem.console().tia().scanlinesLastFrame(), 240); myOSystem.console().tia().scanlinesLastFrame(), 240);
const bool isNTSC = scanlines <= 287; const bool isNTSC = scanlines <= 287;
const Int32 freq = isNTSC ? NTSC_FREQ : PAL_FREQ; // = cycles/second const size_t freq = isNTSC ? NTSC_FREQ : PAL_FREQ; // = cycles/second
constexpr Int32 NUM_UNITS = 5; constexpr size_t NUM_UNITS = 5;
const std::array<string, NUM_UNITS> UNIT_NAMES = { const std::array<string, NUM_UNITS> UNIT_NAMES = {
"cycle", "scanline", "frame", "second", "minute" "cycle", "scanline", "frame", "second", "minute"
}; };
const std::array<Int64, NUM_UNITS+1> UNIT_CYCLES = { const std::array<uInt64, NUM_UNITS+1> UNIT_CYCLES = {
1, 76, 76 * scanlines, freq, freq * 60, Int64{1} << 62 1, 76, 76 * scanlines, freq, freq * 60, Int64{1} << 62
}; };
stringstream result; stringstream result;
Int32 i = 0; size_t i = 0;
cycles = std::abs(cycles); const uInt64 u_cycles = std::abs(cycles);
for(i = 0; i < NUM_UNITS - 1; ++i) for(i = 0; i < NUM_UNITS - 1; ++i)
{ {
// use the lower unit up to twice the nextCycles unit, except for an exact match of the nextCycles unit // use the lower unit up to twice the nextCycles unit, except for an exact match of the nextCycles unit
// TODO: does the latter make sense, e.g. for ROMs with changing scanlines? // TODO: does the latter make sense, e.g. for ROMs with changing scanlines?
if(cycles == 0 || (cycles < UNIT_CYCLES[i + 1] * 2 && cycles % UNIT_CYCLES[i + 1] != 0)) if(u_cycles == 0 || (u_cycles < UNIT_CYCLES[i + 1] * 2 && u_cycles % UNIT_CYCLES[i + 1] != 0))
break; break;
} }
result << (cycles / UNIT_CYCLES[i]) << " " << UNIT_NAMES[i]; result << (u_cycles / UNIT_CYCLES[i]) << " " << UNIT_NAMES[i];
if(cycles / UNIT_CYCLES[i] != 1) if(u_cycles / UNIT_CYCLES[i] != 1)
result << "s"; result << "s";
return result.str(); return result.str();
@ -467,8 +467,9 @@ IntArray RewindManager::cyclesList() const
IntArray arr; IntArray arr;
const uInt64 firstCycle = getFirstCycles(); const uInt64 firstCycle = getFirstCycles();
// NOLINTNEXTLINE (TODO: convert myStateList to use range-for)
for(auto it = myStateList.cbegin(); it != myStateList.cend(); ++it) for(auto it = myStateList.cbegin(); it != myStateList.cend(); ++it)
arr.push_back(uInt32(it->cycles - firstCycle)); arr.push_back(static_cast<uInt32>(it->cycles - firstCycle));
return arr; return arr;
} }

View File

@ -56,7 +56,7 @@ SoundSDL2::SoundSDL2(OSystem& osystem, AudioSettings& audioSettings)
return; return;
} }
queryHardware(myDevices); queryHardware(myDevices); // NOLINT
SDL_zero(myHardwareSpec); SDL_zero(myHardwareSpec);
if(!openDevice()) if(!openDevice())
@ -137,12 +137,12 @@ bool SoundSDL2::openDevice()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundSDL2::setEnabled(bool state) void SoundSDL2::setEnabled(bool enable)
{ {
myAudioSettings.setEnabled(state); myAudioSettings.setEnabled(enable);
if (myAudioQueue) myAudioQueue->ignoreOverflows(!state); if (myAudioQueue) myAudioQueue->ignoreOverflows(!enable);
Logger::debug(state ? "SoundSDL2::setEnabled(true)" : Logger::debug(enable ? "SoundSDL2::setEnabled(true)" :
"SoundSDL2::setEnabled(false)"); "SoundSDL2::setEnabled(false)");
} }
@ -387,7 +387,7 @@ void SoundSDL2::initResampler()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SoundSDL2::callback(void* udata, uInt8* stream, int len) void SoundSDL2::callback(void* udata, uInt8* stream, int len)
{ {
SoundSDL2* self = static_cast<SoundSDL2*>(udata); auto* self = static_cast<SoundSDL2*>(udata);
if (self->myAudioQueue) if (self->myAudioQueue)
self->processFragment(reinterpret_cast<float*>(stream), len >> 2); self->processFragment(reinterpret_cast<float*>(stream), len >> 2);

View File

@ -79,6 +79,6 @@ class FixedStack
FixedStack& operator=(FixedStack&&) = delete; FixedStack& operator=(FixedStack&&) = delete;
}; };
} // Namespace Common } // namespace Common
#endif #endif

View File

@ -29,11 +29,11 @@ namespace {
std::array<char, 100> formattedTime; std::array<char, 100> formattedTime;
formattedTime.fill(0); formattedTime.fill(0);
std::strftime(formattedTime.data(), 99, "%H:%M:%S", &now); std::ignore = std::strftime(formattedTime.data(), 99, "%H:%M:%S", &now);
return formattedTime.data(); return formattedTime.data();
} }
} } // namespace
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
StaggeredLogger::StaggeredLogger(const string& message, Logger::Level level) StaggeredLogger::StaggeredLogger(const string& message, Logger::Level level)

View File

@ -28,9 +28,10 @@
#include "Logger.hxx" #include "Logger.hxx"
/** /**
* This class buffers log events and logs them after a certain time window has expired. * This class buffers log events and logs them after a certain time window has
* The timout increases after every log line by a factor of two until a maximum is reached. * expired. The timout increases after every log line by a factor of two until
* If no events are reported, the window size decreases again. * a maximum is reached. If no events are reported, the window size decreases
* again.
*/ */
class StaggeredLogger class StaggeredLogger
@ -46,7 +47,7 @@ class StaggeredLogger
void _log(); void _log();
void onTimerExpired(uInt32 timerId); void onTimerExpired(uInt32 timerCallbackId);
void startInterval(); void startInterval();

View File

@ -38,7 +38,7 @@ StateManager::StateManager(OSystem& osystem)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
StateManager::~StateManager() StateManager::~StateManager() // NOLINT (we need an empty d'tor)
{ {
} }

View File

@ -46,7 +46,7 @@ class ThreadDebuggingHelper {
private: private:
[[noreturn]] void fail(const string& message); [[noreturn]] static void fail(const string& message);
ThreadDebuggingHelper() = default; ThreadDebuggingHelper() = default;

View File

@ -20,8 +20,7 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TimerManager::TimerManager() TimerManager::TimerManager()
: nextId{no_timer + 1}, : nextId{no_timer + 1}
queue()
{ {
} }
@ -66,7 +65,7 @@ TimerManager::TimerId TimerManager::addTimer(
Duration(msPeriod), func)); Duration(msPeriod), func));
// Insert a reference to the Timer into ordering queue // Insert a reference to the Timer into ordering queue
const Queue::iterator place = queue.emplace(iter.first->second); const auto place = queue.emplace(iter.first->second);
// We need to notify the timer thread only if we inserted // We need to notify the timer thread only if we inserted
// this timer into the front of the timer queue // this timer into the front of the timer queue
@ -204,7 +203,7 @@ bool TimerManager::destroy_impl(ScopedLock& lock, TimerMap::iterator i,
timer.running = false; timer.running = false;
// Assign a condition variable to this timer // Assign a condition variable to this timer
timer.waitCond.reset(new ConditionVar); timer.waitCond = std::make_unique<ConditionVar>();
// Block until the callback is finished // Block until the callback is finished
if (std::this_thread::get_id() != worker.get_id()) if (std::this_thread::get_id() != worker.get_id())

View File

@ -40,6 +40,6 @@ void removeAt(vector<T>& dst, uInt32 idx)
dst.erase(dst.cbegin()+idx); dst.erase(dst.cbegin()+idx);
} }
} // Namespace Vec } // namespace Vec
#endif #endif

View File

@ -156,18 +156,18 @@ string ZipHandler::errorMessage(ZipError err)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ZipHandler::ZipFilePtr ZipHandler::findCached(const string& filename) ZipHandler::ZipFilePtr ZipHandler::findCached(const string& filename)
{ {
for(size_t cachenum = 0; cachenum < myZipCache.size(); ++cachenum) for(auto& cache: myZipCache)
{ {
// If we have a valid entry and it matches our filename, // If we have a valid entry and it matches our filename,
// use it and remove from the cache // use it and remove from the cache
if(myZipCache[cachenum] && (filename == myZipCache[cachenum]->myFilename)) if(cache && (filename == cache->myFilename))
{ {
ZipFilePtr result; ZipFilePtr result;
std::swap(myZipCache[cachenum], result); std::swap(cache, result);
return result; return result;
} }
} }
return ZipFilePtr(); return {};
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -180,7 +180,7 @@ void ZipHandler::addToCache()
myZip->close(); myZip->close();
// Find the first nullptr entry in the cache // Find the first nullptr entry in the cache
size_t cachenum; size_t cachenum{0};
for(cachenum = 0; cachenum < myZipCache.size(); ++cachenum) for(cachenum = 0; cachenum < myZipCache.size(); ++cachenum)
if(myZipCache[cachenum] == nullptr) if(myZipCache[cachenum] == nullptr)
break; break;

View File

@ -50,7 +50,7 @@ namespace {
return sinc(x) * sinc(x / static_cast<float>(a)); return sinc(x) * sinc(x / static_cast<float>(a));
} }
} } // namespace
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
LanczosResampler::LanczosResampler( LanczosResampler::LanczosResampler(
@ -72,11 +72,12 @@ LanczosResampler::LanczosResampler(
myPrecomputedKernelCount{reducedDenominator(formatFrom.sampleRate, formatTo.sampleRate)}, myPrecomputedKernelCount{reducedDenominator(formatFrom.sampleRate, formatTo.sampleRate)},
myKernelSize{2 * kernelParameter}, myKernelSize{2 * kernelParameter},
myKernelParameter{kernelParameter}, myKernelParameter{kernelParameter},
myHighPassL{HIGH_PASS_CUT_OFF, float(formatFrom.sampleRate)}, myHighPassL{HIGH_PASS_CUT_OFF, static_cast<float>(formatFrom.sampleRate)},
myHighPassR{HIGH_PASS_CUT_OFF, float(formatFrom.sampleRate)}, myHighPassR{HIGH_PASS_CUT_OFF, static_cast<float>(formatFrom.sampleRate)},
myHighPass{HIGH_PASS_CUT_OFF, float(formatFrom.sampleRate)} myHighPass{HIGH_PASS_CUT_OFF, static_cast<float>(formatFrom.sampleRate)}
{ {
myPrecomputedKernels = make_unique<float[]>(myPrecomputedKernelCount * myKernelSize); myPrecomputedKernels = make_unique<float[]>(
static_cast<size_t>(myPrecomputedKernelCount) * myKernelSize);
if (myFormatFrom.stereo) if (myFormatFrom.stereo)
{ {
@ -96,7 +97,8 @@ void LanczosResampler::precomputeKernels()
uInt32 timeIndex = 0; uInt32 timeIndex = 0;
for (uInt32 i = 0; i < myPrecomputedKernelCount; ++i) { for (uInt32 i = 0; i < myPrecomputedKernelCount; ++i) {
float* kernel = myPrecomputedKernels.get() + myKernelSize * i; float* kernel = myPrecomputedKernels.get() +
static_cast<size_t>(myKernelSize) * i;
// The kernel is normalized such to be evaluate on time * formatFrom.sampleRate // The kernel is normalized such to be evaluate on time * formatFrom.sampleRate
const float center = const float center =
static_cast<float>(timeIndex) / static_cast<float>(myFormatTo.sampleRate); static_cast<float>(timeIndex) / static_cast<float>(myFormatTo.sampleRate);
@ -140,10 +142,11 @@ void LanczosResampler::fillFragment(float* fragment, uInt32 length)
return; return;
} }
const uInt32 outputSamples = myFormatTo.stereo ? (length >> 1) : length; const size_t outputSamples = myFormatTo.stereo ? (length >> 1) : length;
for (uInt32 i = 0; i < outputSamples; ++i) { for (size_t i = 0; i < outputSamples; ++i) {
const float* kernel = myPrecomputedKernels.get() + (myCurrentKernelIndex * myKernelSize); const float* kernel = myPrecomputedKernels.get() +
static_cast<size_t>(myCurrentKernelIndex) * myKernelSize;
myCurrentKernelIndex = (myCurrentKernelIndex + 1) % myPrecomputedKernelCount; myCurrentKernelIndex = (myCurrentKernelIndex + 1) % myPrecomputedKernelCount;
if (myFormatFrom.stereo) { if (myFormatFrom.stereo) {
@ -180,11 +183,16 @@ inline void LanczosResampler::shiftSamples(uInt32 samplesToShift)
{ {
while (samplesToShift-- > 0) { while (samplesToShift-- > 0) {
if (myFormatFrom.stereo) { if (myFormatFrom.stereo) {
myBufferL->shift(myHighPassL.apply(myCurrentFragment[2*myFragmentIndex] / static_cast<float>(0x7fff))); myBufferL->shift(myHighPassL.apply(
myBufferR->shift(myHighPassR.apply(myCurrentFragment[2*myFragmentIndex + 1] / static_cast<float>(0x7fff))); myCurrentFragment[2 * static_cast<size_t>(myFragmentIndex)] /
static_cast<float>(0x7fff)));
myBufferR->shift(myHighPassR.apply(
myCurrentFragment[2 * static_cast<size_t>(myFragmentIndex) + 1] /
static_cast<float>(0x7fff)));
} }
else else
myBuffer->shift(myHighPass.apply(myCurrentFragment[myFragmentIndex] / static_cast<float>(0x7fff))); myBuffer->shift(myHighPass.apply(myCurrentFragment[myFragmentIndex] /
static_cast<float>(0x7fff)));
++myFragmentIndex; ++myFragmentIndex;

View File

@ -44,13 +44,17 @@ void SimpleResampler::fillFragment(float* fragment, uInt32 length)
return; return;
} }
const uInt32 outputSamples = myFormatTo.stereo ? (length >> 1) : length; const size_t outputSamples = myFormatTo.stereo ? (length >> 1) : length;
// For the following math, remember that myTimeIndex = time * myFormatFrom.sampleRate * myFormatTo.sampleRate // For the following math, remember that myTimeIndex = time * myFormatFrom.sampleRate * myFormatTo.sampleRate
for (uInt32 i = 0; i < outputSamples; ++i) { for (size_t i = 0; i < outputSamples; ++i) {
if (myFormatFrom.stereo) { if (myFormatFrom.stereo) {
const float sampleL = static_cast<float>(myCurrentFragment[2*myFragmentIndex]) / static_cast<float>(0x7fff); const float sampleL = static_cast<float>(
const float sampleR = static_cast<float>(myCurrentFragment[2*myFragmentIndex + 1]) / static_cast<float>(0x7fff); myCurrentFragment[2*static_cast<size_t>(myFragmentIndex)]) /
static_cast<float>(0x7fff);
const float sampleR = static_cast<float>(
myCurrentFragment[2*static_cast<size_t>(myFragmentIndex) + 1]) /
static_cast<float>(0x7fff);
if (myFormatTo.stereo) { if (myFormatTo.stereo) {
fragment[2*i] = sampleL; fragment[2*i] = sampleL;
@ -59,7 +63,8 @@ void SimpleResampler::fillFragment(float* fragment, uInt32 length)
else else
fragment[i] = (sampleL + sampleR) / 2.F; fragment[i] = (sampleL + sampleR) / 2.F;
} else { } else {
const float sample = static_cast<float>(myCurrentFragment[myFragmentIndex] / static_cast<float>(0x7fff)); const auto sample = static_cast<float>(myCurrentFragment[myFragmentIndex] /
static_cast<float>(0x7fff));
if (myFormatTo.stereo) if (myFormatTo.stereo)
fragment[2*i] = fragment[2*i + 1] = sample; fragment[2*i] = fragment[2*i + 1] = sample;

View File

@ -281,7 +281,7 @@ int main(int ac, char* av[])
{ {
attachConsole(); attachConsole();
Logger::debug("Displaying usage"); Logger::debug("Displaying usage");
theOSystem->settings().usage(); Settings::usage();
freeConsole(); freeConsole();
return Cleanup(); return Cleanup();
} }
@ -294,15 +294,15 @@ int main(int ac, char* av[])
// If not, use the built-in ROM launcher. In this case, we enter 'launcher' // If not, use the built-in ROM launcher. In this case, we enter 'launcher'
// mode and let the main event loop take care of opening a new console/ROM. // mode and let the main event loop take care of opening a new console/ROM.
FSNode romnode(romfile); FSNode romnode(romfile);
if(romfile == "" || romnode.isDirectory()) if(romfile.empty() || romnode.isDirectory())
{ {
Logger::debug("Attempting to use ROM launcher ..."); Logger::debug("Attempting to use ROM launcher ...");
bool launcherOpened = romfile != "" ? bool launcherOpened = !romfile.empty() ?
theOSystem->createLauncher(romnode.getPath()) : theOSystem->createLauncher(); theOSystem->createLauncher(romnode.getPath()) : theOSystem->createLauncher();
if(!launcherOpened) if(!launcherOpened)
{ {
Logger::debug("Launcher could not be started, showing usage"); Logger::debug("Launcher could not be started, showing usage");
theOSystem->settings().usage(); Settings::usage();
return Cleanup(); return Cleanup();
} }
} }
@ -333,7 +333,7 @@ int main(int ac, char* av[])
#ifdef DEBUGGER_SUPPORT #ifdef DEBUGGER_SUPPORT
// Set up any breakpoint that was on the command line // Set up any breakpoint that was on the command line
if(localOpts["break"].toString() != "") if(!localOpts["break"].toString().empty())
{ {
Debugger& dbg = theOSystem->debugger(); Debugger& dbg = theOSystem->debugger();
uInt16 bp = uInt16(dbg.stringToValue(localOpts["break"].toString())); uInt16 bp = uInt16(dbg.stringToValue(localOpts["break"].toString()));

View File

@ -28,7 +28,7 @@ namespace {
{} {}
std::map<string, Variant> load() override { std::map<string, Variant> load() override {
if (!myKvr.has(myKey)) return std::map<string, Variant>(); if (!myKvr.has(myKey)) return {};
Variant serialized; Variant serialized;
myKvr.get(myKey, serialized); myKvr.get(myKey, serialized);
@ -51,12 +51,13 @@ namespace {
KeyValueRepositoryAtomic& myKvr; KeyValueRepositoryAtomic& myKvr;
const string& myKey; const string& myKey;
}; };
} } // namespace
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CompositeKVRJsonAdapter::CompositeKVRJsonAdapter(KeyValueRepositoryAtomic& kvr) CompositeKVRJsonAdapter::CompositeKVRJsonAdapter(KeyValueRepositoryAtomic& kvr)
: myKvr{kvr} : myKvr{kvr}
{} {
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
shared_ptr<KeyValueRepository> CompositeKVRJsonAdapter::get(const string& key) shared_ptr<KeyValueRepository> CompositeKVRJsonAdapter::get(const string& key)

View File

@ -17,7 +17,6 @@
#include "repository/CompositeKeyValueRepository.hxx" #include "repository/CompositeKeyValueRepository.hxx"
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CompositeKeyValueRepositoryAtomic::get(const string& key1, const string& key2, Variant& value) bool CompositeKeyValueRepositoryAtomic::get(const string& key1, const string& key2, Variant& value)
{ {
@ -28,8 +27,7 @@ bool CompositeKeyValueRepositoryAtomic::get(const string& key1, const string& ke
shared_ptr<KeyValueRepositoryAtomic> CompositeKeyValueRepositoryAtomic::getAtomic(const string& key) shared_ptr<KeyValueRepositoryAtomic> CompositeKeyValueRepositoryAtomic::getAtomic(const string& key)
{ {
auto repo = get(key); auto repo = get(key);
return {repo, repo->atomic()};
return shared_ptr<KeyValueRepositoryAtomic>(repo, repo->atomic());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -27,7 +27,7 @@ class KeyValueRepositoryConfigfile : public KeyValueRepositoryFile<KeyValueRepos
using KeyValueRepositoryFile<KeyValueRepositoryConfigfile>::load; using KeyValueRepositoryFile<KeyValueRepositoryConfigfile>::load;
using KeyValueRepositoryFile<KeyValueRepositoryConfigfile>::save; using KeyValueRepositoryFile<KeyValueRepositoryConfigfile>::save;
explicit KeyValueRepositoryConfigfile(const FSNode& node); explicit KeyValueRepositoryConfigfile(const FSNode& file);
static std::map<string, Variant> load(istream& in); static std::map<string, Variant> load(istream& in);

View File

@ -27,7 +27,7 @@ namespace {
return parsed.is_discarded() ? json(s) : parsed; return parsed.is_discarded() ? json(s) : parsed;
} }
} } // namespace
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
KeyValueRepositoryJsonFile::KeyValueRepositoryJsonFile(const FSNode& node) KeyValueRepositoryJsonFile::KeyValueRepositoryJsonFile(const FSNode& node)
@ -55,14 +55,16 @@ std::map<string, Variant> KeyValueRepositoryJsonFile::load(istream& in)
return map; return map;
} }
catch (const json::exception& err) { catch (const json::exception& err) {
Logger::error("KeyValueRepositoryJsonFile: error during deserialization: " + string(err.what())); Logger::error("KeyValueRepositoryJsonFile: error during deserialization: " +
string(err.what()));
return std::map<string, Variant>(); return {};
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool KeyValueRepositoryJsonFile::save(ostream& out, const std::map<string, Variant>& values) bool KeyValueRepositoryJsonFile::save(ostream& out,
const std::map<string, Variant>& values)
{ {
try { try {
json serializedJson = json::object(); json serializedJson = json::object();
@ -75,7 +77,8 @@ bool KeyValueRepositoryJsonFile::save(ostream& out, const std::map<string, Varia
return true; return true;
} }
catch (const json::exception& err) { catch (const json::exception& err) {
Logger::error("KeyValueRepositoryJsonFile: error during serialization: " + string(err.what())); Logger::error("KeyValueRepositoryJsonFile: error during serialization: " +
string(err.what()));
return false; return false;
} }

View File

@ -22,7 +22,7 @@ namespace {
string readQuotedString(istream& in) string readQuotedString(istream& in)
{ {
// Read characters until we see a quote // Read characters until we see a quote
char c; char c{0};
while(in.get(c)) while(in.get(c))
if(c == '"') if(c == '"')
break; break;
@ -49,25 +49,24 @@ namespace {
void writeQuotedString(ostream& out, const string& s) void writeQuotedString(ostream& out, const string& s)
{ {
out.put('"'); out.put('"');
for(uInt32 i = 0; i < s.length(); ++i) for(auto c: s)
{ {
if(s[i] == '\\') if(c == '\\')
{ {
out.put('\\'); out.put('\\');
out.put('\\'); out.put('\\');
} }
else if(s[i] == '\"') else if(c == '\"')
{ {
out.put('\\'); out.put('\\');
out.put('"'); out.put('"');
} }
else else
out.put(s[i]); out.put(c);
} }
out.put('"'); out.put('"');
} }
} // namespace
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
KeyValueRepositoryPropertyFile::KeyValueRepositoryPropertyFile( KeyValueRepositoryPropertyFile::KeyValueRepositoryPropertyFile(
@ -92,7 +91,7 @@ std::map<string, Variant> KeyValueRepositoryPropertyFile::load(istream& in)
if(!in) return map; if(!in) return map;
// A null key signifies the end of the property list // A null key signifies the end of the property list
if(key == "") if(key.empty())
break; break;
// Get the value associated with this property // Get the value associated with this property
@ -109,9 +108,10 @@ std::map<string, Variant> KeyValueRepositoryPropertyFile::load(istream& in)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool KeyValueRepositoryPropertyFile::save(ostream& out, const std::map<string, Variant>& values) bool KeyValueRepositoryPropertyFile::save(ostream& out,
const std::map<string, Variant>& values)
{ {
for (auto& [key, value]: values) { for (const auto& [key, value]: values) {
writeQuotedString(out, key); writeQuotedString(out, key);
out.put(' '); out.put(' ');
writeQuotedString(out, value.toString()); writeQuotedString(out, value.toString());

View File

@ -45,7 +45,7 @@ bool CompositeKeyValueRepositorySqlite::has(const string& key)
try { try {
(*myStmtCountSet) (*myStmtCountSet)
.reset() .reset()
.bind(1, key.c_str()); .bind(1, key);
if (!myStmtCountSet->step()) if (!myStmtCountSet->step())
throw SqliteError("count failed"); throw SqliteError("count failed");
@ -68,7 +68,7 @@ void CompositeKeyValueRepositorySqlite::remove(const string& key)
try { try {
(*myStmtDeleteSet) (*myStmtDeleteSet)
.reset() .reset()
.bind(1, key.c_str()) .bind(1, key)
.step(); .step();
myStmtDelete->reset(); myStmtDelete->reset();
@ -153,9 +153,9 @@ SqliteStatement& CompositeKeyValueRepositorySqlite::ProxyRepository::stmtInsert(
) { ) {
return (*myRepo.myStmtInsert) return (*myRepo.myStmtInsert)
.reset() .reset()
.bind(1, myKey.c_str()) .bind(1, myKey)
.bind(2, key.c_str()) .bind(2, key)
.bind(3, value.c_str()); .bind(3, value);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -163,7 +163,7 @@ SqliteStatement& CompositeKeyValueRepositorySqlite::ProxyRepository::stmtSelect(
{ {
return (*myRepo.myStmtSelect) return (*myRepo.myStmtSelect)
.reset() .reset()
.bind(1, myKey.c_str()); .bind(1, myKey);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -172,8 +172,8 @@ SqliteStatement& CompositeKeyValueRepositorySqlite::ProxyRepository::stmtDelete(
myRepo.myStmtDelete->reset(); myRepo.myStmtDelete->reset();
return (*myRepo.myStmtDelete) return (*myRepo.myStmtDelete)
.bind(1, myKey.c_str()) .bind(1, myKey)
.bind(2, key.c_str()); .bind(2, key);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -181,8 +181,8 @@ SqliteStatement& CompositeKeyValueRepositorySqlite::ProxyRepository::stmtSelectO
{ {
return (*myRepo.myStmtSelectOne) return (*myRepo.myStmtSelectOne)
.reset() .reset()
.bind(1, myKey.c_str()) .bind(1, myKey)
.bind(2, key.c_str()); .bind(2, key);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -190,8 +190,8 @@ SqliteStatement& CompositeKeyValueRepositorySqlite::ProxyRepository::stmtCount(c
{ {
return (*myRepo.myStmtCount) return (*myRepo.myStmtCount)
.reset() .reset()
.bind(1, myKey.c_str()) .bind(1, myKey)
.bind(2, key.c_str()); .bind(2, key);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -34,8 +34,8 @@ SqliteStatement& KeyValueRepositorySqlite::stmtInsert(const string& key, const s
{ {
return (*myStmtInsert) return (*myStmtInsert)
.reset() .reset()
.bind(1, key.c_str()) .bind(1, key)
.bind(2, value.c_str()); .bind(2, value);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -50,7 +50,7 @@ SqliteStatement& KeyValueRepositorySqlite::stmtDelete(const string& key)
{ {
return (*myStmtDelete) return (*myStmtDelete)
.reset() .reset()
.bind(1, key.c_str()); .bind(1, key);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -58,7 +58,7 @@ SqliteStatement& KeyValueRepositorySqlite::stmtCount(const string& key)
{ {
return (*myStmtCount) return (*myStmtCount)
.reset() .reset()
.bind(1, key.c_str()); .bind(1, key);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -66,7 +66,7 @@ SqliteStatement& KeyValueRepositorySqlite::stmtSelectOne(const string& key)
{ {
return (*myStmtSelectOne) return (*myStmtSelectOne)
.reset() .reset()
.bind(1, key.c_str()); .bind(1, key);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -53,7 +53,7 @@ void SqliteDatabase::initialize()
if (!dbInitialized && tries == 1) { if (!dbInitialized && tries == 1) {
Logger::info("sqlite DB " + myDatabaseFile + " seems to be corrupt, removing and retrying..."); Logger::info("sqlite DB " + myDatabaseFile + " seems to be corrupt, removing and retrying...");
remove(myDatabaseFile.c_str()); std::ignore = remove(myDatabaseFile.c_str());
if (myHandle) sqlite3_close_v2(myHandle); if (myHandle) sqlite3_close_v2(myHandle);
} }
} }
@ -107,7 +107,7 @@ Int32 SqliteDatabase::getUserVersion() const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SqliteDatabase::setUserVersion(Int32 version) void SqliteDatabase::setUserVersion(Int32 version) const
{ {
SqliteStatement(*this, "PRAGMA user_version = %i", static_cast<int>(version)) SqliteStatement(*this, "PRAGMA user_version = %i", static_cast<int>(version))
.step(); .step();

View File

@ -42,7 +42,7 @@ class SqliteDatabase
void exec(const string& sql, T arg1, Ts... args); void exec(const string& sql, T arg1, Ts... args);
Int32 getUserVersion() const; Int32 getUserVersion() const;
void setUserVersion(Int32 version); void setUserVersion(Int32 version) const;
private: private:

View File

@ -44,7 +44,8 @@ SqliteStatement::~SqliteStatement()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SqliteStatement& SqliteStatement::bind(int index, const string& value) SqliteStatement& SqliteStatement::bind(int index, const string& value)
{ {
if (sqlite3_bind_text(myStmt, index, value.c_str(), -1, SQLITE_TRANSIENT) != SQLITE_OK) if (sqlite3_bind_text(myStmt, index, value.c_str(), -1,
SQLITE_TRANSIENT) != SQLITE_OK) // NOLINT (performance-no-int-to-ptr)
throw SqliteError(myHandle); throw SqliteError(myHandle);
return *this; return *this;

View File

@ -36,7 +36,7 @@
namespace { namespace {
constexpr Int32 CURRENT_VERSION = 1; constexpr Int32 CURRENT_VERSION = 1;
} } // namespace
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
StellaDb::StellaDb(const string& databaseDirectory, const string& databaseName) StellaDb::StellaDb(const string& databaseDirectory, const string& databaseName)
@ -85,7 +85,7 @@ void StellaDb::initialize()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string StellaDb::databaseFileName() const string StellaDb::databaseFileName() const
{ {
return myDb ? FSNode(myDb->fileName()).getShortPath() : "[failed]"; return myDb ? FSNode(myDb->fileName()).getShortPath() : "[failed]";
} }
@ -190,8 +190,11 @@ void StellaDb::importOldPropset(const FSNode& node)
while (true) { while (true) {
auto props = KeyValueRepositoryPropertyFile::load(in); auto props = KeyValueRepositoryPropertyFile::load(in);
if (props.size() == 0) break; if (props.empty())
if ((props.find("Cart.MD5") == props.end()) || props["Cart.MD5"].toString() == "") continue; break;
if ((props.find("Cart.MD5") == props.end()) ||
props["Cart.MD5"].toString().empty())
continue;
myPropertyRepository->get(props["Cart.MD5"].toString())->save(props); myPropertyRepository->get(props["Cart.MD5"].toString())->save(props);
} }
@ -201,7 +204,7 @@ void StellaDb::importOldPropset(const FSNode& node)
void StellaDb::migrate() void StellaDb::migrate()
{ {
const Int32 version = myDb->getUserVersion(); const Int32 version = myDb->getUserVersion();
switch (version) { switch (version) { // NOLINT (could be written as IF/ELSE)
case 1: case 1:
return; return;

View File

@ -27,21 +27,25 @@
class StellaDb class StellaDb
{ {
public: public:
StellaDb(const string& databaseDirectory, const string& databaseName); StellaDb(const string& databaseDirectory, const string& databaseName);
void initialize(); void initialize();
KeyValueRepositoryAtomic& settingsRepository() const { return *mySettingsRepository; } KeyValueRepositoryAtomic& settingsRepository() const {
CompositeKeyValueRepository& propertyRepository() const { return *myPropertyRepository; } return *mySettingsRepository;
CompositeKeyValueRepositoryAtomic& highscoreRepository() const { return *myHighscoreRepository; } }
CompositeKeyValueRepository& propertyRepository() const {
return *myPropertyRepository;
}
CompositeKeyValueRepositoryAtomic& highscoreRepository() const {
return *myHighscoreRepository;
}
const string databaseFileName() const; string databaseFileName() const;
bool isValid() const; bool isValid() const;
private: private:
void initializeDb(); void initializeDb();
void importOldSettings(); void importOldSettings();
void importStellarc(const FSNode& node); void importStellarc(const FSNode& node);
@ -51,7 +55,6 @@ class StellaDb
void migrate(); void migrate();
private: private:
string myDatabaseDirectory; string myDatabaseDirectory;
string myDatabaseName; string myDatabaseName;

View File

@ -126,7 +126,7 @@ void BilinearBlitter::recreateTexturesIfNecessary()
} }
if (myAttributes.blending) { if (myAttributes.blending) {
const uInt8 blendAlpha = static_cast<uInt8>(myAttributes.blendalpha * 2.55); const auto blendAlpha = static_cast<uInt8>(myAttributes.blendalpha * 2.55);
std::array<SDL_Texture*, 2> textures = { myTexture, mySecondaryTexture }; std::array<SDL_Texture*, 2> textures = { myTexture, mySecondaryTexture };
for (SDL_Texture* texture: textures) { for (SDL_Texture* texture: textures) {

View File

@ -181,7 +181,7 @@ void QisBlitter::recreateTexturesIfNecessary()
} }
if (myAttributes.blending) { if (myAttributes.blending) {
const uInt8 blendAlpha = static_cast<uInt8>(myAttributes.blendalpha * 2.55); const auto blendAlpha = static_cast<uInt8>(myAttributes.blendalpha * 2.55);
std::array<SDL_Texture*, 3> textures = { std::array<SDL_Texture*, 3> textures = {
mySrcTexture, myIntermediateTexture, mySecondaryIntermedateTexture mySrcTexture, myIntermediateTexture, mySecondaryIntermedateTexture

View File

@ -37,7 +37,7 @@ class QisBlitter : public Blitter {
SDL_Rect srcRect, SDL_Rect srcRect,
SDL_Rect destRect, SDL_Rect destRect,
FBSurface::Attributes attributes, FBSurface::Attributes attributes,
SDL_Surface* staticData = nullptr SDL_Surface* staticData
) override; ) override;
void blit(SDL_Surface& surface) override; void blit(SDL_Surface& surface) override;

View File

@ -42,11 +42,11 @@ void AtariNTSC::initialize(const Setup& setup)
void AtariNTSC::setPalette(const PaletteArray& palette) void AtariNTSC::setPalette(const PaletteArray& palette)
{ {
uInt8* ptr = myRGBPalette.data(); uInt8* ptr = myRGBPalette.data();
for(size_t i = 0; i < palette.size(); ++i) for(auto p: palette)
{ {
*ptr++ = (palette[i] >> 16) & 0xff; *ptr++ = (p >> 16) & 0xff;
*ptr++ = (palette[i] >> 8) & 0xff; *ptr++ = (p >> 8) & 0xff;
*ptr++ = palette[i] & 0xff; *ptr++ = p & 0xff;
} }
generateKernels(); generateKernels();
} }
@ -60,10 +60,10 @@ void AtariNTSC::generateKernels()
const float r = (*ptr++) / 255.F * rgb_unit + rgb_offset, const float r = (*ptr++) / 255.F * rgb_unit + rgb_offset,
g = (*ptr++) / 255.F * rgb_unit + rgb_offset, g = (*ptr++) / 255.F * rgb_unit + rgb_offset,
b = (*ptr++) / 255.F * rgb_unit + rgb_offset; b = (*ptr++) / 255.F * rgb_unit + rgb_offset;
float y, i, q; RGB_TO_YIQ( r, g, b, y, i, q ); float y, i, q; RGB_TO_YIQ( r, g, b, y, i, q ); // NOLINT
// Generate kernel // Generate kernel
int ir, ig, ib; YIQ_TO_RGB( y, i, q, myImpl.to_rgb.data(), ir, ig, ib ); int ir, ig, ib; YIQ_TO_RGB( y, i, q, myImpl.to_rgb.data(), ir, ig, ib ); //NOLINT
const uInt32 rgb = PACK_RGB( ir, ig, ib ); const uInt32 rgb = PACK_RGB( ir, ig, ib );
uInt32* kernel = myColorTable[entry].data(); uInt32* kernel = myColorTable[entry].data();
@ -123,7 +123,7 @@ void AtariNTSC::render(const uInt8* atari_in, const uInt32 in_width,
// Copy phosphor values into out buffer // Copy phosphor values into out buffer
if(rgb_in != nullptr) if(rgb_in != nullptr)
memcpy(rgb_out, rgb_in, in_height * out_pitch); memcpy(rgb_out, rgb_in, static_cast<size_t>(in_height) * out_pitch);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -134,8 +134,8 @@ void AtariNTSC::renderThread(const uInt8* atari_in, const uInt32 in_width,
// Adapt parameters to thread number // Adapt parameters to thread number
const uInt32 yStart = in_height * threadNum / numThreads; const uInt32 yStart = in_height * threadNum / numThreads;
const uInt32 yEnd = in_height * (threadNum + 1) / numThreads; const uInt32 yEnd = in_height * (threadNum + 1) / numThreads;
atari_in += in_width * yStart; atari_in += static_cast<size_t>(in_width) * yStart;
rgb_out = static_cast<char*>(rgb_out) + out_pitch * yStart; rgb_out = static_cast<char*>(rgb_out) + static_cast<size_t>(out_pitch) * yStart;
uInt32 const chunk_count = (in_width - 1) / PIXEL_in_chunk; uInt32 const chunk_count = (in_width - 1) / PIXEL_in_chunk;
@ -143,7 +143,7 @@ void AtariNTSC::renderThread(const uInt8* atari_in, const uInt32 in_width,
{ {
const uInt8* line_in = atari_in; const uInt8* line_in = atari_in;
ATARI_NTSC_BEGIN_ROW(NTSC_black, line_in[0]); ATARI_NTSC_BEGIN_ROW(NTSC_black, line_in[0]);
uInt32* restrict line_out = static_cast<uInt32*>(rgb_out); auto* restrict line_out = static_cast<uInt32*>(rgb_out);
++line_in; ++line_in;
// shift right by 2 pixel // shift right by 2 pixel
@ -210,8 +210,8 @@ void AtariNTSC::renderWithPhosphorThread(const uInt8* atari_in, const uInt32 in_
const uInt32 yEnd = in_height * (threadNum + 1) / numThreads; const uInt32 yEnd = in_height * (threadNum + 1) / numThreads;
uInt32 bufofs = AtariNTSC::outWidth(in_width) * yStart; uInt32 bufofs = AtariNTSC::outWidth(in_width) * yStart;
const uInt32* out = static_cast<uInt32*>(rgb_out); const uInt32* out = static_cast<uInt32*>(rgb_out);
atari_in += in_width * yStart; atari_in += static_cast<size_t>(in_width) * yStart;
rgb_out = static_cast<char*>(rgb_out) + out_pitch * yStart; rgb_out = static_cast<char*>(rgb_out) + static_cast<size_t>(out_pitch) * yStart;
uInt32 const chunk_count = (in_width - 1) / PIXEL_in_chunk; uInt32 const chunk_count = (in_width - 1) / PIXEL_in_chunk;
@ -219,7 +219,7 @@ void AtariNTSC::renderWithPhosphorThread(const uInt8* atari_in, const uInt32 in_
{ {
const uInt8* line_in = atari_in; const uInt8* line_in = atari_in;
ATARI_NTSC_BEGIN_ROW(NTSC_black, line_in[0]); ATARI_NTSC_BEGIN_ROW(NTSC_black, line_in[0]);
uInt32* restrict line_out = static_cast<uInt32*>(rgb_out); auto* restrict line_out = static_cast<uInt32*>(rgb_out);
++line_in; ++line_in;
// shift right by 2 pixel // shift right by 2 pixel
@ -335,9 +335,8 @@ void AtariNTSC::init(init_t& impl, const Setup& setup)
/* setup decoder matricies */ /* setup decoder matricies */
{ {
float* out = impl.to_rgb.data(); float* out = impl.to_rgb.data();
int n;
n = burst_count; int n = burst_count;
do do
{ {
float const* in = default_decoder.data(); float const* in = default_decoder.data();
@ -362,7 +361,7 @@ void AtariNTSC::init(init_t& impl, const Setup& setup)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AtariNTSC::initFilters(init_t& impl, const Setup& setup) void AtariNTSC::initFilters(init_t& impl, const Setup& setup)
{ {
std::array<float, kernel_size * 2> kernels{0}; std::array<float, static_cast<size_t>(kernel_size) * 2> kernels{0};
/* generate luma (y) filter using sinc kernel */ /* generate luma (y) filter using sinc kernel */
{ {
@ -433,12 +432,11 @@ void AtariNTSC::initFilters(init_t& impl, const Setup& setup)
for ( int i = 0; i < 2; i++ ) for ( int i = 0; i < 2; i++ )
{ {
float sum = 0; float sum = 0;
int x; for ( int x = i; x < kernel_size; x += 2 )
for ( x = i; x < kernel_size; x += 2 )
sum += kernels [x]; sum += kernels [x];
sum = 1.0F / sum; sum = 1.0F / sum;
for ( x = i; x < kernel_size; x += 2 ) for ( int x = i; x < kernel_size; x += 2 )
{ {
kernels [x] *= sum; kernels [x] *= sum;
} }
@ -506,12 +504,13 @@ void AtariNTSC::genKernel(init_t& impl, float y, float i, float q, uInt32* out)
const float fq = k[1]*qc1 + k[3]*qc3; const float fq = k[1]*qc1 + k[3]*qc3;
const float fy = k[kernel_size+0]*yc0 + k[kernel_size+1]*yc1 + const float fy = k[kernel_size+0]*yc0 + k[kernel_size+1]*yc1 +
k[kernel_size+2]*yc2 + k[kernel_size+3]*yc3 + rgb_offset; k[kernel_size+2]*yc2 + k[kernel_size+3]*yc3 + rgb_offset;
if ( k < &impl.kernel [kernel_size * 2 * (rescale_out - 1)] ) if ( k < &impl.kernel [static_cast<size_t>(kernel_size) * 2 *
(rescale_out - 1)] )
k += kernel_size * 2 - 1; k += kernel_size * 2 - 1;
else else
k -= kernel_size * 2 * (rescale_out - 1) + 2; k -= kernel_size * 2 * (rescale_out - 1) + 2;
{ {
int r, g, b; YIQ_TO_RGB( fy, fi, fq, to_rgb, r, g, b ); int r, g, b; YIQ_TO_RGB( fy, fi, fq, to_rgb, r, g, b ); // NOLINT
*out++ = PACK_RGB( r, g, b ) - rgb_bias; *out++ = PACK_RGB( r, g, b ) - rgb_bias;
} }
} }

View File

@ -187,10 +187,10 @@ class AtariNTSC
0.9563F, 0.6210F, -0.2721F, -0.6474F, -1.1070F, 1.7046F 0.9563F, 0.6210F, -0.2721F, -0.6474F, -1.1070F, 1.7046F
}; };
void init(init_t& impl, const Setup& setup); static void init(init_t& impl, const Setup& setup);
void initFilters(init_t& impl, const Setup& setup); static void initFilters(init_t& impl, const Setup& setup);
// Generate pixel at all burst phases and column alignments // Generate pixel at all burst phases and column alignments
void genKernel(init_t& impl, float y, float i, float q, uInt32* out); static void genKernel(init_t& impl, float y, float i, float q, uInt32* out);
// Begins outputting row and starts two pixels. First pixel will be cut // Begins outputting row and starts two pixels. First pixel will be cut
// off a bit. Use atari_ntsc_black for unused pixels. // off a bit. Use atari_ntsc_black for unused pixels.

View File

@ -139,7 +139,7 @@ void NTSCFilter::loadConfig(const Settings& settings)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void NTSCFilter::saveConfig(Settings& settings) const void NTSCFilter::saveConfig(Settings& settings)
{ {
// Save adjustables for custom mode // Save adjustables for custom mode
settings.setValue("tv.sharpness", myCustomSetup.sharpness); settings.setValue("tv.sharpness", myCustomSetup.sharpness);
@ -150,7 +150,7 @@ void NTSCFilter::saveConfig(Settings& settings) const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void NTSCFilter::getAdjustables(Adjustable& adjustable, Preset preset) const void NTSCFilter::getAdjustables(Adjustable& adjustable, Preset preset)
{ {
switch(preset) switch(preset)
{ {
@ -181,7 +181,7 @@ void NTSCFilter::setCustomAdjustables(const Adjustable& adjustable)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void NTSCFilter::convertToAdjustable(Adjustable& adjustable, void NTSCFilter::convertToAdjustable(Adjustable& adjustable,
const AtariNTSC::Setup& setup) const const AtariNTSC::Setup& setup)
{ {
adjustable.sharpness = scaleTo100(setup.sharpness); adjustable.sharpness = scaleTo100(setup.sharpness);
adjustable.resolution = scaleTo100(setup.resolution); adjustable.resolution = scaleTo100(setup.resolution);
@ -192,12 +192,3 @@ void NTSCFilter::convertToAdjustable(Adjustable& adjustable,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AtariNTSC::Setup NTSCFilter::myCustomSetup = AtariNTSC::TV_Composite; AtariNTSC::Setup NTSCFilter::myCustomSetup = AtariNTSC::TV_Composite;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const std::array<NTSCFilter::AdjustableTag, int(NTSCFilter::Adjustables::NUM_ADJUSTABLES)> NTSCFilter::ourCustomAdjustables = { {
{ "sharpness", &myCustomSetup.sharpness },
{ "resolution", &myCustomSetup.resolution },
{ "artifacts", &myCustomSetup.artifacts },
{ "fringing", &myCustomSetup.fringing },
{ "bleeding", &myCustomSetup.bleed }
} };

View File

@ -80,12 +80,12 @@ class NTSCFilter
// Get adjustables for the given preset // Get adjustables for the given preset
// Values will be scaled to 0 - 100 range, independent of how // Values will be scaled to 0 - 100 range, independent of how
// they're actually stored internally // they're actually stored internally
void getAdjustables(Adjustable& adjustable, Preset preset) const; static void getAdjustables(Adjustable& adjustable, Preset preset);
// Set custom adjustables to given values // Set custom adjustables to given values
// Values will be scaled to 0 - 100 range, independent of how // Values will be scaled to 0 - 100 range, independent of how
// they're actually stored internally // they're actually stored internally
void setCustomAdjustables(const Adjustable& adjustable); static void setCustomAdjustables(const Adjustable& adjustable);
// The following methods cycle through each custom adjustable // The following methods cycle through each custom adjustable
// They are used in conjunction with the increase/decrease // They are used in conjunction with the increase/decrease
@ -101,8 +101,8 @@ class NTSCFilter
string& text, string& valueText, Int32& newValue); string& text, string& valueText, Int32& newValue);
// Load and save NTSC-related settings // Load and save NTSC-related settings
void loadConfig(const Settings& settings); static void loadConfig(const Settings& settings);
void saveConfig(Settings& settings) const; static void saveConfig(Settings& settings);
// Perform Blargg filtering on input buffer, place results in // Perform Blargg filtering on input buffer, place results in
// output buffer // output buffer
@ -125,8 +125,8 @@ class NTSCFilter
private: private:
// Convert from atari_ntsc_setup_t values to equivalent adjustables // Convert from atari_ntsc_setup_t values to equivalent adjustables
void convertToAdjustable(Adjustable& adjustable, static void convertToAdjustable(Adjustable& adjustable,
const AtariNTSC::Setup& setup) const; const AtariNTSC::Setup& setup);
private: private:
// The NTSC object // The NTSC object
@ -148,7 +148,14 @@ class NTSCFilter
float* value{nullptr}; float* value{nullptr};
}; };
uInt32 myCurrentAdjustable{0}; uInt32 myCurrentAdjustable{0};
static const std::array<AdjustableTag, 5> ourCustomAdjustables;
static constexpr std::array<AdjustableTag, 5> ourCustomAdjustables = {{
{ "sharpness", &myCustomSetup.sharpness },
{ "resolution", &myCustomSetup.resolution },
{ "artifacts", &myCustomSetup.artifacts },
{ "fringing", &myCustomSetup.fringing },
{ "bleeding", &myCustomSetup.bleed }
}};
private: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported

View File

@ -110,7 +110,8 @@ BreakpointMap::BreakpointList BreakpointMap::getBreakpoints() const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
BreakpointMap::Breakpoint BreakpointMap::convertBreakpoint(const Breakpoint& breakpoint) BreakpointMap::Breakpoint BreakpointMap::convertBreakpoint(
const Breakpoint& breakpoint)
{ {
if(breakpoint.bank == ANY_BANK) if(breakpoint.bank == ANY_BANK)
return Breakpoint(breakpoint.addr, ANY_BANK); return Breakpoint(breakpoint.addr, ANY_BANK);

View File

@ -90,7 +90,7 @@ class BreakpointMap
size_t size() const { return myMap.size(); } size_t size() const { return myMap.size(); }
private: private:
Breakpoint convertBreakpoint(const Breakpoint& breakpoint); static Breakpoint convertBreakpoint(const Breakpoint& breakpoint);
struct BreakpointHash { struct BreakpointHash {
size_t operator()(const Breakpoint& bp) const { size_t operator()(const Breakpoint& bp) const {

View File

@ -140,8 +140,8 @@ CartDebug::CartDebug(Debugger& dbg, Console& console, const OSystem& osystem)
const DebuggerState& CartDebug::getState() const DebuggerState& CartDebug::getState()
{ {
myState.ram.clear(); myState.ram.clear();
for(uInt32 i = 0; i < myState.rport.size(); ++i) for(auto addr: myState.rport)
myState.ram.push_back(myDebugger.peek(myState.rport[i])); myState.ram.push_back(myDebugger.peek(addr));
if(myDebugWidget) if(myDebugWidget)
myState.bank = myDebugWidget->bankState(); myState.bank = myDebugWidget->bankState();
@ -153,8 +153,8 @@ const DebuggerState& CartDebug::getState()
void CartDebug::saveOldState() void CartDebug::saveOldState()
{ {
myOldState.ram.clear(); myOldState.ram.clear();
for(uInt32 i = 0; i < myOldState.rport.size(); ++i) for(auto addr: myOldState.rport)
myOldState.ram.push_back(myDebugger.peek(myOldState.rport[i])); myOldState.ram.push_back(myDebugger.peek(addr));
if(myDebugWidget) if(myDebugWidget)
{ {
@ -209,8 +209,8 @@ string CartDebug::toString()
return DebuggerParser::red("invalid base, this is a BUG"); return DebuggerParser::red("invalid base, this is a BUG");
} }
const CartState& state = static_cast<const CartState&>(getState()); const auto& state = static_cast<const CartState&>(getState());
const CartState& oldstate = static_cast<const CartState&>(getOldState()); const auto& oldstate = static_cast<const CartState&>(getOldState());
uInt32 curraddr = 0, bytesSoFar = 0; uInt32 curraddr = 0, bytesSoFar = 0;
for(uInt32 i = 0; i < state.ram.size(); i += bytesPerLine, bytesSoFar += bytesPerLine) for(uInt32 i = 0; i < state.ram.size(); i += bytesPerLine, bytesSoFar += bytesPerLine)
@ -221,7 +221,7 @@ string CartDebug::toString()
if(state.rport[i] - curraddr > bytesPerLine || bytesSoFar >= 256) if(state.rport[i] - curraddr > bytesPerLine || bytesSoFar >= 256)
{ {
char port[37]; // NOLINT (convert to stringstream) char port[37]; // NOLINT (convert to stringstream)
std::snprintf(port, 36, "%04x: (rport = %04x, wport = %04x)\n", std::ignore = std::snprintf(port, 36, "%04x: (rport = %04x, wport = %04x)\n",
state.rport[i], state.rport[i], state.wport[i]); state.rport[i], state.rport[i], state.wport[i]);
port[2] = port[3] = 'x'; port[2] = port[3] = 'x';
buf << DebuggerParser::red(port); buf << DebuggerParser::red(port);
@ -232,7 +232,7 @@ string CartDebug::toString()
for(uInt32 j = 0; j < bytesPerLine; ++j) for(uInt32 j = 0; j < bytesPerLine; ++j)
{ {
buf << myDebugger.invIfChanged(state.ram[i+j], oldstate.ram[i+j]) << " "; buf << Debugger::invIfChanged(state.ram[i+j], oldstate.ram[i+j]) << " ";
if(j == 0x07) buf << " "; if(j == 0x07) buf << " ";
} }
@ -248,7 +248,8 @@ bool CartDebug::disassembleAddr(uInt16 address, bool force)
const Cartridge& cart = myConsole.cartridge(); const Cartridge& cart = myConsole.cartridge();
const int segCount = cart.segmentCount(); const int segCount = cart.segmentCount();
// ROM/RAM bank or ZP-RAM? // ROM/RAM bank or ZP-RAM?
const int addrBank = (address & 0x1000) ? getBank(address) : int(myBankInfo.size()) - 1; const int addrBank = (address & 0x1000)
? getBank(address) : static_cast<int>(myBankInfo.size()) - 1;
if(segCount > 1) if(segCount > 1)
{ {
@ -260,14 +261,10 @@ bool CartDebug::disassembleAddr(uInt16 address, bool force)
const int bank = cart.getSegmentBank(seg); const int bank = cart.getSegmentBank(seg);
Disassembly disassembly; Disassembly disassembly;
AddrToLineList addrToLineList; AddrToLineList addrToLineList;
uInt16 segAddress;
BankInfo& info = myBankInfo[bank]; BankInfo& info = myBankInfo[bank];
info.offset = cart.bankOrigin(bank) | cart.bankSize() * seg; info.offset = cart.bankOrigin(bank) | cart.bankSize() * seg;
if(bank == addrBank) const uInt16 segAddress = bank == addrBank ? address : info.offset;
segAddress = address;
else
segAddress = info.offset;
// Disassemble segment // Disassemble segment
const bool newChanged = disassemble(bank, segAddress, disassembly, addrToLineList, force); const bool newChanged = disassemble(bank, segAddress, disassembly, addrToLineList, force);
@ -383,12 +380,12 @@ bool CartDebug::fillDisassemblyList(BankInfo& info, Disassembly& disassembly,
disassembly.list.clear(); disassembly.list.clear();
addrToLineList.clear(); addrToLineList.clear();
// An empty address list means that DiStella can't do a disassembly // An empty address list means that DiStella can't do a disassembly
if(info.addressList.size() == 0) if(info.addressList.empty())
return false; return false;
disassembly.fieldwidth = 24 + myLabelLength; disassembly.fieldwidth = 24 + myLabelLength;
// line offset must be set before calling DiStella! // line offset must be set before calling DiStella!
uInt32 lineOfs = static_cast<uInt32>(myDisassembly.list.size()); auto lineOfs = static_cast<uInt32>(myDisassembly.list.size());
DiStella distella(*this, disassembly.list, info, DiStella::settings, DiStella distella(*this, disassembly.list, info, DiStella::settings,
myDisLabels, myDisDirectives, myReserved); myDisLabels, myDisDirectives, myReserved);
@ -480,7 +477,7 @@ bool CartDebug::addDirective(Device::AccessType type,
if(bank < 0) // Do we want the current bank or ZP RAM? if(bank < 0) // Do we want the current bank or ZP RAM?
bank = (myDebugger.cpuDebug().pc() & 0x1000) ? bank = (myDebugger.cpuDebug().pc() & 0x1000) ?
getBank(myDebugger.cpuDebug().pc()) : int(myBankInfo.size())-1; getBank(myDebugger.cpuDebug().pc()) : static_cast<int>(myBankInfo.size())-1;
bank = std::min(bank, romBankCount()); bank = std::min(bank, romBankCount());
BankInfo& info = myBankInfo[bank]; BankInfo& info = myBankInfo[bank];
@ -569,7 +566,7 @@ bool CartDebug::addDirective(Device::AccessType type,
// Can we also merge with the previous range (if any)? // Can we also merge with the previous range (if any)?
if(i != list.begin()) if(i != list.begin())
{ {
DirectiveList::iterator p = i; auto p = i;
--p; --p;
if(p->type == tag.type && p->end + 1 == tag.start) if(p->type == tag.type && p->end + 1 == tag.start)
{ {
@ -632,7 +629,7 @@ bool CartDebug::addLabel(const string& label, uInt16 address)
removeLabel(label); removeLabel(label);
myUserAddresses.emplace(label, address); myUserAddresses.emplace(label, address);
myUserLabels.emplace(address, label); myUserLabels.emplace(address, label);
myLabelLength = std::max(myLabelLength, uInt16(label.size())); myLabelLength = std::max(myLabelLength, static_cast<uInt16>(label.size()));
mySystem.setDirtyPage(address); mySystem.setDirtyPage(address);
return true; return true;
} }
@ -836,7 +833,7 @@ string CartDebug::loadListFile()
getline(in, line); getline(in, line);
if(!in.good() || line == "" || line[0] == '-') if(!in.good() || line.empty() || line[0] == '-')
continue; continue;
else // Search for constants else // Search for constants
{ {
@ -1137,7 +1134,7 @@ string CartDebug::saveDisassembly(string path)
disassembleBank(bank); disassembleBank(bank);
// An empty address list means that DiStella can't do a disassembly // An empty address list means that DiStella can't do a disassembly
if(info.addressList.size() == 0) if(info.addressList.empty())
continue; continue;
buf << "\n\n;***********************************************************\n" buf << "\n\n;***********************************************************\n"
@ -1164,12 +1161,12 @@ string CartDebug::saveDisassembly(string path)
origin += static_cast<uInt32>(info.size); origin += static_cast<uInt32>(info.size);
// Format in 'distella' style // Format in 'distella' style
for(uInt32 i = 0; i < disasm.list.size(); ++i) for(const auto& dt: disasm.list)
{ {
const DisassemblyTag& tag = disasm.list[i]; const DisassemblyTag& tag = dt;
// Add label (if any) // Add label (if any)
if(tag.label != "") if(!tag.label.empty())
buf << ALIGN(4) << (tag.label) << "\n"; buf << ALIGN(4) << (tag.label) << "\n";
buf << " "; buf << " ";
@ -1381,7 +1378,7 @@ string CartDebug::saveDisassembly(string path)
} }
} }
if(myReserved.Label.size() > 0) if(!myReserved.Label.empty())
{ {
out << "\n\n;-----------------------------------------------------------\n" out << "\n\n;-----------------------------------------------------------\n"
<< "; Non Locatable Labels\n" << "; Non Locatable Labels\n"
@ -1390,14 +1387,14 @@ string CartDebug::saveDisassembly(string path)
out << ALIGN(16) << iter.second << "= $" << iter.first << "\n"; out << ALIGN(16) << iter.second << "= $" << iter.first << "\n";
} }
if(myUserLabels.size() > 0) if(!myUserLabels.empty())
{ {
out << "\n\n;-----------------------------------------------------------\n" out << "\n\n;-----------------------------------------------------------\n"
<< "; User Defined Labels\n" << "; User Defined Labels\n"
<< ";-----------------------------------------------------------\n\n"; << ";-----------------------------------------------------------\n\n";
int max_len = 16; int max_len = 16;
for(const auto& iter: myUserLabels) for(const auto& iter: myUserLabels)
max_len = std::max(max_len, int(iter.second.size())); max_len = std::max(max_len, static_cast<int>(iter.second.size()));
for(const auto& iter: myUserLabels) for(const auto& iter: myUserLabels)
out << ALIGN(max_len) << iter.second << "= $" << iter.first << "\n"; out << ALIGN(max_len) << iter.second << "= $" << iter.first << "\n";
} }
@ -1565,7 +1562,7 @@ void CartDebug::getCompletions(const char* in, StringList& completions) const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartDebug::AddrType CartDebug::addressType(uInt16 addr) const CartDebug::AddrType CartDebug::addressType(uInt16 addr)
{ {
// Determine the type of address to access the correct list // Determine the type of address to access the correct list
// These addresses were based on (and checked against) Kroko's 2600 memory // These addresses were based on (and checked against) Kroko's 2600 memory
@ -1647,7 +1644,7 @@ void CartDebug::accessTypeAsString(ostream& buf, uInt16 addr) const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Device::AccessType CartDebug::accessTypeAbsolute(Device::AccessFlags flags) const Device::AccessType CartDebug::accessTypeAbsolute(Device::AccessFlags flags)
{ {
if(flags & Device::CODE) if(flags & Device::CODE)
return Device::CODE; return Device::CODE;
@ -1674,7 +1671,7 @@ Device::AccessType CartDebug::accessTypeAbsolute(Device::AccessFlags flags) cons
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartDebug::AccessTypeAsString(ostream& buf, Device::AccessType type) const void CartDebug::AccessTypeAsString(ostream& buf, Device::AccessType type)
{ {
switch(type) switch(type)
{ {
@ -1693,7 +1690,7 @@ void CartDebug::AccessTypeAsString(ostream& buf, Device::AccessType type) const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartDebug::AccessTypeAsString(ostream& buf, Device::AccessFlags flags) const void CartDebug::AccessTypeAsString(ostream& buf, Device::AccessFlags flags)
{ {
if(flags) if(flags)
{ {

View File

@ -66,7 +66,7 @@ class CartDebug : public DebuggerSystem
// Determine 'type' of address (ie, what part of the system accessed) // Determine 'type' of address (ie, what part of the system accessed)
enum class AddrType { TIA, IO, ZPRAM, ROM }; enum class AddrType { TIA, IO, ZPRAM, ROM };
AddrType addressType(uInt16 addr) const; static AddrType addressType(uInt16 addr);
public: public:
CartDebug(Debugger& dbg, Console& console, const OSystem& osystem); CartDebug(Debugger& dbg, Console& console, const OSystem& osystem);
@ -260,13 +260,13 @@ class CartDebug : public DebuggerSystem
Methods used by the command parser for tab-completion Methods used by the command parser for tab-completion
In this case, return completions from the equate list(s) In this case, return completions from the equate list(s)
*/ */
void getCompletions(const char* in, StringList& list) const; void getCompletions(const char* in, StringList& completions) const;
// Convert given address to corresponding access type and append to buf // Convert given address to corresponding access type and append to buf
void accessTypeAsString(ostream& buf, uInt16 addr) const; void accessTypeAsString(ostream& buf, uInt16 addr) const;
// Convert access enum type to corresponding string and append to buf // Convert access enum type to corresponding string and append to buf
void AccessTypeAsString(ostream& buf, Device::AccessType type) const; static void AccessTypeAsString(ostream& buf, Device::AccessType type);
private: private:
using AddrToLineList = std::map<uInt16, int>; using AddrToLineList = std::map<uInt16, int>;
@ -330,11 +330,11 @@ class CartDebug : public DebuggerSystem
void getBankDirectives(ostream& buf, const BankInfo& info) const; void getBankDirectives(ostream& buf, const BankInfo& info) const;
// Get access enum type from 'flags', taking precendence into account // Get access enum type from 'flags', taking precendence into account
Device::AccessType accessTypeAbsolute(Device::AccessFlags flags) const; static Device::AccessType accessTypeAbsolute(Device::AccessFlags flags);
// Convert all access types in 'flags' to corresponding string and // Convert all access types in 'flags' to corresponding string and
// append to buf // append to buf
void AccessTypeAsString(ostream& buf, Device::AccessFlags flags) const; static void AccessTypeAsString(ostream& buf, Device::AccessFlags flags);
private: private:
const OSystem& myOSystem; const OSystem& myOSystem;

View File

@ -218,13 +218,13 @@ TrapArray& Debugger::writeTraps() const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string Debugger::run(const string& command) string Debugger::run(const string& command)
{ {
return myParser->run(command); return myParser->run(command);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string Debugger::invIfChanged(int reg, int oldReg) string Debugger::invIfChanged(int reg, int oldReg)
{ {
string ret; string ret;
@ -361,7 +361,7 @@ int Debugger::trace()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::setBreakPoint(uInt16 addr, uInt8 bank, uInt32 flags) bool Debugger::setBreakPoint(uInt16 addr, uInt8 bank, uInt32 flags) const
{ {
if(checkBreakPoint(addr, bank)) if(checkBreakPoint(addr, bank))
return false; return false;
@ -371,7 +371,7 @@ bool Debugger::setBreakPoint(uInt16 addr, uInt8 bank, uInt32 flags)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::clearBreakPoint(uInt16 addr, uInt8 bank) bool Debugger::clearBreakPoint(uInt16 addr, uInt8 bank) const
{ {
if(!checkBreakPoint(addr, bank)) if(!checkBreakPoint(addr, bank))
return false; return false;
@ -381,13 +381,13 @@ bool Debugger::clearBreakPoint(uInt16 addr, uInt8 bank)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::checkBreakPoint(uInt16 addr, uInt8 bank) bool Debugger::checkBreakPoint(uInt16 addr, uInt8 bank) const
{ {
return breakPoints().check(addr, bank); return breakPoints().check(addr, bank);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::toggleBreakPoint(uInt16 addr, uInt8 bank) bool Debugger::toggleBreakPoint(uInt16 addr, uInt8 bank) const
{ {
if(checkBreakPoint(addr, bank)) if(checkBreakPoint(addr, bank))
clearBreakPoint(addr, bank); clearBreakPoint(addr, bank);
@ -398,53 +398,53 @@ bool Debugger::toggleBreakPoint(uInt16 addr, uInt8 bank)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::addReadTrap(uInt16 t) void Debugger::addReadTrap(uInt16 t) const
{ {
readTraps().initialize(); readTraps().initialize();
readTraps().add(t); readTraps().add(t);
} }
void Debugger::addWriteTrap(uInt16 t) void Debugger::addWriteTrap(uInt16 t) const
{ {
writeTraps().initialize(); writeTraps().initialize();
writeTraps().add(t); writeTraps().add(t);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::addTrap(uInt16 t) void Debugger::addTrap(uInt16 t) const
{ {
addReadTrap(t); addReadTrap(t);
addWriteTrap(t); addWriteTrap(t);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::removeReadTrap(uInt16 t) void Debugger::removeReadTrap(uInt16 t) const
{ {
readTraps().initialize(); readTraps().initialize();
readTraps().remove(t); readTraps().remove(t);
} }
void Debugger::removeWriteTrap(uInt16 t) void Debugger::removeWriteTrap(uInt16 t) const
{ {
writeTraps().initialize(); writeTraps().initialize();
writeTraps().remove(t); writeTraps().remove(t);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::removeTrap(uInt16 t) void Debugger::removeTrap(uInt16 t) const
{ {
removeReadTrap(t); removeReadTrap(t);
removeWriteTrap(t); removeWriteTrap(t);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::readTrap(uInt16 t) bool Debugger::readTrap(uInt16 t) const
{ {
return readTraps().isInitialized() && readTraps().isSet(t); return readTraps().isInitialized() && readTraps().isSet(t);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::writeTrap(uInt16 t) bool Debugger::writeTrap(uInt16 t) const
{ {
return writeTraps().isInitialized() && writeTraps().isSet(t); return writeTraps().isInitialized() && writeTraps().isSet(t);
} }
@ -700,13 +700,13 @@ uInt16 Debugger::unwindStates(const uInt16 numStates, string& message)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::clearAllBreakPoints() void Debugger::clearAllBreakPoints() const
{ {
breakPoints().clear(); breakPoints().clear();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Debugger::clearAllTraps() void Debugger::clearAllTraps() const
{ {
readTraps().clearAll(); readTraps().clearAll();
writeTraps().clearAll(); writeTraps().clearAll();
@ -829,7 +829,7 @@ bool Debugger::delFunction(const string& name)
const Expression& Debugger::getFunction(const string& name) const const Expression& Debugger::getFunction(const string& name) const
{ {
const auto& iter = myFunctions.find(name); const auto& iter = myFunctions.find(name);
return iter != myFunctions.end() ? *(iter->second.get()) : EmptyExpression; return iter != myFunctions.end() ? *(iter->second) : EmptyExpression;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -840,13 +840,13 @@ const string& Debugger::getFunctionDef(const string& name) const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const Debugger::FunctionDefMap Debugger::getFunctionDefMap() const Debugger::FunctionDefMap Debugger::getFunctionDefMap() const
{ {
return myFunctionDefs; return myFunctionDefs;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Debugger::builtinHelp() const string Debugger::builtinHelp()
{ {
ostringstream buf; ostringstream buf;
size_t c_maxlen = 0, i_maxlen = 0; size_t c_maxlen = 0, i_maxlen = 0;

View File

@ -111,13 +111,13 @@ class Debugger : public DialogContainer
bool addFunction(const string& name, const string& def, bool addFunction(const string& name, const string& def,
Expression* exp, bool builtin = false); Expression* exp, bool builtin = false);
bool isBuiltinFunction(const string& name); static bool isBuiltinFunction(const string& name);
bool delFunction(const string& name); bool delFunction(const string& name);
const Expression& getFunction(const string& name) const; const Expression& getFunction(const string& name) const;
const string& getFunctionDef(const string& name) const; const string& getFunctionDef(const string& name) const;
const FunctionDefMap getFunctionDefMap() const; FunctionDefMap getFunctionDefMap() const;
string builtinHelp() const; static string builtinHelp();
/** /**
Methods used by the command parser for tab-completion Methods used by the command parser for tab-completion
@ -168,33 +168,33 @@ class Debugger : public DialogContainer
Returns true if successfully set Returns true if successfully set
*/ */
bool setBreakPoint(uInt16 addr, uInt8 bank = ANY_BANK, bool setBreakPoint(uInt16 addr, uInt8 bank = ANY_BANK,
uInt32 flags = 0); uInt32 flags = 0) const;
/** /**
Clears a breakpoint. Clears a breakpoint.
Returns true if successfully cleared Returns true if successfully cleared
*/ */
bool clearBreakPoint(uInt16 addr, uInt8 bank); bool clearBreakPoint(uInt16 addr, uInt8 bank) const;
/** /**
Toggles a breakpoint Toggles a breakpoint
Returns new state of breakpoint Returns new state of breakpoint
*/ */
bool toggleBreakPoint(uInt16 addr, uInt8 bank); bool toggleBreakPoint(uInt16 addr, uInt8 bank) const;
/** /**
Checks for a breakpoint. Checks for a breakpoint.
Returns true if existing, else false Returns true if existing, else false
*/ */
bool checkBreakPoint(uInt16 addr, uInt8 bank); bool checkBreakPoint(uInt16 addr, uInt8 bank) const;
/** /**
Run the debugger command and return the result. Run the debugger command and return the result.
*/ */
const string run(const string& command); string run(const string& command);
string autoExec(StringList* history); string autoExec(StringList* history);
@ -235,7 +235,7 @@ class Debugger : public DialogContainer
} }
/** Invert given input if it differs from its previous value */ /** Invert given input if it differs from its previous value */
const string invIfChanged(int reg, int oldReg); static string invIfChanged(int reg, int oldReg);
/** /**
This is used when we want the debugger from a class that can't This is used when we want the debugger from a class that can't
@ -261,7 +261,7 @@ class Debugger : public DialogContainer
Device::AccessFlags getAccessFlags(uInt16 addr) const; Device::AccessFlags getAccessFlags(uInt16 addr) const;
void setAccessFlags(uInt16 addr, Device::AccessFlags flags); void setAccessFlags(uInt16 addr, Device::AccessFlags flags);
uInt32 getBaseAddress(uInt32 addr, bool read); static uInt32 getBaseAddress(uInt32 addr, bool read);
bool patchROM(uInt16 addr, uInt8 value); bool patchROM(uInt16 addr, uInt8 value);
@ -315,17 +315,17 @@ class Debugger : public DialogContainer
uInt16 rewindStates(const uInt16 numStates, string& message); uInt16 rewindStates(const uInt16 numStates, string& message);
uInt16 unwindStates(const uInt16 numStates, string& message); uInt16 unwindStates(const uInt16 numStates, string& message);
void clearAllBreakPoints(); void clearAllBreakPoints() const;
void addReadTrap(uInt16 t); void addReadTrap(uInt16 t) const;
void addWriteTrap(uInt16 t); void addWriteTrap(uInt16 t) const;
void addTrap(uInt16 t); void addTrap(uInt16 t) const;
void removeReadTrap(uInt16 t); void removeReadTrap(uInt16 t) const;
void removeWriteTrap(uInt16 t); void removeWriteTrap(uInt16 t) const;
void removeTrap(uInt16 t); void removeTrap(uInt16 t) const;
bool readTrap(uInt16 t); bool readTrap(uInt16 t) const;
bool writeTrap(uInt16 t); bool writeTrap(uInt16 t) const;
void clearAllTraps(); void clearAllTraps() const;
void log(const string& triggerMsg); void log(const string& triggerMsg);
// Set a bunch of RAM locations at once // Set a bunch of RAM locations at once

View File

@ -25,9 +25,7 @@
#include "ControlLowLevel.hxx" #include "ControlLowLevel.hxx"
#include "TIADebug.hxx" #include "TIADebug.hxx"
#include "TiaOutputWidget.hxx" #include "TiaOutputWidget.hxx"
#include "DebuggerParser.hxx"
#include "YaccParser.hxx" #include "YaccParser.hxx"
#include "M6502.hxx"
#include "Expression.hxx" #include "Expression.hxx"
#include "FSNode.hxx" #include "FSNode.hxx"
#include "OSystem.hxx" #include "OSystem.hxx"
@ -148,7 +146,9 @@ string DebuggerParser::exec(const FSNode& file, StringList* history)
if(!getline(in, command)) if(!getline(in, command))
break; break;
++execDepth;
run(command); run(command);
--execDepth;
if (history != nullptr) if (history != nullptr)
history->push_back(command); history->push_back(command);
count++; count++;
@ -175,7 +175,7 @@ void DebuggerParser::outputCommandError(const string& errorMsg, int command)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// Completion-related stuff: // Completion-related stuff:
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DebuggerParser::getCompletions(const char* in, StringList& completions) const void DebuggerParser::getCompletions(const char* in, StringList& completions)
{ {
// cerr << "Attempting to complete \"" << in << "\"" << endl; // cerr << "Attempting to complete \"" << in << "\"" << endl;
for(const auto& c: commands) for(const auto& c: commands)
@ -236,7 +236,7 @@ int DebuggerParser::decipher_arg(const string& str)
} }
// Special cases (registers): // Special cases (registers):
const CpuState& state = static_cast<const CpuState&>(debugger.cpuDebug().getState()); const auto& state = static_cast<const CpuState&>(debugger.cpuDebug().getState());
int result = 0; int result = 0;
if(arg == "a" && str != "$a") result = state.A; if(arg == "a" && str != "$a") result = state.A;
else if(arg == "x") result = state.X; else if(arg == "x") result = state.X;
@ -307,7 +307,7 @@ string DebuggerParser::showWatches()
ostringstream buf; ostringstream buf;
for(uInt32 i = 0; i < myWatches.size(); ++i) for(uInt32 i = 0; i < myWatches.size(); ++i)
{ {
if(myWatches[i] != "") if(!myWatches[i].empty())
{ {
// Clear the args, since we're going to pass them to eval() // Clear the args, since we're going to pass them to eval()
argStrings.clear(); argStrings.clear();
@ -335,7 +335,7 @@ bool DebuggerParser::getArgs(const string& command, string& verb)
ParseState state = ParseState::IN_COMMAND; ParseState state = ParseState::IN_COMMAND;
size_t i = 0; size_t i = 0;
const size_t length = command.length(); const size_t length = command.length();
string curArg = ""; string curArg;
verb = ""; verb = "";
argStrings.clear(); argStrings.clear();
@ -388,14 +388,14 @@ bool DebuggerParser::getArgs(const string& command, string& verb)
while(i < length); while(i < length);
// Take care of the last argument, if there is one // Take care of the last argument, if there is one
if(curArg != "") if(!curArg.empty())
argStrings.push_back(curArg); argStrings.push_back(curArg);
argCount = static_cast<uInt32>(argStrings.size()); argCount = static_cast<uInt32>(argStrings.size());
for(uInt32 arg = 0; arg < argCount; ++arg) for(uInt32 arg = 0; arg < argCount; ++arg)
{ {
if(!YaccParser::parse(argStrings[arg].c_str())) if(!YaccParser::parse(argStrings[arg]))
{ {
unique_ptr<Expression> expr(YaccParser::getResult()); unique_ptr<Expression> expr(YaccParser::getResult());
args.push_back(expr->evaluate()); args.push_back(expr->evaluate());
@ -488,7 +488,9 @@ bool DebuggerParser::validateArgs(int cmd)
if(curArgInt != 2 && curArgInt != 10 && curArgInt != 16 if(curArgInt != 2 && curArgInt != 10 && curArgInt != 16
&& curArgStr != "hex" && curArgStr != "dec" && curArgStr != "bin") && curArgStr != "hex" && curArgStr != "dec" && curArgStr != "bin")
{ {
commandResult.str(red("invalid base (must be #2, #10, #16, \"bin\", \"dec\", or \"hex\")")); commandResult.str(red(
R"(invalid base (must be #2, #10, #16, "bin", "dec", or "hex"))"
));
return false; return false;
} }
break; break;
@ -541,8 +543,8 @@ string DebuggerParser::eval()
{ {
string rlabel = debugger.cartDebug().getLabel(args[i], true); string rlabel = debugger.cartDebug().getLabel(args[i], true);
string wlabel = debugger.cartDebug().getLabel(args[i], false); string wlabel = debugger.cartDebug().getLabel(args[i], false);
const bool validR = rlabel != "" && rlabel[0] != '$', const bool validR = !rlabel.empty() && rlabel[0] != '$',
validW = wlabel != "" && wlabel[0] != '$'; validW = !wlabel.empty() && wlabel[0] != '$';
if(validR && validW) if(validR && validW)
{ {
if(rlabel == wlabel) if(rlabel == wlabel)
@ -561,7 +563,7 @@ string DebuggerParser::eval()
if(args[i] < 0x10000) if(args[i] < 0x10000)
buf << " %" << Base::toString(args[i], Base::Fmt::_2); buf << " %" << Base::toString(args[i], Base::Fmt::_2);
buf << " #" << int(args[i]); buf << " #" << static_cast<int>(args[i]);
if(i != argCount - 1) if(i != argCount - 1)
buf << endl; buf << endl;
} }
@ -583,7 +585,7 @@ void DebuggerParser::listTraps(bool listCond)
commandResult << (listCond ? "trapifs:" : "traps:") << endl; commandResult << (listCond ? "trapifs:" : "traps:") << endl;
for(uInt32 i = 0; i < names.size(); ++i) for(uInt32 i = 0; i < names.size(); ++i)
{ {
const bool hasCond = names[i] != ""; const bool hasCond = !names[i].empty();
if(hasCond == listCond) if(hasCond == listCond)
{ {
commandResult << Base::toString(i) << ": "; commandResult << Base::toString(i) << ": ";
@ -615,23 +617,23 @@ string DebuggerParser::trapStatus(const Trap& trap)
string lblb = debugger.cartDebug().getLabel(trap.begin, !trap.write); string lblb = debugger.cartDebug().getLabel(trap.begin, !trap.write);
string lble = debugger.cartDebug().getLabel(trap.end, !trap.write); string lble = debugger.cartDebug().getLabel(trap.end, !trap.write);
if(lblb != "") { if(!lblb.empty()) {
result << " ("; result << " (";
result << lblb; result << lblb;
} }
if(trap.begin != trap.end) if(trap.begin != trap.end)
{ {
if(lble != "") if(!lble.empty())
{ {
if (lblb != "") if(!lblb.empty())
result << " "; result << " ";
else else
result << " ("; result << " (";
result << lble; result << lble;
} }
} }
if (lblb != "" || lble != "") if(!lblb.empty() || !lble.empty())
result << ")"; result << ")";
return result.str(); return result.str();
@ -643,7 +645,7 @@ string DebuggerParser::saveScriptFile(string file)
stringstream out; stringstream out;
Debugger::FunctionDefMap funcs = debugger.getFunctionDefMap(); Debugger::FunctionDefMap funcs = debugger.getFunctionDefMap();
for(const auto& [name, cmd]: funcs) for(const auto& [name, cmd]: funcs)
if (!debugger.isBuiltinFunction(name)) if (!Debugger::isBuiltinFunction(name))
out << "function " << name << " {" << cmd << "}" << endl; out << "function " << name << " {" << cmd << "}" << endl;
for(const auto& w: myWatches) for(const auto& w: myWatches)
@ -665,7 +667,7 @@ string DebuggerParser::saveScriptFile(string file)
{ {
const bool read = myTraps[i]->read, const bool read = myTraps[i]->read,
write = myTraps[i]->write, write = myTraps[i]->write,
hasCond = names[i] != ""; hasCond = !names[i].empty();
if(read && write) if(read && write)
out << "trap"; out << "trap";
@ -740,7 +742,7 @@ void DebuggerParser::executeDirective(Device::AccessType type)
const bool result = debugger.cartDebug().addDirective(type, args[0], args[1]); const bool result = debugger.cartDebug().addDirective(type, args[0], args[1]);
commandResult << (result ? "added " : "removed "); commandResult << (result ? "added " : "removed ");
debugger.cartDebug().AccessTypeAsString(commandResult, type); CartDebug::AccessTypeAsString(commandResult, type);
commandResult << " directive on range $" commandResult << " directive on range $"
<< hex << args[0] << " $" << hex << args[1]; << hex << args[0] << " $" << hex << args[1];
debugger.rom().invalidate(); debugger.rom().invalidate();
@ -754,7 +756,7 @@ void DebuggerParser::executeDirective(Device::AccessType type)
// "a" // "a"
void DebuggerParser::executeA() void DebuggerParser::executeA()
{ {
debugger.cpuDebug().setA(uInt8(args[0])); debugger.cpuDebug().setA(static_cast<uInt8>(args[0]));
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -869,7 +871,7 @@ void DebuggerParser::executeBreak()
// "breakIf" // "breakIf"
void DebuggerParser::executeBreakIf() void DebuggerParser::executeBreakIf()
{ {
int res = YaccParser::parse(argStrings[0].c_str()); int res = YaccParser::parse(argStrings[0]);
if(res == 0) if(res == 0)
{ {
string condition = argStrings[0]; string condition = argStrings[0];
@ -1269,7 +1271,7 @@ void DebuggerParser::executeDump()
DebuggerDialog* dlg = debugger.myDialog; DebuggerDialog* dlg = debugger.myDialog;
BrowserDialog::show(dlg, "Save Dump as", path.str(), BrowserDialog::show(dlg, "Save Dump as", path.str(),
BrowserDialog::Mode::FileSave, BrowserDialog::Mode::FileSave,
[this, dlg, outStr, resultStr] [dlg, outStr, resultStr]
(bool OK, const FSNode& node) (bool OK, const FSNode& node)
{ {
if(OK) if(OK)
@ -1315,9 +1317,7 @@ void DebuggerParser::executeExec()
// make sure the commands are added to prompt history // make sure the commands are added to prompt history
StringList history; StringList history;
++execDepth;
commandResult << exec(node, &history); commandResult << exec(node, &history);
--execDepth;
for(const auto& item: history) for(const auto& item: history)
debugger.prompt().addToHistory(item.c_str()); debugger.prompt().addToHistory(item.c_str());
@ -1350,7 +1350,7 @@ void DebuggerParser::executeFunction()
return; return;
} }
int res = YaccParser::parse(argStrings[1].c_str()); int res = YaccParser::parse(argStrings[1]);
if(res == 0) if(res == 0)
{ {
debugger.addFunction(argStrings[0], argStrings[1], YaccParser::getResult()); debugger.addFunction(argStrings[0], argStrings[1], YaccParser::getResult());
@ -1386,7 +1386,7 @@ void DebuggerParser::executeHelp()
commandResult << setw(static_cast<int>(clen)) << right << c.cmdString commandResult << setw(static_cast<int>(clen)) << right << c.cmdString
<< " - " << c.description << endl; << " - " << c.description << endl;
commandResult << debugger.builtinHelp(); commandResult << Debugger::builtinHelp();
} }
else // get help for specific command else // get help for specific command
{ {
@ -1565,7 +1565,7 @@ void DebuggerParser::executeListBreaks()
StringList conds = debugger.m6502().getCondBreakNames(); StringList conds = debugger.m6502().getCondBreakNames();
if(conds.size() > 0) if(!conds.empty())
{ {
if(count) if(count)
commandResult << endl; commandResult << endl;
@ -1577,7 +1577,7 @@ void DebuggerParser::executeListBreaks()
} }
} }
if(commandResult.str() == "") if(commandResult.str().empty())
commandResult << "no breakpoints set"; commandResult << "no breakpoints set";
} }
@ -1597,7 +1597,7 @@ void DebuggerParser::executeListFunctions()
{ {
const Debugger::FunctionDefMap& functions = debugger.getFunctionDefMap(); const Debugger::FunctionDefMap& functions = debugger.getFunctionDefMap();
if(functions.size() > 0) if(!functions.empty())
for(const auto& [name, cmd]: functions) for(const auto& [name, cmd]: functions)
commandResult << name << " -> " << cmd << endl; commandResult << name << " -> " << cmd << endl;
else else
@ -1611,7 +1611,7 @@ void DebuggerParser::executeListSaveStateIfs()
ostringstream buf; ostringstream buf;
StringList conds = debugger.m6502().getCondSaveStateNames(); StringList conds = debugger.m6502().getCondSaveStateNames();
if(conds.size() > 0) if(!conds.empty())
{ {
commandResult << "saveStateIf:" << endl; commandResult << "saveStateIf:" << endl;
for(uInt32 i = 0; i < conds.size(); ++i) for(uInt32 i = 0; i < conds.size(); ++i)
@ -1621,7 +1621,7 @@ void DebuggerParser::executeListSaveStateIfs()
} }
} }
if(commandResult.str() == "") if(commandResult.str().empty())
commandResult << "no savestateifs defined"; commandResult << "no savestateifs defined";
} }
@ -1637,11 +1637,11 @@ void DebuggerParser::executeListTraps()
return; return;
} }
if (names.size() > 0) if(!names.empty())
{ {
bool trapFound = false, trapifFound = false; bool trapFound = false, trapifFound = false;
for(uInt32 i = 0; i < names.size(); ++i) for(const auto& name: names)
if(names[i] == "") if(name.empty())
trapFound = true; trapFound = true;
else else
trapifFound = true; trapifFound = true;
@ -1703,7 +1703,7 @@ void DebuggerParser::executeN()
// "palette" // "palette"
void DebuggerParser::executePalette() void DebuggerParser::executePalette()
{ {
commandResult << debugger.tiaDebug().palette(); commandResult << TIADebug::palette();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -1909,7 +1909,7 @@ void DebuggerParser::executeRunToPc()
// "s" // "s"
void DebuggerParser::executeS() void DebuggerParser::executeS()
{ {
debugger.cpuDebug().setSP(uInt8(args[0])); debugger.cpuDebug().setSP(static_cast<uInt8>(args[0]));
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -2061,7 +2061,7 @@ void DebuggerParser::executeSaveSes()
// "saveSnap" // "saveSnap"
void DebuggerParser::executeSaveSnap() void DebuggerParser::executeSaveSnap()
{ {
debugger.tiaOutput().saveSnapshot(execDepth, execPrefix); debugger.tiaOutput().saveSnapshot(execDepth, execPrefix, argCount == 0);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -2085,7 +2085,7 @@ void DebuggerParser::executeSaveState()
// "saveStateIf" // "saveStateIf"
void DebuggerParser::executeSaveStateIf() void DebuggerParser::executeSaveStateIf()
{ {
int res = YaccParser::parse(argStrings[0].c_str()); int res = YaccParser::parse(argStrings[0]);
if(res == 0) if(res == 0)
{ {
string condition = argStrings[0]; string condition = argStrings[0];
@ -2128,7 +2128,7 @@ void DebuggerParser::executeStep()
// "stepWhile" // "stepWhile"
void DebuggerParser::executeStepWhile() void DebuggerParser::executeStepWhile()
{ {
int res = YaccParser::parse(argStrings[0].c_str()); int res = YaccParser::parse(argStrings[0]);
if(res != 0) { if(res != 0) {
commandResult << red("invalid expression"); commandResult << red("invalid expression");
return; return;
@ -2159,6 +2159,14 @@ void DebuggerParser::executeStepWhile()
commandResult << "executed " << ncycles << " cycles"; commandResult << "executed " << ncycles << " cycles";
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "swchb"
void DebuggerParser::executeSwchb()
{
debugger.riotDebug().switches(args[0]);
commandResult << "SWCHB set to " << std::hex << std::setw(2) << std::setfill('0') << args[0];
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "tia" // "tia"
void DebuggerParser::executeTia() void DebuggerParser::executeTia()
@ -2246,10 +2254,10 @@ void DebuggerParser::executeTraps(bool read, bool write, const string& command,
} }
// base addresses of mirrors // base addresses of mirrors
const uInt32 beginRead = debugger.getBaseAddress(begin, true); const uInt32 beginRead = Debugger::getBaseAddress(begin, true);
const uInt32 endRead = debugger.getBaseAddress(end, true); const uInt32 endRead = Debugger::getBaseAddress(end, true);
const uInt32 beginWrite = debugger.getBaseAddress(begin, false); const uInt32 beginWrite = Debugger::getBaseAddress(begin, false);
const uInt32 endWrite = debugger.getBaseAddress(end, false); const uInt32 endWrite = Debugger::getBaseAddress(end, false);
stringstream conditionBuf; stringstream conditionBuf;
// parenthesize provided and address range condition(s) (begin) // parenthesize provided and address range condition(s) (begin)
@ -2279,7 +2287,7 @@ void DebuggerParser::executeTraps(bool read, bool write, const string& command,
const string condition = conditionBuf.str(); const string condition = conditionBuf.str();
int res = YaccParser::parse(condition.c_str()); int res = YaccParser::parse(condition);
if(res == 0) if(res == 0)
{ {
// duplicates will remove each other // duplicates will remove each other
@ -2324,7 +2332,7 @@ void DebuggerParser::executeTraps(bool read, bool write, const string& command,
// wrapper function for trap(if)/trapRead(if)/trapWrite(if) commands // wrapper function for trap(if)/trapRead(if)/trapWrite(if) commands
void DebuggerParser::executeTrapRW(uInt32 addr, bool read, bool write, bool add) void DebuggerParser::executeTrapRW(uInt32 addr, bool read, bool write, bool add)
{ {
switch(debugger.cartDebug().addressType(addr)) switch(CartDebug::addressType(addr))
{ {
case CartDebug::AddrType::TIA: case CartDebug::AddrType::TIA:
{ {
@ -2480,14 +2488,14 @@ void DebuggerParser::executeWinds(bool unwind)
// "x" // "x"
void DebuggerParser::executeX() void DebuggerParser::executeX()
{ {
debugger.cpuDebug().setX(uInt8(args[0])); debugger.cpuDebug().setX(static_cast<uInt8>(args[0]));
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// "y" // "y"
void DebuggerParser::executeY() void DebuggerParser::executeY()
{ {
debugger.cpuDebug().setY(uInt8(args[0])); debugger.cpuDebug().setY(static_cast<uInt8>(args[0]));
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -3381,6 +3389,16 @@ DebuggerParser::CommandArray DebuggerParser::commands = { {
std::mem_fn(&DebuggerParser::executeStepWhile) std::mem_fn(&DebuggerParser::executeStepWhile)
}, },
{
"swchb",
"Set SWCHB to xx",
"Example: swchb fe",
true,
true,
{ Parameters::ARG_WORD, Parameters::ARG_END_ARGS },
std::mem_fn(&DebuggerParser::executeSwchb)
},
{ {
"tia", "tia",
"Show TIA state", "Show TIA state",

View File

@ -42,7 +42,7 @@ class DebuggerParser
/** Given a substring, determine matching substrings from the list /** Given a substring, determine matching substrings from the list
of available commands. Used in the debugger prompt for tab-completion */ of available commands. Used in the debugger prompt for tab-completion */
void getCompletions(const char* in, StringList& list) const; static void getCompletions(const char* in, StringList& completions);
/** Evaluate the given expression using operators, current base, etc */ /** Evaluate the given expression using operators, current base, etc */
int decipher_arg(const string& str); int decipher_arg(const string& str);
@ -65,7 +65,7 @@ class DebuggerParser
bool validateArgs(int cmd); bool validateArgs(int cmd);
string eval(); string eval();
string saveScriptFile(string file); string saveScriptFile(string file);
void saveDump(const FSNode& node, const stringstream& out, static void saveDump(const FSNode& node, const stringstream& out,
ostringstream& result); ostringstream& result);
const string& cartName() const; const string& cartName() const;
@ -101,7 +101,7 @@ class DebuggerParser
std::array<Parameters, 10> parms; std::array<Parameters, 10> parms;
std::function<void (DebuggerParser*)> executor; std::function<void (DebuggerParser*)> executor;
}; };
using CommandArray = std::array<Command, 103>; using CommandArray = std::array<Command, 104>;
static CommandArray commands; static CommandArray commands;
struct Trap struct Trap
@ -234,6 +234,7 @@ class DebuggerParser
void executeScanLine(); void executeScanLine();
void executeStep(); void executeStep();
void executeStepWhile(); void executeStepWhile();
void executeSwchb();
void executeTia(); void executeTia();
void executeTrace(); void executeTrace();
void executeTrap(); void executeTrap();

View File

@ -80,7 +80,7 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list,
// multi-byte instruction, then we make note of that address for reference // multi-byte instruction, then we make note of that address for reference
// //
// However, we only do this for labels pointing to ROM (above $1000) // However, we only do this for labels pointing to ROM (above $1000)
if (myDbg.addressType(k + myOffset) == CartDebug::AddrType::ROM) { if (CartDebug::addressType(k + myOffset) == CartDebug::AddrType::ROM) {
reservedLabel.str(""); reservedLabel.str("");
reservedLabel << "L" << Base::HEX4 << (k + myOffset); reservedLabel << "L" << Base::HEX4 << (k + myOffset);
myReserved.Label.emplace(k + myOffset, reservedLabel.str()); myReserved.Label.emplace(k + myOffset, reservedLabel.str());
@ -123,7 +123,7 @@ void DiStella::disasm(uInt32 distart, int pass)
// and this results into an access at e.g. 0xffff, // and this results into an access at e.g. 0xffff,
// we have to fix the consequences here (ugly!). // we have to fix the consequences here (ugly!).
if(myPC == myAppData.end) if(myPC == myAppData.end)
goto FIX_LAST; goto FIX_LAST; // NOLINT
if(checkBits(myPC, Device::GFX | Device::PGFX, if(checkBits(myPC, Device::GFX | Device::PGFX,
Device::CODE)) Device::CODE))
@ -944,7 +944,7 @@ DiStella::AddressType DiStella::mark(uInt32 address, uInt16 mask, bool directive
// Check for equates before ROM/ZP-RAM accesses, because the original logic // Check for equates before ROM/ZP-RAM accesses, because the original logic
// of Distella assumed either equates or ROM; it didn't take ZP-RAM into account // of Distella assumed either equates or ROM; it didn't take ZP-RAM into account
const CartDebug::AddrType type = myDbg.addressType(address); const CartDebug::AddrType type = CartDebug::addressType(address);
if(type == CartDebug::AddrType::TIA) { if(type == CartDebug::AddrType::TIA) {
return AddressType::TIA; return AddressType::TIA;
} }
@ -1003,18 +1003,18 @@ bool DiStella::checkBits(uInt16 address, uInt16 mask, uInt16 notMask, bool useDe
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool DiStella::check_range(uInt16 beg, uInt16 end) const bool DiStella::check_range(uInt16 start, uInt16 end) const
{ {
if (beg > end) { if (start > end) {
cerr << "Beginning of range greater than end: start = " << std::hex << beg cerr << "Beginning of range greater than end: start = " << std::hex << start
<< ", end = " << std::hex << end << endl; << ", end = " << std::hex << end << endl;
return false; return false;
} else if (beg > myAppData.end + myOffset) { } else if (start > myAppData.end + myOffset) {
cerr << "Beginning of range out of range: start = " << std::hex << beg cerr << "Beginning of range out of range: start = " << std::hex << start
<< ", range = " << std::hex << (myAppData.end + myOffset) << endl; << ", range = " << std::hex << (myAppData.end + myOffset) << endl;
return false; return false;
} else if (beg < myOffset) { } else if (start < myOffset) {
cerr << "Beginning of range out of range: start = " << std::hex << beg cerr << "Beginning of range out of range: start = " << std::hex << start
<< ", offset = " << std::hex << myOffset << endl; << ", offset = " << std::hex << myOffset << endl;
return false; return false;
} }
@ -1038,7 +1038,7 @@ void DiStella::addEntry(Device::AccessType type)
// Only include addresses within the requested range // Only include addresses within the requested range
if (tag.address < myAppData.start) if (tag.address < myAppData.start)
goto DONE_WITH_ADD; goto DONE_WITH_ADD; // NOLINT
// Label (a user-defined label always overrides any auto-generated one) // Label (a user-defined label always overrides any auto-generated one)
myDisasmBuf.seekg(5, std::ios::beg); myDisasmBuf.seekg(5, std::ios::beg);

View File

@ -257,6 +257,16 @@ int RiotDebug::timReadCycles() const
return mySystem.m6532().myTimReadCycles; return mySystem.m6532().myTimReadCycles;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool RiotDebug::switches(int newVal)
{
uInt8& switches = myConsole.switches().mySwitches;
if(newVal > -1)
switches = newVal;
return switches;
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool RiotDebug::diffP0(int newVal) bool RiotDebug::diffP0(int newVal)
{ {
@ -363,33 +373,33 @@ string RiotDebug::switchesString()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string RiotDebug::toString() string RiotDebug::toString()
{ {
const RiotState& state = static_cast<const RiotState&>(getState()); const auto& state = static_cast<const RiotState&>(getState());
const RiotState& oldstate = static_cast<const RiotState&>(getOldState()); const auto& oldstate = static_cast<const RiotState&>(getOldState());
ostringstream buf; ostringstream buf;
buf << "280/SWCHA(R)=" << myDebugger.invIfChanged(state.SWCHA_R, oldstate.SWCHA_R) buf << "280/SWCHA(R)=" << Debugger::invIfChanged(state.SWCHA_R, oldstate.SWCHA_R)
<< " 280/SWCHA(W)=" << myDebugger.invIfChanged(state.SWCHA_W, oldstate.SWCHA_W) << " 280/SWCHA(W)=" << Debugger::invIfChanged(state.SWCHA_W, oldstate.SWCHA_W)
<< " 281/SWACNT=" << myDebugger.invIfChanged(state.SWACNT, oldstate.SWACNT) << " 281/SWACNT=" << Debugger::invIfChanged(state.SWACNT, oldstate.SWACNT)
<< endl << endl
<< "282/SWCHB(R)=" << myDebugger.invIfChanged(state.SWCHB_R, oldstate.SWCHB_R) << "282/SWCHB(R)=" << Debugger::invIfChanged(state.SWCHB_R, oldstate.SWCHB_R)
<< " 282/SWCHB(W)=" << myDebugger.invIfChanged(state.SWCHB_W, oldstate.SWCHB_W) << " 282/SWCHB(W)=" << Debugger::invIfChanged(state.SWCHB_W, oldstate.SWCHB_W)
<< " 283/SWBCNT=" << myDebugger.invIfChanged(state.SWBCNT, oldstate.SWBCNT) << " 283/SWBCNT=" << Debugger::invIfChanged(state.SWBCNT, oldstate.SWBCNT)
<< endl << endl
// These are squirrely: some symbol files will define these as // These are squirrely: some symbol files will define these as
// 0x284-0x287. Doesn't actually matter, these registers repeat // 0x284-0x287. Doesn't actually matter, these registers repeat
// every 16 bytes. // every 16 bytes.
<< "294/TIM1T=" << myDebugger.invIfChanged(state.TIM1T, oldstate.TIM1T) << "294/TIM1T=" << Debugger::invIfChanged(state.TIM1T, oldstate.TIM1T)
<< " 295/TIM8T=" << myDebugger.invIfChanged(state.TIM8T, oldstate.TIM8T) << " 295/TIM8T=" << Debugger::invIfChanged(state.TIM8T, oldstate.TIM8T)
<< " 296/TIM64T=" << myDebugger.invIfChanged(state.TIM64T, oldstate.TIM64T) << " 296/TIM64T=" << Debugger::invIfChanged(state.TIM64T, oldstate.TIM64T)
<< " 297/T1024T=" << myDebugger.invIfChanged(state.T1024T, oldstate.T1024T) << " 297/T1024T=" << Debugger::invIfChanged(state.T1024T, oldstate.T1024T)
<< endl << endl
<< "0x284/INTIM=" << myDebugger.invIfChanged(state.INTIM, oldstate.INTIM) << "0x284/INTIM=" << Debugger::invIfChanged(state.INTIM, oldstate.INTIM)
<< " 285/TIMINT=" << myDebugger.invIfChanged(state.TIMINT, oldstate.TIMINT) << " 285/TIMINT=" << Debugger::invIfChanged(state.TIMINT, oldstate.TIMINT)
<< " Timer_Clocks=" << myDebugger.invIfChanged(state.TIMCLKS, oldstate.TIMCLKS) << " Timer_Clocks=" << Debugger::invIfChanged(state.TIMCLKS, oldstate.TIMCLKS)
<< " INTIM_Clocks=" << myDebugger.invIfChanged(state.INTIMCLKS, oldstate.INTIMCLKS) << " INTIM_Clocks=" << Debugger::invIfChanged(state.INTIMCLKS, oldstate.INTIMCLKS)
<< " Divider=" << myDebugger.invIfChanged(state.TIMDIV, oldstate.TIMDIV) << " Divider=" << Debugger::invIfChanged(state.TIMDIV, oldstate.TIMDIV)
<< endl << endl
<< "Left/P0diff: " << diffP0String() << " Right/P1diff: " << diffP1String() << "Left/P0diff: " << diffP0String() << " Right/P1diff: " << diffP1String()

View File

@ -89,6 +89,7 @@ class RiotDebug : public DebuggerSystem
int intimAsInt() const { return static_cast<int>(intim()); } // so we can use _inTim pseudo-register int intimAsInt() const { return static_cast<int>(intim()); } // so we can use _inTim pseudo-register
/* Console switches */ /* Console switches */
bool switches(int newVal = -1);
bool diffP0(int newVal = -1); bool diffP0(int newVal = -1);
bool diffP1(int newVal = -1); bool diffP1(int newVal = -1);
bool tvType(int newVal = -1); bool tvType(int newVal = -1);

View File

@ -293,7 +293,7 @@ void TIADebug::saveOldState()
bool TIADebug::vdelP0(int newVal) bool TIADebug::vdelP0(int newVal)
{ {
if(newVal > -1) if(newVal > -1)
mySystem.poke(VDELP0, bool(newVal)); mySystem.poke(VDELP0, static_cast<bool>(newVal));
return myTIA.registerValue(VDELP0) & 0x01; return myTIA.registerValue(VDELP0) & 0x01;
} }
@ -302,7 +302,7 @@ bool TIADebug::vdelP0(int newVal)
bool TIADebug::vdelP1(int newVal) bool TIADebug::vdelP1(int newVal)
{ {
if(newVal > -1) if(newVal > -1)
mySystem.poke(VDELP1, bool(newVal)); mySystem.poke(VDELP1, static_cast<bool>(newVal));
return myTIA.registerValue(VDELP1) & 0x01; return myTIA.registerValue(VDELP1) & 0x01;
} }
@ -311,7 +311,7 @@ bool TIADebug::vdelP1(int newVal)
bool TIADebug::vdelBL(int newVal) bool TIADebug::vdelBL(int newVal)
{ {
if(newVal > -1) if(newVal > -1)
mySystem.poke(VDELBL, bool(newVal)); mySystem.poke(VDELBL, static_cast<bool>(newVal));
return myTIA.registerValue(VDELBL) & 0x01; return myTIA.registerValue(VDELBL) & 0x01;
} }
@ -320,7 +320,7 @@ bool TIADebug::vdelBL(int newVal)
bool TIADebug::enaM0(int newVal) bool TIADebug::enaM0(int newVal)
{ {
if(newVal > -1) if(newVal > -1)
mySystem.poke(ENAM0, bool(newVal) << 1); mySystem.poke(ENAM0, static_cast<bool>(newVal) << 1);
return myTIA.registerValue(ENAM0) & 0x02; return myTIA.registerValue(ENAM0) & 0x02;
} }
@ -329,7 +329,7 @@ bool TIADebug::enaM0(int newVal)
bool TIADebug::enaM1(int newVal) bool TIADebug::enaM1(int newVal)
{ {
if(newVal > -1) if(newVal > -1)
mySystem.poke(ENAM1, bool(newVal) << 1); mySystem.poke(ENAM1, static_cast<bool>(newVal) << 1);
return myTIA.registerValue(ENAM1) & 0x02; return myTIA.registerValue(ENAM1) & 0x02;
} }
@ -338,7 +338,7 @@ bool TIADebug::enaM1(int newVal)
bool TIADebug::enaBL(int newVal) bool TIADebug::enaBL(int newVal)
{ {
if(newVal > -1) if(newVal > -1)
mySystem.poke(ENABL, bool(newVal) << 1); mySystem.poke(ENABL, static_cast<bool>(newVal) << 1);
return myTIA.registerValue(ENABL) & 0x02; return myTIA.registerValue(ENABL) & 0x02;
} }
@ -347,7 +347,7 @@ bool TIADebug::enaBL(int newVal)
bool TIADebug::resMP0(int newVal) bool TIADebug::resMP0(int newVal)
{ {
if(newVal > -1) if(newVal > -1)
mySystem.poke(RESMP0, bool(newVal) << 1); mySystem.poke(RESMP0, static_cast<bool>(newVal) << 1);
return myTIA.registerValue(RESMP0) & 0x02; return myTIA.registerValue(RESMP0) & 0x02;
} }
@ -356,7 +356,7 @@ bool TIADebug::resMP0(int newVal)
bool TIADebug::resMP1(int newVal) bool TIADebug::resMP1(int newVal)
{ {
if(newVal > -1) if(newVal > -1)
mySystem.poke(RESMP1, bool(newVal) << 1); mySystem.poke(RESMP1, static_cast<bool>(newVal) << 1);
return myTIA.registerValue(RESMP1) & 0x02; return myTIA.registerValue(RESMP1) & 0x02;
} }
@ -365,7 +365,7 @@ bool TIADebug::resMP1(int newVal)
bool TIADebug::refP0(int newVal) bool TIADebug::refP0(int newVal)
{ {
if(newVal > -1) if(newVal > -1)
mySystem.poke(REFP0, bool(newVal) << 3); mySystem.poke(REFP0, static_cast<bool>(newVal) << 3);
return myTIA.registerValue(REFP0) & 0x08; return myTIA.registerValue(REFP0) & 0x08;
} }
@ -374,7 +374,7 @@ bool TIADebug::refP0(int newVal)
bool TIADebug::refP1(int newVal) bool TIADebug::refP1(int newVal)
{ {
if(newVal > -1) if(newVal > -1)
mySystem.poke(REFP1, bool(newVal) << 3); mySystem.poke(REFP1, static_cast<bool>(newVal) << 3);
return myTIA.registerValue(REFP1) & 0x08; return myTIA.registerValue(REFP1) & 0x08;
} }
@ -995,7 +995,7 @@ shared_ptr<DelayQueueIterator> TIADebug::delayQueueIterator() const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string TIADebug::colorSwatch(uInt8 c) const string TIADebug::colorSwatch(uInt8 c)
{ {
string ret; string ret;
@ -1019,7 +1019,7 @@ string TIADebug::audFreq1()
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string TIADebug::audFreq(uInt8 dist, uInt8 div) string TIADebug::audFreq(uInt8 dist, uInt8 div) const
{ {
static constexpr uInt16 dist_div[16] = { static constexpr uInt16 dist_div[16] = {
1, 15, 465, 465, 2, 2, 31, 31, 1, 15, 465, 465, 2, 2, 31, 31,
@ -1037,7 +1037,7 @@ string TIADebug::audFreq(uInt8 dist, uInt8 div)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string TIADebug::stringOnly(string value, bool changed) string TIADebug::stringOnly(const string& value, bool changed)
{ {
ostringstream buf; ostringstream buf;
@ -1051,7 +1051,8 @@ string TIADebug::stringOnly(string value, bool changed)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string TIADebug::decWithLabel(string label, uInt16 value, bool changed, uInt16 width) string TIADebug::decWithLabel(const string& label, uInt16 value,
bool changed, uInt16 width)
{ {
ostringstream buf; ostringstream buf;
@ -1068,7 +1069,8 @@ string TIADebug::decWithLabel(string label, uInt16 value, bool changed, uInt16 w
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string TIADebug::hexWithLabel(string label, uInt16 value, bool changed, uInt16 width) string TIADebug::hexWithLabel(const string& label, uInt16 value,
bool changed, uInt16 width)
{ {
ostringstream buf; ostringstream buf;
@ -1085,7 +1087,7 @@ string TIADebug::hexWithLabel(string label, uInt16 value, bool changed, uInt16 w
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string TIADebug::binWithLabel(string label, uInt16 value, bool changed) string TIADebug::binWithLabel(const string& label, uInt16 value, bool changed)
{ {
ostringstream buf; ostringstream buf;
@ -1102,13 +1104,16 @@ string TIADebug::binWithLabel(string label, uInt16 value, bool changed)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string TIADebug::boolWithLabel(string label, bool value, bool changed) string TIADebug::boolWithLabel(const string& label, bool value, bool changed)
{ {
ostringstream buf; ostringstream buf;
if(value) if(value)
buf << "\177" << BSPF::toUpperCase(label) << "\177"; {
string l = label;
buf << "\177" << BSPF::toUpperCase(l) << "\177";
//return "+" + BSPF::toUpperCase(label); //return "+" + BSPF::toUpperCase(label);
}
else else
buf << label; buf << label;
//return "-" + BSPF::toLowerCase(label); //return "-" + BSPF::toLowerCase(label);
@ -1149,7 +1154,7 @@ string TIADebug::debugColors() const
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string TIADebug::palette() const string TIADebug::palette()
{ {
ostringstream buf; ostringstream buf;
@ -1174,11 +1179,11 @@ string TIADebug::toString()
// TODO: strobes? WSYNC RSYNC RESP0/1 RESM0/1 RESBL HMOVE HMCLR CXCLR // TODO: strobes? WSYNC RSYNC RESP0/1 RESM0/1 RESBL HMOVE HMCLR CXCLR
RiotDebug& riot = myDebugger.riotDebug(); RiotDebug& riot = myDebugger.riotDebug();
const RiotState& riotState = static_cast<const RiotState&>(riot.getState()); const auto& riotState = static_cast<const RiotState&>(riot.getState());
const RiotState& oldRiotState = static_cast<const RiotState&>(riot.getOldState()); const auto& oldRiotState = static_cast<const RiotState&>(riot.getOldState());
const TiaState& state = static_cast<const TiaState&>(getState()); const auto& state = static_cast<const TiaState&>(getState());
const TiaState& oldState = static_cast<const TiaState&>(getOldState()); const auto& oldState = static_cast<const TiaState&>(getOldState());
// build up output, then return it. // build up output, then return it.
buf << std::setfill(' ') << std::left buf << std::setfill(' ') << std::left

View File

@ -63,7 +63,7 @@ class TIADebug : public DebuggerSystem
void saveOldState() override; void saveOldState() override;
string toString() override; string toString() override;
string debugColors() const; string debugColors() const;
string palette() const; static string palette();
// TIA byte (or part of a byte) registers // TIA byte (or part of a byte) registers
uInt8 nusiz0(int newVal = -1); uInt8 nusiz0(int newVal = -1);
@ -185,14 +185,18 @@ class TIADebug : public DebuggerSystem
private: private:
/** Display a color patch for color at given index in the palette */ /** Display a color patch for color at given index in the palette */
string colorSwatch(uInt8 c) const; static string colorSwatch(uInt8 c);
string audFreq(uInt8 dist, uInt8 div); string audFreq(uInt8 dist, uInt8 div) const;
string stringOnly(string value, bool changed = false); static string stringOnly(const string& value, bool changed = false);
string decWithLabel(string label, uInt16 value, bool changed = false, uInt16 width = 3); static string decWithLabel(const string& label, uInt16 value,
string hexWithLabel(string label, uInt16 value, bool changed = false, uInt16 width = 2); bool changed = false, uInt16 width = 3);
string binWithLabel(string label, uInt16 value, bool changed = false); static string hexWithLabel(const string& label, uInt16 value,
string boolWithLabel(string label, bool value, bool changed = false); bool changed = false, uInt16 width = 2);
static string binWithLabel(const string& label, uInt16 value,
bool changed = false);
static string boolWithLabel(const string& label, bool value,
bool changed = false);
private: private:
TiaState myState; TiaState myState;

View File

@ -30,15 +30,13 @@ AtariVoxWidget::AtariVoxWidget(GuiObject* boss, const GUI::Font& font,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AtariVoxWidget::eraseCurrent() void AtariVoxWidget::eraseCurrent()
{ {
AtariVox& avox = static_cast<AtariVox&>(controller()); auto& avox = static_cast<AtariVox&>(controller());
avox.eraseCurrent(); avox.eraseCurrent();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool AtariVoxWidget::isPageUsed(uInt32 page) bool AtariVoxWidget::isPageUsed(uInt32 page)
{ {
const AtariVox& avox = static_cast<AtariVox&>(controller()); const auto& avox = static_cast<AtariVox&>(controller());
return avox.isPageUsed(page); return avox.isPageUsed(page);
} }

View File

@ -23,7 +23,6 @@
#include "TIADebug.hxx" #include "TIADebug.hxx"
#include "Widget.hxx" #include "Widget.hxx"
#include "Base.hxx" #include "Base.hxx"
using Common::Base;
#include "AudioWidget.hxx" #include "AudioWidget.hxx"
@ -102,8 +101,8 @@ void AudioWidget::loadConfig()
const Debugger& dbg = instance().debugger(); const Debugger& dbg = instance().debugger();
TIADebug& tia = dbg.tiaDebug(); TIADebug& tia = dbg.tiaDebug();
const TiaState& state = static_cast<const TiaState&>(tia.getState()); const auto& state = static_cast<const TiaState&>(tia.getState());
const TiaState& oldstate = static_cast<const TiaState&>(tia.getOldState()); const auto& oldstate = static_cast<const TiaState&>(tia.getOldState());
// AUDF0/1 // AUDF0/1
alist.clear(); vlist.clear(); changed.clear(); alist.clear(); vlist.clear(); changed.clear();

View File

@ -26,9 +26,7 @@ BoosterWidget::BoosterWidget(GuiObject* boss, const GUI::Font& font,
const int fontHeight = font.getFontHeight(); const int fontHeight = font.getFontHeight();
int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Booster)"); int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Booster)");
StaticTextWidget* t; auto* t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth,
t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth,
fontHeight, label, TextAlign::Left); fontHeight, label, TextAlign::Left);
xpos += t->getWidth()/2 - 5; ypos += t->getHeight() + 10; xpos += t->getWidth()/2 - 5; ypos += t->getHeight() + 10;
myPins[kJUp] = new CheckboxWidget(boss, font, xpos, ypos, "", myPins[kJUp] = new CheckboxWidget(boss, font, xpos, ypos, "",
@ -128,6 +126,3 @@ void BoosterWidget::handleCommand(
} }
} }
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
constexpr std::array<Controller::DigitalPin, 5> BoosterWidget::ourPinNo;

View File

@ -34,7 +34,7 @@ Cartridge3EPlusWidget::Cartridge3EPlusWidget(
string Cartridge3EPlusWidget::description() string Cartridge3EPlusWidget::description()
{ {
ostringstream info; ostringstream info;
size_t size; size_t size{0};
const ByteBuffer& image = myCart.getImage(size); const ByteBuffer& image = myCart.getImage(size);
const uInt16 numRomBanks = myCart.romBankCount(); const uInt16 numRomBanks = myCart.romBankCount();
const uInt16 numRamBanks = myCart.ramBankCount(); const uInt16 numRamBanks = myCart.ramBankCount();
@ -59,7 +59,7 @@ string Cartridge3EPlusWidget::description()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge3EPlusWidget::bankSelect(int& ypos) void Cartridge3EPlusWidget::bankSelect(int& ypos)
{ {
size_t size; size_t size{0};
const ByteBuffer& image = myCart.getImage(size); const ByteBuffer& image = myCart.getImage(size);
const int VGAP = myFontHeight / 4; const int VGAP = myFontHeight / 4;
VariantList banktype; VariantList banktype;
@ -118,22 +118,24 @@ void Cartridge3EPlusWidget::bankSelect(int& ypos)
const int addr1 = start + (seg * 0x400), addr2 = addr1 + 0x200; const int addr1 = start + (seg * 0x400), addr2 = addr1 + 0x200;
label.str(""); label.str("");
label << "$" << Common::Base::HEX4 << addr1 << "-$" << Common::Base::HEX4 << (addr1 + 0x1FF); label << "$" << Common::Base::HEX4 << addr1 << "-$"
StaticTextWidget* t = new StaticTextWidget(_boss, _font, xpos_s, ypos_s + 2, label.str()); << Common::Base::HEX4 << (addr1 + 0x1FF);
auto* t = new StaticTextWidget(_boss, _font, xpos_s, ypos_s + 2, label.str());
const int xoffset = t->getRight() + _font.getMaxCharWidth(); const int xoffset = t->getRight() + _font.getMaxCharWidth();
myBankState[2 * seg] = new EditTextWidget(_boss, _font, xoffset, ypos_s, const size_t bank_off = static_cast<size_t>(seg) * 2;
myBankState[bank_off] = new EditTextWidget(_boss, _font, xoffset, ypos_s,
_w - xoffset - 10, myLineHeight, ""); _w - xoffset - 10, myLineHeight, "");
myBankState[2 * seg]->setEditable(false, true); myBankState[bank_off]->setEditable(false, true);
ypos_s += myLineHeight + VGAP; ypos_s += myLineHeight + VGAP;
label.str(""); label.str("");
label << "$" << Common::Base::HEX4 << addr2 << "-$" << Common::Base::HEX4 << (addr2 + 0x1FF); label << "$" << Common::Base::HEX4 << addr2 << "-$" << Common::Base::HEX4 << (addr2 + 0x1FF);
new StaticTextWidget(_boss, _font, xpos_s, ypos_s + 2, label.str()); new StaticTextWidget(_boss, _font, xpos_s, ypos_s + 2, label.str());
myBankState[2 * seg + 1] = new EditTextWidget(_boss, _font, xoffset, ypos_s, myBankState[bank_off + 1] = new EditTextWidget(_boss, _font,
_w - xoffset - 10, myLineHeight, ""); xoffset, ypos_s, _w - xoffset - 10, myLineHeight, "");
myBankState[2 * seg + 1]->setEditable(false, true); myBankState[bank_off + 1]->setEditable(false, true);
ypos += myLineHeight + VGAP * 4; ypos += myLineHeight + VGAP * 4;
} }
@ -198,6 +200,7 @@ void Cartridge3EPlusWidget::updateUIState()
for(int seg = 0; seg < myCart3EP.myBankSegs; ++seg) for(int seg = 0; seg < myCart3EP.myBankSegs; ++seg)
{ {
const uInt16 bank = myCart.getSegmentBank(seg); const uInt16 bank = myCart.getSegmentBank(seg);
const size_t bank_off = static_cast<size_t>(seg) * 2;
ostringstream buf; ostringstream buf;
if(bank >= myCart.romBankCount()) // was RAM mapped here? if(bank >= myCart.romBankCount()) // was RAM mapped here?
@ -206,12 +209,12 @@ void Cartridge3EPlusWidget::updateUIState()
buf << "RAM @ $" << Common::Base::HEX4 buf << "RAM @ $" << Common::Base::HEX4
<< (ramBank << myCart3EP.myBankShift) << " (R)"; << (ramBank << myCart3EP.myBankShift) << " (R)";
myBankState[seg * 2]->setText(buf.str()); myBankState[bank_off]->setText(buf.str());
buf.str(""); buf.str("");
buf << "RAM @ $" << Common::Base::HEX4 buf << "RAM @ $" << Common::Base::HEX4
<< ((ramBank << myCart3EP.myBankShift) + myCart3EP.myBankSize) << " (W)"; << ((ramBank << myCart3EP.myBankShift) + myCart3EP.myBankSize) << " (W)";
myBankState[seg * 2 + 1]->setText(buf.str()); myBankState[bank_off + 1]->setText(buf.str());
myBankWidgets[seg]->setSelectedIndex(ramBank); myBankWidgets[seg]->setSelectedIndex(ramBank);
myBankType[seg]->setSelected("RAM"); myBankType[seg]->setSelected("RAM");
@ -220,12 +223,12 @@ void Cartridge3EPlusWidget::updateUIState()
{ {
buf << "ROM @ $" << Common::Base::HEX4 buf << "ROM @ $" << Common::Base::HEX4
<< ((bank << myCart3EP.myBankShift)); << ((bank << myCart3EP.myBankShift));
myBankState[seg * 2]->setText(buf.str()); myBankState[bank_off]->setText(buf.str());
buf.str(""); buf.str("");
buf << "ROM @ $" << Common::Base::HEX4 buf << "ROM @ $" << Common::Base::HEX4
<< ((bank << myCart3EP.myBankShift) + myCart3EP.myBankSize); << ((bank << myCart3EP.myBankShift) + myCart3EP.myBankSize);
myBankState[seg * 2 + 1]->setText(buf.str()); myBankState[bank_off + 1]->setText(buf.str());
myBankWidgets[seg]->setSelectedIndex(bank); myBankWidgets[seg]->setSelectedIndex(bank);
myBankType[seg]->setSelected("ROM"); myBankType[seg]->setSelected("ROM");

View File

@ -32,7 +32,7 @@ Cartridge3EWidget::Cartridge3EWidget(
string Cartridge3EWidget::description() string Cartridge3EWidget::description()
{ {
ostringstream info; ostringstream info;
size_t size; size_t size{0};
const ByteBuffer& image = myCart.getImage(size); const ByteBuffer& image = myCart.getImage(size);
const uInt16 numRomBanks = myCart.romBankCount(); const uInt16 numRomBanks = myCart.romBankCount();
const uInt16 numRamBanks = myCart.ramBankCount(); const uInt16 numRamBanks = myCart.ramBankCount();
@ -69,9 +69,9 @@ void Cartridge3EWidget::bankList(uInt16 bankCount, int seg, VariantList& items,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge3EWidget::bankSelect(int& ypos) void Cartridge3EWidget::bankSelect(int& ypos)
{ {
int xpos = 2; int xpos{2};
VariantList items; VariantList items;
int pw; int pw{0};
myBankWidgets = make_unique<PopUpWidget* []>(2); myBankWidgets = make_unique<PopUpWidget* []>(2);
@ -84,7 +84,8 @@ void Cartridge3EWidget::bankSelect(int& ypos)
myBankWidgets[0]->setID(0); myBankWidgets[0]->setID(0);
addFocusWidget(myBankWidgets[0]); addFocusWidget(myBankWidgets[0]);
StaticTextWidget* t = new StaticTextWidget(_boss, _font, myBankWidgets[0]->getRight(), ypos - 1, " (ROM)"); auto* t = new StaticTextWidget(_boss, _font,
myBankWidgets[0]->getRight(), ypos - 1, " (ROM)");
xpos = t->getRight() + 20; xpos = t->getRight() + 20;
items.clear(); items.clear();

View File

@ -68,7 +68,7 @@ void CartridgeARMWidget::addCycleWidgets(int xpos, int ypos)
myThumbCycles->setEditable(false); myThumbCycles->setEditable(false);
myThumbCycles->setToolTip("Approximated CPU cycles of last ARM run.\n"); myThumbCycles->setToolTip("Approximated CPU cycles of last ARM run.\n");
StaticTextWidget* s = new StaticTextWidget(_boss, _font, myCycleFactor->getLeft(), ypos + 1, auto* s = new StaticTextWidget(_boss, _font, myCycleFactor->getLeft(), ypos + 1,
"Instructions #"); "Instructions #");
myPrevThumbInstructions = new DataGridWidget(_boss, _font, s->getRight(), ypos - 1, myPrevThumbInstructions = new DataGridWidget(_boss, _font, s->getRight(), ypos - 1,
@ -162,23 +162,26 @@ void CartridgeARMWidget::loadConfig()
alist.clear(); vlist.clear(); changed.clear(); alist.clear(); vlist.clear(); changed.clear();
alist.push_back(0); vlist.push_back(myCart.prevCycles()); alist.push_back(0); vlist.push_back(myCart.prevCycles());
changed.push_back(myCart.prevCycles() != uInt32(myOldState.armPrevRun[0])); changed.push_back(myCart.prevCycles() !=
static_cast<uInt32>(myOldState.armPrevRun[0]));
myPrevThumbCycles->setList(alist, vlist, changed); myPrevThumbCycles->setList(alist, vlist, changed);
alist.clear(); vlist.clear(); changed.clear(); alist.clear(); vlist.clear(); changed.clear();
alist.push_back(0); vlist.push_back(myCart.prevStats().instructions); alist.push_back(0); vlist.push_back(myCart.prevStats().instructions);
changed.push_back(myCart.prevStats().instructions != uInt32(myOldState.armPrevRun[1])); changed.push_back(myCart.prevStats().instructions !=
static_cast<uInt32>(myOldState.armPrevRun[1]));
myPrevThumbInstructions->setList(alist, vlist, changed); myPrevThumbInstructions->setList(alist, vlist, changed);
alist.clear(); vlist.clear(); changed.clear(); alist.clear(); vlist.clear(); changed.clear();
alist.push_back(0); vlist.push_back(myCart.cycles()); alist.push_back(0); vlist.push_back(myCart.cycles());
changed.push_back(myCart.cycles() != uInt32(myOldState.armRun[0])); changed.push_back(myCart.cycles() !=
static_cast<uInt32>(myOldState.armRun[0]));
myThumbCycles->setList(alist, vlist, changed); myThumbCycles->setList(alist, vlist, changed);
alist.clear(); vlist.clear(); changed.clear(); alist.clear(); vlist.clear(); changed.clear();
alist.push_back(0); vlist.push_back(myCart.stats().instructions); alist.push_back(0); vlist.push_back(myCart.stats().instructions);
changed.push_back(myCart.stats().instructions != uInt32(myOldState.armRun[1])); changed.push_back(myCart.stats().instructions !=
static_cast<uInt32>(myOldState.armRun[1]));
myThumbInstructions->setList(alist, vlist, changed); myThumbInstructions->setList(alist, vlist, changed);
CartDebugWidget::loadConfig(); CartDebugWidget::loadConfig();

View File

@ -83,8 +83,8 @@ CartridgeARWidget::CartridgeARWidget(
void CartridgeARWidget::loadConfig() void CartridgeARWidget::loadConfig()
{ {
CartDebug& cart = instance().debugger().cartDebug(); CartDebug& cart = instance().debugger().cartDebug();
const CartState& state = static_cast<const CartState&>(cart.getState()); const auto& state = static_cast<const CartState&>(cart.getState());
const CartState& oldstate = static_cast<const CartState&>(cart.getOldState()); const auto& oldstate = static_cast<const CartState&>(cart.getOldState());
myBank->setSelectedIndex(myCart.getBank(), state.bank != oldstate.bank); myBank->setSelectedIndex(myCart.getBank(), state.bank != oldstate.bank);

View File

@ -99,8 +99,7 @@ CartridgeBUSWidget::CartridgeBUSWidget(
myDatastreamPointers2->setTarget(this); myDatastreamPointers2->setTarget(this);
myDatastreamPointers2->setEditable(false); myDatastreamPointers2->setEditable(false);
uInt32 row; for(uInt32 row = 0; row < 4; ++row)
for(row = 0; row < 4; ++row)
{ {
myDatastreamLabels[row] = myDatastreamLabels[row] =
new StaticTextWidget(_boss, _font, DS_X - _font.getStringWidth("xx "), new StaticTextWidget(_boss, _font, DS_X - _font.getStringWidth("xx "),
@ -369,7 +368,8 @@ void CartridgeBUSWidget::loadConfig()
for(int i = 0; i < 3; ++i) for(int i = 0; i < 3; ++i)
{ {
alist.push_back(0); vlist.push_back(myCart.myMusicCounters[i]); alist.push_back(0); vlist.push_back(myCart.myMusicCounters[i]);
changed.push_back(myCart.myMusicCounters[i] != uInt32(myOldState.mcounters[i])); changed.push_back(myCart.myMusicCounters[i] !=
static_cast<uInt32>(myOldState.mcounters[i]));
} }
myMusicCounters->setList(alist, vlist, changed); myMusicCounters->setList(alist, vlist, changed);
@ -377,7 +377,8 @@ void CartridgeBUSWidget::loadConfig()
for(int i = 0; i < 3; ++i) for(int i = 0; i < 3; ++i)
{ {
alist.push_back(0); vlist.push_back(myCart.myMusicFrequencies[i]); alist.push_back(0); vlist.push_back(myCart.myMusicFrequencies[i]);
changed.push_back(myCart.myMusicFrequencies[i] != uInt32(myOldState.mfreqs[i])); changed.push_back(myCart.myMusicFrequencies[i] !=
static_cast<uInt32>(myOldState.mfreqs[i]));
} }
myMusicFrequencies->setList(alist, vlist, changed); myMusicFrequencies->setList(alist, vlist, changed);
@ -385,7 +386,8 @@ void CartridgeBUSWidget::loadConfig()
for(int i = 0; i < 3; ++i) for(int i = 0; i < 3; ++i)
{ {
alist.push_back(0); vlist.push_back(myCart.getWaveform(i) >> 5); alist.push_back(0); vlist.push_back(myCart.getWaveform(i) >> 5);
changed.push_back((myCart.getWaveform(i) >> 5) != uInt32(myOldState.mwaves[i])); changed.push_back((myCart.getWaveform(i) >> 5) !=
static_cast<uInt32>(myOldState.mwaves[i]));
} }
myMusicWaveforms->setList(alist, vlist, changed); myMusicWaveforms->setList(alist, vlist, changed);
@ -393,7 +395,8 @@ void CartridgeBUSWidget::loadConfig()
for(int i = 0; i < 3; ++i) for(int i = 0; i < 3; ++i)
{ {
alist.push_back(0); vlist.push_back(myCart.getWaveformSize(i)); alist.push_back(0); vlist.push_back(myCart.getWaveformSize(i));
changed.push_back((myCart.getWaveformSize(i)) != uInt32(myOldState.mwavesizes[i])); changed.push_back((myCart.getWaveformSize(i)) !=
static_cast<uInt32>(myOldState.mwavesizes[i]));
} }
myMusicWaveformSizes->setList(alist, vlist, changed); myMusicWaveformSizes->setList(alist, vlist, changed);
@ -401,7 +404,8 @@ void CartridgeBUSWidget::loadConfig()
{ {
alist.clear(); vlist.clear(); changed.clear(); alist.clear(); vlist.clear(); changed.clear();
alist.push_back(0); vlist.push_back(myCart.getSample()); alist.push_back(0); vlist.push_back(myCart.getSample());
changed.push_back((myCart.getSample()) != uInt32(myOldState.samplepointer[0])); changed.push_back((myCart.getSample()) !=
static_cast<uInt32>(myOldState.samplepointer[0]));
mySamplePointer->setList(alist, vlist, changed); mySamplePointer->setList(alist, vlist, changed);
} }

View File

@ -111,8 +111,7 @@ CartridgeCDFWidget::CartridgeCDFWidget(
myJumpStreamPointers->setTarget(this); myJumpStreamPointers->setTarget(this);
myJumpStreamPointers->setEditable(false); myJumpStreamPointers->setEditable(false);
uInt32 row; for(uInt32 row = 0; row < 8; ++row)
for(row = 0; row < 8; ++row)
{ {
myDatastreamLabels[row] = myDatastreamLabels[row] =
new StaticTextWidget(_boss, _font, DS_X - _font.getStringWidth("xx "), new StaticTextWidget(_boss, _font, DS_X - _font.getStringWidth("xx "),
@ -286,7 +285,8 @@ void CartridgeCDFWidget::loadConfig()
{ {
alist.clear(); vlist.clear(); changed.clear(); alist.clear(); vlist.clear(); changed.clear();
alist.push_back(0); vlist.push_back(myCart.myRAM[myCart.myFastFetcherOffset]); alist.push_back(0); vlist.push_back(myCart.myRAM[myCart.myFastFetcherOffset]);
changed.push_back((myCart.myRAM[myCart.myFastFetcherOffset]) != uInt32(myOldState.fastfetchoffset[0])); changed.push_back((myCart.myRAM[myCart.myFastFetcherOffset]) !=
static_cast<uInt32>(myOldState.fastfetchoffset[0]));
myFastFetcherOffset->setList(alist, vlist, changed); myFastFetcherOffset->setList(alist, vlist, changed);
} }
@ -361,7 +361,8 @@ void CartridgeCDFWidget::loadConfig()
for(int i = 0; i < 3; ++i) for(int i = 0; i < 3; ++i)
{ {
alist.push_back(0); vlist.push_back(myCart.myMusicCounters[i]); alist.push_back(0); vlist.push_back(myCart.myMusicCounters[i]);
changed.push_back(myCart.myMusicCounters[i] != uInt32(myOldState.mcounters[i])); changed.push_back(myCart.myMusicCounters[i] !=
static_cast<uInt32>(myOldState.mcounters[i]));
} }
myMusicCounters->setList(alist, vlist, changed); myMusicCounters->setList(alist, vlist, changed);
@ -369,7 +370,8 @@ void CartridgeCDFWidget::loadConfig()
for(int i = 0; i < 3; ++i) for(int i = 0; i < 3; ++i)
{ {
alist.push_back(0); vlist.push_back(myCart.myMusicFrequencies[i]); alist.push_back(0); vlist.push_back(myCart.myMusicFrequencies[i]);
changed.push_back(myCart.myMusicFrequencies[i] != uInt32(myOldState.mfreqs[i])); changed.push_back(myCart.myMusicFrequencies[i] !=
static_cast<uInt32>(myOldState.mfreqs[i]));
} }
myMusicFrequencies->setList(alist, vlist, changed); myMusicFrequencies->setList(alist, vlist, changed);
@ -377,7 +379,8 @@ void CartridgeCDFWidget::loadConfig()
for(int i = 0; i < 3; ++i) for(int i = 0; i < 3; ++i)
{ {
alist.push_back(0); vlist.push_back(myCart.getWaveform(i) >> 5); alist.push_back(0); vlist.push_back(myCart.getWaveform(i) >> 5);
changed.push_back((myCart.getWaveform(i) >> 5) != uInt32(myOldState.mwaves[i])); changed.push_back((myCart.getWaveform(i) >> 5) !=
static_cast<uInt32>(myOldState.mwaves[i]));
} }
myMusicWaveforms->setList(alist, vlist, changed); myMusicWaveforms->setList(alist, vlist, changed);
@ -385,13 +388,15 @@ void CartridgeCDFWidget::loadConfig()
for(int i = 0; i < 3; ++i) for(int i = 0; i < 3; ++i)
{ {
alist.push_back(0); vlist.push_back(myCart.getWaveformSize(i)); alist.push_back(0); vlist.push_back(myCart.getWaveformSize(i));
changed.push_back((myCart.getWaveformSize(i)) != uInt32(myOldState.mwavesizes[i])); changed.push_back((myCart.getWaveformSize(i)) !=
static_cast<uInt32>(myOldState.mwavesizes[i]));
} }
myMusicWaveformSizes->setList(alist, vlist, changed); myMusicWaveformSizes->setList(alist, vlist, changed);
alist.clear(); vlist.clear(); changed.clear(); alist.clear(); vlist.clear(); changed.clear();
alist.push_back(0); vlist.push_back(myCart.getSample()); alist.push_back(0); vlist.push_back(myCart.getSample());
changed.push_back((myCart.getSample()) != uInt32(myOldState.samplepointer[0])); changed.push_back((myCart.getSample()) !=
static_cast<uInt32>(myOldState.samplepointer[0]));
mySamplePointer->setList(alist, vlist, changed); mySamplePointer->setList(alist, vlist, changed);
myFastFetch->setState((myCart.myMode & 0x0f) == 0); myFastFetch->setState((myCart.myMode & 0x0f) == 0);

View File

@ -166,7 +166,7 @@ void CartridgeCMWidget::loadConfig()
myBank->setSelectedIndex(myCart.getBank(), myCart.getBank() != myOldState.bank); myBank->setSelectedIndex(myCart.getBank(), myCart.getBank() != myOldState.bank);
RiotDebug& riot = Debugger::debugger().riotDebug(); RiotDebug& riot = Debugger::debugger().riotDebug();
const RiotState& state = static_cast<const RiotState&>(riot.getState()); const auto& state = static_cast<const RiotState&>(riot.getState());
const uInt8 swcha = myCart.mySWCHA; const uInt8 swcha = myCart.mySWCHA;

View File

@ -262,7 +262,8 @@ void CartridgeDPCPlusWidget::loadConfig()
for(int i = 0; i < 8; ++i) for(int i = 0; i < 8; ++i)
{ {
alist.push_back(0); vlist.push_back(myCart.myFractionalCounters[i]); alist.push_back(0); vlist.push_back(myCart.myFractionalCounters[i]);
changed.push_back(myCart.myFractionalCounters[i] != uInt32(myOldState.fraccounters[i])); changed.push_back(myCart.myFractionalCounters[i] !=
static_cast<uInt32>(myOldState.fraccounters[i]));
} }
myFracCounters->setList(alist, vlist, changed); myFracCounters->setList(alist, vlist, changed);
@ -286,7 +287,8 @@ void CartridgeDPCPlusWidget::loadConfig()
for(int i = 0; i < 3; ++i) for(int i = 0; i < 3; ++i)
{ {
alist.push_back(0); vlist.push_back(myCart.myMusicCounters[i]); alist.push_back(0); vlist.push_back(myCart.myMusicCounters[i]);
changed.push_back(myCart.myMusicCounters[i] != uInt32(myOldState.mcounters[i])); changed.push_back(myCart.myMusicCounters[i] !=
static_cast<uInt32>(myOldState.mcounters[i]));
} }
myMusicCounters->setList(alist, vlist, changed); myMusicCounters->setList(alist, vlist, changed);
@ -294,7 +296,8 @@ void CartridgeDPCPlusWidget::loadConfig()
for(int i = 0; i < 3; ++i) for(int i = 0; i < 3; ++i)
{ {
alist.push_back(0); vlist.push_back(myCart.myMusicFrequencies[i]); alist.push_back(0); vlist.push_back(myCart.myMusicFrequencies[i]);
changed.push_back(myCart.myMusicFrequencies[i] != uInt32(myOldState.mfreqs[i])); changed.push_back(myCart.myMusicFrequencies[i] !=
static_cast<uInt32>(myOldState.mfreqs[i]));
} }
myMusicFrequencies->setList(alist, vlist, changed); myMusicFrequencies->setList(alist, vlist, changed);

View File

@ -63,7 +63,7 @@ CartridgeE7Widget::CartridgeE7Widget(
void CartridgeE7Widget::initialize(GuiObject* boss, void CartridgeE7Widget::initialize(GuiObject* boss,
const CartridgeE7& cart, const ostringstream& info) const CartridgeE7& cart, const ostringstream& info)
{ {
const uInt32 size = cart.romBankCount() * cart.BANK_SIZE; const uInt32 size = cart.romBankCount() * CartridgeE7::BANK_SIZE;
constexpr int xpos = 2; constexpr int xpos = 2;
int ypos = addBaseInformation(size, "M Network", info.str(), 15) + myLineHeight; int ypos = addBaseInformation(size, "M Network", info.str(), 15) + myLineHeight;
@ -148,7 +148,7 @@ string CartridgeE7Widget::bankState()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeE7Widget::internalRamSize() uInt32 CartridgeE7Widget::internalRamSize()
{ {
return myCart.RAM_SIZE; return CartridgeE7::RAM_SIZE;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -52,9 +52,10 @@ class CartridgeE7Widget : public CartDebugWidget
}; };
protected: protected:
void initialize(GuiObject* boss, const CartridgeE7& cart, const ostringstream& info); void initialize(GuiObject* boss, const CartridgeE7& cart,
const ostringstream& info);
const char* getSpotLower(int idx); const char* getSpotLower(int idx);
const char* getSpotUpper(int idx); static const char* getSpotUpper(int idx);
private: private:
void saveOldState() override; void saveOldState() override;

View File

@ -49,7 +49,7 @@ int CartridgeEnhancedWidget::initialize()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
size_t CartridgeEnhancedWidget::size() size_t CartridgeEnhancedWidget::size()
{ {
size_t size; size_t size{0};
myCart.getImage(size); myCart.getImage(size);
@ -96,7 +96,7 @@ string CartridgeEnhancedWidget::ramDescription()
string CartridgeEnhancedWidget::romDescription() string CartridgeEnhancedWidget::romDescription()
{ {
ostringstream info; ostringstream info;
size_t size; size_t size{0};
const ByteBuffer& image = myCart.getImage(size); const ByteBuffer& image = myCart.getImage(size);
if(myCart.romBankCount() > 1) if(myCart.romBankCount() > 1)
@ -123,7 +123,7 @@ string CartridgeEnhancedWidget::romDescription()
else else
{ {
uInt16 start = (image[myCart.mySize - 3] << 8) | image[myCart.mySize - 4]; uInt16 start = (image[myCart.mySize - 3] << 8) | image[myCart.mySize - 4];
start -= start % std::min(int(size), 0x1000); start -= start % std::min(static_cast<int>(size), 0x1000);
const uInt16 end = start + static_cast<uInt16>(myCart.mySize) - 1; const uInt16 end = start + static_cast<uInt16>(myCart.mySize) - 1;
// special check for ROMs where the extra RAM is not included in the image (e.g. CV). // special check for ROMs where the extra RAM is not included in the image (e.g. CV).
if((start & 0xFFFU) < size) if((start & 0xFFFU) < size)
@ -328,15 +328,15 @@ void CartridgeEnhancedWidget::loadConfig()
ostringstream buf; ostringstream buf;
ByteArray arr = myCart.myPlusROM->getSend(); ByteArray arr = myCart.myPlusROM->getSend();
for(size_t i = 0; i < arr.size(); ++i) for(auto i: arr)
buf << Common::Base::HEX2 << int(arr[i]) << " "; buf << Common::Base::HEX2 << static_cast<int>(i) << " ";
myPlusROMSendWidget->setText(buf.str(), arr != myOldState.send); myPlusROMSendWidget->setText(buf.str(), arr != myOldState.send);
buf.str(""); buf.str("");
arr = myCart.myPlusROM->getReceive(); arr = myCart.myPlusROM->getReceive();
for(size_t i = 0; i < arr.size(); ++i) for(auto i: arr)
buf << Common::Base::HEX2 << int(arr[i]) << " "; buf << Common::Base::HEX2 << static_cast<int>(i) << " ";
myPlusROMReceiveWidget->setText(buf.str(), arr != myOldState.receive); myPlusROMReceiveWidget->setText(buf.str(), arr != myOldState.receive);
} }
if(myBankWidgets != nullptr) if(myBankWidgets != nullptr)
@ -384,7 +384,7 @@ uInt32 CartridgeEnhancedWidget::internalRamRPort(int start)
string CartridgeEnhancedWidget::internalRamDescription() string CartridgeEnhancedWidget::internalRamDescription()
{ {
ostringstream desc; ostringstream desc;
string indent = ""; string indent;
if(myCart.ramBankCount()) if(myCart.ramBankCount())
{ {

View File

@ -30,7 +30,7 @@ CartridgeFA2Widget::CartridgeFA2Widget(
const int bwidth = _font.getStringWidth("Erase") + 20; const int bwidth = _font.getStringWidth("Erase") + 20;
StaticTextWidget* t = new StaticTextWidget(boss, _font, xpos, ypos, auto* t = new StaticTextWidget(boss, _font, xpos, ypos,
_font.getStringWidth("Harmony flash memory "), _font.getStringWidth("Harmony flash memory "),
myFontHeight, "Harmony flash memory ", TextAlign::Left); myFontHeight, "Harmony flash memory ", TextAlign::Left);

View File

@ -65,7 +65,7 @@ CartRamWidget::CartRamWidget(
constexpr uInt16 maxlines = 6; constexpr uInt16 maxlines = 6;
const StringParser bs(desc, (fwidth - ScrollBarWidget::scrollBarWidth(_font)) / myFontWidth); const StringParser bs(desc, (fwidth - ScrollBarWidget::scrollBarWidth(_font)) / myFontWidth);
const StringList& sl = bs.stringList(); const StringList& sl = bs.stringList();
uInt32 lines = static_cast<uInt32>(sl.size()); auto lines = static_cast<uInt32>(sl.size());
bool useScrollbar = false; bool useScrollbar = false;
if(lines < 2) lines = 2; if(lines < 2) lines = 2;

View File

@ -65,7 +65,7 @@ class CartRamWidget : public Widget, public CommandSender
InternalRamWidget(GuiObject* boss, const GUI::Font& lfont, InternalRamWidget(GuiObject* boss, const GUI::Font& lfont,
const GUI::Font& nfont, const GUI::Font& nfont,
int x, int y, int w, int h, int x, int y, int w, int h,
CartDebugWidget& cartDebug); CartDebugWidget& dbg);
~InternalRamWidget() override = default; ~InternalRamWidget() override = default;
string getLabel(int addr) const override; string getLabel(int addr) const override;

View File

@ -22,8 +22,7 @@
CartridgeWDWidget::CartridgeWDWidget( CartridgeWDWidget::CartridgeWDWidget(
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, CartridgeWD& cart) int x, int y, int w, int h, CartridgeWD& cart)
: CartridgeEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart), : CartridgeEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart)
myCartWD{cart}
{ {
initialize(); initialize();
} }
@ -46,7 +45,7 @@ string CartridgeWDWidget::description()
string CartridgeWDWidget::hotspotStr(int bank, int segment, bool prefix) string CartridgeWDWidget::hotspotStr(int bank, int segment, bool prefix)
{ {
ostringstream info; ostringstream info;
const CartridgeWD::BankOrg banks = myCartWD.ourBankOrg[bank]; const CartridgeWD::BankOrg banks = CartridgeWD::ourBankOrg[bank];
info << "(" << (prefix ? "hotspot " : "") info << "(" << (prefix ? "hotspot " : "")
<< "$" << Common::Base::HEX1 << (myCart.hotspot() + bank) << ") [" << "$" << Common::Base::HEX1 << (myCart.hotspot() + bank) << ") ["

View File

@ -31,9 +31,6 @@ class CartridgeWDWidget : public CartridgeEnhancedWidget
CartridgeWD& cart); CartridgeWD& cart);
~CartridgeWDWidget() override = default; ~CartridgeWDWidget() override = default;
private:
CartridgeWD& myCartWD;
private: private:
string manufacturer() override { return "Wickstead Design"; } string manufacturer() override { return "Wickstead Design"; }

Some files were not shown because too many files have changed in this diff Show More