From 12d381020375da2a71f09a2dd991f70e3864bc8d Mon Sep 17 00:00:00 2001 From: "fires.gc" Date: Thu, 9 Oct 2008 20:17:10 +0000 Subject: [PATCH] changed exception behavior a little bit git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@813 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Plugins/Plugin_DSP_LLE/Src/DisAsmDlg.cpp | 3 + .../Plugins/Plugin_DSP_LLE/Src/gdsp_aram.cpp | 6 +- .../Plugin_DSP_LLE/Src/gdsp_interpreter.cpp | 147 ++++++++++++++---- Source/Plugins/Plugin_DSP_LLE/Src/main.cpp | 15 +- 4 files changed, 128 insertions(+), 43 deletions(-) diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/DisAsmDlg.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/DisAsmDlg.cpp index 84e5645a3d..8b6b4f397f 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/DisAsmDlg.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/DisAsmDlg.cpp @@ -179,6 +179,9 @@ int CALLBACK CDisAsmDlg::CompareFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lPar void CDisAsmDlg::RebuildDisAsmListView() { + if (!m_DisAsmListViewCtrl.IsWindow()) + return; + m_DisAsmListViewCtrl.ShowWindow(SW_HIDE); m_DisAsmListViewCtrl.DeleteAllItems(); diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_aram.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_aram.cpp index 6034898129..1c37cb4918 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_aram.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_aram.cpp @@ -63,7 +63,7 @@ sint16 ADPCM_Step(uint32& _rSamplePos, uint32 _BaseAddress) return val; } - +extern void gdsp_generate_exception(uint8 level); uint16 dsp_read_aram() { // uint32 BaseAddress = (gdsp_ifx_regs[DSP_ACSAH] << 16) | gdsp_ifx_regs[DSP_ACSAL]; @@ -99,8 +99,8 @@ uint16 dsp_read_aram() if (Address > EndAddress) { Address = (gdsp_ifx_regs[DSP_ACSAH] << 16) | gdsp_ifx_regs[DSP_ACSAL]; - // ErrorLog("Should we generate a lvl5 exception !??!"); - // gdsp_exception(5); + gdsp_generate_exception(3); + gdsp_generate_exception(5); // 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, diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_interpreter.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_interpreter.cpp index bda59a135f..0d187f967b 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_interpreter.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/gdsp_interpreter.cpp @@ -138,37 +138,10 @@ void gdsp_reset() } +uint8 gdsp_exceptions = 0; void gdsp_generate_exception(uint8 level) { - _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 = 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; - } + gdsp_exceptions |= 1 << level; } @@ -247,7 +220,7 @@ void gdsp_loop_step() dsp_op[opc >> 12](opc); } - +void Hacks(); void gdsp_step() { 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)) { + // level 7 is the interrupt exception gdsp_generate_exception(7); g_dsp.cr &= ~0x0002; 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< 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 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 1024*1024*2) + { + //PanicAlert("%x", bufferAddr); + g_wave_writer.Stop(); + exit(1); + } + } +} \ No newline at end of file diff --git a/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp b/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp index 2f64d63886..ff1cb92a32 100644 --- a/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp +++ b/Source/Plugins/Plugin_DSP_LLE/Src/main.cpp @@ -66,8 +66,8 @@ bool AXTask(u32& _uMail); bool bCanWork = false; // 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 WaveFileWriter g_wave_writer; +static bool log_ai = true; +WaveFileWriter g_wave_writer; // ============== @@ -256,11 +256,12 @@ void DSP_Initialize(DSPInitialize _dspInitialize) // First create DSP_UCode.bin by setting "#define DUMP_DSP_IMEM 1" in Globals.h. Then // make the disassembled file here. // -------------- -/* Dump UCode to file... - FILE* t = fopen("e:\\hmm.txt", "wb"); +// Dump UCode to file... + +/* FILE* t = fopen("C:\\_\\ct.txt", "wb"); gd_globals_t gdg; - gd_dis_file(&gdg, "D:\\DSP_UCode.bin", t); - fclose(t); */ + gd_dis_file(&gdg, "C:\\_\\DSP_UCode.bin", t); + fclose(t); */ // -------------- #ifdef _WIN32 @@ -278,7 +279,7 @@ void DSP_Initialize(DSPInitialize _dspInitialize) #endif // WIN32 if (log_ai) { - g_wave_writer.Start("D:\\ai_log.wav"); + g_wave_writer.Start("C:\\_\\ai_log.wav"); g_wave_writer.SetSkipSilence(false); }