diff options
author | Arisotura <thetotalworm@gmail.com> | 2023-11-04 17:28:16 +0100 |
---|---|---|
committer | Arisotura <thetotalworm@gmail.com> | 2023-11-04 17:28:16 +0100 |
commit | 8f1b0d4a052db068a029cd5784e52da7ecc9813e (patch) | |
tree | a979e06487722e247403a2cf2e19f46c7adc2c0c | |
parent | 2bd09eafebbc98e2e2b9fbb023b31551ccd8cf12 (diff) |
convert AREngine
-rw-r--r-- | src/AREngine.cpp | 37 | ||||
-rw-r--r-- | src/AREngine.h | 28 | ||||
-rw-r--r-- | src/ARM.cpp | 2 | ||||
-rw-r--r-- | src/NDS.cpp | 8 | ||||
-rw-r--r-- | src/NDS.h | 4 | ||||
-rw-r--r-- | src/frontend/qt_sdl/ROMManager.cpp | 6 |
6 files changed, 38 insertions, 47 deletions
diff --git a/src/AREngine.cpp b/src/AREngine.cpp index ffed6b9..c8888ac 100644 --- a/src/AREngine.cpp +++ b/src/AREngine.cpp @@ -26,32 +26,17 @@ using Platform::Log; using Platform::LogLevel; -namespace AREngine -{ - -// AR code file - frontend is responsible for managing this -ARCodeFile* CodeFile; - -u8 (*BusRead8)(u32 addr); -u16 (*BusRead16)(u32 addr); -u32 (*BusRead32)(u32 addr); -void (*BusWrite8)(u32 addr, u8 val); -void (*BusWrite16)(u32 addr, u16 val); -void (*BusWrite32)(u32 addr, u32 val); - -bool Init() +AREngine::AREngine() { CodeFile = nullptr; - - return true; } -void DeInit() +AREngine::~AREngine() { } -void Reset() +void AREngine::Reset() { if (NDS::ConsoleType == 1) { @@ -74,16 +59,6 @@ void Reset() } -ARCodeFile* GetCodeFile() -{ - return CodeFile; -} - -void SetCodeFile(ARCodeFile* file) -{ - CodeFile = file; -} - #define case16(x) \ case ((x)+0x00): case ((x)+0x01): case ((x)+0x02): case ((x)+0x03): \ @@ -91,7 +66,7 @@ void SetCodeFile(ARCodeFile* file) case ((x)+0x08): case ((x)+0x09): case ((x)+0x0A): case ((x)+0x0B): \ case ((x)+0x0C): case ((x)+0x0D): case ((x)+0x0E): case ((x)+0x0F) -void RunCheat(ARCode& arcode) +void AREngine::RunCheat(ARCode& arcode) { u32* code = &arcode.Code[0]; @@ -437,7 +412,7 @@ void RunCheat(ARCode& arcode) } } -void RunCheats() +void AREngine::RunCheats() { if (!CodeFile) return; @@ -454,5 +429,3 @@ void RunCheats() } } } - -} diff --git a/src/AREngine.h b/src/AREngine.h index 5426846..cd6d4a9 100644 --- a/src/AREngine.h +++ b/src/AREngine.h @@ -21,18 +21,30 @@ #include "ARCodeFile.h" -namespace AREngine +class AREngine { +public: + AREngine(); + ~AREngine(); + void Reset(); -bool Init(); -void DeInit(); -void Reset(); + ARCodeFile* GetCodeFile() { return CodeFile; } + void SetCodeFile(ARCodeFile* file) { CodeFile = file; } -ARCodeFile* GetCodeFile(); -void SetCodeFile(ARCodeFile* file); + void RunCheats(); -void RunCheats(); +private: + ARCodeFile* CodeFile; // AR code file - frontend is responsible for managing this -} + // TEMPORARY + u8 (*BusRead8)(u32 addr); + u16 (*BusRead16)(u32 addr); + u32 (*BusRead32)(u32 addr); + void (*BusWrite8)(u32 addr, u8 val); + void (*BusWrite16)(u32 addr, u16 val); + void (*BusWrite32)(u32 addr, u32 val); + + void RunCheat(ARCode& arcode); +}; #endif // ARENGINE_H diff --git a/src/ARM.cpp b/src/ARM.cpp index ea649b7..4f2f892 100644 --- a/src/ARM.cpp +++ b/src/ARM.cpp @@ -590,7 +590,7 @@ void ARM::TriggerIRQ() if (Num == 1) { if ((NDS::IF[1] & NDS::IE[1]) & (1<<NDS::IRQ_VBlank)) - AREngine::RunCheats(); + NDS::AREngine->RunCheats(); } } diff --git a/src/NDS.cpp b/src/NDS.cpp index 2fdbf63..05a7721 100644 --- a/src/NDS.cpp +++ b/src/NDS.cpp @@ -183,6 +183,8 @@ class SPIHost* SPI; class RTC* RTC; class Wifi* Wifi; +class AREngine* AREngine; + bool Running; bool RunningGame; @@ -231,7 +233,7 @@ bool Init() if (!DSi::Init()) return false; - if (!AREngine::Init()) return false; + AREngine = new class AREngine(); return true; } @@ -262,7 +264,7 @@ void DeInit() DSi::DeInit(); - AREngine::DeInit(); + delete AREngine; AREngine = nullptr; UnregisterEventFunc(Event_Div, 0); UnregisterEventFunc(Event_Sqrt, 0); @@ -671,7 +673,7 @@ void Reset() SPU->SetDegrade10Bit(degradeAudio); - AREngine::Reset(); + AREngine->Reset(); } void Start() @@ -35,6 +35,8 @@ class SPIHost; class RTC; class Wifi; +class AREngine; + namespace NDS { @@ -256,6 +258,8 @@ extern class SPIHost* SPI; extern class RTC* RTC; extern class Wifi* Wifi; +extern class AREngine* AREngine; + const u32 ARM7WRAMSize = 0x10000; extern u8* ARM7WRAM; diff --git a/src/frontend/qt_sdl/ROMManager.cpp b/src/frontend/qt_sdl/ROMManager.cpp index 0af1fcc..a0355f6 100644 --- a/src/frontend/qt_sdl/ROMManager.cpp +++ b/src/frontend/qt_sdl/ROMManager.cpp @@ -462,7 +462,7 @@ void UnloadCheats() { delete CheatFile; CheatFile = nullptr; - AREngine::SetCodeFile(nullptr); + NDS::AREngine->SetCodeFile(nullptr); } } @@ -475,7 +475,7 @@ void LoadCheats() // TODO: check for error (malformed cheat file, ...) CheatFile = new ARCodeFile(filename); - AREngine::SetCodeFile(CheatsOn ? CheatFile : nullptr); + NDS::AREngine->SetCodeFile(CheatsOn ? CheatFile : nullptr); } void LoadBIOSFiles() @@ -570,7 +570,7 @@ void EnableCheats(bool enable) { CheatsOn = enable; if (CheatFile) - AREngine::SetCodeFile(CheatsOn ? CheatFile : nullptr); + NDS::AREngine->SetCodeFile(CheatsOn ? CheatFile : nullptr); } ARCodeFile* GetCheatFile() |