Skip to content

Commit

Permalink
Update PCSX 2024-01-14 (#52)
Browse files Browse the repository at this point in the history
* git subrepo pull --force pcsx_rearmed

subrepo:
  subdir:   "pcsx_rearmed"
  merged:   "5ee1c926"
upstream:
  origin:   "https://github.com/libretro/pcsx_rearmed.git"
  branch:   "master"
  commit:   "5ee1c926"
git-subrepo:
  version:  "0.4.6"
  origin:   "https://github.com/ingydotnet/git-subrepo.git"
  commit:   "110b9eb"

* GamecubeMain: Work around in_keystate[] not being defined

Signed-off-by: Paul Cercueil <[email protected]>

* GamecubePlugins: wire up SPUsetCDvol() callback

Wire dfsound's SPUsetCDvol() so that it can be called by libpcsxcore.

Signed-off-by: Paul Cercueil <[email protected]>

---------

Signed-off-by: Paul Cercueil <[email protected]>
  • Loading branch information
pcercuei authored Jan 14, 2024
1 parent 642960a commit 7a1478e
Show file tree
Hide file tree
Showing 86 changed files with 1,957 additions and 996 deletions.
2 changes: 2 additions & 0 deletions Gamecube/GamecubeMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ int in_type[8] = {
PSE_PAD_TYPE_NONE, PSE_PAD_TYPE_NONE
};

unsigned short in_keystate[8];

extern "C" int stop;

static struct {
Expand Down
5 changes: 5 additions & 0 deletions Gamecube/GamecubePlugins.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ void CALLBACK SPUwriteRegister(unsigned long reg, unsigned short val, unsigned i
long CALLBACK SPUopen(void);
long CALLBACK SPUclose(void);
long CALLBACK SPUfreeze(uint32_t ulFreezeMode, void * pF, uint32_t cycles);
void CALLBACK SPUsetCDvol(unsigned char ll, unsigned char lr,
unsigned char rl, unsigned char rr, unsigned int cycle);


#define EMPTY_PLUGIN \
{ NULL, \
Expand Down Expand Up @@ -150,6 +153,8 @@ long CALLBACK SPUfreeze(uint32_t ulFreezeMode, void * pF, uint32_t cycles);
(void*)SPUplayADPCMchannel}, \
{ "SPUfreeze", \
(void*)SPUfreeze}, \
{ "SPUsetCDvol", \
(void*)SPUsetCDvol}, \
{ "SPUregisterCallback", \
(void*)SPUregisterCallback}, \
{ "SPUregisterCDDAVolume", \
Expand Down
4 changes: 2 additions & 2 deletions pcsx_rearmed/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/libretro/pcsx_rearmed.git
branch = master
commit = c396a646b9ce3082bc6aee7da35219f6424c99b6
parent = 879acaff3bcdd4189e49b9f0bf56dd7539471ebc
commit = 5ee1c9269d333936eba3e7e3259956f601ff5edd
parent = 942faf909f84e40c01883547ee430416baf5c2f0
method = merge
cmdver = 0.4.6
10 changes: 9 additions & 1 deletion pcsx_rearmed/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ else
CFLAGS += -O2 -DNDEBUG
endif
endif
ifeq ($(DEBUG_ASAN), 1)
CFLAGS += -fsanitize=address
endif
CFLAGS += -DP_HAVE_MMAP=$(if $(NO_MMAP),0,1) \
-DP_HAVE_PTHREAD=$(if $(NO_PTHREAD),0,1) \
-DP_HAVE_POSIX_MEMALIGN=$(if $(NO_POSIX_MEMALIGN),0,1) \
Expand Down Expand Up @@ -45,6 +48,9 @@ endif
CC_LINK ?= $(CC)
CC_AS ?= $(CC)
LDFLAGS += $(MAIN_LDFLAGS)
ifeq ($(DEBUG_ASAN), 1)
LDFLAGS += -static-libasan
endif
EXTRA_LDFLAGS ?= -Wl,-Map=$@.map
LDLIBS += $(MAIN_LDLIBS)
ifdef PCNT
Expand Down Expand Up @@ -173,7 +179,7 @@ ifeq "$(ARCH)" "arm"
OBJS += plugins/dfsound/arm_utils.o
endif
ifeq "$(HAVE_C64_TOOLS)" "1"
plugins/dfsound/spu.o: CFLAGS += -DC64X_DSP
plugins/dfsound/%.o: CFLAGS += -DC64X_DSP -DWANT_THREAD_CODE
plugins/dfsound/spu.o: plugins/dfsound/spu_c64x.c
frontend/menu.o: CFLAGS += -DC64X_DSP
endif
Expand Down Expand Up @@ -307,6 +313,8 @@ frontend/main.o frontend/menu.o: CFLAGS += -include frontend/pandora/ui_feat.h
frontend/libpicofe/linux/plat.o: CFLAGS += -DPANDORA
USE_PLUGIN_LIB = 1
USE_FRONTEND = 1
CFLAGS += -gdwarf-3 -ffunction-sections -fdata-sections
LDFLAGS += -Wl,--gc-sections
endif
ifeq "$(PLATFORM)" "caanoo"
OBJS += frontend/libpicofe/gp2x/in_gp2x.o frontend/warm/warm.o
Expand Down
2 changes: 1 addition & 1 deletion pcsx_rearmed/Makefile.libretro
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ ifneq (,$(shell $(CC) -E -dD $(CFLAGS) include/arm_features.h | grep 'HAVE_NEON3
BUILTIN_GPU = neon
endif
endif
ifneq (,$(findstring $(ARCH_DETECTED),i686 x86_64 arm64 aarch64))
ifneq (,$(filter $(ARCH_DETECTED),i686 x86_64 arm64 aarch64))
BUILTIN_GPU = neon
endif

Expand Down
4 changes: 2 additions & 2 deletions pcsx_rearmed/deps/lightning/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/pcercuei/gnu_lightning.git
branch = pcsx_rearmed
commit = 4d1ef4c372a2d7cd1cd25c637a18d802af7dfcb4
parent = 0f67f144fb172e9eaa7a722a0a853350f77aad15
commit = de026794c71386983034461bce2df3c63ccd5827
parent = fb67ea334b0f3984a114a6e306806a56347a83ba
method = merge
cmdver = 0.4.6
2 changes: 2 additions & 0 deletions pcsx_rearmed/deps/lightning/include/lightning.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <unistd.h>
#include <stdlib.h>
@MAYBE_INCLUDE_STDINT_H@
#include <stdio.h>
#include <string.h>
#include <pthread.h>

Expand Down Expand Up @@ -1220,6 +1221,7 @@ typedef void (*jit_free_func_ptr) (void*);
/*
* Prototypes
*/
extern void init_jit_with_debug(const char*,FILE*);
extern void init_jit(const char*);
extern void finish_jit(void);

Expand Down
4 changes: 2 additions & 2 deletions pcsx_rearmed/deps/lightning/include/lightning/jit_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -873,8 +873,8 @@ _emit_ldxi_d(jit_state_t*, jit_int32_t, jit_int32_t, jit_word_t);
extern void
_emit_stxi_d(jit_state_t*, jit_word_t, jit_int32_t, jit_int32_t);

extern void jit_init_print(void);
extern void jit_init_debug(const char*);
extern void jit_init_print(FILE*);
extern void jit_init_debug(const char*, FILE*);
extern void jit_finish_debug(void);

extern void jit_init_note(void);
Expand Down
6 changes: 3 additions & 3 deletions pcsx_rearmed/deps/lightning/lib/jit_disasm.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ static int fprintf_styled(void * stream, enum disassembler_style style, const ch
* Implementation
*/
void
jit_init_debug(const char *progname)
jit_init_debug(const char *progname, FILE *stream)
{
jit_init_print();
jit_init_print(stream);
#if DISASSEMBLER
bfd_init();

Expand All @@ -89,7 +89,7 @@ jit_init_debug(const char *progname)
bfd_check_format(disasm_bfd, bfd_object);
bfd_check_format(disasm_bfd, bfd_archive);
if (!disasm_stream)
disasm_stream = stdout;
disasm_stream = stream;

#if BINUTILS_2_38
INIT_DISASSEMBLE_INFO(disasm_info, disasm_stream, fprintf, fprintf_styled);
Expand Down
4 changes: 2 additions & 2 deletions pcsx_rearmed/deps/lightning/lib/jit_print.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ static FILE *print_stream;
* Implementation
*/
void
jit_init_print(void)
jit_init_print(FILE *stream)
{
if (!print_stream)
print_stream = stdout;
print_stream = stream;
}

void
Expand Down
10 changes: 8 additions & 2 deletions pcsx_rearmed/deps/lightning/lib/lightning.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,19 @@ _patch_register(jit_state_t *jit, jit_node_t *node, jit_node_t *link,
* Implementation
*/
void
init_jit(const char *progname)
init_jit_with_debug(const char *progname, FILE *dbg_out)
{
jit_get_cpu();
jit_init_debug(progname);
jit_init_debug(progname, dbg_out);
jit_init_size();
}

void
init_jit(const char *progname)
{
init_jit_with_debug(progname, stderr);
}

void
finish_jit(void)
{
Expand Down
4 changes: 2 additions & 2 deletions pcsx_rearmed/deps/lightrec/.gitrepo
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[subrepo]
remote = https://github.com/pcercuei/lightrec.git
branch = master
commit = b9e4089b3b6121f2077dc85a8fe7f934e3ae1c20
parent = bbe0dac4b7062d5ead765329d9ddb1e1fe01eee2
commit = d88760e40c1d2a5698c7b6f6a53cce31fda799f0
parent = 963f41620dce6ddb2527b7e3dced09564031f783
method = merge
cmdver = 0.4.6
2 changes: 1 addition & 1 deletion pcsx_rearmed/deps/lightrec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ list(APPEND LIGHTREC_HEADERS

option(ENABLE_FIRST_PASS "Run the interpreter as first-pass optimization" ON)

option(ENABLE_THREADED_COMPILER "Enable threaded compiler" OFF)
option(ENABLE_THREADED_COMPILER "Enable threaded compiler" ON)
if (ENABLE_THREADED_COMPILER)
list(APPEND LIGHTREC_SOURCES recompiler.c reaper.c)

Expand Down
2 changes: 1 addition & 1 deletion pcsx_rearmed/deps/lightrec/emitter.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ static void lightrec_emit_end_of_block(struct lightrec_cstate *state,
}

if (has_ds && op_flag_load_delay(ds->flags)
&& opcode_is_load(ds->c) && !state->no_load_delay) {
&& opcode_has_load_delay(ds->c) && !state->no_load_delay) {
/* If the delay slot is a load opcode, its target register
* will be written after the first opcode of the target is
* executed. Handle this by jumping to a special section of
Expand Down
35 changes: 17 additions & 18 deletions pcsx_rearmed/deps/lightrec/interpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ struct interpreter {
struct opcode *op;
u32 cycles;
bool delay_slot;
bool load_delay;
u16 offset;
};

Expand Down Expand Up @@ -150,14 +151,13 @@ static u32 int_delay_slot(struct interpreter *inter, u32 pc, bool branch)
.state = state,
.cycles = inter->cycles,
.delay_slot = true,
.block = NULL,
.load_delay = true,
};
bool run_first_op = false, dummy_ld = false, save_rs = false,
load_in_ds, branch_in_ds = false, branch_at_addr = false,
branch_taken;
u32 new_rt, old_rs = 0, new_rs = 0;
u32 next_pc, ds_next_pc;
u32 cause, epc;
u32 next_pc, ds_next_pc, epc;

if (op->i.op == OP_CP0 && op->r.rs == OP_CP0_RFE) {
/* When an IRQ happens, the PSX exception handlers (when done)
Expand All @@ -168,11 +168,13 @@ static u32 int_delay_slot(struct interpreter *inter, u32 pc, bool branch)
* but on branch boundaries, we need to adjust the return
* address so that the GTE opcode is effectively executed.
*/
cause = state->regs.cp0[13];
epc = state->regs.cp0[14];

if (!(cause & 0x7c) && epc == pc - 4)
pc -= 4;
if (epc == pc - 4) {
op_next = lightrec_read_opcode(state, epc);
if (op_next.i.op == OP_CP2)
pc -= 4;
}
}

if (inter->delay_slot) {
Expand All @@ -187,7 +189,7 @@ static u32 int_delay_slot(struct interpreter *inter, u32 pc, bool branch)
* interpreter in that case.
* Same goes for when we have a branch in a delay slot of another
* branch. */
load_in_ds = opcode_is_load(op->c) || opcode_is_mfc(op->c);
load_in_ds = opcode_has_load_delay(op->c);
branch_in_ds = has_delay_slot(op->c);

if (branch) {
Expand Down Expand Up @@ -600,7 +602,7 @@ static u32 int_io(struct interpreter *inter, bool is_load)
u32 *reg_cache = inter->state->regs.gpr;
u32 val, *flags = NULL;

if (inter->block)
if (!inter->load_delay && inter->block)
flags = &inter->op->flags;

val = lightrec_rw(inter->state, inter->op->c,
Expand Down Expand Up @@ -1188,16 +1190,14 @@ static u32 int_META(struct interpreter *inter)
static u32 lightrec_emulate_block_list(struct lightrec_state *state,
struct block *block, u32 offset)
{
struct interpreter inter;
struct interpreter inter = {
.block = block,
.state = state,
.offset = offset,
.op = &block->opcode_list[offset],
};
u32 pc;

inter.block = block;
inter.state = state;
inter.offset = offset;
inter.op = &block->opcode_list[offset];
inter.cycles = 0;
inter.delay_slot = false;

pc = lightrec_int_op(&inter);

/* Add the cycles of the last branch */
Expand Down Expand Up @@ -1253,9 +1253,8 @@ u32 lightrec_handle_load_delay(struct lightrec_state *state,
struct interpreter inter = {
.block = block,
.state = state,
.offset = 0,
.op = op,
.cycles = 0,
.load_delay = true,
};
bool branch_taken;
u32 reg_mask, next_pc;
Expand Down
Loading

0 comments on commit 7a1478e

Please sign in to comment.