src/mess/video/pc_t1t.c
| r2551 | r2552 | |
| 95 | 95 | /* Initialise the cga palette */ |
| 96 | 96 | static PALETTE_INIT( pcjr ) |
| 97 | 97 | { |
| 98 | | const static unsigned char tga_palette[16][3] = { |
| 98 | const static unsigned char tga_palette[16][3] = |
| 99 | { |
| 99 | 100 | { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0xaa }, { 0x00, 0xaa, 0x00 }, { 0x00, 0xaa, 0xaa }, |
| 100 | 101 | { 0xaa, 0x00, 0x00 }, { 0xaa, 0x00, 0xaa }, { 0xaa, 0x55, 0x00 }, { 0xaa, 0xaa, 0xaa }, |
| 101 | 102 | { 0x55, 0x55, 0x55 }, { 0x55, 0x55, 0xff }, { 0x55, 0xff, 0x55 }, { 0x55, 0xff, 0xff }, |
| r2551 | r2552 | |
| 107 | 108 | palette_set_color_rgb(machine, i, tga_palette[i][0], tga_palette[i][1], tga_palette[i][2]); |
| 108 | 109 | } |
| 109 | 110 | |
| 110 | | static struct { |
| 111 | |
| 112 | static struct |
| 113 | { |
| 111 | 114 | UINT8 mode_control, color_select; |
| 112 | 115 | UINT8 status; |
| 113 | 116 | |
| r2551 | r2552 | |
| 134 | 137 | UINT8 *chr_gen; |
| 135 | 138 | UINT8 chr_size; |
| 136 | 139 | |
| 140 | UINT8 address_data_ff; |
| 141 | |
| 137 | 142 | mc6845_update_row_func update_row; |
| 138 | 143 | UINT8 hsync; |
| 139 | 144 | UINT8 vsync; |
| r2551 | r2552 | |
| 162 | 167 | videoram_size = 0x8000; |
| 163 | 168 | } |
| 164 | 169 | |
| 165 | | static VIDEO_UPDATE( mc6845_t1000 ) { |
| 170 | static VIDEO_UPDATE( mc6845_t1000 ) |
| 171 | { |
| 166 | 172 | device_config *devconf = (device_config *) device_list_find_by_tag(screen->machine->config->devicelist, MC6845, T1000_MC6845_NAME); |
| 167 | 173 | mc6845_update( devconf, bitmap, cliprect); |
| 168 | 174 | return 0; |
| 169 | 175 | } |
| 170 | 176 | |
| 171 | 177 | |
| 172 | | static MC6845_UPDATE_ROW( t1000_text_inten_update_row ) { |
| 178 | static MC6845_UPDATE_ROW( t1000_text_inten_update_row ) |
| 179 | { |
| 173 | 180 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| 174 | 181 | int i; |
| 175 | 182 | |
| 176 | 183 | if ( y == 0 ) logerror("t1000_text_inten_update_row\n"); |
| 177 | | for ( i = 0; i < x_count; i++ ) { |
| 184 | for ( i = 0; i < x_count; i++ ) |
| 185 | { |
| 178 | 186 | UINT16 offset = ( ( ma + i ) << 1 ) & 0x3fff; |
| 179 | 187 | UINT8 chr = pcjr.displayram[ offset ]; |
| 180 | 188 | UINT8 attr = pcjr.displayram[ offset +1 ]; |
| r2551 | r2552 | |
| 182 | 190 | UINT16 fg = attr & 0x0F; |
| 183 | 191 | UINT16 bg = ( attr >> 4 ) & 0x07; |
| 184 | 192 | |
| 185 | | if ( i == cursor_x ) { |
| 193 | if ( i == cursor_x && ( pcjr.pc_framecnt & 0x08 ) ) |
| 194 | { |
| 186 | 195 | data = 0xFF; |
| 187 | 196 | } |
| 188 | 197 | |
| r2551 | r2552 | |
| 198 | 207 | } |
| 199 | 208 | |
| 200 | 209 | |
| 201 | | static MC6845_UPDATE_ROW( t1000_text_blink_update_row ) { |
| 210 | static MC6845_UPDATE_ROW( t1000_text_blink_update_row ) |
| 211 | { |
| 202 | 212 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| 203 | 213 | int i; |
| 204 | 214 | |
| 205 | | for ( i = 0; i < x_count; i++ ) { |
| 215 | for ( i = 0; i < x_count; i++ ) |
| 216 | { |
| 206 | 217 | UINT16 offset = ( ( ma + i ) << 1 ) & 0x3fff; |
| 207 | 218 | UINT8 chr = pcjr.displayram[ offset ]; |
| 208 | 219 | UINT8 attr = pcjr.displayram[ offset +1 ]; |
| r2551 | r2552 | |
| 210 | 221 | UINT16 fg = attr & 0x0F; |
| 211 | 222 | UINT16 bg = ( attr >> 4 ) & 0x07; |
| 212 | 223 | |
| 213 | | if ( i == cursor_x ) { |
| 214 | | data = 0xFF; |
| 215 | | } else { |
| 216 | | if ( ( attr & 0x80 ) && ( pcjr.pc_framecnt & 0x10 ) ) { |
| 224 | if ( i == cursor_x ) |
| 225 | { |
| 226 | if ( pcjr.pc_framecnt & 0x08 ) |
| 227 | { |
| 228 | data = 0xFF; |
| 229 | } |
| 230 | } |
| 231 | else |
| 232 | { |
| 233 | if ( ( attr & 0x80 ) && ( pcjr.pc_framecnt & 0x10 ) ) |
| 234 | { |
| 217 | 235 | data = 0x00; |
| 218 | 236 | } |
| 219 | 237 | } |
| r2551 | r2552 | |
| 230 | 248 | } |
| 231 | 249 | |
| 232 | 250 | |
| 233 | | static MC6845_UPDATE_ROW( t1000_gfx_4bpp_update_row ) { |
| 251 | static MC6845_UPDATE_ROW( t1000_gfx_4bpp_update_row ) |
| 252 | { |
| 234 | 253 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| 235 | 254 | UINT8 *vid = pcjr.displayram + ( ra << 13 ); |
| 236 | 255 | int i; |
| 237 | 256 | |
| 238 | | for ( i = 0; i < x_count; i++ ) { |
| 257 | for ( i = 0; i < x_count; i++ ) |
| 258 | { |
| 239 | 259 | UINT16 offset = ( ( ma + i ) << 1 ) & 0x1fff; |
| 240 | 260 | UINT8 data = vid[ offset ]; |
| 241 | 261 | |
| r2551 | r2552 | |
| 254 | 274 | } |
| 255 | 275 | |
| 256 | 276 | |
| 257 | | static MC6845_UPDATE_ROW( t1000_gfx_2bpp_update_row ) { |
| 277 | static MC6845_UPDATE_ROW( t1000_gfx_2bpp_update_row ) |
| 278 | { |
| 258 | 279 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| 259 | 280 | UINT8 *vid = pcjr.displayram + ( ra << 13 ); |
| 260 | 281 | int i; |
| 261 | 282 | |
| 262 | 283 | if ( y == 0 ) logerror("t1000_gfx_2bpp_update_row\n"); |
| 263 | | for ( i = 0; i < x_count; i++ ) { |
| 284 | for ( i = 0; i < x_count; i++ ) |
| 285 | { |
| 264 | 286 | UINT16 offset = ( ( ma + i ) << 1 ) & 0x1fff; |
| 265 | 287 | UINT8 data = vid[ offset ]; |
| 266 | 288 | |
| r2551 | r2552 | |
| 279 | 301 | } |
| 280 | 302 | |
| 281 | 303 | |
| 282 | | static MC6845_UPDATE_ROW( t1000_gfx_2bpp_tga_update_row ) { |
| 304 | static MC6845_UPDATE_ROW( t1000_gfx_2bpp_tga_update_row ) |
| 305 | { |
| 283 | 306 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| 284 | 307 | UINT8 *vid = pcjr.displayram + ( ra << 13 ); |
| 285 | 308 | int i; |
| 286 | 309 | |
| 287 | 310 | if ( y == 0 ) logerror("t1000_gfx_2bpp_tga_update_row\n"); |
| 288 | | for ( i = 0; i < x_count; i++ ) { |
| 311 | for ( i = 0; i < x_count; i++ ) |
| 312 | { |
| 289 | 313 | UINT16 offset = ( ( ma + i ) << 1 ) & 0x1fff; |
| 290 | 314 | UINT8 data = vid[ offset ]; |
| 291 | 315 | UINT16 data2 = ( vid[ offset + 1 ] ) << 1; |
| r2551 | r2552 | |
| 303 | 327 | } |
| 304 | 328 | |
| 305 | 329 | |
| 306 | | static MC6845_UPDATE_ROW( t1000_gfx_1bpp_update_row ) { |
| 330 | static MC6845_UPDATE_ROW( t1000_gfx_1bpp_update_row ) |
| 331 | { |
| 307 | 332 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| 308 | 333 | UINT8 *vid = pcjr.displayram + ( ra << 13 ); |
| 309 | 334 | UINT8 fg = pcjr.reg.data[0x11]; |
| r2551 | r2552 | |
| 311 | 336 | int i; |
| 312 | 337 | |
| 313 | 338 | if ( y == 0 ) logerror("t1000_gfx_1bpp_update_row\n"); |
| 314 | | for ( i = 0; i < x_count; i++ ) { |
| 339 | for ( i = 0; i < x_count; i++ ) |
| 340 | { |
| 315 | 341 | UINT16 offset = ( ( ma + i ) << 1 ) & 0x1fff; |
| 316 | 342 | UINT8 data = vid[ offset ]; |
| 317 | 343 | |
| r2551 | r2552 | |
| 337 | 363 | } |
| 338 | 364 | } |
| 339 | 365 | |
| 340 | | static MC6845_UPDATE_ROW( t1000_update_row ) { |
| 341 | | if ( pcjr.update_row ) { |
| 366 | static MC6845_UPDATE_ROW( t1000_update_row ) |
| 367 | { |
| 368 | if ( pcjr.update_row ) |
| 369 | { |
| 342 | 370 | pcjr.update_row( device, bitmap, cliprect, ma, ra, y, x_count, cursor_x, param ); |
| 343 | 371 | } |
| 344 | 372 | } |
| r2551 | r2552 | |
| 352 | 380 | } |
| 353 | 381 | |
| 354 | 382 | |
| 355 | | static void pc_t1t_mode_switch( void ) { |
| 356 | | switch( pcjr.mode_control & 0x3B ) { |
| 383 | static void pc_t1t_mode_switch( void ) |
| 384 | { |
| 385 | switch( pcjr.mode_control & 0x3B ) |
| 386 | { |
| 357 | 387 | case 0x08: case 0x09: |
| 358 | 388 | pcjr.update_row = t1000_text_inten_update_row; |
| 359 | 389 | break; |
| r2551 | r2552 | |
| 361 | 391 | pcjr.update_row = t1000_text_blink_update_row; |
| 362 | 392 | break; |
| 363 | 393 | case 0x0A: case 0x0B: case 0x2A: case 0x2B: |
| 364 | | switch( pcjr.bank & 0xc0 ) { |
| 394 | switch( pcjr.bank & 0xc0 ) |
| 395 | { |
| 365 | 396 | case 0x00: |
| 366 | 397 | case 0x40: |
| 367 | 398 | //logerror("t1t_gfx_2bpp - 1\n"); |
| 368 | 399 | pcjr.update_row = t1000_gfx_2bpp_update_row; |
| 369 | | if ( pcjr.color_select ) { |
| 400 | if ( pcjr.color_select ) |
| 401 | { |
| 370 | 402 | pcjr.reg.data[0x10] = 0x00; |
| 371 | 403 | pcjr.reg.data[0x11] = 0x0B; |
| 372 | 404 | pcjr.reg.data[0x12] = 0x0D; |
| 373 | 405 | pcjr.reg.data[0x13] = 0x0F; |
| 374 | | } else { |
| 406 | } |
| 407 | else |
| 408 | { |
| 375 | 409 | pcjr.reg.data[0x10] = 0x00; |
| 376 | 410 | pcjr.reg.data[0x11] = 0x0A; |
| 377 | 411 | pcjr.reg.data[0x12] = 0x0C; |
| r2551 | r2552 | |
| 387 | 421 | break; |
| 388 | 422 | case 0x18: case 0x19: case 0x1A: case 0x1B: |
| 389 | 423 | case 0x38: case 0x39: case 0x3A: case 0x3B: |
| 390 | | switch( pcjr.bank & 0xc0 ) { |
| 424 | switch( pcjr.bank & 0xc0 ) |
| 425 | { |
| 391 | 426 | case 0x00: |
| 392 | 427 | case 0x40: |
| 393 | 428 | //logerror("t1t_gfx_1bpp\n"); |
| r2551 | r2552 | |
| 407 | 442 | } |
| 408 | 443 | |
| 409 | 444 | |
| 445 | /* mode control 1 ( pcjr.reg.data[0] ) */ |
| 446 | /* bit0 - 0 = low bandwidth, 1 = high bandwidth */ |
| 447 | /* bit1 - 0 = alpha, 1 = graphics */ |
| 448 | /* bit2 - 0 = color, 1 = b/w */ |
| 449 | /* bit3 - 0 = video disable, 1 = video enable */ |
| 450 | /* bit4 - 1 = 16 color graphics */ |
| 451 | /* mode control 2 ( pcjr.reg.data[3] ) */ |
| 452 | /* bit1 - 1 = enable blink */ |
| 453 | /* bit3 - 1 = 2 color graphics */ |
| 454 | |
| 455 | static void pc_pcjr_mode_switch( void ) |
| 456 | { |
| 457 | switch( pcjr.reg.data[0] & 0x1F ) |
| 458 | { |
| 459 | case 0x08: case 0x09: |
| 460 | case 0x0C: case 0x0D: /* B/W modes */ |
| 461 | if ( pcjr.reg.data[3] & 0x02 ) |
| 462 | { |
| 463 | pcjr.update_row = t1000_text_blink_update_row; |
| 464 | } |
| 465 | else |
| 466 | { |
| 467 | pcjr.update_row = t1000_text_inten_update_row; |
| 468 | } |
| 469 | break; |
| 470 | case 0x1A: case 0x1B: |
| 471 | pcjr.update_row = t1000_gfx_4bpp_update_row; |
| 472 | break; |
| 473 | case 0x0A: case 0x0B: |
| 474 | pcjr.update_row = t1000_gfx_2bpp_update_row; |
| 475 | break; |
| 476 | case 0x0E: |
| 477 | if ( pcjr.reg.data[3] & 0x08 ) |
| 478 | { |
| 479 | pcjr.update_row = t1000_gfx_1bpp_update_row; |
| 480 | } |
| 481 | else |
| 482 | { |
| 483 | pcjr.update_row = t1000_gfx_2bpp_update_row; /* B/W mode */ |
| 484 | } |
| 485 | break; |
| 486 | default: |
| 487 | pcjr.update_row = NULL; |
| 488 | break; |
| 489 | } |
| 490 | } |
| 491 | |
| 492 | |
| 410 | 493 | /* |
| 411 | 494 | * 3d8 rW T1T mode control register (see #P138) |
| 412 | 495 | */ |
| r2551 | r2552 | |
| 508 | 591 | } |
| 509 | 592 | } |
| 510 | 593 | |
| 594 | |
| 595 | static void pc_pcjr_vga_data_w(int data) |
| 596 | { |
| 597 | pcjr.reg.data[pcjr.reg.index] = data; |
| 598 | |
| 599 | switch (pcjr.reg.index) |
| 600 | { |
| 601 | case 0x00: /* mode control 1 */ |
| 602 | /* bit0 - 0 = low bandwidth, 1 = high bandwidth */ |
| 603 | /* bit1 - 0 = alpha, 1 = graphics */ |
| 604 | /* bit2 - 0 = color, 1 = b/w */ |
| 605 | /* bit3 - 0 = video disable, 1 = video enable */ |
| 606 | /* bit4 - 1 = 16 color graphics */ |
| 607 | pc_pcjr_mode_switch(); |
| 608 | break; |
| 609 | case 0x01: /* palette mask (bits 3-0) */ |
| 610 | break; |
| 611 | case 0x02: /* border color (bits 3-0) */ |
| 612 | break; |
| 613 | case 0x03: /* mode control 2 */ |
| 614 | /* bit1 - 1 = enable blink */ |
| 615 | /* bit3 - 1 = 2 color graphics */ |
| 616 | pc_pcjr_mode_switch(); |
| 617 | break; |
| 618 | case 0x04: /* reset register */ |
| 619 | break; |
| 620 | /* palette array */ |
| 621 | case 0x10: case 0x11: case 0x12: case 0x13: |
| 622 | case 0x14: case 0x15: case 0x16: case 0x17: |
| 623 | case 0x18: case 0x19: case 0x1a: case 0x1b: |
| 624 | case 0x1c: case 0x1d: case 0x1e: case 0x1f: |
| 625 | pcjr.reg.data[pcjr.reg.index] = data & 0x0F; |
| 626 | break; |
| 627 | } |
| 628 | } |
| 629 | |
| 630 | |
| 511 | 631 | static int pc_t1t_vga_data_r(void) |
| 512 | 632 | { |
| 513 | 633 | int data = pcjr.reg.data[pcjr.reg.index]; |
| r2551 | r2552 | |
| 553 | 673 | pcjr.bank = data; |
| 554 | 674 | /* it seems the video ram is mapped to the last 128K of main memory */ |
| 555 | 675 | #if 1 |
| 556 | | if ((data&0xc0)==0xc0) { /* needed for lemmings */ |
| 676 | if ((data&0xc0)==0xc0) /* needed for lemmings */ |
| 677 | { |
| 557 | 678 | dram = 0x80000 + ((data & 0x06) << 14); |
| 558 | 679 | vram = 0x80000 + ((data & 0x30) << (14-3)); |
| 559 | | } else { |
| 680 | } |
| 681 | else |
| 682 | { |
| 560 | 683 | dram = 0x80000 + ((data & 0x07) << 14); |
| 561 | 684 | vram = 0x80000 + ((data & 0x38) << (14-3)); |
| 562 | 685 | } |
| r2551 | r2552 | |
| 621 | 744 | } |
| 622 | 745 | } |
| 623 | 746 | |
| 747 | |
| 748 | WRITE8_HANDLER( pc_pcjr_w ) |
| 749 | { |
| 750 | device_config *devconf; |
| 751 | |
| 752 | switch( offset ) |
| 753 | { |
| 754 | case 0: case 4: |
| 755 | devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, T1000_MC6845_NAME); |
| 756 | mc6845_address_w( devconf, offset, data ); |
| 757 | break; |
| 758 | case 1: case 5: |
| 759 | devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, T1000_MC6845_NAME); |
| 760 | mc6845_register_w( devconf, offset, data ); |
| 761 | break; |
| 762 | case 10: |
| 763 | if ( pcjr.address_data_ff & 0x01 ) |
| 764 | { |
| 765 | pc_pcjr_vga_data_w( data ); |
| 766 | } |
| 767 | else |
| 768 | { |
| 769 | pc_t1t_vga_index_w( data ); |
| 770 | } |
| 771 | pcjr.address_data_ff ^= 0x01; |
| 772 | break; |
| 773 | case 11: |
| 774 | pc_t1t_lightpen_strobe_w(data); |
| 775 | break; |
| 776 | case 12: |
| 777 | break; |
| 778 | case 15: |
| 779 | pc_t1t_bank_w(data); |
| 780 | break; |
| 781 | |
| 782 | default: |
| 783 | break; |
| 784 | } |
| 785 | } |
| 786 | |
| 787 | |
| 624 | 788 | READ8_HANDLER ( pc_T1T_r ) |
| 625 | 789 | { |
| 626 | 790 | device_config *devconf; |
| r2551 | r2552 | |
| 646 | 810 | break; |
| 647 | 811 | |
| 648 | 812 | case 10: |
| 813 | pcjr.address_data_ff = 0; |
| 649 | 814 | data = pc_t1t_status_r(); |
| 650 | 815 | break; |
| 651 | 816 | |
| r2551 | r2552 | |
| 669 | 834 | } |
| 670 | 835 | |
| 671 | 836 | |
| 672 | | static MC6845_ON_HSYNC_CHANGED( t1000_hsync_changed ) { |
| 837 | static MC6845_ON_HSYNC_CHANGED( t1000_hsync_changed ) |
| 838 | { |
| 673 | 839 | pcjr.hsync = hsync ? 0 : 1; |
| 674 | 840 | } |
| 675 | 841 | |
| 676 | 842 | |
| 677 | | static MC6845_ON_VSYNC_CHANGED( t1000_vsync_changed ) { |
| 843 | static MC6845_ON_VSYNC_CHANGED( t1000_vsync_changed ) |
| 844 | { |
| 678 | 845 | pcjr.vsync = vsync ? 8 : 0; |
| 679 | | if ( vsync ) { |
| 846 | if ( vsync ) |
| 847 | { |
| 680 | 848 | pcjr.pc_framecnt++; |
| 681 | 849 | } |
| 682 | 850 | } |
| 683 | 851 | |
| 684 | | static MC6845_ON_VSYNC_CHANGED( pcjr_vsync_changed ) { |
| 852 | static MC6845_ON_VSYNC_CHANGED( pcjr_vsync_changed ) |
| 853 | { |
| 685 | 854 | pcjr.vsync = vsync ? 8 : 0; |
| 686 | | if ( vsync ) { |
| 855 | if ( vsync ) |
| 856 | { |
| 687 | 857 | pcjr.pc_framecnt++; |
| 688 | 858 | } |
| 689 | 859 | pic8259_set_irq_line(device_list_find_by_tag( device->machine->config->devicelist, PIC8259, "pic8259_master" ), 5, vsync); |