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

View File

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

View File

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

View File

@ -68,7 +68,7 @@ bool CheatManager::add(const string& name, const string& code,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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)
myCheatList[idx]->disable();
@ -186,6 +186,9 @@ void CheatManager::parse(const string& cheats)
code = s[1];
add(name, code, s[2] == "1");
break;
default:
break;
}
s.clear();
@ -218,7 +221,6 @@ void CheatManager::loadCheatDatabase()
catch(...) { return; }
string line, md5, cheat;
string::size_type one, two, three, four;
// Loop reading cheats
while(getline(in, line))
@ -226,10 +228,10 @@ void CheatManager::loadCheatDatabase()
if(line.length() == 0)
continue;
one = line.find('\"', 0);
two = line.find('\"', one + 1);
three = line.find('\"', two + 1);
four = line.find('\"', three + 1);
const string::size_type one = line.find('\"', 0);
const string::size_type two = line.find('\"', one + 1);
const string::size_type three = line.find('\"', two + 1);
const string::size_type four = line.find('\"', three + 1);
// Invalid line if it doesn't contain 4 quotes
if((one == string::npos) || (two == string::npos) ||
@ -302,7 +304,7 @@ void CheatManager::saveCheats(const string& md5sum)
// Only update the list if absolutely necessary
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
if(iter != myCheatMap.end())
@ -322,10 +324,10 @@ void CheatManager::saveCheats(const string& md5sum)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool CheatManager::isValidCode(const string& code) const
{
for(char c: code)
for(const auto c: code)
if(!isxdigit(c))
return false;
uInt32 length = uInt32(code.length());
const size_t length = code.length();
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)
: Cheat(os, name, code),
address{uInt16(0xf000 + unhex(code.substr(0, 3)))},
value{uInt8(unhex(code.substr(3, 2)))},
count{uInt8(unhex(code.substr(5, 1)) + 1)}
address{static_cast<uInt16>(0xf000 + unhex(code.substr(0, 3)))},
value{static_cast<uInt8>(unhex(code.substr(3, 2)))},
count{static_cast<uInt8>(unhex(code.substr(5, 1)) + 1)}
{
// Back up original data; we need this if the cheat is ever disabled
for(int i = 0; i < count; ++i)

View File

@ -25,8 +25,8 @@
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RamCheat::RamCheat(OSystem& os, const string& name, const string& code)
: Cheat(os, name, code),
address{uInt16(unhex(myCode.substr(0, 2)))},
value{uInt8(unhex(myCode.substr(2, 2)))}
address{static_cast<uInt16>(unhex(myCode.substr(0, 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
{
return uInt32(myFragmentQueue.size());
return static_cast<uInt32>(myFragmentQueue.size());
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -72,7 +72,7 @@ Int16* AudioQueue::enqueue(Int16* fragment)
{
lock_guard<mutex> guard(myMutex);
Int16* newFragment;
Int16* newFragment = nullptr;
if (!fragment) {
if (!myFirstFragmentForEnqueue) throw runtime_error("enqueue called empty");
@ -83,7 +83,7 @@ Int16* AudioQueue::enqueue(Int16* fragment)
return newFragment;
}
const uInt8 capacity = uInt8(myFragmentQueue.size());
const uInt8 capacity = static_cast<uInt8>(myFragmentQueue.size());
const uInt8 fragmentIndex = (myNextFragment + mySize) % capacity;
newFragment = myFragmentQueue.at(fragmentIndex);

View File

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

View File

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

View File

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

View File

@ -56,7 +56,7 @@ class EventHandlerSDL2 : public EventHandler
void pollEvent() override;
private:
SDL_Event myEvent;
SDL_Event myEvent{0};
// A thin wrapper around a basic PhysicalJoystick, holding the pointer to
// 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);
// evaluate fullscreen display modes (debug only for now)
int numModes = SDL_GetNumDisplayModes(i);
const int numModes = SDL_GetNumDisplayModes(i);
ostringstream s;
s << "Supported video modes (" << numModes << ") for display " << i
@ -166,7 +166,7 @@ void FBBackendSDL2::queryHardware(vector<Common::Size>& fullscreenRes,
{ "software", "Software" }
}};
int numDrivers = SDL_GetNumRenderDrivers();
const int numDrivers = SDL_GetNumRenderDrivers();
for(int i = 0; i < numDrivers; ++i)
{
SDL_RendererInfo info;
@ -229,9 +229,9 @@ bool FBBackendSDL2::setVideoMode(const VideoModeHandler::Mode& mode,
return false;
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");
if(myCenter)
@ -256,7 +256,7 @@ bool FBBackendSDL2::setVideoMode(const VideoModeHandler::Mode& mode,
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);
}
@ -287,8 +287,8 @@ bool FBBackendSDL2::setVideoMode(const VideoModeHandler::Mode& mode,
int w, h;
SDL_GetWindowSize(myWindow, &w, &h);
if(d != displayIndex || uInt32(w) != mode.screenS.w ||
uInt32(h) != mode.screenS.h || adaptRefresh)
if(d != displayIndex || static_cast<uInt32>(w) != mode.screenS.w ||
static_cast<uInt32>(h) != mode.screenS.h || adaptRefresh)
{
// Renderer has to be destroyed *before* the window gets destroyed to avoid memory leaks
SDL_DestroyRenderer(myRenderer);
@ -617,7 +617,7 @@ bool FBBackendSDL2::detectRenderTargetSupport()
if(!tex)
return false;
int sdlError = SDL_SetRenderTarget(myRenderer, tex);
const int sdlError = SDL_SetRenderTarget(myRenderer, tex);
SDL_SetRenderTarget(myRenderer, nullptr);
SDL_DestroyTexture(tex);

View File

@ -243,7 +243,7 @@ void FBSurfaceSDL2::createSurface(uInt32 width, uInt32 height,
////////////////////////////////////////////////////
// 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;
////////////////////////////////////////////////////

View File

@ -29,7 +29,7 @@
FilesystemNodeZIP::FilesystemNodeZIP(const string& p)
{
// 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)
return;
@ -185,7 +185,7 @@ bool FilesystemNodeZIP::getChildren(AbstractFSList& myList, ListMode mode) const
// First strip off the leading directory
const string& curr = next.substr(_virtualPath == "" ? 0 : _virtualPath.size()+1);
// Only add sub-directory entries once
auto pos = curr.find_first_of("/\\");
const auto pos = curr.find_first_of("/\\");
if(pos != string::npos)
dirs.emplace(curr.substr(0, pos));
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
// TODO: maybe there's a more efficient way to do this?
ByteBuffer buffer;
size_t size = read(buffer, 0);
const size_t size = read(buffer, 0);
if(size > 0)
image.write(reinterpret_cast<char*>(buffer.get()), size);

View File

@ -45,7 +45,7 @@ void FpsMeter::render(uInt32 frameCount)
return;
}
size_t queueSize = myQueue.capacity();
const size_t queueSize = myQueue.capacity();
entry first, last;
last.frames = frameCount;
@ -64,7 +64,7 @@ void FpsMeter::render(uInt32 frameCount)
first = myQueue.at(myQueueOffset);
}
float myTimeInterval =
const float myTimeInterval =
duration_cast<duration<float>>(last.timestamp - first.timestamp).count();
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)
jprops[SCORE_INVERTED] = info.scoreInvert;
uInt32 addrBytes = numAddrBytes(info.numDigits, info.trailingZeroes);
const uInt32 addrBytes = numAddrBytes(info.numDigits, info.trailingZeroes);
json addresses = json::array();
for(uInt32 a = 0; a < addrBytes; ++a)
@ -312,7 +312,7 @@ Int32 HighScoresManager::variation(uInt16 addr, bool varBCD, bool zeroBased,
if (!myOSystem.hasConsole())
return DEFAULT_VARIATION;
Int32 var = peek(addr);
const Int32 var = peek(addr);
return convert(var, numVariations, varBCD, zeroBased);
}
@ -344,11 +344,10 @@ Int32 HighScoresManager::score(uInt32 numAddrBytes, uInt32 trailingZeroes,
for (uInt32 b = 0; b < numAddrBytes; ++b)
{
uInt16 addr = scoreAddr[b];
Int32 score;
const uInt16 addr = scoreAddr[b];
totalScore *= isBCD ? 100 : 256;
score = peek(addr);
Int32 score = peek(addr);
if (isBCD)
{
score = fromBCD(score);
@ -373,7 +372,7 @@ Int32 HighScoresManager::score() const
uInt32 numBytes = numAddrBytes(properties(jprops));
const ScoreAddresses scoreAddr = getPropScoreAddr(jprops);
if(uInt32(scoreAddr.size()) < numBytes)
if(static_cast<uInt32>(scoreAddr.size()) < numBytes)
return NO_VALUE;
return score(numBytes, trailingZeroes(jprops), scoreBCD(jprops), scoreAddr);
}
@ -412,7 +411,7 @@ string HighScoresManager::md5Props() const
buf << varAddress(jprops) << numVariations() << varBCD(jprops)
<< varZeroBased(jprops);
uInt32 addrBytes = numAddrBytes(jprops);
const uInt32 addrBytes = numAddrBytes(jprops);
HSM::ScoreAddresses addr = getPropScoreAddr(jprops);
for(uInt32 a = 0; a < addrBytes; ++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 ? 1 : 0;
Int32 bits = isBCD
const Int32 bits = isBCD
? ceil(log(maxVal) / log(10) * 4)
: ceil(log(maxVal) / log(2));
@ -548,7 +547,7 @@ uInt16 HighScoresManager::fromHexStr(const string& addr) const
{
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);
return stringToIntBase16(naked);

View File

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

View File

@ -98,7 +98,7 @@ Event::Type JoyMap::get(const EventMode mode, const int button,
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool JoyMap::check(const JoyMapping& mapping) const
{
auto find = myMap.find(mapping);
const auto find = myMap.find(mapping);
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::Y: buf << "Y"; 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))
@ -290,7 +290,7 @@ json JoyMap::convertLegacyMapping(string list)
std::replace(list.begin(), list.end(), ',', ' ');
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
&& buf >> axis && buf >> adir
@ -302,7 +302,7 @@ json JoyMap::convertLegacyMapping(string list)
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["axisDirection"] = JoyDir(adir);
}
@ -323,7 +323,7 @@ void JoyMap::eraseMode(const EventMode mode)
{
for(auto item = myMap.begin(); item != myMap.end();)
if(item->first.mode == mode) {
auto _item = item++;
const auto _item = item++;
erase(_item->first);
}
else item++;
@ -334,7 +334,7 @@ void JoyMap::eraseEvent(const Event::Type event, const EventMode mode)
{
for(auto item = myMap.begin(); item != myMap.end();)
if(item->second == event && item->first.mode == mode) {
auto _item = item++;
const auto _item = item++;
erase(_item->first);
}
else item++;

View File

@ -99,15 +99,15 @@ Event::Type KeyMap::get(const Mapping& mapping) const
if(myModEnabled)
{
auto find = myMap.find(m);
const auto find = myMap.find(m);
if(find != myMap.end())
return find->second;
}
// 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())
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
{
auto find = myMap.find(convertMod(mapping));
const auto find = myMap.find(convertMod(mapping));
return (find != myMap.end());
}
@ -139,23 +139,23 @@ string KeyMap::getDesc(const Mapping& mapping) const
{
ostringstream buf;
#if defined(BSPF_MACOS) || defined(MACOS_KEYS)
string mod2 = "Option";
int MOD2 = KBDM_ALT;
int LMOD2 = KBDM_LALT;
int RMOD2 = KBDM_RALT;
string mod3 = "Cmd";
int MOD3 = KBDM_GUI;
int LMOD3 = KBDM_LGUI;
int RMOD3 = KBDM_RGUI;
const string mod2 = "Option";
constexpr int MOD2 = KBDM_ALT;
constexpr int LMOD2 = KBDM_LALT;
constexpr int RMOD2 = KBDM_RALT;
const string mod3 = "Cmd";
constexpr int MOD3 = KBDM_GUI;
constexpr int LMOD3 = KBDM_LGUI;
constexpr int RMOD3 = KBDM_RGUI;
#else
string mod2 = "Windows";
int MOD2 = KBDM_GUI;
int LMOD2 = KBDM_LGUI;
int RMOD2 = KBDM_RGUI;
string mod3 = "Alt";
int MOD3 = KBDM_ALT;
int LMOD3 = KBDM_LALT;
int RMOD3 = KBDM_RALT;
const string mod2 = "Windows";
constexpr int MOD2 = KBDM_GUI;
constexpr int LMOD2 = KBDM_LGUI;
constexpr int RMOD2 = KBDM_RGUI;
const string mod3 = "Alt";
constexpr int MOD3 = KBDM_ALT;
constexpr int LMOD3 = KBDM_LALT;
constexpr int RMOD3 = KBDM_RALT;
#endif
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(), ',', ' ');
istringstream buf(list);
int event, key, mod;
int event = 0, key = 0, mod = 0;
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();)
if(item->first.mode == mode) {
auto _item = item++;
const auto _item = item++;
erase(_item->first);
}
else item++;
@ -329,7 +329,7 @@ void KeyMap::eraseEvent(const Event::Type event, const EventMode mode)
{
for(auto item = myMap.begin(); item != myMap.end();)
if(item->second == event && item->first.mode == mode) {
auto _item = item++;
const auto _item = item++;
erase(_item->first);
}
else item++;
@ -346,7 +346,7 @@ KeyMap::Mapping KeyMap::convertMod(const Mapping& mapping) const
else
{
// 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;

View File

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

View File

@ -256,9 +256,9 @@ class LinkedObjectPool
uInt32 capacity() const { return myCapacity; }
uInt32 size() const { return uInt32(myList.size()); }
bool empty() const { return size() == 0; }
bool full() const { return size() >= capacity(); }
uInt32 size() const { return static_cast<uInt32>(myList.size()); }
bool empty() const { return size() == 0; }
bool full() const { return size() >= capacity(); }
friend ostream& operator<<(ostream& os, const LinkedObjectPool<T>& p) {
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[1] >= '0' && m_mode[1] <= '8')
{
MouseControl::Type xaxis = MouseControl::Type(int(m_mode[0]) - '0');
MouseControl::Type yaxis = MouseControl::Type(int(m_mode[1]) - '0');
const MouseControl::Type xaxis = static_cast<MouseControl::Type>(static_cast<int>(m_mode[0]) - '0');
const MouseControl::Type yaxis = static_cast<MouseControl::Type>(static_cast<int>(m_mode[1]) - '0');
ostringstream msg;
Controller::Type xtype = Controller::Type::Joystick, ytype = Controller::Type::Joystick;
int xid = -1, yid = -1;
auto MControlToController = [&msg](MouseControl::Type axis,
Controller::Type& type, int& id) {
const auto MControlToController = [&msg](MouseControl::Type axis,
Controller::Type& type, int& id) {
switch(axis)
{
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
// 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)
{
addLeftControllerModes(noswap);
@ -139,12 +139,13 @@ MouseControl::MouseControl(Console& console, const string& mode)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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];
bool leftControl =
const bool leftControl =
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);
myHasMouseControl = leftControl || rightControl;
@ -197,14 +198,14 @@ void MouseControl::addRightControllerModes(bool noswap)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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;
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 << "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"))
{

View File

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

View File

@ -138,7 +138,7 @@ int PhysicalJoystickHandler::add(const PhysicalJoystickPtr& stick)
if(erased)
// We have to add all Stelladaptors again, because they have changed
// 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)
addToDatabase(_stick);
@ -162,7 +162,7 @@ int PhysicalJoystickHandler::add(const PhysicalJoystickPtr& stick)
void PhysicalJoystickHandler::addToDatabase(const PhysicalJoystickPtr& stick)
{
// Add stick to database
auto it = myDatabase.find(stick->name);
const auto it = myDatabase.find(stick->name);
if(it != myDatabase.end()) // already present
{
it->second.joy = stick;
@ -195,7 +195,7 @@ bool PhysicalJoystickHandler::remove(int 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)
{
ostringstream buf;
@ -222,7 +222,7 @@ bool PhysicalJoystickHandler::remove(int id)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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)
{
myDatabase.erase(it);
@ -248,10 +248,10 @@ bool PhysicalJoystickHandler::mapStelladaptors(const string& saport, int ID)
saOrder[0] = 2; saOrder[1] = 1;
}
for(auto& [_id, _stick]: mySticks)
for(const auto& [_id, _stick]: mySticks)
{
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)
{
@ -303,7 +303,7 @@ bool PhysicalJoystickHandler::hasStelladaptors() const
for(auto& [_id, _joyptr] : mySticks)
{
// 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)
_joyptr->name.erase(pos);
@ -328,7 +328,7 @@ void PhysicalJoystickHandler::setDefaultAction(int stick,
// If event is 'NoType', erase and reset all mappings
// Otherwise, only reset the given event
bool eraseAll = !updateDefaults && (event == Event::NoType);
const bool eraseAll = !updateDefaults && (event == Event::NoType);
if(updateDefaults)
{
@ -395,9 +395,9 @@ void PhysicalJoystickHandler::setStickDefaultMapping(int stick, Event::Type even
}
#if defined(RETRON77)
const bool retron77 = true;
constexpr bool retron77 = true;
#else
const bool retron77 = false;
constexpr bool retron77 = false;
#endif
// 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++)
{
Event::Type event = static_cast<Event::Type>(i);
const Event::Type event = static_cast<Event::Type>(i);
if(isCommonEvent(event))
enableMapping(event, EventMode::kCommonMode);
@ -683,7 +683,7 @@ void PhysicalJoystickHandler::eraseMapping(Event::Type event, EventMode mode)
// Otherwise, only reset the given event
if(event == Event::NoType)
{
for (auto& [_id, _joyptr]: mySticks)
for (const auto& [_id, _joyptr]: mySticks)
{
_joyptr->eraseMap(mode); // erase all events
if(mode == EventMode::kEmulationMode)
@ -698,7 +698,7 @@ void PhysicalJoystickHandler::eraseMapping(Event::Type event, EventMode mode)
}
else
{
for (auto& [_id, _joyptr]: mySticks)
for (const auto& [_id, _joyptr]: mySticks)
{
_joyptr->eraseEvent(event, mode); // only reset the specific event
_joyptr->eraseEvent(event, getEventMode(event, mode));
@ -727,7 +727,7 @@ void PhysicalJoystickHandler::saveMapping()
string PhysicalJoystickHandler::getMappingDesc(Event::Type event, EventMode mode) const
{
ostringstream buf;
EventMode evMode = getEventMode(event, mode);
const EventMode evMode = getEventMode(event, mode);
for(const auto& [_id, _joyptr]: mySticks)
{
@ -753,9 +753,9 @@ bool PhysicalJoystickHandler::addJoyMapping(Event::Type event, EventMode mode, i
if(j && event < Event::LastType &&
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,
// 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 &&
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
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)
{
const PhysicalJoystickPtr j = joy(stick);
const PhysicalJoystickPtr& j = joy(stick);
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 button = j->buttonLast[stick];
const int button = j->buttonLast[stick];
if(myHandler.state() == EventHandlerState::EMULATION)
{
Event::Type eventAxisAnalog;
Event::Type eventAxisAnalog{};
// Check for analog events, which are handled differently
// A value change lower than ~90% indicates analog input
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);
}
@ -889,8 +890,10 @@ void PhysicalJoystickHandler::handleRegularAxisEvent(const PhysicalJoystickPtr j
{
// Otherwise, we assume the event is digital
// Every axis event has two associated values, negative and positive
Event::Type eventAxisNeg = j->joyMap.get(EventMode::kEmulationMode, button, JoyAxis(axis), JoyDir::NEG);
Event::Type eventAxisPos = j->joyMap.get(EventMode::kEmulationMode, button, JoyAxis(axis), JoyDir::POS);
const Event::Type eventAxisNeg = j->joyMap.get(EventMode::kEmulationMode, button,
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())
myHandler.handleEvent(eventAxisPos);
@ -932,10 +935,11 @@ void PhysicalJoystickHandler::handleRegularAxisEvent(const PhysicalJoystickPtr j
// Now filter out consecutive, similar values
// (only pass on the event if the state has changed)
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
myHandler.overlay().handleJoyAxisEvent(stick, JoyAxis(axis), JoyDir::NONE, button);
myHandler.overlay().handleJoyAxisEvent(stick, static_cast<JoyAxis>(axis), JoyDir::NONE, button);
j->axisLastValue[axis] = value;
}
#endif

View File

@ -95,15 +95,15 @@ class PhysicalJoystickHandler
void handleHatEvent(int stick, int hat, int value);
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);
}
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);
}
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);
}
@ -156,7 +156,7 @@ class PhysicalJoystickHandler
}
// Handle regular axis events (besides special Stelladaptor handling)
void handleRegularAxisEvent(const PhysicalJoystickPtr j,
void handleRegularAxisEvent(const PhysicalJoystickPtr& j,
int stick, int axis, int value);
// 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
// Otherwise, only reset the given event
bool eraseAll = !updateDefaults && (event == Event::NoType);
const bool eraseAll = !updateDefaults && (event == Event::NoType);
#ifdef GUI_SUPPORT
// 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 &&
!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)
{
//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:
{
EventMode mode = getMode(type);
const EventMode mode = getMode(type);
if(port == Controller::Jack::Left)
myLeftMode = mode;
@ -377,7 +377,7 @@ void PhysicalKeyboardHandler::enableCommonMappings()
{
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))
enableMapping(event, EventMode::kCommonMode);
@ -495,7 +495,7 @@ bool PhysicalKeyboardHandler::addMapping(Event::Type event, EventMode mode,
return false;
else
{
EventMode evMode = getEventMode(event, mode);
const EventMode evMode = getEventMode(event, mode);
// avoid double mapping in common and controller modes
if (evMode == EventMode::kCommonMode)
@ -543,13 +543,13 @@ void PhysicalKeyboardHandler::handleEvent(StellaKey key, StellaMod mod,
}
#endif
EventHandlerState estate = myHandler.state();
const EventHandlerState estate = myHandler.state();
// special handling for CompuMate in emulation modes
if ((estate == EventHandlerState::EMULATION || estate == EventHandlerState::PAUSE) &&
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.
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)
{
png_structp png_ptr = nullptr;
png_infop info_ptr = nullptr;
png_uint_32 iwidth, iheight;
int bit_depth, color_type, interlace_type;
png_structp png_ptr{nullptr};
png_infop info_ptr{nullptr};
png_uint_32 iwidth{0}, iheight{0};
int bit_depth{0}, color_type{0}, interlace_type{0};
auto loadImageERROR = [&](const char* s) {
const auto loadImageERROR = [&](const char* s) {
if(png_ptr)
png_destroy_read_struct(&png_ptr, info_ptr ? &info_ptr : nullptr, nullptr);
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
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
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())
);
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)
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
vector<png_bytep> rows(height);
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
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
vector<png_bytep> rows(height);
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
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_infop info_ptr = nullptr;
auto saveImageERROR = [&](const char* s) {
const auto saveImageERROR = [&](const char* s) {
if(png_ptr)
png_destroy_write_struct(&png_ptr, &info_ptr);
if(s)
@ -247,7 +247,7 @@ void PNGLibrary::saveImageToDisk(std::ofstream& out, const vector<png_bytep>& ro
void PNGLibrary::updateTime(uInt64 time)
{
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
{
buf << "Enabling snapshots in " << interval << " second intervals";
interval *= uInt32(myOSystem.frameRate());
interval *= static_cast<uInt32>(myOSystem.frameRate());
}
myOSystem.frameBuffer().showTextMessage(buf.str());
setContinuousSnapInterval(interval);
@ -385,11 +385,11 @@ void PNGLibrary::takeSnapshot(uInt32 number)
bool PNGLibrary::allocateStorage(png_uint_32 w, png_uint_32 h)
{
// 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())
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())
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)
{
// 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())
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)
{
uInt32 numComments = uInt32(comments.size());
const uInt32 numComments = static_cast<uInt32>(comments.size());
if(numComments == 0)
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(
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(
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();
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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);
}

View File

@ -180,15 +180,15 @@ class PNGLibrary
/**
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);
/** PNG library callback functions */
static void png_read_data(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_io_flush(png_structp ctx);
[[noreturn]] static void png_user_warn(png_structp ctx, png_const_charp str);
[[noreturn]] static void png_user_error(png_structp ctx, png_const_charp str);
static void png_read_data(const 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(const png_structp ctx);
[[noreturn]] static void png_user_warn(const png_structp ctx, png_const_charp str);
[[noreturn]] static void png_user_error(const png_structp ctx, png_const_charp str);
private:
// 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"));
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);
const string palette = toPaletteName(PaletteType(type));
const string palette = toPaletteName(static_cast<PaletteType>(type));
const string message = MESSAGES[type] + " palette";
myOSystem.frameBuffer().showTextMessage(message);
@ -139,10 +140,11 @@ void PaletteHandler::showAdjustableMessage()
void PaletteHandler::cycleAdjustable(int direction)
{
const bool isCustomPalette = SETTING_CUSTOM == myOSystem.settings().getString("palette");
bool isCustomAdj;
bool isCustomAdj = false;
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();
// skip phase shift when 'Custom' palette is not selected
if(!direction && isCustomAdj && !isCustomPalette)
@ -330,7 +332,7 @@ void PaletteHandler::setPalette()
const ConsoleTiming timing = myOSystem.console().timing();
const PaletteType paletteType = toPaletteType(name);
// 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)
generateCustomPalette(timing);
@ -342,7 +344,7 @@ void PaletteHandler::setPalette()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PaletteArray PaletteHandler::adjustedPalette(const PaletteArray& palette)
{
PaletteArray destPalette;
PaletteArray destPalette{0};
// Constants for saturation and gray scale calculation
constexpr float PR = .2989F;
constexpr float PG = .5870F;
@ -358,7 +360,7 @@ PaletteArray PaletteHandler::adjustedPalette(const PaletteArray& palette)
const float gamma = 1.1333F - myGamma * 0.5F;
/* match common PC's 2.2 gamma to TV's 2.65 gamma */
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++)
adjust[i] = powf(i * toFloat, gamma) * contrast + brightness;
@ -408,19 +410,25 @@ void PaletteHandler::loadUserPalette()
uInt8* pixbuf = in.get();
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;
}
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;
}
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
{
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)+1] = 0;
}

View File

@ -146,19 +146,19 @@ class PaletteHandler
Convert RGB adjustables from/to 100% scale
*/
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
*/
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
*/
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

View File

@ -28,7 +28,7 @@ bool PhosphorHandler::initialize(bool enable, int blend)
myPhosphorPercent = blend / 100.F;
// 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
c2 = static_cast<uInt8>(c2 * myPhosphorPercent);
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 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;
}

View File

@ -84,7 +84,7 @@ bool PhysicalJoystick::setMap(const json& map)
{
int i = 0;
for (auto& entry: map.items()) {
for (const auto& entry: map.items()) {
if (entry.key() == "name") continue;
try {
@ -130,9 +130,9 @@ json PhysicalJoystick::convertLegacyMapping(const string& mapping, const string&
// Remove leading "<mode>|" string
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;

View File

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

View File

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

View File

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

View File

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

View File

@ -128,7 +128,7 @@ void StateManager::toggleRecordMode()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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;
if(myActiveMode == Mode::TimeMachine)

View File

@ -57,7 +57,8 @@ class StringParser
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)
myStringList.push_back(line);
@ -66,7 +67,7 @@ class StringParser
size_t beg = 0;
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)
len = spos - beg;

View File

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

View File

@ -158,7 +158,7 @@ class TimerManager
TimerId id{0};
Timestamp next;
Duration period;
Duration period{0};
TFunction handler;
// 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;
// First calculate maximum zoom that keeps aspect ratio
const float scaleX = float(myImage.w) / myDisplay.w,
scaleY = float(myImage.h) / myDisplay.h;
const float scaleX = static_cast<float>(myImage.w) / myDisplay.w,
scaleY = static_cast<float>(myImage.h) / myDisplay.h;
float zoom = 1.F / std::max(scaleX, scaleY);
// 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;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -110,7 +110,7 @@ void BilinearBlitter::recreateTexturesIfNecessary()
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");
@ -126,7 +126,7 @@ void BilinearBlitter::recreateTexturesIfNecessary()
}
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 };
for (SDL_Texture* texture: textures) {

View File

@ -31,14 +31,14 @@ class BilinearBlitter : public Blitter {
~BilinearBlitter() override;
virtual void reinitialize(
void reinitialize(
SDL_Rect srcRect,
SDL_Rect destRect,
FBSurface::Attributes attributes,
SDL_Surface* staticData = nullptr
) override;
virtual void blit(SDL_Surface& surface) override;
void blit(SDL_Surface& surface) override;
private:
FBBackendSDL2& myFB;

View File

@ -145,7 +145,8 @@ void QisBlitter::recreateTexturesIfNecessary()
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.h = (myDstRect.h / mySrcRect.h) * mySrcRect.h;
@ -180,7 +181,7 @@ void QisBlitter::recreateTexturesIfNecessary()
}
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 = {
mySrcTexture, myIntermediateTexture, mySecondaryIntermedateTexture

View File

@ -33,14 +33,14 @@ class QisBlitter : public Blitter {
~QisBlitter() override;
virtual void reinitialize(
void reinitialize(
SDL_Rect srcRect,
SDL_Rect destRect,
FBSurface::Attributes attributes,
SDL_Surface* staticData = nullptr
) override;
virtual void blit(SDL_Surface& surface) override;
void blit(SDL_Surface& surface) override;
private:

View File

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

View File

@ -57,21 +57,21 @@ void AtariNTSC::generateKernels()
const uInt8* ptr = myRGBPalette.data();
for(size_t entry = 0; entry < myRGBPalette.size() / 3; ++entry)
{
float r = (*ptr++) / 255.F * rgb_unit + rgb_offset,
g = (*ptr++) / 255.F * rgb_unit + rgb_offset,
b = (*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,
b = (*ptr++) / 255.F * rgb_unit + rgb_offset;
float y, i, q; RGB_TO_YIQ( r, g, b, y, i, q );
// Generate kernel
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();
genKernel(myImpl, y, i, q, kernel);
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 + 7] - kernel [c + 3 +14];
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 yEnd = in_height * (threadNum + 1) / numThreads;
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;
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)
{
std::array<float, kernel_size * 2> kernels;
std::array<float, kernel_size * 2> kernels{0};
/* 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;
constexpr float maxh = 32;
float const pow_a_n = powf( rolloff, maxh );
float sum;
/* quadratic mapping to reduce negative (blurring) range */
float to_angle = setup.resolution + 1;
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 */
for ( int i = 0; i < kernel_half * 2 + 1; i++ )
{
int x = i - kernel_half;
float angle = x * to_angle;
const int x = i - kernel_half;
const float angle = x * to_angle;
/* instability occurs at center point with rolloff very close to 1.0 */
if ( x || pow_a_n > 1.056F || pow_a_n < 0.981F )
{
float rolloff_cos_a = rolloff * cosf( angle );
float num = 1 - rolloff_cos_a -
const float rolloff_cos_a = rolloff * cosf( angle );
const float num = 1 - rolloff_cos_a -
pow_a_n * cosf( maxh * 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;
kernels [kernel_size * 3 / 2 - kernel_half + i] = dsf - 0.5F;
}
}
/* apply blackman window and find sum */
sum = 0;
float sum = 0;
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 );
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;
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;
}
}
@ -454,7 +454,7 @@ void AtariNTSC::initFilters(init_t& impl, const Setup& setup)
weight -= 1.0F / rescale_in;
for ( int i = 0; i < kernel_size * 2; i++ )
{
float cur = kernels [i];
const float cur = kernels [i];
float m = cur * weight;
*out++ = m + remain;
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* k = &impl.kernel [pixel->offset];
int n;
++pixel;
for ( n = rgb_kernel_size; n; --n )
for ( int n = rgb_kernel_size; n; --n )
{
float fi = k[0]*ic0 + k[2]*ic2;
float fq = k[1]*qc1 + k[3]*qc3;
float fy = k[kernel_size+0]*yc0 + k[kernel_size+1]*yc1 +
const float fi = k[0]*ic0 + k[2]*ic2;
const float fq = k[1]*qc1 + k[3]*qc3;
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;
if ( k < &impl.kernel [kernel_size * 2 * (rescale_out - 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
// off a bit. Use atari_ntsc_black for unused pixels.
#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();\
unsigned const atari_ntsc_pixel1_ = (pixel1);\
uInt32 const* kernel1 = myColorTable[atari_ntsc_pixel1_].data();\
@ -211,7 +211,7 @@ class AtariNTSC
// Common ntsc macros
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;
io |= clamp;
clamp -= sub;

View File

@ -21,7 +21,7 @@
#include "NTSCFilter.hxx"
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)

View File

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

View File

@ -190,7 +190,7 @@ int CartDebug::lastWriteBaseAddress()
string CartDebug::toString()
{
ostringstream buf;
uInt32 bytesPerLine;
uInt32 bytesPerLine = 0;
switch(Base::format())
{
@ -245,7 +245,7 @@ string CartDebug::toString()
bool CartDebug::disassembleAddr(uInt16 address, bool force)
{
// 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);
}
@ -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
// Also check if the current PC is in the current list
bool bankChanged = myConsole.cartridge().bankChanged();
int pcline = addressToLine(PC);
bool pcfound = (pcline != -1) && (uInt32(pcline) < myDisassembly.list.size()) &&
(myDisassembly.list[pcline].disasm[0] != '.');
bool pagedirty = (PC & 0x1000) ? mySystem.isPageDirty(0x1000, 0x1FFF) :
mySystem.isPageDirty(0x80, 0xFF);
const bool bankChanged = myConsole.cartridge().bankChanged();
const int pcline = addressToLine(PC);
const bool pcfound = (pcline != -1) && (static_cast<uInt32>(pcline) < myDisassembly.list.size()) &&
(myDisassembly.list[pcline].disasm[0] != '.');
const bool pagedirty = (PC & 0x1000) ? mySystem.isPageDirty(0x1000, 0x1FFF) :
mySystem.isPageDirty(0x80, 0xFF);
bool changed = !mySystem.autodetectMode() &&
(force || bankChanged || !pcfound || pagedirty);
const bool changed = !mySystem.autodetectMode() &&
(force || bankChanged || !pcfound || pagedirty);
if(changed)
{
// 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
// specifically disabled
bool found = fillDisassemblyList(info, PC);
const bool found = fillDisassemblyList(info, PC);
if(!found && DiStella::settings.resolveCode)
{
// Temporarily turn off code resolution
@ -385,8 +385,8 @@ string CartDebug::disassembleLines(uInt16 start, uInt16 lines) const
ostringstream buffer;
// First find the lines in the range, and determine the longest string
uInt32 list_size = uInt32(myDisassembly.list.size());
uInt32 begin = list_size, end = 0, length = 0;
const size_t list_size = myDisassembly.list.size();
size_t begin = list_size, end = 0, length = 0;
for(end = 0; end < list_size && lines > 0; ++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(tag.type != Device::ROW)
length = std::max(length, uInt32(tag.disasm.length()));
length = std::max(length, tag.disasm.length());
--lines;
}
}
// 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];
if(tag.type == Device::NONE)
@ -412,7 +412,7 @@ string CartDebug::disassembleLines(uInt16 start, uInt16 lines) const
else
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::setw(4) << std::left << tag.ccount << " " << tag.bytes << endl;
}
@ -618,7 +618,7 @@ bool CartDebug::getLabel(ostream& buf, uInt16 addr, bool isRead,
{
if(isRead)
{
uInt16 a = addr & 0x0F, offset = addr & 0xFFF0;
const uInt16 a = addr & 0x0F, offset = addr & 0xFFF0;
if(ourTIAMnemonicR[a])
{
buf << ourTIAMnemonicR[a];
@ -630,7 +630,7 @@ bool CartDebug::getLabel(ostream& buf, uInt16 addr, bool isRead,
}
else
{
uInt16 a = addr & 0x3F, offset = addr & 0xFFC0;
const uInt16 a = addr & 0x3F, offset = addr & 0xFFC0;
if(ourTIAMnemonicW[a])
{
buf << ourTIAMnemonicW[a];
@ -645,7 +645,7 @@ bool CartDebug::getLabel(ostream& buf, uInt16 addr, bool isRead,
case AddrType::IO:
{
uInt16 a = addr & 0xFF, offset = addr & 0xFD00;
const uInt16 a = addr & 0xFF, offset = addr & 0xFD00;
if(a <= 0x9F)
{
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
// standard mnemonics
AddrToLabel::const_iterator iter;
uInt16 a = addr & 0xFF, offset = addr & 0xFF00;
const uInt16 a = addr & 0xFF, offset = addr & 0xFF00;
bool found = false;
// Search for nearest label
@ -798,7 +798,7 @@ string CartDebug::loadListFile()
if(addr_s.length() == 0)
continue;
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
if(!(addr & 0x1000))
@ -1063,8 +1063,8 @@ string CartDebug::saveDisassembly(string path)
"BLACK", "BLUE", "RED", "PURPLE",
"GREEN", "CYAN", "YELLOW", "WHITE"
};
bool isNTSC = myConsole.timing() == ConsoleTiming::ntsc;
bool isPAL = myConsole.timing() == ConsoleTiming::pal;
const bool isNTSC = myConsole.timing() == ConsoleTiming::ntsc;
const bool isPAL = myConsole.timing() == ConsoleTiming::pal;
#define ALIGN(x) setfill(' ') << left << setw(x)
@ -1086,8 +1086,8 @@ string CartDebug::saveDisassembly(string path)
Disassembly disasm;
disasm.list.reserve(2048);
uInt16 romBankCount = myConsole.cartridge().romBankCount();
uInt16 oldBank = myConsole.cartridge().getBank();
const uInt16 romBankCount = myConsole.cartridge().romBankCount();
const uInt16 oldBank = myConsole.cartridge().getBank();
// prepare for switching banks
myConsole.cartridge().unlockHotspots();
@ -1129,7 +1129,7 @@ string CartDebug::saveDisassembly(string path)
else
buf << " ORG $" << Base::HEX4 << origin << "\n"
<< " RORG $" << Base::HEX4 << info.offset << "\n\n";
origin += uInt32(info.size);
origin += static_cast<uInt32>(info.size);
// Format in 'distella' style
for(uInt32 i = 0; i < disasm.list.size(); ++i)
@ -1298,9 +1298,9 @@ string CartDebug::saveDisassembly(string path)
<< ";-----------------------------------------------------------\n\n";
for (uInt16 addr = 0x80; addr <= 0xFF; ++addr) {
bool ramUsed = (mySystem.getAccessFlags(addr) & (Device::DATA | Device::WRITE));
bool codeUsed = (mySystem.getAccessFlags(addr) & Device::CODE);
bool stackUsed = (mySystem.getAccessFlags(addr|0x100) & (Device::DATA | Device::WRITE));
const bool ramUsed = (mySystem.getAccessFlags(addr) & (Device::DATA | Device::WRITE));
const bool codeUsed = (mySystem.getAccessFlags(addr) & Device::CODE);
const bool stackUsed = (mySystem.getAccessFlags(addr|0x100) & (Device::DATA | Device::WRITE));
if (myReserved.ZPRAM[addr - 0x80] &&
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 0xa00: case 0xb00: case 0xe00: case 0xf00:
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));
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?
if(currType != prevType)
@ -1581,9 +1583,9 @@ void CartDebug::accessTypeAsString(ostream& buf, uInt16 addr) const
return;
}
uInt8 directive = myDisDirectives[addr & 0xFFF] & 0xFC,
debugger = myDebugger.getAccessFlags(addr) & 0xFC,
label = myDisLabels[addr & 0xFFF];
const uInt8 directive = myDisDirectives[addr & 0xFFF] & 0xFC,
debugger = myDebugger.getAccessFlags(addr) & 0xFC,
label = myDisLabels[addr & 0xFFF];
buf << endl << "directive: " << Base::toString(directive, Base::Fmt::_2_8) << " ";
AccessTypeAsString(buf, directive);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -178,8 +178,8 @@ class TIADebug : public DebuggerSystem
int cyclesThisLine() const;
bool vsync() const;
bool vblank() const;
int vsyncAsInt() const { return int(vsync()); } // so we can use _vsync pseudo-register
int vblankAsInt() const { return int(vblank()); } // so we can use _vblank pseudo-register
int vsyncAsInt() const { return static_cast<int>(vsync()); } // so we can use _vsync pseudo-register
int vblankAsInt() const { return static_cast<int>(vblank()); } // so we can use _vblank pseudo-register
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)
{
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,
Common::Base::toString(col, Common::Base::Fmt::_16_1),
TextAlign::Left);
@ -68,7 +69,7 @@ AudioWidget::AudioWidget(GuiObject* boss, const GUI::Font& lfont,
new StaticTextWidget(boss, lfont, xpos, ypos+2, lwidth, fontHeight,
"AUDC", TextAlign::Left);
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);
myAudC->setTarget(this);
myAudC->setID(kAUDCID);
@ -79,7 +80,7 @@ AudioWidget::AudioWidget(GuiObject* boss, const GUI::Font& lfont,
new StaticTextWidget(boss, lfont, xpos, ypos+2, lwidth, fontHeight,
"AUDV", TextAlign::Left);
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);
myAudV->setTarget(this);
myAudV->setID(kAUDVID);
@ -184,8 +185,8 @@ void AudioWidget::handleCommand(CommandSender* sender, int cmd, int data, int id
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AudioWidget::changeFrequencyRegs()
{
int addr = myAudF->getSelectedAddr();
int value = myAudF->getSelectedValue();
const int addr = myAudF->getSelectedAddr();
const int value = myAudF->getSelectedValue();
switch(addr)
{
@ -206,8 +207,8 @@ void AudioWidget::changeFrequencyRegs()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AudioWidget::changeControlRegs()
{
int addr = myAudC->getSelectedAddr();
int value = myAudC->getSelectedValue();
const int addr = myAudC->getSelectedAddr();
const int value = myAudC->getSelectedValue();
switch(addr)
{
@ -229,8 +230,8 @@ void AudioWidget::changeControlRegs()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void AudioWidget::changeVolumeRegs()
{
int addr = myAudV->getSelectedAddr();
int value = myAudV->getSelectedValue();
const int addr = myAudV->getSelectedAddr();
const int value = myAudV->getSelectedValue();
switch(addr)
{

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -24,24 +24,24 @@ CartridgeCDFInfoWidget::CartridgeCDFInfoWidget(
: CartDebugWidget(boss, lfont, nfont, x, y, w, h)
{
ostringstream info;
info << describeCDFVersion(cart.myCDFSubtype) << " cartridge\n"
<< (cart.romSize() / 1024) << "K ROM\n"
<< (cart.ramSize() / 1024) << "K RAM\n"
<< "Seven 4K banks are available to 2600\n"
<< "Functions accessible @ $FFF0 - $FFF3\n"
<< (cart.isCDFJplus() ? "Banks accessible @ $FFF4 to $FFFA\n" : "Banks accessible @ $FFF5 to $FFFB\n")
<< "Startup bank = " << cart.startBank() << "\n"
<< "Fast Fetcher(s): LDA #";
<< (cart.romSize() / 1024) << "K ROM\n"
<< (cart.ramSize() / 1024) << "K RAM\n"
<< "Seven 4K banks are available to 2600\n"
<< "Functions accessible @ $FFF0 - $FFF3\n"
<< (cart.isCDFJplus() ? "Banks accessible @ $FFF4 to $FFFA\n" : "Banks accessible @ $FFF5 to $FFFB\n")
<< "Startup bank = " << cart.startBank() << "\n"
<< "Fast Fetcher(s): LDA #";
if (cart.myLDXenabled)
info << ", LDX #";
if (cart.myLDYenabled)
info << ", LDY #";
info << "\n";
#if 0
// Eventually, we should query this from the debugger/disassembler
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),
myCart{cart}
{
const int VBORDER = 8;
const int HBORDER = 2;
const int INDENT = 20;
const int VGAP = 4;
constexpr int VBORDER = 8,
HBORDER = 2,
INDENT = 20,
VGAP = 4;
int xpos = HBORDER, ypos = VBORDER;
@ -64,14 +64,14 @@ CartridgeCDFWidget::CartridgeCDFWidget(
"Fast Fetcher enabled");
myFastFetch->setTarget(this);
myFastFetch->setEditable(false);
int lwidth;
int lwidth = 0;
// Fast Fetch Offset
if (isCDFJplus())
{
ypos += myLineHeight + VGAP;
new StaticTextWidget(_boss, _font, myFastFetch->getLeft(), ypos, "Fast Fetch Offset: ");
lwidth = _font.getStringWidth("Fast Fetch Offset: ");
@ -223,8 +223,6 @@ CartridgeCDFWidget::CartridgeCDFWidget(
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeCDFWidget::saveOldState()
{
Int32 ds_shift = isCDFJplus() ? 8 : 12;
myOldState.fastfetchoffset.clear();
myOldState.datastreampointers.clear();
myOldState.datastreamincrements.clear();
@ -235,8 +233,7 @@ void CartridgeCDFWidget::saveOldState()
myOldState.mwavesizes.clear();
myOldState.internalram.clear();
myOldState.samplepointer.clear();
if (isCDFJplus())
myOldState.fastfetchoffset.push_back(myCart.myRAM[myCart.myFastFetcherOffset]);
@ -252,7 +249,7 @@ void CartridgeCDFWidget::saveOldState()
// I = Increment
// 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));
}
@ -277,15 +274,14 @@ void CartridgeCDFWidget::saveOldState()
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void CartridgeCDFWidget::loadConfig()
{
Int32 ds_shift = isCDFJplus() ? 8 : 12;
const Int32 ds_shift = isCDFJplus() ? 8 : 12;
myBank->setSelectedIndex(myCart.getBank());
// Get registers, using change tracking
IntArray alist;
IntArray vlist;
BoolArray changed;
if (isCDFJplus())
{
alist.clear(); vlist.clear(); changed.clear();
@ -308,7 +304,7 @@ void CartridgeCDFWidget::loadConfig()
// I = Increment
// 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);
changed.push_back(pointervalue != myOldState.datastreampointers[i]);
}
@ -317,7 +313,7 @@ void CartridgeCDFWidget::loadConfig()
alist.clear(); vlist.clear(); changed.clear();
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);
changed.push_back(pointervalue != myOldState.datastreampointers[i]);
}
@ -331,7 +327,7 @@ void CartridgeCDFWidget::loadConfig()
alist.clear(); vlist.clear(); changed.clear();
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);
changed.push_back(pointervalue != myOldState.datastreampointers[0x21 + i]);
}
@ -340,7 +336,7 @@ void CartridgeCDFWidget::loadConfig()
alist.clear(); vlist.clear(); changed.clear();
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);
changed.push_back(incrementvalue != myOldState.datastreamincrements[i]);
}
@ -355,7 +351,7 @@ void CartridgeCDFWidget::loadConfig()
alist.clear(); vlist.clear(); changed.clear();
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);
changed.push_back(pointervalue != myOldState.datastreamincrements[0x21 + i]);
}

View File

@ -33,7 +33,7 @@ CartridgeCMWidget::CartridgeCMWidget(
: CartDebugWidget(boss, lfont, nfont, x, y, w, h),
myCart{cart}
{
uInt16 size = 4 * 4096;
constexpr uInt16 size = 4 * 4096;
string info =
"CM cartridge, four 4K banks + 2K RAM\n"
@ -87,7 +87,7 @@ CartridgeCMWidget::CartridgeCMWidget(
myIncrease->setTarget(this);
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)
ypos += myLineHeight + 4;
@ -168,7 +168,7 @@ void CartridgeCMWidget::loadConfig()
RiotDebug& riot = Debugger::debugger().riotDebug();
const RiotState& state = static_cast<const RiotState&>(riot.getState());
uInt8 swcha = myCart.mySWCHA;
const uInt8 swcha = myCart.mySWCHA;
// SWCHA
BoolArray oldbits, newbits, changed;

View File

@ -29,7 +29,7 @@ CartridgeCTYWidget::CartridgeCTYWidget(
: CartDebugWidget(boss, lfont, nfont, x, y, w, h),
myCart{cart}
{
uInt16 size = 8 * 4096;
constexpr uInt16 size = 8 * 4096;
string info =
"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"
"\nTHIS SCHEME IS NOT FULLY IMPLEMENTED OR TESTED\n";
int xpos = 2,
ypos = addBaseInformation(size, "Chris D. Walton", info) + myLineHeight;
constexpr int xpos = 2;
const int ypos = addBaseInformation(size, "Chris D. Walton", info) + myLineHeight;
VariantList items;
VarList::push_back(items, "1 ($FFF5)");
@ -96,7 +96,7 @@ string CartridgeCTYWidget::bankState()
static constexpr std::array<const char*, 8> spot = {
"", "$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB"
};
uInt16 bank = myCart.getBank();
const uInt16 bank = myCart.getBank();
buf << "Bank = " << std::dec << bank << ", hotspot = " << spot[bank];
return buf.str();

View File

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

View File

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

View File

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

View File

@ -28,7 +28,7 @@ CartridgeDPCPlusWidget::CartridgeDPCPlusWidget(
: CartridgeARMWidget(boss, lfont, nfont, x, y, w, h, cart),
myCart{cart}
{
size_t size = cart.mySize;
const size_t size = cart.mySize;
ostringstream info;
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),
myCart{cart}
{
const int V_GAP = 4;
size_t size = cart.mySize;
constexpr int V_GAP = 4;
const size_t size = cart.mySize;
ostringstream info;
info << "DPC cartridge, two 4K banks + 2K display bank\n"
@ -38,7 +38,8 @@ CartridgeDPCWidget::CartridgeDPCWidget(
<< "Startup bank = " << cart.startBank() << " or undetermined\n";
// 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];
start -= start % 0x1000;

View File

@ -46,7 +46,8 @@ int CartDebugWidget::addBaseInformation(size_t bytes, const string& manufacturer
EditTextWidget* w = nullptr;
ostringstream buf;
int x = 2, y = 8;
constexpr int x = 2;
int y = 8;
// Add ROM size, manufacturer and bankswitch info
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);
const StringList& sl = bs.stringList();
uInt32 lines = uInt32(sl.size());
size_t lines = sl.size();
if(lines < 3) lines = 3;
bool useScrollbar = false;
if(lines > maxlines)
@ -78,7 +79,8 @@ int CartDebugWidget::addBaseInformation(size_t bytes, const string& manufacturer
new StaticTextWidget(_boss, _font, x, y + 1, "Description ");
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->setEnabled(false);
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
virtual void saveOldState() { }
virtual void loadConfig() override;
virtual void handleCommand(CommandSender* sender, int cmd, int data, int id) override { }
void loadConfig() override;
void handleCommand(CommandSender* sender, int cmd, int data, int id) override { }
// Query internal state of the cart (usually just bankswitching info)
virtual string bankState() { return "0 (non-bankswitched)"; }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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