diff --git a/Source/Core/Core/DSP/DSPHWInterface.cpp b/Source/Core/Core/DSP/DSPHWInterface.cpp index c5fb7a3397..09b66f42e2 100644 --- a/Source/Core/Core/DSP/DSPHWInterface.cpp +++ b/Source/Core/Core/DSP/DSPHWInterface.cpp @@ -5,6 +5,9 @@ #include "Core/DSP/DSPHWInterface.h" +#include +#include + #include "Common/CPUDetect.h" #include "Common/CommonTypes.h" #include "Common/Hash.h" @@ -228,23 +231,22 @@ u16 gdsp_ifx_read(u16 addr) static const u8* gdsp_idma_in(u16 dsp_addr, u32 addr, u32 size) { + u16* dst = g_dsp.iram + (dsp_addr / 2); + const u8* code = &g_dsp.cpu_ram[addr & 0x0fffffff]; g_dsp.iram_crc = HashEctor(code, size); Common::UnWriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false); - - u8* dst = ((u8*)g_dsp.iram); - for (u32 i = 0; i < size; i += 2) - { - *(u16*)&dst[dsp_addr + i] = Common::swap16(*(const u16*)&code[i]); - } + memcpy(dst, code, size); + for (size_t i = 0; i < size / 2; i++) + dst[i] = Common::swap16(dst[i]); Common::WriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false); Host::CodeLoaded(code, size); NOTICE_LOG(DSPLLE, "*** Copy new UCode from 0x%08x to 0x%04x (crc: %8x)", addr, dsp_addr, g_dsp.iram_crc); - return dst + dsp_addr; + return reinterpret_cast(dst); } static const u8* gdsp_idma_out(u16 dsp_addr, u32 addr, u32 size)