From: Paul Cercueil Date: Sun, 11 Sep 2022 16:33:38 +0000 (+0200) Subject: Update lightrec 20220911 (#687) X-Git-Tag: r24l~389 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6ce0b00a79f4fa7c4a1735be9f48bfbc644b080c;p=pcsx_rearmed.git Update lightrec 20220911 (#687) * Fix symlink Using a symlink made it impossible to compile on Windows with MinGW. Signed-off-by: Paul Cercueil * lightrec: Fix crash on Windows and WiiU Fix crash on platforms that don't use Lightrec's custom map. Signed-off-by: Paul Cercueil * lightrec: Fix has_interrupt() using PCSX' registers It should use Lightrec's internal CP0 registers instead. Signed-off-by: Paul Cercueil * 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 --- diff --git a/Makefile b/Makefile index 0cc90ce8..91bf5773 100644 --- 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" diff --git a/deps/lightrec/.gitrepo b/deps/lightrec/.gitrepo index 3f25cc2e..79aaa500 100644 --- a/deps/lightrec/.gitrepo +++ b/deps/lightrec/.gitrepo @@ -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 diff --git a/deps/lightrec/emitter.c b/deps/lightrec/emitter.c index cf32f7a4..523daf77 100644 --- a/deps/lightrec/emitter.c +++ b/deps/lightrec/emitter.c @@ -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); diff --git a/deps/lightrec/lightrec.c b/deps/lightrec/lightrec.c index 497cc685..fa08a800 100644 --- a/deps/lightrec/lightrec.c +++ b/deps/lightrec/lightrec.c @@ -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) { diff --git a/include/mman/sys/mman.h b/include/mman/sys/mman.h deleted file mode 120000 index 1c111c30..00000000 --- a/include/mman/sys/mman.h +++ /dev/null @@ -1 +0,0 @@ -../../../deps/mman/mman.h \ No newline at end of file diff --git a/include/mman/sys/mman.h b/include/mman/sys/mman.h new file mode 100644 index 00000000..55f7ea8a --- /dev/null +++ b/include/mman/sys/mman.h @@ -0,0 +1 @@ +#include diff --git a/libpcsxcore/lightrec/plugin.c b/libpcsxcore/lightrec/plugin.c index 13c11e34..8f12b979 100644 --- a/libpcsxcore/lightrec/plugin.c +++ b/libpcsxcore/lightrec/plugin.c @@ -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; }