--- xmil/io/pcg.c 2004/08/04 17:09:25 1.4 +++ xmil/io/pcg.c 2004/08/12 20:09:42 1.7 @@ -2,6 +2,7 @@ #include "z80core.h" #include "pccore.h" #include "iocore.h" +#include "nevent.h" #include "vram.h" #include "font.h" @@ -48,14 +49,22 @@ static UINT knj_offset(void) { static UINT nowsyncoffset(void) { + SINT32 clock; + UINT h; + UINT v; UINT ret; + UINT line; - ret = (((v_cnt - crtc.s.CRT_YL) / crtc.s.fnty) + crtc.s.TXT_YL) - * crtc.s.TXT_XL + crtc.s.TXT_TOP; - if (pccore.HSYNC_CLK) { - ret += (h_cnt * crtc.s.TXT_XL) / pccore.HSYNC_CLK; - } - + clock = nevent_getwork(NEVENT_FRAMES); + if (corestat.vsync) { + clock += corestat.dispclock; + } + v = clock / RASTER_CLOCK; + h = clock - (v * RASTER_CLOCK); + ret = v / crtc.e.fonty; + line = v - (ret * crtc.e.fonty); + ret = (ret * crtc.s.reg[CRTCREG_HDISP]) + crtc.e.pos; + ret += (h * crtc.s.reg[CRTCREG_HDISP]) / RASTER_CLOCK; if (ret >= 0x0800) { ret = 0x07ff; // オーバーフロー }