dsp stuff - the same ucode hash under lle and hle now (had to rename couple of dissasms), ucode dumping under hle (debug only), small dsp:read32 change (needed for some homebrew)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6059 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Marko Pusljar 2010-08-05 17:00:32 +00:00
parent ca9c174450
commit 8dc01b685f
9 changed files with 60 additions and 42 deletions

View File

@ -497,6 +497,7 @@ void Write16(const u16 _Value, const u32 _Address)
void Read32(u32& _uReturnValue, const u32 _iAddress)
{
INFO_LOG(DSPINTERFACE, "DSPInterface(r32) 0x%08x", _iAddress);
switch (_iAddress & 0xFFFF)
{
// DSP
@ -504,6 +505,24 @@ void Read32(u32& _uReturnValue, const u32 _iAddress)
_uReturnValue = (dsp_plugin->DSP_ReadMailboxHigh(true) << 16) | dsp_plugin->DSP_ReadMailboxLow(true);
break;
// AI
case AUDIO_DMA_START_HI:
_uReturnValue = g_audioDMA.SourceAddress;
break;
// ARAM
case AR_DMA_ARADDR_H:
_uReturnValue = g_arDMA.ARAddr;
break;
case AR_DMA_CNT_H:
_uReturnValue = g_arDMA.Cnt.Hex;
break;
case AR_DMA_MMADDR_H:
_uReturnValue = g_arDMA.MMAddr;
break;
default:
_dbg_assert_(DSPINTERFACE,0);
break;

View File

@ -62,23 +62,23 @@ void CUCode_Rom::HandleMail(u32 _uMail)
break;
case 0x80F3A002:
m_CurrentUCode.m_Length = _uMail;
m_CurrentUCode.m_Length = _uMail & 0xffff;
break;
case 0x80F3C002:
m_CurrentUCode.m_IMEMAddress = _uMail;
m_CurrentUCode.m_IMEMAddress = _uMail & 0xffff;
break;
case 0x80F3B002:
m_CurrentUCode.m_DMEMLength = _uMail;
if (_uMail) {
NOTICE_LOG(DSPHLE,"Game wanted to DMA sth to DSP DRAM.");
m_CurrentUCode.m_DMEMLength = _uMail & 0xffff;
if (m_CurrentUCode.m_DMEMLength) {
NOTICE_LOG(DSPHLE,"m_CurrentUCode.m_DMEMLength = 0x%04x.", m_CurrentUCode.m_DMEMLength);
}
break;
case 0x80F3D001:
{
m_CurrentUCode.m_StartPC = _uMail;
m_CurrentUCode.m_StartPC = _uMail & 0xffff;
BootUCode();
return; // Important! BootUCode indirectly does "delete this;". Must exit immediately.
}
@ -99,6 +99,18 @@ void CUCode_Rom::BootUCode()
(u8*)Memory_Get_Pointer(m_CurrentUCode.m_RAMAddress),
m_CurrentUCode.m_Length);
#if defined(_DEBUG) || defined(DEBUGFAST)
char binFile[MAX_PATH];
sprintf(binFile, "%sDSP_UC_%08X.bin", File::GetUserPath(D_DUMPDSP_IDX), ector_crc);
FILE* pFile = fopen(binFile, "wb");
if (pFile)
{
fwrite((u8*)Memory_Get_Pointer(m_CurrentUCode.m_RAMAddress), m_CurrentUCode.m_Length, 1, pFile);
fclose(pFile);
}
#endif
DEBUG_LOG(DSPHLE, "CurrentUCode SOURCE Addr: 0x%08x", m_CurrentUCode.m_RAMAddress);
DEBUG_LOG(DSPHLE, "CurrentUCode Length: 0x%08x", m_CurrentUCode.m_Length);
DEBUG_LOG(DSPHLE, "CurrentUCode DEST Addr: 0x%08x", m_CurrentUCode.m_IMEMAddress);

View File

@ -147,6 +147,18 @@ void IUCode::PrepareBootUCode(u32 mail)
(u8*)Memory_Get_Pointer(m_NextUCode.iram_mram_addr),
m_NextUCode.iram_size);
#if defined(_DEBUG) || defined(DEBUGFAST)
char binFile[MAX_PATH];
sprintf(binFile, "%sDSP_UC_%08X.bin", File::GetUserPath(D_DUMPDSP_IDX), ector_crc);
FILE* pFile = fopen(binFile, "wb");
if (pFile)
{
fwrite((u8*)Memory_Get_Pointer(m_NextUCode.iram_mram_addr), m_NextUCode.iram_size, 1, pFile);
fclose(pFile);
}
#endif
DEBUG_LOG(DSPHLE, "PrepareBootUCode 0x%08x", ector_crc);
DEBUG_LOG(DSPHLE, "DRAM -> MRAM: src %04x dst %08x size %04x",
m_NextUCode.mram_dram_addr, m_NextUCode.mram_dest_addr,

View File

@ -65,20 +65,16 @@ void DSPHost_InterruptRequest()
u32 DSPHost_CodeLoaded(const u8 *ptr, int size)
{
u32 crc = GenerateCRC(ptr, size);
u32 ector_crc = HashEctor(ptr, size);
#if defined(_DEBUG) || defined(DEBUGFAST)
DumpDSPCode(ptr, size, crc);
DumpDSPCode(ptr, size, ector_crc);
#endif
// HLE plugin uses this crc method
u32 ector_crc = HashEctor(ptr, size);
DSPSymbols::Clear();
// Auto load text file - if none just disassemble.
// TODO: Don't hardcode for Zelda.
NOTICE_LOG(DSPLLE, "ector_crc: %08x", ector_crc);
DSPSymbols::Clear();
@ -87,12 +83,14 @@ u32 DSPHost_CodeLoaded(const u8 *ptr, int size)
{
case 0x86840740: success = DSPSymbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_Zelda.txt"); break;
case 0x42f64ac4: success = DSPSymbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_Luigi.txt"); break;
case 0x07f88145: success = DSPSymbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_4CB8233B.txt"); break;
case 0x3ad3b7ac: success = DSPSymbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_8A7A05E2.txt"); break;
case 0x3daf59b9: success = DSPSymbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_D9D066EA.txt"); break;
case 0x4e8a8b21: success = DSPSymbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_6A696CE7.txt"); break;
case 0xe2136399: success = DSPSymbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_EB79C705.txt"); break;
case 0xdd7e72d5: success = DSPSymbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_3B3B30CA.txt"); break;
case 0x07f88145: success = DSPSymbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_AX_07F88145.txt"); break;
case 0x3ad3b7ac: success = DSPSymbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_AX_3AD3B7AC.txt"); break;
case 0x3daf59b9: success = DSPSymbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_AX_3DAF59B9.txt"); break;
case 0x4e8a8b21: success = DSPSymbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_AX_4E8A8B21.txt"); break;
case 0xe2136399: success = DSPSymbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_AX_E2136399.txt"); break;
case 0xdd7e72d5: success = DSPSymbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_GBA.txt"); break;
case 0x347112BA: success = DSPSymbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_AXWii.txt"); break;
case 0xD643001F: success = DSPSymbols::ReadAnnotatedAssembly("../../docs/DSP/DSP_UC_SuperMarioGalaxy.txt"); break;
default: success = false; break;
}
@ -106,7 +104,7 @@ u32 DSPHost_CodeLoaded(const u8 *ptr, int size)
if (m_DebuggerFrame)
m_DebuggerFrame->Refresh();
#endif
return crc;
return ector_crc;
}
void DSPHost_UpdateDebugger()

View File

@ -67,28 +67,6 @@ bool DumpDSPCode(const u8 *code_be, int size_in_bytes, u32 crc)
return File::WriteStringToFile(true, text, txtFile);
}
u32 GenerateCRC(const unsigned char* _pBuffer, int _pLength)
{
unsigned long CRC = 0xFFFFFFFF;
while (_pLength--)
{
unsigned long Temp = (unsigned long)((CRC & 0xFF) ^ *_pBuffer++);
for (int j = 0; j < 8; j++)
{
if (Temp & 0x1)
Temp = (Temp >> 1) ^ 0xEDB88320;
else
Temp >>= 1;
}
CRC = (CRC >> 8) ^ Temp;
}
return CRC ^ 0xFFFFFFFF;
}
// TODO make this useful :p
bool DumpCWCode(u32 _Address, u32 _Length)
{

View File

@ -19,7 +19,6 @@
#define _DSPLLE_TOOLS_H
bool DumpDSPCode(const u8 *code_be, int size_in_bytes, u32 crc);
u32 GenerateCRC(const unsigned char* _pBuffer, int _pLength);
bool DumpCWCode(u32 _Address, u32 _Length);
#endif //_DSPLLE_TOOLS_H