diff --git a/Source/Core/Core/Src/DSP/DSPCore.cpp b/Source/Core/Core/Src/DSP/DSPCore.cpp index 59e5063af6..64206b3ee0 100644 --- a/Source/Core/Core/Src/DSP/DSPCore.cpp +++ b/Source/Core/Core/Src/DSP/DSPCore.cpp @@ -137,6 +137,7 @@ bool DSPCore_Init(const char *irom_filename, const char *coef_filename, { g_dsp.step_counter = 0; cyclesLeft = 0; + init_hax = false; dspjit = NULL; g_dsp.irom = (u16*)AllocateMemoryPages(DSP_IROM_BYTE_SIZE); diff --git a/Source/Core/Core/Src/DSP/DSPHWInterface.cpp b/Source/Core/Core/Src/DSP/DSPHWInterface.cpp index 371bec572c..56e998d3c0 100644 --- a/Source/Core/Core/Src/DSP/DSPHWInterface.cpp +++ b/Source/Core/Core/Src/DSP/DSPHWInterface.cpp @@ -246,14 +246,9 @@ static void gdsp_idma_in(u16 dsp_addr, u32 addr, u32 size) } WriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false); - g_dsp.iram_crc = DSPHost_CodeLoaded(g_dsp.cpu_ram + (addr & 0x0fffffff), size); - - NOTICE_LOG(DSPLLE, "*** Copy new UCode from 0x%08x to 0x%04x (crc: %8x)", addr, dsp_addr, g_dsp.iram_crc); + DSPHost_CodeLoaded((const u8*)g_dsp.iram + dsp_addr, size); - if (dspjit) - dspjit->ClearIRAM(); - - DSPAnalyzer::Analyze(); + NOTICE_LOG(DSPLLE, "*** Copy new UCode from 0x%08x to 0x%04x (crc: %8x)", addr, dsp_addr, g_dsp.iram_crc); } static void gdsp_idma_out(u16 dsp_addr, u32 addr, u32 size) diff --git a/Source/Core/Core/Src/DSP/DSPHost.h b/Source/Core/Core/Src/DSP/DSPHost.h index 86033b0724..cef329a7ec 100644 --- a/Source/Core/Core/Src/DSP/DSPHost.h +++ b/Source/Core/Core/Src/DSP/DSPHost.h @@ -15,7 +15,7 @@ void DSPHost_WriteHostMemory(u8 value, u32 addr); bool DSPHost_OnThread(); bool DSPHost_Wii(); void DSPHost_InterruptRequest(); -u32 DSPHost_CodeLoaded(const u8 *ptr, int size); +void DSPHost_CodeLoaded(const u8 *ptr, int size); void DSPHost_UpdateDebugger(); #endif diff --git a/Source/Core/Core/Src/HW/DSPLLE/DSPHost.cpp b/Source/Core/Core/Src/HW/DSPLLE/DSPHost.cpp index 9349820450..26e7110d6e 100644 --- a/Source/Core/Core/Src/HW/DSPLLE/DSPHost.cpp +++ b/Source/Core/Core/Src/HW/DSPLLE/DSPHost.cpp @@ -4,6 +4,8 @@ #include "Common.h" #include "Hash.h" +#include "DSP/DSPAnalyzer.h" +#include "DSP/DSPCore.h" #include "DSP/DSPHost.h" #include "DSPSymbols.h" #include "DSPLLETools.h" @@ -45,23 +47,23 @@ void DSPHost_InterruptRequest() DSP::GenerateDSPInterruptFromDSPEmu(DSP::INT_DSP); } -u32 DSPHost_CodeLoaded(const u8 *ptr, int size) +void DSPHost_CodeLoaded(const u8 *ptr, int size) { - u32 ector_crc = HashEctor(ptr, size); + g_dsp.iram_crc = HashEctor(ptr, size); #if defined(_DEBUG) || defined(DEBUGFAST) - DumpDSPCode(ptr, size, ector_crc); + DumpDSPCode(ptr, size, g_dsp.iram_crc); #endif DSPSymbols::Clear(); // Auto load text file - if none just disassemble. - NOTICE_LOG(DSPLLE, "ector_crc: %08x", ector_crc); + NOTICE_LOG(DSPLLE, "g_dsp.iram_crc: %08x", g_dsp.iram_crc); DSPSymbols::Clear(); bool success = false; - switch (ector_crc) + switch (g_dsp.iram_crc) { case 0x86840740: success = DSPSymbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_Zelda.txt"); break; case 0x42f64ac4: success = DSPSymbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_Luigi.txt"); break; @@ -86,7 +88,10 @@ u32 DSPHost_CodeLoaded(const u8 *ptr, int size) DSPHost_UpdateDebugger(); - return ector_crc; + if (dspjit) + dspjit->ClearIRAM(); + + DSPAnalyzer::Analyze(); } void DSPHost_UpdateDebugger() diff --git a/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp b/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp index df43441c03..d16af5f601 100644 --- a/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp +++ b/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.cpp @@ -16,6 +16,7 @@ #include "Core.h" #include "DSPLLEGlobals.h" // Local +#include "DSP/DSPHost.h" #include "DSP/DSPInterpreter.h" #include "DSP/DSPHWInterface.h" #include "DSP/disassemble.h" @@ -67,7 +68,6 @@ void DSPLLE::DoState(PointerWrap &p) p.Do(g_dsp.reg_stack[i]); } - p.Do(g_dsp.iram_crc); p.Do(g_dsp.step_counter); p.Do(g_dsp.ifx_regs); p.Do(g_dsp.mbox[0]); @@ -75,8 +75,11 @@ void DSPLLE::DoState(PointerWrap &p) UnWriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false); p.DoArray(g_dsp.iram, DSP_IRAM_SIZE); WriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false); + if (p.GetMode() == PointerWrap::MODE_READ) + DSPHost_CodeLoaded((const u8*)g_dsp.iram, DSP_IRAM_BYTE_SIZE); p.DoArray(g_dsp.dram, DSP_DRAM_SIZE); p.Do(cyclesLeft); + p.Do(init_hax); p.Do(m_cycle_count); bool prevInitMixer = m_InitMixer; diff --git a/Source/Core/Core/Src/State.cpp b/Source/Core/Core/Src/State.cpp index 40a48b4841..5923ba6917 100644 --- a/Source/Core/Core/Src/State.cpp +++ b/Source/Core/Core/Src/State.cpp @@ -59,7 +59,7 @@ static Common::Event g_compressAndDumpStateSyncEvent; static std::thread g_save_thread; // Don't forget to increase this after doing changes on the savestate system -static const u32 STATE_VERSION = 17; +static const u32 STATE_VERSION = 18; enum {