changed exception behavior a little bit

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@813 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
fires.gc 2008-10-09 20:17:10 +00:00
parent d4f8f0d3ae
commit 12d3810203
4 changed files with 128 additions and 43 deletions

View File

@ -179,6 +179,9 @@ int CALLBACK CDisAsmDlg::CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lPar
void CDisAsmDlg::RebuildDisAsmListView() void CDisAsmDlg::RebuildDisAsmListView()
{ {
if (!m_DisAsmListViewCtrl.IsWindow())
return;
m_DisAsmListViewCtrl.ShowWindow(SW_HIDE); m_DisAsmListViewCtrl.ShowWindow(SW_HIDE);
m_DisAsmListViewCtrl.DeleteAllItems(); m_DisAsmListViewCtrl.DeleteAllItems();

View File

@ -63,7 +63,7 @@ sint16 ADPCM_Step(uint32& _rSamplePos, uint32 _BaseAddress)
return val; return val;
} }
extern void gdsp_generate_exception(uint8 level);
uint16 dsp_read_aram() uint16 dsp_read_aram()
{ {
// uint32 BaseAddress = (gdsp_ifx_regs[DSP_ACSAH] << 16) | gdsp_ifx_regs[DSP_ACSAL]; // uint32 BaseAddress = (gdsp_ifx_regs[DSP_ACSAH] << 16) | gdsp_ifx_regs[DSP_ACSAL];
@ -99,8 +99,8 @@ uint16 dsp_read_aram()
if (Address > EndAddress) if (Address > EndAddress)
{ {
Address = (gdsp_ifx_regs[DSP_ACSAH] << 16) | gdsp_ifx_regs[DSP_ACSAL]; Address = (gdsp_ifx_regs[DSP_ACSAH] << 16) | gdsp_ifx_regs[DSP_ACSAL];
// ErrorLog("Should we generate a lvl5 exception !??!"); gdsp_generate_exception(3);
// gdsp_exception(5); gdsp_generate_exception(5);
// Somehow, YN1 and YN2 must be initialized with their "loop" values, so yeah, // Somehow, YN1 and YN2 must be initialized with their "loop" values, so yeah,
// it seems likely that we should raise an exception to let the DSP program do that, // it seems likely that we should raise an exception to let the DSP program do that,

View File

@ -138,37 +138,10 @@ void gdsp_reset()
} }
uint8 gdsp_exceptions = 0;
void gdsp_generate_exception(uint8 level) void gdsp_generate_exception(uint8 level)
{ {
_dbg_assert_msg_(!g_dsp.exception_in_progress_hack, "assert while exception"); gdsp_exceptions |= 1 << level;
dsp_reg_store_stack(DSP_STACK_C, g_dsp.pc);
dsp_reg_store_stack(DSP_STACK_D, g_dsp.r[R_SR]);
g_dsp.pc = level * 2;
g_dsp.exception_in_progress_hack = true;
}
uint32 gdsp_exception_ready = 0;
void gdsp_exception(uint8 level)
{
switch (level & 0x7)
{
case 0x5: // ACCA > ACCH exception
if (g_dsp.r[R_SR] & 0x200)
{
gdsp_exception_ready = level;
}
break;
default:
break;
}
} }
@ -247,7 +220,7 @@ void gdsp_loop_step()
dsp_op[opc >> 12](opc); dsp_op[opc >> 12](opc);
} }
void Hacks();
void gdsp_step() void gdsp_step()
{ {
g_dsp.step_counter++; g_dsp.step_counter++;
@ -286,15 +259,33 @@ void gdsp_step()
{ {
if (dsp_SR_is_flag_set(FLAG_ENABLE_INTERUPT) && (g_dsp.exception_in_progress_hack == false)) if (dsp_SR_is_flag_set(FLAG_ENABLE_INTERUPT) && (g_dsp.exception_in_progress_hack == false))
{ {
// level 7 is the interrupt exception
gdsp_generate_exception(7); gdsp_generate_exception(7);
g_dsp.cr &= ~0x0002; g_dsp.cr &= ~0x0002;
UpdateCachedCR(); UpdateCachedCR();
} }
// level 7 is the interrupt exception
gdsp_exception_ready = 7;
} }
// check exceptions
if ((gdsp_exceptions > 0) && (!g_dsp.exception_in_progress_hack))
{
for (uint8 i=0; i<8; i++)
{
if (gdsp_exceptions & (1<<i))
{
_dbg_assert_msg_(!g_dsp.exception_in_progress_hack, "assert while exception");
dsp_reg_store_stack(DSP_STACK_C, g_dsp.pc);
dsp_reg_store_stack(DSP_STACK_D, g_dsp.r[R_SR]);
g_dsp.pc = i * 2;
gdsp_exceptions &= ~(1<<i);
g_dsp.exception_in_progress_hack = true;
break;
}
}
}
} }
@ -340,3 +331,93 @@ void gdsp_stop()
gdsp_running = false; gdsp_running = false;
} }
///////////////////////////////////////////////////////////////////////////////
//
// From fires for fires :)
//
//
#include "disassemble.h"
#include "WaveFile.h"
#include "Mixer.h"
uint16 r30 = 0, r31 = 0;
void PanicAlert(const char* text, ...);
extern WaveFileWriter g_wave_writer;
extern uint16 dsp_swap16(uint16 x);
void Hacks()
{
// if (g_wave_writer.GetAudioSize() > 1024*1024*1)
/* if (g_dsp.pc == 0x165)
{
PanicAlert("Opcode_06");
}
if (g_dsp.pc == 0x43b)
{
PanicAlert("Opcode_14");
}
if (g_dsp.pc == 0xb37)
{
PanicAlert("Opcode_08");
}*/
/* if (g_dsp.pc == 0x1bc)
{
r30 = g_dsp.r[30];
r31 = g_dsp.r[31];
}
else if (g_dsp.pc == 0x384)
{
// if ((r30 == 0x1bc) && (r31 == 0xaff))
{
//PanicAlert("%x, %x", r30, r31);
const int numSamples = 0x280;
static short Buffer[numSamples];
uint16 bufferAddr = 0x280; //dsp_dmem_read(0xe44);
for (int i=0; i<numSamples; i++)
{
Buffer[i] = dsp_dmem_read(bufferAddr+i);
}
g_wave_writer.AddStereoSamples(Buffer, numSamples/2); // 2 channels
if (g_wave_writer.GetAudioSize() > 1024*1024*2)
{
//PanicAlert("%x", bufferAddr);
g_wave_writer.Stop();
exit(1);
}
}
} */
if (g_dsp.pc == 0x468)
{
int numSamples = g_dsp.r[25] / 2;
uint16 bufferAddr = g_dsp.r[27];
// PanicAlert("%x %x", bufferAddr, numSamples);
short samples[1024];
for (int i=0; i<numSamples; i++)
{
samples[i] = dsp_dmem_read(bufferAddr+i);
}
Mixer_PushSamples(samples, numSamples / 2, 32000); //sample_rate);
g_wave_writer.AddStereoSamples(samples, numSamples/2); // 2 channels
if (g_wave_writer.GetAudioSize() > 1024*1024*2)
{
//PanicAlert("%x", bufferAddr);
g_wave_writer.Stop();
exit(1);
}
}
}

View File

@ -66,8 +66,8 @@ bool AXTask(u32& _uMail);
bool bCanWork = false; bool bCanWork = false;
// Set this if you want to log audio. search for log_ai in this file to see the filename. // Set this if you want to log audio. search for log_ai in this file to see the filename.
static bool log_ai = false; static bool log_ai = true;
static WaveFileWriter g_wave_writer; WaveFileWriter g_wave_writer;
// ============== // ==============
@ -256,10 +256,11 @@ void DSP_Initialize(DSPInitialize _dspInitialize)
// First create DSP_UCode.bin by setting "#define DUMP_DSP_IMEM 1" in Globals.h. Then // First create DSP_UCode.bin by setting "#define DUMP_DSP_IMEM 1" in Globals.h. Then
// make the disassembled file here. // make the disassembled file here.
// -------------- // --------------
/* Dump UCode to file... // Dump UCode to file...
FILE* t = fopen("e:\\hmm.txt", "wb");
/* FILE* t = fopen("C:\\_\\ct.txt", "wb");
gd_globals_t gdg; gd_globals_t gdg;
gd_dis_file(&gdg, "D:\\DSP_UCode.bin", t); gd_dis_file(&gdg, "C:\\_\\DSP_UCode.bin", t);
fclose(t); */ fclose(t); */
// -------------- // --------------
@ -278,7 +279,7 @@ void DSP_Initialize(DSPInitialize _dspInitialize)
#endif // WIN32 #endif // WIN32
if (log_ai) { if (log_ai) {
g_wave_writer.Start("D:\\ai_log.wav"); g_wave_writer.Start("C:\\_\\ai_log.wav");
g_wave_writer.SetSkipSilence(false); g_wave_writer.SetSkipSilence(false);
} }