diff --git a/libmupen64plus/mupen64plus-core/src/r4300/empty_dynarec.c b/libmupen64plus/mupen64plus-core/src/r4300/empty_dynarec.c index 6af34f7cae..a60e1627a9 100644 --- a/libmupen64plus/mupen64plus-core/src/r4300/empty_dynarec.c +++ b/libmupen64plus/mupen64plus-core/src/r4300/empty_dynarec.c @@ -978,10 +978,30 @@ void gendsubu() { } +void gentge() +{ +} + +void gentgeu() +{ +} + +void gentlt() +{ +} + +void gentltu() +{ +} + void genteq() { } +void gentne() +{ +} + void gendsll() { } diff --git a/libmupen64plus/mupen64plus-core/src/r4300/interpreter_special.def b/libmupen64plus/mupen64plus-core/src/r4300/interpreter_special.def index b6801611d0..fb738e320c 100644 --- a/libmupen64plus/mupen64plus-core/src/r4300/interpreter_special.def +++ b/libmupen64plus/mupen64plus-core/src/r4300/interpreter_special.def @@ -354,6 +354,46 @@ DECLARE_INSTRUCTION(DSUBU) ADD_TO_PC(1); } +DECLARE_INSTRUCTION(TGE) +{ + if (rrs >= rrt) + { + DebugMessage(M64MSG_ERROR, "trap exception in TGE"); + //stop=1; + } + ADD_TO_PC(1); +} + +DECLARE_INSTRUCTION(TGEU) +{ + if ((unsigned long long)rrs >= (unsigned long long)rrt) + { + DebugMessage(M64MSG_ERROR, "trap exception in TGEU"); + //stop=1; + } + ADD_TO_PC(1); +} + +DECLARE_INSTRUCTION(TLT) +{ + if (rrs < rrt) + { + DebugMessage(M64MSG_ERROR, "trap exception in TLT"); + //stop=1; + } + ADD_TO_PC(1); +} + +DECLARE_INSTRUCTION(TLTU) +{ + if ((unsigned long long)rrs < (unsigned long long)rrt) + { + DebugMessage(M64MSG_ERROR, "trap exception in TLTU"); + //stop=1; + } + ADD_TO_PC(1); +} + DECLARE_INSTRUCTION(TEQ) { if (rrs == rrt) @@ -364,6 +404,16 @@ DECLARE_INSTRUCTION(TEQ) ADD_TO_PC(1); } +DECLARE_INSTRUCTION(TNE) +{ + if (rrs != rrt) + { + DebugMessage(M64MSG_ERROR, "trap exception in TNE"); + //stop=1; + } + ADD_TO_PC(1); +} + DECLARE_INSTRUCTION(DSLL) { rrd = rrt << rsa; diff --git a/libmupen64plus/mupen64plus-core/src/r4300/ops.h b/libmupen64plus/mupen64plus-core/src/r4300/ops.h index b63a7ad933..08e962b2ca 100644 --- a/libmupen64plus/mupen64plus-core/src/r4300/ops.h +++ b/libmupen64plus/mupen64plus-core/src/r4300/ops.h @@ -306,7 +306,12 @@ typedef struct _cpu_instruction_table void (*SYSCALL)(void); // Exception instructions + void (*TGE)(void); + void (*TGEU)(void); + void (*TLT)(void); + void (*TLTU)(void); void (*TEQ)(void); + void (*TNE)(void); // Emulator helper functions void (*NOP)(void); // No operation (used to nullify R0 writes) diff --git a/libmupen64plus/mupen64plus-core/src/r4300/pure_interp.c b/libmupen64plus/mupen64plus-core/src/r4300/pure_interp.c index d8f892b82d..81ffcfa8bf 100644 --- a/libmupen64plus/mupen64plus-core/src/r4300/pure_interp.c +++ b/libmupen64plus/mupen64plus-core/src/r4300/pure_interp.c @@ -373,7 +373,12 @@ static cpu_instruction_table pure_interpreter_table = { SYSCALL, + TGE, + TGEU, + TLT, + TLTU, TEQ, + TNE, NOP, RESERVED, diff --git a/libmupen64plus/mupen64plus-core/src/r4300/r4300.c b/libmupen64plus/mupen64plus-core/src/r4300/r4300.c index 3e1a423063..9c8492b767 100644 --- a/libmupen64plus/mupen64plus-core/src/r4300/r4300.c +++ b/libmupen64plus/mupen64plus-core/src/r4300/r4300.c @@ -523,7 +523,12 @@ const cpu_instruction_table cached_interpreter_table = { SYSCALL, + TGE, + TGEU, + TLT, + TLTU, TEQ, + TNE, NOP, RESERVED, diff --git a/libmupen64plus/mupen64plus-core/src/r4300/recomp.c b/libmupen64plus/mupen64plus-core/src/r4300/recomp.c index dfca49aa6c..93bb8506b0 100644 --- a/libmupen64plus/mupen64plus-core/src/r4300/recomp.c +++ b/libmupen64plus/mupen64plus-core/src/r4300/recomp.c @@ -430,26 +430,30 @@ static void RDSUBU(void) static void RTGE(void) { - dst->ops = current_instruction_table.NI; - recomp_func = genni; + dst->ops = current_instruction_table.TGE; + recomp_func = gentge; + recompile_standard_r_type(); } static void RTGEU(void) { - dst->ops = current_instruction_table.NI; - recomp_func = genni; + dst->ops = current_instruction_table.TGEU; + recomp_func = gentgeu; + recompile_standard_r_type(); } static void RTLT(void) { - dst->ops = current_instruction_table.NI; - recomp_func = genni; + dst->ops = current_instruction_table.TLT; + recomp_func = gentlt; + recompile_standard_r_type(); } static void RTLTU(void) { - dst->ops = current_instruction_table.NI; - recomp_func = genni; + dst->ops = current_instruction_table.TLTU; + recomp_func = gentltu; + recompile_standard_r_type(); } static void RTEQ(void) @@ -461,8 +465,9 @@ static void RTEQ(void) static void RTNE(void) { - dst->ops = current_instruction_table.NI; - recomp_func = genni; + dst->ops = current_instruction_table.TNE; + recomp_func = gentne; + recompile_standard_r_type(); } static void RDSLL(void) diff --git a/libmupen64plus/mupen64plus-core/src/r4300/recomph.h b/libmupen64plus/mupen64plus-core/src/r4300/recomph.h index eb88c0f468..b2fabec687 100644 --- a/libmupen64plus/mupen64plus-core/src/r4300/recomph.h +++ b/libmupen64plus/mupen64plus-core/src/r4300/recomph.h @@ -193,7 +193,12 @@ void gendadd(void); void gendaddu(void); void gendsub(void); void gendsubu(void); +void gentge(void); +void gentgeu(void); +void gentlt(void); +void gentltu(void); void genteq(void); +void gentne(void); void gendsrl(void); void gendsrl32(void); void genbltz_idle(void); diff --git a/libmupen64plus/mupen64plus-core/src/r4300/x86/gspecial.c b/libmupen64plus/mupen64plus-core/src/r4300/x86/gspecial.c index 053c7af876..7708c05482 100644 --- a/libmupen64plus/mupen64plus-core/src/r4300/x86/gspecial.c +++ b/libmupen64plus/mupen64plus-core/src/r4300/x86/gspecial.c @@ -1041,11 +1041,36 @@ void gendsubu(void) #endif } +void gentge(void) +{ + gencallinterp((unsigned int)cached_interpreter_table.TGE, 0); +} + +void gentgeu(void) +{ + gencallinterp((unsigned int)cached_interpreter_table.TGEU, 0); +} + +void gentlt(void) +{ + gencallinterp((unsigned int)cached_interpreter_table.TLT, 0); +} + +void gentltu(void) +{ + gencallinterp((unsigned int)cached_interpreter_table.TLTU, 0); +} + void genteq(void) { gencallinterp((unsigned int)cached_interpreter_table.TEQ, 0); } +void gentne(void) +{ + gencallinterp((unsigned int)cached_interpreter_table.TNE, 0); +} + void gendsll(void) { #ifdef INTERPRET_DSLL diff --git a/libmupen64plus/mupen64plus-core/src/r4300/x86_64/gspecial.c b/libmupen64plus/mupen64plus-core/src/r4300/x86_64/gspecial.c index e162464475..49dbc78204 100644 --- a/libmupen64plus/mupen64plus-core/src/r4300/x86_64/gspecial.c +++ b/libmupen64plus/mupen64plus-core/src/r4300/x86_64/gspecial.c @@ -956,6 +956,26 @@ void gendsubu(void) #endif } +void gentge(void) +{ + gencallinterp((unsigned long long)cached_interpreter_table.TGE, 0); +} + +void gentgeu(void) +{ + gencallinterp((unsigned long long)cached_interpreter_table.TGEU, 0); +} + +void gentlt(void) +{ + gencallinterp((unsigned long long)cached_interpreter_table.TLT, 0); +} + +void gentltu(void) +{ + gencallinterp((unsigned long long)cached_interpreter_table.TLTU, 0); +} + void genteq(void) { #if defined(COUNT_INSTR) @@ -964,6 +984,11 @@ void genteq(void) gencallinterp((unsigned long long)cached_interpreter_table.TEQ, 0); } +void gentne(void) +{ + gencallinterp((unsigned long long)cached_interpreter_table.TNE, 0); +} + void gendsll(void) { #if defined(COUNT_INSTR) diff --git a/output/dll/mupen64plus.dll b/output/dll/mupen64plus.dll index 05cf1d522f..7f0a6f47d7 100644 Binary files a/output/dll/mupen64plus.dll and b/output/dll/mupen64plus.dll differ