}
}
-static void p32x_start_blank(void)
+static void p32x_render_frame(void)
{
if (Pico32xDrawMode != PDM32X_OFF && !PicoIn.skipFrame) {
int offs, lines;
lines = 240;
}
- // XXX: no proper handling of 32col mode..
if ((Pico32x.vdp_regs[0] & P32XV_Mx) != 0 && // 32x not blanking
(!(Pico.video.debug_p & PVD_KILL_32X)))
{
pprof_end(draw);
}
+}
+static void p32x_start_blank(void)
+{
// enter vblank
Pico32x.vdp_regs[0x0a/2] |= P32XV_VBLK|P32XV_PEN;
p32x_sh2_poll_event(&ssh2, SH2_STATE_VPOLL, SekCyclesDone());
}
+static void p32x_end_blank(void)
+{
+ // end vblank
+ Pico32x.vdp_regs[0x0a/2] &= ~P32XV_VBLK; // get out of vblank
+ if ((Pico32x.vdp_regs[0] & P32XV_Mx) != 0) // no forced blanking
+ Pico32x.vdp_regs[0x0a/2] &= ~P32XV_PEN; // no palette access
+ if (!(Pico32x.sh2_regs[0] & 0x80))
+ p32x_schedule_hint(NULL, SekCyclesDone());
+}
+
void p32x_schedule_hint(SH2 *sh2, unsigned int m68k_cycles)
{
// rather rough, 32x hint is useless in practice
int after;
-
if (!((Pico32x.sh2irq_mask[0] | Pico32x.sh2irq_mask[1]) & 4))
return; // nobody cares
- // note: when Pico.m.scanline is 224, SH2s might
- // still be at scanline 93 (or so)
- if (!(Pico32x.sh2_regs[0] & 0x80) &&
- Pico.m.scanline > (Pico.video.reg[1] & 0x08 ? 240 : 224))
+ if (!(Pico32x.sh2_regs[0] & 0x80) && (Pico.video.status & PVS_VB2))
return;
after = (Pico32x.sh2_regs[4 / 2] + 1) * 488;
sh2_execute_prepare(&msh2, PicoIn.opt & POPT_EN_DRC);
sh2_execute_prepare(&ssh2, PicoIn.opt & POPT_EN_DRC);
- Pico.m.scanline = 0;
-
- Pico32x.vdp_regs[0x0a/2] &= ~P32XV_VBLK; // get out of vblank
- if ((Pico32x.vdp_regs[0] & P32XV_Mx) != 0) // no forced blanking
- Pico32x.vdp_regs[0x0a/2] &= ~P32XV_PEN; // no palette access
-
- if (!(Pico32x.sh2_regs[0] & 0x80))
- p32x_schedule_hint(NULL, SekCyclesDone());
p32x_sh2_poll_event(&msh2, SH2_STATE_VPOLL, SekCyclesDone());
p32x_sh2_poll_event(&ssh2, SH2_STATE_VPOLL, SekCyclesDone());
SekSyncM68k();
}
+static void SyncCPUs(unsigned int cycles)
+{
+ // sync cpus
+ if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoIn.opt&POPT_EN_Z80))
+ PicoSyncZ80(cycles);
+
+#ifdef PICO_CD
+ if (PicoIn.AHW & PAHW_MCD)
+ pcd_sync_s68k(cycles, 0);
+#endif
+#ifdef PICO_32X
+ p32x_sync_sh2s(cycles);
+#endif
+}
+
static void do_hint(struct PicoVideo *pv)
{
pv->pending_ints |= 0x10;
struct PicoVideo *pv = &Pico.video;
int lines, y, lines_vis, skip;
int vcnt_wrap, vcnt_adj;
- unsigned int cycles;
int hint; // Hint counter
pevt_log_m68k_o(EVT_FRAME_START);
- if ((PicoIn.opt&POPT_ALT_RENDERER) && !PicoIn.skipFrame && (pv->reg[1]&0x40)) { // fast rend., display enabled
- // draw a frame just after vblank in alternative render mode
- // yes, this will cause 1 frame lag, but this is inaccurate mode anyway.
- PicoFrameFull();
-#ifdef DRAW_FINISH_FUNC
- DRAW_FINISH_FUNC();
-#endif
- skip = 1;
- }
- else skip=PicoIn.skipFrame;
+ skip = PicoIn.skipFrame;
Pico.t.m68c_frame_start = Pico.t.m68c_aim;
pv->v_counter = Pico.m.scanline = 0;
PsndStartFrame();
hint = pv->hint_cnt;
+
+ // === active display ===
pv->status |= PVS_ACTIVE;
- for (y = 0; ; y++)
+ lines_vis = (pv->reg[1] & 8) ? 240 : 224;
+ for (y = 0; y < lines_vis; y++)
{
pv->v_counter = Pico.m.scanline = y;
if ((pv->reg[12]&6) == 6) { // interlace mode 2
pv->v_counter &= 0xff;
}
- if ((y == 224 && !(pv->reg[1] & 8)) || y == 240)
- break;
-
PAD_DELAY();
// H-Interrupts:
pevt_log_m68k_o(EVT_NEXT_LINE);
}
- lines_vis = (pv->reg[1] & 8) ? 240 : 224;
- if (y == lines_vis)
- pv->status &= ~PVS_ACTIVE;
+ SyncCPUs(Pico.t.m68c_aim);
+
+ // === VBLANK, 1st line ===
+ pv->status &= ~PVS_ACTIVE;
if (!skip)
{
DRAW_FINISH_FUNC();
#endif
}
+#ifdef PICO_32X
+ p32x_render_frame();
+#endif
memcpy(PicoIn.padInt, PicoIn.pad, sizeof(PicoIn.padInt));
PAD_DELAY();
SekInterrupt(6);
}
- cycles = Pico.t.m68c_aim;
if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoIn.opt&POPT_EN_Z80)) {
- PicoSyncZ80(cycles);
+ PicoSyncZ80(Pico.t.m68c_aim);
elprintf(EL_INTS, "zint");
z80_int();
}
-#ifdef PICO_CD
- if (PicoIn.AHW & PAHW_MCD)
- pcd_sync_s68k(cycles, 0);
-#endif
#ifdef PICO_32X
- p32x_sync_sh2s(cycles);
p32x_start_blank();
#endif
if (PicoLineHook) PicoLineHook();
pevt_log_m68k_o(EVT_NEXT_LINE);
+ // === VBLANK ===
if (Pico.m.pal) {
lines = 313;
vcnt_wrap = 0x103;
}
}
+ // === VBLANK last line ===
pv->status &= ~(SR_VB | PVS_VB2);
pv->status |= ((pv->reg[1] >> 3) ^ SR_VB) & SR_VB; // forced blanking
if (PicoLineHook) PicoLineHook();
pevt_log_m68k_o(EVT_NEXT_LINE);
- // sync cpus
- cycles = Pico.t.m68c_aim;
- if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoIn.opt&POPT_EN_Z80))
- PicoSyncZ80(cycles);
-
-#ifdef PICO_CD
- if (PicoIn.AHW & PAHW_MCD)
- pcd_sync_s68k(cycles, 0);
-#endif
+ SyncCPUs(Pico.t.m68c_aim);
#ifdef PICO_32X
- p32x_sync_sh2s(cycles);
+ p32x_end_blank();
#endif
// get samples from sound chips