- for (y=0;y<lines;y++)
- {
- Pico.m.scanline=(short)y;
-
- // pad delay (for 6 button pads)
- if(PicoOpt&0x20) {
- if(Pico.m.padDelay[0]++ > 25) Pico.m.padTHPhase[0]=0;
- if(Pico.m.padDelay[1]++ > 25) Pico.m.padTHPhase[1]=0;
- }
-
- check_cd_dma();
-
- // H-Interrupts:
- if(y <= lines_vis && --hint < 0) // y <= lines_vis: Comix Zone, Golden Axe
- {
- //dprintf("rhint:old @ %06x", SekPc);
- hint=pv->reg[10]; // Reload H-Int counter
- pv->pending_ints|=0x10;
- if (pv->reg[0]&0x10) SekInterrupt(4);
- //dprintf("rhint: %i @ %06x [%i|%i]", hint, SekPc, y, SekCycleCnt);
- //dprintf("hint_routine: %x", (*(unsigned short*)(Pico.ram+0x0B84)<<16)|*(unsigned short*)(Pico.ram+0x0B86));
- }
-
- // V-Interrupt:
- if (y == lines_vis)
- {
- //dprintf("vint: @ %06x [%i|%i]", SekPc, y, SekCycleCnt);
- pv->status|=0x88; // V-Int happened, go into vblank
- SekRun(128); SekCycleAim-=128; // there must be a gap between H and V ints, also after vblank bit set (Mazin Saga, Bram Stoker's Dracula)
- /*if(Pico.m.z80Run && (PicoOpt&4)) {
- z80CycleAim+=cycles_z80/2;
- total_z80+=z80_run(z80CycleAim-total_z80);
- z80CycleAim-=cycles_z80/2;
- }*/
- pv->pending_ints|=0x20;
- if(pv->reg[1]&0x20) SekInterrupt(6);
- if(Pico.m.z80Run && (PicoOpt&4)) // ?
- z80_int();
- //dprintf("zint: [%i|%i] zPC=%04x", Pico.m.scanline, SekCyclesDone(), mz80GetRegisterValue(NULL, 0));
- }
-
- // decide if we draw this line
-#if CAN_HANDLE_240_LINES
- if(!skip && ((!(pv->reg[1]&8) && y<224) || ((pv->reg[1]&8) && y<240)) )
-#else
- if(!skip && y<224)
-#endif
- PicoLine(y);
-
- if(PicoOpt&1)
- sound_timers_and_dac(y);
-
- // get samples from sound chips
- if (y == 224 && PsndOut) {
- int len = sound_render(0, PsndLen);
- if (PicoWriteSound) PicoWriteSound(len);
- // clear sound buffer
- sound_clear();
- }
-
- // Run scanline:
- //dprintf("m68k starting exec @ %06x", SekPc);
- if(Pico.m.dma_bytes) SekCycleCnt+=CheckDMA();
- SekRun(cycles_68k);
- if ((Pico_mcd->m.busreq&3) == 1) { // no busreq/no reset
-#if 0
- int i;
- FILE *f = fopen("prg_ram.bin", "wb");
- for (i = 0; i < 0x80000; i+=2)
- {
- int tmp = Pico_mcd->prg_ram[i];
- Pico_mcd->prg_ram[i] = Pico_mcd->prg_ram[i+1];
- Pico_mcd->prg_ram[i+1] = tmp;
- }
- fwrite(Pico_mcd->prg_ram, 1, 0x80000, f);
- fclose(f);
- exit(1);