src/mess/machine/amstrad.c
| r8980 | r8981 | |
| 86 | 86 | int vsync; |
| 87 | 87 | int hsync; |
| 88 | 88 | int de; |
| 89 | int ma; |
| 90 | int ra; |
| 89 | 91 | |
| 90 | 92 | /* used for timing */ |
| 91 | 93 | int hsync_after_vsync_counter; |
| 92 | 94 | int hsync_counter; /* The gate array counts CRTC HSYNC pulses using an internal 6-bit counter. */ |
| 93 | 95 | |
| 94 | 96 | /* used for drawing the screen */ |
| 97 | attotime last_draw_time; |
| 95 | 98 | int y; |
| 99 | UINT16 *draw_p; /* Position in the bitmap where we are currently drawing */ |
| 100 | UINT16 colour; |
| 101 | UINT16 address; |
| 102 | UINT8 *mode_lookup; |
| 103 | UINT8 data; |
| 104 | UINT8 ticks; |
| 105 | UINT8 ticks_increment; |
| 106 | UINT16 line_ticks; |
| 107 | UINT8 colour_ticks; |
| 108 | UINT8 max_colour_ticks; |
| 96 | 109 | } gate_array; |
| 97 | 110 | |
| 98 | 111 | |
| r8980 | r8981 | |
| 100 | 113 | * ASIC data (CPC plus) |
| 101 | 114 | ****************************/ |
| 102 | 115 | static struct { |
| 116 | UINT8 *ram; /* pointer to RAM used for the CPC+ ASIC memory-mapped registers */ |
| 103 | 117 | UINT8 enabled; /* Are CPC plus features enabled/unlocked */ |
| 104 | 118 | UINT8 pri; /* Programmable raster interrupt */ |
| 105 | 119 | UINT8 seqptr; /* Current position in the ASIC unlocking sequence */ |
| 106 | 120 | UINT8 rmr2; /* ROM mapping register 2 */ |
| 107 | 121 | UINT16 split_ma_base; /* Used to handle split screen support */ |
| 108 | 122 | UINT16 split_ma_started; /* Used to handle split screen support */ |
| 123 | UINT16 vpos; /* Current logical scanline */ |
| 124 | UINT16 h_start; /* Position where DE became active */ |
| 125 | UINT16 h_end; /* Position where DE became inactive */ |
| 126 | UINT8 addr_6845; /* We need these to store a shadow copy of R1 of the mc6845 */ |
| 127 | UINT8 horiz_disp; |
| 128 | UINT8 hscroll; |
| 109 | 129 | |
| 110 | 130 | /* DMA */ |
| 111 | 131 | UINT8 dma_status; |
| r8980 | r8981 | |
| 126 | 146 | static unsigned char *Aleste_RamBanks[4]; |
| 127 | 147 | static int aleste_active_page[4]; // page mapped to CPU RAM (is readable?) |
| 128 | 148 | |
| 129 | | /* pointer to RAM used for the CPC+ ASIC memory-mapped registers */ |
| 130 | | static UINT8 *amstrad_plus_asic_ram; |
| 131 | | |
| 132 | 149 | /* the hardware allows selection of 256 ROMs. Rom 0 is usually BASIC and Rom 7 is AMSDOS */ |
| 133 | 150 | /* With the CPC hardware, if a expansion ROM is not connected, BASIC rom will be selected instead */ |
| 134 | 151 | static unsigned char *Amstrad_ROM_Table[256]; |
| r8980 | r8981 | |
| 171 | 188 | /* colours can be changed at any time and will take effect immediatly */ |
| 172 | 189 | static UINT16 amstrad_GateArray_render_colours[17]; |
| 173 | 190 | |
| 174 | | static mc6845_update_row_func draw_function; |
| 191 | static UINT8 mode0_lookup[256]; |
| 192 | static UINT8 mode1_lookup[256]; |
| 193 | static UINT8 mode2_lookup[256]; |
| 175 | 194 | |
| 176 | | static UINT8 mode0_lookup[256][2]; |
| 177 | | static UINT8 mode1_lookup[256][4]; |
| 178 | 195 | |
| 179 | | |
| 180 | 196 | /* The Amstrad CPC has a fixed palette of 27 colours generated from 3 levels of Red, Green and Blue. |
| 181 | 197 | The hardware allows selection of 32 colours, but these extra colours are copies of existing colours.*/ |
| 182 | 198 | |
| r8980 | r8981 | |
| 259 | 275 | Prototypes |
| 260 | 276 | *******************************************************************/ |
| 261 | 277 | |
| 262 | | static MC6845_UPDATE_ROW( amstrad_update_row_mode0 ); |
| 263 | | static MC6845_UPDATE_ROW( amstrad_update_row_mode1 ); |
| 264 | | static MC6845_UPDATE_ROW( amstrad_update_row_mode2 ); |
| 265 | | static MC6845_UPDATE_ROW( amstrad_update_row_mode3 ); |
| 266 | | static MC6845_UPDATE_ROW( aleste_update_row_mode2 ); |
| 267 | | static MC6845_UPDATE_ROW( aleste_update_row_mode3 ); |
| 268 | | static MC6845_UPDATE_ROW( amstrad_plus_update_row_mode0 ); |
| 269 | | static MC6845_UPDATE_ROW( amstrad_plus_update_row_mode1 ); |
| 270 | | static MC6845_UPDATE_ROW( amstrad_plus_update_row_mode2 ); |
| 271 | | static MC6845_UPDATE_ROW( amstrad_plus_update_row_mode3 ); |
| 272 | | static MC6845_UPDATE_ROW( amstrad_plus_update_row_sprites ); |
| 278 | INLINE void amstrad_update_video( running_machine *machine ); |
| 279 | INLINE void amstrad_plus_update_video( running_machine *machine ); |
| 273 | 280 | static void amstrad_rethinkMemory(running_machine *machine); |
| 274 | 281 | |
| 275 | 282 | |
| r8980 | r8981 | |
| 434 | 441 | |
| 435 | 442 | for ( i = 0; i < 256; i++ ) |
| 436 | 443 | { |
| 437 | | mode0_lookup[i][0] = ( ( i & 0x80 ) >> 7 ) | ( ( i & 0x20 ) >> 3 ) | ( ( i & 0x08 ) >> 2 ) | ( ( i & 0x02 ) << 2 ); |
| 438 | | mode0_lookup[i][1] = ( ( i & 0x40 ) >> 6 ) | ( ( i & 0x10 ) >> 2 ) | ( ( i & 0x04 ) >> 1 ) | ( ( i & 0x01 ) << 3 ); |
| 439 | | |
| 440 | | mode1_lookup[i][0] = ( ( i & 0x80 ) >> 7 ) | ( ( i & 0x08 ) >> 2 ); |
| 441 | | mode1_lookup[i][1] = ( ( i & 0x40 ) >> 6 ) | ( ( i & 0x04 ) >> 1 ); |
| 442 | | mode1_lookup[i][2] = ( ( i & 0x20 ) >> 5 ) | ( ( i & 0x02 ) ); |
| 443 | | mode1_lookup[i][3] = ( ( i & 0x10 ) >> 4 ) | ( ( i & 0x01 ) << 1 ); |
| 444 | mode0_lookup[i] = ( ( i & 0x80 ) >> 7 ) | ( ( i & 0x20 ) >> 3 ) | ( ( i & 0x08 ) >> 2 ) | ( ( i & 0x02 ) << 2 ); |
| 445 | mode1_lookup[i] = ( ( i & 0x80 ) >> 7 ) | ( ( i & 0x08 ) >> 2 ); |
| 446 | mode2_lookup[i] = ( ( i & 0x80 ) >> 7 ); |
| 444 | 447 | } |
| 445 | 448 | } |
| 446 | 449 | |
| r8980 | r8981 | |
| 454 | 457 | switch ( gate_array.mrer & 0x03 ) |
| 455 | 458 | { |
| 456 | 459 | case 0: /* Mode 0: 160x200, 16 colours */ |
| 457 | | draw_function = amstrad_plus_update_row_mode0; |
| 460 | gate_array.mode_lookup = mode0_lookup; |
| 461 | gate_array.max_colour_ticks = 4; |
| 462 | gate_array.ticks_increment = 1; |
| 458 | 463 | break; |
| 459 | 464 | |
| 460 | 465 | case 1: /* Mode 1: 320x200, 4 colous */ |
| 461 | | draw_function = amstrad_plus_update_row_mode1; |
| 466 | gate_array.mode_lookup = mode1_lookup; |
| 467 | gate_array.max_colour_ticks = 2; |
| 468 | gate_array.ticks_increment = 1; |
| 462 | 469 | break; |
| 463 | 470 | |
| 464 | 471 | case 2: /* Mode 2: 640x200, 2 colours */ |
| 465 | | draw_function = amstrad_plus_update_row_mode2; |
| 472 | gate_array.mode_lookup = mode2_lookup; |
| 473 | gate_array.max_colour_ticks = 1; |
| 474 | gate_array.ticks_increment = 1; |
| 466 | 475 | break; |
| 467 | 476 | |
| 468 | 477 | case 3: /* Mode 3: 160x200, 4 colours */ |
| 469 | | draw_function = amstrad_plus_update_row_mode3; |
| 478 | gate_array.mode_lookup = mode0_lookup; |
| 479 | gate_array.max_colour_ticks = 4; |
| 480 | gate_array.ticks_increment = 1; |
| 470 | 481 | break; |
| 471 | 482 | } |
| 472 | 483 | } |
| r8980 | r8981 | |
| 478 | 489 | switch ( gate_array.mrer & 0x03 ) |
| 479 | 490 | { |
| 480 | 491 | case 0: /* Aleste Mode 0 (= Amstrad CPC mode 2): 640x200, 2 colours */ |
| 481 | | draw_function = amstrad_update_row_mode2; |
| 492 | gate_array.mode_lookup = mode2_lookup; |
| 493 | gate_array.max_colour_ticks = 1; |
| 494 | gate_array.ticks_increment = 1; |
| 482 | 495 | break; |
| 483 | 496 | |
| 484 | | case 1: /* Aleste mode 1: 320x200, 4 colours */ |
| 485 | | draw_function = amstrad_update_row_mode1; |
| 497 | case 1: /* Aleste mode 1 (= Amstrad CPC mode 1): 320x200, 4 colours */ |
| 498 | gate_array.mode_lookup = mode1_lookup; |
| 499 | gate_array.max_colour_ticks = 2; |
| 500 | gate_array.ticks_increment = 1; |
| 486 | 501 | break; |
| 487 | 502 | |
| 488 | 503 | case 2: /* Aleste mode 2: 4 colours */ |
| 489 | | draw_function = aleste_update_row_mode2; |
| 504 | gate_array.mode_lookup = mode1_lookup; |
| 505 | gate_array.max_colour_ticks = 1; |
| 506 | gate_array.ticks_increment = 2; |
| 490 | 507 | break; |
| 491 | 508 | |
| 492 | 509 | case 3: /* Aleste mode 3: 16 colours */ |
| 493 | | draw_function = aleste_update_row_mode3; |
| 510 | gate_array.mode_lookup = mode0_lookup; |
| 511 | gate_array.max_colour_ticks = 2; |
| 512 | gate_array.ticks_increment = 2; |
| 494 | 513 | break; |
| 495 | 514 | } |
| 496 | 515 | } |
| r8980 | r8981 | |
| 500 | 519 | switch ( gate_array.mrer & 0x03 ) |
| 501 | 520 | { |
| 502 | 521 | case 0: /* Mode 0: 160x200, 16 colours */ |
| 503 | | draw_function = amstrad_update_row_mode0; |
| 522 | gate_array.mode_lookup = mode0_lookup; |
| 523 | gate_array.max_colour_ticks = 4; |
| 524 | gate_array.ticks_increment = 1; |
| 504 | 525 | break; |
| 505 | 526 | |
| 506 | 527 | case 1: /* Mode 1: 320x200, 4 colous */ |
| 507 | | draw_function = amstrad_update_row_mode1; |
| 528 | gate_array.mode_lookup = mode1_lookup; |
| 529 | gate_array.max_colour_ticks = 2; |
| 530 | gate_array.ticks_increment = 1; |
| 508 | 531 | break; |
| 509 | 532 | |
| 510 | 533 | case 2: /* Mode 2: 640x200, 2 colours */ |
| 511 | | draw_function = amstrad_update_row_mode2; |
| 534 | gate_array.mode_lookup = mode2_lookup; |
| 535 | gate_array.max_colour_ticks = 1; |
| 536 | gate_array.ticks_increment = 1; |
| 512 | 537 | break; |
| 513 | 538 | |
| 514 | 539 | case 3: /* Mode 3: 160x200, 4 colours */ |
| 515 | | draw_function = amstrad_update_row_mode3; |
| 540 | gate_array.mode_lookup = mode0_lookup; |
| 541 | gate_array.max_colour_ticks = 4; |
| 542 | gate_array.ticks_increment = 1; |
| 516 | 543 | break; |
| 517 | 544 | } |
| 518 | 545 | } |
| r8980 | r8981 | |
| 546 | 573 | if ( asic.dma_prescaler[channel] == 0 ) |
| 547 | 574 | { |
| 548 | 575 | asic.dma_pause[channel]--; |
| 549 | | asic.dma_prescaler[channel] = amstrad_plus_asic_ram[0x2c02 + (4*channel)] + 1; |
| 576 | asic.dma_prescaler[channel] = asic.ram[0x2c02 + (4*channel)] + 1; |
| 550 | 577 | } |
| 551 | 578 | return; |
| 552 | 579 | } |
| r8980 | r8981 | |
| 587 | 614 | if (command & 0x10) // Cause interrupt |
| 588 | 615 | { |
| 589 | 616 | amstrad_plus_irq_cause = channel * 2; |
| 590 | | amstrad_plus_asic_ram[0x2c0f] |= (0x40 >> channel); |
| 617 | asic.ram[0x2c0f] |= (0x40 >> channel); |
| 591 | 618 | cputag_set_input_line(machine, "maincpu", 0, ASSERT_LINE); |
| 592 | 619 | logerror("DMA %i: INT\n",channel); |
| 593 | 620 | } |
| r8980 | r8981 | |
| 618 | 645 | |
| 619 | 646 | |
| 620 | 647 | /* Set the new colour from the GateArray */ |
| 621 | | static void amstrad_vh_update_colour(int PenIndex, UINT16 hw_colour_index) |
| 648 | static void amstrad_vh_update_colour(running_machine *machine, int PenIndex, UINT16 hw_colour_index) |
| 622 | 649 | { |
| 623 | | int val; |
| 624 | | |
| 625 | | amstrad_GateArray_render_colours[PenIndex] = hw_colour_index; |
| 626 | | |
| 627 | 650 | if ( amstrad_system_type == SYSTEM_PLUS || amstrad_system_type == SYSTEM_GX4000 ) |
| 628 | 651 | { |
| 652 | int val; |
| 653 | |
| 654 | amstrad_plus_update_video( machine ); |
| 655 | |
| 629 | 656 | /* CPC+/GX4000 - normal palette changes through the Gate Array also makes the corresponding change in the ASIC palette */ |
| 630 | 657 | val = (amstrad_palette[hw_colour_index] & 0xf00000) >> 16; /* red */ |
| 631 | 658 | val |= (amstrad_palette[hw_colour_index] & 0x0000f0) >> 4; /* blue */ |
| 632 | | amstrad_plus_asic_ram[0x2400+PenIndex*2] = val; |
| 659 | asic.ram[0x2400+PenIndex*2] = val; |
| 633 | 660 | val = (amstrad_palette[hw_colour_index] & 0x00f000) >> 12; /* green */ |
| 634 | | amstrad_plus_asic_ram[0x2401+PenIndex*2] = val; |
| 661 | asic.ram[0x2401+PenIndex*2] = val; |
| 635 | 662 | } |
| 636 | | } |
| 637 | | |
| 638 | | |
| 639 | | static void aleste_vh_update_colour(int PenIndex, UINT16 hw_colour_index) |
| 640 | | { |
| 641 | | amstrad_GateArray_render_colours[PenIndex] = hw_colour_index+32; |
| 642 | | } |
| 643 | | |
| 644 | | |
| 645 | | /* Mode 0: 160x200, 16 colours */ |
| 646 | | static MC6845_UPDATE_ROW( amstrad_update_row_mode0 ) |
| 647 | | { |
| 648 | | UINT16 *p = BITMAP_ADDR16( bitmap, y, 0 ); |
| 649 | | int i; |
| 650 | | |
| 651 | | for ( i = 0; i < x_count; i++ ) |
| 663 | else |
| 652 | 664 | { |
| 653 | | UINT16 address = ( ( ( ma + i ) & 0x3000 ) << 2 ) | ( ( ra & 0x07 ) << 11 ) | ( ( ( ma + i ) & 0x3ff ) << 1 ); |
| 654 | | UINT8 data0 = messram_get_ptr(device->machine->device("messram"))[ address ]; |
| 655 | | UINT8 data1 = messram_get_ptr(device->machine->device("messram"))[ address + 1 ]; |
| 656 | | UINT16 c; |
| 657 | | |
| 658 | | c = amstrad_GateArray_render_colours[ mode0_lookup[data0][0] ]; |
| 659 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 660 | | c = amstrad_GateArray_render_colours[ mode0_lookup[data0][1] ]; |
| 661 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 662 | | c = amstrad_GateArray_render_colours[ mode0_lookup[data1][0] ]; |
| 663 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 664 | | c = amstrad_GateArray_render_colours[ mode0_lookup[data1][1] ]; |
| 665 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 665 | amstrad_update_video( machine ); |
| 666 | 666 | } |
| 667 | amstrad_GateArray_render_colours[PenIndex] = hw_colour_index; |
| 667 | 668 | } |
| 668 | 669 | |
| 669 | 670 | |
| 670 | | /* Mode 1: 320x200, 4 colous */ |
| 671 | | static MC6845_UPDATE_ROW( amstrad_update_row_mode1 ) |
| 671 | static void aleste_vh_update_colour(running_machine *machine, int PenIndex, UINT16 hw_colour_index) |
| 672 | 672 | { |
| 673 | | UINT16 *p = BITMAP_ADDR16( bitmap, y, 0 ); |
| 674 | | int i; |
| 675 | | |
| 676 | | for ( i = 0; i < x_count; i++ ) |
| 677 | | { |
| 678 | | UINT16 address = ( ( ( ma + i ) & 0x3000 ) << 2 ) | ( ( ra & 0x07 ) << 11 ) | ( ( ( ma + i ) & 0x3ff ) << 1 ); |
| 679 | | UINT8 data0 = messram_get_ptr(device->machine->device("messram"))[ address ]; |
| 680 | | UINT8 data1 = messram_get_ptr(device->machine->device("messram"))[ address + 1 ]; |
| 681 | | UINT16 c; |
| 682 | | |
| 683 | | c = amstrad_GateArray_render_colours[ mode1_lookup[data0][0] ]; |
| 684 | | *p = c; p++; *p = c; p++; |
| 685 | | c = amstrad_GateArray_render_colours[ mode1_lookup[data0][1] ]; |
| 686 | | *p = c; p++; *p = c; p++; |
| 687 | | c = amstrad_GateArray_render_colours[ mode1_lookup[data0][2] ]; |
| 688 | | *p = c; p++; *p = c; p++; |
| 689 | | c = amstrad_GateArray_render_colours[ mode1_lookup[data0][3] ]; |
| 690 | | *p = c; p++; *p = c; p++; |
| 691 | | c = amstrad_GateArray_render_colours[ mode1_lookup[data1][0] ]; |
| 692 | | *p = c; p++; *p = c; p++; |
| 693 | | c = amstrad_GateArray_render_colours[ mode1_lookup[data1][1] ]; |
| 694 | | *p = c; p++; *p = c; p++; |
| 695 | | c = amstrad_GateArray_render_colours[ mode1_lookup[data1][2] ]; |
| 696 | | *p = c; p++; *p = c; p++; |
| 697 | | c = amstrad_GateArray_render_colours[ mode1_lookup[data1][3] ]; |
| 698 | | *p = c; p++; *p = c; p++; |
| 699 | | } |
| 673 | amstrad_update_video( machine ); |
| 674 | amstrad_GateArray_render_colours[PenIndex] = hw_colour_index+32; |
| 700 | 675 | } |
| 701 | 676 | |
| 702 | 677 | |
| 703 | | /* Mode 2: 640x200, 2 colours */ |
| 704 | | static MC6845_UPDATE_ROW( amstrad_update_row_mode2 ) |
| 678 | INLINE void amstrad_gate_array_get_video_data( running_machine *machine ) |
| 705 | 679 | { |
| 706 | | UINT16 *p = BITMAP_ADDR16( bitmap, y, 0 ); |
| 707 | | int i; |
| 708 | | |
| 709 | | for ( i = 0; i < x_count; i++ ) |
| 710 | | { |
| 711 | | UINT16 address = ( ( ( ma + i ) & 0x3000 ) << 2 ) | ( ( ra & 0x07 ) << 11 ) | ( ( ( ma + i ) & 0x3ff ) << 1 ); |
| 712 | | UINT8 data0 = messram_get_ptr(device->machine->device("messram"))[ address ]; |
| 713 | | UINT8 data1 = messram_get_ptr(device->machine->device("messram"))[ address + 1 ]; |
| 714 | | |
| 715 | | *p = amstrad_GateArray_render_colours[ ( data0 & 0x80 ) >> 7 ]; p++; |
| 716 | | *p = amstrad_GateArray_render_colours[ ( data0 & 0x40 ) >> 6 ]; p++; |
| 717 | | *p = amstrad_GateArray_render_colours[ ( data0 & 0x20 ) >> 5 ]; p++; |
| 718 | | *p = amstrad_GateArray_render_colours[ ( data0 & 0x10 ) >> 4 ]; p++; |
| 719 | | *p = amstrad_GateArray_render_colours[ ( data0 & 0x08 ) >> 3 ]; p++; |
| 720 | | *p = amstrad_GateArray_render_colours[ ( data0 & 0x04 ) >> 2 ]; p++; |
| 721 | | *p = amstrad_GateArray_render_colours[ ( data0 & 0x02 ) >> 1 ]; p++; |
| 722 | | *p = amstrad_GateArray_render_colours[ ( data0 & 0x01 ) ]; p++; |
| 723 | | *p = amstrad_GateArray_render_colours[ ( data1 & 0x80 ) >> 7 ]; p++; |
| 724 | | *p = amstrad_GateArray_render_colours[ ( data1 & 0x40 ) >> 6 ]; p++; |
| 725 | | *p = amstrad_GateArray_render_colours[ ( data1 & 0x20 ) >> 5 ]; p++; |
| 726 | | *p = amstrad_GateArray_render_colours[ ( data1 & 0x10 ) >> 4 ]; p++; |
| 727 | | *p = amstrad_GateArray_render_colours[ ( data1 & 0x08 ) >> 3 ]; p++; |
| 728 | | *p = amstrad_GateArray_render_colours[ ( data1 & 0x04 ) >> 2 ]; p++; |
| 729 | | *p = amstrad_GateArray_render_colours[ ( data1 & 0x02 ) >> 1 ]; p++; |
| 730 | | *p = amstrad_GateArray_render_colours[ ( data1 & 0x01 ) ]; p++; |
| 731 | | } |
| 680 | if ( aleste_mode & 0x02 ) |
| 681 | gate_array.address = ( ( gate_array.ma & 0x2000 ) << 2 ) | ( ( gate_array.ra & 0x06 ) << 11 ) | ( ( gate_array.ra & 0x01 ) << 14 ) | ( ( gate_array.ma & 0x7ff ) << 1 ); |
| 682 | else |
| 683 | gate_array.address = ( ( gate_array.ma & 0x3000 ) << 2 ) | ( ( gate_array.ra & 0x07 ) << 11 ) | ( ( gate_array.ma & 0x3ff ) << 1 ); |
| 684 | gate_array.data = messram_get_ptr(machine->device("messram"))[ gate_array.address ]; |
| 685 | gate_array.colour = amstrad_GateArray_render_colours[ gate_array.mode_lookup[gate_array.data] ]; |
| 686 | gate_array.colour_ticks = gate_array.max_colour_ticks; |
| 687 | gate_array.ticks = 0; |
| 732 | 688 | } |
| 733 | 689 | |
| 734 | 690 | |
| 735 | | /* Mode 3: 160x200, 4 colours */ |
| 736 | | static MC6845_UPDATE_ROW( amstrad_update_row_mode3 ) |
| 691 | INLINE void amstrad_update_video( running_machine *machine ) |
| 737 | 692 | { |
| 738 | | UINT16 *p = BITMAP_ADDR16( bitmap, y, 0 ); |
| 739 | | int i; |
| 693 | attotime now = timer_get_time(machine); |
| 740 | 694 | |
| 741 | | for ( i = 0; i < x_count; i++ ) |
| 695 | if ( gate_array.draw_p ) |
| 742 | 696 | { |
| 743 | | UINT16 address = ( ( ( ma + i ) & 0x3000 ) << 2 ) | ( ( ra & 0x07 ) << 11 ) | ( ( ( ma + i ) & 0x3ff ) << 1 ); |
| 744 | | UINT8 data0 = messram_get_ptr(device->machine->device("messram"))[ address ]; |
| 745 | | UINT8 data1 = messram_get_ptr(device->machine->device("messram"))[ address + 1 ]; |
| 746 | | UINT16 c; |
| 697 | UINT32 cycles_passed = attotime_to_ticks( attotime_sub( now, gate_array.last_draw_time ), XTAL_16MHz ); |
| 747 | 698 | |
| 748 | | c = amstrad_GateArray_render_colours[ mode1_lookup[data0][0] ]; |
| 749 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 750 | | c = amstrad_GateArray_render_colours[ mode1_lookup[data0][1] ]; |
| 751 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 752 | | c = amstrad_GateArray_render_colours[ mode1_lookup[data1][0] ]; |
| 753 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 754 | | c = amstrad_GateArray_render_colours[ mode1_lookup[data1][1] ]; |
| 755 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 756 | | |
| 757 | | } |
| 758 | | } |
| 759 | | |
| 760 | | |
| 761 | | /* Plus Mode 0: 160x200, 16 colours */ |
| 762 | | static MC6845_UPDATE_ROW( amstrad_plus_update_row_mode0 ) |
| 763 | | { |
| 764 | | UINT16 *p = BITMAP_ADDR16( bitmap, y, 0 ); |
| 765 | | UINT16 c; |
| 766 | | int i; |
| 767 | | |
| 768 | | logerror( "amstrad_plus_update_row_mode0: ma = 0x%04x, ra = %d, y = %d, x_count = %d, cursor_x = %d\n", ma, ra, y, x_count, cursor_x ); |
| 769 | | |
| 770 | | /* Apply horizontal background scrolling */ |
| 771 | | for ( i = amstrad_plus_asic_ram[0x2804] & 0x0f; i > 0; i-- ) |
| 772 | | { |
| 773 | | if ( amstrad_plus_asic_ram[0x2804] & 0x80 ) |
| 699 | while( cycles_passed ) |
| 774 | 700 | { |
| 775 | | /* Border colour */ |
| 776 | | c = amstrad_plus_asic_ram[0x2420] + ( amstrad_plus_asic_ram[0x2421] << 8 ); |
| 701 | if ( ! gate_array.de || ( ( aleste_mode & 0x02 ) && ! ( aleste_mode & 0x08 ) ) ) |
| 702 | { |
| 703 | *gate_array.draw_p = amstrad_GateArray_render_colours[ 16 ]; |
| 704 | } |
| 705 | else |
| 706 | { |
| 707 | *gate_array.draw_p = gate_array.colour; |
| 708 | gate_array.colour_ticks--; |
| 709 | if ( ! gate_array.colour_ticks ) |
| 710 | { |
| 711 | gate_array.data <<= 1; |
| 712 | gate_array.colour = amstrad_GateArray_render_colours[ gate_array.mode_lookup[gate_array.data] ]; |
| 713 | gate_array.colour_ticks = gate_array.max_colour_ticks; |
| 714 | } |
| 715 | gate_array.ticks += gate_array.ticks_increment; |
| 716 | switch( gate_array.ticks) |
| 717 | { |
| 718 | case 8: |
| 719 | gate_array.data = messram_get_ptr(machine->device("messram"))[ gate_array.address + 1 ]; |
| 720 | gate_array.colour = amstrad_GateArray_render_colours[ gate_array.mode_lookup[gate_array.data] ]; |
| 721 | break; |
| 722 | case 16: |
| 723 | gate_array.ma += 1; /* If we were synced with the 6845 mc6845_get_ma should return this value */ |
| 724 | amstrad_gate_array_get_video_data( machine ); |
| 725 | break; |
| 726 | } |
| 727 | } |
| 728 | gate_array.draw_p++; |
| 729 | cycles_passed--; |
| 730 | gate_array.line_ticks++; |
| 731 | if ( gate_array.line_ticks > gate_array.bitmap->width ) |
| 732 | { |
| 733 | gate_array.draw_p = NULL; |
| 734 | cycles_passed = 0; |
| 735 | } |
| 777 | 736 | } |
| 778 | | else |
| 779 | | { |
| 780 | | /* Random(?) colour data */ |
| 781 | | c = amstrad_plus_asic_ram[0x2420] + ( amstrad_plus_asic_ram[0x2421] << 8 ); |
| 782 | | } |
| 783 | | *p = c; p++; |
| 784 | 737 | } |
| 785 | 738 | |
| 786 | | /* Apply vertical background scrolling */ |
| 787 | | ra += ( ( amstrad_plus_asic_ram[0x2804] >> 4 ) & 0x07 ); |
| 788 | | if ( ra > 7 ) |
| 789 | | { |
| 790 | | ma += x_count; |
| 791 | | } |
| 792 | | |
| 793 | | for ( i = 0; i < x_count; i++ ) |
| 794 | | { |
| 795 | | UINT16 address = ( ( ( ma + i ) & 0x3000 ) << 2 ) | ( ( ra & 0x07 ) << 11 ) | ( ( ( ma + i ) & 0x3ff ) << 1 ); |
| 796 | | UINT16 caddr; |
| 797 | | UINT8 data0 = messram_get_ptr(device->machine->device("messram"))[ address ]; |
| 798 | | UINT8 data1 = messram_get_ptr(device->machine->device("messram"))[ address + 1 ]; |
| 799 | | |
| 800 | | caddr = 0x2400 + mode0_lookup[data0][0] * 2; |
| 801 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 802 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 803 | | caddr = 0x2400 + mode0_lookup[data0][1] * 2; |
| 804 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 805 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 806 | | caddr = 0x2400 + mode0_lookup[data1][0] * 2; |
| 807 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 808 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 809 | | caddr = 0x2400 + mode0_lookup[data1][1] * 2; |
| 810 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 811 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 812 | | } |
| 739 | gate_array.last_draw_time = now; |
| 813 | 740 | } |
| 814 | 741 | |
| 815 | 742 | |
| 816 | | /* Plus Mode 1: 320x200, 4 colours */ |
| 817 | | static MC6845_UPDATE_ROW( amstrad_plus_update_row_mode1 ) |
| 743 | INLINE void amstrad_plus_gate_array_get_video_data( running_machine *machine ) |
| 818 | 744 | { |
| 819 | | UINT16 *p = BITMAP_ADDR16( bitmap, y, 0 ); |
| 820 | | UINT16 c; |
| 821 | | int i; |
| 745 | UINT16 caddr; |
| 746 | UINT16 ma = ( gate_array.ma - asic.split_ma_started ) + asic.split_ma_base; |
| 747 | UINT16 ra = gate_array.ra + ( ( asic.ram[0x2804] >> 4 ) & 0x07 ); |
| 822 | 748 | |
| 823 | | logerror( "amstrad_plus_update_row_mode1: ma = 0x%04x, ra = %d, y = %d, x_count = %d, cursor_x = %d\n", ma, ra, y, x_count, cursor_x ); |
| 824 | | |
| 825 | | /* Apply horizontal background scrolling */ |
| 826 | | for ( i = amstrad_plus_asic_ram[0x2804] & 0x0f; i > 0; i-- ) |
| 827 | | { |
| 828 | | if ( amstrad_plus_asic_ram[0x2804] & 0x80 ) |
| 829 | | { |
| 830 | | /* Border colour */ |
| 831 | | c = amstrad_plus_asic_ram[0x2420] + ( amstrad_plus_asic_ram[0x2421] << 8 ); |
| 832 | | } |
| 833 | | else |
| 834 | | { |
| 835 | | /* Random(?) colour data */ |
| 836 | | c = amstrad_plus_asic_ram[0x2420] + ( amstrad_plus_asic_ram[0x2421] << 8 ); |
| 837 | | } |
| 838 | | *p = c; p++; |
| 839 | | } |
| 840 | | |
| 841 | | /* Apply vertical background scrolling */ |
| 842 | | ra += ( ( amstrad_plus_asic_ram[0x2804] >> 4 ) & 0x07 ); |
| 843 | 749 | if ( ra > 7 ) |
| 844 | 750 | { |
| 845 | | ma += x_count; |
| 751 | ma += asic.horiz_disp; |
| 846 | 752 | } |
| 847 | | |
| 848 | | for ( i = 0; i < x_count; i++ ) |
| 849 | | { |
| 850 | | UINT16 address = ( ( ( ma + i ) & 0x3000 ) << 2 ) | ( ( ra & 0x07 ) << 11 ) | ( ( ( ma + i ) & 0x3ff ) << 1 ); |
| 851 | | UINT16 caddr; |
| 852 | | UINT8 data0 = messram_get_ptr(device->machine->device("messram"))[ address ]; |
| 853 | | UINT8 data1 = messram_get_ptr(device->machine->device("messram"))[ address + 1 ]; |
| 854 | | |
| 855 | | caddr = 0x2400 + mode1_lookup[data0][0] * 2; |
| 856 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 857 | | *p = c; p++; *p = c; p++; |
| 858 | | caddr = 0x2400 + mode1_lookup[data0][1] * 2; |
| 859 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 860 | | *p = c; p++; *p = c; p++; |
| 861 | | caddr = 0x2400 + mode1_lookup[data0][2] * 2; |
| 862 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 863 | | *p = c; p++; *p = c; p++; |
| 864 | | caddr = 0x2400 + mode1_lookup[data0][3] * 2; |
| 865 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 866 | | *p = c; p++; *p = c; p++; |
| 867 | | caddr = 0x2400 + mode1_lookup[data1][0] * 2; |
| 868 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 869 | | *p = c; p++; *p = c; p++; |
| 870 | | caddr = 0x2400 + mode1_lookup[data1][1] * 2; |
| 871 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 872 | | *p = c; p++; *p = c; p++; |
| 873 | | caddr = 0x2400 + mode1_lookup[data1][2] * 2; |
| 874 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 875 | | *p = c; p++; *p = c; p++; |
| 876 | | caddr = 0x2400 + mode1_lookup[data1][3] * 2; |
| 877 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 878 | | *p = c; p++; *p = c; p++; |
| 879 | | } |
| 753 | gate_array.address = ( ( ma & 0x3000 ) << 2 ) | ( ( gate_array.ra & 0x07 ) << 11 ) | ( ( ma & 0x3ff ) << 1 ); |
| 754 | gate_array.data = messram_get_ptr(machine->device("messram"))[ gate_array.address ]; |
| 755 | caddr = 0x2400 + gate_array.mode_lookup[gate_array.data] * 2; |
| 756 | gate_array.colour = asic.ram[caddr] + ( asic.ram[caddr+1] << 8 ); |
| 757 | gate_array.colour_ticks = gate_array.max_colour_ticks; |
| 758 | gate_array.ticks = 0; |
| 880 | 759 | } |
| 881 | 760 | |
| 882 | 761 | |
| 883 | | /* Plus Mode 2: 640x200, 2 colours */ |
| 884 | | static MC6845_UPDATE_ROW( amstrad_plus_update_row_mode2 ) |
| 762 | INLINE void amstrad_plus_update_video( running_machine *machine ) |
| 885 | 763 | { |
| 886 | | UINT16 *p = BITMAP_ADDR16( bitmap, y, 0 ); |
| 887 | | UINT16 c; |
| 888 | | int i; |
| 764 | attotime now = timer_get_time(machine); |
| 889 | 765 | |
| 890 | | logerror( "amstrad_plus_update_row_mode2: ma = 0x%04x, ra = %d, y = %d, x_count = %d, cursor_x = %d\n", ma, ra, y, x_count, cursor_x ); |
| 891 | | |
| 892 | | /* Apply horizontal background scrolling */ |
| 893 | | for ( i = amstrad_plus_asic_ram[0x2804] & 0x0f; i > 0; i-- ) |
| 766 | if ( gate_array.draw_p ) |
| 894 | 767 | { |
| 895 | | if ( amstrad_plus_asic_ram[0x2804] & 0x80 ) |
| 768 | UINT32 cycles_passed = attotime_to_ticks( attotime_sub( now, gate_array.last_draw_time ), XTAL_16MHz ); |
| 769 | |
| 770 | while( cycles_passed ) |
| 896 | 771 | { |
| 897 | | /* Border colour */ |
| 898 | | c = amstrad_plus_asic_ram[0x2420] + ( amstrad_plus_asic_ram[0x2421] << 8 ); |
| 899 | | } |
| 900 | | else |
| 901 | | { |
| 902 | | /* Random(?) colour data */ |
| 903 | | c = amstrad_plus_asic_ram[0x2420] + ( amstrad_plus_asic_ram[0x2421] << 8 ); |
| 904 | | } |
| 905 | | *p = c; p++; |
| 906 | | } |
| 772 | if ( ! gate_array.de ) |
| 773 | { |
| 774 | *gate_array.draw_p = asic.ram[0x2420] + ( asic.ram[0x2421] << 8 ); |
| 775 | } |
| 776 | else |
| 777 | { |
| 778 | *gate_array.draw_p = gate_array.colour; |
| 907 | 779 | |
| 908 | | /* Apply vertical background scrolling */ |
| 909 | | ra += ( ( amstrad_plus_asic_ram[0x2804] >> 4 ) & 0x07 ); |
| 910 | | if ( ra > 7 ) |
| 911 | | { |
| 912 | | ma += x_count; |
| 913 | | } |
| 780 | if ( asic.hscroll ) |
| 781 | { |
| 782 | asic.hscroll--; |
| 783 | if ( asic.hscroll == 0 ) |
| 784 | amstrad_plus_gate_array_get_video_data( machine ); |
| 785 | } |
| 786 | else |
| 787 | { |
| 788 | gate_array.colour_ticks--; |
| 789 | if ( ! gate_array.colour_ticks ) |
| 790 | { |
| 791 | UINT16 caddr; |
| 914 | 792 | |
| 915 | | for ( i = 0; i < x_count; i++ ) |
| 916 | | { |
| 917 | | UINT16 address = ( ( ( ma + i ) & 0x3000 ) << 2 ) | ( ( ra & 0x07 ) << 11 ) | ( ( ( ma + i ) & 0x3ff ) << 1 ); |
| 918 | | UINT16 caddr; |
| 919 | | UINT8 data0 = messram_get_ptr(device->machine->device("messram"))[ address ]; |
| 920 | | UINT8 data1 = messram_get_ptr(device->machine->device("messram"))[ address + 1 ]; |
| 793 | gate_array.data <<= 1; |
| 794 | caddr = 0x2400 + gate_array.mode_lookup[gate_array.data] * 2; |
| 795 | gate_array.colour = asic.ram[caddr] + ( asic.ram[caddr+1] << 8 ); |
| 796 | gate_array.colour_ticks = gate_array.max_colour_ticks; |
| 797 | } |
| 798 | gate_array.ticks += gate_array.ticks_increment; |
| 799 | switch( gate_array.ticks) |
| 800 | { |
| 801 | case 8: |
| 802 | { |
| 803 | UINT16 caddr; |
| 921 | 804 | |
| 922 | | caddr = 0x2400 + ( ( data0 & 0x80 ) ? 2 : 0 ); |
| 923 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 924 | | *p = c; p++; |
| 925 | | caddr = 0x2400 + ( ( data0 & 0x40 ) ? 2 : 0 ); |
| 926 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 927 | | *p = c; p++; |
| 928 | | caddr = 0x2400 + ( ( data0 & 0x20 ) ? 2 : 0 ); |
| 929 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 930 | | *p = c; p++; |
| 931 | | caddr = 0x2400 + ( ( data0 & 0x10 ) ? 2 : 0 ); |
| 932 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 933 | | *p = c; p++; |
| 934 | | caddr = 0x2400 + ( ( data0 & 0x08 ) ? 2 : 0 ); |
| 935 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 936 | | *p = c; p++; |
| 937 | | caddr = 0x2400 + ( ( data0 & 0x04 ) ? 2 : 0 ); |
| 938 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 939 | | *p = c; p++; |
| 940 | | caddr = 0x2400 + ( ( data0 & 0x02 ) ? 2 : 0 ); |
| 941 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 942 | | *p = c; p++; |
| 943 | | caddr = 0x2400 + ( ( data0 & 0x01 ) ? 2 : 0 ); |
| 944 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 945 | | *p = c; p++; |
| 946 | | caddr = 0x2400 + ( ( data1 & 0x80 ) ? 2 : 0 ); |
| 947 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 948 | | *p = c; p++; |
| 949 | | caddr = 0x2400 + ( ( data1 & 0x40 ) ? 2 : 0 ); |
| 950 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 951 | | *p = c; p++; |
| 952 | | caddr = 0x2400 + ( ( data1 & 0x20 ) ? 2 : 0 ); |
| 953 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 954 | | *p = c; p++; |
| 955 | | caddr = 0x2400 + ( ( data1 & 0x10 ) ? 2 : 0 ); |
| 956 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 957 | | *p = c; p++; |
| 958 | | caddr = 0x2400 + ( ( data1 & 0x08 ) ? 2 : 0 ); |
| 959 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 960 | | *p = c; p++; |
| 961 | | caddr = 0x2400 + ( ( data1 & 0x04 ) ? 2 : 0 ); |
| 962 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 963 | | *p = c; p++; |
| 964 | | caddr = 0x2400 + ( ( data1 & 0x02 ) ? 2 : 0 ); |
| 965 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 966 | | *p = c; p++; |
| 967 | | caddr = 0x2400 + ( ( data1 & 0x01 ) ? 2 : 0 ); |
| 968 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 969 | | *p = c; p++; |
| 970 | | } |
| 971 | | } |
| 972 | | |
| 973 | | |
| 974 | | /* Plus Mode 3: 160x200, 4 colours */ |
| 975 | | static MC6845_UPDATE_ROW( amstrad_plus_update_row_mode3 ) |
| 976 | | { |
| 977 | | UINT16 *p = BITMAP_ADDR16( bitmap, y, 0 ); |
| 978 | | UINT16 c; |
| 979 | | int i; |
| 980 | | |
| 981 | | logerror( "amstrad_plus_update_row_mode3: ma = 0x%04x, ra = %d, y = %d, x_count = %d, cursor_x = %d\n", ma, ra, y, x_count, cursor_x ); |
| 982 | | |
| 983 | | /* Apply horizontal background scrolling */ |
| 984 | | for ( i = amstrad_plus_asic_ram[0x2804] & 0x0f; i > 0; i-- ) |
| 985 | | { |
| 986 | | if ( amstrad_plus_asic_ram[0x2804] & 0x80 ) |
| 987 | | { |
| 988 | | /* Border colour */ |
| 989 | | c = amstrad_plus_asic_ram[0x2420] + ( amstrad_plus_asic_ram[0x2421] << 8 ); |
| 805 | gate_array.data = messram_get_ptr(machine->device("messram"))[ gate_array.address + 1 ]; |
| 806 | caddr = 0x2400 + gate_array.mode_lookup[gate_array.data] * 2; |
| 807 | gate_array.colour = asic.ram[caddr] + ( asic.ram[caddr+1] << 8 ); |
| 808 | } |
| 809 | break; |
| 810 | case 16: |
| 811 | gate_array.ma += 1; /* If we were synced with the 6845 mc6845_get_ma should return this value */ |
| 812 | amstrad_plus_gate_array_get_video_data( machine ); |
| 813 | break; |
| 814 | } |
| 815 | } |
| 816 | } |
| 817 | gate_array.draw_p++; |
| 818 | cycles_passed--; |
| 819 | gate_array.line_ticks++; |
| 820 | if ( gate_array.line_ticks > gate_array.bitmap->width ) |
| 821 | { |
| 822 | gate_array.draw_p = NULL; |
| 823 | cycles_passed = 0; |
| 824 | } |
| 990 | 825 | } |
| 991 | | else |
| 992 | | { |
| 993 | | /* Random(?) colour data */ |
| 994 | | c = amstrad_plus_asic_ram[0x2420] + ( amstrad_plus_asic_ram[0x2421] << 8 ); |
| 995 | | } |
| 996 | | *p = c; p++; |
| 997 | 826 | } |
| 998 | 827 | |
| 999 | | /* Apply vertical background scrolling */ |
| 1000 | | ra += ( ( amstrad_plus_asic_ram[0x2804] >> 4 ) & 0x07 ); |
| 1001 | | if ( ra > 7 ) |
| 1002 | | { |
| 1003 | | ma += x_count; |
| 1004 | | } |
| 1005 | | |
| 1006 | | for ( i = 0; i < x_count; i++ ) |
| 1007 | | { |
| 1008 | | UINT16 address = ( ( ( ma + i ) & 0x3000 ) << 2 ) | ( ( ra & 0x07 ) << 11 ) | ( ( ( ma + i ) & 0x3ff ) << 1 ); |
| 1009 | | UINT16 caddr; |
| 1010 | | UINT8 data0 = messram_get_ptr(device->machine->device("messram"))[ address ]; |
| 1011 | | UINT8 data1 = messram_get_ptr(device->machine->device("messram"))[ address + 1 ]; |
| 1012 | | |
| 1013 | | caddr = 0x2400 + mode1_lookup[data0][0] * 2; |
| 1014 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 1015 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 1016 | | caddr = 0x2400 + mode1_lookup[data0][1] * 2; |
| 1017 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 1018 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 1019 | | caddr = 0x2400 + mode1_lookup[data1][0] * 2; |
| 1020 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 1021 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 1022 | | caddr = 0x2400 + mode1_lookup[data1][1] * 2; |
| 1023 | | c = amstrad_plus_asic_ram[caddr] + ( amstrad_plus_asic_ram[caddr+1] << 8 ); |
| 1024 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 1025 | | } |
| 828 | gate_array.last_draw_time = now; |
| 1026 | 829 | } |
| 1027 | 830 | |
| 1028 | 831 | |
| 1029 | | /* Plus sprites: 16 16x16 sprites, 16 colours */ |
| 1030 | | static MC6845_UPDATE_ROW( amstrad_plus_update_row_sprites ) |
| 832 | INLINE void amstrad_plus_update_video_sprites( running_machine *machine ) |
| 1031 | 833 | { |
| 1032 | | UINT16 *p = BITMAP_ADDR16( bitmap, y, 0 ); |
| 1033 | | int i; |
| 834 | UINT16 *p = BITMAP_ADDR16( gate_array.bitmap, gate_array.y, asic.h_start ); |
| 835 | int i; |
| 1034 | 836 | |
| 1035 | | // logerror( "amstrad_plus_update_row_sprites: ma = 0x%04x, ra = %d, y = %d, x_count = %d, cursor_x = %d\n", ma, ra, y, x_count, cursor_x ); |
| 837 | if ( gate_array.y < 0 ) |
| 838 | return; |
| 1036 | 839 | |
| 1037 | 840 | for ( i = 15 * 8; i >= 0; i -= 8 ) |
| 1038 | 841 | { |
| 1039 | | UINT8 xmag = ( amstrad_plus_asic_ram[ 0x2000 + i + 4 ] >> 2 ) & 0x03; |
| 1040 | | UINT8 ymag = amstrad_plus_asic_ram[ 0x2000 + i + 4 ] & 0x03; |
| 842 | UINT8 xmag = ( asic.ram[ 0x2000 + i + 4 ] >> 2 ) & 0x03; |
| 843 | UINT8 ymag = asic.ram[ 0x2000 + i + 4 ] & 0x03; |
| 1041 | 844 | |
| 1042 | 845 | /* Check if sprite is enabled */ |
| 1043 | 846 | if ( xmag && ymag ) |
| 1044 | 847 | { |
| 1045 | | INT16 spr_x = amstrad_plus_asic_ram[ 0x2000 + i ] + ( amstrad_plus_asic_ram[ 0x2001 + i ] << 8 ); |
| 1046 | | INT16 spr_y = amstrad_plus_asic_ram[ 0x2002 + i ] + ( amstrad_plus_asic_ram[ 0x2003 + i ] << 8 ); |
| 848 | INT16 spr_x = asic.ram[ 0x2000 + i ] + ( asic.ram[ 0x2001 + i ] << 8 ); |
| 849 | INT16 spr_y = asic.ram[ 0x2002 + i ] + ( asic.ram[ 0x2003 + i ] << 8 ); |
| 1047 | 850 | |
| 1048 | 851 | xmag -= 1; |
| 1049 | 852 | ymag -= 1; |
| 1050 | 853 | |
| 1051 | 854 | /* Check if sprite would appear on this scanline */ |
| 1052 | | if ( spr_y <= y && y < spr_y + ( 16 << ymag ) && spr_x < 16 * x_count && spr_x + ( 16 << xmag ) > 0 ) |
| 855 | if ( spr_y <= asic.vpos && asic.vpos < spr_y + ( 16 << ymag ) && spr_x < ( asic.h_end - asic.h_start ) && spr_x + ( 16 << xmag ) > 0 ) |
| 1053 | 856 | { |
| 1054 | | UINT16 spr_addr = i * 32 + ( ( ( y - spr_y ) >> ymag ) * 16 ); |
| 857 | UINT16 spr_addr = i * 32 + ( ( ( asic.vpos - spr_y ) >> ymag ) * 16 ); |
| 1055 | 858 | int j, k; |
| 1056 | 859 | |
| 1057 | 860 | for ( j = 0; j < 16; j++ ) |
| r8980 | r8981 | |
| 1060 | 863 | { |
| 1061 | 864 | INT16 x = spr_x + ( j << xmag ) + k; |
| 1062 | 865 | |
| 1063 | | if ( x >= 0 && x < 16 * x_count ) |
| 866 | if ( x >= 0 && x < ( asic.h_end - asic.h_start ) ) |
| 1064 | 867 | { |
| 1065 | | UINT8 spr_col = ( amstrad_plus_asic_ram[ spr_addr + j ] & 0x0f ) * 2; |
| 868 | UINT8 spr_col = ( asic.ram[ spr_addr + j ] & 0x0f ) * 2; |
| 1066 | 869 | |
| 1067 | 870 | if ( spr_col ) |
| 1068 | | p[x] = amstrad_plus_asic_ram[ 0x2420 + spr_col ] + ( amstrad_plus_asic_ram[ 0x2421 + spr_col ] << 8 ); |
| 871 | p[x] = asic.ram[ 0x2420 + spr_col ] + ( asic.ram[ 0x2421 + spr_col ] << 8 ); |
| 1069 | 872 | } |
| 1070 | 873 | } |
| 1071 | 874 | } |
| r8980 | r8981 | |
| 1075 | 878 | } |
| 1076 | 879 | |
| 1077 | 880 | |
| 1078 | | /* Aleste Mode 2: 640x200(?), 4 colours */ |
| 1079 | | static MC6845_UPDATE_ROW( aleste_update_row_mode2 ) |
| 881 | static WRITE_LINE_DEVICE_HANDLER( amstrad_hsync_changed ) |
| 1080 | 882 | { |
| 1081 | | UINT16 *p = BITMAP_ADDR16( bitmap, y, 0 ); |
| 1082 | | int i; |
| 883 | amstrad_update_video( device->machine ); |
| 1083 | 884 | |
| 1084 | | // logerror( "aleste_update_row_mode2: ma = 0x%04x, ra = %d, y = %d, x_count = %d, cursor_x = %d\n", ma, ra, y, x_count, cursor_x ); |
| 1085 | | |
| 1086 | | for ( i = 0; i < x_count; i++ ) |
| 885 | /* The gate array reacts to de-assertion of the hsycnc 6845 line */ |
| 886 | if ( gate_array.hsync && !state ) |
| 1087 | 887 | { |
| 1088 | | UINT16 address = ( ( ( ma + i ) & 0x2000 ) << 2 ) | ( ( ra & 0x06 ) << 11 ) | ( ( ra & 0x01 ) << 14 ) | ( ( ( ma + i ) & 0x7ff ) << 1 ); |
| 1089 | | UINT8 data0 = messram_get_ptr(device->machine->device("messram"))[ address ]; |
| 1090 | | UINT8 data1 = messram_get_ptr(device->machine->device("messram"))[ address + 1 ]; |
| 1091 | | UINT16 c; |
| 1092 | | |
| 1093 | | if ( ~ aleste_mode & 0x08 ) |
| 888 | gate_array.hsync_counter++; |
| 889 | /* Advance to next drawing line */ |
| 890 | gate_array.y++; |
| 891 | gate_array.line_ticks = 0; |
| 892 | if ( gate_array.y >= 0 && gate_array.y < gate_array.bitmap->height ) |
| 1094 | 893 | { |
| 1095 | | c = amstrad_GateArray_render_colours[ 16 ]; |
| 1096 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 1097 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 1098 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 1099 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 894 | gate_array.draw_p = BITMAP_ADDR16( gate_array.bitmap, gate_array.y, 0 ); |
| 1100 | 895 | } |
| 1101 | 896 | else |
| 1102 | 897 | { |
| 1103 | | c = amstrad_GateArray_render_colours[ mode1_lookup[data0][0] ]; |
| 1104 | | *p = c; p++; *p = c; p++; |
| 1105 | | c = amstrad_GateArray_render_colours[ mode1_lookup[data0][1] ]; |
| 1106 | | *p = c; p++; *p = c; p++; |
| 1107 | | c = amstrad_GateArray_render_colours[ mode1_lookup[data0][2] ]; |
| 1108 | | *p = c; p++; *p = c; p++; |
| 1109 | | c = amstrad_GateArray_render_colours[ mode1_lookup[data0][3] ]; |
| 1110 | | *p = c; p++; *p = c; p++; |
| 1111 | | c = amstrad_GateArray_render_colours[ mode1_lookup[data1][0] ]; |
| 1112 | | *p = c; p++; *p = c; p++; |
| 1113 | | c = amstrad_GateArray_render_colours[ mode1_lookup[data1][1] ]; |
| 1114 | | *p = c; p++; *p = c; p++; |
| 1115 | | c = amstrad_GateArray_render_colours[ mode1_lookup[data1][2] ]; |
| 1116 | | *p = c; p++; *p = c; p++; |
| 1117 | | c = amstrad_GateArray_render_colours[ mode1_lookup[data1][3] ]; |
| 1118 | | *p = c; p++; *p = c; p++; |
| 898 | gate_array.draw_p = NULL; |
| 1119 | 899 | } |
| 1120 | | } |
| 1121 | | } |
| 1122 | 900 | |
| 1123 | | |
| 1124 | | /* Aleste Mode 3: 320x200, 16 colours */ |
| 1125 | | static MC6845_UPDATE_ROW( aleste_update_row_mode3 ) |
| 1126 | | { |
| 1127 | | UINT16 *p = BITMAP_ADDR16( bitmap, y, 0 ); |
| 1128 | | int i; |
| 1129 | | |
| 1130 | | // logerror( "aleste_update_row_mode3: ma = 0x%04x, ra = %d, y = %d, x_count = %d, cursor_x = %d\n", ma, ra, y, x_count, cursor_x ); |
| 1131 | | |
| 1132 | | for ( i = 0; i < x_count; i++ ) |
| 1133 | | { |
| 1134 | | UINT16 address = ( ( ( ma + i ) & 0x2000 ) << 2 ) | ( ( ra & 0x06 ) << 11 ) | ( ( ra & 0x01 ) << 14 ) | ( ( ( ma + i ) & 0x7ff ) << 1 ); |
| 1135 | | UINT8 data0 = messram_get_ptr(device->machine->device("messram"))[ address ]; |
| 1136 | | UINT8 data1 = messram_get_ptr(device->machine->device("messram"))[ address + 1 ]; |
| 1137 | | UINT16 c; |
| 1138 | | |
| 1139 | | if ( ~ aleste_mode & 0x08 ) |
| 1140 | | { |
| 1141 | | c = amstrad_GateArray_render_colours[ 16 ]; |
| 1142 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 1143 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 1144 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 1145 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 1146 | | } |
| 1147 | | else |
| 1148 | | { |
| 1149 | | c = amstrad_GateArray_render_colours[ mode0_lookup[data0][0] ]; |
| 1150 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 1151 | | c = amstrad_GateArray_render_colours[ mode0_lookup[data0][1] ]; |
| 1152 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 1153 | | c = amstrad_GateArray_render_colours[ mode0_lookup[data1][0] ]; |
| 1154 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 1155 | | c = amstrad_GateArray_render_colours[ mode0_lookup[data1][1] ]; |
| 1156 | | *p = c; p++; *p = c; p++; *p = c; p++; *p = c; p++; |
| 1157 | | } |
| 1158 | | } |
| 1159 | | } |
| 1160 | | |
| 1161 | | |
| 1162 | | static MC6845_UPDATE_ROW( amstrad_update_row ) |
| 1163 | | { |
| 1164 | | // logerror( "amstrad_update_row: ma = 0x%04x, ra = %d, y = %d, x_count = %d, cursor_x = %d\n", ma, ra, y, x_count, cursor_x ); |
| 1165 | | |
| 1166 | | if ( draw_function ) |
| 1167 | | draw_function( device, bitmap, cliprect, ma, ra, y, x_count, cursor_x, param ); |
| 1168 | | } |
| 1169 | | |
| 1170 | | |
| 1171 | | INLINE UINT16 amstrad_plus_translate_split( UINT16 ma, int y ) |
| 1172 | | { |
| 1173 | | if ( y == 0 ) |
| 1174 | | { |
| 1175 | | asic.split_ma_base = 0x0000; |
| 1176 | | asic.split_ma_started = 0x0000; |
| 1177 | | } |
| 1178 | | else if ( asic.enabled && amstrad_plus_asic_ram[0x2801] == y ) |
| 1179 | | { |
| 1180 | | asic.split_ma_started = ma; |
| 1181 | | asic.split_ma_base = ( amstrad_plus_asic_ram[0x2802] << 8 ) | amstrad_plus_asic_ram[0x2803]; |
| 1182 | | } |
| 1183 | | |
| 1184 | | return ( ma - asic.split_ma_started ) + asic.split_ma_base; |
| 1185 | | } |
| 1186 | | |
| 1187 | | |
| 1188 | | static MC6845_UPDATE_ROW( amstrad_plus_update_row ) |
| 1189 | | { |
| 1190 | | // logerror( "amstrad_update_row: ma = 0x%04x, ra = %d, y = %d, x_count = %d, cursor_x = %d\n", ma, ra, y, x_count, cursor_x ); |
| 1191 | | |
| 1192 | | ma = amstrad_plus_translate_split( ma, y ); |
| 1193 | | |
| 1194 | | if ( draw_function ) |
| 1195 | | draw_function( device, bitmap, cliprect, ma, ra, y, x_count, cursor_x, param ); |
| 1196 | | |
| 1197 | | amstrad_plus_update_row_sprites( device, bitmap, cliprect, ma, ra, y, x_count, cursor_x, param ); |
| 1198 | | } |
| 1199 | | |
| 1200 | | |
| 1201 | | static WRITE_LINE_DEVICE_HANDLER( amstrad_hsync_changed ) |
| 1202 | | { |
| 1203 | | /* TODO - Bring video up to date */ |
| 1204 | | |
| 1205 | | if ( ! gate_array.hsync && state ) |
| 1206 | | { |
| 1207 | | gate_array.hsync_counter++; |
| 1208 | | gate_array.y++; |
| 1209 | | |
| 1210 | 901 | if ( gate_array.hsync_after_vsync_counter != 0 ) // counters still operate regardless of PRI state |
| 1211 | 902 | { |
| 1212 | 903 | gate_array.hsync_after_vsync_counter--; |
| r8980 | r8981 | |
| 1233 | 924 | |
| 1234 | 925 | static WRITE_LINE_DEVICE_HANDLER( amstrad_plus_hsync_changed ) |
| 1235 | 926 | { |
| 1236 | | if ( ! gate_array.hsync && state ) |
| 927 | amstrad_plus_update_video( device->machine ); |
| 928 | |
| 929 | if ( gate_array.hsync && !state ) |
| 1237 | 930 | { |
| 1238 | 931 | gate_array.hsync_counter++; |
| 932 | /* Advance to next drawing line */ |
| 933 | gate_array.y++; |
| 934 | gate_array.line_ticks = 0; |
| 935 | if ( gate_array.y >= 0 && gate_array.y < gate_array.bitmap->height ) |
| 936 | { |
| 937 | gate_array.draw_p = BITMAP_ADDR16( gate_array.bitmap, gate_array.y, 0 ); |
| 938 | } |
| 939 | else |
| 940 | { |
| 941 | gate_array.draw_p = NULL; |
| 942 | } |
| 1239 | 943 | |
| 1240 | 944 | if ( gate_array.hsync_after_vsync_counter != 0 ) // counters still operate regardless of PRI state |
| 1241 | 945 | { |
| r8980 | r8981 | |
| 1268 | 972 | // CPC+/GX4000 Programmable Raster Interrupt (disabled if &6800 in ASIC RAM is 0) |
| 1269 | 973 | if ( asic.pri != 0 ) |
| 1270 | 974 | { |
| 1271 | | if ( asic.pri == device->machine->primary_screen->vpos() ) |
| 975 | if ( asic.pri == asic.vpos - 1 ) |
| 1272 | 976 | { |
| 1273 | 977 | logerror("PRI: triggered, scanline %d\n",asic.pri); |
| 1274 | 978 | cputag_set_input_line(device->machine, "maincpu", 0, ASSERT_LINE); |
| r8980 | r8981 | |
| 1277 | 981 | } |
| 1278 | 982 | } |
| 1279 | 983 | // CPC+/GX4000 Split screen registers (disabled if &6801 in ASIC RAM is 0) |
| 1280 | | if(amstrad_plus_asic_ram[0x2801] != 0) |
| 984 | if(asic.ram[0x2801] != 0) |
| 1281 | 985 | { |
| 1282 | | if ( amstrad_plus_asic_ram[0x2801] == device->machine->primary_screen->vpos() ) // split occurs here (hopefully) |
| 986 | if ( asic.ram[0x2801] == asic.vpos - 1 ) // split occurs here (hopefully) |
| 1283 | 987 | { |
| 1284 | | device->machine->primary_screen->update_partial(device->machine->primary_screen->vpos() ); |
| 1285 | | logerror("SSCR: Split screen occured at scanline %d\n",amstrad_plus_asic_ram[0x2801]); |
| 988 | logerror("SSCR: Split screen occured at scanline %d\n",asic.ram[0x2801]); |
| 1286 | 989 | } |
| 1287 | 990 | } |
| 1288 | 991 | // CPC+/GX4000 DMA channels |
| r8980 | r8981 | |
| 1295 | 998 | |
| 1296 | 999 | static WRITE_LINE_DEVICE_HANDLER( amstrad_vsync_changed ) |
| 1297 | 1000 | { |
| 1298 | | /* TODO - Bring video up to date */ |
| 1001 | amstrad_update_video( device->machine ); |
| 1299 | 1002 | |
| 1300 | 1003 | if ( ! gate_array.vsync && state ) |
| 1301 | 1004 | { |
| r8980 | r8981 | |
| 1304 | 1007 | |
| 1305 | 1008 | /* Start of new frame */ |
| 1306 | 1009 | gate_array.y = -1; |
| 1010 | asic.vpos = 0; |
| 1307 | 1011 | } |
| 1308 | 1012 | |
| 1309 | 1013 | gate_array.vsync = state ? 1 : 0; |
| 1310 | 1014 | } |
| 1311 | 1015 | |
| 1312 | 1016 | |
| 1017 | static WRITE_LINE_DEVICE_HANDLER( amstrad_plus_vsync_changed ) |
| 1018 | { |
| 1019 | amstrad_plus_update_video( device->machine ); |
| 1020 | |
| 1021 | if ( ! gate_array.vsync && state ) |
| 1022 | { |
| 1023 | /* Reset the amstrad_CRTC_HS_After_VS_Counter */ |
| 1024 | gate_array.hsync_after_vsync_counter = 2; |
| 1025 | |
| 1026 | /* Start of new frame */ |
| 1027 | gate_array.y = -1; |
| 1028 | asic.vpos = 0; |
| 1029 | } |
| 1030 | |
| 1031 | gate_array.vsync = state ? 1 : 0; |
| 1032 | } |
| 1033 | |
| 1034 | |
| 1313 | 1035 | static WRITE_LINE_DEVICE_HANDLER( amstrad_de_changed ) |
| 1314 | 1036 | { |
| 1315 | | /* TODO - Bring video up to date */ |
| 1037 | amstrad_update_video( device->machine ); |
| 1316 | 1038 | |
| 1039 | if ( ! gate_array.de && state ) |
| 1040 | { |
| 1041 | /* DE became active, store the starting MA and RA signals */ |
| 1042 | running_device *mc6845 = device->machine->device("mc6845" ); |
| 1043 | |
| 1044 | gate_array.ma = mc6845_get_ma( mc6845 ); |
| 1045 | gate_array.ra = mc6845_get_ra( mc6845 ); |
| 1046 | amstrad_gate_array_get_video_data( device->machine ); |
| 1047 | } |
| 1048 | |
| 1049 | if ( gate_array.de && ! state ) |
| 1050 | { |
| 1051 | asic.vpos++; |
| 1052 | } |
| 1053 | |
| 1317 | 1054 | gate_array.de = state ? 1 : 0; |
| 1318 | 1055 | } |
| 1319 | 1056 | |
| 1320 | 1057 | |
| 1058 | static WRITE_LINE_DEVICE_HANDLER( amstrad_plus_de_changed ) |
| 1059 | { |
| 1060 | amstrad_plus_update_video( device->machine ); |
| 1061 | |
| 1062 | if ( ! gate_array.de && state ) |
| 1063 | { |
| 1064 | /* DE became active, store the starting MA and RA signals */ |
| 1065 | running_device *mc6845 = device->machine->device("mc6845" ); |
| 1066 | |
| 1067 | gate_array.ma = mc6845_get_ma( mc6845 ); |
| 1068 | gate_array.ra = mc6845_get_ra( mc6845 ); |
| 1069 | asic.h_start = gate_array.line_ticks; |
| 1070 | |
| 1071 | if ( asic.vpos == 0 ) |
| 1072 | { |
| 1073 | asic.split_ma_base = 0x0000; |
| 1074 | asic.split_ma_started = 0x0000; |
| 1075 | } |
| 1076 | else if ( asic.enabled && asic.ram[0x2801] != 0 && asic.ram[0x2801] == asic.vpos - 1 ) |
| 1077 | { |
| 1078 | asic.split_ma_started = gate_array.ma; |
| 1079 | asic.split_ma_base = ( asic.ram[0x2802] << 8 ) | asic.ram[0x2803]; |
| 1080 | } |
| 1081 | |
| 1082 | gate_array.colour = asic.ram[0x2420] + ( asic.ram[0x2421] << 8 ); |
| 1083 | asic.hscroll = asic.ram[0x2804] & 0x0f; |
| 1084 | |
| 1085 | if ( asic.hscroll == 0 ) |
| 1086 | amstrad_plus_gate_array_get_video_data( device->machine ); |
| 1087 | } |
| 1088 | |
| 1089 | if ( gate_array.de && ! state ) |
| 1090 | { |
| 1091 | asic.h_end = gate_array.line_ticks; |
| 1092 | amstrad_plus_update_video_sprites( device->machine ); |
| 1093 | asic.vpos++; |
| 1094 | } |
| 1095 | |
| 1096 | gate_array.de = state ? 1 : 0; |
| 1097 | } |
| 1098 | |
| 1099 | |
| 1321 | 1100 | VIDEO_START( amstrad ) |
| 1322 | 1101 | { |
| 1102 | screen_device *screen = downcast<screen_device *>(machine->device("screen")); |
| 1103 | |
| 1323 | 1104 | amstrad_init_lookups(); |
| 1324 | 1105 | |
| 1325 | | draw_function = NULL; |
| 1106 | gate_array.bitmap = auto_bitmap_alloc( machine, screen->width(), screen->height(), screen->format() ); |
| 1326 | 1107 | gate_array.hsync_after_vsync_counter = 2; |
| 1327 | 1108 | } |
| 1328 | 1109 | |
| 1329 | 1110 | |
| 1330 | 1111 | VIDEO_UPDATE( amstrad ) |
| 1331 | 1112 | { |
| 1332 | | running_device *mc6845 = screen->machine->device("mc6845" ); |
| 1333 | | mc6845_update( mc6845, bitmap, cliprect ); |
| 1113 | copybitmap( bitmap, gate_array.bitmap, 0, 0, 0, 0, cliprect ); |
| 1334 | 1114 | return 0; |
| 1335 | 1115 | } |
| 1336 | 1116 | |
| 1337 | 1117 | |
| 1338 | 1118 | const mc6845_interface amstrad_mc6845_intf = |
| 1339 | 1119 | { |
| 1340 | | "screen", /* screen name */ |
| 1341 | | 16, /* number of pixels per video memory address */ |
| 1342 | | NULL, /* begin_update */ |
| 1343 | | amstrad_update_row, /* update_row */ |
| 1344 | | NULL, /* end_update */ |
| 1345 | | DEVCB_LINE(amstrad_de_changed), /* on_de_changed */ |
| 1346 | | DEVCB_NULL, /* on_cur_changed */ |
| 1120 | NULL, /* screen name */ |
| 1121 | 16, /* number of pixels per video memory address */ |
| 1122 | NULL, /* begin_update */ |
| 1123 | NULL, /* update_row */ |
| 1124 | NULL, /* end_update */ |
| 1125 | DEVCB_LINE(amstrad_de_changed), /* on_de_changed */ |
| 1126 | DEVCB_NULL, /* on_cur_changed */ |
| 1347 | 1127 | DEVCB_LINE(amstrad_hsync_changed), /* on_hsync_changed */ |
| 1348 | 1128 | DEVCB_LINE(amstrad_vsync_changed), /* on_vsync_changed */ |
| 1349 | 1129 | NULL |
| r8980 | r8981 | |
| 1352 | 1132 | |
| 1353 | 1133 | const mc6845_interface amstrad_plus_mc6845_intf = |
| 1354 | 1134 | { |
| 1355 | | "screen", /* screen name */ |
| 1356 | | 16, /* number of pixels per video memory address */ |
| 1357 | | NULL, /* begin_update */ |
| 1358 | | amstrad_plus_update_row, /* update_row */ |
| 1359 | | NULL, /* end_update */ |
| 1360 | | DEVCB_NULL, /* on_de_changed */ |
| 1361 | | DEVCB_NULL, /* on_cur_changed */ |
| 1362 | | DEVCB_LINE(amstrad_plus_hsync_changed), /* on_hsync_changed */ |
| 1363 | | DEVCB_LINE(amstrad_vsync_changed), /* on_vsync_changed */ |
| 1135 | NULL, /* screen name */ |
| 1136 | 16, /* number of pixels per video memory address */ |
| 1137 | NULL, /* begin_update */ |
| 1138 | NULL, /* update_row */ |
| 1139 | NULL, /* end_update */ |
| 1140 | DEVCB_LINE(amstrad_plus_de_changed), /* on_de_changed */ |
| 1141 | DEVCB_NULL, /* on_cur_changed */ |
| 1142 | DEVCB_LINE(amstrad_plus_hsync_changed), /* on_hsync_changed */ |
| 1143 | DEVCB_LINE(amstrad_plus_vsync_changed), /* on_vsync_changed */ |
| 1364 | 1144 | NULL |
| 1365 | 1145 | }; |
| 1366 | 1146 | |
| r8980 | r8981 | |
| 1888 | 1668 | |
| 1889 | 1669 | WRITE8_HANDLER( amstrad_plus_asic_4000_w ) |
| 1890 | 1670 | { |
| 1891 | | space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); |
| 1892 | 1671 | // logerror("ASIC: Write to register at &%04x\n",offset+0x4000); |
| 1893 | | amstrad_plus_asic_ram[offset] = data & 0x0f; |
| 1672 | asic.ram[offset] = data & 0x0f; |
| 1894 | 1673 | } |
| 1895 | 1674 | |
| 1896 | 1675 | |
| 1897 | 1676 | WRITE8_HANDLER( amstrad_plus_asic_6000_w ) |
| 1898 | 1677 | { |
| 1899 | | space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); |
| 1900 | | amstrad_plus_asic_ram[offset+0x2000] = data; |
| 1678 | asic.ram[offset+0x2000] = data; |
| 1901 | 1679 | if(offset >= 0x0400 && offset < 0x440 && ( offset & 0x01 ) ) // ASIC palette |
| 1902 | 1680 | { |
| 1903 | | amstrad_plus_asic_ram[ offset + 0x2000 ] = data & 0x0f; |
| 1681 | asic.ram[ offset + 0x2000 ] = data & 0x0f; |
| 1904 | 1682 | } |
| 1905 | 1683 | if(offset == 0x0800) // Programmable raster interrupt |
| 1906 | 1684 | { |
| r8980 | r8981 | |
| 1909 | 1687 | } |
| 1910 | 1688 | if(offset >= 0x0801 && offset <= 0x0803) // Split screen registers |
| 1911 | 1689 | { |
| 1912 | | logerror("ASIC: Split screen at line %i, address &%04x\n",amstrad_plus_asic_ram[0x2801],amstrad_plus_asic_ram[0x2803] + (amstrad_plus_asic_ram[0x2802] << 8)); |
| 1690 | logerror("ASIC: Split screen at line %i, address &%04x\n",asic.ram[0x2801],asic.ram[0x2803] + (asic.ram[0x2802] << 8)); |
| 1913 | 1691 | } |
| 1914 | 1692 | if(offset == 0x0804) // Soft scroll register |
| 1915 | 1693 | { |
| r8980 | r8981 | |
| 1932 | 1710 | { |
| 1933 | 1711 | case 0x0c00: |
| 1934 | 1712 | case 0x0c01: |
| 1935 | | asic.dma_addr[0] = (amstrad_plus_asic_ram[0x2c01] << 8) + amstrad_plus_asic_ram[0x2c00]; |
| 1713 | asic.dma_addr[0] = (asic.ram[0x2c01] << 8) + asic.ram[0x2c00]; |
| 1936 | 1714 | asic.dma_status &= ~0x01; |
| 1937 | 1715 | logerror("ASIC: DMA 0 address set to &%04x\n",asic.dma_addr[0]); |
| 1938 | 1716 | break; |
| 1939 | 1717 | case 0x0c04: |
| 1940 | 1718 | case 0x0c05: |
| 1941 | | asic.dma_addr[1] = (amstrad_plus_asic_ram[0x2c05] << 8) + amstrad_plus_asic_ram[0x2c04]; |
| 1719 | asic.dma_addr[1] = (asic.ram[0x2c05] << 8) + asic.ram[0x2c04]; |
| 1942 | 1720 | asic.dma_status &= ~0x02; |
| 1943 | 1721 | logerror("ASIC: DMA 1 address set to &%04x\n",asic.dma_addr[1]); |
| 1944 | 1722 | break; |
| 1945 | 1723 | case 0x0c08: |
| 1946 | 1724 | case 0x0c09: |
| 1947 | | asic.dma_addr[2] = (amstrad_plus_asic_ram[0x2c09] << 8) + amstrad_plus_asic_ram[0x2c08]; |
| 1725 | asic.dma_addr[2] = (asic.ram[0x2c09] << 8) + asic.ram[0x2c08]; |
| 1948 | 1726 | asic.dma_status &= ~0x04; |
| 1949 | 1727 | logerror("ASIC: DMA 2 address set to &%04x\n",asic.dma_addr[2]); |
| 1950 | 1728 | break; |
| r8980 | r8981 | |
| 1968 | 1746 | logerror("ASIC: DMA 0 IRQ acknowledge\n"); |
| 1969 | 1747 | cputag_set_input_line(space->machine, "maincpu", 0, CLEAR_LINE); |
| 1970 | 1748 | amstrad_plus_irq_cause = 0x06; |
| 1971 | | amstrad_plus_asic_ram[0x2c0f] &= ~0x40; |
| 1749 | asic.ram[0x2c0f] &= ~0x40; |
| 1972 | 1750 | } |
| 1973 | 1751 | if(data & 0x20) |
| 1974 | 1752 | { |
| 1975 | 1753 | logerror("ASIC: DMA 1 IRQ acknowledge\n"); |
| 1976 | 1754 | cputag_set_input_line(space->machine, "maincpu", 0, CLEAR_LINE); |
| 1977 | 1755 | amstrad_plus_irq_cause = 0x06; |
| 1978 | | amstrad_plus_asic_ram[0x2c0f] &= ~0x20; |
| 1756 | asic.ram[0x2c0f] &= ~0x20; |
| 1979 | 1757 | } |
| 1980 | 1758 | if(data & 0x10) |
| 1981 | 1759 | { |
| 1982 | 1760 | logerror("ASIC: DMA 2 IRQ acknowledge\n"); |
| 1983 | 1761 | cputag_set_input_line(space->machine, "maincpu", 0, CLEAR_LINE); |
| 1984 | 1762 | amstrad_plus_irq_cause = 0x06; |
| 1985 | | amstrad_plus_asic_ram[0x2c0f] &= ~0x10; |
| 1763 | asic.ram[0x2c0f] &= ~0x10; |
| 1986 | 1764 | } |
| 1987 | 1765 | break; |
| 1988 | 1766 | } |
| r8980 | r8981 | |
| 1992 | 1770 | READ8_HANDLER( amstrad_plus_asic_4000_r ) |
| 1993 | 1771 | { |
| 1994 | 1772 | // logerror("RAM: read from &%04x\n",offset+0x4000); |
| 1995 | | return amstrad_plus_asic_ram[offset]; |
| 1773 | return asic.ram[offset]; |
| 1996 | 1774 | } |
| 1997 | 1775 | |
| 1998 | 1776 | |
| r8980 | r8981 | |
| 2039 | 1817 | return result; |
| 2040 | 1818 | } |
| 2041 | 1819 | #endif |
| 2042 | | return amstrad_plus_asic_ram[offset+0x2000]; |
| 1820 | return asic.ram[offset+0x2000]; |
| 2043 | 1821 | } |
| 2044 | 1822 | |
| 2045 | 1823 | |
| r8980 | r8981 | |
| 2108 | 1886 | 1 x | |
| 2109 | 1887 | 0 x |*/ |
| 2110 | 1888 | case 0x01: |
| 2111 | | machine->primary_screen->update_partial(machine->primary_screen->vpos()); |
| 2112 | | amstrad_vh_update_colour( gate_array.pen_selected, (dataToGateArray & 0x1F)); |
| 1889 | amstrad_vh_update_colour( machine, gate_array.pen_selected, (dataToGateArray & 0x1F)); |
| 2113 | 1890 | break; |
| 2114 | 1891 | |
| 2115 | 1892 | /* Select screen mode and rom configuration |
| r8980 | r8981 | |
| 2172 | 1949 | amstrad_setUpperRom(machine); |
| 2173 | 1950 | |
| 2174 | 1951 | /* b1b0 mode */ |
| 2175 | | machine->primary_screen->update_partial(machine->primary_screen->vpos()); |
| 2176 | 1952 | amstrad_vh_update_mode(); |
| 2177 | 1953 | |
| 2178 | 1954 | break; |
| r8980 | r8981 | |
| 2208 | 1984 | amstrad_GateArray_write(space->machine, data); |
| 2209 | 1985 | break; |
| 2210 | 1986 | case 1: // Colour select (6-bit palette) |
| 2211 | | aleste_vh_update_colour( gate_array.pen_selected, data & 0x3f ); |
| 1987 | aleste_vh_update_colour( space->machine, gate_array.pen_selected, data & 0x3f ); |
| 2212 | 1988 | break; |
| 2213 | 1989 | case 2: // Screen mode, Upper/Lower ROM select |
| 2214 | 1990 | amstrad_GateArray_write(space->machine, data); |
| r8980 | r8981 | |
| 2495 | 2271 | if (data == 0x0c && amstrad_system_type == SYSTEM_PLUS) |
| 2496 | 2272 | printer_bit8_selected = TRUE; |
| 2497 | 2273 | |
| 2274 | asic.addr_6845 = data; |
| 2498 | 2275 | break; |
| 2499 | 2276 | case 0x01: /* Write to selected internal 6845 register Write Only */ |
| 2500 | | space->machine->primary_screen->update_partial(space->machine->primary_screen->vpos()); |
| 2277 | if ( amstrad_system_type == SYSTEM_PLUS || amstrad_system_type == SYSTEM_GX4000 ) |
| 2278 | amstrad_plus_update_video( space->machine ); |
| 2279 | else |
| 2280 | amstrad_update_video( space->machine ); |
| 2501 | 2281 | mc6845_register_w( mc6845, 0, data ); |
| 2502 | 2282 | |
| 2503 | 2283 | /* printer port bit 8 */ |
| r8980 | r8981 | |
| 2508 | 2288 | printer_bit8_selected = FALSE; |
| 2509 | 2289 | } |
| 2510 | 2290 | |
| 2291 | if ( asic.addr_6845 == 0x01 ) |
| 2292 | asic.horiz_disp = data; |
| 2293 | |
| 2511 | 2294 | break; |
| 2512 | 2295 | default: |
| 2513 | 2296 | break; |
| r8980 | r8981 | |
| 2771 | 2554 | ppi_port_inputs[amstrad_ppi_PortB] = (((input_port_read(machine, "solder_links")&MANUFACTURER_NAME)<<1) | (input_port_read(machine, "solder_links")&TV_REFRESH_RATE)); |
| 2772 | 2555 | |
| 2773 | 2556 | if ( amstrad_system_type == SYSTEM_PLUS || amstrad_system_type == SYSTEM_GX4000 ) |
| 2774 | | memset(amstrad_plus_asic_ram,0,16384); // clear ASIC RAM |
| 2557 | memset(asic.ram,0,16384); // clear ASIC RAM |
| 2775 | 2558 | |
| 2776 | 2559 | multiface_reset(); |
| 2777 | 2560 | } |
| r8980 | r8981 | |
| 3112 | 2895 | if( asic.enabled && amstrad_plus_irq_cause != 0x06 && asic.dma_clear & 0x01) |
| 3113 | 2896 | { |
| 3114 | 2897 | logerror("IRQ: Not cleared, IRQ was called by DMA [%i]\n",amstrad_plus_irq_cause); |
| 3115 | | amstrad_plus_asic_ram[0x2c0f] &= ~0x80; // not a raster interrupt, so this bit is reset |
| 3116 | | return (amstrad_plus_asic_ram[0x2805] & 0xf8) | amstrad_plus_irq_cause; |
| 2898 | asic.ram[0x2c0f] &= ~0x80; // not a raster interrupt, so this bit is reset |
| 2899 | return (asic.ram[0x2805] & 0xf8) | amstrad_plus_irq_cause; |
| 3117 | 2900 | } |
| 3118 | 2901 | cputag_set_input_line(device->machine,"maincpu", 0, CLEAR_LINE); |
| 3119 | 2902 | gate_array.hsync_counter &= 0x1F; |
| 3120 | 2903 | if ( asic.enabled ) |
| 3121 | 2904 | { |
| 3122 | 2905 | if(amstrad_plus_irq_cause == 6) // bit 7 is set "if last interrupt acknowledge cycle was caused by a raster interrupt" |
| 3123 | | amstrad_plus_asic_ram[0x2c0f] |= 0x80; |
| 2906 | asic.ram[0x2c0f] |= 0x80; |
| 3124 | 2907 | else |
| 3125 | 2908 | { |
| 3126 | | amstrad_plus_asic_ram[0x2c0f] &= ~0x80; |
| 3127 | | amstrad_plus_asic_ram[0x2c0f] &= (0x40 >> amstrad_plus_irq_cause/2); |
| 2909 | asic.ram[0x2c0f] &= ~0x80; |
| 2910 | asic.ram[0x2c0f] &= (0x40 >> amstrad_plus_irq_cause/2); |
| 3128 | 2911 | } |
| 3129 | | return (amstrad_plus_asic_ram[0x2805] & 0xf8) | amstrad_plus_irq_cause; |
| 2912 | return (asic.ram[0x2805] & 0xf8) | amstrad_plus_irq_cause; |
| 3130 | 2913 | } |
| 3131 | 2914 | return 0xFF; |
| 3132 | 2915 | } |
| r8980 | r8981 | |
| 3317 | 3100 | } |
| 3318 | 3101 | |
| 3319 | 3102 | |
| 3320 | | MACHINE_START( amstrad ) |
| 3103 | static TIMER_CALLBACK( cb_set_resolution ) |
| 3321 | 3104 | { |
| 3322 | 3105 | screen_device *screen = downcast<screen_device *>(machine->device("screen")); |
| 3106 | rectangle visarea; |
| 3107 | attoseconds_t refresh; |
| 3108 | int height; |
| 3323 | 3109 | |
| 3110 | if ( input_port_read( machine, "solder_links" ) & 0x10 ) |
| 3111 | { |
| 3112 | /* PAL */ |
| 3113 | visarea.min_x = 32; |
| 3114 | visarea.max_x = 32 + 640 + 64 - 1; |
| 3115 | visarea.min_y = 56; |
| 3116 | visarea.max_y = 56 + 15 + 200 + 15 - 1; |
| 3117 | height = 312; |
| 3118 | } |
| 3119 | else |
| 3120 | { |
| 3121 | /* NTSC */ |
| 3122 | visarea.min_x = 32; |
| 3123 | visarea.max_x = 32 + 640 + 64 - 1; |
| 3124 | visarea.min_y = 16; |
| 3125 | visarea.max_y = 16 + 15 + 200 + 15 - 1; |
| 3126 | height = 262; |
| 3127 | } |
| 3128 | refresh = HZ_TO_ATTOSECONDS( XTAL_16MHz ) * 1024 * height; |
| 3129 | screen->configure( 1024, height, visarea, refresh ); |
| 3130 | } |
| 3131 | |
| 3132 | |
| 3133 | MACHINE_START( amstrad ) |
| 3134 | { |
| 3324 | 3135 | multiface_init(machine); |
| 3325 | 3136 | amstrad_system_type = SYSTEM_CPC; |
| 3326 | | |
| 3327 | | gate_array.bitmap = auto_bitmap_alloc( machine, screen->width(), screen->height(), screen->format() ); |
| 3328 | 3137 | } |
| 3329 | 3138 | |
| 3330 | 3139 | |
| r8980 | r8981 | |
| 3343 | 3152 | amstrad_reset_machine(machine); |
| 3344 | 3153 | // amstrad_init_palette(machine); |
| 3345 | 3154 | |
| 3155 | gate_array.de = 0; |
| 3156 | gate_array.draw_p = NULL; |
| 3157 | gate_array.hsync = 0; |
| 3158 | gate_array.vsync = 0; |
| 3346 | 3159 | |
| 3160 | timer_set( machine, attotime_zero, NULL, 0, cb_set_resolution ); |
| 3347 | 3161 | } |
| 3348 | 3162 | |
| 3349 | 3163 | |
| 3350 | 3164 | MACHINE_START( plus ) |
| 3351 | 3165 | { |
| 3352 | | amstrad_plus_asic_ram = memory_region(machine, "user1"); // 16kB RAM for ASIC, memory-mapped registers. |
| 3166 | asic.ram = memory_region(machine, "user1"); // 16kB RAM for ASIC, memory-mapped registers. |
| 3353 | 3167 | amstrad_system_type = SYSTEM_PLUS; |
| 3354 | 3168 | } |
| 3355 | 3169 | |
| r8980 | r8981 | |
| 3384 | 3198 | |
| 3385 | 3199 | amstrad_common_init(machine); |
| 3386 | 3200 | amstrad_reset_machine(machine); |
| 3387 | | amstrad_plus_asic_ram[0x2805] = 0x01; // interrupt vector is undefined at startup, except that bit 0 is always 1. |
| 3201 | asic.ram[0x2805] = 0x01; // interrupt vector is undefined at startup, except that bit 0 is always 1. |
| 3388 | 3202 | AmstradCPC_GA_SetRamConfiguration(machine); |
| 3389 | 3203 | amstrad_GateArray_write(machine, 0x081); // Epyx World of Sports requires upper ROM to be enabled by default |
| 3390 | 3204 | |
| 3391 | 3205 | // multiface_init(); |
| 3206 | timer_set( machine, attotime_zero, NULL, 0, cb_set_resolution ); |
| 3392 | 3207 | } |
| 3393 | 3208 | |
| 3394 | 3209 | MACHINE_START( gx4000 ) |
| 3395 | 3210 | { |
| 3396 | | amstrad_plus_asic_ram = memory_region(machine, "user1"); // 16kB RAM for ASIC, memory-mapped registers. |
| 3211 | asic.ram = memory_region(machine, "user1"); // 16kB RAM for ASIC, memory-mapped registers. |
| 3397 | 3212 | amstrad_system_type = SYSTEM_GX4000; |
| 3398 | 3213 | } |
| 3399 | 3214 | |
| r8980 | r8981 | |
| 3427 | 3242 | |
| 3428 | 3243 | amstrad_common_init(machine); |
| 3429 | 3244 | amstrad_reset_machine(machine); |
| 3430 | | amstrad_plus_asic_ram[0x2805] = 0x01; // interrupt vector is undefined at startup, except that bit 0 is always 1. |
| 3245 | asic.ram[0x2805] = 0x01; // interrupt vector is undefined at startup, except that bit 0 is always 1. |
| 3431 | 3246 | AmstradCPC_GA_SetRamConfiguration(machine); |
| 3432 | 3247 | amstrad_GateArray_write(machine, 0x081); // Epyx World of Sports requires upper ROM to be enabled by default |
| 3433 | 3248 | // multiface_init(); |
| 3249 | |
| 3250 | timer_set( machine, attotime_zero, NULL, 0, cb_set_resolution ); |
| 3434 | 3251 | } |
| 3435 | 3252 | |
| 3436 | 3253 | MACHINE_START( kccomp ) |
| r8980 | r8981 | |
| 3483 | 3300 | Amstrad_ROM_Table[7] = &rom[0x018000]; // AMSDOS |
| 3484 | 3301 | amstrad_common_init(machine); |
| 3485 | 3302 | amstrad_reset_machine(machine); |
| 3303 | |
| 3304 | timer_set( machine, attotime_zero, NULL, 0, cb_set_resolution ); |
| 3486 | 3305 | } |
| 3487 | 3306 | |
| 3488 | 3307 | |