From 9a8ffeeeea54301c5289fd510aece552175ce13d Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 6 Oct 2007 16:06:15 +0000 Subject: [PATCH] fast mode timing changed (again...) git-svn-id: file:///home/notaz/opt/svn/PicoDrive@271 be3aeb3a-fb24-0410-a615-afba39da0efa --- Pico/MemoryCmn.c | 6 +++--- Pico/Pico.c | 36 ++++++++++++++++++++++++------------ Pico/PicoFrameHints.c | 2 +- Pico/sound/sound.c | 4 +--- 4 files changed, 29 insertions(+), 19 deletions(-) diff --git a/Pico/MemoryCmn.c b/Pico/MemoryCmn.c index 8e4d04e..219a094 100644 --- a/Pico/MemoryCmn.c +++ b/Pico/MemoryCmn.c @@ -72,17 +72,17 @@ static void z80WriteBusReq(u32 d) { d&=1; d^=1; - if (Pico.m.scanline != -1) + //if (Pico.m.scanline != -1) { if(!d) { // this is for a nasty situation where Z80 was enabled and disabled in the same 68k timeslice (Golden Axe III) if (Pico.m.z80Run) { int lineCycles; z80stopCycle = SekCyclesDone(); - if (Pico.m.z80Run&2) + if ((Pico.m.z80Run&2) && Pico.m.scanline != -1) lineCycles=(488-SekCyclesLeft)&0x1ff; else lineCycles=z80stopCycle-z80startCycle; // z80 was started at current line - if (lineCycles > 0 && lineCycles <= 488) { + if (lineCycles > 0) { // && lineCycles <= 488) { //dprintf("zrun: %i/%i cycles", lineCycles, (lineCycles>>1)-(lineCycles>>5)); lineCycles=(lineCycles>>1)-(lineCycles>>5); z80_run(lineCycles); diff --git a/Pico/Pico.c b/Pico/Pico.c index 96a6da0..c6bf03e 100644 --- a/Pico/Pico.c +++ b/Pico/Pico.c @@ -423,24 +423,34 @@ static int PicoFrameHints(void) #include "PicoFrameHints.c" #endif -// helper z80 runner +// helper z80 runner. Runs only if z80 is enabled at this point +// (z80WriteBusReq will handle the rest) static void PicoRunZ80Simple(int line_from, int line_to) { - int line_from_r=line_from, line_to_r=line_to, line = line_from; + int line_from_r=line_from, line_to_r=line_to, line=0; int line_sample = Pico.m.pal ? 68 : 93; - if(!(PicoOpt&4) || Pico.m.z80Run == 0) { line_from_r = line_to_r; line_to_r = 0; } + if (!(PicoOpt&4) || Pico.m.z80Run == 0) line_to_r = 0; + else { + extern const unsigned short vcounts[]; + if (z80startCycle) { + line = vcounts[z80startCycle>>8]; + if (line > line_from) + line_from_r = line; + } + z80startCycle = SekCyclesDone(); + } - if(PicoOpt&1) { + if (PicoOpt&1) { // we have ym2612 enabled, so we have to run Z80 in lines, so we could update DAC and timers - for(; line < line_to; line++) { + for (line = line_from; line < line_to; line++) { sound_timers_and_dac(line); - if((line == 224 || line == line_sample) && PsndOut) getSamples(line); - if(line == 32 && PsndOut) emustatus &= ~1; - if(line >= line_from_r && line < line_to_r) + if ((line == 224 || line == line_sample) && PsndOut) getSamples(line); + if (line == 32 && PsndOut) emustatus &= ~1; + if (line >= line_from_r && line < line_to_r) z80_run(228); } - } else if(line_to_r-line_from_r > 0) { + } else if (line_to_r-line_from_r > 0) { z80_run(228*(line_to_r-line_from_r)); // samples will be taken by caller } @@ -482,6 +492,7 @@ static int PicoFrameSimple(void) Pico.video.status|=0x200; Pico.m.scanline=-1; + z80startCycle=0; SekCyclesReset(); @@ -507,11 +518,12 @@ static int PicoFrameSimple(void) if(sects) { int c = sects*cycles_68k_block; - lines += sects*lines_step; - PicoRunZ80Simple(line, lines); - // this is for approriate line counter, etc + // this "run" is for approriate line counter, etc SekCycleCnt += c; SekCycleAim += c; + + lines += sects*lines_step; + PicoRunZ80Simple(line, lines); } // here we render sound if ym2612 is disabled diff --git a/Pico/PicoFrameHints.c b/Pico/PicoFrameHints.c index 562229f..c14040a 100644 --- a/Pico/PicoFrameHints.c +++ b/Pico/PicoFrameHints.c @@ -22,7 +22,7 @@ else { \ cnt = SekCyclesDone() - z80startCycle; \ cnt = (cnt>>1)-(cnt>>5); \ - if (cnt > (z80_cycles)) cnt = z80_cycles; \ + if (cnt < 0 || cnt > (z80_cycles)) cnt = z80_cycles; \ Pico.m.z80Run |= 2; \ z80CycleAim+=cnt; \ } \ diff --git a/Pico/sound/sound.c b/Pico/sound/sound.c index 32f2295..8bec0ba 100644 --- a/Pico/sound/sound.c +++ b/Pico/sound/sound.c @@ -106,9 +106,7 @@ PICO_INTERNAL void sound_reset(void) // also clear the internal registers+addr line ym2612_regs = YM2612GetRegs(); memset(ym2612_regs, 0, 0x200+4); - // setting these to 0 might confuse timing code, - // so better set to something like this instead - z80startCycle = z80stopCycle = 0x01000000; + z80startCycle = z80stopCycle = 0; sound_rerate(0); } -- 2.39.2