DSPSpy can now dump all microcodes in a press of a button (2 on the Wii). Please test this

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3407 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
XTra.KrazzY 2009-06-12 10:46:22 +00:00
parent aeb7053230
commit c4632fe345
2 changed files with 101 additions and 69 deletions

View File

@ -193,7 +193,7 @@ void gdsp_idma_in(u16 dsp_addr, u32 addr, u32 size)
UnWriteProtectMemory(g_dsp.iram, DSP_IRAM_BYTE_SIZE, false);
u8* dst = ((u8*)g_dsp.iram);
for (int i = 0; i < size; i += 2)
for (int i = 0; i < (int)size; i += 2)
{
// TODO : this may be different on Wii.
*(u16*)&dst[dsp_addr + i] = Common::swap16(*(const u16*)&g_dsp.cpu_ram[(addr + i) & 0x0fffffff]);

View File

@ -118,6 +118,11 @@ char last_message[20] = "OK";
RealDSP real_dsp;
// Currently running microcode
int curUcode = 0, runningUcode = 1;
int dsp_steps = 0;
// When comparing regs, ignore the loop stack registers.
bool regs_equal(int reg, u16 value1, u16 value2) {
if (reg >= DSP_REG_ST0 && reg <= DSP_REG_ST3)
@ -267,69 +272,8 @@ void ui_pad_edit_reg(void)
#endif
}
void init_video(void)
void handle_dsp_mail(void)
{
VIDEO_Init();
switch (VIDEO_GetCurrentTvMode())
{
case VI_NTSC:
rmode = &TVNtsc480IntDf;
break;
case VI_PAL:
rmode = &TVPal528IntDf;
break;
case VI_MPAL:
rmode = &TVMpal480IntDf;
break;
default:
rmode = &TVNtsc480IntDf;
break;
}
xfb = SYS_AllocateFramebuffer(rmode);
VIDEO_Configure(rmode);
VIDEO_SetNextFramebuffer(xfb);
VIDEO_SetBlack(FALSE);
VIDEO_Flush();
VIDEO_WaitVSync();
}
int main()
{
init_video();
CON_Init(xfb, 20, 64, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * 2);
ui_mode = UIM_SEL;
dspbufP = (u16 *)MEM_VIRTUAL_TO_PHYSICAL(dspbuffer);
dspbufC = dspbuffer;
dspbufU = (u32 *)(MEM_K0_TO_K1(dspbuffer));
DCInvalidateRange(dspbuffer, 0x2000);
for (int j = 0; j < 0x800; j++)
dspbufU[j] = 0xffffffff;
// Initialize DSP.
real_dsp.Init();
// Initialize FAT so we can write to SD.
fatInit(8, false);
// Both GC and Wii controls.
PAD_Init();
#ifdef HW_RVL
WPAD_Init();
#endif
// Currently running microcode
int curUcode = 0, runningUcode = 1;
int dsp_steps = 0;
int show_step = 0;
while (true)
{
// Should put a loop around this too.
if (DSP_CheckMailFrom())
{
@ -379,6 +323,108 @@ int main()
CON_Printf(2, 1, "UCode: %d/%d, Last mail: %08x", runningUcode, NUM_UCODES, mail);
}
}
void dump_all_ucodes(void)
{
char filename[260] = {0};
for(int i = 0; i < NUM_UCODES; i++)
{
// First, change the microcode
dsp_steps = 0;
curUcode = i;
runningUcode = 0;
DCInvalidateRange(dspbufC, 0x2000);
DCFlushRange(dspbufC, 0x2000);
real_dsp.Reset();
VIDEO_WaitVSync();
while(runningUcode != (curUcode + 1))
handle_dsp_mail();
// Then write microcode dump to file
sprintf(filename, "sd:/dsp_dump%d.bin", i + 1);
FILE *f = fopen(filename, "wb");
if (f)
{
// First write initial regs
fwrite(dspreg_in, 1, 32 * 2, f);
// Then write all the dumps.
fwrite(dspreg_out, 1, dsp_steps * 32 * 2, f);
fclose(f);
strcpy(last_message, "Dump Successful.");
}
else
{
strcpy(last_message, "SD Write Error");
break;
}
}
}
void init_video(void)
{
VIDEO_Init();
switch (VIDEO_GetCurrentTvMode())
{
case VI_NTSC:
rmode = &TVNtsc480IntDf;
break;
case VI_PAL:
rmode = &TVPal528IntDf;
break;
case VI_MPAL:
rmode = &TVMpal480IntDf;
break;
default:
rmode = &TVNtsc480IntDf;
break;
}
xfb = SYS_AllocateFramebuffer(rmode);
VIDEO_Configure(rmode);
VIDEO_SetNextFramebuffer(xfb);
VIDEO_SetBlack(FALSE);
VIDEO_Flush();
VIDEO_WaitVSync();
}
int main()
{
init_video();
CON_Init(xfb, 20, 64, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * 2);
ui_mode = UIM_SEL;
dspbufP = (u16 *)MEM_VIRTUAL_TO_PHYSICAL(dspbuffer);
dspbufC = dspbuffer;
dspbufU = (u32 *)(MEM_K0_TO_K1(dspbuffer));
DCInvalidateRange(dspbuffer, 0x2000);
for (int j = 0; j < 0x800; j++)
dspbufU[j] = 0xffffffff;
// Initialize DSP.
real_dsp.Init();
// Initialize FAT so we can write to SD.
fatInit(8, false);
// Both GC and Wii controls.
PAD_Init();
#ifdef HW_RVL
WPAD_Init();
#endif
int show_step = 0;
while (true)
{
handle_dsp_mail();
VIDEO_WaitVSync();
@ -496,21 +542,7 @@ int main()
// Probably could offer to save to memcard (sd gecko) but i dont have one so meh
if (WPAD_ButtonsDown(0) & WPAD_BUTTON_2)
{
FILE *f = fopen("sd:/dsp_dump.bin", "wb");
if (f)
{
// First write initial regs
fwrite(dspreg_in, 1, 32 * 2, f);
// Then write all the dumps.
fwrite(dspreg_out, 1, dsp_steps * 32 * 2, f);
fclose(f);
strcpy(last_message, "Dump Successful.");
}
else
{
strcpy(last_message, "SD Write Error");
}
dump_all_ucodes();
}
#endif
}