|
|
| version 1.9, 2004/08/13 06:49:31 | version 1.13, 2004/08/20 23:01:16 |
|---|---|
| Line 4 | Line 4 |
| #include "iocore.h" | #include "iocore.h" |
| #include "nevent.h" | #include "nevent.h" |
| #include "vram.h" | #include "vram.h" |
| #include "makescrn.h" | |
| #include "font.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) { | static UINT pcg_offset(void) { |
| if (tram[TRAM_ATR + 0x07ff] & 0x20) { | if (tram[TRAM_ATR + 0x07ff] & 0x20) { |
| Line 52 static UINT nowsyncoffset(UINT *line) { | Line 72 static UINT nowsyncoffset(UINT *line) { |
| if (corestat.vsync) { | if (corestat.vsync) { |
| clock += corestat.dispclock; | clock += corestat.dispclock; |
| } | } |
| v = clock / RASTER_CLOCK; | clock = clock << 8; |
| h = clock - (v * RASTER_CLOCK); | v = clock / crtc.e.rasterclock8; |
| h = clock - (v * crtc.e.rasterclock8); | |
| if (crtc.s.SCRN_BITS & SCRN_24KHZ) { | |
| v = v >> 1; | |
| } | |
| ret = v / crtc.e.fonty; | ret = v / crtc.e.fonty; |
| *line = (v - (ret * crtc.e.fonty)) & 7; | *line = (v - (ret * crtc.e.fonty)) & 7; |
| ret = (ret * crtc.s.reg[CRTCREG_HDISP]) + crtc.e.pos; | ret = (ret * crtc.s.reg[CRTCREG_HDISP]) + crtc.e.pos; |
| ret += (h * crtc.s.reg[CRTCREG_HDISP]) / RASTER_CLOCK; | ret += (h * crtc.s.reg[CRTCREG_HDISP]) / crtc.e.rasterclock8; |
| if (ret >= 0x0800) { | if (ret >= 0x0800) { |
| ret = 0x07ff; // オーバーフロー | ret = 0x07ff; // オーバーフロー |
| } | } |
| Line 72 void IOOUTCALL pcg_o(UINT port, REG8 val | Line 96 void IOOUTCALL pcg_o(UINT port, REG8 val |
| UINT line; | UINT line; |
| if (crtc.s.SCRN_BITS & SCRN_PCGMODE) { | if (crtc.s.SCRN_BITS & SCRN_PCGMODE) { |
| waithsync(); | |
| off = pcg_offset(); | off = pcg_offset(); |
| chr = tram[TRAM_ANK + off]; | chr = tram[TRAM_ANK + off]; |
| if (tram[TRAM_KNJ + off] & 0x90) { | if (tram[TRAM_KNJ + off] & 0x90) { |
| Line 87 void IOOUTCALL pcg_o(UINT port, REG8 val | Line 112 void IOOUTCALL pcg_o(UINT port, REG8 val |
| chr = tram[TRAM_ANK + off]; | chr = tram[TRAM_ANK + off]; |
| } | } |
| chr += (port & 0x0300) - 0x100; | 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) { | REG8 IOINPCALL pcg_i(UINT port) { |
| BRESULT ank; | UINT upper; |
| UINT line; | UINT line; |
| UINT off; | UINT off; |
| UINT chr; | UINT chr; |
| UINT knj; | UINT knj; |
| UINT addr; | UINT addr; |
| ank = ((port & 0xff00) == 0x1400); | upper = port & 0x0300; |
| if (crtc.s.SCRN_BITS & SCRN_PCGMODE) { | if (crtc.s.SCRN_BITS & SCRN_PCGMODE) { |
| waithsync(); | |
| line = port & 0x0f; | line = port & 0x0f; |
| if (ank) { | if (!upper) { |
| off = knj_offset(); | off = knj_offset(); |
| chr = tram[TRAM_ANK + off]; | chr = tram[TRAM_ANK + off]; |
| knj = tram[TRAM_KNJ + off]; | knj = tram[TRAM_KNJ + off]; |
| Line 135 REG8 IOINPCALL pcg_i(UINT port) { | Line 164 REG8 IOINPCALL pcg_i(UINT port) { |
| off = nowsyncoffset(&line); | off = nowsyncoffset(&line); |
| chr = tram[TRAM_ANK + off]; | chr = tram[TRAM_ANK + off]; |
| } | } |
| if (ank) { | if (!upper) { |
| return(font_ank[(chr << 3) + line]); | return(font_ank[(chr << 3) + line]); |
| } | } |
| else { | else { |
| chr += (port & 0x0300) - 0x100; | chr += upper - 0x100; |
| return(pcg.d[(chr << 3) + line]); | return(pcg.d[(chr << 3) + line]); |
| } | } |
| } | } |