Merge pull request #146 from cxd4/yo_dawg_i_herd_u_liek_stdint

Redo pull request #92
This commit is contained in:
zilmar 2015-02-26 16:20:33 +11:00
commit f5e36d8356
6 changed files with 208 additions and 176 deletions

View File

@ -99,19 +99,19 @@ void RSP_Opcode_BGTZ ( void ) {
void RSP_Opcode_ADDI ( void ) { void RSP_Opcode_ADDI ( void ) {
if (RSPOpC.rt != 0) { if (RSPOpC.rt != 0) {
RSP_GPR[RSPOpC.rt].W = RSP_GPR[RSPOpC.rs].W + (short)RSPOpC.immediate; RSP_GPR[RSPOpC.rt].W = RSP_GPR[RSPOpC.rs].W + (int16_t)RSPOpC.immediate;
} }
} }
void RSP_Opcode_ADDIU ( void ) { void RSP_Opcode_ADDIU ( void ) {
if (RSPOpC.rt != 0) { if (RSPOpC.rt != 0) {
RSP_GPR[RSPOpC.rt].UW = RSP_GPR[RSPOpC.rs].UW + (DWORD)((short)RSPOpC.immediate); RSP_GPR[RSPOpC.rt].UW = RSP_GPR[RSPOpC.rs].UW + (uint32_t)((int16_t)RSPOpC.immediate);
} }
} }
void RSP_Opcode_SLTI (void) { void RSP_Opcode_SLTI (void) {
if (RSPOpC.rt == 0) { return; } if (RSPOpC.rt == 0) { return; }
if (RSP_GPR[RSPOpC.rs].W < (short)RSPOpC.immediate) { if (RSP_GPR[RSPOpC.rs].W < (int16_t)RSPOpC.immediate) {
RSP_GPR[RSPOpC.rt].W = 1; RSP_GPR[RSPOpC.rt].W = 1;
} else { } else {
RSP_GPR[RSPOpC.rt].W = 0; RSP_GPR[RSPOpC.rt].W = 0;
@ -120,7 +120,7 @@ void RSP_Opcode_SLTI (void) {
void RSP_Opcode_SLTIU (void) { void RSP_Opcode_SLTIU (void) {
if (RSPOpC.rt == 0) { return; } if (RSPOpC.rt == 0) { return; }
if (RSP_GPR[RSPOpC.rs].UW < (DWORD)(short)RSPOpC.immediate) { if (RSP_GPR[RSPOpC.rs].UW < (uint32_t)(int16_t)RSPOpC.immediate) {
RSP_GPR[RSPOpC.rt].W = 1; RSP_GPR[RSPOpC.rt].W = 1;
} else { } else {
RSP_GPR[RSPOpC.rt].W = 0; RSP_GPR[RSPOpC.rt].W = 0;
@ -147,7 +147,7 @@ void RSP_Opcode_XORI ( void ) {
void RSP_Opcode_LUI (void) { void RSP_Opcode_LUI (void) {
if (RSPOpC.rt != 0) { if (RSPOpC.rt != 0) {
RSP_GPR[RSPOpC.rt].W = (short)RSPOpC.offset << 16; RSP_GPR[RSPOpC.rt].W = RSPOpC.immediate << 16;
} }
} }
@ -160,46 +160,46 @@ void RSP_Opcode_COP2 (void) {
} }
void RSP_Opcode_LB ( void ) { void RSP_Opcode_LB ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (short)RSPOpC.offset) & 0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (short)RSPOpC.offset) & 0xFFF;
RSP_LB_DMEM( Address, &RSP_GPR[RSPOpC.rt].UB[0] ); RSP_LB_DMEM( Address, &RSP_GPR[RSPOpC.rt].UB[0] );
RSP_GPR[RSPOpC.rt].W = RSP_GPR[RSPOpC.rt].B[0]; RSP_GPR[RSPOpC.rt].W = RSP_GPR[RSPOpC.rt].B[0];
} }
void RSP_Opcode_LH ( void ) { void RSP_Opcode_LH ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (short)RSPOpC.offset) & 0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (short)RSPOpC.offset) & 0xFFF;
RSP_LH_DMEM( Address, &RSP_GPR[RSPOpC.rt].UHW[0] ); RSP_LH_DMEM( Address, &RSP_GPR[RSPOpC.rt].UHW[0] );
RSP_GPR[RSPOpC.rt].W = RSP_GPR[RSPOpC.rt].HW[0]; RSP_GPR[RSPOpC.rt].W = RSP_GPR[RSPOpC.rt].HW[0];
} }
void RSP_Opcode_LW ( void ) { void RSP_Opcode_LW ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (short)RSPOpC.offset) & 0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (short)RSPOpC.offset) & 0xFFF;
RSP_LW_DMEM( Address, &RSP_GPR[RSPOpC.rt].UW ); RSP_LW_DMEM( Address, &RSP_GPR[RSPOpC.rt].UW );
} }
void RSP_Opcode_LBU ( void ) { void RSP_Opcode_LBU ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (short)RSPOpC.offset) & 0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (short)RSPOpC.offset) & 0xFFF;
RSP_LB_DMEM( Address, &RSP_GPR[RSPOpC.rt].UB[0] ); RSP_LB_DMEM( Address, &RSP_GPR[RSPOpC.rt].UB[0] );
RSP_GPR[RSPOpC.rt].UW = RSP_GPR[RSPOpC.rt].UB[0]; RSP_GPR[RSPOpC.rt].UW = RSP_GPR[RSPOpC.rt].UB[0];
} }
void RSP_Opcode_LHU ( void ) { void RSP_Opcode_LHU ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (short)RSPOpC.offset) & 0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (short)RSPOpC.offset) & 0xFFF;
RSP_LH_DMEM( Address, &RSP_GPR[RSPOpC.rt].UHW[0] ); RSP_LH_DMEM( Address, &RSP_GPR[RSPOpC.rt].UHW[0] );
RSP_GPR[RSPOpC.rt].UW = RSP_GPR[RSPOpC.rt].UHW[0]; RSP_GPR[RSPOpC.rt].UW = RSP_GPR[RSPOpC.rt].UHW[0];
} }
void RSP_Opcode_SB ( void ) { void RSP_Opcode_SB ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (short)RSPOpC.offset) & 0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (short)RSPOpC.offset) & 0xFFF;
RSP_SB_DMEM( Address, RSP_GPR[RSPOpC.rt].UB[0] ); RSP_SB_DMEM( Address, RSP_GPR[RSPOpC.rt].UB[0] );
} }
void RSP_Opcode_SH ( void ) { void RSP_Opcode_SH ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (short)RSPOpC.offset) & 0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (short)RSPOpC.offset) & 0xFFF;
RSP_SH_DMEM( Address, RSP_GPR[RSPOpC.rt].UHW[0] ); RSP_SH_DMEM( Address, RSP_GPR[RSPOpC.rt].UHW[0] );
} }
void RSP_Opcode_SW ( void ) { void RSP_Opcode_SW ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (short)RSPOpC.offset) & 0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (short)RSPOpC.offset) & 0xFFF;
RSP_SW_DMEM( Address, RSP_GPR[RSPOpC.rt].UW ); RSP_SW_DMEM( Address, RSP_GPR[RSPOpC.rt].UW );
} }
@ -210,6 +210,7 @@ void RSP_Opcode_LC2 (void) {
void RSP_Opcode_SC2 (void) { void RSP_Opcode_SC2 (void) {
RSP_Sc2 [ RSPOpC.rd ](); RSP_Sc2 [ RSPOpC.rd ]();
} }
/********************** R4300i OpCodes: Special **********************/ /********************** R4300i OpCodes: Special **********************/
void RSP_Special_SLL ( void ) { void RSP_Special_SLL ( void ) {
if (RSPOpC.rd != 0) { if (RSPOpC.rd != 0) {
@ -332,6 +333,7 @@ void RSP_Special_SLTU (void) {
RSP_GPR[RSPOpC.rd].UW = 0; RSP_GPR[RSPOpC.rd].UW = 0;
} }
} }
/********************** R4300i OpCodes: RegImm **********************/ /********************** R4300i OpCodes: RegImm **********************/
void RSP_Opcode_BLTZ ( void ) { void RSP_Opcode_BLTZ ( void ) {
RSP_NextInstruction = DELAY_SLOT; RSP_NextInstruction = DELAY_SLOT;
@ -370,6 +372,7 @@ void RSP_Opcode_BGEZAL ( void ) {
RSP_JumpTo = ( *PrgCount + 8 ) & 0xFFC; RSP_JumpTo = ( *PrgCount + 8 ) & 0xFFC;
} }
} }
/************************** Cop0 functions *************************/ /************************** Cop0 functions *************************/
void RSP_Cop0_MF (void) { void RSP_Cop0_MF (void) {
if (LogRDP && CPUCore == InterpreterCPU) if (LogRDP && CPUCore == InterpreterCPU)
@ -529,6 +532,7 @@ void RSP_Cop2_CT (void) {
void RSP_COP2_VECTOR (void) { void RSP_COP2_VECTOR (void) {
RSP_Vector[ RSPOpC.funct ](); RSP_Vector[ RSPOpC.funct ]();
} }
/************************** Vect functions **************************/ /************************** Vect functions **************************/
void RSP_Vector_VMULF (void) { void RSP_Vector_VMULF (void) {
int el, del; int el, del;
@ -1648,120 +1652,121 @@ void RSP_Vector_VRSQH (void) {
} }
void RSP_Vector_VNOOP (void) {} void RSP_Vector_VNOOP (void) {}
/************************** lc2 functions **************************/ /************************** lc2 functions **************************/
void RSP_Opcode_LBV ( void ) { void RSP_Opcode_LBV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 0)) & 0xFFF;
RSP_LBV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_LBV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }
void RSP_Opcode_LSV ( void ) { void RSP_Opcode_LSV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset << 1)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 1)) & 0xFFF;
RSP_LSV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_LSV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }
void RSP_Opcode_LLV ( void ) { void RSP_Opcode_LLV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset << 2)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 2)) & 0xFFF;
RSP_LLV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_LLV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }
void RSP_Opcode_LDV ( void ) { void RSP_Opcode_LDV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset << 3)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 3)) & 0xFFF;
RSP_LDV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_LDV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }
void RSP_Opcode_LQV ( void ) { void RSP_Opcode_LQV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset << 4)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 4)) & 0xFFF;
RSP_LQV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_LQV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }
void RSP_Opcode_LRV ( void ) { void RSP_Opcode_LRV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset << 4)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 4)) & 0xFFF;
RSP_LRV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_LRV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }
void RSP_Opcode_LPV ( void ) { void RSP_Opcode_LPV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset << 3)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 3)) & 0xFFF;
RSP_LPV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_LPV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }
void RSP_Opcode_LUV ( void ) { void RSP_Opcode_LUV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset << 3)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 3)) & 0xFFF;
RSP_LUV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_LUV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }
void RSP_Opcode_LHV ( void ) { void RSP_Opcode_LHV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset << 4)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 4)) & 0xFFF;
RSP_LHV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_LHV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }
void RSP_Opcode_LFV ( void ) { void RSP_Opcode_LFV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset << 4)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 4)) & 0xFFF;
RSP_LFV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_LFV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }
void RSP_Opcode_LTV ( void ) { void RSP_Opcode_LTV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset << 4)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 4)) & 0xFFF;
RSP_LTV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_LTV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }
/************************** sc2 functions **************************/ /************************** sc2 functions **************************/
void RSP_Opcode_SBV ( void ) { void RSP_Opcode_SBV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 0)) & 0xFFF;
RSP_SBV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_SBV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }
void RSP_Opcode_SSV ( void ) { void RSP_Opcode_SSV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset << 1)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 1)) & 0xFFF;
RSP_SSV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_SSV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }
void RSP_Opcode_SLV ( void ) { void RSP_Opcode_SLV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset << 2)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 2)) & 0xFFF;
RSP_SLV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_SLV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }
void RSP_Opcode_SDV ( void ) { void RSP_Opcode_SDV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset << 3)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 3)) & 0xFFF;
RSP_SDV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_SDV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }
void RSP_Opcode_SQV ( void ) { void RSP_Opcode_SQV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset << 4)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 4)) & 0xFFF;
RSP_SQV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_SQV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }
void RSP_Opcode_SRV ( void ) { void RSP_Opcode_SRV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset << 4)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 4)) & 0xFFF;
RSP_SRV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_SRV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }
void RSP_Opcode_SPV ( void ) { void RSP_Opcode_SPV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset << 3)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 3)) & 0xFFF;
RSP_SPV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_SPV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }
void RSP_Opcode_SUV ( void ) { void RSP_Opcode_SUV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset << 3)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 3)) & 0xFFF;
RSP_SUV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_SUV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }
void RSP_Opcode_SHV ( void ) { void RSP_Opcode_SHV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset << 4)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 4)) & 0xFFF;
RSP_SHV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_SHV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }
void RSP_Opcode_SFV ( void ) { void RSP_Opcode_SFV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset << 4)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 4)) & 0xFFF;
RSP_SFV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_SFV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }
void RSP_Opcode_STV ( void ) { void RSP_Opcode_STV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset << 4)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 4)) & 0xFFF;
RSP_STV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_STV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }
void RSP_Opcode_SWV ( void ) { void RSP_Opcode_SWV ( void ) {
DWORD Address = ((RSP_GPR[RSPOpC.base].UW + (DWORD)(RSPOpC.voffset << 4)) &0xFFF); uint32_t Address = (uint32_t)(RSP_GPR[RSPOpC.base].W + (RSPOpC.voffset << 4)) & 0xFFF;
RSP_SWV_DMEM( Address, RSPOpC.rt, RSPOpC.del); RSP_SWV_DMEM( Address, RSPOpC.rt, RSPOpC.del);
} }

View File

@ -30,7 +30,7 @@
#pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union #pragma warning(disable : 4201) // nonstandard extension used : nameless struct/union
typedef union tagOPCODE { typedef union tagOPCODE {
unsigned long Hex; uint32_t Hex;
unsigned char Ascii[4]; unsigned char Ascii[4];
struct { struct {

View File

@ -119,7 +119,8 @@ void Disable_RSP_Commands_Window ( void ) {
} }
int DisplayRSPCommand (DWORD location, int InsertPos) { int DisplayRSPCommand (DWORD location, int InsertPos) {
DWORD OpCode, LinesUsed = 1, status; uint32_t OpCode;
DWORD LinesUsed = 1, status;
BOOL Redraw = FALSE; BOOL Redraw = FALSE;
RSP_LW_IMEM(location, &OpCode); RSP_LW_IMEM(location, &OpCode);
@ -149,7 +150,8 @@ int DisplayRSPCommand (DWORD location, int InsertPos) {
void DumpRSPCode (void) { void DumpRSPCode (void) {
char string[100], LogFileName[255], *p ; char string[100], LogFileName[255], *p ;
DWORD location, OpCode, dwWritten; uint32_t OpCode;
DWORD location, dwWritten;
HANDLE hLogFile = NULL; HANDLE hLogFile = NULL;
strcpy(LogFileName,GetCommandLine() + 1); strcpy(LogFileName,GetCommandLine() + 1);
@ -185,7 +187,8 @@ void DumpRSPCode (void) {
void DumpRSPData (void) { void DumpRSPData (void) {
char string[100], LogFileName[255], *p ; char string[100], LogFileName[255], *p ;
DWORD location, value, dwWritten; uint32_t value;
DWORD location, dwWritten;
HANDLE hLogFile = NULL; HANDLE hLogFile = NULL;
strcpy(LogFileName,GetCommandLine() + 1); strcpy(LogFileName,GetCommandLine() + 1);

View File

@ -27,6 +27,24 @@
#ifndef __Types_h #ifndef __Types_h
#define __Types_h #define __Types_h
/*
* Some versions of Microsoft Visual C/++ compilers before Visual Studio 2010
* have <stdint.h> removed in favor of these nonstandard built-in types:
*/
#if defined(_MSC_VER) && (_MSC_VER < 1600)
typedef signed __int8 int8_t;
typedef signed __int16 int16_t;
typedef signed __int32 int32_t;
typedef signed __int64 int64_t;
typedef unsigned __int8 uint8_t;
typedef unsigned __int16 uint16_t;
typedef unsigned __int32 uint32_t;
typedef unsigned __int64 uint64_t;
#else
#include <stdint.h>
#endif
/* /*
* pointer to RSP operation code functions or "func" * pointer to RSP operation code functions or "func"
* This is the type of all RSP interpreter and recompiler functions. * This is the type of all RSP interpreter and recompiler functions.
@ -34,39 +52,42 @@
typedef void(*p_func)(void); typedef void(*p_func)(void);
typedef union tagUWORD { typedef union tagUWORD {
long W; int32_t W;
float F; uint32_t UW;
unsigned long UW; int16_t HW[2];
short HW[2]; uint16_t UHW[2];
unsigned short UHW[2]; int8_t B[4];
char B[4]; uint8_t UB[4];
unsigned char UB[4];
float F;
} UWORD32; } UWORD32;
typedef union tagUDWORD { typedef union tagUDWORD {
double D; int64_t DW;
__int64 DW; uint64_t UDW;
unsigned __int64 UDW; int32_t W[2];
long W[2]; uint32_t UW[2];
float F[2]; int16_t HW[4];
unsigned long UW[2]; uint16_t UHW[4];
short HW[4]; int8_t B[8];
unsigned short UHW[4]; uint8_t UB[8];
char B[8];
unsigned char UB[8]; double D;
float F[2];
} UDWORD; } UDWORD;
typedef union tagVect { typedef union tagVect {
double FD[2]; int64_t DW[2];
__int64 DW[2]; uint64_t UDW[2];
unsigned __int64 UDW[2]; int32_t W[4];
long W[4]; uint32_t UW[4];
float FS[4]; int16_t HW[8];
unsigned long UW[4]; uint16_t UHW[8];
short HW[8]; int8_t B[16];
unsigned short UHW[8]; uint8_t UB[16];
char B[16];
unsigned char UB[16]; double FD[2];
float FS[4];
} VECTOR; } VECTOR;
#endif #endif

View File

@ -109,15 +109,15 @@ void SetJumpTable (DWORD End) {
NoOfMaps += 1; NoOfMaps += 1;
} }
void RSP_LB_DMEM ( DWORD Addr, BYTE * Value ) { void RSP_LB_DMEM ( uint32_t Addr, uint8_t * Value ) {
* Value = *(BYTE *)(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) ; *Value = *(uint8_t *)(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF));
} }
void RSP_LBV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_LBV_DMEM ( uint32_t Addr, int vect, int element ) {
RSP_Vect[vect].B[15 - element] = *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)); RSP_Vect[vect].B[15 - element] = *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF));
} }
void RSP_LDV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_LDV_DMEM ( uint32_t Addr, int vect, int element ) {
int length, Count; int length, Count;
length = 8; length = 8;
@ -131,7 +131,7 @@ void RSP_LDV_DMEM ( DWORD Addr, int vect, int element ) {
} }
void RSP_LFV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_LFV_DMEM ( uint32_t Addr, int vect, int element ) {
int length, count; int length, count;
VECTOR Temp; VECTOR Temp;
@ -154,21 +154,21 @@ void RSP_LFV_DMEM ( DWORD Addr, int vect, int element ) {
} }
} }
void RSP_LH_DMEM ( DWORD Addr, WORD * Value ) { void RSP_LH_DMEM ( uint32_t Addr, uint16_t * Value ) {
if ((Addr & 0x1) != 0) { if ((Addr & 0x1) != 0) {
if (Addr > 0xFFE) { if (Addr > 0xFFE) {
DisplayError("hmmmm.... Problem with:\nRSP_LH_DMEM"); DisplayError("hmmmm.... Problem with:\nRSP_LH_DMEM");
return; return;
} }
Addr &= 0xFFF; Addr &= 0xFFF;
*Value = *(BYTE *)(RSPInfo.DMEM + (Addr^ 3)) << 8; *Value = *(uint8_t *)(RSPInfo.DMEM + ((Addr + 0) ^ 3)) << 8;
*Value += *(BYTE *)(RSPInfo.DMEM + ((Addr + 1)^ 3)); *Value += *(uint8_t *)(RSPInfo.DMEM + ((Addr + 1) ^ 3)) << 0;
return; return;
} }
* Value = *(WORD *)(RSPInfo.DMEM + ((Addr ^ 2 ) & 0xFFF)); *Value = *(uint16_t *)(RSPInfo.DMEM + ((Addr ^ 2) & 0xFFF));
} }
void RSP_LHV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_LHV_DMEM ( uint32_t Addr, int vect, int element ) {
RSP_Vect[vect].HW[7] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element) & 0xF) ^3) & 0xFFF)) << 7; RSP_Vect[vect].HW[7] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element) & 0xF) ^3) & 0xFFF)) << 7;
RSP_Vect[vect].HW[6] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 2) & 0xF) ^3) & 0xFFF)) << 7; RSP_Vect[vect].HW[6] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 2) & 0xF) ^3) & 0xFFF)) << 7;
RSP_Vect[vect].HW[5] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 4) & 0xF) ^3) & 0xFFF)) << 7; RSP_Vect[vect].HW[5] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 4) & 0xF) ^3) & 0xFFF)) << 7;
@ -179,7 +179,7 @@ void RSP_LHV_DMEM ( DWORD Addr, int vect, int element ) {
RSP_Vect[vect].HW[0] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 14) & 0xF) ^3) & 0xFFF)) << 7; RSP_Vect[vect].HW[0] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 14) & 0xF) ^3) & 0xFFF)) << 7;
} }
void RSP_LLV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_LLV_DMEM ( uint32_t Addr, int vect, int element ) {
int length, Count; int length, Count;
length = 4; length = 4;
@ -193,7 +193,7 @@ void RSP_LLV_DMEM ( DWORD Addr, int vect, int element ) {
} }
void RSP_LPV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_LPV_DMEM ( uint32_t Addr, int vect, int element ) {
RSP_Vect[vect].HW[7] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element) & 0xF)^3) & 0xFFF)) << 8; RSP_Vect[vect].HW[7] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element) & 0xF)^3) & 0xFFF)) << 8;
RSP_Vect[vect].HW[6] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 1) & 0xF)^3) & 0xFFF)) << 8; RSP_Vect[vect].HW[6] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 1) & 0xF)^3) & 0xFFF)) << 8;
RSP_Vect[vect].HW[5] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 2) & 0xF)^3) & 0xFFF)) << 8; RSP_Vect[vect].HW[5] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 2) & 0xF)^3) & 0xFFF)) << 8;
@ -204,7 +204,7 @@ void RSP_LPV_DMEM ( DWORD Addr, int vect, int element ) {
RSP_Vect[vect].HW[0] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 7) & 0xF)^3) & 0xFFF)) << 8; RSP_Vect[vect].HW[0] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 7) & 0xF)^3) & 0xFFF)) << 8;
} }
void RSP_LRV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_LRV_DMEM ( uint32_t Addr, int vect, int element ) {
int length, Count, offset; int length, Count, offset;
offset = (Addr & 0xF) - 1; offset = (Addr & 0xF) - 1;
@ -217,7 +217,7 @@ void RSP_LRV_DMEM ( DWORD Addr, int vect, int element ) {
} }
void RSP_LQV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_LQV_DMEM ( uint32_t Addr, int vect, int element ) {
int length, Count; int length, Count;
length = ((Addr + 0x10) & ~0xF) - Addr; length = ((Addr + 0x10) & ~0xF) - Addr;
@ -231,7 +231,7 @@ void RSP_LQV_DMEM ( DWORD Addr, int vect, int element ) {
} }
void RSP_LSV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_LSV_DMEM ( uint32_t Addr, int vect, int element ) {
int length, Count; int length, Count;
length = 2; length = 2;
@ -244,7 +244,7 @@ void RSP_LSV_DMEM ( DWORD Addr, int vect, int element ) {
} }
} }
void RSP_LTV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_LTV_DMEM ( uint32_t Addr, int vect, int element ) {
int del, count, length; int del, count, length;
length = 8; length = 8;
@ -261,7 +261,7 @@ void RSP_LTV_DMEM ( DWORD Addr, int vect, int element ) {
} }
} }
void RSP_LUV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_LUV_DMEM ( uint32_t Addr, int vect, int element ) {
RSP_Vect[vect].HW[7] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element) & 0xF)^3) & 0xFFF)) << 7; RSP_Vect[vect].HW[7] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element) & 0xF)^3) & 0xFFF)) << 7;
RSP_Vect[vect].HW[6] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 1) & 0xF)^3) & 0xFFF)) << 7; RSP_Vect[vect].HW[6] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 1) & 0xF)^3) & 0xFFF)) << 7;
RSP_Vect[vect].HW[5] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 2) & 0xF)^3) & 0xFFF)) << 7; RSP_Vect[vect].HW[5] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 2) & 0xF)^3) & 0xFFF)) << 7;
@ -272,38 +272,38 @@ void RSP_LUV_DMEM ( DWORD Addr, int vect, int element ) {
RSP_Vect[vect].HW[0] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 7) & 0xF)^3) & 0xFFF)) << 7; RSP_Vect[vect].HW[0] = *(RSPInfo.DMEM + ((Addr + ((0x10 - element + 7) & 0xF)^3) & 0xFFF)) << 7;
} }
void RSP_LW_DMEM ( DWORD Addr, DWORD * Value ) { void RSP_LW_DMEM ( uint32_t Addr, uint32_t * Value ) {
if ((Addr & 0x3) != 0) { if ((Addr & 0x3) != 0) {
Addr &= 0xFFF; Addr &= 0xFFF;
if (Addr > 0xFFC) { if (Addr > 0xFFC) {
DisplayError("hmmmm.... Problem with:\nRSP_LW_DMEM"); DisplayError("hmmmm.... Problem with:\nRSP_LW_DMEM");
return; return;
} }
*Value = *(BYTE *)(RSPInfo.DMEM + (Addr^ 3)) << 0x18; *Value = *(uint8_t *)(RSPInfo.DMEM + ((Addr + 0) ^ 3)) << 24;
*Value += *(BYTE *)(RSPInfo.DMEM + ((Addr + 1)^ 3)) << 0x10; *Value += *(uint8_t *)(RSPInfo.DMEM + ((Addr + 1) ^ 3)) << 16;
*Value += *(BYTE *)(RSPInfo.DMEM + ((Addr + 2)^ 3)) << 8; *Value += *(uint8_t *)(RSPInfo.DMEM + ((Addr + 2) ^ 3)) << 8;
*Value += *(BYTE *)(RSPInfo.DMEM + ((Addr + 3)^ 3)); *Value += *(uint8_t *)(RSPInfo.DMEM + ((Addr + 3) ^ 3)) << 0;
return; return;
} }
* Value = *(DWORD *)(RSPInfo.DMEM + (Addr & 0xFFF)); *Value = *(uint32_t *)(RSPInfo.DMEM + (Addr & 0xFFF));
} }
void RSP_LW_IMEM ( DWORD Addr, DWORD * Value ) { void RSP_LW_IMEM ( uint32_t Addr, uint32_t * Value ) {
if ((Addr & 0x3) != 0) { if ((Addr & 0x3) != 0) {
DisplayError("Unaligned RSP_LW_IMEM"); DisplayError("Unaligned RSP_LW_IMEM");
} }
* Value = *(DWORD *)(RSPInfo.IMEM + (Addr & 0xFFF)); *Value = *(uint32_t *)(RSPInfo.IMEM + (Addr & 0xFFF));
} }
void RSP_SB_DMEM ( DWORD Addr, BYTE Value ) { void RSP_SB_DMEM ( uint32_t Addr, uint8_t Value ) {
*(BYTE *)(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = Value; *(uint8_t *)(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = Value;
} }
void RSP_SBV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_SBV_DMEM ( uint32_t Addr, int vect, int element ) {
*(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = RSP_Vect[vect].B[15 - element]; *(RSPInfo.DMEM + ((Addr ^ 3) & 0xFFF)) = RSP_Vect[vect].B[15 - element];
} }
void RSP_SDV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_SDV_DMEM ( uint32_t Addr, int vect, int element ) {
int Count; int Count;
for (Count = element; Count < (8 + element); Count ++ ){ for (Count = element; Count < (8 + element); Count ++ ){
@ -312,22 +312,22 @@ void RSP_SDV_DMEM ( DWORD Addr, int vect, int element ) {
} }
} }
void RSP_SFV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_SFV_DMEM ( uint32_t Addr, int vect, int element ) {
int offset = Addr & 0xF; int offset = Addr & 0xF;
Addr &= 0xFF0; Addr &= 0xFF0;
switch (element) { switch (element) {
case 0: case 0:
*(RSPInfo.DMEM + ((Addr + offset)^3)) = (BYTE)(RSP_Vect[vect].UHW[7] >> 7); *(RSPInfo.DMEM + ((Addr + offset)^3)) = (RSP_Vect[vect].UHW[7] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 4) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[6] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 4) & 0xF))^3)) = (RSP_Vect[vect].UHW[6] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 8) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[5] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 8) & 0xF))^3)) = (RSP_Vect[vect].UHW[5] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[4] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF))^3)) = (RSP_Vect[vect].UHW[4] >> 7) & 0xFF;
break; break;
case 1: case 1:
*(RSPInfo.DMEM + ((Addr + offset)^3)) = (BYTE)(RSP_Vect[vect].UHW[1] >> 7); *(RSPInfo.DMEM + ((Addr + offset)^3)) = (RSP_Vect[vect].UHW[1] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 4) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[0] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 4) & 0xF))^3)) = (RSP_Vect[vect].UHW[0] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 8) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[3] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 8) & 0xF))^3)) = (RSP_Vect[vect].UHW[3] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[2] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF))^3)) = (RSP_Vect[vect].UHW[2] >> 7) & 0xFF;
break; break;
case 2: case 2:
*(RSPInfo.DMEM + ((Addr + offset)^3)) = 0; *(RSPInfo.DMEM + ((Addr + offset)^3)) = 0;
@ -342,16 +342,16 @@ void RSP_SFV_DMEM ( DWORD Addr, int vect, int element ) {
*(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF)^3))) = 0; *(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF)^3))) = 0;
break; break;
case 4: case 4:
*(RSPInfo.DMEM + ((Addr + offset)^3)) = (BYTE)(RSP_Vect[vect].UHW[6] >> 7); *(RSPInfo.DMEM + ((Addr + offset)^3)) = (RSP_Vect[vect].UHW[6] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 4) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[5] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 4) & 0xF))^3)) = (RSP_Vect[vect].UHW[5] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 8) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[4] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 8) & 0xF))^3)) = (RSP_Vect[vect].UHW[4] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[7] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF))^3)) = (RSP_Vect[vect].UHW[7] >> 7) & 0xFF;
break; break;
case 5: case 5:
*(RSPInfo.DMEM + ((Addr + offset)^3)) = (BYTE)(RSP_Vect[vect].UHW[0] >> 7); *(RSPInfo.DMEM + ((Addr + offset)^3)) = (RSP_Vect[vect].UHW[0] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 4) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[3] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 4) & 0xF))^3)) = (RSP_Vect[vect].UHW[3] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 8) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[2] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 8) & 0xF))^3)) = (RSP_Vect[vect].UHW[2] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[1] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF))^3)) = (RSP_Vect[vect].UHW[1] >> 7) & 0xFF;
break; break;
case 6: case 6:
*(RSPInfo.DMEM + ((Addr + offset)^3)) = 0; *(RSPInfo.DMEM + ((Addr + offset)^3)) = 0;
@ -366,10 +366,10 @@ void RSP_SFV_DMEM ( DWORD Addr, int vect, int element ) {
*(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF))^3)) = 0; *(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF))^3)) = 0;
break; break;
case 8: case 8:
*(RSPInfo.DMEM + ((Addr + offset)^3)) = (BYTE)(RSP_Vect[vect].UHW[3] >> 7); *(RSPInfo.DMEM + ((Addr + offset)^3)) = (RSP_Vect[vect].UHW[3] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 4) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[2] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 4) & 0xF))^3)) = (RSP_Vect[vect].UHW[2] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 8) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[1] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 8) & 0xF))^3)) = (RSP_Vect[vect].UHW[1] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[0] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF))^3)) = (RSP_Vect[vect].UHW[0] >> 7) & 0xFF;
break; break;
case 9: case 9:
*(RSPInfo.DMEM + ((Addr + offset)^3)) = 0; *(RSPInfo.DMEM + ((Addr + offset)^3)) = 0;
@ -384,16 +384,16 @@ void RSP_SFV_DMEM ( DWORD Addr, int vect, int element ) {
*(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF))^3)) = 0; *(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF))^3)) = 0;
break; break;
case 11: case 11:
*(RSPInfo.DMEM + ((Addr + offset)^3)) = (BYTE)(RSP_Vect[vect].UHW[4] >> 7); *(RSPInfo.DMEM + ((Addr + offset)^3)) = (RSP_Vect[vect].UHW[4] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 4) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[7] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 4) & 0xF))^3)) = (RSP_Vect[vect].UHW[7] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 8) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[6] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 8) & 0xF))^3)) = (RSP_Vect[vect].UHW[6] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[5] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF))^3)) = (RSP_Vect[vect].UHW[5] >> 7) & 0xFF;
break; break;
case 12: case 12:
*(RSPInfo.DMEM + ((Addr + offset)^3)) = (BYTE)(RSP_Vect[vect].UHW[2] >> 7); *(RSPInfo.DMEM + ((Addr + offset)^3)) = (RSP_Vect[vect].UHW[2] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 4) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[1] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 4) & 0xF))^3)) = (RSP_Vect[vect].UHW[1] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 8) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[0] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 8) & 0xF))^3)) = (RSP_Vect[vect].UHW[0] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[3] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF))^3)) = (RSP_Vect[vect].UHW[3] >> 7) & 0xFF;
break; break;
case 13: case 13:
*(RSPInfo.DMEM + ((Addr + offset)^3)) = 0; *(RSPInfo.DMEM + ((Addr + offset)^3)) = 0;
@ -408,23 +408,23 @@ void RSP_SFV_DMEM ( DWORD Addr, int vect, int element ) {
*(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF))^3)) = 0; *(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF))^3)) = 0;
break; break;
case 15: case 15:
*(RSPInfo.DMEM + ((Addr + offset)^3)) = (BYTE)(RSP_Vect[vect].UHW[7] >> 7); *(RSPInfo.DMEM + ((Addr + offset)^3)) = (RSP_Vect[vect].UHW[7] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 4) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[6] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 4) & 0xF))^3)) = (RSP_Vect[vect].UHW[6] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 8) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[5] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 8) & 0xF))^3)) = (RSP_Vect[vect].UHW[5] >> 7) & 0xFF;
*(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF))^3)) = (BYTE)(RSP_Vect[vect].UHW[4] >> 7); *(RSPInfo.DMEM + ((Addr + ((offset + 12) & 0xF))^3)) = (RSP_Vect[vect].UHW[4] >> 7) & 0xFF;
break; break;
} }
} }
void RSP_SH_DMEM ( DWORD Addr, WORD Value ) { void RSP_SH_DMEM ( uint32_t Addr, uint16_t Value ) {
if ((Addr & 0x1) != 0) { if ((Addr & 0x1) != 0) {
DisplayError("Unaligned RSP_SH_DMEM"); DisplayError("Unaligned RSP_SH_DMEM");
return; return;
} }
*(WORD *)(RSPInfo.DMEM + ((Addr ^ 2) & 0xFFF)) = Value; *(uint16_t *)(RSPInfo.DMEM + ((Addr ^ 2) & 0xFFF)) = Value;
} }
void RSP_SHV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_SHV_DMEM ( uint32_t Addr, int vect, int element ) {
*(RSPInfo.DMEM + ((Addr^3) & 0xFFF)) = (RSP_Vect[vect].UB[(15 - element) & 0xF] << 1) + *(RSPInfo.DMEM + ((Addr^3) & 0xFFF)) = (RSP_Vect[vect].UB[(15 - element) & 0xF] << 1) +
(RSP_Vect[vect].UB[(14 - element) & 0xF] >> 7); (RSP_Vect[vect].UB[(14 - element) & 0xF] >> 7);
*(RSPInfo.DMEM + (((Addr + 2)^3) & 0xFFF)) = (RSP_Vect[vect].UB[(13 - element) & 0xF] << 1) + *(RSPInfo.DMEM + (((Addr + 2)^3) & 0xFFF)) = (RSP_Vect[vect].UB[(13 - element) & 0xF] << 1) +
@ -443,7 +443,7 @@ void RSP_SHV_DMEM ( DWORD Addr, int vect, int element ) {
(RSP_Vect[vect].UB[(0 - element) & 0xF] >> 7); (RSP_Vect[vect].UB[(0 - element) & 0xF] >> 7);
} }
void RSP_SLV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_SLV_DMEM ( uint32_t Addr, int vect, int element ) {
int Count; int Count;
for (Count = element; Count < (4 + element); Count ++ ){ for (Count = element; Count < (4 + element); Count ++ ){
@ -452,7 +452,7 @@ void RSP_SLV_DMEM ( DWORD Addr, int vect, int element ) {
} }
} }
void RSP_SPV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_SPV_DMEM ( uint32_t Addr, int vect, int element ) {
int Count; int Count;
for (Count = element; Count < (8 + element); Count ++ ){ for (Count = element; Count < (8 + element); Count ++ ){
@ -466,7 +466,7 @@ void RSP_SPV_DMEM ( DWORD Addr, int vect, int element ) {
} }
} }
void RSP_SQV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_SQV_DMEM ( uint32_t Addr, int vect, int element ) {
int length, Count; int length, Count;
length = ((Addr + 0x10) & ~0xF) - Addr; length = ((Addr + 0x10) & ~0xF) - Addr;
@ -476,7 +476,7 @@ void RSP_SQV_DMEM ( DWORD Addr, int vect, int element ) {
} }
} }
void RSP_SRV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_SRV_DMEM ( uint32_t Addr, int vect, int element ) {
int length, Count, offset; int length, Count, offset;
length = (Addr & 0xF); length = (Addr & 0xF);
@ -488,7 +488,7 @@ void RSP_SRV_DMEM ( DWORD Addr, int vect, int element ) {
} }
} }
void RSP_SSV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_SSV_DMEM ( uint32_t Addr, int vect, int element ) {
int Count; int Count;
for (Count = element; Count < (2 + element); Count ++ ){ for (Count = element; Count < (2 + element); Count ++ ){
@ -497,7 +497,7 @@ void RSP_SSV_DMEM ( DWORD Addr, int vect, int element ) {
} }
} }
void RSP_STV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_STV_DMEM ( uint32_t Addr, int vect, int element ) {
int del, count, length; int del, count, length;
length = 8; length = 8;
@ -514,7 +514,7 @@ void RSP_STV_DMEM ( DWORD Addr, int vect, int element ) {
} }
} }
void RSP_SUV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_SUV_DMEM ( uint32_t Addr, int vect, int element ) {
int Count; int Count;
for (Count = element; Count < (8 + element); Count ++ ){ for (Count = element; Count < (8 + element); Count ++ ){
@ -528,23 +528,23 @@ void RSP_SUV_DMEM ( DWORD Addr, int vect, int element ) {
} }
} }
void RSP_SW_DMEM ( DWORD Addr, DWORD Value ) { void RSP_SW_DMEM ( uint32_t Addr, uint32_t Value ) {
Addr &= 0xFFF; Addr &= 0xFFF;
if ((Addr & 0x3) != 0) { if ((Addr & 0x3) != 0) {
if (Addr > 0xFFC) { if (Addr > 0xFFC) {
DisplayError("hmmmm.... Problem with:\nRSP_SW_DMEM"); DisplayError("hmmmm.... Problem with:\nRSP_SW_DMEM");
return; return;
} }
*(BYTE *)(RSPInfo.DMEM + (Addr ^ 3)) = (BYTE)((Value >> 0x18) & 0xFF); *(uint8_t *)(RSPInfo.DMEM + ((Addr + 0) ^ 3)) = (Value >> 24) & 0xFF;
*(BYTE *)(RSPInfo.DMEM + ((Addr + 1) ^ 3)) = (BYTE)((Value >> 0x10) & 0xFF); *(uint8_t *)(RSPInfo.DMEM + ((Addr + 1) ^ 3)) = (Value >> 16) & 0xFF;
*(BYTE *)(RSPInfo.DMEM + ((Addr + 2) ^ 3)) = (BYTE)((Value >> 0x8) & 0xFF); *(uint8_t *)(RSPInfo.DMEM + ((Addr + 2) ^ 3)) = (Value >> 8) & 0xFF;
*(BYTE *)(RSPInfo.DMEM + ((Addr + 3) ^ 3)) = (BYTE)(Value &0xFF); *(uint8_t *)(RSPInfo.DMEM + ((Addr + 3) ^ 3)) = (Value >> 0) & 0xFF;
return; return;
} }
*(DWORD *)(RSPInfo.DMEM + Addr) = Value; *(uint32_t *)(RSPInfo.DMEM + Addr) = Value;
} }
void RSP_SWV_DMEM ( DWORD Addr, int vect, int element ) { void RSP_SWV_DMEM ( uint32_t Addr, int vect, int element ) {
int Count, offset; int Count, offset;
offset = Addr & 0xF; offset = Addr & 0xF;

View File

@ -24,6 +24,9 @@
* *
*/ */
#include <windows.h>
#include "types.h"
int AllocateMemory ( void ); int AllocateMemory ( void );
void FreeMemory ( void ); void FreeMemory ( void );
void SetJumpTable ( DWORD End ); void SetJumpTable ( DWORD End );
@ -32,33 +35,33 @@ extern BYTE * RecompCode, * RecompCodeSecondary, * RecompPos;
extern void ** JumpTable; extern void ** JumpTable;
extern DWORD Table; extern DWORD Table;
void RSP_LB_DMEM ( DWORD Addr, BYTE * Value ); void RSP_LB_DMEM ( uint32_t Addr, uint8_t * Value );
void RSP_LBV_DMEM ( DWORD Addr, int vect, int element ); void RSP_LBV_DMEM ( uint32_t Addr, int vect, int element );
void RSP_LDV_DMEM ( DWORD Addr, int vect, int element ); void RSP_LDV_DMEM ( uint32_t Addr, int vect, int element );
void RSP_LFV_DMEM ( DWORD Addr, int vect, int element ); void RSP_LFV_DMEM ( uint32_t Addr, int vect, int element );
void RSP_LH_DMEM ( DWORD Addr, WORD * Value ); void RSP_LH_DMEM ( uint32_t Addr, uint16_t * Value );
void RSP_LHV_DMEM ( DWORD Addr, int vect, int element ); void RSP_LHV_DMEM ( uint32_t Addr, int vect, int element );
void RSP_LLV_DMEM ( DWORD Addr, int vect, int element ); void RSP_LLV_DMEM ( uint32_t Addr, int vect, int element );
void RSP_LPV_DMEM ( DWORD Addr, int vect, int element ); void RSP_LPV_DMEM ( uint32_t Addr, int vect, int element );
void RSP_LRV_DMEM ( DWORD Addr, int vect, int element ); void RSP_LRV_DMEM ( uint32_t Addr, int vect, int element );
void RSP_LQV_DMEM ( DWORD Addr, int vect, int element ); void RSP_LQV_DMEM ( uint32_t Addr, int vect, int element );
void RSP_LSV_DMEM ( DWORD Addr, int vect, int element ); void RSP_LSV_DMEM ( uint32_t Addr, int vect, int element );
void RSP_LTV_DMEM ( DWORD Addr, int vect, int element ); void RSP_LTV_DMEM ( uint32_t Addr, int vect, int element );
void RSP_LUV_DMEM ( DWORD Addr, int vect, int element ); void RSP_LUV_DMEM ( uint32_t Addr, int vect, int element );
void RSP_LW_DMEM ( DWORD Addr, DWORD * Value ); void RSP_LW_DMEM ( uint32_t Addr, uint32_t * Value );
void RSP_LW_IMEM ( DWORD Addr, DWORD * Value ); void RSP_LW_IMEM ( uint32_t Addr, uint32_t * Value );
void RSP_SB_DMEM ( DWORD Addr, BYTE Value ); void RSP_SB_DMEM ( uint32_t Addr, uint8_t Value );
void RSP_SBV_DMEM ( DWORD Addr, int vect, int element ); void RSP_SBV_DMEM ( uint32_t Addr, int vect, int element );
void RSP_SDV_DMEM ( DWORD Addr, int vect, int element ); void RSP_SDV_DMEM ( uint32_t Addr, int vect, int element );
void RSP_SFV_DMEM ( DWORD Addr, int vect, int element ); void RSP_SFV_DMEM ( uint32_t Addr, int vect, int element );
void RSP_SH_DMEM ( DWORD Addr, WORD Value ); void RSP_SH_DMEM ( uint32_t Addr, uint16_t Value );
void RSP_SHV_DMEM ( DWORD Addr, int vect, int element ); void RSP_SHV_DMEM ( uint32_t Addr, int vect, int element );
void RSP_SLV_DMEM ( DWORD Addr, int vect, int element ); void RSP_SLV_DMEM ( uint32_t Addr, int vect, int element );
void RSP_SPV_DMEM ( DWORD Addr, int vect, int element ); void RSP_SPV_DMEM ( uint32_t Addr, int vect, int element );
void RSP_SQV_DMEM ( DWORD Addr, int vect, int element ); void RSP_SQV_DMEM ( uint32_t Addr, int vect, int element );
void RSP_SRV_DMEM ( DWORD Addr, int vect, int element ); void RSP_SRV_DMEM ( uint32_t Addr, int vect, int element );
void RSP_SSV_DMEM ( DWORD Addr, int vect, int element ); void RSP_SSV_DMEM ( uint32_t Addr, int vect, int element );
void RSP_STV_DMEM ( DWORD Addr, int vect, int element ); void RSP_STV_DMEM ( uint32_t Addr, int vect, int element );
void RSP_SUV_DMEM ( DWORD Addr, int vect, int element ); void RSP_SUV_DMEM ( uint32_t Addr, int vect, int element );
void RSP_SW_DMEM ( DWORD Addr, DWORD Value ); void RSP_SW_DMEM ( uint32_t Addr, uint32_t Value );
void RSP_SWV_DMEM ( DWORD Addr, int vect, int element ); void RSP_SWV_DMEM ( uint32_t Addr, int vect, int element );