First pass at fixing warning from Visual Studio (const and C-style casts).

This isn't all the code, just checking in the WIP so far.
It's not exciting work like new features, etc, but is required to keep the codebase clean.
I actually find it kind of relaxing; taking a short break from new features.
This commit is contained in:
Stephen Anthony 2022-03-27 18:09:55 -02:30
parent f4401bea92
commit 6a74c61ac5
150 changed files with 1092 additions and 1077 deletions

View File

@ -29,8 +29,8 @@ BankRomCheat::BankRomCheat(OSystem& os, const string& name, const string& code)
bank = unhex(myCode.substr(0, 2)); bank = unhex(myCode.substr(0, 2));
address = 0xf000 + unhex(myCode.substr(2, 3)); address = 0xf000 + unhex(myCode.substr(2, 3));
value = uInt8(unhex(myCode.substr(5, 2))); value = static_cast<uInt8>(unhex(myCode.substr(5, 2)));
count = uInt8(unhex(myCode.substr(7, 1)) + 1); count = static_cast<uInt8>(unhex(myCode.substr(7, 1)) + 1);
// Back up original data; we need this if the cheat is ever disabled // Back up original data; we need this if the cheat is ever disabled
for(int i = 0; i < count; ++i) for(int i = 0; i < count; ++i)
@ -47,7 +47,7 @@ bool BankRomCheat::enable()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool BankRomCheat::disable() bool BankRomCheat::disable()
{ {
int oldBank = myOSystem.console().cartridge().getBank(address); const int oldBank = myOSystem.console().cartridge().getBank(address);
myOSystem.console().cartridge().bank(bank); myOSystem.console().cartridge().bank(bank);
for(int i = 0; i < count; ++i) for(int i = 0; i < count; ++i)
@ -63,7 +63,7 @@ void BankRomCheat::evaluate()
{ {
if(!myEnabled) if(!myEnabled)
{ {
int oldBank = myOSystem.console().cartridge().getBank(address); const int oldBank = myOSystem.console().cartridge().getBank(address);
myOSystem.console().cartridge().bank(bank); myOSystem.console().cartridge().bank(bank);
for(int i = 0; i < count; ++i) for(int i = 0; i < count; ++i)

View File

@ -44,7 +44,7 @@ class Cheat
static uInt16 unhex(const string& hex) static uInt16 unhex(const string& hex)
{ {
int ret = 0; int ret = 0;
for(char c: hex) for(const auto c: hex)
{ {
ret *= 16; ret *= 16;
if(c >= '0' && c <= '9') if(c >= '0' && c <= '9')

View File

@ -43,7 +43,6 @@ CheatCodeDialog::CheatCodeDialog(OSystem& osystem, DialogContainer& parent,
VGAP = Dialog::vGap(), VGAP = Dialog::vGap(),
VBORDER = Dialog::vBorder(), VBORDER = Dialog::vBorder(),
HBORDER = Dialog::hBorder(); HBORDER = Dialog::hBorder();
int xpos, ypos;
WidgetArray wid; WidgetArray wid;
ButtonWidget* b; ButtonWidget* b;
@ -52,7 +51,7 @@ CheatCodeDialog::CheatCodeDialog(OSystem& osystem, DialogContainer& parent,
_h = _th + 11 * (lineHeight + 4) + VBORDER * 2; _h = _th + 11 * (lineHeight + 4) + VBORDER * 2;
// List of cheats, with checkboxes to enable/disable // List of cheats, with checkboxes to enable/disable
xpos = HBORDER; ypos = _th + VBORDER; int xpos = HBORDER, ypos = _th + VBORDER;
myCheatList = myCheatList =
new CheckListWidget(this, font, xpos, ypos, _w - buttonWidth - HBORDER * 2 - fontWidth, new CheckListWidget(this, font, xpos, ypos, _w - buttonWidth - HBORDER * 2 - fontWidth,
_h - _th - buttonHeight - VBORDER * 3); _h - _th - buttonHeight - VBORDER * 3);
@ -136,7 +135,7 @@ void CheatCodeDialog::loadConfig()
// 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.size() > 0 ? 0 : -1);
bool enabled = (list.size() > 0); const bool enabled = (list.size() > 0);
myEditButton->setEnabled(enabled); myEditButton->setEnabled(enabled);
myRemoveButton->setEnabled(enabled); myRemoveButton->setEnabled(enabled);
} }
@ -169,7 +168,7 @@ void CheatCodeDialog::addCheat()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheatCodeDialog::editCheat() void CheatCodeDialog::editCheat()
{ {
int idx = myCheatList->getSelected(); const int idx = myCheatList->getSelected();
if(idx < 0) if(idx < 0)
return; return;
@ -249,8 +248,8 @@ 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);
bool enable = myCheatList->getSelectedState(); const bool enable = myCheatList->getSelectedState();
int idx = myCheatList->getSelected(); const int idx = myCheatList->getSelected();
if(instance().cheat().isValidCode(code)) if(instance().cheat().isValidCode(code))
{ {
myCheatInput->close(); myCheatInput->close();

View File

@ -68,7 +68,7 @@ bool CheatManager::add(const string& name, const string& code,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CheatManager::remove(int idx) void CheatManager::remove(int idx)
{ {
if(uInt32(idx) < myCheatList.size()) if(static_cast<size_t>(idx) < myCheatList.size())
{ {
// This will also remove it from the per-frame list (if applicable) // This will also remove it from the per-frame list (if applicable)
myCheatList[idx]->disable(); myCheatList[idx]->disable();
@ -186,6 +186,9 @@ void CheatManager::parse(const string& cheats)
code = s[1]; code = s[1];
add(name, code, s[2] == "1"); add(name, code, s[2] == "1");
break; break;
default:
break;
} }
s.clear(); s.clear();
@ -218,7 +221,6 @@ void CheatManager::loadCheatDatabase()
catch(...) { return; } catch(...) { return; }
string line, md5, cheat; string line, md5, cheat;
string::size_type one, two, three, four;
// Loop reading cheats // Loop reading cheats
while(getline(in, line)) while(getline(in, line))
@ -226,10 +228,10 @@ void CheatManager::loadCheatDatabase()
if(line.length() == 0) if(line.length() == 0)
continue; continue;
one = line.find('\"', 0); const string::size_type one = line.find('\"', 0);
two = line.find('\"', one + 1); const string::size_type two = line.find('\"', one + 1);
three = line.find('\"', two + 1); const string::size_type three = line.find('\"', two + 1);
four = line.find('\"', three + 1); const string::size_type four = line.find('\"', three + 1);
// Invalid line if it doesn't contain 4 quotes // Invalid line if it doesn't contain 4 quotes
if((one == string::npos) || (two == string::npos) || if((one == string::npos) || (two == string::npos) ||
@ -302,7 +304,7 @@ void CheatManager::saveCheats(const string& md5sum)
// Only update the list if absolutely necessary // Only update the list if absolutely necessary
if(changed) if(changed)
{ {
auto iter = myCheatMap.find(md5sum); const auto iter = myCheatMap.find(md5sum);
// Erase old entry and add a new one only if it's changed // Erase old entry and add a new one only if it's changed
if(iter != myCheatMap.end()) if(iter != myCheatMap.end())
@ -322,10 +324,10 @@ void CheatManager::saveCheats(const string& md5sum)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CheatManager::isValidCode(const string& code) const bool CheatManager::isValidCode(const string& code) const
{ {
for(char c: code) for(const auto c: code)
if(!isxdigit(c)) if(!isxdigit(c))
return false; return false;
uInt32 length = uInt32(code.length()); const size_t length = code.length();
return (length == 4 || length == 6 || length == 7 || length == 8); return (length == 4 || length == 6 || length == 7 || length == 8);
} }

View File

@ -23,9 +23,9 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CheetahCheat::CheetahCheat(OSystem& os, const string& name, const string& code) CheetahCheat::CheetahCheat(OSystem& os, const string& name, const string& code)
: Cheat(os, name, code), : Cheat(os, name, code),
address{uInt16(0xf000 + unhex(code.substr(0, 3)))}, address{static_cast<uInt16>(0xf000 + unhex(code.substr(0, 3)))},
value{uInt8(unhex(code.substr(3, 2)))}, value{static_cast<uInt8>(unhex(code.substr(3, 2)))},
count{uInt8(unhex(code.substr(5, 1)) + 1)} count{static_cast<uInt8>(unhex(code.substr(5, 1)) + 1)}
{ {
// Back up original data; we need this if the cheat is ever disabled // Back up original data; we need this if the cheat is ever disabled
for(int i = 0; i < count; ++i) for(int i = 0; i < count; ++i)

View File

@ -25,8 +25,8 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RamCheat::RamCheat(OSystem& os, const string& name, const string& code) RamCheat::RamCheat(OSystem& os, const string& name, const string& code)
: Cheat(os, name, code), : Cheat(os, name, code),
address{uInt16(unhex(myCode.substr(0, 2)))}, address{static_cast<uInt16>(unhex(myCode.substr(0, 2)))},
value{uInt8(unhex(myCode.substr(2, 2)))} value{static_cast<uInt8>(unhex(myCode.substr(2, 2)))}
{ {
} }

View File

@ -44,7 +44,7 @@ AudioQueue::AudioQueue(uInt32 fragmentSize, uInt32 capacity, bool isStereo)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 AudioQueue::capacity() const uInt32 AudioQueue::capacity() const
{ {
return uInt32(myFragmentQueue.size()); return static_cast<uInt32>(myFragmentQueue.size());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -72,7 +72,7 @@ Int16* AudioQueue::enqueue(Int16* fragment)
{ {
lock_guard<mutex> guard(myMutex); lock_guard<mutex> guard(myMutex);
Int16* newFragment; Int16* newFragment = nullptr;
if (!fragment) { if (!fragment) {
if (!myFirstFragmentForEnqueue) throw runtime_error("enqueue called empty"); if (!myFirstFragmentForEnqueue) throw runtime_error("enqueue called empty");
@ -83,7 +83,7 @@ Int16* AudioQueue::enqueue(Int16* fragment)
return newFragment; return newFragment;
} }
const uInt8 capacity = uInt8(myFragmentQueue.size()); const uInt8 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

@ -19,12 +19,12 @@
#include "Settings.hxx" #include "Settings.hxx"
namespace { namespace {
uInt32 lboundInt(int x, int defaultValue) constexpr uInt32 lboundInt(int x, int defaultValue)
{ {
return x <= 0 ? defaultValue : x; return x <= 0 ? defaultValue : x;
} }
AudioSettings::Preset normalizedPreset(int numericPreset) constexpr AudioSettings::Preset normalizedPreset(int numericPreset)
{ {
return ( return (
numericPreset >= static_cast<int>(AudioSettings::Preset::custom) && numericPreset >= static_cast<int>(AudioSettings::Preset::custom) &&
@ -32,7 +32,7 @@ namespace {
) ? static_cast<AudioSettings::Preset>(numericPreset) : AudioSettings::DEFAULT_PRESET; ) ? static_cast<AudioSettings::Preset>(numericPreset) : AudioSettings::DEFAULT_PRESET;
} }
AudioSettings::ResamplingQuality normalizeResamplingQuality(int numericResamplingQuality) constexpr AudioSettings::ResamplingQuality normalizeResamplingQuality(int numericResamplingQuality)
{ {
return ( return (
numericResamplingQuality >= static_cast<int>(AudioSettings::ResamplingQuality::nearestNeightbour) && numericResamplingQuality >= static_cast<int>(AudioSettings::ResamplingQuality::nearestNeightbour) &&
@ -52,7 +52,7 @@ AudioSettings::AudioSettings(Settings& settings)
void AudioSettings::normalize(Settings& settings) void AudioSettings::normalize(Settings& settings)
{ {
int settingPreset = settings.getInt(SETTING_PRESET); int settingPreset = settings.getInt(SETTING_PRESET);
Preset preset = normalizedPreset(settingPreset); const Preset preset = normalizedPreset(settingPreset);
if (static_cast<int>(preset) != settingPreset) settings.setValue(SETTING_PRESET, static_cast<int>(DEFAULT_PRESET)); if (static_cast<int>(preset) != settingPreset) settings.setValue(SETTING_PRESET, static_cast<int>(DEFAULT_PRESET));
switch (settings.getInt(SETTING_SAMPLE_RATE)) { switch (settings.getInt(SETTING_SAMPLE_RATE)) {
@ -87,7 +87,7 @@ void AudioSettings::normalize(Settings& settings)
if (settingHeadroom < 0 || settingHeadroom > MAX_HEADROOM) settings.setValue(SETTING_HEADROOM, DEFAULT_HEADROOM); if (settingHeadroom < 0 || settingHeadroom > MAX_HEADROOM) settings.setValue(SETTING_HEADROOM, DEFAULT_HEADROOM);
int settingResamplingQuality = settings.getInt(SETTING_RESAMPLING_QUALITY); int settingResamplingQuality = settings.getInt(SETTING_RESAMPLING_QUALITY);
ResamplingQuality resamplingQuality = normalizeResamplingQuality(settingResamplingQuality); const ResamplingQuality resamplingQuality = normalizeResamplingQuality(settingResamplingQuality);
if (static_cast<int>(resamplingQuality) != settingResamplingQuality) if (static_cast<int>(resamplingQuality) != settingResamplingQuality)
settings.setValue(SETTING_RESAMPLING_QUALITY, static_cast<int>(DEFAULT_RESAMPLING_QUALITY)); settings.setValue(SETTING_RESAMPLING_QUALITY, static_cast<int>(DEFAULT_RESAMPLING_QUALITY));

View File

@ -28,14 +28,14 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DevSettingsHandler::DevSettingsHandler(OSystem& osystem) DevSettingsHandler::DevSettingsHandler(OSystem& osystem)
: myOSystem(osystem) : myOSystem{osystem}
{ {
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DevSettingsHandler::loadSettings(SettingsSet set) void DevSettingsHandler::loadSettings(SettingsSet set)
{ {
bool devSettings = set == SettingsSet::developer; const bool devSettings = set == SettingsSet::developer;
const string& prefix = devSettings ? "dev." : "plr."; const string& prefix = devSettings ? "dev." : "plr.";
const Settings& settings = myOSystem.settings(); const Settings& settings = myOSystem.settings();
@ -91,7 +91,7 @@ void DevSettingsHandler::loadSettings(SettingsSet set)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DevSettingsHandler::saveSettings(SettingsSet set) void DevSettingsHandler::saveSettings(SettingsSet set)
{ {
bool devSettings = set == SettingsSet::developer; const bool devSettings = set == SettingsSet::developer;
const string& prefix = devSettings ? "dev." : "plr."; const string& prefix = devSettings ? "dev." : "plr.";
Settings& settings = myOSystem.settings(); Settings& settings = myOSystem.settings();
@ -220,7 +220,7 @@ void DevSettingsHandler::handleEnableDebugColors(bool enable)
{ {
if(myOSystem.hasConsole()) if(myOSystem.hasConsole())
{ {
bool fixed = myOSystem.console().tia().usingFixedColors(); const bool fixed = myOSystem.console().tia().usingFixedColors();
if(fixed != enable) if(fixed != enable)
myOSystem.console().tia().toggleFixedColors(); myOSystem.console().tia().toggleFixedColors();
} }

View File

@ -30,7 +30,7 @@ EventHandlerSDL2::EventHandlerSDL2(OSystem& osystem)
#ifdef GUI_SUPPORT #ifdef GUI_SUPPORT
{ {
ostringstream buf; ostringstream buf;
myQwertz = int('y') == int(SDL_GetKeyFromScancode(SDL_Scancode(KBDK_Z))); myQwertz = int{'y'} == static_cast<int>(SDL_GetKeyFromScancode(SDL_Scancode(KBDK_Z)));
buf << "Keyboard: " << (myQwertz ? "QWERTZ" : "QWERTY"); buf << "Keyboard: " << (myQwertz ? "QWERTZ" : "QWERTY");
Logger::debug(buf.str()); Logger::debug(buf.str());
} }
@ -133,6 +133,8 @@ void EventHandlerSDL2::pollEvent()
handleMouseButtonEvent(MouseButton::RIGHT, myEvent.button.type == SDL_MOUSEBUTTONDOWN, handleMouseButtonEvent(MouseButton::RIGHT, myEvent.button.type == SDL_MOUSEBUTTONDOWN,
myEvent.button.x, myEvent.button.y); myEvent.button.x, myEvent.button.y);
break; break;
default:
break;
} }
break; break;
} }
@ -166,7 +168,8 @@ void EventHandlerSDL2::pollEvent()
case SDL_JOYHATMOTION: case SDL_JOYHATMOTION:
{ {
int v = myEvent.jhat.value, value = 0; int value = 0;
const int v = myEvent.jhat.value;
if(v == SDL_HAT_CENTERED) if(v == SDL_HAT_CENTERED)
value = EVENT_HATCENTER_M; value = EVENT_HATCENTER_M;
else else
@ -240,8 +243,13 @@ void EventHandlerSDL2::pollEvent()
case SDL_WINDOWEVENT_FOCUS_LOST: case SDL_WINDOWEVENT_FOCUS_LOST:
handleSystemEvent(SystemEvent::WINDOW_FOCUS_LOST); handleSystemEvent(SystemEvent::WINDOW_FOCUS_LOST);
break; break;
default:
break;
} }
break; // SDL_WINDOWEVENT break; // SDL_WINDOWEVENT
default:
break;
} }
} }
} }

View File

@ -56,7 +56,7 @@ class EventHandlerSDL2 : public EventHandler
void pollEvent() override; void pollEvent() override;
private: private:
SDL_Event myEvent; SDL_Event myEvent{0};
// A thin wrapper around a basic PhysicalJoystick, holding the pointer to // A thin wrapper around a basic PhysicalJoystick, holding the pointer to
// the underlying SDL joystick device. // the underlying SDL joystick device.

View File

@ -91,7 +91,7 @@ void FBBackendSDL2::queryHardware(vector<Common::Size>& fullscreenRes,
fullscreenRes.emplace_back(display.w, display.h); fullscreenRes.emplace_back(display.w, display.h);
// evaluate fullscreen display modes (debug only for now) // evaluate fullscreen display modes (debug only for now)
int numModes = SDL_GetNumDisplayModes(i); const int numModes = SDL_GetNumDisplayModes(i);
ostringstream s; ostringstream s;
s << "Supported video modes (" << numModes << ") for display " << i s << "Supported video modes (" << numModes << ") for display " << i
@ -166,7 +166,7 @@ void FBBackendSDL2::queryHardware(vector<Common::Size>& fullscreenRes,
{ "software", "Software" } { "software", "Software" }
}}; }};
int numDrivers = SDL_GetNumRenderDrivers(); const int numDrivers = SDL_GetNumRenderDrivers();
for(int i = 0; i < numDrivers; ++i) for(int i = 0; i < numDrivers; ++i)
{ {
SDL_RendererInfo info; SDL_RendererInfo info;
@ -229,9 +229,9 @@ bool FBBackendSDL2::setVideoMode(const VideoModeHandler::Mode& mode,
return false; return false;
const bool fullScreen = mode.fsIndex != -1; const bool fullScreen = mode.fsIndex != -1;
Int32 displayIndex = std::min(myNumDisplays - 1, winIdx); const Int32 displayIndex = std::min(myNumDisplays - 1, winIdx);
int posX, posY; int posX = 0, posY = 0;
myCenter = myOSystem.settings().getBool("center"); myCenter = myOSystem.settings().getBool("center");
if(myCenter) if(myCenter)
@ -256,7 +256,7 @@ bool FBBackendSDL2::setVideoMode(const VideoModeHandler::Mode& mode,
y1 = std::max(y1, rect.y + rect.h); y1 = std::max(y1, rect.y + rect.h);
} }
} }
posX = BSPF::clamp(posX, x0 - Int32(mode.screenS.w) + 50, x1 - 50); posX = BSPF::clamp(posX, x0 - static_cast<Int32>(mode.screenS.w) + 50, x1 - 50);
posY = BSPF::clamp(posY, y0 + 50, y1 - 50); posY = BSPF::clamp(posY, y0 + 50, y1 - 50);
} }
@ -287,8 +287,8 @@ bool FBBackendSDL2::setVideoMode(const VideoModeHandler::Mode& mode,
int w, h; int w, h;
SDL_GetWindowSize(myWindow, &w, &h); SDL_GetWindowSize(myWindow, &w, &h);
if(d != displayIndex || uInt32(w) != mode.screenS.w || if(d != displayIndex || static_cast<uInt32>(w) != mode.screenS.w ||
uInt32(h) != mode.screenS.h || adaptRefresh) static_cast<uInt32>(h) != mode.screenS.h || adaptRefresh)
{ {
// Renderer has to be destroyed *before* the window gets destroyed to avoid memory leaks // Renderer has to be destroyed *before* the window gets destroyed to avoid memory leaks
SDL_DestroyRenderer(myRenderer); SDL_DestroyRenderer(myRenderer);
@ -617,7 +617,7 @@ bool FBBackendSDL2::detectRenderTargetSupport()
if(!tex) if(!tex)
return false; return false;
int sdlError = SDL_SetRenderTarget(myRenderer, tex); const int sdlError = SDL_SetRenderTarget(myRenderer, tex);
SDL_SetRenderTarget(myRenderer, nullptr); SDL_SetRenderTarget(myRenderer, nullptr);
SDL_DestroyTexture(tex); SDL_DestroyTexture(tex);

View File

@ -243,7 +243,7 @@ void FBSurfaceSDL2::createSurface(uInt32 width, uInt32 height,
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
// These *must* be set for the parent class // These *must* be set for the parent class
myPixels = reinterpret_cast<uInt32*>(mySurface->pixels); myPixels = static_cast<uInt32*>(mySurface->pixels);
myPitch = mySurface->pitch / pf.BytesPerPixel; myPitch = mySurface->pitch / pf.BytesPerPixel;
//////////////////////////////////////////////////// ////////////////////////////////////////////////////

View File

@ -29,7 +29,7 @@
FilesystemNodeZIP::FilesystemNodeZIP(const string& p) FilesystemNodeZIP::FilesystemNodeZIP(const string& p)
{ {
// Extract ZIP file and virtual file (if specified) // Extract ZIP file and virtual file (if specified)
size_t pos = BSPF::findIgnoreCase(p, ".zip"); const size_t pos = BSPF::findIgnoreCase(p, ".zip");
if(pos == string::npos) if(pos == string::npos)
return; return;
@ -185,7 +185,7 @@ bool FilesystemNodeZIP::getChildren(AbstractFSList& myList, ListMode mode) const
// First strip off the leading directory // First strip off the leading directory
const string& curr = next.substr(_virtualPath == "" ? 0 : _virtualPath.size()+1); const string& curr = next.substr(_virtualPath == "" ? 0 : _virtualPath.size()+1);
// Only add sub-directory entries once // Only add sub-directory entries once
auto pos = curr.find_first_of("/\\"); const auto pos = curr.find_first_of("/\\");
if(pos != string::npos) if(pos != string::npos)
dirs.emplace(curr.substr(0, pos)); dirs.emplace(curr.substr(0, pos));
else else
@ -228,7 +228,7 @@ size_t FilesystemNodeZIP::read(stringstream& image) 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 buffer;
size_t size = read(buffer, 0); const size_t size = read(buffer, 0);
if(size > 0) if(size > 0)
image.write(reinterpret_cast<char*>(buffer.get()), size); image.write(reinterpret_cast<char*>(buffer.get()), size);

View File

@ -45,7 +45,7 @@ void FpsMeter::render(uInt32 frameCount)
return; return;
} }
size_t queueSize = myQueue.capacity(); const size_t queueSize = myQueue.capacity();
entry first, last; entry first, last;
last.frames = frameCount; last.frames = frameCount;
@ -64,7 +64,7 @@ void FpsMeter::render(uInt32 frameCount)
first = myQueue.at(myQueueOffset); first = myQueue.at(myQueueOffset);
} }
float myTimeInterval = const float myTimeInterval =
duration_cast<duration<float>>(last.timestamp - first.timestamp).count(); duration_cast<duration<float>>(last.timestamp - first.timestamp).count();
if (myTimeInterval > 0) myFps = (myFrameCount - first.frames) / myTimeInterval; if (myTimeInterval > 0) myFps = (myFrameCount - first.frames) / myTimeInterval;

View File

@ -181,7 +181,7 @@ void HighScoresManager::set(Properties& props, uInt32 numVariations,
if(info.scoreInvert != DEFAULT_SCORE_REVERSED) if(info.scoreInvert != DEFAULT_SCORE_REVERSED)
jprops[SCORE_INVERTED] = info.scoreInvert; jprops[SCORE_INVERTED] = info.scoreInvert;
uInt32 addrBytes = numAddrBytes(info.numDigits, info.trailingZeroes); const uInt32 addrBytes = numAddrBytes(info.numDigits, info.trailingZeroes);
json addresses = json::array(); json addresses = json::array();
for(uInt32 a = 0; a < addrBytes; ++a) for(uInt32 a = 0; a < addrBytes; ++a)
@ -312,7 +312,7 @@ Int32 HighScoresManager::variation(uInt16 addr, bool varBCD, bool zeroBased,
if (!myOSystem.hasConsole()) if (!myOSystem.hasConsole())
return DEFAULT_VARIATION; return DEFAULT_VARIATION;
Int32 var = peek(addr); const Int32 var = peek(addr);
return convert(var, numVariations, varBCD, zeroBased); return convert(var, numVariations, varBCD, zeroBased);
} }
@ -344,11 +344,10 @@ Int32 HighScoresManager::score(uInt32 numAddrBytes, uInt32 trailingZeroes,
for (uInt32 b = 0; b < numAddrBytes; ++b) for (uInt32 b = 0; b < numAddrBytes; ++b)
{ {
uInt16 addr = scoreAddr[b]; const uInt16 addr = scoreAddr[b];
Int32 score;
totalScore *= isBCD ? 100 : 256; totalScore *= isBCD ? 100 : 256;
score = peek(addr); Int32 score = peek(addr);
if (isBCD) if (isBCD)
{ {
score = fromBCD(score); score = fromBCD(score);
@ -373,7 +372,7 @@ Int32 HighScoresManager::score() const
uInt32 numBytes = numAddrBytes(properties(jprops)); uInt32 numBytes = numAddrBytes(properties(jprops));
const ScoreAddresses scoreAddr = getPropScoreAddr(jprops); const ScoreAddresses scoreAddr = getPropScoreAddr(jprops);
if(uInt32(scoreAddr.size()) < numBytes) if(static_cast<uInt32>(scoreAddr.size()) < numBytes)
return NO_VALUE; return NO_VALUE;
return score(numBytes, trailingZeroes(jprops), scoreBCD(jprops), scoreAddr); return score(numBytes, trailingZeroes(jprops), scoreBCD(jprops), scoreAddr);
} }
@ -412,7 +411,7 @@ string HighScoresManager::md5Props() const
buf << varAddress(jprops) << numVariations() << varBCD(jprops) buf << varAddress(jprops) << numVariations() << varBCD(jprops)
<< varZeroBased(jprops); << varZeroBased(jprops);
uInt32 addrBytes = numAddrBytes(jprops); const uInt32 addrBytes = numAddrBytes(jprops);
HSM::ScoreAddresses addr = getPropScoreAddr(jprops); HSM::ScoreAddresses addr = getPropScoreAddr(jprops);
for(uInt32 a = 0; a < addrBytes; ++a) for(uInt32 a = 0; a < addrBytes; ++a)
buf << addr[a]; buf << addr[a];
@ -467,7 +466,7 @@ Int32 HighScoresManager::convert(Int32 val, uInt32 maxVal, bool isBCD, bool zero
{ {
//maxVal += zeroBased ? 0 : 1; //maxVal += zeroBased ? 0 : 1;
maxVal -= zeroBased ? 1 : 0; maxVal -= zeroBased ? 1 : 0;
Int32 bits = isBCD const Int32 bits = isBCD
? ceil(log(maxVal) / log(10) * 4) ? ceil(log(maxVal) / log(10) * 4)
: ceil(log(maxVal) / log(2)); : ceil(log(maxVal) / log(2));
@ -548,7 +547,7 @@ uInt16 HighScoresManager::fromHexStr(const string& addr) const
{ {
string naked = addr; string naked = addr;
if(int pos = naked.find("0x") != std::string::npos) if(const int pos = naked.find("0x") != std::string::npos)
naked = naked.substr(pos + 1); naked = naked.substr(pos + 1);
return stringToIntBase16(naked); return stringToIntBase16(naked);

View File

@ -50,7 +50,7 @@ namespace HSM {
using ScoreAddresses = array<Int16, MAX_SCORE_ADDR>; using ScoreAddresses = array<Int16, MAX_SCORE_ADDR>;
static const uInt32 NUM_RANKS = 10; static constexpr uInt32 NUM_RANKS = 10;
struct ScoresProps { struct ScoresProps {
// Formats // Formats

View File

@ -98,7 +98,7 @@ Event::Type JoyMap::get(const EventMode mode, const int button,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool JoyMap::check(const JoyMapping& mapping) const bool JoyMap::check(const JoyMapping& mapping) const
{ {
auto find = myMap.find(mapping); const auto find = myMap.find(mapping);
return (find != myMap.end()); return (find != myMap.end());
} }
@ -129,7 +129,7 @@ string JoyMap::getDesc(const Event::Type event, const JoyMapping& mapping) const
case JoyAxis::X: buf << "X"; break; case JoyAxis::X: buf << "X"; break;
case JoyAxis::Y: buf << "Y"; break; case JoyAxis::Y: buf << "Y"; break;
case JoyAxis::Z: buf << "Z"; break; case JoyAxis::Z: buf << "Z"; break;
default: buf << int(mapping.axis); break; default: buf << static_cast<int>(mapping.axis); break;
} }
if(Event::isAnalog(event)) if(Event::isAnalog(event))
@ -290,7 +290,7 @@ json JoyMap::convertLegacyMapping(string list)
std::replace(list.begin(), list.end(), ',', ' '); std::replace(list.begin(), list.end(), ',', ' ');
istringstream buf(list); istringstream buf(list);
int event, button, axis, adir, hat, hdir; int event = 0, button = 0, axis = 0, adir = 0, hat = 0, hdir = 0;
while(buf >> event && buf >> button while(buf >> event && buf >> button
&& buf >> axis && buf >> adir && buf >> axis && buf >> adir
@ -302,7 +302,7 @@ json JoyMap::convertLegacyMapping(string list)
if(button != JOY_CTRL_NONE) eventMapping["button"] = button; if(button != JOY_CTRL_NONE) eventMapping["button"] = button;
if(JoyAxis(axis) != JoyAxis::NONE) { if(static_cast<JoyAxis>(axis) != JoyAxis::NONE) {
eventMapping["axis"] = JoyAxis(axis); eventMapping["axis"] = JoyAxis(axis);
eventMapping["axisDirection"] = JoyDir(adir); eventMapping["axisDirection"] = JoyDir(adir);
} }
@ -323,7 +323,7 @@ void JoyMap::eraseMode(const EventMode mode)
{ {
for(auto item = myMap.begin(); item != myMap.end();) for(auto item = myMap.begin(); item != myMap.end();)
if(item->first.mode == mode) { if(item->first.mode == mode) {
auto _item = item++; const auto _item = item++;
erase(_item->first); erase(_item->first);
} }
else item++; else item++;
@ -334,7 +334,7 @@ void JoyMap::eraseEvent(const Event::Type event, const EventMode mode)
{ {
for(auto item = myMap.begin(); item != myMap.end();) for(auto item = myMap.begin(); item != myMap.end();)
if(item->second == event && item->first.mode == mode) { if(item->second == event && item->first.mode == mode) {
auto _item = item++; const auto _item = item++;
erase(_item->first); erase(_item->first);
} }
else item++; else item++;

View File

@ -99,15 +99,15 @@ Event::Type KeyMap::get(const Mapping& mapping) const
if(myModEnabled) if(myModEnabled)
{ {
auto find = myMap.find(m); const auto find = myMap.find(m);
if(find != myMap.end()) if(find != myMap.end())
return find->second; return find->second;
} }
// mapping not found, try without modifiers // mapping not found, try without modifiers
m.mod = StellaMod(0); m.mod = static_cast<StellaMod>(0);
auto find = myMap.find(m); const auto find = myMap.find(m);
if(find != myMap.end()) if(find != myMap.end())
return find->second; return find->second;
@ -123,7 +123,7 @@ Event::Type KeyMap::get(const EventMode mode, const int key, const int mod) cons
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool KeyMap::check(const Mapping& mapping) const bool KeyMap::check(const Mapping& mapping) const
{ {
auto find = myMap.find(convertMod(mapping)); const auto find = myMap.find(convertMod(mapping));
return (find != myMap.end()); return (find != myMap.end());
} }
@ -139,23 +139,23 @@ string KeyMap::getDesc(const Mapping& mapping) const
{ {
ostringstream buf; ostringstream buf;
#if defined(BSPF_MACOS) || defined(MACOS_KEYS) #if defined(BSPF_MACOS) || defined(MACOS_KEYS)
string mod2 = "Option"; const string mod2 = "Option";
int MOD2 = KBDM_ALT; constexpr int MOD2 = KBDM_ALT;
int LMOD2 = KBDM_LALT; constexpr int LMOD2 = KBDM_LALT;
int RMOD2 = KBDM_RALT; constexpr int RMOD2 = KBDM_RALT;
string mod3 = "Cmd"; const string mod3 = "Cmd";
int MOD3 = KBDM_GUI; constexpr int MOD3 = KBDM_GUI;
int LMOD3 = KBDM_LGUI; constexpr int LMOD3 = KBDM_LGUI;
int RMOD3 = KBDM_RGUI; constexpr int RMOD3 = KBDM_RGUI;
#else #else
string mod2 = "Windows"; const string mod2 = "Windows";
int MOD2 = KBDM_GUI; constexpr int MOD2 = KBDM_GUI;
int LMOD2 = KBDM_LGUI; constexpr int LMOD2 = KBDM_LGUI;
int RMOD2 = KBDM_RGUI; constexpr int RMOD2 = KBDM_RGUI;
string mod3 = "Alt"; const string mod3 = "Alt";
int MOD3 = KBDM_ALT; constexpr int MOD3 = KBDM_ALT;
int LMOD3 = KBDM_LALT; constexpr int LMOD3 = KBDM_LALT;
int RMOD3 = KBDM_RALT; constexpr int RMOD3 = KBDM_RALT;
#endif #endif
if((mapping.mod & KBDM_CTRL) == KBDM_CTRL) buf << "Ctrl"; if((mapping.mod & KBDM_CTRL) == KBDM_CTRL) buf << "Ctrl";
@ -295,7 +295,7 @@ json KeyMap::convertLegacyMapping(string list)
std::replace(list.begin(), list.end(), ':', ' '); std::replace(list.begin(), list.end(), ':', ' ');
std::replace(list.begin(), list.end(), ',', ' '); std::replace(list.begin(), list.end(), ',', ' ');
istringstream buf(list); istringstream buf(list);
int event, key, mod; int event = 0, key = 0, mod = 0;
while(buf >> event && buf >> key && buf >> mod) while(buf >> event && buf >> key && buf >> mod)
{ {
@ -318,7 +318,7 @@ void KeyMap::eraseMode(const EventMode mode)
{ {
for(auto item = myMap.begin(); item != myMap.end();) for(auto item = myMap.begin(); item != myMap.end();)
if(item->first.mode == mode) { if(item->first.mode == mode) {
auto _item = item++; const auto _item = item++;
erase(_item->first); erase(_item->first);
} }
else item++; else item++;
@ -329,7 +329,7 @@ void KeyMap::eraseEvent(const Event::Type event, const EventMode mode)
{ {
for(auto item = myMap.begin(); item != myMap.end();) for(auto item = myMap.begin(); item != myMap.end();)
if(item->second == event && item->first.mode == mode) { if(item->second == event && item->first.mode == mode) {
auto _item = item++; const auto _item = item++;
erase(_item->first); erase(_item->first);
} }
else item++; else item++;
@ -346,7 +346,7 @@ KeyMap::Mapping KeyMap::convertMod(const Mapping& mapping) const
else else
{ {
// limit to modifiers we want to support // limit to modifiers we want to support
m.mod = StellaMod(m.mod & (KBDM_SHIFT | KBDM_CTRL | KBDM_ALT | KBDM_GUI)); m.mod = static_cast<StellaMod>(m.mod & (KBDM_SHIFT | KBDM_CTRL | KBDM_ALT | KBDM_GUI));
} }
return m; return m;

View File

@ -41,7 +41,7 @@ class KeyMap
explicit Mapping(EventMode c_mode, StellaKey c_key, StellaMod c_mod) explicit Mapping(EventMode c_mode, StellaKey c_key, StellaMod c_mod)
: mode{c_mode}, key{c_key}, mod{c_mod} { } : mode{c_mode}, key{c_key}, mod{c_mod} { }
explicit Mapping(EventMode c_mode, int c_key, int c_mod) explicit Mapping(EventMode c_mode, int c_key, int c_mod)
: mode{c_mode}, key{StellaKey(c_key)}, mod{StellaMod(c_mod)} { } : mode{c_mode}, key{static_cast<StellaKey>(c_key)}, mod{static_cast<StellaMod>(c_mod)} { }
Mapping(const Mapping&) = default; Mapping(const Mapping&) = default;
Mapping& operator=(const Mapping&) = default; Mapping& operator=(const Mapping&) = default;
Mapping(Mapping&&) = default; Mapping(Mapping&&) = default;

View File

@ -256,9 +256,9 @@ class LinkedObjectPool
uInt32 capacity() const { return myCapacity; } uInt32 capacity() const { return myCapacity; }
uInt32 size() const { return uInt32(myList.size()); } uInt32 size() const { return static_cast<uInt32>(myList.size()); }
bool empty() const { return size() == 0; } bool empty() const { return size() == 0; }
bool full() const { return size() >= capacity(); } bool full() const { return size() >= capacity(); }
friend ostream& operator<<(ostream& os, const LinkedObjectPool<T>& p) { friend ostream& operator<<(ostream& os, const LinkedObjectPool<T>& p) {
for(const auto& i: p.myList) for(const auto& i: p.myList)

View File

@ -41,14 +41,14 @@ 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')
{ {
MouseControl::Type xaxis = MouseControl::Type(int(m_mode[0]) - '0'); const MouseControl::Type xaxis = static_cast<MouseControl::Type>(static_cast<int>(m_mode[0]) - '0');
MouseControl::Type yaxis = MouseControl::Type(int(m_mode[1]) - '0'); const MouseControl::Type 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;
auto MControlToController = [&msg](MouseControl::Type axis, const auto MControlToController = [&msg](MouseControl::Type axis,
Controller::Type& type, int& id) { Controller::Type& type, int& id) {
switch(axis) switch(axis)
{ {
case MouseControl::Type::NoControl: case MouseControl::Type::NoControl:
@ -107,7 +107,7 @@ MouseControl::MouseControl(Console& console, const string& mode)
// Now consider the possible modes for the mouse based on the left // Now consider the possible modes for the mouse based on the left
// and right controllers // and right controllers
bool noswap = BSPF::equalsIgnoreCase(myProps.get(PropType::Console_SwapPorts), "NO"); const bool noswap = BSPF::equalsIgnoreCase(myProps.get(PropType::Console_SwapPorts), "NO");
if(noswap) if(noswap)
{ {
addLeftControllerModes(noswap); addLeftControllerModes(noswap);
@ -139,12 +139,13 @@ MouseControl::MouseControl(Console& console, const string& mode)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string& MouseControl::change(int direction) const string& MouseControl::change(int direction)
{ {
myCurrentModeNum = BSPF::clampw(myCurrentModeNum + direction, 0, int(myModeList.size() - 1)); myCurrentModeNum = BSPF::clampw(myCurrentModeNum + direction, 0,
static_cast<int>(myModeList.size() - 1));
const MouseMode& mode = myModeList[myCurrentModeNum]; const MouseMode& mode = myModeList[myCurrentModeNum];
bool leftControl = const bool leftControl =
myLeftController.setMouseControl(mode.xtype, mode.xid, mode.ytype, mode.yid); myLeftController.setMouseControl(mode.xtype, mode.xid, mode.ytype, mode.yid);
bool rightControl = const bool rightControl =
myRightController.setMouseControl(mode.xtype, mode.xid, mode.ytype, mode.yid); myRightController.setMouseControl(mode.xtype, mode.xid, mode.ytype, mode.yid);
myHasMouseControl = leftControl || rightControl; myHasMouseControl = leftControl || rightControl;
@ -197,14 +198,14 @@ void MouseControl::addRightControllerModes(bool noswap)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void MouseControl::addPaddleModes(int lport, int rport, int lname, int rname) void MouseControl::addPaddleModes(int lport, int rport, int lname, int rname)
{ {
Controller::Type type = Controller::Type::Paddles; const Controller::Type type = Controller::Type::Paddles;
ostringstream msg; ostringstream msg;
msg << "Mouse is Paddle " << lname << " controller"; msg << "Mouse is Paddle " << lname << " controller";
MouseMode mode0(type, lport, type, lport, msg.str()); const MouseMode mode0(type, lport, type, lport, msg.str());
msg.str(""); msg.str("");
msg << "Mouse is Paddle " << rname << " controller"; msg << "Mouse is Paddle " << rname << " controller";
MouseMode mode1(type, rport, type, rport, msg.str()); const MouseMode mode1(type, rport, type, rport, msg.str());
if(BSPF::equalsIgnoreCase(myProps.get(PropType::Controller_SwapPaddles), "NO")) if(BSPF::equalsIgnoreCase(myProps.get(PropType::Controller_SwapPaddles), "NO"))
{ {

View File

@ -85,20 +85,16 @@ class MouseControl
int xid{-1}, yid{-1}; int xid{-1}, yid{-1};
string message; string message;
explicit MouseMode(const string& msg = "") : message(msg) { } explicit MouseMode(const string& msg = "") : message{msg} { }
MouseMode(Controller::Type xt, int xi, MouseMode(Controller::Type xt, int xi,
Controller::Type yt, int yi, Controller::Type yt, int yi,
const string& msg) const string& msg)
: xtype(xt), : xtype{xt}, ytype{yt}, xid{xi}, yid{yi}, message{msg} { }
ytype(yt),
xid(xi),
yid(yi),
message(msg) { }
friend ostream& operator<<(ostream& os, const MouseMode& mm) friend ostream& operator<<(ostream& os, const MouseMode& mm)
{ {
os << "xtype=" << int(mm.xtype) << ", xid=" << mm.xid os << "xtype=" << static_cast<int>(mm.xtype) << ", xid=" << mm.xid
<< ", ytype=" << int(mm.ytype) << ", yid=" << mm.yid << ", ytype=" << static_cast<int>(mm.ytype) << ", yid=" << mm.yid
<< ", msg=" << mm.message; << ", msg=" << mm.message;
return os; return os;
} }

View File

@ -138,7 +138,7 @@ int PhysicalJoystickHandler::add(const PhysicalJoystickPtr& stick)
if(erased) if(erased)
// We have to add all Stelladaptors again, because they have changed // We have to add all Stelladaptors again, because they have changed
// name due to being reordered when mapping them // name due to being reordered when mapping them
for(auto& [_id, _stick] : mySticks) for(const auto& [_id, _stick] : mySticks)
{ {
if(_stick->name.find(" (emulates ") != std::string::npos) if(_stick->name.find(" (emulates ") != std::string::npos)
addToDatabase(_stick); addToDatabase(_stick);
@ -162,7 +162,7 @@ int PhysicalJoystickHandler::add(const PhysicalJoystickPtr& stick)
void PhysicalJoystickHandler::addToDatabase(const PhysicalJoystickPtr& stick) void PhysicalJoystickHandler::addToDatabase(const PhysicalJoystickPtr& stick)
{ {
// Add stick to database // Add stick to database
auto it = myDatabase.find(stick->name); const auto it = myDatabase.find(stick->name);
if(it != myDatabase.end()) // already present if(it != myDatabase.end()) // already present
{ {
it->second.joy = stick; it->second.joy = stick;
@ -195,7 +195,7 @@ bool PhysicalJoystickHandler::remove(int id)
{ {
PhysicalJoystickPtr stick = mySticks.at(id); PhysicalJoystickPtr stick = mySticks.at(id);
auto it = myDatabase.find(stick->name); const auto it = myDatabase.find(stick->name);
if(it != myDatabase.end() && it->second.joy == stick) if(it != myDatabase.end() && it->second.joy == stick)
{ {
ostringstream buf; ostringstream buf;
@ -222,7 +222,7 @@ bool PhysicalJoystickHandler::remove(int id)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool PhysicalJoystickHandler::remove(const string& name) bool PhysicalJoystickHandler::remove(const string& name)
{ {
auto it = myDatabase.find(name); const auto it = myDatabase.find(name);
if(it != myDatabase.end() && it->second.joy == nullptr) if(it != myDatabase.end() && it->second.joy == nullptr)
{ {
myDatabase.erase(it); myDatabase.erase(it);
@ -248,10 +248,10 @@ bool PhysicalJoystickHandler::mapStelladaptors(const string& saport, int ID)
saOrder[0] = 2; saOrder[1] = 1; saOrder[0] = 2; saOrder[1] = 1;
} }
for(auto& [_id, _stick]: mySticks) for(const auto& [_id, _stick]: mySticks)
{ {
bool found = false; bool found = false;
size_t pos = _stick->name.find(" (emulates "); const size_t pos = _stick->name.find(" (emulates ");
if(pos != std::string::npos && ID != -1 && ID < _stick->ID) if(pos != std::string::npos && ID != -1 && ID < _stick->ID)
{ {
@ -303,7 +303,7 @@ bool PhysicalJoystickHandler::hasStelladaptors() const
for(auto& [_id, _joyptr] : mySticks) for(auto& [_id, _joyptr] : mySticks)
{ {
// remove previously added emulated ports // remove previously added emulated ports
size_t pos = _joyptr->name.find(" (emulates "); const size_t pos = _joyptr->name.find(" (emulates ");
if(pos != std::string::npos) if(pos != std::string::npos)
_joyptr->name.erase(pos); _joyptr->name.erase(pos);
@ -328,7 +328,7 @@ void PhysicalJoystickHandler::setDefaultAction(int stick,
// If event is 'NoType', erase and reset all mappings // If event is 'NoType', erase and reset all mappings
// Otherwise, only reset the given event // Otherwise, only reset the given event
bool eraseAll = !updateDefaults && (event == Event::NoType); const bool eraseAll = !updateDefaults && (event == Event::NoType);
if(updateDefaults) if(updateDefaults)
{ {
@ -395,9 +395,9 @@ void PhysicalJoystickHandler::setStickDefaultMapping(int stick, Event::Type even
} }
#if defined(RETRON77) #if defined(RETRON77)
const bool retron77 = true; constexpr bool retron77 = true;
#else #else
const bool retron77 = false; constexpr bool retron77 = false;
#endif #endif
// Regular joysticks can only be used by one player at a time, // Regular joysticks can only be used by one player at a time,
@ -588,7 +588,7 @@ void PhysicalJoystickHandler::enableCommonMappings()
{ {
for (int i = Event::NoType + 1; i < Event::LastType; i++) for (int i = Event::NoType + 1; i < Event::LastType; i++)
{ {
Event::Type event = static_cast<Event::Type>(i); const Event::Type event = static_cast<Event::Type>(i);
if(isCommonEvent(event)) if(isCommonEvent(event))
enableMapping(event, EventMode::kCommonMode); enableMapping(event, EventMode::kCommonMode);
@ -683,7 +683,7 @@ void PhysicalJoystickHandler::eraseMapping(Event::Type event, EventMode mode)
// Otherwise, only reset the given event // Otherwise, only reset the given event
if(event == Event::NoType) if(event == Event::NoType)
{ {
for (auto& [_id, _joyptr]: mySticks) for (const auto& [_id, _joyptr]: mySticks)
{ {
_joyptr->eraseMap(mode); // erase all events _joyptr->eraseMap(mode); // erase all events
if(mode == EventMode::kEmulationMode) if(mode == EventMode::kEmulationMode)
@ -698,7 +698,7 @@ void PhysicalJoystickHandler::eraseMapping(Event::Type event, EventMode mode)
} }
else else
{ {
for (auto& [_id, _joyptr]: mySticks) for (const auto& [_id, _joyptr]: mySticks)
{ {
_joyptr->eraseEvent(event, mode); // only reset the specific event _joyptr->eraseEvent(event, mode); // only reset the specific event
_joyptr->eraseEvent(event, getEventMode(event, mode)); _joyptr->eraseEvent(event, getEventMode(event, mode));
@ -727,7 +727,7 @@ void PhysicalJoystickHandler::saveMapping()
string PhysicalJoystickHandler::getMappingDesc(Event::Type event, EventMode mode) const string PhysicalJoystickHandler::getMappingDesc(Event::Type event, EventMode mode) const
{ {
ostringstream buf; ostringstream buf;
EventMode evMode = getEventMode(event, mode); const EventMode evMode = getEventMode(event, mode);
for(const auto& [_id, _joyptr]: mySticks) for(const auto& [_id, _joyptr]: mySticks)
{ {
@ -753,9 +753,9 @@ bool PhysicalJoystickHandler::addJoyMapping(Event::Type event, EventMode mode, i
if(j && event < Event::LastType && if(j && event < Event::LastType &&
button >= JOY_CTRL_NONE && button < j->numButtons && button >= JOY_CTRL_NONE && button < j->numButtons &&
axis >= JoyAxis::NONE && int(axis) < j->numAxes) axis >= JoyAxis::NONE && static_cast<int>(axis) < j->numAxes)
{ {
EventMode evMode = getEventMode(event, mode); const EventMode evMode = getEventMode(event, mode);
// This confusing code is because each axis has two associated values, // This confusing code is because each axis has two associated values,
// but analog events only affect one of the axis. // but analog events only affect one of the axis.
@ -796,7 +796,7 @@ bool PhysicalJoystickHandler::addJoyHatMapping(Event::Type event, EventMode mode
button >= JOY_CTRL_NONE && button < j->numButtons && button >= JOY_CTRL_NONE && button < j->numButtons &&
hat >= 0 && hat < j->numHats && hdir != JoyHatDir::CENTER) hat >= 0 && hat < j->numHats && hdir != JoyHatDir::CENTER)
{ {
EventMode evMode = getEventMode(event, mode); const EventMode evMode = getEventMode(event, mode);
// avoid double mapping in common and controller modes // avoid double mapping in common and controller modes
if (evMode == EventMode::kCommonMode) if (evMode == EventMode::kCommonMode)
@ -825,7 +825,7 @@ bool PhysicalJoystickHandler::addJoyHatMapping(Event::Type event, EventMode mode
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalJoystickHandler::handleAxisEvent(int stick, int axis, int value) void PhysicalJoystickHandler::handleAxisEvent(int stick, int axis, int value)
{ {
const PhysicalJoystickPtr j = joy(stick); const PhysicalJoystickPtr& j = joy(stick);
if(j) if(j)
{ {
@ -869,19 +869,20 @@ void PhysicalJoystickHandler::handleAxisEvent(int stick, int axis, int value)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PhysicalJoystickHandler::handleRegularAxisEvent(const PhysicalJoystickPtr j, void PhysicalJoystickHandler::handleRegularAxisEvent(const PhysicalJoystickPtr& j,
int stick, int axis, int value) int stick, int axis, int value)
{ {
int button = j->buttonLast[stick]; const int button = j->buttonLast[stick];
if(myHandler.state() == EventHandlerState::EMULATION) if(myHandler.state() == EventHandlerState::EMULATION)
{ {
Event::Type eventAxisAnalog; Event::Type eventAxisAnalog{};
// Check for analog events, which are handled differently // Check for analog events, which are handled differently
// A value change lower than ~90% indicates analog input // A value change lower than ~90% indicates analog input
if((abs(j->axisLastValue[axis] - value) < 30000) if((abs(j->axisLastValue[axis] - value) < 30000)
&& (eventAxisAnalog = j->joyMap.get(EventMode::kEmulationMode, button, JoyAxis(axis), JoyDir::ANALOG)) != Event::Type::NoType) && (eventAxisAnalog = j->joyMap.get(EventMode::kEmulationMode, button,
static_cast<JoyAxis>(axis), JoyDir::ANALOG)) != Event::Type::NoType)
{ {
myHandler.handleEvent(eventAxisAnalog, value); myHandler.handleEvent(eventAxisAnalog, value);
} }
@ -889,8 +890,10 @@ void PhysicalJoystickHandler::handleRegularAxisEvent(const PhysicalJoystickPtr j
{ {
// Otherwise, we assume the event is digital // Otherwise, we assume the event is digital
// Every axis event has two associated values, negative and positive // Every axis event has two associated values, negative and positive
Event::Type eventAxisNeg = j->joyMap.get(EventMode::kEmulationMode, button, JoyAxis(axis), JoyDir::NEG); const Event::Type eventAxisNeg = j->joyMap.get(EventMode::kEmulationMode, button,
Event::Type eventAxisPos = j->joyMap.get(EventMode::kEmulationMode, button, JoyAxis(axis), JoyDir::POS); static_cast<JoyAxis>(axis), JoyDir::NEG);
const Event::Type eventAxisPos = j->joyMap.get(EventMode::kEmulationMode, button,
static_cast<JoyAxis>(axis), JoyDir::POS);
if(value > Controller::digitalDeadZone()) if(value > Controller::digitalDeadZone())
myHandler.handleEvent(eventAxisPos); myHandler.handleEvent(eventAxisPos);
@ -932,10 +935,11 @@ void PhysicalJoystickHandler::handleRegularAxisEvent(const PhysicalJoystickPtr j
// Now filter out consecutive, similar values // Now filter out consecutive, similar values
// (only pass on the event if the state has changed) // (only pass on the event if the state has changed)
if(value != j->axisLastValue[axis]) if(value != j->axisLastValue[axis])
myHandler.overlay().handleJoyAxisEvent(stick, JoyAxis(axis), convertAxisValue(value), button); myHandler.overlay().handleJoyAxisEvent(stick, static_cast<JoyAxis>(axis),
convertAxisValue(value), button);
} }
else else
myHandler.overlay().handleJoyAxisEvent(stick, JoyAxis(axis), JoyDir::NONE, button); myHandler.overlay().handleJoyAxisEvent(stick, static_cast<JoyAxis>(axis), JoyDir::NONE, button);
j->axisLastValue[axis] = value; j->axisLastValue[axis] = value;
} }
#endif #endif

View File

@ -95,15 +95,15 @@ class PhysicalJoystickHandler
void handleHatEvent(int stick, int hat, int value); void handleHatEvent(int stick, int hat, int value);
Event::Type eventForAxis(EventMode mode, int stick, JoyAxis axis, JoyDir adir, int button) const { Event::Type eventForAxis(EventMode mode, int stick, JoyAxis axis, JoyDir adir, int button) const {
const PhysicalJoystickPtr j = joy(stick); const PhysicalJoystickPtr& j = joy(stick);
return j->joyMap.get(mode, button, axis, adir); return j->joyMap.get(mode, button, axis, adir);
} }
Event::Type eventForButton(EventMode mode, int stick, int button) const { Event::Type eventForButton(EventMode mode, int stick, int button) const {
const PhysicalJoystickPtr j = joy(stick); const PhysicalJoystickPtr& j = joy(stick);
return j->joyMap.get(mode, button); return j->joyMap.get(mode, button);
} }
Event::Type eventForHat(EventMode mode, int stick, int hat, JoyHatDir hatDir, int button) const { Event::Type eventForHat(EventMode mode, int stick, int hat, JoyHatDir hatDir, int button) const {
const PhysicalJoystickPtr j = joy(stick); const PhysicalJoystickPtr& j = joy(stick);
return j->joyMap.get(mode, button, hat, hatDir); return j->joyMap.get(mode, button, hat, hatDir);
} }
@ -156,7 +156,7 @@ class PhysicalJoystickHandler
} }
// Handle regular axis events (besides special Stelladaptor handling) // Handle regular axis events (besides special Stelladaptor handling)
void handleRegularAxisEvent(const PhysicalJoystickPtr j, void handleRegularAxisEvent(const PhysicalJoystickPtr& j,
int stick, int axis, int value); int stick, int axis, int value);
// Structures used for action menu items // Structures used for action menu items

View File

@ -128,7 +128,7 @@ void PhysicalKeyboardHandler::setDefaultKey(EventMapping map, Event::Type event,
{ {
// If event is 'NoType', erase and reset all mappings // If event is 'NoType', erase and reset all mappings
// Otherwise, only reset the given event // Otherwise, only reset the given event
bool eraseAll = !updateDefaults && (event == Event::NoType); const bool eraseAll = !updateDefaults && (event == Event::NoType);
#ifdef GUI_SUPPORT #ifdef GUI_SUPPORT
// Swap Y and Z for QWERTZ keyboards // Swap Y and Z for QWERTZ keyboards
@ -148,13 +148,13 @@ void PhysicalKeyboardHandler::setDefaultKey(EventMapping map, Event::Type event,
if (myKeyMap.getEventMapping(map.event, mode).size() == 0 && if (myKeyMap.getEventMapping(map.event, mode).size() == 0 &&
!isMappingUsed(mode, map)) !isMappingUsed(mode, map))
{ {
addMapping(map.event, mode, map.key, StellaMod(map.mod)); addMapping(map.event, mode, map.key, static_cast<StellaMod>(map.mod));
} }
} }
else if (eraseAll || map.event == event) else if (eraseAll || map.event == event)
{ {
//myKeyMap.eraseEvent(map.event, mode); //myKeyMap.eraseEvent(map.event, mode);
addMapping(map.event, mode, map.key, StellaMod(map.mod)); addMapping(map.event, mode, map.key, static_cast<StellaMod>(map.mod));
} }
} }
@ -239,7 +239,7 @@ void PhysicalKeyboardHandler::defineControllerMappings(
default: default:
{ {
EventMode mode = getMode(type); const EventMode mode = getMode(type);
if(port == Controller::Jack::Left) if(port == Controller::Jack::Left)
myLeftMode = mode; myLeftMode = mode;
@ -377,7 +377,7 @@ void PhysicalKeyboardHandler::enableCommonMappings()
{ {
for (int i = Event::NoType + 1; i < Event::LastType; i++) for (int i = Event::NoType + 1; i < Event::LastType; i++)
{ {
Event::Type event = static_cast<Event::Type>(i); const Event::Type event = static_cast<Event::Type>(i);
if (isCommonEvent(event)) if (isCommonEvent(event))
enableMapping(event, EventMode::kCommonMode); enableMapping(event, EventMode::kCommonMode);
@ -495,7 +495,7 @@ bool PhysicalKeyboardHandler::addMapping(Event::Type event, EventMode mode,
return false; return false;
else else
{ {
EventMode evMode = getEventMode(event, mode); const EventMode evMode = getEventMode(event, mode);
// avoid double mapping in common and controller modes // avoid double mapping in common and controller modes
if (evMode == EventMode::kCommonMode) if (evMode == EventMode::kCommonMode)
@ -543,13 +543,13 @@ void PhysicalKeyboardHandler::handleEvent(StellaKey key, StellaMod mod,
} }
#endif #endif
EventHandlerState estate = myHandler.state(); const EventHandlerState estate = myHandler.state();
// special handling for CompuMate in emulation modes // special handling for CompuMate in emulation modes
if ((estate == EventHandlerState::EMULATION || estate == EventHandlerState::PAUSE) && if ((estate == EventHandlerState::EMULATION || estate == EventHandlerState::PAUSE) &&
myOSystem.console().leftController().type() == Controller::Type::CompuMate) myOSystem.console().leftController().type() == Controller::Type::CompuMate)
{ {
Event::Type event = myKeyMap.get(EventMode::kCompuMateMode, key, mod); const Event::Type event = myKeyMap.get(EventMode::kCompuMateMode, key, mod);
// (potential) CompuMate events are handled directly. // (potential) CompuMate events are handled directly.
if (myKeyMap.get(EventMode::kEmulationMode, key, mod) != Event::ExitMode && if (myKeyMap.get(EventMode::kEmulationMode, key, mod) != Event::ExitMode &&

View File

@ -40,12 +40,12 @@ PNGLibrary::PNGLibrary(OSystem& osystem)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PNGLibrary::loadImage(const string& filename, FBSurface& surface) void PNGLibrary::loadImage(const string& filename, FBSurface& surface)
{ {
png_structp png_ptr = nullptr; png_structp png_ptr{nullptr};
png_infop info_ptr = nullptr; png_infop info_ptr{nullptr};
png_uint_32 iwidth, iheight; png_uint_32 iwidth{0}, iheight{0};
int bit_depth, color_type, interlace_type; int bit_depth{0}, color_type{0}, interlace_type{0};
auto loadImageERROR = [&](const char* s) { const auto loadImageERROR = [&](const char* s) {
if(png_ptr) if(png_ptr)
png_destroy_read_struct(&png_ptr, info_ptr ? &info_ptr : nullptr, nullptr); png_destroy_read_struct(&png_ptr, info_ptr ? &info_ptr : nullptr, nullptr);
if(s) if(s)
@ -106,7 +106,7 @@ void PNGLibrary::loadImage(const string& filename, FBSurface& surface)
// The PNG read function expects an array of rows, not a single 1-D array // The PNG read function expects an array of rows, not a single 1-D array
for(uInt32 irow = 0, offset = 0; irow < ReadInfo.height; ++irow, offset += ReadInfo.pitch) for(uInt32 irow = 0, offset = 0; irow < ReadInfo.height; ++irow, offset += ReadInfo.pitch)
ReadInfo.row_pointers[irow] = static_cast<png_bytep>(ReadInfo.buffer.data() + offset); ReadInfo.row_pointers[irow] = ReadInfo.buffer.data() + offset;
// Read the entire image in one go // Read the entire image in one go
png_read_image(png_ptr, ReadInfo.row_pointers.data()); png_read_image(png_ptr, ReadInfo.row_pointers.data());
@ -137,7 +137,7 @@ void PNGLibrary::saveImage(const string& filename, const VariantList& comments)
fb.scaleX(rectUnscaled.w()), fb.scaleY(rectUnscaled.h()) fb.scaleX(rectUnscaled.w()), fb.scaleY(rectUnscaled.h())
); );
png_uint_32 width = rect.w(), height = rect.h(); const png_uint_32 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);
@ -146,7 +146,7 @@ void PNGLibrary::saveImage(const string& filename, const VariantList& comments)
// 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(png_uint_32 k = 0; k < height; ++k)
rows[k] = static_cast<png_bytep>(buffer.data() + k*width*4); rows[k] = buffer.data() + k*width*4;
// And save the image // And save the image
saveImageToDisk(out, rows, width, height, comments); saveImageToDisk(out, rows, width, height, comments);
@ -175,7 +175,7 @@ void PNGLibrary::saveImage(const string& filename, const FBSurface& surface,
// 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(png_uint_32 k = 0; k < height; ++k)
rows[k] = static_cast<png_bytep>(buffer.data() + k*width*4); rows[k] = buffer.data() + k*width*4;
// And save the image // And save the image
saveImageToDisk(out, rows, width, height, comments); saveImageToDisk(out, rows, width, height, comments);
@ -188,7 +188,7 @@ void PNGLibrary::saveImageToDisk(std::ofstream& out, const vector<png_bytep>& ro
png_structp png_ptr = nullptr; png_structp png_ptr = nullptr;
png_infop info_ptr = nullptr; png_infop info_ptr = nullptr;
auto saveImageERROR = [&](const char* s) { const auto saveImageERROR = [&](const char* s) {
if(png_ptr) if(png_ptr)
png_destroy_write_struct(&png_ptr, &info_ptr); png_destroy_write_struct(&png_ptr, &info_ptr);
if(s) if(s)
@ -247,7 +247,7 @@ void PNGLibrary::saveImageToDisk(std::ofstream& out, const vector<png_bytep>& ro
void PNGLibrary::updateTime(uInt64 time) void PNGLibrary::updateTime(uInt64 time)
{ {
if(++mySnapCounter % mySnapInterval == 0) if(++mySnapCounter % mySnapInterval == 0)
takeSnapshot(uInt32(time) >> 10); // not quite milliseconds, but close enough takeSnapshot(static_cast<uInt32>(time) >> 10); // not quite milliseconds, but close enough
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -265,7 +265,7 @@ void PNGLibrary::toggleContinuousSnapshots(bool perFrame)
else else
{ {
buf << "Enabling snapshots in " << interval << " second intervals"; buf << "Enabling snapshots in " << interval << " second intervals";
interval *= uInt32(myOSystem.frameRate()); interval *= static_cast<uInt32>(myOSystem.frameRate());
} }
myOSystem.frameBuffer().showTextMessage(buf.str()); myOSystem.frameBuffer().showTextMessage(buf.str());
setContinuousSnapInterval(interval); setContinuousSnapInterval(interval);
@ -385,11 +385,11 @@ void PNGLibrary::takeSnapshot(uInt32 number)
bool PNGLibrary::allocateStorage(png_uint_32 w, png_uint_32 h) bool PNGLibrary::allocateStorage(png_uint_32 w, png_uint_32 h)
{ {
// 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)
size_t req_buffer_size = w * h * 3; const size_t req_buffer_size = w * h * 3;
if(req_buffer_size > ReadInfo.buffer.size()) if(req_buffer_size > ReadInfo.buffer.size())
ReadInfo.buffer.resize(req_buffer_size); ReadInfo.buffer.resize(req_buffer_size);
size_t req_row_size = h; const size_t req_row_size = h;
if(req_row_size > ReadInfo.row_pointers.size()) if(req_row_size > ReadInfo.row_pointers.size())
ReadInfo.row_pointers.resize(req_row_size); ReadInfo.row_pointers.resize(req_row_size);
@ -404,7 +404,7 @@ bool PNGLibrary::allocateStorage(png_uint_32 w, png_uint_32 h)
void PNGLibrary::loadImagetoSurface(FBSurface& surface) void PNGLibrary::loadImagetoSurface(FBSurface& surface)
{ {
// First determine if we need to resize the surface // First determine if we need to resize the surface
uInt32 iw = ReadInfo.width, ih = ReadInfo.height; const uInt32 iw = ReadInfo.width, ih = ReadInfo.height;
if(iw > surface.width() || ih > surface.height()) if(iw > surface.width() || ih > surface.height())
surface.resize(iw, ih); surface.resize(iw, ih);
@ -430,10 +430,10 @@ void PNGLibrary::loadImagetoSurface(FBSurface& surface)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PNGLibrary::writeComments(png_structp png_ptr, png_infop info_ptr, void PNGLibrary::writeComments(const png_structp png_ptr, png_infop info_ptr,
const VariantList& comments) const VariantList& comments)
{ {
uInt32 numComments = uInt32(comments.size()); const uInt32 numComments = static_cast<uInt32>(comments.size());
if(numComments == 0) if(numComments == 0)
return; return;
@ -449,33 +449,33 @@ void PNGLibrary::writeComments(png_structp png_ptr, png_infop info_ptr,
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PNGLibrary::png_read_data(png_structp ctx, png_bytep area, png_size_t size) void PNGLibrary::png_read_data(const png_structp ctx, 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(png_structp ctx, png_bytep area, png_size_t size) void PNGLibrary::png_write_data(const png_structp ctx, 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(png_structp ctx) void PNGLibrary::png_io_flush(const png_structp ctx)
{ {
(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(png_structp ctx, png_const_charp str) void PNGLibrary::png_user_warn(const png_structp ctx, png_const_charp str)
{ {
throw runtime_error(string("PNGLibrary warning: ") + str); throw runtime_error(string("PNGLibrary warning: ") + str);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void PNGLibrary::png_user_error(png_structp ctx, png_const_charp str) void PNGLibrary::png_user_error(const png_structp ctx, png_const_charp str)
{ {
throw runtime_error(string("PNGLibrary error: ") + str); throw runtime_error(string("PNGLibrary error: ") + str);
} }

View File

@ -180,15 +180,15 @@ class PNGLibrary
/** /**
Write PNG tEXt chunks to the image. Write PNG tEXt chunks to the image.
*/ */
void writeComments(png_structp png_ptr, png_infop info_ptr, void writeComments(const png_structp png_ptr, png_infop info_ptr,
const VariantList& comments); const VariantList& comments);
/** PNG library callback functions */ /** PNG library callback functions */
static void png_read_data(png_structp ctx, png_bytep area, png_size_t size); static void png_read_data(const png_structp ctx, png_bytep area, png_size_t size);
static void png_write_data(png_structp ctx, png_bytep area, 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(png_structp ctx); static void png_io_flush(const png_structp ctx);
[[noreturn]] static void png_user_warn(png_structp ctx, png_const_charp str); [[noreturn]] static void png_user_warn(const png_structp ctx, png_const_charp str);
[[noreturn]] static void png_user_error(png_structp ctx, 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

@ -62,10 +62,11 @@ void PaletteHandler::cyclePalette(int direction)
int type = toPaletteType(myOSystem.settings().getString("palette")); int type = toPaletteType(myOSystem.settings().getString("palette"));
do { do {
type = BSPF::clampw(type + direction, int(PaletteType::MinType), int(PaletteType::MaxType)); type = BSPF::clampw(type + direction,
static_cast<int>(PaletteType::MinType), static_cast<int>(PaletteType::MaxType));
} while(type == PaletteType::User && !myUserPaletteDefined); } while(type == PaletteType::User && !myUserPaletteDefined);
const string palette = toPaletteName(PaletteType(type)); const string palette = toPaletteName(static_cast<PaletteType>(type));
const string message = MESSAGES[type] + " palette"; const string message = MESSAGES[type] + " palette";
myOSystem.frameBuffer().showTextMessage(message); myOSystem.frameBuffer().showTextMessage(message);
@ -139,10 +140,11 @@ void PaletteHandler::showAdjustableMessage()
void PaletteHandler::cycleAdjustable(int direction) void PaletteHandler::cycleAdjustable(int direction)
{ {
const bool isCustomPalette = SETTING_CUSTOM == myOSystem.settings().getString("palette"); const bool isCustomPalette = SETTING_CUSTOM == myOSystem.settings().getString("palette");
bool isCustomAdj; bool isCustomAdj = false;
do { do {
myCurrentAdjustable = BSPF::clampw(int(myCurrentAdjustable + direction), 0, NUM_ADJUSTABLES - 1); myCurrentAdjustable = BSPF::clampw(static_cast<int>(myCurrentAdjustable + direction), 0,
NUM_ADJUSTABLES - 1);
isCustomAdj = isCustomAdjustable(); isCustomAdj = isCustomAdjustable();
// skip phase shift when 'Custom' palette is not selected // skip phase shift when 'Custom' palette is not selected
if(!direction && isCustomAdj && !isCustomPalette) if(!direction && isCustomAdj && !isCustomPalette)
@ -330,7 +332,7 @@ void PaletteHandler::setPalette()
const ConsoleTiming timing = myOSystem.console().timing(); const ConsoleTiming timing = myOSystem.console().timing();
const PaletteType paletteType = toPaletteType(name); const PaletteType paletteType = toPaletteType(name);
// Now consider the current display format // Now consider the current display format
const PaletteArray* palette = palettes[paletteType][int(timing)]; const PaletteArray* palette = palettes[paletteType][static_cast<int>(timing)];
if(paletteType == PaletteType::Custom) if(paletteType == PaletteType::Custom)
generateCustomPalette(timing); generateCustomPalette(timing);
@ -342,7 +344,7 @@ void PaletteHandler::setPalette()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PaletteArray PaletteHandler::adjustedPalette(const PaletteArray& palette) PaletteArray PaletteHandler::adjustedPalette(const PaletteArray& palette)
{ {
PaletteArray destPalette; PaletteArray destPalette{0};
// Constants for saturation and gray scale calculation // Constants for saturation and gray scale calculation
constexpr float PR = .2989F; constexpr float PR = .2989F;
constexpr float PG = .5870F; constexpr float PG = .5870F;
@ -358,7 +360,7 @@ PaletteArray PaletteHandler::adjustedPalette(const PaletteArray& palette)
const float gamma = 1.1333F - myGamma * 0.5F; const float gamma = 1.1333F - myGamma * 0.5F;
/* match common PC's 2.2 gamma to TV's 2.65 gamma */ /* match common PC's 2.2 gamma to TV's 2.65 gamma */
constexpr float toFloat = 1.F / (ADJUST_SIZE - 1); constexpr float toFloat = 1.F / (ADJUST_SIZE - 1);
std::array<float, ADJUST_SIZE> adjust; std::array<float, ADJUST_SIZE> adjust{0};
for(int i = 0; i < ADJUST_SIZE; i++) for(int i = 0; i < ADJUST_SIZE; i++)
adjust[i] = powf(i * toFloat, gamma) * contrast + brightness; adjust[i] = powf(i * toFloat, gamma) * contrast + brightness;
@ -408,19 +410,25 @@ void PaletteHandler::loadUserPalette()
uInt8* pixbuf = in.get(); uInt8* pixbuf = in.get();
for(int i = 0; i < 128; i++, pixbuf += 3) // NTSC palette for(int i = 0; i < 128; i++, pixbuf += 3) // NTSC palette
{ {
const uInt32 pixel = (int(pixbuf[0]) << 16) + (int(pixbuf[1]) << 8) + int(pixbuf[2]); const uInt32 pixel = (static_cast<int>(pixbuf[0]) << 16) +
(static_cast<int>(pixbuf[1]) << 8) +
static_cast<int>(pixbuf[2]);
ourUserNTSCPalette[(i<<1)] = pixel; ourUserNTSCPalette[(i<<1)] = pixel;
} }
for(int i = 0; i < 128; i++, pixbuf += 3) // PAL palette for(int i = 0; i < 128; i++, pixbuf += 3) // PAL palette
{ {
const uInt32 pixel = (int(pixbuf[0]) << 16) + (int(pixbuf[1]) << 8) + int(pixbuf[2]); const uInt32 pixel = (static_cast<int>(pixbuf[0]) << 16) +
(static_cast<int>(pixbuf[1]) << 8) +
static_cast<int>(pixbuf[2]);
ourUserPALPalette[(i<<1)] = pixel; ourUserPALPalette[(i<<1)] = pixel;
} }
std::array<uInt32, 16> secam; // All 8 24-bit pixels, plus 8 colorloss pixels std::array<uInt32, 16> secam{0}; // All 8 24-bit pixels, plus 8 colorloss pixels
for(int i = 0; i < 8; i++, pixbuf += 3) // SECAM palette for(int i = 0; i < 8; i++, pixbuf += 3) // SECAM palette
{ {
const uInt32 pixel = (int(pixbuf[0]) << 16) + (int(pixbuf[1]) << 8) + int(pixbuf[2]); const uInt32 pixel = (static_cast<int>(pixbuf[0]) << 16) +
(static_cast<int>(pixbuf[1]) << 8) +
static_cast<int>(pixbuf[2]);
secam[(i<<1)] = pixel; secam[(i<<1)] = pixel;
secam[(i<<1)+1] = 0; secam[(i<<1)+1] = 0;
} }

View File

@ -146,19 +146,19 @@ class PaletteHandler
Convert RGB adjustables from/to 100% scale Convert RGB adjustables from/to 100% scale
*/ */
static constexpr float scaleRGBFrom100(float x) { return x / 50.F; } static constexpr float scaleRGBFrom100(float x) { return x / 50.F; }
static constexpr uInt32 scaleRGBTo100(float x) { return uInt32(50.0001F * (x - 0.F)); } static constexpr uInt32 scaleRGBTo100(float x) { return static_cast<uInt32>(50.0001F * (x - 0.F)); }
/** /**
Convert angles Convert angles
*/ */
static constexpr float scaleFromAngles(float x) { return x / 10.F; } static constexpr float scaleFromAngles(float x) { return x / 10.F; }
static constexpr Int32 scaleToAngles(float x) { return uInt32(10.F * x); } static constexpr Int32 scaleToAngles(float x) { return static_cast<uInt32>(10.F * x); }
/** /**
Convert adjustables from/to 100% scale Convert adjustables from/to 100% scale
*/ */
static constexpr float scaleFrom100(float x) { return (x / 50.F) - 1.F; } static constexpr float scaleFrom100(float x) { return (x / 50.F) - 1.F; }
static constexpr uInt32 scaleTo100(float x) { return uInt32(50.0001F * (x + 1.F)); } static constexpr uInt32 scaleTo100(float x) { return static_cast<uInt32>(50.0001F * (x + 1.F)); }
/** /**
Check for 'Custom' palette only adjustables Check for 'Custom' palette only adjustables

View File

@ -28,7 +28,7 @@ bool PhosphorHandler::initialize(bool enable, int blend)
myPhosphorPercent = blend / 100.F; myPhosphorPercent = blend / 100.F;
// Used to calculate an averaged color for the 'phosphor' effect // Used to calculate an averaged color for the 'phosphor' effect
auto getPhosphor = [&] (const uInt8 c1, uInt8 c2) -> uInt8 { const auto getPhosphor = [&] (const uInt8 c1, uInt8 c2) -> uInt8 {
// Use maximum of current and decayed previous values // Use maximum of current and decayed previous values
c2 = static_cast<uInt8>(c2 * myPhosphorPercent); c2 = static_cast<uInt8>(c2 * myPhosphorPercent);
if(c1 > c2) return c1; // raise (assumed immediate) if(c1 > c2) return c1; // raise (assumed immediate)
@ -40,7 +40,7 @@ bool PhosphorHandler::initialize(bool enable, int blend)
{ {
for(int c = 255; c >= 0; --c) for(int c = 255; c >= 0; --c)
for(int p = 255; p >= 0; --p) for(int p = 255; p >= 0; --p)
ourPhosphorLUT[c][p] = getPhosphor(uInt8(c), uInt8(p)); ourPhosphorLUT[c][p] = getPhosphor(static_cast<uInt8>(c), static_cast<uInt8>(p));
} }
return true; return true;
} }

View File

@ -84,7 +84,7 @@ bool PhysicalJoystick::setMap(const json& map)
{ {
int i = 0; int i = 0;
for (auto& entry: map.items()) { for (const auto& entry: map.items()) {
if (entry.key() == "name") continue; if (entry.key() == "name") continue;
try { try {
@ -130,9 +130,9 @@ json PhysicalJoystick::convertLegacyMapping(const string& mapping, const string&
// Remove leading "<mode>|" string // Remove leading "<mode>|" string
map.erase(0, 2); map.erase(0, 2);
json mappingForMode = JoyMap::convertLegacyMapping(map); const json mappingForMode = JoyMap::convertLegacyMapping(map);
convertedMapping[jsonName(EventMode(mode))] = mappingForMode; convertedMapping[jsonName(static_cast<EventMode>(mode))] = mappingForMode;
} }
convertedMapping["name"] = name; convertedMapping["name"] = name;

View File

@ -63,7 +63,7 @@ void RewindManager::setup()
// calc interval growth factor for compression // calc interval growth factor for compression
// this factor defines the backward horizon // this factor defines the backward horizon
const double MAX_FACTOR = 1E8; constexpr double MAX_FACTOR = 1E8;
double minFactor = 0, maxFactor = MAX_FACTOR; double minFactor = 0, maxFactor = MAX_FACTOR;
myFactor = 1; myFactor = 1;
@ -82,7 +82,7 @@ void RewindManager::setup()
interval *= myFactor; interval *= myFactor;
cycleSum += interval; cycleSum += interval;
} }
double diff = cycleSum - myHorizon; const double diff = cycleSum - myHorizon;
// exit loop if result is close enough // exit loop if result is close enough
if(std::abs(diff) < myHorizon * 1E-5) if(std::abs(diff) < myHorizon * 1E-5)
@ -102,7 +102,7 @@ bool RewindManager::addState(const string& message, bool timeMachine)
if(timeMachine && myStateList.currentIsValid()) if(timeMachine && myStateList.currentIsValid())
{ {
// check if the current state has the right interval from the last state // check if the current state has the right interval from the last state
RewindState& lastState = myStateList.current(); const RewindState& lastState = myStateList.current();
uInt32 interval = myInterval; uInt32 interval = myInterval;
// adjust frame timed intervals to actual scanlines (vs 262) // adjust frame timed intervals to actual scanlines (vs 262)
@ -145,7 +145,7 @@ bool RewindManager::addState(const string& message, bool timeMachine)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 RewindManager::rewindStates(uInt32 numStates) uInt32 RewindManager::rewindStates(uInt32 numStates)
{ {
uInt64 startCycles = myOSystem.console().tia().cycles(); const uInt64 startCycles = myOSystem.console().tia().cycles();
uInt32 i; uInt32 i;
string message; string message;
@ -185,7 +185,7 @@ uInt32 RewindManager::rewindStates(uInt32 numStates)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 RewindManager::unwindStates(uInt32 numStates) uInt32 RewindManager::unwindStates(uInt32 numStates)
{ {
uInt64 startCycles = myOSystem.console().tia().cycles(); const uInt64 startCycles = myOSystem.console().tia().cycles();
uInt32 i; uInt32 i;
string message; string message;
@ -243,9 +243,9 @@ string RewindManager::saveAllStates()
if (!out) if (!out)
return "Can't save to all states file"; return "Can't save to all states file";
uInt32 curIdx = getCurrentIdx(); const uInt32 curIdx = getCurrentIdx();
rewindStates(MAX_BUF_SIZE); rewindStates(MAX_BUF_SIZE);
uInt32 numStates = uInt32(cyclesList().size()); uInt32 numStates = static_cast<uInt32>(cyclesList().size());
// Save header // Save header
buf.str(""); buf.str("");
@ -256,8 +256,7 @@ string RewindManager::saveAllStates()
{ {
RewindState& state = myStateList.current(); RewindState& state = myStateList.current();
Serializer& s = state.data; Serializer& s = state.data;
uInt32 stateSize = uInt32(s.size()); const uInt32 stateSize = static_cast<uInt32>(s.size());
unique_ptr<uInt8[]> buffer = make_unique<uInt8[]>(stateSize);
out.putInt(stateSize); out.putInt(stateSize);
@ -265,8 +264,9 @@ string RewindManager::saveAllStates()
s.rewind(); s.rewind();
// Save state // Save state
s.getByteArray(buffer.get(), stateSize); ByteArray buffer(stateSize);
out.putByteArray(buffer.get(), stateSize); s.getByteArray(buffer.data(), stateSize);
out.putByteArray(buffer.data(), stateSize);
out.putString(state.message); out.putString(state.message);
out.putLong(state.cycles); out.putLong(state.cycles);
@ -301,7 +301,7 @@ string RewindManager::loadAllStates()
return "Can't load from all states file"; return "Can't load from all states file";
clear(); clear();
uInt32 numStates; uInt32 numStates = 0;
// Load header // Load header
buf.str(""); buf.str("");
@ -315,8 +315,7 @@ string RewindManager::loadAllStates()
if (myStateList.full()) if (myStateList.full())
compressStates(); compressStates();
uInt32 stateSize = in.getInt(); const uInt32 stateSize = in.getInt();
unique_ptr<uInt8[]> buffer = make_unique<uInt8[]>(stateSize);
// Add new state at the end of the list (queue adds at end) // Add new state at the end of the list (queue adds at end)
// This updates the 'current' iterator inside the list // This updates the 'current' iterator inside the list
@ -328,8 +327,9 @@ string RewindManager::loadAllStates()
s.rewind(); s.rewind();
// Fill new state with saved values // Fill new state with saved values
in.getByteArray(buffer.get(), stateSize); ByteArray buffer(stateSize);
s.putByteArray(buffer.get(), stateSize); in.getByteArray(buffer.data(), stateSize);
s.putByteArray(buffer.data(), stateSize);
state.message = in.getString(); state.message = in.getString();
state.cycles = in.getLong(); state.cycles = in.getLong();
} }
@ -366,9 +366,9 @@ void RewindManager::compressStates()
{ {
expectedCycles *= myFactor; expectedCycles *= myFactor;
uInt64 prevCycles = myStateList.previous(it)->cycles; const uInt64 prevCycles = myStateList.previous(it)->cycles;
uInt64 nextCycles = myStateList.next(it)->cycles; const uInt64 nextCycles = myStateList.next(it)->cycles;
double error = expectedCycles / (nextCycles - prevCycles); const double error = expectedCycles / (nextCycles - prevCycles);
if(error > maxError) if(error > maxError)
{ {
@ -390,7 +390,7 @@ string RewindManager::loadState(Int64 startCycles, uInt32 numStates)
myStateManager.loadState(s); myStateManager.loadState(s);
myOSystem.console().tia().loadDisplay(s); myOSystem.console().tia().loadDisplay(s);
Int64 diff = startCycles - state.cycles; const Int64 diff = startCycles - state.cycles;
stringstream message; stringstream message;
message << (diff >= 0 ? "Rewind" : "Unwind") << " " << getUnitString(diff); message << (diff >= 0 ? "Rewind" : "Unwind") << " " << getUnitString(diff);
@ -418,11 +418,11 @@ string RewindManager::getUnitString(Int64 cycles)
"cycle", "scanline", "frame", "second", "minute" "cycle", "scanline", "frame", "second", "minute"
}; };
const std::array<Int64, NUM_UNITS+1> UNIT_CYCLES = { const std::array<Int64, 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; Int32 i = 0;
cycles = std::abs(cycles); cycles = std::abs(cycles);
@ -433,7 +433,7 @@ string RewindManager::getUnitString(Int64 cycles)
if(cycles == 0 || (cycles < UNIT_CYCLES[i + 1] * 2 && cycles % UNIT_CYCLES[i + 1] != 0)) if(cycles == 0 || (cycles < UNIT_CYCLES[i + 1] * 2 && cycles % UNIT_CYCLES[i + 1] != 0))
break; break;
} }
result << cycles / UNIT_CYCLES[i] << " " << UNIT_NAMES[i]; result << (cycles / UNIT_CYCLES[i]) << " " << UNIT_NAMES[i];
if(cycles / UNIT_CYCLES[i] != 1) if(cycles / UNIT_CYCLES[i] != 1)
result << "s"; result << "s";
@ -466,7 +466,7 @@ IntArray RewindManager::cyclesList() const
{ {
IntArray arr; IntArray arr;
uInt64 firstCycle = getFirstCycles(); const uInt64 firstCycle = getFirstCycles();
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(uInt32(it->cycles - firstCycle));

View File

@ -81,8 +81,8 @@ class RewindManager
76 * 262 * 60 * 60, 76 * 262 * 60 * 60,
76 * 262 * 60 * 60 * 3, 76 * 262 * 60 * 60 * 3,
76 * 262 * 60 * 60 * 10, 76 * 262 * 60 * 60 * 10,
uInt64(76) * 262 * 60 * 60 * 30, uInt64{76} *262 * 60 * 60 * 30,
uInt64(76) * 262 * 60 * 60 * 60 uInt64{76} *262 * 60 * 60 * 60
}; };
// settings values for the horzions // settings values for the horzions
const std::array<string, NUM_HORIZONS> HOR_SETTINGS = { const std::array<string, NUM_HORIZONS> HOR_SETTINGS = {
@ -185,8 +185,11 @@ class RewindManager
// We do nothing on object instantiation or copy // We do nothing on object instantiation or copy
// The goal of LinkedObjectPool is to not do any allocations at all // The goal of LinkedObjectPool is to not do any allocations at all
RewindState() = default; RewindState() = default;
~RewindState() = default;
RewindState(const RewindState& rs) : cycles(rs.cycles) { } RewindState(const RewindState& rs) : cycles(rs.cycles) { }
RewindState& operator= (const RewindState& rs) { cycles = rs.cycles; return *this; } RewindState& operator= (const RewindState& rs) { cycles = rs.cycles; return *this; }
RewindState(RewindState&&) = default;
RewindState& operator=(RewindState&&) = default;
// Output object info; used for debugging only // Output object info; used for debugging only
friend ostream& operator<<(ostream& os, const RewindState& s) { friend ostream& operator<<(ostream& os, const RewindState& s) {

View File

@ -83,7 +83,7 @@ void SoundSDL2::queryHardware(VariantList& devices)
{ {
ASSERT_MAIN_THREAD; ASSERT_MAIN_THREAD;
int numDevices = SDL_GetNumAudioDevices(0); const int numDevices = SDL_GetNumAudioDevices(0);
// log the available audio devices // log the available audio devices
ostringstream s; ostringstream s;
@ -112,12 +112,12 @@ bool SoundSDL2::openDevice()
desired.channels = 2; desired.channels = 2;
desired.samples = static_cast<Uint16>(myAudioSettings.fragmentSize()); desired.samples = static_cast<Uint16>(myAudioSettings.fragmentSize());
desired.callback = callback; desired.callback = callback;
desired.userdata = static_cast<void*>(this); desired.userdata = this;
if(myIsInitializedFlag) if(myIsInitializedFlag)
SDL_CloseAudioDevice(myDevice); SDL_CloseAudioDevice(myDevice);
myDeviceId = BSPF::clamp(myAudioSettings.device(), 0U, uInt32(myDevices.size() - 1)); myDeviceId = BSPF::clamp(myAudioSettings.device(), 0U, static_cast<uInt32>(myDevices.size() - 1));
const char* device = myDeviceId ? myDevices.at(myDeviceId).first.c_str() : nullptr; const char* device = myDeviceId ? myDevices.at(myDeviceId).first.c_str() : nullptr;
myDevice = SDL_OpenAudioDevice(device, 0, &desired, &myHardwareSpec, myDevice = SDL_OpenAudioDevice(device, 0, &desired, &myHardwareSpec,
@ -154,8 +154,8 @@ void SoundSDL2::open(shared_ptr<AudioQueue> audioQueue,
// Do we need to re-open the sound device? // Do we need to re-open the sound device?
// Only do this when absolutely necessary // Only do this when absolutely necessary
if(myAudioSettings.sampleRate() != uInt32(myHardwareSpec.freq) || if(myAudioSettings.sampleRate() != static_cast<uInt32>(myHardwareSpec.freq) ||
myAudioSettings.fragmentSize() != uInt32(myHardwareSpec.samples) || myAudioSettings.fragmentSize() != static_cast<uInt32>(myHardwareSpec.samples) ||
myAudioSettings.device() != myDeviceId) myAudioSettings.device() != myDeviceId)
openDevice(); openDevice();
@ -206,7 +206,7 @@ void SoundSDL2::close()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool SoundSDL2::mute(bool state) bool SoundSDL2::mute(bool state)
{ {
bool oldstate = SDL_GetAudioDeviceStatus(myDevice) == SDL_AUDIO_PAUSED; const bool oldstate = SDL_GetAudioDeviceStatus(myDevice) == SDL_AUDIO_PAUSED;
if(myIsInitializedFlag) if(myIsInitializedFlag)
SDL_PauseAudioDevice(myDevice, state ? 1 : 0); SDL_PauseAudioDevice(myDevice, state ? 1 : 0);
@ -216,7 +216,7 @@ bool SoundSDL2::mute(bool state)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool SoundSDL2::toggleMute() bool SoundSDL2::toggleMute()
{ {
bool enabled = !myAudioSettings.enabled(); const bool enabled = !myAudioSettings.enabled();
setEnabled(enabled); setEnabled(enabled);
myOSystem.console().initializeAudio(); myOSystem.console().initializeAudio();
@ -269,7 +269,7 @@ void SoundSDL2::adjustVolume(int direction)
setVolume(percent); setVolume(percent);
// Enable audio if it is currently disabled // Enable audio if it is currently disabled
bool enabled = myAudioSettings.enabled(); const bool enabled = myAudioSettings.enabled();
if(percent > 0 && !enabled) if(percent > 0 && !enabled)
{ {
@ -292,7 +292,7 @@ string SoundSDL2::about() const
buf << "Sound enabled:" << endl buf << "Sound enabled:" << endl
<< " Volume: " << myVolume << "%" << endl << " Volume: " << myVolume << "%" << endl
<< " Device: " << myDevices.at(myDeviceId).first << endl << " Device: " << myDevices.at(myDeviceId).first << endl
<< " Channels: " << uInt32(myHardwareSpec.channels) << " Channels: " << static_cast<uInt32>(myHardwareSpec.channels)
<< (myAudioQueue->isStereo() ? " (Stereo)" : " (Mono)") << endl << (myAudioQueue->isStereo() ? " (Stereo)" : " (Mono)") << endl
<< " Preset: "; << " Preset: ";
switch (myAudioSettings.preset()) { switch (myAudioSettings.preset()) {
@ -312,8 +312,8 @@ string SoundSDL2::about() const
buf << "Ultra quality, minimal lag" << endl; buf << "Ultra quality, minimal lag" << endl;
break; break;
} }
buf << " Fragment size: " << uInt32(myHardwareSpec.samples) << " bytes" << endl buf << " Fragment size: " << static_cast<uInt32>(myHardwareSpec.samples) << " bytes" << endl
<< " Sample rate: " << uInt32(myHardwareSpec.freq) << " Hz" << endl; << " Sample rate: " << static_cast<uInt32>(myHardwareSpec.freq) << " Hz" << endl;
buf << " Resampling: "; buf << " Resampling: ";
switch(myAudioSettings.resamplingQuality()) switch(myAudioSettings.resamplingQuality())
{ {

View File

@ -73,8 +73,8 @@ void StaggeredLogger::_log()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StaggeredLogger::logLine() void StaggeredLogger::logLine()
{ {
high_resolution_clock::time_point now = high_resolution_clock::now(); const high_resolution_clock::time_point now = high_resolution_clock::now();
Int64 millisecondsSinceIntervalStart = const Int64 millisecondsSinceIntervalStart =
duration_cast<duration<Int64, std::milli>>(now - myLastIntervalStartTimestamp).count(); duration_cast<duration<Int64, std::milli>>(now - myLastIntervalStartTimestamp).count();
stringstream ss; stringstream ss;
@ -113,7 +113,7 @@ void StaggeredLogger::startInterval()
myIsCurrentlyCollecting = true; myIsCurrentlyCollecting = true;
high_resolution_clock::time_point now = high_resolution_clock::now(); const high_resolution_clock::time_point now = high_resolution_clock::now();
Int64 msecSinceLastIntervalEnd = Int64 msecSinceLastIntervalEnd =
duration_cast<duration<Int64, std::milli>>(now - myLastIntervalEndTimestamp).count(); duration_cast<duration<Int64, std::milli>>(now - myLastIntervalEndTimestamp).count();

View File

@ -128,7 +128,7 @@ void StateManager::toggleRecordMode()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void StateManager::toggleTimeMachine() void StateManager::toggleTimeMachine()
{ {
bool devSettings = myOSystem.settings().getBool("dev.settings"); const bool devSettings = myOSystem.settings().getBool("dev.settings");
myActiveMode = myActiveMode == Mode::TimeMachine ? Mode::Off : Mode::TimeMachine; myActiveMode = myActiveMode == Mode::TimeMachine ? Mode::Off : Mode::TimeMachine;
if(myActiveMode == Mode::TimeMachine) if(myActiveMode == Mode::TimeMachine)

View File

@ -57,7 +57,8 @@ class StringParser
while(std::getline(buf, line, '\n')) while(std::getline(buf, line, '\n'))
{ {
size_t len = maxlen, size = line.size(); size_t len = maxlen;
const size_t size = line.size();
if(size <= len) if(size <= len)
myStringList.push_back(line); myStringList.push_back(line);
@ -66,7 +67,7 @@ class StringParser
size_t beg = 0; size_t beg = 0;
while((beg + maxlen) < size) while((beg + maxlen) < size)
{ {
size_t spos = line.find_last_of(' ', beg + len); const size_t spos = line.find_last_of(' ', beg + len);
if(spos != string::npos && spos > beg) if(spos != string::npos && spos > beg)
len = spos - beg; len = spos - beg;

View File

@ -62,15 +62,15 @@ TimerManager::TimerId TimerManager::addTimer(
// Assign an ID and insert it into function storage // Assign an ID and insert it into function storage
auto id = nextId++; auto id = nextId++;
auto iter = active.emplace(id, Timer(id, Clock::now() + Duration(msDelay), const auto iter = active.emplace(id, Timer(id, Clock::now() + Duration(msDelay),
Duration(msPeriod), func)); Duration(msPeriod), func));
// Insert a reference to the Timer into ordering queue // Insert a reference to the Timer into ordering queue
Queue::iterator place = queue.emplace(iter.first->second); const Queue::iterator 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
bool needNotify = (place == queue.begin()); const bool needNotify = (place == queue.begin());
lock.unlock(); lock.unlock();
@ -84,7 +84,7 @@ TimerManager::TimerId TimerManager::addTimer(
bool TimerManager::clear(TimerId id) bool TimerManager::clear(TimerId id)
{ {
ScopedLock lock(sync); ScopedLock lock(sync);
auto i = active.find(id); const auto i = active.find(id);
return destroy_impl(lock, i, true); return destroy_impl(lock, i, true);
} }
@ -131,9 +131,9 @@ void TimerManager::timerThreadWorker()
continue; continue;
} }
auto queueHead = queue.begin(); const auto queueHead = queue.begin();
Timer& timer = *queueHead; Timer& timer = *queueHead;
auto now = Clock::now(); const auto now = Clock::now();
if (now >= timer.next) if (now >= timer.next)
{ {
queue.erase(queueHead); queue.erase(queueHead);
@ -181,8 +181,7 @@ void TimerManager::timerThreadWorker()
else else
{ {
// Wait until the timer is ready or a timer creation notifies // Wait until the timer is ready or a timer creation notifies
Timestamp next = timer.next; wakeUp.wait_until(lock, timer.next);
wakeUp.wait_until(lock, next);
} }
} }
} }
@ -232,20 +231,20 @@ bool TimerManager::destroy_impl(ScopedLock& lock, TimerMap::iterator i,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TimerManager::Timer::Timer(Timer&& r) noexcept TimerManager::Timer::Timer(Timer&& r) noexcept
: id(r.id), : id{r.id},
next(r.next), next{r.next},
period(r.period), period{r.period},
handler(std::move(r.handler)), handler{std::move(r.handler)},
running(r.running) running{r.running}
{ {
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TimerManager::Timer::Timer(TimerId tid, Timestamp tnext, Duration tperiod, TimerManager::Timer::Timer(TimerId tid, Timestamp tnext, Duration tperiod,
const TFunction& func) noexcept const TFunction& func) noexcept
: id(tid), : id{tid },
next(tnext), next{tnext},
period(tperiod), period{tperiod},
handler(func) handler{func}
{ {
} }

View File

@ -158,7 +158,7 @@ class TimerManager
TimerId id{0}; TimerId id{0};
Timestamp next; Timestamp next;
Duration period; Duration period{0};
TFunction handler; TFunction handler;
// You must be holding the 'sync' lock to assign waitCond // You must be holding the 'sync' lock to assign waitCond

View File

@ -56,8 +56,8 @@ VideoModeHandler::buildMode(const Settings& settings, bool inTIAMode)
const float overscan = 1 - settings.getInt("tia.fs_overscan") / 100.0; const float overscan = 1 - settings.getInt("tia.fs_overscan") / 100.0;
// First calculate maximum zoom that keeps aspect ratio // First calculate maximum zoom that keeps aspect ratio
const float scaleX = float(myImage.w) / myDisplay.w, const float scaleX = static_cast<float>(myImage.w) / myDisplay.w,
scaleY = float(myImage.h) / myDisplay.h; scaleY = static_cast<float>(myImage.h) / myDisplay.h;
float zoom = 1.F / std::max(scaleX, scaleY); float zoom = 1.F / std::max(scaleX, scaleY);
// When aspect ratio correction is off, we want pixel-exact images, // When aspect ratio correction is off, we want pixel-exact images,

View File

@ -33,7 +33,7 @@ void ConvolutionBuffer::shift(float nextValue)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
float ConvolutionBuffer::convoluteWith(float* kernel) const float ConvolutionBuffer::convoluteWith(const float* const kernel) const
{ {
float result = 0.F; float result = 0.F;

View File

@ -28,7 +28,7 @@ class ConvolutionBuffer
void shift(float nextValue); void shift(float nextValue);
float convoluteWith(float* kernel) const; float convoluteWith(const float* const kernel) const;
private: private:

View File

@ -27,7 +27,7 @@ HighPass::HighPass(float cutOffFrequency, float frequency)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
float HighPass::apply(float valueIn) float HighPass::apply(float valueIn)
{ {
float valueOut = myAlpha * (myLastValueOut + valueIn - myLastValueIn); const float valueOut = myAlpha * (myLastValueOut + valueIn - myLastValueIn);
myLastValueIn = valueIn; myLastValueIn = valueIn;
myLastValueOut = valueOut; myLastValueOut = valueOut;

View File

@ -24,7 +24,7 @@ namespace {
constexpr float CLIPPING_FACTOR = 0.75; constexpr float CLIPPING_FACTOR = 0.75;
constexpr float HIGH_PASS_CUT_OFF = 10; constexpr float HIGH_PASS_CUT_OFF = 10;
uInt32 reducedDenominator(uInt32 n, uInt32 d) constexpr uInt32 reducedDenominator(uInt32 n, uInt32 d)
{ {
for (uInt32 i = std::min(n ,d); i > 1; --i) { for (uInt32 i = std::min(n ,d); i > 1; --i) {
if ((n % i == 0) && (d % i == 0)) { if ((n % i == 0) && (d % i == 0)) {
@ -98,7 +98,7 @@ void LanczosResampler::precomputeKernels()
for (uInt32 i = 0; i < myPrecomputedKernelCount; ++i) { for (uInt32 i = 0; i < myPrecomputedKernelCount; ++i) {
float* kernel = myPrecomputedKernels.get() + myKernelSize * i; float* kernel = myPrecomputedKernels.get() + 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
float center = const float center =
static_cast<float>(timeIndex) / static_cast<float>(myFormatTo.sampleRate); static_cast<float>(timeIndex) / static_cast<float>(myFormatTo.sampleRate);
for (uInt32 j = 0; j < 2 * myKernelParameter; ++j) { for (uInt32 j = 0; j < 2 * myKernelParameter; ++j) {
@ -143,12 +143,12 @@ void LanczosResampler::fillFragment(float* fragment, uInt32 length)
const uInt32 outputSamples = myFormatTo.stereo ? (length >> 1) : length; const uInt32 outputSamples = myFormatTo.stereo ? (length >> 1) : length;
for (uInt32 i = 0; i < outputSamples; ++i) { for (uInt32 i = 0; i < outputSamples; ++i) {
float* kernel = myPrecomputedKernels.get() + (myCurrentKernelIndex * myKernelSize); const float* kernel = myPrecomputedKernels.get() + (myCurrentKernelIndex * myKernelSize);
myCurrentKernelIndex = (myCurrentKernelIndex + 1) % myPrecomputedKernelCount; myCurrentKernelIndex = (myCurrentKernelIndex + 1) % myPrecomputedKernelCount;
if (myFormatFrom.stereo) { if (myFormatFrom.stereo) {
float sampleL = myBufferL->convoluteWith(kernel); const float sampleL = myBufferL->convoluteWith(kernel);
float sampleR = myBufferR->convoluteWith(kernel); const float sampleR = myBufferR->convoluteWith(kernel);
if (myFormatTo.stereo) { if (myFormatTo.stereo) {
fragment[2*i] = sampleL; fragment[2*i] = sampleL;
@ -157,7 +157,7 @@ void LanczosResampler::fillFragment(float* fragment, uInt32 length)
else else
fragment[i] = (sampleL + sampleR) / 2.F; fragment[i] = (sampleL + sampleR) / 2.F;
} else { } else {
float sample = myBuffer->convoluteWith(kernel); const float sample = myBuffer->convoluteWith(kernel);
if (myFormatTo.stereo) if (myFormatTo.stereo)
fragment[2*i] = fragment[2*i + 1] = sample; fragment[2*i] = fragment[2*i + 1] = sample;
@ -167,7 +167,7 @@ void LanczosResampler::fillFragment(float* fragment, uInt32 length)
myTimeIndex += myFormatFrom.sampleRate; myTimeIndex += myFormatFrom.sampleRate;
uInt32 samplesToShift = myTimeIndex / myFormatTo.sampleRate; const uInt32 samplesToShift = myTimeIndex / myFormatTo.sampleRate;
if (samplesToShift == 0) continue; if (samplesToShift == 0) continue;
myTimeIndex %= myFormatTo.sampleRate; myTimeIndex %= myFormatTo.sampleRate;

View File

@ -49,8 +49,8 @@ void SimpleResampler::fillFragment(float* fragment, uInt32 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 (uInt32 i = 0; i < outputSamples; ++i) {
if (myFormatFrom.stereo) { if (myFormatFrom.stereo) {
float sampleL = static_cast<float>(myCurrentFragment[2*myFragmentIndex]) / static_cast<float>(0x7fff); const float sampleL = static_cast<float>(myCurrentFragment[2*myFragmentIndex]) / static_cast<float>(0x7fff);
float sampleR = static_cast<float>(myCurrentFragment[2*myFragmentIndex + 1]) / static_cast<float>(0x7fff); const float sampleR = static_cast<float>(myCurrentFragment[2*myFragmentIndex + 1]) / static_cast<float>(0x7fff);
if (myFormatTo.stereo) { if (myFormatTo.stereo) {
fragment[2*i] = sampleL; fragment[2*i] = sampleL;
@ -59,7 +59,7 @@ void SimpleResampler::fillFragment(float* fragment, uInt32 length)
else else
fragment[i] = (sampleL + sampleR) / 2.F; fragment[i] = (sampleL + sampleR) / 2.F;
} else { } else {
float sample = static_cast<float>(myCurrentFragment[myFragmentIndex] / static_cast<float>(0x7fff)); const float 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

@ -180,7 +180,7 @@ int main(int ac, char* av[])
unique_ptr<OSystem> theOSystem; unique_ptr<OSystem> theOSystem;
auto Cleanup = [&theOSystem]() { const auto Cleanup = [&theOSystem]() {
if(theOSystem) if(theOSystem)
{ {
Logger::debug("Cleanup from main"); Logger::debug("Cleanup from main");

View File

@ -24,7 +24,7 @@ class KeyValueRepositoryNoop : public KeyValueRepositoryAtomic
{ {
public: public:
virtual std::map<string, Variant> load() override { std::map<string, Variant> load() override {
return std::map<string, Variant>(); return std::map<string, Variant>();
} }

View File

@ -110,7 +110,7 @@ void BilinearBlitter::recreateTexturesIfNecessary()
free(); free();
} }
SDL_TextureAccess texAccess = myStaticData == nullptr ? SDL_TEXTUREACCESS_STREAMING : SDL_TEXTUREACCESS_STATIC; const SDL_TextureAccess texAccess = myStaticData == nullptr ? SDL_TEXTUREACCESS_STREAMING : SDL_TEXTUREACCESS_STATIC;
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, myInterpolate ? "1" : "0"); SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, myInterpolate ? "1" : "0");
@ -126,7 +126,7 @@ void BilinearBlitter::recreateTexturesIfNecessary()
} }
if (myAttributes.blending) { if (myAttributes.blending) {
uInt8 blendAlpha = uInt8(myAttributes.blendalpha * 2.55); const uInt8 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

@ -31,14 +31,14 @@ class BilinearBlitter : public Blitter {
~BilinearBlitter() override; ~BilinearBlitter() override;
virtual void reinitialize( void reinitialize(
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 = nullptr
) override; ) override;
virtual void blit(SDL_Surface& surface) override; void blit(SDL_Surface& surface) override;
private: private:
FBBackendSDL2& myFB; FBBackendSDL2& myFB;

View File

@ -145,7 +145,8 @@ void QisBlitter::recreateTexturesIfNecessary()
free(); free();
} }
SDL_TextureAccess texAccess = myStaticData == nullptr ? SDL_TEXTUREACCESS_STREAMING : SDL_TEXTUREACCESS_STATIC; const SDL_TextureAccess texAccess =
myStaticData == nullptr ? SDL_TEXTUREACCESS_STREAMING : SDL_TEXTUREACCESS_STATIC;
myIntermediateRect.w = (myDstRect.w / mySrcRect.w) * mySrcRect.w; myIntermediateRect.w = (myDstRect.w / mySrcRect.w) * mySrcRect.w;
myIntermediateRect.h = (myDstRect.h / mySrcRect.h) * mySrcRect.h; myIntermediateRect.h = (myDstRect.h / mySrcRect.h) * mySrcRect.h;
@ -180,7 +181,7 @@ void QisBlitter::recreateTexturesIfNecessary()
} }
if (myAttributes.blending) { if (myAttributes.blending) {
uInt8 blendAlpha = uInt8(myAttributes.blendalpha * 2.55); const uInt8 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

@ -33,14 +33,14 @@ class QisBlitter : public Blitter {
~QisBlitter() override; ~QisBlitter() override;
virtual void reinitialize( void reinitialize(
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 = nullptr
) override; ) override;
virtual void blit(SDL_Surface& surface) override; void blit(SDL_Surface& surface) override;
private: private:

View File

@ -22,63 +22,63 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
template<unsigned base> template<unsigned base>
uInt8 smartmod(uInt8 x) constexpr uInt8 smartmod(uInt8 x)
{ {
return x % base; return x % base;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
template<> template<>
inline uInt8 smartmod<2>(uInt8 x) inline constexpr uInt8 smartmod<2>(uInt8 x)
{ {
return x & 0x01; return x & 0x01;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
template<> template<>
inline uInt8 smartmod<4>(uInt8 x) inline constexpr uInt8 smartmod<4>(uInt8 x)
{ {
return x & 0x03; return x & 0x03;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
template<> template<>
inline uInt8 smartmod<8>(uInt8 x) inline constexpr uInt8 smartmod<8>(uInt8 x)
{ {
return x & 0x07; return x & 0x07;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
template<> template<>
inline uInt8 smartmod<16>(uInt8 x) inline constexpr uInt8 smartmod<16>(uInt8 x)
{ {
return x & 0x0F; return x & 0x0F;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
template<> template<>
inline uInt8 smartmod<32>(uInt8 x) inline constexpr uInt8 smartmod<32>(uInt8 x)
{ {
return x & 0x1F; return x & 0x1F;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
template<> template<>
inline uInt8 smartmod<64>(uInt8 x) inline constexpr uInt8 smartmod<64>(uInt8 x)
{ {
return x & 0x3F; return x & 0x3F;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
template<> template<>
inline uInt8 smartmod<128>(uInt8 x) inline constexpr uInt8 smartmod<128>(uInt8 x)
{ {
return x & 0x7F; return x & 0x7F;
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
template<> template<>
inline uInt8 smartmod<256>(uInt8 x) inline constexpr uInt8 smartmod<256>(uInt8 x)
{ {
return x & 0xFF; return x & 0xFF;
} }

View File

@ -57,21 +57,21 @@ void AtariNTSC::generateKernels()
const uInt8* ptr = myRGBPalette.data(); const uInt8* ptr = myRGBPalette.data();
for(size_t entry = 0; entry < myRGBPalette.size() / 3; ++entry) for(size_t entry = 0; entry < myRGBPalette.size() / 3; ++entry)
{ {
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 );
// 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 );
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();
genKernel(myImpl, y, i, q, kernel); genKernel(myImpl, y, i, q, kernel);
for ( uInt32 c = 0; c < rgb_kernel_size / 2; ++c ) for ( uInt32 c = 0; c < rgb_kernel_size / 2; ++c )
{ {
uInt32 error = rgb - const uInt32 error = rgb -
kernel [c ] - kernel [(c+10)%14+14] - kernel [c ] - kernel [(c+10)%14+14] -
kernel [c + 7] - kernel [c + 3 +14]; kernel [c + 7] - kernel [c + 3 +14];
kernel [c + 3 + 14] += error; kernel [c + 3 + 14] += error;
@ -208,7 +208,7 @@ void AtariNTSC::renderWithPhosphorThread(const uInt8* atari_in, const uInt32 in_
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;
uInt32 bufofs = AtariNTSC::outWidth(in_width) * yStart; uInt32 bufofs = AtariNTSC::outWidth(in_width) * yStart;
uInt32* out = static_cast<uInt32*>(rgb_out); const uInt32* out = static_cast<uInt32*>(rgb_out);
atari_in += in_width * yStart; atari_in += in_width * yStart;
rgb_out = static_cast<char*>(rgb_out) + out_pitch * yStart; rgb_out = static_cast<char*>(rgb_out) + out_pitch * yStart;
@ -361,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; std::array<float, kernel_size * 2> kernels{0};
/* generate luma (y) filter using sinc kernel */ /* generate luma (y) filter using sinc kernel */
{ {
@ -369,7 +369,7 @@ void AtariNTSC::initFilters(init_t& impl, const Setup& setup)
float const rolloff = 1 + setup.sharpness * 0.032F; float const rolloff = 1 + setup.sharpness * 0.032F;
constexpr float maxh = 32; constexpr float maxh = 32;
float const pow_a_n = powf( rolloff, maxh ); float const pow_a_n = powf( rolloff, maxh );
float sum;
/* quadratic mapping to reduce negative (blurring) range */ /* quadratic mapping to reduce negative (blurring) range */
float to_angle = setup.resolution + 1; float to_angle = setup.resolution + 1;
to_angle = BSPF::PI_f / maxh * luma_cutoff * (to_angle * to_angle + 1.F); to_angle = BSPF::PI_f / maxh * luma_cutoff * (to_angle * to_angle + 1.F);
@ -377,26 +377,26 @@ void AtariNTSC::initFilters(init_t& impl, const Setup& setup)
kernels [kernel_size * 3 / 2] = maxh; /* default center value */ kernels [kernel_size * 3 / 2] = maxh; /* default center value */
for ( int i = 0; i < kernel_half * 2 + 1; i++ ) for ( int i = 0; i < kernel_half * 2 + 1; i++ )
{ {
int x = i - kernel_half; const int x = i - kernel_half;
float angle = x * to_angle; const float angle = x * to_angle;
/* instability occurs at center point with rolloff very close to 1.0 */ /* instability occurs at center point with rolloff very close to 1.0 */
if ( x || pow_a_n > 1.056F || pow_a_n < 0.981F ) if ( x || pow_a_n > 1.056F || pow_a_n < 0.981F )
{ {
float rolloff_cos_a = rolloff * cosf( angle ); const float rolloff_cos_a = rolloff * cosf( angle );
float num = 1 - rolloff_cos_a - const float num = 1 - rolloff_cos_a -
pow_a_n * cosf( maxh * angle ) + pow_a_n * cosf( maxh * angle ) +
pow_a_n * rolloff * cosf( (maxh - 1) * angle ); pow_a_n * rolloff * cosf( (maxh - 1) * angle );
float den = 1 - rolloff_cos_a - rolloff_cos_a + rolloff * rolloff; const float den = 1 - rolloff_cos_a - rolloff_cos_a + rolloff * rolloff;
float dsf = num / den; float dsf = num / den;
kernels [kernel_size * 3 / 2 - kernel_half + i] = dsf - 0.5F; kernels [kernel_size * 3 / 2 - kernel_half + i] = dsf - 0.5F;
} }
} }
/* apply blackman window and find sum */ /* apply blackman window and find sum */
sum = 0; float sum = 0;
for ( int i = 0; i < kernel_half * 2 + 1; i++ ) for ( int i = 0; i < kernel_half * 2 + 1; i++ )
{ {
float x = BSPF::PI_f * 2 / (kernel_half * 2) * i; const float x = BSPF::PI_f * 2 / (kernel_half * 2) * i;
float blackman = 0.42F - 0.5F * cosf( x ) + 0.08F * cosf( x * 2 ); float blackman = 0.42F - 0.5F * cosf( x ) + 0.08F * cosf( x * 2 );
sum += (kernels [kernel_size * 3 / 2 - kernel_half + i] *= blackman); sum += (kernels [kernel_size * 3 / 2 - kernel_half + i] *= blackman);
} }
@ -405,7 +405,7 @@ void AtariNTSC::initFilters(init_t& impl, const Setup& setup)
sum = 1.0F / sum; sum = 1.0F / sum;
for ( int i = 0; i < kernel_half * 2 + 1; i++ ) for ( int i = 0; i < kernel_half * 2 + 1; i++ )
{ {
int x = kernel_size * 3 / 2 - kernel_half + i; const int x = kernel_size * 3 / 2 - kernel_half + i;
kernels [x] *= sum; kernels [x] *= sum;
} }
} }
@ -454,7 +454,7 @@ void AtariNTSC::initFilters(init_t& impl, const Setup& setup)
weight -= 1.0F / rescale_in; weight -= 1.0F / rescale_in;
for ( int i = 0; i < kernel_size * 2; i++ ) for ( int i = 0; i < kernel_size * 2; i++ )
{ {
float cur = kernels [i]; const float cur = kernels [i];
float m = cur * weight; float m = cur * weight;
*out++ = m + remain; *out++ = m + remain;
remain = cur - m; remain = cur - m;
@ -498,13 +498,12 @@ void AtariNTSC::genKernel(init_t& impl, float y, float i, float q, uInt32* out)
float const yc3 = (y - qq) * pixel->kernel [3]; float const yc3 = (y - qq) * pixel->kernel [3];
float const* k = &impl.kernel [pixel->offset]; float const* k = &impl.kernel [pixel->offset];
int n;
++pixel; ++pixel;
for ( n = rgb_kernel_size; n; --n ) for ( int n = rgb_kernel_size; n; --n )
{ {
float fi = k[0]*ic0 + k[2]*ic2; const float fi = k[0]*ic0 + k[2]*ic2;
float fq = k[1]*qc1 + k[3]*qc3; const float fq = k[1]*qc1 + k[3]*qc3;
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 [kernel_size * 2 * (rescale_out - 1)] )
k += kernel_size * 2 - 1; k += kernel_size * 2 - 1;

View File

@ -185,7 +185,7 @@ class AtariNTSC
// 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.
#define ATARI_NTSC_BEGIN_ROW( pixel0, pixel1 ) \ #define ATARI_NTSC_BEGIN_ROW( pixel0, pixel1 ) \
unsigned const atari_ntsc_pixel0_ = (pixel0);\ constexpr unsigned atari_ntsc_pixel0_ = (pixel0);\
uInt32 const* kernel0 = myColorTable[atari_ntsc_pixel0_].data();\ uInt32 const* kernel0 = myColorTable[atari_ntsc_pixel0_].data();\
unsigned const atari_ntsc_pixel1_ = (pixel1);\ unsigned const atari_ntsc_pixel1_ = (pixel1);\
uInt32 const* kernel1 = myColorTable[atari_ntsc_pixel1_].data();\ uInt32 const* kernel1 = myColorTable[atari_ntsc_pixel1_].data();\
@ -211,7 +211,7 @@ class AtariNTSC
// Common ntsc macros // Common ntsc macros
static constexpr void ATARI_NTSC_CLAMP( uInt32& io, uInt32 shift ) { static constexpr void ATARI_NTSC_CLAMP( uInt32& io, uInt32 shift ) {
uInt32 sub = io >> (9-(shift)) & atari_ntsc_clamp_mask; const uInt32 sub = io >> (9-(shift)) & atari_ntsc_clamp_mask;
uInt32 clamp = atari_ntsc_clamp_add - sub; uInt32 clamp = atari_ntsc_clamp_add - sub;
io |= clamp; io |= clamp;
clamp -= sub; clamp -= sub;

View File

@ -21,7 +21,7 @@
#include "NTSCFilter.hxx" #include "NTSCFilter.hxx"
constexpr float scaleFrom100(float x) { return (x / 50.F) - 1.F; } constexpr float scaleFrom100(float x) { return (x / 50.F) - 1.F; }
constexpr uInt32 scaleTo100(float x) { return uInt32(50.0001F * (x + 1.F)); } constexpr uInt32 scaleTo100(float x) { return static_cast<uInt32>(50.0001F * (x + 1.F)); }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string NTSCFilter::setPreset(Preset preset) string NTSCFilter::setPreset(Preset preset)

View File

@ -21,7 +21,7 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void BreakpointMap::add(const Breakpoint& breakpoint, const uInt32 flags) void BreakpointMap::add(const Breakpoint& breakpoint, const uInt32 flags)
{ {
Breakpoint bp = convertBreakpoint(breakpoint); const Breakpoint bp = convertBreakpoint(breakpoint);
myInitialized = true; myInitialized = true;
myMap[bp] = flags; myMap[bp] = flags;
@ -40,7 +40,7 @@ void BreakpointMap::erase(const Breakpoint& breakpoint)
if(!myMap.erase(breakpoint)) if(!myMap.erase(breakpoint))
{ {
// 13 bit breakpoint // 13 bit breakpoint
Breakpoint bp13(breakpoint.addr & ADDRESS_MASK, breakpoint.bank); const Breakpoint bp13(breakpoint.addr & ADDRESS_MASK, breakpoint.bank);
myMap.erase(bp13); myMap.erase(bp13);
} }
@ -61,7 +61,7 @@ uInt32 BreakpointMap::get(const Breakpoint& breakpoint) const
return find->second; return find->second;
// 13 bit breakpoint // 13 bit breakpoint
Breakpoint bp13(breakpoint.addr & ADDRESS_MASK, breakpoint.bank); const Breakpoint bp13(breakpoint.addr & ADDRESS_MASK, breakpoint.bank);
find = myMap.find(bp13); find = myMap.find(bp13);
if(find != myMap.end()) if(find != myMap.end())
@ -85,7 +85,7 @@ bool BreakpointMap::check(const Breakpoint& breakpoint) const
return true; return true;
// 13 bit breakpoint // 13 bit breakpoint
Breakpoint bp13(breakpoint.addr & ADDRESS_MASK, breakpoint.bank); const Breakpoint bp13(breakpoint.addr & ADDRESS_MASK, breakpoint.bank);
find = myMap.find(bp13); find = myMap.find(bp13);
return (find != myMap.end()); return (find != myMap.end());
@ -103,7 +103,7 @@ BreakpointMap::BreakpointList BreakpointMap::getBreakpoints() const
BreakpointList map; BreakpointList map;
std::map<Breakpoint, uInt32> ordered(myMap.begin(), myMap.end()); std::map<Breakpoint, uInt32> ordered(myMap.begin(), myMap.end());
for(auto item : ordered) for(const auto& item : ordered)
map.push_back(item.first); map.push_back(item.first);
return map; return map;

View File

@ -190,7 +190,7 @@ int CartDebug::lastWriteBaseAddress()
string CartDebug::toString() string CartDebug::toString()
{ {
ostringstream buf; ostringstream buf;
uInt32 bytesPerLine; uInt32 bytesPerLine = 0;
switch(Base::format()) switch(Base::format())
{ {
@ -245,7 +245,7 @@ string CartDebug::toString()
bool CartDebug::disassembleAddr(uInt16 address, bool force) bool CartDebug::disassembleAddr(uInt16 address, bool force)
{ {
// ROM/RAM bank or ZP-RAM? // ROM/RAM bank or ZP-RAM?
int bank = (address & 0x1000) ? getBank(address) : int(myBankInfo.size()) - 1; const int bank = (address & 0x1000) ? getBank(address) : int(myBankInfo.size()) - 1;
return disassemble(bank, address, force); return disassemble(bank, address, force);
} }
@ -271,15 +271,15 @@ bool CartDebug::disassemble(int bank, uInt16 PC, bool force)
{ {
// Test current disassembly; don't re-disassemble if it hasn't changed // Test current disassembly; don't re-disassemble if it hasn't changed
// Also check if the current PC is in the current list // Also check if the current PC is in the current list
bool bankChanged = myConsole.cartridge().bankChanged(); const bool bankChanged = myConsole.cartridge().bankChanged();
int pcline = addressToLine(PC); const int pcline = addressToLine(PC);
bool pcfound = (pcline != -1) && (uInt32(pcline) < myDisassembly.list.size()) && const bool pcfound = (pcline != -1) && (static_cast<uInt32>(pcline) < myDisassembly.list.size()) &&
(myDisassembly.list[pcline].disasm[0] != '.'); (myDisassembly.list[pcline].disasm[0] != '.');
bool pagedirty = (PC & 0x1000) ? mySystem.isPageDirty(0x1000, 0x1FFF) : const bool pagedirty = (PC & 0x1000) ? mySystem.isPageDirty(0x1000, 0x1FFF) :
mySystem.isPageDirty(0x80, 0xFF); mySystem.isPageDirty(0x80, 0xFF);
bool changed = !mySystem.autodetectMode() && const bool changed = !mySystem.autodetectMode() &&
(force || bankChanged || !pcfound || pagedirty); (force || bankChanged || !pcfound || pagedirty);
if(changed) if(changed)
{ {
// Are we disassembling from ROM or ZP RAM? // Are we disassembling from ROM or ZP RAM?
@ -316,7 +316,7 @@ bool CartDebug::disassemble(int bank, uInt16 PC, bool force)
// Always attempt to resolve code sections unless it's been // Always attempt to resolve code sections unless it's been
// specifically disabled // specifically disabled
bool found = fillDisassemblyList(info, PC); const bool found = fillDisassemblyList(info, PC);
if(!found && DiStella::settings.resolveCode) if(!found && DiStella::settings.resolveCode)
{ {
// Temporarily turn off code resolution // Temporarily turn off code resolution
@ -385,8 +385,8 @@ string CartDebug::disassembleLines(uInt16 start, uInt16 lines) const
ostringstream buffer; ostringstream buffer;
// First find the lines in the range, and determine the longest string // First find the lines in the range, and determine the longest string
uInt32 list_size = uInt32(myDisassembly.list.size()); const size_t list_size = myDisassembly.list.size();
uInt32 begin = list_size, end = 0, length = 0; size_t begin = list_size, end = 0, length = 0;
for(end = 0; end < list_size && lines > 0; ++end) for(end = 0; end < list_size && lines > 0; ++end)
{ {
const CartDebug::DisassemblyTag& tag = myDisassembly.list[end]; const CartDebug::DisassemblyTag& tag = myDisassembly.list[end];
@ -394,14 +394,14 @@ string CartDebug::disassembleLines(uInt16 start, uInt16 lines) const
{ {
if(begin == list_size) begin = end; if(begin == list_size) begin = end;
if(tag.type != Device::ROW) if(tag.type != Device::ROW)
length = std::max(length, uInt32(tag.disasm.length())); length = std::max(length, tag.disasm.length());
--lines; --lines;
} }
} }
// Now output the disassembly, using as little space as possible // Now output the disassembly, using as little space as possible
for(uInt32 i = begin; i < end; ++i) for(size_t i = begin; i < end; ++i)
{ {
const CartDebug::DisassemblyTag& tag = myDisassembly.list[i]; const CartDebug::DisassemblyTag& tag = myDisassembly.list[i];
if(tag.type == Device::NONE) if(tag.type == Device::NONE)
@ -412,7 +412,7 @@ string CartDebug::disassembleLines(uInt16 start, uInt16 lines) const
else else
buffer << " "; buffer << " ";
buffer << tag.disasm << std::setw(int(length - tag.disasm.length() + 2)) buffer << tag.disasm << std::setw(static_cast<int>(length - tag.disasm.length() + 2))
<< std::setfill(' ') << " " << std::setfill(' ') << " "
<< std::setw(4) << std::left << tag.ccount << " " << tag.bytes << endl; << std::setw(4) << std::left << tag.ccount << " " << tag.bytes << endl;
} }
@ -618,7 +618,7 @@ bool CartDebug::getLabel(ostream& buf, uInt16 addr, bool isRead,
{ {
if(isRead) if(isRead)
{ {
uInt16 a = addr & 0x0F, offset = addr & 0xFFF0; const uInt16 a = addr & 0x0F, offset = addr & 0xFFF0;
if(ourTIAMnemonicR[a]) if(ourTIAMnemonicR[a])
{ {
buf << ourTIAMnemonicR[a]; buf << ourTIAMnemonicR[a];
@ -630,7 +630,7 @@ bool CartDebug::getLabel(ostream& buf, uInt16 addr, bool isRead,
} }
else else
{ {
uInt16 a = addr & 0x3F, offset = addr & 0xFFC0; const uInt16 a = addr & 0x3F, offset = addr & 0xFFC0;
if(ourTIAMnemonicW[a]) if(ourTIAMnemonicW[a])
{ {
buf << ourTIAMnemonicW[a]; buf << ourTIAMnemonicW[a];
@ -645,7 +645,7 @@ bool CartDebug::getLabel(ostream& buf, uInt16 addr, bool isRead,
case AddrType::IO: case AddrType::IO:
{ {
uInt16 a = addr & 0xFF, offset = addr & 0xFD00; const uInt16 a = addr & 0xFF, offset = addr & 0xFD00;
if(a <= 0x9F) if(a <= 0x9F)
{ {
if(ourIOMnemonic[a - 0x80]) if(ourIOMnemonic[a - 0x80])
@ -668,7 +668,7 @@ bool CartDebug::getLabel(ostream& buf, uInt16 addr, bool isRead,
// RAM can use user-defined labels; otherwise we default to // RAM can use user-defined labels; otherwise we default to
// standard mnemonics // standard mnemonics
AddrToLabel::const_iterator iter; AddrToLabel::const_iterator iter;
uInt16 a = addr & 0xFF, offset = addr & 0xFF00; const uInt16 a = addr & 0xFF, offset = addr & 0xFF00;
bool found = false; bool found = false;
// Search for nearest label // Search for nearest label
@ -798,7 +798,7 @@ string CartDebug::loadListFile()
if(addr_s.length() == 0) if(addr_s.length() == 0)
continue; continue;
const char* p = addr_s[0] == 'U' ? addr_s.c_str() + 1 : addr_s.c_str(); const char* p = addr_s[0] == 'U' ? addr_s.c_str() + 1 : addr_s.c_str();
addr = int(strtoul(p, nullptr, 16)); addr = static_cast<int>(strtoul(p, nullptr, 16));
// For now, completely ignore ROM addresses // For now, completely ignore ROM addresses
if(!(addr & 0x1000)) if(!(addr & 0x1000))
@ -1063,8 +1063,8 @@ string CartDebug::saveDisassembly(string path)
"BLACK", "BLUE", "RED", "PURPLE", "BLACK", "BLUE", "RED", "PURPLE",
"GREEN", "CYAN", "YELLOW", "WHITE" "GREEN", "CYAN", "YELLOW", "WHITE"
}; };
bool isNTSC = myConsole.timing() == ConsoleTiming::ntsc; const bool isNTSC = myConsole.timing() == ConsoleTiming::ntsc;
bool isPAL = myConsole.timing() == ConsoleTiming::pal; const bool isPAL = myConsole.timing() == ConsoleTiming::pal;
#define ALIGN(x) setfill(' ') << left << setw(x) #define ALIGN(x) setfill(' ') << left << setw(x)
@ -1086,8 +1086,8 @@ string CartDebug::saveDisassembly(string path)
Disassembly disasm; Disassembly disasm;
disasm.list.reserve(2048); disasm.list.reserve(2048);
uInt16 romBankCount = myConsole.cartridge().romBankCount(); const uInt16 romBankCount = myConsole.cartridge().romBankCount();
uInt16 oldBank = myConsole.cartridge().getBank(); const uInt16 oldBank = myConsole.cartridge().getBank();
// prepare for switching banks // prepare for switching banks
myConsole.cartridge().unlockHotspots(); myConsole.cartridge().unlockHotspots();
@ -1129,7 +1129,7 @@ string CartDebug::saveDisassembly(string path)
else else
buf << " ORG $" << Base::HEX4 << origin << "\n" buf << " ORG $" << Base::HEX4 << origin << "\n"
<< " RORG $" << Base::HEX4 << info.offset << "\n\n"; << " RORG $" << Base::HEX4 << info.offset << "\n\n";
origin += 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(uInt32 i = 0; i < disasm.list.size(); ++i)
@ -1298,9 +1298,9 @@ string CartDebug::saveDisassembly(string path)
<< ";-----------------------------------------------------------\n\n"; << ";-----------------------------------------------------------\n\n";
for (uInt16 addr = 0x80; addr <= 0xFF; ++addr) { for (uInt16 addr = 0x80; addr <= 0xFF; ++addr) {
bool ramUsed = (mySystem.getAccessFlags(addr) & (Device::DATA | Device::WRITE)); const bool ramUsed = (mySystem.getAccessFlags(addr) & (Device::DATA | Device::WRITE));
bool codeUsed = (mySystem.getAccessFlags(addr) & Device::CODE); const bool codeUsed = (mySystem.getAccessFlags(addr) & Device::CODE);
bool stackUsed = (mySystem.getAccessFlags(addr|0x100) & (Device::DATA | Device::WRITE)); const bool stackUsed = (mySystem.getAccessFlags(addr|0x100) & (Device::DATA | Device::WRITE));
if (myReserved.ZPRAM[addr - 0x80] && if (myReserved.ZPRAM[addr - 0x80] &&
myUserLabels.find(addr) == myUserLabels.end()) { myUserLabels.find(addr) == myUserLabels.end()) {
@ -1534,6 +1534,8 @@ CartDebug::AddrType CartDebug::addressType(uInt16 addr) const
case 0x200: case 0x300: case 0x600: case 0x700: case 0x200: case 0x300: case 0x600: case 0x700:
case 0xa00: case 0xb00: case 0xe00: case 0xf00: case 0xa00: case 0xb00: case 0xe00: case 0xf00:
return AddrType::IO; return AddrType::IO;
default:
break;
} }
} }
} }
@ -1551,7 +1553,7 @@ void CartDebug::getBankDirectives(ostream& buf, const BankInfo& info) const
Device::AccessType prevType = accessTypeAbsolute(mySystem.getAccessFlags(prev)); Device::AccessType prevType = accessTypeAbsolute(mySystem.getAccessFlags(prev));
for( ; addr < info.offset + info.size; ++addr) for( ; addr < info.offset + info.size; ++addr)
{ {
Device::AccessType currType = accessTypeAbsolute(mySystem.getAccessFlags(addr)); const Device::AccessType currType = accessTypeAbsolute(mySystem.getAccessFlags(addr));
// Have we changed to a new type? // Have we changed to a new type?
if(currType != prevType) if(currType != prevType)
@ -1581,9 +1583,9 @@ void CartDebug::accessTypeAsString(ostream& buf, uInt16 addr) const
return; return;
} }
uInt8 directive = myDisDirectives[addr & 0xFFF] & 0xFC, const uInt8 directive = myDisDirectives[addr & 0xFFF] & 0xFC,
debugger = myDebugger.getAccessFlags(addr) & 0xFC, debugger = myDebugger.getAccessFlags(addr) & 0xFC,
label = myDisLabels[addr & 0xFFF]; label = myDisLabels[addr & 0xFFF];
buf << endl << "directive: " << Base::toString(directive, Base::Fmt::_2_8) << " "; buf << endl << "directive: " << Base::toString(directive, Base::Fmt::_2_8) << " ";
AccessTypeAsString(buf, directive); AccessTypeAsString(buf, directive);

View File

@ -301,7 +301,7 @@ class CartDebug : public DebuggerSystem
std::array<bool, 64> TIAWrite; std::array<bool, 64> TIAWrite;
std::array<bool, 24> IOReadWrite; std::array<bool, 24> IOReadWrite;
std::array<bool, 128> ZPRAM; std::array<bool, 128> ZPRAM;
AddrToLabel Label; AddrToLabel Label{};
bool breakFound{false}; bool breakFound{false};
}; };
ReservedEquates myReserved; ReservedEquates myReserved;

View File

@ -152,13 +152,13 @@ int CpuDebug::icycles() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::setPC(int pc) void CpuDebug::setPC(int pc)
{ {
my6502.PC = uInt16(pc); my6502.PC = static_cast<uInt16>(pc);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::setSP(int sp) void CpuDebug::setSP(int sp)
{ {
my6502.SP = uInt8(sp); my6502.SP = static_cast<uInt8>(sp);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -170,19 +170,19 @@ void CpuDebug::setPS(int ps)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::setA(int a) void CpuDebug::setA(int a)
{ {
my6502.A = uInt8(a); my6502.A = static_cast<uInt8>(a);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::setX(int x) void CpuDebug::setX(int x)
{ {
my6502.X = uInt8(x); my6502.X = static_cast<uInt8>(x);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CpuDebug::setY(int y) void CpuDebug::setY(int y)
{ {
my6502.Y = uInt8(y); my6502.Y = static_cast<uInt8>(y);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -96,8 +96,8 @@ void Debugger::initialize()
// The debugger dialog is resizable, within certain bounds // The debugger dialog is resizable, within certain bounds
// We check those bounds now // We check those bounds now
mySize.clamp(uInt32(DebuggerDialog::kSmallFontMinW), d.w, mySize.clamp(static_cast<uInt32>(DebuggerDialog::kSmallFontMinW), d.w,
uInt32(DebuggerDialog::kSmallFontMinH), d.h); static_cast<uInt32>(DebuggerDialog::kSmallFontMinH), d.h);
myOSystem.settings().setValue("dbg.res", mySize); myOSystem.settings().setValue("dbg.res", mySize);
@ -190,7 +190,7 @@ string Debugger::autoExec(StringList* history)
for(const auto& func: ourBuiltinFunctions) for(const auto& func: ourBuiltinFunctions)
{ {
// TODO - check this for memory leaks // TODO - check this for memory leaks
int res = YaccParser::parse(func.defn); const int res = YaccParser::parse(func.defn);
if(res == 0) if(res == 0)
addFunction(func.name, func.defn, YaccParser::getResult(), true); addFunction(func.name, func.defn, YaccParser::getResult(), true);
else else
@ -228,7 +228,7 @@ const string Debugger::invIfChanged(int reg, int oldReg)
{ {
string ret; string ret;
bool changed = reg != oldReg; const bool changed = reg != oldReg;
if(changed) ret += "\177"; if(changed) ret += "\177";
ret += Common::Base::toString(reg, Common::Base::Fmt::_16_2); ret += Common::Base::toString(reg, Common::Base::Fmt::_16_2);
if(changed) ret += "\177"; if(changed) ret += "\177";
@ -252,9 +252,9 @@ string Debugger::setRAM(IntArray& args)
{ {
ostringstream buf; ostringstream buf;
int count = int(args.size()); const size_t count = args.size();
int address = args[0]; int address = args[0];
for(int i = 1; i < count; ++i) for(size_t i = 1; i < count; ++i)
mySystem.poke(address++, args[i]); mySystem.poke(address++, args[i]);
buf << "changed " << (count-1) << " location"; buf << "changed " << (count-1) << " location";
@ -309,7 +309,7 @@ int Debugger::step(bool save)
if(save) if(save)
saveOldState(); saveOldState();
uInt64 startCycle = mySystem.cycles(); const uInt64 startCycle = mySystem.cycles();
unlockSystem(); unlockSystem();
myOSystem.console().tia().updateScanlineByStep().flushLineCache(); myOSystem.console().tia().updateScanlineByStep().flushLineCache();
@ -317,7 +317,7 @@ int Debugger::step(bool save)
if(save) if(save)
addState("step"); addState("step");
return int(mySystem.cycles() - startCycle); return static_cast<int>(mySystem.cycles() - startCycle);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -337,11 +337,11 @@ int Debugger::trace()
{ {
saveOldState(); saveOldState();
uInt64 startCycle = mySystem.cycles(); const uInt64 startCycle = mySystem.cycles();
int targetPC = myCpuDebug->pc() + 3; // return address const int targetPC = myCpuDebug->pc() + 3; // return address
// set temporary breakpoint at target PC (if not existing already) // set temporary breakpoint at target PC (if not existing already)
Int8 bank = myCartDebug->getBank(targetPC); const Int8 bank = myCartDebug->getBank(targetPC);
if(!checkBreakPoint(targetPC, bank)) if(!checkBreakPoint(targetPC, bank))
{ {
// add temporary breakpoint and remove later // add temporary breakpoint and remove later
@ -354,7 +354,7 @@ int Debugger::trace()
lockSystem(); lockSystem();
addState("trace"); addState("trace");
return int(mySystem.cycles() - startCycle); return static_cast<int>(mySystem.cycles() - startCycle);
} }
else else
return step(); return step();
@ -363,9 +363,7 @@ int Debugger::trace()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::setBreakPoint(uInt16 addr, uInt8 bank, uInt32 flags) bool Debugger::setBreakPoint(uInt16 addr, uInt8 bank, uInt32 flags)
{ {
bool exists = checkBreakPoint(addr, bank); if(checkBreakPoint(addr, bank))
if(exists)
return false; return false;
breakPoints().add(addr, bank, flags); breakPoints().add(addr, bank, flags);
@ -375,9 +373,7 @@ bool Debugger::setBreakPoint(uInt16 addr, uInt8 bank, uInt32 flags)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool Debugger::clearBreakPoint(uInt16 addr, uInt8 bank) bool Debugger::clearBreakPoint(uInt16 addr, uInt8 bank)
{ {
bool exists = checkBreakPoint(addr, bank); if(!checkBreakPoint(addr, bank))
if(!exists)
return false; return false;
breakPoints().erase(addr, bank); breakPoints().erase(addr, bank);
@ -457,7 +453,7 @@ bool Debugger::writeTrap(uInt16 t)
void Debugger::log(const string& triggerMsg) void Debugger::log(const string& triggerMsg)
{ {
const CartDebug::Disassembly& disasm = myCartDebug->disassembly(); const CartDebug::Disassembly& disasm = myCartDebug->disassembly();
int pc = myCpuDebug->pc(); const int pc = myCpuDebug->pc();
if(myFirstLog) if(myFirstLog)
{ {
@ -477,9 +473,9 @@ void Debugger::log(const string& triggerMsg)
} }
// First find the lines in the range, and determine the longest string // First find the lines in the range, and determine the longest string
uInt16 start = pc & 0xFFF; const uInt16 start = pc & 0xFFF;
uInt32 list_size = uInt32(disasm.list.size()); const size_t list_size = disasm.list.size();
uInt32 pos; size_t pos = 0;
for(pos = 0; pos < list_size; ++pos) for(pos = 0; pos < list_size; ++pos)
{ {
@ -538,7 +534,8 @@ uInt8 Debugger::peek(uInt16 addr, Device::AccessFlags flags)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt16 Debugger::dpeek(uInt16 addr, Device::AccessFlags flags) uInt16 Debugger::dpeek(uInt16 addr, Device::AccessFlags flags)
{ {
return uInt16(mySystem.peek(addr, flags) | (mySystem.peek(addr+1, flags) << 8)); return static_cast<uInt16>(mySystem.peek(addr, flags) |
(mySystem.peek(addr+1, flags) << 8));
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -556,14 +553,14 @@ M6502& Debugger::m6502() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Debugger::peekAsInt(int addr, Device::AccessFlags flags) int Debugger::peekAsInt(int addr, Device::AccessFlags flags)
{ {
return mySystem.peek(uInt16(addr), flags); return mySystem.peek(static_cast<uInt16>(addr), flags);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int Debugger::dpeekAsInt(int addr, Device::AccessFlags flags) int Debugger::dpeekAsInt(int addr, Device::AccessFlags flags)
{ {
return mySystem.peek(uInt16(addr), flags) | return mySystem.peek(static_cast<uInt16>(addr), flags) |
(mySystem.peek(uInt16(addr+1), flags) << 8); (mySystem.peek(static_cast<uInt16>(addr+1), flags) << 8);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -680,8 +677,8 @@ uInt16 Debugger::windStates(uInt16 numStates, bool unwind, string& message)
unlockSystem(); unlockSystem();
uInt64 startCycles = myOSystem.console().tia().cycles(); const uInt64 startCycles = myOSystem.console().tia().cycles();
uInt16 winds = r.windStates(numStates, unwind); const uInt16 winds = r.windStates(numStates, unwind);
message = r.getUnitString(myOSystem.console().tia().cycles() - startCycles); message = r.getUnitString(myOSystem.console().tia().cycles() - startCycles);
lockSystem(); lockSystem();
@ -852,23 +849,23 @@ const Debugger::FunctionDefMap Debugger::getFunctionDefMap() const
string Debugger::builtinHelp() const string Debugger::builtinHelp() const
{ {
ostringstream buf; ostringstream buf;
uInt32 len, c_maxlen = 0, i_maxlen = 0; size_t len = 0, c_maxlen = 0, i_maxlen = 0;
// Get column widths for aligned output (functions) // Get column widths for aligned output (functions)
for(const auto& func: ourBuiltinFunctions) for(const auto& func: ourBuiltinFunctions)
{ {
len = uInt32(func.name.size()); len = func.name.size();
if(len > c_maxlen) c_maxlen = len; if(len > c_maxlen) c_maxlen = len;
len = uInt32(func.defn.size()); len = func.defn.size();
if(len > i_maxlen) i_maxlen = len; if(len > i_maxlen) i_maxlen = len;
} }
buf << std::setfill(' ') << endl << "Built-in functions:" << endl; buf << std::setfill(' ') << endl << "Built-in functions:" << endl;
for(const auto& func: ourBuiltinFunctions) for(const auto& func: ourBuiltinFunctions)
{ {
buf << std::setw(c_maxlen) << std::left << func.name buf << std::setw(static_cast<int>(c_maxlen)) << std::left << func.name
<< std::setw(2) << std::right << "{" << std::setw(2) << std::right << "{"
<< std::setw(i_maxlen) << std::left << func.defn << std::setw(static_cast<int>(i_maxlen)) << std::left << func.defn
<< std::setw(4) << "}" << std::setw(4) << "}"
<< func.help << func.help
<< endl; << endl;
@ -878,16 +875,16 @@ string Debugger::builtinHelp() const
c_maxlen = 0; c_maxlen = 0;
for(const auto& reg: ourPseudoRegisters) for(const auto& reg: ourPseudoRegisters)
{ {
len = uInt32(reg.name.size()); len = reg.name.size();
if(len > c_maxlen) c_maxlen = len; if(len > c_maxlen) c_maxlen = len;
} }
buf << endl << "Pseudo-registers:" << endl; buf << endl << "Pseudo-registers:" << endl;
for(const auto& reg: ourPseudoRegisters) for(const auto& reg: ourPseudoRegisters)
{ {
buf << std::setw(c_maxlen) << std::left << reg.name buf << std::setw(static_cast<int>(c_maxlen)) << std::left << reg.name
<< std::setw(2) << " " << std::setw(2) << " "
<< std::setw(i_maxlen) << std::left << reg.help << std::setw(static_cast<int>(i_maxlen)) << std::left << reg.help
<< endl; << endl;
} }

View File

@ -210,9 +210,9 @@ class Debugger : public DialogContainer
static uInt8 set_bit(uInt8 input, uInt8 bit, bool on) static uInt8 set_bit(uInt8 input, uInt8 bit, bool on)
{ {
if(on) if(on)
return uInt8(input | (1 << bit)); return static_cast<uInt8>(input | (1 << bit));
else else
return uInt8(input & ~(1 << bit)); return static_cast<uInt8>(input & ~(1 << bit));
} }
static void set_bits(uInt8 reg, BoolArray& bits) static void set_bits(uInt8 reg, BoolArray& bits)
{ {

View File

@ -109,7 +109,7 @@ string DebuggerParser::run(const string& command)
getArgs(command, verb); getArgs(command, verb);
commandResult.str(""); commandResult.str("");
for(int i = 0; i < int(commands.size()); ++i) for(int i = 0; i < static_cast<int>(commands.size()); ++i)
{ {
if(BSPF::equalsIgnoreCase(verb, commands[i].cmdString)) if(BSPF::equalsIgnoreCase(verb, commands[i].cmdString))
{ {
@ -193,10 +193,9 @@ void DebuggerParser::getCompletions(const char* in, StringList& completions) con
int DebuggerParser::decipher_arg(const string& str) int DebuggerParser::decipher_arg(const string& str)
{ {
bool derefByte=false, derefWord=false, lobyte=false, hibyte=false, bin=false, dec=false; bool derefByte=false, derefWord=false, lobyte=false, hibyte=false, bin=false, dec=false;
int result;
string arg = str; string arg = str;
Base::Fmt defaultBase = Base::format(); const Base::Fmt defaultBase = Base::format();
if(defaultBase == Base::Fmt::_2) { if(defaultBase == Base::Fmt::_2) {
bin=true; dec=false; bin=true; dec=false;
@ -238,6 +237,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 CpuState& state = static_cast<const CpuState&>(debugger.cpuDebug().getState());
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;
else if(arg == "y") result = state.Y; else if(arg == "y") result = state.Y;
@ -268,7 +268,7 @@ int DebuggerParser::decipher_arg(const string& str)
} else if(dec) { } else if(dec) {
result = 0; result = 0;
while(*a != '\0') { while(*a != '\0') {
int digit = (*a++) - '0'; const int digit = (*a++) - '0';
if(digit < 0 || digit > 9) if(digit < 0 || digit > 9)
return -1; return -1;
@ -278,7 +278,7 @@ int DebuggerParser::decipher_arg(const string& str)
result = 0; result = 0;
while(*a != '\0') { while(*a != '\0') {
int hex = -1; int hex = -1;
char d = *a++; const char d = *a++;
if(d >= '0' && d <= '9') hex = d - '0'; if(d >= '0' && d <= '9') hex = d - '0';
else if(d >= 'a' && d <= 'f') hex = d - 'a' + 10; else if(d >= 'a' && d <= 'f') hex = d - 'a' + 10;
else if(d >= 'A' && d <= 'F') hex = d - 'A' + 10; else if(d >= 'A' && d <= 'F') hex = d - 'A' + 10;
@ -333,7 +333,8 @@ string DebuggerParser::showWatches()
bool DebuggerParser::getArgs(const string& command, string& verb) bool DebuggerParser::getArgs(const string& command, string& verb)
{ {
ParseState state = ParseState::IN_COMMAND; ParseState state = ParseState::IN_COMMAND;
uInt32 i = 0, length = uInt32(command.length()); size_t i = 0;
const size_t length = command.length();
string curArg = ""; string curArg = "";
verb = ""; verb = "";
@ -346,7 +347,7 @@ bool DebuggerParser::getArgs(const string& command, string& verb)
// The first token is the command verb, the rest go in an array // The first token is the command verb, the rest go in an array
do do
{ {
char c = command[i++]; const char c = command[i++];
switch(state) switch(state)
{ {
case ParseState::IN_COMMAND: case ParseState::IN_COMMAND:
@ -390,7 +391,7 @@ bool DebuggerParser::getArgs(const string& command, string& verb)
if(curArg != "") if(curArg != "")
argStrings.push_back(curArg); argStrings.push_back(curArg);
argCount = uInt32(argStrings.size()); argCount = static_cast<uInt32>(argStrings.size());
for(uInt32 arg = 0; arg < argCount; ++arg) for(uInt32 arg = 0; arg < argCount; ++arg)
{ {
@ -410,7 +411,7 @@ bool DebuggerParser::getArgs(const string& command, string& verb)
bool DebuggerParser::validateArgs(int cmd) bool DebuggerParser::validateArgs(int cmd)
{ {
// cerr << "entering validateArgs(" << cmd << ")" << endl; // cerr << "entering validateArgs(" << cmd << ")" << endl;
bool required = commands[cmd].parmsRequired; const bool required = commands[cmd].parmsRequired;
Parameters* p = commands[cmd].parms.data(); Parameters* p = commands[cmd].parms.data();
if(argCount == 0) if(argCount == 0)
@ -444,8 +445,8 @@ bool DebuggerParser::validateArgs(int cmd)
if(curCount >= argCount) if(curCount >= argCount)
break; break;
uInt32 curArgInt = args[curCount]; const uInt32 curArgInt = args[curCount];
string& curArgStr = argStrings[curCount]; const string& curArgStr = argStrings[curCount];
switch(*p) switch(*p)
{ {
@ -540,8 +541,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);
bool validR = rlabel != "" && rlabel[0] != '$', const bool validR = rlabel != "" && rlabel[0] != '$',
validW = wlabel != "" && wlabel[0] != '$'; validW = wlabel != "" && wlabel[0] != '$';
if(validR && validW) if(validR && validW)
{ {
if(rlabel == wlabel) if(rlabel == wlabel)
@ -582,7 +583,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)
{ {
bool hasCond = names[i] != ""; const bool hasCond = names[i] != "";
if(hasCond == listCond) if(hasCond == listCond)
{ {
commandResult << Base::toString(i) << ": "; commandResult << Base::toString(i) << ": ";
@ -662,9 +663,9 @@ string DebuggerParser::saveScriptFile(string file)
StringList names = debugger.m6502().getCondTrapNames(); StringList names = debugger.m6502().getCondTrapNames();
for(uInt32 i = 0; i < myTraps.size(); ++i) for(uInt32 i = 0; i < myTraps.size(); ++i)
{ {
bool read = myTraps[i]->read; const bool read = myTraps[i]->read,
bool write = myTraps[i]->write; write = myTraps[i]->write,
bool hasCond = names[i] != ""; hasCond = names[i] != "";
if(read && write) if(read && write)
out << "trap"; out << "trap";
@ -736,7 +737,7 @@ void DebuggerParser::executeDirective(Device::AccessType type)
return; return;
} }
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); debugger.cartDebug().AccessTypeAsString(commandResult, type);
@ -815,14 +816,9 @@ void DebuggerParser::executeBCol()
// "break" // "break"
void DebuggerParser::executeBreak() void DebuggerParser::executeBreak()
{ {
uInt16 addr; const uInt32 romBankCount = debugger.cartDebug().romBankCount();
uInt8 bank; const uInt16 addr = (argCount == 0) ? debugger.cpuDebug().pc() : args[0];
uInt32 romBankCount = debugger.cartDebug().romBankCount(); uInt8 bank = 0;
if(argCount == 0)
addr = debugger.cpuDebug().pc();
else
addr = args[0];
if(argCount < 2) if(argCount < 2)
bank = debugger.cartDebug().getBank(addr); bank = debugger.cartDebug().getBank(addr);
@ -837,7 +833,7 @@ void DebuggerParser::executeBreak()
} }
if(bank != 0xff) if(bank != 0xff)
{ {
bool set = debugger.toggleBreakPoint(addr, bank); const bool set = debugger.toggleBreakPoint(addr, bank);
if(set) if(set)
commandResult << "set"; commandResult << "set";
@ -846,13 +842,13 @@ void DebuggerParser::executeBreak()
commandResult << " breakpoint at $" << Base::HEX4 << addr << " + mirrors"; commandResult << " breakpoint at $" << Base::HEX4 << addr << " + mirrors";
if(romBankCount > 1) if(romBankCount > 1)
commandResult << " in bank #" << std::dec << int(bank); commandResult << " in bank #" << std::dec << static_cast<int>(bank);
} }
else else
{ {
for(int i = 0; i < debugger.cartDebug().romBankCount(); ++i) for(int i = 0; i < debugger.cartDebug().romBankCount(); ++i)
{ {
bool set = debugger.toggleBreakPoint(addr, i); const bool set = debugger.toggleBreakPoint(addr, i);
if(i) if(i)
commandResult << endl; commandResult << endl;
@ -864,7 +860,7 @@ void DebuggerParser::executeBreak()
commandResult << " breakpoint at $" << Base::HEX4 << addr << " + mirrors"; commandResult << " breakpoint at $" << Base::HEX4 << addr << " + mirrors";
if(romBankCount > 1) if(romBankCount > 1)
commandResult << " in bank #" << std::dec << int(bank); commandResult << " in bank #" << std::dec << static_cast<int>(bank);
} }
} }
} }
@ -886,8 +882,8 @@ void DebuggerParser::executeBreakIf()
return; return;
} }
} }
uInt32 ret = debugger.m6502().addCondBreak( const uInt32 ret = debugger.m6502().addCondBreak(
YaccParser::getResult(), argStrings[0]); YaccParser::getResult(), argStrings[0]);
commandResult << "added breakIf " << Base::toString(ret); commandResult << "added breakIf " << Base::toString(ret);
} }
else else
@ -898,14 +894,8 @@ void DebuggerParser::executeBreakIf()
// "breakLabel" // "breakLabel"
void DebuggerParser::executeBreakLabel() void DebuggerParser::executeBreakLabel()
{ {
uInt16 addr; const uInt16 addr = (argCount == 0) ? debugger.cpuDebug().pc() : args[0];
const bool set = debugger.toggleBreakPoint(addr, BreakpointMap::ANY_BANK);
if(argCount == 0)
addr = debugger.cpuDebug().pc();
else
addr = args[0];
bool set = debugger.toggleBreakPoint(addr, BreakpointMap::ANY_BANK);
commandResult << (set ? "set" : "cleared"); commandResult << (set ? "set" : "cleared");
commandResult << " breakpoint at $" << Base::HEX4 << addr << " (no mirrors)"; commandResult << " breakpoint at $" << Base::HEX4 << addr << " (no mirrors)";
@ -1026,7 +1016,7 @@ void DebuggerParser::executeCol()
void DebuggerParser::executeColorTest() void DebuggerParser::executeColorTest()
{ {
commandResult << "test color: " commandResult << "test color: "
<< char((args[0]>>1) | 0x80) << static_cast<char>((args[0]>>1) | 0x80)
<< inverse(" "); << inverse(" ");
} }
@ -1097,7 +1087,7 @@ void DebuggerParser::executeDelSaveStateIf()
// "delTrap" // "delTrap"
void DebuggerParser::executeDelTrap() void DebuggerParser::executeDelTrap()
{ {
int index = args[0]; const int index = args[0];
if(debugger.m6502().delCondTrap(index)) if(debugger.m6502().delCondTrap(index))
{ {
@ -1115,8 +1105,8 @@ void DebuggerParser::executeDelTrap()
// "delWatch" // "delWatch"
void DebuggerParser::executeDelWatch() void DebuggerParser::executeDelWatch()
{ {
int which = args[0] - 1; const int which = args[0] - 1;
if(which >= 0 && which < int(myWatches.size())) if(which >= 0 && which < static_cast<int>(myWatches.size()))
{ {
Vec::removeAt(myWatches, which); Vec::removeAt(myWatches, which);
commandResult << "removed watch"; commandResult << "removed watch";
@ -1129,7 +1119,7 @@ void DebuggerParser::executeDelWatch()
// "disAsm" // "disAsm"
void DebuggerParser::executeDisAsm() void DebuggerParser::executeDisAsm()
{ {
int start, lines = 20; int start = 0, lines = 20;
if(argCount == 0) { if(argCount == 0) {
start = debugger.cpuDebug().pc(); start = debugger.cpuDebug().pc();
@ -1150,7 +1140,7 @@ void DebuggerParser::executeDisAsm()
// "dump" // "dump"
void DebuggerParser::executeDump() void DebuggerParser::executeDump()
{ {
auto dump = [&](ostream& os, int start, int end) const auto dump = [&](ostream& os, int start, int end)
{ {
for(int i = start; i <= end; i += 16) for(int i = start; i <= end; i += 16)
{ {
@ -1201,7 +1191,7 @@ void DebuggerParser::executeDump()
path << execPrefix; path << execPrefix;
else else
path << std::hex << std::setw(8) << std::setfill('0') path << std::hex << std::setw(8) << std::setfill('0')
<< uInt32(TimerManager::getTicks() / 1000); << static_cast<uInt32>(TimerManager::getTicks() / 1000);
path << ".dump"; path << ".dump";
commandResult << "dumped "; commandResult << "dumped ";
@ -1218,7 +1208,7 @@ void DebuggerParser::executeDump()
if((args[2] & 0x02) != 0) if((args[2] & 0x02) != 0)
{ {
// dump CPU state // dump CPU state
CpuDebug& cpu = debugger.cpuDebug(); const CpuDebug& cpu = debugger.cpuDebug();
out << " <PC>PC SP A X Y - - N V B D I Z C -\n"; out << " <PC>PC SP A X Y - - N V B D I Z C -\n";
out << "XC: " out << "XC: "
<< Base::toString(cpu.pc() & 0xff) << " " // PC lsb << Base::toString(cpu.pc() & 0xff) << " " // PC lsb
@ -1318,7 +1308,7 @@ void DebuggerParser::executeExec()
else { else {
ostringstream prefix; ostringstream prefix;
prefix << std::hex << std::setw(8) << std::setfill('0') prefix << std::hex << std::setw(8) << std::setfill('0')
<< uInt32(TimerManager::getTicks()/1000); << static_cast<uInt32>(TimerManager::getTicks()/1000);
execPrefix = prefix.str(); execPrefix = prefix.str();
} }
@ -1329,7 +1319,7 @@ void DebuggerParser::executeExec()
commandResult << exec(node, &history); commandResult << exec(node, &history);
--execDepth; --execDepth;
for(const auto& item : history) for(const auto& item: history)
debugger.prompt().addToHistory(item.c_str()); debugger.prompt().addToHistory(item.c_str());
} }
@ -1384,16 +1374,16 @@ void DebuggerParser::executeHelp()
if(argCount == 0) // normal help, show all commands if(argCount == 0) // normal help, show all commands
{ {
// Find length of longest command // Find length of longest command
uInt32 clen = 0; size_t clen = 0;
for(const auto& c: commands) for(const auto& c: commands)
{ {
uInt32 len = uInt32(c.cmdString.length()); const size_t len = c.cmdString.length();
if(len > clen) clen = len; if(len > clen) clen = len;
} }
commandResult << setfill(' '); commandResult << setfill(' ');
for(const auto& c: commands) for(const auto& c: commands)
commandResult << setw(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();
@ -1549,9 +1539,9 @@ void DebuggerParser::executeListBreaks()
{ {
stringstream buf; stringstream buf;
int count = 0; int count = 0;
uInt32 romBankCount = debugger.cartDebug().romBankCount(); const uInt32 romBankCount = debugger.cartDebug().romBankCount();
for(const auto& bp : debugger.breakPoints().getBreakpoints()) for(const auto& bp: debugger.breakPoints().getBreakpoints())
{ {
if(romBankCount == 1) if(romBankCount == 1)
{ {
@ -1564,7 +1554,7 @@ void DebuggerParser::executeListBreaks()
buf << ", "; buf << ", ";
buf << debugger.cartDebug().getLabel(bp.addr, true, 4); buf << debugger.cartDebug().getLabel(bp.addr, true, 4);
if(bp.bank != 255) if(bp.bank != 255)
buf << " #" << int(bp.bank); buf << " #" << static_cast<int>(bp.bank);
else else
buf << " *"; buf << " *";
if(!(++count % 6)) buf << endl; if(!(++count % 6)) buf << endl;
@ -1692,7 +1682,7 @@ void DebuggerParser::executeLoadState()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DebuggerParser::executeLogBreaks() void DebuggerParser::executeLogBreaks()
{ {
bool enable = !debugger.mySystem.m6502().getLogBreaks(); const bool enable = !debugger.mySystem.m6502().getLogBreaks();
debugger.mySystem.m6502().setLogBreaks(enable); debugger.mySystem.m6502().setLogBreaks(enable);
settings.setValue("dbg.logbreaks", enable); settings.setValue("dbg.logbreaks", enable);
@ -1832,7 +1822,8 @@ void DebuggerParser::executeRunTo()
debugger.saveOldState(); debugger.saveOldState();
uInt32 count = 0, max_iterations = uInt32(list.size()); size_t count = 0;
const size_t max_iterations = list.size();
// Create a progress dialog box to show the progress searching through the // Create a progress dialog box to show the progress searching through the
// disassembly, since this may be a time-consuming operation // disassembly, since this may be a time-consuming operation
@ -1842,7 +1833,7 @@ void DebuggerParser::executeRunTo()
buf << "runTo searching through " << max_iterations << " disassembled instructions" buf << "runTo searching through " << max_iterations << " disassembled instructions"
<< progress.ELLIPSIS; << progress.ELLIPSIS;
progress.setMessage(buf.str()); progress.setMessage(buf.str());
progress.setRange(0, max_iterations, 5); progress.setRange(0, static_cast<int>(max_iterations), 5);
progress.open(); progress.open();
bool done = false; bool done = false;
@ -1850,7 +1841,7 @@ void DebuggerParser::executeRunTo()
debugger.step(false); debugger.step(false);
// Update romlist to point to current PC // Update romlist to point to current PC
int pcline = cartdbg.addressToLine(debugger.cpuDebug().pc()); const int pcline = cartdbg.addressToLine(debugger.cpuDebug().pc());
if(pcline >= 0) if(pcline >= 0)
{ {
const string& next = list[pcline].disasm; const string& next = list[pcline].disasm;
@ -1897,7 +1888,7 @@ void DebuggerParser::executeRunToPc()
debugger.step(false); debugger.step(false);
// Update romlist to point to current PC // Update romlist to point to current PC
int pcline = cartdbg.addressToLine(debugger.cpuDebug().pc()); const int pcline = cartdbg.addressToLine(debugger.cpuDebug().pc());
done = (pcline >= 0) && (list[pcline].address == args[0]); done = (pcline >= 0) && (list[pcline].address == args[0]);
progress.incProgress(); progress.incProgress();
++count; ++count;
@ -2107,7 +2098,7 @@ void DebuggerParser::executeSaveStateIf()
return; return;
} }
} }
uInt32 ret = debugger.m6502().addCondSaveState( const uInt32 ret = debugger.m6502().addCondSaveState(
YaccParser::getResult(), argStrings[0]); YaccParser::getResult(), argStrings[0]);
commandResult << "added saveStateIf " << Base::toString(ret); commandResult << "added saveStateIf " << Base::toString(ret);
} }
@ -2142,7 +2133,7 @@ void DebuggerParser::executeStepWhile()
commandResult << red("invalid expression"); commandResult << red("invalid expression");
return; return;
} }
Expression* expr = YaccParser::getResult(); const Expression* expr = YaccParser::getResult();
int ncycles = 0; int ncycles = 0;
uInt32 count = 0; uInt32 count = 0;
@ -2229,7 +2220,7 @@ void DebuggerParser::executeTrapWriteIf()
void DebuggerParser::executeTraps(bool read, bool write, const string& command, void DebuggerParser::executeTraps(bool read, bool write, const string& command,
bool hasCond) bool hasCond)
{ {
uInt32 ofs = hasCond ? 1 : 0; const uInt32 ofs = hasCond ? 1 : 0;
uInt32 begin = args[ofs]; uInt32 begin = args[ofs];
uInt32 end = argCount == 2 + ofs ? args[1 + ofs] : begin; uInt32 end = argCount == 2 + ofs ? args[1 + ofs] : begin;
@ -2255,10 +2246,10 @@ void DebuggerParser::executeTraps(bool read, bool write, const string& command,
} }
// base addresses of mirrors // base addresses of mirrors
uInt32 beginRead = debugger.getBaseAddress(begin, true); const uInt32 beginRead = debugger.getBaseAddress(begin, true);
uInt32 endRead = debugger.getBaseAddress(end, true); const uInt32 endRead = debugger.getBaseAddress(end, true);
uInt32 beginWrite = debugger.getBaseAddress(begin, false); const uInt32 beginWrite = debugger.getBaseAddress(begin, false);
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)
@ -2418,7 +2409,7 @@ void DebuggerParser::executeType()
// "uHex" // "uHex"
void DebuggerParser::executeUHex() void DebuggerParser::executeUHex()
{ {
bool enable = !Base::hexUppercase(); const bool enable = !Base::hexUppercase();
Base::setHexUppercase(enable); Base::setHexUppercase(enable);
settings.setValue("dbg.uHex", enable); settings.setValue("dbg.uHex", enable);
@ -2469,16 +2460,12 @@ void DebuggerParser::executeWatch()
// wrapper function for rewind/unwind commands // wrapper function for rewind/unwind commands
void DebuggerParser::executeWinds(bool unwind) void DebuggerParser::executeWinds(bool unwind)
{ {
uInt16 states; const uInt16 states = (argCount == 0) ? 1 : args[0];
string type = unwind ? "unwind" : "rewind"; string type = unwind ? "unwind" : "rewind";
string message; string message;
if(argCount == 0) const uInt16 winds = unwind ? debugger.unwindStates(states, message)
states = 1; : debugger.rewindStates(states, message);
else
states = args[0];
uInt16 winds = unwind ? debugger.unwindStates(states, message) : debugger.rewindStates(states, message);
if(winds > 0) if(winds > 0)
{ {
debugger.rom().invalidate(); debugger.rom().invalidate();

View File

@ -35,8 +35,8 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list,
myDirectives{directives} myDirectives{directives}
{ {
bool resolve_code = mySettings.resolveCode; bool resolve_code = mySettings.resolveCode;
CartDebug::AddressList& debuggerAddresses = info.addressList; const CartDebug::AddressList& debuggerAddresses = info.addressList;
uInt16 start = *debuggerAddresses.cbegin(); const uInt16 start = *debuggerAddresses.cbegin();
myOffset = info.offset; myOffset = info.offset;
if (start & 0x1000) { if (start & 0x1000) {
@ -104,10 +104,10 @@ void DiStella::disasm(uInt32 distart, int pass)
#define LABEL_A12_HIGH(address) labelA12High(nextLine, opcode, address, labelFound) #define LABEL_A12_HIGH(address) labelA12High(nextLine, opcode, address, labelFound)
#define LABEL_A12_LOW(address) labelA12Low(nextLine, opcode, address, labelFound) #define LABEL_A12_LOW(address) labelA12Low(nextLine, opcode, address, labelFound)
uInt8 opcode, d1; uInt8 opcode = 0, d1 = 0;
uInt16 ad; uInt16 ad = 0;
Int32 cycles = 0; Int32 cycles = 0;
AddressingMode addrMode; AddressingMode addrMode{};
AddressType labelFound = AddressType::INVALID; AddressType labelFound = AddressType::INVALID;
stringstream nextLine, nextLineBytes; stringstream nextLine, nextLineBytes;
@ -209,7 +209,7 @@ void DiStella::disasm(uInt32 distart, int pass)
// detect labels inside instructions (e.g. BIT masks) // detect labels inside instructions (e.g. BIT masks)
labelFound = AddressType::INVALID; labelFound = AddressType::INVALID;
for(Uint8 i = 0; i < ourLookup[opcode].bytes - 1; i++) { for(uInt8 i = 0; i < ourLookup[opcode].bytes - 1; i++) {
if(checkBit(myPC + i, Device::REFERENCED)) { if(checkBit(myPC + i, Device::REFERENCED)) {
labelFound = AddressType::ROM; labelFound = AddressType::ROM;
break; break;
@ -220,15 +220,16 @@ void DiStella::disasm(uInt32 distart, int pass)
// the opcode's operand address matches a label address // the opcode's operand address matches a label address
if(pass == 3) { if(pass == 3) {
// output the byte of the opcode incl. cycles // output the byte of the opcode incl. cycles
Uint8 nextOpcode = Debugger::debugger().peek(myPC + myOffset); const uInt8 nextOpcode = Debugger::debugger().peek(myPC + myOffset);
cycles += int(ourLookup[opcode].cycles) - int(ourLookup[nextOpcode].cycles); cycles += static_cast<int>(ourLookup[opcode].cycles) -
nextLine << ".byte $" << Base::HEX2 << int(opcode) << " ;"; static_cast<int>(ourLookup[nextOpcode].cycles);
nextLine << ".byte $" << Base::HEX2 << static_cast<int>(opcode) << " ;";
nextLine << ourLookup[opcode].mnemonic; nextLine << ourLookup[opcode].mnemonic;
myDisasmBuf << nextLine.str() << "'" << ";" myDisasmBuf << nextLine.str() << "'" << ";"
<< std::dec << int(ourLookup[opcode].cycles) << "-" << std::dec << static_cast<int>(ourLookup[opcode].cycles) << "-"
<< std::dec << int(ourLookup[nextOpcode].cycles) << " " << std::dec << static_cast<int>(ourLookup[nextOpcode].cycles) << " "
<< "'= " << std::setw(3) << std::setfill(' ') << std::dec << cycles; << "'= " << std::setw(3) << std::setfill(' ') << std::dec << cycles;
nextLine.str(""); nextLine.str("");
@ -248,12 +249,12 @@ void DiStella::disasm(uInt32 distart, int pass)
// Undefined opcodes start with a '.' // Undefined opcodes start with a '.'
// These are undefined wrt DASM // These are undefined wrt DASM
if(ourLookup[opcode].mnemonic[0] == '.' && pass == 3) { if(ourLookup[opcode].mnemonic[0] == '.' && pass == 3) {
nextLine << ".byte $" << Base::HEX2 << int(opcode) << " ;"; nextLine << ".byte $" << Base::HEX2 << static_cast<int>(opcode) << " ;";
} }
if(pass == 3) { if(pass == 3) {
nextLine << ourLookup[opcode].mnemonic; nextLine << ourLookup[opcode].mnemonic;
nextLineBytes << Base::HEX2 << int(opcode) << " "; nextLineBytes << Base::HEX2 << static_cast<int>(opcode) << " ";
} }
// Add operand(s) for PC values outside the app data range // Add operand(s) for PC values outside the app data range
@ -270,9 +271,9 @@ void DiStella::disasm(uInt32 distart, int pass)
/* Line information is already printed; append .byte since last /* Line information is already printed; append .byte since last
instruction will put recompilable object larger that original instruction will put recompilable object larger that original
binary file */ binary file */
myDisasmBuf << ".byte $" << Base::HEX2 << int(opcode) << " $" myDisasmBuf << ".byte $" << Base::HEX2 << static_cast<int>(opcode) << " $"
<< Base::HEX4 << myPC + myOffset << "'" << Base::HEX4 << myPC + myOffset << "'"
<< Base::HEX2 << int(opcode); << Base::HEX2 << static_cast<int>(opcode);
addEntry(Device::DATA); addEntry(Device::DATA);
if(myPC == myAppData.end) { if(myPC == myAppData.end) {
@ -282,9 +283,9 @@ void DiStella::disasm(uInt32 distart, int pass)
myDisasmBuf << Base::HEX4 << myPC + myOffset << "' '"; myDisasmBuf << Base::HEX4 << myPC + myOffset << "' '";
opcode = Debugger::debugger().peek(myPC + myOffset); ++myPC; opcode = Debugger::debugger().peek(myPC + myOffset); ++myPC;
myDisasmBuf << ".byte $" << Base::HEX2 << int(opcode) << " $" myDisasmBuf << ".byte $" << Base::HEX2 << static_cast<int>(opcode) << " $"
<< Base::HEX4 << myPC + myOffset << "'" << Base::HEX4 << myPC + myOffset << "'"
<< Base::HEX2 << int(opcode); << Base::HEX2 << static_cast<int>(opcode);
addEntry(Device::DATA); addEntry(Device::DATA);
} }
} }
@ -301,7 +302,7 @@ void DiStella::disasm(uInt32 distart, int pass)
if(pass == 3) { if(pass == 3) {
/* Line information is already printed, but we can remove the /* Line information is already printed, but we can remove the
Instruction (i.e. BMI) by simply clearing the buffer to print */ Instruction (i.e. BMI) by simply clearing the buffer to print */
myDisasmBuf << ".byte $" << Base::HEX2 << int(opcode); myDisasmBuf << ".byte $" << Base::HEX2 << static_cast<int>(opcode);
addEntry(Device::ROW); addEntry(Device::ROW);
nextLine.str(""); nextLine.str("");
nextLineBytes.str(""); nextLineBytes.str("");
@ -339,22 +340,26 @@ void DiStella::disasm(uInt32 distart, int pass)
if(labelFound == AddressType::ROM) { if(labelFound == AddressType::ROM) {
LABEL_A12_HIGH(ad); LABEL_A12_HIGH(ad);
nextLineBytes << Base::HEX2 << int(ad & 0xff) << " " << Base::HEX2 << int(ad >> 8); nextLineBytes << Base::HEX2 << static_cast<int>(ad & 0xff) << " "
<< Base::HEX2 << static_cast<int>(ad >> 8);
} }
else if(labelFound == AddressType::ROM_MIRROR) { else if(labelFound == AddressType::ROM_MIRROR) {
if(mySettings.rFlag) { if(mySettings.rFlag) {
int tmp = (ad & myAppData.end) + myOffset; const int tmp = (ad & myAppData.end) + myOffset;
LABEL_A12_HIGH(tmp); LABEL_A12_HIGH(tmp);
nextLineBytes << Base::HEX2 << int(tmp & 0xff) << " " << Base::HEX2 << int(tmp >> 8); nextLineBytes << Base::HEX2 << static_cast<int>(tmp & 0xff) << " "
<< Base::HEX2 << static_cast<int>(tmp >> 8);
} }
else { else {
nextLine << "$" << Base::HEX4 << ad; nextLine << "$" << Base::HEX4 << ad;
nextLineBytes << Base::HEX2 << int(ad & 0xff) << " " << Base::HEX2 << int(ad >> 8); nextLineBytes << Base::HEX2 << static_cast<int>(ad & 0xff) << " "
<< Base::HEX2 << static_cast<int>(ad >> 8);
} }
} }
else { else {
LABEL_A12_LOW(ad); LABEL_A12_LOW(ad);
nextLineBytes << Base::HEX2 << int(ad & 0xff) << " " << Base::HEX2 << int(ad >> 8); nextLineBytes << Base::HEX2 << static_cast<int>(ad & 0xff) << " "
<< Base::HEX2 << static_cast<int>(ad >> 8);
} }
} }
break; break;
@ -367,7 +372,7 @@ void DiStella::disasm(uInt32 distart, int pass)
if(pass == 3) { if(pass == 3) {
nextLine << " "; nextLine << " ";
LABEL_A12_LOW(int(d1)); LABEL_A12_LOW(int(d1));
nextLineBytes << Base::HEX2 << int(d1); nextLineBytes << Base::HEX2 << static_cast<int>(d1);
} }
break; break;
} }
@ -376,8 +381,8 @@ void DiStella::disasm(uInt32 distart, int pass)
{ {
d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC;
if(pass == 3) { if(pass == 3) {
nextLine << " #$" << Base::HEX2 << int(d1) << " "; nextLine << " #$" << Base::HEX2 << static_cast<int>(d1) << " ";
nextLineBytes << Base::HEX2 << int(d1); nextLineBytes << Base::HEX2 << static_cast<int>(d1);
} }
break; break;
} }
@ -402,24 +407,28 @@ void DiStella::disasm(uInt32 distart, int pass)
if(labelFound == AddressType::ROM) { if(labelFound == AddressType::ROM) {
LABEL_A12_HIGH(ad); LABEL_A12_HIGH(ad);
nextLine << ",x"; nextLine << ",x";
nextLineBytes << Base::HEX2 << int(ad & 0xff) << " " << Base::HEX2 << int(ad >> 8); nextLineBytes << Base::HEX2 << static_cast<int>(ad & 0xff) << " "
<< Base::HEX2 << static_cast<int>(ad >> 8);
} }
else if(labelFound == AddressType::ROM_MIRROR) { else if(labelFound == AddressType::ROM_MIRROR) {
if(mySettings.rFlag) { if(mySettings.rFlag) {
int tmp = (ad & myAppData.end) + myOffset; const int tmp = (ad & myAppData.end) + myOffset;
LABEL_A12_HIGH(tmp); LABEL_A12_HIGH(tmp);
nextLine << ",x"; nextLine << ",x";
nextLineBytes << Base::HEX2 << int(tmp & 0xff) << " " << Base::HEX2 << int(tmp >> 8); nextLineBytes << Base::HEX2 << static_cast<int>(tmp & 0xff) << " "
<< Base::HEX2 << static_cast<int>(tmp >> 8);
} }
else { else {
nextLine << "$" << Base::HEX4 << ad << ",x"; nextLine << "$" << Base::HEX4 << ad << ",x";
nextLineBytes << Base::HEX2 << int(ad & 0xff) << " " << Base::HEX2 << int(ad >> 8); nextLineBytes << Base::HEX2 << static_cast<int>(ad & 0xff) << " "
<< Base::HEX2 << static_cast<int>(ad >> 8);
} }
} }
else { else {
LABEL_A12_LOW(ad); LABEL_A12_LOW(ad);
nextLine << ",x"; nextLine << ",x";
nextLineBytes << Base::HEX2 << int(ad & 0xff) << " " << Base::HEX2 << int(ad >> 8); nextLineBytes << Base::HEX2 << static_cast<int>(ad & 0xff) << " "
<< Base::HEX2 << static_cast<int>(ad >> 8);
} }
} }
break; break;
@ -445,24 +454,28 @@ void DiStella::disasm(uInt32 distart, int pass)
if(labelFound == AddressType::ROM) { if(labelFound == AddressType::ROM) {
LABEL_A12_HIGH(ad); LABEL_A12_HIGH(ad);
nextLine << ",y"; nextLine << ",y";
nextLineBytes << Base::HEX2 << int(ad & 0xff) << " " << Base::HEX2 << int(ad >> 8); nextLineBytes << Base::HEX2 << static_cast<int>(ad & 0xff) << " "
<< Base::HEX2 << static_cast<int>(ad >> 8);
} }
else if(labelFound == AddressType::ROM_MIRROR) { else if(labelFound == AddressType::ROM_MIRROR) {
if(mySettings.rFlag) { if(mySettings.rFlag) {
int tmp = (ad & myAppData.end) + myOffset; const int tmp = (ad & myAppData.end) + myOffset;
LABEL_A12_HIGH(tmp); LABEL_A12_HIGH(tmp);
nextLine << ",y"; nextLine << ",y";
nextLineBytes << Base::HEX2 << int(tmp & 0xff) << " " << Base::HEX2 << int(tmp >> 8); nextLineBytes << Base::HEX2 << static_cast<int>(tmp & 0xff) << " "
<< Base::HEX2 << static_cast<int>(tmp >> 8);
} }
else { else {
nextLine << "$" << Base::HEX4 << ad << ",y"; nextLine << "$" << Base::HEX4 << ad << ",y";
nextLineBytes << Base::HEX2 << int(ad & 0xff) << " " << Base::HEX2 << int(ad >> 8); nextLineBytes << Base::HEX2 << static_cast<int>(ad & 0xff) << " "
<< Base::HEX2 << static_cast<int>(ad >> 8);
} }
} }
else { else {
LABEL_A12_LOW(ad); LABEL_A12_LOW(ad);
nextLine << ",y"; nextLine << ",y";
nextLineBytes << Base::HEX2 << int(ad & 0xff) << " " << Base::HEX2 << int(ad >> 8); nextLineBytes << Base::HEX2 << static_cast<int>(ad & 0xff) << " "
<< Base::HEX2 << static_cast<int>(ad >> 8);
} }
} }
break; break;
@ -476,7 +489,7 @@ void DiStella::disasm(uInt32 distart, int pass)
nextLine << " ("; nextLine << " (";
LABEL_A12_LOW(d1); LABEL_A12_LOW(d1);
nextLine << ",x)"; nextLine << ",x)";
nextLineBytes << Base::HEX2 << int(d1); nextLineBytes << Base::HEX2 << static_cast<int>(d1);
} }
break; break;
} }
@ -489,7 +502,7 @@ void DiStella::disasm(uInt32 distart, int pass)
nextLine << " ("; nextLine << " (";
LABEL_A12_LOW(d1); LABEL_A12_LOW(d1);
nextLine << "),y"; nextLine << "),y";
nextLineBytes << Base::HEX2 << int(d1); nextLineBytes << Base::HEX2 << static_cast<int>(d1);
} }
break; break;
} }
@ -503,7 +516,7 @@ void DiStella::disasm(uInt32 distart, int pass)
LABEL_A12_LOW(d1); LABEL_A12_LOW(d1);
nextLine << ",x"; nextLine << ",x";
} }
nextLineBytes << Base::HEX2 << int(d1); nextLineBytes << Base::HEX2 << static_cast<int>(d1);
break; break;
} }
@ -516,7 +529,7 @@ void DiStella::disasm(uInt32 distart, int pass)
LABEL_A12_LOW(d1); LABEL_A12_LOW(d1);
nextLine << ",y"; nextLine << ",y";
} }
nextLineBytes << Base::HEX2 << int(d1); nextLineBytes << Base::HEX2 << static_cast<int>(d1);
break; break;
} }
@ -526,7 +539,7 @@ void DiStella::disasm(uInt32 distart, int pass)
// where wraparound occurred on a 32-bit int, and subsequent // where wraparound occurred on a 32-bit int, and subsequent
// indexing into the labels array caused a crash // indexing into the labels array caused a crash
d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC;
ad = ((myPC + Int8(d1)) & 0xfff) + myOffset; ad = ((myPC + static_cast<Int8>(d1)) & 0xfff) + myOffset;
labelFound = mark(ad, Device::REFERENCED); labelFound = mark(ad, Device::REFERENCED);
if(pass == 3) { if(pass == 3) {
@ -537,7 +550,7 @@ void DiStella::disasm(uInt32 distart, int pass)
else else
nextLine << " $" << Base::HEX4 << ad; nextLine << " $" << Base::HEX4 << ad;
nextLineBytes << Base::HEX2 << int(d1); nextLineBytes << Base::HEX2 << static_cast<int>(d1);
} }
break; break;
} }
@ -567,7 +580,7 @@ void DiStella::disasm(uInt32 distart, int pass)
else if(labelFound == AddressType::ROM_MIRROR) { else if(labelFound == AddressType::ROM_MIRROR) {
nextLine << "("; nextLine << "(";
if(mySettings.rFlag) { if(mySettings.rFlag) {
int tmp = (ad & myAppData.end) + myOffset; const int tmp = (ad & myAppData.end) + myOffset;
LABEL_A12_HIGH(tmp); LABEL_A12_HIGH(tmp);
} }
else { else {
@ -581,7 +594,8 @@ void DiStella::disasm(uInt32 distart, int pass)
nextLine << ")"; nextLine << ")";
} }
nextLineBytes << Base::HEX2 << int(ad & 0xff) << " " << Base::HEX2 << int(ad >> 8); nextLineBytes << Base::HEX2 << static_cast<int>(ad & 0xff) << " "
<< Base::HEX2 << static_cast<int>(ad >> 8);
break; break;
} }
@ -590,10 +604,10 @@ void DiStella::disasm(uInt32 distart, int pass)
} // end switch } // end switch
if(pass == 3) { if(pass == 3) {
cycles += int(ourLookup[opcode].cycles); cycles += static_cast<int>(ourLookup[opcode].cycles);
// A complete line of disassembly (text, cycle count, and bytes) // A complete line of disassembly (text, cycle count, and bytes)
myDisasmBuf << nextLine.str() << "'" myDisasmBuf << nextLine.str() << "'"
<< ";" << std::dec << int(ourLookup[opcode].cycles) << ";" << std::dec << static_cast<int>(ourLookup[opcode].cycles)
<< (addrMode == AddressingMode::RELATIVE ? (ad & 0xf00) != ((myPC + myOffset) & 0xf00) ? "/3!" : "/3 " : " "); << (addrMode == AddressingMode::RELATIVE ? (ad & 0xf00) != ((myPC + myOffset) & 0xf00) ? "/3!" : "/3 " : " ");
if((opcode == 0x40 || opcode == 0x60 || opcode == 0x4c || opcode == 0x00 // code block end if((opcode == 0x40 || opcode == 0x60 || opcode == 0x4c || opcode == 0x00 // code block end
|| checkBit(myPC, Device::REFERENCED) // referenced address || checkBit(myPC, Device::REFERENCED) // referenced address
@ -629,7 +643,7 @@ void DiStella::disasm(uInt32 distart, int pass)
void DiStella::disasmPass1(CartDebug::AddressList& debuggerAddresses) void DiStella::disasmPass1(CartDebug::AddressList& debuggerAddresses)
{ {
auto it = debuggerAddresses.cbegin(); auto it = debuggerAddresses.cbegin();
uInt16 start = *it++; const uInt16 start = *it++;
// After we've disassembled from all addresses in the address list, // After we've disassembled from all addresses in the address list,
// use all access points determined by Stella during emulation // use all access points determined by Stella during emulation
@ -647,7 +661,7 @@ void DiStella::disasmPass1(CartDebug::AddressList& debuggerAddresses)
myAddressQueue.push(start); myAddressQueue.push(start);
while (!(myAddressQueue.empty() || duplicateFound)) { while (!(myAddressQueue.empty() || duplicateFound)) {
uInt16 pcBeg = myPC = lastPC = myAddressQueue.front(); const uInt16 pcBeg = myPC = lastPC = myAddressQueue.front();
myAddressQueue.pop(); myAddressQueue.pop();
disasmFromAddress(myPC); disasmFromAddress(myPC);
@ -691,7 +705,7 @@ void DiStella::disasmPass1(CartDebug::AddressList& debuggerAddresses)
// the ::disasm method // the ::disasm method
// All of these have to be exhausted before considering a new address // All of these have to be exhausted before considering a new address
while (myAddressQueue.empty() && it != debuggerAddresses.end()) { while (myAddressQueue.empty() && it != debuggerAddresses.end()) {
uInt16 addr = *it; const uInt16 addr = *it;
if (!checkBit(addr - myOffset, Device::CODE)) { if (!checkBit(addr - myOffset, Device::CODE)) {
myAddressQueue.push(addr); myAddressQueue.push(addr);
@ -733,9 +747,9 @@ void DiStella::disasmPass1(CartDebug::AddressList& debuggerAddresses)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DiStella::disasmFromAddress(uInt32 distart) void DiStella::disasmFromAddress(uInt32 distart)
{ {
uInt8 opcode, d1; uInt8 opcode = 0, d1 = 0;
uInt16 ad; uInt16 ad = 0;
AddressingMode addrMode; AddressingMode addrMode{};
myPC = distart - myOffset; myPC = distart - myOffset;
@ -843,7 +857,7 @@ void DiStella::disasmFromAddress(uInt32 distart)
// where wraparound occurred on a 32-bit int, and subsequent // where wraparound occurred on a 32-bit int, and subsequent
// indexing into the labels array caused a crash // indexing into the labels array caused a crash
d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC; d1 = Debugger::debugger().peek(myPC + myOffset); ++myPC;
ad = ((myPC + Int8(d1)) & 0xfff) + myOffset; ad = ((myPC + static_cast<Int8>(d1)) & 0xfff) + myOffset;
mark(ad, Device::REFERENCED); mark(ad, Device::REFERENCED);
// do NOT use flags set by debugger, else known CODE will not analyzed statically. // do NOT use flags set by debugger, else known CODE will not analyzed statically.
if (!checkBit(ad - myOffset, Device::CODE, false)) { if (!checkBit(ad - myOffset, Device::CODE, false)) {
@ -933,7 +947,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
CartDebug::AddrType type = myDbg.addressType(address); const CartDebug::AddrType type = myDbg.addressType(address);
if(type == CartDebug::AddrType::TIA) { if(type == CartDebug::AddrType::TIA) {
return AddressType::TIA; return AddressType::TIA;
} }
@ -943,7 +957,8 @@ DiStella::AddressType DiStella::mark(uInt32 address, uInt16 mask, bool directive
else if(type == CartDebug::AddrType::ZPRAM && myOffset != 0) { else if(type == CartDebug::AddrType::ZPRAM && myOffset != 0) {
return AddressType::ZP_RAM; return AddressType::ZP_RAM;
} }
else if(address >= uInt32(myOffset) && address <= uInt32(myAppData.end + myOffset)) { else if(address >= static_cast<uInt32>(myOffset) &&
address <= static_cast<uInt32>(myAppData.end + myOffset)) {
myLabels[address - myOffset] = myLabels[address - myOffset] | mask; myLabels[address - myOffset] = myLabels[address - myOffset] | mask;
if(directive) if(directive)
myDirectives[address - myOffset] = mask; myDirectives[address - myOffset] = mask;
@ -968,7 +983,7 @@ bool DiStella::checkBit(uInt16 address, uInt16 mask, bool useDebugger) const
// an address // an address
// Since they're set only in the labels array (as the lower two bits), // Since they're set only in the labels array (as the lower two bits),
// they must be included in the other bitfields // they must be included in the other bitfields
uInt16 label = myLabels[address & myAppData.end], const uInt16 label = myLabels[address & myAppData.end],
lastbits = label & (Device::REFERENCED | Device::VALID_ENTRY), lastbits = label & (Device::REFERENCED | Device::VALID_ENTRY),
directive = myDirectives[address & myAppData.end] & ~(Device::REFERENCED | Device::VALID_ENTRY), directive = myDirectives[address & myAppData.end] & ~(Device::REFERENCED | Device::VALID_ENTRY),
debugger = Debugger::debugger().getAccessFlags(address | myOffset) & ~(Device::REFERENCED | Device::VALID_ENTRY); debugger = Debugger::debugger().getAccessFlags(address | myOffset) & ~(Device::REFERENCED | Device::VALID_ENTRY);
@ -1097,9 +1112,9 @@ DONE_WITH_ADD:
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void DiStella::outputGraphics() void DiStella::outputGraphics()
{ {
bool isPGfx = checkBit(myPC, Device::PGFX); const bool isPGfx = checkBit(myPC, Device::PGFX);
const string& bitString = isPGfx ? "\x1f" : "\x1e"; const string& bitString = isPGfx ? "\x1f" : "\x1e";
uInt8 byte = Debugger::debugger().peek(myPC + myOffset); const uInt8 byte = Debugger::debugger().peek(myPC + myOffset);
// add extra spacing line when switching from non-graphics to graphics // add extra spacing line when switching from non-graphics to graphics
if (mySegType != Device::GFX && mySegType != Device::NONE) { if (mySegType != Device::GFX && mySegType != Device::NONE) {
@ -1112,14 +1127,14 @@ void DiStella::outputGraphics()
myDisasmBuf << Base::HEX4 << myPC + myOffset << "'L" << Base::HEX4 << myPC + myOffset << "'"; myDisasmBuf << Base::HEX4 << myPC + myOffset << "'L" << Base::HEX4 << myPC + myOffset << "'";
else else
myDisasmBuf << Base::HEX4 << myPC + myOffset << "' '"; myDisasmBuf << Base::HEX4 << myPC + myOffset << "' '";
myDisasmBuf << ".byte $" << Base::HEX2 << int(byte) << " |"; myDisasmBuf << ".byte $" << Base::HEX2 << static_cast<int>(byte) << " |";
for (uInt8 i = 0, c = byte; i < 8; ++i, c <<= 1) for (uInt8 i = 0, c = byte; i < 8; ++i, c <<= 1)
myDisasmBuf << ((c > 127) ? bitString : " "); myDisasmBuf << ((c > 127) ? bitString : " ");
myDisasmBuf << "| $" << Base::HEX4 << myPC + myOffset << "'"; myDisasmBuf << "| $" << Base::HEX4 << myPC + myOffset << "'";
if (mySettings.gfxFormat == Base::Fmt::_2) if (mySettings.gfxFormat == Base::Fmt::_2)
myDisasmBuf << Base::toString(byte, Base::Fmt::_2_8); myDisasmBuf << Base::toString(byte, Base::Fmt::_2_8);
else else
myDisasmBuf << Base::HEX2 << int(byte); myDisasmBuf << Base::HEX2 << static_cast<int>(byte);
addEntry(isPGfx ? Device::PGFX : Device::GFX); addEntry(isPGfx ? Device::PGFX : Device::GFX);
} }
@ -1144,7 +1159,7 @@ void DiStella::outputColors()
"GREEN", "CYAN", "YELLOW", "WHITE" "GREEN", "CYAN", "YELLOW", "WHITE"
}; };
uInt8 byte = Debugger::debugger().peek(myPC + myOffset); const uInt8 byte = Debugger::debugger().peek(myPC + myOffset);
// add extra spacing line when switching from non-colors to colors // add extra spacing line when switching from non-colors to colors
if(mySegType != Device::COL && mySegType != Device::NONE) if(mySegType != Device::COL && mySegType != Device::NONE)
@ -1179,14 +1194,14 @@ void DiStella::outputColors()
color = SECAM_COLOR[(byte >> 1) & 0x7]; color = SECAM_COLOR[(byte >> 1) & 0x7];
myDisasmBuf << "$" << Base::HEX1 << (byte >> 4) << "|" << color; myDisasmBuf << "$" << Base::HEX1 << (byte >> 4) << "|" << color;
} }
myDisasmBuf << std::setw(int(16 - color.length())) << std::setfill(' '); myDisasmBuf << std::setw(static_cast<int>(16 - color.length())) << std::setfill(' ');
// output address // output address
myDisasmBuf << "; $" << Base::HEX4 << myPC + myOffset << " " myDisasmBuf << "; $" << Base::HEX4 << myPC + myOffset << " "
<< (checkBit(myPC, Device::COL) ? "(Px)" : checkBit(myPC, Device::PCOL) ? "(PF)" : "(BK)"); << (checkBit(myPC, Device::COL) ? "(Px)" : checkBit(myPC, Device::PCOL) ? "(PF)" : "(BK)");
// output color value // output color value
myDisasmBuf << "'" << Base::HEX2 << int(byte); myDisasmBuf << "'" << Base::HEX2 << static_cast<int>(byte);
addEntry(checkBit(myPC, Device::COL) ? Device::COL : addEntry(checkBit(myPC, Device::COL) ? Device::COL :
checkBit(myPC, Device::PCOL) ? Device::PCOL : Device::BCOL); checkBit(myPC, Device::PCOL) ? Device::PCOL : Device::BCOL);
@ -1215,14 +1230,14 @@ void DiStella::outputBytes(Device::AccessType type)
myDisasmBuf << Base::HEX4 << myPC + myOffset << "'L" << Base::HEX4 myDisasmBuf << Base::HEX4 << myPC + myOffset << "'L" << Base::HEX4
<< myPC + myOffset << "'.byte " << "$" << Base::HEX2 << myPC + myOffset << "'.byte " << "$" << Base::HEX2
<< int(Debugger::debugger().peek(myPC + myOffset)); << static_cast<int>(Debugger::debugger().peek(myPC + myOffset));
++myPC; ++myPC;
numBytes = 1; numBytes = 1;
lineEmpty = false; lineEmpty = false;
} else if (lineEmpty) { } else if (lineEmpty) {
// start a new line without a label // start a new line without a label
myDisasmBuf << Base::HEX4 << myPC + myOffset << "' '" myDisasmBuf << Base::HEX4 << myPC + myOffset << "' '"
<< ".byte $" << Base::HEX2 << int(Debugger::debugger().peek(myPC + myOffset)); << ".byte $" << Base::HEX2 << static_cast<int>(Debugger::debugger().peek(myPC + myOffset));
++myPC; ++myPC;
numBytes = 1; numBytes = 1;
lineEmpty = false; lineEmpty = false;
@ -1232,7 +1247,7 @@ void DiStella::outputBytes(Device::AccessType type)
addEntry(type); addEntry(type);
lineEmpty = true; lineEmpty = true;
} else { } else {
myDisasmBuf << ",$" << Base::HEX2 << int(Debugger::debugger().peek(myPC + myOffset)); myDisasmBuf << ",$" << Base::HEX2 << static_cast<int>(Debugger::debugger().peek(myPC + myOffset));
++myPC; ++myPC;
} }
isType = checkBits(myPC, type, isType = checkBits(myPC, type,

View File

@ -310,7 +310,7 @@ bool RiotDebug::reset(int newVal)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string RiotDebug::dirP0String() string RiotDebug::dirP0String()
{ {
uInt8 reg = swcha(); const uInt8 reg = swcha();
ostringstream buf; ostringstream buf;
buf << ((reg & 0x80) ? "" : "right ") buf << ((reg & 0x80) ? "" : "right ")
<< ((reg & 0x40) ? "" : "left ") << ((reg & 0x40) ? "" : "left ")
@ -323,7 +323,7 @@ string RiotDebug::dirP0String()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string RiotDebug::dirP1String() string RiotDebug::dirP1String()
{ {
uInt8 reg = swcha(); const uInt8 reg = swcha();
ostringstream buf; ostringstream buf;
buf << ((reg & 0x08) ? "" : "right ") buf << ((reg & 0x08) ? "" : "right ")
<< ((reg & 0x04) ? "" : "left ") << ((reg & 0x04) ? "" : "left ")

View File

@ -85,8 +85,8 @@ class RiotDebug : public DebuggerSystem
int timWrappedOnWrite() const; int timWrappedOnWrite() const;
int timReadCycles() const; int timReadCycles() const;
int timintAsInt() const { return int(timint()); } // so we can use _timInt pseudo-register int timintAsInt() const { return static_cast<int>(timint()); } // so we can use _timInt pseudo-register
int intimAsInt() const { return 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 diffP0(int newVal = -1); bool diffP0(int newVal = -1);

View File

@ -42,7 +42,7 @@ const DebuggerState& TIADebug::getState()
myState.coluRegs.push_back(coluBK()); myState.coluRegs.push_back(coluBK());
// Debug Colors // Debug Colors
int timing = myConsole.timing() == ConsoleTiming::ntsc ? 0 const int timing = myConsole.timing() == ConsoleTiming::ntsc ? 0
: myConsole.timing() == ConsoleTiming::pal ? 1 : 2; : myConsole.timing() == ConsoleTiming::pal ? 1 : 2;
myState.fixedCols.clear(); myState.fixedCols.clear();
@ -925,13 +925,13 @@ int TIADebug::frameWsyncCycles() const
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int TIADebug::cyclesLo() const int TIADebug::cyclesLo() const
{ {
return int(myTIA.cycles()); return static_cast<int>(myTIA.cycles());
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
int TIADebug::cyclesHi() const int TIADebug::cyclesHi() const
{ {
return int(myTIA.cycles() >> 32); return static_cast<int>(myTIA.cycles() >> 32);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -999,7 +999,7 @@ string TIADebug::colorSwatch(uInt8 c) const
{ {
string ret; string ret;
ret += char((c >> 1) | 0x80); ret += static_cast<char>((c >> 1) | 0x80);
ret += "\177 "; ret += "\177 ";
ret += "\177\001 "; ret += "\177\001 ";
@ -1021,7 +1021,7 @@ string TIADebug::audFreq1()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string TIADebug::audFreq(uInt8 dist, uInt8 div) string TIADebug::audFreq(uInt8 dist, uInt8 div)
{ {
uInt16 dist_div[16] = { constexpr uInt16 dist_div[16] = {
1, 15, 465, 465, 2, 2, 31, 31, 1, 15, 465, 465, 2, 2, 31, 31,
511, 31, 31, 1, 6, 6, 93, 93 511, 31, 31, 1, 6, 6, 93, 93
}; };
@ -1044,7 +1044,8 @@ string TIADebug::stringOnly(string value, bool changed)
buf << value; buf << value;
if(changed) if(changed)
return char(kDbgColorRed & 0xff) + buf.str() + char(kTextColor & 0xff); return static_cast<char>(kDbgColorRed & 0xff) + buf.str() +
static_cast<char>(kTextColor & 0xff);
else else
return buf.str(); return buf.str();
} }
@ -1060,7 +1061,8 @@ string TIADebug::decWithLabel(string label, uInt16 value, bool changed, uInt16 w
buf << "#" << std::setw(width) << std::dec << std::left << value; buf << "#" << std::setw(width) << std::dec << std::left << value;
if(changed) if(changed)
return char(kDbgColorRed & 0xff) + buf.str() + char(kTextColor & 0xff); return static_cast<char>(kDbgColorRed & 0xff) + buf.str() +
static_cast<char>(kTextColor & 0xff);
else else
return buf.str(); return buf.str();
} }
@ -1076,7 +1078,8 @@ string TIADebug::hexWithLabel(string label, uInt16 value, bool changed, uInt16 w
buf << "$" << (width == 1 ? Common::Base::HEX1 : Common::Base::HEX2) << value; buf << "$" << (width == 1 ? Common::Base::HEX1 : Common::Base::HEX2) << value;
if(changed) if(changed)
return char(kDbgColorRed & 0xff) + buf.str() + char(kTextColor & 0xff); return static_cast<char>(kDbgColorRed & 0xff) + buf.str() +
static_cast<char>(kTextColor & 0xff);
else else
return buf.str(); return buf.str();
} }
@ -1092,7 +1095,8 @@ string TIADebug::binWithLabel(string label, uInt16 value, bool changed)
buf << "%" << Common::Base::toString(value, Common::Base::Fmt::_2_8); buf << "%" << Common::Base::toString(value, Common::Base::Fmt::_2_8);
if(changed) if(changed)
return char(kDbgColorRed & 0xff) + buf.str() + char(kTextColor & 0xff); return static_cast<char>(kDbgColorRed & 0xff) + buf.str() +
static_cast<char>(kTextColor & 0xff);
else else
return buf.str(); return buf.str();
} }
@ -1110,7 +1114,8 @@ string TIADebug::boolWithLabel(string label, bool value, bool changed)
//return "-" + BSPF::toLowerCase(label); //return "-" + BSPF::toLowerCase(label);
if(changed) if(changed)
return char(kDbgColorRed & 0xff) + buf.str() + char(kTextColor & 0xff); return static_cast<char>(kDbgColorRed & 0xff) + buf.str() +
static_cast<char>(kTextColor & 0xff);
else else
return buf.str(); return buf.str();
} }
@ -1120,7 +1125,7 @@ string TIADebug::debugColors() const
{ {
ostringstream buf; ostringstream buf;
int timing = myConsole.timing() == ConsoleTiming::ntsc ? 0 const int timing = myConsole.timing() == ConsoleTiming::ntsc ? 0
: myConsole.timing() == ConsoleTiming::pal ? 1 : 2; : myConsole.timing() == ConsoleTiming::pal ? 1 : 2;
buf << " " << myTIA.myFixedColorNames[TIA::P0] << " " << colorSwatch(myTIA.myFixedColorPalette[timing][TIA::P0]) buf << " " << myTIA.myFixedColorNames[TIA::P0] << " " << colorSwatch(myTIA.myFixedColorPalette[timing][TIA::P0])
@ -1313,27 +1318,27 @@ string TIADebug::toString()
riotState.INPTDump != oldRiotState.INPTDump) riotState.INPTDump != oldRiotState.INPTDump)
<< endl << endl
<< "AUDF0: " << "AUDF0: "
<< hexWithLabel("", int(audF0()), << hexWithLabel("", static_cast<int>(audF0()),
state.aud[0] != oldState.aud[0]) << "/" state.aud[0] != oldState.aud[0]) << "/"
<< std::setw(9) << std::right << stringOnly(audFreq0(), << std::setw(9) << std::right << stringOnly(audFreq0(),
state.aud[0] != oldState.aud[0]) << " " state.aud[0] != oldState.aud[0]) << " "
<< "AUDC0: " << "AUDC0: "
<< hexWithLabel("", int(audC0()), << hexWithLabel("", static_cast<int>(audC0()),
state.aud[2] != oldState.aud[2], 1) << " " state.aud[2] != oldState.aud[2], 1) << " "
<< "AUDV0: " << "AUDV0: "
<< hexWithLabel("", int(audV0()), << hexWithLabel("", static_cast<int>(audV0()),
state.aud[4] != oldState.aud[4], 1) state.aud[4] != oldState.aud[4], 1)
<< endl << endl
<< "AUDF1: " << "AUDF1: "
<< hexWithLabel("", int(audF1()), << hexWithLabel("", static_cast<int>(audF1()),
state.aud[1] != oldState.aud[1]) << "/" state.aud[1] != oldState.aud[1]) << "/"
<< std::setw(9) << std::right << stringOnly(audFreq1(), << std::setw(9) << std::right << stringOnly(audFreq1(),
state.aud[1] != oldState.aud[1]) << " " state.aud[1] != oldState.aud[1]) << " "
<< "AUDC1: " << "AUDC1: "
<< hexWithLabel("", int(audC1()), << hexWithLabel("", static_cast<int>(audC1()),
state.aud[3] != oldState.aud[3], 1) << " " state.aud[3] != oldState.aud[3], 1) << " "
<< "AUDV1: " << "AUDV1: "
<< hexWithLabel("", int(audV1()), << hexWithLabel("", static_cast<int>(audV1()),
state.aud[5] != oldState.aud[5], 1); state.aud[5] != oldState.aud[5], 1);
// note: last line should not contain \n, caller will add. // note: last line should not contain \n, caller will add.
return buf.str(); return buf.str();

View File

@ -178,8 +178,8 @@ class TIADebug : public DebuggerSystem
int cyclesThisLine() const; int cyclesThisLine() const;
bool vsync() const; bool vsync() const;
bool vblank() const; bool vblank() const;
int vsyncAsInt() const { return int(vsync()); } // so we can use _vsync pseudo-register int vsyncAsInt() const { return static_cast<int>(vsync()); } // so we can use _vsync pseudo-register
int vblankAsInt() const { return int(vblank()); } // so we can use _vblank pseudo-register int vblankAsInt() const { return static_cast<int>(vblank()); } // so we can use _vblank pseudo-register
shared_ptr<DelayQueueIterator> delayQueueIterator() const; shared_ptr<DelayQueueIterator> delayQueueIterator() const;

View File

@ -58,7 +58,8 @@ AudioWidget::AudioWidget(GuiObject* boss, const GUI::Font& lfont,
for(int col = 0; col < 2; ++col) for(int col = 0; col < 2; ++col)
{ {
new StaticTextWidget(boss, lfont, xpos + col * myAudF->colWidth() + int(myAudF->colWidth() / 2.75), new StaticTextWidget(boss, lfont, xpos + col * myAudF->colWidth() +
static_cast<int>(myAudF->colWidth() / 2.75),
ypos - lineHeight, fontWidth, fontHeight, ypos - lineHeight, fontWidth, fontHeight,
Common::Base::toString(col, Common::Base::Fmt::_16_1), Common::Base::toString(col, Common::Base::Fmt::_16_1),
TextAlign::Left); TextAlign::Left);
@ -68,7 +69,7 @@ AudioWidget::AudioWidget(GuiObject* boss, const GUI::Font& lfont,
new StaticTextWidget(boss, lfont, xpos, ypos+2, lwidth, fontHeight, new StaticTextWidget(boss, lfont, xpos, ypos+2, lwidth, fontHeight,
"AUDC", TextAlign::Left); "AUDC", TextAlign::Left);
xpos += lwidth; xpos += lwidth;
myAudC = new DataGridWidget(boss, nfont, xpos + int(myAudF->colWidth() / 2.75), ypos, myAudC = new DataGridWidget(boss, nfont, xpos + static_cast<int>(myAudF->colWidth() / 2.75), ypos,
2, 1, 1, 4, Common::Base::Fmt::_16_1); 2, 1, 1, 4, Common::Base::Fmt::_16_1);
myAudC->setTarget(this); myAudC->setTarget(this);
myAudC->setID(kAUDCID); myAudC->setID(kAUDCID);
@ -79,7 +80,7 @@ AudioWidget::AudioWidget(GuiObject* boss, const GUI::Font& lfont,
new StaticTextWidget(boss, lfont, xpos, ypos+2, lwidth, fontHeight, new StaticTextWidget(boss, lfont, xpos, ypos+2, lwidth, fontHeight,
"AUDV", TextAlign::Left); "AUDV", TextAlign::Left);
xpos += lwidth; xpos += lwidth;
myAudV = new DataGridWidget(boss, nfont, xpos + int(myAudF->colWidth() / 2.75), ypos, myAudV = new DataGridWidget(boss, nfont, xpos + static_cast<int>(myAudF->colWidth() / 2.75), ypos,
2, 1, 1, 4, Common::Base::Fmt::_16_1); 2, 1, 1, 4, Common::Base::Fmt::_16_1);
myAudV->setTarget(this); myAudV->setTarget(this);
myAudV->setID(kAUDVID); myAudV->setID(kAUDVID);
@ -184,8 +185,8 @@ void AudioWidget::handleCommand(CommandSender* sender, int cmd, int data, int id
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AudioWidget::changeFrequencyRegs() void AudioWidget::changeFrequencyRegs()
{ {
int addr = myAudF->getSelectedAddr(); const int addr = myAudF->getSelectedAddr();
int value = myAudF->getSelectedValue(); const int value = myAudF->getSelectedValue();
switch(addr) switch(addr)
{ {
@ -206,8 +207,8 @@ void AudioWidget::changeFrequencyRegs()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AudioWidget::changeControlRegs() void AudioWidget::changeControlRegs()
{ {
int addr = myAudC->getSelectedAddr(); const int addr = myAudC->getSelectedAddr();
int value = myAudC->getSelectedValue(); const int value = myAudC->getSelectedValue();
switch(addr) switch(addr)
{ {
@ -229,8 +230,8 @@ void AudioWidget::changeControlRegs()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AudioWidget::changeVolumeRegs() void AudioWidget::changeVolumeRegs()
{ {
int addr = myAudV->getSelectedAddr(); const int addr = myAudV->getSelectedAddr();
int value = myAudV->getSelectedValue(); const int value = myAudV->getSelectedValue();
switch(addr) switch(addr)
{ {

View File

@ -33,8 +33,8 @@ string Cartridge0840Widget::description()
{ {
ostringstream info; ostringstream info;
info << "0840 ECONObanking, two 4K banks\n"; info << "0840 ECONObanking, two 4K banks\n"
info << CartridgeEnhancedWidget::description(); << CartridgeEnhancedWidget::description();
return info.str(); return info.str();
} }

View File

@ -36,8 +36,8 @@ string Cartridge3EPlusWidget::description()
ostringstream info; ostringstream info;
size_t size; size_t size;
const ByteBuffer& image = myCart.getImage(size); const ByteBuffer& image = myCart.getImage(size);
uInt16 numRomBanks = myCart.romBankCount(); const uInt16 numRomBanks = myCart.romBankCount();
uInt16 numRamBanks = myCart.ramBankCount(); const uInt16 numRamBanks = myCart.ramBankCount();
info << "3E+ cartridge - (4" << ELLIPSIS << "64K ROM + RAM)\n" info << "3E+ cartridge - (4" << ELLIPSIS << "64K ROM + RAM)\n"
<< " " << numRomBanks << " 1K ROM banks + " << numRamBanks << " 512b RAM banks\n" << " " << numRomBanks << " 1K ROM banks + " << numRamBanks << " 512b RAM banks\n"
@ -73,7 +73,7 @@ void Cartridge3EPlusWidget::bankSelect(int& ypos)
for(uInt32 seg = 0; seg < bankSegs(); ++seg) for(uInt32 seg = 0; seg < bankSegs(); ++seg)
{ {
int xpos = 2, xpos_s, ypos_s = ypos + 1, width; int xpos = 2, ypos_s = ypos + 1, width = 0;
ostringstream label; ostringstream label;
VariantList items; VariantList items;
@ -111,18 +111,17 @@ void Cartridge3EPlusWidget::bankSelect(int& ypos)
myBankCommit[seg]->setTarget(this); myBankCommit[seg]->setTarget(this);
addFocusWidget(myBankCommit[seg]); addFocusWidget(myBankCommit[seg]);
xpos_s = myBankCommit[seg]->getRight() + _font.getMaxCharWidth() * 2; const int xpos_s = myBankCommit[seg]->getRight() + _font.getMaxCharWidth() * 2;
StaticTextWidget* t;
uInt16 start = (image[0x400 - 3] << 8) | image[0x400 - 4]; uInt16 start = (image[0x400 - 3] << 8) | image[0x400 - 4];
start -= start % 0x1000; start -= start % 0x1000;
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 << "-$" << Common::Base::HEX4 << (addr1 + 0x1FF);
t = new StaticTextWidget(_boss, _font, xpos_s, ypos_s + 2, label.str()); StaticTextWidget* t = new StaticTextWidget(_boss, _font, xpos_s, ypos_s + 2, label.str());
int xoffset = t->getRight() + _font.getMaxCharWidth(); const int xoffset = t->getRight() + _font.getMaxCharWidth();
myBankState[2 * seg] = new EditTextWidget(_boss, _font, xoffset, ypos_s, myBankState[2 * seg] = new EditTextWidget(_boss, _font, xoffset, ypos_s,
_w - xoffset - 10, myLineHeight, ""); _w - xoffset - 10, myLineHeight, "");
myBankState[2 * seg]->setEditable(false, true); myBankState[2 * seg]->setEditable(false, true);
@ -159,7 +158,7 @@ void Cartridge3EPlusWidget::handleCommand(CommandSender* sender,
case kRomRamChanged: case kRomRamChanged:
{ {
const bool isROM = myBankType[segment]->getSelectedTag() == "ROM"; const bool isROM = myBankType[segment]->getSelectedTag() == "ROM";
int bank = myBankWidgets[segment]->getSelected(); const int bank = myBankWidgets[segment]->getSelected();
myBankCommit[segment]->setEnabled((isROM && bank < myCart.romBankCount()) myBankCommit[segment]->setEnabled((isROM && bank < myCart.romBankCount())
|| (!isROM && bank < myCart.ramBankCount())); || (!isROM && bank < myCart.ramBankCount()));
@ -172,7 +171,7 @@ void Cartridge3EPlusWidget::handleCommand(CommandSender* sender,
myBankType[segment]->getSelected() < 0) myBankType[segment]->getSelected() < 0)
return; return;
uInt8 bank = myBankWidgets[segment]->getSelected(); const uInt8 bank = myBankWidgets[segment]->getSelected();
myCart.unlockHotspots(); myCart.unlockHotspots();
@ -198,12 +197,12 @@ void Cartridge3EPlusWidget::updateUIState()
// Set contents for actual banks number and type (@ each even index) // Set contents for actual banks number and type (@ each even index)
for(int seg = 0; seg < myCart3EP.myBankSegs; ++seg) for(int seg = 0; seg < myCart3EP.myBankSegs; ++seg)
{ {
uInt16 bank = myCart.getSegmentBank(seg); const uInt16 bank = myCart.getSegmentBank(seg);
ostringstream buf; ostringstream buf;
if(bank >= myCart.romBankCount()) // was RAM mapped here? if(bank >= myCart.romBankCount()) // was RAM mapped here?
{ {
uInt16 ramBank = bank - myCart.romBankCount(); const uInt16 ramBank = bank - myCart.romBankCount();
buf << "RAM @ $" << Common::Base::HEX4 buf << "RAM @ $" << Common::Base::HEX4
<< (ramBank << myCart3EP.myBankShift) << " (R)"; << (ramBank << myCart3EP.myBankShift) << " (R)";

View File

@ -34,9 +34,8 @@ string Cartridge3EWidget::description()
ostringstream info; ostringstream info;
size_t size; size_t size;
const ByteBuffer& image = myCart.getImage(size); const ByteBuffer& image = myCart.getImage(size);
uInt16 numRomBanks = myCart.romBankCount(); const uInt16 numRomBanks = myCart.romBankCount();
uInt16 numRamBanks = myCart.ramBankCount(); const uInt16 numRamBanks = myCart.ramBankCount();
info << "3E cartridge (3F + RAM),\n" info << "3E cartridge (3F + RAM),\n"
<< " " << numRomBanks << " 2K ROM banks, " << numRamBanks << " 1K RAM banks\n" << " " << numRomBanks << " 2K ROM banks, " << numRamBanks << " 1K RAM banks\n"
@ -103,8 +102,8 @@ void Cartridge3EWidget::bankSelect(int& ypos)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void Cartridge3EWidget::loadConfig() void Cartridge3EWidget::loadConfig()
{ {
uInt16 oldBank = myOldState.banks[0]; const uInt16 oldBank = myOldState.banks[0];
uInt16 bank = myCart.getBank(); const uInt16 bank = myCart.getBank();
if(myCart.getBank() < myCart.romBankCount()) if(myCart.getBank() < myCart.romBankCount())
{ {
@ -161,7 +160,7 @@ void Cartridge3EWidget::handleCommand(CommandSender* sender, int cmd, int data,
string Cartridge3EWidget::bankState() string Cartridge3EWidget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
uInt16 bank = myCart.getBank(); const uInt16 bank = myCart.getBank();
if(bank < myCart.romBankCount()) if(bank < myCart.romBankCount())
buf << "ROM bank #" << std::dec << bank % myCart.romBankCount() << ", RAM inactive"; buf << "ROM bank #" << std::dec << bank % myCart.romBankCount() << ", RAM inactive";

View File

@ -32,7 +32,7 @@ Cartridge3FWidget::Cartridge3FWidget(
string Cartridge3FWidget::description() string Cartridge3FWidget::description()
{ {
ostringstream info; ostringstream info;
size_t size; size_t size = 0;
const ByteBuffer& image = myCart.getImage(size); const ByteBuffer& image = myCart.getImage(size);
info << "Tigervision 3F cartridge, 2 - 256 2K banks\n" info << "Tigervision 3F cartridge, 2 - 256 2K banks\n"

View File

@ -42,8 +42,8 @@ string Cartridge4KWidget::description()
{ {
ostringstream info; ostringstream info;
info << "Standard 4K cartridge, non-bankswitched\n"; info << "Standard 4K cartridge, non-bankswitched\n"
info << CartridgeEnhancedWidget::description(); << CartridgeEnhancedWidget::description();
return info.str(); return info.str();
} }

View File

@ -35,8 +35,7 @@ CartridgeARMWidget::CartridgeARMWidget(
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeARMWidget::addCycleWidgets(int xpos, int ypos) void CartridgeARMWidget::addCycleWidgets(int xpos, int ypos)
{ {
const int INDENT = 20; constexpr int INDENT = 20, VGAP = 4;
const int VGAP = 4;
VariantList items; VariantList items;
new StaticTextWidget(_boss, _font, xpos, ypos + 1, "ARM emulation cycles:"); new StaticTextWidget(_boss, _font, xpos, ypos + 1, "ARM emulation cycles:");
@ -142,17 +141,16 @@ void CartridgeARMWidget::saveOldState()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeARMWidget::loadConfig() void CartridgeARMWidget::loadConfig()
{ {
bool isChanged;
bool devSettings = instance().settings().getBool("dev.settings"); bool devSettings = instance().settings().getBool("dev.settings");
IntArray alist; IntArray alist;
IntArray vlist; IntArray vlist;
BoolArray changed; BoolArray changed;
myChipType->setSelectedIndex(static_cast<Int32>(instance().settings().getInt("dev.thumb.chiptype") myChipType->setSelectedIndex(static_cast<Int32>(instance().settings().getInt("dev.thumb.chiptype")
- int(Thumbulator::ChipType::AUTO))); - static_cast<int>(Thumbulator::ChipType::AUTO)));
handleChipType(); handleChipType();
isChanged = static_cast<uInt32>(myCart.mamMode()) != myOldState.mamMode; const bool isChanged = static_cast<uInt32>(myCart.mamMode()) != myOldState.mamMode;
myMamMode->setSelectedIndex(static_cast<uInt32>(myCart.mamMode()), isChanged); myMamMode->setSelectedIndex(static_cast<uInt32>(myCart.mamMode()), isChanged);
myMamMode->setEnabled(devSettings && myLockMamMode->getState()); myMamMode->setEnabled(devSettings && myLockMamMode->getState());
myLockMamMode->setEnabled(devSettings); myLockMamMode->setEnabled(devSettings);
@ -245,7 +243,7 @@ void CartridgeARMWidget::handleChipType()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeARMWidget::handleMamLock() void CartridgeARMWidget::handleMamLock()
{ {
bool checked = myLockMamMode->getState(); const bool checked = myLockMamMode->getState();
myMamMode->setEnabled(checked); myMamMode->setEnabled(checked);
myCart.lockMamMode(checked); myCart.lockMamMode(checked);
@ -255,7 +253,7 @@ void CartridgeARMWidget::handleMamLock()
void CartridgeARMWidget::handleMamMode() void CartridgeARMWidget::handleMamMode()
{ {
// override MAM mode set by ROM // override MAM mode set by ROM
Int32 mode = myMamMode->getSelected(); const Int32 mode = myMamMode->getSelected();
string name = myMamMode->getSelectedName(); string name = myMamMode->getSelectedName();
myMamMode->setSelectedName(name + "XXX"); myMamMode->setSelectedName(name + "XXX");
@ -268,9 +266,9 @@ void CartridgeARMWidget::handleMamMode()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeARMWidget::handleArmCycles() void CartridgeARMWidget::handleArmCycles()
{ {
bool devSettings = instance().settings().getBool("dev.settings"); const bool devSettings = instance().settings().getBool("dev.settings");
bool enable = myIncCycles->getState(); const bool enable = myIncCycles->getState();
double factor = static_cast<double>(myCycleFactor->getValue()) / 100.0; const double factor = static_cast<double>(myCycleFactor->getValue()) / 100.0;
if(devSettings) if(devSettings)
{ {

View File

@ -29,14 +29,14 @@ CartridgeARWidget::CartridgeARWidget(
: CartDebugWidget(boss, lfont, nfont, x, y, w, h), : CartDebugWidget(boss, lfont, nfont, x, y, w, h),
myCart{cart} myCart{cart}
{ {
size_t size = myCart.mySize; const size_t size = myCart.mySize;
string info = string info =
"Supercharger cartridge, four 2K slices (3 RAM, 1 ROM)\n" "Supercharger cartridge, four 2K slices (3 RAM, 1 ROM)\n"
"\nTHIS SCHEME IS NOT FULLY IMPLEMENTED OR TESTED\n"; "\nTHIS SCHEME IS NOT FULLY IMPLEMENTED OR TESTED\n";
int xpos = 2, constexpr int xpos = 2;
ypos = addBaseInformation(size, "Starpath", info) + myLineHeight; const int ypos = addBaseInformation(size, "Starpath", info) + myLineHeight;
VariantList items; VariantList items;
VarList::push_back(items, " 0"); VarList::push_back(items, " 0");

View File

@ -32,8 +32,8 @@ string CartridgeBFSCWidget::description()
{ {
ostringstream info; ostringstream info;
info << "256K BFSC + RAM, 64 4K banks\n"; info << "256K BFSC + RAM, 64 4K banks\n"
info << CartridgeEnhancedWidget::description(); << CartridgeEnhancedWidget::description();
return info.str(); return info.str();
} }

View File

@ -32,8 +32,8 @@ string CartridgeBFWidget::description()
{ {
ostringstream info; ostringstream info;
info << "256K BF cartridge, 64 4K banks\n"; info << "256K BF cartridge, 64 4K banks\n"
info << CartridgeEnhancedWidget::description(); << CartridgeEnhancedWidget::description();
return info.str(); return info.str();
} }

View File

@ -28,7 +28,7 @@ CartridgeBUSWidget::CartridgeBUSWidget(
: CartridgeARMWidget(boss, lfont, nfont, x, y, w, h, cart), : CartridgeARMWidget(boss, lfont, nfont, x, y, w, h, cart),
myCart{cart} myCart{cart}
{ {
uInt16 size = 8 * 4096; constexpr uInt16 size = 8 * 4096;
ostringstream info; ostringstream info;
info << "BUS Stuffing cartridge (EXPERIMENTAL)\n" info << "BUS Stuffing cartridge (EXPERIMENTAL)\n"
@ -155,8 +155,8 @@ CartridgeBUSWidget::CartridgeBUSWidget(
myMusicWaveforms->setTarget(this); myMusicWaveforms->setTarget(this);
myMusicWaveforms->setEditable(false); myMusicWaveforms->setEditable(false);
int xpossp = xpos + myMusicWaveforms->getWidth() + 20; const int xpossp = xpos + myMusicWaveforms->getWidth() + 20;
int lwidth2 = _font.getStringWidth("Sample Pointer "); const int lwidth2 = _font.getStringWidth("Sample Pointer ");
new StaticTextWidget(boss, _font, xpossp, ypos, lwidth2, new StaticTextWidget(boss, _font, xpossp, ypos, lwidth2,
myFontHeight, "Sample Pointer ", TextAlign::Left); myFontHeight, "Sample Pointer ", TextAlign::Left);
@ -270,7 +270,7 @@ void CartridgeBUSWidget::loadConfig()
// I = Increment // I = Increment
// F = Fractional // F = Fractional
Int32 pointervalue = myCart.getDatastreamPointer(i) >> 12; const Int32 pointervalue = myCart.getDatastreamPointer(i) >> 12;
alist.push_back(0); vlist.push_back(pointervalue); alist.push_back(0); vlist.push_back(pointervalue);
changed.push_back(pointervalue != myOldState.datastreampointers[i]); changed.push_back(pointervalue != myOldState.datastreampointers[i]);
} }
@ -279,7 +279,7 @@ void CartridgeBUSWidget::loadConfig()
alist.clear(); vlist.clear(); changed.clear(); alist.clear(); vlist.clear(); changed.clear();
for(int i = 16; i < 18; ++i) for(int i = 16; i < 18; ++i)
{ {
Int32 pointervalue = myCart.getDatastreamPointer(i) >> 12; const Int32 pointervalue = myCart.getDatastreamPointer(i) >> 12;
alist.push_back(0); vlist.push_back(pointervalue); alist.push_back(0); vlist.push_back(pointervalue);
changed.push_back(pointervalue != myOldState.datastreampointers[i]); changed.push_back(pointervalue != myOldState.datastreampointers[i]);
} }
@ -288,7 +288,7 @@ void CartridgeBUSWidget::loadConfig()
alist.clear(); vlist.clear(); changed.clear(); alist.clear(); vlist.clear(); changed.clear();
for(int i = 0; i < 16; ++i) for(int i = 0; i < 16; ++i)
{ {
Int32 incrementvalue = myCart.getDatastreamIncrement(i); const Int32 incrementvalue = myCart.getDatastreamIncrement(i);
alist.push_back(0); vlist.push_back(incrementvalue); alist.push_back(0); vlist.push_back(incrementvalue);
changed.push_back(incrementvalue != myOldState.datastreamincrements[i]); changed.push_back(incrementvalue != myOldState.datastreamincrements[i]);
} }
@ -297,7 +297,7 @@ void CartridgeBUSWidget::loadConfig()
alist.clear(); vlist.clear(); changed.clear(); alist.clear(); vlist.clear(); changed.clear();
for(int i = 16; i < 18; ++i) for(int i = 16; i < 18; ++i)
{ {
Int32 incrementvalue = 0x100; constexpr Int32 incrementvalue = 0x100;
alist.push_back(0); vlist.push_back(incrementvalue); alist.push_back(0); vlist.push_back(incrementvalue);
changed.push_back(incrementvalue != myOldState.datastreamincrements[i]); changed.push_back(incrementvalue != myOldState.datastreamincrements[i]);
} }
@ -306,13 +306,13 @@ void CartridgeBUSWidget::loadConfig()
alist.clear(); vlist.clear(); changed.clear(); alist.clear(); vlist.clear(); changed.clear();
for(int i = 0; i < 37; ++i) // only 37 map values for(int i = 0; i < 37; ++i) // only 37 map values
{ {
Int32 mapvalue = myCart.getAddressMap(i); const Int32 mapvalue = myCart.getAddressMap(i);
alist.push_back(0); vlist.push_back(mapvalue); alist.push_back(0); vlist.push_back(mapvalue);
changed.push_back(mapvalue != myOldState.addressmaps[i]); changed.push_back(mapvalue != myOldState.addressmaps[i]);
} }
for(int i = 37; i < 40; ++i) // but need 40 for the grid for(int i = 37; i < 40; ++i) // but need 40 for the grid
{ {
Int32 mapvalue = 0; constexpr Int32 mapvalue = 0;
alist.push_back(0); vlist.push_back(mapvalue); alist.push_back(0); vlist.push_back(mapvalue);
changed.push_back(mapvalue != myOldState.addressmaps[i]); changed.push_back(mapvalue != myOldState.addressmaps[i]);
} }

View File

@ -24,24 +24,24 @@ CartridgeCDFInfoWidget::CartridgeCDFInfoWidget(
: CartDebugWidget(boss, lfont, nfont, x, y, w, h) : CartDebugWidget(boss, lfont, nfont, x, y, w, h)
{ {
ostringstream info; ostringstream info;
info << describeCDFVersion(cart.myCDFSubtype) << " cartridge\n" info << describeCDFVersion(cart.myCDFSubtype) << " cartridge\n"
<< (cart.romSize() / 1024) << "K ROM\n" << (cart.romSize() / 1024) << "K ROM\n"
<< (cart.ramSize() / 1024) << "K RAM\n" << (cart.ramSize() / 1024) << "K RAM\n"
<< "Seven 4K banks are available to 2600\n" << "Seven 4K banks are available to 2600\n"
<< "Functions accessible @ $FFF0 - $FFF3\n" << "Functions accessible @ $FFF0 - $FFF3\n"
<< (cart.isCDFJplus() ? "Banks accessible @ $FFF4 to $FFFA\n" : "Banks accessible @ $FFF5 to $FFFB\n") << (cart.isCDFJplus() ? "Banks accessible @ $FFF4 to $FFFA\n" : "Banks accessible @ $FFF5 to $FFFB\n")
<< "Startup bank = " << cart.startBank() << "\n" << "Startup bank = " << cart.startBank() << "\n"
<< "Fast Fetcher(s): LDA #"; << "Fast Fetcher(s): LDA #";
if (cart.myLDXenabled) if (cart.myLDXenabled)
info << ", LDX #"; info << ", LDX #";
if (cart.myLDYenabled) if (cart.myLDYenabled)
info << ", LDY #"; info << ", LDY #";
info << "\n"; info << "\n";
#if 0 #if 0
// Eventually, we should query this from the debugger/disassembler // Eventually, we should query this from the debugger/disassembler
for(uInt32 i = 0, offset = 0xFFC, spot = 0xFF5; i < 7; ++i, offset += 0x1000) for(uInt32 i = 0, offset = 0xFFC, spot = 0xFF5; i < 7; ++i, offset += 0x1000)

View File

@ -28,10 +28,10 @@ CartridgeCDFWidget::CartridgeCDFWidget(
: CartridgeARMWidget(boss, lfont, nfont, x, y, w, h, cart), : CartridgeARMWidget(boss, lfont, nfont, x, y, w, h, cart),
myCart{cart} myCart{cart}
{ {
const int VBORDER = 8; constexpr int VBORDER = 8,
const int HBORDER = 2; HBORDER = 2,
const int INDENT = 20; INDENT = 20,
const int VGAP = 4; VGAP = 4;
int xpos = HBORDER, ypos = VBORDER; int xpos = HBORDER, ypos = VBORDER;
@ -64,14 +64,14 @@ CartridgeCDFWidget::CartridgeCDFWidget(
"Fast Fetcher enabled"); "Fast Fetcher enabled");
myFastFetch->setTarget(this); myFastFetch->setTarget(this);
myFastFetch->setEditable(false); myFastFetch->setEditable(false);
int lwidth; int lwidth = 0;
// Fast Fetch Offset // Fast Fetch Offset
if (isCDFJplus()) if (isCDFJplus())
{ {
ypos += myLineHeight + VGAP; ypos += myLineHeight + VGAP;
new StaticTextWidget(_boss, _font, myFastFetch->getLeft(), ypos, "Fast Fetch Offset: "); new StaticTextWidget(_boss, _font, myFastFetch->getLeft(), ypos, "Fast Fetch Offset: ");
lwidth = _font.getStringWidth("Fast Fetch Offset: "); lwidth = _font.getStringWidth("Fast Fetch Offset: ");
@ -223,8 +223,6 @@ CartridgeCDFWidget::CartridgeCDFWidget(
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeCDFWidget::saveOldState() void CartridgeCDFWidget::saveOldState()
{ {
Int32 ds_shift = isCDFJplus() ? 8 : 12;
myOldState.fastfetchoffset.clear(); myOldState.fastfetchoffset.clear();
myOldState.datastreampointers.clear(); myOldState.datastreampointers.clear();
myOldState.datastreamincrements.clear(); myOldState.datastreamincrements.clear();
@ -235,8 +233,7 @@ void CartridgeCDFWidget::saveOldState()
myOldState.mwavesizes.clear(); myOldState.mwavesizes.clear();
myOldState.internalram.clear(); myOldState.internalram.clear();
myOldState.samplepointer.clear(); myOldState.samplepointer.clear();
if (isCDFJplus()) if (isCDFJplus())
myOldState.fastfetchoffset.push_back(myCart.myRAM[myCart.myFastFetcherOffset]); myOldState.fastfetchoffset.push_back(myCart.myRAM[myCart.myFastFetcherOffset]);
@ -252,7 +249,7 @@ void CartridgeCDFWidget::saveOldState()
// I = Increment // I = Increment
// F = Fractional // F = Fractional
myOldState.datastreampointers.push_back(myCart.getDatastreamPointer(i)>>ds_shift); myOldState.datastreampointers.push_back(myCart.getDatastreamPointer(i)>>(isCDFJplus() ? 8 : 12));
myOldState.datastreamincrements.push_back(myCart.getDatastreamIncrement(i)); myOldState.datastreamincrements.push_back(myCart.getDatastreamIncrement(i));
} }
@ -277,15 +274,14 @@ void CartridgeCDFWidget::saveOldState()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeCDFWidget::loadConfig() void CartridgeCDFWidget::loadConfig()
{ {
Int32 ds_shift = isCDFJplus() ? 8 : 12; const Int32 ds_shift = isCDFJplus() ? 8 : 12;
myBank->setSelectedIndex(myCart.getBank()); myBank->setSelectedIndex(myCart.getBank());
// Get registers, using change tracking // Get registers, using change tracking
IntArray alist; IntArray alist;
IntArray vlist; IntArray vlist;
BoolArray changed; BoolArray changed;
if (isCDFJplus()) if (isCDFJplus())
{ {
alist.clear(); vlist.clear(); changed.clear(); alist.clear(); vlist.clear(); changed.clear();
@ -308,7 +304,7 @@ void CartridgeCDFWidget::loadConfig()
// I = Increment // I = Increment
// F = Fractional // F = Fractional
Int32 pointervalue = myCart.getDatastreamPointer(i) >> ds_shift; const Int32 pointervalue = myCart.getDatastreamPointer(i) >> ds_shift;
alist.push_back(0); vlist.push_back(pointervalue); alist.push_back(0); vlist.push_back(pointervalue);
changed.push_back(pointervalue != myOldState.datastreampointers[i]); changed.push_back(pointervalue != myOldState.datastreampointers[i]);
} }
@ -317,7 +313,7 @@ void CartridgeCDFWidget::loadConfig()
alist.clear(); vlist.clear(); changed.clear(); alist.clear(); vlist.clear(); changed.clear();
for(int i = 32; i < 34; ++i) for(int i = 32; i < 34; ++i)
{ {
Int32 pointervalue = myCart.getDatastreamPointer(i) >> ds_shift; const Int32 pointervalue = myCart.getDatastreamPointer(i) >> ds_shift;
alist.push_back(0); vlist.push_back(pointervalue); alist.push_back(0); vlist.push_back(pointervalue);
changed.push_back(pointervalue != myOldState.datastreampointers[i]); changed.push_back(pointervalue != myOldState.datastreampointers[i]);
} }
@ -331,7 +327,7 @@ void CartridgeCDFWidget::loadConfig()
alist.clear(); vlist.clear(); changed.clear(); alist.clear(); vlist.clear(); changed.clear();
for(int i = 0; i < ((isCDFJ() || isCDFJplus()) ? 2 : 1); ++i) for(int i = 0; i < ((isCDFJ() || isCDFJplus()) ? 2 : 1); ++i)
{ {
Int32 pointervalue = myCart.getDatastreamPointer(0x21 + i) >> ds_shift; const Int32 pointervalue = myCart.getDatastreamPointer(0x21 + i) >> ds_shift;
alist.push_back(0); vlist.push_back(pointervalue); alist.push_back(0); vlist.push_back(pointervalue);
changed.push_back(pointervalue != myOldState.datastreampointers[0x21 + i]); changed.push_back(pointervalue != myOldState.datastreampointers[0x21 + i]);
} }
@ -340,7 +336,7 @@ void CartridgeCDFWidget::loadConfig()
alist.clear(); vlist.clear(); changed.clear(); alist.clear(); vlist.clear(); changed.clear();
for(int i = 0; i < 32; ++i) for(int i = 0; i < 32; ++i)
{ {
Int32 incrementvalue = myCart.getDatastreamIncrement(i); const Int32 incrementvalue = myCart.getDatastreamIncrement(i);
alist.push_back(0); vlist.push_back(incrementvalue); alist.push_back(0); vlist.push_back(incrementvalue);
changed.push_back(incrementvalue != myOldState.datastreamincrements[i]); changed.push_back(incrementvalue != myOldState.datastreamincrements[i]);
} }
@ -355,7 +351,7 @@ void CartridgeCDFWidget::loadConfig()
alist.clear(); vlist.clear(); changed.clear(); alist.clear(); vlist.clear(); changed.clear();
for(int i = 0; i < ((isCDFJ() || isCDFJplus()) ? 2 : 1); ++i) for(int i = 0; i < ((isCDFJ() || isCDFJplus()) ? 2 : 1); ++i)
{ {
Int32 pointervalue = myCart.getDatastreamIncrement(0x21 + i) >> ds_shift; const Int32 pointervalue = myCart.getDatastreamIncrement(0x21 + i) >> ds_shift;
alist.push_back(0); vlist.push_back(pointervalue); alist.push_back(0); vlist.push_back(pointervalue);
changed.push_back(pointervalue != myOldState.datastreamincrements[0x21 + i]); changed.push_back(pointervalue != myOldState.datastreamincrements[0x21 + i]);
} }

View File

@ -33,7 +33,7 @@ CartridgeCMWidget::CartridgeCMWidget(
: CartDebugWidget(boss, lfont, nfont, x, y, w, h), : CartDebugWidget(boss, lfont, nfont, x, y, w, h),
myCart{cart} myCart{cart}
{ {
uInt16 size = 4 * 4096; constexpr uInt16 size = 4 * 4096;
string info = string info =
"CM cartridge, four 4K banks + 2K RAM\n" "CM cartridge, four 4K banks + 2K RAM\n"
@ -87,7 +87,7 @@ CartridgeCMWidget::CartridgeCMWidget(
myIncrease->setTarget(this); myIncrease->setTarget(this);
myIncrease->setEditable(false); myIncrease->setEditable(false);
int orig_ypos = ypos; // save for when we go to the next column const int orig_ypos = ypos; // save for when we go to the next column
// D5 (column part) // D5 (column part)
ypos += myLineHeight + 4; ypos += myLineHeight + 4;
@ -168,7 +168,7 @@ void CartridgeCMWidget::loadConfig()
RiotDebug& riot = Debugger::debugger().riotDebug(); RiotDebug& riot = Debugger::debugger().riotDebug();
const RiotState& state = static_cast<const RiotState&>(riot.getState()); const RiotState& state = static_cast<const RiotState&>(riot.getState());
uInt8 swcha = myCart.mySWCHA; const uInt8 swcha = myCart.mySWCHA;
// SWCHA // SWCHA
BoolArray oldbits, newbits, changed; BoolArray oldbits, newbits, changed;

View File

@ -29,7 +29,7 @@ CartridgeCTYWidget::CartridgeCTYWidget(
: CartDebugWidget(boss, lfont, nfont, x, y, w, h), : CartDebugWidget(boss, lfont, nfont, x, y, w, h),
myCart{cart} myCart{cart}
{ {
uInt16 size = 8 * 4096; constexpr uInt16 size = 8 * 4096;
string info = string info =
"Chetiry cartridge, eight 4K banks (bank 0 is ARM code and is ignored)\n" "Chetiry cartridge, eight 4K banks (bank 0 is ARM code and is ignored)\n"
@ -37,8 +37,8 @@ CartridgeCTYWidget::CartridgeCTYWidget(
" $F040 - $F07F (R), $F000 - $F03F (W)\n" " $F040 - $F07F (R), $F000 - $F03F (W)\n"
"\nTHIS SCHEME IS NOT FULLY IMPLEMENTED OR TESTED\n"; "\nTHIS SCHEME IS NOT FULLY IMPLEMENTED OR TESTED\n";
int xpos = 2, constexpr int xpos = 2;
ypos = addBaseInformation(size, "Chris D. Walton", info) + myLineHeight; const int ypos = addBaseInformation(size, "Chris D. Walton", info) + myLineHeight;
VariantList items; VariantList items;
VarList::push_back(items, "1 ($FFF5)"); VarList::push_back(items, "1 ($FFF5)");
@ -96,7 +96,7 @@ string CartridgeCTYWidget::bankState()
static constexpr std::array<const char*, 8> spot = { static constexpr std::array<const char*, 8> spot = {
"", "$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB" "", "$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB"
}; };
uInt16 bank = myCart.getBank(); const uInt16 bank = myCart.getBank();
buf << "Bank = " << std::dec << bank << ", hotspot = " << spot[bank]; buf << "Bank = " << std::dec << bank << ", hotspot = " << spot[bank];
return buf.str(); return buf.str();

View File

@ -34,8 +34,8 @@ string CartridgeCVWidget::description()
{ {
ostringstream info; ostringstream info;
info << "CV 2K ROM + 1K RAM, non-bankswitched\n"; info << "CV 2K ROM + 1K RAM, non-bankswitched\n"
info << CartridgeEnhancedWidget::description(); << CartridgeEnhancedWidget::description();
return info.str(); return info.str();
} }

View File

@ -32,8 +32,8 @@ string CartridgeDFSCWidget::description()
{ {
ostringstream info; ostringstream info;
info << "128K DFSC + RAM, 32 4K banks\n"; info << "128K DFSC + RAM, 32 4K banks\n"
info << CartridgeEnhancedWidget::description(); << CartridgeEnhancedWidget::description();
return info.str(); return info.str();
} }

View File

@ -32,8 +32,8 @@ string CartridgeDFWidget::description()
{ {
ostringstream info; ostringstream info;
info << "128K DF, 32 4K banks\n"; info << "128K DF, 32 4K banks\n"
info << CartridgeEnhancedWidget::description(); << CartridgeEnhancedWidget::description();
return info.str(); return info.str();
} }

View File

@ -28,7 +28,7 @@ CartridgeDPCPlusWidget::CartridgeDPCPlusWidget(
: CartridgeARMWidget(boss, lfont, nfont, x, y, w, h, cart), : CartridgeARMWidget(boss, lfont, nfont, x, y, w, h, cart),
myCart{cart} myCart{cart}
{ {
size_t size = cart.mySize; const size_t size = cart.mySize;
ostringstream info; ostringstream info;
info << "Extended DPC cartridge, six 4K banks, 4K display bank, 1K frequency table, " info << "Extended DPC cartridge, six 4K banks, 4K display bank, 1K frequency table, "

View File

@ -27,8 +27,8 @@ CartridgeDPCWidget::CartridgeDPCWidget(
: CartDebugWidget(boss, lfont, nfont, x, y, w, h), : CartDebugWidget(boss, lfont, nfont, x, y, w, h),
myCart{cart} myCart{cart}
{ {
const int V_GAP = 4; constexpr int V_GAP = 4;
size_t size = cart.mySize; const size_t size = cart.mySize;
ostringstream info; ostringstream info;
info << "DPC cartridge, two 4K banks + 2K display bank\n" info << "DPC cartridge, two 4K banks + 2K display bank\n"
@ -38,7 +38,8 @@ CartridgeDPCWidget::CartridgeDPCWidget(
<< "Startup bank = " << cart.startBank() << " or undetermined\n"; << "Startup bank = " << cart.startBank() << " or undetermined\n";
// Eventually, we should query this from the debugger/disassembler // Eventually, we should query this from the debugger/disassembler
for(uInt32 i = 0, offset = 0xFFC, spot = 0xFF8; i < 2; ++i, offset += 0x1000) constexpr uInt32 spot = 0xFF8;
for(uInt32 i = 0, offset = 0xFFC; i < 2; ++i, offset += 0x1000)
{ {
uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset]; uInt16 start = (cart.myImage[offset+1] << 8) | cart.myImage[offset];
start -= start % 0x1000; start -= start % 0x1000;

View File

@ -46,7 +46,8 @@ int CartDebugWidget::addBaseInformation(size_t bytes, const string& manufacturer
EditTextWidget* w = nullptr; EditTextWidget* w = nullptr;
ostringstream buf; ostringstream buf;
int x = 2, y = 8; constexpr int x = 2;
int y = 8;
// Add ROM size, manufacturer and bankswitch info // Add ROM size, manufacturer and bankswitch info
new StaticTextWidget(_boss, _font, x, y + 1, "ROM size "); new StaticTextWidget(_boss, _font, x, y + 1, "ROM size ");
@ -67,7 +68,7 @@ int CartDebugWidget::addBaseInformation(size_t bytes, const string& manufacturer
StringParser bs(desc, (fwidth - ScrollBarWidget::scrollBarWidth(_font)) / myFontWidth - 4); StringParser bs(desc, (fwidth - ScrollBarWidget::scrollBarWidth(_font)) / myFontWidth - 4);
const StringList& sl = bs.stringList(); const StringList& sl = bs.stringList();
uInt32 lines = uInt32(sl.size()); size_t lines = sl.size();
if(lines < 3) lines = 3; if(lines < 3) lines = 3;
bool useScrollbar = false; bool useScrollbar = false;
if(lines > maxlines) if(lines > maxlines)
@ -78,7 +79,8 @@ int CartDebugWidget::addBaseInformation(size_t bytes, const string& manufacturer
new StaticTextWidget(_boss, _font, x, y + 1, "Description "); new StaticTextWidget(_boss, _font, x, y + 1, "Description ");
myDesc = new StringListWidget(_boss, _nfont, x+lwidth, y - 1, myDesc = new StringListWidget(_boss, _nfont, x+lwidth, y - 1,
fwidth, lines * myLineHeight, false, useScrollbar); fwidth, static_cast<int>(lines) * myLineHeight,
false, useScrollbar);
myDesc->setEditable(false); myDesc->setEditable(false);
myDesc->setEnabled(false); myDesc->setEnabled(false);
myDesc->setList(sl); myDesc->setList(sl);

View File

@ -48,8 +48,8 @@ class CartDebugWidget : public Widget, public CommandSender
// implement change tracking; most carts probably won't do anything here // implement change tracking; most carts probably won't do anything here
virtual void saveOldState() { } virtual void saveOldState() { }
virtual void loadConfig() override; void loadConfig() override;
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id) override { } void handleCommand(CommandSender* sender, int cmd, int data, int id) override { }
// Query internal state of the cart (usually just bankswitching info) // Query internal state of the cart (usually just bankswitching info)
virtual string bankState() { return "0 (non-bankswitched)"; } virtual string bankState() { return "0 (non-bankswitched)"; }

View File

@ -32,8 +32,8 @@ string CartridgeE0Widget::description()
{ {
ostringstream info; ostringstream info;
info << "E0 cartridge,\n eight 1K banks mapped into four segments\n"; info << "E0 cartridge,\n eight 1K banks mapped into four segments\n"
info << CartridgeEnhancedWidget::description(); << CartridgeEnhancedWidget::description();
return info.str(); return info.str();
} }
@ -45,7 +45,7 @@ string CartridgeE0Widget::romDescription()
for(int seg = 0; seg < 4; ++seg) for(int seg = 0; seg < 4; ++seg)
{ {
uInt16 segmentOffset = seg << 10; // myCart.myBankShift; const uInt16 segmentOffset = seg << 10; // myCart.myBankShift;
info << "Segment #" << seg << " accessible @ $" info << "Segment #" << seg << " accessible @ $"
<< Common::Base::HEX4 << (ADDR_BASE | segmentOffset) << Common::Base::HEX4 << (ADDR_BASE | segmentOffset)
@ -64,11 +64,11 @@ string CartridgeE0Widget::romDescription()
string CartridgeE0Widget::hotspotStr(int bank, int segment, bool noBrackets) string CartridgeE0Widget::hotspotStr(int bank, int segment, bool noBrackets)
{ {
ostringstream info; ostringstream info;
uInt16 hotspot = myCart.hotspot(); const uInt16 hotspot = myCart.hotspot();
info << (noBrackets ? "" : "("); info << (noBrackets ? "" : "(")
info << "$" << Common::Base::HEX1 << (hotspot + bank + segment * 8); << "$" << Common::Base::HEX1 << (hotspot + bank + segment * 8)
info << (noBrackets ? "" : ")"); << (noBrackets ? "" : ")");
return info.str(); return info.str();
} }

View File

@ -63,11 +63,10 @@ CartridgeE7Widget::CartridgeE7Widget(
void CartridgeE7Widget::initialize(GuiObject* boss, void CartridgeE7Widget::initialize(GuiObject* boss,
CartridgeE7& cart, ostringstream& info) CartridgeE7& cart, ostringstream& info)
{ {
uInt32 size = cart.romBankCount() * cart.BANK_SIZE; const uInt32 size = cart.romBankCount() * cart.BANK_SIZE;
int xpos = 2, constexpr int xpos = 2;
ypos = addBaseInformation(size, "M Network", info.str(), 15) + int ypos = addBaseInformation(size, "M Network", info.str(), 15) + myLineHeight;
myLineHeight;
VariantList items0, items1; VariantList items0, items1;
for(int i = 0; i < cart.romBankCount(); ++i) for(int i = 0; i < cart.romBankCount(); ++i)

View File

@ -32,8 +32,8 @@ string CartridgeEFSCWidget::description()
{ {
ostringstream info; ostringstream info;
info << "64K H. Runner EFSC + RAM, 16 4K banks\n"; info << "64K H. Runner EFSC + RAM, 16 4K banks\n"
info << CartridgeEnhancedWidget::description(); << CartridgeEnhancedWidget::description();
return info.str(); return info.str();
} }

View File

@ -32,8 +32,8 @@ string CartridgeEFWidget::description()
{ {
ostringstream info; ostringstream info;
info << "64K H. Runner EF cartridge, 16 4K banks\n"; info << "64K H. Runner EF cartridge, 16 4K banks\n"
info << CartridgeEnhancedWidget::description(); << CartridgeEnhancedWidget::description();
return info.str(); return info.str();
} }

View File

@ -123,31 +123,28 @@ 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];
uInt16 end;
start -= start % std::min(int(size), 0x1000); start -= start % std::min(int(size), 0x1000);
end = start + 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)
{ {
start += myCart.myRomOffset; start += myCart.myRomOffset;
} }
info << "ROM accessible @ $" info << "ROM accessible @ $"
<< Common::Base::HEX4 << start << " - $" << Common::Base::HEX4 << start << " - $"
<< Common::Base::HEX4 << end; << Common::Base::HEX4 << end;
} }
return info.str(); return info.str();
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeEnhancedWidget::plusROMInfo(int& ypos) void CartridgeEnhancedWidget::plusROMInfo(int& ypos)
{ {
if(myCart.isPlusROM()) if(myCart.isPlusROM())
{ {
const int xpos = 2, constexpr int xpos = 2;
lwidth = _font.getStringWidth("Manufacturer "), const int lwidth = _font.getStringWidth("Manufacturer "),
fwidth = _w - lwidth - 12; fwidth = _w - lwidth - 12;
new StaticTextWidget(_boss, _font, xpos, ypos + 1, "PlusROM:"); new StaticTextWidget(_boss, _font, xpos, ypos + 1, "PlusROM:");
@ -201,7 +198,7 @@ void CartridgeEnhancedWidget::bankSelect(int& ypos)
{ {
if(myCart.romBankCount() > 1) if(myCart.romBankCount() > 1)
{ {
int xpos = 2; constexpr int xpos = 2;
myBankWidgets = make_unique<PopUpWidget* []>(bankSegs()); myBankWidgets = make_unique<PopUpWidget* []>(bankSegs());
@ -240,8 +237,8 @@ string CartridgeEnhancedWidget::bankState()
if(myCart.romBankCount() > 1) if(myCart.romBankCount() > 1)
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
uInt16 hotspot = myCart.hotspot(); const uInt16 hotspot = myCart.hotspot();
bool hasRamBanks = myCart.myRamBankCount > 0; const bool hasRamBanks = myCart.myRamBankCount > 0;
if(bankSegs() > 1) if(bankSegs() > 1)
{ {
@ -249,8 +246,8 @@ string CartridgeEnhancedWidget::bankState()
for(int seg = 0; seg < bankSegs(); ++seg) for(int seg = 0; seg < bankSegs(); ++seg)
{ {
int bank = myCart.getSegmentBank(seg); const int bank = myCart.getSegmentBank(seg);
bool isRamBank = (bank >= myCart.romBankCount()); const bool isRamBank = (bank >= myCart.romBankCount());
if(seg > 0) if(seg > 0)
@ -371,7 +368,7 @@ void CartridgeEnhancedWidget::handleCommand(CommandSender* sender,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
uInt32 CartridgeEnhancedWidget::internalRamSize() uInt32 CartridgeEnhancedWidget::internalRamSize()
{ {
return uInt32(myCart.myRamSize); return static_cast<uInt32>(myCart.myRamSize);
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -34,8 +34,8 @@ string CartridgeF0Widget::description()
ostringstream info; ostringstream info;
info << "Megaboy F0 cartridge, 16 4K banks\n" info << "Megaboy F0 cartridge, 16 4K banks\n"
<< "Startup bank = #" << myCart.startBank() << " or undetermined\n" << "Startup bank = #" << myCart.startBank() << " or undetermined\n"
<< "Bankswitch triggered by accessing $" << Common::Base::HEX4 << 0xFFF0 << "\n"; << "Bankswitch triggered by accessing $" << Common::Base::HEX4 << 0xFFF0 << "\n";
return info.str(); return info.str();
} }
@ -46,7 +46,7 @@ string CartridgeF0Widget::bankState()
ostringstream& buf = buffer(); ostringstream& buf = buffer();
buf << "Bank #" << std::dec << myCart.getBank() buf << "Bank #" << std::dec << myCart.getBank()
<< " (hotspot $" << Common::Base::HEX4 << 0xFFF0 << ")"; << " (hotspot $" << Common::Base::HEX4 << 0xFFF0 << ")";
return buf.str(); return buf.str();
} }

View File

@ -32,8 +32,8 @@ string CartridgeF4SCWidget::description()
{ {
ostringstream info; ostringstream info;
info << "Standard F4SC cartridge, eight 4K banks\n"; info << "Standard F4SC cartridge, eight 4K banks\n"
info << CartridgeEnhancedWidget::description(); << CartridgeEnhancedWidget::description();
return info.str(); return info.str();
} }

View File

@ -32,8 +32,8 @@ string CartridgeF4Widget::description()
{ {
ostringstream info; ostringstream info;
info << "Standard F4 cartridge, eight 4K banks\n"; info << "Standard F4 cartridge, eight 4K banks\n"
info << CartridgeEnhancedWidget::description(); << CartridgeEnhancedWidget::description();
return info.str(); return info.str();
} }

View File

@ -32,8 +32,8 @@ string CartridgeF6SCWidget::description()
{ {
ostringstream info; ostringstream info;
info << "Standard F6SC cartridge, four 4K banks\n"; info << "Standard F6SC cartridge, four 4K banks\n"
info << CartridgeEnhancedWidget::description(); << CartridgeEnhancedWidget::description();
return info.str(); return info.str();
} }

View File

@ -32,8 +32,8 @@ string CartridgeF6Widget::description()
{ {
ostringstream info; ostringstream info;
info << "Standard F6 cartridge, four 4K banks\n"; info << "Standard F6 cartridge, four 4K banks\n"
info << CartridgeEnhancedWidget::description(); << CartridgeEnhancedWidget::description();
return info.str(); return info.str();
} }

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