| version 1.9, 2004/08/12 17:57:36 | version 1.12, 2004/08/13 02:16:33 | 
| Line 1 | Line 1 | 
 | #include        "compiler.h" | #include        "compiler.h" | 
 | #include        "scrnmng.h" | #include        "scrnmng.h" | 
 |  | #include        "z80core.h" | 
 | #include        "pccore.h" | #include        "pccore.h" | 
 | #include        "iocore.h" | #include        "iocore.h" | 
 | #include        "vram.h" | #include        "vram.h" | 
| Line 20  static const UINT16 defpalgrph[64] = { | Line 21  static const UINT16 defpalgrph[64] = { | 
 | 0x550, 0x55a, 0x5f0, 0x5fa, 0xf50, 0xf5a, 0xff0, 0xffa, | 0x550, 0x55a, 0x5f0, 0x5fa, 0xf50, 0xf5a, 0xff0, 0xffa, | 
 | 0x555, 0x55f, 0x5f5, 0x5ff, 0xf55, 0xf5f, 0xff5, 0xfff}; | 0x555, 0x55f, 0x5f5, 0x5ff, 0xf55, 0xf5f, 0xff5, 0xfff}; | 
 |  |  | 
| static const CRTCSTAT crtcdefault = { | static const UINT8 defrgbp[4] = {0xaa, 0xcc, 0xf0, 0x00}; | 
| {0xaa, 0xcc, 0xf0, 0x00},       // rgbp | static const UINT8 defreg[18] = { | 
| 0,                                                      // SCRN_BITS | 55, 40, 45, 0x36, | 
| 0,                                                      // CRTC_NUM | 31, 10, 25, 28, | 
|  | 7, 7, 0, 0, | 
| 7,                                                      // _FNT_YL | 0, 0, 0, 0, 0, 0}; | 
| 40,                                                     // TXT_XL |  | 
| 25,                                                     // TXT_YL |  | 
| 28,                                                     // TXT_YS |  | 
|  |  | 
| //                              200,                                            // CRT_YL |  | 
| //                              232,                                            // CRT_VS |  | 
| //                              266,                                            // CRT_VL |  | 
|  |  | 
| 31,                                                     // TXT_VL |  | 
| 10,                                                     // TXT_VLA |  | 
|  |  | 
| 0,                                                      // TXT_TOP |  | 
| //                              8,                                                      // fnty |  | 
|  |  | 
| 0,                                                      // lastpal |  | 
|  |  | 
| 0,                                                      // BLACKPAL |  | 
| 0,                                                      // EXTPALMODE |  | 
| 0,                                                      // EXTGRPHPAL |  | 
| 0,                                                      // ZPRY |  | 
| }; |  | 
 |  |  | 
 |  |  | 
 | void crtc_bankupdate(void) { | void crtc_bankupdate(void) { | 
| Line 69  void crtc_bankupdate(void) { | Line 49  void crtc_bankupdate(void) { | 
 |  |  | 
 | if ((!(crtc.s.EXTPALMODE & 0x80)) || (crtc.s.SCRN_BITS & SCRN_UNDERLINE)) { | if ((!(crtc.s.EXTPALMODE & 0x80)) || (crtc.s.SCRN_BITS & SCRN_UNDERLINE)) { | 
 | updatemask = 0x7ff; | updatemask = 0x7ff; | 
| if ((crtc.s.SCRN_BITS & SCRN_24KHZ) && (crtc.s.TXT_XL == 80)) { | if ((crtc.s.SCRN_BITS & SCRN_24KHZ) && | 
|  | (crtc.s.reg[CRTCREG_HDISP] == 80)) { | 
 | pal_bank = pal_disp = PAL_HIGHRESO; | pal_bank = pal_disp = PAL_HIGHRESO; | 
 | } | } | 
 | if (crtc.s.SCRN_BITS & SCRN_TEXTYx2) { | if (crtc.s.SCRN_BITS & SCRN_TEXTYx2) { | 
| Line 80  void crtc_bankupdate(void) { | Line 61  void crtc_bankupdate(void) { | 
 | updatemask = 0x3ff; | updatemask = 0x3ff; | 
 | if (!(crtc.s.SCRN_BITS & SCRN_TEXTYx2)) { | if (!(crtc.s.SCRN_BITS & SCRN_TEXTYx2)) { | 
 | if (crtc.s.SCRN_BITS & SCRN_24KHZ) { | if (crtc.s.SCRN_BITS & SCRN_24KHZ) { | 
| if (crtc.s.TXT_XL == 40) { | if (crtc.s.reg[CRTCREG_HDISP] == 40) { | 
 | if (crtc.s.SCRN_BITS & SCRN_200LINE) {  // width 40,25,0,2 | if (crtc.s.SCRN_BITS & SCRN_200LINE) {  // width 40,25,0,2 | 
 | dispmode |= SCRN64_320x200; | dispmode |= SCRN64_320x200; | 
 | } | } | 
| Line 94  void crtc_bankupdate(void) { | Line 75  void crtc_bankupdate(void) { | 
 | } | } | 
 | } | } | 
 | else { | else { | 
| if (crtc.s.TXT_XL == 40) {                                      // width 40,25,0,1 | if (crtc.s.reg[CRTCREG_HDISP] == 40) {          // width 40,25,0,1 | 
 | if (crtc.s.EXTPALMODE & 0x10) { | if (crtc.s.EXTPALMODE & 0x10) { | 
 | if (crtc.s.ZPRY & 0x10) { | if (crtc.s.ZPRY & 0x10) { | 
 | dispmode = SCRN64_L320x200x2 | | dispmode = SCRN64_L320x200x2 | | 
| Line 125  void crtc_bankupdate(void) { | Line 106  void crtc_bankupdate(void) { | 
 | } | } | 
 | else { | else { | 
 | if (crtc.s.SCRN_BITS & SCRN_24KHZ) { | if (crtc.s.SCRN_BITS & SCRN_24KHZ) { | 
| if (crtc.s.TXT_XL == 40) { | if (crtc.s.reg[CRTCREG_HDISP] == 40) { | 
 | if (crtc.s.SCRN_BITS & SCRN_200LINE) {  // width 40,12,0,2 | if (crtc.s.SCRN_BITS & SCRN_200LINE) {  // width 40,12,0,2 | 
 | dispmode |= SCRN64_320x100; | dispmode |= SCRN64_320x100; | 
 | } | } | 
| Line 138  void crtc_bankupdate(void) { | Line 119  void crtc_bankupdate(void) { | 
 | } | } | 
 | } | } | 
 | else { | else { | 
| if (crtc.s.TXT_XL == 40) {                                      // width 40,12,0,1 | if (crtc.s.reg[CRTCREG_HDISP] == 40) {          // width 40,12,0,1 | 
 | if (crtc.s.EXTPALMODE & 0x10) { | if (crtc.s.EXTPALMODE & 0x10) { | 
 | if (crtc.s.ZPRY & 0x10) { | if (crtc.s.ZPRY & 0x10) { | 
 | dispmode = SCRN64_320x100x2 | | dispmode = SCRN64_320x100x2 | | 
| Line 176  void crtc_bankupdate(void) { | Line 157  void crtc_bankupdate(void) { | 
 | void crtc_regupdate(void) { | void crtc_regupdate(void) { | 
 |  |  | 
 | UINT    fonty; | UINT    fonty; | 
 |  | SINT32  fontyclock; | 
 |  |  | 
| fonty = crtc.s._FNT_YL; | crtc.e.pos = crtc.s.reg[CRTCREG_POSL] | 
|  | + ((crtc.s.reg[CRTCREG_POSH] & 7) << 8); | 
|  |  | 
|  | fonty = crtc.s.reg[CRTCREG_CHRCY] & 0x1f; | 
 | if (crtc.s.SCRN_BITS & SCRN_24KHZ) { | if (crtc.s.SCRN_BITS & SCRN_24KHZ) { | 
 | fonty >>= 1; | fonty >>= 1; | 
 | } | } | 
 | fonty += 1; | fonty += 1; | 
 | crtc.e.fonty = fonty; | crtc.e.fonty = fonty; | 
| crtc.e.yl = (crtc.s.TXT_YL & 0x7f); | crtc.e.yl = (crtc.s.reg[CRTCREG_VDISP] & 0x7f); | 
 |  |  | 
| crtc.e.dl = fonty * crtc.e.yl; | fontyclock = fonty * RASTER_CLOCK; | 
| crtc.e.vs = fonty * ((crtc.s.TXT_YS & 0x7f) + 1); | crtc.e.dispclock = fontyclock * crtc.e.yl; | 
| crtc.e.vl = fonty * ((crtc.s.TXT_VL & 0x7f) + 1) + (crtc.s.TXT_VLA & 0x1f); | // YsIIIが yl==0で disp信号見る…なんで? | 
|  | if (!crtc.e.dispclock) { | 
|  | crtc.e.dispclock = fontyclock; | 
|  | } | 
|  | crtc.e.vsyncstart = fontyclock * ((crtc.s.reg[CRTCREG_VSYNC] & 0x7f) + 1); | 
|  | crtc.e.vpulseclock = (crtc.s.reg[CRTCREG_PULSE] >> 4) * RASTER_CLOCK; | 
|  | crtc.e.vl = fonty * ((crtc.s.reg[CRTCREG_VSIZE] & 0x7f) + 1) | 
|  | + (crtc.s.reg[CRTCREG_VSIZEA] & 0x1f); | 
 | } | } | 
 |  |  | 
 |  |  | 
| Line 197  void IOOUTCALL crtc_o(UINT port, REG8 va | Line 189  void IOOUTCALL crtc_o(UINT port, REG8 va | 
 |  |  | 
 | port &= 0xff; | port &= 0xff; | 
 | if (port == 0) { | if (port == 0) { | 
| crtc.s.CRTC_NUM = value; | crtc.s.regnum = value; | 
 | } | } | 
 | else if (port == 1) { | else if (port == 1) { | 
| switch(crtc.s.CRTC_NUM) { | if (crtc.s.regnum < CRTCREG_MAX) { | 
| case 0x01: | if (crtc.s.reg[crtc.s.regnum] != value) { | 
| if (value <= 40) { | crtc.s.reg[crtc.s.regnum] = value; | 
| crtc.s.TXT_XL = 40; |  | 
| } |  | 
| else { |  | 
| crtc.s.TXT_XL = 80; |  | 
| } |  | 
 | crtc_bankupdate(); | crtc_bankupdate(); | 
 | break; |  | 
 |  |  | 
 | case 0x04: |  | 
 | crtc.s.TXT_VL = value; |  | 
 | break; |  | 
 |  |  | 
 | case 0x05: |  | 
 | crtc.s.TXT_VLA = value; |  | 
 | break; |  | 
 |  |  | 
 | case 0x06: |  | 
 | crtc.s.TXT_YL = value; |  | 
 | break; |  | 
 |  |  | 
 | case 0x07: |  | 
 | crtc.s.TXT_YS = value; |  | 
 | break; |  | 
 |  |  | 
 | case 0x09: |  | 
 | crtc.s._FNT_YL = value; |  | 
 | break; |  | 
 |  |  | 
 | case 0x0c: |  | 
 | crtc.s.TXT_TOP &= 0xff; |  | 
 | crtc.s.TXT_TOP |= (value & 7) << 8; |  | 
 | makescrn.remakeattr = 1; | makescrn.remakeattr = 1; | 
| break; | crtc_regupdate(); | 
|  | scrnallflash = 1; | 
| case 0x0d: | } | 
| crtc.s.TXT_TOP &= 0x700; |  | 
| crtc.s.TXT_TOP |= value; |  | 
| makescrn.remakeattr = 1; |  | 
| break; |  | 
|  |  | 
| default: |  | 
| return; |  | 
 | } | } | 
 | //              crtc.s.GRP_XL = crtc.s.TXT_XL << 3; |  | 
 | //              crtc.s.GRP_YL = 200; |  | 
 | crtc_regupdate(); |  | 
 | scrnallflash = 1;                                                               /* 990220 puni */ |  | 
 | } | } | 
 | } | } | 
 |  |  | 
| Line 488  void crtc_initialize(void) { | Line 439  void crtc_initialize(void) { | 
 |  |  | 
 | void crtc_reset(void) { | void crtc_reset(void) { | 
 |  |  | 
| crtc.s = crtcdefault; | ZeroMemory(&crtc, sizeof(crtc)); | 
|  | CopyMemory(crtc.s.rgbp, defrgbp, 4); | 
|  | CopyMemory(crtc.s.reg, defreg, 18); | 
 | if (pccore.ROM_TYPE < 3) { | if (pccore.ROM_TYPE < 3) { | 
 | resetpal(); | resetpal(); | 
 | } | } | 
 | if ((pccore.ROM_TYPE >= 2) && (!(pccore.DIP_SW & 1))) { | if ((pccore.ROM_TYPE >= 2) && (!(pccore.DIP_SW & 1))) { | 
 | crtc.s.SCRN_BITS = SCRN_200LINE; | crtc.s.SCRN_BITS = SCRN_200LINE; | 
| crtc.s._FNT_YL = 15; | crtc.s.reg[CRTCREG_CHRCY] = 15; | 
 | } | } | 
 |  |  | 
 | pal_reset(); | pal_reset(); | 
| Line 506  void crtc_reset(void) { | Line 459  void crtc_reset(void) { | 
 |  |  | 
 | void crtc_forcesetwidth(REG8 width) { | void crtc_forcesetwidth(REG8 width) { | 
 |  |  | 
| crtc.s.TXT_XL = (UINT8)width; | crtc.s.reg[CRTCREG_HDISP] = (UINT8)width; | 
 | crtc_bankupdate(); | crtc_bankupdate(); | 
 | scrnallflash = 1; | scrnallflash = 1; | 
 | } | } |