DSPHWInterface: cleanup gdsp_idma_in

This commit is contained in:
Michael Maltese 2017-05-15 15:08:50 -07:00
parent 5f68a0dcdd
commit 930c165c4e
1 changed files with 9 additions and 7 deletions

View File

@ -5,6 +5,9 @@
#include "Core/DSP/DSPHWInterface.h" #include "Core/DSP/DSPHWInterface.h"
#include <cstddef>
#include <cstring>
#include "Common/CPUDetect.h" #include "Common/CPUDetect.h"
#include "Common/CommonTypes.h" #include "Common/CommonTypes.h"
#include "Common/Hash.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) 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]; const u8* code = &g_dsp.cpu_ram[addr & 0x0fffffff];
g_dsp.iram_crc = HashEctor(code, size); g_dsp.iram_crc = HashEctor(code, size);
Common::UnWriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false); Common::UnWriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false);
memcpy(dst, code, size);
u8* dst = ((u8*)g_dsp.iram); for (size_t i = 0; i < size / 2; i++)
for (u32 i = 0; i < size; i += 2) dst[i] = Common::swap16(dst[i]);
{
*(u16*)&dst[dsp_addr + i] = Common::swap16(*(const u16*)&code[i]);
}
Common::WriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false); Common::WriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false);
Host::CodeLoaded(code, size); Host::CodeLoaded(code, size);
NOTICE_LOG(DSPLLE, "*** Copy new UCode from 0x%08x to 0x%04x (crc: %8x)", addr, dsp_addr, NOTICE_LOG(DSPLLE, "*** Copy new UCode from 0x%08x to 0x%04x (crc: %8x)", addr, dsp_addr,
g_dsp.iram_crc); g_dsp.iram_crc);
return dst + dsp_addr; return reinterpret_cast<u8*>(dst);
} }
static const u8* gdsp_idma_out(u16 dsp_addr, u32 addr, u32 size) static const u8* gdsp_idma_out(u16 dsp_addr, u32 addr, u32 size)