Various fixes for suggestions from clang-16.

This commit is contained in:
Stephen Anthony 2022-12-29 10:19:14 -03:30
parent 204aafa927
commit a15b56aa1e
19 changed files with 84 additions and 77 deletions

View File

@ -66,7 +66,7 @@ ifdef CLANG_WARNINGS
-Wno-inconsistent-missing-destructor-override -Wno-float-equal \ -Wno-inconsistent-missing-destructor-override -Wno-float-equal \
-Wno-exit-time-destructors -Wno-global-constructors -Wno-weak-vtables \ -Wno-exit-time-destructors -Wno-global-constructors -Wno-weak-vtables \
-Wno-four-char-constants -Wno-padded -Wno-reserved-identifier \ -Wno-four-char-constants -Wno-padded -Wno-reserved-identifier \
-Wno-duplicate-enum -Wno-duplicate-enum -Wno-unsafe-buffer-usage
CXXFLAGS+= $(EXTRA_WARN) CXXFLAGS+= $(EXTRA_WARN)
CFLAGS+= $(EXTRA_WARN) CFLAGS+= $(EXTRA_WARN)

View File

@ -90,7 +90,7 @@ class KeyMap
nlohmann::json saveMapping(const EventMode mode) const; nlohmann::json saveMapping(const EventMode mode) const;
int loadMapping(const nlohmann::json& mapping, const EventMode mode); int loadMapping(const nlohmann::json& mapping, const EventMode mode);
static nlohmann::json convertLegacyMapping(string_view list); static nlohmann::json convertLegacyMapping(string_view lm);
/** Erase all mappings for given mode */ /** Erase all mappings for given mode */
void eraseMode(const EventMode mode); void eraseMode(const EventMode mode);

View File

@ -47,7 +47,7 @@ PhysicalJoystickHandler::PhysicalJoystickHandler(
} }
json mappings; json mappings;
string_view serializedMapping = myOSystem.settings().getString("joymap"); const string_view serializedMapping = myOSystem.settings().getString("joymap");
try { try {
mappings = json::parse(serializedMapping); mappings = json::parse(serializedMapping);

View File

@ -106,7 +106,7 @@ std::size_t TimerManager::size() const noexcept
bool TimerManager::empty() const noexcept bool TimerManager::empty() const noexcept
{ {
const ScopedLock lock(sync); const ScopedLock lock(sync);
return active.empty(); return active.empty(); // NOLINT: bugprone-standalone-empty
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -241,7 +241,7 @@ TimerManager::Timer::Timer(Timer&& r) noexcept
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TimerManager::Timer::Timer(TimerId tid, Timestamp tnext, Duration tperiod, TimerManager::Timer::Timer(TimerId tid, Timestamp tnext, Duration tperiod,
const TFunction& func) noexcept const TFunction& func) noexcept
: id{tid }, : id{tid},
next{tnext}, next{tnext},
period{tperiod}, period{tperiod},
handler{func} handler{func}

View File

@ -131,7 +131,7 @@ uInt64 ZipHandler::decompress(ByteBuffer& image)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string ZipHandler::errorMessage(ZipError err) string ZipHandler::errorMessage(ZipError err)
{ {
static constexpr std::array<const char*, 10> zip_error_s = { static constexpr std::array<string_view, 10> zip_error_s = {
"ZIP NONE", "ZIP NONE",
"ZIP OUT_OF_MEMORY", "ZIP OUT_OF_MEMORY",
"ZIP FILE_ERROR", "ZIP FILE_ERROR",
@ -143,7 +143,7 @@ string ZipHandler::errorMessage(ZipError err)
"ZIP LZMA_UNSUPPORTED", "ZIP LZMA_UNSUPPORTED",
"ZIP BUFFER_TOO_SMALL" "ZIP BUFFER_TOO_SMALL"
}; };
return zip_error_s[static_cast<int>(err)]; return string{zip_error_s[static_cast<int>(err)]};
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -453,7 +453,7 @@ string CartridgeBUSWidget::bankState()
if (myCart.myBUSSubtype == CartridgeBUS::BUSSubtype::BUS0) if (myCart.myBUSSubtype == CartridgeBUS::BUSSubtype::BUS0)
{ {
static constexpr std::array<const char*, 6> spot = { static constexpr std::array<string_view, 6> spot = {
"$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB" "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB"
}; };
buf << "Bank = " << std::dec << myCart.getBank() buf << "Bank = " << std::dec << myCart.getBank()
@ -461,7 +461,7 @@ string CartridgeBUSWidget::bankState()
} }
else else
{ {
static constexpr std::array<const char*, 7> spot = { static constexpr std::array<string_view, 7> spot = {
"$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB" "$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB"
}; };
buf << "Bank = " << std::dec << myCart.getBank() buf << "Bank = " << std::dec << myCart.getBank()

View File

@ -439,7 +439,7 @@ string CartridgeCDFWidget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static constexpr std::array<const char*, 8> spot = { static constexpr std::array<string_view, 8> spot = {
"$FFF4", "$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB" "$FFF4", "$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB"
}; };

View File

@ -93,7 +93,7 @@ string CartridgeCTYWidget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static constexpr std::array<const char*, 8> spot = { static constexpr std::array<string_view, 8> spot = {
"", "$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB" "", "$FFF5", "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB"
}; };
const uInt16 bank = myCart.getBank(); const uInt16 bank = myCart.getBank();

View File

@ -338,7 +338,7 @@ string CartridgeDPCPlusWidget::bankState()
{ {
ostringstream& buf = buffer(); ostringstream& buf = buffer();
static constexpr std::array<const char*, 6> spot = { static constexpr std::array<string_view, 6> spot = {
"$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB" "$FFF6", "$FFF7", "$FFF8", "$FFF9", "$FFFA", "$FFFB"
}; };
buf << "Bank = " << std::dec << myCart.getBank() buf << "Bank = " << std::dec << myCart.getBank()

View File

@ -70,7 +70,7 @@ void CartridgeE7Widget::initialize(GuiObject* boss,
VariantList items0, items1; VariantList items0, items1;
for(int i = 0; i < cart.romBankCount(); ++i) for(int i = 0; i < cart.romBankCount(); ++i)
VarList::push_back(items0, getSpotLower(i)); VarList::push_back(items0, getSpotLower(i, myCart.romBankCount()));
for(int i = 0; i < 4; ++i) for(int i = 0; i < 4; ++i)
VarList::push_back(items1, getSpotUpper(i)); VarList::push_back(items1, getSpotUpper(i));
@ -139,7 +139,7 @@ string CartridgeE7Widget::bankState()
ostringstream& buf = buffer(); ostringstream& buf = buffer();
buf << "Segments: " << std::dec buf << "Segments: " << std::dec
<< getSpotLower(myCart.myCurrentBank[0]) << " / " << getSpotLower(myCart.myCurrentBank[0], myCart.romBankCount()) << " / "
<< getSpotUpper(myCart.myCurrentRAM); << getSpotUpper(myCart.myCurrentRAM);
return buf.str(); return buf.str();
@ -202,7 +202,7 @@ uInt8 CartridgeE7Widget::internalRamGetValue(int addr)
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string_view CartridgeE7Widget::getSpotLower(int idx) const string_view CartridgeE7Widget::getSpotLower(int idx, int bankcount)
{ {
static constexpr std::array<string_view, 4> spot_lower_8K = { static constexpr std::array<string_view, 4> spot_lower_8K = {
"#0 - ROM ($FFE4)", "#1 - ROM ($FFE5)", "#2 - ROM ($FFE6)", "#3 - RAM ($FFE7)" "#0 - ROM ($FFE4)", "#1 - ROM ($FFE5)", "#2 - ROM ($FFE6)", "#3 - RAM ($FFE7)"
@ -216,16 +216,16 @@ string_view CartridgeE7Widget::getSpotLower(int idx) const
"#4 - ROM ($FFE4)", "#5 - ROM ($FFE5)", "#6 - ROM ($FFE6)", "#7 - RAM ($FFE7)" "#4 - ROM ($FFE4)", "#5 - ROM ($FFE5)", "#6 - ROM ($FFE6)", "#7 - RAM ($FFE7)"
}; };
return myCart.romBankCount() == 4 return bankcount == 4
? spot_lower_8K[idx] ? spot_lower_8K[idx]
: myCart.romBankCount() == 6 : bankcount == 6
? spot_lower_12K[idx] ? spot_lower_12K[idx]
: spot_lower_16K[idx]; : spot_lower_16K[idx];
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string_view CartridgeE7Widget::getSpotUpper(int idx) const string_view CartridgeE7Widget::getSpotUpper(int idx)
{ {
static constexpr std::array<string_view, 4> spot_upper = { static constexpr std::array<string_view, 4> spot_upper = {
"#0 - RAM ($FFE8)", "#1 - RAM ($FFE9)", "#2 - RAM ($FFEA)", "#3 - RAM ($FFEB)" "#0 - RAM ($FFE8)", "#1 - RAM ($FFE9)", "#2 - RAM ($FFEA)", "#3 - RAM ($FFEB)"

View File

@ -54,8 +54,6 @@ class CartridgeE7Widget : public CartDebugWidget
protected: protected:
void initialize(GuiObject* boss, const CartridgeE7& cart, void initialize(GuiObject* boss, const CartridgeE7& cart,
const ostringstream& info); const ostringstream& info);
string_view getSpotLower(int idx) const;
string_view getSpotUpper(int idx) const;
private: private:
void saveOldState() override; void saveOldState() override;
@ -72,6 +70,9 @@ class CartridgeE7Widget : public CartDebugWidget
uInt8 internalRamGetValue(int addr) override; uInt8 internalRamGetValue(int addr) override;
// end of functions for Cartridge RAM tab // end of functions for Cartridge RAM tab
static string_view getSpotLower(int idx, int bankcount);
static string_view getSpotUpper(int idx);
private: private:
// Following constructors and assignment operators not supported // Following constructors and assignment operators not supported
CartridgeE7Widget() = delete; CartridgeE7Widget() = delete;

View File

@ -125,14 +125,14 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont,
CREATE_IO_REGS("SWCHB(R)", mySWCHBReadBits, kSWCHBRBitsID, true) CREATE_IO_REGS("SWCHB(R)", mySWCHBReadBits, kSWCHBRBitsID, true)
// Timer registers (R/W) // Timer registers (R/W)
static constexpr std::array<const char*, 4> writeNames = { static constexpr std::array<string_view, 4> writeNames = {
"TIM1T", "TIM8T", "TIM64T", "T1024T" "TIM1T", "TIM8T", "TIM64T", "T1024T"
}; };
ypos += _lineHeight + vGap * 4; ypos += _lineHeight + vGap * 4;
for(int row = 0; row < 4; ++row) for(int row = 0; row < 4; ++row)
{ {
myTimWriteLabel[row] = new StaticTextWidget(boss, lfont, hBorder, ypos + row * _lineHeight + 2, myTimWriteLabel[row] = new StaticTextWidget(boss, lfont, hBorder,
writeNames[row]); ypos + row * _lineHeight + 2, writeNames[row]);
} }
xpos = hBorder + lwidth; xpos = hBorder + lwidth;
myTimWrite = new DataGridWidget(boss, nfont, xpos, ypos, 1, 4, 2, 8, Common::Base::Fmt::_16); myTimWrite = new DataGridWidget(boss, nfont, xpos, ypos, 1, 4, 2, 8, Common::Base::Fmt::_16);
@ -150,14 +150,14 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont,
myTimAvail->setEditable(false); myTimAvail->setEditable(false);
// Timer registers (RO) // Timer registers (RO)
static constexpr std::array<const char*, 3> readNames = { static constexpr std::array<string_view, 3> readNames = {
"INTIM", " Clocks", "TIMINT" "INTIM", " Clocks", "TIMINT"
}; };
ypos = myTimWrite->getBottom() + _lineHeight / 2; ypos = myTimWrite->getBottom() + _lineHeight / 2;
for(int row = 0; row < 3; ++row) for(int row = 0; row < 3; ++row)
{ {
t = new StaticTextWidget(boss, lfont, hBorder, ypos + row * _lineHeight + 2, new StaticTextWidget(boss, lfont, hBorder, ypos + row * _lineHeight + 2,
readNames[row]); readNames[row]);
} }
xpos = hBorder + lwidth; xpos = hBorder + lwidth;
myTimRead = new DataGridWidget(boss, nfont, xpos, ypos, 1, 3, 2, 30, Common::Base::Fmt::_16); myTimRead = new DataGridWidget(boss, nfont, xpos, ypos, 1, 3, 2, 30, Common::Base::Fmt::_16);
@ -181,7 +181,7 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont,
// Controller ports // Controller ports
int col = mySWCHAWriteBits->getRight() + hGap * 2.5; const int col = mySWCHAWriteBits->getRight() + hGap * 2.5;
xpos = col; ypos = vBorder; xpos = col; ypos = vBorder;
myLeftControl = addControlWidget(boss, lfont, xpos, ypos, myLeftControl = addControlWidget(boss, lfont, xpos, ypos,
instance().console().leftController()); instance().console().leftController());
@ -192,14 +192,14 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont,
addToFocusList(myRightControl->getFocusList()); addToFocusList(myRightControl->getFocusList());
// TIA INPTx registers (R), left port // TIA INPTx registers (R), left port
static constexpr std::array<const char*, 3> contLeftReadNames = { static constexpr std::array<string_view, 3> contLeftReadNames = {
"INPT0", "INPT1", "INPT4" "INPT0", "INPT1", "INPT4"
}; };
xpos = myLeftControl->getLeft(); ypos += myLeftControl->getHeight() + 2 * _lineHeight; xpos = myLeftControl->getLeft(); ypos += myLeftControl->getHeight() + 2 * _lineHeight;
for(int row = 0; row < 3; ++row) for(int row = 0; row < 3; ++row)
{ {
t = new StaticTextWidget(boss, lfont, xpos, ypos + row * _lineHeight + 2, t = new StaticTextWidget(boss, lfont, xpos, ypos + row * _lineHeight + 2,
contLeftReadNames[row]); contLeftReadNames[row]);
} }
xpos = t->getRight() + hGap; xpos = t->getRight() + hGap;
myLeftINPT = new DataGridWidget(boss, nfont, xpos, ypos, 1, 3, 2, 8, Common::Base::Fmt::_16); myLeftINPT = new DataGridWidget(boss, nfont, xpos, ypos, 1, 3, 2, 8, Common::Base::Fmt::_16);
@ -207,14 +207,14 @@ RiotWidget::RiotWidget(GuiObject* boss, const GUI::Font& lfont,
myLeftINPT->setEditable(false); myLeftINPT->setEditable(false);
// TIA INPTx registers (R), right port // TIA INPTx registers (R), right port
static constexpr std::array<const char*, 3> contRightReadNames = { static constexpr std::array<string_view, 3> contRightReadNames = {
"INPT2", "INPT3", "INPT5" "INPT2", "INPT3", "INPT5"
}; };
xpos = myRightControl->getLeft(); xpos = myRightControl->getLeft();
for(int row = 0; row < 3; ++row) for(int row = 0; row < 3; ++row)
{ {
t = new StaticTextWidget(boss, lfont, xpos, ypos + row*_lineHeight + 2, t = new StaticTextWidget(boss, lfont, xpos, ypos + row*_lineHeight + 2,
contRightReadNames[row]); contRightReadNames[row]);
} }
xpos = t->getRight() + hGap; xpos = t->getRight() + hGap;
myRightINPT = new DataGridWidget(boss, nfont, xpos, ypos, 1, 3, 2, 8, Common::Base::Fmt::_16); myRightINPT = new DataGridWidget(boss, nfont, xpos, ypos, 1, 3, 2, 8, Common::Base::Fmt::_16);

View File

@ -48,7 +48,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& lfont,
vGap = fontHeight / 2, vGap = fontHeight / 2,
hBorder = 10, hBorder = 10,
vBorder = 10; vBorder = 10;
int xpos = hBorder, ypos = vBorder, buttonX, buttonY; int xpos = hBorder, ypos = vBorder;
StaticTextWidget* t = nullptr; StaticTextWidget* t = nullptr;
ButtonWidget* b = nullptr; ButtonWidget* b = nullptr;
@ -56,7 +56,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& lfont,
//////////////////////////// ////////////////////////////
// VSync/VBlank // VSync/VBlank
//////////////////////////// ////////////////////////////
buttonX = xpos; buttonY = ypos; int buttonX = xpos, buttonY = ypos;
myVSync = new CheckboxWidget(boss, lfont, buttonX, buttonY, "VSync", kVSyncCmd); myVSync = new CheckboxWidget(boss, lfont, buttonX, buttonY, "VSync", kVSyncCmd);
myVSync->setTarget(this); myVSync->setTarget(this);
addFocusWidget(myVSync); addFocusWidget(myVSync);
@ -68,7 +68,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& lfont,
// Color registers // Color registers
ypos = vBorder + lineHeight * 2 + vGap / 2; ypos = vBorder + lineHeight * 2 + vGap / 2;
static constexpr std::array<const char*, 4> regNames = { static constexpr std::array<string_view, 4> regNames = {
"COLUP0", "COLUP1", "COLUPF", "COLUBK" "COLUP0", "COLUP1", "COLUPF", "COLUBK"
}; };
for(int row = 0; row < 4; ++row) for(int row = 0; row < 4; ++row)
@ -108,7 +108,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& lfont,
myFixedEnabled->setTarget(this); myFixedEnabled->setTarget(this);
addFocusWidget(myFixedEnabled); addFocusWidget(myFixedEnabled);
static constexpr std::array<const char*, 8> dbgLabels = { static constexpr std::array<string_view, 8> dbgLabels = {
"P0", "P1", "PF", "BK", "M0", "M1", "BL", "HM" "P0", "P1", "PF", "BK", "M0", "M1", "BL", "HM"
}; };
for(uInt32 row = 0; row <= 3; ++row) for(uInt32 row = 0; row <= 3; ++row)
@ -136,8 +136,8 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& lfont,
xpos = myFixedColors[4]->getRight() + 6 * hGap; ypos = vBorder + lineHeight; xpos = myFixedColors[4]->getRight() + 6 * hGap; ypos = vBorder + lineHeight;
// Add all 15 collision bits (with labels) // Add all 15 collision bits (with labels)
static constexpr std::array<const char*, 5> rowLabel = { "P0", "P1", "M0", "M1", "BL" }; static constexpr std::array<string_view, 5> rowLabel = { "P0", "P1", "M0", "M1", "BL" };
static constexpr std::array<const char*, 5> colLabel = { "PF", "BL", "M1", "M0", "P1" }; static constexpr std::array<string_view, 5> colLabel = { "PF", "BL", "M1", "M0", "P1" };
int idx = 0; int idx = 0;
for(uInt32 row = 0; row < 5; ++row) for(uInt32 row = 0; row < 5; ++row)
{ {
@ -154,7 +154,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& lfont,
if(row == 0) if(row == 0)
{ {
// Add centered horizontal label // Add centered horizontal label
int labelx = collX - (2 * fontWidth - myCollision[idx]->getWidth()) / 2; const int labelx = collX - (2 * fontWidth - myCollision[idx]->getWidth()) / 2;
new StaticTextWidget(boss, lfont, labelx, ypos - lineHeight, colLabel[col]); new StaticTextWidget(boss, lfont, labelx, ypos - lineHeight, colLabel[col]);
} }
collX += fontWidth * 2 + hGap; collX += fontWidth * 2 + hGap;
@ -473,7 +473,7 @@ TiaWidget::TiaWidget(GuiObject* boss, const GUI::Font& lfont,
const GUI::Font& sf = instance().frameBuffer().smallFont(); const GUI::Font& sf = instance().frameBuffer().smallFont();
const int sfWidth = sf.getMaxCharWidth(), const int sfWidth = sf.getMaxCharWidth(),
sfHeight = sf.getFontHeight(); sfHeight = sf.getFontHeight();
static constexpr std::array<const char*, 8> bitNames = { static constexpr std::array<string_view, 8> bitNames = {
"0", "1", "2", "3", "4", "5", "6", "7" "0", "1", "2", "3", "4", "5", "6", "7"
}; };

View File

@ -25,8 +25,21 @@ namespace YaccParser {
#include <cctype> #include <cctype>
#include "y.tab.h" #include "y.tab.h"
static YYSTYPE result;
static string errMsg; enum class State {
DEFAULT,
IDENTIFIER,
OPERATOR,
SPACE
};
namespace {
YYSTYPE result;
string errMsg;
State state = State::DEFAULT;
const char *input, *c;
} // namespace
void yyerror(const char* e); void yyerror(const char* e);
@ -41,15 +54,6 @@ void yyerror(const char* e);
#include "y.tab.c" #include "y.tab.c"
#endif #endif
enum class State {
DEFAULT,
IDENTIFIER,
OPERATOR,
SPACE
};
static State state = State::DEFAULT;
static const char *input, *c;
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
const string& errorMessage() const string& errorMessage()

View File

@ -28,21 +28,22 @@
#include "CartBUS.hxx" #include "CartBUS.hxx"
#include "exception/FatalEmulationError.hxx" #include "exception/FatalEmulationError.hxx"
// Location of data within the RAM copy of the BUS Driver. namespace {
static constexpr int // Location of data within the RAM copy of the BUS Driver.
constexpr int
COMMSTREAM = 0x10, COMMSTREAM = 0x10,
JUMPSTREAM = 0x11; JUMPSTREAM = 0x11;
static constexpr bool BUS_STUFF_ON(uInt8 mode) { return (mode & 0x0F) == 0; } constexpr bool BUS_STUFF_ON(uInt8 mode) { return (mode & 0x0F) == 0; }
static constexpr bool DIGITAL_AUDIO_ON(uInt8 mode) { return (mode & 0xF0) == 0; } constexpr bool DIGITAL_AUDIO_ON(uInt8 mode) { return (mode & 0xF0) == 0; }
static constexpr uInt32 getUInt32(const uInt8* _array, size_t _address) {
return static_cast<uInt32>((_array)[(_address) + 0] +
((_array)[(_address) + 1] << 8) +
((_array)[(_address) + 2] << 16) +
((_array)[(_address) + 3] << 24));
}
constexpr uInt32 getUInt32(const uInt8* _array, size_t _address) {
return static_cast<uInt32>((_array)[(_address) + 0] +
((_array)[(_address) + 1] << 8) +
((_array)[(_address) + 2] << 16) +
((_array)[(_address) + 3] << 24));
}
} // namespace
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
CartridgeBUS::CartridgeBUS(const ByteBuffer& image, size_t size, CartridgeBUS::CartridgeBUS(const ByteBuffer& image, size_t size,

View File

@ -28,17 +28,17 @@
#include "TIA.hxx" #include "TIA.hxx"
#include "exception/FatalEmulationError.hxx" #include "exception/FatalEmulationError.hxx"
static constexpr bool FAST_FETCH_ON(uInt8 mode) { return (mode & 0x0F) == 0; }
static constexpr bool DIGITAL_AUDIO_ON(uInt8 mode) { return (mode & 0xF0) == 0; }
static constexpr uInt32 getUInt32(const uInt8* _array, size_t _address) {
return static_cast<uInt32>((_array)[(_address) + 0] +
((_array)[(_address) + 1] << 8) +
((_array)[(_address) + 2] << 16) +
((_array)[(_address) + 3] << 24));
}
namespace { namespace {
constexpr bool FAST_FETCH_ON(uInt8 mode) { return (mode & 0x0F) == 0; }
constexpr bool DIGITAL_AUDIO_ON(uInt8 mode) { return (mode & 0xF0) == 0; }
constexpr uInt32 getUInt32(const uInt8* _array, size_t _address) {
return static_cast<uInt32>((_array)[(_address) + 0] +
((_array)[(_address) + 1] << 8) +
((_array)[(_address) + 2] << 16) +
((_array)[(_address) + 3] << 24));
}
Thumbulator::ConfigureFor thumulatorConfiguration(CartridgeCDF::CDFSubtype subtype) Thumbulator::ConfigureFor thumulatorConfiguration(CartridgeCDF::CDFSubtype subtype)
{ {
switch (subtype) { switch (subtype) {

View File

@ -378,7 +378,7 @@ static constexpr uInt8 scale9[16] = {
static constexpr uInt8 scale10[16] = { static constexpr uInt8 scale10[16] = {
0, 0, 0, 0, 0, 1, 3, 6, 9, 12, 14, 15, 15, 15, 15, 15 /* 2.7778 */ 0, 0, 0, 0, 0, 1, 3, 6, 9, 12, 14, 15, 15, 15, 15, 15 /* 2.7778 */
}; };
static const uInt8* scales[11] = { static constexpr const uInt8* const scales[11] = {
scale0, scale1, scale2, scale3, scale4, scale5, scale0, scale1, scale2, scale3, scale4, scale5,
scale6, scale7, scale8, scale9, scale10 scale6, scale7, scale8, scale9, scale10
}; };

View File

@ -105,7 +105,8 @@ bool Controller::load(Serializer& in)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Controller::getName(const Type type) string Controller::getName(const Type type)
{ {
static constexpr std::array<const char*, static_cast<int>(Controller::Type::LastType)> NAMES = static constexpr std::array<string_view,
static_cast<int>(Controller::Type::LastType)> NAMES =
{ {
"Unknown", "Unknown",
"Amiga mouse", "Atari mouse", "AtariVox", "Booster Grip", "CompuMate", "Amiga mouse", "Atari mouse", "AtariVox", "Booster Grip", "CompuMate",
@ -114,13 +115,13 @@ string Controller::getName(const Type type)
"Light Gun", "QuadTari", "Joy 2B+" "Light Gun", "QuadTari", "Joy 2B+"
}; };
return NAMES[static_cast<int>(type)]; return string{NAMES[static_cast<int>(type)]};
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
string Controller::getPropName(const Type type) string Controller::getPropName(const Type type)
{ {
static constexpr std::array<const char*, static constexpr std::array<string_view,
static_cast<int>(Controller::Type::LastType)> PROP_NAMES = static_cast<int>(Controller::Type::LastType)> PROP_NAMES =
{ {
"AUTO", "AUTO",
@ -130,7 +131,7 @@ string Controller::getPropName(const Type type)
"LIGHTGUN", "QUADTARI", "JOY_2B+" "LIGHTGUN", "QUADTARI", "JOY_2B+"
}; };
return PROP_NAMES[static_cast<int>(type)]; return string{PROP_NAMES[static_cast<int>(type)]};
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

View File

@ -49,7 +49,7 @@ Serializer::Serializer(string_view filename, Mode m)
// So we open in write and append mode - the write creates the file // So we open in write and append mode - the write creates the file
// when necessary, and the append doesn't delete any data if it // when necessary, and the append doesn't delete any data if it
// already exists // already exists
string f{filename}; const string f{filename};
fstream temp(f, ios::out | ios::app); fstream temp(f, ios::out | ios::app);
temp.close(); temp.close();