-static void cop0_mtc_ctc(struct lightrec_state *state,
- u8 reg, u32 value, bool ctc)
-{
- psxRegs.cycle = lightrec_current_cycle_count(state);
-
- switch (reg) {
- case 1:
- case 4:
- case 8:
- case 14:
- case 15:
- /* Those registers are read-only */
- break;
- case 12: /* Status */
- if ((psxRegs.CP0.n.Status & ~value) & (1 << 16)) {
- memcpy(psxM, cache_buf, sizeof(cache_buf));
- lightrec_invalidate_all(state);
- } else if ((~psxRegs.CP0.n.Status & value) & (1 << 16)) {
- memcpy(cache_buf, psxM, sizeof(cache_buf));
- }
-
- psxRegs.CP0.n.Status = value;
- break;
- case 13: /* Cause */
- psxRegs.CP0.n.Cause &= ~0x0300;
- psxRegs.CP0.n.Cause |= value & 0x0300;
- break;
- default:
- psxRegs.CP0.r[reg] = value;
- break;
- }
-
- lightrec_restore_state(state);
-}
-
-static void cop2_mtc_ctc(struct lightrec_state *state,
- u8 reg, u32 value, bool ctc)
-{
- if (ctc)
- CTC2(value, reg);
- else
- MTC2(value, reg);
-}
-
-static void cop0_mtc(struct lightrec_state *state, u32 op, u8 reg, u32 value)
-{
- cop0_mtc_ctc(state, reg, value, false);
-}
-
-static void cop0_ctc(struct lightrec_state *state, u32 op, u8 reg, u32 value)
-{
- cop0_mtc_ctc(state, reg, value, true);
-}
-
-static void cop2_mtc(struct lightrec_state *state, u32 op, u8 reg, u32 value)
-{
- cop2_mtc_ctc(state, reg, value, false);
-}
-
-static void cop2_ctc(struct lightrec_state *state, u32 op, u8 reg, u32 value)
-{
- cop2_mtc_ctc(state, reg, value, true);
-}
-
-static void cop0_op(struct lightrec_state *state, u32 func)
-{
- fprintf(stderr, "Invalid access to COP0\n");
-}
-
-static void cop2_op(struct lightrec_state *state, u32 func)
-{
- psxRegs.code = func;
-
- if (unlikely(!cp2_ops[func & 0x3f]))
- fprintf(stderr, "Invalid CP2 function %u\n", func);
- else
- cp2_ops[func & 0x3f](&psxRegs.CP2);
-}
-