X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=pico%2Fsek.c;h=c76a3e8ed19d215ab668c4a1517f6aa6fc3b94c1;hb=12f23dac6f91eb707f985ef00a5d48e9e5ef8838;hp=f599d9b1d1d719a830ed15719b3e253bcb3e1fac;hpb=88fd63ad10faa746ef9d7ad7d98a72e51fe2aa86;p=picodrive.git diff --git a/pico/sek.c b/pico/sek.c index f599d9b..c76a3e8 100644 --- a/pico/sek.c +++ b/pico/sek.c @@ -25,15 +25,30 @@ M68K_CONTEXT PicoCpuFM68k; #endif +static int do_ack(int level) +{ + struct PicoVideo *pv = &Pico.video; + + elprintf(EL_INTS, "%cack: @ %06x [%u], p=%02x", + level == 6 ? 'v' : 'h', SekPc, SekCyclesDone(), pv->pending_ints); + // the VDP doesn't look at the 68k level + if (pv->pending_ints & pv->reg[1] & 0x20) { + pv->pending_ints &= ~0x20; + pv->status &= ~SR_F; + return (pv->reg[0] & pv->pending_ints & 0x10) >> 2; + } + else if (pv->pending_ints & pv->reg[0] & 0x10) + pv->pending_ints &= ~0x10; + + return 0; +} + /* callbacks */ #ifdef EMU_C68K // interrupt acknowledgment static int SekIntAck(int level) { - // try to emulate VDP's reaction to 68000 int ack - if (level == 4) { Pico.video.pending_ints = 0; elprintf(EL_INTS, "hack: @ %06x [%u]", SekPc, Pico.t.m68c_cnt); } - else if(level == 6) { Pico.video.pending_ints &= ~0x20; elprintf(EL_INTS, "vack: @ %06x [%u]", SekPc, Pico.t.m68c_cnt); } - PicoCpuCM68k.irq = 0; + PicoCpuCM68k.irq = do_ack(level); return CYCLONE_INT_ACK_AUTOVECTOR; } @@ -71,9 +86,7 @@ static int SekUnrecognizedOpcode() #ifdef EMU_M68K static int SekIntAckM68K(int level) { - if (level == 4) { Pico.video.pending_ints = 0; elprintf(EL_INTS, "hack: @ %06x [%u]", SekPc, Pico.t.m68c_cnt); } - else if(level == 6) { Pico.video.pending_ints &= ~0x20; elprintf(EL_INTS, "vack: @ %06x [%u]", SekPc, Pico.t.m68c_cnt); } - CPU_INT_LEVEL = 0; + CPU_INT_LEVEL = do_ack(level) << 8; return M68K_INT_ACK_AUTOVECTOR; } @@ -87,15 +100,7 @@ static int SekTasCallback(void) #ifdef EMU_F68K static void SekIntAckF68K(unsigned level) { - if (level == 4) { - Pico.video.pending_ints = 0; - elprintf(EL_INTS, "hack: @ %06x [%u]", SekPc, SekCyclesDone()); - } - else if(level == 6) { - Pico.video.pending_ints &= ~0x20; - elprintf(EL_INTS, "vack: @ %06x [%u]", SekPc, SekCyclesDone()); - } - PicoCpuFM68k.interrupts[0] = 0; + PicoCpuFM68k.interrupts[0] = do_ack(level); } #endif @@ -152,10 +157,7 @@ PICO_INTERNAL int SekReset(void) REG_USP = 0; // ? #endif #ifdef EMU_F68K - { - g_m68kcontext = &PicoCpuFM68k; - fm68k_reset(); - } + fm68k_reset(&PicoCpuFM68k); #endif return 0; @@ -173,7 +175,7 @@ void SekStepM68k(void) #elif defined(EMU_M68K) Pico.t.m68c_cnt += m68k_execute(1); #elif defined(EMU_F68K) - Pico.t.m68c_cnt += fm68k_emulate(1, 0); + Pico.t.m68c_cnt += fm68k_emulate(&PicoCpuFM68k, 1, 0); #endif } @@ -315,7 +317,7 @@ void SekInitIdleDet(void) CycloneInitIdle(); #endif #ifdef EMU_F68K - fm68k_emulate(0, 1); + fm68k_idle_install(); #endif } @@ -426,7 +428,7 @@ void SekFinishIdleDet(void) CycloneFinishIdle(); #endif #ifdef EMU_F68K - fm68k_emulate(0, 2); + fm68k_idle_remove(); #endif while (idledet_count > 0) {