some HLE LLE stuff :)

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@837 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
fires.gc 2008-10-11 08:43:50 +00:00
parent 4d93e126de
commit f9bd977ffd
15 changed files with 146 additions and 66 deletions

View File

@ -79,7 +79,7 @@ void dsp_op_ext_s(uint16 _Opcode)
uint8 dreg = _Opcode & 0x3;
uint8 sreg = ((_Opcode >> 3) & 0x3) + 0x1c;
OutBuffer::AddCode("*(%s) = %s", OutBuffer::GetRegName(dreg), OutBuffer::GetRegName(sreg));
OutBuffer::AddCode("WriteDMEM(%s, %s)", OutBuffer::GetRegName(dreg), OutBuffer::GetRegName(sreg));
// dsp_dmem_write(g_dsp.r[dreg], g_dsp.r[sreg]);
if (_Opcode & 0x04)
@ -100,7 +100,7 @@ void dsp_op_ext_l(uint16 _Opcode)
uint8 sreg = _Opcode & 0x3;
uint8 dreg = ((_Opcode >> 3) & 0x7) + 0x18;
OutBuffer::AddCode("%s = *(%s)", OutBuffer::GetRegName(dreg), OutBuffer::GetRegName(sreg));
OutBuffer::AddCode("%s = ReadDMEM(%s)", OutBuffer::GetRegName(dreg), OutBuffer::GetRegName(sreg));
// uint16 val = dsp_dmem_read(g_dsp.r[sreg]);
// g_dsp.r[dreg] = val;
@ -121,7 +121,7 @@ void dsp_op_ext_ls_pro(uint16 _Opcode)
{
uint8 areg = (_Opcode & 0x1) + 0x1e;
OutBuffer::AddCode("*(%s) = %s", OutBuffer::GetRegName(0x03), OutBuffer::GetRegName(areg));
OutBuffer::AddCode("WriteDMEM(%s, %s)", OutBuffer::GetRegName(0x03), OutBuffer::GetRegName(areg));
// dsp_dmem_write(g_dsp.r[0x03], g_dsp.r[areg]);
if (_Opcode & 0x8)
@ -141,7 +141,7 @@ void dsp_op_ext_ls_epi(uint16 _Opcode)
{
uint8 dreg = ((_Opcode >> 4) & 0x3) + 0x18;
OutBuffer::AddCode("%s = *(%s)", OutBuffer::GetRegName(dreg), OutBuffer::GetRegName(0x00));
OutBuffer::AddCode("%s = ReadDMEM(%s)", OutBuffer::GetRegName(dreg), OutBuffer::GetRegName(0x00));
// uint16 val = dsp_dmem_read(g_dsp.r[0x00]);
// dsp_op_write_reg(dreg, val);
@ -162,7 +162,7 @@ void dsp_op_ext_sl_pro(uint16 _Opcode)
{
uint8 areg = (_Opcode & 0x1) + 0x1e;
OutBuffer::AddCode("*(%s) = %s", OutBuffer::GetRegName(0x00), OutBuffer::GetRegName(areg));
OutBuffer::AddCode("WriteDMEM(%s, %s)", OutBuffer::GetRegName(0x00), OutBuffer::GetRegName(areg));
// dsp_dmem_write(g_dsp.r[0x00], g_dsp.r[areg]);
if (_Opcode & 0x4)
@ -182,7 +182,7 @@ void dsp_op_ext_sl_epi(uint16 _Opcode)
{
uint8 dreg = ((_Opcode >> 4) & 0x3) + 0x18;
OutBuffer::AddCode("%s = *(%s)", OutBuffer::GetRegName(dreg), OutBuffer::GetRegName(0x03));
OutBuffer::AddCode("%s = ReadDMEM(%s)", OutBuffer::GetRegName(dreg), OutBuffer::GetRegName(0x03));
// uint16 val = dsp_dmem_read(g_dsp.r[0x03]);
// dsp_op_write_reg(dreg, val);
@ -205,8 +205,8 @@ void dsp_op_ext_ld(uint16 _Opcode)
uint8 dreg2 = (((_Opcode >> 4) & 0x1) << 1) + 0x19;
uint8 sreg = _Opcode & 0x3;
OutBuffer::AddCode("%s = *(%s)", OutBuffer::GetRegName(dreg1), OutBuffer::GetRegName(sreg));
OutBuffer::AddCode("%s = *(%s)", OutBuffer::GetRegName(dreg2), OutBuffer::GetRegName(0x03));
OutBuffer::AddCode("%s = ReadDMEM(%s)", OutBuffer::GetRegName(dreg1), OutBuffer::GetRegName(sreg));
OutBuffer::AddCode("%s = ReadDMEM(%s)", OutBuffer::GetRegName(dreg2), OutBuffer::GetRegName(0x03));
// g_dsp.r[dreg1] = dsp_dmem_read(g_dsp.r[sreg]);
// g_dsp.r[dreg2] = dsp_dmem_read(g_dsp.r[0x03]);

View File

@ -318,7 +318,7 @@ void dsp_opc_lrr(uint16 opc)
uint8 sreg = (opc >> 5) & 0x3;
uint8 dreg = opc & 0x1f;
OutBuffer::AddCode("%s = *(%s)", OutBuffer::GetRegName(dreg), OutBuffer::GetRegName(sreg));
OutBuffer::AddCode("%s = ReadDMEM(%s)", OutBuffer::GetRegName(dreg), OutBuffer::GetRegName(sreg));
// uint16 val = dsp_dmem_read(g_dsp.r[sreg]);
// dsp_op_write_reg(dreg, val);
@ -352,7 +352,7 @@ void dsp_opc_srr(uint16 opc)
uint8 dreg = (opc >> 5) & 0x3;
uint8 sreg = opc & 0x1f;
OutBuffer::AddCode("*(%s) = %s", OutBuffer::GetRegName(dreg), OutBuffer::GetRegName(sreg));
OutBuffer::AddCode("WriteDMEM(%s, %s)", OutBuffer::GetRegName(dreg), OutBuffer::GetRegName(sreg));
//uint16 val = dsp_op_read_reg(sreg);
// dsp_dmem_write(g_dsp.r[dreg], val);
@ -1177,7 +1177,7 @@ void dsp_opc_asr16(uint16 opc)
uint8 areg = (opc >> 11) & 0x1;
OutBuffer::AddCode("ACC%i >>= 16", areg);
OutBuffer::AddCode("Update_SR_Register(AC%i)", areg);
OutBuffer::AddCode("Update_SR_Register(ACC%i)", areg);
//sint64 acc = dsp_get_long_acc(areg);
//acc >>= 16;
@ -1885,14 +1885,14 @@ void dsp_op2(uint16 opc)
if (opc & 0x0800)
{
OutBuffer::AddCode("*(%s) = %s", OutBuffer::GetMemName(addr), OutBuffer::GetRegName(reg));
OutBuffer::AddCode("WriteDMEM(%s, %s)", OutBuffer::GetMemName(addr), OutBuffer::GetRegName(reg));
// srs
// dsp_dmem_write(addr, g_dsp.r[reg]);
}
else
{
OutBuffer::AddCode("%s = *(%s)", OutBuffer::GetRegName(reg), OutBuffer::GetMemName(addr));
OutBuffer::AddCode("%s = ReadDMEM(%s)", OutBuffer::GetRegName(reg), OutBuffer::GetMemName(addr));
// lrs
// g_dsp.r[reg] = dsp_dmem_read(addr);

View File

@ -26,7 +26,7 @@ void Decode(uint16 startAddress, uint16 endAddress)
uint16 oldPC = g_currentAddress;
uint16 op = FetchOpcode();
OutBuffer::Add("%4X:", oldPC);
OutBuffer::Add("l_%4X:", oldPC);
DecodeOpcode(op);
}
}

View File

@ -35,7 +35,7 @@ namespace OutBuffer
vsprintf(Msg, _fmt, ap);
va_end(ap);
printf(" %s\n", Msg);
printf(" %s;\n", Msg);
}
// predefined labels
@ -68,18 +68,18 @@ namespace OutBuffer
{0x11, "ACH1", "Accumulator High 1",},
{0x12, "CR", "Config Register",},
{0x13, "SR", "Special Register",},
{0x14, "PROD.L", "PROD L",},
{0x15, "PROD.M1", "PROD M1",},
{0x16, "PROD.H", "PROD H",},
{0x17, "PROD.M2", "PROD M2",},
{0x18, "AX0.L", "Additional Accumulators Low 0",},
{0x19, "AX1.L", "Additional Accumulators Low 1",},
{0x1a, "AX0.H", "Additional Accumulators High 0",},
{0x1b, "AX1.H", "Additional Accumulators High 1",},
{0x1c, "AC0.L", "Register 28",},
{0x1d, "AC1.L", "Register 29",},
{0x1e, "AC0.M", "Register 00",},
{0x1f, "AC1.M", "Register 00",},
{0x14, "PROD_l", "PROD L",},
{0x15, "PROD_m1", "PROD M1",},
{0x16, "PROD_h", "PROD H",},
{0x17, "PROD_m2", "PROD M2",},
{0x18, "AX0_l", "Additional Accumulators Low 0",},
{0x19, "AX1_l", "Additional Accumulators Low 1",},
{0x1a, "AX0_h", "Additional Accumulators High 0",},
{0x1b, "AX1_h", "Additional Accumulators High 1",},
{0x1c, "AC0_l", "Register 28",},
{0x1d, "AC1_l", "Register 29",},
{0x1e, "AC0_m", "Register 00",},
{0x1f, "AC1_m", "Register 00",},
// additional to resolve special names
{0x20, "ACC0", "Accumulators 0",},

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Version="9,00"
Name="Plugin_DSP_HLE"
ProjectGUID="{D6E56527-BBB9-4EAD-A6EC-49D4BF6AFCD8}"
RootNamespace="Plugin_DSP"

View File

@ -31,7 +31,13 @@ struct PBMixer
struct PBInitialTimeDelay
{
u16 unknown[7];
u16 on;
u16 addrMemHigh;
u16 addrMemLow;
u16 offsetLeft;
u16 offsetRight;
u16 targetLeft;
u16 targetRight;
};
// Update data - read these each 1ms subframe and use them!
@ -76,7 +82,7 @@ struct PBAudioAddr
struct PBADPCMInfo
{
s16 coefs[16];
u16 unknown;
u16 gain;
u16 pred_scale;
s16 yn1;
s16 yn2;
@ -112,17 +118,17 @@ struct AXParamBlock
u16 running; // 1=RUN 0=STOP
u16 is_stream; // 1 = stream, 0 = one shot
PBMixer mixer;
PBInitialTimeDelay initial_time_delay;
PBUpdates updates;
PBUnknown unknown2;
PBVolumeEnvelope vol_env;
PBUnknown2 unknown3;
PBAudioAddr audio_addr;
PBADPCMInfo adpcm;
PBSampleRateConverter src;
PBADPCMLoopInfo adpcm_loop_info;
u16 unknown_maybe_padding[3];
/* 9 */ PBMixer mixer;
/* 27 */ PBInitialTimeDelay initial_time_delay;
/* 34 */ PBUpdates updates;
/* 41 */ PBUnknown unknown2;
/* 50 */ PBVolumeEnvelope vol_env;
/* 52 */ PBUnknown2 unknown3;
/* 55 */ PBAudioAddr audio_addr;
/* 63 */ PBADPCMInfo adpcm;
/* 83 */ PBSampleRateConverter src;
/* 90 */ PBADPCMLoopInfo adpcm_loop_info;
/* 93 */ u16 unknown_maybe_padding[3];
};
enum {

View File

@ -747,6 +747,14 @@
>
</File>
</Filter>
<Filter
Name="HLE"
>
<File
RelativePath=".\Src\HLE_Functions.cpp"
>
</File>
</Filter>
<File
RelativePath=".\Src\DSoundStream.cpp"
>

View File

@ -21,8 +21,9 @@
#include "pluginspecs_dsp.h"
#include <stdio.h>
#define WITH_DSP_ON_THREAD 1
#define DUMP_DSP_IMEM 0
#define WITH_DSP_ON_THREAD 1
#define DUMP_DSP_IMEM 0
#define PROFILE 1
extern DSPInitialize g_dspInitialize;
void DebugLog(const char* _fmt, ...);

View File

@ -23,9 +23,11 @@
#include "gdsp_interpreter.h"
bool DumpDSPCode(uint32 _Address, uint32 _Length)
bool DumpDSPCode(uint32 _Address, uint32 _Length, uint32 crc)
{
FILE* pFile = fopen("d:\\DSP_UCode.bin", "wb");
char szFilename[MAX_PATH];
sprintf(szFilename, "c:\\_\\DSP_UC_%08X.bin", crc);
FILE* pFile = fopen(szFilename, "wb");
if (pFile != NULL)
{
@ -33,6 +35,10 @@ bool DumpDSPCode(uint32 _Address, uint32 _Length)
fclose(pFile);
return(true);
}
else
{
PanicAlert("Cant open file (%s) to dump UCode!!", szFilename);
}
return(false);
}

View File

@ -45,6 +45,6 @@ union UDSPControl
};
bool DumpDSPCode(uint32 _Address, uint32 _Length);
bool DumpDSPCode(uint32 _Address, uint32 _Length, uint32 crc);
uint32 GenerateCRC(const unsigned char* _pBuffer, int _pLength);
bool DumpCWCode(uint32 _Address, uint32 _Length);

View File

@ -74,6 +74,9 @@ const pdlabel_t pdlabels[] =
{0xffce, "DSMAH", "DSP DMA Mem Address H",},
{0xffcf, "DSMAL", "DSP DMA Mem Address L",},
{0xffd1, "SampleFormat", "SampleFormat",},
{0xffd3, "Unk Zelda", "Unk Zelda writes to it",},
{0xffd4, "ACSAH", "Accelerator start address H",},
{0xffd5, "ACSAL", "Accelerator start address L",},
{0xffd6, "ACEAH", "Accelerator end address H",},

View File

@ -251,10 +251,6 @@ uint16 gdsp_ifx_read(uint16 addr)
void gdsp_idma_in(uint16 dsp_addr, uint32 addr, uint32 size)
{
#if DUMP_DSP_IMEM
DumpDSPCode(addr, size);
#endif
uint8* dst = ((uint8*)g_dsp.iram);
for (uint32 i = 0; i < size; i += 2)
@ -264,6 +260,10 @@ void gdsp_idma_in(uint16 dsp_addr, uint32 addr, uint32 size)
g_dsp.iram_crc = GenerateCRC(g_dsp.cpu_ram + (addr & 0x0fffffff), size);
DebugLog("*** Copy new UCode from 0x%08x to 0x%04x (crc: %8x)\n", addr, dsp_addr, g_dsp.iram_crc);
#if DUMP_DSP_IMEM
DumpDSPCode(addr, size, g_dsp.iram_crc );
#endif
}

View File

@ -220,12 +220,19 @@ void gdsp_loop_step()
dsp_op[opc >> 12](opc);
}
void Hacks();
u16 HLE_ROM_80E7_81F8();
void hacks();
void gdsp_step()
{
g_dsp.step_counter++;
if (g_dsp.pc == 0x80e7)
{
g_dsp.pc = HLE_ROM_80E7_81F8();
}
g_dsp.err_pc = g_dsp.pc;
uint16 opc = dsp_fetch_code();
dsp_op[opc >> 12](opc);

View File

@ -403,28 +403,28 @@ void dsp_opc_lrr(uint16 opc)
void dsp_opc_srr(uint16 opc)
{
uint8 sreg = (opc >> 5) & 0x3;
uint8 dreg = opc & 0x1f;
uint8 dreg = (opc >> 5) & 0x3;
uint8 sreg = opc & 0x1f;
uint16 val = dsp_op_read_reg(dreg);
dsp_dmem_write(g_dsp.r[sreg], val);
uint16 val = dsp_op_read_reg(sreg);
dsp_dmem_write(g_dsp.r[dreg], val);
// post processing of source reg
// post processing of dest reg
switch ((opc >> 7) & 0x3)
{
case 0x0: // SRR
break;
case 0x1: // SRRD
g_dsp.r[sreg]--;
g_dsp.r[dreg]--;
break;
case 0x2: // SRRI
g_dsp.r[sreg]++;
g_dsp.r[dreg]++;
break;
case 0x3: // SRRX
g_dsp.r[sreg] += g_dsp.r[sreg + 4];
g_dsp.r[dreg] += g_dsp.r[dreg + 4];
break;
}
}
@ -530,7 +530,14 @@ void dsp_opc_clrp(uint16 opc)
// NEW
void dsp_opc_mulc(uint16 opc)
{
ErrorLog("dsp_opc_mulc ni");
// math new prod
uint8 sreg = (opc >> 11) & 0x1;
uint8 treg = (opc >> 12) & 0x1;
sint64 prod = dsp_get_acc_m(sreg) * dsp_get_ax_h(treg) * GetMultiplyModifier();
dsp_set_long_prod(prod);
Update_SR_Register(prod);
}
@ -1023,6 +1030,17 @@ void dsp_opc_subr(uint16 opc)
Update_SR_Register(acc);
}
// NEW
void dsp_opc_subax(uint16 opc)
{
int regD = (opc >> 8) & 0x1;
int regT = (opc >> 9) & 0x1;
sint64 Acc = dsp_get_long_acc(regD) - dsp_get_long_acx(regT);
dsp_set_long_acc(regD, Acc);
Update_SR_Register(Acc);
}
void dsp_opc_addis(uint16 opc)
{
@ -1248,12 +1266,24 @@ void dsp_opc_mul(uint16 opc)
sint64 prod = (sint64)dsp_get_ax_h(sreg) * (sint64)dsp_get_ax_l(sreg) * GetMultiplyModifier();
dsp_set_long_prod(prod);
Update_SR_Register(prod);
}
// NEW
void dsp_opc_mulac(uint16 opc)
{
ErrorLog("Not implemented dsp_opc_mulac() (pc:0x%04x)\n", g_dsp.err_pc);
// add old prod to acc
uint8 rreg = (opc >> 8) & 0x1;
sint64 acR = dsp_get_long_acc(rreg) + dsp_get_long_prod();
dsp_set_long_acc(rreg, acR);
// math new prod
uint8 sreg = (opc >> 11) & 0x1;
sint64 prod = dsp_get_ax_l(sreg) * dsp_get_ax_h(sreg) * GetMultiplyModifier();
dsp_set_long_prod(prod);
Update_SR_Register(prod);
}
@ -1272,6 +1302,8 @@ void dsp_opc_mulmv(uint16 opc)
prod = val1 * val2 * GetMultiplyModifier();
dsp_set_long_prod(prod);
Update_SR_Register(prod);
}
@ -1289,6 +1321,8 @@ void dsp_opc_mulmvz(uint16 opc)
// math prod
prod = (sint64)g_dsp.r[0x18 + sreg] * (sint64)g_dsp.r[0x1a + sreg] * GetMultiplyModifier();
dsp_set_long_prod(prod);
Update_SR_Register(prod);
}
@ -1303,6 +1337,8 @@ void dsp_opc_mulx(uint16 opc)
sint64 prod = val1 * val2 * GetMultiplyModifier();
dsp_set_long_prod(prod);
Update_SR_Register(prod);
}
@ -1323,6 +1359,8 @@ void dsp_opc_mulxac(uint16 opc)
sint64 prod = val1 * val2 * GetMultiplyModifier();
dsp_set_long_prod(prod);
Update_SR_Register(prod);
}
@ -1343,6 +1381,8 @@ void dsp_opc_mulxmv(uint16 opc)
sint64 prod = val1 * val2 * GetMultiplyModifier();
dsp_set_long_prod(prod);
Update_SR_Register(prod);
}
@ -1364,6 +1404,8 @@ void dsp_opc_mulxmvz(uint16 opc)
prod = val1 * val2 * GetMultiplyModifier();
dsp_set_long_prod(prod);
Update_SR_Register(prod);
}
@ -1836,13 +1878,20 @@ void dsp_op5(uint16 opc)
dsp_opc_subr(opc);
break;
case 0x8:
case 0x9:
case 0xa:
case 0xb:
dsp_opc_subax(opc);
break;
case 0xc:
case 0xd:
dsp_opc_sub(opc);
break;
default:
ErrorLog("dsp_op5");
ErrorLog("dsp_op5: %x", (opc >> 8) & 0xf);
break;
}

View File

@ -258,10 +258,10 @@ void DSP_Initialize(DSPInitialize _dspInitialize)
// --------------
// Dump UCode to file...
/* FILE* t = fopen("C:\\_\\ct.txt", "wb");
FILE* t = fopen("C:\\_\\DSP_UC_09CD143F.txt", "wb");
gd_globals_t gdg;
gd_dis_file(&gdg, "C:\\_\\DSP_UCode.bin", t);
fclose(t); */
gd_dis_file(&gdg, "C:\\_\\DSP_UC_09CD143F.bin", t);
fclose(t);
// --------------
#ifdef _WIN32