diff --git a/src/emucore/Console.cxx b/src/emucore/Console.cxx index fca244bde..9387509be 100644 --- a/src/emucore/Console.cxx +++ b/src/emucore/Console.cxx @@ -469,11 +469,11 @@ void Console::setPalette(const string& type) { // Look at all the palettes, since we don't know which one is // currently active - static constexpr PaletteArray* palettes[3][3] = { + static constexpr BSPF::array2D palettes = {{ { &ourNTSCPalette, &ourPALPalette, &ourSECAMPalette }, { &ourNTSCPaletteZ26, &ourPALPaletteZ26, &ourSECAMPaletteZ26 }, { &ourUserNTSCPalette, &ourUserPALPalette, &ourUserSECAMPalette } - }; + }}; // See which format we should be using int paletteNum = 0; @@ -906,25 +906,25 @@ void Console::loadUserPalette() } // Now that we have valid data, create the user-defined palettes - uInt8 pixbuf[3]; // Temporary buffer for one 24-bit pixel + std::array pixbuf; // Temporary buffer for one 24-bit pixel for(int i = 0; i < 128; i++) // NTSC palette { - in.read(reinterpret_cast(pixbuf), 3); + in.read(reinterpret_cast(pixbuf.data()), 3); uInt32 pixel = (int(pixbuf[0]) << 16) + (int(pixbuf[1]) << 8) + int(pixbuf[2]); ourUserNTSCPalette[(i<<1)] = pixel; } for(int i = 0; i < 128; i++) // PAL palette { - in.read(reinterpret_cast(pixbuf), 3); + in.read(reinterpret_cast(pixbuf.data()), 3); uInt32 pixel = (int(pixbuf[0]) << 16) + (int(pixbuf[1]) << 8) + int(pixbuf[2]); ourUserPALPalette[(i<<1)] = pixel; } - uInt32 secam[16]; // All 8 24-bit pixels, plus 8 colorloss pixels - for(int i = 0; i < 8; i++) // SECAM palette + std::array secam; // All 8 24-bit pixels, plus 8 colorloss pixels + for(int i = 0; i < 8; i++) // SECAM palette { - in.read(reinterpret_cast(pixbuf), 3); + in.read(reinterpret_cast(pixbuf.data()), 3); uInt32 pixel = (int(pixbuf[0]) << 16) + (int(pixbuf[1]) << 8) + int(pixbuf[2]); secam[(i<<1)] = pixel; secam[(i<<1)+1] = 0; @@ -932,7 +932,7 @@ void Console::loadUserPalette() uInt32* ptr = ourUserSECAMPalette.data(); for(int i = 0; i < 16; ++i) { - uInt32* s = secam; + const uInt32* s = secam.data(); for(int j = 0; j < 16; ++j) *ptr++ = *s++; } @@ -945,16 +945,16 @@ void Console::generateColorLossPalette() { // Look at all the palettes, since we don't know which one is // currently active - uInt32* palette[9] = { - &ourNTSCPalette[0], &ourPALPalette[0], &ourSECAMPalette[0], - &ourNTSCPaletteZ26[0], &ourPALPaletteZ26[0], &ourSECAMPaletteZ26[0], + std::array palette = { + ourNTSCPalette.data(), ourPALPalette.data(), ourSECAMPalette.data(), + ourNTSCPaletteZ26.data(), ourPALPaletteZ26.data(), ourSECAMPaletteZ26.data(), nullptr, nullptr, nullptr }; if(myUserPaletteDefined) { - palette[6] = &ourUserNTSCPalette[0]; - palette[7] = &ourUserPALPalette[0]; - palette[8] = &ourUserSECAMPalette[0]; + palette[6] = ourUserNTSCPalette.data(); + palette[7] = ourUserPALPalette.data(); + palette[8] = ourUserSECAMPalette.data(); } for(int i = 0; i < 9; ++i) @@ -966,11 +966,11 @@ void Console::generateColorLossPalette() // using the standard RGB -> grayscale conversion formula) for(int j = 0; j < 128; ++j) { - uInt32 pixel = palette[i][(j<<1)]; - uInt8 r = (pixel >> 16) & 0xff; - uInt8 g = (pixel >> 8) & 0xff; - uInt8 b = (pixel >> 0) & 0xff; - uInt8 sum = uInt8((r * 0.2989) + (g * 0.5870) + (b * 0.1140)); + const uInt32 pixel = palette[i][(j<<1)]; + const uInt8 r = (pixel >> 16) & 0xff; + const uInt8 g = (pixel >> 8) & 0xff; + const uInt8 b = (pixel >> 0) & 0xff; + const uInt8 sum = static_cast((r * 0.2989) + (g * 0.5870) + (b * 0.1140)); palette[i][(j<<1)+1] = (sum << 16) + (sum << 8) + sum; } } @@ -980,7 +980,7 @@ void Console::generateColorLossPalette() float Console::getFramerate() const { return - (myConsoleTiming == ConsoleTiming::ntsc ? 262.f * 60.f : 312.f * 50.f) / + (myConsoleTiming == ConsoleTiming::ntsc ? 262.F * 60.F : 312.F * 50.F) / myTIA->frameBufferScanlinesLastFrame(); } diff --git a/src/emucore/FrameBuffer.cxx b/src/emucore/FrameBuffer.cxx index 191bc4e58..c78712ca4 100644 --- a/src/emucore/FrameBuffer.cxx +++ b/src/emucore/FrameBuffer.cxx @@ -387,7 +387,7 @@ void FrameBuffer::update(bool force) // indicates that, and then the code at the top of this method sees // the change and redraws everything if(myMsg.enabled) - force = force || drawMessage(); + drawMessage(); // Push buffers to screen only when necessary if(force) diff --git a/src/emucore/TIASurface.cxx b/src/emucore/TIASurface.cxx index e99df7f7f..fede32436 100644 --- a/src/emucore/TIASurface.cxx +++ b/src/emucore/TIASurface.cxx @@ -55,13 +55,13 @@ TIASurface::TIASurface(OSystem& system) // Generate scanline data, and a pre-defined scanline surface constexpr uInt32 scanHeight = TIAConstants::frameBufferHeight * 2; - uInt32 scanData[scanHeight]; + std::array scanData; for(uInt32 i = 0; i < scanHeight; i += 2) { scanData[i] = 0x00000000; scanData[i+1] = 0xff000000; } - mySLineSurface = myFB.allocateSurface(1, scanHeight, interpolationModeFromSettings(myOSystem.settings()), scanData); + mySLineSurface = myFB.allocateSurface(1, scanHeight, interpolationModeFromSettings(myOSystem.settings()), scanData.data()); // Base TIA surface for use in taking snapshots in 1x mode myBaseTiaSurface = myFB.allocateSurface(TIAConstants::frameBufferWidth*2, diff --git a/src/gui/StellaFont.hxx b/src/gui/StellaFont.hxx index a877fa327..1c33a526e 100644 --- a/src/gui/StellaFont.hxx +++ b/src/gui/StellaFont.hxx @@ -40,7 +40,7 @@ namespace GUI { // Font character bitmap data. -static const uInt16 stella_font_bits[] = { +static const uInt16 stella_font_bits[] = { // NOLINT : too complicated to convert /* Character 29 (0x1d): width 6 diff --git a/src/gui/StellaLargeFont.hxx b/src/gui/StellaLargeFont.hxx index 2cfdec47d..c4935811c 100644 --- a/src/gui/StellaLargeFont.hxx +++ b/src/gui/StellaLargeFont.hxx @@ -40,7 +40,7 @@ namespace GUI { // Font character bitmap data. -static const uInt16 stellaLarge_font_bits[] = { +static const uInt16 stellaLarge_font_bits[] = { // NOLINT : too complicated to convert /* MODIFIED Character 29 (0x1d):