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);
#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
// also clear the internal registers+addr line\r
ym2612_regs = YM2612GetRegs();\r
memset(ym2612_regs, 0, 0x200+4);\r
- // setting these to 0 might confuse timing code,\r
- // so better set to something like this instead\r
- z80startCycle = z80stopCycle = 0x01000000;\r
+ z80startCycle = z80stopCycle = 0;\r
\r
sound_rerate(0);\r
}\r