From 5508e5e718efb063718c6ecd86f2f637fb805393 Mon Sep 17 00:00:00 2001 From: hrydgard Date: Sun, 5 Apr 2009 19:17:19 +0000 Subject: [PATCH] DSP: Code simplification, comments, log improvements. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2885 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Plugin_DSP_LLE_Test.vcproj | 4 - .../Src/DSPInterpreter.cpp | 8 +- .../Plugin_DSP_LLE-testing/Src/HLE_Helper.cpp | 3 +- .../Plugin_DSP_LLE-testing/Src/gdsp_ext_op.h | 11 ++- .../Plugin_DSP_LLE-testing/Src/gdsp_ifx.h | 35 -------- .../Src/gdsp_interface.h | 3 + .../Src/gdsp_memory.cpp | 84 ++++--------------- .../Plugin_DSP_LLE-testing/Src/gdsp_memory.h | 7 +- 8 files changed, 39 insertions(+), 116 deletions(-) delete mode 100644 Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_ifx.h diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Plugin_DSP_LLE_Test.vcproj b/Source/Plugins/Plugin_DSP_LLE-testing/Plugin_DSP_LLE_Test.vcproj index 2336fd2740..20833afe1b 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Plugin_DSP_LLE_Test.vcproj +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Plugin_DSP_LLE_Test.vcproj @@ -646,10 +646,6 @@ RelativePath=".\Src\gdsp_ext_op.h" > - - diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/DSPInterpreter.cpp b/Source/Plugins/Plugin_DSP_LLE-testing/Src/DSPInterpreter.cpp index 698be3b246..b7089fb92c 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/DSPInterpreter.cpp +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/DSPInterpreter.cpp @@ -1060,17 +1060,17 @@ void srbith(const UDSPInstruction& opc) switch ((opc.hex >> 8) & 0xf) { case 0xa: // M2 - ERROR_LOG(DSPHLE, "dsp_opc.hex_m2\n"); + ERROR_LOG(DSPHLE, "dsp_opc.hex_m2"); break; // FIXME: Both of these appear in the beginning of the Wind Waker case 0xb: // M0 - ERROR_LOG(DSPHLE, "dsp_opc.hex_m0\n"); + ERROR_LOG(DSPHLE, "dsp_opc.hex_m0"); break; case 0xc: // CLR15 - ERROR_LOG(DSPHLE, "dsp_opc.hex_clr15\n"); + ERROR_LOG(DSPHLE, "dsp_opc.hex_clr15"); break; case 0xd: // SET15 - ERROR_LOG(DSPHLE, "dsp_opc.hex_set15\n"); + ERROR_LOG(DSPHLE, "dsp_opc.hex_set15"); break; case 0xe: // SET40 (really, clear SR's 0x4000?) something about "set 40-bit operation"? diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/HLE_Helper.cpp b/Source/Plugins/Plugin_DSP_LLE-testing/Src/HLE_Helper.cpp index b6beb185ef..7a558a090d 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/HLE_Helper.cpp +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/HLE_Helper.cpp @@ -27,7 +27,8 @@ bool WriteDMEM(u16 addr, u16 val) { - return dsp_dmem_write(addr, val); + dsp_dmem_write(addr, val); + return true; } u16 ReadDMEM(u16 addr) diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_ext_op.h b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_ext_op.h index ea0fa4b561..85c045833b 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_ext_op.h +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_ext_op.h @@ -25,10 +25,17 @@ #ifndef _GDSP_EXT_OP_H #define _GDSP_EXT_OP_H + #include "DSPTables.h" -void dsp_op_ext_ops_pro(const UDSPInstruction& opc); -void dsp_op_ext_ops_epi(const UDSPInstruction& opc); +// Extended opcode support. +// Many opcode have the lower 0xFF free - there, an opcode extension +// can be stored. The ones that must be executed before the operation +// is handled as a prologue, the ones that must be executed afterwards +// is handled as an epilogue. + +void dsp_op_ext_ops_pro(const UDSPInstruction& opc); // run any prologs +void dsp_op_ext_ops_epi(const UDSPInstruction& opc); // run any epilogs #endif diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_ifx.h b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_ifx.h deleted file mode 100644 index 1fc5fa0db7..0000000000 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_ifx.h +++ /dev/null @@ -1,35 +0,0 @@ -/*==================================================================== - - filename: gdsp_ifx.h - project: GCemu - created: 2004-6-18 - mail: duddie@walla.com - - Copyright (c) 2005 Duddie & Tratax - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - ====================================================================*/ - -// ADPCM hw - -#ifndef _GDSP_IFX_H -#define _GDSP_IFX_H - -void gdsp_ifx_write(u16 addr, u16 val); -u16 gdsp_ifx_read(u16 addr); - - -#endif diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_interface.h b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_interface.h index 2ac76af4e4..69f7676185 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_interface.h +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_interface.h @@ -60,6 +60,9 @@ u16 gdsp_mbox_read_l(u8 mbx); void gdsp_ifx_init(); +void gdsp_ifx_write(u16 addr, u16 val); +u16 gdsp_ifx_read(u16 addr); + void gdsp_idma_in(u16 dsp_addr, u32 addr, u32 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 9647ed7f7a..6e69670586 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_memory.cpp +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_memory.cpp @@ -24,100 +24,55 @@ ====================================================================*/ #include + #include "Globals.h" #include "gdsp_interpreter.h" #include "gdsp_memory.h" -#include "gdsp_ifx.h" +#include "gdsp_interface.h" u16 dsp_swap16(u16 x) { - return((x >> 8) | (x << 8)); + return (x >> 8) | (x << 8); } - -u16* gdsp_get_iram(void) -{ - return(g_dsp.iram); -} - - -u16* gdsp_get_irom(void) -{ - return(g_dsp.irom); -} - - -u16* gdsp_get_dram(void) -{ - return(g_dsp.dram); -} - - -u16* gdsp_get_drom(void) -{ - return(g_dsp.drom); -} - - u16 dsp_imem_read(u16 addr) { - u16 opc; - if (g_dsp.pc & 0x8000) - { - opc = g_dsp.irom[addr & DSP_IROM_MASK]; - } + return dsp_swap16(g_dsp.irom[addr & DSP_IROM_MASK]); else - { - opc = g_dsp.iram[addr & DSP_IRAM_MASK]; - } - - return(dsp_swap16(opc)); + return dsp_swap16(g_dsp.iram[addr & DSP_IRAM_MASK]); } - -u16 dsp_dmem_read(u16 addr) +u16 dsp_dmem_read(u16 addr) { - u16 val; - switch (addr >> 12) { case 0x0: // 0xxx DRAM - val = g_dsp.dram[addr & DSP_DRAM_MASK]; - val = dsp_swap16(val); - break; + return dsp_swap16(g_dsp.dram[addr & DSP_DRAM_MASK]); case 0x8: // 8xxx DROM - DEBUG_LOG(DSPHLE, "someone reads from ROM\n"); - val = g_dsp.drom[addr & DSP_DROM_MASK]; - val = dsp_swap16(val); - break; + ERROR_LOG(DSPHLE, "someone reads from ROM\n"); + return dsp_swap16(g_dsp.drom[addr & DSP_DROM_MASK]); case 0x1: // 1xxx COEF - val = g_dsp.coef[addr & DSP_DROM_MASK]; - val = dsp_swap16(val); - break; + return dsp_swap16(g_dsp.coef[addr & DSP_COEF_MASK]); case 0xf: // Fxxx HW regs - val = gdsp_ifx_read(addr); - break; + return gdsp_ifx_read(addr); default: // error -// ERROR_LOG(DSPHLE, "%04x DSP ERROR: Read from UNKNOWN (%04x) memory\n", g_dsp.pc, addr); - val = 0; - break; + ERROR_LOG(DSPHLE, "%04x DSP ERROR: Read from UNKNOWN (%04x) memory\n", g_dsp.pc, addr); + return 0; } - - return(val); } -bool dsp_dmem_write(u16 addr, u16 val) +void dsp_dmem_write(u16 addr, u16 val) { switch (addr >> 12) { case 0x8: // 8xxx DROM - DEBUG_LOG(DSPHLE, "someone writes to ROM\n"); + ERROR_LOG(DSPHLE, "someone writes to ROM\n"); /* val = dsp_swap16(val); g_dsp.drom[addr & DSP_DROM_MASK] = val;*/ break; @@ -127,16 +82,13 @@ bool dsp_dmem_write(u16 addr, u16 val) break; case 0x0: // 0xxx DRAM - val = dsp_swap16(val); - g_dsp.dram[addr & DSP_DRAM_MASK] = val; + g_dsp.dram[addr & DSP_DRAM_MASK] = dsp_swap16(val); break; default: // error - DEBUG_LOG(DSPHLE, "%04x DSP ERROR: Write to UNKNOWN (%04x) memory\n", g_dsp.pc, addr); + ERROR_LOG(DSPHLE, "%04x DSP ERROR: Write to UNKNOWN (%04x) memory\n", g_dsp.pc, addr); break; } - - return(true); } u16 dsp_fetch_code() @@ -146,7 +98,7 @@ u16 dsp_fetch_code() return opc; } -u16 dsp_peek_code(void) +u16 dsp_peek_code() { return dsp_imem_read(g_dsp.pc); } diff --git a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_memory.h b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_memory.h index f1c4948878..5cdc3bf12d 100644 --- a/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_memory.h +++ b/Source/Plugins/Plugin_DSP_LLE-testing/Src/gdsp_memory.h @@ -27,11 +27,10 @@ #include "Globals.h" -u16 dsp_fetch_code(void); -u16 dsp_peek_code(void); +u16 dsp_fetch_code(); +u16 dsp_peek_code(); u16 dsp_imem_read(u16 addr); -bool dsp_dmem_write(u16 addr, u16 val); +void dsp_dmem_write(u16 addr, u16 val); u16 dsp_dmem_read(u16 addr); - #endif