src/mess/video/pc_mda.c
| r2549 | r2550 | |
| 16 | 16 | #define MDA_LOG(N,M,A) \ |
| 17 | 17 | if(VERBOSE_MDA>=N){ if( M )logerror("%11.6f: %-24s",attotime_to_double(timer_get_time()),(char*)M ); logerror A; } |
| 18 | 18 | |
| 19 | | const unsigned char mda_palette[4][3] = { |
| 19 | const unsigned char mda_palette[4][3] = |
| 20 | { |
| 20 | 21 | { 0x00,0x00,0x00 }, |
| 21 | 22 | { 0x00,0x55,0x00 }, |
| 22 | 23 | { 0x00,0xaa,0x00 }, |
| 23 | 24 | { 0x00,0xff,0x00 } |
| 24 | 25 | }; |
| 25 | 26 | |
| 26 | | static struct { |
| 27 | static struct |
| 28 | { |
| 27 | 29 | UINT8 status; |
| 28 | 30 | |
| 29 | 31 | int pc_framecnt; |
| r2549 | r2550 | |
| 54 | 56 | static MC6845_ON_HSYNC_CHANGED( mda_hsync_changed ); |
| 55 | 57 | static MC6845_ON_VSYNC_CHANGED( mda_vsync_changed ); |
| 56 | 58 | |
| 57 | | static const mc6845_interface mc6845_mda_intf = { |
| 59 | static const mc6845_interface mc6845_mda_intf = |
| 60 | { |
| 58 | 61 | MDA_SCREEN_NAME, /* screen number */ |
| 59 | 62 | MDA_CLOCK/9 /*?*/, /* clock */ |
| 60 | 63 | 9, /* number of pixels per video memory address */ |
| r2549 | r2550 | |
| 117 | 120 | } |
| 118 | 121 | |
| 119 | 122 | |
| 120 | | static VIDEO_UPDATE( mc6845_mda ) { |
| 123 | static VIDEO_UPDATE( mc6845_mda ) |
| 124 | { |
| 121 | 125 | device_config *devconf = (device_config *) device_list_find_by_tag(screen->machine->config->devicelist, MC6845, MDA_MC6845_NAME); |
| 122 | 126 | mc6845_update( devconf, bitmap, cliprect ); |
| 123 | 127 | return 0; |
| r2549 | r2550 | |
| 130 | 134 | character codes 176 to 223. |
| 131 | 135 | ***************************************************************************/ |
| 132 | 136 | |
| 133 | | static MC6845_UPDATE_ROW( mda_text_inten_update_row ) { |
| 137 | static MC6845_UPDATE_ROW( mda_text_inten_update_row ) |
| 138 | { |
| 134 | 139 | UINT16 *p = BITMAP_ADDR16( bitmap, y, 0 ); |
| 135 | 140 | UINT16 chr_base = ( ra & 0x08 ) ? 0x800 | ( ra & 0x07 ) : ra; |
| 136 | 141 | int i; |
| 137 | 142 | |
| 138 | 143 | if ( y == 0 ) MDA_LOG(1,"mda_text_inten_update_row",("\n")); |
| 139 | | for ( i = 0; i < x_count; i++ ) { |
| 144 | for ( i = 0; i < x_count; i++ ) |
| 145 | { |
| 140 | 146 | UINT16 offset = ( ( ma + i ) << 1 ) & 0x0FFF; |
| 141 | 147 | UINT8 chr = videoram[ offset ]; |
| 142 | 148 | UINT8 attr = videoram[ offset + 1 ]; |
| r2549 | r2550 | |
| 144 | 150 | UINT8 fg = ( attr & 0x08 ) ? 3 : 2; |
| 145 | 151 | UINT8 bg = 0; |
| 146 | 152 | |
| 147 | | if ( ( attr & ~0x88 ) == 0 ) { |
| 153 | if ( ( attr & ~0x88 ) == 0 ) |
| 154 | { |
| 148 | 155 | data = 0x00; |
| 149 | 156 | } |
| 150 | 157 | |
| 151 | | switch( attr ) { |
| 158 | switch( attr ) |
| 159 | { |
| 152 | 160 | case 0x70: |
| 153 | 161 | bg = 2; |
| 154 | 162 | fg = 0; |
| r2549 | r2550 | |
| 167 | 175 | break; |
| 168 | 176 | } |
| 169 | 177 | |
| 170 | | if ( i == cursor_x || ( attr & 0x07 ) == 0x01 ) { |
| 178 | if ( ( i == cursor_x && ( mda.pc_framecnt & 0x08 ) ) || ( attr & 0x07 ) == 0x01 ) |
| 179 | { |
| 171 | 180 | data = 0xFF; |
| 172 | 181 | } |
| 173 | 182 | |
| r2549 | r2550 | |
| 179 | 188 | *p = ( data & 0x04 ) ? fg : bg; p++; |
| 180 | 189 | *p = ( data & 0x02 ) ? fg : bg; p++; |
| 181 | 190 | *p = ( data & 0x01 ) ? fg : bg; p++; |
| 182 | | if ( ( chr & 0xE0 ) == 0xC0 ) { |
| 191 | if ( ( chr & 0xE0 ) == 0xC0 ) |
| 192 | { |
| 183 | 193 | *p = ( data & 0x01 ) ? fg : bg; p++; |
| 184 | | } else { |
| 194 | } |
| 195 | else |
| 196 | { |
| 185 | 197 | *p = bg; p++; |
| 186 | 198 | } |
| 187 | 199 | } |
| r2549 | r2550 | |
| 194 | 206 | character codes 176 to 223. |
| 195 | 207 | ***************************************************************************/ |
| 196 | 208 | |
| 197 | | static MC6845_UPDATE_ROW( mda_text_blink_update_row ) { |
| 209 | static MC6845_UPDATE_ROW( mda_text_blink_update_row ) |
| 210 | { |
| 198 | 211 | UINT16 *p = BITMAP_ADDR16( bitmap, y, 0 ); |
| 199 | 212 | UINT16 chr_base = ( ra & 0x08 ) ? 0x800 | ( ra & 0x07 ) : ra; |
| 200 | 213 | int i; |
| 201 | 214 | |
| 202 | 215 | if ( y == 0 ) MDA_LOG(1,"mda_text_blink_update_row",("\n")); |
| 203 | | for ( i = 0; i < x_count; i++ ) { |
| 216 | for ( i = 0; i < x_count; i++ ) |
| 217 | { |
| 204 | 218 | UINT16 offset = ( ( ma + i ) << 1 ) & 0x0FFF; |
| 205 | 219 | UINT8 chr = videoram[ offset ]; |
| 206 | 220 | UINT8 attr = videoram[ offset + 1 ]; |
| r2549 | r2550 | |
| 208 | 222 | UINT8 fg = ( attr & 0x08 ) ? 3 : 2; |
| 209 | 223 | UINT8 bg = 0; |
| 210 | 224 | |
| 211 | | if ( ( attr & ~0x88 ) == 0 ) { |
| 225 | if ( ( attr & ~0x88 ) == 0 ) |
| 226 | { |
| 212 | 227 | data = 0x00; |
| 213 | 228 | } |
| 214 | 229 | |
| 215 | | switch( attr ) { |
| 230 | switch( attr ) |
| 231 | { |
| 216 | 232 | case 0x70: |
| 217 | 233 | case 0xF0: |
| 218 | 234 | bg = 2; |
| r2549 | r2550 | |
| 225 | 241 | break; |
| 226 | 242 | } |
| 227 | 243 | |
| 228 | | if ( i == cursor_x ) { |
| 244 | if ( ( attr & 0x07 ) == 0x01 ) |
| 245 | { |
| 229 | 246 | data = 0xFF; |
| 230 | | } else { |
| 231 | | if ( ( attr & 0x07 ) == 0x01 ) { |
| 247 | } |
| 248 | |
| 249 | if ( i == cursor_x ) |
| 250 | { |
| 251 | if ( mda.pc_framecnt & 0x08 ) |
| 252 | { |
| 232 | 253 | data = 0xFF; |
| 233 | 254 | } |
| 234 | | if ( ( attr & 0x80 ) && ( mda.pc_framecnt & 0x40 ) ) { |
| 255 | } |
| 256 | else |
| 257 | { |
| 258 | if ( ( attr & 0x80 ) && ( mda.pc_framecnt & 0x10 ) ) |
| 259 | { |
| 235 | 260 | data = 0x00; |
| 236 | 261 | } |
| 237 | 262 | } |
| r2549 | r2550 | |
| 244 | 269 | *p = ( data & 0x04 ) ? fg : bg; p++; |
| 245 | 270 | *p = ( data & 0x02 ) ? fg : bg; p++; |
| 246 | 271 | *p = ( data & 0x01 ) ? fg : bg; p++; |
| 247 | | if ( ( chr & 0xE0 ) == 0xC0 ) { |
| 272 | if ( ( chr & 0xE0 ) == 0xC0 ) |
| 273 | { |
| 248 | 274 | *p = ( data & 0x01 ) ? fg : bg; p++; |
| 249 | | } else { |
| 275 | } |
| 276 | else |
| 277 | { |
| 250 | 278 | *p = bg; p++; |
| 251 | 279 | } |
| 252 | 280 | } |
| 253 | 281 | } |
| 254 | 282 | |
| 255 | 283 | |
| 256 | | static MC6845_UPDATE_ROW( mda_update_row ) { |
| 257 | | if ( mda.update_row ) { |
| 284 | static MC6845_UPDATE_ROW( mda_update_row ) |
| 285 | { |
| 286 | if ( mda.update_row ) |
| 287 | { |
| 258 | 288 | mda.update_row( device, bitmap, cliprect, ma, ra, y, x_count, cursor_x, param ); |
| 259 | 289 | } |
| 260 | 290 | } |
| 261 | 291 | |
| 262 | 292 | |
| 263 | | static MC6845_ON_HSYNC_CHANGED( mda_hsync_changed ) { |
| 293 | static MC6845_ON_HSYNC_CHANGED( mda_hsync_changed ) |
| 294 | { |
| 264 | 295 | mda.hsync = hsync ? 1 : 0; |
| 265 | 296 | } |
| 266 | 297 | |
| 267 | 298 | |
| 268 | | static MC6845_ON_VSYNC_CHANGED( mda_vsync_changed ) { |
| 299 | static MC6845_ON_VSYNC_CHANGED( mda_vsync_changed ) |
| 300 | { |
| 269 | 301 | mda.vsync = vsync ? 0x80 : 0; |
| 270 | | if ( vsync ) { |
| 302 | if ( vsync ) |
| 303 | { |
| 271 | 304 | mda.pc_framecnt++; |
| 272 | 305 | } |
| 273 | 306 | } |
| r2549 | r2550 | |
| 282 | 315 | data, (data&1)?80:40, (data>>1)&1, (data>>3)&1, (data>>5)&1)); |
| 283 | 316 | mda.mode_control = data; |
| 284 | 317 | |
| 285 | | switch( mda.mode_control & 0x2a ) { |
| 318 | switch( mda.mode_control & 0x2a ) |
| 319 | { |
| 286 | 320 | case 0x08: |
| 287 | 321 | mda.update_row = mda_text_inten_update_row; |
| 288 | 322 | break; |
| r2549 | r2550 | |
| 377 | 411 | The divder/pixels per 6845 clock is 9 for text mode and 16 for graphics mode. |
| 378 | 412 | */ |
| 379 | 413 | |
| 380 | | static const mc6845_interface mc6845_hercules_intf = { |
| 414 | static const mc6845_interface mc6845_hercules_intf = |
| 415 | { |
| 381 | 416 | HERCULES_SCREEN_NAME, /* screen number */ |
| 382 | 417 | MDA_CLOCK/9 /*?*/, /* clock */ |
| 383 | 418 | 9, /* number of pixels per video memory address */ |
| r2549 | r2550 | |
| 405 | 440 | MACHINE_DRIVER_END |
| 406 | 441 | |
| 407 | 442 | |
| 408 | | static VIDEO_START( pc_hercules ) { |
| 443 | static VIDEO_START( pc_hercules ) |
| 444 | { |
| 409 | 445 | int buswidth; |
| 410 | 446 | |
| 411 | 447 | buswidth = cputype_databus_width(machine->config->cpu[0].type, ADDRESS_SPACE_PROGRAM); |
| r2549 | r2550 | |
| 440 | 476 | bit 7 being the leftmost. |
| 441 | 477 | ***************************************************************************/ |
| 442 | 478 | |
| 443 | | static MC6845_UPDATE_ROW( hercules_gfx_update_row ) { |
| 479 | static MC6845_UPDATE_ROW( hercules_gfx_update_row ) |
| 480 | { |
| 444 | 481 | UINT16 *p = BITMAP_ADDR16( bitmap, y, 0 ); |
| 445 | 482 | UINT16 gfx_base = ( ( mda.mode_control & 0x80 ) ? 0x8000 : 0x0000 ) | ( ( ra & 0x03 ) << 13 ); |
| 446 | 483 | int i; |
| 447 | 484 | |
| 448 | 485 | if ( y == 0 ) MDA_LOG(1,"hercules_gfx_update_row",("\n")); |
| 449 | | for ( i = 0; i < x_count; i++ ) { |
| 486 | for ( i = 0; i < x_count; i++ ) |
| 487 | { |
| 450 | 488 | UINT8 data = videoram[ gfx_base + ( ( ma + i ) << 1 ) ]; |
| 451 | 489 | |
| 452 | 490 | *p = ( data & 0x80 ) ? 2 : 0; p++; |
| r2549 | r2550 | |
| 472 | 510 | } |
| 473 | 511 | |
| 474 | 512 | |
| 475 | | static VIDEO_UPDATE( mc6845_hercules ) { |
| 513 | static VIDEO_UPDATE( mc6845_hercules ) |
| 514 | { |
| 476 | 515 | device_config *devconf = (device_config *) device_list_find_by_tag(screen->machine->config->devicelist, MC6845, HERCULES_MC6845_NAME); |
| 477 | 516 | mc6845_update( devconf, bitmap, cliprect ); |
| 478 | 517 | return 0; |
| 479 | 518 | } |
| 480 | 519 | |
| 481 | 520 | |
| 482 | | static void hercules_mode_control_w(running_machine *machine, int data) { |
| 521 | static void hercules_mode_control_w(running_machine *machine, int data) |
| 522 | { |
| 483 | 523 | device_config *devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, HERCULES_MC6845_NAME); |
| 484 | 524 | |
| 485 | 525 | MDA_LOG(1,"hercules_mode_control_w",("$%02x: colums %d, gfx %d, enable %d, blink %d\n", |
| 486 | 526 | data, (data&1)?80:40, (data>>1)&1, (data>>3)&1, (data>>5)&1)); |
| 487 | 527 | mda.mode_control = data; |
| 488 | 528 | |
| 489 | | switch( mda.mode_control & 0x2a ) { |
| 529 | switch( mda.mode_control & 0x2a ) |
| 530 | { |
| 490 | 531 | case 0x08: |
| 491 | 532 | mda.update_row = mda_text_inten_update_row; |
| 492 | 533 | break; |
| r2549 | r2550 | |
| 513 | 554 | } |
| 514 | 555 | |
| 515 | 556 | |
| 516 | | static WRITE8_HANDLER ( pc_hercules_w ) { |
| 557 | static WRITE8_HANDLER ( pc_hercules_w ) |
| 558 | { |
| 517 | 559 | device_config *devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, HERCULES_MC6845_NAME); |
| 518 | 560 | |
| 519 | | switch( offset ) { |
| 561 | switch( offset ) |
| 562 | { |
| 520 | 563 | case 0: case 2: case 4: case 6: |
| 521 | 564 | mc6845_address_w( devconf, offset, data ); |
| 522 | 565 | break; |
| r2549 | r2550 | |
| 551 | 594 | } |
| 552 | 595 | |
| 553 | 596 | |
| 554 | | static READ8_HANDLER ( pc_hercules_r ) { |
| 597 | static READ8_HANDLER ( pc_hercules_r ) |
| 598 | { |
| 555 | 599 | device_config *devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, HERCULES_MC6845_NAME); |
| 556 | 600 | int data = 0xff; |
| 557 | 601 | |
| 558 | | switch( offset ) { |
| 602 | switch( offset ) |
| 603 | { |
| 559 | 604 | case 0: case 2: case 4: case 6: |
| 560 | 605 | /* return last written mc6845 address value here? */ |
| 561 | 606 | break; |