diff --git a/Core/BaseCoprocessor.h b/Core/BaseCoprocessor.h index 056d93c..b884ae7 100644 --- a/Core/BaseCoprocessor.h +++ b/Core/BaseCoprocessor.h @@ -6,6 +6,8 @@ class BaseCoprocessor : public ISerializable, public IMemoryHandler { public: + using IMemoryHandler::IMemoryHandler; + virtual void Reset() = 0; virtual void ProcessEndOfFrame() { } diff --git a/Core/BsxCart.cpp b/Core/BsxCart.cpp index aff2ff8..18d736c 100644 --- a/Core/BsxCart.cpp +++ b/Core/BsxCart.cpp @@ -9,7 +9,7 @@ #include "RamHandler.h" #include "EmuSettings.h" -BsxCart::BsxCart(Console* console, BsxMemoryPack* memPack) +BsxCart::BsxCart(Console* console, BsxMemoryPack* memPack) : BaseCoprocessor(SnesMemoryType::Register) { _console = console; _memoryManager = _console->GetMemoryManager().get(); diff --git a/Core/BsxSatellaview.cpp b/Core/BsxSatellaview.cpp index 369b08f..c6e5cd7 100644 --- a/Core/BsxSatellaview.cpp +++ b/Core/BsxSatellaview.cpp @@ -5,7 +5,7 @@ #include "EmuSettings.h" #include "../Utilities/Serializer.h" -BsxSatellaview::BsxSatellaview(Console* console, IMemoryHandler* bBusHandler) +BsxSatellaview::BsxSatellaview(Console* console, IMemoryHandler* bBusHandler) : IMemoryHandler(SnesMemoryType::Register) { _console = console; _memoryManager = console->GetMemoryManager().get(); diff --git a/Core/CpuBwRamHandler.h b/Core/CpuBwRamHandler.h index bef9c9e..9e12f8c 100644 --- a/Core/CpuBwRamHandler.h +++ b/Core/CpuBwRamHandler.h @@ -15,7 +15,7 @@ private: Sa1* _sa1; public: - CpuBwRamHandler(IMemoryHandler* handler, Sa1State* state, Sa1* sa1) + CpuBwRamHandler(IMemoryHandler* handler, Sa1State* state, Sa1* sa1) : IMemoryHandler(handler->GetMemoryType()) { _handler = handler; _sa1 = sa1; diff --git a/Core/Cx4.cpp b/Core/Cx4.cpp index d107235..0b276bc 100644 --- a/Core/Cx4.cpp +++ b/Core/Cx4.cpp @@ -13,7 +13,7 @@ //TODO: CPU shouldn't have access to PRG ROM while the CX4 is loading from PRG ROM //TODO: Timings are apparently not perfect (desync in MMX2 intro) -Cx4::Cx4(Console* console) +Cx4::Cx4(Console* console) : BaseCoprocessor(SnesMemoryType::Register) { _console = console; _memoryType = SnesMemoryType::Register; diff --git a/Core/Gsu.cpp b/Core/Gsu.cpp index 63b3cac..bb5e933 100644 --- a/Core/Gsu.cpp +++ b/Core/Gsu.cpp @@ -12,7 +12,7 @@ #include "BatteryManager.h" #include "../Utilities/HexUtilities.h" -Gsu::Gsu(Console *console, uint32_t gsuRamSize) +Gsu::Gsu(Console *console, uint32_t gsuRamSize) : BaseCoprocessor(SnesMemoryType::Register) { _console = console; _memoryManager = console->GetMemoryManager().get(); diff --git a/Core/GsuRamHandler.h b/Core/GsuRamHandler.h index 4fd8556..01daec8 100644 --- a/Core/GsuRamHandler.h +++ b/Core/GsuRamHandler.h @@ -10,9 +10,8 @@ private: IMemoryHandler *_handler; public: - GsuRamHandler(GsuState &state, IMemoryHandler *handler) + GsuRamHandler(GsuState &state, IMemoryHandler *handler) : IMemoryHandler(SnesMemoryType::GsuWorkRam) { - _memoryType = SnesMemoryType::GsuWorkRam; _handler = handler; _state = &state; } diff --git a/Core/GsuRomHandler.h b/Core/GsuRomHandler.h index 3752b88..cf6b0e0 100644 --- a/Core/GsuRomHandler.h +++ b/Core/GsuRomHandler.h @@ -10,9 +10,8 @@ private: IMemoryHandler *_romHandler; public: - GsuRomHandler(GsuState &state, IMemoryHandler *romHandler) + GsuRomHandler(GsuState &state, IMemoryHandler *romHandler) : IMemoryHandler(SnesMemoryType::PrgRom) { - _memoryType = SnesMemoryType::PrgRom; _romHandler = romHandler; _state = &state; } diff --git a/Core/IMemoryHandler.h b/Core/IMemoryHandler.h index 00cfe40..63bb64f 100644 --- a/Core/IMemoryHandler.h +++ b/Core/IMemoryHandler.h @@ -8,6 +8,13 @@ protected: SnesMemoryType _memoryType; public: + IMemoryHandler(SnesMemoryType memType) + { + _memoryType = memType; + } + + virtual ~IMemoryHandler() {} + virtual uint8_t Read(uint32_t addr) = 0; virtual uint8_t Peek(uint32_t addr) = 0; virtual void PeekBlock(uint32_t addr, uint8_t *output) = 0; @@ -19,9 +26,4 @@ public: } virtual AddressInfo GetAbsoluteAddress(uint32_t address) = 0; - - //virtual void GetMemoryRanges(MemoryRanges &ranges) = 0; - //virtual uint8_t PeekRAM(uint16_t addr) { return 0; } - - virtual ~IMemoryHandler() {} }; \ No newline at end of file diff --git a/Core/NecDsp.cpp b/Core/NecDsp.cpp index a40d805..f3ebf88 100644 --- a/Core/NecDsp.cpp +++ b/Core/NecDsp.cpp @@ -13,7 +13,7 @@ #include "FirmwareHelper.h" #include "../Utilities/FolderUtilities.h" -NecDsp::NecDsp(CoprocessorType type, Console* console, vector &programRom, vector &dataRom) +NecDsp::NecDsp(CoprocessorType type, Console* console, vector &programRom, vector &dataRom) : BaseCoprocessor(SnesMemoryType::Register) { _console = console; _type = type; diff --git a/Core/Obc1.cpp b/Core/Obc1.cpp index 3b2cf2d..067d15f 100644 --- a/Core/Obc1.cpp +++ b/Core/Obc1.cpp @@ -4,7 +4,7 @@ #include "MemoryManager.h" #include "MemoryMappings.h" -Obc1::Obc1(Console* console, uint8_t* saveRam, uint32_t saveRamSize) +Obc1::Obc1(Console* console, uint8_t* saveRam, uint32_t saveRamSize) : BaseCoprocessor(SnesMemoryType::Register) { MemoryMappings *mappings = console->GetMemoryManager()->GetMemoryMappings(); mappings->RegisterHandler(0x00, 0x3F, 0x6000, 0x7FFF, this); diff --git a/Core/RamHandler.h b/Core/RamHandler.h index 1476f57..2c694e2 100644 --- a/Core/RamHandler.h +++ b/Core/RamHandler.h @@ -13,7 +13,7 @@ protected: uint32_t _offset; public: - RamHandler(uint8_t *ram, uint32_t offset, uint32_t size, SnesMemoryType memoryType) + RamHandler(uint8_t *ram, uint32_t offset, uint32_t size, SnesMemoryType memoryType) : IMemoryHandler(memoryType) { _ram = ram + offset; _offset = offset; diff --git a/Core/RegisterHandlerA.h b/Core/RegisterHandlerA.h index e374539..6c6c30f 100644 --- a/Core/RegisterHandlerA.h +++ b/Core/RegisterHandlerA.h @@ -13,12 +13,11 @@ private: ControlManager *_controlManager; public: - RegisterHandlerA(DmaController *dmaController, InternalRegisters *regs, ControlManager *controlManager) + RegisterHandlerA(DmaController *dmaController, InternalRegisters *regs, ControlManager *controlManager) : IMemoryHandler(SnesMemoryType::Register) { _regs = regs; _dmaController = dmaController; _controlManager = controlManager; - _memoryType = SnesMemoryType::Register; } uint8_t Read(uint32_t addr) override diff --git a/Core/RegisterHandlerB.cpp b/Core/RegisterHandlerB.cpp index a7a9c5d..3344585 100644 --- a/Core/RegisterHandlerB.cpp +++ b/Core/RegisterHandlerB.cpp @@ -9,7 +9,7 @@ #include "CheatManager.h" #include "../Utilities/Serializer.h" -RegisterHandlerB::RegisterHandlerB(Console *console, Ppu * ppu, Spc * spc, uint8_t * workRam) +RegisterHandlerB::RegisterHandlerB(Console *console, Ppu * ppu, Spc * spc, uint8_t * workRam) : IMemoryHandler(SnesMemoryType::Register) { _console = console; _cheatManager = console->GetCheatManager().get(); @@ -19,7 +19,6 @@ RegisterHandlerB::RegisterHandlerB(Console *console, Ppu * ppu, Spc * spc, uint8 _msu1 = console->GetMsu1().get(); _workRam = workRam; _wramPosition = 0; - _memoryType = SnesMemoryType::Register; } uint8_t RegisterHandlerB::Read(uint32_t addr) diff --git a/Core/Sa1.cpp b/Core/Sa1.cpp index c204dcf..ed8af09 100644 --- a/Core/Sa1.cpp +++ b/Core/Sa1.cpp @@ -15,7 +15,7 @@ #include "MessageManager.h" #include "../Utilities/HexUtilities.h" -Sa1::Sa1(Console* console) +Sa1::Sa1(Console* console) : BaseCoprocessor(SnesMemoryType::Register) { _console = console; _memoryManager = console->GetMemoryManager().get(); diff --git a/Core/Sa1BwRamHandler.h b/Core/Sa1BwRamHandler.h index dbb2297..ac6ae5c 100644 --- a/Core/Sa1BwRamHandler.h +++ b/Core/Sa1BwRamHandler.h @@ -37,7 +37,7 @@ private: } public: - Sa1BwRamHandler(uint8_t* bwRam, uint32_t bwRamSize, Sa1State* state) + Sa1BwRamHandler(uint8_t* bwRam, uint32_t bwRamSize, Sa1State* state) : IMemoryHandler(SnesMemoryType::SaveRam) { _ram = bwRam; _mask = bwRamSize - 1; diff --git a/Core/Sa1IRamHandler.h b/Core/Sa1IRamHandler.h index b04540c..bf7eec8 100644 --- a/Core/Sa1IRamHandler.h +++ b/Core/Sa1IRamHandler.h @@ -18,10 +18,9 @@ private: } public: - Sa1IRamHandler(uint8_t *ram) + Sa1IRamHandler(uint8_t *ram) : IMemoryHandler(SnesMemoryType::Sa1InternalRam) { _ram = ram; - _memoryType = SnesMemoryType::Sa1InternalRam; } uint8_t Read(uint32_t addr) override diff --git a/Core/Sa1VectorHandler.h b/Core/Sa1VectorHandler.h index 7927053..5422885 100644 --- a/Core/Sa1VectorHandler.h +++ b/Core/Sa1VectorHandler.h @@ -11,7 +11,7 @@ private: Sa1State* _state; public: - Sa1VectorHandler(IMemoryHandler* handler, Sa1State* state) + Sa1VectorHandler(IMemoryHandler* handler, Sa1State* state) : IMemoryHandler(handler->GetMemoryType()) { _handler = handler; _state = state; diff --git a/Core/Sdd1.cpp b/Core/Sdd1.cpp index 5df252f..3b15aec 100644 --- a/Core/Sdd1.cpp +++ b/Core/Sdd1.cpp @@ -6,7 +6,7 @@ #include "MemoryManager.h" #include "MemoryMappings.h" -Sdd1::Sdd1(Console* console) +Sdd1::Sdd1(Console* console) : BaseCoprocessor(SnesMemoryType::Register) { //This handler is used to dynamically map the ROM based on the banking registers _sdd1Mmc.reset(new Sdd1Mmc(_state, console->GetCartridge().get())); diff --git a/Core/Sdd1Mmc.cpp b/Core/Sdd1Mmc.cpp index 8102960..4427d04 100644 --- a/Core/Sdd1Mmc.cpp +++ b/Core/Sdd1Mmc.cpp @@ -3,7 +3,7 @@ #include "Sdd1Types.h" #include "BaseCartridge.h" -Sdd1Mmc::Sdd1Mmc(Sdd1State &state, BaseCartridge *cart) +Sdd1Mmc::Sdd1Mmc(Sdd1State &state, BaseCartridge *cart) : IMemoryHandler(SnesMemoryType::Register) { _romHandlers = &cart->GetPrgRomHandlers(); _handlerMask = (uint32_t)((*_romHandlers).size() - 1); diff --git a/Core/Spc7110.cpp b/Core/Spc7110.cpp index 2d175f9..c7dd233 100644 --- a/Core/Spc7110.cpp +++ b/Core/Spc7110.cpp @@ -10,7 +10,7 @@ #include "MessageManager.h" #include "../Utilities/HexUtilities.h" -Spc7110::Spc7110(Console* console, bool useRtc) +Spc7110::Spc7110(Console* console, bool useRtc) : BaseCoprocessor(SnesMemoryType::Register) { _console = console; _cart = console->GetCartridge().get();