Update lightrec 20220911 (#687)
authorPaul Cercueil <paul@crapouillou.net>
Sun, 11 Sep 2022 16:33:38 +0000 (18:33 +0200)
committerGitHub <noreply@github.com>
Sun, 11 Sep 2022 16:33:38 +0000 (18:33 +0200)
* Fix <sys/mman.h> symlink

Using a symlink made it impossible to compile on Windows with MinGW.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
* lightrec: Fix crash on Windows and WiiU

Fix crash on platforms that don't use Lightrec's custom map.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
* lightrec: Fix has_interrupt() using PCSX' registers

It should use Lightrec's internal CP0 registers instead.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
* git subrepo pull --force deps/lightrec

subrepo:
  subdir:   "deps/lightrec"
  merged:   "071973e3ac"
upstream:
  origin:   "https://github.com/pcercuei/lightrec.git"
  branch:   "master"
  commit:   "071973e3ac"
git-subrepo:
  version:  "0.4.3"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "2f68596"

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Makefile
deps/lightrec/.gitrepo
deps/lightrec/emitter.c
deps/lightrec/lightrec.c
include/mman/sys/mman.h [changed from symlink to file mode: 0644]
libpcsxcore/lightrec/plugin.c

index 0cc90ce..91bf577 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -118,7 +118,7 @@ OBJS += deps/lightning/lib/jit_disasm.o \
                deps/lightrec/reaper.o
 libpcsxcore/lightrec/mem.o: CFLAGS += -D_GNU_SOURCE
 ifeq ($(MMAP_WIN32),1)
-CFLAGS += -Iinclude/mman
+CFLAGS += -Iinclude/mman -I deps/mman
 OBJS += deps/mman/mman.o
 endif
 else ifeq "$(DYNAREC)" "ari64"
index 3f25cc2..79aaa50 100644 (file)
@@ -6,7 +6,7 @@
 [subrepo]
        remote = https://github.com/pcercuei/lightrec.git
        branch = master
-       commit = e1222761836bb478dcec86cf441dcc5514565137
-       parent = eeff1b0a26e4c7f7449640c0bf999e506f538694
+       commit = 071973e3ac26619cd3afbe339f020a2d4d61c28a
+       parent = cc8a5c0c654c18b3ad074e49f526cb6cae77f8b0
        method = merge
        cmdver = 0.4.3
index cf32f7a..523daf7 100644 (file)
@@ -679,10 +679,8 @@ static void rec_special_or_nor(struct lightrec_cstate *state,
        if (!nor)
                flags_rd = REG_ZEXT & flags_rs & flags_rt;
 
-       /* E(rd) = (E(rs) & E(rt)) | (E(rt) & !Z(rt)) | (E(rs) & !Z(rs)) */
-       if ((REG_EXT & flags_rs & flags_rt) ||
-           ((flags_rt & (REG_EXT | REG_ZEXT)) == REG_EXT) ||
-           ((flags_rs & (REG_EXT | REG_ZEXT)) == REG_EXT))
+       /* E(rd) = E(rs) & E(rt) */
+       if (REG_EXT & flags_rs & flags_rt)
                flags_rd |= REG_EXT;
 
        lightrec_set_reg_out_flags(reg_cache, rd, flags_rd);
index 497cc68..fa08a80 100644 (file)
@@ -256,16 +256,20 @@ u32 lightrec_rw(struct lightrec_state *state, union code op,
                return 0;
        }
 
-       if (unlikely(map->ops)) {
-               if (flags && !LIGHTREC_FLAGS_GET_IO_MODE(*flags))
-                       *flags |= LIGHTREC_IO_MODE(LIGHTREC_IO_HW);
 
-               ops = map->ops;
-       } else {
+       if (likely(!map->ops)) {
                if (flags && !LIGHTREC_FLAGS_GET_IO_MODE(*flags))
                        *flags |= LIGHTREC_IO_MODE(LIGHTREC_IO_DIRECT);
 
                ops = &lightrec_default_ops;
+       } else if (flags &&
+                  LIGHTREC_FLAGS_GET_IO_MODE(*flags) == LIGHTREC_IO_DIRECT_HW) {
+               ops = &lightrec_default_ops;
+       } else {
+               if (flags && !LIGHTREC_FLAGS_GET_IO_MODE(*flags))
+                       *flags |= LIGHTREC_IO_MODE(LIGHTREC_IO_HW);
+
+               ops = map->ops;
        }
 
        switch (op.i.op) {
deleted file mode 120000 (symlink)
index 1c111c30224d7104a4cf272116947c71579c475f..0000000000000000000000000000000000000000
+++ /dev/null
@@ -1 +0,0 @@
-../../../deps/mman/mman.h
\ No newline at end of file
new file mode 100644 (file)
index 0000000000000000000000000000000000000000..55f7ea8ae15041748a86cddf4e7401a56f946a3d
--- /dev/null
@@ -0,0 +1 @@
+#include <mman.h>
index 13c11e3..8f12b97 100644 (file)
@@ -126,9 +126,11 @@ static void cop2_op(struct lightrec_state *state, u32 func)
 
 static bool has_interrupt(void)
 {
+       struct lightrec_registers *regs = lightrec_get_registers(lightrec_state);
+
        return ((psxHu32(0x1070) & psxHu32(0x1074)) &&
-            (psxRegs.CP0.n.Status & 0x401) == 0x401) ||
-           (psxRegs.CP0.n.Status & psxRegs.CP0.n.Cause & 0x0300);
+               (regs->cp0[12] & 0x401) == 0x401) ||
+               (regs->cp0[12] & regs->cp0[13] & 0x0300);
 }
 
 static void lightrec_restore_state(struct lightrec_state *state)
@@ -390,13 +392,13 @@ static int lightrec_plugin_init(void)
        lightrec_map[PSX_MAP_KERNEL_USER_RAM].address = psxM;
        lightrec_map[PSX_MAP_BIOS].address = psxR;
        lightrec_map[PSX_MAP_SCRATCH_PAD].address = psxH;
+       lightrec_map[PSX_MAP_HW_REGISTERS].address = psxH + 0x1000;
        lightrec_map[PSX_MAP_PARALLEL_PORT].address = psxP;
 
        if (LIGHTREC_CUSTOM_MAP) {
                lightrec_map[PSX_MAP_MIRROR1].address = psxM + 0x200000;
                lightrec_map[PSX_MAP_MIRROR2].address = psxM + 0x400000;
                lightrec_map[PSX_MAP_MIRROR3].address = psxM + 0x600000;
-               lightrec_map[PSX_MAP_HW_REGISTERS].address = psxH + 0x1000;
                lightrec_map[PSX_MAP_CODE_BUFFER].address = code_buffer;
        }