From 346dd4006ea1283136095d5c43f602324a095092 Mon Sep 17 00:00:00 2001 From: Jesse Talavera-Greenberg Date: Sat, 25 Nov 2023 12:32:09 -0500 Subject: [PATCH] Move all core types into namespaces (#1886) * Reorganize namespaces - Most types are now moved into the `melonDS` namespace - Only good chance to do this for a while, since a big refactor is next * Fix the build --- src/ARCodeFile.cpp | 4 +++ src/ARCodeFile.h | 3 ++ src/AREngine.cpp | 4 +++ src/AREngine.h | 3 ++ src/ARM.cpp | 13 ++++--- src/ARM.h | 23 ++++++------- src/ARMInterpreter.cpp | 7 ++-- src/ARMInterpreter.h | 3 ++ src/ARMInterpreter_ALU.cpp | 2 +- src/ARMInterpreter_ALU.h | 3 ++ src/ARMInterpreter_Branch.cpp | 5 ++- src/ARMInterpreter_Branch.h | 3 ++ src/ARMInterpreter_LoadStore.cpp | 2 +- src/ARMInterpreter_LoadStore.h | 2 +- src/ARMJIT.cpp | 34 +++++++++---------- src/ARMJIT.h | 8 ++--- src/ARMJIT_A64/ARMJIT_ALU.cpp | 4 +-- src/ARMJIT_A64/ARMJIT_Branch.cpp | 2 +- src/ARMJIT_A64/ARMJIT_Compiler.cpp | 4 +-- src/ARMJIT_A64/ARMJIT_Compiler.h | 2 +- src/ARMJIT_A64/ARMJIT_LoadStore.cpp | 4 +-- src/ARMJIT_Internal.h | 4 +-- src/ARMJIT_Memory.cpp | 20 ++++++----- src/ARMJIT_Memory.h | 17 +++++----- src/ARMJIT_RegisterCache.h | 3 +- src/ARMJIT_x64/ARMJIT_ALU.cpp | 4 +-- src/ARMJIT_x64/ARMJIT_Branch.cpp | 2 +- src/ARMJIT_x64/ARMJIT_Compiler.cpp | 5 +-- src/ARMJIT_x64/ARMJIT_Compiler.h | 6 ++-- src/ARMJIT_x64/ARMJIT_GenOffsets.cpp | 2 +- src/ARMJIT_x64/ARMJIT_LoadStore.cpp | 4 +-- src/ARM_InstrInfo.cpp | 2 +- src/ARM_InstrInfo.h | 2 +- src/CP15.cpp | 3 ++ src/CRC32.cpp | 4 +++ src/CRC32.h | 3 ++ src/DMA.cpp | 6 +++- src/DMA.h | 8 ++--- src/DMA_Timings.cpp | 2 +- src/DMA_Timings.h | 2 +- src/DSi.cpp | 4 +++ src/DSi.h | 3 ++ src/DSi_AES.cpp | 4 +++ src/DSi_AES.h | 3 ++ src/DSi_Camera.cpp | 4 +++ src/DSi_Camera.h | 3 ++ src/DSi_DSP.cpp | 4 +++ src/DSi_DSP.h | 3 ++ src/DSi_I2C.cpp | 4 +++ src/DSi_I2C.h | 3 ++ src/DSi_NAND.cpp | 4 +-- src/DSi_NAND.h | 2 +- src/DSi_NDMA.cpp | 6 +++- src/DSi_NDMA.h | 8 ++--- src/DSi_NWifi.cpp | 5 +++ src/DSi_NWifi.h | 3 ++ src/DSi_SD.cpp | 4 +++ src/DSi_SD.h | 3 ++ src/DSi_SPI_TSC.cpp | 4 +++ src/DSi_SPI_TSC.h | 3 ++ src/DSi_TMD.h | 2 +- src/FATIO.cpp | 6 ++-- src/FATIO.h | 4 ++- src/FATStorage.cpp | 4 +++ src/FATStorage.h | 4 ++- src/FIFO.h | 3 ++ src/FreeBIOS.cpp | 5 ++- src/FreeBIOS.h | 3 ++ src/GBACart.cpp | 4 +++ src/GBACart.h | 2 +- src/GPU.cpp | 14 ++++---- src/GPU.h | 16 +++------ src/GPU2D.cpp | 6 ++-- src/GPU2D.h | 8 ++--- src/GPU2D_Soft.cpp | 12 ++++--- src/GPU2D_Soft.h | 9 ++--- src/GPU3D.cpp | 5 ++- src/GPU3D.h | 8 ++--- src/GPU3D_OpenGL.cpp | 8 ++--- src/GPU3D_OpenGL.h | 13 +++---- src/GPU3D_OpenGL_shaders.h | 5 +-- src/GPU3D_Soft.cpp | 7 ++-- src/GPU3D_Soft.h | 8 ++--- src/GPU_OpenGL.cpp | 8 ++--- src/GPU_OpenGL.h | 8 ++--- src/GPU_OpenGL_shaders.h | 3 ++ src/JitBlock.h | 2 +- src/NDS.cpp | 12 ++++--- src/NDS.h | 15 +++----- src/NDSCart.cpp | 4 +++ src/NDSCart.h | 2 +- src/NDS_Header.h | 3 ++ src/NonStupidBitfield.h | 3 ++ src/OpenGLSupport.cpp | 5 +++ src/OpenGLSupport.h | 3 +- src/Platform.h | 3 ++ src/ROMList.cpp | 4 +++ src/ROMList.h | 3 ++ src/RTC.cpp | 4 +++ src/RTC.h | 3 ++ src/SPI.cpp | 4 +++ src/SPI.h | 3 ++ src/SPI_Firmware.cpp | 4 +++ src/SPI_Firmware.h | 3 ++ src/SPU.cpp | 4 +++ src/SPU.h | 3 ++ src/Savestate.cpp | 4 +++ src/Savestate.h | 3 ++ src/TinyVector.h | 2 +- src/Wifi.cpp | 4 +++ src/Wifi.h | 3 ++ src/WifiAP.cpp | 4 +++ src/WifiAP.h | 3 ++ src/debug/GdbArch.h | 1 + src/debug/GdbCmds.cpp | 1 + src/debug/GdbProto.cpp | 1 + src/debug/GdbProto.h | 1 + src/debug/GdbStub.cpp | 1 + src/debug/GdbStub.h | 1 + src/debug/hexutil.h | 3 ++ src/dolphin/Arm64Emitter.h | 2 ++ src/dolphin/ArmCommon.h | 2 +- src/dolphin/BitSet.h | 10 +++--- src/dolphin/MathUtil.h | 4 +-- src/dolphin/x64ABI.cpp | 6 ++-- src/dolphin/x64CPUDetect.cpp | 2 ++ src/dolphin/x64Emitter.cpp | 2 ++ src/dolphin/x64Emitter.h | 2 ++ src/frontend/FrontendUtil.h | 1 + src/frontend/Util_Audio.cpp | 1 + src/frontend/duckstation/gl/context.h | 1 + src/frontend/duckstation/gl/context_agl.h | 1 + src/frontend/duckstation/gl/context_wgl.cpp | 1 + src/frontend/duckstation/gl/x11_window.h | 1 + src/frontend/duckstation/window_info.h | 4 +-- src/frontend/mic_blow.h | 4 ++- src/frontend/qt_sdl/ArchiveUtil.cpp | 1 + src/frontend/qt_sdl/ArchiveUtil.h | 1 + src/frontend/qt_sdl/AudioInOut.cpp | 1 + src/frontend/qt_sdl/AudioSettingsDialog.cpp | 1 + src/frontend/qt_sdl/CLI.cpp | 4 +-- src/frontend/qt_sdl/CameraManager.cpp | 1 + src/frontend/qt_sdl/CameraManager.h | 18 +++++----- src/frontend/qt_sdl/CameraSettingsDialog.cpp | 1 + src/frontend/qt_sdl/CheatsDialog.cpp | 1 + src/frontend/qt_sdl/CheatsDialog.h | 6 ++-- src/frontend/qt_sdl/Config.cpp | 1 + src/frontend/qt_sdl/EmuSettingsDialog.cpp | 3 +- .../qt_sdl/FirmwareSettingsDialog.cpp | 2 ++ src/frontend/qt_sdl/Input.cpp | 1 + src/frontend/qt_sdl/Input.h | 1 + .../qt_sdl/InputConfig/InputConfigDialog.cpp | 1 + src/frontend/qt_sdl/InputConfig/MapButton.h | 2 +- src/frontend/qt_sdl/LAN_PCap.cpp | 1 + src/frontend/qt_sdl/LAN_PCap.h | 1 + src/frontend/qt_sdl/LAN_Socket.cpp | 1 + src/frontend/qt_sdl/LAN_Socket.h | 1 + src/frontend/qt_sdl/LocalMP.cpp | 3 ++ src/frontend/qt_sdl/LocalMP.h | 1 + src/frontend/qt_sdl/OSD.cpp | 2 ++ src/frontend/qt_sdl/OSD.h | 3 ++ src/frontend/qt_sdl/PathSettingsDialog.cpp | 2 ++ src/frontend/qt_sdl/Platform.cpp | 2 +- .../PowerManagement/PowerManagementDialog.cpp | 2 ++ .../PowerManagement/PowerManagementDialog.h | 2 +- src/frontend/qt_sdl/RAMInfoDialog.cpp | 1 + src/frontend/qt_sdl/RAMInfoDialog.h | 22 ++++++------ src/frontend/qt_sdl/ROMInfoDialog.cpp | 2 ++ src/frontend/qt_sdl/ROMInfoDialog.h | 2 +- src/frontend/qt_sdl/ROMManager.cpp | 3 +- src/frontend/qt_sdl/ROMManager.h | 1 + src/frontend/qt_sdl/SaveManager.cpp | 3 +- src/frontend/qt_sdl/SaveManager.h | 16 ++++----- src/frontend/qt_sdl/TitleManagerDialog.cpp | 3 +- src/frontend/qt_sdl/TitleManagerDialog.h | 18 +++++----- src/frontend/qt_sdl/main.cpp | 4 +-- src/melonDLDI.h | 3 ++ src/types.h | 3 ++ 178 files changed, 529 insertions(+), 268 deletions(-) diff --git a/src/ARCodeFile.cpp b/src/ARCodeFile.cpp index 595df7d3..602a2e7b 100644 --- a/src/ARCodeFile.cpp +++ b/src/ARCodeFile.cpp @@ -21,6 +21,8 @@ #include "ARCodeFile.h" #include "Platform.h" +namespace melonDS +{ using namespace Platform; // TODO: import codes from other sources (usrcheat.dat, ...) @@ -182,3 +184,5 @@ bool ARCodeFile::Save() CloseFile(f); return true; } + +} \ No newline at end of file diff --git a/src/ARCodeFile.h b/src/ARCodeFile.h index 53b2f752..11e71efe 100644 --- a/src/ARCodeFile.h +++ b/src/ARCodeFile.h @@ -24,6 +24,8 @@ #include #include "types.h" +namespace melonDS +{ struct ARCode { std::string Name; @@ -59,4 +61,5 @@ private: std::string Filename; }; +} #endif // ARCODEFILE_H diff --git a/src/AREngine.cpp b/src/AREngine.cpp index c8888ac6..1d992b81 100644 --- a/src/AREngine.cpp +++ b/src/AREngine.cpp @@ -23,6 +23,9 @@ #include "AREngine.h" #include "Platform.h" +namespace melonDS +{ + using Platform::Log; using Platform::LogLevel; @@ -429,3 +432,4 @@ void AREngine::RunCheats() } } } +} diff --git a/src/AREngine.h b/src/AREngine.h index 8557eb77..a6926abf 100644 --- a/src/AREngine.h +++ b/src/AREngine.h @@ -21,6 +21,8 @@ #include "ARCodeFile.h" +namespace melonDS +{ class AREngine { public: @@ -45,4 +47,5 @@ private: void (*BusWrite32)(u32 addr, u32 val); }; +} #endif // ARENGINE_H diff --git a/src/ARM.cpp b/src/ARM.cpp index a361d778..a1485e99 100644 --- a/src/ARM.cpp +++ b/src/ARM.cpp @@ -28,6 +28,8 @@ #include "GPU.h" #include "ARMJIT_Memory.h" +namespace melonDS +{ using Platform::Log; using Platform::LogLevel; @@ -104,7 +106,7 @@ const u32 ARM::ConditionTable[16] = 0x0000 // NE }; -ARM::ARM(u32 num, ARMJIT::ARMJIT& jit, Melon::GPU& gpu) : +ARM::ARM(u32 num, ARMJIT& jit, melonDS::GPU& gpu) : #ifdef GDBSTUB_ENABLED GdbStub(this, Platform::GetConfigInt(num ? Platform::GdbPortARM7 : Platform::GdbPortARM9)), #endif @@ -128,14 +130,14 @@ ARM::~ARM() // dorp } -ARMv5::ARMv5(ARMJIT::ARMJIT& jit, Melon::GPU& gpu) : ARM(0, jit, gpu) +ARMv5::ARMv5(ARMJIT& jit, melonDS::GPU& gpu) : ARM(0, jit, gpu) { DTCM = JIT.Memory.GetARM9DTCM(); PU_Map = PU_PrivMap; } -ARMv4::ARMv4(ARMJIT::ARMJIT& jit, Melon::GPU& gpu) : ARM(1, jit, gpu) +ARMv4::ARMv4(ARMJIT& jit, melonDS::GPU& gpu) : ARM(1, jit, gpu) { // } @@ -749,7 +751,7 @@ void ARMv5::ExecuteJIT() return; } - ARMJIT::JitBlockEntry block = JIT.LookUpBlock(0, FastBlockLookup, + JitBlockEntry block = JIT.LookUpBlock(0, FastBlockLookup, instrAddr - FastBlockLookupStart, instrAddr); if (block) ARM_Dispatch(this, block); @@ -906,7 +908,7 @@ void ARMv4::ExecuteJIT() return; } - ARMJIT::JitBlockEntry block = JIT.LookUpBlock(1, FastBlockLookup, + JitBlockEntry block = JIT.LookUpBlock(1, FastBlockLookup, instrAddr - FastBlockLookupStart, instrAddr); if (block) ARM_Dispatch(this, block); @@ -1191,5 +1193,6 @@ u32 ARMv5::ReadMem(u32 addr, int size) return ARM::ReadMem(addr, size); } +} #endif diff --git a/src/ARM.h b/src/ARM.h index c8f596a7..9a99a072 100644 --- a/src/ARM.h +++ b/src/ARM.h @@ -28,6 +28,8 @@ #include "debug/GdbStub.h" #endif +namespace melonDS +{ inline u32 ROR(u32 x, u32 n) { return (x >> (n&0x1F)) | (x << ((32-n)&0x1F)); @@ -42,15 +44,9 @@ enum const u32 ITCMPhysicalSize = 0x8000; const u32 DTCMPhysicalSize = 0x4000; -namespace ARMJIT -{ -class ARMJIT; -} -namespace Melon -{ -class GPU; -} +class ARMJIT; +class GPU; class ARMJIT_Memory; class ARM @@ -59,7 +55,7 @@ class ARM #endif { public: - ARM(u32 num, ARMJIT::ARMJIT& jit, Melon::GPU& gpu); + ARM(u32 num, ARMJIT& jit, GPU& gpu); virtual ~ARM(); // destroy shit virtual void Reset(); @@ -190,7 +186,7 @@ public: Gdb::GdbStub GdbStub; #endif - ARMJIT::ARMJIT& JIT; + ARMJIT& JIT; protected: u8 (*BusRead8)(u32 addr); u16 (*BusRead16)(u32 addr); @@ -222,13 +218,13 @@ protected: void GdbCheckB(); void GdbCheckC(); private: - Melon::GPU& GPU; + melonDS::GPU& GPU; }; class ARMv5 : public ARM { public: - ARMv5(ARMJIT::ARMJIT& jit, Melon::GPU& gpu); + ARMv5(ARMJIT& jit, melonDS::GPU& gpu); ~ARMv5(); void Reset() override; @@ -372,7 +368,7 @@ public: class ARMv4 : public ARM { public: - ARMv4(ARMJIT::ARMJIT& jit, Melon::GPU& gpu); + ARMv4(ARMJIT& jit, melonDS::GPU& gpu); void Reset() override; @@ -541,4 +537,5 @@ extern ARMv4* ARM7; } +} #endif // ARM_H diff --git a/src/ARMInterpreter.cpp b/src/ARMInterpreter.cpp index 7aabf4c1..ff73e230 100644 --- a/src/ARMInterpreter.cpp +++ b/src/ARMInterpreter.cpp @@ -24,15 +24,14 @@ #include "ARMInterpreter_LoadStore.h" #include "Platform.h" -using Platform::Log; -using Platform::LogLevel; - #ifdef GDBSTUB_ENABLED #include "debug/GdbStub.h" #endif -namespace ARMInterpreter +namespace melonDS::ARMInterpreter { + using Platform::Log; + using Platform::LogLevel; void A_UNK(ARM* cpu) diff --git a/src/ARMInterpreter.h b/src/ARMInterpreter.h index 38225f00..cff4821a 100644 --- a/src/ARMInterpreter.h +++ b/src/ARMInterpreter.h @@ -22,6 +22,8 @@ #include "types.h" #include "ARM.h" +namespace melonDS +{ namespace ARMInterpreter { @@ -41,4 +43,5 @@ void A_BLX_IMM(ARM* cpu); // I'm a special one look at me } +} #endif // ARMINTERPRETER_H diff --git a/src/ARMInterpreter_ALU.cpp b/src/ARMInterpreter_ALU.cpp index 9fa44db4..313f7641 100644 --- a/src/ARMInterpreter_ALU.cpp +++ b/src/ARMInterpreter_ALU.cpp @@ -19,7 +19,7 @@ #include #include "ARM.h" -namespace ARMInterpreter +namespace melonDS::ARMInterpreter { inline bool CarryAdd(u32 a, u32 b) diff --git a/src/ARMInterpreter_ALU.h b/src/ARMInterpreter_ALU.h index 202d6b04..6998b637 100644 --- a/src/ARMInterpreter_ALU.h +++ b/src/ARMInterpreter_ALU.h @@ -19,6 +19,8 @@ #ifndef ARMINTERPRETER_ALU_H #define ARMINTERPRETER_ALU_H +namespace melonDS +{ namespace ARMInterpreter { @@ -134,4 +136,5 @@ void T_ADD_SP(ARM* cpu); } +} #endif diff --git a/src/ARMInterpreter_Branch.cpp b/src/ARMInterpreter_Branch.cpp index ece783c9..015f5682 100644 --- a/src/ARMInterpreter_Branch.cpp +++ b/src/ARMInterpreter_Branch.cpp @@ -19,12 +19,11 @@ #include "ARM.h" #include "Platform.h" +namespace melonDS::ARMInterpreter +{ using Platform::Log; using Platform::LogLevel; -namespace ARMInterpreter -{ - void A_B(ARM* cpu) { diff --git a/src/ARMInterpreter_Branch.h b/src/ARMInterpreter_Branch.h index 3db6f408..51a561c1 100644 --- a/src/ARMInterpreter_Branch.h +++ b/src/ARMInterpreter_Branch.h @@ -19,6 +19,8 @@ #ifndef ARMINTERPRETER_BRANCH_H #define ARMINTERPRETER_BRANCH_H +namespace melonDS +{ namespace ARMInterpreter { @@ -36,4 +38,5 @@ void T_BL_LONG_2(ARM* cpu); } +} #endif diff --git a/src/ARMInterpreter_LoadStore.cpp b/src/ARMInterpreter_LoadStore.cpp index 3b4b35d7..91acaacc 100644 --- a/src/ARMInterpreter_LoadStore.cpp +++ b/src/ARMInterpreter_LoadStore.cpp @@ -20,7 +20,7 @@ #include "ARM.h" -namespace ARMInterpreter +namespace melonDS::ARMInterpreter { diff --git a/src/ARMInterpreter_LoadStore.h b/src/ARMInterpreter_LoadStore.h index 9016cfa9..32d6e4d2 100644 --- a/src/ARMInterpreter_LoadStore.h +++ b/src/ARMInterpreter_LoadStore.h @@ -19,7 +19,7 @@ #ifndef ARMINTERPRETER_LOADSTORE_H #define ARMINTERPRETER_LOADSTORE_H -namespace ARMInterpreter +namespace melonDS::ARMInterpreter { #define A_PROTO_WB_LDRSTR(x) \ diff --git a/src/ARMJIT.cpp b/src/ARMJIT.cpp index c5512135..45445821 100644 --- a/src/ARMJIT.cpp +++ b/src/ARMJIT.cpp @@ -43,17 +43,17 @@ #include "Wifi.h" #include "NDSCart.h" #include "Platform.h" +#include "ARMJIT_x64/ARMJIT_Offsets.h" +namespace melonDS +{ using Platform::Log; using Platform::LogLevel; -#include "ARMJIT_x64/ARMJIT_Offsets.h" static_assert(offsetof(ARM, CPSR) == ARM_CPSR_offset, ""); static_assert(offsetof(ARM, Cycles) == ARM_Cycles_offset, ""); static_assert(offsetof(ARM, StopExecution) == ARM_StopExecution_offset, ""); -namespace ARMJIT -{ #define JIT_DEBUGPRINT(msg, ...) //#define JIT_DEBUGPRINT(msg, ...) Platform::Log(Platform::LogLevel::Debug, msg, ## __VA_ARGS__) @@ -1056,20 +1056,20 @@ bool ARMJIT::SetupExecutableRegion(u32 num, u32 blockAddr, u64*& entry, u32& sta return false; } -template void ARMJIT::CheckAndInvalidate<0, ARMJIT_Memory::memregion_MainRAM>(u32); -template void ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_MainRAM>(u32); -template void ARMJIT::CheckAndInvalidate<0, ARMJIT_Memory::memregion_SharedWRAM>(u32); -template void ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_SharedWRAM>(u32); -template void ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_WRAM7>(u32); -template void ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_VWRAM>(u32); -template void ARMJIT::CheckAndInvalidate<0, ARMJIT_Memory::memregion_VRAM>(u32); -template void ARMJIT::CheckAndInvalidate<0, ARMJIT_Memory::memregion_ITCM>(u32); -template void ARMJIT::CheckAndInvalidate<0, ARMJIT_Memory::memregion_NewSharedWRAM_A>(u32); -template void ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_NewSharedWRAM_A>(u32); -template void ARMJIT::CheckAndInvalidate<0, ARMJIT_Memory::memregion_NewSharedWRAM_B>(u32); -template void ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_NewSharedWRAM_B>(u32); -template void ARMJIT::CheckAndInvalidate<0, ARMJIT_Memory::memregion_NewSharedWRAM_C>(u32); -template void ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_NewSharedWRAM_C>(u32); +template void ARMJIT::CheckAndInvalidate<0, ARMJIT_Memory::memregion_MainRAM>(u32) noexcept; +template void ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_MainRAM>(u32) noexcept; +template void ARMJIT::CheckAndInvalidate<0, ARMJIT_Memory::memregion_SharedWRAM>(u32) noexcept; +template void ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_SharedWRAM>(u32) noexcept; +template void ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_WRAM7>(u32) noexcept; +template void ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_VWRAM>(u32) noexcept; +template void ARMJIT::CheckAndInvalidate<0, ARMJIT_Memory::memregion_VRAM>(u32) noexcept; +template void ARMJIT::CheckAndInvalidate<0, ARMJIT_Memory::memregion_ITCM>(u32) noexcept; +template void ARMJIT::CheckAndInvalidate<0, ARMJIT_Memory::memregion_NewSharedWRAM_A>(u32) noexcept; +template void ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_NewSharedWRAM_A>(u32) noexcept; +template void ARMJIT::CheckAndInvalidate<0, ARMJIT_Memory::memregion_NewSharedWRAM_B>(u32) noexcept; +template void ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_NewSharedWRAM_B>(u32) noexcept; +template void ARMJIT::CheckAndInvalidate<0, ARMJIT_Memory::memregion_NewSharedWRAM_C>(u32) noexcept; +template void ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_NewSharedWRAM_C>(u32) noexcept; void ARMJIT::ResetBlockCache() noexcept { diff --git a/src/ARMJIT.h b/src/ARMJIT.h index 074e2a13..4191824c 100644 --- a/src/ARMJIT.h +++ b/src/ARMJIT.h @@ -31,10 +31,10 @@ #include "ARMJIT_Compiler.h" +namespace melonDS +{ class ARM; -namespace ARMJIT -{ class JitBlock; class ARMJIT { @@ -74,7 +74,7 @@ public: TinyVector InvalidLiterals {}; private: - friend class ::ARMJIT_Memory; + friend class ARMJIT_Memory; void blockSanityCheck(u32 num, u32 blockAddr, JitBlockEntry entry) noexcept; void RetireJitBlock(JitBlock* block) noexcept; @@ -160,6 +160,6 @@ private: } // Defined in assembly -extern "C" void ARM_Dispatch(ARM* cpu, ARMJIT::JitBlockEntry entry); +extern "C" void ARM_Dispatch(melonDS::ARM* cpu, melonDS::JitBlockEntry entry); #endif diff --git a/src/ARMJIT_A64/ARMJIT_ALU.cpp b/src/ARMJIT_A64/ARMJIT_ALU.cpp index 3d52f280..b25bcaa3 100644 --- a/src/ARMJIT_A64/ARMJIT_ALU.cpp +++ b/src/ARMJIT_A64/ARMJIT_ALU.cpp @@ -20,7 +20,7 @@ using namespace Arm64Gen; -namespace ARMJIT +namespace melonDS { void Compiler::Comp_RegShiftReg(int op, bool S, Op2& op2, ARM64Reg rs) @@ -480,7 +480,7 @@ void Compiler::A_Comp_GetOp2(bool S, Op2& op2) Comp_AddCycles_C(); u32 shift = (CurInstr.Instr >> 7) & 0x1E; - u32 imm = ::ROR(CurInstr.Instr & 0xFF, shift); + u32 imm = melonDS::ROR(CurInstr.Instr & 0xFF, shift); if (S && shift && (CurInstr.SetFlags & 0x2)) { diff --git a/src/ARMJIT_A64/ARMJIT_Branch.cpp b/src/ARMJIT_A64/ARMJIT_Branch.cpp index c7b6e98e..d18a0e05 100644 --- a/src/ARMJIT_A64/ARMJIT_Branch.cpp +++ b/src/ARMJIT_A64/ARMJIT_Branch.cpp @@ -23,7 +23,7 @@ using namespace Arm64Gen; // hack const int kCodeCacheTiming = 3; -namespace ARMJIT +namespace melonDS { template diff --git a/src/ARMJIT_A64/ARMJIT_Compiler.cpp b/src/ARMJIT_A64/ARMJIT_Compiler.cpp index 90940b0c..1b037588 100644 --- a/src/ARMJIT_A64/ARMJIT_Compiler.cpp +++ b/src/ARMJIT_A64/ARMJIT_Compiler.cpp @@ -39,7 +39,7 @@ using namespace Arm64Gen; extern "C" void ARM_Ret(); -namespace ARMJIT +namespace melonDS { /* @@ -106,7 +106,7 @@ void Compiler::A_Comp_MSR() if (CurInstr.Instr & (1 << 25)) { val = W0; - MOVI2R(val, ::ROR((CurInstr.Instr & 0xFF), ((CurInstr.Instr >> 7) & 0x1E))); + MOVI2R(val, melonDS::ROR((CurInstr.Instr & 0xFF), ((CurInstr.Instr >> 7) & 0x1E))); } else { diff --git a/src/ARMJIT_A64/ARMJIT_Compiler.h b/src/ARMJIT_A64/ARMJIT_Compiler.h index 1f79f3d3..d1e5c446 100644 --- a/src/ARMJIT_A64/ARMJIT_Compiler.h +++ b/src/ARMJIT_A64/ARMJIT_Compiler.h @@ -28,7 +28,7 @@ #include -namespace ARMJIT +namespace melonDS { class ARMJIT; const Arm64Gen::ARM64Reg RMemBase = Arm64Gen::X26; diff --git a/src/ARMJIT_A64/ARMJIT_LoadStore.cpp b/src/ARMJIT_A64/ARMJIT_LoadStore.cpp index a779a727..93cd75e6 100644 --- a/src/ARMJIT_A64/ARMJIT_LoadStore.cpp +++ b/src/ARMJIT_A64/ARMJIT_LoadStore.cpp @@ -24,7 +24,7 @@ using namespace Arm64Gen; -namespace ARMJIT +namespace melonDS { bool Compiler::IsJITFault(u8* pc) @@ -79,7 +79,7 @@ bool Compiler::Comp_MemLoadLiteral(int size, bool signExtend, int rd, u32 addr) if (size == 32) { CurCPU->DataRead32(addr & ~0x3, &val); - val = ::ROR(val, (addr & 0x3) << 3); + val = melonDS::ROR(val, (addr & 0x3) << 3); } else if (size == 16) { diff --git a/src/ARMJIT_Internal.h b/src/ARMJIT_Internal.h index 7a8eb6bb..72d40a5f 100644 --- a/src/ARMJIT_Internal.h +++ b/src/ARMJIT_Internal.h @@ -28,13 +28,13 @@ #include "JitBlock.h" #include "TinyVector.h" +namespace melonDS +{ class ARM; class ARMv5; // here lands everything which doesn't fit into ARMJIT.h // where it would be included by pretty much everything -namespace ARMJIT -{ enum { diff --git a/src/ARMJIT_Memory.cpp b/src/ARMJIT_Memory.cpp index 361a1ed3..7ed9b8d1 100644 --- a/src/ARMJIT_Memory.cpp +++ b/src/ARMJIT_Memory.cpp @@ -49,9 +49,6 @@ #include -using Platform::Log; -using Platform::LogLevel; - /* We're handling fastmem here. @@ -100,6 +97,12 @@ using Platform::LogLevel; #endif #endif +namespace melonDS +{ + +using Platform::Log; +using Platform::LogLevel; + #if defined(__ANDROID__) #define ASHMEM_DEVICE "/dev/ashmem" #endif @@ -562,7 +565,7 @@ bool ARMJIT_Memory::MapAtAddress(u32 addr) noexcept } #endif - ARMJIT::AddressRange* range = JIT.CodeMemRegions[region] + memoryOffset / 512; + AddressRange* range = JIT.CodeMemRegions[region] + memoryOffset / 512; // this overcomplicated piece of code basically just finds whole pieces of code memory // which can be mapped/protected @@ -580,9 +583,9 @@ bool ARMJIT_Memory::MapAtAddress(u32 addr) noexcept else { u32 sectionOffset = offset; - bool hasCode = isExecutable && ARMJIT::PageContainsCode(&range[offset / 512]); + bool hasCode = isExecutable && PageContainsCode(&range[offset / 512]); while (offset < mirrorSize - && (!isExecutable || ARMJIT::PageContainsCode(&range[offset / 512]) == hasCode) + && (!isExecutable || PageContainsCode(&range[offset / 512]) == hasCode) && (!skipDTCM || mirrorStart + offset != NDS::ARM9->DTCMBase)) { assert(states[(mirrorStart + offset) >> 12] == memstate_Unmapped); @@ -617,7 +620,7 @@ bool ARMJIT_Memory::MapAtAddress(u32 addr) noexcept return true; } -bool ARMJIT_Memory::FaultHandler(FaultDescription& faultDesc, ARMJIT::ARMJIT& jit) +bool ARMJIT_Memory::FaultHandler(FaultDescription& faultDesc, ARMJIT& jit) { if (jit.JITCompiler.IsJITFault(faultDesc.FaultPC)) { @@ -638,7 +641,7 @@ bool ARMJIT_Memory::FaultHandler(FaultDescription& faultDesc, ARMJIT::ARMJIT& ji const u64 AddrSpaceSize = 0x100000000; -ARMJIT_Memory::ARMJIT_Memory(ARMJIT::ARMJIT& jit) noexcept : JIT(jit) +ARMJIT_Memory::ARMJIT_Memory(ARMJIT& jit) noexcept : JIT(jit) { #if defined(__SWITCH__) MemoryBase = (u8*)aligned_alloc(0x1000, MemoryTotalSize); @@ -1365,3 +1368,4 @@ void* ARMJIT_Memory::GetFuncForAddr(ARM* cpu, u32 addr, bool store, int size) co } return NULL; } +} \ No newline at end of file diff --git a/src/ARMJIT_Memory.h b/src/ARMJIT_Memory.h index 1cf4f811..ed484373 100644 --- a/src/ARMJIT_Memory.h +++ b/src/ARMJIT_Memory.h @@ -42,11 +42,10 @@ #include "NDS.h" #endif -namespace ARMJIT +namespace melonDS { class Compiler; class ARMJIT; -} constexpr u32 RoundUp(u32 size) noexcept { @@ -97,7 +96,7 @@ public: #ifdef JIT_ENABLED public: - explicit ARMJIT_Memory(ARMJIT::ARMJIT& jit) noexcept; + explicit ARMJIT_Memory(ARMJIT& jit) noexcept; ~ARMJIT_Memory() noexcept; ARMJIT_Memory(const ARMJIT_Memory&) = delete; ARMJIT_Memory(ARMJIT_Memory&&) = delete; @@ -138,7 +137,7 @@ public: void* GetFuncForAddr(ARM* cpu, u32 addr, bool store, int size) const noexcept; bool MapAtAddress(u32 addr) noexcept; private: - friend class ARMJIT::Compiler; + friend class Compiler; struct Mapping { u32 Addr; @@ -153,12 +152,12 @@ private: u32 EmulatedFaultAddr; u8* FaultPC; }; - static bool FaultHandler(FaultDescription& faultDesc, ARMJIT::ARMJIT& jit); + static bool FaultHandler(FaultDescription& faultDesc, ARMJIT& jit); bool MapIntoRange(u32 addr, u32 num, u32 offset, u32 size) noexcept; bool UnmapFromRange(u32 addr, u32 num, u32 offset, u32 size) noexcept; void SetCodeProtectionRange(u32 addr, u32 size, u32 num, int protection) noexcept; - ARMJIT::ARMJIT& JIT; + ARMJIT& JIT; void* FastMem9Start; void* FastMem7Start; u8* MemoryBase = nullptr; @@ -178,10 +177,10 @@ private: #endif u8 MappingStatus9[1 << (32-12)] {}; u8 MappingStatus7[1 << (32-12)] {}; - ARMJIT::TinyVector Mappings[memregions_Count] {}; + TinyVector Mappings[memregions_Count] {}; #else public: - explicit ARMJIT_Memory(ARMJIT::ARMJIT&) {}; + explicit ARMJIT_Memory(ARMJIT&) {}; ~ARMJIT_Memory() = default; ARMJIT_Memory(const ARMJIT_Memory&) = delete; ARMJIT_Memory(ARMJIT_Memory&&) = delete; @@ -224,5 +223,5 @@ private: std::array NWRAM_C {}; #endif }; - +} #endif diff --git a/src/ARMJIT_RegisterCache.h b/src/ARMJIT_RegisterCache.h index 16105300..3cb0f79f 100644 --- a/src/ARMJIT_RegisterCache.h +++ b/src/ARMJIT_RegisterCache.h @@ -27,10 +27,11 @@ #include -namespace ARMJIT +namespace melonDS { using Platform::Log; using Platform::LogLevel; + using namespace Common; // Imported inside the namespace so that other headers aren't polluted template diff --git a/src/ARMJIT_x64/ARMJIT_ALU.cpp b/src/ARMJIT_x64/ARMJIT_ALU.cpp index bdc17e8b..69449ff9 100644 --- a/src/ARMJIT_x64/ARMJIT_ALU.cpp +++ b/src/ARMJIT_x64/ARMJIT_ALU.cpp @@ -21,7 +21,7 @@ using namespace Gen; -namespace ARMJIT +namespace melonDS { // uses RSCRATCH3 @@ -129,7 +129,7 @@ OpArg Compiler::A_Comp_GetALUOp2(bool S, bool& carryUsed) Comp_AddCycles_C(); u32 shift = (CurInstr.Instr >> 7) & 0x1E; - u32 imm = ::ROR(CurInstr.Instr & 0xFF, shift); + u32 imm = melonDS::ROR(CurInstr.Instr & 0xFF, shift); carryUsed = false; if (S && shift) diff --git a/src/ARMJIT_x64/ARMJIT_Branch.cpp b/src/ARMJIT_x64/ARMJIT_Branch.cpp index ae7d1aef..5d76447e 100644 --- a/src/ARMJIT_x64/ARMJIT_Branch.cpp +++ b/src/ARMJIT_x64/ARMJIT_Branch.cpp @@ -21,7 +21,7 @@ using namespace Gen; -namespace ARMJIT +namespace melonDS { template diff --git a/src/ARMJIT_x64/ARMJIT_Compiler.cpp b/src/ARMJIT_x64/ARMJIT_Compiler.cpp index 5506db7e..9fc72370 100644 --- a/src/ARMJIT_x64/ARMJIT_Compiler.cpp +++ b/src/ARMJIT_x64/ARMJIT_Compiler.cpp @@ -34,10 +34,11 @@ #endif using namespace Gen; +using namespace Common; extern "C" void ARM_Ret(); -namespace ARMJIT +namespace melonDS { template <> const X64Reg RegisterCache::NativeRegAllocOrder[] = @@ -141,7 +142,7 @@ void Compiler::A_Comp_MSR() Comp_AddCycles_C(); OpArg val = CurInstr.Instr & (1 << 25) - ? Imm32(::ROR((CurInstr.Instr & 0xFF), ((CurInstr.Instr >> 7) & 0x1E))) + ? Imm32(melonDS::ROR((CurInstr.Instr & 0xFF), ((CurInstr.Instr >> 7) & 0x1E))) : MapReg(CurInstr.A_Reg(0)); u32 mask = 0; diff --git a/src/ARMJIT_x64/ARMJIT_Compiler.h b/src/ARMJIT_x64/ARMJIT_Compiler.h index 84efb353..f38a6c3a 100644 --- a/src/ARMJIT_x64/ARMJIT_Compiler.h +++ b/src/ARMJIT_x64/ARMJIT_Compiler.h @@ -30,11 +30,11 @@ #include -class ARMJIT_Memory; -namespace ARMJIT +namespace melonDS { class ARMJIT; +class ARMJIT_Memory; const Gen::X64Reg RCPU = Gen::RBP; const Gen::X64Reg RCPSR = Gen::R15; @@ -172,7 +172,7 @@ public: memop_SubtractOffset = 1 << 4 }; void Comp_MemAccess(int rd, int rn, const Op2& op2, int size, int flags); - s32 Comp_MemAccessBlock(int rn, BitSet16 regs, bool store, bool preinc, bool decrement, bool usermode, bool skipLoadingRn); + s32 Comp_MemAccessBlock(int rn, Common::BitSet16 regs, bool store, bool preinc, bool decrement, bool usermode, bool skipLoadingRn); bool Comp_MemLoadLiteral(int size, bool signExtend, int rd, u32 addr); void Comp_ArithTriOp(void (Compiler::*op)(int, const Gen::OpArg&, const Gen::OpArg&), diff --git a/src/ARMJIT_x64/ARMJIT_GenOffsets.cpp b/src/ARMJIT_x64/ARMJIT_GenOffsets.cpp index 0961fdd9..e2a74eee 100644 --- a/src/ARMJIT_x64/ARMJIT_GenOffsets.cpp +++ b/src/ARMJIT_x64/ARMJIT_GenOffsets.cpp @@ -17,7 +17,7 @@ */ #include "../ARM.h" - +using namespace melonDS; int main(int argc, char* argv[]) { FILE* f = fopen("ARMJIT_Offsets.h", "w"); diff --git a/src/ARMJIT_x64/ARMJIT_LoadStore.cpp b/src/ARMJIT_x64/ARMJIT_LoadStore.cpp index 14334293..9b7d865f 100644 --- a/src/ARMJIT_x64/ARMJIT_LoadStore.cpp +++ b/src/ARMJIT_x64/ARMJIT_LoadStore.cpp @@ -21,7 +21,7 @@ using namespace Gen; -namespace ARMJIT +namespace melonDS { template @@ -85,7 +85,7 @@ bool Compiler::Comp_MemLoadLiteral(int size, bool signExtend, int rd, u32 addr) if (size == 32) { CurCPU->DataRead32(addr & ~0x3, &val); - val = ::ROR(val, (addr & 0x3) << 3); + val = melonDS::ROR(val, (addr & 0x3) << 3); } else if (size == 16) { diff --git a/src/ARM_InstrInfo.cpp b/src/ARM_InstrInfo.cpp index ea9f6810..d53c88f0 100644 --- a/src/ARM_InstrInfo.cpp +++ b/src/ARM_InstrInfo.cpp @@ -22,7 +22,7 @@ #include "ARMJIT.h" -namespace ARMInstrInfo +namespace melonDS::ARMInstrInfo { #define ak(x) ((x) << 23) diff --git a/src/ARM_InstrInfo.h b/src/ARM_InstrInfo.h index 3442c9af..13f66b09 100644 --- a/src/ARM_InstrInfo.h +++ b/src/ARM_InstrInfo.h @@ -21,7 +21,7 @@ #include "types.h" -namespace ARMInstrInfo +namespace melonDS::ARMInstrInfo { // Instruction kinds, for faster dispatch diff --git a/src/CP15.cpp b/src/CP15.cpp index e8d8c1af..af23da3a 100644 --- a/src/CP15.cpp +++ b/src/CP15.cpp @@ -25,6 +25,8 @@ #include "ARMJIT_Memory.h" #include "ARMJIT.h" +namespace melonDS +{ using Platform::Log; using Platform::LogLevel; @@ -1031,3 +1033,4 @@ void ARMv5::GetCodeMemRegion(u32 addr, NDS::MemRegion* region) GetMemRegion(addr, false, &CodeMem); } +} diff --git a/src/CRC32.cpp b/src/CRC32.cpp index 8afa3ba3..0756c034 100644 --- a/src/CRC32.cpp +++ b/src/CRC32.cpp @@ -20,6 +20,8 @@ // http://www.codeproject.com/KB/recipes/crc32_large.aspx +namespace melonDS +{ constexpr u32 _reflect(u32 refl, char ch) { u32 value = 0; @@ -62,3 +64,5 @@ u32 CRC32(const u8 *data, int len, u32 start) return (crc ^ 0xFFFFFFFF); } + +} \ No newline at end of file diff --git a/src/CRC32.h b/src/CRC32.h index 4a1034ca..11879057 100644 --- a/src/CRC32.h +++ b/src/CRC32.h @@ -23,6 +23,9 @@ #include "types.h" +namespace melonDS +{ u32 CRC32(const u8* data, int len, u32 start=0); +} #endif // CRC32_H diff --git a/src/DMA.cpp b/src/DMA.cpp index 91f23454..8afc8971 100644 --- a/src/DMA.cpp +++ b/src/DMA.cpp @@ -24,6 +24,8 @@ #include "DMA_Timings.h" #include "Platform.h" +namespace melonDS +{ using Platform::Log; using Platform::LogLevel; @@ -47,7 +49,7 @@ using Platform::LogLevel; // TODO: timings are nonseq when address is fixed/decrementing -DMA::DMA(u32 cpu, u32 num, Melon::GPU& gpu) : +DMA::DMA(u32 cpu, u32 num, melonDS::GPU& gpu) : CPU(cpu), Num(num), GPU(gpu) @@ -714,3 +716,5 @@ void DMA::Run() template void DMA::Run<0>(); template void DMA::Run<1>(); + +} \ No newline at end of file diff --git a/src/DMA.h b/src/DMA.h index af8b5171..5535661d 100644 --- a/src/DMA.h +++ b/src/DMA.h @@ -24,15 +24,14 @@ #include "Savestate.h" #include "DMA_Timings.h" -namespace Melon +namespace melonDS { class GPU; -} class DMA { public: - DMA(u32 cpu, u32 num, Melon::GPU& gpu); + DMA(u32 cpu, u32 num, GPU& gpu); ~DMA() = default; void Reset(); @@ -84,7 +83,7 @@ public: u32 Cnt {}; private: - Melon::GPU& GPU; + melonDS::GPU& GPU; u32 CPU {}; u32 Num {}; @@ -109,4 +108,5 @@ private: std::array MRAMBurstTable; }; +} #endif diff --git a/src/DMA_Timings.cpp b/src/DMA_Timings.cpp index cea32820..912e4e2e 100644 --- a/src/DMA_Timings.cpp +++ b/src/DMA_Timings.cpp @@ -19,7 +19,7 @@ #include "DMA_Timings.h" #include "types.h" -namespace DMATiming +namespace melonDS::DMATiming { // DMA timing tables diff --git a/src/DMA_Timings.h b/src/DMA_Timings.h index faf2e9c9..63dc4676 100644 --- a/src/DMA_Timings.h +++ b/src/DMA_Timings.h @@ -22,7 +22,7 @@ #include #include "types.h" -namespace DMATiming +namespace melonDS::DMATiming { // DMA timing tables diff --git a/src/DSi.cpp b/src/DSi.cpp index 5c4b5422..351d5ed4 100644 --- a/src/DSi.cpp +++ b/src/DSi.cpp @@ -41,6 +41,8 @@ #include "tiny-AES-c/aes.hpp" +namespace melonDS +{ using namespace Platform; namespace DSi @@ -3143,3 +3145,5 @@ void ARM7IOWrite32(u32 addr, u32 val) } } + +} \ No newline at end of file diff --git a/src/DSi.h b/src/DSi.h index 66a4e808..ac6bf772 100644 --- a/src/DSi.h +++ b/src/DSi.h @@ -22,6 +22,8 @@ #include "NDS.h" #include "DSi_SD.h" +namespace melonDS +{ class DSi_I2CHost; class DSi_CamModule; class DSi_AES; @@ -126,4 +128,5 @@ void ARM7IOWrite32(u32 addr, u32 val); } +} #endif // DSI_H diff --git a/src/DSi_AES.cpp b/src/DSi_AES.cpp index b1d89bd1..a29e43f1 100644 --- a/src/DSi_AES.cpp +++ b/src/DSi_AES.cpp @@ -23,6 +23,8 @@ #include "DSi_AES.h" #include "Platform.h" +namespace melonDS +{ using Platform::Log; using Platform::LogLevel; @@ -572,3 +574,5 @@ void DSi_AES::WriteKeyY(u32 slot, u32 offset, u32 val, u32 mask) DeriveNormalKey(KeyX[slot], KeyY[slot], KeyNormal[slot]); } } + +} \ No newline at end of file diff --git a/src/DSi_AES.h b/src/DSi_AES.h index 1f1c6bf9..9c0a63fe 100644 --- a/src/DSi_AES.h +++ b/src/DSi_AES.h @@ -24,6 +24,8 @@ #include "FIFO.h" #include "tiny-AES-c/aes.hpp" +namespace melonDS +{ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wattributes" #if defined(__GNUC__) && (__GNUC__ >= 11) // gcc 11.* @@ -108,4 +110,5 @@ private: void ProcessBlock_CTR(); }; +} #endif // DSI_AES_H diff --git a/src/DSi_Camera.cpp b/src/DSi_Camera.cpp index 2b259c59..708875c1 100644 --- a/src/DSi_Camera.cpp +++ b/src/DSi_Camera.cpp @@ -23,6 +23,8 @@ #include "DSi_Camera.h" #include "Platform.h" +namespace melonDS +{ using Platform::Log; using Platform::LogLevel; @@ -793,3 +795,5 @@ void DSi_Camera::InputFrame(u32* data, int width, int height, bool rgb) } } } + +} \ No newline at end of file diff --git a/src/DSi_Camera.h b/src/DSi_Camera.h index c3165b3f..8a62e47d 100644 --- a/src/DSi_Camera.h +++ b/src/DSi_Camera.h @@ -23,6 +23,8 @@ #include "Savestate.h" #include "DSi_I2C.h" +namespace melonDS +{ class DSi_CamModule; class DSi_Camera : public DSi_I2CDevice @@ -121,4 +123,5 @@ private: static const u32 kTransferStart; }; +} #endif // DSI_CAMERA_H diff --git a/src/DSi_DSP.cpp b/src/DSi_DSP.cpp index 82a52aeb..61d2b162 100644 --- a/src/DSi_DSP.cpp +++ b/src/DSi_DSP.cpp @@ -24,6 +24,8 @@ #include "NDS.h" #include "Platform.h" +namespace melonDS +{ using Platform::Log; using Platform::LogLevel; @@ -593,3 +595,5 @@ void DSi_DSP::DoSavestate(Savestate* file) // TODO: save the Teakra state!!! } + +} \ No newline at end of file diff --git a/src/DSi_DSP.h b/src/DSi_DSP.h index 56850c0e..18ad3d1d 100644 --- a/src/DSi_DSP.h +++ b/src/DSi_DSP.h @@ -27,6 +27,8 @@ namespace Teakra { class Teakra; } +namespace melonDS +{ class DSi_DSP { public: @@ -104,5 +106,6 @@ private: u16 PDataDMAReadMMIO(); }; +} #endif // DSI_DSP_H diff --git a/src/DSi_I2C.cpp b/src/DSi_I2C.cpp index 8549ecb2..678c8be6 100644 --- a/src/DSi_I2C.cpp +++ b/src/DSi_I2C.cpp @@ -26,6 +26,8 @@ #include "SPI.h" #include "Platform.h" +namespace melonDS +{ using Platform::Log; using Platform::LogLevel; @@ -592,3 +594,5 @@ void DSi_I2CHost::WriteData(u8 val) { Data = val; } + +} \ No newline at end of file diff --git a/src/DSi_I2C.h b/src/DSi_I2C.h index b55dd0bf..83d7e028 100644 --- a/src/DSi_I2C.h +++ b/src/DSi_I2C.h @@ -22,6 +22,8 @@ #include "types.h" #include "Savestate.h" +namespace melonDS +{ class DSi_I2CHost; class DSi_Camera; @@ -180,4 +182,5 @@ private: void GetCurDevice(); }; +} #endif // DSI_I2C_H diff --git a/src/DSi_NAND.cpp b/src/DSi_NAND.cpp index 3db5621f..59f582fd 100644 --- a/src/DSi_NAND.cpp +++ b/src/DSi_NAND.cpp @@ -30,9 +30,9 @@ #include "fatfs/ff.h" -using namespace Platform; +using namespace melonDS::Platform; -namespace DSi_NAND +namespace melonDS::DSi_NAND { NANDImage::NANDImage(Platform::FileHandle* nandfile, const DSiKey& es_keyY) noexcept : NANDImage(nandfile, es_keyY.data()) diff --git a/src/DSi_NAND.h b/src/DSi_NAND.h index 2bb3a02b..699397bd 100644 --- a/src/DSi_NAND.h +++ b/src/DSi_NAND.h @@ -31,7 +31,7 @@ struct AES_ctx; -namespace DSi_NAND +namespace melonDS::DSi_NAND { enum diff --git a/src/DSi_NDMA.cpp b/src/DSi_NDMA.cpp index 0afb2010..4f248eae 100644 --- a/src/DSi_NDMA.cpp +++ b/src/DSi_NDMA.cpp @@ -23,10 +23,12 @@ #include "GPU.h" #include "DSi_AES.h" +namespace melonDS +{ using Platform::Log; using Platform::LogLevel; -DSi_NDMA::DSi_NDMA(u32 cpu, u32 num, Melon::GPU& gpu) : GPU(gpu) +DSi_NDMA::DSi_NDMA(u32 cpu, u32 num, melonDS::GPU& gpu) : GPU(gpu) { CPU = cpu; Num = num; @@ -375,3 +377,5 @@ void DSi_NDMA::Run7() DSi::AES->CheckInputDMA(); DSi::AES->CheckOutputDMA(); } + +} \ No newline at end of file diff --git a/src/DSi_NDMA.h b/src/DSi_NDMA.h index 732bc9d2..4479341b 100644 --- a/src/DSi_NDMA.h +++ b/src/DSi_NDMA.h @@ -22,15 +22,14 @@ #include "types.h" #include "Savestate.h" -namespace Melon +namespace melonDS { class GPU; -} class DSi_NDMA { public: - DSi_NDMA(u32 cpu, u32 num, Melon::GPU& gpu); + DSi_NDMA(u32 cpu, u32 num, GPU& gpu); ~DSi_NDMA(); void Reset(); @@ -78,7 +77,7 @@ public: u32 Cnt; private: - Melon::GPU& GPU; + melonDS::GPU& GPU; u32 CPU, Num; u32 StartMode; @@ -100,4 +99,5 @@ private: bool IsGXFIFODMA; }; +} #endif // DSI_NDMA_H diff --git a/src/DSi_NWifi.cpp b/src/DSi_NWifi.cpp index 6e19421d..66320ba2 100644 --- a/src/DSi_NWifi.cpp +++ b/src/DSi_NWifi.cpp @@ -24,6 +24,9 @@ #include "WifiAP.h" #include "Platform.h" +namespace melonDS +{ + using Platform::Log; using Platform::LogLevel; @@ -1607,3 +1610,5 @@ void DSi_NWifi::MSTimer(u32 param) NDS::ScheduleEvent(NDS::Event_DSi_NWifi, true, 33611, 0, 0); } + +} \ No newline at end of file diff --git a/src/DSi_NWifi.h b/src/DSi_NWifi.h index c3e577c2..f3e5e150 100644 --- a/src/DSi_NWifi.h +++ b/src/DSi_NWifi.h @@ -23,6 +23,8 @@ #include "FIFO.h" #include "Savestate.h" +namespace melonDS +{ class DSi_NWifi : public DSi_SDDevice { public: @@ -146,4 +148,5 @@ private: u8 LANBuffer[2048]; }; +} #endif // DSI_NWIFI_H diff --git a/src/DSi_SD.cpp b/src/DSi_SD.cpp index 409a4083..5174af33 100644 --- a/src/DSi_SD.cpp +++ b/src/DSi_SD.cpp @@ -24,6 +24,8 @@ #include "DSi_NWifi.h" #include "Platform.h" +namespace melonDS +{ using namespace Platform; // observed IRQ behavior during transfers @@ -1095,3 +1097,5 @@ u32 DSi_MMCStorage::WriteBlock(u64 addr) return len; } + +} \ No newline at end of file diff --git a/src/DSi_SD.h b/src/DSi_SD.h index 0940b547..faa42964 100644 --- a/src/DSi_SD.h +++ b/src/DSi_SD.h @@ -24,6 +24,8 @@ #include "FATStorage.h" #include "Savestate.h" +namespace melonDS +{ namespace DSi_NAND { class NANDImage; @@ -169,4 +171,5 @@ private: u32 WriteBlock(u64 addr); }; +} #endif // DSI_SD_H diff --git a/src/DSi_SPI_TSC.cpp b/src/DSi_SPI_TSC.cpp index 7040fccf..520e57ba 100644 --- a/src/DSi_SPI_TSC.cpp +++ b/src/DSi_SPI_TSC.cpp @@ -22,6 +22,8 @@ #include "DSi_SPI_TSC.h" #include "Platform.h" +namespace melonDS +{ using Platform::Log; using Platform::LogLevel; @@ -219,3 +221,5 @@ void DSi_TSC::Release() DataPos = 0; } + +} \ No newline at end of file diff --git a/src/DSi_SPI_TSC.h b/src/DSi_SPI_TSC.h index ebac3952..8e9ff912 100644 --- a/src/DSi_SPI_TSC.h +++ b/src/DSi_SPI_TSC.h @@ -23,6 +23,8 @@ #include "Savestate.h" #include "SPI.h" +namespace melonDS +{ class DSi_TSC : public TSC { public: @@ -50,4 +52,5 @@ private: u8 TSCMode; }; +} #endif // DSI_SPI_TSC diff --git a/src/DSi_TMD.h b/src/DSi_TMD.h index 12226c55..f07b3d1c 100644 --- a/src/DSi_TMD.h +++ b/src/DSi_TMD.h @@ -22,7 +22,7 @@ #include "types.h" #include -namespace DSi_TMD +namespace melonDS::DSi_TMD { struct TitleMetadataContent { diff --git a/src/FATIO.cpp b/src/FATIO.cpp index 3e91fbad..233014e4 100644 --- a/src/FATIO.cpp +++ b/src/FATIO.cpp @@ -20,13 +20,15 @@ #include "fatfs/ff.h" #include "fatfs/diskio.h" +using namespace melonDS; + static ff_disk_read_cb ReadCb; static ff_disk_write_cb WriteCb; static LBA_t SectorCount; static DSTATUS Status = STA_NOINIT | STA_NODISK; -void ff_disk_open(const ff_disk_read_cb& readcb, const ff_disk_write_cb& writecb, LBA_t seccnt) +void melonDS::ff_disk_open(const ff_disk_read_cb& readcb, const ff_disk_write_cb& writecb, LBA_t seccnt) { if (!readcb) return; @@ -39,7 +41,7 @@ void ff_disk_open(const ff_disk_read_cb& readcb, const ff_disk_write_cb& writecb else Status &= ~STA_PROTECT; } -void ff_disk_close() +void melonDS::ff_disk_close() { ReadCb = nullptr; WriteCb = nullptr; diff --git a/src/FATIO.h b/src/FATIO.h index b3b63f3f..6d8aa499 100644 --- a/src/FATIO.h +++ b/src/FATIO.h @@ -24,11 +24,13 @@ #include "fatfs/ff.h" // extra additions for interfacing with melonDS - +namespace melonDS +{ using ff_disk_read_cb = std::function; using ff_disk_write_cb = std::function; void ff_disk_open(const ff_disk_read_cb& readcb, const ff_disk_write_cb& writecb, LBA_t seccnt); void ff_disk_close(); +} #endif // FATIO_H diff --git a/src/FATStorage.cpp b/src/FATStorage.cpp index e357470b..cd0a03c8 100644 --- a/src/FATStorage.cpp +++ b/src/FATStorage.cpp @@ -25,6 +25,8 @@ #include "FATStorage.h" #include "Platform.h" +namespace melonDS +{ namespace fs = std::filesystem; using namespace Platform; @@ -1104,3 +1106,5 @@ bool FATStorage::Save() return true; } + +} \ No newline at end of file diff --git a/src/FATStorage.h b/src/FATStorage.h index 54adb5d4..2bdafad8 100644 --- a/src/FATStorage.h +++ b/src/FATStorage.h @@ -28,7 +28,8 @@ #include "types.h" #include "fatfs/ff.h" - +namespace melonDS +{ class FATStorage { public: @@ -99,4 +100,5 @@ private: std::map FileIndex; }; +} #endif // FATSTORAGE_H diff --git a/src/FIFO.h b/src/FIFO.h index c1cbdbf4..cbff4ab9 100644 --- a/src/FIFO.h +++ b/src/FIFO.h @@ -22,6 +22,8 @@ #include "types.h" #include "Savestate.h" +namespace melonDS +{ template class FIFO { @@ -189,4 +191,5 @@ private: u32 ReadPos, WritePos; }; +} #endif diff --git a/src/FreeBIOS.cpp b/src/FreeBIOS.cpp index 972f4b8e..7eef18b7 100644 --- a/src/FreeBIOS.cpp +++ b/src/FreeBIOS.cpp @@ -26,6 +26,8 @@ #include "FreeBIOS.h" +namespace melonDS +{ unsigned char bios_arm7_bin[] = { 0x1c, 0x04, 0x00, 0xea, 0x1c, 0x04, 0x00, 0xea, 0x1c, 0x04, 0x00, 0xea, 0x1a, 0x04, 0x00, 0xea, 0x19, 0x04, 0x00, 0xea, 0x18, 0x04, 0x00, 0xea, @@ -1738,4 +1740,5 @@ unsigned char bios_arm9_bin[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; \ No newline at end of file +}; +} \ No newline at end of file diff --git a/src/FreeBIOS.h b/src/FreeBIOS.h index 82cb3694..ce90725d 100644 --- a/src/FreeBIOS.h +++ b/src/FreeBIOS.h @@ -28,7 +28,10 @@ #ifndef FREEBIOS_H #define FREEBIOS_H +namespace melonDS +{ extern unsigned char bios_arm7_bin[16384]; extern unsigned char bios_arm9_bin[4096]; +} #endif // FREEBIOS_H diff --git a/src/GBACart.cpp b/src/GBACart.cpp index f20feea7..a0c5467e 100644 --- a/src/GBACart.cpp +++ b/src/GBACart.cpp @@ -24,6 +24,8 @@ #include "CRC32.h" #include "Platform.h" +namespace melonDS +{ using Platform::Log; using Platform::LogLevel; @@ -897,3 +899,5 @@ void GBACartSlot::SRAMWrite(u32 addr, u8 val) noexcept } } + +} \ No newline at end of file diff --git a/src/GBACart.h b/src/GBACart.h index 7447f6f4..a5570897 100644 --- a/src/GBACart.h +++ b/src/GBACart.h @@ -23,7 +23,7 @@ #include "types.h" #include "Savestate.h" -namespace GBACart +namespace melonDS::GBACart { enum CartType diff --git a/src/GPU.cpp b/src/GPU.cpp index 5c67cfbb..27dcbfbb 100644 --- a/src/GPU.cpp +++ b/src/GPU.cpp @@ -26,6 +26,8 @@ #include "GPU3D_Soft.h" #include "GPU3D_OpenGL.h" +namespace melonDS +{ using Platform::Log; using Platform::LogLevel; @@ -33,8 +35,6 @@ using Platform::LogLevel; #define HBLANK_CYCLES (48+(256*6)) #define FRAME_CYCLES (LINE_CYCLES * 263) -namespace Melon -{ enum { LCD_StartHBlank = 0, @@ -64,7 +64,7 @@ enum VRAMDirty need to be reset for the respective VRAM bank. */ -GPU::GPU(ARMJIT::ARMJIT& jit) noexcept : GPU2D_A(0, *this), GPU2D_B(1, *this), JIT(jit) +GPU::GPU(ARMJIT& jit) noexcept : GPU2D_A(0, *this), GPU2D_B(1, *this), JIT(jit) { NDS::RegisterEventFunc(NDS::Event_LCD, LCD_StartHBlank, MemberEventFunc(GPU, StartHBlank)); NDS::RegisterEventFunc(NDS::Event_LCD, LCD_StartScanline, MemberEventFunc(GPU, StartScanline)); @@ -319,21 +319,21 @@ void GPU::InitRenderer(int renderer) noexcept { // Fallback on software renderer renderer = 0; - GPU3D.SetCurrentRenderer(std::make_unique(*this)); + GPU3D.SetCurrentRenderer(std::make_unique(*this)); } - GPU3D.SetCurrentRenderer(GPU3D::GLRenderer::New(*this)); + GPU3D.SetCurrentRenderer(GLRenderer::New(*this)); if (!GPU3D.GetCurrentRenderer()) { // Fallback on software renderer CurGLCompositor.reset(); renderer = 0; - GPU3D.SetCurrentRenderer(std::make_unique(*this)); + GPU3D.SetCurrentRenderer(std::make_unique(*this)); } } else #endif { - GPU3D.SetCurrentRenderer(std::make_unique(*this)); + GPU3D.SetCurrentRenderer(std::make_unique(*this)); } Renderer = renderer; diff --git a/src/GPU.h b/src/GPU.h index c3941eb3..dbeec528 100644 --- a/src/GPU.h +++ b/src/GPU.h @@ -29,19 +29,11 @@ #include "GPU_OpenGL.h" #endif - -namespace GPU3D +namespace melonDS { class GPU3D; -} - -namespace ARMJIT -{ class ARMJIT; -} -namespace Melon -{ static constexpr u32 VRAMDirtyGranularity = 512; class GPU; @@ -75,7 +67,7 @@ struct RenderSettings class GPU { public: - GPU(ARMJIT::ARMJIT& jit) noexcept; + GPU(ARMJIT& jit) noexcept; ~GPU() noexcept; void Reset() noexcept; void Stop() noexcept; @@ -544,7 +536,7 @@ public: void SyncDirtyFlags() noexcept; - ARMJIT::ARMJIT& JIT; + ARMJIT& JIT; u16 VCount = 0; u16 TotalScanlines = 0; u16 DispStat[2] {}; @@ -590,7 +582,7 @@ public: GPU2D::Unit GPU2D_A; GPU2D::Unit GPU2D_B; - GPU3D::GPU3D GPU3D {}; + melonDS::GPU3D GPU3D {}; NonStupidBitField<128*1024/VRAMDirtyGranularity> VRAMDirty[9] {}; VRAMTrackingSet<512*1024, 16*1024> VRAMDirty_ABG {}; diff --git a/src/GPU2D.cpp b/src/GPU2D.cpp index e892116c..e7fb9a29 100644 --- a/src/GPU2D.cpp +++ b/src/GPU2D.cpp @@ -21,6 +21,8 @@ #include "NDS.h" #include "GPU.h" +namespace melonDS +{ using Platform::Log; using Platform::LogLevel; @@ -84,8 +86,7 @@ using Platform::LogLevel; namespace GPU2D { - -Unit::Unit(u32 num, Melon::GPU& gpu) : Num(num), GPU(gpu) +Unit::Unit(u32 num, melonDS::GPU& gpu) : Num(num), GPU(gpu) { } @@ -722,3 +723,4 @@ void Unit::GetOBJVRAM(u8*& data, u32& mask) } } +} diff --git a/src/GPU2D.h b/src/GPU2D.h index ad052bf1..dd3bbf6b 100644 --- a/src/GPU2D.h +++ b/src/GPU2D.h @@ -22,10 +22,9 @@ #include "types.h" #include "Savestate.h" -namespace Melon +namespace melonDS { class GPU; -} namespace GPU2D { @@ -35,7 +34,7 @@ class Unit public: // take a reference to the GPU so we can access its state // and ensure that it's not null - Unit(u32 num, Melon::GPU& gpu); + Unit(u32 num, melonDS::GPU& gpu); Unit(const Unit&) = delete; Unit& operator=(const Unit&) = delete; @@ -124,7 +123,7 @@ public: u16 MasterBrightness; private: - Melon::GPU& GPU; + melonDS::GPU& GPU; }; class Renderer2D @@ -150,4 +149,5 @@ protected: } +} #endif diff --git a/src/GPU2D_Soft.cpp b/src/GPU2D_Soft.cpp index 7447bcf9..9e7d8491 100644 --- a/src/GPU2D_Soft.cpp +++ b/src/GPU2D_Soft.cpp @@ -20,10 +20,11 @@ #include "GPU.h" #include "GPU3D_OpenGL.h" +namespace melonDS +{ namespace GPU2D { - -SoftRenderer::SoftRenderer(Melon::GPU& gpu) +SoftRenderer::SoftRenderer(melonDS::GPU& gpu) : Renderer2D(), GPU(gpu) { // initialize mosaic table @@ -368,7 +369,7 @@ void SoftRenderer::VBlankEnd(Unit* unitA, Unit* unitB) { if ((unitA->CaptureCnt & (1<<31)) && (((unitA->CaptureCnt >> 29) & 0x3) != 1)) { - reinterpret_cast(GPU.GPU3D.GetCurrentRenderer())->PrepareCaptureFrame(); + reinterpret_cast(GPU.GPU3D.GetCurrentRenderer())->PrepareCaptureFrame(); } } #endif @@ -479,8 +480,8 @@ void SoftRenderer::DoCapture(u32 line, u32 width) dstaddr &= 0xFFFF; srcBaddr &= 0xFFFF; - static_assert(Melon::VRAMDirtyGranularity == 512); - GPU.VRAMDirty[dstvram][(dstaddr * 2) / Melon::VRAMDirtyGranularity] = true; + static_assert(VRAMDirtyGranularity == 512); + GPU.VRAMDirty[dstvram][(dstaddr * 2) / VRAMDirtyGranularity] = true; switch ((captureCnt >> 29) & 0x3) { @@ -2226,3 +2227,4 @@ void SoftRenderer::DrawSprite_Normal(u32 num, u32 width, u32 height, s32 xpos, s } } +} diff --git a/src/GPU2D_Soft.h b/src/GPU2D_Soft.h index 7d6d65f9..86943d33 100644 --- a/src/GPU2D_Soft.h +++ b/src/GPU2D_Soft.h @@ -20,10 +20,9 @@ #include "GPU2D.h" -namespace Melon +namespace melonDS { class GPU; -} namespace GPU2D { @@ -31,14 +30,14 @@ namespace GPU2D class SoftRenderer : public Renderer2D { public: - SoftRenderer(Melon::GPU& gpu); + SoftRenderer(melonDS::GPU& gpu); ~SoftRenderer() override {} void DrawScanline(u32 line, Unit* unit) override; void DrawSprites(u32 line, Unit* unit) override; void VBlankEnd(Unit* unitA, Unit* unitB) override; private: - Melon::GPU& GPU; + melonDS::GPU& GPU; alignas(8) u32 BGOBJLine[256*3]; u32* _3DLine; @@ -84,3 +83,5 @@ private: }; } + +} \ No newline at end of file diff --git a/src/GPU3D.cpp b/src/GPU3D.cpp index 80c5d468..b00e6fd2 100644 --- a/src/GPU3D.cpp +++ b/src/GPU3D.cpp @@ -24,6 +24,8 @@ #include "FIFO.h" #include "Platform.h" +namespace melonDS +{ using Platform::Log; using Platform::LogLevel; @@ -98,9 +100,6 @@ using Platform::LogLevel; // * additionally, some commands (BEGIN, LIGHT_VECTOR, BOXTEST) stall the polygon pipeline -namespace GPU3D -{ - const u8 CmdNumParams[256] = { // 0x00 diff --git a/src/GPU3D.h b/src/GPU3D.h index b8a2d55d..f543ff86 100644 --- a/src/GPU3D.h +++ b/src/GPU3D.h @@ -25,13 +25,9 @@ #include "Savestate.h" #include "FIFO.h" -namespace Melon +namespace melonDS { struct RenderSettings; -} - -namespace GPU3D -{ struct Vertex { @@ -340,7 +336,7 @@ public: // are more detailed "traits" that we can ask of the Renderer3D type const bool Accelerated; - virtual void SetRenderSettings(const Melon::RenderSettings& settings) noexcept = 0; + virtual void SetRenderSettings(const RenderSettings& settings) noexcept = 0; virtual void VCount144() {}; diff --git a/src/GPU3D_OpenGL.cpp b/src/GPU3D_OpenGL.cpp index 629ec157..fb9f2461 100644 --- a/src/GPU3D_OpenGL.cpp +++ b/src/GPU3D_OpenGL.cpp @@ -25,7 +25,7 @@ #include "GPU.h" #include "GPU3D_OpenGL_shaders.h" -namespace GPU3D +namespace melonDS { bool GLRenderer::BuildRenderShader(u32 flags, const char* vs, const char* fs) @@ -97,14 +97,14 @@ void SetupDefaultTexParams(GLuint tex) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); } -GLRenderer::GLRenderer(Melon::GPU& gpu) noexcept : Renderer3D(true), GPU(gpu) +GLRenderer::GLRenderer(melonDS::GPU& gpu) noexcept : Renderer3D(true), GPU(gpu) { // GLRenderer::New() will be used to actually initialize the renderer; // The various glDelete* functions silently ignore invalid IDs, // so we can just let the destructor clean up a half-initialized renderer. } -std::unique_ptr GLRenderer::New(Melon::GPU& gpu) noexcept +std::unique_ptr GLRenderer::New(melonDS::GPU& gpu) noexcept { assert(glEnable != nullptr); @@ -329,7 +329,7 @@ void GLRenderer::Reset() { } -void GLRenderer::SetRenderSettings(const Melon::RenderSettings& settings) noexcept +void GLRenderer::SetRenderSettings(const RenderSettings& settings) noexcept { int scale = settings.GL_ScaleFactor; diff --git a/src/GPU3D_OpenGL.h b/src/GPU3D_OpenGL.h index 3657a12a..0bc20d81 100644 --- a/src/GPU3D_OpenGL.h +++ b/src/GPU3D_OpenGL.h @@ -23,20 +23,17 @@ #include "OpenGLSupport.h" -namespace Melon +namespace melonDS { class GPU; -} -namespace GPU3D -{ class GLRenderer : public Renderer3D { public: virtual ~GLRenderer() override; virtual void Reset() override; - virtual void SetRenderSettings(const Melon::RenderSettings& settings) noexcept override; + virtual void SetRenderSettings(const RenderSettings& settings) noexcept override; virtual void VCount144() override {}; virtual void RenderFrame() override; @@ -45,10 +42,10 @@ public: void SetupAccelFrame(); void PrepareCaptureFrame(); - static std::unique_ptr New(Melon::GPU& gpu) noexcept; + static std::unique_ptr New(melonDS::GPU& gpu) noexcept; private: // Used by New() - GLRenderer(Melon::GPU& gpu) noexcept; + GLRenderer(melonDS::GPU& gpu) noexcept; // GL version requirements // * texelFetch: 3.0 (GLSL 1.30) (3.2/1.50 for MS) @@ -68,7 +65,7 @@ private: u32 RenderKey; }; - Melon::GPU& GPU; + melonDS::GPU& GPU; RendererPolygon PolygonList[2048] {}; bool BuildRenderShader(u32 flags, const char* vs, const char* fs); diff --git a/src/GPU3D_OpenGL_shaders.h b/src/GPU3D_OpenGL_shaders.h index 81313812..13492b7f 100644 --- a/src/GPU3D_OpenGL_shaders.h +++ b/src/GPU3D_OpenGL_shaders.h @@ -21,7 +21,8 @@ #define kShaderHeader "#version 140" - +namespace melonDS +{ const char* kClearVS = kShaderHeader R"( in vec2 vPosition; @@ -802,5 +803,5 @@ void main() gl_FragDepth = fZ; } )"; - +} #endif // GPU3D_OPENGL_SHADERS_H diff --git a/src/GPU3D_Soft.cpp b/src/GPU3D_Soft.cpp index 823f7520..c6b46312 100644 --- a/src/GPU3D_Soft.cpp +++ b/src/GPU3D_Soft.cpp @@ -24,8 +24,7 @@ #include "NDS.h" #include "GPU.h" - -namespace GPU3D +namespace melonDS { void RenderThreadFunc(); @@ -72,7 +71,7 @@ void SoftRenderer::SetupRenderThread() } -SoftRenderer::SoftRenderer(Melon::GPU& gpu) noexcept +SoftRenderer::SoftRenderer(melonDS::GPU& gpu) noexcept : Renderer3D(false), GPU(gpu) { Sema_RenderStart = Platform::Semaphore_Create(); @@ -105,7 +104,7 @@ void SoftRenderer::Reset() SetupRenderThread(); } -void SoftRenderer::SetRenderSettings(const Melon::RenderSettings& settings) noexcept +void SoftRenderer::SetRenderSettings(const RenderSettings& settings) noexcept { Threaded = settings.Soft_Threaded; SetupRenderThread(); diff --git a/src/GPU3D_Soft.h b/src/GPU3D_Soft.h index b1cfb2f1..9fb9a718 100644 --- a/src/GPU3D_Soft.h +++ b/src/GPU3D_Soft.h @@ -24,16 +24,16 @@ #include #include -namespace GPU3D +namespace melonDS { class SoftRenderer : public Renderer3D { public: - SoftRenderer(Melon::GPU& gpu) noexcept; + SoftRenderer(melonDS::GPU& gpu) noexcept; virtual ~SoftRenderer() override; virtual void Reset() override; - virtual void SetRenderSettings(const Melon::RenderSettings& settings) noexcept override; + virtual void SetRenderSettings(const RenderSettings& settings) noexcept override; virtual void VCount144() override; virtual void RenderFrame() override; @@ -451,7 +451,7 @@ private: }; - Melon::GPU& GPU; + melonDS::GPU& GPU; RendererPolygon PolygonList[2048]; void TextureLookup(u32 texparam, u32 texpal, s16 s, s16 t, u16* color, u8* alpha); u32 RenderPixel(Polygon* polygon, u8 vr, u8 vg, u8 vb, s16 s, s16 t); diff --git a/src/GPU_OpenGL.cpp b/src/GPU_OpenGL.cpp index d0649bb1..2db38105 100644 --- a/src/GPU_OpenGL.cpp +++ b/src/GPU_OpenGL.cpp @@ -28,12 +28,12 @@ #include "OpenGLSupport.h" #include "GPU_OpenGL_shaders.h" -namespace Melon +namespace melonDS { using namespace OpenGL; -std::unique_ptr GLCompositor::New(Melon::GPU& gpu) noexcept +std::unique_ptr GLCompositor::New(melonDS::GPU& gpu) noexcept { assert(glBindAttribLocation != nullptr); @@ -53,7 +53,7 @@ std::unique_ptr GLCompositor::New(Melon::GPU& gpu) noexcept return std::unique_ptr(new GLCompositor(CompShader, gpu)); } -GLCompositor::GLCompositor(std::array compShader, Melon::GPU& gpu) noexcept : CompShader(compShader), GPU(gpu) +GLCompositor::GLCompositor(std::array compShader, melonDS::GPU& gpu) noexcept : CompShader(compShader), GPU(gpu) { CompScaleLoc = glGetUniformLocation(CompShader[2], "u3DScale"); Comp3DXPosLoc = glGetUniformLocation(CompShader[2], "u3DXPos"); @@ -218,7 +218,7 @@ void GLCompositor::RenderFrame() } glActiveTexture(GL_TEXTURE1); - reinterpret_cast(GPU.GPU3D.GetCurrentRenderer())->SetupAccelFrame(); + reinterpret_cast(GPU.GPU3D.GetCurrentRenderer())->SetupAccelFrame(); glBindBuffer(GL_ARRAY_BUFFER, CompVertexBufferID); glBindVertexArray(CompVertexArrayID); diff --git a/src/GPU_OpenGL.h b/src/GPU_OpenGL.h index 3763b6b4..68462a9a 100644 --- a/src/GPU_OpenGL.h +++ b/src/GPU_OpenGL.h @@ -23,7 +23,7 @@ #include #include -namespace Melon +namespace melonDS { class GPU; struct RenderSettings; @@ -31,7 +31,7 @@ struct RenderSettings; class GLCompositor { public: - static std::unique_ptr New(Melon::GPU& gpu) noexcept; + static std::unique_ptr New(melonDS::GPU& gpu) noexcept; GLCompositor(const GLCompositor&) = delete; GLCompositor& operator=(const GLCompositor&) = delete; ~GLCompositor(); @@ -44,8 +44,8 @@ public: void RenderFrame(); void BindOutputTexture(int buf); private: - GLCompositor(std::array CompShader, Melon::GPU& gpu) noexcept; - Melon::GPU& GPU; + GLCompositor(std::array CompShader, melonDS::GPU& gpu) noexcept; + melonDS::GPU& GPU; int Scale; int ScreenH, ScreenW; diff --git a/src/GPU_OpenGL_shaders.h b/src/GPU_OpenGL_shaders.h index 9a7d6aba..a8c5b951 100644 --- a/src/GPU_OpenGL_shaders.h +++ b/src/GPU_OpenGL_shaders.h @@ -19,6 +19,8 @@ #ifndef GPU_OPENGL_SHADERS_H #define GPU_OPENGL_SHADERS_H +namespace melonDS +{ const char* kCompositorVS = R"(#version 140 in vec2 vPosition; @@ -866,5 +868,6 @@ void main() +} #endif // GPU_OPENGL_SHADERS_H diff --git a/src/JitBlock.h b/src/JitBlock.h index abd435be..6a187b27 100644 --- a/src/JitBlock.h +++ b/src/JitBlock.h @@ -22,7 +22,7 @@ #include "types.h" #include "TinyVector.h" -namespace ARMJIT +namespace melonDS { typedef void (*JitBlockEntry)(); diff --git a/src/NDS.cpp b/src/NDS.cpp index a216fed2..576eb9cd 100644 --- a/src/NDS.cpp +++ b/src/NDS.cpp @@ -43,6 +43,8 @@ #include "ARMJIT.h" #include "ARMJIT_Memory.h" +namespace melonDS +{ using namespace Platform; namespace NDS @@ -182,8 +184,8 @@ class RTC* RTC; class Wifi* Wifi; std::unique_ptr NDSCartSlot; std::unique_ptr GBACartSlot; -std::unique_ptr GPU; -std::unique_ptr JIT; +std::unique_ptr GPU; +std::unique_ptr JIT; class AREngine* AREngine; bool Running; @@ -203,8 +205,8 @@ bool Init() RegisterEventFunc(Event_Div, 0, DivDone); RegisterEventFunc(Event_Sqrt, 0, SqrtDone); - JIT = std::make_unique(); - GPU = std::make_unique(*JIT); + JIT = std::make_unique(); + GPU = std::make_unique(*JIT); MainRAM = JIT->Memory.GetMainRAM(); SharedWRAM = JIT->Memory.GetSharedWRAM(); @@ -4462,3 +4464,5 @@ void ARM7IOWrite32(u32 addr, u32 val) } } + +} \ No newline at end of file diff --git a/src/NDS.h b/src/NDS.h index a1155ba0..7bfad625 100644 --- a/src/NDS.h +++ b/src/NDS.h @@ -34,22 +34,16 @@ // with this enabled, to make sure it doesn't desync //#define DEBUG_CHECK_DESYNC +namespace melonDS +{ class SPU; class SPIHost; class RTC; class Wifi; class AREngine; - -namespace Melon -{ class GPU; -} - -namespace ARMJIT -{ class ARMJIT; -} namespace NDS { @@ -273,8 +267,8 @@ extern class RTC* RTC; extern class Wifi* Wifi; extern std::unique_ptr NDSCartSlot; extern std::unique_ptr GBACartSlot; -extern std::unique_ptr GPU; -extern std::unique_ptr JIT; +extern std::unique_ptr GPU; +extern std::unique_ptr JIT; extern class AREngine* AREngine; const u32 ARM7WRAMSize = 0x10000; @@ -394,4 +388,5 @@ void ARM7IOWrite32(u32 addr, u32 val); } +} #endif // NDS_H diff --git a/src/NDSCart.cpp b/src/NDSCart.cpp index bf2b7913..77262a70 100644 --- a/src/NDSCart.cpp +++ b/src/NDSCart.cpp @@ -27,6 +27,8 @@ #include "melonDLDI.h" #include "xxhash/xxhash.h" +namespace melonDS +{ using Platform::Log; using Platform::LogLevel; @@ -2068,3 +2070,5 @@ void NDSCartSlot::WriteSPIData(u8 val) noexcept } } + +} \ No newline at end of file diff --git a/src/NDSCart.h b/src/NDSCart.h index 33a17bba..18d1fb6d 100644 --- a/src/NDSCart.h +++ b/src/NDSCart.h @@ -30,7 +30,7 @@ #include "FATStorage.h" #include "ROMList.h" -namespace NDSCart +namespace melonDS::NDSCart { enum CartType diff --git a/src/NDS_Header.h b/src/NDS_Header.h index 626f80cb..de75f7c7 100644 --- a/src/NDS_Header.h +++ b/src/NDS_Header.h @@ -22,6 +22,8 @@ #include #include "types.h" +namespace melonDS +{ /// Set to indicate the console regions that a ROM (including DSiWare) /// can be played on. enum RegionMask : u32 @@ -242,5 +244,6 @@ struct NDSBanner static_assert(sizeof(NDSBanner) == 9152, "NDSBanner is not 9152 bytes!"); +} #endif //NDS_HEADER_H diff --git a/src/NonStupidBitfield.h b/src/NonStupidBitfield.h index a4fe7ec8..eb5e1f2b 100644 --- a/src/NonStupidBitfield.h +++ b/src/NonStupidBitfield.h @@ -29,6 +29,8 @@ // like std::bitset but less stupid and optimised for // our use case (keeping track of memory invalidations) +namespace melonDS +{ template struct NonStupidBitField { @@ -203,5 +205,6 @@ struct NonStupidBitField } }; +} #endif diff --git a/src/OpenGLSupport.cpp b/src/OpenGLSupport.cpp index 4962b4c1..0eb05c53 100644 --- a/src/OpenGLSupport.cpp +++ b/src/OpenGLSupport.cpp @@ -18,6 +18,9 @@ #include "OpenGLSupport.h" +namespace melonDS +{ + using Platform::Log; using Platform::LogLevel; @@ -142,3 +145,5 @@ void UseShaderProgram(GLuint* ids) } } + +} \ No newline at end of file diff --git a/src/OpenGLSupport.h b/src/OpenGLSupport.h index ed75f386..ee5b5043 100644 --- a/src/OpenGLSupport.h +++ b/src/OpenGLSupport.h @@ -25,8 +25,7 @@ #include "Platform.h" #include "PlatformOGL.h" - -namespace OpenGL +namespace melonDS::OpenGL { bool BuildShaderProgram(const char* vs, const char* fs, GLuint* ids, const char* name); diff --git a/src/Platform.h b/src/Platform.h index de1ca8b2..f8b0453c 100644 --- a/src/Platform.h +++ b/src/Platform.h @@ -24,6 +24,8 @@ #include #include +namespace melonDS +{ class Firmware; namespace Platform @@ -394,4 +396,5 @@ void DynamicLibrary_Unload(DynamicLibrary* lib); void* DynamicLibrary_LoadFunction(DynamicLibrary* lib, const char* name); } +} #endif // PLATFORM_H diff --git a/src/ROMList.cpp b/src/ROMList.cpp index 564f4a40..3ff771f8 100644 --- a/src/ROMList.cpp +++ b/src/ROMList.cpp @@ -18,6 +18,8 @@ #include "ROMList.h" +namespace melonDS +{ const ROMListEntry ROMList[] = { {0x41464141, 0x00800000, 0x00000004}, @@ -6801,3 +6803,5 @@ const ROMListEntry ROMList[] = }; const size_t ROMListEntryCount = sizeof(ROMList) / sizeof(ROMListEntry); + +} \ No newline at end of file diff --git a/src/ROMList.h b/src/ROMList.h index 11db1773..82ee0ccf 100644 --- a/src/ROMList.h +++ b/src/ROMList.h @@ -23,6 +23,8 @@ #include "types.h" +namespace melonDS +{ struct ROMListEntry { u32 GameCode; @@ -36,4 +38,5 @@ extern const ROMListEntry ROMList[]; /// The number of elements in \c ROMList. extern const size_t ROMListEntryCount; +} #endif // ROMLIST_H diff --git a/src/RTC.cpp b/src/RTC.cpp index d451585b..747348ce 100644 --- a/src/RTC.cpp +++ b/src/RTC.cpp @@ -21,6 +21,8 @@ #include "RTC.h" #include "Platform.h" +namespace melonDS +{ using Platform::Log; using Platform::LogLevel; @@ -940,3 +942,5 @@ void RTC::Write(u16 val, bool byte) else IO = (IO & 0x0001) | (val & 0xFFFE); } + +} \ No newline at end of file diff --git a/src/RTC.h b/src/RTC.h index 313d2377..45d0f26b 100644 --- a/src/RTC.h +++ b/src/RTC.h @@ -22,6 +22,8 @@ #include "types.h" #include "Savestate.h" +namespace melonDS +{ class RTC { public: @@ -113,4 +115,5 @@ private: void ByteIn(u8 val); }; +} #endif diff --git a/src/SPI.cpp b/src/SPI.cpp index a95cd1c2..3ded7bcc 100644 --- a/src/SPI.cpp +++ b/src/SPI.cpp @@ -27,6 +27,8 @@ #include "DSi_SPI_TSC.h" #include "Platform.h" +namespace melonDS +{ using namespace Platform; @@ -641,3 +643,5 @@ void SPIHost::WriteData(u8 val) u32 delay = 8 * (8 << (Cnt & 0x3)); NDS::ScheduleEvent(NDS::Event_SPITransfer, false, delay, 0, 0); } + +} \ No newline at end of file diff --git a/src/SPI.h b/src/SPI.h index bf665d90..c889fb5e 100644 --- a/src/SPI.h +++ b/src/SPI.h @@ -28,6 +28,8 @@ #include "Savestate.h" #include "SPI_Firmware.h" +namespace melonDS +{ enum { SPIDevice_PowerMan = 0, @@ -164,4 +166,5 @@ private: SPIDevice* Devices[3]; }; +} #endif diff --git a/src/SPI_Firmware.cpp b/src/SPI_Firmware.cpp index 55071453..89c8fa61 100644 --- a/src/SPI_Firmware.cpp +++ b/src/SPI_Firmware.cpp @@ -20,6 +20,8 @@ #include "SPI.h" #include "Platform.h" +namespace melonDS +{ using Platform::Log; using Platform::LogLevel; @@ -404,3 +406,5 @@ void Firmware::UpdateChecksums() u.UpdateChecksum(); } } + +} \ No newline at end of file diff --git a/src/SPI_Firmware.h b/src/SPI_Firmware.h index a264a6cb..c8ca25c3 100644 --- a/src/SPI_Firmware.h +++ b/src/SPI_Firmware.h @@ -24,6 +24,8 @@ #include "types.h" #include "Platform.h" +namespace melonDS +{ u16 CRC16(const u8* data, u32 len, u32 start); @@ -563,4 +565,5 @@ private: u32 FirmwareMask; }; +} #endif //MELONDS_SPI_FIRMWARE_H diff --git a/src/SPU.cpp b/src/SPU.cpp index 89b7fb3b..a5570d66 100644 --- a/src/SPU.cpp +++ b/src/SPU.cpp @@ -24,6 +24,8 @@ #include "DSi.h" #include "SPU.h" +namespace melonDS +{ using Platform::Log; using Platform::LogLevel; @@ -1208,3 +1210,5 @@ void SPU::Write32(u32 addr, u32 val) } } } + +} \ No newline at end of file diff --git a/src/SPU.h b/src/SPU.h index 407a3f62..144c19ba 100644 --- a/src/SPU.h +++ b/src/SPU.h @@ -22,6 +22,8 @@ #include "Savestate.h" #include "Platform.h" +namespace melonDS +{ class SPU; class SPUChannel @@ -257,4 +259,5 @@ private: SPUCaptureUnit* Capture[2]; }; +} #endif // SPU_H diff --git a/src/Savestate.cpp b/src/Savestate.cpp index 77c2e621..6d6a9a47 100644 --- a/src/Savestate.cpp +++ b/src/Savestate.cpp @@ -22,6 +22,8 @@ #include "Savestate.h" #include "Platform.h" +namespace melonDS +{ using Platform::Log; using Platform::LogLevel; @@ -379,3 +381,5 @@ u32 Savestate::FindSection(const char* magic) const Log(LogLevel::Error, "savestate: section %s not found. blarg\n", magic); return NO_SECTION; } + +} \ No newline at end of file diff --git a/src/Savestate.h b/src/Savestate.h index ede3963c..236aa643 100644 --- a/src/Savestate.h +++ b/src/Savestate.h @@ -27,6 +27,8 @@ #define SAVESTATE_MAJOR 11 #define SAVESTATE_MINOR 1 +namespace melonDS +{ class Savestate { public: @@ -117,5 +119,6 @@ private: bool buffer_owned; bool finished; }; +} #endif // SAVESTATE_H diff --git a/src/TinyVector.h b/src/TinyVector.h index 63e7cafa..1904f2ad 100644 --- a/src/TinyVector.h +++ b/src/TinyVector.h @@ -23,7 +23,7 @@ #include #include "types.h" -namespace ARMJIT +namespace melonDS { /* TinyVector diff --git a/src/Wifi.cpp b/src/Wifi.cpp index 1486b409..1441d1dd 100644 --- a/src/Wifi.cpp +++ b/src/Wifi.cpp @@ -24,6 +24,8 @@ #include "WifiAP.h" #include "Platform.h" +namespace melonDS +{ using Platform::Log; using Platform::LogLevel; @@ -2265,3 +2267,5 @@ u8* Wifi::GetBSSID() { return (u8*)&IOPORT(W_BSSID0); } + +} \ No newline at end of file diff --git a/src/Wifi.h b/src/Wifi.h index 5a4f839e..c47a8833 100644 --- a/src/Wifi.h +++ b/src/Wifi.h @@ -21,6 +21,8 @@ #include "Savestate.h" +namespace melonDS +{ class WifiAP; class Wifi @@ -285,4 +287,5 @@ private: void RFTransfer_Type3(); }; +} #endif diff --git a/src/WifiAP.cpp b/src/WifiAP.cpp index 50100c50..efc34a5c 100644 --- a/src/WifiAP.cpp +++ b/src/WifiAP.cpp @@ -27,6 +27,8 @@ #include #endif +namespace melonDS +{ using Platform::Log; using Platform::LogLevel; @@ -401,3 +403,5 @@ int WifiAP::RecvPacket(u8* data) return 0; } + +} \ No newline at end of file diff --git a/src/WifiAP.h b/src/WifiAP.h index 34f71e7c..5d966687 100644 --- a/src/WifiAP.h +++ b/src/WifiAP.h @@ -21,6 +21,8 @@ #include "types.h" +namespace melonDS +{ class Wifi; class WifiAP @@ -61,4 +63,5 @@ private: int HandleManagementFrame(u8* data, int len); }; +} #endif diff --git a/src/debug/GdbArch.h b/src/debug/GdbArch.h index 45f1c1b2..1d45fb0b 100644 --- a/src/debug/GdbArch.h +++ b/src/debug/GdbArch.h @@ -5,6 +5,7 @@ namespace Gdb { +using namespace melonDS; enum class Register : int { r0, diff --git a/src/debug/GdbCmds.cpp b/src/debug/GdbCmds.cpp index 057502f2..c4706138 100644 --- a/src/debug/GdbCmds.cpp +++ b/src/debug/GdbCmds.cpp @@ -8,6 +8,7 @@ #include "GdbProto.h" +using namespace melonDS; using Platform::Log; using Platform::LogLevel; diff --git a/src/debug/GdbProto.cpp b/src/debug/GdbProto.cpp index dc803649..ebdf3be5 100644 --- a/src/debug/GdbProto.cpp +++ b/src/debug/GdbProto.cpp @@ -24,6 +24,7 @@ #include "GdbProto.h" +using namespace melonDS; using Platform::Log; using Platform::LogLevel; diff --git a/src/debug/GdbProto.h b/src/debug/GdbProto.h index ef8bdec9..68122f06 100644 --- a/src/debug/GdbProto.h +++ b/src/debug/GdbProto.h @@ -13,6 +13,7 @@ namespace Gdb { +using namespace melonDS; constexpr int GDBPROTO_BUFFER_CAPACITY = 1024+128; extern u8 Cmdbuf[GDBPROTO_BUFFER_CAPACITY]; diff --git a/src/debug/GdbStub.cpp b/src/debug/GdbStub.cpp index d756ce44..099f27f1 100644 --- a/src/debug/GdbStub.cpp +++ b/src/debug/GdbStub.cpp @@ -25,6 +25,7 @@ #include "../Platform.h" #include "GdbProto.h" +using namespace melonDS; using Platform::Log; using Platform::LogLevel; diff --git a/src/debug/GdbStub.h b/src/debug/GdbStub.h index b3bdab72..ace07bf6 100644 --- a/src/debug/GdbStub.h +++ b/src/debug/GdbStub.h @@ -13,6 +13,7 @@ namespace Gdb { +using namespace melonDS; enum class TgtStatus { NoEvent, diff --git a/src/debug/hexutil.h b/src/debug/hexutil.h index 9eb4ad22..63d1deb7 100644 --- a/src/debug/hexutil.h +++ b/src/debug/hexutil.h @@ -9,6 +9,8 @@ extern "C" #include +namespace melonDS +{ inline static uint8_t hex2nyb(uint8_t v) { if (v >= '0' && v <= '9') return v - '0'; @@ -71,5 +73,6 @@ inline static uint32_t unhex32(const uint8_t* src) } #endif +} #endif diff --git a/src/dolphin/Arm64Emitter.h b/src/dolphin/Arm64Emitter.h index 0b066ded..0fe4c919 100644 --- a/src/dolphin/Arm64Emitter.h +++ b/src/dolphin/Arm64Emitter.h @@ -14,6 +14,8 @@ namespace Arm64Gen { +using namespace melonDS; +using namespace Common; // X30 serves a dual purpose as a link register // Encoded as // Types: diff --git a/src/dolphin/ArmCommon.h b/src/dolphin/ArmCommon.h index 6d82e9d7..cae2ecb9 100644 --- a/src/dolphin/ArmCommon.h +++ b/src/dolphin/ArmCommon.h @@ -24,4 +24,4 @@ enum CCFlags CC_HS = CC_CS, // Alias of CC_CS Unsigned higher or same CC_LO = CC_CC, // Alias of CC_CC Unsigned lower }; -const u32 NO_COND = 0xE0000000; +const melonDS::u32 NO_COND = 0xE0000000; diff --git a/src/dolphin/BitSet.h b/src/dolphin/BitSet.h index 09cc1ce6..424364eb 100644 --- a/src/dolphin/BitSet.h +++ b/src/dolphin/BitSet.h @@ -10,6 +10,7 @@ namespace Common { +using namespace melonDS; #if defined(__GNUC__) || defined(__clang__) __attribute((always_inline)) static constexpr int CountSetBits(u8 val) { @@ -218,9 +219,10 @@ public: constexpr Iterator end() const { return Iterator(m_val, -1); } IntTy m_val; }; + +using BitSet8 = BitSet; +using BitSet16 = BitSet; +using BitSet32 = BitSet; +using BitSet64 = BitSet; } // namespace Common -using BitSet8 = Common::BitSet; -using BitSet16 = Common::BitSet; -using BitSet32 = Common::BitSet; -using BitSet64 = Common::BitSet; diff --git a/src/dolphin/MathUtil.h b/src/dolphin/MathUtil.h index b1dbbaec..800a3275 100644 --- a/src/dolphin/MathUtil.h +++ b/src/dolphin/MathUtil.h @@ -38,7 +38,7 @@ constexpr bool IsPow2(T imm) return imm > 0 && (imm & (imm - 1)) == 0; } -constexpr u32 NextPowerOf2(u32 value) +constexpr melonDS::u32 NextPowerOf2(melonDS::u32 value) { --value; value |= value >> 1; @@ -99,7 +99,7 @@ struct Rectangle float MathFloatVectorSum(const std::vector&); // Rounds down. 0 -> undefined -inline int IntLog2(u64 val) +inline int IntLog2(melonDS::u64 val) { #if defined(__GNUC__) return 63 - __builtin_clzll(val); diff --git a/src/dolphin/x64ABI.cpp b/src/dolphin/x64ABI.cpp index d86a1589..d85168a1 100644 --- a/src/dolphin/x64ABI.cpp +++ b/src/dolphin/x64ABI.cpp @@ -6,8 +6,9 @@ #include "x64ABI.h" #include "x64Emitter.h" -using namespace Gen; - +namespace Gen +{ +using namespace Common; // Shared code between Win64 and Unix64 void XEmitter::ABI_CalculateFrameSize(BitSet32 mask, size_t rsp_alignment, size_t needed_frame_size, @@ -117,3 +118,4 @@ void XEmitter::MOVTwo(int bits, Gen::X64Reg dst1, Gen::X64Reg src1, s32 offset1, ADD(bits, R(dst1), Imm32(offset1)); } } +} \ No newline at end of file diff --git a/src/dolphin/x64CPUDetect.cpp b/src/dolphin/x64CPUDetect.cpp index 49b51c9d..23390486 100644 --- a/src/dolphin/x64CPUDetect.cpp +++ b/src/dolphin/x64CPUDetect.cpp @@ -17,6 +17,8 @@ #include #endif +using namespace melonDS; + static inline void __cpuidex(int info[4], int function_id, int subfunction_id) { #ifdef __FreeBSD__ diff --git a/src/dolphin/x64Emitter.cpp b/src/dolphin/x64Emitter.cpp index fd90ba7f..a4543afd 100644 --- a/src/dolphin/x64Emitter.cpp +++ b/src/dolphin/x64Emitter.cpp @@ -12,6 +12,8 @@ #include "Compat.h" #include "CommonFuncs.h" +using namespace melonDS; + namespace Gen { // TODO(ector): Add EAX special casing, for ever so slightly smaller code. diff --git a/src/dolphin/x64Emitter.h b/src/dolphin/x64Emitter.h index 87996003..36603218 100644 --- a/src/dolphin/x64Emitter.h +++ b/src/dolphin/x64Emitter.h @@ -19,6 +19,8 @@ namespace Gen { +using namespace melonDS; +using namespace Common; enum CCFlags { CC_O = 0, diff --git a/src/frontend/FrontendUtil.h b/src/frontend/FrontendUtil.h index 375769d2..8d94b37d 100644 --- a/src/frontend/FrontendUtil.h +++ b/src/frontend/FrontendUtil.h @@ -26,6 +26,7 @@ namespace Frontend { +using namespace melonDS; enum ScreenLayout { diff --git a/src/frontend/Util_Audio.cpp b/src/frontend/Util_Audio.cpp index 278a5a00..4a1d089e 100644 --- a/src/frontend/Util_Audio.cpp +++ b/src/frontend/Util_Audio.cpp @@ -27,6 +27,7 @@ #include "mic_blow.h" +using namespace melonDS; namespace Frontend { diff --git a/src/frontend/duckstation/gl/context.h b/src/frontend/duckstation/gl/context.h index 41d8a2cd..06e0bc5e 100644 --- a/src/frontend/duckstation/gl/context.h +++ b/src/frontend/duckstation/gl/context.h @@ -6,6 +6,7 @@ #include namespace GL { +using namespace melonDS; class Context { public: diff --git a/src/frontend/duckstation/gl/context_agl.h b/src/frontend/duckstation/gl/context_agl.h index 459bf2fd..4ae5202d 100644 --- a/src/frontend/duckstation/gl/context_agl.h +++ b/src/frontend/duckstation/gl/context_agl.h @@ -13,6 +13,7 @@ struct NSView; namespace GL { +using namespace melonDS; class ContextAGL final : public Context { public: diff --git a/src/frontend/duckstation/gl/context_wgl.cpp b/src/frontend/duckstation/gl/context_wgl.cpp index 03c18e87..09f994c9 100644 --- a/src/frontend/duckstation/gl/context_wgl.cpp +++ b/src/frontend/duckstation/gl/context_wgl.cpp @@ -3,6 +3,7 @@ #include "../log.h" #include "../scoped_guard.h" #include "loader.h" +using namespace melonDS; Log_SetChannel(GL::ContextWGL); // TODO: get rid of this diff --git a/src/frontend/duckstation/gl/x11_window.h b/src/frontend/duckstation/gl/x11_window.h index aff38b7b..e216a058 100644 --- a/src/frontend/duckstation/gl/x11_window.h +++ b/src/frontend/duckstation/gl/x11_window.h @@ -4,6 +4,7 @@ #include namespace GL { +using namespace melonDS; class X11Window { public: diff --git a/src/frontend/duckstation/window_info.h b/src/frontend/duckstation/window_info.h index 44912caa..43526172 100644 --- a/src/frontend/duckstation/window_info.h +++ b/src/frontend/duckstation/window_info.h @@ -28,8 +28,8 @@ struct WindowInfo Type type = Type::Surfaceless; void* display_connection = nullptr; void* window_handle = nullptr; - u32 surface_width = 0; - u32 surface_height = 0; + melonDS::u32 surface_width = 0; + melonDS::u32 surface_height = 0; float surface_refresh_rate = 0.0f; float surface_scale = 1.0f; SurfaceFormat surface_format = SurfaceFormat::RGB8; diff --git a/src/frontend/mic_blow.h b/src/frontend/mic_blow.h index 20d5017c..f8dbc107 100644 --- a/src/frontend/mic_blow.h +++ b/src/frontend/mic_blow.h @@ -19,7 +19,9 @@ #ifndef MIC_BLOW_H #define MIC_BLOW_H -const u16 mic_blow[] = +#include "types.h" + +const melonDS::u16 mic_blow[] = { 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFC, 0xFFFF, 0xFFFC, 0xFFFF, 0xFFFD, 0xFFFF, 0xFFFC, 0xFFFF, 0xFFFD, 0xFFFF, 0xFFFF, 0xFFFE, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF, 0xFFFE, 0xFFFF, 0xFFFC, 0xFFFF, 0xFFFC, 0xFFFF, 0xFFFD, 0xFFFF, 0xFFFC, 0xFFFF, diff --git a/src/frontend/qt_sdl/ArchiveUtil.cpp b/src/frontend/qt_sdl/ArchiveUtil.cpp index 6f4b1348..7d1eca9c 100644 --- a/src/frontend/qt_sdl/ArchiveUtil.cpp +++ b/src/frontend/qt_sdl/ArchiveUtil.cpp @@ -19,6 +19,7 @@ #include "ArchiveUtil.h" #include "Platform.h" +using namespace melonDS; using Platform::Log; using Platform::LogLevel; diff --git a/src/frontend/qt_sdl/ArchiveUtil.h b/src/frontend/qt_sdl/ArchiveUtil.h index 14ff9968..eaffb0dd 100644 --- a/src/frontend/qt_sdl/ArchiveUtil.h +++ b/src/frontend/qt_sdl/ArchiveUtil.h @@ -35,6 +35,7 @@ namespace Archive { +using namespace melonDS; QVector ListArchive(QString path); s32 ExtractFileFromArchive(QString path, QString wantedFile, u8** filedata, u32* filesize); //QVector ExtractFileFromArchive(QString path, QString wantedFile, QByteArray *romBuffer); diff --git a/src/frontend/qt_sdl/AudioInOut.cpp b/src/frontend/qt_sdl/AudioInOut.cpp index 7faac9f3..90708b20 100644 --- a/src/frontend/qt_sdl/AudioInOut.cpp +++ b/src/frontend/qt_sdl/AudioInOut.cpp @@ -28,6 +28,7 @@ #include "Input.h" #include "main.h" +using namespace melonDS; namespace AudioInOut { diff --git a/src/frontend/qt_sdl/AudioSettingsDialog.cpp b/src/frontend/qt_sdl/AudioSettingsDialog.cpp index 386519bf..cb42e641 100644 --- a/src/frontend/qt_sdl/AudioSettingsDialog.cpp +++ b/src/frontend/qt_sdl/AudioSettingsDialog.cpp @@ -31,6 +31,7 @@ #include "ui_AudioSettingsDialog.h" +using namespace melonDS; AudioSettingsDialog* AudioSettingsDialog::currentDlg = nullptr; extern std::string EmuDirectory; diff --git a/src/frontend/qt_sdl/CLI.cpp b/src/frontend/qt_sdl/CLI.cpp index dce8ab67..299ce65b 100644 --- a/src/frontend/qt_sdl/CLI.cpp +++ b/src/frontend/qt_sdl/CLI.cpp @@ -27,8 +27,8 @@ #include "CLI.h" #include "Platform.h" -using Platform::Log; -using Platform::LogLevel; +using melonDS::Platform::Log; +using melonDS::Platform::LogLevel; namespace CLI { diff --git a/src/frontend/qt_sdl/CameraManager.cpp b/src/frontend/qt_sdl/CameraManager.cpp index cc532ff1..cc575d2c 100644 --- a/src/frontend/qt_sdl/CameraManager.cpp +++ b/src/frontend/qt_sdl/CameraManager.cpp @@ -21,6 +21,7 @@ #include "CameraManager.h" #include "Config.h" +using namespace melonDS; #if QT_VERSION >= 0x060000 diff --git a/src/frontend/qt_sdl/CameraManager.h b/src/frontend/qt_sdl/CameraManager.h index 91e73fbe..882b051a 100644 --- a/src/frontend/qt_sdl/CameraManager.h +++ b/src/frontend/qt_sdl/CameraManager.h @@ -89,11 +89,11 @@ public: void setXFlip(bool flip); - void captureFrame(u32* frame, int width, int height, bool yuv); + void captureFrame(melonDS::u32* frame, int width, int height, bool yuv); - void feedFrame(u32* frame, int width, int height, bool yuv); - void feedFrame_UYVY(u32* frame, int width, int height); - void feedFrame_NV12(u8* planeY, u8* planeUV, int width, int height); + void feedFrame(melonDS::u32* frame, int width, int height, bool yuv); + void feedFrame_UYVY(melonDS::u32* frame, int width, int height); + void feedFrame_NV12(melonDS::u8* planeY, melonDS::u8* planeUV, int width, int height); signals: void camStartSignal(); @@ -120,15 +120,15 @@ private: int frameWidth, frameHeight; bool frameFormatYUV; - u32* frameBuffer; - u32* tempFrameBuffer; + melonDS::u32* frameBuffer; + melonDS::u32* tempFrameBuffer; QMutex frameMutex; bool xFlip; - void copyFrame_Straight(u32* src, int swidth, int sheight, u32* dst, int dwidth, int dheight, bool xflip, bool yuv); - void copyFrame_RGBtoYUV(u32* src, int swidth, int sheight, u32* dst, int dwidth, int dheight, bool xflip); - void copyFrame_YUVtoRGB(u32* src, int swidth, int sheight, u32* dst, int dwidth, int dheight, bool xflip); + void copyFrame_Straight(melonDS::u32* src, int swidth, int sheight, melonDS::u32* dst, int dwidth, int dheight, bool xflip, bool yuv); + void copyFrame_RGBtoYUV(melonDS::u32* src, int swidth, int sheight, melonDS::u32* dst, int dwidth, int dheight, bool xflip); + void copyFrame_YUVtoRGB(melonDS::u32* src, int swidth, int sheight, melonDS::u32* dst, int dwidth, int dheight, bool xflip); }; #endif // CAMERAMANAGER_H diff --git a/src/frontend/qt_sdl/CameraSettingsDialog.cpp b/src/frontend/qt_sdl/CameraSettingsDialog.cpp index 1da0318f..cf404173 100644 --- a/src/frontend/qt_sdl/CameraSettingsDialog.cpp +++ b/src/frontend/qt_sdl/CameraSettingsDialog.cpp @@ -26,6 +26,7 @@ #include "CameraSettingsDialog.h" #include "ui_CameraSettingsDialog.h" +using namespace melonDS; CameraSettingsDialog* CameraSettingsDialog::currentDlg = nullptr; diff --git a/src/frontend/qt_sdl/CheatsDialog.cpp b/src/frontend/qt_sdl/CheatsDialog.cpp index ceaf8032..df687230 100644 --- a/src/frontend/qt_sdl/CheatsDialog.cpp +++ b/src/frontend/qt_sdl/CheatsDialog.cpp @@ -29,6 +29,7 @@ #include "CheatsDialog.h" #include "ui_CheatsDialog.h" +using namespace melonDS; using Platform::Log; using Platform::LogLevel; diff --git a/src/frontend/qt_sdl/CheatsDialog.h b/src/frontend/qt_sdl/CheatsDialog.h index 8af75be9..ab2ac309 100644 --- a/src/frontend/qt_sdl/CheatsDialog.h +++ b/src/frontend/qt_sdl/CheatsDialog.h @@ -27,8 +27,8 @@ #include "ARCodeFile.h" -Q_DECLARE_METATYPE(ARCodeList::iterator) -Q_DECLARE_METATYPE(ARCodeCatList::iterator) +Q_DECLARE_METATYPE(melonDS::ARCodeList::iterator) +Q_DECLARE_METATYPE(melonDS::ARCodeCatList::iterator) namespace Ui { class CheatsDialog; } class CheatsDialog; @@ -87,7 +87,7 @@ private slots: private: Ui::CheatsDialog* ui; - ARCodeFile* codeFile; + melonDS::ARCodeFile* codeFile; ARCodeChecker* codeChecker; }; diff --git a/src/frontend/qt_sdl/Config.cpp b/src/frontend/qt_sdl/Config.cpp index 9c6aff84..b6fca7d6 100644 --- a/src/frontend/qt_sdl/Config.cpp +++ b/src/frontend/qt_sdl/Config.cpp @@ -26,6 +26,7 @@ namespace Config { +using namespace melonDS; int KeyMapping[12]; int JoyMapping[12]; diff --git a/src/frontend/qt_sdl/EmuSettingsDialog.cpp b/src/frontend/qt_sdl/EmuSettingsDialog.cpp index 48b380b6..0a834a65 100644 --- a/src/frontend/qt_sdl/EmuSettingsDialog.cpp +++ b/src/frontend/qt_sdl/EmuSettingsDialog.cpp @@ -29,7 +29,8 @@ #include "EmuSettingsDialog.h" #include "ui_EmuSettingsDialog.h" -using namespace Platform; +using namespace melonDS::Platform; +using namespace melonDS; EmuSettingsDialog* EmuSettingsDialog::currentDlg = nullptr; diff --git a/src/frontend/qt_sdl/FirmwareSettingsDialog.cpp b/src/frontend/qt_sdl/FirmwareSettingsDialog.cpp index 5f76b08a..1ec2e8c4 100644 --- a/src/frontend/qt_sdl/FirmwareSettingsDialog.cpp +++ b/src/frontend/qt_sdl/FirmwareSettingsDialog.cpp @@ -24,6 +24,8 @@ #include "FirmwareSettingsDialog.h" #include "ui_FirmwareSettingsDialog.h" +using namespace melonDS::Platform; +namespace Platform = melonDS::Platform; FirmwareSettingsDialog* FirmwareSettingsDialog::currentDlg = nullptr; diff --git a/src/frontend/qt_sdl/Input.cpp b/src/frontend/qt_sdl/Input.cpp index 1d39a0fb..c429cd36 100644 --- a/src/frontend/qt_sdl/Input.cpp +++ b/src/frontend/qt_sdl/Input.cpp @@ -22,6 +22,7 @@ #include "Input.h" #include "Config.h" +using namespace melonDS; namespace Input { diff --git a/src/frontend/qt_sdl/Input.h b/src/frontend/qt_sdl/Input.h index 04f7a1f1..366c9c39 100644 --- a/src/frontend/qt_sdl/Input.h +++ b/src/frontend/qt_sdl/Input.h @@ -24,6 +24,7 @@ namespace Input { +using namespace melonDS; extern int JoystickID; extern SDL_Joystick* Joystick; diff --git a/src/frontend/qt_sdl/InputConfig/InputConfigDialog.cpp b/src/frontend/qt_sdl/InputConfig/InputConfigDialog.cpp index 6d651c9d..02a76bb7 100644 --- a/src/frontend/qt_sdl/InputConfig/InputConfigDialog.cpp +++ b/src/frontend/qt_sdl/InputConfig/InputConfigDialog.cpp @@ -32,6 +32,7 @@ #include "ui_InputConfigDialog.h" +using namespace melonDS; InputConfigDialog* InputConfigDialog::currentDlg = nullptr; const int dskeyorder[12] = {0, 1, 10, 11, 5, 4, 6, 7, 9, 8, 2, 3}; diff --git a/src/frontend/qt_sdl/InputConfig/MapButton.h b/src/frontend/qt_sdl/InputConfig/MapButton.h index b35cc1ff..5d4fb3eb 100644 --- a/src/frontend/qt_sdl/InputConfig/MapButton.h +++ b/src/frontend/qt_sdl/InputConfig/MapButton.h @@ -52,7 +52,7 @@ protected: { if (!isChecked()) return QPushButton::keyPressEvent(event); - Platform::Log(Platform::Debug, "KEY PRESSED = %08X %08X | %08X %08X %08X\n", event->key(), (int)event->modifiers(), event->nativeVirtualKey(), event->nativeModifiers(), event->nativeScanCode()); + Log(melonDS::Platform::Debug, "KEY PRESSED = %08X %08X | %08X %08X %08X\n", event->key(), (int)event->modifiers(), event->nativeVirtualKey(), event->nativeModifiers(), event->nativeScanCode()); int key = event->key(); int mod = event->modifiers(); diff --git a/src/frontend/qt_sdl/LAN_PCap.cpp b/src/frontend/qt_sdl/LAN_PCap.cpp index e1cbc11a..4a1ebc35 100644 --- a/src/frontend/qt_sdl/LAN_PCap.cpp +++ b/src/frontend/qt_sdl/LAN_PCap.cpp @@ -41,6 +41,7 @@ #endif #endif +using namespace melonDS; using Platform::Log; using Platform::LogLevel; diff --git a/src/frontend/qt_sdl/LAN_PCap.h b/src/frontend/qt_sdl/LAN_PCap.h index fe6e0009..2e03d66a 100644 --- a/src/frontend/qt_sdl/LAN_PCap.h +++ b/src/frontend/qt_sdl/LAN_PCap.h @@ -24,6 +24,7 @@ namespace LAN_PCap { +using namespace melonDS; struct AdapterData { char DeviceName[128]; diff --git a/src/frontend/qt_sdl/LAN_Socket.cpp b/src/frontend/qt_sdl/LAN_Socket.cpp index e1c86633..e938af80 100644 --- a/src/frontend/qt_sdl/LAN_Socket.cpp +++ b/src/frontend/qt_sdl/LAN_Socket.cpp @@ -37,6 +37,7 @@ #include #endif +using namespace melonDS; namespace LAN_Socket { diff --git a/src/frontend/qt_sdl/LAN_Socket.h b/src/frontend/qt_sdl/LAN_Socket.h index 9b97301d..043e1330 100644 --- a/src/frontend/qt_sdl/LAN_Socket.h +++ b/src/frontend/qt_sdl/LAN_Socket.h @@ -23,6 +23,7 @@ namespace LAN_Socket { +using namespace melonDS; // diff --git a/src/frontend/qt_sdl/LocalMP.cpp b/src/frontend/qt_sdl/LocalMP.cpp index 4b3a6a64..a0dfdf76 100644 --- a/src/frontend/qt_sdl/LocalMP.cpp +++ b/src/frontend/qt_sdl/LocalMP.cpp @@ -38,6 +38,9 @@ #include "LocalMP.h" #include "Platform.h" +using namespace melonDS; +using namespace melonDS::Platform; + using Platform::Log; using Platform::LogLevel; diff --git a/src/frontend/qt_sdl/LocalMP.h b/src/frontend/qt_sdl/LocalMP.h index 07c6f43c..e7b4188a 100644 --- a/src/frontend/qt_sdl/LocalMP.h +++ b/src/frontend/qt_sdl/LocalMP.h @@ -24,6 +24,7 @@ namespace LocalMP { +using namespace melonDS; bool Init(); void DeInit(); diff --git a/src/frontend/qt_sdl/OSD.cpp b/src/frontend/qt_sdl/OSD.cpp index 02ec1587..25072df7 100644 --- a/src/frontend/qt_sdl/OSD.cpp +++ b/src/frontend/qt_sdl/OSD.cpp @@ -32,6 +32,8 @@ #include "Config.h" +using namespace melonDS; + extern MainWindow* mainWindow; namespace OSD diff --git a/src/frontend/qt_sdl/OSD.h b/src/frontend/qt_sdl/OSD.h index b399fb42..64131d5b 100644 --- a/src/frontend/qt_sdl/OSD.h +++ b/src/frontend/qt_sdl/OSD.h @@ -19,9 +19,12 @@ #ifndef OSD_H #define OSD_H +#include "types.h" + namespace OSD { +using namespace melonDS; bool Init(bool openGL); void DeInit(); diff --git a/src/frontend/qt_sdl/PathSettingsDialog.cpp b/src/frontend/qt_sdl/PathSettingsDialog.cpp index 1f1c35cd..1d698537 100644 --- a/src/frontend/qt_sdl/PathSettingsDialog.cpp +++ b/src/frontend/qt_sdl/PathSettingsDialog.cpp @@ -27,6 +27,8 @@ #include "PathSettingsDialog.h" #include "ui_PathSettingsDialog.h" +using namespace melonDS::Platform; +namespace Platform = melonDS::Platform; PathSettingsDialog* PathSettingsDialog::currentDlg = nullptr; diff --git a/src/frontend/qt_sdl/Platform.cpp b/src/frontend/qt_sdl/Platform.cpp index df97590f..c2e2f47b 100644 --- a/src/frontend/qt_sdl/Platform.cpp +++ b/src/frontend/qt_sdl/Platform.cpp @@ -54,7 +54,7 @@ extern CameraManager* camManager[2]; void emuStop(); -namespace Platform +namespace melonDS::Platform { QSharedMemory* IPCBuffer = nullptr; diff --git a/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.cpp b/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.cpp index 1d69988b..14ccd51c 100644 --- a/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.cpp +++ b/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.cpp @@ -30,6 +30,8 @@ #include +using namespace melonDS; + PowerManagementDialog* PowerManagementDialog::currentDlg = nullptr; PowerManagementDialog::PowerManagementDialog(QWidget* parent) : QDialog(parent), ui(new Ui::PowerManagementDialog) diff --git a/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.h b/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.h index 03025864..cd2954a1 100644 --- a/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.h +++ b/src/frontend/qt_sdl/PowerManagement/PowerManagementDialog.h @@ -67,7 +67,7 @@ private: bool inited; bool oldDSBatteryLevel; - u8 oldDSiBatteryLevel; + melonDS::u8 oldDSiBatteryLevel; bool oldDSiBatteryCharging; void updateDSBatteryLevelControls(); diff --git a/src/frontend/qt_sdl/RAMInfoDialog.cpp b/src/frontend/qt_sdl/RAMInfoDialog.cpp index b13ff022..b58662c8 100644 --- a/src/frontend/qt_sdl/RAMInfoDialog.cpp +++ b/src/frontend/qt_sdl/RAMInfoDialog.cpp @@ -21,6 +21,7 @@ #include "main.h" +using namespace melonDS; extern EmuThread* emuThread; s32 GetMainRAMValue(const u32& addr, const ramInfo_ByteType& byteType) diff --git a/src/frontend/qt_sdl/RAMInfoDialog.h b/src/frontend/qt_sdl/RAMInfoDialog.h index 33afd988..adc9b284 100644 --- a/src/frontend/qt_sdl/RAMInfoDialog.h +++ b/src/frontend/qt_sdl/RAMInfoDialog.h @@ -53,22 +53,22 @@ enum ramInfo_Previous }; -s32 GetMainRAMValue(const u32& addr, const ramInfo_ByteType& byteType); +melonDS::s32 GetMainRAMValue(const melonDS::u32& addr, const ramInfo_ByteType& byteType); struct ramInfo_RowData { - u32 Address; - s32 Value; - s32 Previous; + melonDS::u32 Address; + melonDS::s32 Value; + melonDS::s32 Previous; void Update(const ramInfo_ByteType& byteType) { Value = GetMainRAMValue(Address, byteType); } - void SetValue(const s32& value) + void SetValue(const melonDS::s32& value) { - NDS::MainRAM[Address&NDS::MainRAMMask] = (u32)value; + melonDS::NDS::MainRAM[Address&melonDS::NDS::MainRAMMask] = (melonDS::u32)value; Value = value; } }; @@ -99,7 +99,7 @@ public: currentDlg = nullptr; } - s32 SearchValue = 0; + melonDS::s32 SearchValue = 0; void ClearTableContents(); @@ -115,7 +115,7 @@ private slots: void OnSearchFinished(); void ShowRowsInTable(); - void SetProgressbarValue(const u32& value); + void SetProgressbarValue(const melonDS::u32& value); private: Ui::RAMInfoDialog* ui; @@ -132,7 +132,7 @@ public: explicit RAMSearchThread(RAMInfoDialog* dialog); ~RAMSearchThread() override; - void Start(const s32& searchValue, const ramInfoSTh_SearchMode& searchMode = ramInfoSTh_Default); + void Start(const melonDS::s32& searchValue, const ramInfoSTh_SearchMode& searchMode = ramInfoSTh_Default); void Start(const ramInfoSTh_SearchMode& searchMode); void SetSearchByteType(const ramInfo_ByteType& bytetype); @@ -148,14 +148,14 @@ private: bool SearchRunning = false; ramInfoSTh_SearchMode SearchMode; - s32 SearchValue; + melonDS::s32 SearchValue; ramInfo_ByteType SearchByteType = ramInfo_OneByte; std::vector* RowDataVector = nullptr; void ClearTableContents(); signals: - void SetProgressbarValue(const u32& value); + void SetProgressbarValue(const melonDS::u32& value); }; #endif // RAMINFODIALOG_H diff --git a/src/frontend/qt_sdl/ROMInfoDialog.cpp b/src/frontend/qt_sdl/ROMInfoDialog.cpp index 34917d00..6a46b18e 100644 --- a/src/frontend/qt_sdl/ROMInfoDialog.cpp +++ b/src/frontend/qt_sdl/ROMInfoDialog.cpp @@ -28,6 +28,8 @@ #include "Platform.h" #include "Config.h" +using namespace melonDS; + QString IntToHex(u64 num) { return ("0x" + QString::number(num, 16).toUpper()); diff --git a/src/frontend/qt_sdl/ROMInfoDialog.h b/src/frontend/qt_sdl/ROMInfoDialog.h index 630ac22d..7316e98a 100644 --- a/src/frontend/qt_sdl/ROMInfoDialog.h +++ b/src/frontend/qt_sdl/ROMInfoDialog.h @@ -69,7 +69,7 @@ private: QImage iconImage; QTimeLine* iconTimeline; - u32 animatedIconData[64][32*32] = {0}; + melonDS::u32 animatedIconData[64][32*32] = {0}; std::vector animatedIconImages; std::vector animatedSequence; }; diff --git a/src/frontend/qt_sdl/ROMManager.cpp b/src/frontend/qt_sdl/ROMManager.cpp index 1c58055f..9584c381 100644 --- a/src/frontend/qt_sdl/ROMManager.cpp +++ b/src/frontend/qt_sdl/ROMManager.cpp @@ -51,7 +51,8 @@ using std::string; using std::tie; using std::unique_ptr; using std::wstring_convert; -using namespace Platform; +using namespace melonDS; +using namespace melonDS::Platform; namespace ROMManager { diff --git a/src/frontend/qt_sdl/ROMManager.h b/src/frontend/qt_sdl/ROMManager.h index 6d957631..92285608 100644 --- a/src/frontend/qt_sdl/ROMManager.h +++ b/src/frontend/qt_sdl/ROMManager.h @@ -31,6 +31,7 @@ namespace ROMManager { +using namespace melonDS; extern SaveManager* NDSSave; extern SaveManager* GBASave; extern std::unique_ptr FirmwareSave; diff --git a/src/frontend/qt_sdl/SaveManager.cpp b/src/frontend/qt_sdl/SaveManager.cpp index 78d4b0ec..55279dca 100644 --- a/src/frontend/qt_sdl/SaveManager.cpp +++ b/src/frontend/qt_sdl/SaveManager.cpp @@ -22,7 +22,8 @@ #include "SaveManager.h" #include "Platform.h" -using namespace Platform; +using namespace melonDS; +using namespace melonDS::Platform; SaveManager::SaveManager(const std::string& path) : QThread() { diff --git a/src/frontend/qt_sdl/SaveManager.h b/src/frontend/qt_sdl/SaveManager.h index 6ffb4f86..d7132e69 100644 --- a/src/frontend/qt_sdl/SaveManager.h +++ b/src/frontend/qt_sdl/SaveManager.h @@ -41,31 +41,31 @@ public: std::string GetPath(); void SetPath(const std::string& path, bool reload); - void RequestFlush(const u8* savedata, u32 savelen, u32 writeoffset, u32 writelen); + void RequestFlush(const melonDS::u8* savedata, melonDS::u32 savelen, melonDS::u32 writeoffset, melonDS::u32 writelen); void CheckFlush(); bool NeedsFlush(); - void FlushSecondaryBuffer(u8* dst = nullptr, u32 dstLength = 0); + void FlushSecondaryBuffer(melonDS::u8* dst = nullptr, melonDS::u32 dstLength = 0); private: std::string Path; std::atomic_bool Running; - std::unique_ptr Buffer; - u32 Length; + std::unique_ptr Buffer; + melonDS::u32 Length; bool FlushRequested; QMutex* SecondaryBufferLock; - std::unique_ptr SecondaryBuffer; - u32 SecondaryBufferLength; + std::unique_ptr SecondaryBuffer; + melonDS::u32 SecondaryBufferLength; time_t TimeAtLastFlushRequest; // We keep versions in case the user closes the application before // a flush cycle is finished. - u32 PreviousFlushVersion; - u32 FlushVersion; + melonDS::u32 PreviousFlushVersion; + melonDS::u32 FlushVersion; }; #endif // SAVEMANAGER_H diff --git a/src/frontend/qt_sdl/TitleManagerDialog.cpp b/src/frontend/qt_sdl/TitleManagerDialog.cpp index eb6b594f..eda1bbce 100644 --- a/src/frontend/qt_sdl/TitleManagerDialog.cpp +++ b/src/frontend/qt_sdl/TitleManagerDialog.cpp @@ -30,7 +30,8 @@ #include "ui_TitleManagerDialog.h" #include "ui_TitleImportDialog.h" -using namespace Platform; +using namespace melonDS; +using namespace melonDS::Platform; std::unique_ptr TitleManagerDialog::nand = nullptr; TitleManagerDialog* TitleManagerDialog::currentDlg = nullptr; diff --git a/src/frontend/qt_sdl/TitleManagerDialog.h b/src/frontend/qt_sdl/TitleManagerDialog.h index 7209f96a..2e392ebf 100644 --- a/src/frontend/qt_sdl/TitleManagerDialog.h +++ b/src/frontend/qt_sdl/TitleManagerDialog.h @@ -46,10 +46,10 @@ class TitleManagerDialog : public QDialog Q_OBJECT public: - explicit TitleManagerDialog(QWidget* parent, DSi_NAND::NANDImage& image); + explicit TitleManagerDialog(QWidget* parent, melonDS::DSi_NAND::NANDImage& image); ~TitleManagerDialog(); - static std::unique_ptr nand; + static std::unique_ptr nand; static bool openNAND(); static void closeNAND(); @@ -94,17 +94,17 @@ private slots: void onExportTitleData(); private: - DSi_NAND::NANDMount nandmount; + melonDS::DSi_NAND::NANDMount nandmount; Ui::TitleManagerDialog* ui; QString importAppPath; - DSi_TMD::TitleMetadata importTmdData; + melonDS::DSi_TMD::TitleMetadata importTmdData; bool importReadOnly; QAction* actImportTitleData[3]; QAction* actExportTitleData[3]; - void createTitleItem(u32 category, u32 titleid); + void createTitleItem(melonDS::u32 category, melonDS::u32 titleid); }; class TitleImportDialog : public QDialog @@ -112,7 +112,7 @@ class TitleImportDialog : public QDialog Q_OBJECT public: - explicit TitleImportDialog(QWidget* parent, QString& apppath, const DSi_TMD::TitleMetadata* tmd, bool& readonly, DSi_NAND::NANDMount& nand); + explicit TitleImportDialog(QWidget* parent, QString& apppath, const melonDS::DSi_TMD::TitleMetadata* tmd, bool& readonly, melonDS::DSi_NAND::NANDMount& nand); ~TitleImportDialog(); private slots: @@ -125,7 +125,7 @@ private slots: private: Ui::TitleImportDialog* ui; - DSi_NAND::NANDMount& nandmount; + melonDS::DSi_NAND::NANDMount& nandmount; QButtonGroup* grpTmdSource; @@ -133,10 +133,10 @@ private: QNetworkReply* netreply; QString& appPath; - const DSi_TMD::TitleMetadata* tmdData; + const melonDS::DSi_TMD::TitleMetadata* tmdData; bool& readOnly; - u32 titleid[2]; + melonDS::u32 titleid[2]; }; #endif // TITLEMANAGERDIALOG_H diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp index b820b508..42864986 100644 --- a/src/frontend/qt_sdl/main.cpp +++ b/src/frontend/qt_sdl/main.cpp @@ -105,7 +105,7 @@ #include "CLI.h" // TODO: uniform variable spelling - +using namespace melonDS; const QString NdsRomMimeType = "application/x-nintendo-ds-rom"; const QStringList NdsRomExtensions { ".nds", ".srl", ".dsi", ".ids" }; @@ -163,7 +163,7 @@ EmuThread* emuThread; int autoScreenSizing = 0; int videoRenderer; -Melon::RenderSettings videoSettings; +RenderSettings videoSettings; bool videoSettingsDirty; CameraManager* camManager[2]; diff --git a/src/melonDLDI.h b/src/melonDLDI.h index 1fe1e599..908a2f60 100644 --- a/src/melonDLDI.h +++ b/src/melonDLDI.h @@ -21,6 +21,8 @@ #include "types.h" +namespace melonDS +{ const u8 melonDLDI[] = { 0xED, 0xA5, 0x8D, 0xBF, 0x20, 0x43, 0x68, 0x69, 0x73, 0x68, 0x6D, 0x00, 0x01, 0x09, 0x00, 0x00, @@ -54,4 +56,5 @@ const u8 melonDLDI[] = 0x1E, 0xFF, 0x2F, 0xE1 }; +} #endif // MELONDLDI_H diff --git a/src/types.h b/src/types.h index 38556440..d37b2251 100644 --- a/src/types.h +++ b/src/types.h @@ -21,6 +21,8 @@ #include +namespace melonDS +{ typedef uint8_t u8; typedef uint16_t u16; typedef uint32_t u32; @@ -30,4 +32,5 @@ typedef int16_t s16; typedef int32_t s32; typedef int64_t s64; +} #endif // TYPES_H