mirror of https://github.com/stella-emu/stella.git
Merge branch 'master' into feature/filesystem
This commit is contained in:
commit
a35dfc0906
|
@ -18,7 +18,7 @@ project.xcworkspace/
|
|||
xcuserdata/
|
||||
.DS_Store
|
||||
build/
|
||||
src/macosx/M6502.ins
|
||||
src/os/macos/M6502.ins
|
||||
*.dSYM
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/settings.json
|
||||
|
|
|
@ -1017,6 +1017,7 @@ clearSaveStateIfs - Clear all saveState points
|
|||
scanLine - Advance emulation by <xx> scanlines (default=1)
|
||||
step - Single step CPU [with count xx]
|
||||
stepWhile - Single step CPU while <condition> is true
|
||||
swchb - Set SWCHB to value xx
|
||||
tia - Show TIA state
|
||||
trace - Single step CPU over subroutines [with count xx]
|
||||
trap - Trap read/write access to address(es) xx [yy]
|
||||
|
|
|
@ -51,7 +51,7 @@ bool BankRomCheat::disable()
|
|||
myOSystem.console().cartridge().bank(bank);
|
||||
|
||||
for(int i = 0; i < count; ++i)
|
||||
myOSystem.console().cartridge().patch(address + i, savedRom[i]);
|
||||
myOSystem.console().cartridge().patch(address + i, savedRom[i]);
|
||||
|
||||
myOSystem.console().cartridge().bank(oldBank);
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ CheatCodeDialog::CheatCodeDialog(OSystem& osystem, DialogContainer& parent,
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
CheatCodeDialog::~CheatCodeDialog()
|
||||
CheatCodeDialog::~CheatCodeDialog() // NOLINT (we need an empty d'tor)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -128,14 +128,14 @@ void CheatCodeDialog::loadConfig()
|
|||
for(const auto& c: list)
|
||||
{
|
||||
l.push_back(c->name());
|
||||
b.push_back(bool(c->enabled()));
|
||||
b.push_back(c->enabled());
|
||||
}
|
||||
myCheatList->setList(l, b);
|
||||
|
||||
// Redraw the list, auto-selecting the first item if possible
|
||||
myCheatList->setSelected(l.size() > 0 ? 0 : -1);
|
||||
myCheatList->setSelected(!l.empty() ? 0 : -1);
|
||||
|
||||
const bool enabled = (list.size() > 0);
|
||||
const bool enabled = !list.empty();
|
||||
myEditButton->setEnabled(enabled);
|
||||
myRemoveButton->setEnabled(enabled);
|
||||
}
|
||||
|
@ -233,7 +233,7 @@ void CheatCodeDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
{
|
||||
const string& name = myCheatInput->getResult(0);
|
||||
const string& code = myCheatInput->getResult(1);
|
||||
if(instance().cheat().isValidCode(code))
|
||||
if(CheatManager::isValidCode(code))
|
||||
{
|
||||
myCheatInput->close();
|
||||
instance().cheat().add(name, code);
|
||||
|
@ -250,7 +250,7 @@ void CheatCodeDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
const string& code = myCheatInput->getResult(1);
|
||||
const bool enable = myCheatList->getSelectedState();
|
||||
const int idx = myCheatList->getSelected();
|
||||
if(instance().cheat().isValidCode(code))
|
||||
if(CheatManager::isValidCode(code))
|
||||
{
|
||||
myCheatInput->close();
|
||||
instance().cheat().add(name, code, enable, idx);
|
||||
|
@ -273,7 +273,7 @@ void CheatCodeDialog::handleCommand(CommandSender* sender, int cmd,
|
|||
{
|
||||
const string& name = myCheatInput->getResult(0);
|
||||
const string& code = myCheatInput->getResult(1);
|
||||
if(instance().cheat().isValidCode(code))
|
||||
if(CheatManager::isValidCode(code))
|
||||
{
|
||||
myCheatInput->close();
|
||||
instance().cheat().addOneShot(name, code);
|
||||
|
|
|
@ -93,8 +93,8 @@ void CheatManager::addPerFrame(const string& name, const string& code, bool enab
|
|||
}
|
||||
|
||||
// Make sure there are no duplicates
|
||||
bool found = false;
|
||||
uInt32 i;
|
||||
bool found{false};
|
||||
uInt32 i{0};
|
||||
for(i = 0; i < myPerFrameList.size(); ++i)
|
||||
{
|
||||
if(myPerFrameList[i]->code() == cheat->code())
|
||||
|
@ -272,11 +272,11 @@ void CheatManager::loadCheats(const string& md5sum)
|
|||
// Set up any cheatcodes that was on the command line
|
||||
// (and remove the key from the settings, so they won't get set again)
|
||||
const string& cheats = myOSystem.settings().getString("cheat");
|
||||
if(cheats != "")
|
||||
if(!cheats.empty())
|
||||
myOSystem.settings().setValue("cheat", "");
|
||||
|
||||
const auto& iter = myCheatMap.find(md5sum);
|
||||
if(iter == myCheatMap.end() && cheats == "")
|
||||
if(iter == myCheatMap.end() && cheats.empty())
|
||||
return;
|
||||
|
||||
// Remember the cheats for this ROM
|
||||
|
@ -311,7 +311,7 @@ void CheatManager::saveCheats(const string& md5sum)
|
|||
myCheatMap.erase(iter);
|
||||
|
||||
// Add new entry only if there are any cheats defined
|
||||
if(cheats.str() != "")
|
||||
if(!cheats.str().empty())
|
||||
myCheatMap.emplace(md5sum, cheats.str());
|
||||
}
|
||||
|
||||
|
@ -322,7 +322,7 @@ void CheatManager::saveCheats(const string& md5sum)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool CheatManager::isValidCode(const string& code) const
|
||||
bool CheatManager::isValidCode(const string& code)
|
||||
{
|
||||
for(const auto c: code)
|
||||
if(!isxdigit(c))
|
||||
|
|
|
@ -121,7 +121,7 @@ class CheatManager
|
|||
/**
|
||||
Checks if a code is valid.
|
||||
*/
|
||||
bool isValidCode(const string& code) const;
|
||||
static bool isValidCode(const string& code);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
|
|
@ -29,16 +29,20 @@ AudioQueue::AudioQueue(uInt32 fragmentSize, uInt32 capacity, bool isStereo)
|
|||
{
|
||||
const uInt8 sampleSize = myIsStereo ? 2 : 1;
|
||||
|
||||
myFragmentBuffer = make_unique<Int16[]>(myFragmentSize * sampleSize * (capacity + 2));
|
||||
myFragmentBuffer = make_unique<Int16[]>(
|
||||
static_cast<size_t>(myFragmentSize) * sampleSize * (capacity + 2));
|
||||
|
||||
for (uInt32 i = 0; i < capacity; ++i)
|
||||
myFragmentQueue[i] = myAllFragments[i] = myFragmentBuffer.get() + i * sampleSize * myFragmentSize;
|
||||
myFragmentQueue[i] = myAllFragments[i] = myFragmentBuffer.get() +
|
||||
static_cast<size_t>(myFragmentSize) * sampleSize * i;
|
||||
|
||||
myAllFragments[capacity] = myFirstFragmentForEnqueue =
|
||||
myFragmentBuffer.get() + capacity * sampleSize * myFragmentSize;
|
||||
myFragmentBuffer.get() + static_cast<size_t>(myFragmentSize) * sampleSize *
|
||||
capacity;
|
||||
|
||||
myAllFragments[capacity + 1] = myFirstFragmentForDequeue =
|
||||
myFragmentBuffer.get() + (capacity + 1) * sampleSize * myFragmentSize;
|
||||
myFragmentBuffer.get() + static_cast<size_t>(myFragmentSize) * sampleSize *
|
||||
(capacity + 1);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -83,7 +87,7 @@ Int16* AudioQueue::enqueue(Int16* fragment)
|
|||
return newFragment;
|
||||
}
|
||||
|
||||
const uInt8 capacity = static_cast<uInt8>(myFragmentQueue.size());
|
||||
const auto capacity = static_cast<uInt8>(myFragmentQueue.size());
|
||||
const uInt8 fragmentIndex = (myNextFragment + mySize) % capacity;
|
||||
|
||||
newFragment = myFragmentQueue.at(fragmentIndex);
|
||||
|
|
|
@ -39,7 +39,7 @@ namespace {
|
|||
numericResamplingQuality <= static_cast<int>(AudioSettings::ResamplingQuality::lanczos_3)
|
||||
) ? static_cast<AudioSettings::ResamplingQuality>(numericResamplingQuality) : AudioSettings::DEFAULT_RESAMPLING_QUALITY;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
AudioSettings::AudioSettings(Settings& settings)
|
||||
|
|
|
@ -47,74 +47,83 @@ string Base::toString(int value, Common::Base::Fmt outputBase)
|
|||
|
||||
case Base::Fmt::_10: // base 10: 3 or 5 bytes (depending on value)
|
||||
if(value > -0x100 && value < 0x100)
|
||||
std::snprintf(vToS_buf, 5, "%3d", static_cast<Int16>(value));
|
||||
std::ignore = std::snprintf(vToS_buf, 5, "%3d", static_cast<Int16>(value));
|
||||
else
|
||||
std::snprintf(vToS_buf, 6, "%5d", value);
|
||||
std::ignore = std::snprintf(vToS_buf, 6, "%5d", value);
|
||||
break;
|
||||
|
||||
case Base::Fmt::_10_02: // base 10: 2 digits (with leading zero)
|
||||
std::snprintf(vToS_buf, 3, "%02d", value);
|
||||
std::ignore = std::snprintf(vToS_buf, 3, "%02d", value);
|
||||
break;
|
||||
|
||||
case Base::Fmt::_10_3: // base 10: 3 digits
|
||||
std::snprintf(vToS_buf, 4, "%3d", value);
|
||||
std::ignore = std::snprintf(vToS_buf, 4, "%3d", value);
|
||||
break;
|
||||
|
||||
case Base::Fmt::_10_4: // base 10: 4 digits
|
||||
std::snprintf(vToS_buf, 5, "%4d", value);
|
||||
std::ignore = std::snprintf(vToS_buf, 5, "%4d", value);
|
||||
break;
|
||||
|
||||
case Base::Fmt::_10_5: // base 10: 5 digits
|
||||
std::snprintf(vToS_buf, 6, "%5d", value);
|
||||
std::ignore = std::snprintf(vToS_buf, 6, "%5d", value);
|
||||
break;
|
||||
|
||||
case Base::Fmt::_10_6: // base 10: 6 digits
|
||||
std::snprintf(vToS_buf, 7, "%6d", value);
|
||||
std::ignore = std::snprintf(vToS_buf, 7, "%6d", value);
|
||||
break;
|
||||
|
||||
case Base::Fmt::_10_8: // base 10: 8 digits
|
||||
std::snprintf(vToS_buf, 9, "%8d", value);
|
||||
std::ignore = std::snprintf(vToS_buf, 9, "%8d", value);
|
||||
break;
|
||||
|
||||
case Base::Fmt::_16_1: // base 16: 1 byte wide
|
||||
std::snprintf(vToS_buf, 2, hexUppercase() ? "%1X" : "%1x", value);
|
||||
std::ignore = std::snprintf(
|
||||
vToS_buf, 2, hexUppercase() ? "%1X" : "%1x", value);
|
||||
break;
|
||||
case Base::Fmt::_16_2: // base 16: 2 bytes wide
|
||||
std::snprintf(vToS_buf, 3, hexUppercase() ? "%02X" : "%02x", value);
|
||||
std::ignore = std::snprintf(
|
||||
vToS_buf, 3, hexUppercase() ? "%02X" : "%02x", value);
|
||||
break;
|
||||
case Base::Fmt::_16_2_2:
|
||||
std::snprintf(vToS_buf, 6, hexUppercase() ? "%02X.%02X" : "%02x.%02x",
|
||||
value >> 8, value & 0xff );
|
||||
std::ignore = std::snprintf(
|
||||
vToS_buf, 6, hexUppercase() ? "%02X.%02X" : "%02x.%02x",
|
||||
value >> 8, value & 0xff );
|
||||
break;
|
||||
case Base::Fmt::_16_3_2:
|
||||
std::snprintf(vToS_buf, 7, hexUppercase() ? "%03X.%02X" : "%03x.%02x",
|
||||
value >> 8, value & 0xff );
|
||||
std::ignore = std::snprintf(
|
||||
vToS_buf, 7, hexUppercase() ? "%03X.%02X" : "%03x.%02x",
|
||||
value >> 8, value & 0xff );
|
||||
break;
|
||||
case Base::Fmt::_16_4: // base 16: 4 bytes wide
|
||||
std::snprintf(vToS_buf, 5, hexUppercase() ? "%04X" : "%04x", value);
|
||||
std::ignore = std::snprintf(
|
||||
vToS_buf, 5, hexUppercase() ? "%04X" : "%04x", value);
|
||||
break;
|
||||
case Base::Fmt::_16_8: // base 16: 8 bytes wide
|
||||
std::snprintf(vToS_buf, 9, hexUppercase() ? "%08X" : "%08x", value);
|
||||
std::ignore = std::snprintf(
|
||||
vToS_buf, 9, hexUppercase() ? "%08X" : "%08x", value);
|
||||
break;
|
||||
|
||||
case Base::Fmt::_16: // base 16: 2, 4, 8 bytes (depending on value)
|
||||
default:
|
||||
if(value < 0x100)
|
||||
std::snprintf(vToS_buf, 3, hexUppercase() ? "%02X" : "%02x", value);
|
||||
std::ignore = std::snprintf(
|
||||
vToS_buf, 3, hexUppercase() ? "%02X" : "%02x", value);
|
||||
else if(value < 0x10000)
|
||||
std::snprintf(vToS_buf, 5, hexUppercase() ? "%04X" : "%04x", value);
|
||||
std::ignore = std::snprintf(
|
||||
vToS_buf, 5, hexUppercase() ? "%04X" : "%04x", value);
|
||||
else
|
||||
std::snprintf(vToS_buf, 9, hexUppercase() ? "%08X" : "%08x", value);
|
||||
std::ignore = std::snprintf(
|
||||
vToS_buf, 9, hexUppercase() ? "%08X" : "%08x", value);
|
||||
break;
|
||||
}
|
||||
|
||||
return string(vToS_buf);
|
||||
return {vToS_buf};
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Base::Fmt Base::myDefaultBase = Base::Fmt::_16;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
std::ios_base::fmtflags Base::myHexflags = std::ios_base::hex;
|
||||
std::ios_base::fmtflags Base::myHexflags = std::ios_base::hex; // NOLINT
|
||||
|
||||
} // Namespace Common
|
||||
} // namespace Common
|
||||
|
|
|
@ -30,7 +30,8 @@ EventHandlerSDL2::EventHandlerSDL2(OSystem& osystem)
|
|||
#ifdef GUI_SUPPORT
|
||||
{
|
||||
ostringstream buf;
|
||||
myQwertz = int{'y'} == static_cast<int>(SDL_GetKeyFromScancode(SDL_Scancode(KBDK_Z)));
|
||||
myQwertz = int{'y'} == static_cast<int>
|
||||
(SDL_GetKeyFromScancode(static_cast<SDL_Scancode>(KBDK_Z)));
|
||||
buf << "Keyboard: " << (myQwertz ? "QWERTZ" : "QWERTY");
|
||||
Logger::debug(buf.str());
|
||||
}
|
||||
|
@ -141,7 +142,7 @@ void EventHandlerSDL2::pollEvent()
|
|||
|
||||
case SDL_MOUSEWHEEL:
|
||||
{
|
||||
int x, y;
|
||||
int x{0}, y{0};
|
||||
SDL_GetMouseState(&x, &y); // we need mouse position too
|
||||
if(myEvent.wheel.y < 0)
|
||||
handleMouseButtonEvent(MouseButton::WHEELDOWN, true, x, y);
|
||||
|
|
|
@ -97,8 +97,7 @@ void FBBackendSDL2::queryHardware(vector<Common::Size>& fullscreenRes,
|
|||
s << "Supported video modes (" << numModes << ") for display " << i
|
||||
<< " (" << SDL_GetDisplayName(i) << "):";
|
||||
|
||||
string lastRes = "";
|
||||
|
||||
string lastRes;
|
||||
for(int m = 0; m < numModes; ++m)
|
||||
{
|
||||
SDL_DisplayMode mode;
|
||||
|
@ -174,11 +173,11 @@ void FBBackendSDL2::queryHardware(vector<Common::Size>& fullscreenRes,
|
|||
{
|
||||
// Map SDL names into nicer Stella names (if available)
|
||||
bool found = false;
|
||||
for(size_t j = 0; j < RENDERER_NAMES.size(); ++j)
|
||||
for(const auto& render: RENDERER_NAMES)
|
||||
{
|
||||
if(RENDERER_NAMES[j].sdlName == info.name)
|
||||
if(render.sdlName == info.name)
|
||||
{
|
||||
VarList::push_back(renderers, RENDERER_NAMES[j].stellaName, info.name);
|
||||
VarList::push_back(renderers, render.stellaName, info.name);
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
|
@ -284,7 +283,7 @@ bool FBBackendSDL2::setVideoMode(const VideoModeHandler::Mode& mode,
|
|||
if(myWindow)
|
||||
{
|
||||
const int d = SDL_GetWindowDisplayIndex(myWindow);
|
||||
int w, h;
|
||||
int w{0}, h{0};
|
||||
|
||||
SDL_GetWindowSize(myWindow, &w, &h);
|
||||
if(d != displayIndex || static_cast<uInt32>(w) != mode.screenS.w ||
|
||||
|
@ -358,8 +357,8 @@ bool FBBackendSDL2::adaptRefreshRate(Int32 displayIndex,
|
|||
const int wantedRefreshRate =
|
||||
myOSystem.hasConsole() ? myOSystem.console().gameRefreshRate() : 0;
|
||||
// Take care of rounded refresh rates (e.g. 59.94 Hz)
|
||||
float factor = std::min(float(currentRefreshRate) / wantedRefreshRate,
|
||||
float(currentRefreshRate) / (wantedRefreshRate - 1));
|
||||
float factor = std::min(
|
||||
static_cast<float>(currentRefreshRate) / wantedRefreshRate, static_cast<float>(currentRefreshRate) / (wantedRefreshRate - 1));
|
||||
// Calculate difference taking care of integer factors (e.g. 100/120)
|
||||
float bestDiff = std::abs(factor - std::round(factor)) / factor;
|
||||
bool adapt = false;
|
||||
|
@ -378,8 +377,9 @@ bool FBBackendSDL2::adaptRefreshRate(Int32 displayIndex,
|
|||
Logger::error("ERROR: Closest display mode could not be retrieved");
|
||||
return adapt;
|
||||
}
|
||||
factor = std::min(float(sdlMode.refresh_rate) / sdlMode.refresh_rate,
|
||||
float(sdlMode.refresh_rate) / (sdlMode.refresh_rate - 1));
|
||||
factor = std::min(
|
||||
static_cast<float>(sdlMode.refresh_rate) / sdlMode.refresh_rate,
|
||||
static_cast<float>(sdlMode.refresh_rate) / (sdlMode.refresh_rate - 1));
|
||||
const float diff = std::abs(factor - std::round(factor)) / factor;
|
||||
if(diff < bestDiff)
|
||||
{
|
||||
|
@ -428,7 +428,7 @@ bool FBBackendSDL2::createRenderer()
|
|||
if(myRenderer)
|
||||
SDL_DestroyRenderer(myRenderer);
|
||||
|
||||
if(video != "")
|
||||
if(!video.empty())
|
||||
SDL_SetHint(SDL_HINT_RENDER_DRIVER, video.c_str());
|
||||
|
||||
myRenderer = SDL_CreateRenderer(myWindow, -1, renderFlags);
|
||||
|
@ -567,7 +567,7 @@ unique_ptr<FBSurface> FBBackendSDL2::createSurface(
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void FBBackendSDL2::readPixels(uInt8* pixels, uInt32 pitch,
|
||||
void FBBackendSDL2::readPixels(uInt8* buffer, size_t pitch,
|
||||
const Common::Rect& rect) const
|
||||
{
|
||||
ASSERT_MAIN_THREAD;
|
||||
|
@ -576,7 +576,7 @@ void FBBackendSDL2::readPixels(uInt8* pixels, uInt32 pitch,
|
|||
r.x = rect.x(); r.y = rect.y();
|
||||
r.w = rect.w(); r.h = rect.h();
|
||||
|
||||
SDL_RenderReadPixels(myRenderer, &r, 0, pixels, pitch);
|
||||
SDL_RenderReadPixels(myRenderer, &r, 0, buffer, static_cast<int>(pitch));
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -121,7 +121,7 @@ class FBBackendSDL2 : public FBBackend
|
|||
@param pitch The pitch (in bytes) for the pixel data
|
||||
@param rect The bounding rectangle for the buffer
|
||||
*/
|
||||
void readPixels(uInt8* buffer, uInt32 pitch,
|
||||
void readPixels(uInt8* buffer, size_t pitch,
|
||||
const Common::Rect& rect) const override;
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace {
|
|||
throw runtime_error("unreachable");
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
FBSurfaceSDL2::FBSurfaceSDL2(FBBackendSDL2& backend,
|
||||
|
@ -249,9 +249,10 @@ void FBSurfaceSDL2::createSurface(uInt32 width, uInt32 height,
|
|||
|
||||
myIsStatic = data != nullptr;
|
||||
if(myIsStatic)
|
||||
SDL_memcpy(mySurface->pixels, data, mySurface->w * mySurface->h * 4);
|
||||
SDL_memcpy(mySurface->pixels, data,
|
||||
static_cast<size_t>(mySurface->w) * mySurface->h * 4);
|
||||
|
||||
reload();
|
||||
reload(); // NOLINT
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -38,7 +38,7 @@ FSNodeZIP::FSNodeZIP(const string& p)
|
|||
// Expand '~' to the users 'home' directory
|
||||
if (_zipFile[0] == '~')
|
||||
{
|
||||
const char* home = std::getenv("HOME");
|
||||
const char* home = std::getenv("HOME"); // NOLINT (not thread safe)
|
||||
if (home != nullptr)
|
||||
_zipFile.replace(0, 1, home);
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ void FSNodeZIP::setFlags(const string& zipfile, const string& virtualpath,
|
|||
_shortPath = _realNode->getShortPath();
|
||||
|
||||
// Is a file component present?
|
||||
if(_virtualPath.size() != 0)
|
||||
if(!_virtualPath.empty())
|
||||
{
|
||||
_path += ("/" + _virtualPath);
|
||||
_shortPath += ("/" + _virtualPath);
|
||||
|
@ -186,7 +186,7 @@ bool FSNodeZIP::getChildren(AbstractFSList& myList, ListMode mode) const
|
|||
{
|
||||
// First strip off the leading directory
|
||||
const string& curr = name.substr(
|
||||
_virtualPath == "" ? 0 : _virtualPath.size()+1);
|
||||
_virtualPath.empty() ? 0 : _virtualPath.size()+1);
|
||||
// cerr << " curr: " << curr << endl;
|
||||
// Only add sub-directory entries once
|
||||
const auto pos = curr.find_first_of("/\\");
|
||||
|
@ -199,7 +199,7 @@ bool FSNodeZIP::getChildren(AbstractFSList& myList, ListMode mode) const
|
|||
for(const auto& dir: dirs)
|
||||
{
|
||||
// Prepend previous path
|
||||
const string& vpath = _virtualPath != "" ? _virtualPath + "/" + dir : dir;
|
||||
const string& vpath = !_virtualPath.empty() ? _virtualPath + "/" + dir : dir;
|
||||
myList.emplace_back(new FSNodeZIP(_zipFile, vpath, _realNode, 0, true));
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ bool FSNodeZIP::getChildren(AbstractFSList& myList, ListMode mode) const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
size_t FSNodeZIP::read(ByteBuffer& image, size_t) const
|
||||
size_t FSNodeZIP::read(ByteBuffer& buffer, size_t) const
|
||||
{
|
||||
switch(_error)
|
||||
{
|
||||
|
@ -230,24 +230,24 @@ size_t FSNodeZIP::read(ByteBuffer& image, size_t) const
|
|||
found = name == _virtualPath;
|
||||
}
|
||||
|
||||
return found ? myZipHandler->decompress(image) : 0;
|
||||
return found ? myZipHandler->decompress(buffer) : 0;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
size_t FSNodeZIP::read(stringstream& image) const
|
||||
size_t FSNodeZIP::read(stringstream& buffer) const
|
||||
{
|
||||
// For now, we just read into a buffer and store in the stream
|
||||
// TODO: maybe there's a more efficient way to do this?
|
||||
ByteBuffer buffer;
|
||||
const size_t size = read(buffer, 0);
|
||||
ByteBuffer read_buf;
|
||||
const size_t size = read(read_buf, 0);
|
||||
if(size > 0)
|
||||
image.write(reinterpret_cast<char*>(buffer.get()), size);
|
||||
buffer.write(reinterpret_cast<char*>(read_buf.get()), size);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
size_t FSNodeZIP::write(const ByteBuffer& buffer, size_t size) const
|
||||
size_t FSNodeZIP::write(const ByteBuffer& buffer, size_t) const
|
||||
{
|
||||
// TODO: Not yet implemented
|
||||
throw runtime_error("ZIP file not writable");
|
||||
|
@ -263,7 +263,7 @@ size_t FSNodeZIP::write(const stringstream& buffer) const
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
AbstractFSNodePtr FSNodeZIP::getParent() const
|
||||
{
|
||||
if(_virtualPath == "")
|
||||
if(_virtualPath.empty())
|
||||
return _realNode ? _realNode->getParent() : nullptr;
|
||||
|
||||
const char* start = _path.c_str();
|
||||
|
|
|
@ -63,9 +63,9 @@ class FSNodeZIP : public AbstractFSNode
|
|||
bool getChildren(AbstractFSList& list, ListMode mode) const override;
|
||||
AbstractFSNodePtr getParent() const override;
|
||||
|
||||
size_t read(ByteBuffer& buffer, size_t size) const override;
|
||||
size_t read(ByteBuffer& buffer, size_t) const override;
|
||||
size_t read(stringstream& buffer) const override;
|
||||
size_t write(const ByteBuffer& buffer, size_t size) const override;
|
||||
size_t write(const ByteBuffer& buffer, size_t) const override;
|
||||
size_t write(const stringstream& buffer) const override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -65,9 +65,10 @@ HighScoresManager::HighScoresManager(OSystem& osystem)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void HighScoresManager::setRepository(shared_ptr<CompositeKeyValueRepositoryAtomic> repo)
|
||||
void HighScoresManager::setRepository(
|
||||
shared_ptr<CompositeKeyValueRepositoryAtomic> repo)
|
||||
{
|
||||
myHighscoreRepository = repo;
|
||||
myHighscoreRepository = std::move(repo);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -84,7 +85,7 @@ Int16 HighScoresManager::peek(uInt16 addr) const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const json HighScoresManager::properties(const Properties& props) const
|
||||
json HighScoresManager::properties(const Properties& props)
|
||||
{
|
||||
const string& property = props.get(PropType::Cart_Highscore);
|
||||
|
||||
|
@ -94,7 +95,6 @@ const json HighScoresManager::properties(const Properties& props) const
|
|||
return json::parse(property);
|
||||
}
|
||||
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
json HighScoresManager::properties(json& jprops) const
|
||||
{
|
||||
|
@ -113,7 +113,6 @@ json HighScoresManager::properties(json& jprops) const
|
|||
return jprops = properties(props);
|
||||
}
|
||||
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool HighScoresManager::enabled() const
|
||||
{
|
||||
|
@ -123,12 +122,11 @@ bool HighScoresManager::enabled() const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 HighScoresManager::numVariations(const json& jprops) const
|
||||
uInt32 HighScoresManager::numVariations(const json& jprops)
|
||||
{
|
||||
return min(getPropInt(jprops, VARIATIONS_COUNT, DEFAULT_VARIATION), MAX_VARIATIONS);
|
||||
}
|
||||
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool HighScoresManager::get(const Properties& props, uInt32& numVariationsR,
|
||||
ScoresProps& info) const
|
||||
|
@ -158,7 +156,7 @@ bool HighScoresManager::get(const Properties& props, uInt32& numVariationsR,
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void HighScoresManager::set(Properties& props, uInt32 numVariations,
|
||||
const ScoresProps& info) const
|
||||
const ScoresProps& info)
|
||||
{
|
||||
json jprops = json::object();
|
||||
|
||||
|
@ -206,85 +204,79 @@ void HighScoresManager::set(Properties& props, uInt32 numVariations,
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 HighScoresManager::numDigits(const json& jprops) const
|
||||
uInt32 HighScoresManager::numDigits(const json& jprops)
|
||||
{
|
||||
return min(getPropInt(jprops, SCORE_DIGITS, DEFAULT_DIGITS), MAX_SCORE_DIGITS);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 HighScoresManager::trailingZeroes(const json& jprops) const
|
||||
uInt32 HighScoresManager::trailingZeroes(const json& jprops)
|
||||
{
|
||||
return min(getPropInt(jprops, SCORE_TRAILING_ZEROES, DEFAULT_TRAILING), MAX_TRAILING);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool HighScoresManager::scoreBCD(const json& jprops) const
|
||||
bool HighScoresManager::scoreBCD(const json& jprops)
|
||||
{
|
||||
return getPropBool(jprops, SCORE_BCD, DEFAULT_SCORE_BCD);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool HighScoresManager::scoreInvert(const json& jprops) const
|
||||
bool HighScoresManager::scoreInvert(const json& jprops)
|
||||
{
|
||||
return getPropBool(jprops, SCORE_INVERTED, DEFAULT_SCORE_REVERSED);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool HighScoresManager::varBCD(const json& jprops) const
|
||||
bool HighScoresManager::varBCD(const json& jprops)
|
||||
{
|
||||
return getPropBool(jprops, VARIATIONS_BCD, DEFAULT_VARS_BCD);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool HighScoresManager::varZeroBased(const json& jprops) const
|
||||
bool HighScoresManager::varZeroBased(const json& jprops)
|
||||
{
|
||||
return getPropBool(jprops, VARIATIONS_ZERO_BASED, DEFAULT_VARS_ZERO_BASED);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const string HighScoresManager::specialLabel(const json& jprops) const
|
||||
string HighScoresManager::specialLabel(const json& jprops)
|
||||
{
|
||||
return getPropStr(jprops, SPECIAL_LABEL);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool HighScoresManager::specialBCD(const json& jprops) const
|
||||
bool HighScoresManager::specialBCD(const json& jprops)
|
||||
{
|
||||
return getPropBool(jprops, SPECIAL_BCD, DEFAULT_SPECIAL_BCD);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool HighScoresManager::specialZeroBased(const json& jprops) const
|
||||
bool HighScoresManager::specialZeroBased(const json& jprops)
|
||||
{
|
||||
return getPropBool(jprops, SPECIAL_ZERO_BASED, DEFAULT_SPECIAL_ZERO_BASED);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const string HighScoresManager::notes(const json& jprops) const
|
||||
string HighScoresManager::notes(const json& jprops)
|
||||
{
|
||||
return getPropStr(jprops, NOTES);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt16 HighScoresManager::varAddress(const json& jprops) const
|
||||
uInt16 HighScoresManager::varAddress(const json& jprops)
|
||||
{
|
||||
return getPropAddr(jprops, VARIATIONS_ADDRESS, DEFAULT_ADDRESS);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt16 HighScoresManager::specialAddress(const json& jprops) const
|
||||
uInt16 HighScoresManager::specialAddress(const json& jprops)
|
||||
{
|
||||
return getPropAddr(jprops, SPECIAL_ADDRESS, DEFAULT_ADDRESS);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 HighScoresManager::numAddrBytes(Int32 digits, Int32 trailing) const
|
||||
{
|
||||
return (digits - trailing + 1) / 2;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 HighScoresManager::numAddrBytes(const json& jprops) const
|
||||
uInt32 HighScoresManager::numAddrBytes(const json& jprops)
|
||||
{
|
||||
return numAddrBytes(numDigits(jprops), trailingZeroes(jprops));
|
||||
}
|
||||
|
@ -298,7 +290,7 @@ Int32 HighScoresManager::numVariations() const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const string HighScoresManager::specialLabel() const
|
||||
string HighScoresManager::specialLabel() const
|
||||
{
|
||||
json jprops;
|
||||
|
||||
|
@ -378,7 +370,7 @@ Int32 HighScoresManager::score() const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const string HighScoresManager::formattedScore(Int32 score, Int32 width) const
|
||||
string HighScoresManager::formattedScore(Int32 score, Int32 width) const
|
||||
{
|
||||
if(score <= 0)
|
||||
return "";
|
||||
|
@ -402,6 +394,7 @@ const string HighScoresManager::formattedScore(Int32 score, Int32 width) const
|
|||
return buf.str();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string HighScoresManager::md5Props() const
|
||||
{
|
||||
json jprops;
|
||||
|
@ -424,6 +417,7 @@ string HighScoresManager::md5Props() const
|
|||
return MD5::hash(buf.str());
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool HighScoresManager::scoreInvert() const
|
||||
{
|
||||
json jprops;
|
||||
|
@ -454,7 +448,7 @@ Int32 HighScoresManager::special() const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const string HighScoresManager::notes() const
|
||||
string HighScoresManager::notes() const
|
||||
{
|
||||
json jprops;
|
||||
|
||||
|
@ -462,7 +456,8 @@ const string HighScoresManager::notes() const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Int32 HighScoresManager::convert(Int32 val, uInt32 maxVal, bool isBCD, bool zeroBased) const
|
||||
Int32 HighScoresManager::convert(Int32 val, uInt32 maxVal, bool isBCD,
|
||||
bool zeroBased)
|
||||
{
|
||||
//maxVal += zeroBased ? 0 : 1;
|
||||
maxVal -= zeroBased ? 1 : 0;
|
||||
|
@ -486,29 +481,28 @@ Int32 HighScoresManager::convert(Int32 val, uInt32 maxVal, bool isBCD, bool zero
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool HighScoresManager::getPropBool(const json& jprops, const string& key,
|
||||
bool defVal) const
|
||||
bool defVal)
|
||||
{
|
||||
return jprops.contains(key) ? jprops.at(key).get<bool>() : defVal;
|
||||
}
|
||||
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 HighScoresManager::getPropInt(const json& jprops, const string& key,
|
||||
uInt32 defVal) const
|
||||
uInt32 defVal)
|
||||
{
|
||||
return jprops.contains(key) ? jprops.at(key).get<uInt32>() : defVal;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const string HighScoresManager::getPropStr(const json& jprops, const string& key,
|
||||
const string& defVal) const
|
||||
string HighScoresManager::getPropStr(const json& jprops, const string& key,
|
||||
const string& defVal)
|
||||
{
|
||||
return jprops.contains(key) ? jprops.at(key).get<string>() : defVal;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt16 HighScoresManager::getPropAddr(const json& jprops, const string& key,
|
||||
uInt16 defVal) const
|
||||
uInt16 defVal)
|
||||
{
|
||||
const string str = getPropStr(jprops, key);
|
||||
|
||||
|
@ -516,7 +510,7 @@ uInt16 HighScoresManager::getPropAddr(const json& jprops, const string& key,
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const HSM::ScoreAddresses HighScoresManager::getPropScoreAddr(const json& jprops) const
|
||||
HSM::ScoreAddresses HighScoresManager::getPropScoreAddr(const json& jprops)
|
||||
{
|
||||
ScoreAddresses scoreAddr{};
|
||||
|
||||
|
@ -543,7 +537,7 @@ const HSM::ScoreAddresses HighScoresManager::getPropScoreAddr(const json& jprops
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt16 HighScoresManager::fromHexStr(const string& addr) const
|
||||
uInt16 HighScoresManager::fromHexStr(const string& addr)
|
||||
{
|
||||
string naked = addr;
|
||||
|
||||
|
@ -554,7 +548,7 @@ uInt16 HighScoresManager::fromHexStr(const string& addr) const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Int32 HighScoresManager::fromBCD(uInt8 bcd) const
|
||||
Int32 HighScoresManager::fromBCD(uInt8 bcd)
|
||||
{
|
||||
// verify if score is legit
|
||||
if ((bcd & 0xF0) >= 0xA0 || (bcd & 0xF) >= 0xA)
|
||||
|
@ -701,12 +695,12 @@ bool HighScoresManager::load(const json& hsData, ScoresData& data)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void HighScoresManager::clearHighScores(ScoresData& data)
|
||||
{
|
||||
for(uInt32 r = 0; r < NUM_RANKS; ++r)
|
||||
for(auto& s: data.scores)
|
||||
{
|
||||
data.scores[r].score = 0;
|
||||
data.scores[r].special = 0;
|
||||
data.scores[r].name = "";
|
||||
data.scores[r].date = "";
|
||||
s.score = 0;
|
||||
s.special = 0;
|
||||
s.name = "";
|
||||
s.date = "";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -112,8 +112,8 @@ class HighScoresManager
|
|||
/**
|
||||
Set the highscore data of game's properties
|
||||
*/
|
||||
void set(Properties& props, uInt32 numVariations,
|
||||
const HSM::ScoresProps& info) const;
|
||||
static void set(Properties& props, uInt32 numVariations,
|
||||
const HSM::ScoresProps& info);
|
||||
|
||||
/**
|
||||
Calculate the score from given parameters
|
||||
|
@ -125,24 +125,26 @@ class HighScoresManager
|
|||
|
||||
// Convert the given value, using only the maximum bits required by maxVal
|
||||
// and adjusted for BCD and zero based data
|
||||
Int32 convert(Int32 val, uInt32 maxVal, bool isBCD, bool zeroBased) const;
|
||||
static Int32 convert(Int32 val, uInt32 maxVal, bool isBCD, bool zeroBased);
|
||||
|
||||
/**
|
||||
Calculate the number of bytes for one player's score from given parameters
|
||||
|
||||
@return The number of score address bytes
|
||||
*/
|
||||
uInt32 numAddrBytes(Int32 digits, Int32 trailing) const;
|
||||
static uInt32 numAddrBytes(Int32 digits, Int32 trailing) {
|
||||
return (digits - trailing + 1) / 2;
|
||||
}
|
||||
|
||||
// Retrieve current values (using game's properties)
|
||||
Int32 numVariations() const;
|
||||
const string specialLabel() const;
|
||||
string specialLabel() const;
|
||||
Int32 variation() const;
|
||||
Int32 score() const;
|
||||
const string formattedScore(Int32 score, Int32 width = -1) const;
|
||||
string formattedScore(Int32 score, Int32 width = -1) const;
|
||||
bool scoreInvert() const;
|
||||
Int32 special() const;
|
||||
const string notes() const;
|
||||
string notes() const;
|
||||
|
||||
// Get md5 property definition checksum
|
||||
string md5Props() const;
|
||||
|
@ -150,8 +152,8 @@ class HighScoresManager
|
|||
// Peek into memory
|
||||
Int16 peek(uInt16 addr) const;
|
||||
|
||||
void loadHighScores(HSM::ScoresData& scores);
|
||||
void saveHighScores(HSM::ScoresData& scores) const;
|
||||
void loadHighScores(HSM::ScoresData& data);
|
||||
void saveHighScores(HSM::ScoresData& data) const;
|
||||
|
||||
private:
|
||||
static const string VARIATIONS_COUNT;
|
||||
|
@ -198,53 +200,53 @@ class HighScoresManager
|
|||
Int32 variation(uInt16 addr, bool varBCD, bool zeroBased, uInt32 numVariations) const;
|
||||
|
||||
// Get individual highscore info from properties
|
||||
uInt32 numVariations(const json& jprops) const;
|
||||
uInt16 varAddress(const json& jprops) const;
|
||||
uInt16 specialAddress(const json& jprops) const;
|
||||
uInt32 numDigits(const json& jprops) const;
|
||||
uInt32 trailingZeroes(const json& jprops) const;
|
||||
bool scoreBCD(const json& jprops) const;
|
||||
bool scoreInvert(const json& jprops) const;
|
||||
bool varBCD(const json& jprops) const;
|
||||
bool varZeroBased(const json& jprops) const;
|
||||
const string specialLabel(const json& jprops) const;
|
||||
bool specialBCD(const json& jprops) const;
|
||||
bool specialZeroBased(const json& jprops) const;
|
||||
const string notes(const json& jprops) const;
|
||||
static uInt32 numVariations(const json& jprops);
|
||||
static uInt16 varAddress(const json& jprops);
|
||||
static uInt16 specialAddress(const json& jprops);
|
||||
static uInt32 numDigits(const json& jprops);
|
||||
static uInt32 trailingZeroes(const json& jprops);
|
||||
static bool scoreBCD(const json& jprops);
|
||||
static bool scoreInvert(const json& jprops);
|
||||
static bool varBCD(const json& jprops);
|
||||
static bool varZeroBased(const json& jprops);
|
||||
static string specialLabel(const json& jprops);
|
||||
static bool specialBCD(const json& jprops);
|
||||
static bool specialZeroBased(const json& jprops);
|
||||
static string notes(const json& jprops);
|
||||
|
||||
// Calculate the number of bytes for one player's score from property parameters
|
||||
uInt32 numAddrBytes(const json& jprops) const;
|
||||
static uInt32 numAddrBytes(const json& jprops);
|
||||
|
||||
// Get properties
|
||||
const json properties(const Properties& props) const;
|
||||
static json properties(const Properties& props);
|
||||
json properties(json& jprops) const;
|
||||
|
||||
// Get value from highscore properties for given key
|
||||
bool getPropBool(const json& jprops, const string& key,
|
||||
bool defVal = false) const;
|
||||
uInt32 getPropInt(const json& jprops, const string& key,
|
||||
uInt32 defVal = 0) const;
|
||||
const string getPropStr(const json& jprops, const string& key,
|
||||
const string& defVal = "") const;
|
||||
uInt16 getPropAddr(const json& jprops, const string& key,
|
||||
uInt16 defVal = 0) const;
|
||||
const HSM::ScoreAddresses getPropScoreAddr(const json& jprops) const;
|
||||
static bool getPropBool(const json& jprops, const string& key,
|
||||
bool defVal = false);
|
||||
static uInt32 getPropInt(const json& jprops, const string& key,
|
||||
uInt32 defVal = 0);
|
||||
static string getPropStr(const json& jprops, const string& key,
|
||||
const string& defVal = "");
|
||||
static uInt16 getPropAddr(const json& jprops, const string& key,
|
||||
uInt16 defVal = 0);
|
||||
static HSM::ScoreAddresses getPropScoreAddr(const json& jprops);
|
||||
|
||||
uInt16 fromHexStr(const string& addr) const;
|
||||
Int32 fromBCD(uInt8 bcd) const;
|
||||
static uInt16 fromHexStr(const string& addr);
|
||||
static Int32 fromBCD(uInt8 bcd);
|
||||
string hash(const HSM::ScoresData& data) const;
|
||||
|
||||
/**
|
||||
Loads the current high scores for this game and variation from the given JSON object.
|
||||
|
||||
@param hsData The JSON to parse
|
||||
@param scores The loaded high score data
|
||||
@param data The loaded high score data
|
||||
|
||||
@return The result of the load. True on success, false on failure.
|
||||
*/
|
||||
bool load(const json& hsData, HSM::ScoresData& scores);
|
||||
static bool load(const json& hsData, HSM::ScoresData& data);
|
||||
|
||||
void clearHighScores(HSM::ScoresData& data);
|
||||
static void clearHighScores(HSM::ScoresData& data);
|
||||
|
||||
private:
|
||||
// Reference to the osystem object
|
||||
|
@ -261,4 +263,5 @@ class HighScoresManager
|
|||
HighScoresManager& operator=(const HighScoresManager&) = delete;
|
||||
HighScoresManager& operator=(HighScoresManager&&) = delete;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -87,7 +87,7 @@ void JPGLibrary::loadImagetoSurface(FBSurface& surface)
|
|||
surface.setSrcSize(iw, ih);
|
||||
|
||||
// Convert RGB triples into pixels and store in the surface
|
||||
uInt32* s_buf, s_pitch;
|
||||
uInt32 *s_buf{nullptr}, s_pitch{0};
|
||||
surface.basePtr(s_buf, s_pitch);
|
||||
const uInt8* i_buf = myReadInfo.buffer;
|
||||
const uInt32 i_pitch = myReadInfo.pitch;
|
||||
|
|
|
@ -46,7 +46,8 @@ class JPGLibrary
|
|||
runtime_error is thrown containing a more detailed
|
||||
error message.
|
||||
*/
|
||||
void loadImage(const string& filename, FBSurface& surface, VariantList& metaData);
|
||||
void loadImage(const string& filename, FBSurface& surface,
|
||||
VariantList& metaData);
|
||||
|
||||
private:
|
||||
// Global OSystem object
|
||||
|
@ -76,7 +77,7 @@ class JPGLibrary
|
|||
@param filename The filename to load the JPG image
|
||||
@param metaData The meta data of the JPG image
|
||||
*/
|
||||
void readMetaData(const string& filename, VariantList& metaData);
|
||||
static void readMetaData(const string& filename, VariantList& metaData);
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
|
|
|
@ -112,7 +112,7 @@ bool JoyMap::check(const EventMode mode, const int button,
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string JoyMap::getDesc(const Event::Type event, const JoyMapping& mapping) const
|
||||
string JoyMap::getDesc(const Event::Type event, const JoyMapping& mapping)
|
||||
{
|
||||
ostringstream buf;
|
||||
|
||||
|
@ -166,7 +166,7 @@ string JoyMap::getEventMappingDesc(int stick, const Event::Type event, const Eve
|
|||
{
|
||||
if (_event == event && _mapping.mode == mode)
|
||||
{
|
||||
if(buf.str() != "")
|
||||
if(!buf.str().empty())
|
||||
buf << ", ";
|
||||
buf << "C" << stick << getDesc(event, _mapping);
|
||||
}
|
||||
|
@ -193,26 +193,26 @@ json JoyMap::saveMapping(const EventMode mode) const
|
|||
std::vector<MapType> sortedMap(myMap.begin(), myMap.end());
|
||||
|
||||
std::sort(sortedMap.begin(), sortedMap.end(),
|
||||
[](const MapType& a, const MapType& b)
|
||||
{
|
||||
// Event::Type first
|
||||
if(a.first.button != b.first.button)
|
||||
return a.first.button < b.first.button;
|
||||
[](const MapType& a, const MapType& b)
|
||||
{
|
||||
// Event::Type first
|
||||
if(a.first.button != b.first.button)
|
||||
return a.first.button < b.first.button;
|
||||
|
||||
if(a.first.axis != b.first.axis)
|
||||
return a.first.axis < b.first.axis;
|
||||
if(a.first.axis != b.first.axis)
|
||||
return a.first.axis < b.first.axis;
|
||||
|
||||
if(a.first.adir != b.first.adir)
|
||||
return a.first.adir < b.first.adir;
|
||||
if(a.first.adir != b.first.adir)
|
||||
return a.first.adir < b.first.adir;
|
||||
|
||||
if(a.first.hat != b.first.hat)
|
||||
return a.first.hat < b.first.hat;
|
||||
if(a.first.hat != b.first.hat)
|
||||
return a.first.hat < b.first.hat;
|
||||
|
||||
if(a.first.hdir != b.first.hdir)
|
||||
return a.first.hdir < b.first.hdir;
|
||||
if(a.first.hdir != b.first.hdir)
|
||||
return a.first.hdir < b.first.hdir;
|
||||
|
||||
return a.second < b.second;
|
||||
}
|
||||
return a.second < b.second;
|
||||
}
|
||||
);
|
||||
|
||||
json eventMappings = json::array();
|
||||
|
@ -298,18 +298,18 @@ json JoyMap::convertLegacyMapping(string list)
|
|||
{
|
||||
json eventMapping = json::object();
|
||||
|
||||
eventMapping["event"] = Event::Type(event);
|
||||
eventMapping["event"] = static_cast<Event::Type>(event);
|
||||
|
||||
if(button != JOY_CTRL_NONE) eventMapping["button"] = button;
|
||||
|
||||
if(static_cast<JoyAxis>(axis) != JoyAxis::NONE) {
|
||||
eventMapping["axis"] = JoyAxis(axis);
|
||||
eventMapping["axisDirection"] = JoyDir(adir);
|
||||
eventMapping["axis"] = static_cast<JoyAxis>(axis);
|
||||
eventMapping["axisDirection"] = static_cast<JoyDir>(adir);
|
||||
}
|
||||
|
||||
if(hat != -1) {
|
||||
eventMapping["hat"] = hat;
|
||||
eventMapping["hatDirection"] = JoyHatDir(hdir);
|
||||
eventMapping["hatDirection"] = static_cast<JoyHatDir>(hdir);
|
||||
}
|
||||
|
||||
eventMappings.push_back(eventMapping);
|
||||
|
|
|
@ -122,10 +122,10 @@ class JoyMap
|
|||
void eraseEvent(const Event::Type event, const EventMode mode);
|
||||
/** clear all mappings for a modes */
|
||||
// void clear() { myMap.clear(); }
|
||||
size_t size() { return myMap.size(); }
|
||||
size_t size() const { return myMap.size(); }
|
||||
|
||||
private:
|
||||
string getDesc(const Event::Type event, const JoyMapping& mapping) const;
|
||||
static string getDesc(const Event::Type event, const JoyMapping& mapping);
|
||||
|
||||
struct JoyHash {
|
||||
size_t operator()(const JoyMapping& m)const {
|
||||
|
|
|
@ -25,7 +25,7 @@ using json = nlohmann::json;
|
|||
namespace {
|
||||
json serializeModkeyMask(int mask)
|
||||
{
|
||||
if(mask == StellaMod::KBDM_NONE) return json(nullptr);
|
||||
if(mask == StellaMod::KBDM_NONE) return {};
|
||||
|
||||
json serializedMask = json::array();
|
||||
|
||||
|
@ -66,7 +66,7 @@ namespace {
|
|||
|
||||
return mask;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void KeyMap::add(const Event::Type event, const Mapping& mapping)
|
||||
|
@ -135,7 +135,7 @@ bool KeyMap::check(const EventMode mode, const int key, const int mod) const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string KeyMap::getDesc(const Mapping& mapping) const
|
||||
string KeyMap::getDesc(const Mapping& mapping)
|
||||
{
|
||||
ostringstream buf;
|
||||
#if defined(BSPF_MACOS) || defined(MACOS_KEYS)
|
||||
|
@ -184,7 +184,7 @@ string KeyMap::getDesc(const Mapping& mapping) const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string KeyMap::getDesc(const EventMode mode, const int key, const int mod) const
|
||||
string KeyMap::getDesc(const EventMode mode, const int key, const int mod)
|
||||
{
|
||||
return getDesc(Mapping(mode, key, mod));
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ string KeyMap::getEventMappingDesc(const Event::Type event, const EventMode mode
|
|||
{
|
||||
if (_event == event && _mapping.mode == mode)
|
||||
{
|
||||
if(buf.str() != "")
|
||||
if(!buf.str().empty())
|
||||
buf << ", ";
|
||||
buf << getDesc(_mapping);
|
||||
}
|
||||
|
@ -301,11 +301,11 @@ json KeyMap::convertLegacyMapping(string list)
|
|||
{
|
||||
json mapping = json::object();
|
||||
|
||||
mapping["event"] = Event::Type(event);
|
||||
mapping["key"] = StellaKey(key);
|
||||
mapping["event"] = static_cast<Event::Type>(event);
|
||||
mapping["key"] = static_cast<StellaKey>(key);
|
||||
|
||||
if(StellaMod(mod) != StellaMod::KBDM_NONE)
|
||||
mapping["mod"] = serializeModkeyMask(StellaMod(mod));
|
||||
if(static_cast<StellaMod>(mod) != StellaMod::KBDM_NONE)
|
||||
mapping["mod"] = serializeModkeyMask(static_cast<StellaMod>(mod));
|
||||
|
||||
convertedMapping.push_back(mapping);
|
||||
}
|
||||
|
@ -336,7 +336,7 @@ void KeyMap::eraseEvent(const Event::Type event, const EventMode mode)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
KeyMap::Mapping KeyMap::convertMod(const Mapping& mapping) const
|
||||
KeyMap::Mapping KeyMap::convertMod(const Mapping& mapping)
|
||||
{
|
||||
Mapping m = mapping;
|
||||
|
||||
|
|
|
@ -79,8 +79,8 @@ class KeyMap
|
|||
bool check(const EventMode mode, const int key, const int mod) const;
|
||||
|
||||
/** Get mapping description */
|
||||
string getDesc(const Mapping& mapping) const;
|
||||
string getDesc(const EventMode mode, const int key, const int mod) const;
|
||||
static string getDesc(const Mapping& mapping);
|
||||
static string getDesc(const EventMode mode, const int key, const int mod);
|
||||
|
||||
/** Get the mapping description(s) for given event and mode */
|
||||
string getEventMappingDesc(const Event::Type event, const EventMode mode) const;
|
||||
|
@ -104,7 +104,7 @@ class KeyMap
|
|||
|
||||
private:
|
||||
//** Convert modifiers */
|
||||
Mapping convertMod(const Mapping& mapping) const;
|
||||
static Mapping convertMod(const Mapping& mapping);
|
||||
|
||||
struct KeyHash {
|
||||
size_t operator()(const Mapping& m) const {
|
||||
|
|
|
@ -287,6 +287,6 @@ class LinkedObjectPool
|
|||
LinkedObjectPool& operator=(LinkedObjectPool&&) = delete;
|
||||
};
|
||||
|
||||
} // Namespace Common
|
||||
} // namespace Common
|
||||
|
||||
#endif
|
||||
|
|
|
@ -41,8 +41,10 @@ MouseControl::MouseControl(Console& console, const string& mode)
|
|||
m_mode[0] >= '0' && m_mode[0] <= '8' &&
|
||||
m_mode[1] >= '0' && m_mode[1] <= '8')
|
||||
{
|
||||
const MouseControl::Type xaxis = static_cast<MouseControl::Type>(static_cast<int>(m_mode[0]) - '0');
|
||||
const MouseControl::Type yaxis = static_cast<MouseControl::Type>(static_cast<int>(m_mode[1]) - '0');
|
||||
const auto xaxis = static_cast<MouseControl::Type>
|
||||
(static_cast<int>(m_mode[0]) - '0');
|
||||
const auto 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;
|
||||
|
@ -127,7 +129,7 @@ MouseControl::MouseControl(Console& console, const string& mode)
|
|||
Paddles::setDigitalPaddleRange(m_range);
|
||||
|
||||
// If the mouse isn't used at all, we still need one item in the list
|
||||
if(myModeList.size() == 0)
|
||||
if(myModeList.empty())
|
||||
myModeList.emplace_back("Mouse not used for current controllers");
|
||||
|
||||
#if 0
|
||||
|
|
|
@ -73,7 +73,7 @@ class MouseControl
|
|||
void addLeftControllerModes(bool noswap);
|
||||
void addRightControllerModes(bool noswap);
|
||||
void addPaddleModes(int lport, int rport, int lname, int rname);
|
||||
bool controllerSupportsMouse(Controller& controller);
|
||||
static bool controllerSupportsMouse(Controller& controller);
|
||||
|
||||
private:
|
||||
const Properties& myProps;
|
||||
|
|
|
@ -15,7 +15,6 @@
|
|||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//============================================================================
|
||||
|
||||
#include "Logger.hxx"
|
||||
#include "OSystem.hxx"
|
||||
#include "Console.hxx"
|
||||
#include "Joystick.hxx"
|
||||
|
@ -149,11 +148,9 @@ int PhysicalJoystickHandler::add(const PhysicalJoystickPtr& stick)
|
|||
// We're potentially swapping out an input device behind the back of
|
||||
// the Event system, so we make sure all Stelladaptor-generated events
|
||||
// are reset
|
||||
for(int port = 0; port < NUM_PORTS; ++port)
|
||||
{
|
||||
for(int axis = 0; axis < NUM_SA_AXIS; ++axis)
|
||||
for(int port = 0; port < NUM_PORTS; ++port) // NOLINT
|
||||
for(int axis = 0; axis < NUM_SA_AXIS; ++axis) // NOLINT
|
||||
myEvent.set(SA_Axis[port][axis], 0);
|
||||
}
|
||||
|
||||
return stick->ID;
|
||||
}
|
||||
|
@ -300,7 +297,7 @@ bool PhysicalJoystickHandler::mapStelladaptors(const string& saport, int ID)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool PhysicalJoystickHandler::hasStelladaptors() const
|
||||
{
|
||||
for(auto& [_id, _joyptr] : mySticks)
|
||||
for(const auto& [_id, _joyptr] : mySticks)
|
||||
{
|
||||
// remove previously added emulated ports
|
||||
const size_t pos = _joyptr->name.find(" (emulates ");
|
||||
|
@ -334,7 +331,7 @@ void PhysicalJoystickHandler::setDefaultAction(int stick,
|
|||
{
|
||||
// if there is no existing mapping for the event and
|
||||
// the default mapping for the event is unused, set default key for event
|
||||
if(j->joyMap.getEventMapping(map.event, mode).size() == 0 &&
|
||||
if(j->joyMap.getEventMapping(map.event, mode).empty() &&
|
||||
!j->joyMap.check(mode, map.button, map.axis, map.adir, map.hat, map.hdir))
|
||||
{
|
||||
if (map.hat == JOY_CTRL_NONE)
|
||||
|
@ -355,8 +352,8 @@ void PhysicalJoystickHandler::setDefaultAction(int stick,
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PhysicalJoystickHandler::setStickDefaultMapping(int stick, Event::Type event,
|
||||
EventMode mode, bool updateDefaults)
|
||||
void PhysicalJoystickHandler::setStickDefaultMapping(
|
||||
int stick, Event::Type event, EventMode mode, bool updateDefaults)
|
||||
{
|
||||
const PhysicalJoystickPtr j = joy(stick);
|
||||
|
||||
|
@ -588,7 +585,7 @@ void PhysicalJoystickHandler::enableCommonMappings()
|
|||
{
|
||||
for (int i = Event::NoType + 1; i < Event::LastType; i++)
|
||||
{
|
||||
const Event::Type event = static_cast<Event::Type>(i);
|
||||
const auto event = static_cast<Event::Type>(i);
|
||||
|
||||
if(isCommonEvent(event))
|
||||
enableMapping(event, EventMode::kCommonMode);
|
||||
|
@ -619,7 +616,8 @@ void PhysicalJoystickHandler::enableMapping(const Event::Type event, EventMode m
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
EventMode PhysicalJoystickHandler::getEventMode(const Event::Type event, const EventMode mode) const
|
||||
EventMode PhysicalJoystickHandler::getEventMode(const Event::Type event,
|
||||
const EventMode mode)
|
||||
{
|
||||
if(mode == EventMode::kEmulationMode)
|
||||
{
|
||||
|
@ -643,35 +641,35 @@ EventMode PhysicalJoystickHandler::getEventMode(const Event::Type event, const E
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool PhysicalJoystickHandler::isJoystickEvent(const Event::Type event) const
|
||||
bool PhysicalJoystickHandler::isJoystickEvent(const Event::Type event)
|
||||
{
|
||||
return LeftJoystickEvents.find(event) != LeftJoystickEvents.end()
|
||||
|| RightJoystickEvents.find(event) != RightJoystickEvents.end();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool PhysicalJoystickHandler::isPaddleEvent(const Event::Type event) const
|
||||
bool PhysicalJoystickHandler::isPaddleEvent(const Event::Type event)
|
||||
{
|
||||
return LeftPaddlesEvents.find(event) != LeftPaddlesEvents.end()
|
||||
|| RightPaddlesEvents.find(event) != RightPaddlesEvents.end();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool PhysicalJoystickHandler::isKeyboardEvent(const Event::Type event) const
|
||||
bool PhysicalJoystickHandler::isKeyboardEvent(const Event::Type event)
|
||||
{
|
||||
return LeftKeyboardEvents.find(event) != LeftKeyboardEvents.end()
|
||||
|| RightKeyboardEvents.find(event) != RightKeyboardEvents.end();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool PhysicalJoystickHandler::isDrivingEvent(const Event::Type event) const
|
||||
bool PhysicalJoystickHandler::isDrivingEvent(const Event::Type event)
|
||||
{
|
||||
return LeftDrivingEvents.find(event) != LeftDrivingEvents.end()
|
||||
|| RightDrivingEvents.find(event) != RightDrivingEvents.end();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool PhysicalJoystickHandler::isCommonEvent(const Event::Type event) const
|
||||
bool PhysicalJoystickHandler::isCommonEvent(const Event::Type event)
|
||||
{
|
||||
return !(isJoystickEvent(event) || isPaddleEvent(event) || isKeyboardEvent(event) || isDrivingEvent(event));
|
||||
}
|
||||
|
@ -734,9 +732,9 @@ string PhysicalJoystickHandler::getMappingDesc(Event::Type event, EventMode mode
|
|||
if(_joyptr)
|
||||
{
|
||||
//Joystick mapping / labeling
|
||||
if(_joyptr->joyMap.getEventMapping(event, evMode).size())
|
||||
if(!_joyptr->joyMap.getEventMapping(event, evMode).empty())
|
||||
{
|
||||
if(buf.str() != "")
|
||||
if(!buf.str().empty())
|
||||
buf << ", ";
|
||||
buf << _joyptr->joyMap.getEventMappingDesc(_id, event, evMode);
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ class PhysicalJoystickHandler
|
|||
bool remove(const string& name);
|
||||
bool mapStelladaptors(const string& saport, int ID = -1);
|
||||
bool hasStelladaptors() const;
|
||||
void setDefaultMapping(Event::Type type, EventMode mode);
|
||||
void setDefaultMapping(Event::Type event, EventMode mode);
|
||||
|
||||
/** define mappings for current controllers */
|
||||
void defineControllerMappings(const Controller::Type type, Controller::Jack port);
|
||||
|
@ -150,7 +150,7 @@ class PhysicalJoystickHandler
|
|||
void addToDatabase(const PhysicalJoystickPtr& stick);
|
||||
|
||||
// Set default mapping for given joystick when no mappings already exist
|
||||
void setStickDefaultMapping(int stick, Event::Type type, EventMode mode,
|
||||
void setStickDefaultMapping(int stick, Event::Type event, EventMode mode,
|
||||
bool updateDefaults = false);
|
||||
|
||||
friend ostream& operator<<(ostream& os, const PhysicalJoystickHandler& jh);
|
||||
|
@ -180,13 +180,13 @@ class PhysicalJoystickHandler
|
|||
bool updateDefaults = false);
|
||||
|
||||
/** returns the event's controller mode */
|
||||
EventMode getEventMode(const Event::Type event, const EventMode mode) const;
|
||||
static EventMode getEventMode(const Event::Type event, const EventMode mode);
|
||||
/** Checks event type. */
|
||||
bool isJoystickEvent(const Event::Type event) const;
|
||||
bool isPaddleEvent(const Event::Type event) const;
|
||||
bool isKeyboardEvent(const Event::Type event) const;
|
||||
bool isDrivingEvent(const Event::Type event) const;
|
||||
bool isCommonEvent(const Event::Type event) const;
|
||||
static bool isJoystickEvent(const Event::Type event);
|
||||
static bool isPaddleEvent(const Event::Type event);
|
||||
static bool isKeyboardEvent(const Event::Type event);
|
||||
static bool isDrivingEvent(const Event::Type event);
|
||||
static bool isCommonEvent(const Event::Type event);
|
||||
|
||||
void enableCommonMappings();
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ void PhysicalKeyboardHandler::setDefaultKey(EventMapping map, Event::Type event,
|
|||
{
|
||||
// if there is no existing mapping for the event and
|
||||
// the default mapping for the event is unused, set default key for event
|
||||
if (myKeyMap.getEventMapping(map.event, mode).size() == 0 &&
|
||||
if (myKeyMap.getEventMapping(map.event, mode).empty() &&
|
||||
!isMappingUsed(mode, map))
|
||||
{
|
||||
addMapping(map.event, mode, map.key, static_cast<StellaMod>(map.mod));
|
||||
|
@ -219,10 +219,8 @@ void PhysicalKeyboardHandler::setDefaultMapping(Event::Type event, EventMode mod
|
|||
void PhysicalKeyboardHandler::defineControllerMappings(
|
||||
const Controller::Type type, Controller::Jack port, const Properties& properties)
|
||||
{
|
||||
|
||||
//const string& test = myOSystem.settings().getString("aq");
|
||||
// determine controller events to use
|
||||
switch(type)
|
||||
// Determine controller events to use
|
||||
switch(type) // NOLINT (could be written as IF/ELSE)
|
||||
{
|
||||
case Controller::Type::QuadTari:
|
||||
if(port == Controller::Jack::Left)
|
||||
|
@ -251,7 +249,8 @@ void PhysicalKeyboardHandler::defineControllerMappings(
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
EventMode PhysicalKeyboardHandler::getMode(const Properties& properties, const PropType propType)
|
||||
EventMode PhysicalKeyboardHandler::getMode(const Properties& properties,
|
||||
const PropType propType)
|
||||
{
|
||||
const string& propName = properties.get(propType);
|
||||
|
||||
|
@ -377,7 +376,7 @@ void PhysicalKeyboardHandler::enableCommonMappings()
|
|||
{
|
||||
for (int i = Event::NoType + 1; i < Event::LastType; i++)
|
||||
{
|
||||
const Event::Type event = static_cast<Event::Type>(i);
|
||||
const auto event = static_cast<Event::Type>(i);
|
||||
|
||||
if (isCommonEvent(event))
|
||||
enableMapping(event, EventMode::kCommonMode);
|
||||
|
@ -405,7 +404,7 @@ void PhysicalKeyboardHandler::enableMapping(const Event::Type event,
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
EventMode PhysicalKeyboardHandler::getEventMode(const Event::Type event,
|
||||
const EventMode mode) const
|
||||
const EventMode mode)
|
||||
{
|
||||
if (mode == EventMode::kEmulationMode)
|
||||
{
|
||||
|
@ -429,7 +428,7 @@ EventMode PhysicalKeyboardHandler::getEventMode(const Event::Type event,
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool PhysicalKeyboardHandler::isJoystickEvent(const Event::Type event) const
|
||||
bool PhysicalKeyboardHandler::isJoystickEvent(const Event::Type event)
|
||||
{
|
||||
return LeftJoystickEvents.find(event) != LeftJoystickEvents.end()
|
||||
|| QTJoystick3Events.find(event) != QTJoystick3Events.end()
|
||||
|
@ -438,7 +437,7 @@ bool PhysicalKeyboardHandler::isJoystickEvent(const Event::Type event) const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool PhysicalKeyboardHandler::isPaddleEvent(const Event::Type event) const
|
||||
bool PhysicalKeyboardHandler::isPaddleEvent(const Event::Type event)
|
||||
{
|
||||
return LeftPaddlesEvents.find(event) != LeftPaddlesEvents.end()
|
||||
|| QTPaddles3Events.find(event) != QTPaddles3Events.end()
|
||||
|
@ -447,21 +446,21 @@ bool PhysicalKeyboardHandler::isPaddleEvent(const Event::Type event) const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool PhysicalKeyboardHandler::isDrivingEvent(const Event::Type event) const
|
||||
bool PhysicalKeyboardHandler::isDrivingEvent(const Event::Type event)
|
||||
{
|
||||
return LeftDrivingEvents.find(event) != LeftDrivingEvents.end()
|
||||
|| RightDrivingEvents.find(event) != RightDrivingEvents.end();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool PhysicalKeyboardHandler::isKeyboardEvent(const Event::Type event) const
|
||||
bool PhysicalKeyboardHandler::isKeyboardEvent(const Event::Type event)
|
||||
{
|
||||
return LeftKeyboardEvents.find(event) != LeftKeyboardEvents.end()
|
||||
|| RightKeyboardEvents.find(event) != RightKeyboardEvents.end();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool PhysicalKeyboardHandler::isCommonEvent(const Event::Type event) const
|
||||
bool PhysicalKeyboardHandler::isCommonEvent(const Event::Type event)
|
||||
{
|
||||
return !(isJoystickEvent(event) || isPaddleEvent(event) || isKeyboardEvent(event));
|
||||
}
|
||||
|
|
|
@ -48,10 +48,12 @@ class PhysicalKeyboardHandler
|
|||
|
||||
void loadSerializedMappings(const string& serializedMappings, EventMode mode);
|
||||
|
||||
void setDefaultMapping(Event::Type type, EventMode mode, bool updateDefaults = false);
|
||||
void setDefaultMapping(Event::Type event, EventMode mode,
|
||||
bool updateDefaults = false);
|
||||
|
||||
/** define mappings for current controllers */
|
||||
void defineControllerMappings(const Controller::Type type, Controller::Jack port,
|
||||
void defineControllerMappings(const Controller::Type type,
|
||||
Controller::Jack port,
|
||||
const Properties& properties);
|
||||
/** enable mappings for emulation mode */
|
||||
void enableEmulationMappings();
|
||||
|
@ -100,13 +102,13 @@ class PhysicalKeyboardHandler
|
|||
EventMode mode = EventMode::kEmulationMode, bool updateDefaults = false);
|
||||
|
||||
/** returns the event's controller mode */
|
||||
EventMode getEventMode(const Event::Type event, const EventMode mode) const;
|
||||
static EventMode getEventMode(const Event::Type event, const EventMode mode);
|
||||
/** Checks event type. */
|
||||
bool isJoystickEvent(const Event::Type event) const;
|
||||
bool isPaddleEvent(const Event::Type event) const;
|
||||
bool isKeyboardEvent(const Event::Type event) const;
|
||||
bool isDrivingEvent(const Event::Type event) const;
|
||||
bool isCommonEvent(const Event::Type event) const;
|
||||
static bool isJoystickEvent(const Event::Type event);
|
||||
static bool isPaddleEvent(const Event::Type event);
|
||||
static bool isKeyboardEvent(const Event::Type event);
|
||||
static bool isDrivingEvent(const Event::Type event);
|
||||
static bool isCommonEvent(const Event::Type event);
|
||||
|
||||
void enableCommonMappings();
|
||||
|
||||
|
@ -114,9 +116,9 @@ class PhysicalKeyboardHandler
|
|||
void enableMapping(const Event::Type event, EventMode mode);
|
||||
|
||||
/** return event mode for given property */
|
||||
EventMode getMode(const Properties& properties, const PropType propType);
|
||||
static EventMode getMode(const Properties& properties, const PropType propType);
|
||||
/** return event mode for given controller type */
|
||||
EventMode getMode(const Controller::Type type);
|
||||
static EventMode getMode(const Controller::Type type);
|
||||
|
||||
private:
|
||||
OSystem& myOSystem;
|
||||
|
|
|
@ -135,16 +135,16 @@ void PNGLibrary::saveImage(const string& filename, const VariantList& metaData)
|
|||
fb.scaleX(rectUnscaled.w()), fb.scaleY(rectUnscaled.h())
|
||||
);
|
||||
|
||||
const png_uint_32 width = rect.w(), height = rect.h();
|
||||
const size_t width = rect.w(), height = rect.h();
|
||||
|
||||
// Get framebuffer pixel data (we get ABGR format)
|
||||
vector<png_byte> buffer(width * height * 4);
|
||||
fb.readPixels(buffer.data(), width*4, rect);
|
||||
fb.readPixels(buffer.data(), width * 4, rect);
|
||||
|
||||
// Set up pointers into "buffer" byte array
|
||||
vector<png_bytep> rows(height);
|
||||
for(png_uint_32 k = 0; k < height; ++k)
|
||||
rows[k] = buffer.data() + k*width*4;
|
||||
for(size_t k = 0; k < height; ++k)
|
||||
rows[k] = buffer.data() + k * width * 4;
|
||||
|
||||
// And save the image
|
||||
saveImageToDisk(out, rows, width, height, metaData);
|
||||
|
@ -159,7 +159,7 @@ void PNGLibrary::saveImage(const string& filename, const FBSurface& surface,
|
|||
throw runtime_error("ERROR: Couldn't create snapshot file");
|
||||
|
||||
// Do we want the entire surface or just a section?
|
||||
png_uint_32 width = rect.w(), height = rect.h();
|
||||
size_t width = rect.w(), height = rect.h();
|
||||
if(rect.empty())
|
||||
{
|
||||
width = surface.width();
|
||||
|
@ -168,12 +168,12 @@ void PNGLibrary::saveImage(const string& filename, const FBSurface& surface,
|
|||
|
||||
// Get the surface pixel data (we get ABGR format)
|
||||
vector<png_byte> buffer(width * height * 4);
|
||||
surface.readPixels(buffer.data(), width, rect);
|
||||
surface.readPixels(buffer.data(), static_cast<uInt32>(width), rect);
|
||||
|
||||
// Set up pointers into "buffer" byte array
|
||||
vector<png_bytep> rows(height);
|
||||
for(png_uint_32 k = 0; k < height; ++k)
|
||||
rows[k] = buffer.data() + k*width*4;
|
||||
for(size_t k = 0; k < height; ++k)
|
||||
rows[k] = buffer.data() + k * width * 4;
|
||||
|
||||
// And save the image
|
||||
saveImageToDisk(out, rows, width, height, metaData);
|
||||
|
@ -181,10 +181,10 @@ void PNGLibrary::saveImage(const string& filename, const FBSurface& surface,
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PNGLibrary::saveImageToDisk(std::ofstream& out, const vector<png_bytep>& rows,
|
||||
png_uint_32 width, png_uint_32 height, const VariantList& metaData)
|
||||
size_t width, size_t height, const VariantList& metaData)
|
||||
{
|
||||
png_structp png_ptr = nullptr;
|
||||
png_infop info_ptr = nullptr;
|
||||
png_structp png_ptr{nullptr};
|
||||
png_infop info_ptr{nullptr};
|
||||
|
||||
const auto saveImageERROR = [&](const char* s) {
|
||||
if(png_ptr)
|
||||
|
@ -208,7 +208,8 @@ void PNGLibrary::saveImageToDisk(std::ofstream& out, const vector<png_bytep>& ro
|
|||
png_set_write_fn(png_ptr, &out, png_write_data, png_io_flush);
|
||||
|
||||
// Write PNG header info
|
||||
png_set_IHDR(png_ptr, info_ptr, width, height, 8,
|
||||
png_set_IHDR(png_ptr, info_ptr,
|
||||
static_cast<png_uint_32>(width), static_cast<png_uint_32>(height), 8,
|
||||
PNG_COLOR_TYPE_RGB, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT,
|
||||
PNG_FILTER_TYPE_DEFAULT);
|
||||
|
||||
|
@ -381,20 +382,20 @@ void PNGLibrary::takeSnapshot(uInt32 number)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool PNGLibrary::allocateStorage(png_uint_32 w, png_uint_32 h)
|
||||
bool PNGLibrary::allocateStorage(size_t width, size_t height)
|
||||
{
|
||||
// Create space for the entire image (3 bytes per pixel in RGB format)
|
||||
const size_t req_buffer_size = w * h * 3;
|
||||
const size_t req_buffer_size = width * height * 3;
|
||||
if(req_buffer_size > ReadInfo.buffer.capacity())
|
||||
ReadInfo.buffer.reserve(req_buffer_size * 1.5);
|
||||
|
||||
const size_t req_row_size = h;
|
||||
const size_t req_row_size = height;
|
||||
if(req_row_size > ReadInfo.row_pointers.capacity())
|
||||
ReadInfo.row_pointers.reserve(req_row_size * 1.5);
|
||||
|
||||
ReadInfo.width = w;
|
||||
ReadInfo.height = h;
|
||||
ReadInfo.pitch = w * 3;
|
||||
ReadInfo.width = static_cast<png_uint_32>(width);
|
||||
ReadInfo.height = static_cast<png_uint_32>(height);
|
||||
ReadInfo.pitch = static_cast<png_uint_32>(width * 3);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -413,7 +414,7 @@ void PNGLibrary::loadImagetoSurface(FBSurface& surface)
|
|||
surface.setSrcSize(iw, ih);
|
||||
|
||||
// Convert RGB triples into pixels and store in the surface
|
||||
uInt32 *s_buf, s_pitch;
|
||||
uInt32 *s_buf{nullptr}, s_pitch{0};
|
||||
surface.basePtr(s_buf, s_pitch);
|
||||
const uInt8* i_buf = ReadInfo.buffer.data();
|
||||
const uInt32 i_pitch = ReadInfo.pitch;
|
||||
|
@ -429,30 +430,32 @@ void PNGLibrary::loadImagetoSurface(FBSurface& surface)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PNGLibrary::writeMetaData(const png_structp png_ptr, png_infop info_ptr,
|
||||
const VariantList& metaData)
|
||||
void PNGLibrary::writeMetaData(
|
||||
const png_structp png_ptr, png_infop info_ptr, // NOLINT
|
||||
const VariantList& metaData)
|
||||
{
|
||||
const uInt32 numMetaData = static_cast<uInt32>(metaData.size());
|
||||
const size_t numMetaData = metaData.size();
|
||||
if(numMetaData == 0)
|
||||
return;
|
||||
|
||||
vector<png_text> text_ptr(numMetaData);
|
||||
for(uInt32 i = 0; i < numMetaData; ++i)
|
||||
for(size_t i = 0; i < numMetaData; ++i)
|
||||
{
|
||||
text_ptr[i].key = const_cast<char*>(metaData[i].first.c_str());
|
||||
text_ptr[i].text = const_cast<char*>(metaData[i].second.toCString());
|
||||
text_ptr[i].compression = PNG_TEXT_COMPRESSION_NONE;
|
||||
text_ptr[i].text_length = 0;
|
||||
}
|
||||
png_set_text(png_ptr, info_ptr, text_ptr.data(), numMetaData);
|
||||
png_set_text(png_ptr, info_ptr, text_ptr.data(), static_cast<int>(numMetaData));
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PNGLibrary::readMetaData(const png_structp png_ptr, png_infop info_ptr,
|
||||
VariantList& metaData)
|
||||
void PNGLibrary::readMetaData(
|
||||
const png_structp png_ptr, png_infop info_ptr, // NOLINT
|
||||
VariantList& metaData)
|
||||
{
|
||||
png_textp text_ptr;
|
||||
int numMetaData = 0;
|
||||
png_textp text_ptr{nullptr};
|
||||
int numMetaData{0};
|
||||
|
||||
png_get_text(png_ptr, info_ptr, &text_ptr, &numMetaData);
|
||||
|
||||
|
@ -464,33 +467,37 @@ void PNGLibrary::readMetaData(const png_structp png_ptr, png_infop info_ptr,
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PNGLibrary::png_read_data(const png_structp ctx, png_bytep area, png_size_t size)
|
||||
void PNGLibrary::png_read_data(const png_structp ctx, // NOLINT
|
||||
png_bytep area, png_size_t size)
|
||||
{
|
||||
(static_cast<std::ifstream*>(png_get_io_ptr(ctx)))->read(
|
||||
reinterpret_cast<char *>(area), size);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PNGLibrary::png_write_data(const png_structp ctx, png_bytep area, png_size_t size)
|
||||
void PNGLibrary::png_write_data(const png_structp ctx, // NOLINT
|
||||
png_bytep area, png_size_t size)
|
||||
{
|
||||
(static_cast<std::ofstream*>(png_get_io_ptr(ctx)))->write(
|
||||
reinterpret_cast<const char *>(area), size);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PNGLibrary::png_io_flush(const png_structp ctx)
|
||||
void PNGLibrary::png_io_flush(const png_structp ctx) // NOLINT
|
||||
{
|
||||
(static_cast<std::ofstream*>(png_get_io_ptr(ctx)))->flush();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PNGLibrary::png_user_warn(const png_structp ctx, png_const_charp str)
|
||||
void PNGLibrary::png_user_warn(const png_structp ctx, // NOLINT
|
||||
png_const_charp str)
|
||||
{
|
||||
throw runtime_error(string("PNGLibrary warning: ") + str);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PNGLibrary::png_user_error(const png_structp ctx, png_const_charp str)
|
||||
void PNGLibrary::png_user_error(const png_structp ctx, // NOLINT
|
||||
png_const_charp str)
|
||||
{
|
||||
throw runtime_error(string("PNGLibrary error: ") + str);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,8 @@ class PNGLibrary
|
|||
runtime_error is thrown containing a more detailed
|
||||
error message.
|
||||
*/
|
||||
void loadImage(const string& filename, FBSurface& surface, VariantList& metaData);
|
||||
void loadImage(const string& filename, FBSurface& surface,
|
||||
VariantList& metaData);
|
||||
|
||||
/**
|
||||
Save the current FrameBuffer image to a PNG file. Note that in most
|
||||
|
@ -78,9 +79,9 @@ class PNGLibrary
|
|||
otherwise a runtime_error is thrown containing a
|
||||
more detailed error message.
|
||||
*/
|
||||
void saveImage(const string& filename, const FBSurface& surface,
|
||||
const Common::Rect& rect = Common::Rect{},
|
||||
const VariantList& metaData = VariantList{});
|
||||
static void saveImage(const string& filename, const FBSurface& surface,
|
||||
const Common::Rect& rect = Common::Rect{},
|
||||
const VariantList& metaData = VariantList{});
|
||||
|
||||
/**
|
||||
Called at regular intervals, and used to determine whether a
|
||||
|
@ -149,10 +150,10 @@ class PNGLibrary
|
|||
dependent on the given dimensions. If memory has been previously
|
||||
allocated and it can accommodate the given dimensions, it is used directly.
|
||||
|
||||
@param iwidth The width of the PNG image
|
||||
@param iheight The height of the PNG image
|
||||
@param width The width of the PNG image
|
||||
@param height The height of the PNG image
|
||||
*/
|
||||
bool allocateStorage(png_uint_32 iwidth, png_uint_32 iheight);
|
||||
static bool allocateStorage(size_t width, size_t height);
|
||||
|
||||
/** The actual method which saves a PNG image.
|
||||
|
||||
|
@ -162,9 +163,9 @@ class PNGLibrary
|
|||
@param height The height of the PNG image
|
||||
@param metaData The meta data to add to the PNG image
|
||||
*/
|
||||
void saveImageToDisk(std::ofstream& out, const vector<png_bytep>& rows,
|
||||
png_uint_32 width, png_uint_32 height,
|
||||
const VariantList& metaData);
|
||||
static void saveImageToDisk(std::ofstream& out, const vector<png_bytep>& rows,
|
||||
size_t width, size_t height,
|
||||
const VariantList& metaData);
|
||||
|
||||
/**
|
||||
Load the PNG data from 'ReadInfo' into the FBSurface. The surface
|
||||
|
@ -177,21 +178,25 @@ class PNGLibrary
|
|||
/**
|
||||
Write PNG tEXt chunks to the image.
|
||||
*/
|
||||
void writeMetaData(const png_structp png_ptr, png_infop info_ptr,
|
||||
const VariantList& metaData);
|
||||
static void writeMetaData(const png_structp png_ptr, png_infop info_ptr,
|
||||
const VariantList& metaData);
|
||||
|
||||
/**
|
||||
Read PNG tEXt chunks from the image.
|
||||
*/
|
||||
void readMetaData(const png_structp png_ptr, png_infop info_ptr,
|
||||
VariantList& metaData);
|
||||
static void readMetaData(const png_structp png_ptr, png_infop info_ptr,
|
||||
VariantList& metaData);
|
||||
|
||||
/** PNG library callback functions */
|
||||
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_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);
|
||||
[[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
|
||||
|
|
|
@ -44,9 +44,9 @@ PaletteHandler::PaletteType PaletteHandler::toPaletteType(const string& name) co
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string PaletteHandler::toPaletteName(PaletteType type) const
|
||||
string PaletteHandler::toPaletteName(PaletteType type)
|
||||
{
|
||||
const string SETTING_NAMES[int(PaletteType::NumTypes)] = {
|
||||
const string SETTING_NAMES[static_cast<int>(PaletteType::NumTypes)] = {
|
||||
SETTING_STANDARD, SETTING_Z26, SETTING_USER, SETTING_CUSTOM
|
||||
};
|
||||
|
||||
|
@ -321,12 +321,13 @@ void PaletteHandler::setPalette()
|
|||
|
||||
// Look at all the palettes, since we don't know which one is
|
||||
// currently active
|
||||
static constexpr BSPF::array2D<const PaletteArray*, PaletteType::NumTypes, int(ConsoleTiming::numTimings)> palettes = {{
|
||||
static constexpr BSPF::array2D<const PaletteArray*, PaletteType::NumTypes,
|
||||
static_cast<int>(ConsoleTiming::numTimings)> palettes = {{
|
||||
{ &ourNTSCPalette, &ourPALPalette, &ourSECAMPalette },
|
||||
{ &ourNTSCPaletteZ26, &ourPALPaletteZ26, &ourSECAMPaletteZ26 },
|
||||
{ &ourUserNTSCPalette, &ourUserPALPalette, &ourUserSECAMPalette },
|
||||
{ &ourCustomNTSCPalette, &ourCustomPALPalette, &ourSECAMPalette }
|
||||
}};
|
||||
}};
|
||||
// See which format we should be using
|
||||
const ConsoleTiming timing = myOSystem.console().timing();
|
||||
const PaletteType paletteType = toPaletteType(name);
|
||||
|
@ -341,7 +342,7 @@ void PaletteHandler::setPalette()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
PaletteArray PaletteHandler::adjustedPalette(const PaletteArray& palette)
|
||||
PaletteArray PaletteHandler::adjustedPalette(const PaletteArray& palette) const
|
||||
{
|
||||
PaletteArray destPalette{0};
|
||||
// Constants for saturation and gray scale calculation
|
||||
|
@ -389,7 +390,7 @@ PaletteArray PaletteHandler::adjustedPalette(const PaletteArray& palette)
|
|||
// Fill the odd numbered palette entries with gray values (calculated
|
||||
// using the standard RGB -> grayscale conversion formula)
|
||||
// Used for PAL color-loss data and 'greying out' the frame in the debugger.
|
||||
const uInt8 lum = static_cast<uInt8>((r * PR) + (g * PG) + (b * PB));
|
||||
const auto lum = static_cast<uInt8>((r * PR) + (g * PG) + (b * PB));
|
||||
|
||||
destPalette[i + 1] = (lum << 16) + (lum << 8) + lum;
|
||||
}
|
||||
|
@ -443,7 +444,7 @@ void PaletteHandler::loadUserPalette()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PaletteHandler::generateCustomPalette(ConsoleTiming timing)
|
||||
void PaletteHandler::generateCustomPalette(ConsoleTiming timing) const
|
||||
{
|
||||
constexpr int NUM_CHROMA = 16;
|
||||
constexpr int NUM_LUMA = 8;
|
||||
|
@ -572,7 +573,8 @@ void PaletteHandler::adjustHueSaturation(int& R, int& G, int& B, float H, float
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
PaletteHandler::vector2d PaletteHandler::rotate(const PaletteHandler::vector2d& vec, float angle) const
|
||||
PaletteHandler::vector2d
|
||||
PaletteHandler::rotate(const PaletteHandler::vector2d& vec, float angle)
|
||||
{
|
||||
const float r = angle * BSPF::PI_f / 180;
|
||||
|
||||
|
@ -581,14 +583,15 @@ PaletteHandler::vector2d PaletteHandler::rotate(const PaletteHandler::vector2d&
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
PaletteHandler::vector2d PaletteHandler::scale(const PaletteHandler::vector2d& vec, float factor) const
|
||||
PaletteHandler::vector2d
|
||||
PaletteHandler::scale(const PaletteHandler::vector2d& vec, float factor)
|
||||
{
|
||||
return PaletteHandler::vector2d(vec.x * factor, vec.y * factor);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
float PaletteHandler::dotProduct(const PaletteHandler::vector2d& vec1,
|
||||
const PaletteHandler::vector2d& vec2) const
|
||||
const PaletteHandler::vector2d& vec2)
|
||||
{
|
||||
return vec1.x * vec2.x + vec1.y * vec2.y;
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ class PaletteHandler
|
|||
|
||||
@return The palette's settings name
|
||||
*/
|
||||
string toPaletteName(PaletteType type) const;
|
||||
static string toPaletteName(PaletteType type);
|
||||
|
||||
/**
|
||||
Display current adjustable with gauge bar message
|
||||
|
@ -208,16 +208,16 @@ class PaletteHandler
|
|||
|
||||
@param timing Use NTSC or PAL phase shift and generate according palette
|
||||
*/
|
||||
void generateCustomPalette(ConsoleTiming timing);
|
||||
void generateCustomPalette(ConsoleTiming timing) const;
|
||||
|
||||
/**
|
||||
Create new palette by applying palette adjustments on given palette.
|
||||
|
||||
@param source The palette which should be adjusted
|
||||
@param palette The palette which should be adjusted
|
||||
|
||||
@return An adjusted palette
|
||||
*/
|
||||
PaletteArray adjustedPalette(const PaletteArray& source);
|
||||
PaletteArray adjustedPalette(const PaletteArray& palette) const;
|
||||
|
||||
/**
|
||||
Adjust hue and saturation for given RGB values.
|
||||
|
@ -228,22 +228,22 @@ class PaletteHandler
|
|||
@param H The hue adjustment value
|
||||
@param S The saturation
|
||||
*/
|
||||
void adjustHueSaturation(int& R, int& G, int& B, float H, float S);
|
||||
static void adjustHueSaturation(int& R, int& G, int& B, float H, float S);
|
||||
|
||||
/**
|
||||
Rotate a 2D vector.
|
||||
*/
|
||||
vector2d rotate(const vector2d& vec, float angle) const;
|
||||
static vector2d rotate(const vector2d& vec, float angle);
|
||||
|
||||
/**
|
||||
Scale a 2D vector.
|
||||
*/
|
||||
vector2d scale(const vector2d& vec, float factor) const;
|
||||
static vector2d scale(const vector2d& vec, float factor);
|
||||
|
||||
/**
|
||||
Get the dot product of two 2D vectors.
|
||||
*/
|
||||
float dotProduct(const vector2d& vec1, const vector2d& vec2) const;
|
||||
static float dotProduct(const vector2d& vec1, const vector2d& vec2);
|
||||
|
||||
/**
|
||||
Loads a user-defined palette file (from OSystem::paletteFile), filling the
|
||||
|
|
|
@ -33,13 +33,13 @@ namespace {
|
|||
}
|
||||
|
||||
EventMode eventModeFromJsonName(const string& name) {
|
||||
EventMode result;
|
||||
EventMode result{};
|
||||
|
||||
from_json(json(name), result);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PhysicalJoystick::initialize(int index, const string& desc,
|
||||
|
@ -70,9 +70,8 @@ json PhysicalJoystick::getMap() const
|
|||
|
||||
mapping["name"] = name;
|
||||
|
||||
for (auto& mode: {
|
||||
EventMode::kMenuMode, EventMode::kJoystickMode, EventMode::kPaddlesMode, EventMode::kKeyboardMode,
|
||||
EventMode::kDrivingMode, EventMode::kCommonMode
|
||||
for (const auto& mode: {
|
||||
EventMode::kMenuMode, EventMode::kJoystickMode, EventMode::kPaddlesMode, EventMode::kKeyboardMode, EventMode::kDrivingMode, EventMode::kCommonMode
|
||||
})
|
||||
mapping[jsonName(mode)] = joyMap.saveMapping(mode);
|
||||
|
||||
|
@ -120,7 +119,7 @@ json PhysicalJoystick::convertLegacyMapping(const string& mapping, const string&
|
|||
|
||||
while (getline(buf, map, MODE_DELIM))
|
||||
{
|
||||
int mode;
|
||||
int mode{0};
|
||||
|
||||
// Get event mode
|
||||
std::replace(map.begin(), map.end(), '|', ' ');
|
||||
|
@ -153,12 +152,12 @@ void PhysicalJoystick::eraseEvent(Event::Type event, EventMode mode)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void PhysicalJoystick::getValues(const string& list, IntArray& map) const
|
||||
void PhysicalJoystick::getValues(const string& list, IntArray& map)
|
||||
{
|
||||
map.clear();
|
||||
istringstream buf(list);
|
||||
|
||||
int value;
|
||||
int value{0};
|
||||
buf >> value; // we don't need to know the # of items at this point
|
||||
while(buf >> value)
|
||||
map.push_back(value);
|
||||
|
|
|
@ -76,7 +76,7 @@ class PhysicalJoystick
|
|||
JoyMap joyMap;
|
||||
|
||||
private:
|
||||
void getValues(const string& list, IntArray& map) const;
|
||||
static void getValues(const string& list, IntArray& map);
|
||||
|
||||
friend ostream& operator<<(ostream& os, const PhysicalJoystick& s) {
|
||||
os << " ID: " << s.ID << ", name: " << s.name << ", numaxis: " << s.numAxes
|
||||
|
|
|
@ -186,6 +186,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
} // End of namespace Common
|
||||
} // namespace Common
|
||||
|
||||
#endif
|
||||
|
|
|
@ -146,7 +146,7 @@ bool RewindManager::addState(const string& message, bool timeMachine)
|
|||
uInt32 RewindManager::rewindStates(uInt32 numStates)
|
||||
{
|
||||
const uInt64 startCycles = myOSystem.console().tia().cycles();
|
||||
uInt32 i;
|
||||
uInt32 i{0};
|
||||
string message;
|
||||
|
||||
for(i = 0; i < numStates; ++i)
|
||||
|
@ -186,7 +186,7 @@ uInt32 RewindManager::rewindStates(uInt32 numStates)
|
|||
uInt32 RewindManager::unwindStates(uInt32 numStates)
|
||||
{
|
||||
const uInt64 startCycles = myOSystem.console().tia().cycles();
|
||||
uInt32 i;
|
||||
uInt32 i{0};
|
||||
string message;
|
||||
|
||||
for(i = 0; i < numStates; ++i)
|
||||
|
@ -256,7 +256,7 @@ string RewindManager::saveAllStates()
|
|||
{
|
||||
RewindState& state = myStateList.current();
|
||||
Serializer& s = state.data;
|
||||
const uInt32 stateSize = static_cast<uInt32>(s.size());
|
||||
const auto stateSize = static_cast<uInt32>(s.size());
|
||||
|
||||
out.putInt(stateSize);
|
||||
|
||||
|
@ -354,7 +354,7 @@ void RewindManager::compressStates()
|
|||
double maxError = 1.5;
|
||||
uInt32 idx = myStateList.size() - 2;
|
||||
// in case maxError is <= 1.5 remove first state by default:
|
||||
Common::LinkedObjectPool<RewindState>::const_iter removeIter = myStateList.first();
|
||||
auto removeIter = myStateList.first();
|
||||
/*if(myUncompressed < mySize)
|
||||
// if compression is enabled, the first but one state is removed by default:
|
||||
removeIter++;*/
|
||||
|
@ -406,35 +406,35 @@ string RewindManager::loadState(Int64 startCycles, uInt32 numStates)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string RewindManager::getUnitString(Int64 cycles)
|
||||
{
|
||||
constexpr Int32 NTSC_FREQ = 1193182; // ~76*262*60
|
||||
constexpr Int32 PAL_FREQ = 1182298; // ~76*312*50
|
||||
const Int32 scanlines = std::max<Int32>(
|
||||
constexpr size_t NTSC_FREQ = 1193182; // ~76*262*60
|
||||
constexpr size_t PAL_FREQ = 1182298; // ~76*312*50
|
||||
const size_t scanlines = std::max<size_t>(
|
||||
myOSystem.console().tia().scanlinesLastFrame(), 240);
|
||||
const bool isNTSC = scanlines <= 287;
|
||||
const Int32 freq = isNTSC ? NTSC_FREQ : PAL_FREQ; // = cycles/second
|
||||
const size_t freq = isNTSC ? NTSC_FREQ : PAL_FREQ; // = cycles/second
|
||||
|
||||
constexpr Int32 NUM_UNITS = 5;
|
||||
constexpr size_t NUM_UNITS = 5;
|
||||
const std::array<string, NUM_UNITS> UNIT_NAMES = {
|
||||
"cycle", "scanline", "frame", "second", "minute"
|
||||
};
|
||||
const std::array<Int64, NUM_UNITS+1> UNIT_CYCLES = {
|
||||
const std::array<uInt64, NUM_UNITS+1> UNIT_CYCLES = {
|
||||
1, 76, 76 * scanlines, freq, freq * 60, Int64{1} << 62
|
||||
};
|
||||
|
||||
stringstream result;
|
||||
Int32 i = 0;
|
||||
size_t i = 0;
|
||||
|
||||
cycles = std::abs(cycles);
|
||||
const uInt64 u_cycles = std::abs(cycles);
|
||||
|
||||
for(i = 0; i < NUM_UNITS - 1; ++i)
|
||||
{
|
||||
// use the lower unit up to twice the nextCycles unit, except for an exact match of the nextCycles unit
|
||||
// TODO: does the latter make sense, e.g. for ROMs with changing scanlines?
|
||||
if(cycles == 0 || (cycles < UNIT_CYCLES[i + 1] * 2 && cycles % UNIT_CYCLES[i + 1] != 0))
|
||||
if(u_cycles == 0 || (u_cycles < UNIT_CYCLES[i + 1] * 2 && u_cycles % UNIT_CYCLES[i + 1] != 0))
|
||||
break;
|
||||
}
|
||||
result << (cycles / UNIT_CYCLES[i]) << " " << UNIT_NAMES[i];
|
||||
if(cycles / UNIT_CYCLES[i] != 1)
|
||||
result << (u_cycles / UNIT_CYCLES[i]) << " " << UNIT_NAMES[i];
|
||||
if(u_cycles / UNIT_CYCLES[i] != 1)
|
||||
result << "s";
|
||||
|
||||
return result.str();
|
||||
|
@ -467,8 +467,9 @@ IntArray RewindManager::cyclesList() const
|
|||
IntArray arr;
|
||||
|
||||
const uInt64 firstCycle = getFirstCycles();
|
||||
// NOLINTNEXTLINE (TODO: convert myStateList to use range-for)
|
||||
for(auto it = myStateList.cbegin(); it != myStateList.cend(); ++it)
|
||||
arr.push_back(uInt32(it->cycles - firstCycle));
|
||||
arr.push_back(static_cast<uInt32>(it->cycles - firstCycle));
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ SoundSDL2::SoundSDL2(OSystem& osystem, AudioSettings& audioSettings)
|
|||
return;
|
||||
}
|
||||
|
||||
queryHardware(myDevices);
|
||||
queryHardware(myDevices); // NOLINT
|
||||
|
||||
SDL_zero(myHardwareSpec);
|
||||
if(!openDevice())
|
||||
|
@ -137,12 +137,12 @@ bool SoundSDL2::openDevice()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void SoundSDL2::setEnabled(bool state)
|
||||
void SoundSDL2::setEnabled(bool enable)
|
||||
{
|
||||
myAudioSettings.setEnabled(state);
|
||||
if (myAudioQueue) myAudioQueue->ignoreOverflows(!state);
|
||||
myAudioSettings.setEnabled(enable);
|
||||
if (myAudioQueue) myAudioQueue->ignoreOverflows(!enable);
|
||||
|
||||
Logger::debug(state ? "SoundSDL2::setEnabled(true)" :
|
||||
Logger::debug(enable ? "SoundSDL2::setEnabled(true)" :
|
||||
"SoundSDL2::setEnabled(false)");
|
||||
}
|
||||
|
||||
|
@ -387,7 +387,7 @@ void SoundSDL2::initResampler()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void SoundSDL2::callback(void* udata, uInt8* stream, int len)
|
||||
{
|
||||
SoundSDL2* self = static_cast<SoundSDL2*>(udata);
|
||||
auto* self = static_cast<SoundSDL2*>(udata);
|
||||
|
||||
if (self->myAudioQueue)
|
||||
self->processFragment(reinterpret_cast<float*>(stream), len >> 2);
|
||||
|
|
|
@ -79,6 +79,6 @@ class FixedStack
|
|||
FixedStack& operator=(FixedStack&&) = delete;
|
||||
};
|
||||
|
||||
} // Namespace Common
|
||||
} // namespace Common
|
||||
|
||||
#endif
|
||||
|
|
|
@ -29,11 +29,11 @@ namespace {
|
|||
|
||||
std::array<char, 100> formattedTime;
|
||||
formattedTime.fill(0);
|
||||
std::strftime(formattedTime.data(), 99, "%H:%M:%S", &now);
|
||||
std::ignore = std::strftime(formattedTime.data(), 99, "%H:%M:%S", &now);
|
||||
|
||||
return formattedTime.data();
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
StaggeredLogger::StaggeredLogger(const string& message, Logger::Level level)
|
||||
|
|
|
@ -28,9 +28,10 @@
|
|||
#include "Logger.hxx"
|
||||
|
||||
/**
|
||||
* This class buffers log events and logs them after a certain time window has expired.
|
||||
* The timout increases after every log line by a factor of two until a maximum is reached.
|
||||
* If no events are reported, the window size decreases again.
|
||||
* This class buffers log events and logs them after a certain time window has
|
||||
* expired. The timout increases after every log line by a factor of two until
|
||||
* a maximum is reached. If no events are reported, the window size decreases
|
||||
* again.
|
||||
*/
|
||||
|
||||
class StaggeredLogger
|
||||
|
@ -46,7 +47,7 @@ class StaggeredLogger
|
|||
|
||||
void _log();
|
||||
|
||||
void onTimerExpired(uInt32 timerId);
|
||||
void onTimerExpired(uInt32 timerCallbackId);
|
||||
|
||||
void startInterval();
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ StateManager::StateManager(OSystem& osystem)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
StateManager::~StateManager()
|
||||
StateManager::~StateManager() // NOLINT (we need an empty d'tor)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ class ThreadDebuggingHelper {
|
|||
|
||||
private:
|
||||
|
||||
[[noreturn]] void fail(const string& message);
|
||||
[[noreturn]] static void fail(const string& message);
|
||||
|
||||
ThreadDebuggingHelper() = default;
|
||||
|
||||
|
|
|
@ -20,8 +20,7 @@
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
TimerManager::TimerManager()
|
||||
: nextId{no_timer + 1},
|
||||
queue()
|
||||
: nextId{no_timer + 1}
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -66,7 +65,7 @@ TimerManager::TimerId TimerManager::addTimer(
|
|||
Duration(msPeriod), func));
|
||||
|
||||
// Insert a reference to the Timer into ordering queue
|
||||
const Queue::iterator place = queue.emplace(iter.first->second);
|
||||
const auto place = queue.emplace(iter.first->second);
|
||||
|
||||
// We need to notify the timer thread only if we inserted
|
||||
// this timer into the front of the timer queue
|
||||
|
@ -204,7 +203,7 @@ bool TimerManager::destroy_impl(ScopedLock& lock, TimerMap::iterator i,
|
|||
timer.running = false;
|
||||
|
||||
// Assign a condition variable to this timer
|
||||
timer.waitCond.reset(new ConditionVar);
|
||||
timer.waitCond = std::make_unique<ConditionVar>();
|
||||
|
||||
// Block until the callback is finished
|
||||
if (std::this_thread::get_id() != worker.get_id())
|
||||
|
|
|
@ -40,6 +40,6 @@ void removeAt(vector<T>& dst, uInt32 idx)
|
|||
dst.erase(dst.cbegin()+idx);
|
||||
}
|
||||
|
||||
} // Namespace Vec
|
||||
} // namespace Vec
|
||||
|
||||
#endif
|
||||
|
|
|
@ -156,18 +156,18 @@ string ZipHandler::errorMessage(ZipError err)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
ZipHandler::ZipFilePtr ZipHandler::findCached(const string& filename)
|
||||
{
|
||||
for(size_t cachenum = 0; cachenum < myZipCache.size(); ++cachenum)
|
||||
for(auto& cache: myZipCache)
|
||||
{
|
||||
// If we have a valid entry and it matches our filename,
|
||||
// use it and remove from the cache
|
||||
if(myZipCache[cachenum] && (filename == myZipCache[cachenum]->myFilename))
|
||||
if(cache && (filename == cache->myFilename))
|
||||
{
|
||||
ZipFilePtr result;
|
||||
std::swap(myZipCache[cachenum], result);
|
||||
std::swap(cache, result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return ZipFilePtr();
|
||||
return {};
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -180,7 +180,7 @@ void ZipHandler::addToCache()
|
|||
myZip->close();
|
||||
|
||||
// Find the first nullptr entry in the cache
|
||||
size_t cachenum;
|
||||
size_t cachenum{0};
|
||||
for(cachenum = 0; cachenum < myZipCache.size(); ++cachenum)
|
||||
if(myZipCache[cachenum] == nullptr)
|
||||
break;
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace {
|
|||
return sinc(x) * sinc(x / static_cast<float>(a));
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
LanczosResampler::LanczosResampler(
|
||||
|
@ -72,11 +72,12 @@ LanczosResampler::LanczosResampler(
|
|||
myPrecomputedKernelCount{reducedDenominator(formatFrom.sampleRate, formatTo.sampleRate)},
|
||||
myKernelSize{2 * kernelParameter},
|
||||
myKernelParameter{kernelParameter},
|
||||
myHighPassL{HIGH_PASS_CUT_OFF, float(formatFrom.sampleRate)},
|
||||
myHighPassR{HIGH_PASS_CUT_OFF, float(formatFrom.sampleRate)},
|
||||
myHighPass{HIGH_PASS_CUT_OFF, float(formatFrom.sampleRate)}
|
||||
myHighPassL{HIGH_PASS_CUT_OFF, static_cast<float>(formatFrom.sampleRate)},
|
||||
myHighPassR{HIGH_PASS_CUT_OFF, static_cast<float>(formatFrom.sampleRate)},
|
||||
myHighPass{HIGH_PASS_CUT_OFF, static_cast<float>(formatFrom.sampleRate)}
|
||||
{
|
||||
myPrecomputedKernels = make_unique<float[]>(myPrecomputedKernelCount * myKernelSize);
|
||||
myPrecomputedKernels = make_unique<float[]>(
|
||||
static_cast<size_t>(myPrecomputedKernelCount) * myKernelSize);
|
||||
|
||||
if (myFormatFrom.stereo)
|
||||
{
|
||||
|
@ -96,7 +97,8 @@ void LanczosResampler::precomputeKernels()
|
|||
uInt32 timeIndex = 0;
|
||||
|
||||
for (uInt32 i = 0; i < myPrecomputedKernelCount; ++i) {
|
||||
float* kernel = myPrecomputedKernels.get() + myKernelSize * i;
|
||||
float* kernel = myPrecomputedKernels.get() +
|
||||
static_cast<size_t>(myKernelSize) * i;
|
||||
// The kernel is normalized such to be evaluate on time * formatFrom.sampleRate
|
||||
const float center =
|
||||
static_cast<float>(timeIndex) / static_cast<float>(myFormatTo.sampleRate);
|
||||
|
@ -140,10 +142,11 @@ void LanczosResampler::fillFragment(float* fragment, uInt32 length)
|
|||
return;
|
||||
}
|
||||
|
||||
const uInt32 outputSamples = myFormatTo.stereo ? (length >> 1) : length;
|
||||
const size_t outputSamples = myFormatTo.stereo ? (length >> 1) : length;
|
||||
|
||||
for (uInt32 i = 0; i < outputSamples; ++i) {
|
||||
const float* kernel = myPrecomputedKernels.get() + (myCurrentKernelIndex * myKernelSize);
|
||||
for (size_t i = 0; i < outputSamples; ++i) {
|
||||
const float* kernel = myPrecomputedKernels.get() +
|
||||
static_cast<size_t>(myCurrentKernelIndex) * myKernelSize;
|
||||
myCurrentKernelIndex = (myCurrentKernelIndex + 1) % myPrecomputedKernelCount;
|
||||
|
||||
if (myFormatFrom.stereo) {
|
||||
|
@ -180,11 +183,16 @@ inline void LanczosResampler::shiftSamples(uInt32 samplesToShift)
|
|||
{
|
||||
while (samplesToShift-- > 0) {
|
||||
if (myFormatFrom.stereo) {
|
||||
myBufferL->shift(myHighPassL.apply(myCurrentFragment[2*myFragmentIndex] / static_cast<float>(0x7fff)));
|
||||
myBufferR->shift(myHighPassR.apply(myCurrentFragment[2*myFragmentIndex + 1] / static_cast<float>(0x7fff)));
|
||||
myBufferL->shift(myHighPassL.apply(
|
||||
myCurrentFragment[2 * static_cast<size_t>(myFragmentIndex)] /
|
||||
static_cast<float>(0x7fff)));
|
||||
myBufferR->shift(myHighPassR.apply(
|
||||
myCurrentFragment[2 * static_cast<size_t>(myFragmentIndex) + 1] /
|
||||
static_cast<float>(0x7fff)));
|
||||
}
|
||||
else
|
||||
myBuffer->shift(myHighPass.apply(myCurrentFragment[myFragmentIndex] / static_cast<float>(0x7fff)));
|
||||
myBuffer->shift(myHighPass.apply(myCurrentFragment[myFragmentIndex] /
|
||||
static_cast<float>(0x7fff)));
|
||||
|
||||
++myFragmentIndex;
|
||||
|
||||
|
|
|
@ -44,13 +44,17 @@ void SimpleResampler::fillFragment(float* fragment, uInt32 length)
|
|||
return;
|
||||
}
|
||||
|
||||
const uInt32 outputSamples = myFormatTo.stereo ? (length >> 1) : length;
|
||||
const size_t outputSamples = myFormatTo.stereo ? (length >> 1) : length;
|
||||
|
||||
// For the following math, remember that myTimeIndex = time * myFormatFrom.sampleRate * myFormatTo.sampleRate
|
||||
for (uInt32 i = 0; i < outputSamples; ++i) {
|
||||
for (size_t i = 0; i < outputSamples; ++i) {
|
||||
if (myFormatFrom.stereo) {
|
||||
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);
|
||||
const float sampleL = static_cast<float>(
|
||||
myCurrentFragment[2*static_cast<size_t>(myFragmentIndex)]) /
|
||||
static_cast<float>(0x7fff);
|
||||
const float sampleR = static_cast<float>(
|
||||
myCurrentFragment[2*static_cast<size_t>(myFragmentIndex) + 1]) /
|
||||
static_cast<float>(0x7fff);
|
||||
|
||||
if (myFormatTo.stereo) {
|
||||
fragment[2*i] = sampleL;
|
||||
|
@ -59,7 +63,8 @@ void SimpleResampler::fillFragment(float* fragment, uInt32 length)
|
|||
else
|
||||
fragment[i] = (sampleL + sampleR) / 2.F;
|
||||
} else {
|
||||
const float sample = static_cast<float>(myCurrentFragment[myFragmentIndex] / static_cast<float>(0x7fff));
|
||||
const auto sample = static_cast<float>(myCurrentFragment[myFragmentIndex] /
|
||||
static_cast<float>(0x7fff));
|
||||
|
||||
if (myFormatTo.stereo)
|
||||
fragment[2*i] = fragment[2*i + 1] = sample;
|
||||
|
|
|
@ -281,7 +281,7 @@ int main(int ac, char* av[])
|
|||
{
|
||||
attachConsole();
|
||||
Logger::debug("Displaying usage");
|
||||
theOSystem->settings().usage();
|
||||
Settings::usage();
|
||||
freeConsole();
|
||||
return Cleanup();
|
||||
}
|
||||
|
@ -294,15 +294,15 @@ int main(int ac, char* av[])
|
|||
// If not, use the built-in ROM launcher. In this case, we enter 'launcher'
|
||||
// mode and let the main event loop take care of opening a new console/ROM.
|
||||
FSNode romnode(romfile);
|
||||
if(romfile == "" || romnode.isDirectory())
|
||||
if(romfile.empty() || romnode.isDirectory())
|
||||
{
|
||||
Logger::debug("Attempting to use ROM launcher ...");
|
||||
bool launcherOpened = romfile != "" ?
|
||||
bool launcherOpened = !romfile.empty() ?
|
||||
theOSystem->createLauncher(romnode.getPath()) : theOSystem->createLauncher();
|
||||
if(!launcherOpened)
|
||||
{
|
||||
Logger::debug("Launcher could not be started, showing usage");
|
||||
theOSystem->settings().usage();
|
||||
Settings::usage();
|
||||
return Cleanup();
|
||||
}
|
||||
}
|
||||
|
@ -333,7 +333,7 @@ int main(int ac, char* av[])
|
|||
|
||||
#ifdef DEBUGGER_SUPPORT
|
||||
// Set up any breakpoint that was on the command line
|
||||
if(localOpts["break"].toString() != "")
|
||||
if(!localOpts["break"].toString().empty())
|
||||
{
|
||||
Debugger& dbg = theOSystem->debugger();
|
||||
uInt16 bp = uInt16(dbg.stringToValue(localOpts["break"].toString()));
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace {
|
|||
{}
|
||||
|
||||
std::map<string, Variant> load() override {
|
||||
if (!myKvr.has(myKey)) return std::map<string, Variant>();
|
||||
if (!myKvr.has(myKey)) return {};
|
||||
|
||||
Variant serialized;
|
||||
myKvr.get(myKey, serialized);
|
||||
|
@ -51,12 +51,13 @@ namespace {
|
|||
KeyValueRepositoryAtomic& myKvr;
|
||||
const string& myKey;
|
||||
};
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
CompositeKVRJsonAdapter::CompositeKVRJsonAdapter(KeyValueRepositoryAtomic& kvr)
|
||||
: myKvr{kvr}
|
||||
{}
|
||||
{
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
shared_ptr<KeyValueRepository> CompositeKVRJsonAdapter::get(const string& key)
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
#include "repository/CompositeKeyValueRepository.hxx"
|
||||
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool CompositeKeyValueRepositoryAtomic::get(const string& key1, const string& key2, Variant& value)
|
||||
{
|
||||
|
@ -28,8 +27,7 @@ bool CompositeKeyValueRepositoryAtomic::get(const string& key1, const string& ke
|
|||
shared_ptr<KeyValueRepositoryAtomic> CompositeKeyValueRepositoryAtomic::getAtomic(const string& key)
|
||||
{
|
||||
auto repo = get(key);
|
||||
|
||||
return shared_ptr<KeyValueRepositoryAtomic>(repo, repo->atomic());
|
||||
return {repo, repo->atomic()};
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -27,7 +27,7 @@ class KeyValueRepositoryConfigfile : public KeyValueRepositoryFile<KeyValueRepos
|
|||
using KeyValueRepositoryFile<KeyValueRepositoryConfigfile>::load;
|
||||
using KeyValueRepositoryFile<KeyValueRepositoryConfigfile>::save;
|
||||
|
||||
explicit KeyValueRepositoryConfigfile(const FSNode& node);
|
||||
explicit KeyValueRepositoryConfigfile(const FSNode& file);
|
||||
|
||||
static std::map<string, Variant> load(istream& in);
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace {
|
|||
|
||||
return parsed.is_discarded() ? json(s) : parsed;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
KeyValueRepositoryJsonFile::KeyValueRepositoryJsonFile(const FSNode& node)
|
||||
|
@ -55,14 +55,16 @@ std::map<string, Variant> KeyValueRepositoryJsonFile::load(istream& in)
|
|||
return map;
|
||||
}
|
||||
catch (const json::exception& err) {
|
||||
Logger::error("KeyValueRepositoryJsonFile: error during deserialization: " + string(err.what()));
|
||||
Logger::error("KeyValueRepositoryJsonFile: error during deserialization: " +
|
||||
string(err.what()));
|
||||
|
||||
return std::map<string, Variant>();
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool KeyValueRepositoryJsonFile::save(ostream& out, const std::map<string, Variant>& values)
|
||||
bool KeyValueRepositoryJsonFile::save(ostream& out,
|
||||
const std::map<string, Variant>& values)
|
||||
{
|
||||
try {
|
||||
json serializedJson = json::object();
|
||||
|
@ -75,7 +77,8 @@ bool KeyValueRepositoryJsonFile::save(ostream& out, const std::map<string, Varia
|
|||
return true;
|
||||
}
|
||||
catch (const json::exception& err) {
|
||||
Logger::error("KeyValueRepositoryJsonFile: error during serialization: " + string(err.what()));
|
||||
Logger::error("KeyValueRepositoryJsonFile: error during serialization: " +
|
||||
string(err.what()));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace {
|
|||
string readQuotedString(istream& in)
|
||||
{
|
||||
// Read characters until we see a quote
|
||||
char c;
|
||||
char c{0};
|
||||
while(in.get(c))
|
||||
if(c == '"')
|
||||
break;
|
||||
|
@ -49,25 +49,24 @@ namespace {
|
|||
void writeQuotedString(ostream& out, const string& s)
|
||||
{
|
||||
out.put('"');
|
||||
for(uInt32 i = 0; i < s.length(); ++i)
|
||||
for(auto c: s)
|
||||
{
|
||||
if(s[i] == '\\')
|
||||
if(c == '\\')
|
||||
{
|
||||
out.put('\\');
|
||||
out.put('\\');
|
||||
}
|
||||
else if(s[i] == '\"')
|
||||
else if(c == '\"')
|
||||
{
|
||||
out.put('\\');
|
||||
out.put('"');
|
||||
}
|
||||
else
|
||||
out.put(s[i]);
|
||||
out.put(c);
|
||||
}
|
||||
out.put('"');
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
KeyValueRepositoryPropertyFile::KeyValueRepositoryPropertyFile(
|
||||
|
@ -92,7 +91,7 @@ std::map<string, Variant> KeyValueRepositoryPropertyFile::load(istream& in)
|
|||
if(!in) return map;
|
||||
|
||||
// A null key signifies the end of the property list
|
||||
if(key == "")
|
||||
if(key.empty())
|
||||
break;
|
||||
|
||||
// Get the value associated with this property
|
||||
|
@ -109,9 +108,10 @@ std::map<string, Variant> KeyValueRepositoryPropertyFile::load(istream& in)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool KeyValueRepositoryPropertyFile::save(ostream& out, const std::map<string, Variant>& values)
|
||||
bool KeyValueRepositoryPropertyFile::save(ostream& out,
|
||||
const std::map<string, Variant>& values)
|
||||
{
|
||||
for (auto& [key, value]: values) {
|
||||
for (const auto& [key, value]: values) {
|
||||
writeQuotedString(out, key);
|
||||
out.put(' ');
|
||||
writeQuotedString(out, value.toString());
|
||||
|
|
|
@ -45,7 +45,7 @@ bool CompositeKeyValueRepositorySqlite::has(const string& key)
|
|||
try {
|
||||
(*myStmtCountSet)
|
||||
.reset()
|
||||
.bind(1, key.c_str());
|
||||
.bind(1, key);
|
||||
|
||||
if (!myStmtCountSet->step())
|
||||
throw SqliteError("count failed");
|
||||
|
@ -68,7 +68,7 @@ void CompositeKeyValueRepositorySqlite::remove(const string& key)
|
|||
try {
|
||||
(*myStmtDeleteSet)
|
||||
.reset()
|
||||
.bind(1, key.c_str())
|
||||
.bind(1, key)
|
||||
.step();
|
||||
|
||||
myStmtDelete->reset();
|
||||
|
@ -153,9 +153,9 @@ SqliteStatement& CompositeKeyValueRepositorySqlite::ProxyRepository::stmtInsert(
|
|||
) {
|
||||
return (*myRepo.myStmtInsert)
|
||||
.reset()
|
||||
.bind(1, myKey.c_str())
|
||||
.bind(2, key.c_str())
|
||||
.bind(3, value.c_str());
|
||||
.bind(1, myKey)
|
||||
.bind(2, key)
|
||||
.bind(3, value);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -163,7 +163,7 @@ SqliteStatement& CompositeKeyValueRepositorySqlite::ProxyRepository::stmtSelect(
|
|||
{
|
||||
return (*myRepo.myStmtSelect)
|
||||
.reset()
|
||||
.bind(1, myKey.c_str());
|
||||
.bind(1, myKey);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -172,8 +172,8 @@ SqliteStatement& CompositeKeyValueRepositorySqlite::ProxyRepository::stmtDelete(
|
|||
myRepo.myStmtDelete->reset();
|
||||
|
||||
return (*myRepo.myStmtDelete)
|
||||
.bind(1, myKey.c_str())
|
||||
.bind(2, key.c_str());
|
||||
.bind(1, myKey)
|
||||
.bind(2, key);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -181,8 +181,8 @@ SqliteStatement& CompositeKeyValueRepositorySqlite::ProxyRepository::stmtSelectO
|
|||
{
|
||||
return (*myRepo.myStmtSelectOne)
|
||||
.reset()
|
||||
.bind(1, myKey.c_str())
|
||||
.bind(2, key.c_str());
|
||||
.bind(1, myKey)
|
||||
.bind(2, key);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -190,8 +190,8 @@ SqliteStatement& CompositeKeyValueRepositorySqlite::ProxyRepository::stmtCount(c
|
|||
{
|
||||
return (*myRepo.myStmtCount)
|
||||
.reset()
|
||||
.bind(1, myKey.c_str())
|
||||
.bind(2, key.c_str());
|
||||
.bind(1, myKey)
|
||||
.bind(2, key);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -34,8 +34,8 @@ SqliteStatement& KeyValueRepositorySqlite::stmtInsert(const string& key, const s
|
|||
{
|
||||
return (*myStmtInsert)
|
||||
.reset()
|
||||
.bind(1, key.c_str())
|
||||
.bind(2, value.c_str());
|
||||
.bind(1, key)
|
||||
.bind(2, value);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -50,7 +50,7 @@ SqliteStatement& KeyValueRepositorySqlite::stmtDelete(const string& key)
|
|||
{
|
||||
return (*myStmtDelete)
|
||||
.reset()
|
||||
.bind(1, key.c_str());
|
||||
.bind(1, key);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -58,7 +58,7 @@ SqliteStatement& KeyValueRepositorySqlite::stmtCount(const string& key)
|
|||
{
|
||||
return (*myStmtCount)
|
||||
.reset()
|
||||
.bind(1, key.c_str());
|
||||
.bind(1, key);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -66,7 +66,7 @@ SqliteStatement& KeyValueRepositorySqlite::stmtSelectOne(const string& key)
|
|||
{
|
||||
return (*myStmtSelectOne)
|
||||
.reset()
|
||||
.bind(1, key.c_str());
|
||||
.bind(1, key);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -53,7 +53,7 @@ void SqliteDatabase::initialize()
|
|||
if (!dbInitialized && tries == 1) {
|
||||
Logger::info("sqlite DB " + myDatabaseFile + " seems to be corrupt, removing and retrying...");
|
||||
|
||||
remove(myDatabaseFile.c_str());
|
||||
std::ignore = remove(myDatabaseFile.c_str());
|
||||
if (myHandle) sqlite3_close_v2(myHandle);
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ Int32 SqliteDatabase::getUserVersion() const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void SqliteDatabase::setUserVersion(Int32 version)
|
||||
void SqliteDatabase::setUserVersion(Int32 version) const
|
||||
{
|
||||
SqliteStatement(*this, "PRAGMA user_version = %i", static_cast<int>(version))
|
||||
.step();
|
||||
|
|
|
@ -42,7 +42,7 @@ class SqliteDatabase
|
|||
void exec(const string& sql, T arg1, Ts... args);
|
||||
|
||||
Int32 getUserVersion() const;
|
||||
void setUserVersion(Int32 version);
|
||||
void setUserVersion(Int32 version) const;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -44,7 +44,8 @@ SqliteStatement::~SqliteStatement()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
SqliteStatement& SqliteStatement::bind(int index, const string& value)
|
||||
{
|
||||
if (sqlite3_bind_text(myStmt, index, value.c_str(), -1, SQLITE_TRANSIENT) != SQLITE_OK)
|
||||
if (sqlite3_bind_text(myStmt, index, value.c_str(), -1,
|
||||
SQLITE_TRANSIENT) != SQLITE_OK) // NOLINT (performance-no-int-to-ptr)
|
||||
throw SqliteError(myHandle);
|
||||
|
||||
return *this;
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
namespace {
|
||||
constexpr Int32 CURRENT_VERSION = 1;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
StellaDb::StellaDb(const string& databaseDirectory, const string& databaseName)
|
||||
|
@ -85,7 +85,7 @@ void StellaDb::initialize()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const string StellaDb::databaseFileName() const
|
||||
string StellaDb::databaseFileName() const
|
||||
{
|
||||
return myDb ? FSNode(myDb->fileName()).getShortPath() : "[failed]";
|
||||
}
|
||||
|
@ -190,8 +190,11 @@ void StellaDb::importOldPropset(const FSNode& node)
|
|||
while (true) {
|
||||
auto props = KeyValueRepositoryPropertyFile::load(in);
|
||||
|
||||
if (props.size() == 0) break;
|
||||
if ((props.find("Cart.MD5") == props.end()) || props["Cart.MD5"].toString() == "") continue;
|
||||
if (props.empty())
|
||||
break;
|
||||
if ((props.find("Cart.MD5") == props.end()) ||
|
||||
props["Cart.MD5"].toString().empty())
|
||||
continue;
|
||||
|
||||
myPropertyRepository->get(props["Cart.MD5"].toString())->save(props);
|
||||
}
|
||||
|
@ -201,7 +204,7 @@ void StellaDb::importOldPropset(const FSNode& node)
|
|||
void StellaDb::migrate()
|
||||
{
|
||||
const Int32 version = myDb->getUserVersion();
|
||||
switch (version) {
|
||||
switch (version) { // NOLINT (could be written as IF/ELSE)
|
||||
case 1:
|
||||
return;
|
||||
|
||||
|
|
|
@ -27,21 +27,25 @@
|
|||
class StellaDb
|
||||
{
|
||||
public:
|
||||
|
||||
StellaDb(const string& databaseDirectory, const string& databaseName);
|
||||
|
||||
void initialize();
|
||||
|
||||
KeyValueRepositoryAtomic& settingsRepository() const { return *mySettingsRepository; }
|
||||
CompositeKeyValueRepository& propertyRepository() const { return *myPropertyRepository; }
|
||||
CompositeKeyValueRepositoryAtomic& highscoreRepository() const { return *myHighscoreRepository; }
|
||||
KeyValueRepositoryAtomic& settingsRepository() const {
|
||||
return *mySettingsRepository;
|
||||
}
|
||||
CompositeKeyValueRepository& propertyRepository() const {
|
||||
return *myPropertyRepository;
|
||||
}
|
||||
CompositeKeyValueRepositoryAtomic& highscoreRepository() const {
|
||||
return *myHighscoreRepository;
|
||||
}
|
||||
|
||||
const string databaseFileName() const;
|
||||
string databaseFileName() const;
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
private:
|
||||
|
||||
void initializeDb();
|
||||
void importOldSettings();
|
||||
void importStellarc(const FSNode& node);
|
||||
|
@ -51,7 +55,6 @@ class StellaDb
|
|||
void migrate();
|
||||
|
||||
private:
|
||||
|
||||
string myDatabaseDirectory;
|
||||
string myDatabaseName;
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ void BilinearBlitter::recreateTexturesIfNecessary()
|
|||
}
|
||||
|
||||
if (myAttributes.blending) {
|
||||
const uInt8 blendAlpha = static_cast<uInt8>(myAttributes.blendalpha * 2.55);
|
||||
const auto blendAlpha = static_cast<uInt8>(myAttributes.blendalpha * 2.55);
|
||||
|
||||
std::array<SDL_Texture*, 2> textures = { myTexture, mySecondaryTexture };
|
||||
for (SDL_Texture* texture: textures) {
|
||||
|
|
|
@ -181,7 +181,7 @@ void QisBlitter::recreateTexturesIfNecessary()
|
|||
}
|
||||
|
||||
if (myAttributes.blending) {
|
||||
const uInt8 blendAlpha = static_cast<uInt8>(myAttributes.blendalpha * 2.55);
|
||||
const auto blendAlpha = static_cast<uInt8>(myAttributes.blendalpha * 2.55);
|
||||
|
||||
std::array<SDL_Texture*, 3> textures = {
|
||||
mySrcTexture, myIntermediateTexture, mySecondaryIntermedateTexture
|
||||
|
|
|
@ -37,7 +37,7 @@ class QisBlitter : public Blitter {
|
|||
SDL_Rect srcRect,
|
||||
SDL_Rect destRect,
|
||||
FBSurface::Attributes attributes,
|
||||
SDL_Surface* staticData = nullptr
|
||||
SDL_Surface* staticData
|
||||
) override;
|
||||
|
||||
void blit(SDL_Surface& surface) override;
|
||||
|
|
|
@ -42,11 +42,11 @@ void AtariNTSC::initialize(const Setup& setup)
|
|||
void AtariNTSC::setPalette(const PaletteArray& palette)
|
||||
{
|
||||
uInt8* ptr = myRGBPalette.data();
|
||||
for(size_t i = 0; i < palette.size(); ++i)
|
||||
for(auto p: palette)
|
||||
{
|
||||
*ptr++ = (palette[i] >> 16) & 0xff;
|
||||
*ptr++ = (palette[i] >> 8) & 0xff;
|
||||
*ptr++ = palette[i] & 0xff;
|
||||
*ptr++ = (p >> 16) & 0xff;
|
||||
*ptr++ = (p >> 8) & 0xff;
|
||||
*ptr++ = p & 0xff;
|
||||
}
|
||||
generateKernels();
|
||||
}
|
||||
|
@ -60,10 +60,10 @@ void AtariNTSC::generateKernels()
|
|||
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 );
|
||||
float y, i, q; RGB_TO_YIQ( r, g, b, y, i, q ); // NOLINT
|
||||
|
||||
// Generate kernel
|
||||
int ir, ig, ib; YIQ_TO_RGB( y, i, q, myImpl.to_rgb.data(), ir, ig, ib );
|
||||
int ir, ig, ib; YIQ_TO_RGB( y, i, q, myImpl.to_rgb.data(), ir, ig, ib ); //NOLINT
|
||||
const uInt32 rgb = PACK_RGB( ir, ig, ib );
|
||||
|
||||
uInt32* kernel = myColorTable[entry].data();
|
||||
|
@ -123,7 +123,7 @@ void AtariNTSC::render(const uInt8* atari_in, const uInt32 in_width,
|
|||
|
||||
// Copy phosphor values into out buffer
|
||||
if(rgb_in != nullptr)
|
||||
memcpy(rgb_out, rgb_in, in_height * out_pitch);
|
||||
memcpy(rgb_out, rgb_in, static_cast<size_t>(in_height) * out_pitch);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -134,8 +134,8 @@ void AtariNTSC::renderThread(const uInt8* atari_in, const uInt32 in_width,
|
|||
// Adapt parameters to thread number
|
||||
const uInt32 yStart = in_height * threadNum / numThreads;
|
||||
const uInt32 yEnd = in_height * (threadNum + 1) / numThreads;
|
||||
atari_in += in_width * yStart;
|
||||
rgb_out = static_cast<char*>(rgb_out) + out_pitch * yStart;
|
||||
atari_in += static_cast<size_t>(in_width) * yStart;
|
||||
rgb_out = static_cast<char*>(rgb_out) + static_cast<size_t>(out_pitch) * yStart;
|
||||
|
||||
uInt32 const chunk_count = (in_width - 1) / PIXEL_in_chunk;
|
||||
|
||||
|
@ -143,7 +143,7 @@ void AtariNTSC::renderThread(const uInt8* atari_in, const uInt32 in_width,
|
|||
{
|
||||
const uInt8* line_in = atari_in;
|
||||
ATARI_NTSC_BEGIN_ROW(NTSC_black, line_in[0]);
|
||||
uInt32* restrict line_out = static_cast<uInt32*>(rgb_out);
|
||||
auto* restrict line_out = static_cast<uInt32*>(rgb_out);
|
||||
++line_in;
|
||||
|
||||
// shift right by 2 pixel
|
||||
|
@ -210,8 +210,8 @@ void AtariNTSC::renderWithPhosphorThread(const uInt8* atari_in, const uInt32 in_
|
|||
const uInt32 yEnd = in_height * (threadNum + 1) / numThreads;
|
||||
uInt32 bufofs = AtariNTSC::outWidth(in_width) * yStart;
|
||||
const uInt32* out = static_cast<uInt32*>(rgb_out);
|
||||
atari_in += in_width * yStart;
|
||||
rgb_out = static_cast<char*>(rgb_out) + out_pitch * yStart;
|
||||
atari_in += static_cast<size_t>(in_width) * yStart;
|
||||
rgb_out = static_cast<char*>(rgb_out) + static_cast<size_t>(out_pitch) * yStart;
|
||||
|
||||
uInt32 const chunk_count = (in_width - 1) / PIXEL_in_chunk;
|
||||
|
||||
|
@ -219,7 +219,7 @@ void AtariNTSC::renderWithPhosphorThread(const uInt8* atari_in, const uInt32 in_
|
|||
{
|
||||
const uInt8* line_in = atari_in;
|
||||
ATARI_NTSC_BEGIN_ROW(NTSC_black, line_in[0]);
|
||||
uInt32* restrict line_out = static_cast<uInt32*>(rgb_out);
|
||||
auto* restrict line_out = static_cast<uInt32*>(rgb_out);
|
||||
++line_in;
|
||||
|
||||
// shift right by 2 pixel
|
||||
|
@ -335,9 +335,8 @@ void AtariNTSC::init(init_t& impl, const Setup& setup)
|
|||
/* setup decoder matricies */
|
||||
{
|
||||
float* out = impl.to_rgb.data();
|
||||
int n;
|
||||
|
||||
n = burst_count;
|
||||
int n = burst_count;
|
||||
do
|
||||
{
|
||||
float const* in = default_decoder.data();
|
||||
|
@ -355,14 +354,14 @@ void AtariNTSC::init(init_t& impl, const Setup& setup)
|
|||
ROTATE_IQ( s, c, 0.866025F, -0.5F ); /* +120 degrees */
|
||||
#endif
|
||||
}
|
||||
while ( --n );
|
||||
while (--n);
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void AtariNTSC::initFilters(init_t& impl, const Setup& setup)
|
||||
{
|
||||
std::array<float, kernel_size * 2> kernels{0};
|
||||
std::array<float, static_cast<size_t>(kernel_size) * 2> kernels{0};
|
||||
|
||||
/* generate luma (y) filter using sinc kernel */
|
||||
{
|
||||
|
@ -433,12 +432,11 @@ void AtariNTSC::initFilters(init_t& impl, const Setup& setup)
|
|||
for ( int i = 0; i < 2; i++ )
|
||||
{
|
||||
float sum = 0;
|
||||
int x;
|
||||
for ( x = i; x < kernel_size; x += 2 )
|
||||
for ( int x = i; x < kernel_size; x += 2 )
|
||||
sum += kernels [x];
|
||||
|
||||
sum = 1.0F / sum;
|
||||
for ( x = i; x < kernel_size; x += 2 )
|
||||
for ( int x = i; x < kernel_size; x += 2 )
|
||||
{
|
||||
kernels [x] *= sum;
|
||||
}
|
||||
|
@ -506,12 +504,13 @@ void AtariNTSC::genKernel(init_t& impl, float y, float i, float q, uInt32* out)
|
|||
const float fq = k[1]*qc1 + k[3]*qc3;
|
||||
const float 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)] )
|
||||
if ( k < &impl.kernel [static_cast<size_t>(kernel_size) * 2 *
|
||||
(rescale_out - 1)] )
|
||||
k += kernel_size * 2 - 1;
|
||||
else
|
||||
k -= kernel_size * 2 * (rescale_out - 1) + 2;
|
||||
{
|
||||
int r, g, b; YIQ_TO_RGB( fy, fi, fq, to_rgb, r, g, b );
|
||||
int r, g, b; YIQ_TO_RGB( fy, fi, fq, to_rgb, r, g, b ); // NOLINT
|
||||
*out++ = PACK_RGB( r, g, b ) - rgb_bias;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,10 +187,10 @@ class AtariNTSC
|
|||
0.9563F, 0.6210F, -0.2721F, -0.6474F, -1.1070F, 1.7046F
|
||||
};
|
||||
|
||||
void init(init_t& impl, const Setup& setup);
|
||||
void initFilters(init_t& impl, const Setup& setup);
|
||||
static void init(init_t& impl, const Setup& setup);
|
||||
static void initFilters(init_t& impl, const Setup& setup);
|
||||
// Generate pixel at all burst phases and column alignments
|
||||
void genKernel(init_t& impl, float y, float i, float q, uInt32* out);
|
||||
static void genKernel(init_t& impl, float y, float i, float q, uInt32* out);
|
||||
|
||||
// Begins outputting row and starts two pixels. First pixel will be cut
|
||||
// off a bit. Use atari_ntsc_black for unused pixels.
|
||||
|
|
|
@ -139,7 +139,7 @@ void NTSCFilter::loadConfig(const Settings& settings)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void NTSCFilter::saveConfig(Settings& settings) const
|
||||
void NTSCFilter::saveConfig(Settings& settings)
|
||||
{
|
||||
// Save adjustables for custom mode
|
||||
settings.setValue("tv.sharpness", myCustomSetup.sharpness);
|
||||
|
@ -150,7 +150,7 @@ void NTSCFilter::saveConfig(Settings& settings) const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void NTSCFilter::getAdjustables(Adjustable& adjustable, Preset preset) const
|
||||
void NTSCFilter::getAdjustables(Adjustable& adjustable, Preset preset)
|
||||
{
|
||||
switch(preset)
|
||||
{
|
||||
|
@ -181,7 +181,7 @@ void NTSCFilter::setCustomAdjustables(const Adjustable& adjustable)
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void NTSCFilter::convertToAdjustable(Adjustable& adjustable,
|
||||
const AtariNTSC::Setup& setup) const
|
||||
const AtariNTSC::Setup& setup)
|
||||
{
|
||||
adjustable.sharpness = scaleTo100(setup.sharpness);
|
||||
adjustable.resolution = scaleTo100(setup.resolution);
|
||||
|
@ -192,12 +192,3 @@ void NTSCFilter::convertToAdjustable(Adjustable& adjustable,
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
AtariNTSC::Setup NTSCFilter::myCustomSetup = AtariNTSC::TV_Composite;
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const std::array<NTSCFilter::AdjustableTag, int(NTSCFilter::Adjustables::NUM_ADJUSTABLES)> NTSCFilter::ourCustomAdjustables = { {
|
||||
{ "sharpness", &myCustomSetup.sharpness },
|
||||
{ "resolution", &myCustomSetup.resolution },
|
||||
{ "artifacts", &myCustomSetup.artifacts },
|
||||
{ "fringing", &myCustomSetup.fringing },
|
||||
{ "bleeding", &myCustomSetup.bleed }
|
||||
} };
|
||||
|
|
|
@ -80,12 +80,12 @@ class NTSCFilter
|
|||
// Get adjustables for the given preset
|
||||
// Values will be scaled to 0 - 100 range, independent of how
|
||||
// they're actually stored internally
|
||||
void getAdjustables(Adjustable& adjustable, Preset preset) const;
|
||||
static void getAdjustables(Adjustable& adjustable, Preset preset);
|
||||
|
||||
// Set custom adjustables to given values
|
||||
// Values will be scaled to 0 - 100 range, independent of how
|
||||
// they're actually stored internally
|
||||
void setCustomAdjustables(const Adjustable& adjustable);
|
||||
static void setCustomAdjustables(const Adjustable& adjustable);
|
||||
|
||||
// The following methods cycle through each custom adjustable
|
||||
// They are used in conjunction with the increase/decrease
|
||||
|
@ -101,8 +101,8 @@ class NTSCFilter
|
|||
string& text, string& valueText, Int32& newValue);
|
||||
|
||||
// Load and save NTSC-related settings
|
||||
void loadConfig(const Settings& settings);
|
||||
void saveConfig(Settings& settings) const;
|
||||
static void loadConfig(const Settings& settings);
|
||||
static void saveConfig(Settings& settings);
|
||||
|
||||
// Perform Blargg filtering on input buffer, place results in
|
||||
// output buffer
|
||||
|
@ -125,8 +125,8 @@ class NTSCFilter
|
|||
|
||||
private:
|
||||
// Convert from atari_ntsc_setup_t values to equivalent adjustables
|
||||
void convertToAdjustable(Adjustable& adjustable,
|
||||
const AtariNTSC::Setup& setup) const;
|
||||
static void convertToAdjustable(Adjustable& adjustable,
|
||||
const AtariNTSC::Setup& setup);
|
||||
|
||||
private:
|
||||
// The NTSC object
|
||||
|
@ -148,7 +148,14 @@ class NTSCFilter
|
|||
float* value{nullptr};
|
||||
};
|
||||
uInt32 myCurrentAdjustable{0};
|
||||
static const std::array<AdjustableTag, 5> ourCustomAdjustables;
|
||||
|
||||
static constexpr std::array<AdjustableTag, 5> ourCustomAdjustables = {{
|
||||
{ "sharpness", &myCustomSetup.sharpness },
|
||||
{ "resolution", &myCustomSetup.resolution },
|
||||
{ "artifacts", &myCustomSetup.artifacts },
|
||||
{ "fringing", &myCustomSetup.fringing },
|
||||
{ "bleeding", &myCustomSetup.bleed }
|
||||
}};
|
||||
|
||||
private:
|
||||
// Following constructors and assignment operators not supported
|
||||
|
|
|
@ -110,7 +110,8 @@ BreakpointMap::BreakpointList BreakpointMap::getBreakpoints() const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
BreakpointMap::Breakpoint BreakpointMap::convertBreakpoint(const Breakpoint& breakpoint)
|
||||
BreakpointMap::Breakpoint BreakpointMap::convertBreakpoint(
|
||||
const Breakpoint& breakpoint)
|
||||
{
|
||||
if(breakpoint.bank == ANY_BANK)
|
||||
return Breakpoint(breakpoint.addr, ANY_BANK);
|
||||
|
|
|
@ -90,7 +90,7 @@ class BreakpointMap
|
|||
size_t size() const { return myMap.size(); }
|
||||
|
||||
private:
|
||||
Breakpoint convertBreakpoint(const Breakpoint& breakpoint);
|
||||
static Breakpoint convertBreakpoint(const Breakpoint& breakpoint);
|
||||
|
||||
struct BreakpointHash {
|
||||
size_t operator()(const Breakpoint& bp) const {
|
||||
|
|
|
@ -140,8 +140,8 @@ CartDebug::CartDebug(Debugger& dbg, Console& console, const OSystem& osystem)
|
|||
const DebuggerState& CartDebug::getState()
|
||||
{
|
||||
myState.ram.clear();
|
||||
for(uInt32 i = 0; i < myState.rport.size(); ++i)
|
||||
myState.ram.push_back(myDebugger.peek(myState.rport[i]));
|
||||
for(auto addr: myState.rport)
|
||||
myState.ram.push_back(myDebugger.peek(addr));
|
||||
|
||||
if(myDebugWidget)
|
||||
myState.bank = myDebugWidget->bankState();
|
||||
|
@ -153,8 +153,8 @@ const DebuggerState& CartDebug::getState()
|
|||
void CartDebug::saveOldState()
|
||||
{
|
||||
myOldState.ram.clear();
|
||||
for(uInt32 i = 0; i < myOldState.rport.size(); ++i)
|
||||
myOldState.ram.push_back(myDebugger.peek(myOldState.rport[i]));
|
||||
for(auto addr: myOldState.rport)
|
||||
myOldState.ram.push_back(myDebugger.peek(addr));
|
||||
|
||||
if(myDebugWidget)
|
||||
{
|
||||
|
@ -209,8 +209,8 @@ string CartDebug::toString()
|
|||
return DebuggerParser::red("invalid base, this is a BUG");
|
||||
}
|
||||
|
||||
const CartState& state = static_cast<const CartState&>(getState());
|
||||
const CartState& oldstate = static_cast<const CartState&>(getOldState());
|
||||
const auto& state = static_cast<const CartState&>(getState());
|
||||
const auto& oldstate = static_cast<const CartState&>(getOldState());
|
||||
|
||||
uInt32 curraddr = 0, bytesSoFar = 0;
|
||||
for(uInt32 i = 0; i < state.ram.size(); i += bytesPerLine, bytesSoFar += bytesPerLine)
|
||||
|
@ -221,7 +221,7 @@ string CartDebug::toString()
|
|||
if(state.rport[i] - curraddr > bytesPerLine || bytesSoFar >= 256)
|
||||
{
|
||||
char port[37]; // NOLINT (convert to stringstream)
|
||||
std::snprintf(port, 36, "%04x: (rport = %04x, wport = %04x)\n",
|
||||
std::ignore = std::snprintf(port, 36, "%04x: (rport = %04x, wport = %04x)\n",
|
||||
state.rport[i], state.rport[i], state.wport[i]);
|
||||
port[2] = port[3] = 'x';
|
||||
buf << DebuggerParser::red(port);
|
||||
|
@ -232,7 +232,7 @@ string CartDebug::toString()
|
|||
|
||||
for(uInt32 j = 0; j < bytesPerLine; ++j)
|
||||
{
|
||||
buf << myDebugger.invIfChanged(state.ram[i+j], oldstate.ram[i+j]) << " ";
|
||||
buf << Debugger::invIfChanged(state.ram[i+j], oldstate.ram[i+j]) << " ";
|
||||
|
||||
if(j == 0x07) buf << " ";
|
||||
}
|
||||
|
@ -248,7 +248,8 @@ bool CartDebug::disassembleAddr(uInt16 address, bool force)
|
|||
const Cartridge& cart = myConsole.cartridge();
|
||||
const int segCount = cart.segmentCount();
|
||||
// ROM/RAM bank or ZP-RAM?
|
||||
const int addrBank = (address & 0x1000) ? getBank(address) : int(myBankInfo.size()) - 1;
|
||||
const int addrBank = (address & 0x1000)
|
||||
? getBank(address) : static_cast<int>(myBankInfo.size()) - 1;
|
||||
|
||||
if(segCount > 1)
|
||||
{
|
||||
|
@ -260,14 +261,10 @@ bool CartDebug::disassembleAddr(uInt16 address, bool force)
|
|||
const int bank = cart.getSegmentBank(seg);
|
||||
Disassembly disassembly;
|
||||
AddrToLineList addrToLineList;
|
||||
uInt16 segAddress;
|
||||
BankInfo& info = myBankInfo[bank];
|
||||
|
||||
info.offset = cart.bankOrigin(bank) | cart.bankSize() * seg;
|
||||
if(bank == addrBank)
|
||||
segAddress = address;
|
||||
else
|
||||
segAddress = info.offset;
|
||||
const uInt16 segAddress = bank == addrBank ? address : info.offset;
|
||||
// Disassemble segment
|
||||
const bool newChanged = disassemble(bank, segAddress, disassembly, addrToLineList, force);
|
||||
|
||||
|
@ -383,12 +380,12 @@ bool CartDebug::fillDisassemblyList(BankInfo& info, Disassembly& disassembly,
|
|||
disassembly.list.clear();
|
||||
addrToLineList.clear();
|
||||
// An empty address list means that DiStella can't do a disassembly
|
||||
if(info.addressList.size() == 0)
|
||||
if(info.addressList.empty())
|
||||
return false;
|
||||
|
||||
disassembly.fieldwidth = 24 + myLabelLength;
|
||||
// line offset must be set before calling DiStella!
|
||||
uInt32 lineOfs = static_cast<uInt32>(myDisassembly.list.size());
|
||||
auto lineOfs = static_cast<uInt32>(myDisassembly.list.size());
|
||||
DiStella distella(*this, disassembly.list, info, DiStella::settings,
|
||||
myDisLabels, myDisDirectives, myReserved);
|
||||
|
||||
|
@ -480,7 +477,7 @@ bool CartDebug::addDirective(Device::AccessType type,
|
|||
|
||||
if(bank < 0) // Do we want the current bank or ZP RAM?
|
||||
bank = (myDebugger.cpuDebug().pc() & 0x1000) ?
|
||||
getBank(myDebugger.cpuDebug().pc()) : int(myBankInfo.size())-1;
|
||||
getBank(myDebugger.cpuDebug().pc()) : static_cast<int>(myBankInfo.size())-1;
|
||||
|
||||
bank = std::min(bank, romBankCount());
|
||||
BankInfo& info = myBankInfo[bank];
|
||||
|
@ -569,7 +566,7 @@ bool CartDebug::addDirective(Device::AccessType type,
|
|||
// Can we also merge with the previous range (if any)?
|
||||
if(i != list.begin())
|
||||
{
|
||||
DirectiveList::iterator p = i;
|
||||
auto p = i;
|
||||
--p;
|
||||
if(p->type == tag.type && p->end + 1 == tag.start)
|
||||
{
|
||||
|
@ -632,7 +629,7 @@ bool CartDebug::addLabel(const string& label, uInt16 address)
|
|||
removeLabel(label);
|
||||
myUserAddresses.emplace(label, address);
|
||||
myUserLabels.emplace(address, label);
|
||||
myLabelLength = std::max(myLabelLength, uInt16(label.size()));
|
||||
myLabelLength = std::max(myLabelLength, static_cast<uInt16>(label.size()));
|
||||
mySystem.setDirtyPage(address);
|
||||
return true;
|
||||
}
|
||||
|
@ -836,7 +833,7 @@ string CartDebug::loadListFile()
|
|||
|
||||
getline(in, line);
|
||||
|
||||
if(!in.good() || line == "" || line[0] == '-')
|
||||
if(!in.good() || line.empty() || line[0] == '-')
|
||||
continue;
|
||||
else // Search for constants
|
||||
{
|
||||
|
@ -1137,7 +1134,7 @@ string CartDebug::saveDisassembly(string path)
|
|||
disassembleBank(bank);
|
||||
|
||||
// An empty address list means that DiStella can't do a disassembly
|
||||
if(info.addressList.size() == 0)
|
||||
if(info.addressList.empty())
|
||||
continue;
|
||||
|
||||
buf << "\n\n;***********************************************************\n"
|
||||
|
@ -1164,12 +1161,12 @@ string CartDebug::saveDisassembly(string path)
|
|||
origin += static_cast<uInt32>(info.size);
|
||||
|
||||
// Format in 'distella' style
|
||||
for(uInt32 i = 0; i < disasm.list.size(); ++i)
|
||||
for(const auto& dt: disasm.list)
|
||||
{
|
||||
const DisassemblyTag& tag = disasm.list[i];
|
||||
const DisassemblyTag& tag = dt;
|
||||
|
||||
// Add label (if any)
|
||||
if(tag.label != "")
|
||||
if(!tag.label.empty())
|
||||
buf << ALIGN(4) << (tag.label) << "\n";
|
||||
buf << " ";
|
||||
|
||||
|
@ -1381,7 +1378,7 @@ string CartDebug::saveDisassembly(string path)
|
|||
}
|
||||
}
|
||||
|
||||
if(myReserved.Label.size() > 0)
|
||||
if(!myReserved.Label.empty())
|
||||
{
|
||||
out << "\n\n;-----------------------------------------------------------\n"
|
||||
<< "; Non Locatable Labels\n"
|
||||
|
@ -1390,14 +1387,14 @@ string CartDebug::saveDisassembly(string path)
|
|||
out << ALIGN(16) << iter.second << "= $" << iter.first << "\n";
|
||||
}
|
||||
|
||||
if(myUserLabels.size() > 0)
|
||||
if(!myUserLabels.empty())
|
||||
{
|
||||
out << "\n\n;-----------------------------------------------------------\n"
|
||||
<< "; User Defined Labels\n"
|
||||
<< ";-----------------------------------------------------------\n\n";
|
||||
int max_len = 16;
|
||||
for(const auto& iter: myUserLabels)
|
||||
max_len = std::max(max_len, int(iter.second.size()));
|
||||
max_len = std::max(max_len, static_cast<int>(iter.second.size()));
|
||||
for(const auto& iter: myUserLabels)
|
||||
out << ALIGN(max_len) << iter.second << "= $" << iter.first << "\n";
|
||||
}
|
||||
|
@ -1565,7 +1562,7 @@ void CartDebug::getCompletions(const char* in, StringList& completions) const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
CartDebug::AddrType CartDebug::addressType(uInt16 addr) const
|
||||
CartDebug::AddrType CartDebug::addressType(uInt16 addr)
|
||||
{
|
||||
// Determine the type of address to access the correct list
|
||||
// These addresses were based on (and checked against) Kroko's 2600 memory
|
||||
|
@ -1647,7 +1644,7 @@ void CartDebug::accessTypeAsString(ostream& buf, uInt16 addr) const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
Device::AccessType CartDebug::accessTypeAbsolute(Device::AccessFlags flags) const
|
||||
Device::AccessType CartDebug::accessTypeAbsolute(Device::AccessFlags flags)
|
||||
{
|
||||
if(flags & Device::CODE)
|
||||
return Device::CODE;
|
||||
|
@ -1674,7 +1671,7 @@ Device::AccessType CartDebug::accessTypeAbsolute(Device::AccessFlags flags) cons
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CartDebug::AccessTypeAsString(ostream& buf, Device::AccessType type) const
|
||||
void CartDebug::AccessTypeAsString(ostream& buf, Device::AccessType type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
|
@ -1693,7 +1690,7 @@ void CartDebug::AccessTypeAsString(ostream& buf, Device::AccessType type) const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CartDebug::AccessTypeAsString(ostream& buf, Device::AccessFlags flags) const
|
||||
void CartDebug::AccessTypeAsString(ostream& buf, Device::AccessFlags flags)
|
||||
{
|
||||
if(flags)
|
||||
{
|
||||
|
|
|
@ -66,7 +66,7 @@ class CartDebug : public DebuggerSystem
|
|||
|
||||
// Determine 'type' of address (ie, what part of the system accessed)
|
||||
enum class AddrType { TIA, IO, ZPRAM, ROM };
|
||||
AddrType addressType(uInt16 addr) const;
|
||||
static AddrType addressType(uInt16 addr);
|
||||
|
||||
public:
|
||||
CartDebug(Debugger& dbg, Console& console, const OSystem& osystem);
|
||||
|
@ -260,13 +260,13 @@ class CartDebug : public DebuggerSystem
|
|||
Methods used by the command parser for tab-completion
|
||||
In this case, return completions from the equate list(s)
|
||||
*/
|
||||
void getCompletions(const char* in, StringList& list) const;
|
||||
void getCompletions(const char* in, StringList& completions) const;
|
||||
|
||||
// Convert given address to corresponding access type and append to buf
|
||||
void accessTypeAsString(ostream& buf, uInt16 addr) const;
|
||||
|
||||
// Convert access enum type to corresponding string and append to buf
|
||||
void AccessTypeAsString(ostream& buf, Device::AccessType type) const;
|
||||
static void AccessTypeAsString(ostream& buf, Device::AccessType type);
|
||||
|
||||
private:
|
||||
using AddrToLineList = std::map<uInt16, int>;
|
||||
|
@ -330,11 +330,11 @@ class CartDebug : public DebuggerSystem
|
|||
void getBankDirectives(ostream& buf, const BankInfo& info) const;
|
||||
|
||||
// Get access enum type from 'flags', taking precendence into account
|
||||
Device::AccessType accessTypeAbsolute(Device::AccessFlags flags) const;
|
||||
static Device::AccessType accessTypeAbsolute(Device::AccessFlags flags);
|
||||
|
||||
// Convert all access types in 'flags' to corresponding string and
|
||||
// append to buf
|
||||
void AccessTypeAsString(ostream& buf, Device::AccessFlags flags) const;
|
||||
static void AccessTypeAsString(ostream& buf, Device::AccessFlags flags);
|
||||
|
||||
private:
|
||||
const OSystem& myOSystem;
|
||||
|
|
|
@ -218,13 +218,13 @@ TrapArray& Debugger::writeTraps() const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const string Debugger::run(const string& command)
|
||||
string Debugger::run(const string& command)
|
||||
{
|
||||
return myParser->run(command);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const string Debugger::invIfChanged(int reg, int oldReg)
|
||||
string Debugger::invIfChanged(int reg, int oldReg)
|
||||
{
|
||||
string ret;
|
||||
|
||||
|
@ -361,7 +361,7 @@ int Debugger::trace()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Debugger::setBreakPoint(uInt16 addr, uInt8 bank, uInt32 flags)
|
||||
bool Debugger::setBreakPoint(uInt16 addr, uInt8 bank, uInt32 flags) const
|
||||
{
|
||||
if(checkBreakPoint(addr, bank))
|
||||
return false;
|
||||
|
@ -371,7 +371,7 @@ bool Debugger::setBreakPoint(uInt16 addr, uInt8 bank, uInt32 flags)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Debugger::clearBreakPoint(uInt16 addr, uInt8 bank)
|
||||
bool Debugger::clearBreakPoint(uInt16 addr, uInt8 bank) const
|
||||
{
|
||||
if(!checkBreakPoint(addr, bank))
|
||||
return false;
|
||||
|
@ -381,13 +381,13 @@ bool Debugger::clearBreakPoint(uInt16 addr, uInt8 bank)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Debugger::checkBreakPoint(uInt16 addr, uInt8 bank)
|
||||
bool Debugger::checkBreakPoint(uInt16 addr, uInt8 bank) const
|
||||
{
|
||||
return breakPoints().check(addr, bank);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Debugger::toggleBreakPoint(uInt16 addr, uInt8 bank)
|
||||
bool Debugger::toggleBreakPoint(uInt16 addr, uInt8 bank) const
|
||||
{
|
||||
if(checkBreakPoint(addr, bank))
|
||||
clearBreakPoint(addr, bank);
|
||||
|
@ -398,53 +398,53 @@ bool Debugger::toggleBreakPoint(uInt16 addr, uInt8 bank)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Debugger::addReadTrap(uInt16 t)
|
||||
void Debugger::addReadTrap(uInt16 t) const
|
||||
{
|
||||
readTraps().initialize();
|
||||
readTraps().add(t);
|
||||
}
|
||||
|
||||
void Debugger::addWriteTrap(uInt16 t)
|
||||
void Debugger::addWriteTrap(uInt16 t) const
|
||||
{
|
||||
writeTraps().initialize();
|
||||
writeTraps().add(t);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Debugger::addTrap(uInt16 t)
|
||||
void Debugger::addTrap(uInt16 t) const
|
||||
{
|
||||
addReadTrap(t);
|
||||
addWriteTrap(t);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Debugger::removeReadTrap(uInt16 t)
|
||||
void Debugger::removeReadTrap(uInt16 t) const
|
||||
{
|
||||
readTraps().initialize();
|
||||
readTraps().remove(t);
|
||||
}
|
||||
|
||||
void Debugger::removeWriteTrap(uInt16 t)
|
||||
void Debugger::removeWriteTrap(uInt16 t) const
|
||||
{
|
||||
writeTraps().initialize();
|
||||
writeTraps().remove(t);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Debugger::removeTrap(uInt16 t)
|
||||
void Debugger::removeTrap(uInt16 t) const
|
||||
{
|
||||
removeReadTrap(t);
|
||||
removeWriteTrap(t);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Debugger::readTrap(uInt16 t)
|
||||
bool Debugger::readTrap(uInt16 t) const
|
||||
{
|
||||
return readTraps().isInitialized() && readTraps().isSet(t);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool Debugger::writeTrap(uInt16 t)
|
||||
bool Debugger::writeTrap(uInt16 t) const
|
||||
{
|
||||
return writeTraps().isInitialized() && writeTraps().isSet(t);
|
||||
}
|
||||
|
@ -700,13 +700,13 @@ uInt16 Debugger::unwindStates(const uInt16 numStates, string& message)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Debugger::clearAllBreakPoints()
|
||||
void Debugger::clearAllBreakPoints() const
|
||||
{
|
||||
breakPoints().clear();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Debugger::clearAllTraps()
|
||||
void Debugger::clearAllTraps() const
|
||||
{
|
||||
readTraps().clearAll();
|
||||
writeTraps().clearAll();
|
||||
|
@ -829,7 +829,7 @@ bool Debugger::delFunction(const string& name)
|
|||
const Expression& Debugger::getFunction(const string& name) const
|
||||
{
|
||||
const auto& iter = myFunctions.find(name);
|
||||
return iter != myFunctions.end() ? *(iter->second.get()) : EmptyExpression;
|
||||
return iter != myFunctions.end() ? *(iter->second) : EmptyExpression;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -840,13 +840,13 @@ const string& Debugger::getFunctionDef(const string& name) const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const Debugger::FunctionDefMap Debugger::getFunctionDefMap() const
|
||||
Debugger::FunctionDefMap Debugger::getFunctionDefMap() const
|
||||
{
|
||||
return myFunctionDefs;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string Debugger::builtinHelp() const
|
||||
string Debugger::builtinHelp()
|
||||
{
|
||||
ostringstream buf;
|
||||
size_t c_maxlen = 0, i_maxlen = 0;
|
||||
|
|
|
@ -111,13 +111,13 @@ class Debugger : public DialogContainer
|
|||
|
||||
bool addFunction(const string& name, const string& def,
|
||||
Expression* exp, bool builtin = false);
|
||||
bool isBuiltinFunction(const string& name);
|
||||
static bool isBuiltinFunction(const string& name);
|
||||
bool delFunction(const string& name);
|
||||
const Expression& getFunction(const string& name) const;
|
||||
|
||||
const string& getFunctionDef(const string& name) const;
|
||||
const FunctionDefMap getFunctionDefMap() const;
|
||||
string builtinHelp() const;
|
||||
FunctionDefMap getFunctionDefMap() const;
|
||||
static string builtinHelp();
|
||||
|
||||
/**
|
||||
Methods used by the command parser for tab-completion
|
||||
|
@ -168,33 +168,33 @@ class Debugger : public DialogContainer
|
|||
Returns true if successfully set
|
||||
*/
|
||||
bool setBreakPoint(uInt16 addr, uInt8 bank = ANY_BANK,
|
||||
uInt32 flags = 0);
|
||||
uInt32 flags = 0) const;
|
||||
|
||||
/**
|
||||
Clears a breakpoint.
|
||||
|
||||
Returns true if successfully cleared
|
||||
*/
|
||||
bool clearBreakPoint(uInt16 addr, uInt8 bank);
|
||||
bool clearBreakPoint(uInt16 addr, uInt8 bank) const;
|
||||
|
||||
/**
|
||||
Toggles a breakpoint
|
||||
|
||||
Returns new state of breakpoint
|
||||
*/
|
||||
bool toggleBreakPoint(uInt16 addr, uInt8 bank);
|
||||
bool toggleBreakPoint(uInt16 addr, uInt8 bank) const;
|
||||
|
||||
/**
|
||||
Checks for a breakpoint.
|
||||
|
||||
Returns true if existing, else false
|
||||
*/
|
||||
bool checkBreakPoint(uInt16 addr, uInt8 bank);
|
||||
bool checkBreakPoint(uInt16 addr, uInt8 bank) const;
|
||||
|
||||
/**
|
||||
Run the debugger command and return the result.
|
||||
*/
|
||||
const string run(const string& command);
|
||||
string run(const string& command);
|
||||
|
||||
string autoExec(StringList* history);
|
||||
|
||||
|
@ -235,7 +235,7 @@ class Debugger : public DialogContainer
|
|||
}
|
||||
|
||||
/** Invert given input if it differs from its previous value */
|
||||
const string invIfChanged(int reg, int oldReg);
|
||||
static string invIfChanged(int reg, int oldReg);
|
||||
|
||||
/**
|
||||
This is used when we want the debugger from a class that can't
|
||||
|
@ -261,7 +261,7 @@ class Debugger : public DialogContainer
|
|||
Device::AccessFlags getAccessFlags(uInt16 addr) const;
|
||||
void setAccessFlags(uInt16 addr, Device::AccessFlags flags);
|
||||
|
||||
uInt32 getBaseAddress(uInt32 addr, bool read);
|
||||
static uInt32 getBaseAddress(uInt32 addr, bool read);
|
||||
|
||||
bool patchROM(uInt16 addr, uInt8 value);
|
||||
|
||||
|
@ -315,17 +315,17 @@ class Debugger : public DialogContainer
|
|||
uInt16 rewindStates(const uInt16 numStates, string& message);
|
||||
uInt16 unwindStates(const uInt16 numStates, string& message);
|
||||
|
||||
void clearAllBreakPoints();
|
||||
void clearAllBreakPoints() const;
|
||||
|
||||
void addReadTrap(uInt16 t);
|
||||
void addWriteTrap(uInt16 t);
|
||||
void addTrap(uInt16 t);
|
||||
void removeReadTrap(uInt16 t);
|
||||
void removeWriteTrap(uInt16 t);
|
||||
void removeTrap(uInt16 t);
|
||||
bool readTrap(uInt16 t);
|
||||
bool writeTrap(uInt16 t);
|
||||
void clearAllTraps();
|
||||
void addReadTrap(uInt16 t) const;
|
||||
void addWriteTrap(uInt16 t) const;
|
||||
void addTrap(uInt16 t) const;
|
||||
void removeReadTrap(uInt16 t) const;
|
||||
void removeWriteTrap(uInt16 t) const;
|
||||
void removeTrap(uInt16 t) const;
|
||||
bool readTrap(uInt16 t) const;
|
||||
bool writeTrap(uInt16 t) const;
|
||||
void clearAllTraps() const;
|
||||
void log(const string& triggerMsg);
|
||||
|
||||
// Set a bunch of RAM locations at once
|
||||
|
|
|
@ -25,9 +25,7 @@
|
|||
#include "ControlLowLevel.hxx"
|
||||
#include "TIADebug.hxx"
|
||||
#include "TiaOutputWidget.hxx"
|
||||
#include "DebuggerParser.hxx"
|
||||
#include "YaccParser.hxx"
|
||||
#include "M6502.hxx"
|
||||
#include "Expression.hxx"
|
||||
#include "FSNode.hxx"
|
||||
#include "OSystem.hxx"
|
||||
|
@ -148,7 +146,9 @@ string DebuggerParser::exec(const FSNode& file, StringList* history)
|
|||
if(!getline(in, command))
|
||||
break;
|
||||
|
||||
++execDepth;
|
||||
run(command);
|
||||
--execDepth;
|
||||
if (history != nullptr)
|
||||
history->push_back(command);
|
||||
count++;
|
||||
|
@ -175,7 +175,7 @@ void DebuggerParser::outputCommandError(const string& errorMsg, int command)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// Completion-related stuff:
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void DebuggerParser::getCompletions(const char* in, StringList& completions) const
|
||||
void DebuggerParser::getCompletions(const char* in, StringList& completions)
|
||||
{
|
||||
// cerr << "Attempting to complete \"" << in << "\"" << endl;
|
||||
for(const auto& c: commands)
|
||||
|
@ -236,7 +236,7 @@ int DebuggerParser::decipher_arg(const string& str)
|
|||
}
|
||||
|
||||
// Special cases (registers):
|
||||
const CpuState& state = static_cast<const CpuState&>(debugger.cpuDebug().getState());
|
||||
const auto& state = static_cast<const CpuState&>(debugger.cpuDebug().getState());
|
||||
int result = 0;
|
||||
if(arg == "a" && str != "$a") result = state.A;
|
||||
else if(arg == "x") result = state.X;
|
||||
|
@ -307,7 +307,7 @@ string DebuggerParser::showWatches()
|
|||
ostringstream buf;
|
||||
for(uInt32 i = 0; i < myWatches.size(); ++i)
|
||||
{
|
||||
if(myWatches[i] != "")
|
||||
if(!myWatches[i].empty())
|
||||
{
|
||||
// Clear the args, since we're going to pass them to eval()
|
||||
argStrings.clear();
|
||||
|
@ -335,7 +335,7 @@ bool DebuggerParser::getArgs(const string& command, string& verb)
|
|||
ParseState state = ParseState::IN_COMMAND;
|
||||
size_t i = 0;
|
||||
const size_t length = command.length();
|
||||
string curArg = "";
|
||||
string curArg;
|
||||
verb = "";
|
||||
|
||||
argStrings.clear();
|
||||
|
@ -388,14 +388,14 @@ bool DebuggerParser::getArgs(const string& command, string& verb)
|
|||
while(i < length);
|
||||
|
||||
// Take care of the last argument, if there is one
|
||||
if(curArg != "")
|
||||
if(!curArg.empty())
|
||||
argStrings.push_back(curArg);
|
||||
|
||||
argCount = static_cast<uInt32>(argStrings.size());
|
||||
|
||||
for(uInt32 arg = 0; arg < argCount; ++arg)
|
||||
{
|
||||
if(!YaccParser::parse(argStrings[arg].c_str()))
|
||||
if(!YaccParser::parse(argStrings[arg]))
|
||||
{
|
||||
unique_ptr<Expression> expr(YaccParser::getResult());
|
||||
args.push_back(expr->evaluate());
|
||||
|
@ -488,7 +488,9 @@ bool DebuggerParser::validateArgs(int cmd)
|
|||
if(curArgInt != 2 && curArgInt != 10 && curArgInt != 16
|
||||
&& curArgStr != "hex" && curArgStr != "dec" && curArgStr != "bin")
|
||||
{
|
||||
commandResult.str(red("invalid base (must be #2, #10, #16, \"bin\", \"dec\", or \"hex\")"));
|
||||
commandResult.str(red(
|
||||
R"(invalid base (must be #2, #10, #16, "bin", "dec", or "hex"))"
|
||||
));
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
@ -541,8 +543,8 @@ string DebuggerParser::eval()
|
|||
{
|
||||
string rlabel = debugger.cartDebug().getLabel(args[i], true);
|
||||
string wlabel = debugger.cartDebug().getLabel(args[i], false);
|
||||
const bool validR = rlabel != "" && rlabel[0] != '$',
|
||||
validW = wlabel != "" && wlabel[0] != '$';
|
||||
const bool validR = !rlabel.empty() && rlabel[0] != '$',
|
||||
validW = !wlabel.empty() && wlabel[0] != '$';
|
||||
if(validR && validW)
|
||||
{
|
||||
if(rlabel == wlabel)
|
||||
|
@ -561,7 +563,7 @@ string DebuggerParser::eval()
|
|||
if(args[i] < 0x10000)
|
||||
buf << " %" << Base::toString(args[i], Base::Fmt::_2);
|
||||
|
||||
buf << " #" << int(args[i]);
|
||||
buf << " #" << static_cast<int>(args[i]);
|
||||
if(i != argCount - 1)
|
||||
buf << endl;
|
||||
}
|
||||
|
@ -583,7 +585,7 @@ void DebuggerParser::listTraps(bool listCond)
|
|||
commandResult << (listCond ? "trapifs:" : "traps:") << endl;
|
||||
for(uInt32 i = 0; i < names.size(); ++i)
|
||||
{
|
||||
const bool hasCond = names[i] != "";
|
||||
const bool hasCond = !names[i].empty();
|
||||
if(hasCond == listCond)
|
||||
{
|
||||
commandResult << Base::toString(i) << ": ";
|
||||
|
@ -615,23 +617,23 @@ string DebuggerParser::trapStatus(const Trap& trap)
|
|||
string lblb = debugger.cartDebug().getLabel(trap.begin, !trap.write);
|
||||
string lble = debugger.cartDebug().getLabel(trap.end, !trap.write);
|
||||
|
||||
if(lblb != "") {
|
||||
if(!lblb.empty()) {
|
||||
result << " (";
|
||||
result << lblb;
|
||||
}
|
||||
|
||||
if(trap.begin != trap.end)
|
||||
{
|
||||
if(lble != "")
|
||||
if(!lble.empty())
|
||||
{
|
||||
if (lblb != "")
|
||||
if(!lblb.empty())
|
||||
result << " ";
|
||||
else
|
||||
result << " (";
|
||||
result << lble;
|
||||
}
|
||||
}
|
||||
if (lblb != "" || lble != "")
|
||||
if(!lblb.empty() || !lble.empty())
|
||||
result << ")";
|
||||
|
||||
return result.str();
|
||||
|
@ -643,7 +645,7 @@ string DebuggerParser::saveScriptFile(string file)
|
|||
stringstream out;
|
||||
Debugger::FunctionDefMap funcs = debugger.getFunctionDefMap();
|
||||
for(const auto& [name, cmd]: funcs)
|
||||
if (!debugger.isBuiltinFunction(name))
|
||||
if (!Debugger::isBuiltinFunction(name))
|
||||
out << "function " << name << " {" << cmd << "}" << endl;
|
||||
|
||||
for(const auto& w: myWatches)
|
||||
|
@ -665,7 +667,7 @@ string DebuggerParser::saveScriptFile(string file)
|
|||
{
|
||||
const bool read = myTraps[i]->read,
|
||||
write = myTraps[i]->write,
|
||||
hasCond = names[i] != "";
|
||||
hasCond = !names[i].empty();
|
||||
|
||||
if(read && write)
|
||||
out << "trap";
|
||||
|
@ -740,7 +742,7 @@ void DebuggerParser::executeDirective(Device::AccessType type)
|
|||
const bool result = debugger.cartDebug().addDirective(type, args[0], args[1]);
|
||||
|
||||
commandResult << (result ? "added " : "removed ");
|
||||
debugger.cartDebug().AccessTypeAsString(commandResult, type);
|
||||
CartDebug::AccessTypeAsString(commandResult, type);
|
||||
commandResult << " directive on range $"
|
||||
<< hex << args[0] << " $" << hex << args[1];
|
||||
debugger.rom().invalidate();
|
||||
|
@ -754,7 +756,7 @@ void DebuggerParser::executeDirective(Device::AccessType type)
|
|||
// "a"
|
||||
void DebuggerParser::executeA()
|
||||
{
|
||||
debugger.cpuDebug().setA(uInt8(args[0]));
|
||||
debugger.cpuDebug().setA(static_cast<uInt8>(args[0]));
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -869,7 +871,7 @@ void DebuggerParser::executeBreak()
|
|||
// "breakIf"
|
||||
void DebuggerParser::executeBreakIf()
|
||||
{
|
||||
int res = YaccParser::parse(argStrings[0].c_str());
|
||||
int res = YaccParser::parse(argStrings[0]);
|
||||
if(res == 0)
|
||||
{
|
||||
string condition = argStrings[0];
|
||||
|
@ -1269,7 +1271,7 @@ void DebuggerParser::executeDump()
|
|||
DebuggerDialog* dlg = debugger.myDialog;
|
||||
BrowserDialog::show(dlg, "Save Dump as", path.str(),
|
||||
BrowserDialog::Mode::FileSave,
|
||||
[this, dlg, outStr, resultStr]
|
||||
[dlg, outStr, resultStr]
|
||||
(bool OK, const FSNode& node)
|
||||
{
|
||||
if(OK)
|
||||
|
@ -1315,9 +1317,7 @@ void DebuggerParser::executeExec()
|
|||
// make sure the commands are added to prompt history
|
||||
StringList history;
|
||||
|
||||
++execDepth;
|
||||
commandResult << exec(node, &history);
|
||||
--execDepth;
|
||||
|
||||
for(const auto& item: history)
|
||||
debugger.prompt().addToHistory(item.c_str());
|
||||
|
@ -1350,7 +1350,7 @@ void DebuggerParser::executeFunction()
|
|||
return;
|
||||
}
|
||||
|
||||
int res = YaccParser::parse(argStrings[1].c_str());
|
||||
int res = YaccParser::parse(argStrings[1]);
|
||||
if(res == 0)
|
||||
{
|
||||
debugger.addFunction(argStrings[0], argStrings[1], YaccParser::getResult());
|
||||
|
@ -1386,7 +1386,7 @@ void DebuggerParser::executeHelp()
|
|||
commandResult << setw(static_cast<int>(clen)) << right << c.cmdString
|
||||
<< " - " << c.description << endl;
|
||||
|
||||
commandResult << debugger.builtinHelp();
|
||||
commandResult << Debugger::builtinHelp();
|
||||
}
|
||||
else // get help for specific command
|
||||
{
|
||||
|
@ -1565,7 +1565,7 @@ void DebuggerParser::executeListBreaks()
|
|||
|
||||
StringList conds = debugger.m6502().getCondBreakNames();
|
||||
|
||||
if(conds.size() > 0)
|
||||
if(!conds.empty())
|
||||
{
|
||||
if(count)
|
||||
commandResult << endl;
|
||||
|
@ -1577,7 +1577,7 @@ void DebuggerParser::executeListBreaks()
|
|||
}
|
||||
}
|
||||
|
||||
if(commandResult.str() == "")
|
||||
if(commandResult.str().empty())
|
||||
commandResult << "no breakpoints set";
|
||||
}
|
||||
|
||||
|
@ -1597,7 +1597,7 @@ void DebuggerParser::executeListFunctions()
|
|||
{
|
||||
const Debugger::FunctionDefMap& functions = debugger.getFunctionDefMap();
|
||||
|
||||
if(functions.size() > 0)
|
||||
if(!functions.empty())
|
||||
for(const auto& [name, cmd]: functions)
|
||||
commandResult << name << " -> " << cmd << endl;
|
||||
else
|
||||
|
@ -1611,7 +1611,7 @@ void DebuggerParser::executeListSaveStateIfs()
|
|||
ostringstream buf;
|
||||
|
||||
StringList conds = debugger.m6502().getCondSaveStateNames();
|
||||
if(conds.size() > 0)
|
||||
if(!conds.empty())
|
||||
{
|
||||
commandResult << "saveStateIf:" << endl;
|
||||
for(uInt32 i = 0; i < conds.size(); ++i)
|
||||
|
@ -1621,7 +1621,7 @@ void DebuggerParser::executeListSaveStateIfs()
|
|||
}
|
||||
}
|
||||
|
||||
if(commandResult.str() == "")
|
||||
if(commandResult.str().empty())
|
||||
commandResult << "no savestateifs defined";
|
||||
}
|
||||
|
||||
|
@ -1637,11 +1637,11 @@ void DebuggerParser::executeListTraps()
|
|||
return;
|
||||
}
|
||||
|
||||
if (names.size() > 0)
|
||||
if(!names.empty())
|
||||
{
|
||||
bool trapFound = false, trapifFound = false;
|
||||
for(uInt32 i = 0; i < names.size(); ++i)
|
||||
if(names[i] == "")
|
||||
for(const auto& name: names)
|
||||
if(name.empty())
|
||||
trapFound = true;
|
||||
else
|
||||
trapifFound = true;
|
||||
|
@ -1703,7 +1703,7 @@ void DebuggerParser::executeN()
|
|||
// "palette"
|
||||
void DebuggerParser::executePalette()
|
||||
{
|
||||
commandResult << debugger.tiaDebug().palette();
|
||||
commandResult << TIADebug::palette();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -1909,7 +1909,7 @@ void DebuggerParser::executeRunToPc()
|
|||
// "s"
|
||||
void DebuggerParser::executeS()
|
||||
{
|
||||
debugger.cpuDebug().setSP(uInt8(args[0]));
|
||||
debugger.cpuDebug().setSP(static_cast<uInt8>(args[0]));
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -2061,7 +2061,7 @@ void DebuggerParser::executeSaveSes()
|
|||
// "saveSnap"
|
||||
void DebuggerParser::executeSaveSnap()
|
||||
{
|
||||
debugger.tiaOutput().saveSnapshot(execDepth, execPrefix);
|
||||
debugger.tiaOutput().saveSnapshot(execDepth, execPrefix, argCount == 0);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -2085,7 +2085,7 @@ void DebuggerParser::executeSaveState()
|
|||
// "saveStateIf"
|
||||
void DebuggerParser::executeSaveStateIf()
|
||||
{
|
||||
int res = YaccParser::parse(argStrings[0].c_str());
|
||||
int res = YaccParser::parse(argStrings[0]);
|
||||
if(res == 0)
|
||||
{
|
||||
string condition = argStrings[0];
|
||||
|
@ -2128,7 +2128,7 @@ void DebuggerParser::executeStep()
|
|||
// "stepWhile"
|
||||
void DebuggerParser::executeStepWhile()
|
||||
{
|
||||
int res = YaccParser::parse(argStrings[0].c_str());
|
||||
int res = YaccParser::parse(argStrings[0]);
|
||||
if(res != 0) {
|
||||
commandResult << red("invalid expression");
|
||||
return;
|
||||
|
@ -2159,6 +2159,14 @@ void DebuggerParser::executeStepWhile()
|
|||
commandResult << "executed " << ncycles << " cycles";
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// "swchb"
|
||||
void DebuggerParser::executeSwchb()
|
||||
{
|
||||
debugger.riotDebug().switches(args[0]);
|
||||
commandResult << "SWCHB set to " << std::hex << std::setw(2) << std::setfill('0') << args[0];
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// "tia"
|
||||
void DebuggerParser::executeTia()
|
||||
|
@ -2246,10 +2254,10 @@ void DebuggerParser::executeTraps(bool read, bool write, const string& command,
|
|||
}
|
||||
|
||||
// base addresses of mirrors
|
||||
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);
|
||||
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)
|
||||
|
@ -2279,7 +2287,7 @@ void DebuggerParser::executeTraps(bool read, bool write, const string& command,
|
|||
|
||||
const string condition = conditionBuf.str();
|
||||
|
||||
int res = YaccParser::parse(condition.c_str());
|
||||
int res = YaccParser::parse(condition);
|
||||
if(res == 0)
|
||||
{
|
||||
// duplicates will remove each other
|
||||
|
@ -2324,7 +2332,7 @@ void DebuggerParser::executeTraps(bool read, bool write, const string& command,
|
|||
// wrapper function for trap(if)/trapRead(if)/trapWrite(if) commands
|
||||
void DebuggerParser::executeTrapRW(uInt32 addr, bool read, bool write, bool add)
|
||||
{
|
||||
switch(debugger.cartDebug().addressType(addr))
|
||||
switch(CartDebug::addressType(addr))
|
||||
{
|
||||
case CartDebug::AddrType::TIA:
|
||||
{
|
||||
|
@ -2480,14 +2488,14 @@ void DebuggerParser::executeWinds(bool unwind)
|
|||
// "x"
|
||||
void DebuggerParser::executeX()
|
||||
{
|
||||
debugger.cpuDebug().setX(uInt8(args[0]));
|
||||
debugger.cpuDebug().setX(static_cast<uInt8>(args[0]));
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
// "y"
|
||||
void DebuggerParser::executeY()
|
||||
{
|
||||
debugger.cpuDebug().setY(uInt8(args[0]));
|
||||
debugger.cpuDebug().setY(static_cast<uInt8>(args[0]));
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
@ -3381,6 +3389,16 @@ DebuggerParser::CommandArray DebuggerParser::commands = { {
|
|||
std::mem_fn(&DebuggerParser::executeStepWhile)
|
||||
},
|
||||
|
||||
{
|
||||
"swchb",
|
||||
"Set SWCHB to xx",
|
||||
"Example: swchb fe",
|
||||
true,
|
||||
true,
|
||||
{ Parameters::ARG_WORD, Parameters::ARG_END_ARGS },
|
||||
std::mem_fn(&DebuggerParser::executeSwchb)
|
||||
},
|
||||
|
||||
{
|
||||
"tia",
|
||||
"Show TIA state",
|
||||
|
|
|
@ -42,7 +42,7 @@ class DebuggerParser
|
|||
|
||||
/** Given a substring, determine matching substrings from the list
|
||||
of available commands. Used in the debugger prompt for tab-completion */
|
||||
void getCompletions(const char* in, StringList& list) const;
|
||||
static void getCompletions(const char* in, StringList& completions);
|
||||
|
||||
/** Evaluate the given expression using operators, current base, etc */
|
||||
int decipher_arg(const string& str);
|
||||
|
@ -65,8 +65,8 @@ class DebuggerParser
|
|||
bool validateArgs(int cmd);
|
||||
string eval();
|
||||
string saveScriptFile(string file);
|
||||
void saveDump(const FSNode& node, const stringstream& out,
|
||||
ostringstream& result);
|
||||
static void saveDump(const FSNode& node, const stringstream& out,
|
||||
ostringstream& result);
|
||||
const string& cartName() const;
|
||||
|
||||
private:
|
||||
|
@ -101,7 +101,7 @@ class DebuggerParser
|
|||
std::array<Parameters, 10> parms;
|
||||
std::function<void (DebuggerParser*)> executor;
|
||||
};
|
||||
using CommandArray = std::array<Command, 103>;
|
||||
using CommandArray = std::array<Command, 104>;
|
||||
static CommandArray commands;
|
||||
|
||||
struct Trap
|
||||
|
@ -234,6 +234,7 @@ class DebuggerParser
|
|||
void executeScanLine();
|
||||
void executeStep();
|
||||
void executeStepWhile();
|
||||
void executeSwchb();
|
||||
void executeTia();
|
||||
void executeTrace();
|
||||
void executeTrap();
|
||||
|
|
|
@ -80,7 +80,7 @@ DiStella::DiStella(const CartDebug& dbg, CartDebug::DisassemblyList& list,
|
|||
// multi-byte instruction, then we make note of that address for reference
|
||||
//
|
||||
// However, we only do this for labels pointing to ROM (above $1000)
|
||||
if (myDbg.addressType(k + myOffset) == CartDebug::AddrType::ROM) {
|
||||
if (CartDebug::addressType(k + myOffset) == CartDebug::AddrType::ROM) {
|
||||
reservedLabel.str("");
|
||||
reservedLabel << "L" << Base::HEX4 << (k + myOffset);
|
||||
myReserved.Label.emplace(k + myOffset, reservedLabel.str());
|
||||
|
@ -123,7 +123,7 @@ void DiStella::disasm(uInt32 distart, int pass)
|
|||
// and this results into an access at e.g. 0xffff,
|
||||
// we have to fix the consequences here (ugly!).
|
||||
if(myPC == myAppData.end)
|
||||
goto FIX_LAST;
|
||||
goto FIX_LAST; // NOLINT
|
||||
|
||||
if(checkBits(myPC, Device::GFX | Device::PGFX,
|
||||
Device::CODE))
|
||||
|
@ -944,7 +944,7 @@ DiStella::AddressType DiStella::mark(uInt32 address, uInt16 mask, bool directive
|
|||
|
||||
// Check for equates before ROM/ZP-RAM accesses, because the original logic
|
||||
// of Distella assumed either equates or ROM; it didn't take ZP-RAM into account
|
||||
const CartDebug::AddrType type = myDbg.addressType(address);
|
||||
const CartDebug::AddrType type = CartDebug::addressType(address);
|
||||
if(type == CartDebug::AddrType::TIA) {
|
||||
return AddressType::TIA;
|
||||
}
|
||||
|
@ -1003,18 +1003,18 @@ bool DiStella::checkBits(uInt16 address, uInt16 mask, uInt16 notMask, bool useDe
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool DiStella::check_range(uInt16 beg, uInt16 end) const
|
||||
bool DiStella::check_range(uInt16 start, uInt16 end) const
|
||||
{
|
||||
if (beg > end) {
|
||||
cerr << "Beginning of range greater than end: start = " << std::hex << beg
|
||||
if (start > end) {
|
||||
cerr << "Beginning of range greater than end: start = " << std::hex << start
|
||||
<< ", end = " << std::hex << end << endl;
|
||||
return false;
|
||||
} else if (beg > myAppData.end + myOffset) {
|
||||
cerr << "Beginning of range out of range: start = " << std::hex << beg
|
||||
} else if (start > myAppData.end + myOffset) {
|
||||
cerr << "Beginning of range out of range: start = " << std::hex << start
|
||||
<< ", range = " << std::hex << (myAppData.end + myOffset) << endl;
|
||||
return false;
|
||||
} else if (beg < myOffset) {
|
||||
cerr << "Beginning of range out of range: start = " << std::hex << beg
|
||||
} else if (start < myOffset) {
|
||||
cerr << "Beginning of range out of range: start = " << std::hex << start
|
||||
<< ", offset = " << std::hex << myOffset << endl;
|
||||
return false;
|
||||
}
|
||||
|
@ -1038,7 +1038,7 @@ void DiStella::addEntry(Device::AccessType type)
|
|||
|
||||
// Only include addresses within the requested range
|
||||
if (tag.address < myAppData.start)
|
||||
goto DONE_WITH_ADD;
|
||||
goto DONE_WITH_ADD; // NOLINT
|
||||
|
||||
// Label (a user-defined label always overrides any auto-generated one)
|
||||
myDisasmBuf.seekg(5, std::ios::beg);
|
||||
|
|
|
@ -257,6 +257,16 @@ int RiotDebug::timReadCycles() const
|
|||
return mySystem.m6532().myTimReadCycles;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool RiotDebug::switches(int newVal)
|
||||
{
|
||||
uInt8& switches = myConsole.switches().mySwitches;
|
||||
if(newVal > -1)
|
||||
switches = newVal;
|
||||
|
||||
return switches;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool RiotDebug::diffP0(int newVal)
|
||||
{
|
||||
|
@ -363,33 +373,33 @@ string RiotDebug::switchesString()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string RiotDebug::toString()
|
||||
{
|
||||
const RiotState& state = static_cast<const RiotState&>(getState());
|
||||
const RiotState& oldstate = static_cast<const RiotState&>(getOldState());
|
||||
const auto& state = static_cast<const RiotState&>(getState());
|
||||
const auto& oldstate = static_cast<const RiotState&>(getOldState());
|
||||
|
||||
ostringstream buf;
|
||||
buf << "280/SWCHA(R)=" << myDebugger.invIfChanged(state.SWCHA_R, oldstate.SWCHA_R)
|
||||
<< " 280/SWCHA(W)=" << myDebugger.invIfChanged(state.SWCHA_W, oldstate.SWCHA_W)
|
||||
<< " 281/SWACNT=" << myDebugger.invIfChanged(state.SWACNT, oldstate.SWACNT)
|
||||
buf << "280/SWCHA(R)=" << Debugger::invIfChanged(state.SWCHA_R, oldstate.SWCHA_R)
|
||||
<< " 280/SWCHA(W)=" << Debugger::invIfChanged(state.SWCHA_W, oldstate.SWCHA_W)
|
||||
<< " 281/SWACNT=" << Debugger::invIfChanged(state.SWACNT, oldstate.SWACNT)
|
||||
<< endl
|
||||
<< "282/SWCHB(R)=" << myDebugger.invIfChanged(state.SWCHB_R, oldstate.SWCHB_R)
|
||||
<< " 282/SWCHB(W)=" << myDebugger.invIfChanged(state.SWCHB_W, oldstate.SWCHB_W)
|
||||
<< " 283/SWBCNT=" << myDebugger.invIfChanged(state.SWBCNT, oldstate.SWBCNT)
|
||||
<< "282/SWCHB(R)=" << Debugger::invIfChanged(state.SWCHB_R, oldstate.SWCHB_R)
|
||||
<< " 282/SWCHB(W)=" << Debugger::invIfChanged(state.SWCHB_W, oldstate.SWCHB_W)
|
||||
<< " 283/SWBCNT=" << Debugger::invIfChanged(state.SWBCNT, oldstate.SWBCNT)
|
||||
<< endl
|
||||
|
||||
// These are squirrely: some symbol files will define these as
|
||||
// 0x284-0x287. Doesn't actually matter, these registers repeat
|
||||
// every 16 bytes.
|
||||
<< "294/TIM1T=" << myDebugger.invIfChanged(state.TIM1T, oldstate.TIM1T)
|
||||
<< " 295/TIM8T=" << myDebugger.invIfChanged(state.TIM8T, oldstate.TIM8T)
|
||||
<< " 296/TIM64T=" << myDebugger.invIfChanged(state.TIM64T, oldstate.TIM64T)
|
||||
<< " 297/T1024T=" << myDebugger.invIfChanged(state.T1024T, oldstate.T1024T)
|
||||
<< "294/TIM1T=" << Debugger::invIfChanged(state.TIM1T, oldstate.TIM1T)
|
||||
<< " 295/TIM8T=" << Debugger::invIfChanged(state.TIM8T, oldstate.TIM8T)
|
||||
<< " 296/TIM64T=" << Debugger::invIfChanged(state.TIM64T, oldstate.TIM64T)
|
||||
<< " 297/T1024T=" << Debugger::invIfChanged(state.T1024T, oldstate.T1024T)
|
||||
<< endl
|
||||
|
||||
<< "0x284/INTIM=" << myDebugger.invIfChanged(state.INTIM, oldstate.INTIM)
|
||||
<< " 285/TIMINT=" << myDebugger.invIfChanged(state.TIMINT, oldstate.TIMINT)
|
||||
<< " Timer_Clocks=" << myDebugger.invIfChanged(state.TIMCLKS, oldstate.TIMCLKS)
|
||||
<< " INTIM_Clocks=" << myDebugger.invIfChanged(state.INTIMCLKS, oldstate.INTIMCLKS)
|
||||
<< " Divider=" << myDebugger.invIfChanged(state.TIMDIV, oldstate.TIMDIV)
|
||||
<< "0x284/INTIM=" << Debugger::invIfChanged(state.INTIM, oldstate.INTIM)
|
||||
<< " 285/TIMINT=" << Debugger::invIfChanged(state.TIMINT, oldstate.TIMINT)
|
||||
<< " Timer_Clocks=" << Debugger::invIfChanged(state.TIMCLKS, oldstate.TIMCLKS)
|
||||
<< " INTIM_Clocks=" << Debugger::invIfChanged(state.INTIMCLKS, oldstate.INTIMCLKS)
|
||||
<< " Divider=" << Debugger::invIfChanged(state.TIMDIV, oldstate.TIMDIV)
|
||||
<< endl
|
||||
|
||||
<< "Left/P0diff: " << diffP0String() << " Right/P1diff: " << diffP1String()
|
||||
|
|
|
@ -89,6 +89,7 @@ class RiotDebug : public DebuggerSystem
|
|||
int intimAsInt() const { return static_cast<int>(intim()); } // so we can use _inTim pseudo-register
|
||||
|
||||
/* Console switches */
|
||||
bool switches(int newVal = -1);
|
||||
bool diffP0(int newVal = -1);
|
||||
bool diffP1(int newVal = -1);
|
||||
bool tvType(int newVal = -1);
|
||||
|
|
|
@ -293,7 +293,7 @@ void TIADebug::saveOldState()
|
|||
bool TIADebug::vdelP0(int newVal)
|
||||
{
|
||||
if(newVal > -1)
|
||||
mySystem.poke(VDELP0, bool(newVal));
|
||||
mySystem.poke(VDELP0, static_cast<bool>(newVal));
|
||||
|
||||
return myTIA.registerValue(VDELP0) & 0x01;
|
||||
}
|
||||
|
@ -302,7 +302,7 @@ bool TIADebug::vdelP0(int newVal)
|
|||
bool TIADebug::vdelP1(int newVal)
|
||||
{
|
||||
if(newVal > -1)
|
||||
mySystem.poke(VDELP1, bool(newVal));
|
||||
mySystem.poke(VDELP1, static_cast<bool>(newVal));
|
||||
|
||||
return myTIA.registerValue(VDELP1) & 0x01;
|
||||
}
|
||||
|
@ -311,7 +311,7 @@ bool TIADebug::vdelP1(int newVal)
|
|||
bool TIADebug::vdelBL(int newVal)
|
||||
{
|
||||
if(newVal > -1)
|
||||
mySystem.poke(VDELBL, bool(newVal));
|
||||
mySystem.poke(VDELBL, static_cast<bool>(newVal));
|
||||
|
||||
return myTIA.registerValue(VDELBL) & 0x01;
|
||||
}
|
||||
|
@ -320,7 +320,7 @@ bool TIADebug::vdelBL(int newVal)
|
|||
bool TIADebug::enaM0(int newVal)
|
||||
{
|
||||
if(newVal > -1)
|
||||
mySystem.poke(ENAM0, bool(newVal) << 1);
|
||||
mySystem.poke(ENAM0, static_cast<bool>(newVal) << 1);
|
||||
|
||||
return myTIA.registerValue(ENAM0) & 0x02;
|
||||
}
|
||||
|
@ -329,7 +329,7 @@ bool TIADebug::enaM0(int newVal)
|
|||
bool TIADebug::enaM1(int newVal)
|
||||
{
|
||||
if(newVal > -1)
|
||||
mySystem.poke(ENAM1, bool(newVal) << 1);
|
||||
mySystem.poke(ENAM1, static_cast<bool>(newVal) << 1);
|
||||
|
||||
return myTIA.registerValue(ENAM1) & 0x02;
|
||||
}
|
||||
|
@ -338,7 +338,7 @@ bool TIADebug::enaM1(int newVal)
|
|||
bool TIADebug::enaBL(int newVal)
|
||||
{
|
||||
if(newVal > -1)
|
||||
mySystem.poke(ENABL, bool(newVal) << 1);
|
||||
mySystem.poke(ENABL, static_cast<bool>(newVal) << 1);
|
||||
|
||||
return myTIA.registerValue(ENABL) & 0x02;
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ bool TIADebug::enaBL(int newVal)
|
|||
bool TIADebug::resMP0(int newVal)
|
||||
{
|
||||
if(newVal > -1)
|
||||
mySystem.poke(RESMP0, bool(newVal) << 1);
|
||||
mySystem.poke(RESMP0, static_cast<bool>(newVal) << 1);
|
||||
|
||||
return myTIA.registerValue(RESMP0) & 0x02;
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ bool TIADebug::resMP0(int newVal)
|
|||
bool TIADebug::resMP1(int newVal)
|
||||
{
|
||||
if(newVal > -1)
|
||||
mySystem.poke(RESMP1, bool(newVal) << 1);
|
||||
mySystem.poke(RESMP1, static_cast<bool>(newVal) << 1);
|
||||
|
||||
return myTIA.registerValue(RESMP1) & 0x02;
|
||||
}
|
||||
|
@ -365,7 +365,7 @@ bool TIADebug::resMP1(int newVal)
|
|||
bool TIADebug::refP0(int newVal)
|
||||
{
|
||||
if(newVal > -1)
|
||||
mySystem.poke(REFP0, bool(newVal) << 3);
|
||||
mySystem.poke(REFP0, static_cast<bool>(newVal) << 3);
|
||||
|
||||
return myTIA.registerValue(REFP0) & 0x08;
|
||||
}
|
||||
|
@ -374,7 +374,7 @@ bool TIADebug::refP0(int newVal)
|
|||
bool TIADebug::refP1(int newVal)
|
||||
{
|
||||
if(newVal > -1)
|
||||
mySystem.poke(REFP1, bool(newVal) << 3);
|
||||
mySystem.poke(REFP1, static_cast<bool>(newVal) << 3);
|
||||
|
||||
return myTIA.registerValue(REFP1) & 0x08;
|
||||
}
|
||||
|
@ -995,7 +995,7 @@ shared_ptr<DelayQueueIterator> TIADebug::delayQueueIterator() const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string TIADebug::colorSwatch(uInt8 c) const
|
||||
string TIADebug::colorSwatch(uInt8 c)
|
||||
{
|
||||
string ret;
|
||||
|
||||
|
@ -1019,7 +1019,7 @@ string TIADebug::audFreq1()
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string TIADebug::audFreq(uInt8 dist, uInt8 div)
|
||||
string TIADebug::audFreq(uInt8 dist, uInt8 div) const
|
||||
{
|
||||
static constexpr uInt16 dist_div[16] = {
|
||||
1, 15, 465, 465, 2, 2, 31, 31,
|
||||
|
@ -1037,7 +1037,7 @@ string TIADebug::audFreq(uInt8 dist, uInt8 div)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string TIADebug::stringOnly(string value, bool changed)
|
||||
string TIADebug::stringOnly(const string& value, bool changed)
|
||||
{
|
||||
ostringstream buf;
|
||||
|
||||
|
@ -1051,7 +1051,8 @@ string TIADebug::stringOnly(string value, bool changed)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string TIADebug::decWithLabel(string label, uInt16 value, bool changed, uInt16 width)
|
||||
string TIADebug::decWithLabel(const string& label, uInt16 value,
|
||||
bool changed, uInt16 width)
|
||||
{
|
||||
ostringstream buf;
|
||||
|
||||
|
@ -1068,7 +1069,8 @@ string TIADebug::decWithLabel(string label, uInt16 value, bool changed, uInt16 w
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string TIADebug::hexWithLabel(string label, uInt16 value, bool changed, uInt16 width)
|
||||
string TIADebug::hexWithLabel(const string& label, uInt16 value,
|
||||
bool changed, uInt16 width)
|
||||
{
|
||||
ostringstream buf;
|
||||
|
||||
|
@ -1085,7 +1087,7 @@ string TIADebug::hexWithLabel(string label, uInt16 value, bool changed, uInt16 w
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string TIADebug::binWithLabel(string label, uInt16 value, bool changed)
|
||||
string TIADebug::binWithLabel(const string& label, uInt16 value, bool changed)
|
||||
{
|
||||
ostringstream buf;
|
||||
|
||||
|
@ -1102,13 +1104,16 @@ string TIADebug::binWithLabel(string label, uInt16 value, bool changed)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string TIADebug::boolWithLabel(string label, bool value, bool changed)
|
||||
string TIADebug::boolWithLabel(const string& label, bool value, bool changed)
|
||||
{
|
||||
ostringstream buf;
|
||||
|
||||
if(value)
|
||||
buf << "\177" << BSPF::toUpperCase(label) << "\177";
|
||||
{
|
||||
string l = label;
|
||||
buf << "\177" << BSPF::toUpperCase(l) << "\177";
|
||||
//return "+" + BSPF::toUpperCase(label);
|
||||
}
|
||||
else
|
||||
buf << label;
|
||||
//return "-" + BSPF::toLowerCase(label);
|
||||
|
@ -1149,7 +1154,7 @@ string TIADebug::debugColors() const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
string TIADebug::palette() const
|
||||
string TIADebug::palette()
|
||||
{
|
||||
ostringstream buf;
|
||||
|
||||
|
@ -1174,11 +1179,11 @@ string TIADebug::toString()
|
|||
// TODO: strobes? WSYNC RSYNC RESP0/1 RESM0/1 RESBL HMOVE HMCLR CXCLR
|
||||
|
||||
RiotDebug& riot = myDebugger.riotDebug();
|
||||
const RiotState& riotState = static_cast<const RiotState&>(riot.getState());
|
||||
const RiotState& oldRiotState = static_cast<const RiotState&>(riot.getOldState());
|
||||
const auto& riotState = static_cast<const RiotState&>(riot.getState());
|
||||
const auto& oldRiotState = static_cast<const RiotState&>(riot.getOldState());
|
||||
|
||||
const TiaState& state = static_cast<const TiaState&>(getState());
|
||||
const TiaState& oldState = static_cast<const TiaState&>(getOldState());
|
||||
const auto& state = static_cast<const TiaState&>(getState());
|
||||
const auto& oldState = static_cast<const TiaState&>(getOldState());
|
||||
|
||||
// build up output, then return it.
|
||||
buf << std::setfill(' ') << std::left
|
||||
|
|
|
@ -63,7 +63,7 @@ class TIADebug : public DebuggerSystem
|
|||
void saveOldState() override;
|
||||
string toString() override;
|
||||
string debugColors() const;
|
||||
string palette() const;
|
||||
static string palette();
|
||||
|
||||
// TIA byte (or part of a byte) registers
|
||||
uInt8 nusiz0(int newVal = -1);
|
||||
|
@ -185,14 +185,18 @@ class TIADebug : public DebuggerSystem
|
|||
|
||||
private:
|
||||
/** Display a color patch for color at given index in the palette */
|
||||
string colorSwatch(uInt8 c) const;
|
||||
static string colorSwatch(uInt8 c);
|
||||
|
||||
string audFreq(uInt8 dist, uInt8 div);
|
||||
string stringOnly(string value, bool changed = false);
|
||||
string decWithLabel(string label, uInt16 value, bool changed = false, uInt16 width = 3);
|
||||
string hexWithLabel(string label, uInt16 value, bool changed = false, uInt16 width = 2);
|
||||
string binWithLabel(string label, uInt16 value, bool changed = false);
|
||||
string boolWithLabel(string label, bool value, bool changed = false);
|
||||
string audFreq(uInt8 dist, uInt8 div) const;
|
||||
static string stringOnly(const string& value, bool changed = false);
|
||||
static string decWithLabel(const string& label, uInt16 value,
|
||||
bool changed = false, uInt16 width = 3);
|
||||
static string hexWithLabel(const string& label, uInt16 value,
|
||||
bool changed = false, uInt16 width = 2);
|
||||
static string binWithLabel(const string& label, uInt16 value,
|
||||
bool changed = false);
|
||||
static string boolWithLabel(const string& label, bool value,
|
||||
bool changed = false);
|
||||
|
||||
private:
|
||||
TiaState myState;
|
||||
|
|
|
@ -30,15 +30,13 @@ AtariVoxWidget::AtariVoxWidget(GuiObject* boss, const GUI::Font& font,
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void AtariVoxWidget::eraseCurrent()
|
||||
{
|
||||
AtariVox& avox = static_cast<AtariVox&>(controller());
|
||||
|
||||
auto& avox = static_cast<AtariVox&>(controller());
|
||||
avox.eraseCurrent();
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool AtariVoxWidget::isPageUsed(uInt32 page)
|
||||
{
|
||||
const AtariVox& avox = static_cast<AtariVox&>(controller());
|
||||
|
||||
const auto& avox = static_cast<AtariVox&>(controller());
|
||||
return avox.isPageUsed(page);
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include "TIADebug.hxx"
|
||||
#include "Widget.hxx"
|
||||
#include "Base.hxx"
|
||||
using Common::Base;
|
||||
|
||||
#include "AudioWidget.hxx"
|
||||
|
||||
|
@ -102,8 +101,8 @@ void AudioWidget::loadConfig()
|
|||
|
||||
const Debugger& dbg = instance().debugger();
|
||||
TIADebug& tia = dbg.tiaDebug();
|
||||
const TiaState& state = static_cast<const TiaState&>(tia.getState());
|
||||
const TiaState& oldstate = static_cast<const TiaState&>(tia.getOldState());
|
||||
const auto& state = static_cast<const TiaState&>(tia.getState());
|
||||
const auto& oldstate = static_cast<const TiaState&>(tia.getOldState());
|
||||
|
||||
// AUDF0/1
|
||||
alist.clear(); vlist.clear(); changed.clear();
|
||||
|
|
|
@ -26,10 +26,8 @@ BoosterWidget::BoosterWidget(GuiObject* boss, const GUI::Font& font,
|
|||
|
||||
const int fontHeight = font.getFontHeight();
|
||||
int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Booster)");
|
||||
StaticTextWidget* t;
|
||||
|
||||
t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth,
|
||||
fontHeight, label, TextAlign::Left);
|
||||
auto* t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth,
|
||||
fontHeight, label, TextAlign::Left);
|
||||
xpos += t->getWidth()/2 - 5; ypos += t->getHeight() + 10;
|
||||
myPins[kJUp] = new CheckboxWidget(boss, font, xpos, ypos, "",
|
||||
CheckboxWidget::kCheckActionCmd);
|
||||
|
@ -128,6 +126,3 @@ void BoosterWidget::handleCommand(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
constexpr std::array<Controller::DigitalPin, 5> BoosterWidget::ourPinNo;
|
||||
|
|
|
@ -34,7 +34,7 @@ Cartridge3EPlusWidget::Cartridge3EPlusWidget(
|
|||
string Cartridge3EPlusWidget::description()
|
||||
{
|
||||
ostringstream info;
|
||||
size_t size;
|
||||
size_t size{0};
|
||||
const ByteBuffer& image = myCart.getImage(size);
|
||||
const uInt16 numRomBanks = myCart.romBankCount();
|
||||
const uInt16 numRamBanks = myCart.ramBankCount();
|
||||
|
@ -59,7 +59,7 @@ string Cartridge3EPlusWidget::description()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Cartridge3EPlusWidget::bankSelect(int& ypos)
|
||||
{
|
||||
size_t size;
|
||||
size_t size{0};
|
||||
const ByteBuffer& image = myCart.getImage(size);
|
||||
const int VGAP = myFontHeight / 4;
|
||||
VariantList banktype;
|
||||
|
@ -118,22 +118,24 @@ void Cartridge3EPlusWidget::bankSelect(int& ypos)
|
|||
const int addr1 = start + (seg * 0x400), addr2 = addr1 + 0x200;
|
||||
|
||||
label.str("");
|
||||
label << "$" << Common::Base::HEX4 << addr1 << "-$" << Common::Base::HEX4 << (addr1 + 0x1FF);
|
||||
StaticTextWidget* t = new StaticTextWidget(_boss, _font, xpos_s, ypos_s + 2, label.str());
|
||||
label << "$" << Common::Base::HEX4 << addr1 << "-$"
|
||||
<< Common::Base::HEX4 << (addr1 + 0x1FF);
|
||||
auto* t = new StaticTextWidget(_boss, _font, xpos_s, ypos_s + 2, label.str());
|
||||
|
||||
const int xoffset = t->getRight() + _font.getMaxCharWidth();
|
||||
myBankState[2 * seg] = new EditTextWidget(_boss, _font, xoffset, ypos_s,
|
||||
_w - xoffset - 10, myLineHeight, "");
|
||||
myBankState[2 * seg]->setEditable(false, true);
|
||||
const size_t bank_off = static_cast<size_t>(seg) * 2;
|
||||
myBankState[bank_off] = new EditTextWidget(_boss, _font, xoffset, ypos_s,
|
||||
_w - xoffset - 10, myLineHeight, "");
|
||||
myBankState[bank_off]->setEditable(false, true);
|
||||
ypos_s += myLineHeight + VGAP;
|
||||
|
||||
label.str("");
|
||||
label << "$" << Common::Base::HEX4 << addr2 << "-$" << Common::Base::HEX4 << (addr2 + 0x1FF);
|
||||
new StaticTextWidget(_boss, _font, xpos_s, ypos_s + 2, label.str());
|
||||
|
||||
myBankState[2 * seg + 1] = new EditTextWidget(_boss, _font, xoffset, ypos_s,
|
||||
_w - xoffset - 10, myLineHeight, "");
|
||||
myBankState[2 * seg + 1]->setEditable(false, true);
|
||||
myBankState[bank_off + 1] = new EditTextWidget(_boss, _font,
|
||||
xoffset, ypos_s, _w - xoffset - 10, myLineHeight, "");
|
||||
myBankState[bank_off + 1]->setEditable(false, true);
|
||||
|
||||
ypos += myLineHeight + VGAP * 4;
|
||||
}
|
||||
|
@ -198,6 +200,7 @@ void Cartridge3EPlusWidget::updateUIState()
|
|||
for(int seg = 0; seg < myCart3EP.myBankSegs; ++seg)
|
||||
{
|
||||
const uInt16 bank = myCart.getSegmentBank(seg);
|
||||
const size_t bank_off = static_cast<size_t>(seg) * 2;
|
||||
ostringstream buf;
|
||||
|
||||
if(bank >= myCart.romBankCount()) // was RAM mapped here?
|
||||
|
@ -205,13 +208,13 @@ void Cartridge3EPlusWidget::updateUIState()
|
|||
const uInt16 ramBank = bank - myCart.romBankCount();
|
||||
|
||||
buf << "RAM @ $" << Common::Base::HEX4
|
||||
<< (ramBank << myCart3EP.myBankShift) << " (R)";
|
||||
myBankState[seg * 2]->setText(buf.str());
|
||||
<< (ramBank << myCart3EP.myBankShift) << " (R)";
|
||||
myBankState[bank_off]->setText(buf.str());
|
||||
|
||||
buf.str("");
|
||||
buf << "RAM @ $" << Common::Base::HEX4
|
||||
<< ((ramBank << myCart3EP.myBankShift) + myCart3EP.myBankSize) << " (W)";
|
||||
myBankState[seg * 2 + 1]->setText(buf.str());
|
||||
myBankState[bank_off + 1]->setText(buf.str());
|
||||
|
||||
myBankWidgets[seg]->setSelectedIndex(ramBank);
|
||||
myBankType[seg]->setSelected("RAM");
|
||||
|
@ -220,12 +223,12 @@ void Cartridge3EPlusWidget::updateUIState()
|
|||
{
|
||||
buf << "ROM @ $" << Common::Base::HEX4
|
||||
<< ((bank << myCart3EP.myBankShift));
|
||||
myBankState[seg * 2]->setText(buf.str());
|
||||
myBankState[bank_off]->setText(buf.str());
|
||||
|
||||
buf.str("");
|
||||
buf << "ROM @ $" << Common::Base::HEX4
|
||||
<< ((bank << myCart3EP.myBankShift) + myCart3EP.myBankSize);
|
||||
myBankState[seg * 2 + 1]->setText(buf.str());
|
||||
myBankState[bank_off + 1]->setText(buf.str());
|
||||
|
||||
myBankWidgets[seg]->setSelectedIndex(bank);
|
||||
myBankType[seg]->setSelected("ROM");
|
||||
|
|
|
@ -32,7 +32,7 @@ Cartridge3EWidget::Cartridge3EWidget(
|
|||
string Cartridge3EWidget::description()
|
||||
{
|
||||
ostringstream info;
|
||||
size_t size;
|
||||
size_t size{0};
|
||||
const ByteBuffer& image = myCart.getImage(size);
|
||||
const uInt16 numRomBanks = myCart.romBankCount();
|
||||
const uInt16 numRamBanks = myCart.ramBankCount();
|
||||
|
@ -69,9 +69,9 @@ void Cartridge3EWidget::bankList(uInt16 bankCount, int seg, VariantList& items,
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Cartridge3EWidget::bankSelect(int& ypos)
|
||||
{
|
||||
int xpos = 2;
|
||||
int xpos{2};
|
||||
VariantList items;
|
||||
int pw;
|
||||
int pw{0};
|
||||
|
||||
myBankWidgets = make_unique<PopUpWidget* []>(2);
|
||||
|
||||
|
@ -84,7 +84,8 @@ void Cartridge3EWidget::bankSelect(int& ypos)
|
|||
myBankWidgets[0]->setID(0);
|
||||
addFocusWidget(myBankWidgets[0]);
|
||||
|
||||
StaticTextWidget* t = new StaticTextWidget(_boss, _font, myBankWidgets[0]->getRight(), ypos - 1, " (ROM)");
|
||||
auto* t = new StaticTextWidget(_boss, _font,
|
||||
myBankWidgets[0]->getRight(), ypos - 1, " (ROM)");
|
||||
|
||||
xpos = t->getRight() + 20;
|
||||
items.clear();
|
||||
|
|
|
@ -68,8 +68,8 @@ void CartridgeARMWidget::addCycleWidgets(int xpos, int ypos)
|
|||
myThumbCycles->setEditable(false);
|
||||
myThumbCycles->setToolTip("Approximated CPU cycles of last ARM run.\n");
|
||||
|
||||
StaticTextWidget* s = new StaticTextWidget(_boss, _font, myCycleFactor->getLeft(), ypos + 1,
|
||||
"Instructions #");
|
||||
auto* s = new StaticTextWidget(_boss, _font, myCycleFactor->getLeft(), ypos + 1,
|
||||
"Instructions #");
|
||||
|
||||
myPrevThumbInstructions = new DataGridWidget(_boss, _font, s->getRight(), ypos - 1,
|
||||
1, 1, 6, 32, Common::Base::Fmt::_10_6);
|
||||
|
@ -162,23 +162,26 @@ void CartridgeARMWidget::loadConfig()
|
|||
|
||||
alist.clear(); vlist.clear(); changed.clear();
|
||||
alist.push_back(0); vlist.push_back(myCart.prevCycles());
|
||||
changed.push_back(myCart.prevCycles() != uInt32(myOldState.armPrevRun[0]));
|
||||
changed.push_back(myCart.prevCycles() !=
|
||||
static_cast<uInt32>(myOldState.armPrevRun[0]));
|
||||
myPrevThumbCycles->setList(alist, vlist, changed);
|
||||
|
||||
alist.clear(); vlist.clear(); changed.clear();
|
||||
alist.push_back(0); vlist.push_back(myCart.prevStats().instructions);
|
||||
changed.push_back(myCart.prevStats().instructions != uInt32(myOldState.armPrevRun[1]));
|
||||
changed.push_back(myCart.prevStats().instructions !=
|
||||
static_cast<uInt32>(myOldState.armPrevRun[1]));
|
||||
myPrevThumbInstructions->setList(alist, vlist, changed);
|
||||
|
||||
alist.clear(); vlist.clear(); changed.clear();
|
||||
alist.push_back(0); vlist.push_back(myCart.cycles());
|
||||
changed.push_back(myCart.cycles() != uInt32(myOldState.armRun[0]));
|
||||
changed.push_back(myCart.cycles() !=
|
||||
static_cast<uInt32>(myOldState.armRun[0]));
|
||||
myThumbCycles->setList(alist, vlist, changed);
|
||||
|
||||
|
||||
alist.clear(); vlist.clear(); changed.clear();
|
||||
alist.push_back(0); vlist.push_back(myCart.stats().instructions);
|
||||
changed.push_back(myCart.stats().instructions != uInt32(myOldState.armRun[1]));
|
||||
changed.push_back(myCart.stats().instructions !=
|
||||
static_cast<uInt32>(myOldState.armRun[1]));
|
||||
myThumbInstructions->setList(alist, vlist, changed);
|
||||
|
||||
CartDebugWidget::loadConfig();
|
||||
|
|
|
@ -83,8 +83,8 @@ CartridgeARWidget::CartridgeARWidget(
|
|||
void CartridgeARWidget::loadConfig()
|
||||
{
|
||||
CartDebug& cart = instance().debugger().cartDebug();
|
||||
const CartState& state = static_cast<const CartState&>(cart.getState());
|
||||
const CartState& oldstate = static_cast<const CartState&>(cart.getOldState());
|
||||
const auto& state = static_cast<const CartState&>(cart.getState());
|
||||
const auto& oldstate = static_cast<const CartState&>(cart.getOldState());
|
||||
|
||||
myBank->setSelectedIndex(myCart.getBank(), state.bank != oldstate.bank);
|
||||
|
||||
|
|
|
@ -99,8 +99,7 @@ CartridgeBUSWidget::CartridgeBUSWidget(
|
|||
myDatastreamPointers2->setTarget(this);
|
||||
myDatastreamPointers2->setEditable(false);
|
||||
|
||||
uInt32 row;
|
||||
for(row = 0; row < 4; ++row)
|
||||
for(uInt32 row = 0; row < 4; ++row)
|
||||
{
|
||||
myDatastreamLabels[row] =
|
||||
new StaticTextWidget(_boss, _font, DS_X - _font.getStringWidth("xx "),
|
||||
|
@ -369,7 +368,8 @@ void CartridgeBUSWidget::loadConfig()
|
|||
for(int i = 0; i < 3; ++i)
|
||||
{
|
||||
alist.push_back(0); vlist.push_back(myCart.myMusicCounters[i]);
|
||||
changed.push_back(myCart.myMusicCounters[i] != uInt32(myOldState.mcounters[i]));
|
||||
changed.push_back(myCart.myMusicCounters[i] !=
|
||||
static_cast<uInt32>(myOldState.mcounters[i]));
|
||||
}
|
||||
myMusicCounters->setList(alist, vlist, changed);
|
||||
|
||||
|
@ -377,7 +377,8 @@ void CartridgeBUSWidget::loadConfig()
|
|||
for(int i = 0; i < 3; ++i)
|
||||
{
|
||||
alist.push_back(0); vlist.push_back(myCart.myMusicFrequencies[i]);
|
||||
changed.push_back(myCart.myMusicFrequencies[i] != uInt32(myOldState.mfreqs[i]));
|
||||
changed.push_back(myCart.myMusicFrequencies[i] !=
|
||||
static_cast<uInt32>(myOldState.mfreqs[i]));
|
||||
}
|
||||
myMusicFrequencies->setList(alist, vlist, changed);
|
||||
|
||||
|
@ -385,7 +386,8 @@ void CartridgeBUSWidget::loadConfig()
|
|||
for(int i = 0; i < 3; ++i)
|
||||
{
|
||||
alist.push_back(0); vlist.push_back(myCart.getWaveform(i) >> 5);
|
||||
changed.push_back((myCart.getWaveform(i) >> 5) != uInt32(myOldState.mwaves[i]));
|
||||
changed.push_back((myCart.getWaveform(i) >> 5) !=
|
||||
static_cast<uInt32>(myOldState.mwaves[i]));
|
||||
}
|
||||
myMusicWaveforms->setList(alist, vlist, changed);
|
||||
|
||||
|
@ -393,7 +395,8 @@ void CartridgeBUSWidget::loadConfig()
|
|||
for(int i = 0; i < 3; ++i)
|
||||
{
|
||||
alist.push_back(0); vlist.push_back(myCart.getWaveformSize(i));
|
||||
changed.push_back((myCart.getWaveformSize(i)) != uInt32(myOldState.mwavesizes[i]));
|
||||
changed.push_back((myCart.getWaveformSize(i)) !=
|
||||
static_cast<uInt32>(myOldState.mwavesizes[i]));
|
||||
}
|
||||
myMusicWaveformSizes->setList(alist, vlist, changed);
|
||||
|
||||
|
@ -401,7 +404,8 @@ void CartridgeBUSWidget::loadConfig()
|
|||
{
|
||||
alist.clear(); vlist.clear(); changed.clear();
|
||||
alist.push_back(0); vlist.push_back(myCart.getSample());
|
||||
changed.push_back((myCart.getSample()) != uInt32(myOldState.samplepointer[0]));
|
||||
changed.push_back((myCart.getSample()) !=
|
||||
static_cast<uInt32>(myOldState.samplepointer[0]));
|
||||
mySamplePointer->setList(alist, vlist, changed);
|
||||
}
|
||||
|
||||
|
|
|
@ -111,8 +111,7 @@ CartridgeCDFWidget::CartridgeCDFWidget(
|
|||
myJumpStreamPointers->setTarget(this);
|
||||
myJumpStreamPointers->setEditable(false);
|
||||
|
||||
uInt32 row;
|
||||
for(row = 0; row < 8; ++row)
|
||||
for(uInt32 row = 0; row < 8; ++row)
|
||||
{
|
||||
myDatastreamLabels[row] =
|
||||
new StaticTextWidget(_boss, _font, DS_X - _font.getStringWidth("xx "),
|
||||
|
@ -286,7 +285,8 @@ void CartridgeCDFWidget::loadConfig()
|
|||
{
|
||||
alist.clear(); vlist.clear(); changed.clear();
|
||||
alist.push_back(0); vlist.push_back(myCart.myRAM[myCart.myFastFetcherOffset]);
|
||||
changed.push_back((myCart.myRAM[myCart.myFastFetcherOffset]) != uInt32(myOldState.fastfetchoffset[0]));
|
||||
changed.push_back((myCart.myRAM[myCart.myFastFetcherOffset]) !=
|
||||
static_cast<uInt32>(myOldState.fastfetchoffset[0]));
|
||||
myFastFetcherOffset->setList(alist, vlist, changed);
|
||||
}
|
||||
|
||||
|
@ -361,7 +361,8 @@ void CartridgeCDFWidget::loadConfig()
|
|||
for(int i = 0; i < 3; ++i)
|
||||
{
|
||||
alist.push_back(0); vlist.push_back(myCart.myMusicCounters[i]);
|
||||
changed.push_back(myCart.myMusicCounters[i] != uInt32(myOldState.mcounters[i]));
|
||||
changed.push_back(myCart.myMusicCounters[i] !=
|
||||
static_cast<uInt32>(myOldState.mcounters[i]));
|
||||
}
|
||||
myMusicCounters->setList(alist, vlist, changed);
|
||||
|
||||
|
@ -369,7 +370,8 @@ void CartridgeCDFWidget::loadConfig()
|
|||
for(int i = 0; i < 3; ++i)
|
||||
{
|
||||
alist.push_back(0); vlist.push_back(myCart.myMusicFrequencies[i]);
|
||||
changed.push_back(myCart.myMusicFrequencies[i] != uInt32(myOldState.mfreqs[i]));
|
||||
changed.push_back(myCart.myMusicFrequencies[i] !=
|
||||
static_cast<uInt32>(myOldState.mfreqs[i]));
|
||||
}
|
||||
myMusicFrequencies->setList(alist, vlist, changed);
|
||||
|
||||
|
@ -377,7 +379,8 @@ void CartridgeCDFWidget::loadConfig()
|
|||
for(int i = 0; i < 3; ++i)
|
||||
{
|
||||
alist.push_back(0); vlist.push_back(myCart.getWaveform(i) >> 5);
|
||||
changed.push_back((myCart.getWaveform(i) >> 5) != uInt32(myOldState.mwaves[i]));
|
||||
changed.push_back((myCart.getWaveform(i) >> 5) !=
|
||||
static_cast<uInt32>(myOldState.mwaves[i]));
|
||||
}
|
||||
myMusicWaveforms->setList(alist, vlist, changed);
|
||||
|
||||
|
@ -385,13 +388,15 @@ void CartridgeCDFWidget::loadConfig()
|
|||
for(int i = 0; i < 3; ++i)
|
||||
{
|
||||
alist.push_back(0); vlist.push_back(myCart.getWaveformSize(i));
|
||||
changed.push_back((myCart.getWaveformSize(i)) != uInt32(myOldState.mwavesizes[i]));
|
||||
changed.push_back((myCart.getWaveformSize(i)) !=
|
||||
static_cast<uInt32>(myOldState.mwavesizes[i]));
|
||||
}
|
||||
myMusicWaveformSizes->setList(alist, vlist, changed);
|
||||
|
||||
alist.clear(); vlist.clear(); changed.clear();
|
||||
alist.push_back(0); vlist.push_back(myCart.getSample());
|
||||
changed.push_back((myCart.getSample()) != uInt32(myOldState.samplepointer[0]));
|
||||
changed.push_back((myCart.getSample()) !=
|
||||
static_cast<uInt32>(myOldState.samplepointer[0]));
|
||||
mySamplePointer->setList(alist, vlist, changed);
|
||||
|
||||
myFastFetch->setState((myCart.myMode & 0x0f) == 0);
|
||||
|
|
|
@ -166,7 +166,7 @@ void CartridgeCMWidget::loadConfig()
|
|||
myBank->setSelectedIndex(myCart.getBank(), myCart.getBank() != myOldState.bank);
|
||||
|
||||
RiotDebug& riot = Debugger::debugger().riotDebug();
|
||||
const RiotState& state = static_cast<const RiotState&>(riot.getState());
|
||||
const auto& state = static_cast<const RiotState&>(riot.getState());
|
||||
|
||||
const uInt8 swcha = myCart.mySWCHA;
|
||||
|
||||
|
|
|
@ -262,7 +262,8 @@ void CartridgeDPCPlusWidget::loadConfig()
|
|||
for(int i = 0; i < 8; ++i)
|
||||
{
|
||||
alist.push_back(0); vlist.push_back(myCart.myFractionalCounters[i]);
|
||||
changed.push_back(myCart.myFractionalCounters[i] != uInt32(myOldState.fraccounters[i]));
|
||||
changed.push_back(myCart.myFractionalCounters[i] !=
|
||||
static_cast<uInt32>(myOldState.fraccounters[i]));
|
||||
}
|
||||
myFracCounters->setList(alist, vlist, changed);
|
||||
|
||||
|
@ -286,7 +287,8 @@ void CartridgeDPCPlusWidget::loadConfig()
|
|||
for(int i = 0; i < 3; ++i)
|
||||
{
|
||||
alist.push_back(0); vlist.push_back(myCart.myMusicCounters[i]);
|
||||
changed.push_back(myCart.myMusicCounters[i] != uInt32(myOldState.mcounters[i]));
|
||||
changed.push_back(myCart.myMusicCounters[i] !=
|
||||
static_cast<uInt32>(myOldState.mcounters[i]));
|
||||
}
|
||||
myMusicCounters->setList(alist, vlist, changed);
|
||||
|
||||
|
@ -294,7 +296,8 @@ void CartridgeDPCPlusWidget::loadConfig()
|
|||
for(int i = 0; i < 3; ++i)
|
||||
{
|
||||
alist.push_back(0); vlist.push_back(myCart.myMusicFrequencies[i]);
|
||||
changed.push_back(myCart.myMusicFrequencies[i] != uInt32(myOldState.mfreqs[i]));
|
||||
changed.push_back(myCart.myMusicFrequencies[i] !=
|
||||
static_cast<uInt32>(myOldState.mfreqs[i]));
|
||||
}
|
||||
myMusicFrequencies->setList(alist, vlist, changed);
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ CartridgeE7Widget::CartridgeE7Widget(
|
|||
void CartridgeE7Widget::initialize(GuiObject* boss,
|
||||
const CartridgeE7& cart, const ostringstream& info)
|
||||
{
|
||||
const uInt32 size = cart.romBankCount() * cart.BANK_SIZE;
|
||||
const uInt32 size = cart.romBankCount() * CartridgeE7::BANK_SIZE;
|
||||
|
||||
constexpr int xpos = 2;
|
||||
int ypos = addBaseInformation(size, "M Network", info.str(), 15) + myLineHeight;
|
||||
|
@ -148,7 +148,7 @@ string CartridgeE7Widget::bankState()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 CartridgeE7Widget::internalRamSize()
|
||||
{
|
||||
return myCart.RAM_SIZE;
|
||||
return CartridgeE7::RAM_SIZE;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
|
|
|
@ -52,9 +52,10 @@ class CartridgeE7Widget : public CartDebugWidget
|
|||
};
|
||||
|
||||
protected:
|
||||
void initialize(GuiObject* boss, const CartridgeE7& cart, const ostringstream& info);
|
||||
void initialize(GuiObject* boss, const CartridgeE7& cart,
|
||||
const ostringstream& info);
|
||||
const char* getSpotLower(int idx);
|
||||
const char* getSpotUpper(int idx);
|
||||
static const char* getSpotUpper(int idx);
|
||||
|
||||
private:
|
||||
void saveOldState() override;
|
||||
|
|
|
@ -49,7 +49,7 @@ int CartridgeEnhancedWidget::initialize()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
size_t CartridgeEnhancedWidget::size()
|
||||
{
|
||||
size_t size;
|
||||
size_t size{0};
|
||||
|
||||
myCart.getImage(size);
|
||||
|
||||
|
@ -96,7 +96,7 @@ string CartridgeEnhancedWidget::ramDescription()
|
|||
string CartridgeEnhancedWidget::romDescription()
|
||||
{
|
||||
ostringstream info;
|
||||
size_t size;
|
||||
size_t size{0};
|
||||
const ByteBuffer& image = myCart.getImage(size);
|
||||
|
||||
if(myCart.romBankCount() > 1)
|
||||
|
@ -123,7 +123,7 @@ string CartridgeEnhancedWidget::romDescription()
|
|||
else
|
||||
{
|
||||
uInt16 start = (image[myCart.mySize - 3] << 8) | image[myCart.mySize - 4];
|
||||
start -= start % std::min(int(size), 0x1000);
|
||||
start -= start % std::min(static_cast<int>(size), 0x1000);
|
||||
const uInt16 end = start + static_cast<uInt16>(myCart.mySize) - 1;
|
||||
// special check for ROMs where the extra RAM is not included in the image (e.g. CV).
|
||||
if((start & 0xFFFU) < size)
|
||||
|
@ -328,15 +328,15 @@ void CartridgeEnhancedWidget::loadConfig()
|
|||
ostringstream buf;
|
||||
ByteArray arr = myCart.myPlusROM->getSend();
|
||||
|
||||
for(size_t i = 0; i < arr.size(); ++i)
|
||||
buf << Common::Base::HEX2 << int(arr[i]) << " ";
|
||||
for(auto i: arr)
|
||||
buf << Common::Base::HEX2 << static_cast<int>(i) << " ";
|
||||
myPlusROMSendWidget->setText(buf.str(), arr != myOldState.send);
|
||||
|
||||
buf.str("");
|
||||
arr = myCart.myPlusROM->getReceive();
|
||||
|
||||
for(size_t i = 0; i < arr.size(); ++i)
|
||||
buf << Common::Base::HEX2 << int(arr[i]) << " ";
|
||||
for(auto i: arr)
|
||||
buf << Common::Base::HEX2 << static_cast<int>(i) << " ";
|
||||
myPlusROMReceiveWidget->setText(buf.str(), arr != myOldState.receive);
|
||||
}
|
||||
if(myBankWidgets != nullptr)
|
||||
|
@ -384,7 +384,7 @@ uInt32 CartridgeEnhancedWidget::internalRamRPort(int start)
|
|||
string CartridgeEnhancedWidget::internalRamDescription()
|
||||
{
|
||||
ostringstream desc;
|
||||
string indent = "";
|
||||
string indent;
|
||||
|
||||
if(myCart.ramBankCount())
|
||||
{
|
||||
|
|
|
@ -30,7 +30,7 @@ CartridgeFA2Widget::CartridgeFA2Widget(
|
|||
|
||||
const int bwidth = _font.getStringWidth("Erase") + 20;
|
||||
|
||||
StaticTextWidget* t = new StaticTextWidget(boss, _font, xpos, ypos,
|
||||
auto* t = new StaticTextWidget(boss, _font, xpos, ypos,
|
||||
_font.getStringWidth("Harmony flash memory "),
|
||||
myFontHeight, "Harmony flash memory ", TextAlign::Left);
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ CartRamWidget::CartRamWidget(
|
|||
constexpr uInt16 maxlines = 6;
|
||||
const StringParser bs(desc, (fwidth - ScrollBarWidget::scrollBarWidth(_font)) / myFontWidth);
|
||||
const StringList& sl = bs.stringList();
|
||||
uInt32 lines = static_cast<uInt32>(sl.size());
|
||||
auto lines = static_cast<uInt32>(sl.size());
|
||||
bool useScrollbar = false;
|
||||
|
||||
if(lines < 2) lines = 2;
|
||||
|
|
|
@ -65,7 +65,7 @@ class CartRamWidget : public Widget, public CommandSender
|
|||
InternalRamWidget(GuiObject* boss, const GUI::Font& lfont,
|
||||
const GUI::Font& nfont,
|
||||
int x, int y, int w, int h,
|
||||
CartDebugWidget& cartDebug);
|
||||
CartDebugWidget& dbg);
|
||||
~InternalRamWidget() override = default;
|
||||
string getLabel(int addr) const override;
|
||||
|
||||
|
|
|
@ -22,8 +22,7 @@
|
|||
CartridgeWDWidget::CartridgeWDWidget(
|
||||
GuiObject* boss, const GUI::Font& lfont, const GUI::Font& nfont,
|
||||
int x, int y, int w, int h, CartridgeWD& cart)
|
||||
: CartridgeEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart),
|
||||
myCartWD{cart}
|
||||
: CartridgeEnhancedWidget(boss, lfont, nfont, x, y, w, h, cart)
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
|
@ -46,7 +45,7 @@ string CartridgeWDWidget::description()
|
|||
string CartridgeWDWidget::hotspotStr(int bank, int segment, bool prefix)
|
||||
{
|
||||
ostringstream info;
|
||||
const CartridgeWD::BankOrg banks = myCartWD.ourBankOrg[bank];
|
||||
const CartridgeWD::BankOrg banks = CartridgeWD::ourBankOrg[bank];
|
||||
|
||||
info << "(" << (prefix ? "hotspot " : "")
|
||||
<< "$" << Common::Base::HEX1 << (myCart.hotspot() + bank) << ") ["
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue