diff options
Diffstat (limited to 'src/NDS.cpp')
-rw-r--r-- | src/NDS.cpp | 136 |
1 files changed, 40 insertions, 96 deletions
diff --git a/src/NDS.cpp b/src/NDS.cpp index 5290423..d13fd91 100644 --- a/src/NDS.cpp +++ b/src/NDS.cpp @@ -35,16 +35,13 @@ #include "Platform.h" #include "FreeBIOS.h" -#ifdef JIT_ENABLED -#include "ARMJIT.h" -#include "ARMJIT_Memory.h" -#endif - #include "DSi.h" #include "DSi_SPI_TSC.h" #include "DSi_NWifi.h" #include "DSi_Camera.h" #include "DSi_DSP.h" +#include "ARMJIT.h" +#include "ARMJIT_Memory.h" using namespace Platform; @@ -186,6 +183,7 @@ class Wifi* Wifi; std::unique_ptr<NDSCart::NDSCartSlot> NDSCartSlot; std::unique_ptr<GBACart::GBACartSlot> GBACartSlot; std::unique_ptr<Melon::GPU> GPU; +std::unique_ptr<ARMJIT::ARMJIT> JIT; class AREngine* AREngine; bool Running; @@ -205,17 +203,15 @@ bool Init() RegisterEventFunc(Event_Div, 0, DivDone); RegisterEventFunc(Event_Sqrt, 0, SqrtDone); - GPU = std::make_unique<Melon::GPU>(); - ARM9 = new ARMv5(*GPU); - ARM7 = new ARMv4(*GPU); + JIT = std::make_unique<ARMJIT::ARMJIT>(); + GPU = std::make_unique<Melon::GPU>(*JIT); -#ifdef JIT_ENABLED - ARMJIT::Init(); -#else - MainRAM = new u8[0x1000000]; - ARM7WRAM = new u8[ARM7WRAMSize]; - SharedWRAM = new u8[SharedWRAMSize]; -#endif + MainRAM = JIT->Memory.GetMainRAM(); + SharedWRAM = JIT->Memory.GetSharedWRAM(); + ARM7WRAM = JIT->Memory.GetARM7WRAM(); + + ARM9 = new ARMv5(*JIT, *GPU); + ARM7 = new ARMv4(*JIT, *GPU); DMAs[0] = new DMA(0, 0, *GPU); DMAs[1] = new DMA(0, 1, *GPU); @@ -242,10 +238,6 @@ bool Init() void DeInit() { -#ifdef JIT_ENABLED - ARMJIT::DeInit(); -#endif - delete ARM9; ARM9 = nullptr; delete ARM7; ARM7 = nullptr; @@ -270,6 +262,8 @@ void DeInit() UnregisterEventFunc(Event_Div, 0); UnregisterEventFunc(Event_Sqrt, 0); + + JIT = nullptr; } @@ -548,9 +542,7 @@ void Reset() // BIOS files are now loaded by the frontend -#ifdef JIT_ENABLED - ARMJIT::Reset(); -#endif + JIT->Reset(); if (ConsoleType == 1) { @@ -869,8 +861,8 @@ bool DoSavestate(Savestate* file) #ifdef JIT_ENABLED if (!file->Saving) { - ARMJIT::ResetBlockCache(); - ARMJIT_Memory::Reset(); + JIT->ResetBlockCache(); + JIT->Memory.Reset(); } #endif @@ -1401,9 +1393,7 @@ void MapSharedWRAM(u8 val) if (val == WRAMCnt) return; -#ifdef JIT_ENABLED - ARMJIT_Memory::RemapSWRAM(); -#endif + NDS::JIT->Memory.RemapSWRAM(); WRAMCnt = val; @@ -2315,18 +2305,14 @@ void ARM9Write8(u32 addr, u8 val) switch (addr & 0xFF000000) { case 0x02000000: -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<0, ARMJIT_Memory::memregion_MainRAM>(addr); -#endif + NDS::JIT->CheckAndInvalidate<0, ARMJIT_Memory::memregion_MainRAM>(addr); *(u8*)&MainRAM[addr & MainRAMMask] = val; return; case 0x03000000: if (SWRAM_ARM9.Mem) { -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<0, ARMJIT_Memory::memregion_SharedWRAM>(addr); -#endif + NDS::JIT->CheckAndInvalidate<0, ARMJIT_Memory::memregion_SharedWRAM>(addr); *(u8*)&SWRAM_ARM9.Mem[addr & SWRAM_ARM9.Mask] = val; } return; @@ -2361,18 +2347,14 @@ void ARM9Write16(u32 addr, u16 val) switch (addr & 0xFF000000) { case 0x02000000: -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<0, ARMJIT_Memory::memregion_MainRAM>(addr); -#endif + NDS::JIT->CheckAndInvalidate<0, ARMJIT_Memory::memregion_MainRAM>(addr); *(u16*)&MainRAM[addr & MainRAMMask] = val; return; case 0x03000000: if (SWRAM_ARM9.Mem) { -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<0, ARMJIT_Memory::memregion_SharedWRAM>(addr); -#endif + NDS::JIT->CheckAndInvalidate<0, ARMJIT_Memory::memregion_SharedWRAM>(addr); *(u16*)&SWRAM_ARM9.Mem[addr & SWRAM_ARM9.Mask] = val; } return; @@ -2387,9 +2369,7 @@ void ARM9Write16(u32 addr, u16 val) return; case 0x06000000: -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<0, ARMJIT_Memory::memregion_VRAM>(addr); -#endif + NDS::JIT->CheckAndInvalidate<0, ARMJIT_Memory::memregion_VRAM>(addr); switch (addr & 0x00E00000) { case 0x00000000: GPU->WriteVRAM_ABG<u16>(addr, val); return; @@ -2429,18 +2409,14 @@ void ARM9Write32(u32 addr, u32 val) switch (addr & 0xFF000000) { case 0x02000000: -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<0, ARMJIT_Memory::memregion_MainRAM>(addr); -#endif + NDS::JIT->CheckAndInvalidate<0, ARMJIT_Memory::memregion_MainRAM>(addr); *(u32*)&MainRAM[addr & MainRAMMask] = val; return ; case 0x03000000: if (SWRAM_ARM9.Mem) { -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<0, ARMJIT_Memory::memregion_SharedWRAM>(addr); -#endif + NDS::JIT->CheckAndInvalidate<0, ARMJIT_Memory::memregion_SharedWRAM>(addr); *(u32*)&SWRAM_ARM9.Mem[addr & SWRAM_ARM9.Mask] = val; } return; @@ -2455,9 +2431,7 @@ void ARM9Write32(u32 addr, u32 val) return; case 0x06000000: -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<0, ARMJIT_Memory::memregion_VRAM>(addr); -#endif + NDS::JIT->CheckAndInvalidate<0, ARMJIT_Memory::memregion_VRAM>(addr); switch (addr & 0x00E00000) { case 0x00000000: GPU->WriteVRAM_ABG<u32>(addr, val); return; @@ -2738,34 +2712,26 @@ void ARM7Write8(u32 addr, u8 val) { case 0x02000000: case 0x02800000: -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_MainRAM>(addr); -#endif + NDS::JIT->CheckAndInvalidate<1, ARMJIT_Memory::memregion_MainRAM>(addr); *(u8*)&MainRAM[addr & MainRAMMask] = val; return; case 0x03000000: if (SWRAM_ARM7.Mem) { -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_SharedWRAM>(addr); -#endif + NDS::JIT->CheckAndInvalidate<1, ARMJIT_Memory::memregion_SharedWRAM>(addr); *(u8*)&SWRAM_ARM7.Mem[addr & SWRAM_ARM7.Mask] = val; return; } else { -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_WRAM7>(addr); -#endif + NDS::JIT->CheckAndInvalidate<1, ARMJIT_Memory::memregion_WRAM7>(addr); *(u8*)&ARM7WRAM[addr & (ARM7WRAMSize - 1)] = val; return; } case 0x03800000: -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_WRAM7>(addr); -#endif + NDS::JIT->CheckAndInvalidate<1, ARMJIT_Memory::memregion_WRAM7>(addr); *(u8*)&ARM7WRAM[addr & (ARM7WRAMSize - 1)] = val; return; @@ -2775,9 +2741,7 @@ void ARM7Write8(u32 addr, u8 val) case 0x06000000: case 0x06800000: -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_VWRAM>(addr); -#endif + NDS::JIT->CheckAndInvalidate<1, ARMJIT_Memory::memregion_VWRAM>(addr); GPU->WriteVRAM_ARM7<u8>(addr, val); return; @@ -2808,34 +2772,26 @@ void ARM7Write16(u32 addr, u16 val) { case 0x02000000: case 0x02800000: -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_MainRAM>(addr); -#endif + NDS::JIT->CheckAndInvalidate<1, ARMJIT_Memory::memregion_MainRAM>(addr); *(u16*)&MainRAM[addr & MainRAMMask] = val; return; case 0x03000000: if (SWRAM_ARM7.Mem) { -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_SharedWRAM>(addr); -#endif + NDS::JIT->CheckAndInvalidate<1, ARMJIT_Memory::memregion_SharedWRAM>(addr); *(u16*)&SWRAM_ARM7.Mem[addr & SWRAM_ARM7.Mask] = val; return; } else { -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_WRAM7>(addr); -#endif + NDS::JIT->CheckAndInvalidate<1, ARMJIT_Memory::memregion_WRAM7>(addr); *(u16*)&ARM7WRAM[addr & (ARM7WRAMSize - 1)] = val; return; } case 0x03800000: -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_WRAM7>(addr); -#endif + NDS::JIT->CheckAndInvalidate<1, ARMJIT_Memory::memregion_WRAM7>(addr); *(u16*)&ARM7WRAM[addr & (ARM7WRAMSize - 1)] = val; return; @@ -2854,9 +2810,7 @@ void ARM7Write16(u32 addr, u16 val) case 0x06000000: case 0x06800000: -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_VWRAM>(addr); -#endif + NDS::JIT->CheckAndInvalidate<1, ARMJIT_Memory::memregion_VWRAM>(addr); GPU->WriteVRAM_ARM7<u16>(addr, val); return; @@ -2889,34 +2843,26 @@ void ARM7Write32(u32 addr, u32 val) { case 0x02000000: case 0x02800000: -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_MainRAM>(addr); -#endif + NDS::JIT->CheckAndInvalidate<1, ARMJIT_Memory::memregion_MainRAM>(addr); *(u32*)&MainRAM[addr & MainRAMMask] = val; return; case 0x03000000: if (SWRAM_ARM7.Mem) { -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_SharedWRAM>(addr); -#endif + NDS::JIT->CheckAndInvalidate<1, ARMJIT_Memory::memregion_SharedWRAM>(addr); *(u32*)&SWRAM_ARM7.Mem[addr & SWRAM_ARM7.Mask] = val; return; } else { -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_WRAM7>(addr); -#endif + NDS::JIT->CheckAndInvalidate<1, ARMJIT_Memory::memregion_WRAM7>(addr); *(u32*)&ARM7WRAM[addr & (ARM7WRAMSize - 1)] = val; return; } case 0x03800000: -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_WRAM7>(addr); -#endif + NDS::JIT->CheckAndInvalidate<1, ARMJIT_Memory::memregion_WRAM7>(addr); *(u32*)&ARM7WRAM[addr & (ARM7WRAMSize - 1)] = val; return; @@ -2936,9 +2882,7 @@ void ARM7Write32(u32 addr, u32 val) case 0x06000000: case 0x06800000: -#ifdef JIT_ENABLED - ARMJIT::CheckAndInvalidate<1, ARMJIT_Memory::memregion_VWRAM>(addr); -#endif + NDS::JIT->CheckAndInvalidate<1, ARMJIT_Memory::memregion_VWRAM>(addr); GPU->WriteVRAM_ARM7<u32>(addr, val); return; |