|
|
| version 1.6, 2004/08/08 15:14:08 | version 1.9, 2004/08/12 17:57:36 |
|---|---|
| Line 21 static const UINT16 defpalgrph[64] = { | Line 21 static const UINT16 defpalgrph[64] = { |
| 0x555, 0x55f, 0x5f5, 0x5ff, 0xf55, 0xf5f, 0xff5, 0xfff}; | 0x555, 0x55f, 0x5f5, 0x5ff, 0xf55, 0xf5f, 0xff5, 0xfff}; |
| static const CRTCSTAT crtcdefault = { | static const CRTCSTAT crtcdefault = { |
| 0xaa, // PAL_B; | {0xaa, 0xcc, 0xf0, 0x00}, // rgbp |
| 0xcc, // PAL_R; | |
| 0xf0, // PAL_G; | |
| 0x00, // PLY | |
| // {0, 1, 2, 3, 4, 5, 6, 7}, // TEXT_PAL[8] | |
| 0, // SCRN_BITS | 0, // SCRN_BITS |
| 0, // CRTC_NUM | 0, // CRTC_NUM |
| 0, // DISP_PAGE | 7, // _FNT_YL |
| 8, // FNT_XL | |
| 8, // FNT_YL | |
| 40, // TXT_XL | 40, // TXT_XL |
| 25, // TXT_YL | 25, // TXT_YL |
| 28, // TXT_YS | 28, // TXT_YS |
| 320, // GRP_XL | |
| 200, // GRP_YL | // 200, // CRT_YL |
| // 0, // CPU_BANK | // 232, // CRT_VS |
| // 0, // CRT_BANK | // 266, // CRT_VL |
| 200, // CRT_YL | |
| 232, // CRT_VS | |
| 266, // CRT_VL | |
| 31, // TXT_VL | 31, // TXT_VL |
| 10, // TXT_VLA | 10, // TXT_VLA |
| 0, // TXT_TOP | 0, // TXT_TOP |
| 8, // fnty | // 8, // fnty |
| 0, // lastpal | 0, // lastpal |
| Line 58 static const CRTCSTAT crtcdefault = { | Line 48 static const CRTCSTAT crtcdefault = { |
| 0, // ZPRY | 0, // ZPRY |
| }; | }; |
| BYTE dispmode = SCRN64_INVALID; | |
| BYTE pal_bank = PAL_NORMAL; | |
| BYTE pal_disp = PAL_NORMAL; | |
| void vrambank_patch(void) { | void crtc_bankupdate(void) { |
| UINT updatemask; | UINT updatemask; |
| UINT8 dispmode; | |
| UINT8 pal_bank; | |
| UINT8 pal_disp; | |
| if (crtc.s.SCRN_BITS & 0x10) { | if (crtc.s.SCRN_BITS & 0x10) { |
| crtc.e.gram = GRP_RAM + GRAM_BANK1; | crtc.e.gram = gram + GRAM_BANK1; |
| crtc.e.updatebit = UPDATE_VRAM1; | crtc.e.updatebit = UPDATE_VRAM1; |
| } | } |
| else { | else { |
| crtc.e.gram = GRP_RAM + GRAM_BANK0; | crtc.e.gram = gram + GRAM_BANK0; |
| crtc.e.updatebit = UPDATE_VRAM0; | crtc.e.updatebit = UPDATE_VRAM0; |
| } | } |
| dispmode = (crtc.s.SCRN_BITS & SCRN_DISPVRAM)?SCRN_BANK1:SCRN_BANK0; | dispmode = (crtc.s.SCRN_BITS & SCRN_DISPVRAM)?SCRN_BANK1:SCRN_BANK0; |
| Line 178 void vrambank_patch(void) { | Line 168 void vrambank_patch(void) { |
| } | } |
| } | } |
| crtc.e.updatemask = updatemask; | crtc.e.updatemask = updatemask; |
| crtc.e.dispmode = dispmode; | |
| crtc.e.pal_bank = pal_bank; | |
| crtc.e.pal_disp = pal_disp; | |
| } | } |
| static void crtc_updt(void) { | void crtc_regupdate(void) { |
| UINT fonty; | |
| fonty = crtc.s._FNT_YL; | |
| if (crtc.s.SCRN_BITS & SCRN_24KHZ) { | if (crtc.s.SCRN_BITS & SCRN_24KHZ) { |
| crtc.s.fnty = (crtc.s.FNT_YL >> 1) & 0xfffe; | fonty >>= 1; |
| } | |
| else { | |
| crtc.s.fnty = crtc.s.FNT_YL & 0xfffe; | |
| } | |
| if (crtc.s.TXT_YL) { | |
| crtc.s.CRT_YL = crtc.s.fnty * crtc.s.TXT_YL; | |
| } | |
| else { | |
| crtc.s.CRT_YL = crtc.s.fnty * 1; | |
| } | } |
| crtc.s.CRT_VS = crtc.s.fnty * (crtc.s.TXT_YS + 1); | fonty += 1; |
| crtc.s.CRT_VL = (crtc.s.TXT_VL + 1) * crtc.s.fnty + crtc.s.TXT_VLA; | crtc.e.fonty = fonty; |
| // TRACEOUT(("set> %d / %d / %d", crtc.s.CRT_YL, crtc.s.CRT_VS, crtc.s.CRT_VL)); | crtc.e.yl = (crtc.s.TXT_YL & 0x7f); |
| crtc.e.dl = fonty * crtc.e.yl; | |
| crtc.e.vs = fonty * ((crtc.s.TXT_YS & 0x7f) + 1); | |
| crtc.e.vl = fonty * ((crtc.s.TXT_VL & 0x7f) + 1) + (crtc.s.TXT_VLA & 0x1f); | |
| } | } |
| Line 204 static void crtc_updt(void) { | Line 195 static void crtc_updt(void) { |
| void IOOUTCALL crtc_o(UINT port, REG8 value) { | void IOOUTCALL crtc_o(UINT port, REG8 value) { |
| if (port == 0x1800) { | port &= 0xff; |
| if (port == 0) { | |
| crtc.s.CRTC_NUM = value; | crtc.s.CRTC_NUM = value; |
| } | } |
| else if (port == 0x1801) { | else if (port == 1) { |
| switch(crtc.s.CRTC_NUM) { | switch(crtc.s.CRTC_NUM) { |
| case 0x01: | case 0x01: |
| if (value <= 40) { | if (value <= 40) { |
| Line 216 void IOOUTCALL crtc_o(UINT port, REG8 va | Line 208 void IOOUTCALL crtc_o(UINT port, REG8 va |
| else { | else { |
| crtc.s.TXT_XL = 80; | crtc.s.TXT_XL = 80; |
| } | } |
| vrambank_patch(); | crtc_bankupdate(); |
| break; | break; |
| case 0x04: | case 0x04: |
| Line 236 void IOOUTCALL crtc_o(UINT port, REG8 va | Line 228 void IOOUTCALL crtc_o(UINT port, REG8 va |
| break; | break; |
| case 0x09: | case 0x09: |
| crtc.s.FNT_YL = (WORD)value+1; | crtc.s._FNT_YL = value; |
| break; | break; |
| case 0x0c: | case 0x0c: |
| Line 246 void IOOUTCALL crtc_o(UINT port, REG8 va | Line 238 void IOOUTCALL crtc_o(UINT port, REG8 va |
| break; | break; |
| case 0x0d: | case 0x0d: |
| crtc.s.TXT_TOP &= 0x7ff; | crtc.s.TXT_TOP &= 0x700; |
| crtc.s.TXT_TOP |= value; | crtc.s.TXT_TOP |= value; |
| makescrn.remakeattr = 1; | makescrn.remakeattr = 1; |
| break; | break; |
| Line 254 void IOOUTCALL crtc_o(UINT port, REG8 va | Line 246 void IOOUTCALL crtc_o(UINT port, REG8 va |
| default: | default: |
| return; | return; |
| } | } |
| crtc.s.GRP_XL = crtc.s.TXT_XL << 3; | // crtc.s.GRP_XL = crtc.s.TXT_XL << 3; |
| crtc.s.GRP_YL = 200; | // crtc.s.GRP_YL = 200; |
| crtc_updt(); | crtc_regupdate(); |
| scrnallflash = 1; /* 990220 puni */ | scrnallflash = 1; /* 990220 puni */ |
| } | } |
| } | } |
| Line 274 void IOOUTCALL scrn_o(UINT port, REG8 va | Line 266 void IOOUTCALL scrn_o(UINT port, REG8 va |
| // pal_reset(); // なんで? | // pal_reset(); // なんで? |
| scrnallflash = 1; | scrnallflash = 1; |
| makescrn.palandply = 1; | makescrn.palandply = 1; |
| crtc_updt(); | crtc_regupdate(); |
| } | } |
| vrambank_patch(); | crtc_bankupdate(); |
| // crtc.s.CPU_BANK = (BYTE)((crtc.s.SCRN_BITS & SCRN_ACCESSVRAM)?1:0); | |
| // crtc.s.CRT_BANK = (BYTE)((crtc.s.SCRN_BITS & SCRN_DISPVRAM)?1:0); | |
| (void)port; | (void)port; |
| } | } |
| Line 293 REG8 IOINPCALL scrn_i(UINT port) { | Line 283 REG8 IOINPCALL scrn_i(UINT port) { |
| void IOOUTCALL ply_o(UINT port, REG8 value) { | void IOOUTCALL ply_o(UINT port, REG8 value) { |
| if (crtc.s.PLY != value) { | if (crtc.s.rgbp[CRTC_PLY] != value) { |
| crtc.s.PLY = value; | crtc.s.rgbp[CRTC_PLY] = value; |
| makescrn.palandply = 1; | makescrn.palandply = 1; |
| } | } |
| (void)port; | (void)port; |
| Line 303 void IOOUTCALL ply_o(UINT port, REG8 val | Line 293 void IOOUTCALL ply_o(UINT port, REG8 val |
| REG8 IOINPCALL ply_i(UINT port) { | REG8 IOINPCALL ply_i(UINT port) { |
| (void)port; | (void)port; |
| return(crtc.s.PLY); | return(crtc.s.rgbp[CRTC_PLY]); |
| } | } |
| Line 321 void IOOUTCALL palette_o(UINT port, REG8 | Line 311 void IOOUTCALL palette_o(UINT port, REG8 |
| return; | return; |
| } | } |
| sft = (port >> (8 - 2)) & (3 << 2); | sft = (port >> (8 - 2)) & (3 << 2); |
| if (pal_bank & PAL_4096) { // use 4096palettes | if (crtc.e.pal_bank & PAL_4096) { // use 4096palettes |
| switch(pal_bank & (PAL_4096FULL | PAL_4096BANK)) { | num = ((port & 0xff) << 4) + (crtc.s.lastpal >> 4); |
| case 0: | if (!(crtc.e.pal_bank & PAL_4096FULL)) { |
| num = ((port & 0xcc) << 4) + ((value & 0xc0) >> 4); | num &= 0xccc; |
| break; | if (crtc.e.pal_bank & PAL_4096BANK) { |
| num >>= 2; | |
| case 1: | } |
| num = ((port & 0xcc) << 2) + ((value & 0xc0) >> 6); | |
| break; | |
| default: | |
| num = ((port & 0xff) << 4) + (crtc.s.lastpal >> 4); | |
| break; | |
| } | } |
| pal = crtc.p.grph4096[num]; | pal = crtc.p.grph4096[num]; |
| pal &= ~((0x0f) << sft); | pal &= ~((0x0f) << sft); |
| Line 344 void IOOUTCALL palette_o(UINT port, REG8 | Line 328 void IOOUTCALL palette_o(UINT port, REG8 |
| else { | else { |
| num = ((port & 0x80) >> 5) | ((port & 0x08) >> 2) | | num = ((port & 0x80) >> 5) | ((port & 0x08) >> 2) | |
| ((value & 0x80) >> 7); | ((value & 0x80) >> 7); |
| if ((dispmode & SCRN64_MASK) == SCRN64_INVALID) { | if ((crtc.e.dispmode & SCRN64_MASK) == SCRN64_INVALID) { |
| num |= (num << 3); | num |= (num << 3); |
| } | } |
| else { | else { |
| num += ((port & 0x40) >> 1) | ((port & 0x04) << 2) | | num += ((port & 0x40) >> 1) | ((port & 0x04) << 2) | |
| ((value & 0x40) >> 3); | ((value & 0x40) >> 3); |
| } | } |
| pal = crtc.p.grph[pal_bank][num]; | pal = crtc.p.grph[crtc.e.pal_bank][num]; |
| pal &= ~((0x0f) << sft); | pal &= ~((0x0f) << sft); |
| pal |= (value & 0x0f) << sft; | pal |= (value & 0x0f) << sft; |
| crtc.p.grph[pal_bank][num] = pal; | crtc.p.grph[crtc.e.pal_bank][num] = pal; |
| pal_setgrph(pal_bank, (REG8)num); | pal_setgrph(crtc.e.pal_bank, (REG8)num); |
| } | } |
| } | } |
| else { | else { |
| switch(port & 0xff00) { | num = (port >> 8) & 3; |
| case 0x1000: | if (crtc.s.rgbp[num] != value) { |
| if (crtc.s.PAL_B != value) { | crtc.s.rgbp[num] = value; |
| crtc.s.PAL_B = value; | makescrn.palandply = 1; |
| makescrn.palandply = 1; | |
| } | |
| break; | |
| case 0x1100: | |
| if (crtc.s.PAL_R != value) { | |
| crtc.s.PAL_R = value; | |
| makescrn.palandply = 1; | |
| } | |
| break; | |
| case 0x1200: | |
| if (crtc.s.PAL_G != value) { | |
| crtc.s.PAL_G = value; | |
| makescrn.palandply = 1; | |
| } | |
| break; | |
| } | } |
| } | } |
| } | } |
| Line 391 REG8 IOINPCALL palette_i(UINT port) { | Line 358 REG8 IOINPCALL palette_i(UINT port) { |
| REG8 sft; | REG8 sft; |
| if ((crtc.s.EXTPALMODE & 0x80) && ((crtc.s.EXTGRPHPAL & 0x88) == 0x88)) { | if ((crtc.s.EXTPALMODE & 0x80) && ((crtc.s.EXTGRPHPAL & 0x88) == 0x88)) { |
| if (pal_bank & PAL_4096) { // use 4096palettes | if (crtc.e.pal_bank & PAL_4096) { // use 4096palettes |
| switch(pal_bank & (PAL_4096FULL | PAL_4096BANK)) { | num = ((port & 0xff) << 4) + (crtc.s.lastpal >> 4); |
| case 0: | if (!(crtc.e.pal_bank & PAL_4096FULL)) { |
| num = ((port & 0xcc) << 4) | | num &= 0xccc; |
| ((crtc.s.lastpal & 0xc0) >> 4); | if (crtc.e.pal_bank & PAL_4096BANK) { |
| break; | num >>= 2; |
| } | |
| case 1: | |
| num = ((port & 0xcc) << 2) | | |
| ((crtc.s.lastpal & 0xc0) >> 6); | |
| break; | |
| default: | |
| num = ((port & 0xff) << 4) | (crtc.s.lastpal >> 4); | |
| break; | |
| } | } |
| pal = crtc.p.grph4096[num]; | pal = crtc.p.grph4096[num]; |
| } | } |
| else { | else { |
| num = ((port & 0x80) >> 5) | ((port & 0x08) >> 2) | | num = ((port & 0x80) >> 5) | ((port & 0x08) >> 2) | |
| ((crtc.s.lastpal & 0x80) >> 7); | ((crtc.s.lastpal & 0x80) >> 7); |
| if ((dispmode & SCRN64_MASK) == SCRN64_INVALID) { | if ((crtc.e.dispmode & SCRN64_MASK) == SCRN64_INVALID) { |
| num |= (num << 3); | num |= (num << 3); |
| } | } |
| else { | else { |
| num += ((port & 0x40) >> 1) | ((port & 0x04) << 2) | | num += ((port & 0x40) >> 1) | ((port & 0x04) << 2) | |
| ((crtc.s.lastpal & 0x40) >> 3); | ((crtc.s.lastpal & 0x40) >> 3); |
| } | } |
| pal = crtc.p.grph[pal_bank][num]; | pal = crtc.p.grph[crtc.e.pal_bank][num]; |
| } | } |
| sft = (port >> (8 - 2)) & (3 << 2); | sft = (port >> (8 - 2)) & (3 << 2); |
| return((REG8)(crtc.s.lastpal + ((pal >> sft) & 0xf))); | return((REG8)(crtc.s.lastpal + ((pal >> sft) & 0xf))); |
| Line 435 REG8 IOINPCALL palette_i(UINT port) { | Line 394 REG8 IOINPCALL palette_i(UINT port) { |
| void IOOUTCALL extpal_o(UINT port, REG8 value) { | void IOOUTCALL extpal_o(UINT port, REG8 value) { |
| crtc.s.EXTPALMODE = value; | crtc.s.EXTPALMODE = value; |
| vrambank_patch(); | crtc_bankupdate(); |
| (void)port; | (void)port; |
| } | } |
| Line 481 REG8 IOINPCALL exttextpal_i(UINT port) { | Line 440 REG8 IOINPCALL exttextpal_i(UINT port) { |
| void IOOUTCALL exttextdisp_o(UINT port, REG8 value) { | void IOOUTCALL exttextdisp_o(UINT port, REG8 value) { |
| crtc.s.ZPRY = value; | crtc.s.ZPRY = value; |
| vrambank_patch(); | crtc_bankupdate(); |
| (void)port; | (void)port; |
| } | } |
| Line 530 void crtc_initialize(void) { | Line 489 void crtc_initialize(void) { |
| void crtc_reset(void) { | void crtc_reset(void) { |
| crtc.s = crtcdefault; | crtc.s = crtcdefault; |
| dispmode = SCRN64_INVALID; | |
| pal_bank = pal_disp = PAL_NORMAL; | |
| 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 = 16; | crtc.s._FNT_YL = 15; |
| } | } |
| pal_reset(); | pal_reset(); |
| crtc_updt(); | crtc_bankupdate(); |
| crtc_regupdate(); | |
| vrambank_patch(); | |
| makescrn.palandply = 1; | makescrn.palandply = 1; |
| scrnallflash = 1; | scrnallflash = 1; |
| } | } |
| void crtc_forcesetwidth(REG8 width) { | |
| crtc.s.TXT_XL = (UINT8)width; | |
| crtc_bankupdate(); | |
| scrnallflash = 1; | |
| } | |