}
 }
 
-#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) {}
 
        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;
 
        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),
 
 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,
 };
 
        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";
 #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"
 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[] =
 #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,
 
                }
 
        }
-       //printf("%4d %4d %4d %4d\n", in_a1[0], in_a1[1], in_a2[0], in_a2[1]);
 }
 
 static void update_input(void)
 
 
 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 {
        return CD_FRAMESIZE_RAW;
 }
 #endif
+
 static int cdread_2048(FILE *f, unsigned int base, void *dest, int sector)
 {
        int ret;
        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();
 
 #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
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 
 #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
 
  */
 
 #include "gte.h"
+#include "gte_divider.h"
 
 static const u8 table[] =
 {
 
 /*
- * (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.
 
 
        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);
                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);
                        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);
                                                        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;
                CdromLabel[0] = '\0';
        }
 
-       fclose(tmpFile);
+       if (tmpFile)
+               fclose(tmpFile);
        return retval;
 
 fail_io:
 
        }
 
        //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:
 
        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) {
                        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;
 
                        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;
        // 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;
                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:
 
 
 #include "psxcounters.h"
 #include "gpu.h"
-#include "debug.h"
+//#include "debug.h"
+#define DebugVSync()
 
 /******************************************************************************/
 
 
                // 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;
 }
 
        psxRegs.pc = psxRegs.GPR.n.ra;
 }
 
-const void (*psxHLEt[8])() = {
+void (* const psxHLEt[8])() = {
        hleDummy, hleA0, hleB0, hleC0,
        hleBootstrap, hleExecRet,
        hleDummy, hleDummy
 
 #include "r3000a.h"
 #include "plugins.h"
 
-extern const void (*psxHLEt[8])();
+extern void (* const psxHLEt[8])();
 
 #ifdef __cplusplus
 }
 
 void gteNULL(struct psxCP2Regs *regs);
 extern void (*psxCP2[64])(struct psxCP2Regs *regs);
 
+// called by lightrec
+void intExecuteBlock();
+
 #endif // __PSXINTERPRETER_H__
 
 #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);
                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;
 
 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)
                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];
        free(psxMemWLUT); psxMemWLUT = NULL;
 }
 
+static int writeok = 1;
+
 u8 psxMemRead8(u32 mem) {
        char *p;
        u32 t;
                                        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;
 
 
 #endif
 
+#ifdef LIGHTREC
 #define INVALID_PTR ((void *)-1)
+#else
+#define INVALID_PTR NULL
+#endif
 
 extern s8 *psxM;
 #define psxMs8(mem)            psxM[(mem) & 0x1fffff]
 
        // asm in libpcsxcore/new_dynarec/
 } psxRegisters;
 
-extern boolean writeok;
-
 extern psxRegisters psxRegs;
 
 /* new_dynarec stuff */
 
 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
 
        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
 
 
 /*
- * (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):
                        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: \
                        break; \
                } \
        }
-#endif /* HAVE_LIBRETRO */
-
 
 void dfinput_activate(void)
 {
-       #ifndef HAVE_LIBRETRO
        PadDataS pad;
 
        pad.portMultitap = -1;
        pad.requestPadIndex = 1;
        PAD2_readPort2(&pad);
        select_pad(2);
-       #endif
 }
+
+#else // use libretro's libpcsxcore/plugins.c code
+
+void dfinput_activate(void)
+{
+}
+
+#endif
 
    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;
 
 
 unsigned long  lSetMask = 0;
 long           lLowerpart;
 
+#if defined(__GNUC__) && __GNUC__ >= 6
+#pragma GCC diagnostic ignored "-Wmisleading-indentation"
+#endif
+
 #include "soft.c"
 #include "prim.c"
 
 
        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
 //              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
  return FALSE;\r
 }\r
 \r
-__inline BOOL CheckCoord3()\r
+static __inline BOOL CheckCoord3()\r
 {\r
  if(lx0<0)\r
   {\r
 }\r
 \r
 \r
-__inline BOOL CheckCoord2()\r
+static __inline BOOL CheckCoord2()\r
 {\r
  if(lx0<0)\r
   {\r
 
   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
 
 #endif\r
 #include <math.h> \r
 \r
-#define __inline static inline\r
+#define __inline inline\r
 \r
 #endif\r
 \r
 
 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);
 }
 
 
 static noinline void do_reset(void)
 {
   unsigned int i;
+
   do_cmd_reset();
 
   memset(gpu.regs, 0, sizeof(gpu.regs));
     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;
 
 
   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)
     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)