mirror of https://github.com/stella-emu/stella.git
More const fixes, this time from suggestions from VS code analyzer.
This commit is contained in:
parent
c7acb9d65e
commit
debec03900
|
@ -83,7 +83,7 @@ void FBBackendSDL2::queryHardware(vector<Common::Size>& fullscreenRes,
|
|||
myNumDisplays = SDL_GetNumVideoDisplays();
|
||||
|
||||
// First get the maximum fullscreen desktop resolution
|
||||
SDL_DisplayMode display;
|
||||
SDL_DisplayMode display{};
|
||||
for(int i = 0; i < myNumDisplays; ++i)
|
||||
{
|
||||
SDL_GetDesktopDisplayMode(i, &display);
|
||||
|
@ -133,7 +133,7 @@ void FBBackendSDL2::queryHardware(vector<Common::Size>& fullscreenRes,
|
|||
SDL_DestroyWindow(tmpWindow);
|
||||
}
|
||||
|
||||
SDL_Rect r;
|
||||
SDL_Rect r{};
|
||||
for(int i = 0; i < myNumDisplays; ++i)
|
||||
{
|
||||
// Display bounds minus dock
|
||||
|
@ -261,7 +261,7 @@ bool FBBackendSDL2::setVideoMode(const VideoModeHandler::Mode& mode,
|
|||
}
|
||||
|
||||
#ifdef ADAPTABLE_REFRESH_SUPPORT
|
||||
SDL_DisplayMode adaptedSdlMode;
|
||||
SDL_DisplayMode adaptedSdlMode{};
|
||||
const int gameRefreshRate =
|
||||
myOSystem.hasConsole() ? myOSystem.console().gameRefreshRate() : 0;
|
||||
const bool shouldAdapt = fullScreen
|
||||
|
@ -374,7 +374,7 @@ bool FBBackendSDL2::adaptRefreshRate(Int32 displayIndex,
|
|||
// Check for integer factors 1 (60/50 Hz) and 2 (120/100 Hz)
|
||||
for(int m = 1; m <= 2; ++m)
|
||||
{
|
||||
SDL_DisplayMode closestSdlMode;
|
||||
SDL_DisplayMode closestSdlMode{};
|
||||
|
||||
sdlMode.refresh_rate = wantedRefreshRate * m;
|
||||
if(SDL_GetClosestDisplayMode(displayIndex, &sdlMode, &closestSdlMode) == nullptr)
|
||||
|
@ -416,7 +416,7 @@ bool FBBackendSDL2::createRenderer()
|
|||
bool recreate = myRenderer == nullptr;
|
||||
uInt32 renderFlags = SDL_RENDERER_ACCELERATED;
|
||||
const string& video = myOSystem.settings().getString("video"); // Render hint
|
||||
SDL_RendererInfo renderInfo;
|
||||
SDL_RendererInfo renderInfo{};
|
||||
|
||||
if(myOSystem.settings().getBool("vsync")
|
||||
&& !myOSystem.settings().getBool("turbo")) // V'synced blits option
|
||||
|
|
|
@ -132,7 +132,7 @@ class HighScoresManager
|
|||
|
||||
@return The number of score address bytes
|
||||
*/
|
||||
static uInt32 numAddrBytes(Int32 digits, Int32 trailing) {
|
||||
static constexpr uInt32 numAddrBytes(Int32 digits, Int32 trailing) {
|
||||
return (digits - trailing + 1) / 2;
|
||||
}
|
||||
|
||||
|
|
|
@ -367,7 +367,7 @@ void SoundSDL2::initResampler()
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void SoundSDL2::callback(void* object, uInt8* stream, int len)
|
||||
{
|
||||
auto* self = static_cast<SoundSDL2*>(object);
|
||||
const auto* self = static_cast<SoundSDL2*>(object);
|
||||
|
||||
if(self->myAudioQueue && self->myResampler)
|
||||
{
|
||||
|
|
|
@ -442,7 +442,7 @@ namespace StellaKeyName
|
|||
inline string_view forKey(StellaKey key)
|
||||
{
|
||||
#ifdef SDL_SUPPORT
|
||||
return SDL_GetScancodeName(SDL_Scancode(key));
|
||||
return SDL_GetScancodeName(static_cast<SDL_Scancode>(key));
|
||||
#else
|
||||
return string_view{};
|
||||
#endif
|
||||
|
|
|
@ -206,7 +206,7 @@ namespace BSPF
|
|||
try {
|
||||
int i{};
|
||||
s = s.substr(s.find_first_not_of(' '));
|
||||
auto result = std::from_chars(s.data(), s.data() + s.size(), i, BASE);
|
||||
const auto result = std::from_chars(s.data(), s.data() + s.size(), i, BASE);
|
||||
return result.ec == std::errc() ? i : defaultValue;
|
||||
}
|
||||
catch(...) { return defaultValue; }
|
||||
|
@ -262,7 +262,7 @@ namespace BSPF
|
|||
}
|
||||
|
||||
// Test whether the first string contains the second one (case insensitive)
|
||||
inline constexpr bool containsIgnoreCase(string_view s1, string_view s2)
|
||||
constexpr bool containsIgnoreCase(string_view s1, string_view s2)
|
||||
{
|
||||
return findIgnoreCase(s1, s2) != string::npos;
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ void checkForCustomBaseDir(Settings::Options& options)
|
|||
OSystem::overrideBaseDirWithApp();
|
||||
else
|
||||
{
|
||||
auto it = options.find("basedir");
|
||||
const auto it = options.find("basedir");
|
||||
if(it != options.end())
|
||||
OSystem::overrideBaseDir(it->second.toString());
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ void attachConsole()
|
|||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
if(GetConsoleScreenBufferInfo(hConsole, &csbi))
|
||||
{
|
||||
COORD pos = {0, csbi.dwCursorPosition.Y};
|
||||
const COORD pos = {0, csbi.dwCursorPosition.Y};
|
||||
SetConsoleCursorPosition(hConsole, pos);
|
||||
cout << std::setw(160) << ""; // this clears the extra prompt display
|
||||
SetConsoleCursorPosition(hConsole, pos);
|
||||
|
|
|
@ -378,7 +378,7 @@ bool CartDebug::fillDisassemblyList(BankInfo& info, Disassembly& disassembly,
|
|||
|
||||
disassembly.fieldwidth = 24 + myLabelLength;
|
||||
// line offset must be set before calling DiStella!
|
||||
auto lineOfs = static_cast<uInt32>(myDisassembly.list.size());
|
||||
const auto lineOfs = static_cast<uInt32>(myDisassembly.list.size());
|
||||
const DiStella distella(*this, disassembly.list, info, DiStella::settings,
|
||||
myDisLabels, myDisDirectives, myReserved);
|
||||
|
||||
|
@ -1209,7 +1209,7 @@ string CartDebug::saveDisassembly(string path)
|
|||
cart.lockHotspots();
|
||||
|
||||
// Some boilerplate, similar to what DiStella adds
|
||||
auto timeinfo = BSPF::localTime();
|
||||
const auto timeinfo = BSPF::localTime();
|
||||
stringstream out;
|
||||
out << "; Disassembly of " << myOSystem.romFile().getShortPath() << "\n"
|
||||
<< "; Disassembled " << std::put_time(&timeinfo, "%c\n")
|
||||
|
|
|
@ -2170,7 +2170,7 @@ void DebuggerParser::executeSaveRom()
|
|||
void DebuggerParser::executeSaveSes()
|
||||
{
|
||||
ostringstream filename; // NOLINT (filename is not a const)
|
||||
auto timeinfo = BSPF::localTime();
|
||||
const auto timeinfo = BSPF::localTime();
|
||||
filename << std::put_time(&timeinfo, "session_%F_%H-%M-%S.txt");
|
||||
|
||||
if(argCount && argStrings[0] == "?")
|
||||
|
@ -2356,8 +2356,8 @@ void DebuggerParser::executeTimer()
|
|||
}
|
||||
|
||||
uInt32 numAddrs = 0, numBanks = 0;
|
||||
uInt16 addr[2];
|
||||
uInt8 bank[2];
|
||||
uInt16 addr[2]{};
|
||||
uInt8 bank[2]{};
|
||||
|
||||
// set defaults:
|
||||
addr[0] = debugger.cpuDebug().pc() ;
|
||||
|
|
|
@ -94,7 +94,7 @@ uInt32 TimerMap::add(uInt16 addr, uInt8 bank, bool mirrors, bool anyBank)
|
|||
// update tp key in myFromMap for new mirrors & anyBank settings
|
||||
// 1. find map entry using OLD tp key settings:
|
||||
toKey(tpFrom, oldMirrors, oldAnyBank);
|
||||
auto from = myFromMap.equal_range(tpFrom);
|
||||
const auto from = myFromMap.equal_range(tpFrom);
|
||||
for(auto it = from.first; it != from.second; ++it)
|
||||
if(it->second == &tmPartial)
|
||||
{
|
||||
|
|
|
@ -35,8 +35,9 @@ AudioWidget::AudioWidget(GuiObject* boss, const GUI::Font& lfont,
|
|||
{
|
||||
const int fontWidth = lfont.getMaxCharWidth(),
|
||||
fontHeight = lfont.getFontHeight(),
|
||||
lineHeight = lfont.getLineHeight();
|
||||
int xpos = 10, ypos = 25, lwidth = lfont.getStringWidth("AUDW ");
|
||||
lineHeight = lfont.getLineHeight(),
|
||||
lwidth = lfont.getStringWidth("AUDW ");
|
||||
int xpos = 10, ypos = 25;
|
||||
|
||||
// AudF registers
|
||||
new StaticTextWidget(boss, lfont, xpos, ypos+2,
|
||||
|
|
|
@ -24,10 +24,11 @@ BoosterWidget::BoosterWidget(GuiObject* boss, const GUI::Font& font,
|
|||
{
|
||||
const string& label = isLeftPort() ? "Left (Booster)" : "Right (Booster)";
|
||||
|
||||
const int fontHeight = font.getFontHeight();
|
||||
int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Booster)");
|
||||
auto* t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth,
|
||||
fontHeight, label, TextAlign::Left);
|
||||
const int fontHeight = font.getFontHeight(),
|
||||
lwidth = font.getStringWidth("Right (Booster)");
|
||||
int xpos = x, ypos = y;
|
||||
const 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);
|
||||
|
|
|
@ -120,7 +120,7 @@ void Cartridge3EPlusWidget::bankSelect(int& ypos)
|
|||
label.str("");
|
||||
label << "$" << Common::Base::HEX4 << addr1 << "-$"
|
||||
<< Common::Base::HEX4 << (addr1 + 0x1FF);
|
||||
auto* t = new StaticTextWidget(_boss, _font, xpos_s, ypos_s + 2, label.view());
|
||||
const auto* t = new StaticTextWidget(_boss, _font, xpos_s, ypos_s + 2, label.view());
|
||||
|
||||
const int xoffset = t->getRight() + _font.getMaxCharWidth();
|
||||
const size_t bank_off = static_cast<size_t>(seg) * 2;
|
||||
|
|
|
@ -84,7 +84,7 @@ void Cartridge3EWidget::bankSelect(int& ypos)
|
|||
myBankWidgets[0]->setID(0);
|
||||
addFocusWidget(myBankWidgets[0]);
|
||||
|
||||
auto* t = new StaticTextWidget(_boss, _font,
|
||||
const auto* t = new StaticTextWidget(_boss, _font,
|
||||
myBankWidgets[0]->getRight(), ypos - 1, " (ROM)");
|
||||
|
||||
xpos = t->getRight() + 20;
|
||||
|
|
|
@ -156,7 +156,8 @@ void CartridgeELFStateWidget::loadConfig()
|
|||
s << myCart.myTransactionQueue.size();
|
||||
myQueueSize->setText(s.str());
|
||||
|
||||
BusTransactionQueue::Transaction* nextTransaction = myCart.myTransactionQueue.peekNextTransaction();
|
||||
const BusTransactionQueue::Transaction* nextTransaction =
|
||||
myCart.myTransactionQueue.peekNextTransaction();
|
||||
myNextTransaction->setLabel(nextTransaction
|
||||
? describeTransaction(
|
||||
nextTransaction->address,
|
||||
|
|
|
@ -26,11 +26,10 @@ CartridgeFA2Widget::CartridgeFA2Widget(
|
|||
myCartFA2{cart}
|
||||
{
|
||||
int xpos = 2;
|
||||
const int ypos = initialize() + 12;
|
||||
const int ypos = initialize() + 12,
|
||||
bwidth = _font.getStringWidth("Erase") + 20;
|
||||
|
||||
const int bwidth = _font.getStringWidth("Erase") + 20;
|
||||
|
||||
auto* t = new StaticTextWidget(boss, _font, xpos, ypos,
|
||||
const auto* t = new StaticTextWidget(boss, _font, xpos, ypos,
|
||||
_font.getStringWidth("Harmony flash memory "),
|
||||
myFontHeight, "Harmony flash memory ", TextAlign::Left);
|
||||
|
||||
|
|
|
@ -24,11 +24,12 @@ GenesisWidget::GenesisWidget(GuiObject* boss, const GUI::Font& font,
|
|||
{
|
||||
const string& label = getHeader();
|
||||
|
||||
const int fontHeight = font.getFontHeight();
|
||||
int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Genesis)");
|
||||
const int fontHeight = font.getFontHeight(),
|
||||
lwidth = font.getStringWidth("Right (Genesis)");
|
||||
int xpos = x, ypos = y;
|
||||
|
||||
const StaticTextWidget* t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth,
|
||||
fontHeight, label, TextAlign::Left);
|
||||
fontHeight, label, TextAlign::Left);
|
||||
xpos += t->getWidth()/2 - 5; ypos += t->getHeight() + 20;
|
||||
myPins[kJUp] = new CheckboxWidget(boss, font, xpos, ypos, "",
|
||||
CheckboxWidget::kCheckActionCmd);
|
||||
|
|
|
@ -24,10 +24,11 @@ Joy2BPlusWidget::Joy2BPlusWidget(GuiObject* boss, const GUI::Font& font,
|
|||
{
|
||||
const string& label = isLeftPort() ? "Left (Joy 2B+)" : "Right (Joy 2B+)";
|
||||
|
||||
const int fontHeight = font.getFontHeight();
|
||||
int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Joy 2B+)");
|
||||
auto* t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth,
|
||||
fontHeight, label, TextAlign::Left);
|
||||
const int fontHeight = font.getFontHeight(),
|
||||
lwidth = font.getStringWidth("Right (Joy 2B+)");
|
||||
int xpos = x, ypos = y;
|
||||
const 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);
|
||||
|
|
|
@ -26,8 +26,9 @@ KeyboardWidget::KeyboardWidget(GuiObject* boss, const GUI::Font& font,
|
|||
const bool leftport = isLeftPort();
|
||||
const string& label = leftport ? "Left (Keyboard)" : "Right (Keyboard)";
|
||||
|
||||
const int fontHeight = font.getFontHeight();
|
||||
int xpos = x, ypos = y, lwidth = font.getStringWidth("Right (Keyboard)");
|
||||
const int fontHeight = font.getFontHeight(),
|
||||
lwidth = font.getStringWidth("Right (Keyboard)");
|
||||
int xpos = x, ypos = y;
|
||||
const StaticTextWidget* t = new StaticTextWidget(boss, font, xpos, ypos+2, lwidth,
|
||||
fontHeight, label, TextAlign::Left);
|
||||
|
||||
|
|
|
@ -25,10 +25,9 @@ PaddleWidget::PaddleWidget(GuiObject* boss, const GUI::Font& font, int x, int y,
|
|||
{
|
||||
const bool leftport = isLeftPort();
|
||||
const string& label = getHeader();
|
||||
const int fontHeight = font.getFontHeight();
|
||||
|
||||
int xpos = x, ypos = y,
|
||||
lwidth = font.getStringWidth("Right (Paddles)");
|
||||
const int fontHeight = font.getFontHeight(),
|
||||
lwidth = font.getStringWidth("Right (Paddles)");
|
||||
int xpos = x, ypos = y;
|
||||
|
||||
if(!embedded)
|
||||
{
|
||||
|
|
|
@ -36,7 +36,7 @@ RomWidget::RomWidget(GuiObject* boss, const GUI::Font& lfont, const GUI::Font& n
|
|||
{
|
||||
// Show current bank state
|
||||
int xpos = x, ypos = y + 7;
|
||||
auto* t = new StaticTextWidget(boss, lfont, xpos, ypos, "Info ");
|
||||
const auto* t = new StaticTextWidget(boss, lfont, xpos, ypos, "Info ");
|
||||
|
||||
xpos += t->getRight();
|
||||
myBank = new EditTextWidget(boss, nfont, xpos, ypos-2,
|
||||
|
@ -90,7 +90,7 @@ void RomWidget::handleCommand(CommandSender* sender, int cmd, int data, int id)
|
|||
case RomListWidget::kRomChangedCmd:
|
||||
// 'data' is the line in the disassemblylist to be accessed
|
||||
// 'id' is the base to use for the data to be changed
|
||||
patchROM(data, myRomList->getText(), Common::Base::Fmt(id));
|
||||
patchROM(data, myRomList->getText(), static_cast<Common::Base::Fmt>(id));
|
||||
break;
|
||||
|
||||
case RomListWidget::kSetPCCmd:
|
||||
|
|
|
@ -412,7 +412,7 @@ string CartridgeELF::getDebugLog() const
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
std::pair<unique_ptr<uInt8[]>, size_t> CartridgeELF::getArmImage() const
|
||||
{
|
||||
const size_t imageSize = ADDR_TABLES_BASE + TABLES_SIZE;
|
||||
constexpr size_t imageSize = ADDR_TABLES_BASE + TABLES_SIZE;
|
||||
unique_ptr<uInt8[]> image = make_unique<uInt8[]>(imageSize);
|
||||
|
||||
memset(image.get(), 0, imageSize);
|
||||
|
@ -430,7 +430,7 @@ std::pair<unique_ptr<uInt8[]>, size_t> CartridgeELF::getArmImage() const
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
inline uInt8 CartridgeELF::driveBus(uInt16 address, uInt8 value)
|
||||
{
|
||||
auto* nextTransaction = myTransactionQueue.getNextTransaction(address,
|
||||
const auto* nextTransaction = myTransactionQueue.getNextTransaction(address,
|
||||
mySystem->cycles() * myArmCyclesPer6502Cycle - myArmCyclesOffset);
|
||||
if (nextTransaction) {
|
||||
nextTransaction->setBusState(myIsBusDriven, myDriveBusValue);
|
||||
|
@ -459,7 +459,7 @@ void CartridgeELF::parseAndLinkElf()
|
|||
|
||||
try {
|
||||
myElfParser.parse(myImage.get(), myImageSize);
|
||||
} catch (ElfParser::ElfParseError& e) {
|
||||
} catch (const ElfParser::ElfParseError& e) {
|
||||
throw runtime_error("failed to initialize ELF: " + string(e.what()));
|
||||
}
|
||||
|
||||
|
@ -695,7 +695,7 @@ void CartridgeELF::BusFallbackDelegate::setErrorsAreFatal(bool fatal)
|
|||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
CortexM0::err_t CartridgeELF::BusFallbackDelegate::handleError(
|
||||
string_view accessType, uInt32 address, CortexM0::err_t err, CortexM0& cortex
|
||||
string_view accessType, uInt32 address, CortexM0::err_t err, const CortexM0& cortex
|
||||
) const {
|
||||
if (myErrorsAreFatal) return CortexM0::errIntrinsic(err, address);
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ class CartridgeELF: public Cartridge {
|
|||
|
||||
private:
|
||||
CortexM0::err_t handleError(
|
||||
string_view accessType, uInt32 address, CortexM0::err_t err, CortexM0& cortex
|
||||
string_view accessType, uInt32 address, CortexM0::err_t err, const CortexM0& cortex
|
||||
) const;
|
||||
|
||||
private:
|
||||
|
|
|
@ -775,7 +775,7 @@ FBInitStatus Console::initializeVideo(bool full)
|
|||
|
||||
if(full)
|
||||
{
|
||||
auto size = myOSystem.settings().getBool("tia.correct_aspect") ?
|
||||
const auto size = myOSystem.settings().getBool("tia.correct_aspect") ?
|
||||
Common::Size(TIAConstants::viewableWidth, TIAConstants::viewableHeight) :
|
||||
Common::Size(2 * myTIA->width(), myTIA->height());
|
||||
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//============================================================================
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "System.hxx"
|
||||
#include "Control.hxx"
|
||||
|
||||
|
@ -148,51 +146,12 @@ Controller::Type Controller::getType(string_view propName)
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Controller::setDigitalDeadZone(int deadZone)
|
||||
{
|
||||
DIGITAL_DEAD_ZONE = digitalDeadZoneValue(deadZone);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
int Controller::digitalDeadZoneValue(int deadZone)
|
||||
{
|
||||
deadZone = BSPF::clamp(deadZone, MIN_DIGITAL_DEADZONE, MAX_DIGITAL_DEADZONE);
|
||||
|
||||
return 3200 + deadZone * 1000;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Controller::setAnalogDeadZone(int deadZone)
|
||||
{
|
||||
ANALOG_DEAD_ZONE = analogDeadZoneValue(deadZone);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
int Controller::analogDeadZoneValue(int deadZone)
|
||||
{
|
||||
deadZone = BSPF::clamp(deadZone, MIN_ANALOG_DEADZONE, MAX_ANALOG_DEADZONE);
|
||||
|
||||
return deadZone * std::round(32768 / 2. / MAX_DIGITAL_DEADZONE);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Controller::setMouseSensitivity(int sensitivity)
|
||||
{
|
||||
MOUSE_SENSITIVITY = BSPF::clamp(sensitivity, MIN_MOUSE_SENSE, MAX_MOUSE_SENSE);
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Controller::setAutoFire(bool enable)
|
||||
{
|
||||
AUTO_FIRE = enable;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void Controller::setAutoFireRate(int rate, bool isNTSC)
|
||||
{
|
||||
rate = BSPF::clamp(rate, 0, isNTSC ? 30 : 25);
|
||||
AUTO_FIRE_RATE = 32 * 1024 * rate / (isNTSC ? 60 : 50);
|
||||
}
|
||||
// int Controller::analogDeadZoneValue(int deadZone)
|
||||
// {
|
||||
// deadZone = BSPF::clamp(deadZone, MIN_ANALOG_DEADZONE, MAX_ANALOG_DEADZONE);
|
||||
//
|
||||
// return deadZone * std::round(32768 / 2. / MAX_DIGITAL_DEADZONE);
|
||||
// }
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
int Controller::DIGITAL_DEAD_ZONE = 3200;
|
||||
|
|
|
@ -23,6 +23,7 @@ class ControllerLowLevel;
|
|||
class Event;
|
||||
class System;
|
||||
|
||||
#include <cmath>
|
||||
#include <functional>
|
||||
|
||||
#include "bspf.hxx"
|
||||
|
@ -286,24 +287,35 @@ class Controller : public Serializable
|
|||
|
||||
@param deadZone Value from 0 to 29
|
||||
*/
|
||||
static void setDigitalDeadZone(int deadZone);
|
||||
static void setDigitalDeadZone(int deadZone) {
|
||||
DIGITAL_DEAD_ZONE = digitalDeadZoneValue(deadZone);
|
||||
}
|
||||
|
||||
/**
|
||||
Sets the dead zone for analog paddles.
|
||||
|
||||
@param deadZone Value from 0 to 29
|
||||
*/
|
||||
static void setAnalogDeadZone(int deadZone);
|
||||
static void setAnalogDeadZone(int deadZone) {
|
||||
ANALOG_DEAD_ZONE = analogDeadZoneValue(deadZone);
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieves the effective digital dead zone value
|
||||
*/
|
||||
static int digitalDeadZoneValue(int deadZone);
|
||||
static constexpr int digitalDeadZoneValue(int deadZone) {
|
||||
deadZone = BSPF::clamp(deadZone, MIN_DIGITAL_DEADZONE, MAX_DIGITAL_DEADZONE);
|
||||
return 3200 + deadZone * 1000;
|
||||
}
|
||||
|
||||
/**
|
||||
Retrieves the effective analog dead zone value
|
||||
TODO: std::round not constexpr until C++23
|
||||
*/
|
||||
static int analogDeadZoneValue(int deadZone);
|
||||
static /*constexpr*/ int analogDeadZoneValue(int deadZone) {
|
||||
deadZone = BSPF::clamp(deadZone, MIN_ANALOG_DEADZONE, MAX_ANALOG_DEADZONE);
|
||||
return deadZone * std::round(32768 / 2. / MAX_DIGITAL_DEADZONE);
|
||||
}
|
||||
|
||||
static int digitalDeadZone() { return DIGITAL_DEAD_ZONE; }
|
||||
static int analogDeadZone() { return ANALOG_DEAD_ZONE; }
|
||||
|
@ -315,14 +327,18 @@ class Controller : public Serializable
|
|||
@param sensitivity Value from 1 to MAX_MOUSE_SENSE, with larger
|
||||
values causing more movement
|
||||
*/
|
||||
static void setMouseSensitivity(int sensitivity);
|
||||
static void setMouseSensitivity(int sensitivity) {
|
||||
MOUSE_SENSITIVITY = BSPF::clamp(sensitivity, MIN_MOUSE_SENSE, MAX_MOUSE_SENSE);
|
||||
}
|
||||
|
||||
/**
|
||||
Set auto fire state.
|
||||
|
||||
@param enable The new autofire state
|
||||
*/
|
||||
static void setAutoFire(bool enable);
|
||||
static void setAutoFire(bool enable) {
|
||||
AUTO_FIRE = enable;
|
||||
}
|
||||
|
||||
/**
|
||||
Sets the auto fire rate. 0 disables auto fire.
|
||||
|
@ -330,7 +346,10 @@ class Controller : public Serializable
|
|||
@param rate Auto fire rate (0..30/25) in Hz
|
||||
@param isNTSC NTSC or PAL frame rate
|
||||
*/
|
||||
static void setAutoFireRate(int rate, bool isNTSC = true);
|
||||
static void setAutoFireRate(int rate, bool isNTSC = true) {
|
||||
rate = BSPF::clamp(rate, 0, isNTSC ? 30 : 25);
|
||||
AUTO_FIRE_RATE = 32 * 1024 * rate / (isNTSC ? 60 : 50);
|
||||
}
|
||||
|
||||
protected:
|
||||
/**
|
||||
|
|
|
@ -591,7 +591,7 @@ void CortexM0::MemoryRegion::saveDirtyBits(Serializer& out) const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void CortexM0::MemoryRegion::loadDirtyBits(Serializer& in)
|
||||
void CortexM0::MemoryRegion::loadDirtyBits(const Serializer& in)
|
||||
{
|
||||
if (type != MemoryRegionType::directCode && type != MemoryRegionType::directData) return;
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ class CortexM0: public Serializable
|
|||
|
||||
void reset();
|
||||
void saveDirtyBits(Serializer& out) const;
|
||||
void loadDirtyBits(Serializer& in);
|
||||
void loadDirtyBits(const Serializer& in);
|
||||
|
||||
private:
|
||||
MemoryRegion(const MemoryRegion&) = delete;
|
||||
|
|
|
@ -499,7 +499,7 @@ void PlusROM::receive()
|
|||
ByteArray PlusROM::getSend() const
|
||||
{
|
||||
ByteArray arr;
|
||||
uInt8 txPos = myTxPos != 0 ? myTxPos : myLastTxPos;
|
||||
const uInt8 txPos = myTxPos != 0 ? myTxPos : myLastTxPos;
|
||||
|
||||
for(int i = 0; i < txPos; ++i)
|
||||
arr.push_back(myTxBuffer[i]);
|
||||
|
@ -511,7 +511,7 @@ ByteArray PlusROM::getSend() const
|
|||
ByteArray PlusROM::getReceive() const
|
||||
{
|
||||
ByteArray arr;
|
||||
uInt8 txReadPos = myRxReadPos != myRxWritePos ? myRxReadPos : myLastRxReadPos;
|
||||
const uInt8 txReadPos = myRxReadPos != myRxWritePos ? myRxReadPos : myLastRxReadPos;
|
||||
|
||||
for(uInt8 i = txReadPos; i != myRxWritePos; ++i)
|
||||
arr.push_back(myRxBuffer[i]);
|
||||
|
|
|
@ -264,7 +264,7 @@ TIASurface::ScanlineMask TIASurface::scanlineMaskType(int direction)
|
|||
int i = 0;
|
||||
const string& name = myOSystem.settings().getString("tv.scanmask");
|
||||
|
||||
for(const auto& mask: Masks)
|
||||
for(const auto mask: Masks)
|
||||
{
|
||||
if(mask == name)
|
||||
{
|
||||
|
|
|
@ -21,17 +21,17 @@
|
|||
#include "exception/FatalEmulationError.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
BusTransactionQueue::Transaction BusTransactionQueue::Transaction::transactionYield(
|
||||
uInt16 address, uInt64 timestamp, uInt16 mask
|
||||
) {
|
||||
constexpr BusTransactionQueue::Transaction BusTransactionQueue::Transaction::transactionYield(
|
||||
uInt16 address, uInt64 timestamp, uInt16 mask)
|
||||
{
|
||||
address &= 0x1fff;
|
||||
return {.address = address, .mask = mask, .value = 0, .timestamp = timestamp, .yield = true};
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
BusTransactionQueue::Transaction BusTransactionQueue::Transaction::transactionDrive(
|
||||
uInt16 address, uInt8 value, uInt64 timestamp
|
||||
) {
|
||||
constexpr BusTransactionQueue::Transaction BusTransactionQueue::Transaction::transactionDrive(
|
||||
uInt16 address, uInt8 value, uInt64 timestamp)
|
||||
{
|
||||
address &= 0x1fff;
|
||||
return {.address = address, .mask = 0xffff, .value = value, .timestamp = timestamp, .yield = false};
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ void BusTransactionQueue::Transaction::serialize(Serializer& out) const
|
|||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
void BusTransactionQueue::Transaction::deserialize(Serializer& in)
|
||||
void BusTransactionQueue::Transaction::deserialize(const Serializer& in)
|
||||
{
|
||||
address = in.getShort();
|
||||
mask = in.getShort();
|
||||
|
|
|
@ -26,8 +26,8 @@ class Serializer;
|
|||
class BusTransactionQueue: public Serializable {
|
||||
public:
|
||||
struct Transaction {
|
||||
static Transaction transactionYield(uInt16 address, uInt64 timestamp, uInt16 mask);
|
||||
static Transaction transactionDrive(uInt16 address, uInt8 value, uInt64 timestamp);
|
||||
static constexpr Transaction transactionYield(uInt16 address, uInt64 timestamp, uInt16 mask);
|
||||
static constexpr Transaction transactionDrive(uInt16 address, uInt8 value, uInt64 timestamp);
|
||||
|
||||
void setBusState(bool& drive, uInt8& value) const;
|
||||
|
||||
|
@ -38,7 +38,7 @@ class BusTransactionQueue: public Serializable {
|
|||
bool yield{false};
|
||||
|
||||
void serialize(Serializer& out) const;
|
||||
void deserialize(Serializer& in);
|
||||
void deserialize(const Serializer& in);
|
||||
};
|
||||
|
||||
public:
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "ElfEnvironment.hxx"
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const uInt8 elfEnvironment::OVERBLANK_PROGRAM[] = {
|
||||
constexpr uInt8 elfEnvironment::OVERBLANK_PROGRAM[] = {
|
||||
0xa0,0x00, // ldy #0
|
||||
0xa5,0xe0, // lda $e0
|
||||
// OverblankLoop:
|
||||
|
@ -53,7 +53,7 @@ const uInt8 elfEnvironment::OVERBLANK_PROGRAM[] = {
|
|||
};
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const uInt32 elfEnvironment::OVERBLANK_PROGRAM_SIZE = sizeof(elfEnvironment::OVERBLANK_PROGRAM);
|
||||
constexpr uInt32 elfEnvironment::OVERBLANK_PROGRAM_SIZE = sizeof(elfEnvironment::OVERBLANK_PROGRAM);
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
const uInt8 elfEnvironment::LOOKUP_TABLES[3 * 256] = {
|
||||
|
|
|
@ -254,7 +254,7 @@ const char* ElfParser::getName(const Section& section, uInt32 offset) const
|
|||
if (offset >= section.size) ElfParseError::raise("name out of bounds");
|
||||
const uInt32 imageOffset = offset + section.offset;
|
||||
|
||||
const char *name = reinterpret_cast<const char *>(myData + imageOffset);
|
||||
const char* name = reinterpret_cast<const char*>(myData + imageOffset);
|
||||
|
||||
if (myData[imageOffset + strnlen(name, section.size - offset)] != '\0')
|
||||
ElfParseError::raise("unterminated section name");
|
||||
|
|
|
@ -124,7 +124,7 @@ EventMappingWidget::EventMappingWidget(GuiObject* boss, const GUI::Font& font,
|
|||
// Show message for currently selected event
|
||||
xpos = HBORDER;
|
||||
ypos = myActionsList->getBottom() + VGAP * 2;
|
||||
auto* t = new StaticTextWidget(boss, font, xpos, ypos+2, "Action");
|
||||
const auto* t = new StaticTextWidget(boss, font, xpos, ypos+2, "Action");
|
||||
|
||||
myKeyMapping = new EditTextWidget(boss, font, xpos + t->getWidth() + fontWidth, ypos,
|
||||
_w - xpos - t->getWidth() - fontWidth - HBORDER + 2,
|
||||
|
|
|
@ -220,7 +220,7 @@ void FavoritesManager::addRecent(string_view path)
|
|||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
bool FavoritesManager::removeRecent(string_view path)
|
||||
{
|
||||
auto it = std::ranges::find(myRecentList, path);
|
||||
const auto it = std::ranges::find(myRecentList, path);
|
||||
|
||||
if(it != myRecentList.end())
|
||||
myRecentList.erase(it);
|
||||
|
|
|
@ -685,7 +685,7 @@ const FileListWidget::Icon* FileListWidget::getIcon(int i) const
|
|||
0b11111111111'11111111110,
|
||||
0b11111111111'11111111110
|
||||
};
|
||||
const int idx = static_cast<int>(IconType::numTypes);
|
||||
constexpr int idx = static_cast<int>(IconType::numTypes);
|
||||
static const Icon* const small_icons[idx] = {
|
||||
&unknown_small, &rom_small, &directory_small, &zip_small, &up_small
|
||||
};
|
||||
|
|
|
@ -132,7 +132,7 @@ HighScoresDialog::HighScoresDialog(OSystem& osystem, DialogContainer& parent,
|
|||
int ypos = VBORDER + _th;
|
||||
ypos += lineHeight + VGAP * 2; // space for game name
|
||||
|
||||
auto* s = new StaticTextWidget(this, _font, xpos, ypos + 1, "Variation ");
|
||||
const auto* s = new StaticTextWidget(this, _font, xpos, ypos + 1, "Variation ");
|
||||
myVariationPopup = new PopUpWidget(this, _font, s->getRight(), ypos,
|
||||
_font.getStringWidth("256"), lineHeight, items, "", 0, kVariationChanged);
|
||||
wid.push_back(myVariationPopup);
|
||||
|
|
|
@ -48,7 +48,7 @@ JoystickDialog::JoystickDialog(GuiObject* boss, const GUI::Font& font,
|
|||
|
||||
// Joystick ID
|
||||
ypos = _h - VBORDER - (buttonHeight + lineHeight) / 2;
|
||||
auto* t = new StaticTextWidget(this, font, xpos, ypos, "Controller ID ");
|
||||
const auto* t = new StaticTextWidget(this, font, xpos, ypos, "Controller ID ");
|
||||
xpos += t->getWidth();
|
||||
myJoyText = new EditTextWidget(this, font, xpos, ypos - 2,
|
||||
font.getStringWidth("Unplugged "), lineHeight, "");
|
||||
|
|
|
@ -177,13 +177,13 @@ void QuadTariDialog::defineController(const Properties& props, PropType key,
|
|||
{
|
||||
if(instance().hasConsole())
|
||||
{
|
||||
Controller& controller = (jack == Controller::Jack::Left
|
||||
const Controller& controller = (jack == Controller::Jack::Left
|
||||
? instance().console().leftController()
|
||||
: instance().console().rightController());
|
||||
|
||||
if(BSPF::startsWithIgnoreCase(controller.name(), "QT"))
|
||||
{
|
||||
const QuadTari* qt = static_cast<QuadTari*>(&controller);
|
||||
const auto* qt = static_cast<const QuadTari*>(&controller);
|
||||
label = (first
|
||||
? qt->firstController().name()
|
||||
: qt->secondController().name())
|
||||
|
|
|
@ -89,18 +89,3 @@ bool UndoHandler::redo(string& text)
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||
uInt32 UndoHandler::lastDiff(string_view text, string_view oldText)
|
||||
{
|
||||
auto pos = static_cast<uInt32>(text.size());
|
||||
|
||||
for(auto itn = text.crbegin(), ito = oldText.crbegin();
|
||||
itn != text.crend() && ito != oldText.crend(); ++itn, ++ito)
|
||||
{
|
||||
if(*itn != *ito)
|
||||
break;
|
||||
pos--;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,18 @@ class UndoHandler
|
|||
bool endChars(string_view text);
|
||||
|
||||
// Get index into text of last different character
|
||||
static uInt32 lastDiff(string_view text, string_view oldText);
|
||||
static constexpr uInt32 lastDiff(string_view text, string_view oldText) {
|
||||
auto pos = static_cast<uInt32>(text.size());
|
||||
|
||||
for (auto itn = text.crbegin(), ito = oldText.crbegin();
|
||||
itn != text.crend() && ito != oldText.crend(); ++itn, ++ito)
|
||||
{
|
||||
if (*itn != *ito)
|
||||
break;
|
||||
pos--;
|
||||
}
|
||||
return pos;
|
||||
}
|
||||
|
||||
private:
|
||||
std::deque<string> myBuffer;
|
||||
|
|
|
@ -315,7 +315,7 @@ void VideoAudioDialog::addPaletteTab()
|
|||
CREATE_CUSTOM_SLIDERS(Gamma, "Gamma ", kPaletteUpdated)
|
||||
|
||||
ypos += VGAP;
|
||||
auto* s = new StaticTextWidget(myTab, _font, xpos, ypos + 1, "Autodetection");
|
||||
const auto* s = new StaticTextWidget(myTab, _font, xpos, ypos + 1, "Autodetection");
|
||||
|
||||
myDetectPal60 = new CheckboxWidget(myTab, _font, s->getRight() + fontWidth * 2, ypos + 1, "PAL-60");
|
||||
myDetectPal60 ->setToolTip("Enable autodetection of PAL-60 based on colors used.");
|
||||
|
|
|
@ -40,9 +40,9 @@ FSNodeWINDOWS::FSNodeWINDOWS(string_view p)
|
|||
bool FSNodeWINDOWS::setFlags()
|
||||
{
|
||||
// Get absolute path
|
||||
static TCHAR buf[MAX_PATH];
|
||||
if (GetFullPathName(_path.c_str(), MAX_PATH - 1, buf, NULL))
|
||||
_path = buf;
|
||||
static std::array<TCHAR, MAX_PATH> buf;
|
||||
if (GetFullPathName(_path.c_str(), MAX_PATH - 1, buf.data(), NULL))
|
||||
_path = buf.data();
|
||||
|
||||
_displayName = lastPathComponent(_path);
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ StringList SerialPortWINDOWS::portNames()
|
|||
L"HARDWARE\\DEVICEMAP\\SERIALCOMM", 0, KEY_READ, &hKey);
|
||||
if (result == ERROR_SUCCESS)
|
||||
{
|
||||
TCHAR deviceName[2048], friendlyName[32];
|
||||
TCHAR deviceName[2048]{}, friendlyName[32]{};
|
||||
DWORD numValues = 0;
|
||||
|
||||
result = RegQueryInfoKey(hKey, NULL, NULL, NULL, NULL, NULL, NULL,
|
||||
|
|
Loading…
Reference in New Issue