misc gp2x tweaks
[picodrive.git] / pico / carthw / svp / ssp16.c
index 1d59406..07831b0 100644 (file)
 #define IJind  (((op>>6)&4)|(op&3))
 
 #define GET_PC() (PC - (unsigned short *)svp->iram_rom)
-#define GET_PPC_OFFS() ((unsigned int)PC - (unsigned int)svp->iram_rom - 2)
+#define GET_PPC_OFFS() ((unsigned char *)PC - svp->iram_rom - 2)
 #define SET_PC(d) PC = (unsigned short *)svp->iram_rom + d
 
 #define REG_READ(r) (((r) <= 4) ? ssp->gr[r].h : read_handlers[r]())
@@ -647,12 +647,14 @@ static void write_XST(u32 d)
 static u32 read_PM4(void)
 {
        u32 d = pm_io(4, 0, 0);
+
        if (d == 0) {
                switch (GET_PPC_OFFS()) {
                        case 0x0854: ssp->emu_status |= SSP_WAIT_30FE08; elprintf(EL_SVP, "det TIGHT loop: [30fe08]"); break;
                        case 0x4f12: ssp->emu_status |= SSP_WAIT_30FE06; elprintf(EL_SVP, "det TIGHT loop: [30fe06]"); break;
                }
        }
+
        if (d != (u32)-1) return d;
        // can be removed?
        elprintf(EL_SVP|EL_ANOMALY, "PM4 raw r %04x @ %04x", rPM4, GET_PPC_OFFS());