From: notaz Date: Mon, 2 Sep 2013 23:52:07 +0000 (+0300) Subject: make hcnt code friendly with split timeslices X-Git-Tag: v1.90~23 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=53f948c9014404685aaacce497755794c25bc5b6;p=picodrive.git make hcnt code friendly with split timeslices values need to be fixed, they're wrong, wrong wrong... --- diff --git a/pico/pico_cmn.c b/pico/pico_cmn.c index af696e57..5ce13aae 100644 --- a/pico/pico_cmn.c +++ b/pico/pico_cmn.c @@ -157,6 +157,7 @@ static int PicoFrameHints(void) } // Run scanline: + line_base_cycles = SekCyclesDone(); if (Pico.m.dma_xfers) SekCyclesBurn(CheckDMA()); CPUS_RUN(CYCLES_M68K_LINE); @@ -201,6 +202,7 @@ static int PicoFrameHints(void) // there must be a delay after vblank bit is set and irq is asserted (Mazin Saga) // also delay between F bit (bit 7) is set in SR and IRQ happens (Ex-Mutants) // also delay between last H-int and V-int (Golden Axe 3) + line_base_cycles = SekCyclesDone(); CPUS_RUN(CYCLES_M68K_VINT_LAG); if (pv->reg[1]&0x20) { @@ -253,6 +255,7 @@ static int PicoFrameHints(void) PAD_DELAY(); // Run scanline: + line_base_cycles = SekCyclesDone(); if (Pico.m.dma_xfers) SekCyclesBurn(CheckDMA()); CPUS_RUN(CYCLES_M68K_LINE); diff --git a/pico/pico_int.h b/pico/pico_int.h index 14a8d423..84661c4d 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -704,6 +704,7 @@ void ym2612_unpack_state(void); // videoport.c +extern int line_base_cycles; PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d); PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a); PICO_INTERNAL_ASM unsigned int PicoVideoRead8(unsigned int a); diff --git a/pico/videoport.c b/pico/videoport.c index 42f55c82..1e606868 100644 --- a/pico/videoport.c +++ b/pico/videoport.c @@ -10,6 +10,7 @@ #include "pico_int.h" #include "cd/gfx_cd.h" +int line_base_cycles; extern const unsigned char hcounts_32[]; extern const unsigned char hcounts_40[]; @@ -396,7 +397,8 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d) return; } - if (num == 1 && !(d&0x40) && SekCyclesLeft > 390) blank_on = 1; + if (num == 1 && !(d&0x40) && SekCyclesDone() - line_base_cycles <= 488-390) + blank_on = 1; DrawSync(blank_on); pvid->reg[num]=(unsigned char)d; switch (num) @@ -457,7 +459,8 @@ PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a) unsigned int d; d=pv->status; //if (PicoOpt&POPT_ALT_RENDERER) d|=0x0020; // sprite collision (Shadow of the Beast) - if (SekCyclesLeft < 84+4) d|=0x0004; // H-Blank (Sonic3 vs) + if (SekCyclesDone() - line_base_cycles >= 488-88) + d|=0x0004; // H-Blank (Sonic3 vs) d |= ((pv->reg[1]&0x40)^0x40) >> 3; // set V-Blank if display is disabled d |= (pv->pending_ints&0x20)<<2; // V-int pending? @@ -487,12 +490,11 @@ PICO_INTERNAL_ASM unsigned int PicoVideoRead(unsigned int a) if ((a&0x1c)==0x08) { unsigned int d; - int lineCycles; - lineCycles = (488-SekCyclesLeft)&0x1ff; + d = (SekCyclesDone() - line_base_cycles) & 0x1ff; // FIXME if (Pico.video.reg[12]&1) - d = hcounts_40[lineCycles]; - else d = hcounts_32[lineCycles]; + d = hcounts_40[d]; + else d = hcounts_32[d]; elprintf(EL_HVCNT, "hv: %02x %02x (%i) @ %06x", d, Pico.video.v_counter, SekCyclesDone(), SekPc); return d | (Pico.video.v_counter << 8); @@ -526,7 +528,7 @@ unsigned int PicoVideoRead8(unsigned int a) //if (PicoOpt&POPT_ALT_RENDERER) d|=0x0020; // sprite collision (Shadow of the Beast) d |= ((Pico.video.reg[1]&0x40)^0x40) >> 3; // set V-Blank if display is disabled d |= (Pico.video.pending_ints&0x20)<<2; // V-int pending? - if (SekCyclesLeft < 84+4) d |= 4; // H-Blank + if (SekCyclesDone() - line_base_cycles >= 488-88) d |= 4; // H-Blank Pico.video.pending = 0; elprintf(EL_SR, "SR read (l): %02x @ %06x", d, SekPc); return d; @@ -534,7 +536,7 @@ unsigned int PicoVideoRead8(unsigned int a) elprintf(EL_HVCNT, "vcounter: %02x (%i) @ %06x", Pico.video.v_counter, SekCyclesDone(), SekPc); return Pico.video.v_counter; case 9: - d = (488-SekCyclesLeft)&0x1ff; + d = (SekCyclesDone() - line_base_cycles) & 0x1ff; // FIXME if (Pico.video.reg[12]&1) d = hcounts_40[d]; else d = hcounts_32[d];