DSP: Code simplification, comments, log improvements.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2885 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2009-04-05 19:17:19 +00:00
parent 40a7cd15ad
commit 5508e5e718
8 changed files with 39 additions and 116 deletions

View File

@ -646,10 +646,6 @@
RelativePath=".\Src\gdsp_ext_op.h"
>
</File>
<File
RelativePath=".\Src\gdsp_ifx.h"
>
</File>
<File
RelativePath=".\Src\gdsp_interface.cpp"
>

View File

@ -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"?

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -24,100 +24,55 @@
====================================================================*/
#include <stdio.h>
#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);
}

View File

@ -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