use dolphin-style typedefs in dsp-lle testing

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2793 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman 2009-03-30 03:27:31 +00:00
parent 20b54fb71f
commit 57105f08d6
28 changed files with 687 additions and 701 deletions

View File

@ -66,7 +66,7 @@ void ProfilerInit()
memset(g_profileMap, 0, sizeof(g_profileMap)); memset(g_profileMap, 0, sizeof(g_profileMap));
} }
void ProfilerDump(uint64 count) void ProfilerDump(u64 count)
{ {
FILE* pFile = fopen("DSP_Prof.txt", "wt"); FILE* pFile = fopen("DSP_Prof.txt", "wt");
if (pFile != NULL) if (pFile != NULL)

View File

@ -28,25 +28,11 @@
void DSP_DebugBreak(); void DSP_DebugBreak();
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
typedef unsigned int uint;
typedef signed char sint8;
typedef signed short sint16;
typedef signed int sint32;
typedef signed long long sint64;
typedef const uint32 cuint32;
u16 Memory_Read_U16(u32 _uAddress); // For PB address detection u16 Memory_Read_U16(u32 _uAddress); // For PB address detection
u32 Memory_Read_U32(u32 _uAddress); u32 Memory_Read_U32(u32 _uAddress);
#if PROFILE #if PROFILE
void ProfilerDump(uint64 _count); void ProfilerDump(u64 _count);
void ProfilerInit(); void ProfilerInit();
void ProfilerAddDelta(int _addr, int _delta); void ProfilerAddDelta(int _addr, int _delta);
void ProfilerStart(); void ProfilerStart();

View File

@ -22,60 +22,60 @@
#include "HLE_Helper.h" #include "HLE_Helper.h"
uint16& R00 = g_dsp.r[0x00]; u16& R00 = g_dsp.r[0x00];
uint16& R01 = g_dsp.r[0x01]; u16& R01 = g_dsp.r[0x01];
uint16& R02 = g_dsp.r[0x02]; u16& R02 = g_dsp.r[0x02];
uint16& R03 = g_dsp.r[0x03]; u16& R03 = g_dsp.r[0x03];
uint16& R04 = g_dsp.r[0x04]; u16& R04 = g_dsp.r[0x04];
uint16& R05 = g_dsp.r[0x05]; u16& R05 = g_dsp.r[0x05];
uint16& R06 = g_dsp.r[0x06]; u16& R06 = g_dsp.r[0x06];
uint16& R07 = g_dsp.r[0x07]; u16& R07 = g_dsp.r[0x07];
uint16& R08 = g_dsp.r[0x08]; u16& R08 = g_dsp.r[0x08];
uint16& R09 = g_dsp.r[0x09]; u16& R09 = g_dsp.r[0x09];
uint16& R0A = g_dsp.r[0x0a]; u16& R0A = g_dsp.r[0x0a];
uint16& R0B = g_dsp.r[0x0b]; u16& R0B = g_dsp.r[0x0b];
uint16& R0C = g_dsp.r[0x0c]; u16& R0C = g_dsp.r[0x0c];
uint16& R0D = g_dsp.r[0x0d]; u16& R0D = g_dsp.r[0x0d];
uint16& R0E = g_dsp.r[0x0e]; u16& R0E = g_dsp.r[0x0e];
uint16& R0F = g_dsp.r[0x0f]; u16& R0F = g_dsp.r[0x0f];
uint16& R10 = g_dsp.r[0x10]; u16& R10 = g_dsp.r[0x10];
uint16& R11 = g_dsp.r[0x11]; u16& R11 = g_dsp.r[0x11];
uint16& R12 = g_dsp.r[0x12]; u16& R12 = g_dsp.r[0x12];
uint16& R13 = g_dsp.r[0x13]; u16& R13 = g_dsp.r[0x13];
uint16& R14 = g_dsp.r[0x14]; u16& R14 = g_dsp.r[0x14];
uint16& R15 = g_dsp.r[0x15]; u16& R15 = g_dsp.r[0x15];
uint16& R16 = g_dsp.r[0x16]; u16& R16 = g_dsp.r[0x16];
uint16& R17 = g_dsp.r[0x17]; u16& R17 = g_dsp.r[0x17];
uint16& R18 = g_dsp.r[0x18]; u16& R18 = g_dsp.r[0x18];
uint16& R19 = g_dsp.r[0x19]; u16& R19 = g_dsp.r[0x19];
uint16& R1A = g_dsp.r[0x1a]; u16& R1A = g_dsp.r[0x1a];
uint16& R1B = g_dsp.r[0x1b]; u16& R1B = g_dsp.r[0x1b];
uint16& R1C = g_dsp.r[0x1c]; u16& R1C = g_dsp.r[0x1c];
uint16& R1D = g_dsp.r[0x1d]; u16& R1D = g_dsp.r[0x1d];
uint16& R1E = g_dsp.r[0x1e]; u16& R1E = g_dsp.r[0x1e];
uint16& R1F = g_dsp.r[0x1f]; u16& R1F = g_dsp.r[0x1f];
uint16& ST0 = g_dsp.r[0x0c]; u16& ST0 = g_dsp.r[0x0c];
uint16& ST1 = g_dsp.r[0x0d]; u16& ST1 = g_dsp.r[0x0d];
uint16& ST2 = g_dsp.r[0x0e]; u16& ST2 = g_dsp.r[0x0e];
uint16& ST3 = g_dsp.r[0x0f]; u16& ST3 = g_dsp.r[0x0f];
uint16& ACH0 = g_dsp.r[0x10]; u16& ACH0 = g_dsp.r[0x10];
uint16& ACH1 = g_dsp.r[0x11]; u16& ACH1 = g_dsp.r[0x11];
uint16& CR = g_dsp.r[0x12]; u16& CR = g_dsp.r[0x12];
uint16& SR = g_dsp.r[0x13]; u16& SR = g_dsp.r[0x13];
uint16& PROD_l = g_dsp.r[0x14]; u16& PROD_l = g_dsp.r[0x14];
uint16& PROD_m1 = g_dsp.r[0x15]; u16& PROD_m1 = g_dsp.r[0x15];
uint16& PROD_h = g_dsp.r[0x16]; u16& PROD_h = g_dsp.r[0x16];
uint16& PROD_m2 = g_dsp.r[0x17]; u16& PROD_m2 = g_dsp.r[0x17];
uint16& AX0_l = g_dsp.r[0x18]; u16& AX0_l = g_dsp.r[0x18];
uint16& AX1_l = g_dsp.r[0x19]; u16& AX1_l = g_dsp.r[0x19];
uint16& AX0_h = g_dsp.r[0x1a]; u16& AX0_h = g_dsp.r[0x1a];
uint16& AX1_h = g_dsp.r[0x1b]; u16& AX1_h = g_dsp.r[0x1b];
uint16& AC0_l = g_dsp.r[0x1c]; u16& AC0_l = g_dsp.r[0x1c];
uint16& AC1_l = g_dsp.r[0x1d]; u16& AC1_l = g_dsp.r[0x1d];
uint16& AC0_m = g_dsp.r[0x1e]; u16& AC0_m = g_dsp.r[0x1e];
uint16& AC1_m = g_dsp.r[0x1f]; u16& AC1_m = g_dsp.r[0x1f];
TAccumulator<0> ACC0; TAccumulator<0> ACC0;
TAccumulator<1> ACC1; TAccumulator<1> ACC1;
@ -84,7 +84,7 @@ CProd PROD;
u16 HLE_ROM_80E7_81F8() u16 HLE_ROM_80E7_81F8()
{ {
sint8 MultiplyModifier = GetMultiplyModifier(); s8 MultiplyModifier = GetMultiplyModifier();
// l_80E7: // l_80E7:
AX0_h = ReadDMEM(R00); AX0_h = ReadDMEM(R00);
R00++; R00++;

View File

@ -25,12 +25,12 @@
#include "gdsp_opcodes_helper.h" #include "gdsp_opcodes_helper.h"
bool WriteDMEM(uint16 addr, uint16 val) bool WriteDMEM(u16 addr, u16 val)
{ {
return dsp_dmem_write(addr, val); return dsp_dmem_write(addr, val);
} }
uint16 ReadDMEM(uint16 addr) u16 ReadDMEM(u16 addr)
{ {
return dsp_dmem_read(addr); return dsp_dmem_read(addr);
} }

View File

@ -20,10 +20,10 @@
#include "gdsp_interpreter.h" #include "gdsp_interpreter.h"
bool WriteDMEM(uint16 addr, uint16 val); bool WriteDMEM(u16 addr, u16 val);
uint16 ReadDMEM(uint16 addr); u16 ReadDMEM(u16 addr);
void Update_SR_Register(sint64 _Value); void Update_SR_Register(s64 _Value);
sint8 GetMultiplyModifier(); s8 GetMultiplyModifier();
template<unsigned N> template<unsigned N>
class TAccumulator class TAccumulator
@ -35,56 +35,56 @@ public:
_assert_(N < 2); _assert_(N < 2);
} }
void operator=(sint64 val) void operator=(s64 val)
{ {
setValue(val); setValue(val);
} }
void operator<<=(sint64 value) void operator<<=(s64 value)
{ {
sint64 acc = getValue(); s64 acc = getValue();
acc <<= value; acc <<= value;
setValue(acc); setValue(acc);
} }
void operator>>=(sint64 value) void operator>>=(s64 value)
{ {
sint64 acc = getValue(); s64 acc = getValue();
acc >>= value; acc >>= value;
setValue(acc); setValue(acc);
} }
void operator+=(sint64 value) void operator+=(s64 value)
{ {
sint64 acc = getValue(); s64 acc = getValue();
acc += value; acc += value;
setValue(acc); setValue(acc);
} }
operator sint64() operator s64()
{ {
return getValue(); return getValue();
} }
operator uint64() operator u64()
{ {
return getValue(); return getValue();
} }
inline void setValue(sint64 val) inline void setValue(s64 val)
{ {
g_dsp.r[0x1c + N] = (uint16)val; g_dsp.r[0x1c + N] = (u16)val;
val >>= 16; val >>= 16;
g_dsp.r[0x1e + N] = (uint16)val; g_dsp.r[0x1e + N] = (u16)val;
val >>= 16; val >>= 16;
g_dsp.r[0x10 + N] = (uint16)val; g_dsp.r[0x10 + N] = (u16)val;
} }
inline sint64 getValue() inline s64 getValue()
{ {
sint64 val; s64 val;
sint64 low_acc; s64 low_acc;
val = (sint8)g_dsp.r[0x10 + N]; val = (s8)g_dsp.r[0x10 + N];
val <<= 32; val <<= 32;
low_acc = g_dsp.r[0x1e + N]; low_acc = g_dsp.r[0x1e + N];
low_acc <<= 16; low_acc <<= 16;
@ -101,21 +101,21 @@ public:
{ {
} }
void operator=(sint64 val) void operator=(s64 val)
{ {
g_dsp.r[0x14] = (uint16)val; g_dsp.r[0x14] = (u16)val;
val >>= 16; val >>= 16;
g_dsp.r[0x15] = (uint16)val; g_dsp.r[0x15] = (u16)val;
val >>= 16; val >>= 16;
g_dsp.r[0x16] = (uint16)val; g_dsp.r[0x16] = (u16)val;
g_dsp.r[0x17] = 0; g_dsp.r[0x17] = 0;
} }
operator sint64() operator s64()
{ {
sint64 val; s64 val;
sint64 low_prod; s64 low_prod;
val = (sint8)g_dsp.r[0x16]; val = (s8)g_dsp.r[0x16];
val <<= 32; val <<= 32;
low_prod = g_dsp.r[0x15]; low_prod = g_dsp.r[0x15];
low_prod += g_dsp.r[0x17]; low_prod += g_dsp.r[0x17];

View File

@ -23,7 +23,7 @@
#include "gdsp_interpreter.h" #include "gdsp_interpreter.h"
bool DumpDSPCode(uint32 _Address, uint32 _Length, uint32 crc) bool DumpDSPCode(u32 _Address, u32 _Length, u32 crc)
{ {
char szFilename[MAX_PATH]; char szFilename[MAX_PATH];
sprintf(szFilename, "c:\\_\\DSP_UC_%08X.bin", crc); sprintf(szFilename, "c:\\_\\DSP_UC_%08X.bin", crc);
@ -44,7 +44,7 @@ bool DumpDSPCode(uint32 _Address, uint32 _Length, uint32 crc)
} }
uint32 GenerateCRC(const unsigned char* _pBuffer, int _pLength) u32 GenerateCRC(const unsigned char* _pBuffer, int _pLength)
{ {
unsigned long CRC = 0xFFFFFFFF; unsigned long CRC = 0xFFFFFFFF;
@ -71,7 +71,7 @@ uint32 GenerateCRC(const unsigned char* _pBuffer, int _pLength)
} }
bool DumpCWCode(uint32 _Address, uint32 _Length) bool DumpCWCode(u32 _Address, u32 _Length)
{ {
FILE* pFile = fopen("d:\\DSP_UCode.bin", "wb"); FILE* pFile = fopen("d:\\DSP_UCode.bin", "wb");
@ -79,7 +79,7 @@ bool DumpCWCode(uint32 _Address, uint32 _Length)
{ {
for (size_t i = _Address; i < _Address + _Length; i++) for (size_t i = _Address; i < _Address + _Length; i++)
{ {
uint16 val = Common::swap16(g_dsp.iram[i]); u16 val = Common::swap16(g_dsp.iram[i]);
fprintf(pFile, " cw 0x%04x \n", val); fprintf(pFile, " cw 0x%04x \n", val);
} }

View File

@ -20,7 +20,7 @@
// UDSPControl // UDSPControl
union UDSPControl union UDSPControl
{ {
uint16 Hex; u16 Hex;
struct struct
{ {
unsigned DSPReset : 1; // Write 1 to reset and waits for 0 unsigned DSPReset : 1; // Write 1 to reset and waits for 0
@ -40,11 +40,11 @@ union UDSPControl
unsigned pad : 4; unsigned pad : 4;
}; };
UDSPControl(uint16 _Hex = 0) UDSPControl(u16 _Hex = 0)
: Hex(_Hex) {} : Hex(_Hex) {}
}; };
bool DumpDSPCode(uint32 _Address, uint32 _Length, uint32 crc); bool DumpDSPCode(u32 _Address, u32 _Length, u32 crc);
uint32 GenerateCRC(const unsigned char* _pBuffer, int _pLength); u32 GenerateCRC(const unsigned char* _pBuffer, int _pLength);
bool DumpCWCode(uint32 _Address, uint32 _Length); bool DumpCWCode(u32 _Address, u32 _Length);

View File

@ -37,15 +37,15 @@
#pragma warning(disable:4996) #pragma warning(disable:4996)
#endif #endif
uint32 unk_opcodes[0x10000]; u32 unk_opcodes[0x10000];
uint16 swap16(uint16 x); u16 swap16(u16 x);
// predefined labels // predefined labels
typedef struct pdlabel_t typedef struct pdlabel_t
{ {
uint16 addr; u16 addr;
const char* name; const char* name;
const char* description; const char* description;
} pdlabels_t; } pdlabels_t;
@ -138,7 +138,7 @@ pdlabel_t regnames[] =
{0x23, "AX1", "Additional Accumulators 1",}, {0x23, "AX1", "Additional Accumulators 1",},
}; };
const char* pdname(uint16 val) const char* pdname(u16 val)
{ {
static char tmpstr[12]; // nasty static char tmpstr[12]; // nasty
@ -155,10 +155,10 @@ const char* pdname(uint16 val)
} }
char* gd_dis_params(gd_globals_t* gdg, opc_t* opc, uint16 op1, uint16 op2, char* strbuf) char* gd_dis_params(gd_globals_t* gdg, opc_t* opc, u16 op1, u16 op2, char* strbuf)
{ {
char* buf = strbuf; char* buf = strbuf;
uint32 val; u32 val;
int j; int j;
for (j = 0; j < opc->param_count; j++) for (j = 0; j < opc->param_count; j++)
@ -189,7 +189,7 @@ char* gd_dis_params(gd_globals_t* gdg, opc_t* opc, uint16 op1, uint16 op2, char*
val = val >> opc->params[j].lshift; val = val >> opc->params[j].lshift;
} }
uint32 type; u32 type;
type = opc->params[j].type; type = opc->params[j].type;
if (type & P_REG) if (type & P_REG)
@ -243,7 +243,7 @@ char* gd_dis_params(gd_globals_t* gdg, opc_t* opc, uint16 op1, uint16 op2, char*
if (opc->params[j].size != 2) if (opc->params[j].size != 2)
{ {
val = (uint16)(sint8)val; val = (u16)(s8)val;
} }
if (gdg->decode_names) if (gdg->decode_names)
@ -278,7 +278,7 @@ gd_globals_t* gd_init()
} }
uint16 gd_dis_get_opcode_size(gd_globals_t* gdg) u16 gd_dis_get_opcode_size(gd_globals_t* gdg)
{ {
opc_t* opc = 0; opc_t* opc = 0;
opc_t* opc_ext = 0; opc_t* opc_ext = 0;
@ -289,11 +289,11 @@ uint16 gd_dis_get_opcode_size(gd_globals_t* gdg)
return(1); return(1);
} }
uint32 op1 = swap16(gdg->binbuf[gdg->pc & 0x0fff]); u32 op1 = swap16(gdg->binbuf[gdg->pc & 0x0fff]);
for (uint32 j = 0; j < opcodes_size; j++) for (u32 j = 0; j < opcodes_size; j++)
{ {
uint16 mask; u16 mask;
if (opcodes[j].size & P_EXT) if (opcodes[j].size & P_EXT)
{ {
@ -330,7 +330,7 @@ uint16 gd_dis_get_opcode_size(gd_globals_t* gdg)
{ {
// opcode has an extension // opcode has an extension
// find opcode // find opcode
for (uint32 j = 0; j < opcodes_ext_size; j++) for (u32 j = 0; j < opcodes_ext_size; j++)
{ {
if ((op1 & opcodes_ext[j].opcode_mask) == opcodes_ext[j].opcode) if ((op1 & opcodes_ext[j].opcode_mask) == opcodes_ext[j].opcode)
{ {
@ -353,11 +353,11 @@ uint16 gd_dis_get_opcode_size(gd_globals_t* gdg)
char* gd_dis_opcode(gd_globals_t* gdg) char* gd_dis_opcode(gd_globals_t* gdg)
{ {
uint32 j; u32 j;
uint32 op1, op2; u32 op1, op2;
opc_t* opc = NULL; opc_t* opc = NULL;
opc_t* opc_ext = NULL; opc_t* opc_ext = NULL;
uint16 pc; u16 pc;
char* buf = gdg->buffer; char* buf = gdg->buffer;
bool extended; bool extended;
@ -376,7 +376,7 @@ char* gd_dis_opcode(gd_globals_t* gdg)
// find opcode // find opcode
for (j = 0; j < opcodes_size; j++) for (j = 0; j < opcodes_size; j++)
{ {
uint16 mask; u16 mask;
if (opcodes[j].size & P_EXT) if (opcodes[j].size & P_EXT)
{ {
@ -510,7 +510,7 @@ char* gd_dis_opcode(gd_globals_t* gdg)
bool gd_dis_file(gd_globals_t* gdg, char* name, FILE* output) bool gd_dis_file(gd_globals_t* gdg, char* name, FILE* output)
{ {
FILE* in; FILE* in;
uint32 size; u32 size;
in = fopen(name, "rb"); in = fopen(name, "rb");
@ -522,7 +522,7 @@ bool gd_dis_file(gd_globals_t* gdg, char* name, FILE* output)
fseek(in, 0, SEEK_END); fseek(in, 0, SEEK_END);
size = (int)ftell(in); size = (int)ftell(in);
fseek(in, 0, SEEK_SET); fseek(in, 0, SEEK_SET);
gdg->binbuf = (uint16*)malloc(size); gdg->binbuf = (u16*)malloc(size);
fread(gdg->binbuf, 1, size, in); fread(gdg->binbuf, 1, size, in);
gdg->buffer = (char*)malloc(256); gdg->buffer = (char*)malloc(256);
@ -550,7 +550,7 @@ void gd_dis_close_unkop()
{ {
FILE* uo; FILE* uo;
int i, j; int i, j;
uint32 count = 0; u32 count = 0;
uo = fopen("uo.bin", "wb"); uo = fopen("uo.bin", "wb");
@ -614,7 +614,7 @@ void gd_dis_open_unkop()
} }
const char* gd_dis_get_reg_name(uint16 reg) const char* gd_dis_get_reg_name(u16 reg)
{ {
return(regnames[reg].name); return(regnames[reg].name);
} }

View File

@ -33,14 +33,14 @@ typedef struct gd_globals_t
bool decode_names; bool decode_names;
bool decode_registers; bool decode_registers;
uint16* binbuf; u16* binbuf;
uint16 pc; u16 pc;
char* buffer; char* buffer;
uint16 buffer_size; u16 buffer_size;
char ext_separator; char ext_separator;
} gd_globals_t; } gd_globals_t;
char* gd_dis_opcode(gd_globals_t* gdg); char* gd_dis_opcode(gd_globals_t* gdg);
bool gd_dis_file(gd_globals_t* gdg, char* name, FILE* output); bool gd_dis_file(gd_globals_t* gdg, char* name, FILE* output);
const char* gd_dis_get_reg_name(uint16 reg); const char* gd_dis_get_reg_name(u16 reg);

View File

@ -18,12 +18,12 @@
#include "Globals.h" #include "Globals.h"
#include "gdsp_interface.h" #include "gdsp_interface.h"
extern uint16 dsp_swap16(uint16 x); extern u16 dsp_swap16(u16 x);
// The hardware adpcm decoder :) // The hardware adpcm decoder :)
sint16 ADPCM_Step(uint32& _rSamplePos, uint32 _BaseAddress) s16 ADPCM_Step(u32& _rSamplePos, u32 _BaseAddress)
{ {
sint16* pCoefTable = (sint16*)&gdsp_ifx_regs[DSP_COEF_A1_0]; s16* pCoefTable = (s16*)&gdsp_ifx_regs[DSP_COEF_A1_0];
if (((_rSamplePos) & 15) == 0) if (((_rSamplePos) & 15) == 0)
{ {
@ -34,8 +34,8 @@ sint16 ADPCM_Step(uint32& _rSamplePos, uint32 _BaseAddress)
int scale = 1 << (gdsp_ifx_regs[DSP_PRED_SCALE] & 0xF); int scale = 1 << (gdsp_ifx_regs[DSP_PRED_SCALE] & 0xF);
int coef_idx = gdsp_ifx_regs[DSP_PRED_SCALE] >> 4; int coef_idx = gdsp_ifx_regs[DSP_PRED_SCALE] >> 4;
sint32 coef1 = pCoefTable[coef_idx * 2 + 0]; s32 coef1 = pCoefTable[coef_idx * 2 + 0];
sint32 coef2 = pCoefTable[coef_idx * 2 + 1]; s32 coef2 = pCoefTable[coef_idx * 2 + 1];
int temp = (_rSamplePos & 1) ? int temp = (_rSamplePos & 1) ?
(g_dspInitialize.pARAM_Read_U8(_rSamplePos >> 1) & 0xF) : (g_dspInitialize.pARAM_Read_U8(_rSamplePos >> 1) & 0xF) :
@ -45,7 +45,7 @@ sint16 ADPCM_Step(uint32& _rSamplePos, uint32 _BaseAddress)
temp -= 16; temp -= 16;
// 0x400 = 0.5 in 11-bit fixed point // 0x400 = 0.5 in 11-bit fixed point
int val = (scale * temp) + ((0x400 + coef1 * (sint16)gdsp_ifx_regs[DSP_YN1] + coef2 * (sint16)gdsp_ifx_regs[DSP_YN2]) >> 11); int val = (scale * temp) + ((0x400 + coef1 * (s16)gdsp_ifx_regs[DSP_YN1] + coef2 * (s16)gdsp_ifx_regs[DSP_YN2]) >> 11);
// Clamp values. // Clamp values.
if (val > 0x7FFF) if (val > 0x7FFF)
@ -63,14 +63,14 @@ sint16 ADPCM_Step(uint32& _rSamplePos, uint32 _BaseAddress)
return val; return val;
} }
extern void gdsp_generate_exception(uint8 level); extern void gdsp_generate_exception(u8 level);
uint16 dsp_read_aram() u16 dsp_read_aram()
{ {
// uint32 BaseAddress = (gdsp_ifx_regs[DSP_ACSAH] << 16) | gdsp_ifx_regs[DSP_ACSAL]; // u32 BaseAddress = (gdsp_ifx_regs[DSP_ACSAH] << 16) | gdsp_ifx_regs[DSP_ACSAL];
uint32 EndAddress = (gdsp_ifx_regs[DSP_ACEAH] << 16) | gdsp_ifx_regs[DSP_ACEAL]; u32 EndAddress = (gdsp_ifx_regs[DSP_ACEAH] << 16) | gdsp_ifx_regs[DSP_ACEAL];
uint32 Address = (gdsp_ifx_regs[DSP_ACCAH] << 16) | gdsp_ifx_regs[DSP_ACCAL]; u32 Address = (gdsp_ifx_regs[DSP_ACCAH] << 16) | gdsp_ifx_regs[DSP_ACCAL];
uint16 val; u16 val;
// lets the "hardware" decode // lets the "hardware" decode
switch (gdsp_ifx_regs[DSP_FORMAT]) switch (gdsp_ifx_regs[DSP_FORMAT])

View File

@ -18,6 +18,6 @@
#ifndef _GDSP_ARAM_H #ifndef _GDSP_ARAM_H
#define _GDSP_ARAM_H #define _GDSP_ARAM_H
uint16 dsp_read_aram(); u16 dsp_read_aram();
#endif #endif

View File

@ -33,10 +33,10 @@
// //
void dsp_op_ext_r_epi(uint16 _Opcode) void dsp_op_ext_r_epi(u16 _Opcode)
{ {
uint8 op = (_Opcode >> 2) & 0x3; u8 op = (_Opcode >> 2) & 0x3;
uint8 reg = _Opcode & 0x3; u8 reg = _Opcode & 0x3;
switch (op) switch (op)
{ {
@ -59,19 +59,19 @@ void dsp_op_ext_r_epi(uint16 _Opcode)
} }
void dsp_op_ext_mv(uint16 _Opcode) void dsp_op_ext_mv(u16 _Opcode)
{ {
uint8 sreg = _Opcode & 0x3; u8 sreg = _Opcode & 0x3;
uint8 dreg = ((_Opcode >> 2) & 0x3); u8 dreg = ((_Opcode >> 2) & 0x3);
g_dsp.r[dreg + 0x18] = g_dsp.r[sreg + 0x1c]; g_dsp.r[dreg + 0x18] = g_dsp.r[sreg + 0x1c];
} }
void dsp_op_ext_s(uint16 _Opcode) void dsp_op_ext_s(u16 _Opcode)
{ {
uint8 dreg = _Opcode & 0x3; u8 dreg = _Opcode & 0x3;
uint8 sreg = ((_Opcode >> 3) & 0x3) + 0x1c; u8 sreg = ((_Opcode >> 3) & 0x3) + 0x1c;
dsp_dmem_write(g_dsp.r[dreg], g_dsp.r[sreg]); dsp_dmem_write(g_dsp.r[dreg], g_dsp.r[sreg]);
@ -86,12 +86,12 @@ void dsp_op_ext_s(uint16 _Opcode)
} }
void dsp_op_ext_l(uint16 _Opcode) void dsp_op_ext_l(u16 _Opcode)
{ {
uint8 sreg = _Opcode & 0x3; u8 sreg = _Opcode & 0x3;
uint8 dreg = ((_Opcode >> 3) & 0x7) + 0x18; u8 dreg = ((_Opcode >> 3) & 0x7) + 0x18;
uint16 val = dsp_dmem_read(g_dsp.r[sreg]); u16 val = dsp_dmem_read(g_dsp.r[sreg]);
g_dsp.r[dreg] = val; g_dsp.r[dreg] = val;
if (_Opcode & 0x04) if (_Opcode & 0x04)
@ -105,9 +105,9 @@ void dsp_op_ext_l(uint16 _Opcode)
} }
void dsp_op_ext_ls_pro(uint16 _Opcode) void dsp_op_ext_ls_pro(u16 _Opcode)
{ {
uint8 areg = (_Opcode & 0x1) + 0x1e; u8 areg = (_Opcode & 0x1) + 0x1e;
dsp_dmem_write(g_dsp.r[0x03], g_dsp.r[areg]); dsp_dmem_write(g_dsp.r[0x03], g_dsp.r[areg]);
if (_Opcode & 0x8) if (_Opcode & 0x8)
@ -121,10 +121,10 @@ void dsp_op_ext_ls_pro(uint16 _Opcode)
} }
void dsp_op_ext_ls_epi(uint16 _Opcode) void dsp_op_ext_ls_epi(u16 _Opcode)
{ {
uint8 dreg = ((_Opcode >> 4) & 0x3) + 0x18; u8 dreg = ((_Opcode >> 4) & 0x3) + 0x18;
uint16 val = dsp_dmem_read(g_dsp.r[0x00]); u16 val = dsp_dmem_read(g_dsp.r[0x00]);
dsp_op_write_reg(dreg, val); dsp_op_write_reg(dreg, val);
if (_Opcode & 0x4) if (_Opcode & 0x4)
@ -138,9 +138,9 @@ void dsp_op_ext_ls_epi(uint16 _Opcode)
} }
void dsp_op_ext_sl_pro(uint16 _Opcode) void dsp_op_ext_sl_pro(u16 _Opcode)
{ {
uint8 areg = (_Opcode & 0x1) + 0x1e; u8 areg = (_Opcode & 0x1) + 0x1e;
dsp_dmem_write(g_dsp.r[0x00], g_dsp.r[areg]); dsp_dmem_write(g_dsp.r[0x00], g_dsp.r[areg]);
if (_Opcode & 0x4) if (_Opcode & 0x4)
@ -154,10 +154,10 @@ void dsp_op_ext_sl_pro(uint16 _Opcode)
} }
void dsp_op_ext_sl_epi(uint16 _Opcode) void dsp_op_ext_sl_epi(u16 _Opcode)
{ {
uint8 dreg = ((_Opcode >> 4) & 0x3) + 0x18; u8 dreg = ((_Opcode >> 4) & 0x3) + 0x18;
uint16 val = dsp_dmem_read(g_dsp.r[0x03]); u16 val = dsp_dmem_read(g_dsp.r[0x03]);
dsp_op_write_reg(dreg, val); dsp_op_write_reg(dreg, val);
if (_Opcode & 0x8) if (_Opcode & 0x8)
@ -171,11 +171,11 @@ void dsp_op_ext_sl_epi(uint16 _Opcode)
} }
void dsp_op_ext_ld(uint16 _Opcode) void dsp_op_ext_ld(u16 _Opcode)
{ {
uint8 dreg1 = (((_Opcode >> 5) & 0x1) << 1) + 0x18; u8 dreg1 = (((_Opcode >> 5) & 0x1) << 1) + 0x18;
uint8 dreg2 = (((_Opcode >> 4) & 0x1) << 1) + 0x19; u8 dreg2 = (((_Opcode >> 4) & 0x1) << 1) + 0x19;
uint8 sreg = _Opcode & 0x3; u8 sreg = _Opcode & 0x3;
g_dsp.r[dreg1] = dsp_dmem_read(g_dsp.r[sreg]); g_dsp.r[dreg1] = dsp_dmem_read(g_dsp.r[sreg]);
g_dsp.r[dreg2] = dsp_dmem_read(g_dsp.r[0x03]); g_dsp.r[dreg2] = dsp_dmem_read(g_dsp.r[0x03]);
@ -205,7 +205,7 @@ void dsp_op_ext_ld(uint16 _Opcode)
// //
// ================================================================================ // ================================================================================
void dsp_op_ext_ops_pro(uint16 _Opcode) void dsp_op_ext_ops_pro(u16 _Opcode)
{ {
if ((_Opcode & 0xFF) == 0){return;} if ((_Opcode & 0xFF) == 0){return;}
@ -257,7 +257,7 @@ void dsp_op_ext_ops_pro(uint16 _Opcode)
} }
void dsp_op_ext_ops_epi(uint16 _Opcode) void dsp_op_ext_ops_epi(u16 _Opcode)
{ {
if ((_Opcode & 0xFF) == 0){return;} if ((_Opcode & 0xFF) == 0){return;}

View File

@ -26,8 +26,8 @@
#ifndef _GDSP_EXT_OP_H #ifndef _GDSP_EXT_OP_H
#define _GDSP_EXT_OP_H #define _GDSP_EXT_OP_H
void dsp_op_ext_ops_pro(uint16 _Opcode); void dsp_op_ext_ops_pro(u16 _Opcode);
void dsp_op_ext_ops_epi(uint16 _Opcode); void dsp_op_ext_ops_epi(u16 _Opcode);
#endif #endif

View File

@ -28,8 +28,8 @@
#ifndef _GDSP_IFX_H #ifndef _GDSP_IFX_H
#define _GDSP_IFX_H #define _GDSP_IFX_H
void gdsp_ifx_write(uint16 addr, uint16 val); void gdsp_ifx_write(u16 addr, u16 val);
uint16 gdsp_ifx_read(uint16 addr); u16 gdsp_ifx_read(u16 addr);
#endif #endif

View File

@ -66,9 +66,9 @@ void gdsp_dma();
Common::CriticalSection g_CriticalSection; Common::CriticalSection g_CriticalSection;
#endif #endif
static volatile uint16 gdsp_mbox[2][2]; static volatile u16 gdsp_mbox[2][2];
uint16 gdsp_ifx_regs[256]; u16 gdsp_ifx_regs[256];
void gdsp_ifx_init() void gdsp_ifx_init()
{ {
@ -86,12 +86,12 @@ void gdsp_ifx_init()
} }
uint32 gdsp_mbox_peek(uint8 mbx) u32 gdsp_mbox_peek(u8 mbx)
{ {
#if WITH_DSP_ON_THREAD #if WITH_DSP_ON_THREAD
g_CriticalSection.Enter(); g_CriticalSection.Enter();
#endif #endif
uint32 value = ((gdsp_mbox[mbx][0] << 16) | gdsp_mbox[mbx][1]); u32 value = ((gdsp_mbox[mbx][0] << 16) | gdsp_mbox[mbx][1]);
#if WITH_DSP_ON_THREAD #if WITH_DSP_ON_THREAD
g_CriticalSection.Leave(); g_CriticalSection.Leave();
#endif #endif
@ -99,7 +99,7 @@ uint32 gdsp_mbox_peek(uint8 mbx)
} }
void gdsp_mbox_write_h(uint8 mbx, uint16 val) void gdsp_mbox_write_h(u8 mbx, u16 val)
{ {
#if WITH_DSP_ON_THREAD #if WITH_DSP_ON_THREAD
g_CriticalSection.Enter(); g_CriticalSection.Enter();
@ -113,7 +113,7 @@ void gdsp_mbox_write_h(uint8 mbx, uint16 val)
} }
void gdsp_mbox_write_l(uint8 mbx, uint16 val) void gdsp_mbox_write_l(u8 mbx, u16 val)
{ {
#if WITH_DSP_ON_THREAD #if WITH_DSP_ON_THREAD
g_CriticalSection.Enter(); g_CriticalSection.Enter();
@ -133,15 +133,15 @@ void gdsp_mbox_write_l(uint8 mbx, uint16 val)
} }
uint16 gdsp_mbox_read_h(uint8 mbx) u16 gdsp_mbox_read_h(u8 mbx)
{ {
return (gdsp_mbox[mbx][0]); return (gdsp_mbox[mbx][0]);
} }
uint16 gdsp_mbox_read_l(uint8 mbx) u16 gdsp_mbox_read_l(u8 mbx)
{ {
uint16 val; u16 val;
#if WITH_DSP_ON_THREAD #if WITH_DSP_ON_THREAD
g_CriticalSection.Enter(); g_CriticalSection.Enter();
#endif #endif
@ -156,7 +156,7 @@ uint16 gdsp_mbox_read_l(uint8 mbx)
} }
void gdsp_ifx_write(uint16 addr, uint16 val) void gdsp_ifx_write(u16 addr, u16 val)
{ {
addr &= 0xff; addr &= 0xff;
@ -203,9 +203,9 @@ void gdsp_ifx_write(uint16 addr, uint16 val)
} }
uint16 gdsp_ifx_read(uint16 addr) u16 gdsp_ifx_read(u16 addr)
{ {
uint16 val; u16 val;
addr &= 0xff; addr &= 0xff;
@ -244,13 +244,13 @@ uint16 gdsp_ifx_read(uint16 addr)
} }
void gdsp_idma_in(uint16 dsp_addr, uint32 addr, uint32 size) void gdsp_idma_in(u16 dsp_addr, u32 addr, u32 size)
{ {
uint8* dst = ((uint8*)g_dsp.iram); u8* dst = ((u8*)g_dsp.iram);
for (uint32 i = 0; i < size; i += 2) for (u32 i = 0; i < size; i += 2)
{ {
*(uint16*)&dst[dsp_addr + i] = *(uint16*)&g_dsp.cpu_ram[(addr + i) & 0x0fffffff]; *(u16*)&dst[dsp_addr + i] = *(u16*)&g_dsp.cpu_ram[(addr + i) & 0x0fffffff];
} }
g_dsp.iram_crc = GenerateCRC(g_dsp.cpu_ram + (addr & 0x0fffffff), size); g_dsp.iram_crc = GenerateCRC(g_dsp.cpu_ram + (addr & 0x0fffffff), size);
@ -262,13 +262,13 @@ void gdsp_idma_in(uint16 dsp_addr, uint32 addr, uint32 size)
} }
void gdsp_idma_out(uint16 dsp_addr, uint32 addr, uint32 size) void gdsp_idma_out(u16 dsp_addr, u32 addr, u32 size)
{ {
ERROR_LOG(DSPHLE, "*** idma_out IRAM_DSP (0x%04x) -> RAM (0x%08x) : size (0x%08x)\n", dsp_addr / 2, addr, size); ERROR_LOG(DSPHLE, "*** idma_out IRAM_DSP (0x%04x) -> RAM (0x%08x) : size (0x%08x)\n", dsp_addr / 2, addr, size);
} }
void gdsp_ddma_in(uint16 dsp_addr, uint32 addr, uint32 size) void gdsp_ddma_in(u16 dsp_addr, u32 addr, u32 size)
{ {
if ((addr & 0x7FFFFFFF) > 0x01FFFFFF) if ((addr & 0x7FFFFFFF) > 0x01FFFFFF)
{ {
@ -276,18 +276,18 @@ void gdsp_ddma_in(uint16 dsp_addr, uint32 addr, uint32 size)
return; return;
} }
uint8* dst = ((uint8*)g_dsp.dram); u8* dst = ((u8*)g_dsp.dram);
for (uint32 i = 0; i < size; i += 2) for (u32 i = 0; i < size; i += 2)
{ {
*(uint16*)&dst[dsp_addr + i] = *(uint16*)&g_dsp.cpu_ram[(addr + i) & 0x7FFFFFFF]; *(u16*)&dst[dsp_addr + i] = *(u16*)&g_dsp.cpu_ram[(addr + i) & 0x7FFFFFFF];
} }
DEBUG_LOG(DSPHLE, "*** ddma_in RAM (0x%08x) -> DRAM_DSP (0x%04x) : size (0x%08x)\n", addr, dsp_addr / 2, size); DEBUG_LOG(DSPHLE, "*** ddma_in RAM (0x%08x) -> DRAM_DSP (0x%04x) : size (0x%08x)\n", addr, dsp_addr / 2, size);
} }
void gdsp_ddma_out(uint16 dsp_addr, uint32 addr, uint32 size) void gdsp_ddma_out(u16 dsp_addr, u32 addr, u32 size)
{ {
if ((addr & 0x7FFFFFFF) > 0x01FFFFFF) if ((addr & 0x7FFFFFFF) > 0x01FFFFFF)
{ {
@ -295,11 +295,11 @@ void gdsp_ddma_out(uint16 dsp_addr, uint32 addr, uint32 size)
return; return;
} }
uint8* src = ((uint8*)g_dsp.dram); u8* src = ((u8*)g_dsp.dram);
for (uint32 i = 0; i < size; i += 2) for (u32 i = 0; i < size; i += 2)
{ {
*(uint16*)&g_dsp.cpu_ram[(addr + i) & 0x7FFFFFFF] = *(uint16*)&src[dsp_addr + i]; *(u16*)&g_dsp.cpu_ram[(addr + i) & 0x7FFFFFFF] = *(u16*)&src[dsp_addr + i];
} }
DEBUG_LOG(DSPHLE, "*** ddma_out DRAM_DSP (0x%04x) -> RAM (0x%08x) : size (0x%08x)\n", dsp_addr / 2, addr, size); DEBUG_LOG(DSPHLE, "*** ddma_out DRAM_DSP (0x%04x) -> RAM (0x%08x) : size (0x%08x)\n", dsp_addr / 2, addr, size);
@ -313,10 +313,10 @@ void gdsp_ddma_out(uint16 dsp_addr, uint32 addr, uint32 size)
void gdsp_dma() void gdsp_dma()
{ {
uint16 ctl; u16 ctl;
uint32 addr; u32 addr;
uint16 dsp_addr; u16 dsp_addr;
uint16 len; u16 len;
addr = (gdsp_ifx_regs[DSP_DSMAH] << 16) | gdsp_ifx_regs[DSP_DSMAL]; addr = (gdsp_ifx_regs[DSP_DSMAH] << 16) | gdsp_ifx_regs[DSP_DSMAL];
ctl = gdsp_ifx_regs[DSP_DSCR]; ctl = gdsp_ifx_regs[DSP_DSCR];

View File

@ -50,17 +50,17 @@
#define DSP_ARAM 0xdd #define DSP_ARAM 0xdd
#define DSP_GAIN 0xde #define DSP_GAIN 0xde
extern uint16 gdsp_ifx_regs[256]; extern u16 gdsp_ifx_regs[256];
uint32 gdsp_mbox_peek(uint8 mbx); u32 gdsp_mbox_peek(u8 mbx);
void gdsp_mbox_write_h(uint8 mbx, uint16 val); void gdsp_mbox_write_h(u8 mbx, u16 val);
void gdsp_mbox_write_l(uint8 mbx, uint16 val); void gdsp_mbox_write_l(u8 mbx, u16 val);
uint16 gdsp_mbox_read_h(uint8 mbx); u16 gdsp_mbox_read_h(u8 mbx);
uint16 gdsp_mbox_read_l(uint8 mbx); u16 gdsp_mbox_read_l(u8 mbx);
void gdsp_ifx_init(); void gdsp_ifx_init();
void gdsp_idma_in(uint16 dsp_addr, uint32 addr, uint32 size); void gdsp_idma_in(u16 dsp_addr, u32 addr, u32 size);
#endif #endif

View File

@ -34,25 +34,25 @@
SDSP g_dsp; SDSP g_dsp;
uint16 SDSP::r[32]; u16 SDSP::r[32];
uint16 SDSP::pc = 0; u16 SDSP::pc = 0;
uint16 SDSP::err_pc = 0; u16 SDSP::err_pc = 0;
uint16* SDSP::iram = 0; u16* SDSP::iram = 0;
uint16* SDSP::dram = 0; u16* SDSP::dram = 0;
uint16* SDSP::irom = 0; u16* SDSP::irom = 0;
uint16* SDSP::drom = 0; u16* SDSP::drom = 0;
uint16* SDSP::coef = 0; u16* SDSP::coef = 0;
uint8* SDSP::cpu_ram = 0; u8* SDSP::cpu_ram = 0;
uint16 SDSP::cr = 0; u16 SDSP::cr = 0;
uint8 SDSP::reg_stack_ptr[4]; u8 SDSP::reg_stack_ptr[4];
// lets make stack depth to 32 for now // lets make stack depth to 32 for now
uint16 SDSP::reg_stack[4][DSP_STACK_DEPTH]; u16 SDSP::reg_stack[4][DSP_STACK_DEPTH];
void (*SDSP::irq_request)() = NULL; void (*SDSP::irq_request)() = NULL;
bool SDSP::exception_in_progress_hack = false; bool SDSP::exception_in_progress_hack = false;
// for debugger only // for debugger only
uint32 SDSP::iram_crc = 0; u32 SDSP::iram_crc = 0;
uint64 SDSP::step_counter = 0; u64 SDSP::step_counter = 0;
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
@ -69,7 +69,7 @@ void UpdateCachedCR()
//------------------------------------------------------------------------------- //-------------------------------------------------------------------------------
void (*dsp_op[])(uint16 opc) = void (*dsp_op[])(u16 opc) =
{ {
dsp_op0, dsp_op1, dsp_op2, dsp_op3, dsp_op0, dsp_op1, dsp_op2, dsp_op3,
dsp_op4, dsp_op5, dsp_op6, dsp_op7, dsp_op4, dsp_op5, dsp_op6, dsp_op7,
@ -85,11 +85,11 @@ void dbg_error(char* err_msg)
void gdsp_init() void gdsp_init()
{ {
g_dsp.irom = (uint16*)malloc(DSP_IROM_SIZE * sizeof(uint16)); g_dsp.irom = (u16*)malloc(DSP_IROM_SIZE * sizeof(u16));
g_dsp.iram = (uint16*)malloc(DSP_IRAM_SIZE * sizeof(uint16)); g_dsp.iram = (u16*)malloc(DSP_IRAM_SIZE * sizeof(u16));
g_dsp.drom = (uint16*)malloc(DSP_DROM_SIZE * sizeof(uint16)); g_dsp.drom = (u16*)malloc(DSP_DROM_SIZE * sizeof(u16));
g_dsp.dram = (uint16*)malloc(DSP_DRAM_SIZE * sizeof(uint16)); g_dsp.dram = (u16*)malloc(DSP_DRAM_SIZE * sizeof(u16));
g_dsp.coef = (uint16*)malloc(DSP_COEF_SIZE * sizeof(uint16)); g_dsp.coef = (u16*)malloc(DSP_COEF_SIZE * sizeof(u16));
for (int i = 0; i < DSP_IRAM_SIZE; i++) for (int i = 0; i < DSP_IRAM_SIZE; i++)
{ {
@ -138,8 +138,8 @@ void gdsp_reset()
} }
uint8 gdsp_exceptions = 0; u8 gdsp_exceptions = 0;
void gdsp_generate_exception(uint8 level) void gdsp_generate_exception(u8 level)
{ {
gdsp_exceptions |= 1 << level; gdsp_exceptions |= 1 << level;
} }
@ -175,7 +175,7 @@ bool gdsp_load_coef(char* fname)
} }
void gdsp_write_cr(uint16 val) void gdsp_write_cr(u16 val)
{ {
// reset // reset
if (val & 0x0001) if (val & 0x0001)
@ -192,7 +192,7 @@ void gdsp_write_cr(uint16 val)
} }
uint16 gdsp_read_cr() u16 gdsp_read_cr()
{ {
if (g_dsp.pc & 0x8000) if (g_dsp.pc & 0x8000)
{ {
@ -216,7 +216,7 @@ uint16 gdsp_read_cr()
void gdsp_loop_step() void gdsp_loop_step()
{ {
g_dsp.err_pc = g_dsp.pc; g_dsp.err_pc = g_dsp.pc;
uint16 opc = dsp_fetch_code(); u16 opc = dsp_fetch_code();
dsp_op[opc >> 12](opc); dsp_op[opc >> 12](opc);
} }
@ -247,15 +247,15 @@ void gdsp_step()
#endif #endif
uint16 opc = dsp_fetch_code(); u16 opc = dsp_fetch_code();
dsp_op[opc >> 12](opc); dsp_op[opc >> 12](opc);
uint16& rLoopCounter = g_dsp.r[DSP_REG_ST0 + 3]; u16& rLoopCounter = g_dsp.r[DSP_REG_ST0 + 3];
if (rLoopCounter > 0) if (rLoopCounter > 0)
{ {
const uint16& rCallAddress = g_dsp.r[DSP_REG_ST0 + 0]; const u16& rCallAddress = g_dsp.r[DSP_REG_ST0 + 0];
const uint16& rLoopAddress = g_dsp.r[DSP_REG_ST0 + 2]; const u16& rLoopAddress = g_dsp.r[DSP_REG_ST0 + 2];
if (g_dsp.pc == (rLoopAddress + 1)) if (g_dsp.pc == (rLoopAddress + 1))
{ {
@ -290,7 +290,7 @@ void gdsp_step()
// check exceptions // check exceptions
if ((gdsp_exceptions > 0) && (!g_dsp.exception_in_progress_hack)) if ((gdsp_exceptions > 0) && (!g_dsp.exception_in_progress_hack))
{ {
for (uint8 i=0; i<8; i++) for (u8 i=0; i<8; i++)
{ {
if (gdsp_exceptions & (1<<i)) if (gdsp_exceptions & (1<<i))
{ {
@ -311,7 +311,7 @@ void gdsp_step()
bool gdsp_running; bool gdsp_running;
extern volatile uint32 dsp_running; extern volatile u32 dsp_running;
bool gdsp_run() bool gdsp_run()
{ {
@ -327,7 +327,7 @@ bool gdsp_run()
} }
bool gdsp_runx(uint16 cnt) bool gdsp_runx(u16 cnt)
{ {
gdsp_running = true; gdsp_running = true;
@ -363,10 +363,10 @@ void gdsp_stop()
//#include "WaveFile.h" //#include "WaveFile.h"
#include "Mixer.h" #include "Mixer.h"
uint16 r30 = 0, r31 = 0; u16 r30 = 0, r31 = 0;
//extern WaveFileWriter g_wave_writer; //extern WaveFileWriter g_wave_writer;
extern uint16 dsp_swap16(uint16 x); extern u16 dsp_swap16(u16 x);
void Hacks() void Hacks()
{ {
// if (g_wave_writer.GetAudioSize() > 1024*1024*1) // if (g_wave_writer.GetAudioSize() > 1024*1024*1)
@ -400,7 +400,7 @@ void Hacks()
const int numSamples = 0x280; const int numSamples = 0x280;
static short Buffer[numSamples]; static short Buffer[numSamples];
uint16 bufferAddr = 0x280; //dsp_dmem_read(0xe44); u16 bufferAddr = 0x280; //dsp_dmem_read(0xe44);
for (int i=0; i<numSamples; i++) for (int i=0; i<numSamples; i++)
{ {
Buffer[i] = dsp_dmem_read(bufferAddr+i); Buffer[i] = dsp_dmem_read(bufferAddr+i);
@ -420,7 +420,7 @@ void Hacks()
if (g_dsp.pc == 0x468) if (g_dsp.pc == 0x468)
{ {
int numSamples = g_dsp.r[25] / 2; int numSamples = g_dsp.r[25] / 2;
uint16 bufferAddr = g_dsp.r[27]; u16 bufferAddr = g_dsp.r[27];
// PanicAlert("%x %x", bufferAddr, numSamples); // PanicAlert("%x %x", bufferAddr, numSamples);

View File

@ -46,24 +46,24 @@
struct SDSP struct SDSP
{ {
static uint16 r[32]; static u16 r[32];
static uint16 pc; static u16 pc;
static uint16 err_pc; static u16 err_pc;
static uint16* iram; static u16* iram;
static uint16* dram; static u16* dram;
static uint16* irom; static u16* irom;
static uint16* drom; static u16* drom;
static uint16* coef; static u16* coef;
static uint8* cpu_ram; static u8* cpu_ram;
static uint16 cr; static u16 cr;
static uint8 reg_stack_ptr[4]; static u8 reg_stack_ptr[4];
// lets make stack depth to 32 for now // lets make stack depth to 32 for now
static uint16 reg_stack[4][DSP_STACK_DEPTH]; static u16 reg_stack[4][DSP_STACK_DEPTH];
static void (* irq_request)(void); static void (* irq_request)(void);
// for debugger only // for debugger only
static uint32 iram_crc; static u32 iram_crc;
static uint64 step_counter; static u64 step_counter;
static bool exception_in_progress_hack; static bool exception_in_progress_hack;
}; };
@ -80,15 +80,15 @@ bool gdsp_load_coef(char* fname);
void gdsp_step(void); void gdsp_step(void);
void gdsp_loop_step(); void gdsp_loop_step();
bool gdsp_run(void); bool gdsp_run(void);
bool gdsp_runx(uint16 cnt); bool gdsp_runx(u16 cnt);
void gdsp_stop(void); void gdsp_stop(void);
void gdsp_write_cr(uint16 val); void gdsp_write_cr(u16 val);
uint16 gdsp_read_cr(void); u16 gdsp_read_cr(void);
uint16* gdsp_get_iram(void); u16* gdsp_get_iram(void);
uint16* gdsp_get_irom(void); u16* gdsp_get_irom(void);
uint16* gdsp_get_dram(void); u16* gdsp_get_dram(void);
uint16* gdsp_get_drom(void); u16* gdsp_get_drom(void);
#endif #endif

View File

@ -29,39 +29,39 @@
#include "gdsp_memory.h" #include "gdsp_memory.h"
#include "gdsp_ifx.h" #include "gdsp_ifx.h"
uint16 dsp_swap16(uint16 x) u16 dsp_swap16(u16 x)
{ {
return((x >> 8) | (x << 8)); return((x >> 8) | (x << 8));
} }
uint16* gdsp_get_iram(void) u16* gdsp_get_iram(void)
{ {
return(g_dsp.iram); return(g_dsp.iram);
} }
uint16* gdsp_get_irom(void) u16* gdsp_get_irom(void)
{ {
return(g_dsp.irom); return(g_dsp.irom);
} }
uint16* gdsp_get_dram(void) u16* gdsp_get_dram(void)
{ {
return(g_dsp.dram); return(g_dsp.dram);
} }
uint16* gdsp_get_drom(void) u16* gdsp_get_drom(void)
{ {
return(g_dsp.drom); return(g_dsp.drom);
} }
uint16 dsp_imem_read(uint16 addr) u16 dsp_imem_read(u16 addr)
{ {
uint16 opc; u16 opc;
if (g_dsp.pc & 0x8000) if (g_dsp.pc & 0x8000)
{ {
@ -76,9 +76,9 @@ uint16 dsp_imem_read(uint16 addr)
} }
uint16 dsp_dmem_read(uint16 addr) u16 dsp_dmem_read(u16 addr)
{ {
uint16 val; u16 val;
switch (addr >> 12) switch (addr >> 12)
{ {
@ -112,7 +112,7 @@ uint16 dsp_dmem_read(uint16 addr)
} }
bool dsp_dmem_write(uint16 addr, uint16 val) bool dsp_dmem_write(u16 addr, u16 val)
{ {
switch (addr >> 12) switch (addr >> 12)
{ {
@ -140,15 +140,15 @@ bool dsp_dmem_write(uint16 addr, uint16 val)
} }
uint16 dsp_fetch_code(void) u16 dsp_fetch_code(void)
{ {
uint16 opc = dsp_imem_read(g_dsp.pc); u16 opc = dsp_imem_read(g_dsp.pc);
g_dsp.pc++; g_dsp.pc++;
return(opc); return(opc);
} }
uint16 dsp_peek_code(void) u16 dsp_peek_code(void)
{ {
return(dsp_imem_read(g_dsp.pc)); return(dsp_imem_read(g_dsp.pc));
} }

View File

@ -27,11 +27,11 @@
#include "Globals.h" #include "Globals.h"
uint16 dsp_fetch_code(void); u16 dsp_fetch_code(void);
uint16 dsp_peek_code(void); u16 dsp_peek_code(void);
uint16 dsp_imem_read(uint16 addr); u16 dsp_imem_read(u16 addr);
bool dsp_dmem_write(uint16 addr, uint16 val); bool dsp_dmem_write(u16 addr, u16 val);
uint16 dsp_dmem_read(uint16 addr); u16 dsp_dmem_read(u16 addr);
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -27,20 +27,20 @@
#include "Globals.h" #include "Globals.h"
void dsp_op0(uint16 opc); void dsp_op0(u16 opc);
void dsp_op1(uint16 opc); void dsp_op1(u16 opc);
void dsp_op2(uint16 opc); void dsp_op2(u16 opc);
void dsp_op3(uint16 opc); void dsp_op3(u16 opc);
void dsp_op4(uint16 opc); void dsp_op4(u16 opc);
void dsp_op5(uint16 opc); void dsp_op5(u16 opc);
void dsp_op6(uint16 opc); void dsp_op6(u16 opc);
void dsp_op7(uint16 opc); void dsp_op7(u16 opc);
void dsp_op8(uint16 opc); void dsp_op8(u16 opc);
void dsp_op9(uint16 opc); void dsp_op9(u16 opc);
void dsp_opab(uint16 opc); void dsp_opab(u16 opc);
void dsp_opcd(uint16 opc); void dsp_opcd(u16 opc);
void dsp_ope(uint16 opc); void dsp_ope(u16 opc);
void dsp_opf(uint16 opc); void dsp_opf(u16 opc);
#define R_SR 0x13 #define R_SR 0x13

View File

@ -40,13 +40,13 @@
// //
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
inline void dsp_SR_set_flag(uint8 flag) inline void dsp_SR_set_flag(u8 flag)
{ {
g_dsp.r[R_SR] |= (1 << flag); g_dsp.r[R_SR] |= (1 << flag);
} }
inline bool dsp_SR_is_flag_set(uint8 flag) inline bool dsp_SR_is_flag_set(u8 flag)
{ {
return((g_dsp.r[R_SR] & (1 << flag)) > 0); return((g_dsp.r[R_SR] & (1 << flag)) > 0);
} }
@ -58,9 +58,9 @@ inline bool dsp_SR_is_flag_set(uint8 flag)
// //
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
inline uint16 dsp_op_read_reg(uint8 reg) inline u16 dsp_op_read_reg(u8 reg)
{ {
uint16 val; u16 val;
switch (reg & 0x1f) switch (reg & 0x1f)
{ {
@ -80,7 +80,7 @@ inline uint16 dsp_op_read_reg(uint8 reg)
} }
inline void dsp_op_write_reg(uint8 reg, uint16 val) inline void dsp_op_write_reg(u8 reg, u16 val)
{ {
switch (reg & 0x1f) switch (reg & 0x1f)
{ {
@ -105,15 +105,15 @@ inline void dsp_op_write_reg(uint8 reg, uint16 val)
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
inline sint64 dsp_get_long_prod() inline s64 dsp_get_long_prod()
{ {
#if PROFILE #if PROFILE
ProfilerAddDelta(g_dsp.err_pc, 1); ProfilerAddDelta(g_dsp.err_pc, 1);
#endif #endif
sint64 val; s64 val;
sint64 low_prod; s64 low_prod;
val = (sint8)g_dsp.r[0x16]; val = (s8)g_dsp.r[0x16];
val <<= 32; val <<= 32;
low_prod = g_dsp.r[0x15]; low_prod = g_dsp.r[0x15];
low_prod += g_dsp.r[0x17]; low_prod += g_dsp.r[0x17];
@ -124,17 +124,17 @@ inline sint64 dsp_get_long_prod()
} }
inline void dsp_set_long_prod(sint64 val) inline void dsp_set_long_prod(s64 val)
{ {
#if PROFILE #if PROFILE
ProfilerAddDelta(g_dsp.err_pc, 1); ProfilerAddDelta(g_dsp.err_pc, 1);
#endif #endif
g_dsp.r[0x14] = (uint16)val; g_dsp.r[0x14] = (u16)val;
val >>= 16; val >>= 16;
g_dsp.r[0x15] = (uint16)val; g_dsp.r[0x15] = (u16)val;
val >>= 16; val >>= 16;
g_dsp.r[0x16] = (uint16)val; g_dsp.r[0x16] = (u16)val;
g_dsp.r[0x17] = 0; g_dsp.r[0x17] = 0;
} }
@ -145,16 +145,16 @@ inline void dsp_set_long_prod(sint64 val)
// //
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
inline sint64 dsp_get_long_acc(uint8 reg) inline s64 dsp_get_long_acc(u8 reg)
{ {
#if PROFILE #if PROFILE
ProfilerAddDelta(g_dsp.err_pc, 1); ProfilerAddDelta(g_dsp.err_pc, 1);
#endif #endif
_assert_(reg < 2); _assert_(reg < 2);
sint64 val; s64 val;
sint64 low_acc; s64 low_acc;
val = (sint8)g_dsp.r[0x10 + reg]; val = (s8)g_dsp.r[0x10 + reg];
val <<= 32; val <<= 32;
low_acc = g_dsp.r[0x1e + reg]; low_acc = g_dsp.r[0x1e + reg];
low_acc <<= 16; low_acc <<= 16;
@ -164,16 +164,16 @@ inline sint64 dsp_get_long_acc(uint8 reg)
} }
inline uint64 dsp_get_ulong_acc(uint8 reg) inline u64 dsp_get_ulong_acc(u8 reg)
{ {
#if PROFILE #if PROFILE
ProfilerAddDelta(g_dsp.err_pc, 1); ProfilerAddDelta(g_dsp.err_pc, 1);
#endif #endif
_assert_(reg < 2); _assert_(reg < 2);
uint64 val; u64 val;
uint64 low_acc; u64 low_acc;
val = (uint8)g_dsp.r[0x10 + reg]; val = (u8)g_dsp.r[0x10 + reg];
val <<= 32; val <<= 32;
low_acc = g_dsp.r[0x1e + reg]; low_acc = g_dsp.r[0x1e + reg];
low_acc <<= 16; low_acc <<= 16;
@ -183,36 +183,36 @@ inline uint64 dsp_get_ulong_acc(uint8 reg)
} }
inline void dsp_set_long_acc(uint8 _reg, sint64 val) inline void dsp_set_long_acc(u8 _reg, s64 val)
{ {
#if PROFILE #if PROFILE
ProfilerAddDelta(g_dsp.err_pc, 1); ProfilerAddDelta(g_dsp.err_pc, 1);
#endif #endif
_assert_(_reg < 2); _assert_(_reg < 2);
g_dsp.r[0x1c + _reg] = (uint16)val; g_dsp.r[0x1c + _reg] = (u16)val;
val >>= 16; val >>= 16;
g_dsp.r[0x1e + _reg] = (uint16)val; g_dsp.r[0x1e + _reg] = (u16)val;
val >>= 16; val >>= 16;
g_dsp.r[0x10 + _reg] = (uint16)val; g_dsp.r[0x10 + _reg] = (u16)val;
} }
inline sint16 dsp_get_acc_l(uint8 _reg) inline s16 dsp_get_acc_l(u8 _reg)
{ {
_assert_(_reg < 2); _assert_(_reg < 2);
return(g_dsp.r[0x1c + _reg]); return(g_dsp.r[0x1c + _reg]);
} }
inline sint16 dsp_get_acc_m(uint8 _reg) inline s16 dsp_get_acc_m(u8 _reg)
{ {
_assert_(_reg < 2); _assert_(_reg < 2);
return(g_dsp.r[0x1e + _reg]); return(g_dsp.r[0x1e + _reg]);
} }
inline sint16 dsp_get_acc_h(uint8 _reg) inline s16 dsp_get_acc_h(u8 _reg)
{ {
_assert_(_reg < 2); _assert_(_reg < 2);
return(g_dsp.r[0x10 + _reg]); return(g_dsp.r[0x10 + _reg]);
@ -226,29 +226,29 @@ inline sint16 dsp_get_acc_h(uint8 _reg)
// --------------------------------------------------------------------------------------- // ---------------------------------------------------------------------------------------
inline sint64 dsp_get_long_acx(uint8 _reg) inline s64 dsp_get_long_acx(u8 _reg)
{ {
#if PROFILE #if PROFILE
ProfilerAddDelta(g_dsp.err_pc, 1); ProfilerAddDelta(g_dsp.err_pc, 1);
#endif #endif
_assert_(_reg < 2); _assert_(_reg < 2);
sint64 val = (sint16)g_dsp.r[0x1a + _reg]; s64 val = (s16)g_dsp.r[0x1a + _reg];
val <<= 16; val <<= 16;
sint64 low_acc = g_dsp.r[0x18 + _reg]; s64 low_acc = g_dsp.r[0x18 + _reg];
val |= low_acc; val |= low_acc;
return(val); return(val);
} }
inline sint16 dsp_get_ax_l(uint8 _reg) inline s16 dsp_get_ax_l(u8 _reg)
{ {
_assert_(_reg < 2); _assert_(_reg < 2);
return(g_dsp.r[0x18 + _reg]); return(g_dsp.r[0x18 + _reg]);
} }
inline sint16 dsp_get_ax_h(uint8 _reg) inline s16 dsp_get_ax_h(u8 _reg)
{ {
_assert_(_reg < 2); _assert_(_reg < 2);
return(g_dsp.r[0x1a + _reg]); return(g_dsp.r[0x1a + _reg]);

View File

@ -29,7 +29,7 @@
void dsp_reg_stack_push(uint8 stack_reg) void dsp_reg_stack_push(u8 stack_reg)
{ {
g_dsp.reg_stack_ptr[stack_reg]++; g_dsp.reg_stack_ptr[stack_reg]++;
g_dsp.reg_stack_ptr[stack_reg] &= DSP_STACK_MASK; g_dsp.reg_stack_ptr[stack_reg] &= DSP_STACK_MASK;
@ -37,7 +37,7 @@ void dsp_reg_stack_push(uint8 stack_reg)
} }
void dsp_reg_stack_pop(uint8 stack_reg) void dsp_reg_stack_pop(u8 stack_reg)
{ {
g_dsp.r[DSP_REG_ST0 + stack_reg] = g_dsp.reg_stack[stack_reg][g_dsp.reg_stack_ptr[stack_reg]]; g_dsp.r[DSP_REG_ST0 + stack_reg] = g_dsp.reg_stack[stack_reg][g_dsp.reg_stack_ptr[stack_reg]];
g_dsp.reg_stack_ptr[stack_reg]--; g_dsp.reg_stack_ptr[stack_reg]--;
@ -45,16 +45,16 @@ void dsp_reg_stack_pop(uint8 stack_reg)
} }
void dsp_reg_store_stack(uint8 stack_reg, uint16 val) void dsp_reg_store_stack(u8 stack_reg, u16 val)
{ {
dsp_reg_stack_push(stack_reg); dsp_reg_stack_push(stack_reg);
g_dsp.r[DSP_REG_ST0 + stack_reg] = val; g_dsp.r[DSP_REG_ST0 + stack_reg] = val;
} }
uint16 dsp_reg_load_stack(uint8 stack_reg) u16 dsp_reg_load_stack(u8 stack_reg)
{ {
uint16 val = g_dsp.r[DSP_REG_ST0 + stack_reg]; u16 val = g_dsp.r[DSP_REG_ST0 + stack_reg];
dsp_reg_stack_pop(stack_reg); dsp_reg_stack_pop(stack_reg);
return(val); return(val);
} }

View File

@ -35,8 +35,8 @@
#define DSP_STACK_C 0 #define DSP_STACK_C 0
#define DSP_STACK_D 1 #define DSP_STACK_D 1
void dsp_reg_store_stack(uint8 stack_reg, uint16 val); void dsp_reg_store_stack(u8 stack_reg, u16 val);
uint16 dsp_reg_load_stack(uint8 stack_reg); u16 dsp_reg_load_stack(u8 stack_reg);
#endif #endif

View File

@ -45,8 +45,8 @@ SoundStream *soundStream = NULL;
#define GDSP_MBOX_CPU 0 #define GDSP_MBOX_CPU 0
#define GDSP_MBOX_DSP 1 #define GDSP_MBOX_DSP 1
uint32 g_LastDMAAddress = 0; u32 g_LastDMAAddress = 0;
uint32 g_LastDMASize = 0; u32 g_LastDMASize = 0;
extern u32 m_addressPBs; extern u32 m_addressPBs;
bool AXTask(u32& _uMail); bool AXTask(u32& _uMail);

View File

@ -232,6 +232,6 @@ opc_t opcodes_ext[] =
{"XXX", 0x0000, 0x0000, 1, 1, {{P_VAL, 1, 0, 0, 0x00ff}},}, {"XXX", 0x0000, 0x0000, 1, 1, {{P_VAL, 1, 0, 0, 0x00ff}},},
}; };
const uint32 opcodes_size = sizeof(opcodes) / sizeof(opc_t); const u32 opcodes_size = sizeof(opcodes) / sizeof(opc_t);
const uint32 opcodes_ext_size = sizeof(opcodes_ext) / sizeof(opc_t); const u32 opcodes_ext_size = sizeof(opcodes_ext) / sizeof(opc_t);

View File

@ -55,28 +55,28 @@ enum partype_t
typedef struct opcpar_t typedef struct opcpar_t
{ {
partype_t type; partype_t type;
uint8 size; u8 size;
uint8 loc; u8 loc;
sint8 lshift; s8 lshift;
uint16 mask; u16 mask;
} opcpar_t; } opcpar_t;
typedef struct opc_t typedef struct opc_t
{ {
const char* name; const char* name;
uint16 opcode; u16 opcode;
uint16 opcode_mask; u16 opcode_mask;
uint8 size; u8 size;
uint8 param_count; u8 param_count;
opcpar_t params[8]; opcpar_t params[8];
} opc_t; } opc_t;
extern opc_t opcodes[]; extern opc_t opcodes[];
extern const uint32 opcodes_size; extern const u32 opcodes_size;
extern opc_t opcodes_ext[]; extern opc_t opcodes_ext[];
extern const uint32 opcodes_ext_size; extern const u32 opcodes_ext_size;
inline uint16 swap16(uint16 x) inline u16 swap16(u16 x)
{ {
return((x >> 8) | (x << 8)); return((x >> 8) | (x << 8));
} }