reduce differences from upstream
authornotaz <notasas@gmail.com>
Fri, 14 Oct 2022 20:24:21 +0000 (23:24 +0300)
committernotaz <notasas@gmail.com>
Sat, 15 Oct 2022 22:47:45 +0000 (01:47 +0300)
because libretro-only breakage is too annoying to track down

31 files changed:
frontend/cspace.c
frontend/main.c
frontend/menu.c
frontend/plugin_lib.c
libpcsxcore/cdriso.c
libpcsxcore/debug.c
libpcsxcore/disr3000a.c
libpcsxcore/gte_divider.c
libpcsxcore/gte_neon.S
libpcsxcore/misc.c
libpcsxcore/plugins.c
libpcsxcore/ppf.c
libpcsxcore/psxcounters.c
libpcsxcore/psxdma.c
libpcsxcore/psxhle.c
libpcsxcore/psxhle.h
libpcsxcore/psxinterpreter.h
libpcsxcore/psxmem.c
libpcsxcore/psxmem.h
libpcsxcore/r3000a.h
libpcsxcore/system.h
plugins/cdrcimg/cdrcimg.c
plugins/dfinput/main.c
plugins/dfxvideo/gpu.c
plugins/dfxvideo/gpulib_if.c
plugins/gpu-gles/gpuDraw.c
plugins/gpu-gles/gpuPlugin.c
plugins/gpu-gles/gpuStdafx.h
plugins/gpu_neon/psx_gpu_if.c
plugins/gpulib/gpu.c
plugins/gpulib/vout_pl.c

index 5f3075b..fb7fba4 100644 (file)
@@ -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) {}
index fbb184a..f59eed3 100644 (file)
@@ -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;
index ef0bf4c..187fbfc 100644 (file)
@@ -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,
index 555e396..171296d 100644 (file)
@@ -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)
index d421322..a5a16a5 100644 (file)
@@ -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();
index 4ba7f57..7fac2e4 100644 (file)
 #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
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
index ceb60dc..5a79442 100644 (file)
 
 #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
index e1d6c6b..a4cd0d2 100644 (file)
@@ -10,6 +10,7 @@
  */
 
 #include "gte.h"
+#include "gte_divider.h"
 
 static const u8 table[] =
 {
index 2799caa..7d97ff3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * (C) Gra\9evydas "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.
index a60360f..7929dc7 100644 (file)
@@ -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(&section_address, sizeof(section_address), 1, tmpFile) != sizeof(section_address))
+                                                       if (fread(&section_address, 1, sizeof(section_address), tmpFile) != sizeof(section_address))
                                                                goto fail_io;
-                                                       if (fread(&section_size, sizeof(section_size), 1, tmpFile) != sizeof(section_size))
+                                                       if (fread(&section_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:
index 87b574d..c806b67 100644 (file)
@@ -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:
index a76b153..18c5413 100644 (file)
@@ -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:
index d3935fc..e19b781 100644 (file)
@@ -23,7 +23,8 @@
 
 #include "psxcounters.h"
 #include "gpu.h"
-#include "debug.h"
+//#include "debug.h"
+#define DebugVSync()
 
 /******************************************************************************/
 
index 8a2b9a9..d7c4cae 100644 (file)
@@ -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;
 }
index d575cb7..7ca81b4 100644 (file)
@@ -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
index 0529c38..0412634 100644 (file)
@@ -28,7 +28,7 @@ extern "C" {
 #include "r3000a.h"
 #include "plugins.h"
 
-extern const void (*psxHLEt[8])();
+extern void (* const psxHLEt[8])();
 
 #ifdef __cplusplus
 }
index f8581b8..b3652c0 100644 (file)
@@ -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__
index a85fb27..37a0efd 100644 (file)
@@ -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"
 #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;
index c51aebe..14ff003 100644 (file)
@@ -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]
index 1c58b17..2339d59 100644 (file)
@@ -197,8 +197,6 @@ typedef struct {
        // asm in libpcsxcore/new_dynarec/
 } psxRegisters;
 
-extern boolean writeok;
-
 extern psxRegisters psxRegs;
 
 /* new_dynarec stuff */
index 254be08..c380aa4 100644 (file)
@@ -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
index 047357a..b3bee27 100644 (file)
@@ -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
 
index 974c4dd..4f1d03f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * (C) GraÃ\85¾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
index a67d8c1..1a3f25a 100644 (file)
@@ -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;
 
index a13da03..e883b86 100644 (file)
@@ -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"
 
index 34d1c3b..c49eac5 100644 (file)
@@ -291,7 +291,7 @@ bool TestEGLError(const char* pszLocation)
        EGLint iErr = eglGetError();\r
        if (iErr != EGL_SUCCESS)\r
        {\r
-               printf("%s failed (0x%x).\n", pszLocation, iErr);\r
+               printf("%s failed (0x%x).\n", pszLocation, (int)iErr);\r
                return FALSE;\r
        }\r
 \r
@@ -572,7 +572,7 @@ void GLcleanup()
 //              real psx polygon coord mapping right... the following\r
 //              works not to bad with many games, though\r
 \r
-__inline BOOL CheckCoord4()\r
+static __inline BOOL CheckCoord4()\r
 {\r
  if(lx0<0)\r
   {\r
@@ -638,7 +638,7 @@ __inline BOOL CheckCoord4()
  return FALSE;\r
 }\r
 \r
-__inline BOOL CheckCoord3()\r
+static __inline BOOL CheckCoord3()\r
 {\r
  if(lx0<0)\r
   {\r
@@ -675,7 +675,7 @@ __inline BOOL CheckCoord3()
 }\r
 \r
 \r
-__inline BOOL CheckCoord2()\r
+static __inline BOOL CheckCoord2()\r
 {\r
  if(lx0<0)\r
   {\r
index 60570ac..6d3ca14 100644 (file)
@@ -2205,9 +2205,8 @@ do
   if(count>0) GPUwriteDataMem(&baseAddrL[dmaMem>>2],count);\r
   \r
   addr = baseAddrL[addr>>2]&0xffffff;\r
- }\r
-while (addr != 0xffffff);\r
-\r
+  } while (!(addr & 0x800000)); // contrary to some documentation, the end-of-linked-list marker is not actually 0xFF'FFFF\r
+                                  // any pointer with bit 23 set will do.\r
 GPUIsIdle;\r
 \r
 return 0;\r
index 6b8e23d..41051dc 100644 (file)
@@ -75,7 +75,7 @@ extern "C" {
 #endif\r
 #include <math.h> \r
 \r
-#define __inline static inline\r
+#define __inline inline\r
 \r
 #endif\r
 \r
index 638d4ec..fc4706c 100644 (file)
@@ -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);
 }
 
index d729091..d08b2b5 100644 (file)
@@ -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;
index 05da217..9e2d900 100644 (file)
@@ -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)