mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-03-25 23:37:57 +00:00
DSP - fix ROM loading (seriously, have we only been loading half the ROMs??? doesn't make sense).
Also delete some unused old junk variables. Add some comments. Start #defining SR flag constants. "implement" nx. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2872 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
a9e71fe351
commit
6eb6db21ce
@ -78,7 +78,7 @@ s8 GetMultiplyModifier()
|
||||
{
|
||||
return(1);
|
||||
}
|
||||
return(2);
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
@ -89,7 +89,6 @@ s8 GetMultiplyModifier()
|
||||
bool CheckCondition(u8 _Condition)
|
||||
{
|
||||
bool taken = false;
|
||||
|
||||
switch (_Condition & 0xf)
|
||||
{
|
||||
case 0x0: //NS - NOT SIGN
|
||||
@ -660,9 +659,11 @@ void andc(const UDSPInstruction& opc)
|
||||
|
||||
//-------------------------------------------------------------
|
||||
|
||||
// TODO: Implement
|
||||
void nx(const UDSPInstruction& opc)
|
||||
{}
|
||||
{
|
||||
// This opcode is supposed to do nothing - it's used if you want to use
|
||||
// an opcode extension but not do anything. At least according to duddie.
|
||||
}
|
||||
|
||||
|
||||
// FIXME inside
|
||||
@ -1410,4 +1411,4 @@ void lrs(const UDSPInstruction& opc)
|
||||
g_dsp.r[reg] = dsp_dmem_read(addr);
|
||||
}
|
||||
|
||||
};
|
||||
} // namespace
|
||||
|
@ -23,6 +23,6 @@ namespace DSPJit {
|
||||
// TODO(XK): Fill
|
||||
|
||||
|
||||
};
|
||||
} // namespace
|
||||
|
||||
#endif // _DSPJIT_H
|
||||
|
@ -21,6 +21,7 @@
|
||||
#define _DSPTABLES_H
|
||||
|
||||
#include "Common.h"
|
||||
|
||||
enum parameterType
|
||||
{
|
||||
P_NONE = 0x0000,
|
||||
|
@ -52,28 +52,31 @@ u8 SDSP::exceptions;
|
||||
// lets make stack depth to 32 for now
|
||||
u16 SDSP::reg_stack[4][DSP_STACK_DEPTH];
|
||||
void (*SDSP::irq_request)() = NULL;
|
||||
bool SDSP::exception_in_progress_hack = false;
|
||||
bool SDSP::exception_in_progress_hack = false; // should be replaced with bit9 in SR?
|
||||
|
||||
// for debugger only
|
||||
bool SDSP::dump_imem = false;
|
||||
u32 SDSP::iram_crc = 0;
|
||||
u64 SDSP::step_counter = 0;
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
static bool CR_HALT = true;
|
||||
static bool CR_EXTERNAL_INT = false;
|
||||
|
||||
|
||||
bool gdsp_running;
|
||||
extern volatile u32 dsp_running;
|
||||
|
||||
static bool cr_halt = true;
|
||||
static bool cr_external_int = false;
|
||||
|
||||
// SR flag defines.
|
||||
// These are probably not accurate. Do not use yet.
|
||||
#define SR_LOGIC_ZERO 0x0040 // ?? duddie's doc sometimes say & 1<<6, sometimes 1<<14 (0x4000)
|
||||
#define SR_PROD_MUL2 0x2000
|
||||
#define SR_SIGN 0x0008
|
||||
#define SR_ARITH_ZERO 0x0002
|
||||
#define SR_INT_ENABLE 0x0200
|
||||
|
||||
void UpdateCachedCR()
|
||||
{
|
||||
CR_HALT = (g_dsp.cr & 0x4) != 0;
|
||||
CR_EXTERNAL_INT = (g_dsp.cr & 0x02) != 0;
|
||||
cr_halt = (g_dsp.cr & 0x4) != 0;
|
||||
cr_external_int = (g_dsp.cr & 0x02) != 0;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
@ -85,12 +88,14 @@ void dbg_error(char* err_msg)
|
||||
|
||||
void gdsp_init()
|
||||
{
|
||||
// Why do we have DROM? Does it exist? Has it been dumped?
|
||||
g_dsp.irom = (u16*)malloc(DSP_IROM_SIZE * sizeof(u16));
|
||||
g_dsp.iram = (u16*)malloc(DSP_IRAM_SIZE * sizeof(u16));
|
||||
g_dsp.drom = (u16*)malloc(DSP_DROM_SIZE * sizeof(u16));
|
||||
g_dsp.dram = (u16*)malloc(DSP_DRAM_SIZE * sizeof(u16));
|
||||
g_dsp.coef = (u16*)malloc(DSP_COEF_SIZE * sizeof(u16));
|
||||
|
||||
// Fill memories with junk.
|
||||
for (int i = 0; i < DSP_IRAM_SIZE; i++)
|
||||
{
|
||||
g_dsp.iram[i] = 0x0021; // HALT opcode
|
||||
@ -101,6 +106,8 @@ void gdsp_init()
|
||||
g_dsp.dram[i] = 0x0021; // HALT opcode
|
||||
}
|
||||
|
||||
// Fill roms with zeros.
|
||||
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
g_dsp.r[i] = 0;
|
||||
@ -132,7 +139,7 @@ void gdsp_init()
|
||||
void gdsp_reset()
|
||||
{
|
||||
// _assert_msg_(0, "gdsp_reset()");
|
||||
_assert_msg_(MASTER_LOG, !g_dsp.exception_in_progress_hack, "assert while exception");
|
||||
_assert_msg_(MASTER_LOG, !g_dsp.exception_in_progress_hack, "reset while exception");
|
||||
g_dsp.pc = DSP_RESET_VECTOR;
|
||||
g_dsp.exception_in_progress_hack = false;
|
||||
}
|
||||
@ -144,36 +151,51 @@ void gdsp_generate_exception(u8 level)
|
||||
}
|
||||
|
||||
|
||||
bool gdsp_load_rom(char* fname)
|
||||
bool gdsp_load_rom(const char *fname)
|
||||
{
|
||||
FILE* pFile = fopen(fname, "rb");
|
||||
FILE *pFile = fopen(fname, "rb");
|
||||
|
||||
if (pFile)
|
||||
{
|
||||
fread(g_dsp.irom, 1, DSP_IRAM_SIZE, pFile);
|
||||
size_t size_in_bytes = DSP_IROM_SIZE * sizeof(u16);
|
||||
size_t read_bytes = fread(g_dsp.irom, 1, size_in_bytes, pFile);
|
||||
if (read_bytes != size_in_bytes)
|
||||
{
|
||||
PanicAlert("IROM too short : %i/%i", (int)read_bytes, (int)size_in_bytes);
|
||||
fclose(pFile);
|
||||
return(true);
|
||||
return false;
|
||||
}
|
||||
fclose(pFile);
|
||||
return true;
|
||||
}
|
||||
|
||||
return(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool gdsp_load_coef(char* fname)
|
||||
bool gdsp_load_coef(const char *fname)
|
||||
{
|
||||
FILE* pFile = fopen(fname, "rb");
|
||||
FILE *pFile = fopen(fname, "rb");
|
||||
|
||||
if (pFile)
|
||||
{
|
||||
fread(g_dsp.coef, 1, DSP_COEF_SIZE, pFile);
|
||||
size_t size_in_bytes = DSP_COEF_SIZE * sizeof(u16);
|
||||
size_t read_bytes = fread(g_dsp.coef, 1, size_in_bytes, pFile);
|
||||
if (read_bytes != size_in_bytes)
|
||||
{
|
||||
PanicAlert("COEF too short : %i/%i", (int)read_bytes, (int)size_in_bytes);
|
||||
fclose(pFile);
|
||||
return(true);
|
||||
return false;
|
||||
}
|
||||
fclose(pFile);
|
||||
return true;
|
||||
}
|
||||
|
||||
return(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Hm, should instructions that change CR use this? Probably not (but they
|
||||
// should call UpdateCachedCR())
|
||||
void gdsp_write_cr(u16 val)
|
||||
{
|
||||
// reset
|
||||
@ -191,6 +213,7 @@ void gdsp_write_cr(u16 val)
|
||||
}
|
||||
|
||||
|
||||
// Hm, should instructions that read CR use this? (Probably not).
|
||||
u16 gdsp_read_cr()
|
||||
{
|
||||
if (g_dsp.pc & 0x8000)
|
||||
@ -204,14 +227,17 @@ u16 gdsp_read_cr()
|
||||
|
||||
UpdateCachedCR();
|
||||
|
||||
return(g_dsp.cr);
|
||||
return g_dsp.cr;
|
||||
}
|
||||
|
||||
|
||||
// special loop step.. because exception in loop or loopi fails
|
||||
// dunno how we have to fix it
|
||||
// atm we execute this instructions directly inside the loop command
|
||||
// so it cant be interrupted by an exception
|
||||
// so it cant be interrupted by an exception.
|
||||
// TODO - we really should figure this out - on the real DSP, exception inside
|
||||
// loop should work. Think through the stack management and how it works
|
||||
// with exceptions and in loops.
|
||||
void gdsp_loop_step()
|
||||
{
|
||||
g_dsp.err_pc = g_dsp.pc;
|
||||
@ -275,7 +301,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))
|
||||
{
|
||||
@ -313,16 +339,16 @@ bool gdsp_run()
|
||||
{
|
||||
gdsp_running = true;
|
||||
|
||||
while (!CR_HALT)
|
||||
while (!cr_halt)
|
||||
{
|
||||
gdsp_step();
|
||||
|
||||
if(!gdsp_running)
|
||||
if (!gdsp_running)
|
||||
break;
|
||||
}
|
||||
|
||||
gdsp_running = false;
|
||||
return(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -342,7 +368,7 @@ bool gdsp_runx(u16 cnt)
|
||||
}
|
||||
|
||||
gdsp_running = false;
|
||||
return(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,6 +45,7 @@
|
||||
|
||||
#include "Globals.h"
|
||||
|
||||
// Are these in bytes or 16-bit words? Probably 16-bit words.
|
||||
#define DSP_IRAM_SIZE (0x1000)
|
||||
#define DSP_IRAM_MASK (0x0fff)
|
||||
#define DSP_IROM_SIZE (0x1000)
|
||||
@ -92,8 +93,8 @@ extern SDSP g_dsp;
|
||||
|
||||
void gdsp_init(void);
|
||||
void gdsp_reset(void);
|
||||
bool gdsp_load_rom(char* fname);
|
||||
bool gdsp_load_coef(char* fname);
|
||||
bool gdsp_load_rom(const char *fname);
|
||||
bool gdsp_load_coef(const char *fname);
|
||||
|
||||
|
||||
// steps through DSP code, returns false if error occured
|
||||
|
@ -49,9 +49,6 @@ SoundStream *soundStream = NULL;
|
||||
#define GDSP_MBOX_CPU 0
|
||||
#define GDSP_MBOX_DSP 1
|
||||
|
||||
u32 g_LastDMAAddress = 0;
|
||||
u32 g_LastDMASize = 0;
|
||||
|
||||
extern u32 m_addressPBs;
|
||||
bool AXTask(u32& _uMail);
|
||||
|
||||
@ -234,14 +231,14 @@ void Initialize(void *init)
|
||||
g_dsp.irq_request = dspi_req_dsp_irq;
|
||||
gdsp_reset();
|
||||
|
||||
if (!gdsp_load_rom((char *)DSP_ROM_FILE)) {
|
||||
if (!gdsp_load_rom(DSP_ROM_FILE)) {
|
||||
bCanWork = false;
|
||||
PanicAlert("Cannot load DSP ROM");
|
||||
PanicAlert("Failed loading DSP ROM from " DSP_ROM_FILE);
|
||||
}
|
||||
|
||||
if (!gdsp_load_coef((char *)DSP_COEF_FILE)) {
|
||||
if (!gdsp_load_coef(DSP_COEF_FILE)) {
|
||||
bCanWork = false;
|
||||
PanicAlert("Cannot load DSP COEF");
|
||||
PanicAlert("Failed loading DSP COEF from " DSP_COEF_FILE);
|
||||
}
|
||||
|
||||
if(!bCanWork)
|
||||
@ -250,7 +247,6 @@ void Initialize(void *init)
|
||||
bIsRunning = true;
|
||||
|
||||
g_hDSPThread = new Common::Thread(dsp_thread, NULL);
|
||||
|
||||
soundStream = AudioCommon::InitSoundStream();
|
||||
|
||||
InitInstructionTable();
|
||||
@ -272,12 +268,12 @@ void Shutdown(void)
|
||||
u16 DSP_WriteControlRegister(u16 _uFlag)
|
||||
{
|
||||
gdsp_write_cr(_uFlag);
|
||||
return(gdsp_read_cr());
|
||||
return gdsp_read_cr();
|
||||
}
|
||||
|
||||
u16 DSP_ReadControlRegister()
|
||||
{
|
||||
return(gdsp_read_cr());
|
||||
return gdsp_read_cr();
|
||||
}
|
||||
|
||||
u16 DSP_ReadMailboxHigh(bool _CPUMailbox)
|
||||
|
Loading…
x
Reference in New Issue
Block a user