-// Simple frame without H-Ints\r
-static int PicoFrameSimple(void)\r
-{\r
- struct PicoVideo *pv=&Pico.video;\r
- int y=0,lines_step=0,sects,line_last;\r
- int cycles_68k_vblock,cycles_68k_block;\r
-\r
- // split to 16 run calls for active scan, for vblank split to 2 (ntsc), 3 (pal 240), 4 (pal 224)\r
- if (Pico.m.pal)\r
- {\r
- if(pv->reg[1]&8) { // 240 lines\r
- cycles_68k_block = 7308;\r
- cycles_68k_vblock = 11694;\r
- lines_step = 15;\r
- } else {\r
- cycles_68k_block = 6821;\r
- cycles_68k_vblock = 10719;\r
- lines_step = 14;\r
- }\r
- line_last = 312-1;\r
- } else {\r
- // M68k cycles/frame: 127840.71\r
- cycles_68k_block = 6841; // (488*224+148)/16.0, -4\r
- cycles_68k_vblock = 9164; // (38*488-148-68)/2.0, 0\r
- lines_step = 14;\r
- line_last = 262-1;\r
- }\r
-\r
- // a hack for VR, to get it running in fast mode\r
- if (PicoAHW & PAHW_SVP)\r
- Pico.ram[0xd864^1] = 0x1a;\r
-\r
- // we don't emulate DMA timing in this mode\r
- if (Pico.m.dma_xfers) {\r
- Pico.m.dma_xfers=0;\r
- Pico.video.status&=~2;\r
- }\r
-\r
- // VDP FIFO too\r
- pv->lwrite_cnt = 0;\r
- Pico.video.status|=0x200;\r
-\r
- Pico.m.scanline=-1;\r
- PsndDacLine = 0;\r
-\r
- SekCyclesReset();\r
- z80_resetCycles();\r
- timers_cycle();\r
-\r
- // 6 button pad: let's just say it timed out now\r
- Pico.m.padTHPhase[0]=Pico.m.padTHPhase[1]=0;\r
-\r
- // ---- Active Scan ----\r
- pv->status&=~0x88; // clear V-Int, come out of vblank\r
-\r
- // Run in sections:\r
- for (sects=16; sects; sects--)\r
- {\r
- if (CheckIdle()) break;\r
-\r
- SekRunM68k(cycles_68k_block);\r
- if (PicoLineHook) PicoLineHook(lines_step);\r
- }\r
-\r
- // do remaining sections without 68k\r
- if (sects) {\r
- SekCycleCnt += sects * cycles_68k_block;\r
- SekCycleAim += sects * cycles_68k_block;\r
-\r
- if (PicoLineHook) PicoLineHook(sects*lines_step);\r
- }\r
-\r
- // another hack for VR (it needs hints to work)\r
- if (PicoAHW & PAHW_SVP) {\r
- Pico.ram[0xd864^1] = 1;\r
- pv->pending_ints|=0x10;\r
- if (pv->reg[0]&0x10) SekInterrupt(4);\r
- SekRunM68k(160);\r
- }\r
-\r
- // render screen\r
- if (!PicoSkipFrame)\r
- {\r
- if (!(PicoOpt&POPT_ALT_RENDERER))\r
- {\r
- // Draw the screen\r
-#if CAN_HANDLE_240_LINES\r
- if (pv->reg[1]&8) {\r
- for (y=0;y<240;y++) PicoLine(y);\r
- } else {\r
- for (y=0;y<224;y++) PicoLine(y);\r
- }\r
-#else\r
- for (y=0;y<224;y++) PicoLine(y);\r
-#endif\r
- }\r
- else PicoFrameFull();\r
-#ifdef DRAW_FINISH_FUNC\r
- DRAW_FINISH_FUNC();\r
-#endif\r
- }\r
-\r
- // a gap between flags set and vint\r
- pv->pending_ints|=0x20;\r
- pv->status|=8; // go into vblank\r
- SekRunM68k(68+4);\r
-\r
- if (Pico.m.z80Run && (PicoOpt&POPT_EN_Z80))\r
- PicoSyncZ80(SekCycleCnt);\r
-\r
- // render sound\r
- if (PsndOut)\r
- {\r
- int len;\r
- if (ym2612.dacen && PsndDacLine <= lines_step*16)\r
- PsndDoDAC(lines_step*16);\r
- len = PsndRender(0, PsndLen);\r
- if (PicoWriteSound) PicoWriteSound(len);\r
- // clear sound buffer\r
- PsndClear();\r
- }\r
-\r
- // ---- V-Blanking period ----\r
- // fix line counts\r
- if(Pico.m.pal) {\r
- if(pv->reg[1]&8) { // 240 lines\r
- sects = 3;\r
- lines_step = 24;\r
- } else {\r
- sects = 4;\r
- lines_step = 22;\r
- }\r
- } else {\r
- sects = 2;\r
- lines_step = 19;\r
- }\r
-\r
- if (pv->reg[1]&0x20) SekInterrupt(6); // Set IRQ\r
- if (Pico.m.z80Run && (PicoOpt&POPT_EN_Z80))\r
- z80_int();\r
-\r
- while (1)\r
- {\r
- SekRunM68k(cycles_68k_vblock);\r
- if (PicoLineHook) PicoLineHook(lines_step);\r
-\r
- sects--;\r
- if (sects == 0) break;\r
- if (CheckIdle()) break;\r
- }\r
-\r
- if (sects) {\r
- SekCycleCnt += sects * cycles_68k_vblock;\r
- SekCycleAim += sects * cycles_68k_vblock;\r
- if (PicoLineHook) PicoLineHook(sects*lines_step);\r
- }\r
-\r
- // must sync z80 before return, and extend last DAC sample\r
- if (Pico.m.z80Run && (PicoOpt&POPT_EN_Z80))\r
- PicoSyncZ80(SekCycleCnt);\r
- if (PsndOut && ym2612.dacen && PsndDacLine <= line_last)\r
- PsndDoDAC(line_last);\r
-\r
- return 0;\r
-}\r
-\r
-int PicoFrame(void)\r