svp compiler: working asm dispatcher
[picodrive.git] / Pico / carthw / svp / ssp16.c
index c371492..feef99b 100644 (file)
 
 #define IJind  (((op>>6)&4)|(op&3))
 
-#ifndef EMBED_INTERPRETER
 #define GET_PC() (PC - (unsigned short *)svp->iram_rom)
 #define GET_PPC_OFFS() ((unsigned int)PC - (unsigned int)svp->iram_rom - 2)
 #define SET_PC(d) PC = (unsigned short *)svp->iram_rom + d
-#endif
 
 #define REG_READ(r) (((r) <= 4) ? ssp->gr[r].h : read_handlers[r]())
 #define REG_WRITE(r,d) { \
 #define CHECK_ST(d)
 #endif
 
-#ifndef EMBED_INTERPRETER
-static
-#endif
 ssp1601_t *ssp = NULL;
 static unsigned short *PC;
 static int g_cycles;
@@ -374,9 +369,6 @@ static int g_cycles;
 static int running = 0;
 static int last_iram = 0;
 #endif
-#ifdef EMBED_INTERPRETER
-static int iram_dirty = 0;
-#endif
 
 // -----------------------------------------------------
 // register i/o handlers
@@ -454,7 +446,7 @@ static int get_inc(int mode)
        return inc;
 }
 
-#define overwite_write(dst, d) \
+#define overwrite_write(dst, d) \
 { \
        if (d & 0xf000) { dst &= ~0xf000; dst |= d & 0xf000; } \
        if (d & 0x0f00) { dst &= ~0x0f00; dst |= d & 0x0f00; } \
@@ -508,7 +500,7 @@ static u32 pm_io(int reg, int write, u32 d)
                                elprintf(EL_SVP, "ssp PM%i DRAM w [%06x] %04x (inc %i, ovrw %i)",
                                        reg, CADDR, d, inc, (mode>>10)&1);
                                if (mode & 0x0400) {
-                                      overwite_write(dram[addr], d);
+                                      overwrite_write(dram[addr], d);
                                } else dram[addr] = d;
                                ssp->pmac_write[reg] += inc;
                        }
@@ -517,7 +509,7 @@ static u32 pm_io(int reg, int write, u32 d)
                                elprintf(EL_SVP, "ssp PM%i DRAM w [%06x] %04x (cell inc, ovrw %i) @ %04x",
                                        reg, CADDR, d, (mode>>10)&1, GET_PPC_OFFS());
                                if (mode & 0x0400) {
-                                      overwite_write(dram[addr], d);
+                                      overwrite_write(dram[addr], d);
                                } else dram[addr] = d;
                                ssp->pmac_write[reg] += (addr&1) ? 31 : 1;
                        }
@@ -529,9 +521,6 @@ static u32 pm_io(int reg, int write, u32 d)
                                elprintf(EL_SVP, "ssp IRAM w [%06x] %04x (inc %i)", (addr<<1)&0x7ff, d, inc);
                                ((unsigned short *)svp->iram_rom)[addr&0x3ff] = d;
                                ssp->pmac_write[reg] += inc;
-#ifdef EMBED_INTERPRETER
-                               iram_dirty = 1;
-#endif
                        }
                        else
                        {
@@ -581,11 +570,9 @@ static u32 read_PM0(void)
        if (d != (u32)-1) return d;
        elprintf(EL_SVP, "PM0 raw r %04x @ %04x", rPM0, GET_PPC_OFFS());
        d = rPM0;
-#ifndef EMBED_INTERPRETER
        if (!(d & 2) && (GET_PPC_OFFS() == 0x800 || GET_PPC_OFFS() == 0x1851E)) {
                ssp->emu_status |= SSP_WAIT_PM0; elprintf(EL_SVP, "det TIGHT loop: PM0");
        }
-#endif
        rPM0 &= ~2; // ?
        return d;
 }
@@ -662,14 +649,12 @@ static void write_XST(u32 d)
 static u32 read_PM4(void)
 {
        u32 d = pm_io(4, 0, 0);
-#ifndef EMBED_INTERPRETER
        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;
                }
        }
-#endif
        if (d != (u32)-1) return d;
        // can be removed?
        elprintf(EL_SVP|EL_ANOMALY, "PM4 raw r %04x @ %04x", rPM4, GET_PPC_OFFS());
@@ -721,10 +706,9 @@ static void write_PMC(u32 d)
 // 15
 static u32 read_AL(void)
 {
-       if (*(PC-1) == 0x000f) {
+       if (*(PC-1) == 0x000f)
                elprintf(EL_SVP, "ssp dummy PM assign %08x @ %04x", rPMC.v, GET_PPC_OFFS());
-               ssp->emu_status &= ~(SSP_PMC_SET|SSP_PMC_HAVE_ADDR); // ?
-       }
+       ssp->emu_status &= ~(SSP_PMC_SET|SSP_PMC_HAVE_ADDR); // ?
        return rAL;
 }
 
@@ -917,7 +901,7 @@ static u32 ptr2_read(int op)
 
 // -----------------------------------------------------
 
-#if defined(USE_DEBUGGER) //|| defined(EMBED_INTERPRETER)
+#if defined(USE_DEBUGGER)
 static void debug_dump2file(const char *fname, void *mem, int len)
 {
        FILE *f = fopen(fname, "wb");
@@ -1033,9 +1017,8 @@ void ssp1601_reset(ssp1601_t *l_ssp)
 
 void ssp1601_run(int cycles)
 {
-#ifndef EMBED_INTERPRETER
        SET_PC(rPC);
-#endif
+
        g_cycles = cycles;
 
        while (g_cycles > 0 && !(ssp->emu_status & SSP_WAIT_MASK))
@@ -1054,7 +1037,6 @@ void ssp1601_run(int cycles)
                                CHECK_B_SET();
                                if (op == 0) break; // nop
                                if (op == ((SSP_A<<4)|SSP_P)) { // A <- P
-                                       // not sure. MAME claims that only hi word is transfered.
                                        read_P(); // update P
                                        rA32 = rP.v;
                                }