Skip to content

Commit

Permalink
standalone: revive spu_c64x build
Browse files Browse the repository at this point in the history
and some other minor pandora stuff
  • Loading branch information
notaz committed Dec 11, 2023
1 parent 8338889 commit 42dde52
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 19 deletions.
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,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 @@ -220,6 +220,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
5 changes: 3 additions & 2 deletions frontend/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1720,6 +1720,7 @@ static const char h_confirm_save[] = "Ask for confirmation when overwriting s
static const char h_restore_def[] = "Switches back to default / recommended\n"
"configuration";
static const char h_frameskip[] = "Warning: frameskip sometimes causes glitches\n";
static const char h_sputhr[] = "Warning: has some known bugs\n";

static menu_entry e_menu_options[] =
{
Expand All @@ -1730,9 +1731,9 @@ static menu_entry e_menu_options[] =
mee_enum ("Region", 0, region, men_region),
mee_range ("CPU clock", MA_OPT_CPU_CLOCKS, cpu_clock, 20, 5000),
#ifdef C64X_DSP
mee_onoff ("Use C64x DSP for sound", MA_OPT_SPU_THREAD, spu_config.iUseThread, 1),
mee_onoff_h ("Use C64x DSP for sound", MA_OPT_SPU_THREAD, spu_config.iUseThread, 1, h_sputhr),
#else
mee_onoff ("Threaded SPU", MA_OPT_SPU_THREAD, spu_config.iUseThread, 1),
mee_onoff_h ("Threaded SPU", MA_OPT_SPU_THREAD, spu_config.iUseThread, 1, h_sputhr),
#endif
mee_handler_id("[Display]", MA_OPT_DISP_OPTS, menu_loop_gfx_options),
mee_handler ("[BIOS/Plugins]", menu_loop_plugin_options),
Expand Down
2 changes: 1 addition & 1 deletion frontend/plugin_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ static void pl_vout_flip(const void *vram, int stride, int bgr24,
doffs = xoffs + y * dstride;

if (dims_changed)
flip_clear_counter = 2;
flip_clear_counter = 3;

if (flip_clear_counter > 0) {
if (pl_plat_clear)
Expand Down
3 changes: 3 additions & 0 deletions plugins/dfsound/Makefile.c64p
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
ifndef C64_TOOLS_DSP_ROOT
$(error need C64_TOOLS_DSP_ROOT)
endif
ifndef TI_CGTOOLS
$(error need TI_CGTOOLS and stuff, source c64_tools/dsp/setenv.sh)
endif

include $(C64_TOOLS_DSP_ROOT)/install.mk

Expand Down
10 changes: 7 additions & 3 deletions plugins/dfsound/externals.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,17 @@ typedef struct

sample_buf sb[MAXCHAN];
int interpolation;
sample_buf sb_thread[MAXCHAN];

#if P_HAVE_PTHREAD || defined(WANT_THREAD_CODE)
sample_buf * sb_thread;
sample_buf sb_thread_[MAXCHAN];
#endif
} SPUInfo;

#define regAreaGet(offset) \
spu.regArea[((offset) - 0xc00)>>1]
spu.regArea[((offset) - 0xc00) >> 1]
#define regAreaGetCh(ch, offset) \
spu.regArea[((ch<<4)|(offset))>>1]
spu.regArea[(((ch) << 4) | (offset)) >> 1]

///////////////////////////////////////////////////////////
// SPU.C globals
Expand Down
2 changes: 1 addition & 1 deletion plugins/dfsound/gauss_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,4 @@ const int gauss[]={
0xffffffff, 0x1307, 0x59b3, 0x12c7,
};

#endif
#endif
2 changes: 2 additions & 0 deletions plugins/dfsound/spu.c
Original file line number Diff line number Diff line change
Expand Up @@ -1490,6 +1490,8 @@ static void init_spu_thread(void)
{
int ret;

spu.sb_thread = spu.sb_thread_;

if (sysconf(_SC_NPROCESSORS_ONLN) <= 1)
return;

Expand Down
9 changes: 4 additions & 5 deletions plugins/dfsound/spu_c64x.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ static void thread_work_wait_sync(struct work_item *work, int force)
preload(work->SSumLR);
preload(work->SSumLR + 64/4);

f.stale_caches = 1; // SB, spuMem
f.stale_caches = 1; // sb, spuMem

if (limit == 0)
printf("dsp: wait timeout\n");
Expand All @@ -188,7 +188,7 @@ static void thread_work_wait_sync(struct work_item *work, int force)
static void thread_sync_caches(void)
{
if (f.stale_caches) {
f.dsp_cache_inv_virt(spu.SB, sizeof(spu.SB[0]) * SB_SIZE * 24);
f.dsp_cache_inv_virt(spu.sb_thread, sizeof(spu.sb_thread[0]) * MAXCHAN);
f.dsp_cache_inv_virt(spu.spuMemC + 0x800, 0x800);
if (spu.rvb->StartAddr) {
int left = 0x40000 - spu.rvb->StartAddr;
Expand Down Expand Up @@ -281,8 +281,7 @@ static void init_spu_thread(void)
// override default allocations
free(spu.spuMemC);
spu.spuMemC = mem->spu_ram;
free(spu.SB);
spu.SB = mem->SB;
spu.sb_thread = mem->sb_thread;
free(spu.s_chan);
spu.s_chan = mem->in.s_chan;
free(spu.rvb);
Expand Down Expand Up @@ -326,7 +325,7 @@ static void exit_spu_thread(void)
f.dsp_close();

spu.spuMemC = NULL;
spu.SB = NULL;
spu.sb_thread = spu.sb_thread_;
spu.s_chan = NULL;
spu.rvb = NULL;
worker = NULL;
Expand Down
7 changes: 5 additions & 2 deletions plugins/dfsound/spu_c64x.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#ifndef __P_SPU_C64X_H__
#define __P_SPU_C64X_H__

#include "externals.h"
#include "spu_config.h"

#define COMPONENT_NAME "pcsxr_spu"

enum {
Expand All @@ -10,10 +13,10 @@ enum {

struct region_mem {
unsigned char spu_ram[512 * 1024];
int SB[SB_SIZE * 24];
sample_buf sb_thread[MAXCHAN];
// careful not to lose ARM writes by DSP overwriting
// with old data when it's writing out neighbor cachelines
int _pad1[128/4 - ((SB_SIZE * 24) & (128/4 - 1))];
int _pad1[128/4 - ((sizeof(sample_buf) * MAXCHAN / 4) & (128/4 - 1))];
struct spu_in {
// these are not to be modified by DSP
SPUCHAN s_chan[24 + 1];
Expand Down
6 changes: 3 additions & 3 deletions plugins/dfsound/spu_c64x_dspcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ static void do_processing(void)
// nothing to do? Write out non-critical caches
if (dirty) {
syscalls.cache_wb(spu.spuMemC + 0x800, 0x800, 1);
syscalls.cache_wb(spu.SB, sizeof(spu.SB[0]) * SB_SIZE * 24, 1);
syscalls.cache_wb(spu.sb_thread, sizeof(spu.sb_thread[0]) * MAXCHAN, 1);
if (had_rvb) {
left = 0x40000 - spu.rvb->StartAddr;
syscalls.cache_wb(spu.spuMem + spu.rvb->StartAddr, left * 2, 1);
Expand Down Expand Up @@ -143,7 +143,7 @@ static unsigned int exec(dsp_component_cmd_t cmd,
InitADSR();

spu.spuMemC = mem->spu_ram;
spu.SB = mem->SB;
spu.sb_thread = mem->sb_thread;
spu.s_chan = mem->in.s_chan;
spu.rvb = &mem->in.rvb;
worker = &mem->worker;
Expand All @@ -169,7 +169,7 @@ static unsigned int exec(dsp_component_cmd_t cmd,

do_processing();

syscalls.cache_inv(&mem->SB, sizeof(mem->SB), 0);
syscalls.cache_inv(&mem->sb_thread, sizeof(mem->sb_thread), 0);
syscalls.cache_inv(&mem->in, sizeof(mem->in), 0);
break;

Expand Down
2 changes: 1 addition & 1 deletion plugins/dfsound/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#define INLINE static inline
#endif

#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#if defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define HTOLE16(x) __builtin_bswap16(x)
#define LE16TOH(x) __builtin_bswap16(x)
#else
Expand Down

0 comments on commit 42dde52

Please sign in to comment.