src/mess/video/pc_cga.c
| r2074 | r2075 | |
| 48 | 48 | ***************************************************************************/ |
| 49 | 49 | |
| 50 | 50 | #include "driver.h" |
| 51 | | #include "deprecat.h" |
| 52 | 51 | #include "pc_cga.h" |
| 53 | | #include "includes/crtc6845.h" |
| 52 | #include "video/mc6845.h" |
| 54 | 53 | #include "video/pc_video.h" |
| 55 | 54 | #include "memconv.h" |
| 56 | 55 | |
| r2074 | r2075 | |
| 68 | 67 | static VIDEO_START( pc_cga ); |
| 69 | 68 | static PALETTE_INIT( pc_cga ); |
| 70 | 69 | |
| 71 | | /*************************************************************************** |
| 72 | 70 | |
| 73 | | MachineDriver stuff |
| 74 | | |
| 75 | | Note - two character ROMs needed: |
| 76 | | |
| 77 | | // cutted from some aga char rom |
| 78 | | // 256 8x8 thick chars |
| 79 | | // 256 8x8 thin chars |
| 80 | | ROM_LOAD("cga.chr", 0x00000, 0x01000, 0x42009069) |
| 81 | | // first font of above |
| 82 | | ROM_LOAD("cga2.chr", 0x00000, 0x800, 0xa362ffe6) |
| 83 | | |
| 84 | | ***************************************************************************/ |
| 85 | | |
| 86 | 71 | /* In cgapal.c; it's quite big */ |
| 87 | 72 | extern const unsigned char cga_palette[16 * CGA_PALETTE_SETS][3]; |
| 88 | 73 | |
| 89 | 74 | |
| 90 | | const unsigned short cga_colortable[] = |
| 91 | | { |
| 92 | | /* Text modes */ |
| 93 | | 0, 0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 0, 9, 0,10, 0,11, 0,12, 0,13, 0,14, 0,15, |
| 94 | | 1, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1, 5, 1, 6, 1, 7, 1, 8, 1, 9, 1,10, 1,11, 1,12, 1,13, 1,14, 1,15, |
| 95 | | 2, 0, 2, 1, 2, 2, 2, 3, 2, 4, 2, 5, 2, 6, 2, 7, 2, 8, 2, 9, 2,10, 2,11, 2,12, 2,13, 2,14, 2,15, |
| 96 | | 3, 0, 3, 1, 3, 2, 3, 3, 3, 4, 3, 5, 3, 6, 3, 7, 3, 8, 3, 9, 3,10, 3,11, 3,12, 3,13, 3,14, 3,15, |
| 97 | | 4, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4, 5, 4, 6, 4, 7, 4, 8, 4, 9, 4,10, 4,11, 4,12, 4,13, 4,14, 4,15, |
| 98 | | 5, 0, 5, 1, 5, 2, 5, 3, 5, 4, 5, 5, 5, 6, 5, 7, 5, 8, 5, 9, 5,10, 5,11, 5,12, 5,13, 5,14, 5,15, |
| 99 | | 6, 0, 6, 1, 6, 2, 6, 3, 6, 4, 6, 5, 6, 6, 6, 7, 6, 8, 6, 9, 6,10, 6,11, 6,12, 6,13, 6,14, 6,15, |
| 100 | | 7, 0, 7, 1, 7, 2, 7, 3, 7, 4, 7, 5, 7, 6, 7, 7, 7, 8, 7, 9, 7,10, 7,11, 7,12, 7,13, 7,14, 7,15, |
| 101 | | /* flashing is done by dirtying the videoram buffer positions with attr bit #7 set */ |
| 102 | | 8, 0, 8, 1, 8, 2, 8, 3, 8, 4, 8, 5, 8, 6, 8, 7, 8, 8, 8, 9, 8,10, 8,11, 8,12, 8,13, 8,14, 8,15, |
| 103 | | 9, 0, 9, 1, 9, 2, 9, 3, 9, 4, 9, 5, 9, 6, 9, 7, 9, 8, 9, 9, 9,10, 9,11, 9,12, 9,13, 9,14, 9,15, |
| 104 | | 10, 0,10, 1,10, 2,10, 3,10, 4,10, 5,10, 6,10, 7,10, 8,10, 9,10,10,10,11,10,12,10,13,10,14,10,15, |
| 105 | | 11, 0,11, 1,11, 2,11, 3,11, 4,11, 5,11, 6,11, 7,11, 8,11, 9,11,10,11,11,11,12,11,13,11,14,11,15, |
| 106 | | 12, 0,12, 1,12, 2,12, 3,12, 4,12, 5,12, 6,12, 7,12, 8,12, 9,12,10,12,11,12,12,12,13,12,14,12,15, |
| 107 | | 13, 0,13, 1,13, 2,13, 3,13, 4,13, 5,13, 6,13, 7,13, 8,13, 9,13,10,13,11,13,12,13,13,13,14,13,15, |
| 108 | | 14, 0,14, 1,14, 2,14, 3,14, 4,14, 5,14, 6,14, 7,14, 8,14, 9,14,10,14,11,14,12,14,13,14,14,14,15, |
| 109 | | 15, 0,15, 1,15, 2,15, 3,15, 4,15, 5,15, 6,15, 7,15, 8,15, 9,15,10,15,11,15,12,15,13,15,14,15,15, |
| 110 | | /* the color sets for 1bpp graphics mode */ |
| 111 | | 0,0, 0,1, 0,2, 0,3, 0,4, 0,5, 0,6, 0,7, |
| 112 | | 0,8, 0,9, 0,10, 0,11, 0,12, 0,13, 0,14, 0,15, |
| 113 | | /* the color sets for 2bpp graphics mode. There are 32*3 = 96 of these, |
| 114 | | * though only the first 64 are documented. */ |
| 115 | | /* Red/Green/Yellow set */ |
| 116 | | 0, 2, 4, 6, 1, 2, 4, 6, 2, 2, 4, 6, 3, 2, 4, 6, |
| 117 | | 4, 2, 4, 6, 5, 2, 4, 6, 6, 2, 4, 6, 7, 2, 4, 6, |
| 118 | | 8, 2, 4, 6, 9, 2, 4, 6, 10, 2, 4, 6, 11, 2, 4, 6, |
| 119 | | 12, 2, 4, 6, 13, 2, 4, 6, 14, 2, 4, 6, 15, 2, 4, 6, |
| 120 | | 0,10,12,14, 1,10,12,14, 2,10,12,14, 3,10,12,14, |
| 121 | | 4,10,12,14, 5,10,12,14, 6,10,12,14, 7,10,12,14, |
| 122 | | 8,10,12,14, 9,10,12,14, 10,10,12,14, 11,10,12,14, |
| 123 | | 12,10,12,14, 13,10,12,14, 14,10,12,14, 15,10,12,14, |
| 124 | | /* Magenta/Cyan/White set */ |
| 125 | | 0, 3, 5, 7, 1, 3, 5, 7, 2, 3, 5, 7, 3, 3, 5, 7, |
| 126 | | 4, 3, 5, 7, 5, 3, 5, 7, 6, 3, 5, 7, 7, 3, 5, 7, |
| 127 | | 8, 3, 5, 7, 9, 3, 5, 7, 10, 3, 5, 7, 11, 3, 5, 7, |
| 128 | | 12, 3, 5, 7, 13, 3, 5, 7, 14, 3, 5, 7, 15, 3, 5, 7, |
| 129 | | 0,11,13,15, 1,11,13,15, 2,11,13,15, 3,11,13,15, |
| 130 | | 4,11,13,15, 5,11,13,15, 6,11,13,15, 7,11,13,15, |
| 131 | | 8,11,13,15, 9,11,13,15, 10,11,13,15, 11,11,13,15, |
| 132 | | 12,11,13,15, 13,11,13,15, 14,11,13,15, 15,11,13,15, |
| 133 | | /* Red/Cyan/White set (undocumented) */ |
| 134 | | 0, 3, 4, 7, 1, 3, 4, 7, 2, 3, 4, 7, 3, 3, 4, 7, |
| 135 | | 4, 3, 4, 7, 5, 3, 4, 7, 6, 3, 4, 7, 7, 3, 4, 7, |
| 136 | | 8, 3, 4, 7, 9, 3, 4, 7, 10, 3, 4, 7, 11, 3, 4, 7, |
| 137 | | 12, 3, 4, 7, 13, 3, 4, 7, 14, 3, 4, 7, 15, 3, 4, 7, |
| 138 | | 0,11,12,15, 1,11,12,15, 2,11,12,15, 3,11,12,15, |
| 139 | | 4,11,12,15, 5,11,12,15, 6,11,12,15, 7,11,12,15, |
| 140 | | 8,11,12,15, 9,11,12,15, 10,11,12,15, 11,11,12,15, |
| 141 | | 12,11,12,15, 13,11,12,15, 14,11,12,15, 15,11,12,15, |
| 142 | | }; |
| 75 | static VIDEO_UPDATE( mc6845_cga ); |
| 76 | static READ8_HANDLER( pc_cga8_r ); |
| 77 | static WRITE8_HANDLER( pc_cga8_w ); |
| 78 | static READ16_HANDLER( pc_cga16le_r ); |
| 79 | static WRITE16_HANDLER( pc_cga16le_w ); |
| 80 | static READ32_HANDLER( pc_cga32le_r ); |
| 81 | static WRITE32_HANDLER( pc_cga32le_w ); |
| 82 | static MC6845_UPDATE_ROW( cga_update_row ); |
| 83 | static MC6845_ON_HSYNC_CHANGED( cga_hsync_changed ); |
| 84 | static MC6845_ON_VSYNC_CHANGED( cga_vsync_changed ); |
| 85 | static VIDEO_START( pc1512 ); |
| 86 | static VIDEO_UPDATE( mc6845_pc1512 ); |
| 143 | 87 | |
| 144 | | const gfx_layout CGA_charlayout = |
| 145 | | { |
| 146 | | 8,16, /* 8 x 16 characters */ |
| 147 | | 256, /* 256 characters */ |
| 148 | | 1, /* 1 bits per pixel */ |
| 149 | | { 0 }, /* no bitplanes; 1 bit per pixel */ |
| 150 | | /* x offsets */ |
| 151 | | { 0,1,2,3,4,5,6,7 }, |
| 152 | | /* y offsets */ |
| 153 | | { 0*8,1*8,2*8,3*8, |
| 154 | | 4*8,5*8,6*8,7*8, |
| 155 | | 0*8,1*8,2*8,3*8, |
| 156 | | 4*8,5*8,6*8,7*8 }, |
| 157 | | 8*8 /* every char takes 8 bytes */ |
| 88 | |
| 89 | static const mc6845_interface mc6845_cga_intf = { |
| 90 | CGA_SCREEN_NAME, /* screen number */ |
| 91 | XTAL_14_31818MHz/8, /* clock */ |
| 92 | 8, /* numbers of pixels per video memory address */ |
| 93 | NULL, /* begin_update */ |
| 94 | cga_update_row, /* update_row */ |
| 95 | NULL, /* end_update */ |
| 96 | NULL, /* on_de_chaged */ |
| 97 | cga_hsync_changed, /* on_hsync_changed */ |
| 98 | cga_vsync_changed /* on_vsync_changed */ |
| 158 | 99 | }; |
| 159 | 100 | |
| 160 | | static GFXDECODE_START( CGA ) |
| 161 | | /* Support up to four CGA fonts */ |
| 162 | | GFXDECODE_ENTRY( REGION_GFX1, 0x0000, CGA_charlayout, 0, 256 ) /* Font 0 */ |
| 163 | | GFXDECODE_ENTRY( REGION_GFX1, 0x0800, CGA_charlayout, 0, 256 ) /* Font 1 */ |
| 164 | | GFXDECODE_ENTRY( REGION_GFX1, 0x1000, CGA_charlayout, 0, 256 ) /* Font 2 */ |
| 165 | | GFXDECODE_ENTRY( REGION_GFX1, 0x1800, CGA_charlayout, 0, 256 ) /* Font 3*/ |
| 166 | | GFXDECODE_END |
| 167 | 101 | |
| 168 | 102 | MACHINE_DRIVER_START( pcvideo_cga ) |
| 169 | | MDRV_SCREEN_ADD("main", RASTER) |
| 103 | MDRV_SCREEN_ADD(CGA_SCREEN_NAME, RASTER) |
| 170 | 104 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 171 | | MDRV_SCREEN_SIZE(80*8, 25*8) |
| 172 | | MDRV_SCREEN_VISIBLE_AREA(0,80*8-1, 0,25*8-1) |
| 173 | | MDRV_GFXDECODE(CGA) |
| 174 | | MDRV_PALETTE_LENGTH(sizeof(cga_palette) / (CGA_PALETTE_SETS * sizeof(cga_palette[0]))) |
| 105 | MDRV_SCREEN_RAW_PARAMS(XTAL_14_31818MHz,912,0,640,262,0,200) |
| 106 | MDRV_PALETTE_LENGTH( CGA_PALETTE_SETS * 16 ) |
| 175 | 107 | |
| 176 | 108 | MDRV_PALETTE_INIT(pc_cga) |
| 177 | | MDRV_VIDEO_START(pc_cga) |
| 178 | | MDRV_VIDEO_UPDATE(pc_video) |
| 109 | |
| 110 | MDRV_DEVICE_ADD(CGA_MC6845_NAME, MC6845) |
| 111 | MDRV_DEVICE_CONFIG( mc6845_cga_intf ) |
| 112 | |
| 113 | MDRV_VIDEO_START( pc_cga ) |
| 114 | MDRV_VIDEO_UPDATE( mc6845_cga ) |
| 179 | 115 | MACHINE_DRIVER_END |
| 180 | 116 | |
| 181 | 117 | MACHINE_DRIVER_START( pcvideo_pc1512 ) |
| 182 | 118 | MDRV_IMPORT_FROM( pcvideo_cga ) |
| 183 | 119 | MDRV_VIDEO_START( pc1512 ) |
| 120 | MDRV_VIDEO_UPDATE( mc6845_pc1512 ) |
| 184 | 121 | MACHINE_DRIVER_END |
| 185 | 122 | |
| 186 | 123 | |
| r2074 | r2075 | |
| 220 | 157 | UINT8 status; /* ro 0x3da */ |
| 221 | 158 | UINT8 plantronics; /* wo 0x3dd, ATI chipset only */ |
| 222 | 159 | |
| 223 | | int pc_blink; |
| 224 | | int frame; |
| 225 | | int palette; |
| 226 | | } cga; |
| 160 | UINT8 frame; |
| 227 | 161 | |
| 228 | | static TIMER_CALLBACK(cga_timerproc); |
| 229 | | static int cga_blinkthisframe(void); |
| 162 | UINT8 *chr_gen; |
| 230 | 163 | |
| 164 | mc6845_update_row_func update_row; |
| 165 | UINT8 palette_lut_2bpp[4]; |
| 166 | UINT8 vsync; |
| 167 | UINT8 hsync; |
| 168 | } cga; |
| 231 | 169 | |
| 232 | 170 | |
| 171 | |
| 233 | 172 | /*************************************************************************** |
| 234 | 173 | |
| 235 | 174 | Methods |
| r2074 | r2075 | |
| 239 | 178 | /* Initialise the cga palette */ |
| 240 | 179 | static PALETTE_INIT( pc_cga ) |
| 241 | 180 | { |
| 242 | | } |
| 181 | int i; |
| 243 | 182 | |
| 244 | | |
| 245 | | |
| 246 | | void pc_cga_cursor(struct mscrtc6845_cursor *cursor) |
| 247 | | { |
| 183 | for ( i = 0; i < CGA_PALETTE_SETS * 16; i++ ) { |
| 184 | palette_set_color_rgb( machine, i, cga_palette[i][0], cga_palette[i][1], cga_palette[i][2] ); |
| 185 | } |
| 248 | 186 | } |
| 249 | 187 | |
| 250 | 188 | |
| 251 | | |
| 252 | | static struct mscrtc6845_config config = { 14318180 /*?*/, pc_cga_cursor }; |
| 253 | | |
| 254 | 189 | static int internal_pc_cga_video_start(int personality) |
| 255 | 190 | { |
| 256 | 191 | memset(&cga, 0, sizeof(cga)); |
| 257 | | cga.palette = -1; |
| 192 | cga.update_row = NULL; |
| 258 | 193 | |
| 259 | | config.personality = personality; |
| 260 | | if (!pc_video_start(&config, pc_cga_choosevideomode, 0x8000)) |
| 261 | | return 1; |
| 194 | cga.chr_gen = memory_region(REGION_GFX1) + 0x1000; |
| 262 | 195 | |
| 263 | 196 | state_save_register_item("pccga", 0, cga.mode_control); |
| 264 | 197 | state_save_register_item("pccga", 0, cga.color_select); |
| 265 | 198 | state_save_register_item("pccga", 0, cga.status); |
| 266 | 199 | state_save_register_item("pccga", 0, cga.plantronics); |
| 267 | 200 | |
| 268 | | timer_pulse(ATTOTIME_IN_USEC(133333), NULL, 0, cga_timerproc); |
| 269 | 201 | return 0; |
| 270 | 202 | } |
| 271 | 203 | |
| r2074 | r2075 | |
| 283 | 215 | switch(buswidth) |
| 284 | 216 | { |
| 285 | 217 | case 8: |
| 286 | | memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0xb8000, 0xbffff, 0, 0, SMH_BANK11 ); |
| 287 | | memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0xb8000, 0xbffff, 0, 0, pc_video_videoram_w ); |
| 218 | memory_install_read8_handler(0, ADDRESS_SPACE_PROGRAM, 0xb8000, 0xbbfff, 0, 0x0c000, SMH_BANK11 ); |
| 219 | memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0xb8000, 0xbbfff, 0, 0x0c000, pc_video_videoram_w ); |
| 288 | 220 | memory_install_read8_handler(0, ADDRESS_SPACE_IO, 0x3d0, 0x3df, 0, 0, pc_cga8_r ); |
| 289 | 221 | memory_install_write8_handler(0, ADDRESS_SPACE_IO, 0x3d0, 0x3df, 0, 0, pc_cga8_w ); |
| 290 | 222 | break; |
| 291 | 223 | |
| 292 | 224 | case 16: |
| 293 | | memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0xb8000, 0xbffff, 0, 0, SMH_BANK11 ); |
| 294 | | memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0xb8000, 0xbffff, 0, 0, pc_video_videoram16le_w ); |
| 225 | memory_install_read16_handler(0, ADDRESS_SPACE_PROGRAM, 0xb8000, 0xbbfff, 0, 0x0c000, SMH_BANK11 ); |
| 226 | memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0xb8000, 0xbbfff, 0, 0x0c000, pc_video_videoram16le_w ); |
| 295 | 227 | memory_install_read16_handler(0, ADDRESS_SPACE_IO, 0x3d0, 0x3df, 0, 0, pc_cga16le_r ); |
| 296 | 228 | memory_install_write16_handler(0, ADDRESS_SPACE_IO, 0x3d0, 0x3df, 0, 0, pc_cga16le_w ); |
| 297 | 229 | break; |
| 298 | 230 | |
| 299 | 231 | case 32: |
| 300 | | memory_install_read32_handler(0, ADDRESS_SPACE_PROGRAM, 0xb8000, 0xbffff, 0, 0, SMH_BANK11 ); |
| 301 | | memory_install_write32_handler(0, ADDRESS_SPACE_PROGRAM, 0xb8000, 0xbffff, 0, 0, pc_video_videoram32_w ); |
| 232 | memory_install_read32_handler(0, ADDRESS_SPACE_PROGRAM, 0xb8000, 0xbbfff, 0, 0x0c000, SMH_BANK11 ); |
| 233 | memory_install_write32_handler(0, ADDRESS_SPACE_PROGRAM, 0xb8000, 0xbbfff, 0, 0x0c000, pc_video_videoram32_w ); |
| 302 | 234 | memory_install_read32_handler(0, ADDRESS_SPACE_IO, 0x3d0, 0x3df, 0, 0, pc_cga32le_r ); |
| 303 | 235 | memory_install_write32_handler(0, ADDRESS_SPACE_IO, 0x3d0, 0x3df, 0, 0, pc_cga32le_w ); |
| 304 | 236 | break; |
| r2074 | r2075 | |
| 308 | 240 | break; |
| 309 | 241 | } |
| 310 | 242 | |
| 311 | | if (videoram_size == 0) |
| 312 | | videoram_size = 0x8000; |
| 313 | | if (!videoram) |
| 314 | | videoram = auto_malloc(videoram_size); |
| 243 | videoram_size = 0x4000; |
| 244 | |
| 245 | videoram = auto_malloc(videoram_size); |
| 246 | |
| 315 | 247 | memory_set_bankptr(11, videoram); |
| 316 | 248 | |
| 317 | 249 | internal_pc_cga_video_start(M6845_PERSONALITY_GENUINE); |
| r2074 | r2075 | |
| 319 | 251 | |
| 320 | 252 | |
| 321 | 253 | |
| 322 | | static void pc_cga_check_palette(void) |
| 323 | | { |
| 324 | | int i, p = 0; /* RGB palette */ |
| 254 | static VIDEO_UPDATE( mc6845_cga ) { |
| 255 | device_config *devconf = (device_config *) device_list_find_by_tag(screen->machine->config->devicelist, MC6845, CGA_MC6845_NAME); |
| 256 | mc6845_update( devconf, bitmap, cliprect); |
| 325 | 257 | |
| 326 | | switch(CGA_MONITOR) |
| 327 | | { |
| 328 | | case CGA_MONITOR_COMPOSITE: |
| 329 | | if (cga.mode_control & 4) |
| 330 | | { |
| 331 | | p = 1; /* Greyscale palette */ |
| 332 | | } |
| 333 | | else if (cga.mode_control & 2) /* Graphics mode */ |
| 334 | | { |
| 335 | | if (cga.mode_control & 0x10) /* Hi-Res */ |
| 336 | | { |
| 337 | | p = (cga.color_select & 0x0F) + 0x03; |
| 338 | | } |
| 339 | | else /* Lo-Res */ |
| 340 | | { |
| 341 | | p = (cga.color_select & 0x3F) + 0x13; |
| 342 | | } |
| 343 | | |
| 344 | | } |
| 345 | | else |
| 346 | | { |
| 347 | | p = 2; /* Text-mode colour palette */ |
| 348 | | } |
| 349 | | break; |
| 350 | | case CGA_MONITOR_MONO: |
| 351 | | case CGA_MONITOR_LCD: |
| 352 | | p = 1; /* Greyscale palette */ |
| 353 | | break; |
| 258 | /* Check for changes in font dipsetting */ |
| 259 | switch ( CGA_FONT & 0x01 ) { |
| 260 | case 0: |
| 261 | cga.chr_gen = memory_region(REGION_GFX1) + 0x1800; |
| 262 | break; |
| 263 | case 1: |
| 264 | cga.chr_gen = memory_region(REGION_GFX1) + 0x1000; |
| 265 | break; |
| 354 | 266 | } |
| 355 | | p *= 16; |
| 356 | | |
| 357 | | if (p != cga.palette) |
| 358 | | { |
| 359 | | for(i = 0; i < (sizeof(cga_palette) / (3 * CGA_PALETTE_SETS)); i++) |
| 360 | | palette_set_color_rgb(Machine, i, cga_palette[i + p][0], |
| 361 | | cga_palette[i + p][1], |
| 362 | | cga_palette[i + p][2]); |
| 363 | | cga.palette = p; |
| 364 | | } |
| 267 | return 0; |
| 365 | 268 | } |
| 366 | 269 | |
| 367 | 270 | |
| 271 | /*************************************************************************** |
| 272 | Draw text mode with 40x25 characters (default) with high intensity bg. |
| 273 | The character cell size is 16x8 |
| 274 | ***************************************************************************/ |
| 368 | 275 | |
| 369 | | /* |
| 370 | | * rW CGA mode control register (see #P138) |
| 371 | | */ |
| 372 | | static void pc_cga_mode_control_w(int data) |
| 373 | | { |
| 374 | | unsigned char mask = 0x3B; |
| 276 | static MC6845_UPDATE_ROW( cga_text_inten_update_row ) { |
| 277 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| 278 | int i; |
| 375 | 279 | |
| 376 | | CGA_LOG(1,"CGA_mode_control_w",("$%02x: columns %d, gfx %d, hires %d, blink %d\n", |
| 377 | | data, (data&1)?80:40, (data>>1)&1, (data>>4)&1, (data>>5)&1)); |
| 280 | if ( y == 0 ) logerror("cga_text_inten_update_row\n"); |
| 281 | for ( i = 0; i < x_count; i++ ) { |
| 282 | UINT16 offset = ( ( ma + i ) << 1 ) & 0x3fff; |
| 283 | UINT8 chr = videoram[ offset ]; |
| 284 | UINT8 attr = videoram[ offset +1 ]; |
| 285 | UINT8 data = cga.chr_gen[ chr * 8 + ra ]; |
| 286 | UINT16 fg = attr & 0x0F; |
| 287 | UINT16 bg = ( attr >> 4 ) & 0x07; |
| 378 | 288 | |
| 379 | | /* CGA composite: Switching between mono & colour behaves like a |
| 380 | | * mode change */ |
| 381 | | if(CGA_MONITOR == CGA_MONITOR_COMPOSITE) mask = 0x3F; |
| 382 | | cga.mode_control = data; |
| 383 | | } |
| 289 | if ( i == cursor_x ) { |
| 290 | data = 0xFF; |
| 291 | } |
| 384 | 292 | |
| 385 | | |
| 386 | | |
| 387 | | /* |
| 388 | | * ?W reserved for color select register on color adapter |
| 389 | | */ |
| 390 | | static void pc_cga_color_select_w(int data) |
| 391 | | { |
| 392 | | CGA_LOG(1,"CGA_color_select_w",("$%02x\n", data)); |
| 393 | | if( cga.color_select == data ) |
| 394 | | return; |
| 395 | | cga.color_select = data; |
| 396 | | } |
| 397 | | |
| 398 | | |
| 399 | | |
| 400 | | /* |
| 401 | | * Select Plantronics modes |
| 402 | | */ |
| 403 | | static void pc_cga_plantronics_w(int data) |
| 404 | | { |
| 405 | | CGA_LOG(1,"CGA_plantronics_w",("$%02x\n", data)); |
| 406 | | |
| 407 | | if (CGA_CHIPSET != CGA_CHIPSET_ATI) return; |
| 408 | | |
| 409 | | data &= 0x70; /* Only bits 6-4 are used */ |
| 410 | | if (cga.plantronics == data) return; |
| 411 | | cga.plantronics = data; |
| 412 | | } |
| 413 | | |
| 414 | | |
| 415 | | |
| 416 | | /* Bitfields for CGA status register: |
| 417 | | * Bit(s) Description (Table P179) |
| 418 | | * 7-6 not used |
| 419 | | * 5-4 color EGA, color ET4000: diagnose video display feedback, select |
| 420 | | * from color plane enable |
| 421 | | * 3 in vertical retrace |
| 422 | | * 2 (CGA,color EGA) light pen switch is off |
| 423 | | * (MCGA,color ET4000) reserved (0) |
| 424 | | * 1 (CGA,color EGA) positive edge from light pen has set trigger |
| 425 | | * (MCGA,color ET4000) reserved (0) |
| 426 | | * 0 horizontal retrace in progress |
| 427 | | * =0 do not use memory |
| 428 | | * =1 memory access without interfering with display |
| 429 | | * (Genoa SuperEGA) horizontal or vertical retrace |
| 430 | | */ |
| 431 | | static int pc_cga_status_r(void) |
| 432 | | { |
| 433 | | int data = ((~readinputport(0)) & 0x08) | cga.status; |
| 434 | | cga.status ^= 0x01; |
| 435 | | return data; |
| 436 | | } |
| 437 | | |
| 438 | | |
| 439 | | |
| 440 | | /************************************************************************* |
| 441 | | * |
| 442 | | * CGA |
| 443 | | * color graphics adapter |
| 444 | | * |
| 445 | | *************************************************************************/ |
| 446 | | |
| 447 | | READ8_HANDLER( pc_cga8_r ) |
| 448 | | { |
| 449 | | int data = 0xff; |
| 450 | | switch( offset ) |
| 451 | | { |
| 452 | | case 0: case 2: case 4: case 6: |
| 453 | | data = mscrtc6845_port_r(mscrtc6845, 0); |
| 454 | | break; |
| 455 | | case 1: case 3: case 5: case 7: |
| 456 | | data = mscrtc6845_port_r(mscrtc6845, 1); |
| 457 | | break; |
| 458 | | case 10: |
| 459 | | data = pc_cga_status_r(); |
| 460 | | break; |
| 461 | | } |
| 462 | | return data; |
| 463 | | } |
| 464 | | |
| 465 | | |
| 466 | | |
| 467 | | WRITE8_HANDLER( pc_cga8_w ) |
| 468 | | { |
| 469 | | switch(offset) { |
| 470 | | case 0: case 2: case 4: case 6: |
| 471 | | case 1: case 3: case 5: case 7: |
| 472 | | mscrtc6845_port_w(mscrtc6845, offset, data); |
| 473 | | break; |
| 474 | | case 8: |
| 475 | | pc_cga_mode_control_w(data); |
| 476 | | break; |
| 477 | | case 9: |
| 478 | | pc_cga_color_select_w(data); |
| 479 | | break; |
| 480 | | case 0x0d: |
| 481 | | pc_cga_plantronics_w(data); |
| 482 | | break; |
| 293 | *p = ( data & 0x80 ) ? fg : bg; p++; |
| 294 | *p = ( data & 0x40 ) ? fg : bg; p++; |
| 295 | *p = ( data & 0x20 ) ? fg : bg; p++; |
| 296 | *p = ( data & 0x10 ) ? fg : bg; p++; |
| 297 | *p = ( data & 0x08 ) ? fg : bg; p++; |
| 298 | *p = ( data & 0x04 ) ? fg : bg; p++; |
| 299 | *p = ( data & 0x02 ) ? fg : bg; p++; |
| 300 | *p = ( data & 0x01 ) ? fg : bg; p++; |
| 483 | 301 | } |
| 484 | 302 | } |
| 485 | 303 | |
| 486 | 304 | |
| 487 | | |
| 488 | | READ16_HANDLER( pc_cga16le_r ) { return read16le_with_read8_handler(pc_cga8_r,machine, offset, mem_mask); } |
| 489 | | WRITE16_HANDLER( pc_cga16le_w ) { write16le_with_write8_handler(pc_cga8_w, machine, offset, data, mem_mask); } |
| 490 | | READ32_HANDLER( pc_cga32le_r ) { return read32le_with_read8_handler(pc_cga8_r, machine, offset, mem_mask); } |
| 491 | | WRITE32_HANDLER( pc_cga32le_w ) { write32le_with_write8_handler(pc_cga8_w, machine, offset, data, mem_mask); } |
| 492 | | |
| 493 | | |
| 494 | | |
| 495 | 305 | /*************************************************************************** |
| 496 | 306 | Draw text mode with 40x25 characters (default) with high intensity bg. |
| 497 | 307 | The character cell size is 16x8 |
| 498 | 308 | ***************************************************************************/ |
| 499 | 309 | |
| 500 | | static void cga_text_inten(bitmap_t *bitmap, struct mscrtc6845 *crtc) |
| 501 | | { |
| 502 | | int sx, sy; |
| 503 | | int offs = mscrtc6845_get_start(crtc) * 2; |
| 504 | | int lines = mscrtc6845_get_char_lines(crtc); |
| 505 | | int height = mscrtc6845_get_char_height(crtc); |
| 506 | | int columns = mscrtc6845_get_char_columns(crtc); |
| 507 | | rectangle r; |
| 508 | | struct mscrtc6845_cursor cursor; |
| 509 | | const device_config *screen = video_screen_first(Machine->config); |
| 510 | | int screen_height = video_screen_get_height(screen); |
| 310 | static MC6845_UPDATE_ROW( cga_text_inten_alt_update_row ) { |
| 311 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| 312 | int i; |
| 511 | 313 | |
| 512 | | mscrtc6845_time(crtc); |
| 513 | | mscrtc6845_get_cursor(crtc, &cursor); |
| 514 | | pc_cga_check_palette(); |
| 314 | if ( y == 0 ) logerror("cga_text_inten_alt_update_row\n"); |
| 315 | for ( i = 0; i < x_count; i++ ) { |
| 316 | UINT16 offset = ( ( ma + i ) << 1 ) & 0x3fff; |
| 317 | UINT8 chr = videoram[ offset ]; |
| 318 | UINT8 attr = videoram[ offset +1 ]; |
| 319 | UINT8 data = cga.chr_gen[ chr * 8 + ra ]; |
| 320 | UINT16 fg = attr & 0x0F; |
| 515 | 321 | |
| 516 | | for (sy=0, r.min_y=0, r.max_y=height-1; sy<lines; sy++, r.min_y+=height,r.max_y+=height) |
| 517 | | { |
| 518 | | if (r.min_y >= screen_height) |
| 519 | | break; |
| 520 | | for (sx=0, r.min_x=0, r.max_x=7; sx<columns; |
| 521 | | sx++, offs=(offs+2)&0x3fff, r.min_x+=8, r.max_x+=8) |
| 522 | | { |
| 523 | | drawgfx(bitmap, Machine->gfx[CGA_FONT], videoram[offs], videoram[offs+1], |
| 524 | | 0,0,r.min_x,r.min_y,&r,TRANSPARENCY_NONE,0); |
| 525 | | if (height > 16) |
| 526 | | { |
| 527 | | r.min_y+=16; |
| 528 | | drawgfx(bitmap, Machine->gfx[CGA_FONT], videoram[offs], videoram[offs+1], |
| 529 | | 0,0,r.min_x,r.min_y,&r,TRANSPARENCY_NONE,0); |
| 530 | | r.min_y-=16; |
| 531 | | } |
| 532 | | |
| 533 | | if (cursor.on && cga_blinkthisframe() && (offs==cursor.pos*2)) |
| 534 | | { |
| 535 | | int k=height-cursor.top; |
| 536 | | if (cursor.bottom<height) k=cursor.bottom-cursor.top+1; |
| 537 | | |
| 538 | | if (k>0) |
| 539 | | { |
| 540 | | plot_box(bitmap, r.min_x, |
| 541 | | r.min_y+cursor.top, |
| 542 | | 8, k, Machine->pens[7]); |
| 543 | | } |
| 544 | | } |
| 322 | if ( i == cursor_x ) { |
| 323 | data = 0xFF; |
| 545 | 324 | } |
| 325 | |
| 326 | *p = ( data & 0x80 ) ? fg : 0; p++; |
| 327 | *p = ( data & 0x40 ) ? fg : 0; p++; |
| 328 | *p = ( data & 0x20 ) ? fg : 0; p++; |
| 329 | *p = ( data & 0x10 ) ? fg : 0; p++; |
| 330 | *p = ( data & 0x08 ) ? fg : 0; p++; |
| 331 | *p = ( data & 0x04 ) ? fg : 0; p++; |
| 332 | *p = ( data & 0x02 ) ? fg : 0; p++; |
| 333 | *p = ( data & 0x01 ) ? fg : 0; p++; |
| 546 | 334 | } |
| 547 | 335 | } |
| 548 | 336 | |
| 549 | 337 | |
| 550 | | |
| 551 | 338 | /*************************************************************************** |
| 552 | | Draw text mode with 40x25 characters (default) with high intensity bg. |
| 339 | Draw text mode with 40x25 characters (default) and blinking colors. |
| 553 | 340 | The character cell size is 16x8 |
| 554 | 341 | ***************************************************************************/ |
| 555 | 342 | |
| 556 | | static void cga_text_inten_alt(bitmap_t *bitmap, struct mscrtc6845 *crtc) |
| 557 | | { |
| 558 | | int sx, sy; |
| 559 | | int offs = mscrtc6845_get_start(crtc) * 2; |
| 560 | | int lines = mscrtc6845_get_char_lines(crtc); |
| 561 | | int height = mscrtc6845_get_char_height(crtc); |
| 562 | | int columns = mscrtc6845_get_char_columns(crtc); |
| 563 | | rectangle r; |
| 564 | | struct mscrtc6845_cursor cursor; |
| 343 | static MC6845_UPDATE_ROW( cga_text_blink_update_row ) { |
| 344 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| 345 | int i; |
| 565 | 346 | |
| 566 | | if (CGA_CHIPSET != CGA_CHIPSET_PC200) |
| 567 | | { |
| 568 | | cga_text_inten(bitmap, crtc); |
| 569 | | return; |
| 570 | | } |
| 347 | for ( i = 0; i < x_count; i++ ) { |
| 348 | UINT16 offset = ( ( ma + i ) << 1 ) & 0x3fff; |
| 349 | UINT8 chr = videoram[ offset ]; |
| 350 | UINT8 attr = videoram[ offset +1 ]; |
| 351 | UINT8 data = cga.chr_gen[ chr * 8 + ra ]; |
| 352 | UINT16 fg = attr & 0x0F; |
| 353 | UINT16 bg = ( attr >> 4 ) & 0x07; |
| 571 | 354 | |
| 572 | | mscrtc6845_time(crtc); |
| 573 | | mscrtc6845_get_cursor(crtc, &cursor); |
| 574 | | pc_cga_check_palette(); |
| 575 | | |
| 576 | | for (sy=0, r.min_y=0, r.max_y=height-1; sy<lines; sy++, r.min_y+=height,r.max_y+=height) |
| 577 | | { |
| 578 | | for (sx=0, r.min_x=0, r.max_x=7; sx<columns; |
| 579 | | sx++, offs=(offs+2)&0x3fff, r.min_x+=8, r.max_x+=8) |
| 580 | | { |
| 581 | | drawgfx(bitmap, Machine->gfx[CGA_FONT], videoram[offs], (videoram[offs+1] & 15), |
| 582 | | 0,0,r.min_x,r.min_y,&r,TRANSPARENCY_NONE,0); |
| 583 | | if (cursor.on && cga_blinkthisframe() && (offs==cursor.pos*2)) |
| 584 | | { |
| 585 | | int k=height-cursor.top; |
| 586 | | if (cursor.bottom<height) k=cursor.bottom-cursor.top+1; |
| 587 | | |
| 588 | | if (k>0) |
| 589 | | { |
| 590 | | plot_box(bitmap, r.min_x, |
| 591 | | r.min_y+cursor.top, |
| 592 | | 8, k, Machine->pens[7]); |
| 593 | | } |
| 355 | if ( i == cursor_x ) { |
| 356 | data = 0xFF; |
| 357 | } else { |
| 358 | if ( ( attr & 0x80 ) && ( cga.frame & 0x10 ) ) { |
| 359 | data = 0x00; |
| 594 | 360 | } |
| 595 | 361 | } |
| 362 | |
| 363 | *p = ( data & 0x80 ) ? fg : bg; p++; |
| 364 | *p = ( data & 0x40 ) ? fg : bg; p++; |
| 365 | *p = ( data & 0x20 ) ? fg : bg; p++; |
| 366 | *p = ( data & 0x10 ) ? fg : bg; p++; |
| 367 | *p = ( data & 0x08 ) ? fg : bg; p++; |
| 368 | *p = ( data & 0x04 ) ? fg : bg; p++; |
| 369 | *p = ( data & 0x02 ) ? fg : bg; p++; |
| 370 | *p = ( data & 0x01 ) ? fg : bg; p++; |
| 596 | 371 | } |
| 597 | 372 | } |
| 598 | 373 | |
| 599 | 374 | |
| 600 | | |
| 601 | 375 | /*************************************************************************** |
| 602 | 376 | Draw text mode with 40x25 characters (default) and blinking colors. |
| 603 | 377 | The character cell size is 16x8 |
| 604 | 378 | ***************************************************************************/ |
| 605 | | static void cga_text_blink(bitmap_t *bitmap, struct mscrtc6845 *crtc) |
| 606 | | { |
| 607 | | int sx, sy; |
| 608 | | int offs = mscrtc6845_get_start(crtc)*2; |
| 609 | | int lines = mscrtc6845_get_char_lines(crtc); |
| 610 | | int height = mscrtc6845_get_char_height(crtc); |
| 611 | | int columns = mscrtc6845_get_char_columns(crtc); |
| 612 | | rectangle r; |
| 613 | | struct mscrtc6845_cursor cursor; |
| 614 | | const device_config *screen = video_screen_first(Machine->config); |
| 615 | | int screen_height = video_screen_get_height(screen); |
| 616 | 379 | |
| 617 | | mscrtc6845_time(crtc); |
| 618 | | mscrtc6845_get_cursor(crtc, &cursor); |
| 619 | | pc_cga_check_palette(); |
| 380 | static MC6845_UPDATE_ROW( cga_text_blink_alt_update_row ) { |
| 381 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| 382 | int i; |
| 620 | 383 | |
| 621 | | for (sy=0, r.min_y=0, r.max_y=height-1; sy<lines; sy++, r.min_y+=height,r.max_y+=height) |
| 622 | | { |
| 623 | | if (r.min_y >= screen_height) |
| 624 | | break; |
| 384 | if ( y == 0 ) logerror("cga_text_blink_alt_update_row\n"); |
| 385 | for ( i = 0; i < x_count; i++ ) { |
| 386 | UINT16 offset = ( ( ma + i ) << 1 ) & 0x3fff; |
| 387 | UINT8 chr = videoram[ offset ]; |
| 388 | UINT8 attr = videoram[ offset +1 ]; |
| 389 | UINT8 data = cga.chr_gen[ chr * 8 + ra ]; |
| 390 | UINT16 fg = attr & 0x07; |
| 391 | UINT16 bg = 0; |
| 625 | 392 | |
| 626 | | for (sx=0, r.min_x=0, r.max_x=7; sx<columns; |
| 627 | | sx++, offs=(offs+2)&0x3fff, r.min_x+=8, r.max_x+=8) |
| 628 | | { |
| 629 | | int attr = videoram[offs+1]; |
| 630 | | |
| 631 | | if (attr & 0x80) /* blinking ? */ |
| 632 | | { |
| 633 | | if (cga.pc_blink) |
| 634 | | attr = (attr & 0x70) | ((attr & 0x70) >> 4); |
| 635 | | else |
| 636 | | attr = attr & 0x7f; |
| 393 | if ( i == cursor_x ) { |
| 394 | data = 0xFF; |
| 395 | } else { |
| 396 | if ( ( attr & 0x80 ) && ( cga.frame & 0x10 ) ) { |
| 397 | data = 0x00; |
| 398 | bg = ( attr >> 4 ) & 0x07; |
| 637 | 399 | } |
| 638 | | |
| 639 | | drawgfx(bitmap, Machine->gfx[CGA_FONT], videoram[offs], attr, |
| 640 | | 0,0,r.min_x,r.min_y,&r,TRANSPARENCY_NONE,0); |
| 641 | | if (height>16) |
| 642 | | { |
| 643 | | r.min_y+=16; |
| 644 | | drawgfx(bitmap, Machine->gfx[CGA_FONT], videoram[offs], videoram[offs+1], |
| 645 | | 0,0,r.min_x,r.min_y,&r,TRANSPARENCY_NONE,0); |
| 646 | | r.min_y-=16; |
| 647 | | } |
| 648 | | |
| 649 | | if (cursor.on && cga_blinkthisframe() && (offs==cursor.pos*2)) |
| 650 | | { |
| 651 | | int k=height-cursor.top; |
| 652 | | if (cursor.bottom<height) k=cursor.bottom-cursor.top+1; |
| 653 | | |
| 654 | | if (k > 0) |
| 655 | | { |
| 656 | | plot_box(bitmap, r.min_x, |
| 657 | | r.min_y+cursor.top, |
| 658 | | 8, k, Machine->pens[7]); |
| 659 | | } |
| 660 | | } |
| 661 | 400 | } |
| 401 | |
| 402 | *p = ( data & 0x80 ) ? fg : bg; p++; |
| 403 | *p = ( data & 0x40 ) ? fg : bg; p++; |
| 404 | *p = ( data & 0x20 ) ? fg : bg; p++; |
| 405 | *p = ( data & 0x10 ) ? fg : bg; p++; |
| 406 | *p = ( data & 0x08 ) ? fg : bg; p++; |
| 407 | *p = ( data & 0x04 ) ? fg : bg; p++; |
| 408 | *p = ( data & 0x02 ) ? fg : bg; p++; |
| 409 | *p = ( data & 0x01 ) ? fg : bg; p++; |
| 662 | 410 | } |
| 663 | 411 | } |
| 664 | 412 | |
| 665 | 413 | |
| 414 | /* The lo-res graphics mode on a colour composite monitor */ |
| 666 | 415 | |
| 667 | | /*************************************************************************** |
| 668 | | Draw text mode with 40x25 characters (default) and blinking colors. |
| 669 | | The character cell size is 16x8 |
| 670 | | ***************************************************************************/ |
| 416 | static MC6845_UPDATE_ROW( cga_gfx_4bppl_update_row ) { |
| 417 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| 418 | int i; |
| 671 | 419 | |
| 672 | | static void cga_text_blink_alt(bitmap_t *bitmap, struct mscrtc6845 *crtc) |
| 673 | | { |
| 674 | | int sx, sy; |
| 675 | | int offs = mscrtc6845_get_start(crtc)*2; |
| 676 | | int lines = mscrtc6845_get_char_lines(crtc); |
| 677 | | int height = mscrtc6845_get_char_height(crtc); |
| 678 | | int columns = mscrtc6845_get_char_columns(crtc); |
| 679 | | rectangle r; |
| 680 | | struct mscrtc6845_cursor cursor; |
| 681 | | const device_config *screen = video_screen_first(Machine->config); |
| 682 | | int screen_height = video_screen_get_height(screen); |
| 420 | if ( y == 0 ) logerror("cga_gfx_4bppl_update_row\n"); |
| 421 | for ( i = 0; i < x_count; i++ ) { |
| 422 | UINT16 offset = ( ( ( ma + i ) << 1 ) & 0x1fff ) | ( ( y & 1 ) << 13 ); |
| 423 | UINT8 data = videoram[ offset ]; |
| 683 | 424 | |
| 684 | | if (CGA_CHIPSET != CGA_CHIPSET_PC200) |
| 685 | | { |
| 686 | | cga_text_blink(bitmap, crtc); |
| 687 | | return; |
| 425 | *p = data >> 4; p++; |
| 426 | *p = data >> 4; p++; |
| 427 | *p = data & 0x0F; p++; |
| 428 | *p = data & 0x0F; p++; |
| 429 | |
| 430 | data = videoram[ offset + 1 ]; |
| 431 | |
| 432 | *p = data >> 4; p++; |
| 433 | *p = data >> 4; p++; |
| 434 | *p = data & 0x0F; p++; |
| 435 | *p = data & 0x0F; p++; |
| 688 | 436 | } |
| 437 | } |
| 689 | 438 | |
| 690 | | mscrtc6845_time(crtc); |
| 691 | | mscrtc6845_get_cursor(crtc, &cursor); |
| 692 | | pc_cga_check_palette(); |
| 693 | 439 | |
| 694 | | for (sy=0, r.min_y=0, r.max_y=height-1; sy<lines; sy++, r.min_y+=height,r.max_y+=height) |
| 695 | | { |
| 696 | | if (r.min_y >= screen_height) |
| 697 | | break; |
| 440 | /* The hi-res graphics mode on a colour composite monitor |
| 441 | * |
| 442 | * The different scaling factors mean that the '160x200' versions of screens |
| 443 | * are the same size as the normal colour ones. |
| 444 | */ |
| 698 | 445 | |
| 699 | | for (sx=0, r.min_x=0, r.max_x=7; sx<columns; |
| 700 | | sx++, offs=(offs+2)&0x3fff, r.min_x+=8, r.max_x+=8) |
| 701 | | { |
| 702 | | int attr = videoram[offs+1]; |
| 446 | static MC6845_UPDATE_ROW( cga_gfx_4bpph_update_row ) { |
| 447 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| 448 | int i; |
| 703 | 449 | |
| 704 | | if ((attr & 0x80) && cga.pc_blink) /* blinking ? */ |
| 705 | | attr = (attr & 0x70) >> 4; |
| 706 | | else |
| 707 | | attr = attr & 0x0F; |
| 450 | if ( y == 0 ) logerror("cga_gfx_4bpph_update_row\n"); |
| 451 | for ( i = 0; i < x_count; i++ ) { |
| 452 | UINT16 offset = ( ( ( ma + i ) << 1 ) & 0x1fff ) | ( ( y & 1 ) << 13 ); |
| 453 | UINT8 data = videoram[ offset ]; |
| 708 | 454 | |
| 709 | | drawgfx(bitmap, Machine->gfx[CGA_FONT], videoram[offs], attr, |
| 710 | | 0,0,r.min_x,r.min_y,&r,TRANSPARENCY_NONE,0); |
| 455 | *p = data >> 4; p++; |
| 456 | *p = data >> 4; p++; |
| 457 | *p = data & 0x0F; p++; |
| 458 | *p = data & 0x0F; p++; |
| 711 | 459 | |
| 712 | | if (cga_blinkthisframe() && (offs==cursor.pos*2)) |
| 713 | | { |
| 714 | | int k=height-cursor.top; |
| 715 | | if (cursor.bottom<height) k=cursor.bottom-cursor.top+1; |
| 460 | data = videoram[ offset + 1 ]; |
| 716 | 461 | |
| 717 | | if (k > 0) |
| 718 | | { |
| 719 | | plot_box(bitmap, r.min_x, |
| 720 | | r.min_y+cursor.top, |
| 721 | | 8, k, Machine->pens[7]); |
| 722 | | } |
| 723 | | } |
| 724 | | } |
| 462 | *p = data >> 4; p++; |
| 463 | *p = data >> 4; p++; |
| 464 | *p = data & 0x0F; p++; |
| 465 | *p = data & 0x0F; p++; |
| 725 | 466 | } |
| 726 | 467 | } |
| 727 | 468 | |
| 728 | 469 | |
| 729 | | |
| 730 | 470 | /*************************************************************************** |
| 731 | 471 | Draw graphics mode with 320x200 pixels (default) with 2 bits/pixel. |
| 732 | 472 | Even scanlines are from CGA_base + 0x0000, odd from CGA_base + 0x2000 |
| 733 | | cga fetches 2 byte per mscrtc6845 access (not modeled here)! |
| 473 | cga fetches 2 byte per mscrtc6845 access. |
| 734 | 474 | ***************************************************************************/ |
| 735 | 475 | |
| 736 | | static void cga_gfx_2bpp(bitmap_t *bitmap, struct mscrtc6845 *crtc) |
| 737 | | { |
| 738 | | const UINT16 *palette; |
| 739 | | int colorset = cga.color_select & 0x3F; |
| 476 | static MC6845_UPDATE_ROW( cga_gfx_2bpp_update_row ) { |
| 477 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| 478 | int i; |
| 740 | 479 | |
| 741 | | /* Most chipsets use bit 2 of the mode control register to |
| 742 | | * access a third palette. But not consistently. */ |
| 743 | | pc_cga_check_palette(); |
| 744 | | switch(CGA_CHIPSET) |
| 745 | | { |
| 746 | | /* The IBM Professional Graphics Controller behaves like |
| 747 | | * the PC1512, btw. */ |
| 748 | | case CGA_CHIPSET_PC1512: |
| 749 | | if ((colorset < 32) && (cga.mode_control & 4)) colorset += 64; |
| 750 | | break; |
| 480 | // if ( y == 0 ) logerror("cga_gfx_2bpp_update_row\n"); |
| 481 | for ( i = 0; i < x_count; i++ ) { |
| 482 | UINT16 offset = ( ( ( ma + i ) << 1 ) & 0x1fff ) | ( ( y & 1 ) << 13 ); |
| 483 | UINT8 data = videoram[ offset ]; |
| 751 | 484 | |
| 752 | | case CGA_CHIPSET_IBM: |
| 753 | | case CGA_CHIPSET_PC200: |
| 754 | | case CGA_CHIPSET_ATI: |
| 755 | | case CGA_CHIPSET_PARADISE: |
| 756 | | if (cga.mode_control & 4) colorset = (colorset & 0x1F) + 64; |
| 757 | | break; |
| 758 | | } |
| 485 | *p = cga.palette_lut_2bpp[ ( data >> 6 ) & 0x03 ]; p++; |
| 486 | *p = cga.palette_lut_2bpp[ ( data >> 4 ) & 0x03 ]; p++; |
| 487 | *p = cga.palette_lut_2bpp[ ( data >> 2 ) & 0x03 ]; p++; |
| 488 | *p = cga.palette_lut_2bpp[ data & 0x03 ]; p++; |
| 759 | 489 | |
| 760 | | /* The fact that our palette is located in cga_colortable is a vestigial |
| 761 | | * aspect from when we were doing that ugly trick where drawgfx() would |
| 762 | | * handle graphics drawing. Truthfully, we should probably be using |
| 763 | | * palette_set_color_rgb() here and not doing the palette lookup in the loop |
| 764 | | */ |
| 765 | | palette = &cga_colortable[256*2 + 16*2] + colorset * 4; |
| 490 | data = videoram[ offset+1 ]; |
| 766 | 491 | |
| 767 | | pc_render_gfx_2bpp(bitmap, crtc, NULL, palette, 2); |
| 492 | *p = cga.palette_lut_2bpp[ ( data >> 6 ) & 0x03 ]; p++; |
| 493 | *p = cga.palette_lut_2bpp[ ( data >> 4 ) & 0x03 ]; p++; |
| 494 | *p = cga.palette_lut_2bpp[ ( data >> 2 ) & 0x03 ]; p++; |
| 495 | *p = cga.palette_lut_2bpp[ data & 0x03 ]; p++; |
| 496 | } |
| 768 | 497 | } |
| 769 | 498 | |
| 770 | 499 | |
| 771 | | |
| 772 | 500 | /*************************************************************************** |
| 773 | 501 | Draw graphics mode with 640x200 pixels (default). |
| 774 | 502 | The cell size is 1x1 (1 scanline is the real default) |
| 775 | 503 | Even scanlines are from CGA_base + 0x0000, odd from CGA_base + 0x2000 |
| 776 | 504 | ***************************************************************************/ |
| 777 | 505 | |
| 778 | | static void cga_gfx_1bpp(bitmap_t *bitmap, struct mscrtc6845 *crtc) |
| 779 | | { |
| 780 | | const UINT16 *palette; |
| 781 | | |
| 782 | | /* The fact that our palette is located in cga_colortable is a vestigial |
| 783 | | * aspect from when we were doing that silly trick where drawgfx() would |
| 784 | | * handle graphics drawing. Truthfully, we should probably be using |
| 785 | | * palette_set_color_rgb() here and not doing the palette lookup in the loop |
| 786 | | */ |
| 787 | | palette = &cga_colortable[256*2] + (cga.color_select & 0xf) * 2; |
| 788 | | |
| 789 | | pc_render_gfx_1bpp(bitmap, crtc, NULL, palette, 2); |
| 790 | | } |
| 791 | | |
| 792 | | |
| 793 | | |
| 794 | | INLINE void cga_plot_unit_4bpp(bitmap_t *bitmap, |
| 795 | | int x, int y, int offs, int scale) |
| 796 | | { |
| 797 | | int color; |
| 506 | static MC6845_UPDATE_ROW( cga_gfx_1bpp_update_row ) { |
| 507 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| 508 | UINT8 fg = cga.color_select & 0x0F; |
| 798 | 509 | int i; |
| 799 | 510 | |
| 800 | | color = (videoram[offs] & 0xF0) >> 4; |
| 801 | | for (i = 0; i < scale; i++) *BITMAP_ADDR16(bitmap, y, x++) = Machine->pens[color]; |
| 802 | | color = videoram[offs] & 0x0F; |
| 803 | | for (i = 0; i < scale; i++) *BITMAP_ADDR16(bitmap, y, x++) = Machine->pens[color]; |
| 804 | | } |
| 511 | if ( y == 0 ) logerror("cga_gfx_1bpp_update_row\n"); |
| 512 | for ( i = 0; i < x_count; i++ ) { |
| 513 | UINT16 offset = ( ( ( ma + i ) << 1 ) & 0x1fff ) | ( ( y & 1 ) << 13 ); |
| 514 | UINT8 data = videoram[ offset ]; |
| 805 | 515 | |
| 516 | *p = ( data & 0x80 ) ? fg : 0; p++; |
| 517 | *p = ( data & 0x40 ) ? fg : 0; p++; |
| 518 | *p = ( data & 0x20 ) ? fg : 0; p++; |
| 519 | *p = ( data & 0x10 ) ? fg : 0; p++; |
| 520 | *p = ( data & 0x08 ) ? fg : 0; p++; |
| 521 | *p = ( data & 0x04 ) ? fg : 0; p++; |
| 522 | *p = ( data & 0x02 ) ? fg : 0; p++; |
| 523 | *p = ( data & 0x01 ) ? fg : 0; p++; |
| 806 | 524 | |
| 807 | | static void cga_gfx_4bpp(bitmap_t *bitmap, struct mscrtc6845 *crtc, int scale) |
| 808 | | { |
| 809 | | int i, sx, sy, sh; |
| 810 | | int offs = mscrtc6845_get_start(crtc)*2; |
| 811 | | int lines = mscrtc6845_get_char_lines(crtc); |
| 812 | | int height = mscrtc6845_get_char_height(crtc); |
| 813 | | int columns = mscrtc6845_get_char_columns(crtc)*2; |
| 525 | data = videoram[ offset + 1 ]; |
| 814 | 526 | |
| 815 | | pc_cga_check_palette(); |
| 816 | | |
| 817 | | for (sy=0; sy<lines; sy++,offs=(offs+columns)&0x1fff) |
| 818 | | { |
| 819 | | for (sh=0; sh<height; sh++, offs|=0x2000) |
| 820 | | { |
| 821 | | // char line 0 used as a12 line in graphic mode |
| 822 | | if (!(sh & 1)) |
| 823 | | { |
| 824 | | for (i=offs, sx=0; sx<columns; sx++, i=(i+1)&0x1fff) |
| 825 | | { |
| 826 | | cga_plot_unit_4bpp(bitmap, sx*scale, sy*height+sh, i, scale/2); |
| 827 | | } |
| 828 | | } |
| 829 | | else |
| 830 | | { |
| 831 | | for (i=offs|0x2000, sx=0; sx<columns; sx++, i=((i+1)&0x1fff)|0x2000) |
| 832 | | { |
| 833 | | cga_plot_unit_4bpp(bitmap, sx*scale, sy*height+sh, i, scale/2); |
| 834 | | } |
| 835 | | } |
| 836 | | } |
| 527 | *p = ( data & 0x80 ) ? fg : 0; p++; |
| 528 | *p = ( data & 0x80 ) ? fg : 0; p++; |
| 529 | *p = ( data & 0x80 ) ? fg : 0; p++; |
| 530 | *p = ( data & 0x80 ) ? fg : 0; p++; |
| 531 | *p = ( data & 0x80 ) ? fg : 0; p++; |
| 532 | *p = ( data & 0x80 ) ? fg : 0; p++; |
| 533 | *p = ( data & 0x80 ) ? fg : 0; p++; |
| 534 | *p = ( data & 0x80 ) ? fg : 0; p++; |
| 837 | 535 | } |
| 838 | 536 | } |
| 839 | 537 | |
| 840 | 538 | |
| 841 | | /* The hi-res graphics mode on a colour composite monitor |
| 842 | | * |
| 843 | | * The different scaling factors mean that the '160x200' versions of screens |
| 844 | | * are the same size as the normal colour ones. |
| 845 | | */ |
| 846 | | static void cga_gfx_4bpph(bitmap_t *bitmap, struct mscrtc6845 *crtc) |
| 847 | | { |
| 848 | | pc_cga_check_palette(); |
| 849 | | cga_gfx_4bpp(bitmap, crtc, 8); |
| 539 | static MC6845_UPDATE_ROW( cga_update_row ) { |
| 540 | if ( cga.update_row ) { |
| 541 | cga.update_row( device, bitmap, cliprect, ma, ra, y, x_count, cursor_x, param ); |
| 542 | } |
| 850 | 543 | } |
| 851 | 544 | |
| 852 | 545 | |
| 853 | | /* The lo-res graphics mode on a colour composite monitor */ |
| 854 | | static void cga_gfx_4bppl(bitmap_t *bitmap, struct mscrtc6845 *crtc) |
| 855 | | { |
| 856 | | pc_cga_check_palette(); |
| 857 | | cga_gfx_4bpp(bitmap, crtc, 4); |
| 546 | static MC6845_ON_HSYNC_CHANGED( cga_hsync_changed ) { |
| 547 | cga.hsync = hsync ? 1 : 0; |
| 858 | 548 | } |
| 859 | 549 | |
| 860 | 550 | |
| 861 | | |
| 862 | | |
| 863 | | INLINE void pgfx_plot_unit_4bpp(bitmap_t *bitmap, |
| 864 | | int x, int y, int offs) |
| 865 | | { |
| 866 | | int color, values[2]; |
| 867 | | int i; |
| 868 | | |
| 869 | | if (cga.plantronics & 0x40) |
| 870 | | { |
| 871 | | values[0] = videoram[offs | 0x4000]; |
| 872 | | values[1] = videoram[offs]; |
| 551 | static MC6845_ON_VSYNC_CHANGED( cga_vsync_changed ) { |
| 552 | cga.vsync = vsync ? 8 : 0; |
| 553 | if ( vsync ) { |
| 554 | cga.frame++; |
| 873 | 555 | } |
| 874 | | else |
| 875 | | { |
| 876 | | values[0] = videoram[offs]; |
| 877 | | values[1] = videoram[offs | 0x4000]; |
| 878 | | } |
| 879 | | for (i=3; i>=0; i--) |
| 880 | | { |
| 881 | | color = ((values[0] & 0x3) << 1) | |
| 882 | | ((values[1] & 2) >> 1) | |
| 883 | | ((values[1] & 1) << 3); |
| 884 | | *BITMAP_ADDR16(bitmap, y, x+i) = Machine->pens[color]; |
| 885 | | values[0]>>=2; |
| 886 | | values[1]>>=2; |
| 887 | | } |
| 888 | 556 | } |
| 889 | 557 | |
| 890 | 558 | |
| 891 | | |
| 892 | | /*************************************************************************** |
| 893 | | Draw graphics mode with 640x200 pixels (default) with 2 bits/pixel. |
| 894 | | Even scanlines are from CGA_base + 0x0000, odd from CGA_base + 0x2000 |
| 895 | | Second plane at CGA_base + 0x4000 / 0x6000 |
| 896 | | ***************************************************************************/ |
| 897 | | |
| 898 | | static void cga_pgfx_4bpp(bitmap_t *bitmap, struct mscrtc6845 *crtc) |
| 899 | | { |
| 900 | | int i, sx, sy, sh; |
| 901 | | int offs = mscrtc6845_get_start(crtc)*2; |
| 902 | | int lines = mscrtc6845_get_char_lines(crtc); |
| 903 | | int height = mscrtc6845_get_char_height(crtc); |
| 904 | | int columns = mscrtc6845_get_char_columns(crtc)*2; |
| 905 | | |
| 906 | | for (sy=0; sy<lines; sy++,offs=(offs+columns)&0x1fff) |
| 907 | | { |
| 908 | | for (sh=0; sh<height; sh++, offs|=0x2000) |
| 909 | | { |
| 910 | | // char line 0 used as a12 line in graphic mode |
| 911 | | if (!(sh & 1)) |
| 912 | | { |
| 913 | | for (i=offs, sx=0; sx<columns; sx++, i=(i+1)&0x1fff) |
| 914 | | { |
| 915 | | pgfx_plot_unit_4bpp(bitmap, sx*4, sy*height+sh, i); |
| 916 | | } |
| 917 | | } |
| 918 | | else |
| 919 | | { |
| 920 | | for (i=offs|0x2000, sx=0; sx<columns; sx++, i=((i+1)&0x1fff)|0x2000) |
| 921 | | { |
| 922 | | pgfx_plot_unit_4bpp(bitmap, sx*4, sy*height+sh, i); |
| 923 | | } |
| 924 | | } |
| 559 | static void pc_cga_set_palette_luts(void) { |
| 560 | /* Setup 2bpp palette lookup table */ |
| 561 | if ( cga.mode_control & 0x10 ) { |
| 562 | cga.palette_lut_2bpp[0] = 0; |
| 563 | } else { |
| 564 | cga.palette_lut_2bpp[0] = cga.color_select & 0x0F; |
| 565 | } |
| 566 | if ( cga.mode_control & 0x04 ) { |
| 567 | cga.palette_lut_2bpp[1] = ( ( cga.color_select & 0x10 ) >> 1 ) | 3; |
| 568 | cga.palette_lut_2bpp[2] = ( ( cga.color_select & 0x10 ) >> 1 ) | 4; |
| 569 | cga.palette_lut_2bpp[3] = ( ( cga.color_select & 0x10 ) >> 1 ) | 7; |
| 570 | } else { |
| 571 | if ( cga.color_select & 0x20 ) { |
| 572 | cga.palette_lut_2bpp[1] = ( ( cga.color_select & 0x10 ) >> 1 ) | 3; |
| 573 | cga.palette_lut_2bpp[2] = ( ( cga.color_select & 0x10 ) >> 1 ) | 5; |
| 574 | cga.palette_lut_2bpp[3] = ( ( cga.color_select & 0x10 ) >> 1 ) | 7; |
| 575 | } else { |
| 576 | cga.palette_lut_2bpp[1] = ( ( cga.color_select & 0x10 ) >> 1 ) | 2; |
| 577 | cga.palette_lut_2bpp[2] = ( ( cga.color_select & 0x10 ) >> 1 ) | 4; |
| 578 | cga.palette_lut_2bpp[3] = ( ( cga.color_select & 0x10 ) >> 1 ) | 6; |
| 925 | 579 | } |
| 926 | 580 | } |
| 581 | //logerror("2bpp lut set to %d,%d,%d,%d\n", cga.palette_lut_2bpp[0], cga.palette_lut_2bpp[1], cga.palette_lut_2bpp[2], cga.palette_lut_2bpp[3]); |
| 927 | 582 | } |
| 928 | 583 | |
| 929 | | |
| 930 | | |
| 931 | | INLINE void pgfx_plot_unit_2bpp(bitmap_t *bitmap, |
| 932 | | int x, int y, const UINT16 *palette, int offs) |
| 584 | /* |
| 585 | * rW CGA mode control register (see #P138) |
| 586 | */ |
| 587 | static void pc_cga_mode_control_w(int data) |
| 933 | 588 | { |
| 934 | | int i; |
| 935 | | UINT8 bmap[2], values[2]; |
| 936 | | UINT16 *dest; |
| 589 | unsigned char mask = 0x3B; |
| 937 | 590 | |
| 938 | | if (cga.plantronics & 0x40) |
| 939 | | { |
| 940 | | values[0] = videoram[offs]; |
| 941 | | values[1] = videoram[offs | 0x4000]; |
| 942 | | } |
| 943 | | else |
| 944 | | { |
| 945 | | values[0] = videoram[offs | 0x4000]; |
| 946 | | values[1] = videoram[offs]; |
| 947 | | } |
| 948 | | bmap[0] = bmap[1] = 0; |
| 949 | | for (i=3; i>=0; i--) |
| 950 | | { |
| 951 | | bmap[0] = bmap[0] << 1; if (values[0] & 0x80) bmap[0] |= 1; |
| 952 | | bmap[0] = bmap[0] << 1; if (values[1] & 0x80) bmap[0] |= 1; |
| 953 | | bmap[1] = bmap[1] << 1; if (values[0] & 0x08) bmap[1] |= 1; |
| 954 | | bmap[1] = bmap[1] << 1; if (values[1] & 0x08) bmap[1] |= 1; |
| 955 | | values[0] = values[0] << 1; |
| 956 | | values[1] = values[1] << 1; |
| 957 | | } |
| 591 | CGA_LOG(1,"CGA_mode_control_w",("$%02x: columns %d, gfx %d, hires %d, blink %d\n", |
| 592 | data, (data&1)?80:40, (data>>1)&1, (data>>4)&1, (data>>5)&1)); |
| 958 | 593 | |
| 959 | | dest = BITMAP_ADDR16(bitmap, y, x); |
| 960 | | *(dest++) = palette[(bmap[0] >> 6) & 0x03]; |
| 961 | | *(dest++) = palette[(bmap[0] >> 4) & 0x03]; |
| 962 | | *(dest++) = palette[(bmap[0] >> 2) & 0x03]; |
| 963 | | *(dest++) = palette[(bmap[0] >> 0) & 0x03]; |
| 964 | | *(dest++) = palette[(bmap[1] >> 6) & 0x03]; |
| 965 | | *(dest++) = palette[(bmap[1] >> 4) & 0x03]; |
| 966 | | *(dest++) = palette[(bmap[1] >> 2) & 0x03]; |
| 967 | | *(dest++) = palette[(bmap[1] >> 0) & 0x03]; |
| 968 | | } |
| 594 | /* CGA composite: Switching between mono & colour behaves like a |
| 595 | * mode change */ |
| 596 | if(CGA_MONITOR == CGA_MONITOR_COMPOSITE) mask = 0x3F; |
| 597 | cga.mode_control = data; |
| 969 | 598 | |
| 970 | | |
| 971 | | |
| 972 | | /*************************************************************************** |
| 973 | | Draw graphics mode with 320x200 pixels (default) with 2 bits/pixel. |
| 974 | | Even scanlines are from CGA_base + 0x0000, odd from CGA_base + 0x2000 |
| 975 | | cga fetches 2 byte per mscrtc6845 access (not modeled here)! |
| 976 | | ***************************************************************************/ |
| 977 | | |
| 978 | | static void cga_pgfx_2bpp(bitmap_t *bitmap, struct mscrtc6845 *crtc) |
| 979 | | { |
| 980 | | int i, sx, sy, sh; |
| 981 | | int offs = mscrtc6845_get_start(crtc)*2; |
| 982 | | int lines = mscrtc6845_get_char_lines(crtc); |
| 983 | | int height = mscrtc6845_get_char_height(crtc); |
| 984 | | int columns = mscrtc6845_get_char_columns(crtc)*2; |
| 985 | | int colorset = cga.color_select & 0x3F; |
| 986 | | const UINT16 *palette; |
| 987 | | |
| 988 | | /* Most chipsets use bit 2 of the mode control register to |
| 989 | | * access a third palette. But not consistently. */ |
| 990 | | pc_cga_check_palette(); |
| 991 | | switch(CGA_CHIPSET) |
| 992 | | { |
| 993 | | /* The IBM Professional Graphics Controller behaves like |
| 994 | | * the PC1512, btw. */ |
| 995 | | case CGA_CHIPSET_PC1512: |
| 996 | | if ((colorset < 32) && (cga.mode_control & 4)) colorset += 64; |
| 599 | //logerror("mode set to %02X\n", cga.mode_control & 0x3F ); |
| 600 | switch ( cga.mode_control & 0x3F ) { |
| 601 | case 0x08: case 0x09: case 0x0C: case 0x0D: |
| 602 | cga.update_row = cga_text_inten_update_row; |
| 997 | 603 | break; |
| 998 | | |
| 999 | | case CGA_CHIPSET_IBM: |
| 1000 | | case CGA_CHIPSET_PC200: |
| 1001 | | case CGA_CHIPSET_ATI: |
| 1002 | | case CGA_CHIPSET_PARADISE: |
| 1003 | | if (cga.mode_control & 4) colorset = (colorset & 0x1F) + 64; |
| 604 | case 0x0A: case 0x0B: case 0x2A: case 0x2B: |
| 605 | if ( CGA_MONITOR == CGA_MONITOR_COMPOSITE ) { |
| 606 | cga.update_row = cga_gfx_4bppl_update_row; |
| 607 | } else { |
| 608 | cga.update_row = cga_gfx_2bpp_update_row; |
| 609 | } |
| 1004 | 610 | break; |
| 611 | case 0x0E: case 0x0F: case 0x2E: case 0x2F: |
| 612 | cga.update_row = cga_gfx_2bpp_update_row; |
| 613 | break; |
| 614 | case 0x18: case 0x19: case 0x1C: case 0x1D: |
| 615 | cga.update_row = cga_text_inten_alt_update_row; |
| 616 | break; |
| 617 | case 0x1A: case 0x1B: case 0x3A: case 0x3B: |
| 618 | if ( CGA_MONITOR == CGA_MONITOR_COMPOSITE ) { |
| 619 | cga.update_row = cga_gfx_4bpph_update_row; |
| 620 | } else { |
| 621 | cga.update_row = cga_gfx_2bpp_update_row; |
| 622 | } |
| 623 | break; |
| 624 | case 0x1E: case 0x1F: case 0x3E: case 0x3F: |
| 625 | cga.update_row = cga_gfx_1bpp_update_row; |
| 626 | break; |
| 627 | case 0x28: case 0x29: case 0x2C: case 0x2D: |
| 628 | cga.update_row = cga_text_blink_update_row; |
| 629 | break; |
| 630 | case 0x38: case 0x39: case 0x3C: case 0x3D: |
| 631 | cga.update_row = cga_text_blink_alt_update_row; |
| 632 | break; |
| 633 | default: |
| 634 | cga.update_row = NULL; |
| 635 | break; |
| 1005 | 636 | } |
| 1006 | 637 | |
| 638 | pc_cga_set_palette_luts(); |
| 639 | } |
| 1007 | 640 | |
| 1008 | | /* The fact that our palette is located in cga_colortable is a vestigial |
| 1009 | | * aspect from when we were doing that ugly trick where drawgfx() would |
| 1010 | | * handle graphics drawing. Truthfully, we should probably be using |
| 1011 | | * palette_set_color_rgb() here and not doing the palette lookup in the loop |
| 1012 | | */ |
| 1013 | | palette = &cga_colortable[256*2 + 16*2] + colorset * 4; |
| 1014 | 641 | |
| 1015 | | for (sy=0; sy<lines; sy++,offs=(offs+columns)&0x1fff) { |
| 1016 | 642 | |
| 1017 | | for (sh=0; sh<height; sh++) |
| 1018 | | { |
| 1019 | | if (!(sh&1)) { // char line 0 used as a12 line in graphic mode |
| 1020 | | for (i=offs, sx=0; sx<columns; sx++, i=(i+1)&0x1fff) |
| 1021 | | { |
| 1022 | | pgfx_plot_unit_2bpp(bitmap, sx*8, sy*height+sh, palette, i); |
| 1023 | | } |
| 1024 | | } |
| 1025 | | else |
| 1026 | | { |
| 1027 | | for (i=offs|0x2000, sx=0; sx<columns; sx++, i=((i+1)&0x1fff)|0x2000) |
| 1028 | | { |
| 1029 | | pgfx_plot_unit_2bpp(bitmap, sx*8, sy*height+sh, palette, i); |
| 1030 | | } |
| 1031 | | } |
| 1032 | | } |
| 1033 | | } |
| 643 | /* |
| 644 | * ?W reserved for color select register on color adapter |
| 645 | */ |
| 646 | static void pc_cga_color_select_w(int data) |
| 647 | { |
| 648 | CGA_LOG(1,"CGA_color_select_w",("$%02x\n", data)); |
| 649 | cga.color_select = data; |
| 650 | //logerror("color_select_w: %02X\n", data); |
| 651 | pc_cga_set_palette_luts(); |
| 1034 | 652 | } |
| 1035 | 653 | |
| 1036 | 654 | |
| 1037 | 655 | |
| 1038 | | // amstrad pc1512 video hardware |
| 1039 | | // mapping of the 4 planes into videoram |
| 1040 | | // (text data should be readable at videoram+0) |
| 1041 | | static const int videoram_offset[4]= { 0xc000, 0x8000, 0x4000, 0 }; |
| 1042 | | INLINE void pc1512_plot_unit(bitmap_t *bitmap, |
| 1043 | | int x, int y, int offs) |
| 656 | /* |
| 657 | * Select Plantronics modes |
| 658 | */ |
| 659 | static void pc_cga_plantronics_w(int data) |
| 1044 | 660 | { |
| 1045 | | int color, values[4]; |
| 1046 | | int i; |
| 661 | CGA_LOG(1,"CGA_plantronics_w",("$%02x\n", data)); |
| 1047 | 662 | |
| 1048 | | for (i = 0; i < 4; i++) values[i] = 0; |
| 663 | if (CGA_CHIPSET != CGA_CHIPSET_ATI) return; |
| 1049 | 664 | |
| 1050 | | if (cga.color_select & 1) values[0]=videoram[offs|videoram_offset[0]]; // red |
| 1051 | | if (cga.color_select & 2) values[1]=videoram[offs|videoram_offset[1]]<<1; // green |
| 1052 | | if (cga.color_select & 4) values[2]=videoram[offs|videoram_offset[2]]<<2; // blue |
| 1053 | | if (cga.color_select & 8) values[3]=videoram[offs|videoram_offset[3]]<<3; // intensity |
| 1054 | | |
| 1055 | | for (i=7; i>=0; i--) |
| 1056 | | { |
| 1057 | | color = (values[0]&1)|(values[1]&2)|(values[2]&4)|(values[3]&8); |
| 1058 | | *BITMAP_ADDR16(bitmap, y, x+i) = Machine->pens[color]; |
| 1059 | | values[0]>>=1; |
| 1060 | | values[1]>>=1; |
| 1061 | | values[2]>>=1; |
| 1062 | | values[3]>>=1; |
| 1063 | | } |
| 665 | data &= 0x70; /* Only bits 6-4 are used */ |
| 666 | if (cga.plantronics == data) return; |
| 667 | cga.plantronics = data; |
| 1064 | 668 | } |
| 1065 | 669 | |
| 1066 | 670 | |
| 1067 | 671 | |
| 1068 | | /*************************************************************************** |
| 1069 | | Draw graphics mode with 640x200 pixels (default). |
| 1070 | | The cell size is 1x1 (1 scanline is the real default) |
| 1071 | | Even scanlines are from CGA_base + 0x0000, odd from CGA_base + 0x2000 |
| 1072 | | ***************************************************************************/ |
| 672 | /************************************************************************* |
| 673 | * |
| 674 | * CGA |
| 675 | * color graphics adapter |
| 676 | * |
| 677 | *************************************************************************/ |
| 1073 | 678 | |
| 1074 | | static void pc1512_gfx_4bpp(bitmap_t *bitmap, struct mscrtc6845 *crtc) |
| 679 | static READ8_HANDLER( pc_cga8_r ) |
| 1075 | 680 | { |
| 1076 | | int i, sx, sy, sh; |
| 1077 | | int offs = mscrtc6845_get_start(crtc)*2; |
| 1078 | | int lines = mscrtc6845_get_char_lines(crtc); |
| 1079 | | int height = mscrtc6845_get_char_height(crtc); |
| 1080 | | int columns = mscrtc6845_get_char_columns(crtc)*2; |
| 1081 | | |
| 1082 | | for (sy=0; sy<lines; sy++,offs=(offs+columns)&0x1fff) |
| 681 | device_config *devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, CGA_MC6845_NAME); |
| 682 | int data = 0xff; |
| 683 | switch( offset ) |
| 1083 | 684 | { |
| 1084 | | for (sh=0; sh<height; sh++) |
| 1085 | | { |
| 1086 | | if (sy*height+sh >= bitmap->height) |
| 1087 | | break; |
| 1088 | | // char line 0 used as a12 line in graphic mode |
| 1089 | | if (!(sh & 1)) |
| 1090 | | { |
| 1091 | | for (i=offs, sx=0; sx<columns; sx++, i=(i+1)&0x1fff) |
| 1092 | | { |
| 1093 | | pc1512_plot_unit(bitmap, sx*8, sy*height+sh, i); |
| 1094 | | } |
| 1095 | | } |
| 1096 | | else |
| 1097 | | { |
| 1098 | | for (i=offs|0x2000, sx=0; sx<columns; sx++, i=((i+1)&0x1fff)|0x2000) |
| 1099 | | { |
| 1100 | | pc1512_plot_unit(bitmap, sx*8, sy*height+sh, i); |
| 1101 | | } |
| 1102 | | } |
| 1103 | | } |
| 1104 | | if (sy*height >= bitmap->height) |
| 685 | case 0: case 2: case 4: case 6: |
| 686 | /* return last written mc6845 address value here? */ |
| 1105 | 687 | break; |
| 1106 | | } |
| 688 | case 1: case 3: case 5: case 7: |
| 689 | data = mc6845_register_r( devconf, offset ); |
| 690 | break; |
| 691 | case 10: |
| 692 | data = cga.vsync | ( ( data & 0x40 ) >> 4 ) | cga.hsync; |
| 693 | break; |
| 694 | } |
| 695 | return data; |
| 1107 | 696 | } |
| 1108 | 697 | |
| 1109 | 698 | |
| 1110 | 699 | |
| 1111 | | /*************************************************************************** |
| 1112 | | Mark all text positions with attribute bit 7 set dirty |
| 1113 | | ***************************************************************************/ |
| 1114 | | |
| 1115 | | static void pc_cga_blink_textcolors(int on) |
| 700 | static WRITE8_HANDLER( pc_cga8_w ) |
| 1116 | 701 | { |
| 1117 | | int offs, size; |
| 702 | device_config *devconf; |
| 1118 | 703 | |
| 1119 | | if (cga.pc_blink == on) return; |
| 1120 | | |
| 1121 | | cga.pc_blink = on; |
| 1122 | | offs = (mscrtc6845_get_start(mscrtc6845)*2) & 0x3fff; |
| 1123 | | size = mscrtc6845_get_char_lines(mscrtc6845)*mscrtc6845_get_char_columns(mscrtc6845); |
| 704 | switch(offset) { |
| 705 | case 0: case 2: case 4: case 6: |
| 706 | devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, CGA_MC6845_NAME); |
| 707 | mc6845_address_w( devconf, offset, data ); |
| 708 | break; |
| 709 | case 1: case 3: case 5: case 7: |
| 710 | devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, CGA_MC6845_NAME); |
| 711 | mc6845_register_w( devconf, offset, data ); |
| 712 | break; |
| 713 | case 8: |
| 714 | pc_cga_mode_control_w(data); |
| 715 | break; |
| 716 | case 9: |
| 717 | pc_cga_color_select_w(data); |
| 718 | break; |
| 719 | case 0x0d: |
| 720 | pc_cga_plantronics_w(data); |
| 721 | break; |
| 722 | } |
| 1124 | 723 | } |
| 1125 | 724 | |
| 1126 | 725 | |
| 1127 | 726 | |
| 1128 | | static TIMER_CALLBACK(cga_timerproc) |
| 1129 | | { |
| 1130 | | cga.frame++; |
| 1131 | | if ((cga.frame & 1) == 0) |
| 1132 | | pc_cga_blink_textcolors(cga.frame & 2); |
| 1133 | | } |
| 727 | static READ16_HANDLER( pc_cga16le_r ) { return read16le_with_read8_handler(pc_cga8_r,machine, offset, mem_mask); } |
| 728 | static WRITE16_HANDLER( pc_cga16le_w ) { write16le_with_write8_handler(pc_cga8_w, machine, offset, data, mem_mask); } |
| 729 | static READ32_HANDLER( pc_cga32le_r ) { return read32le_with_read8_handler(pc_cga8_r, machine, offset, mem_mask); } |
| 730 | static WRITE32_HANDLER( pc_cga32le_w ) { write32le_with_write8_handler(pc_cga8_w, machine, offset, data, mem_mask); } |
| 1134 | 731 | |
| 1135 | 732 | |
| 733 | /* Old plantronics rendering code, leaving it uncommented until we have re-implemented it */ |
| 1136 | 734 | |
| 1137 | | static int cga_blinkthisframe(void) |
| 1138 | | { |
| 1139 | | return cga.frame & 1; |
| 1140 | | } |
| 735 | // |
| 736 | // From choosevideomode: |
| 737 | // |
| 738 | // /* Plantronics high-res */ |
| 739 | // if ((cga.mode_control & 2) && (cga.plantronics & 0x20)) |
| 740 | // proc = cga_pgfx_2bpp; |
| 741 | // /* Plantronics low-res */ |
| 742 | // if ((cga.mode_control & 2) && (cga.plantronics & 0x10)) |
| 743 | // proc = cga_pgfx_4bpp; |
| 744 | // |
| 1141 | 745 | |
| 746 | //INLINE void pgfx_plot_unit_4bpp(bitmap_t *bitmap, |
| 747 | // int x, int y, int offs) |
| 748 | //{ |
| 749 | // int color, values[2]; |
| 750 | // int i; |
| 751 | // |
| 752 | // if (cga.plantronics & 0x40) |
| 753 | // { |
| 754 | // values[0] = videoram[offs | 0x4000]; |
| 755 | // values[1] = videoram[offs]; |
| 756 | // } |
| 757 | // else |
| 758 | // { |
| 759 | // values[0] = videoram[offs]; |
| 760 | // values[1] = videoram[offs | 0x4000]; |
| 761 | // } |
| 762 | // for (i=3; i>=0; i--) |
| 763 | // { |
| 764 | // color = ((values[0] & 0x3) << 1) | |
| 765 | // ((values[1] & 2) >> 1) | |
| 766 | // ((values[1] & 1) << 3); |
| 767 | // *BITMAP_ADDR16(bitmap, y, x+i) = Machine->pens[color]; |
| 768 | // values[0]>>=2; |
| 769 | // values[1]>>=2; |
| 770 | // } |
| 771 | //} |
| 772 | // |
| 773 | // |
| 774 | // |
| 775 | ///*************************************************************************** |
| 776 | // Draw graphics mode with 640x200 pixels (default) with 2 bits/pixel. |
| 777 | // Even scanlines are from CGA_base + 0x0000, odd from CGA_base + 0x2000 |
| 778 | // Second plane at CGA_base + 0x4000 / 0x6000 |
| 779 | //***************************************************************************/ |
| 780 | // |
| 781 | //static void cga_pgfx_4bpp(bitmap_t *bitmap, struct mscrtc6845 *crtc) |
| 782 | //{ |
| 783 | // int i, sx, sy, sh; |
| 784 | // int offs = mscrtc6845_get_start(crtc)*2; |
| 785 | // int lines = mscrtc6845_get_char_lines(crtc); |
| 786 | // int height = mscrtc6845_get_char_height(crtc); |
| 787 | // int columns = mscrtc6845_get_char_columns(crtc)*2; |
| 788 | // |
| 789 | // for (sy=0; sy<lines; sy++,offs=(offs+columns)&0x1fff) |
| 790 | // { |
| 791 | // for (sh=0; sh<height; sh++, offs|=0x2000) |
| 792 | // { |
| 793 | // // char line 0 used as a12 line in graphic mode |
| 794 | // if (!(sh & 1)) |
| 795 | // { |
| 796 | // for (i=offs, sx=0; sx<columns; sx++, i=(i+1)&0x1fff) |
| 797 | // { |
| 798 | // pgfx_plot_unit_4bpp(bitmap, sx*4, sy*height+sh, i); |
| 799 | // } |
| 800 | // } |
| 801 | // else |
| 802 | // { |
| 803 | // for (i=offs|0x2000, sx=0; sx<columns; sx++, i=((i+1)&0x1fff)|0x2000) |
| 804 | // { |
| 805 | // pgfx_plot_unit_4bpp(bitmap, sx*4, sy*height+sh, i); |
| 806 | // } |
| 807 | // } |
| 808 | // } |
| 809 | // } |
| 810 | //} |
| 811 | // |
| 812 | // |
| 813 | // |
| 814 | //INLINE void pgfx_plot_unit_2bpp(bitmap_t *bitmap, |
| 815 | // int x, int y, const UINT16 *palette, int offs) |
| 816 | //{ |
| 817 | // int i; |
| 818 | // UINT8 bmap[2], values[2]; |
| 819 | // UINT16 *dest; |
| 820 | // |
| 821 | // if (cga.plantronics & 0x40) |
| 822 | // { |
| 823 | // values[0] = videoram[offs]; |
| 824 | // values[1] = videoram[offs | 0x4000]; |
| 825 | // } |
| 826 | // else |
| 827 | // { |
| 828 | // values[0] = videoram[offs | 0x4000]; |
| 829 | // values[1] = videoram[offs]; |
| 830 | // } |
| 831 | // bmap[0] = bmap[1] = 0; |
| 832 | // for (i=3; i>=0; i--) |
| 833 | // { |
| 834 | // bmap[0] = bmap[0] << 1; if (values[0] & 0x80) bmap[0] |= 1; |
| 835 | // bmap[0] = bmap[0] << 1; if (values[1] & 0x80) bmap[0] |= 1; |
| 836 | // bmap[1] = bmap[1] << 1; if (values[0] & 0x08) bmap[1] |= 1; |
| 837 | // bmap[1] = bmap[1] << 1; if (values[1] & 0x08) bmap[1] |= 1; |
| 838 | // values[0] = values[0] << 1; |
| 839 | // values[1] = values[1] << 1; |
| 840 | // } |
| 841 | // |
| 842 | // dest = BITMAP_ADDR16(bitmap, y, x); |
| 843 | // *(dest++) = palette[(bmap[0] >> 6) & 0x03]; |
| 844 | // *(dest++) = palette[(bmap[0] >> 4) & 0x03]; |
| 845 | // *(dest++) = palette[(bmap[0] >> 2) & 0x03]; |
| 846 | // *(dest++) = palette[(bmap[0] >> 0) & 0x03]; |
| 847 | // *(dest++) = palette[(bmap[1] >> 6) & 0x03]; |
| 848 | // *(dest++) = palette[(bmap[1] >> 4) & 0x03]; |
| 849 | // *(dest++) = palette[(bmap[1] >> 2) & 0x03]; |
| 850 | // *(dest++) = palette[(bmap[1] >> 0) & 0x03]; |
| 851 | //} |
| 852 | // |
| 853 | // |
| 854 | // |
| 855 | ///*************************************************************************** |
| 856 | // Draw graphics mode with 320x200 pixels (default) with 2 bits/pixel. |
| 857 | // Even scanlines are from CGA_base + 0x0000, odd from CGA_base + 0x2000 |
| 858 | // cga fetches 2 byte per mscrtc6845 access (not modeled here)! |
| 859 | //***************************************************************************/ |
| 860 | // |
| 861 | //static void cga_pgfx_2bpp(bitmap_t *bitmap, struct mscrtc6845 *crtc) |
| 862 | //{ |
| 863 | // int i, sx, sy, sh; |
| 864 | // int offs = mscrtc6845_get_start(crtc)*2; |
| 865 | // int lines = mscrtc6845_get_char_lines(crtc); |
| 866 | // int height = mscrtc6845_get_char_height(crtc); |
| 867 | // int columns = mscrtc6845_get_char_columns(crtc)*2; |
| 868 | // int colorset = cga.color_select & 0x3F; |
| 869 | // const UINT16 *palette; |
| 870 | // |
| 871 | // /* Most chipsets use bit 2 of the mode control register to |
| 872 | // * access a third palette. But not consistently. */ |
| 873 | // pc_cga_check_palette(); |
| 874 | // switch(CGA_CHIPSET) |
| 875 | // { |
| 876 | // /* The IBM Professional Graphics Controller behaves like |
| 877 | // * the PC1512, btw. */ |
| 878 | // case CGA_CHIPSET_PC1512: |
| 879 | // if ((colorset < 32) && (cga.mode_control & 4)) colorset += 64; |
| 880 | // break; |
| 881 | // |
| 882 | // case CGA_CHIPSET_IBM: |
| 883 | // case CGA_CHIPSET_PC200: |
| 884 | // case CGA_CHIPSET_ATI: |
| 885 | // case CGA_CHIPSET_PARADISE: |
| 886 | // if (cga.mode_control & 4) colorset = (colorset & 0x1F) + 64; |
| 887 | // break; |
| 888 | // } |
| 889 | // |
| 890 | // |
| 891 | // /* The fact that our palette is located in cga_colortable is a vestigial |
| 892 | // * aspect from when we were doing that ugly trick where drawgfx() would |
| 893 | // * handle graphics drawing. Truthfully, we should probably be using |
| 894 | // * palette_set_color_rgb() here and not doing the palette lookup in the loop |
| 895 | // */ |
| 896 | // palette = &cga_colortable[256*2 + 16*2] + colorset * 4; |
| 897 | // |
| 898 | // for (sy=0; sy<lines; sy++,offs=(offs+columns)&0x1fff) { |
| 899 | // |
| 900 | // for (sh=0; sh<height; sh++) |
| 901 | // { |
| 902 | // if (!(sh&1)) { // char line 0 used as a12 line in graphic mode |
| 903 | // for (i=offs, sx=0; sx<columns; sx++, i=(i+1)&0x1fff) |
| 904 | // { |
| 905 | // pgfx_plot_unit_2bpp(bitmap, sx*8, sy*height+sh, palette, i); |
| 906 | // } |
| 907 | // } |
| 908 | // else |
| 909 | // { |
| 910 | // for (i=offs|0x2000, sx=0; sx<columns; sx++, i=((i+1)&0x1fff)|0x2000) |
| 911 | // { |
| 912 | // pgfx_plot_unit_2bpp(bitmap, sx*8, sy*height+sh, palette, i); |
| 913 | // } |
| 914 | // } |
| 915 | // } |
| 916 | // } |
| 917 | //} |
| 1142 | 918 | |
| 1143 | 919 | |
| 1144 | | /*************************************************************************** |
| 1145 | | Choose the appropriate video mode |
| 1146 | | ***************************************************************************/ |
| 1147 | 920 | |
| 1148 | | pc_video_update_proc pc_cga_choosevideomode(int *width, int *height, struct mscrtc6845 *crtc) |
| 1149 | | { |
| 1150 | | pc_video_update_proc proc = NULL; |
| 1151 | | const pc_video_update_proc *procarray; |
| 1152 | | UINT8 mode; |
| 921 | // amstrad pc1512 video hardware |
| 922 | // mapping of the 4 planes into videoram |
| 923 | // (text data should be readable at videoram+0) |
| 924 | static const int videoram_offset[4]= { 0x0000, 0x4000, 0x8000, 0xC000 }; |
| 1153 | 925 | |
| 1154 | | static const pc_video_update_proc videoprocs_cga[] = |
| 1155 | | { |
| 1156 | | /* 0x08 - 0x0f */ |
| 1157 | | cga_text_inten, cga_text_inten, cga_gfx_4bppl, cga_gfx_4bppl, |
| 1158 | | cga_text_inten, cga_text_inten, cga_gfx_2bpp, cga_gfx_2bpp, |
| 1159 | 926 | |
| 1160 | | /* 0x18 - 0x1f */ |
| 1161 | | cga_text_inten_alt, cga_text_inten_alt, cga_gfx_4bpph, cga_gfx_4bpph, |
| 1162 | | cga_text_inten_alt, cga_text_inten_alt, cga_gfx_1bpp, cga_gfx_1bpp, |
| 927 | static const UINT8 mc6845_writeonce_register[31] = { |
| 928 | 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
| 929 | }; |
| 1163 | 930 | |
| 1164 | | /* 0x28 - 0x2f */ |
| 1165 | | cga_text_blink, cga_text_blink, cga_gfx_4bppl, cga_gfx_4bppl, |
| 1166 | | cga_text_blink, cga_text_blink, cga_gfx_2bpp, cga_gfx_2bpp, |
| 1167 | 931 | |
| 1168 | | /* 0x38 - 0x3f */ |
| 1169 | | cga_text_blink_alt, cga_text_blink_alt, cga_gfx_4bpph, cga_gfx_4bpph, |
| 1170 | | cga_text_blink_alt, cga_text_blink_alt, cga_gfx_1bpp, cga_gfx_1bpp, |
| 1171 | | }; |
| 932 | static struct |
| 933 | { |
| 934 | UINT8 write; |
| 935 | UINT8 read; |
| 936 | UINT8 mc6845_address; |
| 937 | UINT8 mc6845_locked_register[31]; |
| 938 | } pc1512; |
| 1172 | 939 | |
| 1173 | | static const pc_video_update_proc videoprocs_pc1512[] = |
| 1174 | | { |
| 1175 | | /* 0x08 - 0x0f */ |
| 1176 | | cga_text_inten, cga_text_inten, cga_gfx_2bpp, cga_gfx_2bpp, |
| 1177 | | cga_text_inten, cga_text_inten, cga_gfx_2bpp, cga_gfx_2bpp, |
| 1178 | 940 | |
| 1179 | | /* 0x18 - 0x1f */ |
| 1180 | | cga_text_inten, cga_text_inten, pc1512_gfx_4bpp, pc1512_gfx_4bpp, |
| 1181 | | cga_text_inten, cga_text_inten, pc1512_gfx_4bpp, pc1512_gfx_4bpp, |
| 941 | static MC6845_UPDATE_ROW( pc1512_gfx_4bpp_update_row ) { |
| 942 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| 943 | UINT16 offset_base = ra << 13; |
| 944 | int i; |
| 1182 | 945 | |
| 1183 | | /* 0x28 - 0x2f */ |
| 1184 | | cga_text_blink, cga_text_blink, cga_gfx_2bpp, cga_gfx_2bpp, |
| 1185 | | cga_text_blink, cga_text_blink, cga_gfx_2bpp, cga_gfx_2bpp, |
| 946 | if ( y == 0 ) logerror("pc1512_gfx_4bpp_update_row\n"); |
| 947 | for ( i = 0; i < x_count; i++ ) { |
| 948 | UINT16 offset = offset_base | ( ( ma + i ) & 0x1FFF ); |
| 949 | UINT16 i = ( cga.color_select & 8 ) ? videoram[ videoram_offset[3] | offset ] << 3 : 0; |
| 950 | UINT16 r = ( cga.color_select & 4 ) ? videoram[ videoram_offset[2] | offset ] << 2 : 0; |
| 951 | UINT16 g = ( cga.color_select & 2 ) ? videoram[ videoram_offset[1] | offset ] << 1 : 0; |
| 952 | UINT16 b = ( cga.color_select & 1 ) ? videoram[ videoram_offset[0] | offset ] : 0; |
| 1186 | 953 | |
| 1187 | | /* 0x38 - 0x3f */ |
| 1188 | | cga_text_blink, cga_text_blink, pc1512_gfx_4bpp, pc1512_gfx_4bpp, |
| 1189 | | cga_text_blink, cga_text_blink, pc1512_gfx_4bpp, pc1512_gfx_4bpp |
| 1190 | | }; |
| 1191 | | |
| 1192 | | static const pc_video_update_proc *videoprocs[] = |
| 1193 | | { |
| 1194 | | videoprocs_cga, /* M6845_PERSONALITY_GENUINE */ |
| 1195 | | videoprocs_pc1512 /* M6845_PERSONALITY_PC1512 */ |
| 1196 | | }; |
| 1197 | | |
| 1198 | | if (cga.mode_control & 0x08) |
| 1199 | | { |
| 1200 | | mode = (cga.mode_control & 0x07) | ((cga.mode_control & 0x30) / 2); |
| 1201 | | |
| 1202 | | procarray = videoprocs[mscrtc6845_get_personality(crtc)]; |
| 1203 | | proc = procarray[mode]; |
| 1204 | | |
| 1205 | | /* Plantronics high-res */ |
| 1206 | | if ((cga.mode_control & 2) && (cga.plantronics & 0x20)) |
| 1207 | | proc = cga_pgfx_2bpp; |
| 1208 | | /* Plantronics low-res */ |
| 1209 | | if ((cga.mode_control & 2) && (cga.plantronics & 0x10)) |
| 1210 | | proc = cga_pgfx_4bpp; |
| 1211 | | |
| 1212 | | /* The 160x200 modes are only available on a composite |
| 1213 | | * monitor */ |
| 1214 | | if (proc == cga_gfx_4bppl && |
| 1215 | | CGA_MONITOR != CGA_MONITOR_COMPOSITE) proc = cga_gfx_2bpp; |
| 1216 | | if (proc == cga_gfx_4bpph && |
| 1217 | | CGA_MONITOR != CGA_MONITOR_COMPOSITE) proc = cga_gfx_1bpp; |
| 1218 | | |
| 1219 | | /* Modes that are 640 pixels wide */ |
| 1220 | | if (proc == cga_gfx_1bpp || |
| 1221 | | proc == cga_gfx_4bpph || |
| 1222 | | proc == pc1512_gfx_4bpp || |
| 1223 | | proc == cga_pgfx_2bpp) |
| 1224 | | { |
| 1225 | | *width *= 16; |
| 1226 | | } |
| 1227 | | else |
| 1228 | | { |
| 1229 | | *width *= 8; |
| 1230 | | } |
| 954 | *p = ( ( i & 0x400 ) | ( r & 0x200 ) | ( g & 0x100 ) | ( b & 0x80 ) ) >> 7; p++; |
| 955 | *p = ( ( i & 0x200 ) | ( r & 0x100 ) | ( g & 0x080 ) | ( b & 0x40 ) ) >> 6; p++; |
| 956 | *p = ( ( i & 0x100 ) | ( r & 0x080 ) | ( g & 0x040 ) | ( b & 0x20 ) ) >> 5; p++; |
| 957 | *p = ( ( i & 0x080 ) | ( r & 0x040 ) | ( g & 0x020 ) | ( b & 0x10 ) ) >> 4; p++; |
| 958 | *p = ( ( i & 0x040 ) | ( r & 0x020 ) | ( g & 0x010 ) | ( b & 0x08 ) ) >> 3; p++; |
| 959 | *p = ( ( i & 0x020 ) | ( r & 0x010 ) | ( g & 0x008 ) | ( b & 0x04 ) ) >> 2; p++; |
| 960 | *p = ( ( i & 0x010 ) | ( r & 0x008 ) | ( g & 0x004 ) | ( b & 0x02 ) ) >> 1; p++; |
| 961 | *p = ( i & 0x008 ) | ( r & 0x004 ) | ( g & 0x002 ) | ( b & 0x01 ) ; p++; |
| 1231 | 962 | } |
| 1232 | | return proc; |
| 1233 | 963 | } |
| 1234 | 964 | |
| 1235 | | static struct |
| 1236 | | { |
| 1237 | | UINT8 write; |
| 1238 | | UINT8 read; |
| 1239 | | } pc1512; |
| 1240 | 965 | |
| 1241 | 966 | static WRITE8_HANDLER ( pc1512_w ) |
| 1242 | 967 | { |
| 1243 | | UINT8 char_height; |
| 968 | device_config *devconf; |
| 1244 | 969 | |
| 1245 | 970 | switch (offset) { |
| 1246 | | case 0xd: |
| 1247 | | pc1512.write = data; |
| 971 | case 0: case 2: case 4: case 6: |
| 972 | devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, CGA_MC6845_NAME); |
| 973 | data &= 0x1F; |
| 974 | mc6845_address_w( devconf, offset, data ); |
| 975 | pc1512.mc6845_address = data; |
| 1248 | 976 | break; |
| 1249 | 977 | |
| 1250 | | case 0xe: |
| 1251 | | pc1512.read = data; |
| 1252 | | memory_set_bankptr(1, videoram + videoram_offset[data & 3]); |
| 978 | case 1: case 3: case 5: case 7: |
| 979 | devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, CGA_MC6845_NAME); |
| 980 | if ( ! pc1512.mc6845_locked_register[pc1512.mc6845_address] ) { |
| 981 | mc6845_register_w( devconf, offset, data ); |
| 982 | if ( mc6845_writeonce_register[pc1512.mc6845_address] ) { |
| 983 | pc1512.mc6845_locked_register[pc1512.mc6845_address] = 1; |
| 984 | } |
| 985 | } |
| 1253 | 986 | break; |
| 1254 | 987 | |
| 1255 | | /* The PC1512 doesn't have a full 6845; writes to the first 9 6845 |
| 1256 | | * registers are ignored, and screen resolution is entirely controlled |
| 1257 | | * by the mode control register. Since MESS does actually use the |
| 1258 | | * character columns register, program it manually. */ |
| 1259 | | |
| 1260 | 988 | case 0x8: |
| 1261 | | char_height = mscrtc6845_get_char_height(mscrtc6845); |
| 1262 | | if (data & 2) /* Graphics */ |
| 1263 | | { |
| 1264 | | mscrtc6845_set_char_columns(mscrtc6845, 40); |
| 989 | /* Check if we're changing to graphics mode 2 */ |
| 990 | if ( ( cga.mode_control & 0x12 ) != 0x12 && ( data & 0x12 ) == 0x12 ) { |
| 991 | pc1512.write = 0x0F; |
| 992 | } else { |
| 993 | memory_set_bankptr(1, videoram + videoram_offset[0]); |
| 1265 | 994 | } |
| 1266 | | else |
| 1267 | | { |
| 1268 | | if (data & 1) /* 80-column */ |
| 1269 | | { |
| 1270 | | mscrtc6845_set_char_columns(mscrtc6845, 80); |
| 995 | cga.mode_control = data; |
| 996 | switch( cga.mode_control & 0x3F ) { |
| 997 | case 0x08: case 0x09: case 0x0C: case 0x0D: |
| 998 | cga.update_row = cga_text_inten_update_row; |
| 999 | break; |
| 1000 | case 0x0A: case 0x0B: case 0x2A: case 0x2B: |
| 1001 | if ( CGA_MONITOR == CGA_MONITOR_COMPOSITE ) { |
| 1002 | cga.update_row = cga_gfx_4bppl_update_row; |
| 1003 | } else { |
| 1004 | cga.update_row = cga_gfx_2bpp_update_row; |
| 1271 | 1005 | } |
| 1272 | | else |
| 1273 | | { |
| 1274 | | mscrtc6845_set_char_columns(mscrtc6845, 40); |
| 1275 | | } |
| 1006 | break; |
| 1007 | case 0x0E: case 0x0F: case 0x2E: case 0x2F: |
| 1008 | cga.update_row = cga_gfx_2bpp_update_row; |
| 1009 | break; |
| 1010 | case 0x18: case 0x19: case 0x1C: case 0x1D: |
| 1011 | cga.update_row = cga_text_inten_alt_update_row; |
| 1012 | break; |
| 1013 | case 0x1A: case 0x1B: case 0x3A: case 0x3B: |
| 1014 | cga.update_row = pc1512_gfx_4bpp_update_row; |
| 1015 | break; |
| 1016 | case 0x1E: case 0x1F: case 0x3E: case 0x3F: |
| 1017 | cga.update_row = cga_gfx_1bpp_update_row; |
| 1018 | break; |
| 1019 | case 0x28: case 0x29: case 0x2C: case 0x2D: |
| 1020 | cga.update_row = cga_text_blink_update_row; |
| 1021 | break; |
| 1022 | case 0x38: case 0x39: case 0x3C: case 0x3D: |
| 1023 | cga.update_row = cga_text_blink_alt_update_row; |
| 1024 | break; |
| 1025 | default: |
| 1026 | cga.update_row = NULL; |
| 1027 | break; |
| 1276 | 1028 | } |
| 1277 | | mscrtc6845_set_char_lines(mscrtc6845, 200 ); |
| 1278 | | pc_cga8_w(machine, offset, data); |
| 1279 | 1029 | break; |
| 1280 | 1030 | |
| 1031 | case 0xd: |
| 1032 | pc1512.write = data; |
| 1033 | break; |
| 1034 | |
| 1035 | case 0xe: |
| 1036 | pc1512.read = data; |
| 1037 | if ( ( cga.mode_control & 0x12 ) == 0x12 ) { |
| 1038 | memory_set_bankptr(1, videoram + videoram_offset[data & 3]); |
| 1039 | } |
| 1040 | break; |
| 1041 | |
| 1281 | 1042 | default: |
| 1282 | 1043 | pc_cga8_w(machine, offset,data); |
| 1283 | 1044 | break; |
| r2074 | r2075 | |
| 1307 | 1068 | |
| 1308 | 1069 | static WRITE8_HANDLER ( pc1512_videoram_w ) |
| 1309 | 1070 | { |
| 1310 | | if (pc1512.write & 1) |
| 1311 | | videoram[offset+videoram_offset[0]] = data; /* blue plane */ |
| 1312 | | if (pc1512.write & 2) |
| 1313 | | videoram[offset+videoram_offset[1]] = data; /* green */ |
| 1314 | | if (pc1512.write & 4) |
| 1315 | | videoram[offset+videoram_offset[2]] = data; /* red */ |
| 1316 | | if (pc1512.write & 8) |
| 1317 | | videoram[offset+videoram_offset[3]] = data; /* intensity (text, 4color) */ |
| 1071 | if ( ( cga.mode_control & 0x12 ) == 0x12 ) { |
| 1072 | if (pc1512.write & 1) |
| 1073 | videoram[offset+videoram_offset[0]] = data; /* blue plane */ |
| 1074 | if (pc1512.write & 2) |
| 1075 | videoram[offset+videoram_offset[1]] = data; /* green */ |
| 1076 | if (pc1512.write & 4) |
| 1077 | videoram[offset+videoram_offset[2]] = data; /* red */ |
| 1078 | if (pc1512.write & 8) |
| 1079 | videoram[offset+videoram_offset[3]] = data; /* intensity (text, 4color) */ |
| 1080 | } else { |
| 1081 | videoram[offset + videoram_offset[0]] = data; |
| 1082 | } |
| 1318 | 1083 | } |
| 1319 | 1084 | |
| 1320 | 1085 | |
| r2074 | r2075 | |
| 1325 | 1090 | |
| 1326 | 1091 | |
| 1327 | 1092 | |
| 1328 | | VIDEO_START( pc1512 ) |
| 1093 | static VIDEO_START( pc1512 ) |
| 1329 | 1094 | { |
| 1330 | | videoram = (UINT8*) auto_malloc(0x10000); |
| 1331 | | videoram_size = 0x4000; //! used in cga this way, size of plain memory in 1 bank |
| 1095 | videoram_size = 0x10000; |
| 1096 | videoram = auto_malloc( videoram_size ); |
| 1332 | 1097 | memory_set_bankptr(1,videoram + videoram_offset[0]); |
| 1098 | |
| 1099 | memset( &pc1512, 0, sizeof ( pc1512 ) ); |
| 1333 | 1100 | pc1512.write = 0xf; |
| 1334 | 1101 | pc1512.read = 0; |
| 1335 | 1102 | |
| 1336 | 1103 | /* PC1512 cut-down 6845 */ |
| 1337 | 1104 | internal_pc_cga_video_start(M6845_PERSONALITY_PC1512); |
| 1338 | 1105 | } |
| 1106 | |
| 1107 | |
| 1108 | static VIDEO_UPDATE( mc6845_pc1512 ) { |
| 1109 | device_config *devconf = (device_config *) device_list_find_by_tag(screen->machine->config->devicelist, MC6845, CGA_MC6845_NAME); |
| 1110 | mc6845_update( devconf, bitmap, cliprect); |
| 1111 | |
| 1112 | /* Check for changes in font dipsetting */ |
| 1113 | switch ( CGA_FONT & 0x03 ) { |
| 1114 | case 0: |
| 1115 | cga.chr_gen = memory_region(REGION_GFX1) + 0x0000; |
| 1116 | break; |
| 1117 | case 1: |
| 1118 | cga.chr_gen = memory_region(REGION_GFX1) + 0x0800; |
| 1119 | break; |
| 1120 | case 2: |
| 1121 | cga.chr_gen = memory_region(REGION_GFX1) + 0x1000; |
| 1122 | break; |
| 1123 | case 3: |
| 1124 | cga.chr_gen = memory_region(REGION_GFX1) + 0x1800; |
| 1125 | break; |
| 1126 | } |
| 1127 | return 0; |
| 1128 | } |
| 1129 | |
| 1130 | |