X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FSek.c;h=1f2316eee20dd576daaeb9d48a2ff03992068ec5;hb=69996cb7c62468cd97842e35bdd2b74006a28dba;hp=0ca575f83c2d2ac1bdeb234de344e91721a8ba1e;hpb=b837b69b3fcff1737431c8be1c78d1cfd64003a6;p=picodrive.git diff --git a/Pico/Sek.c b/Pico/Sek.c index 0ca575f..1f2316e 100644 --- a/Pico/Sek.c +++ b/Pico/Sek.c @@ -43,19 +43,18 @@ static int (*ResetCallback)()=DoReset; #ifdef EMU_C68K // interrupt acknowledgment -static void SekIntAck(int level) +static int SekIntAck(int level) { // try to emulate VDP's reaction to 68000 int ack - if (level == 4) Pico.video.pending_ints = 0; - else if(level == 6) Pico.video.pending_ints &= ~0x20; + if (level == 4) { Pico.video.pending_ints = 0; elprintf(EL_INTS, "hack: @ %06x [%i]", SekPc, SekCycleCnt); } + else if(level == 6) { Pico.video.pending_ints &= ~0x20; elprintf(EL_INTS, "vack: @ %06x [%i]", SekPc, SekCycleCnt); } PicoCpu.irq = 0; + return CYCLONE_INT_ACK_AUTOVECTOR; } -static void SekResetAck() +static void SekResetAck(void) { -#if defined(__DEBUG_PRINT) || defined(WIN32) - dprintf("Reset encountered @ %06x", SekPc); -#endif + elprintf(EL_ANOMALY, "Reset encountered @ %06x", SekPc); } static int SekUnrecognizedOpcode() @@ -63,15 +62,19 @@ static int SekUnrecognizedOpcode() unsigned int pc, op; pc = SekPc; op = PicoCpu.read16(pc); -#if defined(__DEBUG_PRINT) || defined(WIN32) - dprintf("Unrecognized Opcode %04x @ %06x", op, pc); -#endif + elprintf(EL_ANOMALY, "Unrecognized Opcode %04x @ %06x", op, pc); // see if we are not executing trash if (pc < 0x200 || (pc > Pico.romsize+4 && (pc&0xe00000)!=0xe00000)) { PicoCpu.cycles = 0; - PicoCpu.stopped = 1; + PicoCpu.state_flags |= 1; return 1; } +#ifdef EMU_M68K // debugging cyclone + { + extern int have_illegal; + have_illegal = 1; + } +#endif //exit(1); return 0; } @@ -81,16 +84,21 @@ static int SekUnrecognizedOpcode() #ifdef EMU_M68K static int SekIntAckM68K(int level) { - if (level == 4) { Pico.video.pending_ints = 0; dprintf("hack: [%i|%i]", Pico.m.scanline, SekCyclesDone()); } - else if(level == 6) { Pico.video.pending_ints &= ~0x20; dprintf("vack: [%i|%i]", Pico.m.scanline, SekCyclesDone()); } + if (level == 4) { Pico.video.pending_ints = 0; elprintf(EL_INTS, "hack: @ %06x [%i]", SekPc, SekCycleCnt); } + else if(level == 6) { Pico.video.pending_ints &= ~0x20; elprintf(EL_INTS, "vack: @ %06x [%i]", SekPc, SekCycleCnt); } CPU_INT_LEVEL = 0; return M68K_INT_ACK_AUTOVECTOR; } + +static int SekTasCallback(void) +{ + return 0; // no writeback +} #endif -int SekInit() +PICO_INTERNAL int SekInit() { #ifdef EMU_C68K CycloneInit(); @@ -112,6 +120,7 @@ int SekInit() m68k_set_cpu_type(M68K_CPU_TYPE_68000); m68k_init(); m68k_set_int_ack_callback(SekIntAckM68K); + m68k_set_tas_instr_callback(SekTasCallback); m68k_pulse_reset(); // Init cpu emulator m68k_set_context(oldcontext); } @@ -121,12 +130,12 @@ int SekInit() } // Reset the 68000: -int SekReset() +PICO_INTERNAL int SekReset() { if (Pico.rom==NULL) return 1; #ifdef EMU_C68K - PicoCpu.stopped=0; + PicoCpu.state_flags=0; PicoCpu.osp=0; PicoCpu.srh =0x27; // Supervisor mode PicoCpu.flags=4; // Z set @@ -144,6 +153,8 @@ int SekReset() #endif #ifdef EMU_M68K m68k_set_context(&PicoM68kCPU); // if we ever reset m68k, we always need it's context to be set + m68ki_cpu.sp[0]=0; + m68k_set_irq(0); m68k_pulse_reset(); #endif @@ -151,8 +162,15 @@ int SekReset() } -int SekInterrupt(int irq) +PICO_INTERNAL int SekInterrupt(int irq) { +#if defined(EMU_C68K) && defined(EMU_M68K) + { + extern unsigned int dbg_irq_level; + dbg_irq_level=irq; + return 0; + } +#endif #ifdef EMU_C68K PicoCpu.irq=irq; #endif @@ -174,7 +192,7 @@ int SekInterrupt(int irq) //int SekPc() { return M68000_regs.pc; } //int SekPc() { return m68k_get_reg(NULL, M68K_REG_PC); } -void SekState(unsigned char *data) +PICO_INTERNAL void SekState(unsigned char *data) { #ifdef EMU_C68K memcpy(data,PicoCpu.d,0x44); @@ -186,3 +204,11 @@ void SekState(unsigned char *data) memcpy(data+0x40,&PicoM68kCPU.pc, 0x04); #endif } + +PICO_INTERNAL void SekSetRealTAS(int use_real) +{ +#ifdef EMU_C68K + CycloneSetRealTAS(use_real); +#endif +} +