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
This commit is contained in:
hrydgard 2009-04-05 15:46:47 +00:00
parent 405480342a
commit a583950f82
20 changed files with 94 additions and 84 deletions

View File

@ -93,7 +93,7 @@
#define FONT_ANSI "font_ansi.bin" #define FONT_ANSI "font_ansi.bin"
#define FONT_SJIS "font_sjis.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 DSP_COEF "dsp_coef.bin"
#define GC_IPL "IPL.bin" #define GC_IPL "IPL.bin"
@ -159,7 +159,7 @@
#define FONT_ANSI_FILE FULL_GC_SYS_DIR FONT_ANSI #define FONT_ANSI_FILE FULL_GC_SYS_DIR FONT_ANSI
#define FONT_SJIS_FILE FULL_GC_SYS_DIR FONT_SJIS #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 DSP_COEF_FILE FULL_GC_SYS_DIR DSP_COEF
#define WII_EUR_SETTING_FILE FULL_WII_SYS_DIR WII_EUR_SETTING #define WII_EUR_SETTING_FILE FULL_WII_SYS_DIR WII_EUR_SETTING

View File

@ -179,7 +179,7 @@ bool CBoot::SetupWiiMemory(unsigned int _CountryCode)
break; break;
default: 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; filename = WII_EUR_SETTING_FILE;
break; break;
} }

View File

@ -578,7 +578,7 @@ void Update_ARAM_DMA()
if (g_arDMA.Cnt.dir) if (g_arDMA.Cnt.dir)
{ {
//read from ARAM //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 iMemAddress = g_arDMA.MMAddr;
u32 iARAMAddress = g_arDMA.ARAddr; u32 iARAMAddress = g_arDMA.ARAddr;
@ -598,7 +598,7 @@ void Update_ARAM_DMA()
u32 iARAMAddress = g_arDMA.ARAddr; u32 iARAMAddress = g_arDMA.ARAddr;
//write to g_ARAM //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); g_arDMA.Cnt.count, g_arDMA.MMAddr, g_arDMA.ARAddr);
for (u32 i = 0; i < g_arDMA.Cnt.count; i++) for (u32 i = 0; i < g_arDMA.Cnt.count; i++)
{ {

View File

@ -1972,6 +1972,12 @@ bool CWII_IPC_HLE_Device_usb_oh0::Open(u32 _CommandAddress, u32 _Mode)
return true; 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) bool CWII_IPC_HLE_Device_usb_oh0::IOCtl(u32 _CommandAddress)
{ {
// write return value // write return value
@ -1983,7 +1989,6 @@ bool CWII_IPC_HLE_Device_usb_oh0::IOCtlV(u32 _CommandAddress)
{ {
// write return value // write return value
Memory::Write_U32(0, _CommandAddress + 0x4); Memory::Write_U32(0, _CommandAddress + 0x4);
return true; return true;
} }

View File

@ -227,6 +227,7 @@ public:
virtual ~CWII_IPC_HLE_Device_usb_oh0(); virtual ~CWII_IPC_HLE_Device_usb_oh0();
virtual bool Open(u32 _CommandAddress, u32 _Mode); virtual bool Open(u32 _CommandAddress, u32 _Mode);
virtual bool Close(u32 _CommandAddress); // hermes' dsp demo
virtual bool IOCtlV(u32 _CommandAddress); virtual bool IOCtlV(u32 _CommandAddress);
virtual bool IOCtl(u32 _CommandAddress); virtual bool IOCtl(u32 _CommandAddress);

View File

@ -530,10 +530,12 @@ Global
{3D8156A9-64D1-4C8E-ADBE-1B319030E4A4}.Debug|x64.ActiveCfg = Debug|x64 {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|Win32.ActiveCfg = DebugFast|Win32
{3D8156A9-64D1-4C8E-ADBE-1B319030E4A4}.DebugFast|x64.ActiveCfg = DebugFast|x64 {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|Win32.ActiveCfg = Release|Win32
{3D8156A9-64D1-4C8E-ADBE-1B319030E4A4}.Release_JITIL|x64.ActiveCfg = Release|x64 {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|Win32.ActiveCfg = Release|Win32
{3D8156A9-64D1-4C8E-ADBE-1B319030E4A4}.Release|x64.ActiveCfg = Release|x64 {3D8156A9-64D1-4C8E-ADBE-1B319030E4A4}.Release|x64.ActiveCfg = Release|x64
{3D8156A9-64D1-4C8E-ADBE-1B319030E4A4}.Release|x64.Build.0 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -75,7 +75,7 @@ void CUCode_Rom::HandleMail(u32 _uMail)
{ {
m_CurrentUCode.m_StartPC = _uMail; m_CurrentUCode.m_StartPC = _uMail;
BootUCode(); BootUCode();
return; // FIXES THE OVERWRITE return; // Important! BootUCode indirectly does "delete this;". Must exit immediately.
} }
break; break;
} }
@ -90,7 +90,6 @@ void CUCode_Rom::BootUCode()
// simple non-scientific crc invented by ector :P // simple non-scientific crc invented by ector :P
// too annoying to change now, and probably good enough anyway // too annoying to change now, and probably good enough anyway
u32 crc = 0; u32 crc = 0;
for (u32 i = 0; i < m_CurrentUCode.m_Length; i++) for (u32 i = 0; i < m_CurrentUCode.m_Length; i++)
{ {
crc ^= Memory_Read_U8(m_CurrentUCode.m_RAMAddress + i); crc ^= Memory_Read_U8(m_CurrentUCode.m_RAMAddress + i);

View File

@ -29,9 +29,6 @@
namespace DSPInterpreter { namespace DSPInterpreter {
// END OF HELPER FUNCTIONS
void unknown(const UDSPInstruction& opc) void unknown(const UDSPInstruction& opc)
{ {
//_assert_msg_(MASTER_LOG, !g_dsp.exception_in_progress_hack, "assert while exception"); //_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) if ((ac1 & ac2) == 0)
{ {
g_dsp.r[R_SR] |= 0x20; g_dsp.r[R_SR] |= 0x20; // 0x40?
} }
else 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!! // hcs give me this code!!
// More docs needed - the operation is really odd!
// Decrement Address Register
void dar(const UDSPInstruction& opc) 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]; int temp = g_dsp.r[reg] + g_dsp.r[8];
if (temp <= 0x7ff){g_dsp.r[reg] = temp;} if (temp <= 0x7ff) // ???
else {g_dsp.r[reg]--;} g_dsp.r[reg] = temp;
else
g_dsp.r[reg]--;
} }
// hcs give me this code!! // hcs give me this code!!
// More docs needed - the operation is really odd!
// Increment Address Register
void iar(const UDSPInstruction& opc) 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]; int temp = g_dsp.r[reg] + g_dsp.r[8];
if (temp <= 0x7ff){g_dsp.r[reg] = temp;} if (temp <= 0x7ff) // ???
else {g_dsp.r[reg]++;} g_dsp.r[reg] = temp;
else
g_dsp.r[reg]++;
} }
//------------------------------------------------------------- //-------------------------------------------------------------
@ -1019,6 +1024,7 @@ void sbset(const UDSPInstruction& opc)
// FIXME inside // FIXME inside
// No idea what most of this is supposed to do.
void srbith(const UDSPInstruction& opc) void srbith(const UDSPInstruction& opc)
{ {
switch ((opc.hex >> 8) & 0xf) switch ((opc.hex >> 8) & 0xf)
@ -1036,11 +1042,13 @@ void srbith(const UDSPInstruction& opc)
case 0xd: // SET15 case 0xd: // SET15
ERROR_LOG(DSPHLE, "dsp_opc.hex_set15\n"); ERROR_LOG(DSPHLE, "dsp_opc.hex_set15\n");
break; 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); g_dsp.r[R_SR] &= ~(1 << 14);
break; 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); g_dsp.r[R_SR] |= (1 << 14);
break; break;

View File

@ -28,7 +28,6 @@
// -------------- // --------------
u32 RAM_MASK = 0x1FFFFFF; u32 RAM_MASK = 0x1FFFFFF;
u16 Memory_Read_U16(u32 _uAddress) u16 Memory_Read_U16(u32 _uAddress)
{ {
_uAddress &= RAM_MASK; _uAddress &= RAM_MASK;

View File

@ -18,6 +18,7 @@
#ifndef _GLOBALS_H #ifndef _GLOBALS_H
#define _GLOBALS_H #define _GLOBALS_H
#include "Common.h"
#include "AudioCommon.h" #include "AudioCommon.h"
#include <stdio.h> #include <stdio.h>

View File

@ -25,15 +25,15 @@
#include "disassemble.h" #include "disassemble.h"
#include "gdsp_interpreter.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]; char szFilename[MAX_PATH];
sprintf(szFilename, "%sDSP_UC_%08X.bin", FULL_DSP_DUMP_DIR, crc); sprintf(szFilename, "%sDSP_UC_%08X.bin", FULL_DSP_DUMP_DIR, crc);
FILE* pFile = fopen(szFilename, "wb"); 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); fclose(pFile);
} }
else else

View File

@ -44,7 +44,7 @@ union UDSPControl
: Hex(_Hex) {} : Hex(_Hex) {}
}; };
bool DumpDSPCode(u32 _Address, u32 _Length, u32 crc); bool DumpDSPCode(const u8 *data, u32 _Length, u32 crc);
bool DisasmUCodeDump(u32 crc); bool DisasmUCodeDump(u32 crc);
u32 GenerateCRC(const unsigned char* _pBuffer, int _pLength); u32 GenerateCRC(const unsigned char* _pBuffer, int _pLength);
bool DumpCWCode(u32 _Address, u32 _Length); bool DumpCWCode(u32 _Address, u32 _Length);

View File

@ -150,13 +150,14 @@ const char* pdname(u16 val)
return tmpstr; 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; char* buf = strbuf;
u32 val; u32 val;
int j;
for (j = 0; j < opc->param_count; j++) for (int j = 0; j < opc->param_count; j++)
{ {
if (j > 0) 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].size != 2)
{ {
if (opc->params[j].mask == 0x007f) // LSL, LSR, ASL, ASR 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 else
sprintf(buf, "#0x%02x", val); 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: default:
ERROR_LOG(DSPHLE, "Unknown parameter type: %x", opc->params[j].type); ERROR_LOG(DSPHLE, "Unknown parameter type: %x", opc->params[j].type);
exit(-1); // exit(-1);
break; break;
} }
@ -320,13 +321,12 @@ u16 gd_dis_get_opcode_size(gd_globals_t* gdg)
return(opc->size & ~P_EXT); return(opc->size & ~P_EXT);
} }
char* gd_dis_opcode(gd_globals_t* gdg) char* gd_dis_opcode(gd_globals_t* gdg)
{ {
u32 j; u32 j;
u32 op1, op2; u32 op1, op2;
DSPOPCTemplate *opc = NULL; const DSPOPCTemplate *opc = NULL;
DSPOPCTemplate *opc_ext = NULL; const DSPOPCTemplate *opc_ext = NULL;
u16 pc; u16 pc;
char* buf = gdg->buffer; char* buf = gdg->buffer;
bool extended; bool extended;
@ -337,7 +337,7 @@ char* gd_dis_opcode(gd_globals_t* gdg)
if ((pc & 0x7fff) >= 0x1000) if ((pc & 0x7fff) >= 0x1000)
{ {
gdg->pc++; gdg->pc++;
return(gdg->buffer); return gdg->buffer;
} }
pc &= 0x0fff; 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) if (opc->size & P_EXT && op1 & 0x00ff)
extended = true; extended = true;
else else

View File

@ -95,6 +95,9 @@ u16 dsp_read_aram()
break; break;
} }
// TODO: Take ifx GAIN into account.
// check for loop // check for loop
if (Address > EndAddress) if (Address > EndAddress)
{ {

View File

@ -40,7 +40,7 @@ void Update_SR_Register64(s64 _Value)
g_dsp.r[R_SR] |= 0x4; g_dsp.r[R_SR] |= 0x4;
} }
// logic // weird
if ((_Value >> 62) == 0) if ((_Value >> 62) == 0)
{ {
g_dsp.r[R_SR] |= 0x20; g_dsp.r[R_SR] |= 0x20;
@ -61,7 +61,7 @@ void Update_SR_Register16(s16 _Value)
g_dsp.r[R_SR] |= 0x4; g_dsp.r[R_SR] |= 0x4;
} }
// logic // weird
if ((_Value >> 14) == 0) if ((_Value >> 14) == 0)
{ {
g_dsp.r[R_SR] |= 0x20; g_dsp.r[R_SR] |= 0x20;

View File

@ -32,10 +32,11 @@ namespace DSPInterpreter {
#define SR_CMP_MASK 0x3f // Shouldn't this include 0x40? #define SR_CMP_MASK 0x3f // Shouldn't this include 0x40?
// These are probably not accurate. Do not use yet. // 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_UNKNOWN 0x0002 // ????????
#define SR_PROD_MUL2 0x2000 #define SR_ARITH_ZERO 0x0004
#define SR_SIGN 0x0008 #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_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 #define SR_MUL_MODIFY 0x2000 // 1 = normal. 0 = x2

View File

@ -49,7 +49,7 @@ const char* reg_names[] =
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
NULL, "DSCR", NULL, "DSBL", NULL, "DSPA", "DSMAH", "DSMAL", NULL, "DSCR", NULL, "DSBL", NULL, "DSPA", "DSMAH", "DSMAL",
// d0 // 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, "ACCAH", "ACCAL", "PRED_SCALE", "YN1", "YN2", "ARAM", "GAIN", NULL,
// e0 // e0
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
@ -72,9 +72,7 @@ u16 gdsp_ifx_regs[256];
void gdsp_ifx_init() void gdsp_ifx_init()
{ {
int i; for (int i = 0; i < 256; i++)
for (i = 0; i < 256; i++)
{ {
gdsp_ifx_regs[i] = 0; gdsp_ifx_regs[i] = 0;
} }
@ -128,14 +126,14 @@ void gdsp_mbox_write_l(u8 mbx, u16 val)
if (mbx == GDSP_MBOX_DSP) 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) 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]; val = gdsp_mbox[mbx][1];
gdsp_mbox[mbx][0] &= ~0x8000; 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 #if WITH_DSP_ON_THREAD
g_CriticalSection.Leave(); g_CriticalSection.Leave();
#endif #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) 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]; *(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); 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) 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]; *(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]; *(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);
} }

View File

@ -139,18 +139,14 @@ bool dsp_dmem_write(u16 addr, u16 val)
return(true); return(true);
} }
u16 dsp_fetch_code()
u16 dsp_fetch_code(void)
{ {
u16 opc = dsp_imem_read(g_dsp.pc); u16 opc = dsp_imem_read(g_dsp.pc);
g_dsp.pc++; g_dsp.pc++;
return(opc); return opc;
} }
u16 dsp_peek_code(void) u16 dsp_peek_code(void)
{ {
return(dsp_imem_read(g_dsp.pc)); return dsp_imem_read(g_dsp.pc);
} }

View File

@ -27,7 +27,7 @@
#include "gdsp_registers.h" #include "gdsp_registers.h"
#include "gdsp_interpreter.h" #include "gdsp_interpreter.h"
// Stacks. The stacks are outside the DSP RAM, in dedicated hardware.
void dsp_reg_stack_push(u8 stack_reg) 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]; 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) 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]]; 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; g_dsp.reg_stack_ptr[stack_reg] &= DSP_STACK_MASK;
} }
void dsp_reg_store_stack(u8 stack_reg, u16 val) void dsp_reg_store_stack(u8 stack_reg, u16 val)
{ {
dsp_reg_stack_push(stack_reg); dsp_reg_stack_push(stack_reg);
g_dsp.r[DSP_REG_ST0 + stack_reg] = val; g_dsp.r[DSP_REG_ST0 + stack_reg] = val;
} }
u16 dsp_reg_load_stack(u8 stack_reg) u16 dsp_reg_load_stack(u8 stack_reg)
{ {
u16 val = g_dsp.r[DSP_REG_ST0 + stack_reg]; u16 val = g_dsp.r[DSP_REG_ST0 + stack_reg];
dsp_reg_stack_pop(stack_reg); dsp_reg_stack_pop(stack_reg);
return(val); return val;
} }

View File

@ -216,6 +216,7 @@ void DSP_DebugBreak()
void dspi_req_dsp_irq() void dspi_req_dsp_irq()
{ {
// Fire an interrupt on the PPC ASAP.
g_dspInitialize.pGenerateDSPInterrupt(); g_dspInitialize.pGenerateDSPInterrupt();
} }
@ -225,27 +226,28 @@ void Initialize(void *init)
g_dspInitialize = *(DSPInitialize*)init; g_dspInitialize = *(DSPInitialize*)init;
g_Config.Load(); g_Config.Load();
gdsp_init(); gdsp_init();
g_dsp.step_counter = 0; g_dsp.step_counter = 0;
g_dsp.cpu_ram = g_dspInitialize.pGetMemoryPointer(0); g_dsp.cpu_ram = g_dspInitialize.pGetMemoryPointer(0);
g_dsp.irq_request = dspi_req_dsp_irq; g_dsp.irq_request = dspi_req_dsp_irq;
gdsp_reset(); gdsp_reset();
if (!gdsp_load_rom(DSP_ROM_FILE)) { if (!gdsp_load_rom(DSP_IROM_FILE)) {
bCanWork = false; 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)) { if (!gdsp_load_coef(DSP_COEF_FILE)) {
bCanWork = false; bCanWork = false;
PanicAlert("Failed loading DSP COEF from " DSP_COEF_FILE); PanicAlert("Failed loading DSP COEF from " DSP_COEF_FILE);
} }
if(!bCanWork) if (!bCanWork)
return; // TODO: Don't let it work return; // TODO: Don't let it work
bIsRunning = true; bIsRunning = true;
g_hDSPThread = new Common::Thread(dsp_thread, NULL); g_hDSPThread = new Common::Thread(dsp_thread, NULL);
soundStream = AudioCommon::InitSoundStream(); soundStream = AudioCommon::InitSoundStream();
@ -279,25 +281,17 @@ u16 DSP_ReadControlRegister()
u16 DSP_ReadMailboxHigh(bool _CPUMailbox) u16 DSP_ReadMailboxHigh(bool _CPUMailbox)
{ {
if (_CPUMailbox) if (_CPUMailbox)
{ return gdsp_mbox_read_h(GDSP_MBOX_CPU);
return(gdsp_mbox_read_h(GDSP_MBOX_CPU));
}
else else
{ return gdsp_mbox_read_h(GDSP_MBOX_DSP);
return(gdsp_mbox_read_h(GDSP_MBOX_DSP));
}
} }
u16 DSP_ReadMailboxLow(bool _CPUMailbox) u16 DSP_ReadMailboxLow(bool _CPUMailbox)
{ {
if (_CPUMailbox) if (_CPUMailbox)
{ return gdsp_mbox_read_l(GDSP_MBOX_CPU);
return(gdsp_mbox_read_l(GDSP_MBOX_CPU));
}
else else
{ return gdsp_mbox_read_l(GDSP_MBOX_DSP);
return(gdsp_mbox_read_l(GDSP_MBOX_DSP));
}
} }
void DSP_WriteMailboxHigh(bool _CPUMailbox, u16 _uHighMail) 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); u32 uAddress = gdsp_mbox_peek(GDSP_MBOX_CPU);
u16 errpc = g_dsp.err_pc; 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 // I couldn't find any better way to detect the AX mails so this had to
// do. Please feel free to change it. // do. Please feel free to change it.