From 587dbbb3ffbf662370e87ef5f8867f7e7228a02e Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 24 Jan 2015 15:39:18 -0500 Subject: [PATCH 1/3] func pointers stored in arrays of func pointers (fixes 720 warnings) --- Source/RSP/Cpu.c | 16 ++++++++-------- Source/RSP/Cpu.h | 16 ++++++++-------- Source/RSP/Types.h | 6 ++++++ 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/Source/RSP/Cpu.c b/Source/RSP/Cpu.c index 5d09ce355..b7a92ffad 100644 --- a/Source/RSP/Cpu.c +++ b/Source/RSP/Cpu.c @@ -43,14 +43,14 @@ UDWORD EleSpec[32], Indx[32]; OPCODE RSPOpC; DWORD *PrgCount, NextInstruction, RSP_Running, RSP_MfStatusCount; -void * RSP_Opcode[64]; -void * RSP_RegImm[32]; -void * RSP_Special[64]; -void * RSP_Cop0[32]; -void * RSP_Cop2[32]; -void * RSP_Vector[64]; -void * RSP_Lc2[32]; -void * RSP_Sc2[32]; +p_func RSP_Opcode[64]; +p_func RSP_RegImm[32]; +p_func RSP_Special[64]; +p_func RSP_Cop0[32]; +p_func RSP_Cop2[32]; +p_func RSP_Vector[64]; +p_func RSP_Lc2[32]; +p_func RSP_Sc2[32]; void BuildInterpreterCPU(void); void BuildRecompilerCPU(void); diff --git a/Source/RSP/Cpu.h b/Source/RSP/Cpu.h index 8c345d225..4159e8f89 100644 --- a/Source/RSP/Cpu.h +++ b/Source/RSP/Cpu.h @@ -28,14 +28,14 @@ extern UDWORD EleSpec[32], Indx[32]; -extern void * RSP_Opcode[64]; -extern void * RSP_RegImm[32]; -extern void * RSP_Special[64]; -extern void * RSP_Cop0[32]; -extern void * RSP_Cop2[32]; -extern void * RSP_Vector[64]; -extern void * RSP_Lc2[32]; -extern void * RSP_Sc2[32]; +extern p_func RSP_Opcode[64]; +extern p_func RSP_RegImm[32]; +extern p_func RSP_Special[64]; +extern p_func RSP_Cop0[32]; +extern p_func RSP_Cop2[32]; +extern p_func RSP_Vector[64]; +extern p_func RSP_Lc2[32]; +extern p_func RSP_Sc2[32]; extern DWORD * PrgCount, RSP_Running; extern OPCODE RSPOpC; diff --git a/Source/RSP/Types.h b/Source/RSP/Types.h index bb38baee3..12862d845 100644 --- a/Source/RSP/Types.h +++ b/Source/RSP/Types.h @@ -27,6 +27,12 @@ #ifndef __Types_h #define __Types_h +/* + * pointer to RSP operation code functions or "func" + * This is the type of all RSP interpreter and recompiler functions. + */ +typedef void(*p_func)(void); + typedef union tagUWORD { long W; float F; From 87aa0faf1773d00d8a1bc79857ee4464c5e32d67 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 24 Jan 2015 16:01:50 -0500 Subject: [PATCH 2/3] removed old explicit type casts (now calling strict func addr arrays) --- Source/RSP/Interpreter CPU.c | 2 +- Source/RSP/Interpreter Ops.c | 14 +++++++------- Source/RSP/Recompiler CPU.c | 2 +- Source/RSP/Recompiler Ops.c | 14 +++++++------- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Source/RSP/Interpreter CPU.c b/Source/RSP/Interpreter CPU.c index bc5d7c74b..b8647093d 100644 --- a/Source/RSP/Interpreter CPU.c +++ b/Source/RSP/Interpreter CPU.c @@ -443,7 +443,7 @@ DWORD RunInterpreterCPU(DWORD Cycles) { RDP_LogLoc(*PrgCount); RSP_LW_IMEM(*PrgCount, &RSPOpC.Hex); - ((void (*)()) RSP_Opcode[ RSPOpC.op ])(); + RSP_Opcode[ RSPOpC.op ](); switch (RSP_NextInstruction) { case NORMAL: diff --git a/Source/RSP/Interpreter Ops.c b/Source/RSP/Interpreter Ops.c index d5837f555..0cd7738b2 100644 --- a/Source/RSP/Interpreter Ops.c +++ b/Source/RSP/Interpreter Ops.c @@ -43,11 +43,11 @@ extern BOOL AudioHle, GraphicsHle; /************************* OpCode functions *************************/ void RSP_Opcode_SPECIAL ( void ) { - ((void (*)()) RSP_Special[ RSPOpC.funct ])(); + RSP_Special[ RSPOpC.funct ](); } void RSP_Opcode_REGIMM ( void ) { - ((void (*)()) RSP_RegImm[ RSPOpC.rt ])(); + RSP_RegImm[ RSPOpC.rt ](); } void RSP_Opcode_J ( void ) { @@ -152,11 +152,11 @@ void RSP_Opcode_LUI (void) { } void RSP_Opcode_COP0 (void) { - ((void (*)()) RSP_Cop0[ RSPOpC.rs ])(); + RSP_Cop0[ RSPOpC.rs ](); } void RSP_Opcode_COP2 (void) { - ((void (*)()) RSP_Cop2[ RSPOpC.rs ])(); + RSP_Cop2[ RSPOpC.rs ](); } void RSP_Opcode_LB ( void ) { @@ -204,11 +204,11 @@ void RSP_Opcode_SW ( void ) { } void RSP_Opcode_LC2 (void) { - ((void (*)()) RSP_Lc2 [ RSPOpC.rd ])(); + RSP_Lc2 [ RSPOpC.rd ](); } void RSP_Opcode_SC2 (void) { - ((void (*)()) RSP_Sc2 [ RSPOpC.rd ])(); + RSP_Sc2 [ RSPOpC.rd ](); } /********************** R4300i OpCodes: Special **********************/ void RSP_Special_SLL ( void ) { @@ -527,7 +527,7 @@ void RSP_Cop2_CT (void) { } void RSP_COP2_VECTOR (void) { - ((void (*)()) RSP_Vector[ RSPOpC.funct ])(); + RSP_Vector[ RSPOpC.funct ](); } /************************** Vect functions **************************/ void RSP_Vector_VMULF (void) { diff --git a/Source/RSP/Recompiler CPU.c b/Source/RSP/Recompiler CPU.c index a8e7271e7..82d8feae5 100644 --- a/Source/RSP/Recompiler CPU.c +++ b/Source/RSP/Recompiler CPU.c @@ -835,7 +835,7 @@ void CompilerRSPBlock ( void ) { /* i think this pops up an unknown op dialog */ /* NextInstruction = FINISH_BLOCK; */ } else { - ((void (*)()) RSP_Opcode[ RSPOpC.op ])(); + RSP_Opcode[ RSPOpC.op ](); } switch (NextInstruction) { diff --git a/Source/RSP/Recompiler Ops.c b/Source/RSP/Recompiler Ops.c index fbdc4bfec..ed32b881e 100644 --- a/Source/RSP/Recompiler Ops.c +++ b/Source/RSP/Recompiler Ops.c @@ -168,11 +168,11 @@ void CompileBranchExit(DWORD TargetPC, DWORD ContinuePC) /************************* OpCode functions *************************/ void Compile_SPECIAL ( void ) { - ((void (*)()) RSP_Special[ RSPOpC.funct ])(); + RSP_Special[ RSPOpC.funct ](); } void Compile_REGIMM ( void ) { - ((void (*)()) RSP_RegImm[ RSPOpC.rt ])(); + RSP_RegImm[ RSPOpC.rt ](); } void Compile_J ( void ) { @@ -572,11 +572,11 @@ void Compile_LUI ( void ) { } void Compile_COP0 (void) { - ((void (*)()) RSP_Cop0[ RSPOpC.rs ])(); + RSP_Cop0[ RSPOpC.rs ](); } void Compile_COP2 (void) { - ((void (*)()) RSP_Cop2[ RSPOpC.rs ])(); + RSP_Cop2[ RSPOpC.rs ](); } void Compile_LB ( void ) { @@ -948,11 +948,11 @@ void Compile_SW ( void ) { } void Compile_LC2 (void) { - ((void (*)()) RSP_Lc2 [ RSPOpC.rd ])(); + RSP_Lc2 [ RSPOpC.rd ](); } void Compile_SC2 (void) { - ((void (*)()) RSP_Sc2 [ RSPOpC.rd ])(); + RSP_Sc2 [ RSPOpC.rd ](); } /********************** R4300i OpCodes: Special **********************/ @@ -1789,7 +1789,7 @@ void Compile_Cop2_CT ( void ) { } void Compile_COP2_VECTOR (void) { - ((void (*)()) RSP_Vector[ RSPOpC.funct ])(); + RSP_Vector[ RSPOpC.funct ](); } /************************** Vect functions **************************/ From fd564c802ae75d34ea94d451e9faeabaa64ea948 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 24 Jan 2015 16:21:39 -0500 Subject: [PATCH 3/3] RSP recompiler cheating expects a RSP function address: p_func. --- Source/RSP/Recompiler Ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/RSP/Recompiler Ops.c b/Source/RSP/Recompiler Ops.c index ed32b881e..3c39c5875 100644 --- a/Source/RSP/Recompiler Ops.c +++ b/Source/RSP/Recompiler Ops.c @@ -118,13 +118,13 @@ void Branch_AddRef(DWORD Target, DWORD * X86Loc) { } } -void Cheat_r4300iOpcode ( void * FunctAddress, char * FunctName) { +void Cheat_r4300iOpcode(p_func FunctAddress, char * FunctName) { CPU_Message(" %X %s",CompilePC,RSPOpcodeName(RSPOpC.Hex,CompilePC)); MoveConstToVariable(RSPOpC.Hex, &RSPOpC.Hex, "RSPOpC.Hex" ); Call_Direct(FunctAddress, FunctName); } -void Cheat_r4300iOpcodeNoMessage( void * FunctAddress, char * FunctName) { +void Cheat_r4300iOpcodeNoMessage(p_func FunctAddress, char * FunctName) { MoveConstToVariable(RSPOpC.Hex, &RSPOpC.Hex, "RSPOpC.Hex" ); Call_Direct(FunctAddress, FunctName); }