src/mess/video/pc_t1t.c
| r5363 | r5364 | |
| 48 | 48 | MDRV_SCREEN_ADD(T1000_SCREEN_NAME, RASTER) |
| 49 | 49 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 50 | 50 | MDRV_SCREEN_RAW_PARAMS(XTAL_14_31818MHz,912,0,640,262,0,200) |
| 51 | | MDRV_PALETTE_LENGTH( 16 ) |
| 51 | MDRV_PALETTE_LENGTH( 32 ) |
| 52 | 52 | MDRV_PALETTE_INIT(pcjr) |
| 53 | 53 | |
| 54 | 54 | MDRV_MC6845_ADD(T1000_MC6845_NAME, MC6845, XTAL_14_31818MHz/8, mc6845_t1000_intf) |
| r5363 | r5364 | |
| 76 | 76 | MDRV_SCREEN_ADD(T1000_SCREEN_NAME, RASTER) |
| 77 | 77 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 78 | 78 | MDRV_SCREEN_RAW_PARAMS(XTAL_14_31818MHz,912,0,640,262,0,200) |
| 79 | | MDRV_PALETTE_LENGTH( 16 ) |
| 79 | MDRV_PALETTE_LENGTH( 32 ) |
| 80 | 80 | MDRV_PALETTE_INIT(pcjr) |
| 81 | 81 | |
| 82 | 82 | MDRV_MC6845_ADD(T1000_MC6845_NAME, MC6845, XTAL_14_31818MHz/16, mc6845_pcjr_intf) |
| r5363 | r5364 | |
| 104 | 104 | }; |
| 105 | 105 | int i; |
| 106 | 106 | |
| 107 | /* colors */ |
| 107 | 108 | for(i = 0; i < 16; i++) |
| 108 | 109 | palette_set_color_rgb(machine, i, tga_palette[i][0], tga_palette[i][1], tga_palette[i][2]); |
| 110 | |
| 111 | /* b/w mode shades */ |
| 112 | for(i = 0; i < 16; i++) |
| 113 | palette_set_color_rgb( machine, 16+i, ( i << 4 ) | i, ( i << 4 ) | i, ( i << 4 ) | i ); |
| 109 | 114 | } |
| 110 | 115 | |
| 111 | 116 | |
| r5363 | r5364 | |
| 142 | 147 | mc6845_update_row_func update_row; |
| 143 | 148 | UINT8 display_enable; |
| 144 | 149 | UINT8 vsync; |
| 150 | UINT8 palette_base; |
| 145 | 151 | } pcjr = { 0 }; |
| 146 | 152 | |
| 147 | 153 | |
| r5363 | r5364 | |
| 187 | 193 | UINT8 chr = pcjr.displayram[ offset ]; |
| 188 | 194 | UINT8 attr = pcjr.displayram[ offset +1 ]; |
| 189 | 195 | UINT8 data = pcjr.chr_gen[ chr * pcjr.chr_size + ra ]; |
| 190 | | UINT16 fg = attr & 0x0F; |
| 191 | | UINT16 bg = ( attr >> 4 ) & 0x07; |
| 196 | UINT16 fg = pcjr.palette_base + ( attr & 0x0F ); |
| 197 | UINT16 bg = pcjr.palette_base + ( ( attr >> 4 ) & 0x07 ); |
| 192 | 198 | |
| 193 | 199 | if ( i == cursor_x && ( pcjr.pc_framecnt & 0x08 ) ) |
| 194 | 200 | { |
| r5363 | r5364 | |
| 218 | 224 | UINT8 chr = pcjr.displayram[ offset ]; |
| 219 | 225 | UINT8 attr = pcjr.displayram[ offset +1 ]; |
| 220 | 226 | UINT8 data = pcjr.chr_gen[ chr * pcjr.chr_size + ra ]; |
| 221 | | UINT16 fg = attr & 0x0F; |
| 222 | | UINT16 bg = ( attr >> 4 ) & 0x07; |
| 227 | UINT16 fg = pcjr.palette_base + ( attr & 0x0F ); |
| 228 | UINT16 bg = pcjr.palette_base + ( ( attr >> 4 ) & 0x07 ); |
| 223 | 229 | |
| 224 | 230 | if ( i == cursor_x ) |
| 225 | 231 | { |
| r5363 | r5364 | |
| 259 | 265 | UINT16 offset = ( ( ma + i ) << 1 ) & 0x1fff; |
| 260 | 266 | UINT8 data = vid[ offset ]; |
| 261 | 267 | |
| 262 | | *p = pcjr.reg.data[0x10 + ( data >> 4 )]; p++; |
| 263 | | *p = pcjr.reg.data[0x10 + ( data >> 4 )]; p++; |
| 264 | | *p = pcjr.reg.data[0x10 + ( data & 0x0F )]; p++; |
| 265 | | *p = pcjr.reg.data[0x10 + ( data & 0x0F )]; p++; |
| 268 | *p = pcjr.palette_base + pcjr.reg.data[0x10 + ( data >> 4 )]; p++; |
| 269 | *p = pcjr.palette_base + pcjr.reg.data[0x10 + ( data >> 4 )]; p++; |
| 270 | *p = pcjr.palette_base + pcjr.reg.data[0x10 + ( data & 0x0F )]; p++; |
| 271 | *p = pcjr.palette_base + pcjr.reg.data[0x10 + ( data & 0x0F )]; p++; |
| 266 | 272 | |
| 267 | 273 | data = vid[ offset + 1 ]; |
| 268 | 274 | |
| 269 | | *p = pcjr.reg.data[0x10 + ( data >> 4 )]; p++; |
| 270 | | *p = pcjr.reg.data[0x10 + ( data >> 4 )]; p++; |
| 271 | | *p = pcjr.reg.data[0x10 + ( data & 0x0F )]; p++; |
| 272 | | *p = pcjr.reg.data[0x10 + ( data & 0x0F )]; p++; |
| 275 | *p = pcjr.palette_base + pcjr.reg.data[0x10 + ( data >> 4 )]; p++; |
| 276 | *p = pcjr.palette_base + pcjr.reg.data[0x10 + ( data >> 4 )]; p++; |
| 277 | *p = pcjr.palette_base + pcjr.reg.data[0x10 + ( data & 0x0F )]; p++; |
| 278 | *p = pcjr.palette_base + pcjr.reg.data[0x10 + ( data & 0x0F )]; p++; |
| 273 | 279 | } |
| 274 | 280 | } |
| 275 | 281 | |
| r5363 | r5364 | |
| 280 | 286 | UINT8 *vid = pcjr.displayram + ( ra << 13 ); |
| 281 | 287 | int i; |
| 282 | 288 | |
| 283 | | if ( y == 0 ) logerror("t1000_gfx_2bpp_update_row\n"); |
| 284 | 289 | for ( i = 0; i < x_count; i++ ) |
| 285 | 290 | { |
| 286 | 291 | UINT16 offset = ( ( ma + i ) << 1 ) & 0x1fff; |
| 287 | 292 | UINT8 data = vid[ offset ]; |
| 288 | 293 | |
| 289 | | *p = pcjr.reg.data[ 0x10 + ( ( data >> 6 ) & 0x03 ) ]; p++; |
| 290 | | *p = pcjr.reg.data[ 0x10 + ( ( data >> 4 ) & 0x03 ) ]; p++; |
| 291 | | *p = pcjr.reg.data[ 0x10 + ( ( data >> 2 ) & 0x03 ) ]; p++; |
| 292 | | *p = pcjr.reg.data[ 0x10 + ( data & 0x03 ) ]; p++; |
| 294 | *p = pcjr.palette_base + pcjr.reg.data[ 0x10 + ( ( data >> 6 ) & 0x03 ) ]; p++; |
| 295 | *p = pcjr.palette_base + pcjr.reg.data[ 0x10 + ( ( data >> 4 ) & 0x03 ) ]; p++; |
| 296 | *p = pcjr.palette_base + pcjr.reg.data[ 0x10 + ( ( data >> 2 ) & 0x03 ) ]; p++; |
| 297 | *p = pcjr.palette_base + pcjr.reg.data[ 0x10 + ( data & 0x03 ) ]; p++; |
| 293 | 298 | |
| 294 | 299 | data = vid[ offset+1 ]; |
| 295 | 300 | |
| 296 | | *p = pcjr.reg.data[ 0x10 + ( ( data >> 6 ) & 0x03 ) ]; p++; |
| 297 | | *p = pcjr.reg.data[ 0x10 + ( ( data >> 4 ) & 0x03 ) ]; p++; |
| 298 | | *p = pcjr.reg.data[ 0x10 + ( ( data >> 2 ) & 0x03 ) ]; p++; |
| 299 | | *p = pcjr.reg.data[ 0x10 + ( data & 0x03 ) ]; p++; |
| 301 | *p = pcjr.palette_base + pcjr.reg.data[ 0x10 + ( ( data >> 6 ) & 0x03 ) ]; p++; |
| 302 | *p = pcjr.palette_base + pcjr.reg.data[ 0x10 + ( ( data >> 4 ) & 0x03 ) ]; p++; |
| 303 | *p = pcjr.palette_base + pcjr.reg.data[ 0x10 + ( ( data >> 2 ) & 0x03 ) ]; p++; |
| 304 | *p = pcjr.palette_base + pcjr.reg.data[ 0x10 + ( data & 0x03 ) ]; p++; |
| 300 | 305 | } |
| 301 | 306 | } |
| 302 | 307 | |
| 303 | 308 | |
| 309 | static MC6845_UPDATE_ROW( pcjr_gfx_2bpp_high_update_row ) |
| 310 | { |
| 311 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| 312 | UINT8 *vid = pcjr.displayram + ( ra << 13 ); |
| 313 | int i; |
| 314 | |
| 315 | for ( i = 0; i < x_count; i++ ) |
| 316 | { |
| 317 | UINT16 offset = ( ( ma + i ) << 1 ) & 0x1fff; |
| 318 | UINT8 data0 = vid[ offset ]; |
| 319 | UINT8 data1 = vid[ offset + 1 ]; |
| 320 | |
| 321 | *p = pcjr.palette_base + pcjr.reg.data[ 0x10 + ( ( ( data0 & 0x80 ) >> 7 ) | ( ( data1 & 0x80 ) >> 6 ) ) ]; p++; |
| 322 | *p = pcjr.palette_base + pcjr.reg.data[ 0x10 + ( ( ( data0 & 0x40 ) >> 6 ) | ( ( data1 & 0x40 ) >> 5 ) ) ]; p++; |
| 323 | *p = pcjr.palette_base + pcjr.reg.data[ 0x10 + ( ( ( data0 & 0x20 ) >> 5 ) | ( ( data1 & 0x20 ) >> 4 ) ) ]; p++; |
| 324 | *p = pcjr.palette_base + pcjr.reg.data[ 0x10 + ( ( ( data0 & 0x10 ) >> 4 ) | ( ( data1 & 0x10 ) >> 3 ) ) ]; p++; |
| 325 | *p = pcjr.palette_base + pcjr.reg.data[ 0x10 + ( ( ( data0 & 0x08 ) >> 3 ) | ( ( data1 & 0x08 ) >> 2 ) ) ]; p++; |
| 326 | *p = pcjr.palette_base + pcjr.reg.data[ 0x10 + ( ( ( data0 & 0x04 ) >> 2 ) | ( ( data1 & 0x04 ) >> 1 ) ) ]; p++; |
| 327 | *p = pcjr.palette_base + pcjr.reg.data[ 0x10 + ( ( ( data0 & 0x02 ) >> 1 ) | ( ( data1 & 0x02 ) ) ) ]; p++; |
| 328 | *p = pcjr.palette_base + pcjr.reg.data[ 0x10 + ( ( ( data0 & 0x01 ) ) | ( ( data1 & 0x01 ) << 1 ) ) ]; p++; |
| 329 | } |
| 330 | } |
| 331 | |
| 332 | |
| 304 | 333 | static MC6845_UPDATE_ROW( t1000_gfx_2bpp_tga_update_row ) |
| 305 | 334 | { |
| 306 | 335 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| r5363 | r5364 | |
| 331 | 360 | { |
| 332 | 361 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| 333 | 362 | UINT8 *vid = pcjr.displayram + ( ra << 13 ); |
| 334 | | UINT8 fg = pcjr.reg.data[0x11]; |
| 335 | | UINT8 bg = pcjr.reg.data[0x10]; |
| 363 | UINT8 fg = pcjr.palette_base + pcjr.reg.data[0x11]; |
| 364 | UINT8 bg = pcjr.palette_base + pcjr.reg.data[0x10]; |
| 336 | 365 | int i; |
| 337 | 366 | |
| 338 | 367 | if ( y == 0 ) logerror("t1000_gfx_1bpp_update_row\n"); |
| r5363 | r5364 | |
| 363 | 392 | } |
| 364 | 393 | } |
| 365 | 394 | |
| 395 | |
| 366 | 396 | static MC6845_UPDATE_ROW( t1000_update_row ) |
| 367 | 397 | { |
| 368 | 398 | if ( pcjr.update_row ) |
| r5363 | r5364 | |
| 371 | 401 | } |
| 372 | 402 | } |
| 373 | 403 | |
| 404 | |
| 374 | 405 | READ8_HANDLER ( pc_t1t_videoram_r ) |
| 375 | 406 | { |
| 376 | 407 | int data = 0xff; |
| r5363 | r5364 | |
| 452 | 483 | /* bit1 - 1 = enable blink */ |
| 453 | 484 | /* bit3 - 1 = 2 color graphics */ |
| 454 | 485 | |
| 455 | | static void pc_pcjr_mode_switch( void ) |
| 486 | static void pc_pcjr_mode_switch( running_machine *machine ) |
| 456 | 487 | { |
| 457 | | switch( pcjr.reg.data[0] & 0x1F ) |
| 488 | const device_config *mc6845 = devtag_get_device(machine, T1000_MC6845_NAME); |
| 489 | |
| 490 | switch( pcjr.reg.data[0] & 0x1A ) |
| 458 | 491 | { |
| 459 | | case 0x08: case 0x09: |
| 460 | | case 0x0C: case 0x0D: /* B/W modes */ |
| 492 | case 0x08: /* 01x0x */ |
| 461 | 493 | if ( pcjr.reg.data[3] & 0x02 ) |
| 462 | 494 | { |
| 463 | 495 | pcjr.update_row = t1000_text_blink_update_row; |
| r5363 | r5364 | |
| 467 | 499 | pcjr.update_row = t1000_text_inten_update_row; |
| 468 | 500 | } |
| 469 | 501 | break; |
| 470 | | case 0x1A: case 0x1B: |
| 471 | | pcjr.update_row = t1000_gfx_4bpp_update_row; |
| 472 | | break; |
| 473 | | case 0x0A: case 0x0B: |
| 502 | case 0x0A: /* 01x1x */ |
| 503 | /* By default use medium resolution mode */ |
| 474 | 504 | pcjr.update_row = t1000_gfx_2bpp_update_row; |
| 475 | | break; |
| 476 | | case 0x0E: |
| 477 | | if ( pcjr.reg.data[3] & 0x08 ) |
| 505 | |
| 506 | /* Check for high resolution mode */ |
| 507 | if ( ( pcjr.bank & 0xc0 ) == 0xc0 ) |
| 508 | pcjr.update_row = pcjr_gfx_2bpp_high_update_row; |
| 509 | |
| 510 | /* Check for 640x200 b/w 2 shades mode */ |
| 511 | if ( ( pcjr.reg.data[0] & 0x04 ) && ( pcjr.reg.data[3] & 0x08 ) ) |
| 478 | 512 | { |
| 479 | 513 | pcjr.update_row = t1000_gfx_1bpp_update_row; |
| 480 | 514 | } |
| 481 | | else |
| 482 | | { |
| 483 | | pcjr.update_row = t1000_gfx_2bpp_update_row; /* B/W mode */ |
| 484 | | } |
| 485 | 515 | break; |
| 516 | case 0x18: /* 11x0x - invalid?? */ |
| 517 | pcjr.update_row = NULL; |
| 518 | break; |
| 519 | case 0x1A: /* 11x1x */ |
| 520 | pcjr.update_row = t1000_gfx_4bpp_update_row; |
| 521 | break; |
| 486 | 522 | default: |
| 487 | 523 | pcjr.update_row = NULL; |
| 488 | 524 | break; |
| 489 | 525 | } |
| 526 | |
| 527 | /* Determine mc6845 input clock */ |
| 528 | if ( pcjr.reg.data[0] & 0x01 ) |
| 529 | { |
| 530 | mc6845_set_clock( mc6845, XTAL_14_31818MHz/8 ); |
| 531 | } |
| 532 | else |
| 533 | { |
| 534 | mc6845_set_clock( mc6845, XTAL_14_31818MHz/16 ); |
| 535 | } |
| 536 | |
| 537 | /* color or b/w? */ |
| 538 | pcjr.palette_base = ( pcjr.reg.data[0] & 0x04 ) ? 16 : 0; |
| 490 | 539 | } |
| 491 | 540 | |
| 492 | 541 | |
| r5363 | r5364 | |
| 592 | 641 | } |
| 593 | 642 | |
| 594 | 643 | |
| 595 | | static void pc_pcjr_vga_data_w(int data) |
| 644 | static void pc_pcjr_vga_data_w(running_machine *machine, int data) |
| 596 | 645 | { |
| 597 | 646 | pcjr.reg.data[pcjr.reg.index] = data; |
| 598 | 647 | |
| r5363 | r5364 | |
| 604 | 653 | /* bit2 - 0 = color, 1 = b/w */ |
| 605 | 654 | /* bit3 - 0 = video disable, 1 = video enable */ |
| 606 | 655 | /* bit4 - 1 = 16 color graphics */ |
| 607 | | pc_pcjr_mode_switch(); |
| 656 | //printf("pc_pcjr_vga_data_w: mode control 1 write %02x\n", data ); |
| 657 | pc_pcjr_mode_switch(machine); |
| 608 | 658 | break; |
| 609 | 659 | case 0x01: /* palette mask (bits 3-0) */ |
| 610 | 660 | break; |
| r5363 | r5364 | |
| 613 | 663 | case 0x03: /* mode control 2 */ |
| 614 | 664 | /* bit1 - 1 = enable blink */ |
| 615 | 665 | /* bit3 - 1 = 2 color graphics */ |
| 616 | | pc_pcjr_mode_switch(); |
| 666 | //printf("pc_pcjr_vga_data_w: mode control 2 write %02x\n", data ); |
| 667 | pc_pcjr_mode_switch(machine); |
| 617 | 668 | break; |
| 618 | 669 | case 0x04: /* reset register */ |
| 619 | 670 | break; |
| r5363 | r5364 | |
| 690 | 741 | #endif |
| 691 | 742 | videoram = &ram[vram]; |
| 692 | 743 | pcjr.displayram = &ram[dram]; |
| 744 | pc_t1t_mode_switch(); |
| 693 | 745 | } |
| 694 | | pc_t1t_mode_switch(); |
| 695 | 746 | } |
| 696 | 747 | |
| 697 | 748 | |
| 698 | 749 | static void pc_pcjr_bank_w(running_machine *machine, int data) |
| 699 | 750 | { |
| 751 | //printf("pc_pcjr_bank_w: %02x\n", data); |
| 700 | 752 | if (pcjr.bank != data) |
| 701 | 753 | { |
| 702 | 754 | int dram, vram; |
| r5363 | r5364 | |
| 712 | 764 | dram = ((data & 0x07) << 14); |
| 713 | 765 | vram = ((data & 0x38) << (14-3)); |
| 714 | 766 | } |
| 715 | | videoram = mess_ram + vram; |
| 767 | memory_set_bankptr( machine, 14, mess_ram + vram ); |
| 716 | 768 | pcjr.displayram = mess_ram + dram; |
| 717 | 769 | } |
| 718 | | pc_pcjr_mode_switch(); |
| 770 | pc_pcjr_mode_switch(machine); |
| 719 | 771 | } |
| 720 | 772 | |
| 721 | 773 | |
| r5363 | r5364 | |
| 788 | 840 | case 10: |
| 789 | 841 | if ( pcjr.address_data_ff & 0x01 ) |
| 790 | 842 | { |
| 791 | | pc_pcjr_vga_data_w( data ); |
| 843 | pc_pcjr_vga_data_w( space->machine, data ); |
| 792 | 844 | } |
| 793 | 845 | else |
| 794 | 846 | { |