* flags correspond to full 32bit accumulator
* only Z and N status flags are emulated (others unused by SVP)
* modifiers for 'OP a, ri' are ignored (invalid?/not used by SVP)
- * 'ld d, (a)' loads from program ROM
*/
#include "../../PicoInt.h"
static int running = 0;
static int last_iram = 0;
#endif
+#ifdef EMBED_INTERPRETER
+static int iram_dirty = 0;
+#endif
// -----------------------------------------------------
// register i/o handlers
elprintf(EL_SVP, "PM%i (%c) set to %08x @ %04x", reg, write ? 'w' : 'r', rPMC.v, GET_PPC_OFFS());
ssp->pmac_read[write ? reg + 6 : reg] = rPMC.v;
ssp->emu_status &= ~SSP_PMC_SET;
- if ((rPMC.h & 0x7f) == 0x1c && (rPMC.l & 0x7fff) == 0) {
+ if ((rPMC.v & 0x7fffff) == 0x1c8000 || (rPMC.v & 0x7fffff) == 0x1c8240) {
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_dirty = 1;
#endif
}
return 0;
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;
}
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());
// -----------------------------------------------------
+#if defined(USE_DEBUGGER) //|| defined(EMBED_INTERPRETER)
+static void debug_dump2file(const char *fname, void *mem, int len)
+{
+ FILE *f = fopen(fname, "wb");
+ unsigned short *p = mem;
+ int i;
+ if (f) {
+ for (i = 0; i < len/2; i++) p[i] = (p[i]<<8) | (p[i]>>8);
+ fwrite(mem, 1, len, f);
+ fclose(f);
+ for (i = 0; i < len/2; i++) p[i] = (p[i]<<8) | (p[i]>>8);
+ printf("dumped to %s\n", fname);
+ }
+ else
+ printf("dump failed\n");
+}
+#endif
+
#ifdef USE_DEBUGGER
static void debug_dump(void)
{
}
}
-static void debug_dump2file(const char *fname, void *mem, int len)
-{
- FILE *f = fopen(fname, "wb");
- unsigned short *p = mem;
- int i;
- if (f) {
- for (i = 0; i < len/2; i++) p[i] = (p[i]<<8) | (p[i]>>8);
- fwrite(mem, 1, len, f);
- fclose(f);
- for (i = 0; i < len/2; i++) p[i] = (p[i]<<8) | (p[i]>>8);
- printf("dumped to %s\n", fname);
- }
- else
- printf("dump failed\n");
-}
-
static int bpts[10] = { 0, };
static void debug(unsigned int pc, unsigned int op)
#endif
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))
case 0x6c: OP_ORA (op & 0xff); break;
case 0x7c: OP_EORA(op & 0xff); break;
+#ifdef EMBED_INTERPRETER
+ case 0x7f: goto interp_end; /* pseudo op */
+#endif
default:
elprintf(EL_ANOMALY|EL_SVP, "ssp FIXME unhandled op %04x @ %04x", op, GET_PPC_OFFS());
break;
g_cycles--;
}
- read_P(); // update P
rPC = GET_PC();
+#ifdef EMBED_INTERPRETER
+interp_end:
+#endif
+ read_P(); // update P
if (ssp->gr[SSP_GR0].v != 0xffff0000)
elprintf(EL_ANOMALY|EL_SVP, "ssp FIXME: REG 0 corruption! %08x", ssp->gr[SSP_GR0].v);