From 5b5680983b7b3dde95acfe42f58e748d9f7fe1cb Mon Sep 17 00:00:00 2001 From: notaz Date: Fri, 14 Oct 2022 23:24:21 +0300 Subject: [PATCH] reduce differences from upstream because libretro-only breakage is too annoying to track down --- frontend/cspace.c | 3 -- frontend/main.c | 17 ++++++----- frontend/menu.c | 55 +++++++++++++++++++++++------------ frontend/plugin_lib.c | 1 - libpcsxcore/cdriso.c | 8 ++--- libpcsxcore/debug.c | 5 ++++ libpcsxcore/disr3000a.c | 5 ++++ libpcsxcore/gte_divider.c | 1 + libpcsxcore/gte_neon.S | 2 +- libpcsxcore/misc.c | 15 +++++----- libpcsxcore/plugins.c | 5 ++-- libpcsxcore/ppf.c | 18 ++++++------ libpcsxcore/psxcounters.c | 3 +- libpcsxcore/psxdma.c | 3 +- libpcsxcore/psxhle.c | 2 +- libpcsxcore/psxhle.h | 2 +- libpcsxcore/psxinterpreter.h | 3 ++ libpcsxcore/psxmem.c | 43 ++++++++++++++------------- libpcsxcore/psxmem.h | 4 +++ libpcsxcore/r3000a.h | 2 -- libpcsxcore/system.h | 1 - plugins/cdrcimg/cdrcimg.c | 2 -- plugins/dfinput/main.c | 23 ++++++++------- plugins/dfxvideo/gpu.c | 4 +-- plugins/dfxvideo/gpulib_if.c | 4 +++ plugins/gpu-gles/gpuDraw.c | 8 ++--- plugins/gpu-gles/gpuPlugin.c | 5 ++-- plugins/gpu-gles/gpuStdafx.h | 2 +- plugins/gpu_neon/psx_gpu_if.c | 3 +- plugins/gpulib/gpu.c | 5 ++-- plugins/gpulib/vout_pl.c | 4 +-- 31 files changed, 147 insertions(+), 111 deletions(-) diff --git a/frontend/cspace.c b/frontend/cspace.c index 5f3075b5..fb7fba47 100644 --- a/frontend/cspace.c +++ b/frontend/cspace.c @@ -135,9 +135,6 @@ void bgr888_to_rgb565(void *dst_, const void *src_, int bytes) } } -#endif - -#ifndef __ARM_NEON__ // TODO? void rgb888_to_rgb565(void *dst, const void *src, int bytes) {} void bgr888_to_rgb888(void *dst, const void *src, int bytes) {} diff --git a/frontend/main.c b/frontend/main.c index fbb184ab..f59eed3f 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -134,24 +134,25 @@ void emu_set_default_config(void) Config.PsxAuto = 1; Config.cycle_multiplier = CYCLE_MULT_DEFAULT; - pl_rearmed_cbs.thread_rendering = 0; - pl_rearmed_cbs.gpu_neon.allow_interlace = 2; // auto pl_rearmed_cbs.gpu_neon.enhancement_enable = pl_rearmed_cbs.gpu_neon.enhancement_no_main = 0; pl_rearmed_cbs.gpu_peops.iUseDither = 0; pl_rearmed_cbs.gpu_peops.dwActFixes = 1<<7; - pl_rearmed_cbs.gpu_unai.ilace_force = 0; - pl_rearmed_cbs.gpu_unai.pixel_skip = 1; +#if 0 + pl_rearmed_cbs.gpu_senquack.ilace_force = 0; + pl_rearmed_cbs.gpu_senquack.pixel_skip = 0; + pl_rearmed_cbs.gpu_senquack.lighting = 1; + pl_rearmed_cbs.gpu_senquack.fast_lighting = 0; + pl_rearmed_cbs.gpu_senquack.blending = 1; + pl_rearmed_cbs.gpu_senquack.dithering = 0; +#else pl_rearmed_cbs.gpu_unai.lighting = 1; - pl_rearmed_cbs.gpu_unai.fast_lighting = 1; pl_rearmed_cbs.gpu_unai.blending = 1; - pl_rearmed_cbs.gpu_unai.dithering = 0; - // old gpu_unai config +#endif pl_rearmed_cbs.gpu_unai.abe_hack = pl_rearmed_cbs.gpu_unai.no_light = pl_rearmed_cbs.gpu_unai.no_blend = 0; - pl_rearmed_cbs.gpu_unai.scale_hires = 0; memset(&pl_rearmed_cbs.gpu_peopsgl, 0, sizeof(pl_rearmed_cbs.gpu_peopsgl)); pl_rearmed_cbs.gpu_peopsgl.iVRamSize = 64; pl_rearmed_cbs.gpu_peopsgl.iTexGarbageCollection = 1; diff --git a/frontend/menu.c b/frontend/menu.c index ef0bf4c9..187fbfce 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -422,20 +422,21 @@ static const struct { CE_INTVAL_N("adev0_is_nublike", in_adev_is_nublike[0]), CE_INTVAL_N("adev1_is_nublike", in_adev_is_nublike[1]), CE_INTVAL_V(frameskip, 3), - CE_INTVAL_P(thread_rendering), CE_INTVAL_P(gpu_peops.iUseDither), CE_INTVAL_P(gpu_peops.dwActFixes), - CE_INTVAL_P(gpu_unai.ilace_force), - CE_INTVAL_P(gpu_unai.pixel_skip), - CE_INTVAL_P(gpu_unai.lighting), - CE_INTVAL_P(gpu_unai.fast_lighting), - CE_INTVAL_P(gpu_unai.blending), - CE_INTVAL_P(gpu_unai.dithering), CE_INTVAL_P(gpu_unai.lineskip), CE_INTVAL_P(gpu_unai.abe_hack), CE_INTVAL_P(gpu_unai.no_light), CE_INTVAL_P(gpu_unai.no_blend), - CE_INTVAL_P(gpu_unai.scale_hires), +#if 0 + CE_INTVAL_P(gpu_senquack.ilace_force), + CE_INTVAL_P(gpu_senquack.pixel_skip), + CE_INTVAL_P(gpu_senquack.lighting), + CE_INTVAL_P(gpu_senquack.fast_lighting), + CE_INTVAL_P(gpu_senquack.blending), + CE_INTVAL_P(gpu_senquack.dithering), + CE_INTVAL_P(gpu_senquack.scale_hires), +#endif CE_INTVAL_P(gpu_neon.allow_interlace), CE_INTVAL_P(gpu_neon.enhancement_enable), CE_INTVAL_P(gpu_neon.enhancement_no_main), @@ -1371,16 +1372,10 @@ static int menu_loop_plugin_gpu_neon(int id, int keys) static menu_entry e_menu_plugin_gpu_unai[] = { - //mee_onoff ("Skip every 2nd line", 0, pl_rearmed_cbs.gpu_unai.lineskip, 1), - //mee_onoff ("Abe's Odyssey hack", 0, pl_rearmed_cbs.gpu_unai.abe_hack, 1), - //mee_onoff ("Disable lighting", 0, pl_rearmed_cbs.gpu_unai.no_light, 1), - //mee_onoff ("Disable blending", 0, pl_rearmed_cbs.gpu_unai.no_blend, 1), - mee_onoff ("Interlace", 0, pl_rearmed_cbs.gpu_unai.ilace_force, 1), - mee_onoff ("Dithering", 0, pl_rearmed_cbs.gpu_unai.dithering, 1), - mee_onoff ("Lighting", 0, pl_rearmed_cbs.gpu_unai.lighting, 1), - mee_onoff ("Fast lighting", 0, pl_rearmed_cbs.gpu_unai.fast_lighting, 1), - mee_onoff ("Blending", 0, pl_rearmed_cbs.gpu_unai.blending, 1), - mee_onoff ("Pixel skip", 0, pl_rearmed_cbs.gpu_unai.pixel_skip, 1), + mee_onoff ("Skip every 2nd line", 0, pl_rearmed_cbs.gpu_unai.lineskip, 1), + mee_onoff ("Abe's Odyssey hack", 0, pl_rearmed_cbs.gpu_unai.abe_hack, 1), + mee_onoff ("Disable lighting", 0, pl_rearmed_cbs.gpu_unai.no_light, 1), + mee_onoff ("Disable blending", 0, pl_rearmed_cbs.gpu_unai.no_blend, 1), mee_end, }; @@ -1391,6 +1386,27 @@ static int menu_loop_plugin_gpu_unai(int id, int keys) return 0; } +static menu_entry e_menu_plugin_gpu_senquack[] = +{ +#if 0 + mee_onoff ("Interlace", 0, pl_rearmed_cbs.gpu_senquack.ilace_force, 1), + mee_onoff ("Dithering", 0, pl_rearmed_cbs.gpu_senquack.dithering, 1), + mee_onoff ("Lighting", 0, pl_rearmed_cbs.gpu_senquack.lighting, 1), + mee_onoff ("Fast lighting", 0, pl_rearmed_cbs.gpu_senquack.fast_lighting, 1), + mee_onoff ("Blending", 0, pl_rearmed_cbs.gpu_senquack.blending, 1), + mee_onoff ("Pixel skip", 0, pl_rearmed_cbs.gpu_senquack.pixel_skip, 1), +#endif + mee_end, +}; + +static int menu_loop_plugin_gpu_senquack(int id, int keys) +{ + int sel = 0; + me_loop(e_menu_plugin_gpu_senquack, &sel); + return 0; +} + + static const char *men_gpu_dithering[] = { "None", "Game dependant", "Always", NULL }; //static const char h_gpu_0[] = "Needed for Chrono Cross"; static const char h_gpu_1[] = "Capcom fighting games"; @@ -1492,6 +1508,7 @@ static const char h_plugin_gpu[] = #endif "gpu_peops is Pete's soft GPU, slow but accurate\n" "gpu_unai is GPU from PCSX4ALL, fast but glitchy\n" + "gpu_senquack is more accurate but slower\n" "gpu_gles Pete's hw GPU, uses 3D chip but is glitchy\n" "must save config and reload the game if changed"; static const char h_plugin_spu[] = "spunull effectively disables sound\n" @@ -1499,6 +1516,7 @@ static const char h_plugin_spu[] = "spunull effectively disables sound\n" static const char h_gpu_peops[] = "Configure P.E.Op.S. SoftGL Driver V1.17"; static const char h_gpu_peopsgl[]= "Configure P.E.Op.S. MesaGL Driver V1.78"; static const char h_gpu_unai[] = "Configure Unai/PCSX4ALL Team GPU plugin"; +static const char h_gpu_senquack[] = "Configure Unai/PCSX4ALL Senquack plugin"; static const char h_spu[] = "Configure built-in P.E.Op.S. Sound Driver V1.7"; static menu_entry e_menu_plugin_options[] = @@ -1511,6 +1529,7 @@ static menu_entry e_menu_plugin_options[] = #endif mee_handler_h ("Configure gpu_peops plugin", menu_loop_plugin_gpu_peops, h_gpu_peops), mee_handler_h ("Configure gpu_unai GPU plugin", menu_loop_plugin_gpu_unai, h_gpu_unai), + mee_handler_h ("Configure gpu_senquack GPU plugin", menu_loop_plugin_gpu_senquack, h_gpu_senquack), mee_handler_h ("Configure gpu_gles GPU plugin", menu_loop_plugin_gpu_peopsgl, h_gpu_peopsgl), mee_handler_h ("Configure built-in SPU plugin", menu_loop_plugin_spu, h_spu), mee_end, diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c index 555e3963..171296d2 100644 --- a/frontend/plugin_lib.c +++ b/frontend/plugin_lib.c @@ -600,7 +600,6 @@ static void update_analogs(void) } } - //printf("%4d %4d %4d %4d\n", in_a1[0], in_a1[1], in_a2[0], in_a2[1]); } static void update_input(void) diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c index d4213227..a5a16a56 100644 --- a/libpcsxcore/cdriso.c +++ b/libpcsxcore/cdriso.c @@ -70,16 +70,13 @@ static unsigned char subbuffer[SUB_FRAMESIZE]; static boolean playing = FALSE; static boolean cddaBigEndian = FALSE; -// cdda sectors in toc, byte offset in file -static unsigned int cdda_cur_sector; -static unsigned int cdda_file_offset; /* Frame offset into CD image where pregap data would be found if it was there. * If a game seeks there we must *not* return subchannel data since it's * not in the CD image, so that cdrom code can fake subchannel data instead. * XXX: there could be multiple pregaps but PSX dumps only have one? */ static unsigned int pregapOffset; -#define cddaCurPos cdda_cur_sector +static unsigned int cddaCurPos; // compressed image stuff static struct { @@ -1423,6 +1420,7 @@ static int cdread_chd(FILE *f, unsigned int base, void *dest, int sector) return CD_FRAMESIZE_RAW; } #endif + static int cdread_2048(FILE *f, unsigned int base, void *dest, int sector) { int ret; @@ -1652,8 +1650,6 @@ static long CALLBACK ISOopen(void) { if (numtracks > 1 && ti[1].handle == NULL) { ti[1].handle = fopen(bin_filename, "rb"); } - cdda_cur_sector = 0; - cdda_file_offset = 0; if (Config.AsyncCD) { readThreadStart(); diff --git a/libpcsxcore/debug.c b/libpcsxcore/debug.c index 4ba7f570..7fac2e42 100644 --- a/libpcsxcore/debug.c +++ b/libpcsxcore/debug.c @@ -20,6 +20,11 @@ #include "debug.h" #include "socket.h" +// XXX: don't care but maybe fix it someday +#if defined(__GNUC__) && __GNUC__ >= 7 +#pragma GCC diagnostic ignored "-Wrestrict" +#endif + /* PCSX Debug console protocol description, version 1.0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/libpcsxcore/disr3000a.c b/libpcsxcore/disr3000a.c index ceb60dc1..5a79442d 100644 --- a/libpcsxcore/disr3000a.c +++ b/libpcsxcore/disr3000a.c @@ -23,6 +23,11 @@ #include "psxcommon.h" +// XXX: don't care but maybe fix it someday +#if defined(__GNUC__) && __GNUC__ >= 7 +#pragma GCC diagnostic ignored "-Wrestrict" +#endif + char ostr[256]; // Names of registers diff --git a/libpcsxcore/gte_divider.c b/libpcsxcore/gte_divider.c index e1d6c6b7..a4cd0d2a 100644 --- a/libpcsxcore/gte_divider.c +++ b/libpcsxcore/gte_divider.c @@ -10,6 +10,7 @@ */ #include "gte.h" +#include "gte_divider.h" static const u8 table[] = { diff --git a/libpcsxcore/gte_neon.S b/libpcsxcore/gte_neon.S index 2799caaa..7d97ff37 100644 --- a/libpcsxcore/gte_neon.S +++ b/libpcsxcore/gte_neon.S @@ -1,5 +1,5 @@ /* - * (C) Gražvydas "notaz" Ignotas, 2011 + * (C) Gražvydas "notaz" Ignotas, 2011 * * This work is licensed under the terms of GNU GPL version 2 or later. * See the COPYING file in the top-level directory. diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c index a60360f9..7929dc76 100644 --- a/libpcsxcore/misc.c +++ b/libpcsxcore/misc.c @@ -418,7 +418,7 @@ static int PSXGetFileType(FILE *f) { current = ftell(f); fseek(f, 0L, SEEK_SET); - if (fread(&mybuf, sizeof(mybuf), 1, f) != sizeof(mybuf)) + if (fread(&mybuf, 1, sizeof(mybuf), f) != sizeof(mybuf)) goto io_fail; fseek(f, current, SEEK_SET); @@ -479,7 +479,7 @@ int Load(const char *ExePath) { type = PSXGetFileType(tmpFile); switch (type) { case PSX_EXE: - if (fread(&tmpHead, sizeof(EXE_HEADER), 1, tmpFile) != sizeof(EXE_HEADER)) + if (fread(&tmpHead, 1, sizeof(EXE_HEADER), tmpFile) != sizeof(EXE_HEADER)) goto fail_io; section_address = SWAP32(tmpHead.t_addr); section_size = SWAP32(tmpHead.t_size); @@ -499,13 +499,13 @@ int Load(const char *ExePath) { case CPE_EXE: fseek(tmpFile, 6, SEEK_SET); /* Something tells me we should go to 4 and read the "08 00" here... */ do { - if (fread(&opcode, sizeof(opcode), 1, tmpFile) != sizeof(opcode)) + if (fread(&opcode, 1, sizeof(opcode), tmpFile) != sizeof(opcode)) goto fail_io; switch (opcode) { case 1: /* Section loading */ - if (fread(§ion_address, sizeof(section_address), 1, tmpFile) != sizeof(section_address)) + if (fread(§ion_address, 1, sizeof(section_address), tmpFile) != sizeof(section_address)) goto fail_io; - if (fread(§ion_size, sizeof(section_size), 1, tmpFile) != sizeof(section_size)) + if (fread(§ion_size, 1, sizeof(section_size), tmpFile) != sizeof(section_size)) goto fail_io; section_address = SWAPu32(section_address); section_size = SWAPu32(section_size); @@ -520,7 +520,7 @@ int Load(const char *ExePath) { break; case 3: /* register loading (PC only?) */ fseek(tmpFile, 2, SEEK_CUR); /* unknown field */ - if (fread(&psxRegs.pc, sizeof(psxRegs.pc), 1, tmpFile) != sizeof(psxRegs.pc)) + if (fread(&psxRegs.pc, 1, sizeof(psxRegs.pc), tmpFile) != sizeof(psxRegs.pc)) goto fail_io; psxRegs.pc = SWAPu32(psxRegs.pc); break; @@ -550,7 +550,8 @@ int Load(const char *ExePath) { CdromLabel[0] = '\0'; } - fclose(tmpFile); + if (tmpFile) + fclose(tmpFile); return retval; fail_io: diff --git a/libpcsxcore/plugins.c b/libpcsxcore/plugins.c index 87b574d4..c806b672 100644 --- a/libpcsxcore/plugins.c +++ b/libpcsxcore/plugins.c @@ -776,9 +776,8 @@ unsigned char _PADpoll(int port, unsigned char value) { } //if no new request the pad return 0xff, for signaling connected - if (reqPos >= respSize - && writeok - ) return 0xff; + if (reqPos >= respSize) + return 0xff; switch(reqPos){ case 2: diff --git a/libpcsxcore/ppf.c b/libpcsxcore/ppf.c index a76b153f..18c5413e 100644 --- a/libpcsxcore/ppf.c +++ b/libpcsxcore/ppf.c @@ -212,7 +212,7 @@ void BuildPPFCache() { if (ppffile == NULL) return; memset(buffer, 0, 5); - if (fread(buffer, 3, 1, ppffile) != 3) + if (fread(buffer, 1, 3, ppffile) != 3) goto fail_io; if (strcmp(buffer, "PPF") != 0) { @@ -236,13 +236,13 @@ void BuildPPFCache() { fseek(ppffile, -8, SEEK_END); memset(buffer, 0, 5); - if (fread(buffer, 4, 1, ppffile) != 4) + if (fread(buffer, 1, 4, ppffile) != 4) goto fail_io; if (strcmp(".DIZ", buffer) != 0) { dizyn = 0; } else { - if (fread(&dizlen, 4, 1, ppffile) != 4) + if (fread(&dizlen, 1, 4, ppffile) != 4) goto fail_io; dizlen = SWAP32(dizlen); dizyn = 1; @@ -269,14 +269,14 @@ void BuildPPFCache() { fseek(ppffile, -6, SEEK_END); memset(buffer, 0, 5); - if (fread(buffer, 4, 1, ppffile) != 4) + if (fread(buffer, 1, 4, ppffile) != 4) goto fail_io; dizlen = 0; if (strcmp(".DIZ", buffer) == 0) { fseek(ppffile, -2, SEEK_END); // TODO: Endian/size unsafe? - if (fread(&dizlen, 2, 1, ppffile) != 2) + if (fread(&dizlen, 1, 2, ppffile) != 2) goto fail_io; dizlen = SWAP32(dizlen); dizlen += 36; @@ -304,18 +304,18 @@ void BuildPPFCache() { // now do the data reading do { fseek(ppffile, seekpos, SEEK_SET); - if (fread(&pos, sizeof(pos), 1, ppffile) != sizeof(pos)) + if (fread(&pos, 1, sizeof(pos), ppffile) != sizeof(pos)) goto fail_io; pos = SWAP32(pos); if (method == 2) { // skip 4 bytes on ppf3 (no int64 support here) - if (fread(buffer, 4, 1, ppffile) != 4) + if (fread(buffer, 1, 4, ppffile) != 4) goto fail_io; } anz = fgetc(ppffile); - if (fread(ppfmem, anz, 1, ppffile) != anz) + if (fread(ppfmem, 1, anz, ppffile) != anz) goto fail_io; ladr = pos / CD_FRAMESIZE_RAW; @@ -378,7 +378,7 @@ int LoadSBI(const char *fname, int sector_count) { s = fread(sbitime, 1, 3, sbihandle); if (s != 3) goto fail_io; - if (fread(&t, sizeof(t), 1, sbihandle) != sizeof(t)) + if (fread(&t, 1, sizeof(t), sbihandle) != sizeof(t)) goto fail_io; switch (t) { default: diff --git a/libpcsxcore/psxcounters.c b/libpcsxcore/psxcounters.c index d3935fc5..e19b7819 100644 --- a/libpcsxcore/psxcounters.c +++ b/libpcsxcore/psxcounters.c @@ -23,7 +23,8 @@ #include "psxcounters.h" #include "gpu.h" -#include "debug.h" +//#include "debug.h" +#define DebugVSync() /******************************************************************************/ diff --git a/libpcsxcore/psxdma.c b/libpcsxcore/psxdma.c index 8a2b9a93..d7c4caec 100644 --- a/libpcsxcore/psxdma.c +++ b/libpcsxcore/psxdma.c @@ -120,7 +120,8 @@ static u32 gpuDmaChainSize(u32 addr) { // next 32-bit pointer addr = psxMu32( addr & ~0x3 ) & 0xffffff; size += 1; - } while (addr != 0xffffff); + } while (!(addr & 0x800000)); // contrary to some documentation, the end-of-linked-list marker is not actually 0xFF'FFFF + // any pointer with bit 23 set will do. return size; } diff --git a/libpcsxcore/psxhle.c b/libpcsxcore/psxhle.c index d575cb72..7ca81b47 100644 --- a/libpcsxcore/psxhle.c +++ b/libpcsxcore/psxhle.c @@ -95,7 +95,7 @@ static void hleExecRet() { psxRegs.pc = psxRegs.GPR.n.ra; } -const void (*psxHLEt[8])() = { +void (* const psxHLEt[8])() = { hleDummy, hleA0, hleB0, hleC0, hleBootstrap, hleExecRet, hleDummy, hleDummy diff --git a/libpcsxcore/psxhle.h b/libpcsxcore/psxhle.h index 0529c389..04126345 100644 --- a/libpcsxcore/psxhle.h +++ b/libpcsxcore/psxhle.h @@ -28,7 +28,7 @@ extern "C" { #include "r3000a.h" #include "plugins.h" -extern const void (*psxHLEt[8])(); +extern void (* const psxHLEt[8])(); #ifdef __cplusplus } diff --git a/libpcsxcore/psxinterpreter.h b/libpcsxcore/psxinterpreter.h index f8581b82..b3652c0e 100644 --- a/libpcsxcore/psxinterpreter.h +++ b/libpcsxcore/psxinterpreter.h @@ -8,4 +8,7 @@ void MTC0(psxRegisters *regs_, int reg, u32 val); void gteNULL(struct psxCP2Regs *regs); extern void (*psxCP2[64])(struct psxCP2Regs *regs); +// called by lightrec +void intExecuteBlock(); + #endif // __PSXINTERPRETER_H__ diff --git a/libpcsxcore/psxmem.c b/libpcsxcore/psxmem.c index a85fb27d..37a0efd0 100644 --- a/libpcsxcore/psxmem.c +++ b/libpcsxcore/psxmem.c @@ -27,7 +27,8 @@ #include "psxmem_map.h" #include "r3000a.h" #include "psxhw.h" -#include "debug.h" +//#include "debug.h" +#define DebugCheckBP(...) #include "lightrec/mem.h" #include "memmap.h" @@ -40,14 +41,6 @@ #define MAP_ANONYMOUS MAP_ANON #endif -boolean writeok = TRUE; - -#if 0 //ndef NDEBUG -#include "debug.h" -#else -void DebugCheckBP(u32 address, enum breakpoint_types type) {} -#endif - void *(*psxMapHook)(unsigned long addr, size_t size, int is_fixed, enum psxMapTag tag); void (*psxUnmapHook)(void *ptr, size_t size, enum psxMapTag tag); @@ -147,14 +140,20 @@ static int psxMemInitMap(void) psxM = psxMap(0x77000000, 0x00210000, 0, MAP_TAG_RAM); if (psxM == MAP_FAILED) { SysMessage(_("mapping main RAM failed")); + psxM = NULL; return -1; } - psxP = &psxM[0x200000]; + psxH = psxMap(0x1f800000, 0x10000, 0, MAP_TAG_OTHER); - psxR = psxMap(0x1fc00000, 0x80000, 0, MAP_TAG_OTHER); + if (psxH == MAP_FAILED) { + SysMessage(_("Error allocating memory!")); + psxMemShutdown(); + return -1; + } - if (psxR == MAP_FAILED || psxH == MAP_FAILED) { + psxR = psxMap(0x1fc00000, 0x80000, 0, MAP_TAG_OTHER); + if (psxR == MAP_FAILED) { SysMessage(_("Error allocating memory!")); psxMemShutdown(); return -1; @@ -165,9 +164,11 @@ static int psxMemInitMap(void) static void psxMemFreeMap(void) { - psxUnmap(psxM, 0x00210000, MAP_TAG_RAM); psxM = NULL; - psxUnmap(psxH, 0x10000, MAP_TAG_OTHER); psxH = NULL; - psxUnmap(psxR, 0x80000, MAP_TAG_OTHER); psxR = NULL; + if (psxM) psxUnmap(psxM, 0x00210000, MAP_TAG_RAM); + if (psxH) psxUnmap(psxH, 0x10000, MAP_TAG_OTHER); + if (psxR) psxUnmap(psxR, 0x80000, MAP_TAG_OTHER); + psxM = psxH = psxR = NULL; + psxP = NULL; } int psxMemInit(void) @@ -194,8 +195,8 @@ int psxMemInit(void) return -1; } - memset(psxMemRLUT, 0xff, 0x10000 * sizeof(void *)); - memset(psxMemWLUT, 0xff, 0x10000 * sizeof(void *)); + memset(psxMemRLUT, (uintptr_t)INVALID_PTR, 0x10000 * sizeof(void *)); + memset(psxMemWLUT, (uintptr_t)INVALID_PTR, 0x10000 * sizeof(void *)); // MemR for (i = 0; i < 0x80; i++) psxMemRLUT[i + 0x0000] = (u8 *)&psxM[(i & 0x1f) << 16]; @@ -264,6 +265,8 @@ void psxMemShutdown() { free(psxMemWLUT); psxMemWLUT = NULL; } +static int writeok = 1; + u8 psxMemRead8(u32 mem) { char *p; u32 t; @@ -430,9 +433,9 @@ void psxMemWrite32(u32 mem, u32 value) { case 0x800: case 0x804: if (writeok == 0) break; writeok = 0; - memset(psxMemWLUT + 0x0000, 0xff, 0x80 * sizeof(void *)); - memset(psxMemWLUT + 0x8000, 0xff, 0x80 * sizeof(void *)); - memset(psxMemWLUT + 0xa000, 0xff, 0x80 * sizeof(void *)); + memset(psxMemWLUT + 0x0000, (uintptr_t)INVALID_PTR, 0x80 * sizeof(void *)); + memset(psxMemWLUT + 0x8000, (uintptr_t)INVALID_PTR, 0x80 * sizeof(void *)); + memset(psxMemWLUT + 0xa000, (uintptr_t)INVALID_PTR, 0x80 * sizeof(void *)); /* Required for icache interpreter otherwise Armored Core won't boot on icache interpreter */ psxCpu->Notify(R3000ACPU_NOTIFY_CACHE_ISOLATED, NULL); break; diff --git a/libpcsxcore/psxmem.h b/libpcsxcore/psxmem.h index c51aebe0..14ff0033 100644 --- a/libpcsxcore/psxmem.h +++ b/libpcsxcore/psxmem.h @@ -46,7 +46,11 @@ extern "C" { #endif +#ifdef LIGHTREC #define INVALID_PTR ((void *)-1) +#else +#define INVALID_PTR NULL +#endif extern s8 *psxM; #define psxMs8(mem) psxM[(mem) & 0x1fffff] diff --git a/libpcsxcore/r3000a.h b/libpcsxcore/r3000a.h index 1c58b177..2339d595 100644 --- a/libpcsxcore/r3000a.h +++ b/libpcsxcore/r3000a.h @@ -197,8 +197,6 @@ typedef struct { // asm in libpcsxcore/new_dynarec/ } psxRegisters; -extern boolean writeok; - extern psxRegisters psxRegs; /* new_dynarec stuff */ diff --git a/libpcsxcore/system.h b/libpcsxcore/system.h index 254be083..c380aa47 100644 --- a/libpcsxcore/system.h +++ b/libpcsxcore/system.h @@ -35,7 +35,6 @@ void SysCloseLibrary(void *lib); // Closes Library void SysUpdate(); // Called on VBlank (to update i.e. pads) void SysRunGui(); // Returns to the Gui void SysClose(); // Close mem and plugins -void SysDLog(const char *fmt, ...); // Prints debug-level logs // log if the game does something we don't handle (well) //#define log_unhandled printf diff --git a/plugins/cdrcimg/cdrcimg.c b/plugins/cdrcimg/cdrcimg.c index 047357ac..b3bee271 100644 --- a/plugins/cdrcimg/cdrcimg.c +++ b/plugins/cdrcimg/cdrcimg.c @@ -414,8 +414,6 @@ static long CDRopen(void) char *ext; FILE *f = NULL; - printf("%s cd_file=%d\n", __func__, cd_file == NULL ? 0 : 1); - if (cd_file != NULL) return 0; // it's already open diff --git a/plugins/dfinput/main.c b/plugins/dfinput/main.c index 974c4ddd..4f1d03f6 100644 --- a/plugins/dfinput/main.c +++ b/plugins/dfinput/main.c @@ -1,5 +1,5 @@ /* - * (C) Gražvydas "notaz" Ignotas, 2011 + * (C) Gražvydas "notaz" Ignotas, 2011 * * This work is licensed under the terms of any of these licenses * (at your option): @@ -35,11 +35,10 @@ static int old_controller_type1 = -1, old_controller_type2 = -1; pad_init(); \ break; \ case PSE_PAD_TYPE_GUNCON: \ - /* Removed for new Guncon functionality, may have been required for very old touchscreen support */ \ - /* PAD##n##_startPoll = PADstartPoll_guncon; */ \ - /* PAD##n##_poll = PADpoll_guncon; */ \ - /* guncon_init(); */ \ - /* break; */ \ + PAD##n##_startPoll = PADstartPoll_guncon; \ + PAD##n##_poll = PADpoll_guncon; \ + guncon_init(); \ + break; \ case PSE_PAD_TYPE_NEGCON: \ case PSE_PAD_TYPE_GUN: \ default: \ @@ -48,12 +47,9 @@ static int old_controller_type1 = -1, old_controller_type2 = -1; break; \ } \ } -#endif /* HAVE_LIBRETRO */ - void dfinput_activate(void) { - #ifndef HAVE_LIBRETRO PadDataS pad; pad.portMultitap = -1; @@ -64,5 +60,12 @@ void dfinput_activate(void) pad.requestPadIndex = 1; PAD2_readPort2(&pad); select_pad(2); - #endif } + +#else // use libretro's libpcsxcore/plugins.c code + +void dfinput_activate(void) +{ +} + +#endif diff --git a/plugins/dfxvideo/gpu.c b/plugins/dfxvideo/gpu.c index a67d8c1f..1a3f25ac 100644 --- a/plugins/dfxvideo/gpu.c +++ b/plugins/dfxvideo/gpu.c @@ -1051,8 +1051,8 @@ long CALLBACK GPUdmaChain(uint32_t * baseAddrL, uint32_t addr) if(count>0) GPUwriteDataMem(&baseAddrL[dmaMem>>2],count); addr = GETLE32(&baseAddrL[addr>>2])&0xffffff; - } - while (addr != 0xffffff); + } while (!(addr & 0x800000)); // contrary to some documentation, the end-of-linked-list marker is not actually 0xFF'FFFF + // any pointer with bit 23 set will do. GPUIsIdle; diff --git a/plugins/dfxvideo/gpulib_if.c b/plugins/dfxvideo/gpulib_if.c index a13da035..e883b86d 100644 --- a/plugins/dfxvideo/gpulib_if.c +++ b/plugins/dfxvideo/gpulib_if.c @@ -270,6 +270,10 @@ unsigned short sSetMask = 0; unsigned long lSetMask = 0; long lLowerpart; +#if defined(__GNUC__) && __GNUC__ >= 6 +#pragma GCC diagnostic ignored "-Wmisleading-indentation" +#endif + #include "soft.c" #include "prim.c" diff --git a/plugins/gpu-gles/gpuDraw.c b/plugins/gpu-gles/gpuDraw.c index 34d1c3bd..c49eac5f 100644 --- a/plugins/gpu-gles/gpuDraw.c +++ b/plugins/gpu-gles/gpuDraw.c @@ -291,7 +291,7 @@ bool TestEGLError(const char* pszLocation) EGLint iErr = eglGetError(); if (iErr != EGL_SUCCESS) { - printf("%s failed (0x%x).\n", pszLocation, iErr); + printf("%s failed (0x%x).\n", pszLocation, (int)iErr); return FALSE; } @@ -572,7 +572,7 @@ void GLcleanup() // real psx polygon coord mapping right... the following // works not to bad with many games, though -__inline BOOL CheckCoord4() +static __inline BOOL CheckCoord4() { if(lx0<0) { @@ -638,7 +638,7 @@ __inline BOOL CheckCoord4() return FALSE; } -__inline BOOL CheckCoord3() +static __inline BOOL CheckCoord3() { if(lx0<0) { @@ -675,7 +675,7 @@ __inline BOOL CheckCoord3() } -__inline BOOL CheckCoord2() +static __inline BOOL CheckCoord2() { if(lx0<0) { diff --git a/plugins/gpu-gles/gpuPlugin.c b/plugins/gpu-gles/gpuPlugin.c index 60570ace..6d3ca14c 100644 --- a/plugins/gpu-gles/gpuPlugin.c +++ b/plugins/gpu-gles/gpuPlugin.c @@ -2205,9 +2205,8 @@ do if(count>0) GPUwriteDataMem(&baseAddrL[dmaMem>>2],count); addr = baseAddrL[addr>>2]&0xffffff; - } -while (addr != 0xffffff); - + } while (!(addr & 0x800000)); // contrary to some documentation, the end-of-linked-list marker is not actually 0xFF'FFFF + // any pointer with bit 23 set will do. GPUIsIdle; return 0; diff --git a/plugins/gpu-gles/gpuStdafx.h b/plugins/gpu-gles/gpuStdafx.h index 6b8e23de..41051dce 100644 --- a/plugins/gpu-gles/gpuStdafx.h +++ b/plugins/gpu-gles/gpuStdafx.h @@ -75,7 +75,7 @@ extern "C" { #endif #include -#define __inline static inline +#define __inline inline #endif diff --git a/plugins/gpu_neon/psx_gpu_if.c b/plugins/gpu_neon/psx_gpu_if.c index 638d4ec3..fc4706c1 100644 --- a/plugins/gpu_neon/psx_gpu_if.c +++ b/plugins/gpu_neon/psx_gpu_if.c @@ -147,8 +147,7 @@ void renderer_sync_ecmds(uint32_t *ecmds) void renderer_update_caches(int x, int y, int w, int h) { update_texture_cache_region(&egpu, x, y, x + w - 1, y + h - 1); - if (gpu.state.enhancement_active && - !(gpu.status & PSX_GPU_STATUS_RGB24)) + if (gpu.state.enhancement_active && !(gpu.status & PSX_GPU_STATUS_RGB24)) sync_enhancement_buffers(x, y, w, h); } diff --git a/plugins/gpulib/gpu.c b/plugins/gpulib/gpu.c index d7290916..d08b2b50 100644 --- a/plugins/gpulib/gpu.c +++ b/plugins/gpulib/gpu.c @@ -54,6 +54,7 @@ static noinline void do_cmd_reset(void) static noinline void do_reset(void) { unsigned int i; + do_cmd_reset(); memset(gpu.regs, 0, sizeof(gpu.regs)); @@ -133,11 +134,11 @@ static noinline void get_gpu_info(uint32_t data) case 0x02: case 0x03: case 0x04: + case 0x05: gpu.gp0 = gpu.ex_regs[data & 7] & 0xfffff; break; - case 0x05: case 0x06: - gpu.gp0 = gpu.ex_regs[5] & 0x3fffff; + gpu.gp0 = gpu.ex_regs[5] & 0xfffff; break; case 0x07: gpu.gp0 = 2; diff --git a/plugins/gpulib/vout_pl.c b/plugins/gpulib/vout_pl.c index 05da217b..9e2d9007 100644 --- a/plugins/gpulib/vout_pl.c +++ b/plugins/gpulib/vout_pl.c @@ -95,7 +95,7 @@ void vout_update(void) vram += y * 1024 + x; - cbs->pl_vout_flip(vram, 1024, gpu.status & PSX_GPU_STATUS_RGB24, w, h); + cbs->pl_vout_flip(vram, 1024, !!(gpu.status & PSX_GPU_STATUS_RGB24), w, h); } void vout_blank(void) @@ -108,7 +108,7 @@ void vout_blank(void) w *= 2; h *= 2; } - cbs->pl_vout_flip(NULL, 1024, gpu.status & PSX_GPU_STATUS_RGB24, w, h); + cbs->pl_vout_flip(NULL, 1024, !!(gpu.status & PSX_GPU_STATUS_RGB24), w, h); } long GPUopen(void **unused) -- 2.39.5