X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2Fcarthw%2Fsvp%2Fssp16.c;h=b2de4596ae20b1cb38cb79f6cfb23b4046c3515b;hb=892b1dd258c41e6ffa9555a172db1394b07e322d;hp=9835165a73deba7600e3e081b5ea6877469bc8ad;hpb=6b6a3e50f21fc4d5f6de9321118599284528ac47;p=picodrive.git diff --git a/Pico/carthw/svp/ssp16.c b/Pico/carthw/svp/ssp16.c index 9835165..b2de459 100644 --- a/Pico/carthw/svp/ssp16.c +++ b/Pico/carthw/svp/ssp16.c @@ -184,7 +184,6 @@ * 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" @@ -341,6 +340,9 @@ 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 @@ -441,7 +443,7 @@ static u32 pm_io(int reg, int write, u32 d) 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; @@ -494,6 +496,9 @@ 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 { @@ -543,9 +548,11 @@ 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; } @@ -622,12 +629,14 @@ 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()); @@ -875,6 +884,24 @@ static u32 ptr2_read(int op) // ----------------------------------------------------- +#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) { @@ -904,22 +931,6 @@ static void debug_dump_mem(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) @@ -976,9 +987,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; @@ -990,12 +998,11 @@ void ssp1601_reset(ssp1601_t *l_ssp) } -#ifdef EMBED_INTERPRETER -static -#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)) @@ -1177,6 +1184,9 @@ void ssp1601_run(int cycles) 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; @@ -1184,8 +1194,11 @@ void ssp1601_run(int cycles) 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);