From a583950f828c7b089b66204b2d60d94a962d3d12 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Sun, 5 Apr 2009 15:46:47 +0000 Subject: [PATCH] DSP: Unbreak disassembler (broken since 2866), commenting, logging changes, minor cleanup git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2878 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/CommonPaths.h | 4 +-- Source/Core/Core/Src/Boot/Boot_BIOSEmu.cpp | 2 +- Source/Core/Core/Src/HW/DSP.cpp | 4 +-- .../Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp | 7 +++- .../Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h | 1 + Source/Dolphin.sln | 2 ++ .../Plugin_DSP_HLE/Src/UCodes/UCode_ROM.cpp | 3 +- .../Src/DSPInterpreter.cpp | 34 ++++++++++++------- .../Plugin_DSP_LLE-testing/Src/Globals.cpp | 1 - .../Plugin_DSP_LLE-testing/Src/Globals.h | 1 + .../Plugin_DSP_LLE-testing/Src/Tools.cpp | 6 ++-- .../Plugin_DSP_LLE-testing/Src/Tools.h | 2 +- .../Src/disassemble.cpp | 23 ++++++++----- .../Plugin_DSP_LLE-testing/Src/gdsp_aram.cpp | 3 ++ .../Src/gdsp_condition_codes.cpp | 4 +-- .../Src/gdsp_condition_codes.h | 7 ++-- .../Src/gdsp_interface.cpp | 23 +++++++------ .../Src/gdsp_memory.cpp | 10 ++---- .../Src/gdsp_registers.cpp | 9 ++--- .../Plugin_DSP_LLE-testing/Src/main.cpp | 32 +++++++---------- 20 files changed, 94 insertions(+), 84 deletions(-) diff --git a/Source/Core/Common/Src/CommonPaths.h b/Source/Core/Common/Src/CommonPaths.h index 0bb59efd4b..26ac722ae7 100644 --- a/Source/Core/Common/Src/CommonPaths.h +++ b/Source/Core/Common/Src/CommonPaths.h @@ -93,7 +93,7 @@ #define FONT_ANSI "font_ansi.bin" #define FONT_SJIS "font_sjis.bin" -#define DSP_ROM "dsp_rom.bin" +#define DSP_IROM "dsp_rom.bin" #define DSP_COEF "dsp_coef.bin" #define GC_IPL "IPL.bin" @@ -159,7 +159,7 @@ #define FONT_ANSI_FILE FULL_GC_SYS_DIR FONT_ANSI #define FONT_SJIS_FILE FULL_GC_SYS_DIR FONT_SJIS -#define DSP_ROM_FILE FULL_GC_SYS_DIR DSP_ROM +#define DSP_IROM_FILE FULL_GC_SYS_DIR DSP_IROM #define DSP_COEF_FILE FULL_GC_SYS_DIR DSP_COEF #define WII_EUR_SETTING_FILE FULL_WII_SYS_DIR WII_EUR_SETTING diff --git a/Source/Core/Core/Src/Boot/Boot_BIOSEmu.cpp b/Source/Core/Core/Src/Boot/Boot_BIOSEmu.cpp index d8ce02edc0..48d3f46e19 100644 --- a/Source/Core/Core/Src/Boot/Boot_BIOSEmu.cpp +++ b/Source/Core/Core/Src/Boot/Boot_BIOSEmu.cpp @@ -179,7 +179,7 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode) break; default: - PanicAlert("SetupWiiMem: Unknown country. Wii boot process will be switched to European settings."); + // PanicAlert("SetupWiiMem: Unknown country. Wii boot process will be switched to European settings."); filename = WII_EUR_SETTING_FILE; break; } diff --git a/Source/Core/Core/Src/HW/DSP.cpp b/Source/Core/Core/Src/HW/DSP.cpp index 5bfd8823b6..21c3e72688 100644 --- a/Source/Core/Core/Src/HW/DSP.cpp +++ b/Source/Core/Core/Src/HW/DSP.cpp @@ -578,7 +578,7 @@ void Update_ARAM_DMA() if (g_arDMA.Cnt.dir) { //read from ARAM - INFO_LOG(DSPINTERFACE, "ARAM DMA read %08x bytes from %08x to Mem: %08x",g_arDMA.Cnt.count, g_arDMA.ARAddr, g_arDMA.MMAddr); + INFO_LOG(DSPINTERFACE, "DMA copy %08x bytes from ARAM %08x to Mem: %08x",g_arDMA.Cnt.count, g_arDMA.ARAddr, g_arDMA.MMAddr); u32 iMemAddress = g_arDMA.MMAddr; u32 iARAMAddress = g_arDMA.ARAddr; @@ -598,7 +598,7 @@ void Update_ARAM_DMA() u32 iARAMAddress = g_arDMA.ARAddr; //write to g_ARAM - INFO_LOG(DSPINTERFACE, "g_ARAM DMA write %08x bytes from %08x to Aram: %08x", + INFO_LOG(DSPINTERFACE, "DMA copy %08x bytes from Mem %08x to ARAM %08x (sound data loaded)", g_arDMA.Cnt.count, g_arDMA.MMAddr, g_arDMA.ARAddr); for (u32 i = 0; i < g_arDMA.Cnt.count; i++) { diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp index 3299d13c9e..05692a065c 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp @@ -1972,6 +1972,12 @@ bool CWII_IPC_HLE_Device_usb_oh0::Open(u32 _CommandAddress, u32 _Mode) return true; } +bool CWII_IPC_HLE_Device_usb_oh0::Close(u32 _CommandAddress) +{ + Memory::Write_U32(0, _CommandAddress + 0x4); + return true; +} + bool CWII_IPC_HLE_Device_usb_oh0::IOCtl(u32 _CommandAddress) { // write return value @@ -1983,7 +1989,6 @@ bool CWII_IPC_HLE_Device_usb_oh0::IOCtlV(u32 _CommandAddress) { // write return value Memory::Write_U32(0, _CommandAddress + 0x4); - return true; } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h index d2ca70c2e4..d770c6df92 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.h @@ -227,6 +227,7 @@ public: virtual ~CWII_IPC_HLE_Device_usb_oh0(); virtual bool Open(u32 _CommandAddress, u32 _Mode); + virtual bool Close(u32 _CommandAddress); // hermes' dsp demo virtual bool IOCtlV(u32 _CommandAddress); virtual bool IOCtl(u32 _CommandAddress); diff --git a/Source/Dolphin.sln b/Source/Dolphin.sln index 5dc39ac730..7275ebe67b 100644 --- a/Source/Dolphin.sln +++ b/Source/Dolphin.sln @@ -530,10 +530,12 @@ Global {3D8156A9-64D1-4C8E-ADBE-1B319030E4A4}.Debug|x64.ActiveCfg = Debug|x64 {3D8156A9-64D1-4C8E-ADBE-1B319030E4A4}.DebugFast|Win32.ActiveCfg = DebugFast|Win32 {3D8156A9-64D1-4C8E-ADBE-1B319030E4A4}.DebugFast|x64.ActiveCfg = DebugFast|x64 + {3D8156A9-64D1-4C8E-ADBE-1B319030E4A4}.DebugFast|x64.Build.0 = DebugFast|x64 {3D8156A9-64D1-4C8E-ADBE-1B319030E4A4}.Release_JITIL|Win32.ActiveCfg = Release|Win32 {3D8156A9-64D1-4C8E-ADBE-1B319030E4A4}.Release_JITIL|x64.ActiveCfg = Release|x64 {3D8156A9-64D1-4C8E-ADBE-1B319030E4A4}.Release|Win32.ActiveCfg = Release|Win32 {3D8156A9-64D1-4C8E-ADBE-1B319030E4A4}.Release|x64.ActiveCfg = Release|x64 + {3D8156A9-64D1-4C8E-ADBE-1B319030E4A4}.Release|x64.Build.0 = Release|x64 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_ROM.cpp b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_ROM.cpp index 7929ed9465..0fc209ab27 100644 --- a/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_ROM.cpp +++ b/Source/Plugins/Plugin_DSP_HLE/Src/UCodes/UCode_ROM.cpp @@ -75,7 +75,7 @@ void CUCode_Rom::HandleMail(u32 _uMail) { m_CurrentUCode.m_StartPC = _uMail; BootUCode(); - return; // FIXES THE OVERWRITE + return; // Important! BootUCode indirectly does "delete this;". Must exit immediately. } break; } @@ -90,7 +90,6 @@ void CUCode_Rom::BootUCode() // simple non-scientific crc invented by ector :P // too annoying to change now, and probably good enough anyway u32 crc = 0; - for (u32 i = 0; i < m_CurrentUCode.m_Length; i++) { crc ^= Memory_Read_U8(m_CurrentUCode.m_RAMAddress + i); diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/DSPInterpreter.cpp b/Source/Plugins/Plugin_DSP_LLE-testing/Src/DSPInterpreter.cpp index 18c4508d8c..4784d2deb3 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/DSPInterpreter.cpp +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/DSPInterpreter.cpp @@ -29,9 +29,6 @@ namespace DSPInterpreter { - -// END OF HELPER FUNCTIONS - void unknown(const UDSPInstruction& opc) { //_assert_msg_(MASTER_LOG, !g_dsp.exception_in_progress_hack, "assert while exception"); @@ -517,11 +514,11 @@ void andc(const UDSPInstruction& opc) if ((ac1 & ac2) == 0) { - g_dsp.r[R_SR] |= 0x20; + g_dsp.r[R_SR] |= 0x20; // 0x40? } else { - g_dsp.r[R_SR] &= ~0x20; + g_dsp.r[R_SR] &= ~0x20; // 0x40? } } @@ -980,26 +977,34 @@ void shifti(const UDSPInstruction& opc) //------------------------------------------------------------- // hcs give me this code!! +// More docs needed - the operation is really odd! +// Decrement Address Register void dar(const UDSPInstruction& opc) { - u8 reg = opc.hex & 0x3; + int reg = opc.hex & 0x3; int temp = g_dsp.r[reg] + g_dsp.r[8]; - if (temp <= 0x7ff){g_dsp.r[reg] = temp;} - else {g_dsp.r[reg]--;} + if (temp <= 0x7ff) // ??? + g_dsp.r[reg] = temp; + else + g_dsp.r[reg]--; } // hcs give me this code!! +// More docs needed - the operation is really odd! +// Increment Address Register void iar(const UDSPInstruction& opc) { - u8 reg = opc.hex & 0x3; + int reg = opc.hex & 0x3; int temp = g_dsp.r[reg] + g_dsp.r[8]; - if (temp <= 0x7ff){g_dsp.r[reg] = temp;} - else {g_dsp.r[reg]++;} + if (temp <= 0x7ff) // ??? + g_dsp.r[reg] = temp; + else + g_dsp.r[reg]++; } //------------------------------------------------------------- @@ -1019,6 +1024,7 @@ void sbset(const UDSPInstruction& opc) // FIXME inside +// No idea what most of this is supposed to do. void srbith(const UDSPInstruction& opc) { switch ((opc.hex >> 8) & 0xf) @@ -1036,11 +1042,13 @@ void srbith(const UDSPInstruction& opc) case 0xd: // SET15 ERROR_LOG(DSPHLE, "dsp_opc.hex_set15\n"); break; - case 0xe: // SET40 + + case 0xe: // SET40 (really, clear SR's 0x4000?) something about "set 40-bit operation"? g_dsp.r[R_SR] &= ~(1 << 14); break; - case 0xf: // SET16 // that doesnt happen on a real console + case 0xf: // SET16 (really, set SR's 0x4000?) something about "set 16-bit operation"? + // that doesnt happen on a real console << what does this comment mean? g_dsp.r[R_SR] |= (1 << 14); break; diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/Globals.cpp b/Source/Plugins/Plugin_DSP_LLE-testing/Src/Globals.cpp index 0f6f18f4e0..c1b4ea09ad 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/Globals.cpp +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/Globals.cpp @@ -28,7 +28,6 @@ // -------------- u32 RAM_MASK = 0x1FFFFFF; - u16 Memory_Read_U16(u32 _uAddress) { _uAddress &= RAM_MASK; diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/Globals.h b/Source/Plugins/Plugin_DSP_LLE-testing/Src/Globals.h index 9471b02a04..82fa2503ac 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/Globals.h +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/Globals.h @@ -18,6 +18,7 @@ #ifndef _GLOBALS_H #define _GLOBALS_H +#include "Common.h" #include "AudioCommon.h" #include diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/Tools.cpp b/Source/Plugins/Plugin_DSP_LLE-testing/Src/Tools.cpp index 6bbf856d58..036e37d830 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/Tools.cpp +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/Tools.cpp @@ -25,15 +25,15 @@ #include "disassemble.h" #include "gdsp_interpreter.h" -bool DumpDSPCode(u32 _Address, u32 _Length, u32 crc) +bool DumpDSPCode(const u8 *data, u32 _Length, u32 crc) { char szFilename[MAX_PATH]; sprintf(szFilename, "%sDSP_UC_%08X.bin", FULL_DSP_DUMP_DIR, crc); FILE* pFile = fopen(szFilename, "wb"); - if (pFile != NULL) + if (pFile) { - fwrite(g_dspInitialize.pGetMemoryPointer(_Address), _Length, 1, pFile); + fwrite(data, _Length, 1, pFile); fclose(pFile); } else diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/Tools.h b/Source/Plugins/Plugin_DSP_LLE-testing/Src/Tools.h index 0520ef4bbe..3f5870717b 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/Tools.h +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/Tools.h @@ -44,7 +44,7 @@ union UDSPControl : Hex(_Hex) {} }; -bool DumpDSPCode(u32 _Address, u32 _Length, u32 crc); +bool DumpDSPCode(const u8 *data, u32 _Length, u32 crc); bool DisasmUCodeDump(u32 crc); u32 GenerateCRC(const unsigned char* _pBuffer, int _pLength); bool DumpCWCode(u32 _Address, u32 _Length); diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/disassemble.cpp b/Source/Plugins/Plugin_DSP_LLE-testing/Src/disassemble.cpp index 8be950f5f2..e8a10ff3a9 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/disassemble.cpp +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/disassemble.cpp @@ -150,13 +150,14 @@ const char* pdname(u16 val) return tmpstr; } -char* gd_dis_params(gd_globals_t* gdg, DSPOPCTemplate* opc, u16 op1, u16 op2, char* strbuf) +extern void nop(const UDSPInstruction& opc); + +char* gd_dis_params(gd_globals_t* gdg, const DSPOPCTemplate* opc, u16 op1, u16 op2, char* strbuf) { char* buf = strbuf; u32 val; - int j; - for (j = 0; j < opc->param_count; j++) + for (int j = 0; j < opc->param_count; j++) { if (j > 0) { @@ -219,7 +220,7 @@ char* gd_dis_params(gd_globals_t* gdg, DSPOPCTemplate* opc, u16 op1, u16 op2, ch if (opc->params[j].size != 2) { if (opc->params[j].mask == 0x007f) // LSL, LSR, ASL, ASR - sprintf(buf, "#%d", val < 64 ? val : -(0x80-(s32)val)); + sprintf(buf, "#%d", val < 64 ? val : -(0x80 - (s32)val)); else sprintf(buf, "#0x%02x", val); } @@ -239,7 +240,7 @@ char* gd_dis_params(gd_globals_t* gdg, DSPOPCTemplate* opc, u16 op1, u16 op2, ch default: ERROR_LOG(DSPHLE, "Unknown parameter type: %x", opc->params[j].type); - exit(-1); +// exit(-1); break; } @@ -320,13 +321,12 @@ u16 gd_dis_get_opcode_size(gd_globals_t* gdg) return(opc->size & ~P_EXT); } - char* gd_dis_opcode(gd_globals_t* gdg) { u32 j; u32 op1, op2; - DSPOPCTemplate *opc = NULL; - DSPOPCTemplate *opc_ext = NULL; + const DSPOPCTemplate *opc = NULL; + const DSPOPCTemplate *opc_ext = NULL; u16 pc; char* buf = gdg->buffer; bool extended; @@ -337,7 +337,7 @@ char* gd_dis_opcode(gd_globals_t* gdg) if ((pc & 0x7fff) >= 0x1000) { gdg->pc++; - return(gdg->buffer); + return gdg->buffer; } pc &= 0x0fff; @@ -360,6 +360,11 @@ char* gd_dis_opcode(gd_globals_t* gdg) } } + + const DSPOPCTemplate fake_op = {"CW", 0x0000, 0x0000, nop, nop, 1, 1, {{P_VAL, 2, 0, 0, 0xffff}}, NULL, NULL,}; + if (!opc) + opc = &fake_op; + if (opc->size & P_EXT && op1 & 0x00ff) extended = true; else diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_aram.cpp b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_aram.cpp index 5ea0ff1e59..f077ad2940 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_aram.cpp +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_aram.cpp @@ -95,6 +95,9 @@ u16 dsp_read_aram() break; } + // TODO: Take ifx GAIN into account. + + // check for loop if (Address > EndAddress) { diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_condition_codes.cpp b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_condition_codes.cpp index 2223c8b1c5..3e7c7fbd67 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_condition_codes.cpp +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_condition_codes.cpp @@ -40,7 +40,7 @@ void Update_SR_Register64(s64 _Value) g_dsp.r[R_SR] |= 0x4; } - // logic + // weird if ((_Value >> 62) == 0) { g_dsp.r[R_SR] |= 0x20; @@ -61,7 +61,7 @@ void Update_SR_Register16(s16 _Value) g_dsp.r[R_SR] |= 0x4; } - // logic + // weird if ((_Value >> 14) == 0) { g_dsp.r[R_SR] |= 0x20; diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_condition_codes.h b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_condition_codes.h index 5ecaa267d9..5f85494f65 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_condition_codes.h +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_condition_codes.h @@ -32,10 +32,11 @@ namespace DSPInterpreter { #define SR_CMP_MASK 0x3f // Shouldn't this include 0x40? // These are probably not accurate. Do not use yet. -#define SR_LOGIC_ZERO 0x0040 // ?? duddie's doc sometimes say & 1<<6 (0x40), sometimes 1<<14 (0x4000), while we have 0x20 .. eh -#define SR_PROD_MUL2 0x2000 +#define SR_UNKNOWN 0x0002 // ???????? +#define SR_ARITH_ZERO 0x0004 #define SR_SIGN 0x0008 -#define SR_ARITH_ZERO 0x0002 // ???????? +#define SR_TOP2BITS 0x0020 // this is an odd one. +#define SR_LOGIC_ZERO 0x0040 // ?? duddie's doc sometimes say & 1<<6 (0x40), sometimes 1<<14 (0x4000), while we have 0x20 .. eh #define SR_INT_ENABLE 0x0200 // Not 100% sure but duddie says so. This should replace the hack, if so. #define SR_MUL_MODIFY 0x2000 // 1 = normal. 0 = x2 diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_interface.cpp b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_interface.cpp index 2aa7a94c30..5b6374aa44 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_interface.cpp +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_interface.cpp @@ -49,7 +49,7 @@ const char* reg_names[] = NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, "DSCR", NULL, "DSBL", NULL, "DSPA", "DSMAH", "DSMAL", // d0 - NULL, "SampleFormat", NULL, NULL, "ACSAH", "ACSAL", "ACEAH", "ACEAL", + NULL, "SampleFormat", NULL, NULL, "ACSAH", "ACSAL", "ACEAH", "ACEAL", "ACCAH", "ACCAL", "PRED_SCALE", "YN1", "YN2", "ARAM", "GAIN", NULL, // e0 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, @@ -72,9 +72,7 @@ u16 gdsp_ifx_regs[256]; void gdsp_ifx_init() { - int i; - - for (i = 0; i < 256; i++) + for (int i = 0; i < 256; i++) { gdsp_ifx_regs[i] = 0; } @@ -128,14 +126,14 @@ void gdsp_mbox_write_l(u8 mbx, u16 val) if (mbx == GDSP_MBOX_DSP) { - DEBUG_LOG(DSPHLE, "- Write DSP Mail: 0x%08x (pc=0x%04x)\n", gdsp_mbox_peek(GDSP_MBOX_DSP), g_dsp.err_pc); + DEBUG_LOG(DSPHLE, " - DSP writes mail to mbx %i: 0x%08x (pc=0x%04x)", mbx, gdsp_mbox_peek(GDSP_MBOX_DSP), g_dsp.err_pc); } } u16 gdsp_mbox_read_h(u8 mbx) { - return (gdsp_mbox[mbx][0]); + return (gdsp_mbox[mbx][0]); // TODO: mask away the top bit? } @@ -149,10 +147,12 @@ u16 gdsp_mbox_read_l(u8 mbx) val = gdsp_mbox[mbx][1]; gdsp_mbox[mbx][0] &= ~0x8000; + DEBUG_LOG(DSPHLE, "- DSP reads mail from mbx %i: %08x (pc=0x%04x)", mbx, gdsp_mbox_peek(mbx), g_dsp.err_pc); + #if WITH_DSP_ON_THREAD g_CriticalSection.Leave(); #endif - return(val); + return val; } @@ -250,14 +250,15 @@ void gdsp_idma_in(u16 dsp_addr, u32 addr, u32 size) for (u32 i = 0; i < size; i += 2) { + // TODO : this may be different on Wii. *(u16*)&dst[dsp_addr + i] = *(u16*)&g_dsp.cpu_ram[(addr + i) & 0x0fffffff]; } g_dsp.iram_crc = GenerateCRC(g_dsp.cpu_ram + (addr & 0x0fffffff), size); - DEBUG_LOG(DSPHLE, "*** Copy new UCode from 0x%08x to 0x%04x (crc: %8x)\n", addr, dsp_addr, g_dsp.iram_crc); + INFO_LOG(DSPHLE, "*** Copy new UCode from 0x%08x to 0x%04x (crc: %8x)\n", addr, dsp_addr, g_dsp.iram_crc); if (g_dsp.dump_imem) - DumpDSPCode(addr, size, g_dsp.iram_crc); + DumpDSPCode(&dst[dsp_addr], size, g_dsp.iram_crc); } @@ -282,7 +283,7 @@ void gdsp_ddma_in(u16 dsp_addr, u32 addr, u32 size) *(u16*)&dst[dsp_addr + i] = *(u16*)&g_dsp.cpu_ram[(addr + i) & 0x7FFFFFFF]; } - DEBUG_LOG(DSPHLE, "*** ddma_in RAM (0x%08x) -> DRAM_DSP (0x%04x) : size (0x%08x)\n", addr, dsp_addr / 2, size); + INFO_LOG(DSPHLE, "*** ddma_in RAM (0x%08x) -> DRAM_DSP (0x%04x) : size (0x%08x)\n", addr, dsp_addr / 2, size); } @@ -301,7 +302,7 @@ void gdsp_ddma_out(u16 dsp_addr, u32 addr, u32 size) *(u16*)&g_dsp.cpu_ram[(addr + i) & 0x7FFFFFFF] = *(u16*)&src[dsp_addr + i]; } - DEBUG_LOG(DSPHLE, "*** ddma_out DRAM_DSP (0x%04x) -> RAM (0x%08x) : size (0x%08x)\n", dsp_addr / 2, addr, size); + INFO_LOG(DSPHLE, "*** ddma_out DRAM_DSP (0x%04x) -> RAM (0x%08x) : size (0x%08x)\n", dsp_addr / 2, addr, size); } diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_memory.cpp b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_memory.cpp index 7818a22003..9647ed7f7a 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_memory.cpp +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_memory.cpp @@ -139,18 +139,14 @@ bool dsp_dmem_write(u16 addr, u16 val) return(true); } - -u16 dsp_fetch_code(void) +u16 dsp_fetch_code() { u16 opc = dsp_imem_read(g_dsp.pc); g_dsp.pc++; - return(opc); + return opc; } - u16 dsp_peek_code(void) { - return(dsp_imem_read(g_dsp.pc)); + return dsp_imem_read(g_dsp.pc); } - - diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_registers.cpp b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_registers.cpp index b430ac07d5..aa74291ec7 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_registers.cpp +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_registers.cpp @@ -27,7 +27,7 @@ #include "gdsp_registers.h" #include "gdsp_interpreter.h" - +// Stacks. The stacks are outside the DSP RAM, in dedicated hardware. void dsp_reg_stack_push(u8 stack_reg) { @@ -36,7 +36,6 @@ void dsp_reg_stack_push(u8 stack_reg) g_dsp.reg_stack[stack_reg][g_dsp.reg_stack_ptr[stack_reg]] = g_dsp.r[DSP_REG_ST0 + stack_reg]; } - void dsp_reg_stack_pop(u8 stack_reg) { g_dsp.r[DSP_REG_ST0 + stack_reg] = g_dsp.reg_stack[stack_reg][g_dsp.reg_stack_ptr[stack_reg]]; @@ -44,19 +43,15 @@ void dsp_reg_stack_pop(u8 stack_reg) g_dsp.reg_stack_ptr[stack_reg] &= DSP_STACK_MASK; } - void dsp_reg_store_stack(u8 stack_reg, u16 val) { dsp_reg_stack_push(stack_reg); g_dsp.r[DSP_REG_ST0 + stack_reg] = val; } - u16 dsp_reg_load_stack(u8 stack_reg) { u16 val = g_dsp.r[DSP_REG_ST0 + stack_reg]; dsp_reg_stack_pop(stack_reg); - return(val); + return val; } - - diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/main.cpp b/Source/Plugins/Plugin_DSP_LLE-testing/Src/main.cpp index 3b0bf61313..db95b253c7 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/main.cpp +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/main.cpp @@ -216,6 +216,7 @@ void DSP_DebugBreak() void dspi_req_dsp_irq() { + // Fire an interrupt on the PPC ASAP. g_dspInitialize.pGenerateDSPInterrupt(); } @@ -225,27 +226,28 @@ void Initialize(void *init) g_dspInitialize = *(DSPInitialize*)init; g_Config.Load(); + gdsp_init(); g_dsp.step_counter = 0; g_dsp.cpu_ram = g_dspInitialize.pGetMemoryPointer(0); g_dsp.irq_request = dspi_req_dsp_irq; gdsp_reset(); - if (!gdsp_load_rom(DSP_ROM_FILE)) { + if (!gdsp_load_rom(DSP_IROM_FILE)) { bCanWork = false; - PanicAlert("Failed loading DSP ROM from " DSP_ROM_FILE); + PanicAlert("Failed loading DSP ROM from " DSP_IROM_FILE); } - + if (!gdsp_load_coef(DSP_COEF_FILE)) { bCanWork = false; PanicAlert("Failed loading DSP COEF from " DSP_COEF_FILE); } - - if(!bCanWork) + + if (!bCanWork) return; // TODO: Don't let it work bIsRunning = true; - + g_hDSPThread = new Common::Thread(dsp_thread, NULL); soundStream = AudioCommon::InitSoundStream(); @@ -279,25 +281,17 @@ u16 DSP_ReadControlRegister() u16 DSP_ReadMailboxHigh(bool _CPUMailbox) { if (_CPUMailbox) - { - return(gdsp_mbox_read_h(GDSP_MBOX_CPU)); - } + return gdsp_mbox_read_h(GDSP_MBOX_CPU); else - { - return(gdsp_mbox_read_h(GDSP_MBOX_DSP)); - } + return gdsp_mbox_read_h(GDSP_MBOX_DSP); } u16 DSP_ReadMailboxLow(bool _CPUMailbox) { if (_CPUMailbox) - { - return(gdsp_mbox_read_l(GDSP_MBOX_CPU)); - } + return gdsp_mbox_read_l(GDSP_MBOX_CPU); else - { - return(gdsp_mbox_read_l(GDSP_MBOX_DSP)); - } + return gdsp_mbox_read_l(GDSP_MBOX_DSP); } void DSP_WriteMailboxHigh(bool _CPUMailbox, u16 _uHighMail) @@ -333,7 +327,7 @@ void DSP_WriteMailboxLow(bool _CPUMailbox, u16 _uLowMail) u32 uAddress = gdsp_mbox_peek(GDSP_MBOX_CPU); u16 errpc = g_dsp.err_pc; - DEBUG_LOG(DSPHLE, "Write CPU Mail: 0x%08x (pc=0x%04x)\n", uAddress, errpc); + DEBUG_LOG(DSPHLE, "CPU writes mail to mbx 0: 0x%08x (pc=0x%04x)\n", uAddress, errpc); // I couldn't find any better way to detect the AX mails so this had to // do. Please feel free to change it.