--- xmil/io/pcg.c 2004/08/14 12:16:17 1.10 +++ xmil/io/pcg.c 2004/08/20 23:01:16 1.13 @@ -4,9 +4,29 @@ #include "iocore.h" #include "nevent.h" #include "vram.h" +#include "makescrn.h" #include "font.h" +static void waithsync(void) { + + SINT32 clock; + SINT32 h; + +// 必ず hsyncを待つ? +// if (corestat.vsync) { +// return; +// } + clock = nevent_getwork(NEVENT_FRAMES) << 8; + h = clock % crtc.e.rasterclock8; + h = crtc.e.rasterdisp8 - h; + if (h < 0) { + h += crtc.e.rasterclock8; + } + CPU_REMCLOCK -= (h >> 8); +} + + static UINT pcg_offset(void) { if (tram[TRAM_ATR + 0x07ff] & 0x20) { @@ -76,6 +96,7 @@ void IOOUTCALL pcg_o(UINT port, REG8 val UINT line; if (crtc.s.SCRN_BITS & SCRN_PCGMODE) { + waithsync(); off = pcg_offset(); chr = tram[TRAM_ANK + off]; if (tram[TRAM_KNJ + off] & 0x90) { @@ -91,7 +112,10 @@ void IOOUTCALL pcg_o(UINT port, REG8 val chr = tram[TRAM_ANK + off]; } chr += (port & 0x0300) - 0x100; - pcg.d[(chr << 3) + line] = value; + if (pcg.d[(chr << 3) + line] != value) { + pcg.d[(chr << 3) + line] = value; + scrnallflash = TRUE; + } } REG8 IOINPCALL pcg_i(UINT port) { @@ -105,6 +129,7 @@ REG8 IOINPCALL pcg_i(UINT port) { upper = port & 0x0300; if (crtc.s.SCRN_BITS & SCRN_PCGMODE) { + waithsync(); line = port & 0x0f; if (!upper) { off = knj_offset();