From 4ad17db3c1b6bfa042832d613369eda9c7ffff4f Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 10 Sep 2022 17:53:54 +0300 Subject: [PATCH] some big endian fixes "kinda sucks but it works" kind of thing --- frontend/libpicofe | 2 +- frontend/menu.c | 41 ++++++++++++++++++++++++++++-------- libpcsxcore/cdrom.c | 16 +++++++++++++- libpcsxcore/cdrom.h | 1 - plugins/dfxvideo/gpu.c | 9 -------- plugins/dfxvideo/gpu.h | 4 ---- plugins/dfxvideo/gpulib_if.c | 20 ++++++++---------- plugins/dfxvideo/soft.c | 15 +++++++------ 8 files changed, 65 insertions(+), 43 deletions(-) diff --git a/frontend/libpicofe b/frontend/libpicofe index 33787db4..7167e5f3 160000 --- a/frontend/libpicofe +++ b/frontend/libpicofe @@ -1 +1 @@ -Subproject commit 33787db41d955f8dcafe833097f2cc87d70186ec +Subproject commit 7167e5f3376f0d0692ae102ed2df1ef5d2cc199a diff --git a/frontend/menu.c b/frontend/menu.c index 1c9ed6ab..4816ecea 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -96,6 +96,7 @@ static int config_save_counter, region, in_type_sel1, in_type_sel2; static int psx_clock; static int memcard1_sel = -1, memcard2_sel = -1; extern int g_autostateld_opt; +static int menu_iopts[8]; int g_opts, g_scaler, g_gamma = 100; int scanlines, scanline_level = 20; int soft_scaling, analog_deadzone; // for Caanoo @@ -1571,14 +1572,16 @@ static menu_entry e_menu_speed_hacks[] = mee_onoff_h ("Assume GTE regs unneeded", 0, new_dynarec_hacks, NDHACK_GTE_UNNEEDED, h_cfg_gteunn), mee_onoff_h ("Disable GTE flags", 0, new_dynarec_hacks, NDHACK_GTE_NO_FLAGS, h_cfg_gteflgs), #endif - mee_onoff_h ("Disable CPU/GTE stalls", 0, Config.DisableStalls, 1, h_cfg_stalls), + mee_onoff_h ("Disable CPU/GTE stalls", 0, menu_iopts[0], 1, h_cfg_stalls), mee_end, }; static int menu_loop_speed_hacks(int id, int keys) { static int sel = 0; + menu_iopts[0] = Config.DisableStalls; me_loop(e_menu_speed_hacks, &sel); + Config.DisableStalls = menu_iopts[0]; return 0; } @@ -1603,22 +1606,24 @@ static const char h_cfg_nodrc[] = "Disable dynamic recompiler and use interpret static const char h_cfg_shacks[] = "Breaks games but may give better performance"; static const char h_cfg_icache[] = "Support F1 games (only when dynarec is off)"; +enum { AMO_XA, AMO_CDDA, AMO_SIO, AMO_SPUI, AMO_IC, AMO_RCNT, AMO_WA, AMO_CPU }; + static menu_entry e_menu_adv_options[] = { mee_onoff_h ("Show CPU load", 0, g_opts, OPT_SHOWCPU, h_cfg_cpul), mee_onoff_h ("Show SPU channels", 0, g_opts, OPT_SHOWSPU, h_cfg_spu), mee_onoff_h ("Disable Frame Limiter", 0, g_opts, OPT_NO_FRAMELIM, h_cfg_fl), - mee_onoff_h ("Disable XA Decoding", 0, Config.Xa, 1, h_cfg_xa), - mee_onoff_h ("Disable CD Audio", 0, Config.Cdda, 1, h_cfg_cdda), - //mee_onoff_h ("SIO IRQ Always Enabled", 0, Config.Sio, 1, h_cfg_sio), - mee_onoff_h ("SPU IRQ Always Enabled", 0, Config.SpuIrq, 1, h_cfg_spuirq), - mee_onoff_h ("ICache emulation", 0, Config.icache_emulation, 1, h_cfg_icache), + mee_onoff_h ("Disable XA Decoding", 0, menu_iopts[AMO_XA], 1, h_cfg_xa), + mee_onoff_h ("Disable CD Audio", 0, menu_iopts[AMO_CDDA], 1, h_cfg_cdda), + //mee_onoff_h ("SIO IRQ Always Enabled", 0, menu_iopts[AMO_SIO], 1, h_cfg_sio), + mee_onoff_h ("SPU IRQ Always Enabled", 0, menu_iopts[AMO_SPUI], 1, h_cfg_spuirq), + mee_onoff_h ("ICache emulation", 0, menu_iopts[AMO_IC], 1, h_cfg_icache), #ifdef DRC_DISABLE - mee_onoff_h ("Rootcounter hack", 0, Config.RCntFix, 1, h_cfg_rcnt1), + mee_onoff_h ("Rootcounter hack", 0, menu_iopts[AMO_RCNT], 1, h_cfg_rcnt1), #endif - mee_onoff_h ("Rootcounter hack 2", 0, Config.VSyncWA, 1, h_cfg_rcnt2), + mee_onoff_h ("Rootcounter hack 2", 0, menu_iopts[AMO_WA], 1, h_cfg_rcnt2), #if !defined(DRC_DISABLE) || defined(LIGHTREC) - mee_onoff_h ("Disable dynarec (slow!)",0, Config.Cpu, 1, h_cfg_nodrc), + mee_onoff_h ("Disable dynarec (slow!)",0, menu_iopts[AMO_CPU], 1, h_cfg_nodrc), #endif mee_handler_h ("[Speed hacks]", menu_loop_speed_hacks, h_cfg_shacks), mee_end, @@ -1627,7 +1632,25 @@ static menu_entry e_menu_adv_options[] = static int menu_loop_adv_options(int id, int keys) { static int sel = 0; + static struct { + boolean *opt; + int *mopt; + } opts[] = { + { &Config.Xa, &menu_iopts[AMO_XA] }, + { &Config.Cdda, &menu_iopts[AMO_CDDA] }, + { &Config.Sio, &menu_iopts[AMO_SIO] }, + { &Config.SpuIrq, &menu_iopts[AMO_SPUI] }, + { &Config.icache_emulation, &menu_iopts[AMO_IC] }, + { &Config.RCntFix, &menu_iopts[AMO_RCNT] }, + { &Config.VSyncWA, &menu_iopts[AMO_WA] }, + { &Config.Cpu, &menu_iopts[AMO_CPU] }, + }; + int i; + for (i = 0; i < ARRAY_SIZE(opts); i++) + *opts[i].mopt = *opts[i].opt; me_loop(e_menu_adv_options, &sel); + for (i = 0; i < ARRAY_SIZE(opts); i++) + *opts[i].opt = *opts[i].mopt; return 0; } diff --git a/libpcsxcore/cdrom.c b/libpcsxcore/cdrom.c index 3fafc198..cdb7a1ee 100644 --- a/libpcsxcore/cdrom.c +++ b/libpcsxcore/cdrom.c @@ -567,6 +567,8 @@ static int cdrSeekTime(unsigned char *target) } static void cdrReadInterrupt(void); +static void cdrPrepCdda(s16 *buf, int samples); +static void cdrAttenuate(s16 *buf, int samples, int stereo); void cdrPlaySeekReadInterrupt(void) { @@ -613,6 +615,7 @@ void cdrPlaySeekReadInterrupt(void) cdrPlayInterrupt_Autopause(); if (!cdr.Muted && !Config.Cdda) { + cdrPrepCdda(read_buf, CD_FRAMESIZE_RAW / 4); cdrAttenuate(read_buf, CD_FRAMESIZE_RAW / 4, 1); SPU_playCDDAchannel(read_buf, CD_FRAMESIZE_RAW, psxRegs.cycle, cdr.FirstSector); cdr.FirstSector = 0; @@ -1117,7 +1120,18 @@ void cdrInterrupt(void) { } while (0) #endif -void cdrAttenuate(s16 *buf, int samples, int stereo) +static void cdrPrepCdda(s16 *buf, int samples) +{ +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + int i; + for (i = 0; i < samples; i++) { + buf[i * 2 + 0] = SWAP16(buf[i * 2 + 0]); + buf[i * 2 + 1] = SWAP16(buf[i * 2 + 1]); + } +#endif +} + +static void cdrAttenuate(s16 *buf, int samples, int stereo) { int i, l, r; int ll = cdr.AttenuatorLeftToLeft; diff --git a/libpcsxcore/cdrom.h b/libpcsxcore/cdrom.h index 0cd6c5f6..52bd21c0 100644 --- a/libpcsxcore/cdrom.h +++ b/libpcsxcore/cdrom.h @@ -46,7 +46,6 @@ extern "C" { #define SUB_FRAMESIZE 96 void cdrReset(); -void cdrAttenuate(s16 *buf, int samples, int stereo); void cdrInterrupt(void); void cdrPlaySeekReadInterrupt(void); diff --git a/plugins/dfxvideo/gpu.c b/plugins/dfxvideo/gpu.c index 9356a6e9..1a3f25ac 100644 --- a/plugins/dfxvideo/gpu.c +++ b/plugins/dfxvideo/gpu.c @@ -24,12 +24,8 @@ //////////////////////////////////////////////////////////////////////// unsigned char *psxVub; -signed char *psxVsb; unsigned short *psxVuw; unsigned short *psxVuw_eom; -signed short *psxVsw; -uint32_t *psxVul; -int32_t *psxVsl; //////////////////////////////////////////////////////////////////////// // GPU globals @@ -96,12 +92,7 @@ long CALLBACK GPUinit(void) // GPU INIT //!!! ATTENTION !!! psxVub=vram + 512 * 1024; // security offset into double sized psx vram! - psxVsb=(signed char *)psxVub; // different ways of accessing PSX VRAM - psxVsw=(signed short *)psxVub; - psxVsl=(int32_t *)psxVub; psxVuw=(unsigned short *)psxVub; - psxVul=(uint32_t *)psxVub; - psxVuw_eom=psxVuw+1024*512; // pre-calc of end of vram memset(vram,0x00,(512*2)*1024 + (1024*1024)); diff --git a/plugins/dfxvideo/gpu.h b/plugins/dfxvideo/gpu.h index 74556928..224bc654 100644 --- a/plugins/dfxvideo/gpu.h +++ b/plugins/dfxvideo/gpu.h @@ -277,11 +277,7 @@ extern BOOL bSkipNextFrame; extern long lGPUstatusRet; extern unsigned char * psxVSecure; extern unsigned char * psxVub; -extern signed char * psxVsb; extern unsigned short * psxVuw; -extern signed short * psxVsw; -extern uint32_t * psxVul; -extern int32_t * psxVsl; extern unsigned short * psxVuw_eom; extern BOOL bChangeWinMode; extern long lSelectedSlot; diff --git a/plugins/dfxvideo/gpulib_if.c b/plugins/dfxvideo/gpulib_if.c index 47cccedf..86cfd268 100644 --- a/plugins/dfxvideo/gpulib_if.c +++ b/plugins/dfxvideo/gpulib_if.c @@ -233,12 +233,8 @@ extern int32_t drawH; PSXDisplay_t PSXDisplay; unsigned char *psxVub; -signed char *psxVsb; unsigned short *psxVuw; unsigned short *psxVuw_eom; -signed short *psxVsw; -uint32_t *psxVul; -int32_t *psxVsl; long lGPUstatusRet; uint32_t lGPUInfoVals[16]; @@ -266,13 +262,7 @@ long lLowerpart; static void set_vram(void *vram) { psxVub=vram; - - psxVsb=(signed char *)psxVub; // different ways of accessing PSX VRAM - psxVsw=(signed short *)psxVub; - psxVsl=(int32_t *)psxVub; psxVuw=(unsigned short *)psxVub; - psxVul=(uint32_t *)psxVub; - psxVuw_eom=psxVuw+1024*512; // pre-calc of end of vram } @@ -402,8 +392,16 @@ breakloop: return list - list_start; } -void renderer_sync_ecmds(uint32_t *ecmds) +void renderer_sync_ecmds(uint32_t *ecmds_) { +#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ + // the funcs below expect LE + uint32_t i, ecmds[8]; + for (i = 1; i <= 6; i++) + ecmds[i] = HTOLE32(ecmds_[i]); +#else + uint32_t *ecmds = ecmds_; +#endif cmdTexturePage((unsigned char *)&ecmds[1]); cmdTextureWindow((unsigned char *)&ecmds[2]); cmdDrawAreaStart((unsigned char *)&ecmds[3]); diff --git a/plugins/dfxvideo/soft.c b/plugins/dfxvideo/soft.c index 70cf50cd..a9d9e042 100644 --- a/plugins/dfxvideo/soft.c +++ b/plugins/dfxvideo/soft.c @@ -971,13 +971,14 @@ static void FillSoftwareAreaTrans(short x0,short y0,short x1, // FILL AREA TRANS { uint32_t *DSTPtr; unsigned short LineOffset; - uint32_t lcol = HOST2LE32(lSetMask | (((uint32_t)(col)) << 16) | col); + uint32_t lcol = lSetMask | ((uint32_t)col << 16) | col; dx>>=1; DSTPtr = (uint32_t *)(psxVuw + (1024*y0) + x0); LineOffset = 512 - dx; if(!bCheckMask && !DrawSemiTrans) { + lcol = HOST2LE32(lcol); for(i=0;i> 16; if(drawX>xmin) xmin=drawX; @@ -2409,9 +2410,9 @@ static inline void drawPoly3Fi(short x1,short y1,short x2,short y2,short x3,shor for(j=xmin;j> 16; if(drawX>xmin) xmin=drawX; @@ -2489,9 +2490,9 @@ static void drawPoly4F(int32_t rgb) for(j=xmin;j