tiny DSP cleanup: Move pending exceptions register into SDSP struct.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2869 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2009-04-05 09:23:43 +00:00
parent 82880f96da
commit 07c1b7d784
4 changed files with 24 additions and 16 deletions

View File

@ -17,6 +17,7 @@
#include "Globals.h"
#include "gdsp_interface.h"
#include "gdsp_interpreter.h"
extern u16 dsp_swap16(u16 x);
@ -63,7 +64,6 @@ s16 ADPCM_Step(u32& _rSamplePos, u32 _BaseAddress)
return val;
}
extern void gdsp_generate_exception(u8 level);
u16 dsp_read_aram()
{
// u32 BaseAddress = (gdsp_ifx_regs[DSP_ACSAH] << 16) | gdsp_ifx_regs[DSP_ACSAL];

View File

@ -47,6 +47,8 @@ u16* SDSP::coef = 0;
u8* SDSP::cpu_ram = 0;
u16 SDSP::cr = 0;
u8 SDSP::reg_stack_ptr[4];
u8 SDSP::exceptions;
// lets make stack depth to 32 for now
u16 SDSP::reg_stack[4][DSP_STACK_DEPTH];
void (*SDSP::irq_request)() = NULL;
@ -63,6 +65,11 @@ u64 SDSP::step_counter = 0;
static bool CR_HALT = true;
static bool CR_EXTERNAL_INT = false;
bool gdsp_running;
extern volatile u32 dsp_running;
void UpdateCachedCR()
{
CR_HALT = (g_dsp.cr & 0x4) != 0;
@ -131,10 +138,9 @@ void gdsp_reset()
}
u8 gdsp_exceptions = 0;
void gdsp_generate_exception(u8 level)
{
gdsp_exceptions |= 1 << level;
g_dsp.exceptions |= 1 << level;
}
@ -269,7 +275,7 @@ void gdsp_step()
}
// check if there is an external interrupt
if (CR_EXTERNAL_INT)
if (CR_EXTERNAL_INT)
{
if (dsp_SR_is_flag_set(FLAG_ENABLE_INTERUPT) && (g_dsp.exception_in_progress_hack == false))
{
@ -281,19 +287,19 @@ void gdsp_step()
}
// check exceptions
if ((gdsp_exceptions > 0) && (!g_dsp.exception_in_progress_hack))
if ((g_dsp.exceptions != 0) && (!g_dsp.exception_in_progress_hack))
{
for (u8 i=0; i<8; i++)
for (int i = 0; i < 8; i++)
{
if (gdsp_exceptions & (1<<i))
if (g_dsp.exceptions & (1 << i))
{
_assert_msg_(MASTER_LOG, !g_dsp.exception_in_progress_hack, "assert while exception");
_assert_msg_(MASTER_LOG, !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.exceptions &= ~(1 << i);
g_dsp.exception_in_progress_hack = true;
break;
@ -303,9 +309,6 @@ void gdsp_step()
}
bool gdsp_running;
extern volatile u32 dsp_running;
bool gdsp_run()
{
gdsp_running = true;
@ -359,7 +362,7 @@ void gdsp_stop()
//#include "WaveFile.h"
#include "Mixer.h"
u16 r30 = 0, r31 = 0;
// u16 r30 = 0, r31 = 0;
//extern WaveFileWriter g_wave_writer;
extern u16 dsp_swap16(u16 x);

View File

@ -74,6 +74,8 @@ struct SDSP
static u8* cpu_ram;
static u16 cr;
static u8 reg_stack_ptr[4];
static u8 exceptions; // pending exceptiosn?
// lets make stack depth to 32 for now
static u16 reg_stack[4][DSP_STACK_DEPTH];
static void (* irq_request)(void);
@ -109,4 +111,7 @@ u16* gdsp_get_irom(void);
u16* gdsp_get_dram(void);
u16* gdsp_get_drom(void);
// sets a flag in the pending exception register.
void gdsp_generate_exception(u8 level);
#endif

View File

@ -28,9 +28,9 @@
#include "Globals.h"
#define DSP_REG_ST0 0x0c
#define DSP_REG_ST1 0x0c
#define DSP_REG_ST2 0x0c
#define DSP_REG_ST3 0x0c
//#define DSP_REG_ST1 0x0d
//#define DSP_REG_ST2 0x0e
//#define DSP_REG_ST3 0x0f
#define DSP_STACK_C 0
#define DSP_STACK_D 1