src/mess/machine/svi318.c
| r3680 | r3681 | |
| 3 | 3 | ** |
| 4 | 4 | ** Sean Young, Tomas Karlsson |
| 5 | 5 | ** |
| 6 | | ** Todo: |
| 7 | | ** - modem port |
| 8 | | ** - svi_cas format |
| 9 | 6 | */ |
| 10 | 7 | |
| 11 | 8 | #include "driver.h" |
| r3680 | r3681 | |
| 263 | 260 | |
| 264 | 261 | /* Printer port */ |
| 265 | 262 | |
| 266 | | static const device_config *printer_device(running_machine *machine) |
| 263 | static const device_config *printer_image(running_machine *machine) |
| 267 | 264 | { |
| 268 | 265 | return device_list_find_by_tag(machine->config->devicelist, PRINTER, "printer"); |
| 269 | 266 | } |
| r3680 | r3681 | |
| 275 | 272 | else |
| 276 | 273 | { |
| 277 | 274 | if ( (svi.prn_strobe & 1) && !(data & 1) ) |
| 278 | | printer_output(printer_device(machine), svi.prn_data); |
| 275 | printer_output(printer_image(space->machine), svi.prn_data); |
| 279 | 276 | |
| 280 | 277 | svi.prn_strobe = data; |
| 281 | 278 | } |
| r3680 | r3681 | |
| 283 | 280 | |
| 284 | 281 | static READ8_HANDLER( svi318_printer_r ) |
| 285 | 282 | { |
| 286 | | return printer_is_ready(printer_device(machine)) ? 0xfe:0xff; /* 0xfe if printer is ready to work */ |
| 283 | return printer_is_ready(printer_image(space->machine)) ? 0xfe:0xff; /* 0xfe if printer is ready to work */ |
| 287 | 284 | } |
| 288 | 285 | |
| 289 | 286 | /* PSG */ |
| r3680 | r3681 | |
| 303 | 300 | |
| 304 | 301 | READ8_HANDLER( svi318_psg_port_a_r ) |
| 305 | 302 | { |
| 306 | | return input_port_read(machine, "JOYSTICKS"); |
| 303 | return input_port_read(space->machine, "JOYSTICKS"); |
| 307 | 304 | } |
| 308 | 305 | |
| 309 | 306 | /* |
| r3680 | r3681 | |
| 328 | 325 | set_led_status (0, !(data & 0x20) ); |
| 329 | 326 | |
| 330 | 327 | svi.bank_switch = data; |
| 331 | | svi318_set_banks(machine); |
| 328 | svi318_set_banks(space->machine); |
| 332 | 329 | } |
| 333 | 330 | |
| 334 | 331 | /* Disk drives */ |
| r3680 | r3681 | |
| 484 | 481 | */ |
| 485 | 482 | } |
| 486 | 483 | |
| 487 | | static TIMER_CALLBACK(svi318_80col_init_registers) { |
| 488 | | cpuintrf_push_context( 0 ); |
| 484 | static TIMER_CALLBACK(svi318_80col_init_registers) |
| 485 | { |
| 486 | cpu_push_context(machine->cpu[0]); |
| 487 | |
| 489 | 488 | /* set some default values for the 6845 controller */ |
| 490 | 489 | svi806_set_crtc_register( 0, 109 ); |
| 491 | 490 | svi806_set_crtc_register( 1, 80 ); |
| r3680 | r3681 | |
| 503 | 502 | svi806_set_crtc_register( 13, 0 ); |
| 504 | 503 | svi806_set_crtc_register( 14, 0 ); |
| 505 | 504 | svi806_set_crtc_register( 15, 0 ); |
| 506 | | cpuintrf_pop_context(); |
| 505 | |
| 506 | cpu_pop_context(); |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | /* 80 column card init */ |
| r3680 | r3681 | |
| 522 | 522 | static WRITE8_HANDLER( svi806_ram_enable_w ) |
| 523 | 523 | { |
| 524 | 524 | svi.svi806_ram_enabled = ( data & 0x01 ); |
| 525 | | svi318_set_banks(machine); |
| 525 | svi318_set_banks(space->machine); |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | 528 | VIDEO_START( svi328_806 ) |
| r3680 | r3681 | |
| 585 | 585 | svi.svi318 = 1; |
| 586 | 586 | } |
| 587 | 587 | |
| 588 | | cpunum_set_input_line_vector (0, 0, 0xff); |
| 588 | cpu_set_input_line_vector(machine->cpu[0], 0, 0xff); |
| 589 | 589 | |
| 590 | 590 | /* memory */ |
| 591 | 591 | svi.empty_bank = auto_malloc (0x8000); |
| r3680 | r3681 | |
| 597 | 597 | UINT8 *table = auto_malloc (0x100); |
| 598 | 598 | const UINT8 *old_table; |
| 599 | 599 | |
| 600 | | old_table = cpunum_get_info_ptr (0, CPUINFO_PTR_Z80_CYCLE_TABLE + z80_cycle_table[i]); |
| 600 | old_table = cpu_get_info_ptr(machine->cpu[0], CPUINFO_PTR_Z80_CYCLE_TABLE + z80_cycle_table[i]); |
| 601 | 601 | memcpy (table, old_table, 0x100); |
| 602 | 602 | |
| 603 | 603 | if (z80_cycle_table[i] == Z80_TABLE_ex) |
| r3680 | r3681 | |
| 618 | 618 | } |
| 619 | 619 | } |
| 620 | 620 | } |
| 621 | | cpunum_set_info_ptr(0, CPUINFO_PTR_Z80_CYCLE_TABLE + z80_cycle_table[i], (void*)table); |
| 621 | cpu_set_info_ptr(machine->cpu[0], CPUINFO_PTR_Z80_CYCLE_TABLE + z80_cycle_table[i], (void*)table); |
| 622 | 622 | } |
| 623 | 623 | } |
| 624 | 624 | |
| r3680 | r3681 | |
| 667 | 667 | { |
| 668 | 668 | int set; |
| 669 | 669 | |
| 670 | | set = input_port_read(machine, "CONFIG"); |
| 670 | set = input_port_read(device->machine, "CONFIG"); |
| 671 | 671 | TMS9928A_set_spriteslimit (set & 0x20); |
| 672 | | TMS9928A_interrupt(machine); |
| 672 | TMS9928A_interrupt(device->machine); |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | /* Memory */ |
| r3680 | r3681 | |
| 792 | 792 | } |
| 793 | 793 | } |
| 794 | 794 | |
| 795 | | memory_set_bankptr( 1, svi.bankLow_ptr ); |
| 796 | | memory_set_bankptr( 2, svi.bankHigh1_ptr ); |
| 797 | | memory_set_bankptr( 3, svi.bankHigh2_ptr ); |
| 795 | memory_set_bankptr(machine, 1, svi.bankLow_ptr ); |
| 796 | memory_set_bankptr(machine, 2, svi.bankHigh1_ptr ); |
| 797 | memory_set_bankptr(machine, 3, svi.bankHigh2_ptr ); |
| 798 | 798 | |
| 799 | 799 | /* SVI-806 80 column card specific banking */ |
| 800 | 800 | if ( svi.svi806_present ) { |
| 801 | 801 | if ( svi.svi806_ram_enabled ) { |
| 802 | | memory_set_bankptr( 4, svi.svi806_ram ); |
| 802 | memory_set_bankptr(machine, 4, svi.svi806_ram ); |
| 803 | 803 | } else { |
| 804 | | memory_set_bankptr( 4, svi.bankHigh2_ptr + 0x3000 ); |
| 804 | memory_set_bankptr(machine, 4, svi.bankHigh2_ptr + 0x3000 ); |
| 805 | 805 | } |
| 806 | 806 | } |
| 807 | 807 | } |
| r3680 | r3681 | |
| 829 | 829 | |
| 830 | 830 | switch( offset ) { |
| 831 | 831 | case 0x12: |
| 832 | | data = svi318_printer_r(machine, 0); |
| 832 | data = svi318_printer_r(space, 0); |
| 833 | 833 | break; |
| 834 | 834 | |
| 835 | 835 | case 0x20: |
| r3680 | r3681 | |
| 840 | 840 | case 0x25: |
| 841 | 841 | case 0x26: |
| 842 | 842 | case 0x27: |
| 843 | | data = ins8250_r(device_list_find_by_tag( machine->config->devicelist, INS8250, "ins8250_0" ), offset & 7); |
| 843 | data = ins8250_r(device_list_find_by_tag( space->machine->config->devicelist, INS8250, "ins8250_0" ), offset & 7); |
| 844 | 844 | break; |
| 845 | 845 | |
| 846 | 846 | case 0x28: |
| r3680 | r3681 | |
| 851 | 851 | case 0x2D: |
| 852 | 852 | case 0x2E: |
| 853 | 853 | case 0x2F: |
| 854 | | data = ins8250_r(device_list_find_by_tag( machine->config->devicelist, INS8250, "ins8250_1" ), offset & 7); |
| 854 | data = ins8250_r(device_list_find_by_tag( space->machine->config->devicelist, INS8250, "ins8250_1" ), offset & 7); |
| 855 | 855 | break; |
| 856 | 856 | |
| 857 | 857 | case 0x30: |
| 858 | | data = wd17xx_status_r(machine, 0); |
| 858 | data = wd17xx_status_r(space, 0); |
| 859 | 859 | break; |
| 860 | 860 | case 0x31: |
| 861 | | data = wd17xx_track_r(machine, 0); |
| 861 | data = wd17xx_track_r(space, 0); |
| 862 | 862 | break; |
| 863 | 863 | case 0x32: |
| 864 | | data = wd17xx_sector_r(machine, 0); |
| 864 | data = wd17xx_sector_r(space, 0); |
| 865 | 865 | break; |
| 866 | 866 | case 0x33: |
| 867 | | data = wd17xx_data_r(machine, 0); |
| 867 | data = wd17xx_data_r(space, 0); |
| 868 | 868 | break; |
| 869 | 869 | case 0x34: |
| 870 | | data = svi318_fdc_irqdrq_r(machine, 0); |
| 870 | data = svi318_fdc_irqdrq_r(space, 0); |
| 871 | 871 | break; |
| 872 | 872 | case 0x51: { |
| 873 | | device_config *devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, "crtc"); |
| 873 | device_config *devconf = (device_config *) device_list_find_by_tag( space->machine->config->devicelist, MC6845, "crtc"); |
| 874 | 874 | data = mc6845_register_r(devconf, 0); |
| 875 | 875 | } |
| 876 | 876 | break; |
| r3680 | r3681 | |
| 888 | 888 | switch( offset ) { |
| 889 | 889 | case 0x10: |
| 890 | 890 | case 0x11: |
| 891 | | svi318_printer_w(machine, offset & 1, data); |
| 891 | svi318_printer_w(space, offset & 1, data); |
| 892 | 892 | break; |
| 893 | 893 | |
| 894 | 894 | case 0x20: |
| r3680 | r3681 | |
| 899 | 899 | case 0x25: |
| 900 | 900 | case 0x26: |
| 901 | 901 | case 0x27: |
| 902 | | ins8250_w(device_list_find_by_tag( machine->config->devicelist, INS8250, "ins8250_0" ), offset & 7, data); |
| 902 | ins8250_w(device_list_find_by_tag( space->machine->config->devicelist, INS8250, "ins8250_0" ), offset & 7, data); |
| 903 | 903 | break; |
| 904 | 904 | |
| 905 | 905 | case 0x28: |
| r3680 | r3681 | |
| 910 | 910 | case 0x2D: |
| 911 | 911 | case 0x2E: |
| 912 | 912 | case 0x2F: |
| 913 | | ins8250_w(device_list_find_by_tag( machine->config->devicelist, INS8250, "ins8250_1" ), offset & 7, data); |
| 913 | ins8250_w(device_list_find_by_tag( space->machine->config->devicelist, INS8250, "ins8250_1" ), offset & 7, data); |
| 914 | 914 | break; |
| 915 | 915 | |
| 916 | 916 | case 0x30: |
| 917 | | wd17xx_command_w(machine, 0, data); |
| 917 | wd17xx_command_w(space, 0, data); |
| 918 | 918 | break; |
| 919 | 919 | case 0x31: |
| 920 | | wd17xx_track_w(machine, 0, data); |
| 920 | wd17xx_track_w(space, 0, data); |
| 921 | 921 | break; |
| 922 | 922 | case 0x32: |
| 923 | | wd17xx_sector_w(machine, 0, data); |
| 923 | wd17xx_sector_w(space, 0, data); |
| 924 | 924 | break; |
| 925 | 925 | case 0x33: |
| 926 | | wd17xx_data_w(machine, 0, data); |
| 926 | wd17xx_data_w(space, 0, data); |
| 927 | 927 | break; |
| 928 | 928 | case 0x34: |
| 929 | | svi318_fdc_drive_motor_w(machine, 0, data); |
| 929 | svi318_fdc_drive_motor_w(space, 0, data); |
| 930 | 930 | break; |
| 931 | 931 | case 0x38: |
| 932 | | svi318_fdc_density_side_w(machine, 0, data); |
| 932 | svi318_fdc_density_side_w(space, 0, data); |
| 933 | 933 | break; |
| 934 | 934 | |
| 935 | 935 | case 0x50: { |
| 936 | | device_config *devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, "crtc"); |
| 936 | device_config *devconf = (device_config *) device_list_find_by_tag(space->machine->config->devicelist, MC6845, "crtc"); |
| 937 | 937 | mc6845_address_w(devconf, 0, data); |
| 938 | 938 | } |
| 939 | 939 | break; |
| 940 | 940 | case 0x51: { |
| 941 | | device_config *devconf = (device_config *) device_list_find_by_tag(machine->config->devicelist, MC6845, "crtc"); |
| 941 | device_config *devconf = (device_config *) device_list_find_by_tag(space->machine->config->devicelist, MC6845, "crtc"); |
| 942 | 942 | mc6845_register_w(devconf, 0, data); |
| 943 | 943 | } |
| 944 | 944 | break; |
| 945 | 945 | |
| 946 | 946 | case 0x58: |
| 947 | | svi806_ram_enable_w(machine, 0, data); |
| 947 | svi806_ram_enable_w(space, 0, data); |
| 948 | 948 | break; |
| 949 | 949 | } |
| 950 | 950 | } |