svp compiler: added first wait loop detection
[picodrive.git] / Pico / carthw / svp / ssp16.c
index 630065c..ea0529f 100644 (file)
 }
 
 
-static ssp1601_t *ssp = NULL;
+#ifndef EMBED_INTERPRETER
+static
+#endif
+ssp1601_t *ssp = NULL;
 static unsigned short *PC;
 static int g_cycles;
 
@@ -341,7 +344,7 @@ static int running = 0;
 static int last_iram = 0;
 #endif
 #ifdef EMBED_INTERPRETER
-static int iram_id = 0;
+static int iram_dirty = 0;
 #endif
 
 // -----------------------------------------------------
@@ -447,9 +450,6 @@ static u32 pm_io(int reg, int write, u32 d)
                        elprintf(EL_SVP, "ssp IRAM copy from %06x", (ssp->RAM1[0]-1)<<1);
 #ifdef USE_DEBUGGER
                        last_iram = (ssp->RAM1[0]-1)<<1;
-#endif
-#ifdef EMBED_INTERPRETER
-                       iram_id = ssp->RAM1[0];
 #endif
                }
                return 0;
@@ -494,17 +494,14 @@ static u32 pm_io(int reg, int write, u32 d)
                        else if ((mode & 0x47ff) == 0x001c) // IRAM
                        {
                                int inc = get_inc(mode);
-#ifdef EMBED_INTERPRETER
-                               if (addr == 0x8047) {
-                                       iram_id &= 0xffff;
-                                       iram_id |= d << 16;
-                               }
-#endif
                                if ((addr&0xfc00) != 0x8000)
                                        elprintf(EL_SVP|EL_ANOMALY, "ssp FIXME: invalid IRAM addr: %04x", addr<<1);
                                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
                        {
@@ -890,7 +887,7 @@ static u32 ptr2_read(int op)
 
 // -----------------------------------------------------
 
-#if defined(USE_DEBUGGER) // || defined(EMBED_INTERPRETER)
+#if defined(USE_DEBUGGER) //|| defined(EMBED_INTERPRETER)
 static void debug_dump2file(const char *fname, void *mem, int len)
 {
        FILE *f = fopen(fname, "wb");
@@ -993,9 +990,6 @@ static void debug(unsigned int pc, unsigned int op)
 #endif // USE_DEBUGGER
 
 
-#ifdef EMBED_INTERPRETER
-static
-#endif
 void ssp1601_reset(ssp1601_t *l_ssp)
 {
        ssp = l_ssp;
@@ -1007,9 +1001,6 @@ void ssp1601_reset(ssp1601_t *l_ssp)
 }
 
 
-#ifdef EMBED_INTERPRETER
-static
-#endif
 void ssp1601_run(int cycles)
 {
 #ifndef EMBED_INTERPRETER