From ccebd7512e920138105c5378740cb31f9e31cc0b Mon Sep 17 00:00:00 2001 From: hrydgard Date: Sat, 11 Jul 2009 10:18:25 +0000 Subject: [PATCH] Fix a DSP disasm problem, misc minor stuff .. not much to see here git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3745 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/Common/Src/ABI.cpp | 32 ++++++++++++++++++++ Source/Core/Common/Src/x64Emitter.h | 4 ++- Source/Core/Core/Src/HW/Memmap.h | 9 ------ Source/Core/Core/Src/HW/MemmapFunctions.cpp | 7 +++++ Source/Core/DSPCore/Src/DSPIntExtOps.cpp | 8 ++--- Source/Core/DSPCore/Src/DSPTables.h | 2 +- Source/Core/DSPCore/Src/DspIntBranch.cpp | 2 +- Source/Core/DSPCore/Src/DspIntMultiplier.cpp | 2 +- 8 files changed, 49 insertions(+), 17 deletions(-) diff --git a/Source/Core/Common/Src/ABI.cpp b/Source/Core/Common/Src/ABI.cpp index f316b3ff57..4b1a7870da 100644 --- a/Source/Core/Common/Src/ABI.cpp +++ b/Source/Core/Common/Src/ABI.cpp @@ -81,6 +81,24 @@ void XEmitter::ABI_CallFunctionCC(void *func, u32 param1, u32 param2) { ABI_RestoreStack(2 * 4); } +void XEmitter::ABI_CallFunctionCCC(void *func, u32 param1, u32 param2, u32 param3) { + ABI_AlignStack(3 * 4); + PUSH(32, Imm32(param3)); + PUSH(32, Imm32(param2)); + PUSH(32, Imm32(param1)); + CALL(func); + ABI_RestoreStack(3 * 4); +} + +void XEmitter::ABI_CallFunctionCCP(void *func, u32 param1, u32 param2, void *param3) { + ABI_AlignStack(3 * 4); + PUSH(32, Imm32((u32)param3)); + PUSH(32, Imm32(param2)); + PUSH(32, Imm32(param1)); + CALL(func); + ABI_RestoreStack(3 * 4); +} + // Pass a register as a paremeter. void XEmitter::ABI_CallFunctionR(void *func, X64Reg reg1) { ABI_AlignStack(1 * 4); @@ -177,6 +195,20 @@ void XEmitter::ABI_CallFunctionCC(void *func, u32 param1, u32 param2) { CALL(func); } +void XEmitter::ABI_CallFunctionCCC(void *func, u32 param1, u32 param2, u32 param3) { + MOV(32, R(ABI_PARAM1), Imm32(param1)); + MOV(32, R(ABI_PARAM2), Imm32(param2)); + MOV(32, R(ABI_PARAM3), Imm32(param3)); + CALL(func); +} + +void XEmitter::ABI_CallFunctionCCP(void *func, u32 param1, u32 param2, void *param3) { + MOV(32, R(ABI_PARAM1), Imm32(param1)); + MOV(32, R(ABI_PARAM2), Imm32(param2)); + MOV(64, R(ABI_PARAM3), Imm64((u64)param3)); + CALL(func); +} + // Pass a register as a paremeter. void XEmitter::ABI_CallFunctionR(void *func, X64Reg reg1) { if (reg1 != ABI_PARAM1) diff --git a/Source/Core/Common/Src/x64Emitter.h b/Source/Core/Common/Src/x64Emitter.h index f02f72c7e2..a1fb427349 100644 --- a/Source/Core/Common/Src/x64Emitter.h +++ b/Source/Core/Common/Src/x64Emitter.h @@ -585,6 +585,8 @@ public: // These will destroy the 1 or 2 first "parameter regs". void ABI_CallFunctionC(void *func, u32 param1); void ABI_CallFunctionCC(void *func, u32 param1, u32 param2); + void ABI_CallFunctionCCC(void *func, u32 param1, u32 param2, u32 param3); + void ABI_CallFunctionCCP(void *func, u32 param1, u32 param2, void *param3); void ABI_CallFunctionAC(void *func, const Gen::OpArg &arg1, u32 param2); // Pass a register as a paremeter. @@ -607,7 +609,7 @@ public: void ABI_RestoreStack(unsigned int frameSize); // Sets up a __cdecl function. - // Only x64 really needs the parameter. + // Only x64 really needs the parameter count. void ABI_EmitPrologue(int maxCallParams); void ABI_EmitEpilogue(int maxCallParams); diff --git a/Source/Core/Core/Src/HW/Memmap.h b/Source/Core/Core/Src/HW/Memmap.h index 04670d43d3..6c334f6abb 100644 --- a/Source/Core/Core/Src/HW/Memmap.h +++ b/Source/Core/Core/Src/HW/Memmap.h @@ -102,17 +102,8 @@ namespace Memory u32 Read_Opcode(const u32 _Address); - // For use by emulator - /* Local byteswap shortcuts. They are placed inline so that they may hopefully be executed faster - than otherwise */ - inline u8 bswap(u8 val) {return val;} - inline u16 bswap(u16 val) {return Common::swap16(val);} - inline u32 bswap(u32 val) {return Common::swap32(val);} - inline u64 bswap(u64 val) {return Common::swap64(val);} - // ================= - // Read and write functions #define NUMHWMEMFUN 64 #define HWSHIFT 10 diff --git a/Source/Core/Core/Src/HW/MemmapFunctions.cpp b/Source/Core/Core/Src/HW/MemmapFunctions.cpp index 0dbeba41a9..513a508db5 100644 --- a/Source/Core/Core/Src/HW/MemmapFunctions.cpp +++ b/Source/Core/Core/Src/HW/MemmapFunctions.cpp @@ -77,6 +77,13 @@ extern readFn8 hwReadWii8 [NUMHWMEMFUN]; extern readFn16 hwReadWii16[NUMHWMEMFUN]; extern readFn32 hwReadWii32[NUMHWMEMFUN]; +// Overloaded byteswap functions, for use within the templated functions below. +inline u8 bswap(u8 val) {return val;} +inline u16 bswap(u16 val) {return Common::swap16(val);} +inline u32 bswap(u32 val) {return Common::swap32(val);} +inline u64 bswap(u64 val) {return Common::swap64(val);} +// ================= + /////////////////////////////////////////////////////////////////////////////////// // Read and write // ---------------- diff --git a/Source/Core/DSPCore/Src/DSPIntExtOps.cpp b/Source/Core/DSPCore/Src/DSPIntExtOps.cpp index c9671e139b..e04739d628 100644 --- a/Source/Core/DSPCore/Src/DSPIntExtOps.cpp +++ b/Source/Core/DSPCore/Src/DSPIntExtOps.cpp @@ -317,7 +317,6 @@ void dsp_op_ext_ls_epi(const UDSPInstruction& opc) } } - void dsp_op_ext_sl_pro(const UDSPInstruction& opc) { u8 areg = (opc.hex & 0x1) + 0x1e; @@ -334,13 +333,12 @@ void dsp_op_ext_sl_pro(const UDSPInstruction& opc) } } - void dsp_op_ext_sl_epi(const UDSPInstruction& opc) { u8 dreg = ((opc.hex >> 4) & 0x3) + 0x18; - u16 val = dsp_dmem_read(g_dsp.r[0x03]); + const u8 sreg = 0x03; + u16 val = dsp_dmem_read(g_dsp.r[sreg]); dsp_op_write_reg(dreg, val); - u8 sreg = 0x03; if (opc.hex & 0x8) // SLM/SLMN { @@ -379,6 +377,8 @@ void dsp_op_ext_ld(const UDSPInstruction& opc) } else { + // Hmm + // if (sreg != 0x3) dsp_increment_addr_reg(0x03); } } diff --git a/Source/Core/DSPCore/Src/DSPTables.h b/Source/Core/DSPCore/Src/DSPTables.h index a56a112b72..c0fd6b6310 100644 --- a/Source/Core/DSPCore/Src/DSPTables.h +++ b/Source/Core/DSPCore/Src/DSPTables.h @@ -48,12 +48,12 @@ enum partype_t P_REG1A = P_REG | 0x1a80, P_REG1C = P_REG | 0x1c00, // P_ACC = P_REG | 0x1c10, // used for global accum (gcdsptool's value) - P_ACC_D = P_REG | 0x1c80, P_ACCL = P_REG | 0x1c00, // used for low part of accum P_ACCM = P_REG | 0x1e00, // used for mid part of accum // The following are not in gcdsptool P_ACCM_D = P_REG | 0x1e80, P_ACC = P_REG | 0x2000, // used for full accum. + P_ACC_D = P_REG | 0x2080, P_AX = P_REG | 0x2200, P_REGS_MASK = 0x03f80, // gcdsptool's value = 0x01f80 P_REF = P_REG | 0x4000, diff --git a/Source/Core/DSPCore/Src/DspIntBranch.cpp b/Source/Core/DSPCore/Src/DspIntBranch.cpp index 3d4becc61d..d5d1eace25 100644 --- a/Source/Core/DSPCore/Src/DspIntBranch.cpp +++ b/Source/Core/DSPCore/Src/DspIntBranch.cpp @@ -154,7 +154,7 @@ void HandleLoop() if (rLoopAddress > 0 && rLoopCounter > 0) { - // FIXME: why -1? + // FIXME: why -1? because we just read past it. if (g_dsp.pc - 1 == rLoopAddress) { rLoopCounter--; diff --git a/Source/Core/DSPCore/Src/DspIntMultiplier.cpp b/Source/Core/DSPCore/Src/DspIntMultiplier.cpp index 13167e6fae..7cf71e7f9b 100644 --- a/Source/Core/DSPCore/Src/DspIntMultiplier.cpp +++ b/Source/Core/DSPCore/Src/DspIntMultiplier.cpp @@ -32,7 +32,7 @@ namespace DSPInterpreter { s64 dsp_multiply_conditional_unsigned(u16 a, u16 b) { s64 prod; -#if 0 // Makes games sound horrible. TODO: activate and figure out why - it's been verified through DSPSpy :/ +#if 0 // Makes AX games sound horrible. TODO: activate and figure out why - it's been verified through DSPSpy :/ if (g_dsp.r[DSP_REG_SR] & SR_MUL_UNSIGNED) prod = (u64)a * (u64)b; // won't overflow 32-bits else