From ab0fe3c6e1736254dd2927bba3c246b6ab09d836 Mon Sep 17 00:00:00 2001 From: Sour Date: Sun, 6 Jun 2021 13:29:45 -0400 Subject: [PATCH] Minor fixes --- Core/Gameboy/Gameboy.cpp | 2 +- Core/Gameboy/GbDefaultVideoFilter.h | 4 +-- Core/NES/APU/ApuTimer.h | 1 - Core/NES/Debugger/NesAssembler.cpp | 1 - Core/NES/Debugger/NesAssembler.h | 3 ++- Core/NES/MapperFactory.cpp | 1 + Core/NES/NesDefaultVideoFilter.h | 4 +-- Core/SNES/Debugger/SnesAssembler.cpp | 1 - Core/SNES/SnesDefaultVideoFilter.h | 2 +- Core/Shared/ShortcutKeyHandler.cpp | 2 -- Core/Shared/ShortcutKeyHandler.h | 4 +-- makefile | 40 ++++++++++++++-------------- 12 files changed, 31 insertions(+), 34 deletions(-) diff --git a/Core/Gameboy/Gameboy.cpp b/Core/Gameboy/Gameboy.cpp index 90beb3be..343b4b9b 100644 --- a/Core/Gameboy/Gameboy.cpp +++ b/Core/Gameboy/Gameboy.cpp @@ -417,7 +417,7 @@ LoadRomResult Gameboy::LoadRom(VirtualFile& romFile) GbCart* cart = GbCartFactory::CreateCart(header.CartType); if(cart) { - Init(cart, romData, header.GetCartRamSize(), header.HasBattery(), (header.CgbFlag & 0x80) != false); + Init(cart, romData, header.GetCartRamSize(), header.HasBattery(), (header.CgbFlag & 0x80) != 0); return LoadRomResult::Success; } } diff --git a/Core/Gameboy/GbDefaultVideoFilter.h b/Core/Gameboy/GbDefaultVideoFilter.h index 3e96f8ec..09c19916 100644 --- a/Core/Gameboy/GbDefaultVideoFilter.h +++ b/Core/Gameboy/GbDefaultVideoFilter.h @@ -21,7 +21,7 @@ private: __forceinline uint32_t GetPixel(uint16_t* ppuFrame, uint32_t offset); protected: - void OnBeforeApplyFilter(); + void OnBeforeApplyFilter() override; public: GbDefaultVideoFilter(Emulator* emu); @@ -29,5 +29,5 @@ public: FrameInfo GetFrameInfo() override; - void ApplyFilter(uint16_t* ppuOutputBuffer); + void ApplyFilter(uint16_t* ppuOutputBuffer) override; }; \ No newline at end of file diff --git a/Core/NES/APU/ApuTimer.h b/Core/NES/APU/ApuTimer.h index 35e75767..017710f4 100644 --- a/Core/NES/APU/ApuTimer.h +++ b/Core/NES/APU/ApuTimer.h @@ -60,7 +60,6 @@ public: int32_t cyclesToRun = targetCycle - _previousCycle; if(cyclesToRun > _timer) { - cyclesToRun -= _timer + 1; _previousCycle += _timer + 1; _timer = _period; return true; diff --git a/Core/NES/Debugger/NesAssembler.cpp b/Core/NES/Debugger/NesAssembler.cpp index 76d7ab9f..3d900d01 100644 --- a/Core/NES/Debugger/NesAssembler.cpp +++ b/Core/NES/Debugger/NesAssembler.cpp @@ -400,7 +400,6 @@ uint32_t NesAssembler::AssembleCode(string code, uint32_t startAddress, int16_t* std::unordered_map temporaryLabels; std::unordered_map currentPassLabels; - size_t i = 0; vector output; output.reserve(1000); diff --git a/Core/NES/Debugger/NesAssembler.h b/Core/NES/Debugger/NesAssembler.h index 69c08aa1..d530e213 100644 --- a/Core/NES/Debugger/NesAssembler.h +++ b/Core/NES/Debugger/NesAssembler.h @@ -20,7 +20,7 @@ struct NesLineData bool HasOpeningParenthesis = false; }; -class NesAssembler : public IAssembler +class NesAssembler final : public IAssembler { private: std::unordered_map> _availableModesByOpName; @@ -36,6 +36,7 @@ private: public: NesAssembler(shared_ptr labelManager); + virtual ~NesAssembler() = default; uint32_t AssembleCode(string code, uint32_t startAddress, int16_t* assembledCode); }; \ No newline at end of file diff --git a/Core/NES/MapperFactory.cpp b/Core/NES/MapperFactory.cpp index e9c8d74f..9e390f64 100644 --- a/Core/NES/MapperFactory.cpp +++ b/Core/NES/MapperFactory.cpp @@ -691,6 +691,7 @@ unique_ptr MapperFactory::InitializeFromFile(NesConsole* console, Vi } else { //File is a valid NES file, but it couldn't be loaded result = LoadRomResult::Failure; + return nullptr; } } result = LoadRomResult::UnknownType; diff --git a/Core/NES/NesDefaultVideoFilter.h b/Core/NES/NesDefaultVideoFilter.h index 85fafba0..cf49aefe 100644 --- a/Core/NES/NesDefaultVideoFilter.h +++ b/Core/NES/NesDefaultVideoFilter.h @@ -18,7 +18,7 @@ private: protected: void DecodePpuBuffer(uint16_t* ppuOutputBuffer, uint32_t* outputBuffer, bool displayScanlines); - void OnBeforeApplyFilter(); + void OnBeforeApplyFilter() override; public: NesDefaultVideoFilter(Emulator* emu); @@ -26,5 +26,5 @@ public: static void GenerateFullColorPalette(uint32_t paletteBuffer[512]); static void GetFullPalette(uint32_t palette[512], NesConfig& nesCfg, PpuModel model); - void ApplyFilter(uint16_t* ppuOutputBuffer); + void ApplyFilter(uint16_t* ppuOutputBuffer) override; }; \ No newline at end of file diff --git a/Core/SNES/Debugger/SnesAssembler.cpp b/Core/SNES/Debugger/SnesAssembler.cpp index 16288f35..38f3def1 100644 --- a/Core/SNES/Debugger/SnesAssembler.cpp +++ b/Core/SNES/Debugger/SnesAssembler.cpp @@ -431,7 +431,6 @@ uint32_t SnesAssembler::AssembleCode(string code, uint32_t startAddress, int16_t std::unordered_map temporaryLabels; std::unordered_map currentPassLabels; - size_t i = 0; vector output; output.reserve(1000); diff --git a/Core/SNES/SnesDefaultVideoFilter.h b/Core/SNES/SnesDefaultVideoFilter.h index 9018e02f..673f041f 100644 --- a/Core/SNES/SnesDefaultVideoFilter.h +++ b/Core/SNES/SnesDefaultVideoFilter.h @@ -19,7 +19,7 @@ private: __forceinline uint32_t GetPixel(uint16_t* ppuFrame, uint32_t offset); protected: - void OnBeforeApplyFilter(); + void OnBeforeApplyFilter() override; public: SnesDefaultVideoFilter(Emulator* emu); diff --git a/Core/Shared/ShortcutKeyHandler.cpp b/Core/Shared/ShortcutKeyHandler.cpp index a8eaa98e..9db62479 100644 --- a/Core/Shared/ShortcutKeyHandler.cpp +++ b/Core/Shared/ShortcutKeyHandler.cpp @@ -269,8 +269,6 @@ void ShortcutKeyHandler::ProcessShortcutReleased(EmulatorShortcut shortcut) void ShortcutKeyHandler::CheckMappedKeys() { - EmuSettings* settings = _emu->GetSettings(); - //Let the UI handle these shortcuts for(uint64_t i = 0; i < (uint64_t)EmulatorShortcut::ShortcutCount; i++) { EmulatorShortcut shortcut = (EmulatorShortcut)i; diff --git a/Core/Shared/ShortcutKeyHandler.h b/Core/Shared/ShortcutKeyHandler.h index be56c334..d44eb1da 100644 --- a/Core/Shared/ShortcutKeyHandler.h +++ b/Core/Shared/ShortcutKeyHandler.h @@ -7,7 +7,7 @@ class Emulator; -class ShortcutKeyHandler : public INotificationListener, public std::enable_shared_from_this +class ShortcutKeyHandler final : public INotificationListener, public std::enable_shared_from_this { private: Emulator* _emu; @@ -43,7 +43,7 @@ private: public: ShortcutKeyHandler(Emulator* emu); - ~ShortcutKeyHandler(); + virtual ~ShortcutKeyHandler(); bool IsShortcutAllowed(EmulatorShortcut shortcut); void ProcessKeys(); diff --git a/makefile b/makefile index 6492117e..da7d7e16 100644 --- a/makefile +++ b/makefile @@ -21,45 +21,45 @@ MESENFLAGS= libretro : MESENFLAGS=-D LIBRETRO ifeq ($(USE_GCC),true) - CPPC=g++ + CXX=g++ CC=gcc PROFILE_GEN_FLAG=-fprofile-generate PROFILE_USE_FLAG=-fprofile-use else - CPPC=clang++ + CXX=clang++ CC=clang PROFILE_GEN_FLAG = -fprofile-instr-generate=$(CURDIR)/PGOHelper/pgo.profraw PROFILE_USE_FLAG = -fprofile-instr-use=$(CURDIR)/PGOHelper/pgo.profdata endif -GCCOPTIONS=-fPIC -Wall --std=c++17 -O3 $(MESENFLAGS) -I/usr/include/SDL2 -I $(realpath ./) -I $(realpath ./Core) -I $(realpath ./Utilities) -I $(realpath ./Linux) -CCOPTIONS=-fPIC -Wall -O3 $(MESENFLAGS) +CXXFLAGS=-fPIC -Wall --std=c++17 -O3 $(MESENFLAGS) -I/usr/include/SDL2 -I $(realpath ./) -I $(realpath ./Core) -I $(realpath ./Utilities) -I $(realpath ./Linux) +CFLAGS=-fPIC -Wall -O3 $(MESENFLAGS) LINKOPTIONS= ifeq ($(MESENPLATFORM),x86) MESENPLATFORM=x86 - GCCOPTIONS += -m32 - CCOPTIONS += -m32 + CXXFLAGS += -m32 + CFLAGS += -m32 else MESENPLATFORM=x64 - GCCOPTIONS += -m64 - CCOPTIONS += -m64 + CXXFLAGS += -m64 + CFLAGS += -m64 endif ifeq ($(LTO),true) - CCOPTIONS += -flto - GCCOPTIONS += -flto + CFLAGS += -flto + CXXFLAGS += -flto endif ifeq ($(PGO),profile) - CCOPTIONS += ${PROFILE_GEN_FLAG} - GCCOPTIONS += ${PROFILE_GEN_FLAG} + CFLAGS += ${PROFILE_GEN_FLAG} + CXXFLAGS += ${PROFILE_GEN_FLAG} endif ifeq ($(PGO),optimize) - CCOPTIONS += ${PROFILE_USE_FLAG} - GCCOPTIONS += ${PROFILE_USE_FLAG} + CFLAGS += ${PROFILE_USE_FLAG} + CXXFLAGS += ${PROFILE_USE_FLAG} endif ifeq ($(STATICLINK),true) @@ -121,29 +121,29 @@ runtests: testhelper: InteropDLL/$(OBJFOLDER)/$(SHAREDLIB) mkdir -p TestHelper/$(OBJFOLDER) - $(CPPC) $(GCCOPTIONS) -Wl,-z,defs -o testhelper TestHelper/*.cpp InteropDLL/ConsoleWrapper.cpp $(SEVENZIPOBJ) $(LUAOBJ) $(LINUXOBJ) $(LIBEVDEVOBJ) $(UTILOBJ) $(COREOBJ) -pthread $(FSLIB) $(SDL2LIB) $(LIBEVDEVLIB) + $(CXX) $(CXXFLAGS) -Wl,-z,defs -o testhelper TestHelper/*.cpp InteropDLL/ConsoleWrapper.cpp $(SEVENZIPOBJ) $(LUAOBJ) $(LINUXOBJ) $(LIBEVDEVOBJ) $(UTILOBJ) $(COREOBJ) -pthread $(FSLIB) $(SDL2LIB) $(LIBEVDEVLIB) mv testhelper TestHelper/$(OBJFOLDER) pgohelper: InteropDLL/$(OBJFOLDER)/$(SHAREDLIB) - mkdir -p PGOHelper/$(OBJFOLDER) && cd PGOHelper/$(OBJFOLDER) && $(CPPC) $(GCCOPTIONS) -Wl,-z,defs -o pgohelper ../PGOHelper.cpp ../../bin/pgohelperlib.so -pthread $(FSLIB) $(SDL2LIB) $(LIBEVDEVLIB) + mkdir -p PGOHelper/$(OBJFOLDER) && cd PGOHelper/$(OBJFOLDER) && $(CXX) $(CXXFLAGS) -Wl,-z,defs -o pgohelper ../PGOHelper.cpp ../../bin/pgohelperlib.so -pthread $(FSLIB) $(SDL2LIB) $(LIBEVDEVLIB) %.o: %.c - $(CC) $(CCOPTIONS) -c $< -o $@ + $(CC) $(CFLAGS) -c $< -o $@ %.o: %.cpp - $(CPPC) $(GCCOPTIONS) -c $< -o $@ + $(CXX) $(CXXFLAGS) -c $< -o $@ InteropDLL/$(OBJFOLDER)/$(SHAREDLIB): $(SEVENZIPOBJ) $(LUAOBJ) $(UTILOBJ) $(COREOBJ) $(LIBEVDEVOBJ) $(LINUXOBJ) $(DLLOBJ) mkdir -p bin mkdir -p InteropDLL/$(OBJFOLDER) - $(CPPC) $(GCCOPTIONS) $(LINKOPTIONS) -Wl,-z,defs -shared -o $(SHAREDLIB) $(DLLOBJ) $(SEVENZIPOBJ) $(LUAOBJ) $(LINUXOBJ) $(LIBEVDEVOBJ) $(UTILOBJ) $(COREOBJ) $(SDL2INC) -pthread $(FSLIB) $(SDL2LIB) $(LIBEVDEVLIB) + $(CXX) $(CXXFLAGS) $(LINKOPTIONS) -Wl,-z,defs -shared -o $(SHAREDLIB) $(DLLOBJ) $(SEVENZIPOBJ) $(LUAOBJ) $(LINUXOBJ) $(LIBEVDEVOBJ) $(UTILOBJ) $(COREOBJ) $(SDL2INC) -pthread $(FSLIB) $(SDL2LIB) $(LIBEVDEVLIB) cp $(SHAREDLIB) bin/pgohelperlib.so mv $(SHAREDLIB) InteropDLL/$(OBJFOLDER) Libretro/$(OBJFOLDER)/$(LIBRETROLIB): $(SEVENZIPOBJ) $(UTILOBJ) $(COREOBJ) Libretro/libretro.cpp mkdir -p bin mkdir -p Libretro/$(OBJFOLDER) - $(CPPC) $(GCCOPTIONS) $(LINKOPTIONS) -Wl,-z,defs -shared -o $(LIBRETROLIB) Libretro/*.cpp $(SEVENZIPOBJ) $(UTILOBJ) $(COREOBJ) -pthread + $(CXX) $(CXXFLAGS) $(LINKOPTIONS) -Wl,-z,defs -shared -o $(LIBRETROLIB) Libretro/*.cpp $(SEVENZIPOBJ) $(UTILOBJ) $(COREOBJ) -pthread cp $(LIBRETROLIB) bin/pgohelperlib.so mv $(LIBRETROLIB) Libretro/$(OBJFOLDER)