src/mess/video/isa_mda.c
| r14392 | r14393 | |
| 488 | 488 | |
| 489 | 489 | ***************************************************************************/ |
| 490 | 490 | |
| 491 | | static READ8_DEVICE_HANDLER( hercules_r ); |
| 492 | | static WRITE8_DEVICE_HANDLER( hercules_w ); |
| 493 | | |
| 494 | 491 | /* |
| 495 | 492 | When the Hercules changes to graphics mode, the number of pixels per access and |
| 496 | 493 | clock divider should be changed. The currect mc6845 implementation does not |
| r14392 | r14393 | |
| 583 | 580 | { |
| 584 | 581 | m_videoram = auto_alloc_array(machine(), UINT8, 0x10000); |
| 585 | 582 | set_isa_device(); |
| 586 | | m_isa->install_device(this, 0x3b0, 0x3bf, 0, 0, FUNC(hercules_r), FUNC(hercules_w) ); |
| 583 | m_isa->install_device(0x3b0, 0x3bf, 0, 0, read8_delegate( FUNC(isa8_hercules_device::io_read), this ), write8_delegate( FUNC(isa8_hercules_device::io_write), this ) ); |
| 587 | 584 | m_isa->install_bank(0xb0000, 0xbffff, 0, 0, "bank_hercules", m_videoram); |
| 588 | 585 | |
| 589 | 586 | /* Initialise the mda palette */ |
| r14392 | r14393 | |
| 646 | 643 | } |
| 647 | 644 | |
| 648 | 645 | |
| 649 | | static WRITE8_DEVICE_HANDLER(hercules_mode_control_w) |
| 646 | WRITE8_MEMBER( isa8_hercules_device::mode_control_w ) |
| 650 | 647 | { |
| 651 | | isa8_hercules_device *herc = downcast<isa8_hercules_device *>(device->owner()); |
| 648 | mc6845_device *mc6845 = subdevice<mc6845_device>(HERCULES_MC6845_NAME); |
| 652 | 649 | |
| 653 | | MDA_LOG(1,"hercules_mode_control_w",("$%02x: colums %d, gfx %d, enable %d, blink %d\n", |
| 654 | | data, (data&1)?80:40, (data>>1)&1, (data>>3)&1, (data>>5)&1)); |
| 655 | | herc->m_mode_control = data; |
| 650 | m_mode_control = data; |
| 656 | 651 | |
| 657 | | switch( herc->m_mode_control & 0x2a ) |
| 652 | switch( m_mode_control & 0x2a ) |
| 658 | 653 | { |
| 659 | 654 | case 0x08: |
| 660 | | herc->m_update_row = mda_text_inten_update_row; |
| 655 | m_update_row = mda_text_inten_update_row; |
| 661 | 656 | break; |
| 662 | 657 | case 0x28: |
| 663 | | herc->m_update_row = mda_text_blink_update_row; |
| 658 | m_update_row = mda_text_blink_update_row; |
| 664 | 659 | break; |
| 665 | 660 | case 0x0A: /* Hercules modes */ |
| 666 | 661 | case 0x2A: |
| 667 | | herc->m_update_row = hercules_gfx_update_row; |
| 662 | m_update_row = hercules_gfx_update_row; |
| 668 | 663 | break; |
| 669 | 664 | default: |
| 670 | | herc->m_update_row = NULL; |
| 665 | m_update_row = NULL; |
| 671 | 666 | } |
| 672 | 667 | |
| 673 | | downcast<mc6845_device *>(device)->set_clock( herc->m_mode_control & 0x02 ? MDA_CLOCK / 16 : MDA_CLOCK / 9 ); |
| 674 | | downcast<mc6845_device *>(device)->set_hpixels_per_column( herc->m_mode_control & 0x02 ? 16 : 9 ); |
| 668 | mc6845->set_clock( m_mode_control & 0x02 ? MDA_CLOCK / 16 : MDA_CLOCK / 9 ); |
| 669 | mc6845->set_hpixels_per_column( m_mode_control & 0x02 ? 16 : 9 ); |
| 675 | 670 | } |
| 676 | 671 | |
| 677 | 672 | |
| 678 | | static WRITE8_DEVICE_HANDLER(hercules_config_w) |
| 673 | WRITE8_MEMBER( isa8_hercules_device::io_write ) |
| 679 | 674 | { |
| 680 | | isa8_hercules_device *herc = downcast<isa8_hercules_device *>(device); |
| 681 | | MDA_LOG(1,"HGC_config_w",("$%02x\n", data)); |
| 682 | | herc->m_configuration_switch = data; |
| 683 | | } |
| 684 | | |
| 685 | | |
| 686 | | static WRITE8_DEVICE_HANDLER ( hercules_w ) |
| 687 | | { |
| 688 | | mc6845_device *mc6845 = downcast<mc6845_device *>(device->subdevice(HERCULES_MC6845_NAME)); |
| 689 | | address_space *space = device->machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 690 | | device_t *lpt = device->subdevice("lpt"); |
| 675 | mc6845_device *mc6845 = subdevice<mc6845_device>(HERCULES_MC6845_NAME); |
| 676 | device_t *lpt = subdevice("lpt"); |
| 691 | 677 | switch( offset ) |
| 692 | 678 | { |
| 693 | 679 | case 0: case 2: case 4: case 6: |
| 694 | | mc6845->address_w( *space, offset, data ); |
| 680 | mc6845->address_w( space, offset, data ); |
| 695 | 681 | break; |
| 696 | 682 | case 1: case 3: case 5: case 7: |
| 697 | | mc6845->register_w( *space, offset, data ); |
| 683 | mc6845->register_w( space, offset, data ); |
| 698 | 684 | break; |
| 699 | 685 | case 8: |
| 700 | | hercules_mode_control_w(mc6845, offset, data); |
| 686 | mode_control_w(space, offset, data); |
| 701 | 687 | break; |
| 702 | 688 | case 12: case 13: case 14: |
| 703 | 689 | pc_lpt_w(lpt, offset - 12, data); |
| 704 | 690 | break; |
| 705 | 691 | case 15: |
| 706 | | hercules_config_w(device, offset, data); |
| 692 | m_configuration_switch = data; |
| 707 | 693 | break; |
| 708 | 694 | } |
| 709 | 695 | } |
| r14392 | r14393 | |
| 720 | 706 | * 2-1 reserved |
| 721 | 707 | * 0 horizontal drive enable |
| 722 | 708 | */ |
| 723 | | static READ8_DEVICE_HANDLER(hercules_status_r) |
| 709 | READ8_MEMBER( isa8_hercules_device::status_r ) |
| 724 | 710 | { |
| 725 | | isa8_hercules_device *herc = downcast<isa8_hercules_device *>(device); |
| 726 | | |
| 727 | 711 | // Faking pixel stream here |
| 728 | | herc->m_pixel++; |
| 712 | m_pixel++; |
| 729 | 713 | |
| 730 | | return herc->m_vsync | ( herc->m_pixel & 0x08 ) | herc->m_hsync; |
| 714 | return m_vsync | ( m_pixel & 0x08 ) | m_hsync; |
| 731 | 715 | } |
| 732 | 716 | |
| 733 | 717 | |
| 734 | | static READ8_DEVICE_HANDLER ( hercules_r ) |
| 718 | READ8_MEMBER( isa8_hercules_device::io_read ) |
| 735 | 719 | { |
| 736 | 720 | int data = 0xff; |
| 737 | | mc6845_device *mc6845 = downcast<mc6845_device *>(device->subdevice(HERCULES_MC6845_NAME)); |
| 738 | | address_space *space = device->machine().device("maincpu")->memory().space(AS_PROGRAM); |
| 739 | | device_t *lpt = device->subdevice("lpt"); |
| 721 | mc6845_device *mc6845 = subdevice<mc6845_device>(HERCULES_MC6845_NAME); |
| 722 | device_t *lpt = subdevice("lpt"); |
| 740 | 723 | switch( offset ) |
| 741 | 724 | { |
| 742 | 725 | case 0: case 2: case 4: case 6: |
| 743 | 726 | /* return last written mc6845 address value here? */ |
| 744 | 727 | break; |
| 745 | 728 | case 1: case 3: case 5: case 7: |
| 746 | | data = mc6845->register_r( *space, offset ); |
| 729 | data = mc6845->register_r( space, offset ); |
| 747 | 730 | break; |
| 748 | 731 | case 10: |
| 749 | | data = hercules_status_r(device, offset); |
| 732 | data = status_r(space, offset); |
| 750 | 733 | break; |
| 751 | 734 | /* 12, 13, 14 are the LPT ports */ |
| 752 | 735 | case 12: case 13: case 14: |