case 0x04: return PicoVideoRead8CtlH(1);\r
case 0x05: return PicoVideoRead8CtlL(1);\r
case 0x08:\r
- case 0x0c: return get_scanline(1); // FIXME: make it proper\r
+ case 0x0c: return PicoVideoGetV(get_scanline(1));\r
case 0x09:\r
case 0x0d: return Pico.m.rotate++;\r
}\r
// force setting possibly changed..\r
Pico.m.pal = (PicoIn.regionOverride == 2 || PicoIn.regionOverride == 8) ? 1 : 0;\r
\r
+ if (Pico.m.pal) {\r
+ Pico.t.vcnt_wrap = 0x103;\r
+ Pico.t.vcnt_adj = 57;\r
+ }\r
+ else {\r
+ Pico.t.vcnt_wrap = 0xEB;\r
+ Pico.t.vcnt_adj = 6;\r
+ }\r
+\r
Pico.m.dirtyPal = 1;\r
rendstatus_old = -1;\r
\r
{
struct PicoVideo *pv = &Pico.video;
int lines, y, lines_vis, skip;
- int vcnt_wrap, vcnt_adj;
int hint; // Hint counter
pevt_log_m68k_o(EVT_FRAME_START);
skip = PicoIn.skipFrame;
Pico.t.m68c_frame_start = Pico.t.m68c_aim;
- pv->v_counter = Pico.m.scanline = 0;
z80_resetCycles();
PsndStartFrame();
// === active display ===
pv->status |= PVS_ACTIVE;
- for (y = 0; ; y++)
+ for (y = 0;; y++)
{
- pv->v_counter = Pico.m.scanline = y;
- if ((pv->reg[12]&6) == 6) { // interlace mode 2
- pv->v_counter <<= 1;
- pv->v_counter |= pv->v_counter >> 8;
- pv->v_counter &= 0xff;
- }
+ Pico.m.scanline = y;
+ pv->v_counter = PicoVideoGetV(y);
- if ((y == 224 && !(pv->reg[1] & 8)) || y == 240)
+ lines_vis = (pv->reg[1] & 8) ? 240 : 224;
+ if (y == lines_vis)
break;
PAD_DELAY();
pevt_log_m68k_o(EVT_NEXT_LINE);
// === VBLANK ===
- if (Pico.m.pal) {
- lines = 313;
- vcnt_wrap = 0x103;
- vcnt_adj = 57;
- }
- else {
- lines = 262;
- vcnt_wrap = 0xEB;
- vcnt_adj = 6;
- }
-
+ lines = Pico.m.pal ? 313 : 262;
for (y++; y < lines - 1; y++)
{
- pv->v_counter = Pico.m.scanline = y;
- if (y >= vcnt_wrap)
- pv->v_counter -= vcnt_adj;
- if ((pv->reg[12]&6) == 6)
- pv->v_counter = (pv->v_counter << 1) | 1;
- pv->v_counter &= 0xff;
+ Pico.m.scanline = y;
+ pv->v_counter = PicoVideoGetV(y);
PAD_DELAY();
\r
int timer_a_next_oflow, timer_a_step; // in z80 cycles\r
int timer_b_next_oflow, timer_b_step;\r
+\r
+ int vcnt_wrap, vcnt_adj;\r
};\r
\r
struct PicoSound\r
UpdateSAT(a, d);\r
}\r
\r
+static __inline u8 PicoVideoGetV(int scanline)\r
+{\r
+ if (scanline >= Pico.t.vcnt_wrap) scanline -= Pico.t.vcnt_adj;\r
+ if ((Pico.video.reg[12]&6) == 6) scanline = (scanline<<1) | 1;\r
+ return scanline;\r
+}\r
+\r
PICO_INTERNAL_ASM void PicoVideoWrite(u32 a,unsigned short d);\r
PICO_INTERNAL_ASM u32 PicoVideoRead(u32 a);\r
unsigned char PicoVideoRead8DataH(int is_from_z80);\r