diff --git a/Core/Debugger.cpp b/Core/Debugger.cpp index fdb1ab31..19fc3217 100644 --- a/Core/Debugger.cpp +++ b/Core/Debugger.cpp @@ -275,7 +275,6 @@ void Debugger::ProcessBreakpoints(BreakpointType type, OperationInfo &operationI return; } - uint32_t absoluteAddr; AddressTypeInfo info { -1, AddressType::InternalRam }; PpuAddressTypeInfo ppuInfo { -1, PpuAddressType::None }; bool isPpuBreakpoint = false; @@ -284,13 +283,11 @@ void Debugger::ProcessBreakpoints(BreakpointType type, OperationInfo &operationI case BreakpointType::ReadRam: case BreakpointType::WriteRam: GetAbsoluteAddressAndType(operationInfo.Address, &info); - absoluteAddr = info.Address; break; case BreakpointType::ReadVram: case BreakpointType::WriteVram: GetPpuAbsoluteAddressAndType(operationInfo.Address, &ppuInfo); - absoluteAddr = ppuInfo.Address; isPpuBreakpoint = true; break; } @@ -446,7 +443,7 @@ void Debugger::StaticProcessEvent(EventType type) } } -void Debugger::ProcessStepConditions(uint32_t addr) +void Debugger::ProcessStepConditions(uint16_t addr) { if(_stepOut && (_lastInstruction == 0x60 || _lastInstruction == 0x40) && _stepOutReturnAddress == addr) { //RTS/RTI found, if we're on the expected return address, break immediately diff --git a/Core/Debugger.h b/Core/Debugger.h index d5542e7e..d2efeb90 100644 --- a/Core/Debugger.h +++ b/Core/Debugger.h @@ -137,7 +137,7 @@ private: void UpdateCallstack(uint8_t currentInstruction, uint32_t addr); void PrivateProcessInterrupt(uint16_t cpuAddr, uint16_t destCpuAddr, bool forNmi); - void ProcessStepConditions(uint32_t addr); + void ProcessStepConditions(uint16_t addr); bool SleepUntilResume(BreakSource source = BreakSource::Break); void AddDebugEvent(DebugEventType type, uint16_t address = -1, uint8_t value = 0, int16_t breakpointId = -1, int8_t ppuLatch = -1); diff --git a/Core/Disassembler.cpp b/Core/Disassembler.cpp index 620b8892..6f67964e 100644 --- a/Core/Disassembler.cpp +++ b/Core/Disassembler.cpp @@ -468,7 +468,7 @@ string Disassembler::GetCode(AddressTypeInfo &addressInfo, uint32_t endAddr, uin vector> *cache; uint8_t *source; - char memoryType; + char memoryType = 'P'; switch(addressInfo.Type) { case AddressType::InternalRam: memoryType = 'N'; break; case AddressType::PrgRom: memoryType = 'P'; break; @@ -489,7 +489,7 @@ string Disassembler::GetCode(AddressTypeInfo &addressInfo, uint32_t endAddr, uin string commentLines; shared_ptr infoRef; DisassemblyInfo* info; - DataType dataType; + DataType dataType = DataType::UnidentifiedData; string spaces = " "; string effAddress; string code; diff --git a/Core/FamilyBasicDataRecorder.h b/Core/FamilyBasicDataRecorder.h index c1a7508b..164b1b56 100644 --- a/Core/FamilyBasicDataRecorder.h +++ b/Core/FamilyBasicDataRecorder.h @@ -7,7 +7,7 @@ class FamilyBasicDataRecorder : public BaseControlDevice { private: - static const uint32_t SamplingRate = 88; + static const int32_t SamplingRate = 88; vector _data; vector _fileData; bool _enabled = false; diff --git a/Core/HdData.h b/Core/HdData.h index d768c374..5037ef3b 100644 --- a/Core/HdData.h +++ b/Core/HdData.h @@ -6,11 +6,11 @@ struct HdTileKey { - static const uint32_t NoTile = -1; + static const int32_t NoTile = -1; uint32_t PaletteColors; uint8_t TileData[16]; - uint32_t TileIndex; + int32_t TileIndex; bool IsChrRamTile = false; HdTileKey GetKey(bool defaultKey) diff --git a/Core/HdNesPack.cpp b/Core/HdNesPack.cpp index c902f7b5..05e0e098 100644 --- a/Core/HdNesPack.cpp +++ b/Core/HdNesPack.cpp @@ -29,12 +29,12 @@ void HdNesPack::BlendColors(uint8_t output[4], uint8_t input[4]) uint32_t HdNesPack::AdjustBrightness(uint8_t input[4], uint16_t brightness) { - uint8_t output[4]; - output[0] = std::min(255, (brightness * input[0]) >> 8); - output[1] = std::min(255, (brightness * input[1]) >> 8); - output[2] = std::min(255, (brightness * input[2]) >> 8); - output[3] = input[3]; - return *((uint32_t*)output); + return ( + std::min(255, (brightness * input[0]) >> 8) | + (std::min(255, (brightness * input[1]) >> 8) << 8) | + (std::min(255, (brightness * input[2]) >> 8) << 16) | + (input[3] << 24) + ); } void HdNesPack::DrawColor(uint32_t color, uint32_t *outputBuffer, uint32_t scale, uint32_t screenWidth) diff --git a/Core/HdPackBuilder.h b/Core/HdPackBuilder.h index 731d6905..20271b0f 100644 --- a/Core/HdPackBuilder.h +++ b/Core/HdPackBuilder.h @@ -31,7 +31,7 @@ private: uint32_t _flags; //Used to group blank tiles together - int _blankTileIndex = 0; + uint32_t _blankTileIndex = 0; int _blankTilePalette = 0; void AddTile(HdPackTileInfo *tile, uint32_t usageCount); diff --git a/Core/HdPackLoader.cpp b/Core/HdPackLoader.cpp index 366d0c94..dc834ce8 100644 --- a/Core/HdPackLoader.cpp +++ b/Core/HdPackLoader.cpp @@ -292,6 +292,7 @@ void HdPackLoader::ProcessTileTag(vector &tokens, vectorTileData[i] = HexUtilities::FromHex(tileData.substr(i * 2, 2)); } tileInfo->IsChrRamTile = true; + tileInfo->TileIndex = -1; } else { tileInfo->TileIndex = std::stoi(tileData); tileInfo->IsChrRamTile = false; @@ -453,6 +454,8 @@ void HdPackLoader::ProcessConditionTag(vector &tokens, bool createInvert op = HdPackConditionOperator::GreaterThan; } else if(opString == "<") { op = HdPackConditionOperator::LowerThan; + } else { + checkConstraint(false, "[HDPack] Invalid operator."); } uint32_t operandB = HexUtilities::FromHex(tokens[index++]); diff --git a/Core/NtscFilter.cpp b/Core/NtscFilter.cpp index 88b9d736..2b4d0d0a 100644 --- a/Core/NtscFilter.cpp +++ b/Core/NtscFilter.cpp @@ -14,13 +14,25 @@ NtscFilter::NtscFilter() FrameInfo NtscFilter::GetFrameInfo() { OverscanDimensions overscan = GetOverscan(); - int overscanLeft = overscan.Left > 0 ? NES_NTSC_OUT_WIDTH(overscan.Left) : 0; - int overscanRight = overscan.Right > 0 ? NES_NTSC_OUT_WIDTH(overscan.Right) : 0; + uint32_t overscanLeft = overscan.Left > 0 ? NES_NTSC_OUT_WIDTH(overscan.Left) : 0; + uint32_t overscanRight = overscan.Right > 0 ? NES_NTSC_OUT_WIDTH(overscan.Right) : 0; if(_keepVerticalRes) { - return { NES_NTSC_OUT_WIDTH(PPU::ScreenWidth) - overscanLeft - overscanRight, (PPU::ScreenHeight - overscan.Top - overscan.Bottom), NES_NTSC_OUT_WIDTH(PPU::ScreenWidth), PPU::ScreenHeight, 4 }; + return { + (NES_NTSC_OUT_WIDTH(PPU::ScreenWidth) - overscanLeft - overscanRight), + (PPU::ScreenHeight - overscan.Top - overscan.Bottom), + NES_NTSC_OUT_WIDTH(PPU::ScreenWidth), + PPU::ScreenHeight, + 4 + }; } else { - return { NES_NTSC_OUT_WIDTH(PPU::ScreenWidth) - overscanLeft - overscanRight, (PPU::ScreenHeight - overscan.Top - overscan.Bottom) * 2, NES_NTSC_OUT_WIDTH(PPU::ScreenWidth), PPU::ScreenHeight * 2, 4 }; + return { + NES_NTSC_OUT_WIDTH(PPU::ScreenWidth) - overscanLeft - overscanRight, + (PPU::ScreenHeight - overscan.Top - overscan.Bottom) * 2, + NES_NTSC_OUT_WIDTH(PPU::ScreenWidth), + PPU::ScreenHeight * 2, + 4 + }; } } diff --git a/Core/PPU.h b/Core/PPU.h index db50e436..14d923b1 100644 --- a/Core/PPU.h +++ b/Core/PPU.h @@ -159,10 +159,10 @@ class PPU : public IMemoryHandler, public Snapshotable void StreamState(bool saving) override; public: - static const uint32_t ScreenWidth = 256; - static const uint32_t ScreenHeight = 240; - static const uint32_t PixelCount = 256*240; - static const uint32_t OutputBufferSize = 256*240*2; + static const int32_t ScreenWidth = 256; + static const int32_t ScreenHeight = 240; + static const int32_t PixelCount = 256*240; + static const int32_t OutputBufferSize = 256*240*2; PPU(BaseMapper *mapper, ControlManager *controlManager); virtual ~PPU(); diff --git a/Core/RewindManager.cpp b/Core/RewindManager.cpp index b8b4d7e4..11bc0174 100644 --- a/Core/RewindManager.cpp +++ b/Core/RewindManager.cpp @@ -226,7 +226,7 @@ void RewindManager::ProcessFrame(void * frameBuffer, uint32_t width, uint32_t he _videoHistoryBuilder.push_back(vector((uint32_t*)frameBuffer, (uint32_t*)frameBuffer + width*height)); - if(_videoHistoryBuilder.size() == _historyBackup.front().FrameCount) { + if(_videoHistoryBuilder.size() == (size_t)_historyBackup.front().FrameCount) { for(int i = (int)_videoHistoryBuilder.size() - 1; i >= 0; i--) { _videoHistory.push_front(_videoHistoryBuilder[i]); } diff --git a/Core/RewindManager.h b/Core/RewindManager.h index 7b1073a2..8fe07ee7 100644 --- a/Core/RewindManager.h +++ b/Core/RewindManager.h @@ -18,7 +18,7 @@ enum class RewindState class RewindManager : public INotificationListener, public IInputProvider, public IInputRecorder { private: - static const uint32_t BufferSize = 30; //Number of frames between each save state + static const int32_t BufferSize = 30; //Number of frames between each save state static RewindManager* _instance; std::deque _history; std::deque _historyBackup; diff --git a/Core/TraceLogger.cpp b/Core/TraceLogger.cpp index 47f51fa4..20e5b985 100644 --- a/Core/TraceLogger.cpp +++ b/Core/TraceLogger.cpp @@ -67,7 +67,7 @@ void TraceLogger::StopLogging() } } -void TraceLogger::LogStatic(char *log) +void TraceLogger::LogStatic(const char *log) { if(_instance && _instance->_logToFile && _instance->_options.ShowExtraInfo) { LogStatic(string(log)); diff --git a/Core/TraceLogger.h b/Core/TraceLogger.h index 0c22cc0d..75fe5440 100644 --- a/Core/TraceLogger.h +++ b/Core/TraceLogger.h @@ -88,7 +88,7 @@ public: const char* GetExecutionTrace(uint32_t lineCount); - static void LogStatic(char *log); + static void LogStatic(const char *log); static void LogStatic(string log); }; \ No newline at end of file diff --git a/Utilities/BpsPatcher.cpp b/Utilities/BpsPatcher.cpp index a6dd83dc..f958f194 100644 --- a/Utilities/BpsPatcher.cpp +++ b/Utilities/BpsPatcher.cpp @@ -4,9 +4,9 @@ #include "BpsPatcher.h" #include "CRC32.h" -uint64_t BpsPatcher::ReadBase128Number(std::istream &file) +int64_t BpsPatcher::ReadBase128Number(std::istream &file) { - uint64_t result = 0; + int64_t result = 0; int shift = 0; uint8_t buffer; while(true) { @@ -19,7 +19,7 @@ uint64_t BpsPatcher::ReadBase128Number(std::istream &file) if(buffer & 0x80) { break; } - result += (uint64_t)1 << shift; + result += (int64_t)1 << shift; } return result; @@ -47,14 +47,14 @@ bool BpsPatcher::PatchBuffer(std::istream &bpsFile, vector &input, vect return false; } - uint64_t inputFileSize = ReadBase128Number(bpsFile); - uint64_t outputFileSize = ReadBase128Number(bpsFile); + int64_t inputFileSize = ReadBase128Number(bpsFile); + int64_t outputFileSize = ReadBase128Number(bpsFile); if(inputFileSize == -1 || outputFileSize == -1) { //Invalid file return false; } - uint64_t metadataSize = ReadBase128Number(bpsFile); + int64_t metadataSize = ReadBase128Number(bpsFile); bpsFile.seekg(metadataSize, std::ios::cur); output.resize((size_t)outputFileSize); @@ -63,7 +63,7 @@ bool BpsPatcher::PatchBuffer(std::istream &bpsFile, vector &input, vect uint32_t inputRelativeOffset = 0; uint32_t outputRelativeOffset = 0; while((size_t)bpsFile.tellg() < fileSize - 12) { - uint64_t data = ReadBase128Number(bpsFile); + int64_t data = ReadBase128Number(bpsFile); if(data == -1) { //Invalid file return false; @@ -92,7 +92,7 @@ bool BpsPatcher::PatchBuffer(std::istream &bpsFile, vector &input, vect case 2: { //SourceCopy - uint32_t data = (uint32_t)ReadBase128Number(bpsFile); + int32_t data = (int32_t)ReadBase128Number(bpsFile); inputRelativeOffset += (data & 1 ? -1 : +1) * (data >> 1); while(length--) { output[outputOffset++] = input[inputRelativeOffset++]; @@ -102,7 +102,7 @@ bool BpsPatcher::PatchBuffer(std::istream &bpsFile, vector &input, vect case 3: { //TargetCopy - uint32_t data = (uint32_t)ReadBase128Number(bpsFile); + int32_t data = (int32_t)ReadBase128Number(bpsFile); outputRelativeOffset += (data & 1 ? -1 : +1) * (data >> 1); while(length--) { output[outputOffset++] = output[outputRelativeOffset++]; diff --git a/Utilities/BpsPatcher.h b/Utilities/BpsPatcher.h index 6179f748..f10bb13d 100644 --- a/Utilities/BpsPatcher.h +++ b/Utilities/BpsPatcher.h @@ -5,7 +5,7 @@ class BpsPatcher { private: - static uint64_t ReadBase128Number(std::istream &file); + static int64_t ReadBase128Number(std::istream &file); public: static bool PatchBuffer(std::istream &bpsFile, vector &input, vector &output); diff --git a/Utilities/UpsPatcher.cpp b/Utilities/UpsPatcher.cpp index 3e69117d..1c3a72bc 100644 --- a/Utilities/UpsPatcher.cpp +++ b/Utilities/UpsPatcher.cpp @@ -4,9 +4,9 @@ #include "UpsPatcher.h" #include "CRC32.h" -uint64_t UpsPatcher::ReadBase128Number(std::istream &file) +int64_t UpsPatcher::ReadBase128Number(std::istream &file) { - uint64_t result = 0; + int64_t result = 0; int shift = 0; uint8_t buffer; while(true) { @@ -19,7 +19,7 @@ uint64_t UpsPatcher::ReadBase128Number(std::istream &file) if(buffer & 0x80) { break; } - result += (uint64_t)1 << shift; + result += (int64_t)1 << shift; } return result; @@ -47,8 +47,8 @@ bool UpsPatcher::PatchBuffer(std::istream &upsFile, vector &input, vect return false; } - uint64_t inputFileSize = ReadBase128Number(upsFile); - uint64_t outputFileSize = ReadBase128Number(upsFile); + int64_t inputFileSize = ReadBase128Number(upsFile); + int64_t outputFileSize = ReadBase128Number(upsFile); if(inputFileSize == -1 || outputFileSize == -1) { //Invalid file return false; @@ -59,7 +59,7 @@ bool UpsPatcher::PatchBuffer(std::istream &upsFile, vector &input, vect uint32_t pos = 0; while((size_t)upsFile.tellg() < fileSize - 12) { - uint32_t offset = (uint32_t)ReadBase128Number(upsFile); + int32_t offset = (int32_t)ReadBase128Number(upsFile); if(offset == -1) { //Invalid file return false; diff --git a/Utilities/UpsPatcher.h b/Utilities/UpsPatcher.h index b6762b16..bf75b1e9 100644 --- a/Utilities/UpsPatcher.h +++ b/Utilities/UpsPatcher.h @@ -5,7 +5,7 @@ class UpsPatcher { private: - static uint64_t ReadBase128Number(std::istream &file); + static int64_t ReadBase128Number(std::istream &file); public: static bool PatchBuffer(std::istream &upsFile, vector &input, vector &output); diff --git a/makefile b/makefile index 2a187638..bad3491f 100644 --- a/makefile +++ b/makefile @@ -21,7 +21,7 @@ MESENFLAGS= libretro : MESENFLAGS=-D LIBRETRO CPPC=clang++ -GCCOPTIONS=-fPIC -Wall --std=c++14 -O3 $(MESENFLAGS) +GCCOPTIONS=-fPIC -Wall --std=c++14 -O3 $(MESENFLAGS) -Wno-parentheses -Wno-switch CC=clang CCOPTIONS=-fPIC -Wall -O3 $(MESENFLAGS) @@ -90,7 +90,7 @@ testhelper: InteropDLL/$(OBJFOLDER)/$(SHAREDLIB) $(AR) TestHelper/$(OBJFOLDER)/libMesenLinux.a $(LINUXOBJ) $(LIBEVDEVOBJ) $(AR) TestHelper/$(OBJFOLDER)/libUtilities.a $(UTILOBJ) $(AR) TestHelper/$(OBJFOLDER)/libCore.a $(COREOBJ) - cd TestHelper/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) $(LINKFLAG) -Wl,-z,defs -Wno-parentheses -Wno-switch -o testhelper ../*.cpp ../../InteropDLL/ConsoleWrapper.cpp -L ./ -lCore -lMesenLinux -lUtilities -lSevenZip -pthread -lSDL2 -lstdc++fs + cd TestHelper/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) $(LINKFLAG) -Wl,-z,defs -o testhelper ../*.cpp ../../InteropDLL/ConsoleWrapper.cpp -L ./ -lCore -lMesenLinux -lUtilities -lSevenZip -pthread -lSDL2 -lstdc++fs SevenZip/$(OBJFOLDER)/%.o: SevenZip/%.c mkdir -p SevenZip/$(OBJFOLDER) && cd SevenZip/$(OBJFOLDER) && $(CC) $(CCOPTIONS) -c $(patsubst SevenZip/%, ../%, $<) @@ -107,11 +107,11 @@ Utilities/$(OBJFOLDER)/%.o: Utilities/KreedSaiEagle/%.cpp Utilities/$(OBJFOLDER)/%.o: Utilities/Scale2x/%.cpp mkdir -p Utilities/$(OBJFOLDER) && cd Utilities/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -c $(patsubst Utilities/%, ../%, $<) Core/$(OBJFOLDER)/%.o: Core/%.cpp - mkdir -p Core/$(OBJFOLDER) && cd Core/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -Wno-parentheses -Wno-switch -c $(patsubst Core/%, ../%, $<) + mkdir -p Core/$(OBJFOLDER) && cd Core/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -c $(patsubst Core/%, ../%, $<) Linux/$(OBJFOLDER)/%.o: Linux/%.cpp - mkdir -p Linux/$(OBJFOLDER) && cd Linux/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -Wno-parentheses -Wno-switch -c $(patsubst Linux/%, ../%, $<) + mkdir -p Linux/$(OBJFOLDER) && cd Linux/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -c $(patsubst Linux/%, ../%, $<) Linux/$(OBJFOLDER)/%.o: Linux/libevdev/%.c - mkdir -p Linux/$(OBJFOLDER) && cd Linux/$(OBJFOLDER) && $(CC) $(CCOPTIONS) -Wno-parentheses -Wno-switch -c $(patsubst Linux/%, ../%, $<) + mkdir -p Linux/$(OBJFOLDER) && cd Linux/$(OBJFOLDER) && $(CC) $(CCOPTIONS) -c $(patsubst Linux/%, ../%, $<) InteropDLL/$(OBJFOLDER)/$(SHAREDLIB): $(SEVENZIPOBJ) $(LUAOBJ) $(UTILOBJ) $(COREOBJ) $(LIBEVDEVOBJ) $(LINUXOBJ) InteropDLL/ConsoleWrapper.cpp InteropDLL/DebugWrapper.cpp mkdir -p InteropDLL/$(OBJFOLDER) @@ -120,7 +120,7 @@ InteropDLL/$(OBJFOLDER)/$(SHAREDLIB): $(SEVENZIPOBJ) $(LUAOBJ) $(UTILOBJ) $(CORE $(AR) InteropDLL/$(OBJFOLDER)/libMesenLinux.a $(LINUXOBJ) $(LIBEVDEVOBJ) $(AR) InteropDLL/$(OBJFOLDER)/libUtilities.a $(UTILOBJ) $(AR) InteropDLL/$(OBJFOLDER)/libCore.a $(COREOBJ) - cd InteropDLL/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) $(LINKFLAG) -Wl,-z,defs -Wno-parentheses -Wno-switch -shared -o $(SHAREDLIB) ../*.cpp -L . -lMesenLinux -lCore -lUtilities -lLua -lSevenZip -pthread -lSDL2 -lstdc++fs + cd InteropDLL/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) $(LINKFLAG) -Wl,-z,defs -shared -o $(SHAREDLIB) ../*.cpp -L . -lMesenLinux -lCore -lUtilities -lLua -lSevenZip -pthread -lSDL2 -lstdc++fs Libretro/$(OBJFOLDER)/$(LIBRETROLIB): $(SEVENZIPOBJ) $(UTILOBJ) $(COREOBJ) Libretro/libretro.cpp @@ -128,7 +128,7 @@ Libretro/$(OBJFOLDER)/$(LIBRETROLIB): $(SEVENZIPOBJ) $(UTILOBJ) $(COREOBJ) Libre $(AR) Libretro/$(OBJFOLDER)/libSevenZip.a $(SEVENZIPOBJ) $(AR) Libretro/$(OBJFOLDER)/libUtilities.a $(UTILOBJ) $(AR) Libretro/$(OBJFOLDER)/libCore.a $(COREOBJ) - cd Libretro/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) $(LINKFLAG) -Wl,-z,defs -Wno-parentheses -Wno-switch -shared -o $(LIBRETROLIB) ../*.cpp -L . -lCore -lUtilities -lSevenZip -pthread + cd Libretro/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) $(LINKFLAG) -Wl,-z,defs -shared -o $(LIBRETROLIB) ../*.cpp -L . -lCore -lUtilities -lSevenZip -pthread debug: MONO_LOG_LEVEL=debug mono $(RELEASEFOLDER)/Mesen.exe