From 46453edd8c4a739bb6bb2f8f7fcf5b8b1ec37a96 Mon Sep 17 00:00:00 2001 From: toxieainc Date: Wed, 2 Oct 2024 20:55:24 +0200 Subject: [PATCH 1/3] address mostly harmless things found by static analysis --- Src/BlockFile.h | 2 +- Src/CPU/PowerPC/PPCDisasm.cpp | 14 +++--- Src/CPU/PowerPC/PPCDisasm.h | 2 + Src/CPU/PowerPC/ppc.cpp | 15 +++--- Src/GameLoader.cpp | 12 ++--- Src/GameLoader.h | 2 - Src/Graphics/Legacy3D/Legacy3D.cpp | 23 +++++---- Src/Graphics/Legacy3D/Models.cpp | 25 ++++------ Src/Graphics/Legacy3D/Shaders3D.h | 6 +-- Src/Graphics/Legacy3D/TextureRefs.cpp | 5 +- Src/Graphics/New3D/Model.h | 1 - Src/Graphics/New3D/New3D.h | 1 + Src/Graphics/New3D/R3DFrameBuffers.h | 1 - Src/Graphics/Render2D.cpp | 2 +- Src/Graphics/Render2D.h | 4 +- Src/Graphics/Shaders2D.h | 6 +-- Src/Inputs/InputSource.cpp | 3 +- Src/Inputs/InputSystem.cpp | 6 +-- Src/Inputs/InputTypes.cpp | 2 +- Src/Inputs/Inputs.cpp | 10 ++-- Src/Inputs/MultiInputSource.cpp | 3 +- Src/Model3/53C810.h | 10 ++-- Src/Model3/Crypto.h | 4 +- Src/Model3/DSB.cpp | 9 ++-- Src/Model3/DriveBoard/DriveBoard.cpp | 2 +- Src/Model3/DriveBoard/JoystickBoard.cpp | 3 +- Src/Model3/DriveBoard/SkiBoard.h | 2 +- Src/Model3/DriveBoard/WheelBoard.cpp | 2 +- Src/Model3/JTAG.cpp | 14 +++--- Src/Model3/MPC10x.cpp | 4 +- Src/Model3/Model3.cpp | 64 +++++++++++++------------ Src/Model3/Model3.h | 6 +-- Src/Model3/Real3D.cpp | 6 +-- Src/Model3/Real3D.h | 10 ++-- Src/Model3/SoundBoard.h | 1 - Src/Model3/TileGen.cpp | 12 ++--- Src/Model3/TileGen.h | 4 +- Src/Network/NetBoard.cpp | 8 ++-- Src/Network/NetBoard.h | 4 +- Src/Network/SimNetBoard.cpp | 36 +++++++------- Src/Network/TCPReceive.cpp | 2 +- Src/Network/TCPSend.cpp | 2 - Src/OSD/Logger.cpp | 6 +-- Src/OSD/Logger.h | 8 ++-- Src/OSD/SDL/Audio.cpp | 59 +++++++++++------------ Src/OSD/SDL/Crosshair.h | 2 +- Src/OSD/SDL/Main.cpp | 44 ++++++++--------- Src/OSD/SDL/SDLInputSystem.cpp | 4 +- Src/OSD/Windows/DirectInputSystem.cpp | 15 +++--- Src/OSD/Windows/WinOutputs.cpp | 2 +- Src/Pkgs/unzip.c | 2 +- Src/Sound/MPEG/MpegAudio.cpp | 4 +- Src/Sound/SCSP.cpp | 22 ++++----- Src/Sound/SCSPDSP.cpp | 7 +-- Src/Sound/SCSPLFO.cpp | 6 +-- Src/Util/BMPFile.h | 20 ++++---- Src/Util/BitCast.h | 14 +++--- Src/Util/Format.cpp | 2 +- Src/Util/GenericValue.h | 6 +-- Src/Util/NewConfig.cpp | 2 +- Src/Util/NewConfig.h | 1 - 61 files changed, 277 insertions(+), 299 deletions(-) diff --git a/Src/BlockFile.h b/Src/BlockFile.h index e31b5975..69be96d2 100644 --- a/Src/BlockFile.h +++ b/Src/BlockFile.h @@ -132,7 +132,7 @@ class CBlockFile * name Block name. Must be unique and not NULL. * comment Comment string to embed in the block header. */ - void NewBlock(const std::string &title, const std::string &comment); + void NewBlock(const std::string &name, const std::string &comment); /* * Create(file, headerName, comment): diff --git a/Src/CPU/PowerPC/PPCDisasm.cpp b/Src/CPU/PowerPC/PPCDisasm.cpp index 2ab6e8bc..89dce06c 100644 --- a/Src/CPU/PowerPC/PPCDisasm.cpp +++ b/Src/CPU/PowerPC/PPCDisasm.cpp @@ -655,7 +655,7 @@ static bool Simplified(uint32_t op, uint32_t vpc, char *signed16, char *mnem, ch sprintf(oprs, "r%d,r%d", G_RA(op), G_RT(op)); } else - return 0; + return false; } else if ((op & ~(M_RT|M_RA|M_RB|M_RC)) == (D_OP(31)|D_XO(124))) { @@ -666,7 +666,7 @@ static bool Simplified(uint32_t op, uint32_t vpc, char *signed16, char *mnem, ch sprintf(oprs, "r%d,r%d", G_RA(op), G_RT(op)); } else - return 0; + return false; } else if ((op & ~(M_RT|M_RA|M_SIMM)) == D_OP(14)) { @@ -676,7 +676,7 @@ static bool Simplified(uint32_t op, uint32_t vpc, char *signed16, char *mnem, ch sprintf(oprs, "r%d,0x%08X", G_RT(op), value); } else - return 0; + return false; } else if ((op & ~(M_RT|M_RA|M_SIMM)) == D_OP(15)) { @@ -757,7 +757,7 @@ static bool Simplified(uint32_t op, uint32_t vpc, char *signed16, char *mnem, ch strcat(mnem, "bt"); break; default: - return 0; + return false; } if (op & M_LK) strcat(mnem, "l"); @@ -780,8 +780,8 @@ static bool Simplified(uint32_t op, uint32_t vpc, char *signed16, char *mnem, ch sprintf(oprs, "r%d,r%d,r%d", G_RT(op), G_RB(op), G_RA(op)); } else - return 0; // no match - return 1; + return false; // no match + return true; } /* @@ -821,7 +821,7 @@ Result DisassemblePowerPC(uint32_t op, uint32_t vpc, char *mnem, char *oprs, * Decode signed 16-bit fields (SIMM and d) to spare us the work later */ - DecodeSigned16(signed16, op, 0); + DecodeSigned16(signed16, op, false); /* * Try simplified forms first, then real instructions diff --git a/Src/CPU/PowerPC/PPCDisasm.h b/Src/CPU/PowerPC/PPCDisasm.h index 4220a818..5d0188e6 100644 --- a/Src/CPU/PowerPC/PPCDisasm.h +++ b/Src/CPU/PowerPC/PPCDisasm.h @@ -28,6 +28,8 @@ #ifndef INCLUDED_PPCDISASM_H #define INCLUDED_PPCDISASM_H +#include "Types.h" + /* * DisassemblePowerPC(op, vpc, mnem, oprs, simplify): * diff --git a/Src/CPU/PowerPC/ppc.cpp b/Src/CPU/PowerPC/ppc.cpp index 80365d51..cff750da 100644 --- a/Src/CPU/PowerPC/ppc.cpp +++ b/Src/CPU/PowerPC/ppc.cpp @@ -117,12 +117,12 @@ static UINT32 ppc_field_xlat[256]; -#define BITMASK_0(n) (UINT32)(((UINT64)1 << n) - 1) -#define CRBIT(x) ((ppc.cr[x / 4] & (1 << (3 - (x % 4)))) ? 1 : 0) +#define BITMASK_0(n) (UINT32)(((UINT64)1 << (n)) - 1) +#define CRBIT(x) ((ppc.cr[(x) / 4] & (1 << (3 - ((x) % 4)))) ? 1 : 0) #define _BIT(n) (1 << (n)) #define GET_ROTATE_MASK(mb,me) (ppc_rotate_mask[mb][me]) -#define ADD_CA(r,a,b) ((UINT32)r < (UINT32)a) -#define SUB_CA(r,a,b) (!((UINT32)a < (UINT32)b)) +#define ADD_CA(r,a,b) ((UINT32)(r) < (UINT32)(a)) +#define SUB_CA(r,a,b) (!((UINT32)(a) < (UINT32)(b))) #define ADD_OV(r,a,b) ((~((a) ^ (b)) & ((a) ^ (r))) & 0x80000000) #define SUB_OV(r,a,b) (( ((a) ^ (b)) & ((a) ^ (r))) & 0x80000000) @@ -154,8 +154,8 @@ static UINT32 ppc_field_xlat[256]; #define TSR_ENW 0x80000000 #define TSR_WIS 0x40000000 -#define BYTE_REVERSE16(x) (((x >> 8) | (x << 8)) & 0xFFFF) -#define BYTE_REVERSE32(x) ((x >> 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x << 24)) +#define BYTE_REVERSE16(x) ((((x) >> 8) | ((x) << 8)) & 0xFFFF) +#define BYTE_REVERSE32(x) (((x) >> 24) | (((x) << 8) & 0x00FF0000) | (((x) >> 8) & 0x0000FF00) | ((x) << 24)) typedef union { UINT64 id; @@ -714,10 +714,9 @@ void ppc_base_init(void) /* Calculate rotate mask table */ for( i=0; i < 32; i++ ) { for( j=0; j < 32; j++ ) { - UINT32 mask; int mb = i; int me = j; - mask = ((UINT32)0xFFFFFFFF >> mb) ^ ((me >= 31) ? 0 : ((UINT32)0xFFFFFFFF >> (me + 1))); + UINT32 mask = ((UINT32)0xFFFFFFFF >> mb) ^ ((me >= 31) ? 0 : ((UINT32)0xFFFFFFFF >> (me + 1))); if( mb > me ) mask = ~mask; diff --git a/Src/GameLoader.cpp b/Src/GameLoader.cpp index 26a1b8af..99d53c3f 100644 --- a/Src/GameLoader.cpp +++ b/Src/GameLoader.cpp @@ -363,8 +363,8 @@ bool GameLoader::LoadGamesFromXML(const Util::Config::Node &xml) // Look up region structure or create new one if needed std::string region_name = region_node["name"].Value(); - auto it = regions_by_name.find(region_name); - Region::ptr_t region = (it != regions_by_name.end()) ? it->second : Region::Create(*this, region_node); + auto it2 = regions_by_name.find(region_name); + Region::ptr_t region = (it2 != regions_by_name.end()) ? it2->second : Region::Create(*this, region_node); if (!region) continue; @@ -432,7 +432,7 @@ bool GameLoader::LoadGamesFromXML(const Util::Config::Node &xml) static bool IsChildSet(const Game &game) { - return game.parent.length() > 0; + return !game.parent.empty(); } bool GameLoader::MergeChildrenWithParents() @@ -587,7 +587,7 @@ void GameLoader::IdentifyGamesInZipArchive( Region::ptr_t region = v2.second; if (!region->required) continue; - for (auto file: region->files) + for (const auto& file: region->files) { // Add each file to the set of required files per game files_required_by_game[game_name].insert(file); @@ -757,7 +757,7 @@ bool GameLoader::ComputeRegionSize(uint32_t *region_size, const GameLoader::Regi // use maximum end_addr = offset + stride * (num_chunks - 1) + chunk_size. std::vector end_addr; bool error = false; - for (auto file: region->files) + for (const auto& file: region->files) { const ZippedFile *zipped_file = LookupFile(file, zip); if (zipped_file) @@ -781,7 +781,7 @@ bool GameLoader::ComputeRegionSize(uint32_t *region_size, const GameLoader::Regi static bool ApplyLayout(ROM *rom, const std::string &byte_layout, size_t stride, const std::string ®ion_name) { // Empty layout means do nothing - if (byte_layout.size() == 0) + if (byte_layout.empty()) return false; // Validate that the layout string includes the same number of bytes as the region stride. The diff --git a/Src/GameLoader.h b/Src/GameLoader.h index 70703bcb..0f8e82e0 100644 --- a/Src/GameLoader.h +++ b/Src/GameLoader.h @@ -99,8 +99,6 @@ class GameLoader void ChooseGameInZipArchive(std::string *chosen_game, bool *missing_parent_roms, const ZipArchive &zip, const std::string &zipfilename) const; bool LoadRegion(ROM *buffer, const GameLoader::Region::ptr_t ®ion, const ZipArchive &zip) const; bool LoadROMs(ROMSet *rom_set, const std::string &game_name, const ZipArchive &zip) const; - std::string ChooseGame(const std::set &games_found, const std::string &zipfilename) const; - static bool CompareFilesByName(const File::ptr_t &a,const File::ptr_t &b); public: GameLoader(const std::string &xml_file); diff --git a/Src/Graphics/Legacy3D/Legacy3D.cpp b/Src/Graphics/Legacy3D/Legacy3D.cpp index 585a9fd7..a85f549a 100644 --- a/Src/Graphics/Legacy3D/Legacy3D.cpp +++ b/Src/Graphics/Legacy3D/Legacy3D.cpp @@ -441,7 +441,7 @@ const UINT32 *CLegacy3D::TranslateModelAddress(UINT32 modelAddr) ******************************************************************************/ // Macro to generate column-major (OpenGL) index from y,x subscripts -#define CMINDEX(y,x) (x*4+y) +#define CMINDEX(y,x) ((x)*4+(y)) /* * MultMatrix(): @@ -527,7 +527,7 @@ void CLegacy3D::InitMatrixStack(UINT32 matrixBaseAddr) } // Set matrix base address and apply matrix #0 (coordinate system matrix) - matrixBasePtr = (float *) TranslateCullingAddress(matrixBaseAddr); + matrixBasePtr = (const float *) TranslateCullingAddress(matrixBaseAddr); MultMatrix(0); } @@ -547,7 +547,7 @@ static bool IsDynamicModel(const UINT32 *data) { if (data == NULL) return false; - unsigned sharedVerts[16] = { 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4 }; + static constexpr unsigned sharedVerts[16] = { 0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4 }; // VROM models are only dynamic if they reference polygon RAM via color palette indices bool done = false; do @@ -561,7 +561,7 @@ static bool IsDynamicModel(const UINT32 *data) unsigned numVerts = (data[0]&0x40 ? 4 : 3); // Deduct number of reused verts numVerts -= sharedVerts[data[0]&0xf]; - done = (data[1] & 4) > 0; + done = (data[1] & 4) > 0; // Skip header and vertices to next polygon data += 7 + numVerts * 4; } @@ -1353,22 +1353,21 @@ CLegacy3D::~CLegacy3D(void) if (glBindBuffer != NULL) // we may have failed earlier due to lack of OpenGL 2.0 functions glBindBuffer(GL_ARRAY_BUFFER, 0); // disable VBOs by binding to 0 glDeleteTextures(numTexMaps, texMapIDs); - + DestroyModelCache(&VROMCache); DestroyModelCache(&PolyCache); - + cullingRAMLo = NULL; cullingRAMHi = NULL; polyRAM = NULL; vrom = NULL; textureRAM = NULL; - - if (texSheets != NULL) - delete [] texSheets; - if (textureBuffer != NULL) - delete [] textureBuffer; - textureBuffer = NULL; + delete [] texSheets; + texSheets = nullptr; + + delete [] textureBuffer; + textureBuffer = nullptr; DebugLog("Destroyed Legacy3D\n"); } diff --git a/Src/Graphics/Legacy3D/Models.cpp b/Src/Graphics/Legacy3D/Models.cpp index a9601fea..3723900c 100644 --- a/Src/Graphics/Legacy3D/Models.cpp +++ b/Src/Graphics/Legacy3D/Models.cpp @@ -160,7 +160,7 @@ namespace Legacy3D { ******************************************************************************/ // Macro to generate column-major (OpenGL) index from y,x subscripts -#define CMINDEX(y,x) (x*4+y) +#define CMINDEX(y,x) ((x)*4+(y)) static void CrossProd(GLfloat out[3], const GLfloat a[3], const GLfloat b[3]) { @@ -190,12 +190,11 @@ static GLfloat Sign(GLfloat x) // 4x4 matrix with the extra components undefined (do not use them!) static void InvertTransposeMat3(GLfloat out[4*4], GLfloat m[4*4]) { - GLfloat invDet; GLfloat a00 = m[CMINDEX(0,0)], a01 = m[CMINDEX(0,1)], a02 = m[CMINDEX(0,2)]; GLfloat a10 = m[CMINDEX(1,0)], a11 = m[CMINDEX(1,1)], a12 = m[CMINDEX(1,2)]; GLfloat a20 = m[CMINDEX(2,0)], a21 = m[CMINDEX(2,1)], a22 = m[CMINDEX(2,2)]; - invDet = 1.0f/(a00*(a22*a11-a21*a12)-a10*(a22*a01-a21*a02)+a20*(a12*a01-a11*a02)); + GLfloat invDet = 1.0f/(a00*(a22*a11-a21*a12)-a10*(a22*a01-a21*a02)+a20*(a12*a01-a11*a02)); out[CMINDEX(0,0)] = invDet*(a22*a11-a21*a12); out[CMINDEX(1,0)] = invDet*(-(a22*a01-a21*a02)); out[CMINDEX(2,0)] = invDet*(a12*a01-a11*a02); out[CMINDEX(0,1)] = invDet*(-(a22*a10-a20*a12)); out[CMINDEX(1,1)] = invDet*(a22*a00-a20*a02); out[CMINDEX(2,1)] = invDet*(-(a12*a00-a10*a02)); out[CMINDEX(0,2)] = invDet*(a21*a10-a20*a11); out[CMINDEX(1,2)] = invDet*(-(a21*a00-a20*a01)); out[CMINDEX(2,2)] = invDet*(a11*a00-a10*a01); @@ -390,8 +389,8 @@ Result CLegacy3D::AppendDisplayList(ModelCache *Cache, bool isViewport, const st * This is described further in InsertPolygon(), where the vertices * are ordered in clockwise fashion. */ - static const GLfloat x[3] = { 1.0f, 0.0f, 0.0f }; - static const GLfloat y[3] = { 0.0f, 1.0f, 0.0f }; + static constexpr GLfloat x[3] = { 1.0f, 0.0f, 0.0f }; + static constexpr GLfloat y[3] = { 0.0f, 1.0f, 0.0f }; const GLfloat z[3] = { 0.0f, 0.0f, -1.0f*matrixBasePtr[0x5] }; GLfloat m[4*4]; GLfloat xT[3], yT[3], zT[3], pT[3]; @@ -1268,7 +1267,7 @@ Result CLegacy3D::CreateModelCache(ModelCache *Cache, unsigned vboMaxVerts, // Clear LUT (MUST be done here because ClearModelCache() won't do it for dynamic models) for (size_t i = 0; i < numLUTEntries; i++) Cache->lut[i] = -1; - + // All good! return Result::OKAY; } @@ -1279,16 +1278,12 @@ void CLegacy3D::DestroyModelCache(ModelCache *Cache) for (size_t i = 0; i < 2; i++) { - if (Cache->verts[i] != NULL) - delete [] Cache->verts[i]; + delete [] Cache->verts[i]; } - if (Cache->Models != NULL) - delete [] Cache->Models; - if (Cache->lut != NULL) - delete [] Cache->lut; - if (Cache->List != NULL) - delete [] Cache->List; - + delete [] Cache->Models; + delete [] Cache->lut; + delete [] Cache->List; + memset(Cache, 0, sizeof(ModelCache)); } diff --git a/Src/Graphics/Legacy3D/Shaders3D.h b/Src/Graphics/Legacy3D/Shaders3D.h index 5f3728be..e2fc753a 100644 --- a/Src/Graphics/Legacy3D/Shaders3D.h +++ b/Src/Graphics/Legacy3D/Shaders3D.h @@ -31,7 +31,7 @@ namespace Legacy3D { // Vertex shader -static const char vertexShaderSource[] = +static constexpr char vertexShaderSource[] = { "/**\n" " ** Supermodel\n" @@ -246,7 +246,7 @@ static const char vertexShaderSource[] = // Fragment shader (single texture sheet) -static const char fragmentShaderSingleSheetSource[] = +static constexpr char fragmentShaderSingleSheetSource[] = { "/**\n" " ** Supermodel\n" @@ -446,7 +446,7 @@ static const char fragmentShaderSingleSheetSource[] = // Fragment shader (8 texture sheets) -static const char fragmentShaderMultiSheetSource[] = +static constexpr char fragmentShaderMultiSheetSource[] = { "/**\n" " ** Supermodel\n" diff --git a/Src/Graphics/Legacy3D/TextureRefs.cpp b/Src/Graphics/Legacy3D/TextureRefs.cpp index 67217b02..0917adb2 100644 --- a/Src/Graphics/Legacy3D/TextureRefs.cpp +++ b/Src/Graphics/Legacy3D/TextureRefs.cpp @@ -39,7 +39,7 @@ namespace Legacy3D { CTextureRefs::CTextureRefs() : m_size(0), m_hashCapacity(0), m_hashEntries(NULL) { - // + memset(m_array, 0, sizeof(m_array)); } CTextureRefs::~CTextureRefs() @@ -261,8 +261,7 @@ void CTextureRefs::DeleteAllHashEntries() for (unsigned i = 0; i < m_hashCapacity; i++) { HashEntry *entry = m_hashEntries[i]; - if (entry) - delete entry; + delete entry; } delete[] m_hashEntries; } diff --git a/Src/Graphics/New3D/Model.h b/Src/Graphics/New3D/Model.h index d63985bb..6a4eb82d 100644 --- a/Src/Graphics/New3D/Model.h +++ b/Src/Graphics/New3D/Model.h @@ -2,7 +2,6 @@ #define _MODEL_H_ #include -#include #include #include #include "Types.h" diff --git a/Src/Graphics/New3D/New3D.h b/Src/Graphics/New3D/New3D.h index f7f02a0c..07940b06 100644 --- a/Src/Graphics/New3D/New3D.h +++ b/Src/Graphics/New3D/New3D.h @@ -28,6 +28,7 @@ #ifndef INCLUDED_NEW3D_H #define INCLUDED_NEW3D_H +#include #include #include "Types.h" #include "Graphics/IRender3D.h" diff --git a/Src/Graphics/New3D/R3DFrameBuffers.h b/Src/Graphics/New3D/R3DFrameBuffers.h index 133a397d..6f3e9bcc 100644 --- a/Src/Graphics/New3D/R3DFrameBuffers.h +++ b/Src/Graphics/New3D/R3DFrameBuffers.h @@ -2,7 +2,6 @@ #define FBO_H #include -#include "VBO.h" #include "GLSLShader.h" #include "Model.h" diff --git a/Src/Graphics/Render2D.cpp b/Src/Graphics/Render2D.cpp index c917c90c..beb6cf00 100644 --- a/Src/Graphics/Render2D.cpp +++ b/Src/Graphics/Render2D.cpp @@ -411,7 +411,7 @@ void CRender2D::AttachVRAM(const uint8_t* vramPtr) { } -void CRender2D::AttachDrawBuffers(std::shared_ptr bottom, std::shared_ptr top) +void CRender2D::AttachDrawBuffers(const std::shared_ptr& bottom, const std::shared_ptr& top) { m_drawBuffers[0] = bottom; m_drawBuffers[1] = top; diff --git a/Src/Graphics/Render2D.h b/Src/Graphics/Render2D.h index 20764acd..c87c7472 100644 --- a/Src/Graphics/Render2D.h +++ b/Src/Graphics/Render2D.h @@ -148,9 +148,9 @@ class CRender2D * * Parameters: * bottom Bottom surface - * top Top surface + * top Top surface */ - void AttachDrawBuffers(std::shared_ptr bottom, std::shared_ptr top); + void AttachDrawBuffers(const std::shared_ptr& bottom, const std::shared_ptr& top); /* * Init(xOffset, yOffset, xRes, yRes, totalXRes, totalYRes); diff --git a/Src/Graphics/Shaders2D.h b/Src/Graphics/Shaders2D.h index 124bb469..c3adcf3f 100644 --- a/Src/Graphics/Shaders2D.h +++ b/Src/Graphics/Shaders2D.h @@ -30,7 +30,7 @@ // Vertex shader -static const char s_vertexShader[] = R"glsl( +static constexpr char s_vertexShader[] = R"glsl( #version 410 core @@ -57,13 +57,13 @@ static const char s_vertexShader[] = R"glsl( // Fragment shader -static const char s_fragmentShaderHeader[] = R"glsl( +static constexpr char s_fragmentShaderHeader[] = R"glsl( #version 410 core )glsl"; -static const char s_fragmentShader[] = R"glsl( +static constexpr char s_fragmentShader[] = R"glsl( // inputs uniform sampler2D tex1; // texture diff --git a/Src/Inputs/InputSource.cpp b/Src/Inputs/InputSource.cpp index 79aadc90..64f0fab2 100644 --- a/Src/Inputs/InputSource.cpp +++ b/Src/Inputs/InputSource.cpp @@ -33,10 +33,9 @@ #include "Input.h" #include "InputSystem.h" -#include using namespace std; -CInputSource::CInputSource(ESourceType sourceType) : type(sourceType), m_acquired(0) +CInputSource::CInputSource(ESourceType sourceType) : m_acquired(0), type(sourceType) { // } diff --git a/Src/Inputs/InputSystem.cpp b/Src/Inputs/InputSystem.cpp index 40a7a778..c2dfc824 100644 --- a/Src/Inputs/InputSystem.cpp +++ b/Src/Inputs/InputSystem.cpp @@ -1734,19 +1734,19 @@ bool CInputSystem::ReadMapping(char *buffer, unsigned bufSize, bool fullAxisOnly CInputSource *escape = ParseSource(escapeMapping); if (escape) escape->Acquire(); - + string badMapping; string mapping; vector badSources; vector sources; bool mseCentered = false; - + // See which sources activated to begin with and from here on ignore these (this stops badly calibrated axes that are constantly "active" // from preventing the user from exiting read loop) if (!Poll()) goto Cancelled; - CheckAllSources(readFlags, fullAxisOnly, mseCentered, badSources, badMapping, sources); + CheckAllSources(readFlags, fullAxisOnly, mseCentered, sources, badMapping, badSources); // Loop until have received meaningful inputs for (;;) diff --git a/Src/Inputs/InputTypes.cpp b/Src/Inputs/InputTypes.cpp index 3c88cf2d..08b93675 100644 --- a/Src/Inputs/InputTypes.cpp +++ b/Src/Inputs/InputTypes.cpp @@ -179,7 +179,7 @@ void CGearShift4Input::Poll() CTriggerInput::CTriggerInput(const char *inputId, const char *inputLabel, unsigned inputGameFlags, CSwitchInput *triggerInput, CSwitchInput *offscreenInput, UINT16 offVal, UINT16 onVal) : CInput(inputId, inputLabel, INPUT_FLAGS_VIRTUAL, inputGameFlags), - m_triggerInput(triggerInput), m_offscreenInput(offscreenInput), m_autoTrigger(false), m_offscreenCount(0), m_offVal(offVal), m_onVal(onVal), offscreenValue(0) + m_triggerInput(triggerInput), m_offscreenInput(offscreenInput), m_offVal(offVal), m_onVal(onVal), m_autoTrigger(false), m_offscreenCount(0), offscreenValue(0) { // } diff --git a/Src/Inputs/Inputs.cpp b/Src/Inputs/Inputs.cpp index 2a4b7cc5..a786c506 100644 --- a/Src/Inputs/Inputs.cpp +++ b/Src/Inputs/Inputs.cpp @@ -33,7 +33,7 @@ #include "InputSystem.h" #include "InputTypes.h" #include "Game.h" -#include +#include #include #include #include @@ -316,9 +316,9 @@ CGearShift4Input *CInputs::AddGearShift4Input(const char *id, const char *label, } CTriggerInput *CInputs::AddTriggerInput(const char *id, const char *label, unsigned gameFlags, - CSwitchInput *trigger, CSwitchInput *offscreen, UINT16 offVal, UINT16 onVal) + CSwitchInput *_trigger, CSwitchInput *offscreen, UINT16 offVal, UINT16 onVal) { - CTriggerInput *input = new CTriggerInput(id, label, gameFlags, trigger, offscreen, offVal, onVal); + CTriggerInput *input = new CTriggerInput(id, label, gameFlags, _trigger, offscreen, offVal, onVal); m_inputs.push_back(input); return input; } @@ -488,9 +488,9 @@ bool CInputs::ConfigureInputs(const Game &game) // Loop until user has selected a valid option bool done = false; - char mapping[50]; while (!done) { + char mapping[50]; // Wait for input from user if (!m_system->ReadMapping(mapping, 50, false, READ_KEYBOARD|READ_MERGE, uiExit->GetMapping())) { @@ -500,7 +500,7 @@ bool CInputs::ConfigureInputs(const Game &game) { (*it)->SetMapping(oldMappings[index].c_str()); index++; - } + } cancelled = true; goto Finish; diff --git a/Src/Inputs/MultiInputSource.cpp b/Src/Inputs/MultiInputSource.cpp index c4e7a970..b2332c8a 100644 --- a/Src/Inputs/MultiInputSource.cpp +++ b/Src/Inputs/MultiInputSource.cpp @@ -83,8 +83,7 @@ CMultiInputSource::CMultiInputSource(bool isOr, vector &sources) CMultiInputSource::~CMultiInputSource() { - if (m_srcArray != NULL) - delete [] m_srcArray; + delete [] m_srcArray; } void CMultiInputSource::Acquire() diff --git a/Src/Model3/53C810.h b/Src/Model3/53C810.h index 711aaede..ea04f6f8 100644 --- a/Src/Model3/53C810.h +++ b/Src/Model3/53C810.h @@ -137,7 +137,7 @@ class C53C810: public IPCIDevice * Returns: * Register data. */ - UINT32 ReadPCIConfigSpace(unsigned device, unsigned reg, unsigned bits, unsigned width); + UINT32 ReadPCIConfigSpace(unsigned device, unsigned reg, unsigned bits, unsigned offset); /* * WritePCIConfigSpace(device, reg, bits, offset, data): @@ -154,7 +154,7 @@ class C53C810: public IPCIDevice * register number. * data Data. */ - void WritePCIConfigSpace(unsigned device, unsigned reg, unsigned bits, unsigned width, UINT32 data); + void WritePCIConfigSpace(unsigned device, unsigned reg, unsigned bits, unsigned offset, UINT32 data); /* * GetBaseAddress(void): @@ -194,19 +194,19 @@ class C53C810: public IPCIDevice */ C53C810(void); ~C53C810(void); - + private: // Private members void Run(bool singleStep); void BuildOpTable(void); void Insert(UINT8 mask, UINT8 op, Result (*Handler)(struct NCR53C810Context *)); Result (*OpTable[256])(struct NCR53C810Context *); - + // Context (register file) struct NCR53C810Context Ctx; // IRQ controller and IRQ identifier for this SCSI controller - CIRQ *IRQ; + //CIRQ *IRQ; unsigned scsiIRQ; // Base address of the SCSI device (varies by game) diff --git a/Src/Model3/Crypto.h b/Src/Model3/Crypto.h index 113a8fd0..b39d7a1d 100644 --- a/Src/Model3/Crypto.h +++ b/Src/Model3/Crypto.h @@ -98,8 +98,8 @@ class CCrypto static const sbox fn1_sboxes[4][4]; static const sbox fn2_sboxes[4][4]; - static const int FN1GK = 38; - static const int FN2GK = 32; + static constexpr int FN1GK = 38; + static constexpr int FN2GK = 32; static const int fn1_game_key_scheduling[FN1GK][2]; static const int fn2_game_key_scheduling[FN2GK][2]; static const int fn1_sequence_key_scheduling[20][2]; diff --git a/Src/Model3/DSB.cpp b/Src/Model3/DSB.cpp index fbee818e..414f990a 100644 --- a/Src/Model3/DSB.cpp +++ b/Src/Model3/DSB.cpp @@ -603,11 +603,8 @@ CDSB1::CDSB1(const Util::Config::Node &config) CDSB1::~CDSB1(void) { - if (memoryPool != NULL) - { - delete [] memoryPool; - memoryPool = NULL; - } + delete [] memoryPool; + memoryPool = NULL; progROM = NULL; mpegROM = NULL; @@ -648,7 +645,7 @@ enum ST_GOTB6 }; -static const char *stateName[] = +static constexpr char *stateName[] = { "idle", "st_got_14", diff --git a/Src/Model3/DriveBoard/DriveBoard.cpp b/Src/Model3/DriveBoard/DriveBoard.cpp index 641d2807..8572a437 100644 --- a/Src/Model3/DriveBoard/DriveBoard.cpp +++ b/Src/Model3/DriveBoard/DriveBoard.cpp @@ -293,7 +293,7 @@ void CDriveBoard::RunFrame(void) // Assuming Z80 runs @ 8.0MHz and INT triggers @ 60.0KHz for BillBoard // TODO - find out if Z80 frequency is correct and exact frequency of NMI interrupts (just guesswork at the moment!) int cycles = (int)(m_z80Clock * 1000000 / 60); - int loopCycles = 10000; + constexpr int loopCycles = 10000; while (cycles > 0) { if (m_allowInterrupts) diff --git a/Src/Model3/DriveBoard/JoystickBoard.cpp b/Src/Model3/DriveBoard/JoystickBoard.cpp index 1d8d9a74..9669b384 100644 --- a/Src/Model3/DriveBoard/JoystickBoard.cpp +++ b/Src/Model3/DriveBoard/JoystickBoard.cpp @@ -287,6 +287,7 @@ void CJoyBoard::SimulateWrite(UINT8 cmd) case 6: /* Ignore */ break; // 0x86 Set cockpit banking position case 7: /* Ignore */ break; // 0x87 Lamp on/off } + break; case 0x9: // 0x90-9F ??? Don't appear to have any effect with Scud Race ROM /* TODO */ break; @@ -575,7 +576,7 @@ void CJoyBoard::SendStopAll(void) { //DebugLog(">> Stop All Effects\n"); - ForceFeedbackCmd ffCmd; + ForceFeedbackCmd ffCmd{}; ffCmd.id = FFStop; m_inputs->analogJoyX->SendForceFeedbackCmd(ffCmd); diff --git a/Src/Model3/DriveBoard/SkiBoard.h b/Src/Model3/DriveBoard/SkiBoard.h index 6e9b25fc..c4701447 100644 --- a/Src/Model3/DriveBoard/SkiBoard.h +++ b/Src/Model3/DriveBoard/SkiBoard.h @@ -150,7 +150,7 @@ class CSkiBoard : public CDriveBoard UINT8 SimulateRead(void); - void SimulateWrite(UINT8 data); + void SimulateWrite(UINT8 cmd); void SendVibrate(UINT8 val); diff --git a/Src/Model3/DriveBoard/WheelBoard.cpp b/Src/Model3/DriveBoard/WheelBoard.cpp index 08ddb50b..e2df820d 100644 --- a/Src/Model3/DriveBoard/WheelBoard.cpp +++ b/Src/Model3/DriveBoard/WheelBoard.cpp @@ -610,7 +610,7 @@ void CWheelBoard::SendStopAll(void) { //DebugLog(">> Stop All Effects\n"); - ForceFeedbackCmd ffCmd; + ForceFeedbackCmd ffCmd{}; ffCmd.id = FFStop; m_inputs->steering->SendForceFeedbackCmd(ffCmd); diff --git a/Src/Model3/JTAG.cpp b/Src/Model3/JTAG.cpp index 53f6ee24..abec9fd3 100644 --- a/Src/Model3/JTAG.cpp +++ b/Src/Model3/JTAG.cpp @@ -226,20 +226,20 @@ void CJTAG::SaveState(CBlockFile* SaveState) } } -void CJTAG::LoadState(CBlockFile* SaveState) +void CJTAG::LoadState(CBlockFile* LoadState) { - if (Result::OKAY != SaveState->FindBlock("JTAG2")) + if (Result::OKAY != LoadState->FindBlock("JTAG2")) { ErrorLog("Unable to load JTAG state. Save state file is corrupt."); return; } - SaveState->Read(&m_state, sizeof(m_state)); - SaveState->Read(&m_lastTck, sizeof(m_lastTck)); - SaveState->Read(&m_tdo, sizeof(m_tdo)); - SaveState->Read(&m_numDevices, sizeof(m_numDevices)); + LoadState->Read(&m_state, sizeof(m_state)); + LoadState->Read(&m_lastTck, sizeof(m_lastTck)); + LoadState->Read(&m_tdo, sizeof(m_tdo)); + LoadState->Read(&m_numDevices, sizeof(m_numDevices)); for (auto& device : m_device) { - device->LoadStateFromBlock(SaveState); + device->LoadStateFromBlock(LoadState); } } diff --git a/Src/Model3/MPC10x.cpp b/Src/Model3/MPC10x.cpp index 27707a6d..a0c702a8 100644 --- a/Src/Model3/MPC10x.cpp +++ b/Src/Model3/MPC10x.cpp @@ -347,9 +347,9 @@ void CMPC10x::Init(void) * Constructor. */ CMPC10x::CMPC10x(void) : - regs{}, - PCIBus(nullptr), model(0x105), // default to MPC105 + PCIBus(nullptr), + regs{}, pciBus(0), pciDevice(0), pciFunction(0), diff --git a/Src/Model3/Model3.cpp b/Src/Model3/Model3.cpp index 6ec78167..924ee753 100644 --- a/Src/Model3/Model3.cpp +++ b/Src/Model3/Model3.cpp @@ -838,6 +838,7 @@ UINT32 CModel3::ReadPCIConfigSpace(unsigned device, unsigned reg, unsigned bits, default: break; } + break; default: break; } @@ -1144,13 +1145,13 @@ UINT16 CModel3::Read16(UINT32 addr) if (addr < 0xF1120000) { // Tile generator accesses its RAM as little endian, no adjustment needed here - uint16_t data = TileGen.ReadRAM16(addr&0x1FFFFF); + data = TileGen.ReadRAM16(addr&0x1FFFFF); return FLIPENDIAN16(data); } break; #ifdef NET_BOARD - case 0xc0: // spikeout call this + case 0xc0: // spikeout calls this // interesting : poking @4 master to same value as slave (0x100) or simply !=0 -> connected and go in game, but freeze (prints comm error) as soon as players appear after the gate // sort of sync ack ? who writes this 16b value ? { @@ -1165,6 +1166,7 @@ UINT16 CModel3::Read16(UINT32 addr) break; } } + break; #endif // Unknown default: @@ -3119,21 +3121,21 @@ void CModel3::AttachOutputs(COutputs *OutputsPtr) DebugLog("Model 3 attached outputs\n"); } -const static int RAM_SIZE = 0x800000; //8MB -const static int CROM_SIZE = 0x800000; //8MB -const static int CROMxx_SIZE = 0x8000000; //128MB -const static int VROM_SIZE = 0x4000000; //64MB -const static int BACKUPRAM_SIZE = 0x20000; //128KB -const static int SECURITYRAM_SIZE = 0x20000; //128KB -const static int SOUNDROM_SIZE = 0x80000; //512KB -const static int SAMPLEROM_SIZE = 0x1000000; //16MB -const static int DSBPROGROM_SIZE = 0x20000; //128KB -const static int DSBMPEGROM_SIZE = 0x1000000; //16MB -const static int DRIVEROM_SIZE = 0x10000; //64KB -const static int NETBUFFER_SIZE = 0x20000; //128KB -const static int NETRAM_SIZE = 0x10000; //64KB - -const static int MEM_POOL_SIZE = RAM_SIZE + CROM_SIZE + +constexpr static int RAM_SIZE = 0x800000; //8MB +constexpr static int CROM_SIZE = 0x800000; //8MB +constexpr static int CROMxx_SIZE = 0x8000000; //128MB +constexpr static int VROM_SIZE = 0x4000000; //64MB +constexpr static int BACKUPRAM_SIZE = 0x20000; //128KB +constexpr static int SECURITYRAM_SIZE = 0x20000; //128KB +constexpr static int SOUNDROM_SIZE = 0x80000; //512KB +constexpr static int SAMPLEROM_SIZE = 0x1000000; //16MB +constexpr static int DSBPROGROM_SIZE = 0x20000; //128KB +constexpr static int DSBMPEGROM_SIZE = 0x1000000; //16MB +constexpr static int DRIVEROM_SIZE = 0x10000; //64KB +constexpr static int NETBUFFER_SIZE = 0x20000; //128KB +constexpr static int NETRAM_SIZE = 0x10000; //64KB + +constexpr static int MEM_POOL_SIZE = RAM_SIZE + CROM_SIZE + CROMxx_SIZE + VROM_SIZE + BACKUPRAM_SIZE + SECURITYRAM_SIZE + SOUNDROM_SIZE + SAMPLEROM_SIZE + @@ -3141,24 +3143,24 @@ const static int MEM_POOL_SIZE = RAM_SIZE + CROM_SIZE + DRIVEROM_SIZE + NETBUFFER_SIZE + NETRAM_SIZE; -const static int RAM_OFFSET = 0; -const static int CROM_OFFSET = RAM_OFFSET + RAM_SIZE; -const static int CROMxx_OFFSET = CROM_OFFSET + CROM_SIZE; -const static int VROM_OFFSET = CROMxx_OFFSET + CROMxx_SIZE; -const static int BACKUPRAM_OFFSET = VROM_OFFSET + VROM_SIZE; -const static int SECURITYRAM_OFFSET = BACKUPRAM_OFFSET + BACKUPRAM_SIZE; -const static int SOUNDROM_OFFSET = SECURITYRAM_OFFSET + SECURITYRAM_SIZE; -const static int SAMPLEROM_OFFSET = SOUNDROM_OFFSET + SOUNDROM_SIZE; -const static int DSBPROGROM_OFFSET = SAMPLEROM_OFFSET + SAMPLEROM_SIZE; -const static int DSBMPEGROM_OFFSET = DSBPROGROM_OFFSET + DSBPROGROM_SIZE; -const static int DRIVEROM_OFFSET = DSBMPEGROM_OFFSET + DSBMPEGROM_SIZE; -const static int NETBUFFER_OFFSET = DRIVEROM_OFFSET + DRIVEROM_SIZE; -const static int NETRAM_OFFSET = NETBUFFER_OFFSET + NETBUFFER_SIZE; +constexpr static int RAM_OFFSET = 0; +constexpr static int CROM_OFFSET = RAM_OFFSET + RAM_SIZE; +constexpr static int CROMxx_OFFSET = CROM_OFFSET + CROM_SIZE; +constexpr static int VROM_OFFSET = CROMxx_OFFSET + CROMxx_SIZE; +constexpr static int BACKUPRAM_OFFSET = VROM_OFFSET + VROM_SIZE; +constexpr static int SECURITYRAM_OFFSET = BACKUPRAM_OFFSET + BACKUPRAM_SIZE; +constexpr static int SOUNDROM_OFFSET = SECURITYRAM_OFFSET + SECURITYRAM_SIZE; +constexpr static int SAMPLEROM_OFFSET = SOUNDROM_OFFSET + SOUNDROM_SIZE; +constexpr static int DSBPROGROM_OFFSET = SAMPLEROM_OFFSET + SAMPLEROM_SIZE; +constexpr static int DSBMPEGROM_OFFSET = DSBPROGROM_OFFSET + DSBPROGROM_SIZE; +constexpr static int DRIVEROM_OFFSET = DSBMPEGROM_OFFSET + DSBMPEGROM_SIZE; +constexpr static int NETBUFFER_OFFSET = DRIVEROM_OFFSET + DRIVEROM_SIZE; +constexpr static int NETRAM_OFFSET = NETBUFFER_OFFSET + NETBUFFER_SIZE; // Model 3 initialization. Some initialization is deferred until ROMs are loaded in LoadROMSet() Result CModel3::Init(void) { - float memSizeMB = (float)MEM_POOL_SIZE / (float)0x100000; + constexpr float memSizeMB = (float)MEM_POOL_SIZE / (float)0x100000; // Allocate all memory for ROMs and PPC RAM memoryPool = new(std::nothrow) UINT8[MEM_POOL_SIZE]; diff --git a/Src/Model3/Model3.h b/Src/Model3/Model3.h index a1f86cc5..d880e704 100644 --- a/Src/Model3/Model3.h +++ b/Src/Model3/Model3.h @@ -46,7 +46,7 @@ #endif // NET_BOARD #include "Util/NewConfig.h" #include "Graphics/SuperAA.h" - +#include "OSD/Thread.h" /* * FrameTimings @@ -102,8 +102,8 @@ class CModel3: public IEmulator, public IBus, public IPCIDevice Util::Config::Node& GetConfig() { return this->m_config; } // IPCIDevice interface - UINT32 ReadPCIConfigSpace(unsigned device, unsigned reg, unsigned bits, unsigned width); - void WritePCIConfigSpace(unsigned device, unsigned reg, unsigned bits, unsigned width, UINT32 data); + UINT32 ReadPCIConfigSpace(unsigned device, unsigned reg, unsigned bits, unsigned offset); + void WritePCIConfigSpace(unsigned device, unsigned reg, unsigned bits, unsigned offset, UINT32 data); // IBus interface UINT8 Read8(UINT32 addr); diff --git a/Src/Model3/Real3D.cpp b/Src/Model3/Real3D.cpp index d7d34dda..91e66902 100644 --- a/Src/Model3/Real3D.cpp +++ b/Src/Model3/Real3D.cpp @@ -53,8 +53,8 @@ // Macros that divide memory regions into pages and mark them as dirty when they are written to #define PAGE_WIDTH 12 #define PAGE_SIZE (1<>(PAGE_WIDTH+3)] |= 1<<((addr>>PAGE_WIDTH)&7) +#define DIRTY_SIZE(arraySize) (1+((arraySize)-1)/(8*PAGE_SIZE)) +#define MARK_DIRTY(dirtyArray, addr) dirtyArray[(addr)>>(PAGE_WIDTH+3)] |= 1<<(((addr)>>PAGE_WIDTH)&7) // Offsets of memory regions within Real3D memory pool #define OFFSET_8C 0x0000000 // 4 MB, culling RAM low (at 0x8C000000) @@ -375,7 +375,7 @@ void CReal3D::StoreTexture(unsigned level, unsigned xPos, unsigned yPos, unsigne // Outer 2 loops: NxN tiles const uint8_t byteSelect = (uint8_t)writeLSB | ((uint8_t)writeMSB << 1); uint16_t tempData; - const uint16_t byteMask[4] = {0xFFFF, 0xFF00, 0x00FF, 0x0000}; + static constexpr uint16_t byteMask[4] = {0xFFFF, 0xFF00, 0x00FF, 0x0000}; for (uint32_t y = yPos; y < (yPos + height); y += tileY) { for (uint32_t x = xPos; x < (xPos + width); x += tileX) diff --git a/Src/Model3/Real3D.h b/Src/Model3/Real3D.h index 09adce8e..4a9fb935 100644 --- a/Src/Model3/Real3D.h +++ b/Src/Model3/Real3D.h @@ -307,8 +307,8 @@ class CReal3D: public IPCIDevice * Returns: * Register data. */ - uint32_t ReadPCIConfigSpace(unsigned device, unsigned reg, unsigned bits, unsigned width); - + uint32_t ReadPCIConfigSpace(unsigned device, unsigned reg, unsigned bits, unsigned offset); + /* * WritePCIConfigSpace(device, reg, bits, offset, data): * @@ -324,8 +324,8 @@ class CReal3D: public IPCIDevice * register number. * data Data. */ - void WritePCIConfigSpace(unsigned device, unsigned reg, unsigned bits, unsigned width, uint32_t data); - + void WritePCIConfigSpace(unsigned device, unsigned reg, unsigned bits, unsigned offset, uint32_t data); + /* * Reset(void): * @@ -333,7 +333,7 @@ class CReal3D: public IPCIDevice * device. */ void Reset(void); - + /* * AttachRenderer(render3DPtr): * diff --git a/Src/Model3/SoundBoard.h b/Src/Model3/SoundBoard.h index 9463d53e..525fcf07 100644 --- a/Src/Model3/SoundBoard.h +++ b/Src/Model3/SoundBoard.h @@ -31,7 +31,6 @@ #include "Types.h" #include "CPU/Bus.h" #include "Model3/DSB.h" -#include "OSD/Thread.h" /* * CSoundBoard: diff --git a/Src/Model3/TileGen.cpp b/Src/Model3/TileGen.cpp index b1cf8095..68d1f487 100644 --- a/Src/Model3/TileGen.cpp +++ b/Src/Model3/TileGen.cpp @@ -325,23 +325,23 @@ Result CTileGen::Init(CIRQ *IRQObjectPtr) } CTileGen::CTileGen(const Util::Config::Node& config) - : m_config(config), + : //m_config(config), m_gpuMultiThreaded(config["GPUMultiThreaded"].ValueAs()), IRQ(nullptr), - memoryPool(nullptr), Render2D(nullptr), - m_regs{}, + memoryPool(nullptr), m_vram(nullptr), m_vramP(nullptr), m_palP(nullptr), - m_pal{nullptr} + m_pal{nullptr}, + m_regs{} { for (auto& s : m_drawSurface) { - s = std::shared_ptr(new TileGenBuffer()); + s = std::make_shared(); } for (auto& s : m_drawSurfaceRO) { - s = std::shared_ptr(new TileGenBuffer()); + s = std::make_shared(); } for (auto& p : m_pal) { diff --git a/Src/Model3/TileGen.h b/Src/Model3/TileGen.h index 8d3f98f7..ac42e82c 100644 --- a/Src/Model3/TileGen.h +++ b/Src/Model3/TileGen.h @@ -310,14 +310,14 @@ class CTileGen void WritePalette (int layer, int address, UINT32 data); void RecomputePalettes(int layer); // 0 = bottom, 1 = top - const Util::Config::Node& m_config; + //const Util::Config::Node& m_config; const bool m_gpuMultiThreaded; CIRQ* IRQ; // IRQ controller the tile generator is attached to CRender2D* Render2D; // 2D renderer the tile generator is attached to UINT8* memoryPool; // all memory allocated here - UINT8* m_vram; // 1.125MB of VRAM + UINT8* m_vram; // 1.125MB of VRAM UINT32* m_vramP; // vram pointer but integer size UINT32* m_palP; // just a pointer to the palette ram which comes after the vram diff --git a/Src/Network/NetBoard.cpp b/Src/Network/NetBoard.cpp index 9df26b03..c85569c1 100644 --- a/Src/Network/NetBoard.cpp +++ b/Src/Network/NetBoard.cpp @@ -111,11 +111,11 @@ #endif #ifndef SAFE_DELETE - #define SAFE_DELETE(p) if (p != nullptr) { delete (p); (p) = NULL; } + #define SAFE_DELETE(p) { delete (p); (p) = nullptr; } #endif #ifndef SAFE_ARRAY_DELETE - #define SAFE_ARRAY_DELETE(x) if (x != nullptr) { delete[] x; x = NULL; } + #define SAFE_ARRAY_DELETE(x) { delete[] (x); (x) = nullptr; } #endif static int(*Runnet68kCB)(int cycles); @@ -218,7 +218,7 @@ UINT8 CNetBoard::Read8(UINT32 a) case 0x11: // ioreg[c0011] DebugLog("Netboard R8\tioreg[%x]=%x\t\treceive result status\n", a & 0xff, ioreg[a & 0xff]); //return 0x5; /////////////////////////////////// pure hack for spikofe - must have the pure hack spikeout enable too /////////////////////////////////////////////////////// - if (Gameinfo.name.compare("spikeofe") == 0) return 0x5; + if (Gameinfo.name == "spikeofe") return 0x5; return ioreg[(a&0xff) ^ 1]; break; @@ -836,7 +836,7 @@ void CNetBoard::Write8(UINT32 a, UINT8 d) case 0x89: // ioreg[c0089] // dayto2pe loops with values 00 01 02 during type 2 trame ioreg[(a & 0xff) ^ 1] = d; //CommRAM[4] = d; /////////////////////////////////// pure hack for spikeout ///////////////////////////////////////////////////////////////////////////////////////////// - if (Gameinfo.name.compare("spikeout") == 0 || Gameinfo.name.compare("spikeofe") == 0) CommRAM[4] = d; + if (Gameinfo.name == "spikeout" || Gameinfo.name == "spikeofe") CommRAM[4] = d; DebugLog("Netboard W8\tioreg[%x] <- %x\n", a & 0xff, d); break; diff --git a/Src/Network/NetBoard.h b/Src/Network/NetBoard.h index 087613d8..8799aaad 100644 --- a/Src/Network/NetBoard.h +++ b/Src/Network/NetBoard.h @@ -99,7 +99,7 @@ class CNetBoard : public IBus, public INetBoard UINT16 recv_size; UINT16 send_offset; UINT16 send_size; - UINT8 slot; + //UINT8 slot; // netsock UINT16 port_in = 0; @@ -114,7 +114,7 @@ class CNetBoard : public IBus, public INetBoard // only for some tests UINT8 *bank; - UINT8 *bank2; + //UINT8 *bank2; UINT8 test_irq; std::thread interrupt5; diff --git a/Src/Network/SimNetBoard.cpp b/Src/Network/SimNetBoard.cpp index 26cacd08..9a963348 100644 --- a/Src/Network/SimNetBoard.cpp +++ b/Src/Network/SimNetBoard.cpp @@ -157,7 +157,7 @@ void CSimNetBoard::RunFrame(void) if (recv_data.empty()) break; uint64_t testGUID; - memcpy(&testGUID, &recv_data[0], recv_data.size()); + memcpy(&testGUID, recv_data.data(), recv_data.size()); if (testGUID != netGUID) testGUID = 0; @@ -193,7 +193,7 @@ void CSimNetBoard::RunFrame(void) if (recv_data.empty()) break; uint64_t testGUID; - memcpy(&testGUID, &recv_data[0], recv_data.size()); + memcpy(&testGUID, recv_data.data(), recv_data.size()); if (testGUID != netGUID) testGUID = 0; nets->Send(&testGUID, sizeof(testGUID)); @@ -202,7 +202,7 @@ void CSimNetBoard::RunFrame(void) recv_data = netr->Receive(); if (recv_data.empty()) break; - memcpy(&testGUID, &recv_data[0], recv_data.size()); + memcpy(&testGUID, recv_data.data(), recv_data.size()); if (testGUID != netGUID) testGUID = 0; nets->Send(&testGUID, sizeof(testGUID)); @@ -231,7 +231,7 @@ void CSimNetBoard::RunFrame(void) // if there are no other linked machines, only continue if Supermodel is linked to itself // there might be more than one machine set to master which would cause glitches - if ((numMachines == 0) && ((port_in != port_out) || (addr_out.compare("127.0.0.1") != 0))) + if ((numMachines == 0) && ((port_in != port_out) || (addr_out != "127.0.0.1"))) { ErrorLog("no slave machines detected. Make sure only one machine is set to master!"); m_state = State::error; @@ -285,7 +285,7 @@ void CSimNetBoard::RunFrame(void) break; uint64_t testGUID; - memcpy(&testGUID, &recv_data[0], recv_data.size()); + memcpy(&testGUID, recv_data.data(), recv_data.size()); if (testGUID != netGUID) testGUID = 0; @@ -301,14 +301,14 @@ void CSimNetBoard::RunFrame(void) } // master has indices set to zero - machineIndex.total = 0, machineIndex.playable = 0; + machineIndex.total = 0; machineIndex.playable = 0; nets->Send(&machineIndex, sizeof(machineIndex)); // receive back the number of other linked machines recv_data = netr->Receive(); if (recv_data.empty()) break; - memcpy(&numMachines, &recv_data[0], recv_data.size()); + memcpy(&numMachines, recv_data.data(), recv_data.size()); // send the number of other linked machines nets->Send(&numMachines, sizeof(numMachines)); @@ -321,7 +321,7 @@ void CSimNetBoard::RunFrame(void) if (recv_data.empty()) break; uint64_t testGUID; - memcpy(&testGUID, &recv_data[0], recv_data.size()); + memcpy(&testGUID, recv_data.data(), recv_data.size()); if (testGUID != netGUID) testGUID = 0; nets->Send(&testGUID, sizeof(testGUID)); @@ -330,7 +330,7 @@ void CSimNetBoard::RunFrame(void) recv_data = netr->Receive(); if (recv_data.empty()) break; - memcpy(&testGUID, &recv_data[0], recv_data.size()); + memcpy(&testGUID, recv_data.data(), recv_data.size()); if (testGUID != netGUID) testGUID = 0; nets->Send(&testGUID, sizeof(testGUID)); @@ -346,8 +346,8 @@ void CSimNetBoard::RunFrame(void) recv_data = netr->Receive(); if (recv_data.empty()) break; - memcpy(&machineIndex, &recv_data[0], recv_data.size()); - machineIndex.total++, machineIndex.playable++; + memcpy(&machineIndex, recv_data.data(), recv_data.size()); + machineIndex.total++; machineIndex.playable++; // send our indices to the next machine nets->Send(&machineIndex, sizeof(machineIndex)); @@ -356,7 +356,7 @@ void CSimNetBoard::RunFrame(void) recv_data = netr->Receive(); if (recv_data.empty()) break; - memcpy(&numMachines, &recv_data[0], recv_data.size()); + memcpy(&numMachines, recv_data.data(), recv_data.size()); // forward the number of machines nets->Send(&numMachines, sizeof(numMachines)); @@ -370,7 +370,7 @@ void CSimNetBoard::RunFrame(void) if (recv_data.empty()) break; uint64_t testGUID; - memcpy(&testGUID, &recv_data[0], recv_data.size()); + memcpy(&testGUID, recv_data.data(), recv_data.size()); if (testGUID != netGUID) testGUID = 0; nets->Send(&testGUID, sizeof(testGUID)); @@ -379,7 +379,7 @@ void CSimNetBoard::RunFrame(void) recv_data = netr->Receive(); if (recv_data.empty()) break; - memcpy(&testGUID, &recv_data[0], recv_data.size()); + memcpy(&testGUID, recv_data.data(), recv_data.size()); if (testGUID != netGUID) testGUID = 0; nets->Send(&testGUID, sizeof(testGUID)); @@ -395,7 +395,7 @@ void CSimNetBoard::RunFrame(void) recv_data = netr->Receive(); if (recv_data.empty()) break; - memcpy(&machineIndex, &recv_data[0], recv_data.size()); + memcpy(&machineIndex, recv_data.data(), recv_data.size()); machineIndex.total++; // send our indices to the next machine @@ -405,7 +405,7 @@ void CSimNetBoard::RunFrame(void) recv_data = netr->Receive(); if (recv_data.empty()) break; - memcpy(&numMachines, &recv_data[0], recv_data.size()); + memcpy(&numMachines, recv_data.data(), recv_data.size()); // forward the number of machines nets->Send(&numMachines, sizeof(numMachines)); @@ -417,7 +417,7 @@ void CSimNetBoard::RunFrame(void) // if there are no other linked machines, only continue if Supermodel is linked to itself // there might be more than one machine set to master which would cause glitches - if ((numMachines.total == 0) && ((port_in != port_out) || (addr_out.compare("127.0.0.1") != 0))) + if ((numMachines.total == 0) && ((port_in != port_out) || (addr_out != "127.0.0.1"))) { ErrorLog("no slave machines detected. Make sure only one machine is set to master!"); if (IsGame("dirtdvls")) @@ -463,7 +463,7 @@ void CSimNetBoard::RunFrame(void) { nets->Send(CommRAM + 0x100 + i * m_segmentSize, m_segmentSize); auto& recv_data = netr->Receive(); - if (recv_data.size() == 0) + if (recv_data.empty()) { // link broken - send an "empty" packet to alert other machines nets->Send(nullptr, 0); diff --git a/Src/Network/TCPReceive.cpp b/Src/Network/TCPReceive.cpp index 4b3dcdc4..69297df2 100644 --- a/Src/Network/TCPReceive.cpp +++ b/Src/Network/TCPReceive.cpp @@ -25,7 +25,7 @@ #include "OSD/Thread.h" #if defined(_DEBUG) -#include +#include #define DPRINTF DebugLog #else #define DPRINTF(a, ...) diff --git a/Src/Network/TCPSend.cpp b/Src/Network/TCPSend.cpp index 8254b7b0..b9b640b1 100644 --- a/Src/Network/TCPSend.cpp +++ b/Src/Network/TCPSend.cpp @@ -30,8 +30,6 @@ #define DPRINTF(a, ...) #endif -static const int RETRY_COUNT = 10; // shrugs - TCPSend::TCPSend(std::string& ip, int port) : m_ip(ip), m_port(port), diff --git a/Src/OSD/Logger.cpp b/Src/OSD/Logger.cpp index 71d9d2f7..bb2bbc71 100644 --- a/Src/OSD/Logger.cpp +++ b/Src/OSD/Logger.cpp @@ -295,7 +295,7 @@ void CFileLogger::ReopenFiles(std::ios_base::openmode mode) m_logFiles.clear(); // (Re-)Open - for (auto filename: m_logFilenames) + for (const auto& filename: m_logFilenames) { std::ofstream ofs(filename.c_str(), mode); if (ofs.is_open() && ofs.good()) @@ -318,14 +318,14 @@ void CFileLogger::WriteToFiles(const char *str) } } -CFileLogger::CFileLogger(CLogger::LogLevel level, std::vector filenames) +CFileLogger::CFileLogger(CLogger::LogLevel level, const std::vector& filenames) : m_logLevel(level), m_logFilenames(filenames) { ReopenFiles(std::ios::out); } -CFileLogger::CFileLogger(CLogger::LogLevel level, std::vector filenames, std::vector systemFiles) +CFileLogger::CFileLogger(CLogger::LogLevel level, const std::vector& filenames, const std::vector& systemFiles) : m_logLevel(level), m_logFilenames(filenames), m_systemFiles(systemFiles) diff --git a/Src/OSD/Logger.h b/Src/OSD/Logger.h index 53ed15c9..ec46e686 100644 --- a/Src/OSD/Logger.h +++ b/Src/OSD/Logger.h @@ -183,13 +183,13 @@ class CFileLogger: public CLogger void DebugLog(const char *fmt, va_list vl); void InfoLog(const char *fmt, va_list vl); void ErrorLog(const char *fmt, va_list vl); - CFileLogger(LogLevel level, std::vector filenames); - CFileLogger(LogLevel level, std::vector filenames, std::vector systemFiles); + CFileLogger(LogLevel level, const std::vector& filenames); + CFileLogger(LogLevel level, const std::vector& filenames, const std::vector& systemFiles); private: - std::mutex m_mtx; // needed because we may close/reopen files and logging must be thread-safe + std::mutex m_mtx; // needed because we may close/reopen files and logging must be thread-safe LogLevel m_logLevel; - const std::vector m_logFilenames; + const std::vector m_logFilenames; std::vector m_logFiles; std::vector m_systemFiles; diff --git a/Src/OSD/SDL/Audio.cpp b/Src/OSD/SDL/Audio.cpp index 61a73c23..c9567531 100755 --- a/Src/OSD/SDL/Audio.cpp +++ b/Src/OSD/SDL/Audio.cpp @@ -182,16 +182,16 @@ static void PlayCallback(void* data, Uint8* stream, int len) adjWritePos += audioBufferSize; // Check if play position overlaps write position (ie buffer under-run) - if (playPos + len > adjWritePos) - { + if (playPos + len > adjWritePos) + { underRuns++; //printf("Audio buffer under-run #%u in PlayCallback(%d) [writePos = %u, writeWrapped = %s, playPos = %u, audioBufferSize = %u]\n", // underRuns, len, writePos, (writeWrapped ? "true" : "false"), playPos, audioBufferSize); // See what action to take on under-run - if (underRunLoop) - { + if (underRunLoop) + { // If loop, then move play position back to beginning of data in buffer playPos = adjWritePos + bytes_per_frame_host; @@ -202,9 +202,9 @@ static void PlayCallback(void* data, Uint8* stream, int len) else // Otherwise, set write wrapped flag as will now appear as if write has wrapped but play position has not writeWrapped = true; - } - else - { + } + else + { // Otherwise, just copy silence to audio output stream and exit memset(stream, 0, len); return; @@ -217,26 +217,26 @@ static void PlayCallback(void* data, Uint8* stream, int len) UINT32 len2; // Check if play region extends past end of buffer - if (playPos + len > audioBufferSize) - { + if (playPos + len > audioBufferSize) + { // If so, split play region into two src1 = audioBuffer + playPos; src2 = audioBuffer; len1 = audioBufferSize - playPos; len2 = len - len1; - } - else - { + } + else + { // Otherwise, just copy whole region src1 = audioBuffer + playPos; - src2 = 0; + src2 = nullptr; len1 = len; len2 = 0; } // Check if audio is enabled - if (enabled) - { + if (enabled) + { // If so, copy play region into audio output stream memcpy(stream, src1, len1); @@ -244,8 +244,8 @@ static void PlayCallback(void* data, Uint8* stream, int len) if (!underRunLoop) memset(src1, 0, len1); - if (len2) - { + if (len2) + { // If region was split into two, copy second half into audio output stream as well memcpy(stream + len1, src2, len2); @@ -253,8 +253,8 @@ static void PlayCallback(void* data, Uint8* stream, int len) if (!underRunLoop) memset(src2, 0, len2); } - } - else + } + else // Otherwise, just copy silence to audio output stream memset(stream, 0, len); @@ -264,8 +264,8 @@ static void PlayCallback(void* data, Uint8* stream, int len) bool bufferFull = adjWritePos + 2 * bytes_per_frame_host > playPos + audioBufferSize; // Check if play position has moved past end of buffer - if (playPos >= audioBufferSize) - { + if (playPos >= audioBufferSize) + { // If so, wrap it around to beginning again and reset write wrapped flag playPos -= audioBufferSize; writeWrapped = false; @@ -560,8 +560,8 @@ bool OutputAudio(unsigned numSamples, const float* leftFrontBuffer, const float* writePos += audioBufferSize; // Check if play region has caught up with write position and now overlaps it (ie buffer under-run) - if (playEndPos > writePos) - { + if (playEndPos > writePos) + { underRuns++; //printf("Audio buffer under-run #%u in OutputAudio(%u) [writePos = %u, writeWrapped = %s, playPos = %u, audioBufferSize = %u, numBytes = %u]\n", @@ -605,8 +605,8 @@ bool OutputAudio(unsigned numSamples, const float* leftFrontBuffer, const float* writePos -= audioBufferSize; // Handle buffer over-run - if (overRun) - { + if (overRun) + { overRuns++; //printf("Audio buffer over-run #%u in OutputAudio(%u) [writePos = %u, writeWrapped = %s, playPos = %u, audioBufferSize = %u, numBytes = %u]\n", @@ -683,9 +683,6 @@ void CloseAudio() SDL_CloseAudio(); // Delete audio buffer - if (audioBuffer != NULL) - { - delete[] audioBuffer; - audioBuffer = NULL; - } -} \ No newline at end of file + delete[] audioBuffer; + audioBuffer = nullptr; +} diff --git a/Src/OSD/SDL/Crosshair.h b/Src/OSD/SDL/Crosshair.h index 2b2d57b4..6a184c8a 100644 --- a/Src/OSD/SDL/Crosshair.h +++ b/Src/OSD/SDL/Crosshair.h @@ -31,7 +31,7 @@ class CCrosshair private: const Util::Config::Node& m_config; bool m_isBitmapCrosshair = false; - std::string m_crosshairStyle = ""; + std::string m_crosshairStyle; GLuint m_crosshairTexId[2] = { 0 }; int m_p1CrosshairW = 0, m_p1CrosshairH = 0, m_p2CrosshairW = 0, m_p2CrosshairH = 0; float m_diagDpi = 0.0f, m_hDpi = 0.0f, m_vDpi = 0.0f; diff --git a/Src/OSD/SDL/Main.cpp b/Src/OSD/SDL/Main.cpp index bdaa34f5..d627e052 100644 --- a/Src/OSD/SDL/Main.cpp +++ b/Src/OSD/SDL/Main.cpp @@ -148,20 +148,20 @@ static Result SetGLGeometry(unsigned *xOffsetPtr, unsigned *yOffsetPtr, unsigned *totalYResPtr = actualHeight; // If required, fix the aspect ratio of the resolution that the user passed to match Model 3 ratio - float xRes = float(*xResPtr); - float yRes = float(*yResPtr); + float xResF = float(*xResPtr); + float yResF = float(*yResPtr); if (keepAspectRatio) { float model3Ratio = float(496.0/384.0); - if (yRes < (xRes/model3Ratio)) - xRes = yRes*model3Ratio; - if (xRes < (yRes*model3Ratio)) - yRes = xRes/model3Ratio; + if (yResF < (xResF/model3Ratio)) + xResF = yResF*model3Ratio; + if (xResF < (yResF*model3Ratio)) + yResF = xResF/model3Ratio; } // Center the visible area - *xOffsetPtr = (*xResPtr - (unsigned) xRes)/2; - *yOffsetPtr = (*yResPtr - (unsigned) yRes)/2; + *xOffsetPtr = (*xResPtr - (unsigned) xResF)/2; + *yOffsetPtr = (*yResPtr - (unsigned) yResF)/2; // If the desired resolution is smaller than what we got, re-center again if (int(*xResPtr) < actualWidth) @@ -185,8 +185,8 @@ static Result SetGLGeometry(unsigned *xOffsetPtr, unsigned *yOffsetPtr, unsigned } // Write back resolution parameters - *xResPtr = (unsigned) xRes; - *yResPtr = (unsigned) yRes; + *xResPtr = (unsigned) xResF; + *yResPtr = (unsigned) yResF; UINT32 correction = (UINT32)(((*yResPtr / 384.) * 2.) + 0.5); // due to the 2D layer compensation (2 pixels off) @@ -1013,7 +1013,7 @@ int Supermodel(const Game &game, ROMSet *rom_set, IEmulator *Model3, CInputs *In Model3->Reset(); // Load initial save state if requested - if (initialState.length() > 0) + if (!initialState.empty()) LoadState(Model3, initialState); #ifdef SUPERMODEL_DEBUGGER @@ -1141,9 +1141,9 @@ int Supermodel(const Game &game, ROMSet *rom_set, IEmulator *Model3, CInputs *In // Resize screen totalXRes = xRes = s_runtime_config["XResolution"].ValueAs(); totalYRes = yRes = s_runtime_config["YResolution"].ValueAs(); - bool stretch = s_runtime_config["Stretch"].ValueAs(); - bool fullscreen = s_runtime_config["FullScreen"].ValueAs(); - if (Result::OKAY != ResizeGLScreen(&xOffset,&yOffset,&xRes,&yRes,&totalXRes,&totalYRes,!stretch,fullscreen)) + bool stretchc = s_runtime_config["Stretch"].ValueAs(); + bool fullscreenc = s_runtime_config["FullScreen"].ValueAs(); + if (Result::OKAY != ResizeGLScreen(&xOffset,&yOffset,&xRes,&yRes,&totalXRes,&totalYRes,!stretchc,fullscreenc)) goto QuitError; // Recreate renderers and attach to the emulator @@ -1383,7 +1383,7 @@ int Supermodel(const Game &game, ROMSet *rom_set, IEmulator *Model3, CInputs *In // Create and configure inputs static Result ConfigureInputs(CInputs *Inputs, Util::Config::Node *fileConfig, Util::Config::Node *runtimeConfig, const Game &game, bool configure) { - static const char configFileComment[] = { + static constexpr char configFileComment[] = { ";\n" "; Supermodel Configuration File\n" ";\n" @@ -1769,7 +1769,7 @@ static ParsedCommandLine ParseCommandLine(int argc, char **argv) { std::string option(arg.begin(), arg.begin() + idx_equals); std::string value(arg.begin() + idx_equals + 1, arg.end()); - if (value.length() == 0) + if (value.empty()) { ErrorLog("Argument to '%s' cannot be blank.", option.c_str()); cmd_line.error = true; @@ -2185,14 +2185,10 @@ int main(int argc, char **argv) delete Model3; Exit: - if (Inputs != NULL) - delete Inputs; - if (InputSystem != NULL) - delete InputSystem; - if (Outputs != NULL) - delete Outputs; - if (s_crosshair != NULL) - delete s_crosshair; + delete Inputs; + delete InputSystem; + delete Outputs; + delete s_crosshair; DestroyGLScreen(); SDL_Quit(); diff --git a/Src/OSD/SDL/SDLInputSystem.cpp b/Src/OSD/SDL/SDLInputSystem.cpp index 4c6c901a..a6bb4b73 100644 --- a/Src/OSD/SDL/SDLInputSystem.cpp +++ b/Src/OSD/SDL/SDLInputSystem.cpp @@ -174,8 +174,8 @@ CSDLInputSystem::CSDLInputSystem(const Util::Config::Node& config) m_mouseX(0), m_mouseY(0), m_mouseZ(0), - m_mouseButtons(0), - m_config(config) + m_config(config), + m_mouseButtons(0) { // } diff --git a/Src/OSD/Windows/DirectInputSystem.cpp b/Src/OSD/Windows/DirectInputSystem.cpp index 31855bbe..04cdc27d 100644 --- a/Src/OSD/Windows/DirectInputSystem.cpp +++ b/Src/OSD/Windows/DirectInputSystem.cpp @@ -355,8 +355,6 @@ static BOOL CALLBACK DI8EnumObjectsCallback(LPCDIDEVICEOBJECTINSTANCE instance, else if (instance->dwType & DIDFT_AXIS) { // If is an axis but couldn't match GUID above (which, according to MSDN, is an optional attribute), then flag error and try matching via offset - int objNum = DIDFT_GETINSTANCE(instance->dwType); - DIOBJECTDATAFORMAT fmt = c_dfDIJoystick2.rgodf[objNum]; diObjsContext->enumError = true; #ifdef _MSC_VER // MS VisualC++ switch (fmt.dwOfs) @@ -431,7 +429,7 @@ CDirectInputSystem::CDirectInputSystem(const Util::Config::Node &config, SDL_Win CInputSystem(ConstructName(useRawInput, useXInput)), m_config(config), m_useRawInput(useRawInput), m_useXInput(useXInput), m_enableFFeedback(true), - m_initializedCOM(false), m_activated(false), m_window(window), m_hwnd(NULL), m_screenW(0), m_screenH(0), + m_hwnd(NULL), m_screenW(0), m_screenH(0), m_initializedCOM(false), m_activated(false), m_window(window), m_getRIDevListPtr(NULL), m_getRIDevInfoPtr(NULL), m_regRIDevsPtr(NULL), m_getRIDataPtr(NULL), m_xiGetCapabilitiesPtr(NULL), m_xiGetStatePtr(NULL), m_xiSetStatePtr(NULL), m_di8(NULL), m_di8Keyboard(NULL), m_di8Mouse(NULL) { @@ -658,8 +656,8 @@ void CDirectInputSystem::OpenKeyboardsAndMice() DebugLog("RawInput - found %d keyboards and %d mice", m_rawKeyboards.size(), m_rawMice.size()); - // Check some devices were actually found - m_useRawInput = m_rawKeyboards.size() > 0 && m_rawMice.size() > 0; + // Check if some devices were actually found + m_useRawInput = !m_rawKeyboards.empty() && !m_rawMice.empty(); } else { @@ -668,8 +666,7 @@ void CDirectInputSystem::OpenKeyboardsAndMice() m_useRawInput = false; } - if (pDeviceList != NULL) - delete[] pDeviceList; + delete[] pDeviceList; } else { @@ -1325,7 +1322,7 @@ void CDirectInputSystem::PollJoysticks() // Map XInput state onto joystick's DirectInput state object XINPUT_GAMEPAD gamepad = xState.Gamepad; - pJoyState->lX = (LONG)gamepad.sThumbLX, + pJoyState->lX = (LONG)gamepad.sThumbLX; pJoyState->lY = (LONG)-gamepad.sThumbLY; pJoyState->lZ = (LONG)CInputSource::Scale(gamepad.bLeftTrigger, 0, 255, 0, 32767); pJoyState->lRx = (LONG)gamepad.sThumbRX; @@ -1569,7 +1566,7 @@ bool CDirectInputSystem::InitializeSystem() if (m_useRawInput) { // Get screen resolution (needed for absolute mouse devices) - DEVMODEA settings = { 0 }; + DEVMODEA settings{}; if (!EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &settings)) { ErrorLog("Unable to read current display settings\n"); diff --git a/Src/OSD/Windows/WinOutputs.cpp b/Src/OSD/Windows/WinOutputs.cpp index e7e2adf8..94e16542 100755 --- a/Src/OSD/Windows/WinOutputs.cpp +++ b/Src/OSD/Windows/WinOutputs.cpp @@ -130,7 +130,7 @@ bool CWinOutputs::CreateWindowClass() return true; // Setup description of window class - WNDCLASS wc = { 0 }; + WNDCLASS wc{}; wc.lpszClassName = OUTPUT_WINDOW_CLASS; wc.hInstance = GetModuleHandle(NULL); wc.lpfnWndProc = OutputWindowProcCallback; diff --git a/Src/Pkgs/unzip.c b/Src/Pkgs/unzip.c index bcfb9416..1b3fa2dc 100644 --- a/Src/Pkgs/unzip.c +++ b/Src/Pkgs/unzip.c @@ -1162,7 +1162,7 @@ extern int ZEXPORT unzGetCurrentFileInfo (unzFile file, pfile_info->internal_fa = file_info64.internal_fa; pfile_info->external_fa = file_info64.external_fa; - pfile_info->tmu_date = file_info64.tmu_date, + pfile_info->tmu_date = file_info64.tmu_date; pfile_info->compressed_size = (uLong)file_info64.compressed_size; diff --git a/Src/Sound/MPEG/MpegAudio.cpp b/Src/Sound/MPEG/MpegAudio.cpp index c33540ba..045f30e8 100644 --- a/Src/Sound/MPEG/MpegAudio.cpp +++ b/Src/Sound/MPEG/MpegAudio.cpp @@ -216,11 +216,11 @@ struct Decoder std::shared_ptr custom_mpeg_data; }; -static Decoder dec = { 0 }; +static Decoder dec{}; void MpegDec::SetMemory(const uint8_t *data, int offset, int length, bool loop) { - mp3dec_init(&dec.mp3d); + mp3dec_init(&dec.mp3d); auto it = s_custom_tracks_by_mpeg_rom_address.find(offset); if (it == s_custom_tracks_by_mpeg_rom_address.end()) { diff --git a/Src/Sound/SCSP.cpp b/Src/Sound/SCSP.cpp index 3aca9dc3..4159b8d7 100644 --- a/Src/Sound/SCSP.cpp +++ b/Src/Sound/SCSP.cpp @@ -94,7 +94,7 @@ static float* bufferrl; static float* bufferrr; static int length; -static const double srate=44100; +static constexpr double srate=44100; #define ICLIP16(x) (((x)<-32768)?-32768:(((x)>32767)?32767:(x))) @@ -149,7 +149,7 @@ static INT32 EG_TABLE[0x400]; static int volume[256 * 4]; // precalculated attenuation values with some marging for enveloppe and pan levels static int pan_left[32], pan_right[32]; // pan volume offsets #else -static const float SDLT[8] = { -1000000.0f,-36.0f,-30.0f,-24.0f,-18.0f,-12.0f,-6.0f,0.0f }; +static constexpr float SDLT[8] = { -1000000.0f,-36.0f,-30.0f,-24.0f,-18.0f,-12.0f,-6.0f,0.0f }; static int LPANTABLE[0x10000]; static int RPANTABLE[0x10000]; #endif @@ -226,11 +226,11 @@ static int TimCnt[3]; int ARTABLE[64],DRTABLE[64]; //Envelope times in ms -static const double ARTimes[64] = {100000/*infinity*/,100000/*infinity*/,8100.0,6900.0,6000.0,4800.0,4000.0,3400.0,3000.0,2400.0,2000.0,1700.0,1500.0, +static constexpr double ARTimes[64] = {100000/*infinity*/,100000/*infinity*/,8100.0,6900.0,6000.0,4800.0,4000.0,3400.0,3000.0,2400.0,2000.0,1700.0,1500.0, 1200.0,1000.0,860.0,760.0,600.0,500.0,430.0,380.0,300.0,250.0,220.0,190.0,150.0,130.0,110.0,95.0, 76.0,63.0,55.0,47.0,38.0,31.0,27.0,24.0,19.0,15.0,13.0,12.0,9.4,7.9,6.8,6.0,4.7,3.8,3.4,3.0,2.4, 2.0,1.8,1.6,1.3,1.1,0.93,0.85,0.65,0.53,0.44,0.40,0.35,0.0,0.0}; -static const double DRTimes[64] = {100000/*infinity*/,100000/*infinity*/,118200.0,101300.0,88600.0,70900.0,59100.0,50700.0,44300.0,35500.0,29600.0,25300.0,22200.0,17700.0, +static constexpr double DRTimes[64] = {100000/*infinity*/,100000/*infinity*/,118200.0,101300.0,88600.0,70900.0,59100.0,50700.0,44300.0,35500.0,29600.0,25300.0,22200.0,17700.0, 14800.0,12700.0,11100.0,8900.0,7400.0,6300.0,5500.0,4400.0,3700.0,3200.0,2800.0,2200.0,1800.0,1600.0,1400.0,1100.0, 920.0,790.0,690.0,550.0,460.0,390.0,340.0,270.0,230.0,200.0,170.0,140.0,110.0,98.0,85.0,68.0,57.0,49.0,43.0,34.0, 28.0,25.0,22.0,18.0,14.0,12.0,11.0,8.5,7.1,6.1,5.4,4.3,3.6,3.1}; @@ -1512,7 +1512,7 @@ void SCSP_CpuRunScanline() void SCSP_DoMasterSamples(int nsamples) { - const int slice = 11289600 / 44100; // 68K clocked at 11.2896MHz (45.1584MHz OSC / 4), which is 256 cycles/sample + constexpr int slice = 11289600 / 44100; // 68K clocked at 11.2896MHz (45.1584MHz OSC / 4), which is 256 cycles/sample static int lastdiff = 0; /* @@ -1634,10 +1634,10 @@ void SCSP_DoMasterSamples(int nsamples) } if (HasSlaveSCSP) { - _SLOT *slot = SCSPs[1].Slots + i; - if (EFSDL(slot)) + _SLOT *slot1 = SCSPs[1].Slots + i; + if (EFSDL(slot1)) { - UINT16 Enc = ((EFPAN(slot)) << 0x8) | ((EFSDL(slot)) << 0xe); + UINT16 Enc = ((EFPAN(slot1)) << 0x8) | ((EFSDL(slot1)) << 0xe); smprl += (int)(slaveBalance*(float)(((SCSPs[1].DSP.EFREG[i] * LPANTABLE[Enc]) >> SHIFT))); smprr += (int)(slaveBalance*(float)(((SCSPs[1].DSP.EFREG[i] * RPANTABLE[Enc]) >> SHIFT))); } @@ -1652,10 +1652,10 @@ void SCSP_DoMasterSamples(int nsamples) } if (HasSlaveSCSP) { - _SLOT *slot = SCSPs[1].Slots + i; - if (EFSDL(slot)) + _SLOT *slot1 = SCSPs[1].Slots + i; + if (EFSDL(slot1)) { - UINT16 Enc = ((EFPAN(slot)) << 0x8) | ((EFSDL(slot)) << 0xd); + UINT16 Enc = ((EFPAN(slot1)) << 0x8) | ((EFSDL(slot1)) << 0xd); smprl += (int)(slaveBalance*(float)(((SCSPs[1].DSP.EFREG[i] * LPANTABLE[Enc]) >> SHIFT))); smprr += (int)(slaveBalance*(float)(((SCSPs[1].DSP.EFREG[i] * RPANTABLE[Enc]) >> SHIFT))); } diff --git a/Src/Sound/SCSPDSP.cpp b/Src/Sound/SCSPDSP.cpp index e0c51bbd..e8ae9295 100644 --- a/Src/Sound/SCSPDSP.cpp +++ b/Src/Sound/SCSPDSP.cpp @@ -200,7 +200,7 @@ void SCSPDSP_Init(_SCSPDSP *DSP) { memset(DSP, 0, sizeof(_SCSPDSP)); DSP->RBL = (8 * 1024); // Initial RBL is 0 - DSP->Stopped = 1; + DSP->Stopped = true; } //#ifndef DYNDSP void SCSPDSP_Step(_SCSPDSP *DSP) @@ -455,7 +455,7 @@ void SCSPDSP_SetSample(_SCSPDSP *DSP, INT32 sample, int SEL, int MXL) void SCSPDSP_Start(_SCSPDSP *DSP) { int i; - DSP->Stopped = 0; + DSP->Stopped = false; for (i = 127; i >= 0; --i) { UINT16 *IPtr = DSP->MPRO + i * 4; @@ -479,13 +479,14 @@ void SCSPDSP_Start(_SCSPDSP *DSP) } */ - for(int t=0;t<0x10000;++t) +/* for(int t=0;t<0x10000;++t) { signed int unp=UNPACK(t); unsigned short t2=PACK(unp); if(t2!=t) int a=1; } +*/ #ifdef DYNDSP SCSPDSP_Recompile(DSP); diff --git a/Src/Sound/SCSPLFO.cpp b/Src/Sound/SCSPLFO.cpp index c0d06cf6..2ae023c5 100644 --- a/Src/Sound/SCSPLFO.cpp +++ b/Src/Sound/SCSPLFO.cpp @@ -49,13 +49,13 @@ struct _LFO static int PLFO_TRI[256], PLFO_SQR[256], PLFO_SAW[256], PLFO_NOI[256]; static int ALFO_TRI[256], ALFO_SQR[256], ALFO_SAW[256], ALFO_NOI[256]; -static const float LFOFreq[32] = +static constexpr float LFOFreq[32] = { 0.17f,0.19f,0.23f,0.27f,0.34f,0.39f,0.45f,0.55f,0.68f,0.78f,0.92f,1.10f,1.39f,1.60f,1.87f,2.27f, 2.87f,3.31f,3.92f,4.79f,6.15f,7.18f,8.60f,10.8f,14.4f,17.2f,21.5f,28.7f,43.1f,57.4f,86.1f,172.3f }; -static const float ASCALE[8] = {0.0f,0.4f,0.8f,1.5f,3.0f,6.0f,12.0f,24.0f}; -static const float PSCALE[8] = {0.0f,7.0f,13.5f,27.0f,55.0f,112.0f,230.0f,494.0f}; +static constexpr float ASCALE[8] = {0.0f,0.4f,0.8f,1.5f,3.0f,6.0f,12.0f,24.0f}; +static constexpr float PSCALE[8] = {0.0f,7.0f,13.5f,27.0f,55.0f,112.0f,230.0f,494.0f}; static int PSCALES[8][256]; static int ASCALES[8][256]; diff --git a/Src/Util/BMPFile.h b/Src/Util/BMPFile.h index 049ab54f..1ac5d03f 100644 --- a/Src/Util/BMPFile.h +++ b/Src/Util/BMPFile.h @@ -109,7 +109,7 @@ namespace Util struct RGBA8 { - static const unsigned bytes_per_pixel = 4; + static constexpr unsigned bytes_per_pixel = 4; static inline uint8_t GetRed(const uint8_t *pixel) { return pixel[0]; @@ -132,7 +132,7 @@ namespace Util template struct T1RGB5 { - static const unsigned bytes_per_pixel = 2; + static constexpr unsigned bytes_per_pixel = 2; static inline uint8_t GetRed(const uint8_t *pixel) { return uint8_t((255.0f / 31.0f) * float((*reinterpret_cast(pixel) >> 10) & 0x1f)); @@ -165,7 +165,7 @@ using T1RGB5ContourIgnored = T1RGB5; // Texture format 1: xxxx xxxx AAAA LLLL struct A4L4Low { - static const unsigned bytes_per_pixel = 2; + static constexpr unsigned bytes_per_pixel = 2; static inline uint8_t GetRed(const uint8_t* pixel) { return uint8_t((255.0f / 15.0f) * float((*reinterpret_cast(pixel) >> 0) & 0xf)); @@ -187,7 +187,7 @@ using T1RGB5ContourIgnored = T1RGB5; // Texture format 2: xxxx xxxx LLLL AAAA struct L4A4Low { - static const unsigned bytes_per_pixel = 2; + static constexpr unsigned bytes_per_pixel = 2; static inline uint8_t GetRed(const uint8_t* pixel) { return uint8_t((255.0f / 15.0f) * float((*reinterpret_cast(pixel) >> 4) & 0xf)); @@ -209,7 +209,7 @@ using T1RGB5ContourIgnored = T1RGB5; // Texture format 3: AAAA LLLL xxxx xxxx struct A4L4High { - static const unsigned bytes_per_pixel = 2; + static constexpr unsigned bytes_per_pixel = 2; static inline uint8_t GetRed(const uint8_t* pixel) { return uint8_t((255.0f / 15.0f) * float((*reinterpret_cast(pixel) >> 8) & 0xf)); @@ -231,7 +231,7 @@ using T1RGB5ContourIgnored = T1RGB5; // Texture format 4: LLLL AAAA xxxx xxxx struct L4A4High { - static const unsigned bytes_per_pixel = 2; + static constexpr unsigned bytes_per_pixel = 2; static inline uint8_t GetRed(const uint8_t* pixel) { return uint8_t((255.0f / 15.0f) * float((*reinterpret_cast(pixel) >> 12) & 0xf)); @@ -253,7 +253,7 @@ using T1RGB5ContourIgnored = T1RGB5; // Texture format 5: xxxx xxxx LLLL LLLL, where L=0xff is transparent and L!=0xff is opaque struct L8Low { - static const unsigned bytes_per_pixel = 2; + static constexpr unsigned bytes_per_pixel = 2; static inline uint8_t GetRed(const uint8_t* pixel) { return uint8_t((*reinterpret_cast(pixel) >> 0) & 0xff); @@ -276,7 +276,7 @@ using T1RGB5ContourIgnored = T1RGB5; // Texture format 6: LLLL LLLL xxxx xxxx, where L=0xff is transparent and L!=0xff is opaque struct L8High { - static const unsigned bytes_per_pixel = 2; + static constexpr unsigned bytes_per_pixel = 2; static inline uint8_t GetRed(const uint8_t* pixel) { return uint8_t((*reinterpret_cast(pixel) >> 8) & 0xff); @@ -299,7 +299,7 @@ using T1RGB5ContourIgnored = T1RGB5; // Texture format 7: RRRR GGGG BBBB AAAA struct RGBA4 { - static const unsigned bytes_per_pixel = 2; + static constexpr unsigned bytes_per_pixel = 2; static inline uint8_t GetRed(const uint8_t *pixel) { return uint8_t((255.0f / 15.0f) * float((*reinterpret_cast(pixel) >> 12) & 0xf)); @@ -325,7 +325,7 @@ using T1RGB5ContourIgnored = T1RGB5; template struct L4 { - static const unsigned bytes_per_pixel = 2; + static constexpr unsigned bytes_per_pixel = 2; static inline uint8_t GetRed(const uint8_t* pixel) { return uint8_t((255.0f / 15.0f) * float((*reinterpret_cast(pixel) >> (Channel * 4)) & 0xf)); diff --git a/Src/Util/BitCast.h b/Src/Util/BitCast.h index cb4aee85..0da45e1a 100644 --- a/Src/Util/BitCast.h +++ b/Src/Util/BitCast.h @@ -1,23 +1,25 @@ #ifndef INCLUDED_UTIL_BITCAST_H #define INCLUDED_UTIL_BITCAST_H -#include -#include #include -namespace Util -{ #if __cplusplus >= 202002L #include +namespace Util +{ #define FloatAsInt32(x) std::bit_cast(x) #define Int32AsFloat(x) std::bit_cast(x) #define Uint32AsFloat(x) std::bit_cast(x) #else +#include +#include +namespace Util +{ template inline Dest bit_cast(Source const& source) { static_assert(sizeof(Dest) == sizeof(Source), "size of destination and source objects must be equal"); - static_assert(std::is_trivially_copyable::value, "destination type must be trivially copyable."); - static_assert(std::is_trivially_copyable::value, "source type must be trivially copyable"); + static_assert(std::is_trivially_copyable_v, "destination type must be trivially copyable."); + static_assert(std::is_trivially_copyable_v, "source type must be trivially copyable"); Dest dest; std::memcpy(&dest, &source, sizeof(dest)); diff --git a/Src/Util/Format.cpp b/Src/Util/Format.cpp index df55349a..e841a995 100644 --- a/Src/Util/Format.cpp +++ b/Src/Util/Format.cpp @@ -39,7 +39,7 @@ namespace Util return std::string(str.c_str() + first, last - first); } - static const char hex_digits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; + static constexpr char hex_digits[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; std::string Hex(uint64_t n, size_t num_digits) { diff --git a/Src/Util/GenericValue.h b/Src/Util/GenericValue.h index aa57e0db..8920674f 100644 --- a/Src/Util/GenericValue.h +++ b/Src/Util/GenericValue.h @@ -29,19 +29,19 @@ namespace Util template struct IntegerEncodableAsHex { - static const bool value = std::is_integral::value && sizeof(T) >= 2 && sizeof(T) <= 8; + static const bool value = std::is_integral_v && sizeof(T) >= 2 && sizeof(T) <= 8; }; // This case should never actually be called template - static typename std::enable_if::value, T>::type ParseInteger(const std::string &str) + static typename std::enable_if_t::value, T> ParseInteger(const std::string &str) { return T(); } // This case will be generated for hex encodable integers and executed template - static typename std::enable_if::value, T>::type ParseInteger(const std::string &str) + static typename std::enable_if_t::value, T> ParseInteger(const std::string &str) { T tmp = 0; if (str.length() >= 3 && ( diff --git a/Src/Util/NewConfig.cpp b/Src/Util/NewConfig.cpp index 37826d8b..97256373 100644 --- a/Src/Util/NewConfig.cpp +++ b/Src/Util/NewConfig.cpp @@ -238,7 +238,7 @@ namespace Util if (Exists()) m_value->Serialize(os); *os << "\" children={"; - for (auto v: m_children) + for (const auto& v: m_children) *os << ' ' << v.first; *os << " }" << std::endl; for (ptr_t child = m_first_child; child; child = child->m_next_sibling) diff --git a/Src/Util/NewConfig.h b/Src/Util/NewConfig.h index c28e8f82..8154e590 100644 --- a/Src/Util/NewConfig.h +++ b/Src/Util/NewConfig.h @@ -4,7 +4,6 @@ #include "Util/GenericValue.h" #include #include -#include #include namespace Util From d9e1cc07e395838fb90afb633cd643d96332d5dc Mon Sep 17 00:00:00 2001 From: toxieainc Date: Thu, 3 Oct 2024 08:43:17 +0200 Subject: [PATCH 2/3] address reviews --- Src/GameLoader.cpp | 6 +++--- Src/Graphics/Render2D.cpp | 2 +- Src/Graphics/Render2D.h | 2 +- Src/OSD/Logger.cpp | 4 ++-- Src/OSD/Logger.h | 4 ++-- Src/Sound/SCSPDSP.cpp | 4 +++- Src/Sound/SCSPDSP.h | 9 ++------- Src/Util/NewConfig.cpp | 2 +- 8 files changed, 15 insertions(+), 18 deletions(-) diff --git a/Src/GameLoader.cpp b/Src/GameLoader.cpp index 99d53c3f..366ec23d 100644 --- a/Src/GameLoader.cpp +++ b/Src/GameLoader.cpp @@ -587,7 +587,7 @@ void GameLoader::IdentifyGamesInZipArchive( Region::ptr_t region = v2.second; if (!region->required) continue; - for (const auto& file: region->files) + for (const auto &file: region->files) { // Add each file to the set of required files per game files_required_by_game[game_name].insert(file); @@ -757,7 +757,7 @@ bool GameLoader::ComputeRegionSize(uint32_t *region_size, const GameLoader::Regi // use maximum end_addr = offset + stride * (num_chunks - 1) + chunk_size. std::vector end_addr; bool error = false; - for (const auto& file: region->files) + for (const auto &file: region->files) { const ZippedFile *zipped_file = LookupFile(file, zip); if (zipped_file) @@ -767,7 +767,7 @@ bool GameLoader::ComputeRegionSize(uint32_t *region_size, const GameLoader::Regi ErrorLog("File '%s' in '%s' is not sized in %d-byte chunks.", zipped_file->filename.c_str(), zipped_file->zipfilename.c_str(), region->chunk_size); error = true; } - uint32_t num_chunks = (uint32_t)(zipped_file->uncompressed_size / region->chunk_size); + uint32_t num_chunks = (uint32_t)(zipped_file->uncompressed_size / region->chunk_size); end_addr.push_back(file->offset + region->stride * (num_chunks - 1) + region->chunk_size); } else diff --git a/Src/Graphics/Render2D.cpp b/Src/Graphics/Render2D.cpp index beb6cf00..c917c90c 100644 --- a/Src/Graphics/Render2D.cpp +++ b/Src/Graphics/Render2D.cpp @@ -411,7 +411,7 @@ void CRender2D::AttachVRAM(const uint8_t* vramPtr) { } -void CRender2D::AttachDrawBuffers(const std::shared_ptr& bottom, const std::shared_ptr& top) +void CRender2D::AttachDrawBuffers(std::shared_ptr bottom, std::shared_ptr top) { m_drawBuffers[0] = bottom; m_drawBuffers[1] = top; diff --git a/Src/Graphics/Render2D.h b/Src/Graphics/Render2D.h index c87c7472..278b4b75 100644 --- a/Src/Graphics/Render2D.h +++ b/Src/Graphics/Render2D.h @@ -150,7 +150,7 @@ class CRender2D * bottom Bottom surface * top Top surface */ - void AttachDrawBuffers(const std::shared_ptr& bottom, const std::shared_ptr& top); + void AttachDrawBuffers(std::shared_ptr bottom, std::shared_ptr top); /* * Init(xOffset, yOffset, xRes, yRes, totalXRes, totalYRes); diff --git a/Src/OSD/Logger.cpp b/Src/OSD/Logger.cpp index bb2bbc71..dc161691 100644 --- a/Src/OSD/Logger.cpp +++ b/Src/OSD/Logger.cpp @@ -318,14 +318,14 @@ void CFileLogger::WriteToFiles(const char *str) } } -CFileLogger::CFileLogger(CLogger::LogLevel level, const std::vector& filenames) +CFileLogger::CFileLogger(CLogger::LogLevel level, const std::vector &filenames) : m_logLevel(level), m_logFilenames(filenames) { ReopenFiles(std::ios::out); } -CFileLogger::CFileLogger(CLogger::LogLevel level, const std::vector& filenames, const std::vector& systemFiles) +CFileLogger::CFileLogger(CLogger::LogLevel level, const std::vector &filenames, const std::vector &systemFiles) : m_logLevel(level), m_logFilenames(filenames), m_systemFiles(systemFiles) diff --git a/Src/OSD/Logger.h b/Src/OSD/Logger.h index ec46e686..d8c1d627 100644 --- a/Src/OSD/Logger.h +++ b/Src/OSD/Logger.h @@ -183,8 +183,8 @@ class CFileLogger: public CLogger void DebugLog(const char *fmt, va_list vl); void InfoLog(const char *fmt, va_list vl); void ErrorLog(const char *fmt, va_list vl); - CFileLogger(LogLevel level, const std::vector& filenames); - CFileLogger(LogLevel level, const std::vector& filenames, const std::vector& systemFiles); + CFileLogger(LogLevel level, const std::vector &filenames); + CFileLogger(LogLevel level, const std::vector &filenames, const std::vector &systemFiles); private: std::mutex m_mtx; // needed because we may close/reopen files and logging must be thread-safe diff --git a/Src/Sound/SCSPDSP.cpp b/Src/Sound/SCSPDSP.cpp index e8ae9295..2f4ecbd2 100644 --- a/Src/Sound/SCSPDSP.cpp +++ b/Src/Sound/SCSPDSP.cpp @@ -44,13 +44,15 @@ //#define USEFLOATPACK //the PACK func in asm plus mov [esi],ax -unsigned char PackFunc[]={0x8B,0xD8,0xA9,0x00,0x00,0x80,0x00,0x75,0x02,0xF7,0xD3,0xF7,0xD3,0x0F,0xBD,0xCB, +/*unsigned char PackFunc[]={0x8B,0xD8,0xA9,0x00,0x00,0x80,0x00,0x75,0x02,0xF7,0xD3,0xF7,0xD3,0x0F,0xBD,0xCB, 0xF7,0xD9,0xC1,0xE0,0x08,0x83,0xC1,0x16,0xD3,0xE0,0xC1,0xF8,0x13,0xC1,0xE1,0x0B, 0x25,0xFF,0x87,0x00,0x00,0x0B,0xC1,0x66,0x89,0x06}; unsigned char UnpackFunc[]={0x8B,0xD8,0x8B,0xC8,0x81,0xE3,0x00,0x80,0x00,0x00,0x25,0xFF,0x07, 0x00,0x00,0xC1,0xE9,0x0B,0xC1,0xE0,0x0B,0xC1,0xE3,0x08,0x83,0xE1,0x0F,0x0B,0xC3, 0xD1,0xEB,0x81,0xF3,0x00,0x00,0x40,0x00,0x0B,0xC3,0x83,0xC1,0x08,0xC1,0xE0,0x08, 0xD3,0xF8}; +*/ + //#if 0 //unsigned short inline PACK(signed int val) //{ diff --git a/Src/Sound/SCSPDSP.h b/Src/Sound/SCSPDSP.h index ea88bac3..c6c6c0d9 100644 --- a/Src/Sound/SCSPDSP.h +++ b/Src/Sound/SCSPDSP.h @@ -18,7 +18,7 @@ ** You should have received a copy of the GNU General Public License along ** with Supermodel. If not, see . **/ - + /* * SCSPDSP.h * @@ -32,8 +32,6 @@ #include "Types.h" //#define DYNDSP -#define DYNOPT 1 //set to 1 to enable optimization of recompiler - //the DSP Context struct _SCSPDSP @@ -84,7 +82,4 @@ void SCSPDSP_SetSample(_SCSPDSP *DSP,INT32 sample,int SEL,int MXL); void SCSPDSP_Step(_SCSPDSP *DSP); void SCSPDSP_Start(_SCSPDSP *DSP); - - - -#endif // INCLUDED_SCSPDSP_H \ No newline at end of file +#endif // INCLUDED_SCSPDSP_H diff --git a/Src/Util/NewConfig.cpp b/Src/Util/NewConfig.cpp index 97256373..a656765f 100644 --- a/Src/Util/NewConfig.cpp +++ b/Src/Util/NewConfig.cpp @@ -238,7 +238,7 @@ namespace Util if (Exists()) m_value->Serialize(os); *os << "\" children={"; - for (const auto& v: m_children) + for (const auto &v: m_children) *os << ' ' << v.first; *os << " }" << std::endl; for (ptr_t child = m_first_child; child; child = child->m_next_sibling) From 3f6fe29464b2cca7a5dd603c24bedd26d49861a6 Mon Sep 17 00:00:00 2001 From: toxieainc Date: Thu, 3 Oct 2024 08:55:15 +0200 Subject: [PATCH 3/3] some more from the review --- Src/Model3/53C810.h | 21 ++++++++++----------- Src/Network/NetBoard.h | 4 ---- Src/OSD/Logger.cpp | 2 +- 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/Src/Model3/53C810.h b/Src/Model3/53C810.h index ea04f6f8..7a4b88aa 100644 --- a/Src/Model3/53C810.h +++ b/Src/Model3/53C810.h @@ -18,7 +18,7 @@ ** You should have received a copy of the GNU General Public License along ** with Supermodel. If not, see . **/ - + /* * 53C810.h * @@ -42,7 +42,7 @@ struct NCR53C810Context { UINT8 regs[0x60]; - + // Registers defined below should not be read from here, not regs[] UINT32 regTEMP; // TEMP UINT32 regDSP; // DSP: DMA SCRIPTS Pointer @@ -54,13 +54,13 @@ struct NCR53C810Context UINT8 regDSTAT; // DSTAT: DMA Status (read only) UINT8 regDIEN; // DIEN: DMA Interrupt Enable UINT8 regISTAT; // ISTAT: Interrupt Status - + // Operational status bool halt; // set true if halted by interrupt instruction - + // Big endian bus object for DMA memory access and instruction fetching IBus *Bus; - + // IRQ handling CIRQ *IRQ; // IRQ controller unsigned scsiIRQ; // IRQ bit to use when calling IRQ handler @@ -93,7 +93,7 @@ class C53C810: public IPCIDevice * SaveState Block file to load state information from. */ void LoadState(CBlockFile *SaveState); - + /* * ReadRegister(reg): * @@ -104,7 +104,7 @@ class C53C810: public IPCIDevice * is ignored and returns 0. */ UINT8 ReadRegister(unsigned reg); - + /* * WriteRegister(reg, data): * @@ -119,7 +119,7 @@ class C53C810: public IPCIDevice * data Data to write. */ void WriteRegister(unsigned reg, UINT8 data); - + /* * ReadPCIConfigSpace(device, reg, bits, offset): * @@ -138,7 +138,7 @@ class C53C810: public IPCIDevice * Register data. */ UINT32 ReadPCIConfigSpace(unsigned device, unsigned reg, unsigned bits, unsigned offset); - + /* * WritePCIConfigSpace(device, reg, bits, offset, data): * @@ -205,8 +205,7 @@ class C53C810: public IPCIDevice // Context (register file) struct NCR53C810Context Ctx; - // IRQ controller and IRQ identifier for this SCSI controller - //CIRQ *IRQ; + // IRQ identifier for this SCSI controller unsigned scsiIRQ; // Base address of the SCSI device (varies by game) diff --git a/Src/Network/NetBoard.h b/Src/Network/NetBoard.h index 8799aaad..7bff8f8f 100644 --- a/Src/Network/NetBoard.h +++ b/Src/Network/NetBoard.h @@ -99,7 +99,6 @@ class CNetBoard : public IBus, public INetBoard UINT16 recv_size; UINT16 send_offset; UINT16 send_size; - //UINT8 slot; // netsock UINT16 port_in = 0; @@ -114,7 +113,6 @@ class CNetBoard : public IBus, public INetBoard // only for some tests UINT8 *bank; - //UINT8 *bank2; UINT8 test_irq; std::thread interrupt5; @@ -124,5 +122,3 @@ class CNetBoard : public IBus, public INetBoard void Net_SetCB(int(*Run68k)(int cycles), void(*Int68k)(int irq)); #endif // INCLUDED_NETBOARD_H - - diff --git a/Src/OSD/Logger.cpp b/Src/OSD/Logger.cpp index dc161691..122c4463 100644 --- a/Src/OSD/Logger.cpp +++ b/Src/OSD/Logger.cpp @@ -295,7 +295,7 @@ void CFileLogger::ReopenFiles(std::ios_base::openmode mode) m_logFiles.clear(); // (Re-)Open - for (const auto& filename: m_logFilenames) + for (const auto &filename: m_logFilenames) { std::ofstream ofs(filename.c_str(), mode); if (ofs.is_open() && ofs.good())