#include "PicoFrameHints.c"\r
#endif\r
\r
-// helper z80 runner\r
+// helper z80 runner. Runs only if z80 is enabled at this point\r
+// (z80WriteBusReq will handle the rest)\r
static void PicoRunZ80Simple(int line_from, int line_to)\r
{\r
- int line_from_r=line_from, line_to_r=line_to, line = line_from;\r
+ int line_from_r=line_from, line_to_r=line_to, line=0;\r
int line_sample = Pico.m.pal ? 68 : 93;\r
\r
- if(!(PicoOpt&4) || Pico.m.z80Run == 0) { line_from_r = line_to_r; line_to_r = 0; }\r
+ if (!(PicoOpt&4) || Pico.m.z80Run == 0) line_to_r = 0;\r
+ else {\r
+ extern const unsigned short vcounts[];\r
+ if (z80startCycle) {\r
+ line = vcounts[z80startCycle>>8];\r
+ if (line > line_from)\r
+ line_from_r = line;\r
+ }\r
+ z80startCycle = SekCyclesDone();\r
+ }\r
\r
- if(PicoOpt&1) {\r
+ if (PicoOpt&1) {\r
// we have ym2612 enabled, so we have to run Z80 in lines, so we could update DAC and timers\r
- for(; line < line_to; line++) {\r
+ for (line = line_from; line < line_to; line++) {\r
sound_timers_and_dac(line);\r
- if((line == 224 || line == line_sample) && PsndOut) getSamples(line);\r
- if(line == 32 && PsndOut) emustatus &= ~1;\r
- if(line >= line_from_r && line < line_to_r)\r
+ if ((line == 224 || line == line_sample) && PsndOut) getSamples(line);\r
+ if (line == 32 && PsndOut) emustatus &= ~1;\r
+ if (line >= line_from_r && line < line_to_r)\r
z80_run(228);\r
}\r
- } else if(line_to_r-line_from_r > 0) {\r
+ } else if (line_to_r-line_from_r > 0) {\r
z80_run(228*(line_to_r-line_from_r));\r
// samples will be taken by caller\r
}\r
Pico.video.status|=0x200;\r
\r
Pico.m.scanline=-1;\r
+ z80startCycle=0;\r
\r
SekCyclesReset();\r
\r
if(sects) {\r
int c = sects*cycles_68k_block;\r
\r
- lines += sects*lines_step;\r
- PicoRunZ80Simple(line, lines);\r
- // this is for approriate line counter, etc\r
+ // this "run" is for approriate line counter, etc\r
SekCycleCnt += c;\r
SekCycleAim += c;\r
+\r
+ lines += sects*lines_step;\r
+ PicoRunZ80Simple(line, lines);\r
}\r
\r
// here we render sound if ym2612 is disabled\r