src/mess/machine/thomson.c
| r3854 | r3855 | |
| 7 | 7 | **********************************************************************/ |
| 8 | 8 | |
| 9 | 9 | #include "driver.h" |
| 10 | | #include "deprecat.h" |
| 11 | | #include "includes/thomson.h" |
| 12 | | #include "cpu/m6809/m6809.h" |
| 13 | | #include "machine/6821pia.h" |
| 14 | | #include "machine/mc6846.h" |
| 15 | | #include "machine/6850acia.h" |
| 16 | | #include "machine/6551.h" |
| 17 | | #include "sound/dac.h" |
| 18 | | #include "audio/mea8000.h" |
| 19 | | #include "devices/cartslot.h" |
| 20 | | #include "machine/centroni.h" |
| 21 | | #include "devices/printer.h" |
| 22 | | #include "includes/serial.h" |
| 23 | | #include "devices/cassette.h" |
| 24 | 10 | #include "devices/thomflop.h" |
| 25 | 11 | #include "formats/thom_dsk.h" |
| 12 | #include "includes/thomson.h" |
| 26 | 13 | |
| 27 | 14 | #define VERBOSE 0 |
| 28 | 15 | #define VERBOSE_IRQ 0 |
| r3854 | r3855 | |
| 105 | 92 | /* hack, feed existing bits */ |
| 106 | 93 | if ( bitpos >= to7_k7_bitsize ) |
| 107 | 94 | bitpos = to7_k7_bitsize -1; |
| 108 | | // VLOG (( "$%04x %f to7_get_cassette: state=$%X pos=%f samppos=%i bit=%i\n", |
| 109 | | // cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), state, pos, bitpos, |
| 110 | | // to7_k7_bits[ bitpos ] )); |
| 95 | VLOG (( "$%04x %f to7_get_cassette: state=$%X pos=%f samppos=%i bit=%i\n", |
| 96 | cpu_get_previouspc( machine->cpu[0] ), attotime_to_double(timer_get_time(machine)), state, pos, bitpos, |
| 97 | to7_k7_bits[ bitpos ] )); |
| 111 | 98 | return to7_k7_bits[ bitpos ]; |
| 112 | 99 | } |
| 113 | 100 | else |
| r3854 | r3855 | |
| 126 | 113 | chg++; |
| 127 | 114 | } |
| 128 | 115 | k = ( chg >= 13 ) ? 1 : 0; |
| 129 | | // VLOG (( "$%04x %f to7_get_cassette: state=$%X pos=%f samppos=%i bit=%i (%i)\n", |
| 130 | | // cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), state, pos, bitpos, |
| 131 | | // k, chg )); |
| 116 | VLOG (( "$%04x %f to7_get_cassette: state=$%X pos=%f samppos=%i bit=%i (%i)\n", |
| 117 | cpu_get_previouspc( machine->cpu[0] ), attotime_to_double(timer_get_time(machine)), state, pos, bitpos, |
| 118 | k, chg )); |
| 132 | 119 | return k; |
| 133 | 120 | } |
| 134 | 121 | |
| r3854 | r3855 | |
| 150 | 137 | |
| 151 | 138 | static WRITE8_HANDLER ( to7_set_cassette_motor ) |
| 152 | 139 | { |
| 153 | | const device_config* img = thom_cassette_img(space->machine); |
| 140 | const device_config* img = thom_cassette_img( space->machine ); |
| 154 | 141 | cassette_state state = cassette_get_state( img ); |
| 155 | 142 | double pos = cassette_get_position(img); |
| 156 | 143 | |
| 157 | 144 | LOG (( "$%04x %f to7_set_cassette_motor: cassette motor %s bitpos=%i\n", |
| 158 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data ? "off" : "on", |
| 145 | cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(img->machine)), data ? "off" : "on", |
| 159 | 146 | (int) (pos / TO7_BIT_LENGTH) )); |
| 160 | 147 | |
| 161 | 148 | if ( (state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_DISABLED && !data && pos > 0.3 ) |
| r3854 | r3855 | |
| 204 | 191 | cassette_get_sample( cass, 0, pos, 0, &hbit ); |
| 205 | 192 | hbit = hbit >= 0; |
| 206 | 193 | |
| 207 | | // VLOG (( "$%04x %f mo5_get_cassette: state=$%X pos=%f hbitpos=%i hbit=%i\n", |
| 208 | | // cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), state, pos, |
| 209 | | // (int) (pos / MO5_HBIT_LENGTH), hbit )); |
| 194 | VLOG (( "$%04x %f mo5_get_cassette: state=$%X pos=%f hbitpos=%i hbit=%i\n", |
| 195 | cpu_get_previouspc( machine->cpu[0] ), attotime_to_double(timer_get_time(machine)), state, pos, |
| 196 | (int) (pos / MO5_HBIT_LENGTH), hbit )); |
| 210 | 197 | return hbit; |
| 211 | 198 | } |
| 212 | 199 | else |
| r3854 | r3855 | |
| 225 | 212 | |
| 226 | 213 | static WRITE8_HANDLER ( mo5_set_cassette_motor ) |
| 227 | 214 | { |
| 228 | | const device_config* img = thom_cassette_img(space->machine); |
| 215 | const device_config* img = thom_cassette_img( space->machine ); |
| 229 | 216 | cassette_state state = cassette_get_state( img ); |
| 230 | 217 | double pos = cassette_get_position(img); |
| 231 | 218 | |
| 232 | 219 | LOG (( "$%04x %f mo5_set_cassette_motor: cassette motor %s hbitpos=%i\n", |
| 233 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data ? "off" : "on", |
| 220 | cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data ? "off" : "on", |
| 234 | 221 | (int) (pos / MO5_HBIT_LENGTH) )); |
| 235 | 222 | |
| 236 | 223 | if ( (state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_DISABLED && !data && pos > 0.3 ) |
| r3854 | r3855 | |
| 293 | 280 | if ( old && !thom_firq ) |
| 294 | 281 | LOG_IRQ(( "%f thom_set_firq: firq line down %i\n", attotime_to_double(timer_get_time(machine)), line )); |
| 295 | 282 | |
| 296 | | cpu_set_input_line(machine->cpu[0], M6809_FIRQ_LINE, thom_firq ? ASSERT_LINE : CLEAR_LINE ); |
| 283 | cpu_set_input_line( machine->cpu[0], M6809_FIRQ_LINE, thom_firq ? ASSERT_LINE : CLEAR_LINE ); |
| 297 | 284 | } |
| 298 | 285 | |
| 299 | 286 | |
| r3854 | r3855 | |
| 302 | 289 | { |
| 303 | 290 | thom_irq = 0; |
| 304 | 291 | thom_firq = 0; |
| 305 | | cpu_set_input_line(machine->cpu[0], M6809_IRQ_LINE, CLEAR_LINE ); |
| 306 | | cpu_set_input_line(machine->cpu[0], M6809_FIRQ_LINE, CLEAR_LINE ); |
| 292 | cpu_set_input_line( machine->cpu[0], M6809_IRQ_LINE, CLEAR_LINE ); |
| 293 | cpu_set_input_line( machine->cpu[0], M6809_FIRQ_LINE, CLEAR_LINE ); |
| 307 | 294 | } |
| 308 | 295 | |
| 309 | 296 | |
| 310 | 297 | |
| 311 | 298 | static void thom_irq_init ( running_machine *machine ) |
| 312 | 299 | { |
| 313 | | state_save_register_global(machine, thom_irq ); |
| 314 | | state_save_register_global(machine, thom_firq ); |
| 300 | state_save_register_global( machine, thom_irq ); |
| 301 | state_save_register_global( machine, thom_firq ); |
| 315 | 302 | } |
| 316 | 303 | |
| 317 | 304 | |
| r3854 | r3855 | |
| 321 | 308 | thom_set_irq ( machine, 0, state ); |
| 322 | 309 | } |
| 323 | 310 | |
| 311 | static void thom_dev_irq_0 ( const device_config *device, int state ) |
| 312 | { |
| 313 | thom_irq_0( device->machine, state ); |
| 314 | } |
| 315 | |
| 316 | |
| 317 | |
| 324 | 318 | static void thom_irq_1 ( running_machine *machine, int state ) |
| 325 | 319 | { |
| 326 | 320 | thom_set_irq ( machine, 1, state ); |
| r3854 | r3855 | |
| 365 | 359 | |
| 366 | 360 | |
| 367 | 361 | |
| 368 | | static void thom_set_caps_led ( int led ) |
| 362 | static void thom_set_caps_led ( running_machine *machine, int led ) |
| 369 | 363 | { |
| 370 | 364 | output_set_value( "led0", led ); |
| 371 | 365 | } |
| r3854 | r3855 | |
| 512 | 506 | |
| 513 | 507 | static void to7_update_cart_bank(running_machine *machine) |
| 514 | 508 | { |
| 509 | const address_space* space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 515 | 510 | static int old_bank = -1; |
| 516 | 511 | int bank = 0; |
| 517 | 512 | if ( thom_cart_nb_banks ) |
| 518 | 513 | { |
| 519 | 514 | bank = thom_cart_bank % thom_cart_nb_banks; |
| 520 | | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x0003, 0, 0, to7_cartridge_r ); |
| 515 | memory_install_read8_handler(space, 0x0000, 0x0003, 0, 0, to7_cartridge_r ); |
| 521 | 516 | } |
| 522 | 517 | |
| 523 | 518 | if ( bank != old_bank ) |
| r3854 | r3855 | |
| 564 | 559 | |
| 565 | 560 | |
| 566 | 561 | |
| 567 | | static WRITE8_HANDLER ( to7_timer_port_out ) |
| 562 | static WRITE8_DEVICE_HANDLER ( to7_timer_port_out ) |
| 568 | 563 | { |
| 569 | | thom_set_mode_point( space->machine, data & 1 ); /* bit 0: video bank switch */ |
| 570 | | thom_set_caps_led( (data & 8) ? 1 : 0 ) ; /* bit 3: keyboard led */ |
| 571 | | thom_set_border_color( ((data & 0x10) ? 1 : 0) | /* bits 4-6: border color */ |
| 564 | thom_set_mode_point( device->machine, data & 1 ); /* bit 0: video bank switch */ |
| 565 | thom_set_caps_led( device->machine, (data & 8) ? 1 : 0 ) ; /* bit 3: keyboard led */ |
| 566 | thom_set_border_color( device->machine, |
| 567 | ((data & 0x10) ? 1 : 0) | /* bits 4-6: border color */ |
| 572 | 568 | ((data & 0x20) ? 2 : 0) | |
| 573 | 569 | ((data & 0x40) ? 4 : 0) ); |
| 574 | 570 | } |
| 575 | 571 | |
| 576 | 572 | |
| 577 | 573 | |
| 578 | | static WRITE8_HANDLER ( to7_timer_cp2_out ) |
| 574 | static WRITE8_DEVICE_HANDLER ( to7_timer_cp2_out ) |
| 579 | 575 | { |
| 580 | 576 | dac_data_w( THOM_SOUND_BUZ, data ? 0x80 : 0); /* 1-bit buzzer */ |
| 581 | 577 | } |
| 582 | 578 | |
| 583 | 579 | |
| 584 | 580 | |
| 585 | | static READ8_HANDLER ( to7_timer_port_in ) |
| 581 | static READ8_DEVICE_HANDLER ( to7_timer_port_in ) |
| 586 | 582 | { |
| 587 | | int lightpen = (input_port_read(space->machine, "lightpen_button") & 1) ? 2 : 0; |
| 588 | | int cass = to7_get_cassette(space->machine) ? 0x80 : 0; |
| 583 | int lightpen = (input_port_read(device->machine, "lightpen_button") & 1) ? 2 : 0; |
| 584 | int cass = to7_get_cassette(device->machine) ? 0x80 : 0; |
| 589 | 585 | return lightpen | cass; |
| 590 | 586 | } |
| 591 | 587 | |
| 592 | 588 | |
| 593 | 589 | |
| 594 | | static WRITE8_HANDLER ( to7_timer_tco_out ) |
| 590 | static WRITE8_DEVICE_HANDLER ( to7_timer_tco_out ) |
| 595 | 591 | { |
| 596 | 592 | /* 1-bit cassette output */ |
| 597 | | to7_set_cassette( space->machine, data ); |
| 593 | to7_set_cassette( device->machine, data ); |
| 598 | 594 | } |
| 599 | 595 | |
| 600 | 596 | |
| 601 | 597 | |
| 602 | | static const mc6846_interface to7_timer = |
| 598 | mc6846_interface to7_timer = |
| 603 | 599 | { |
| 604 | 600 | to7_timer_port_out, NULL, to7_timer_cp2_out, |
| 605 | 601 | to7_timer_port_in, to7_timer_tco_out, |
| 606 | | thom_irq_0 |
| 602 | thom_dev_irq_0 |
| 607 | 603 | }; |
| 608 | 604 | |
| 609 | 605 | |
| r3854 | r3855 | |
| 756 | 752 | { |
| 757 | 753 | /* acknowledge from centronics printer to PIA */ |
| 758 | 754 | int ack = (data & CENTRONICS_ACKNOWLEDGE) ? 1 : 0; |
| 759 | | //LOG (( "%f to7_io_ack: CENTRONICS new state $%02X (ack=%i)\n", attotime_to_double(timer_get_time(machine)), data, ack )); |
| 755 | //LOG_IO (( "%f to7_io_ack: CENTRONICS new state $%02X (ack=%i)\n", attotime_to_double(timer_get_time(machine)), data, ack )); |
| 760 | 756 | pia_set_input_cb1( THOM_PIA_IO, ack ); |
| 761 | 757 | } |
| 762 | 758 | |
| r3854 | r3855 | |
| 767 | 763 | int tx = data & 1; |
| 768 | 764 | int dtr = ( data & 2 ) ? 1 : 0; |
| 769 | 765 | |
| 770 | | LOG_IO(( "$%04x %f to7_io_porta_out: tx=%i, dtr=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), tx, dtr )); |
| 766 | LOG_IO(( "$%04x %f to7_io_porta_out: tx=%i, dtr=%i\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), tx, dtr )); |
| 771 | 767 | if ( dtr ) |
| 772 | 768 | to7_io_line.State |= SERIAL_STATE_DTR; |
| 773 | 769 | else |
| r3854 | r3855 | |
| 790 | 786 | else |
| 791 | 787 | cts = ( centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY ) ? 1 : 0; |
| 792 | 788 | |
| 793 | | LOG_IO(( "$%04x %f to7_io_porta_in: mode=%i cts=%i, dsr=%i, rd=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), to7_io_mode(space->machine), cts, dsr, rd )); |
| 789 | LOG_IO(( "$%04x %f to7_io_porta_in: mode=%i cts=%i, dsr=%i, rd=%i\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), to7_io_mode(space->machine), cts, dsr, rd )); |
| 794 | 790 | |
| 795 | 791 | return (dsr ? 0x20 : 0) | (cts ? 0x40 : 0) | (rd ? 0x80: 0); |
| 796 | 792 | } |
| r3854 | r3855 | |
| 801 | 797 | { |
| 802 | 798 | /* set 8-bit data */ |
| 803 | 799 | |
| 804 | | LOG_IO(( "$%04x %f to7_io_portb_out: CENTRONICS set data=$%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data )); |
| 800 | LOG_IO(( "$%04x %f to7_io_portb_out: CENTRONICS set data=$%02X\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data )); |
| 805 | 801 | |
| 806 | 802 | centronics_write_data( 0, data ); |
| 807 | 803 | } |
| r3854 | r3855 | |
| 812 | 808 | { |
| 813 | 809 | /* send STROBE to printer */ |
| 814 | 810 | |
| 815 | | LOG_IO(( "$%04x %f to7_io_cb2_out: CENTRONICS set strobe=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data )); |
| 811 | LOG_IO(( "$%04x %f to7_io_cb2_out: CENTRONICS set strobe=%i\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data )); |
| 816 | 812 | |
| 817 | 813 | centronics_write_handshake( 0, data ? CENTRONICS_STROBE : 0, CENTRONICS_STROBE ); |
| 818 | 814 | } |
| 819 | 815 | |
| 820 | 816 | |
| 821 | 817 | |
| 822 | | static void to7_io_in_callback ( int id, unsigned long state ) |
| 818 | static void to7_io_in_cb ( int id, unsigned long state ) |
| 823 | 819 | { |
| 824 | 820 | /* our peer's state has changed */ |
| 825 | 821 | to7_io_line.input_state = state; |
| r3854 | r3855 | |
| 842 | 838 | |
| 843 | 839 | |
| 844 | 840 | |
| 845 | | static void thom_centronics_reset( void ) |
| 841 | static void thom_centronics_reset( running_machine *machine ) |
| 846 | 842 | { |
| 847 | 843 | centronics_write_handshake |
| 848 | 844 | ( 0, |
| r3854 | r3855 | |
| 858 | 854 | static void to7_io_reset( running_machine *machine ) |
| 859 | 855 | { |
| 860 | 856 | LOG (( "to7_io_reset called\n" )); |
| 861 | | thom_centronics_reset(); |
| 857 | thom_centronics_reset(machine); |
| 862 | 858 | /* pia_reset() is called in MACHINE_RESET */ |
| 863 | 859 | pia_set_port_a_z_mask( THOM_PIA_IO, 0x03 ); |
| 864 | 860 | to7_io_line.input_state = SERIAL_STATE_CTS; |
| r3854 | r3855 | |
| 870 | 866 | |
| 871 | 867 | |
| 872 | 868 | |
| 873 | | static void to7_io_init( void ) |
| 869 | static void to7_io_init( running_machine *machine ) |
| 874 | 870 | { |
| 875 | 871 | LOG (( "to7_io_init: CC 90-323 serial / parallel extension\n" )); |
| 876 | 872 | pia_config( THOM_PIA_IO, &to7_io ); |
| 877 | 873 | centronics_config( 0, &to7_centronics ); |
| 878 | 874 | serial_connection_init( &to7_io_line ); |
| 879 | | serial_connection_set_in_callback( &to7_io_line, to7_io_in_callback ); |
| 875 | serial_connection_set_in_callback( &to7_io_line, to7_io_in_cb ); |
| 880 | 876 | } |
| 881 | 877 | |
| 882 | 878 | |
| r3854 | r3855 | |
| 891 | 887 | |
| 892 | 888 | |
| 893 | 889 | |
| 894 | | static void to7_rf57932_reset( void ) |
| 895 | | { |
| 896 | | LOG (( "to7_rf57932_reset called\n" )); |
| 897 | | } |
| 898 | | |
| 899 | | |
| 900 | | |
| 901 | 890 | /* ------------ MD 90-120 MODEM extension (not functional) ------------ */ |
| 902 | 891 | |
| 903 | 892 | /* Features: |
| r3854 | r3855 | |
| 916 | 905 | |
| 917 | 906 | |
| 918 | 907 | |
| 919 | | static void to7_modem_cb(const device_config *device, int state ) |
| 908 | static void to7_modem_cb( const device_config *device, int state ) |
| 920 | 909 | { |
| 921 | 910 | LOG(( "to7_modem_cb: called %i\n", state )); |
| 922 | 911 | } |
| r3854 | r3855 | |
| 932 | 921 | |
| 933 | 922 | |
| 934 | 923 | |
| 935 | | const acia6850_interface to7_acia_modem = |
| 924 | acia6850_interface to7_modem = |
| 936 | 925 | { |
| 937 | 926 | 1200, 1200, /* 1200 bauds, might be divided by 16 */ |
| 938 | 927 | &to7_modem_rx, &to7_modem_tx, |
| r3854 | r3855 | |
| 942 | 931 | |
| 943 | 932 | |
| 944 | 933 | |
| 945 | | static void to7_modem_reset( void ) |
| 934 | static void to7_modem_reset( running_machine *machine ) |
| 946 | 935 | { |
| 947 | 936 | LOG (( "to7_modem_reset called\n" )); |
| 948 | 937 | to7_modem_rx = 0; |
| r3854 | r3855 | |
| 957 | 946 | { |
| 958 | 947 | LOG (( "to7_modem_init: MODEM not implemented!\n" )); |
| 959 | 948 | pia_config( THOM_PIA_MODEM, &to7_pia_modem ); |
| 960 | | state_save_register_global(machine, to7_modem_rx ); |
| 961 | | state_save_register_global(machine, to7_modem_tx ); |
| 949 | state_save_register_global( machine, to7_modem_rx ); |
| 950 | state_save_register_global( machine, to7_modem_tx ); |
| 962 | 951 | } |
| 963 | 952 | |
| 964 | 953 | |
| r3854 | r3855 | |
| 966 | 955 | /* ------------ dispatch MODEM / speech extension ------------ */ |
| 967 | 956 | |
| 968 | 957 | |
| 958 | mea8000_interface to7_speech = { THOM_SOUND_SPEECH, NULL }; |
| 969 | 959 | |
| 960 | |
| 970 | 961 | READ8_HANDLER ( to7_modem_mea8000_r ) |
| 971 | 962 | { |
| 972 | | if ( input_port_read(space->machine, "mconfig") & 1 ) |
| 973 | | return mea8000_r( space, offset ); |
| 974 | | else |
| 963 | if ( input_port_read(space->machine, "mconfig") & 1 ) |
| 975 | 964 | { |
| 976 | | switch ( offset ) { |
| 977 | | case 0: return acia6850_stat_r( (device_config*)device_list_find_by_tag( space->machine->config->devicelist, ACIA6850, "acia_1"), 0 ); |
| 978 | | case 1: return acia6850_data_r( (device_config*)device_list_find_by_tag( space->machine->config->devicelist, ACIA6850, "acia_1"), 0 ); |
| 965 | const device_config* device = devtag_get_device(space->machine, MEA8000, "mea8000" ); |
| 966 | return mea8000_r( device, offset ); |
| 967 | } |
| 968 | else |
| 969 | { |
| 970 | const device_config* device = devtag_get_device(space->machine, ACIA6850, "acia6850" ); |
| 971 | switch (offset) { |
| 972 | case 0: return acia6850_stat_r( device, offset ); |
| 973 | case 1: return acia6850_data_r( device, offset ); |
| 979 | 974 | default: return 0; |
| 980 | 975 | } |
| 981 | 976 | } |
| r3854 | r3855 | |
| 986 | 981 | WRITE8_HANDLER ( to7_modem_mea8000_w ) |
| 987 | 982 | { |
| 988 | 983 | if ( input_port_read(space->machine, "mconfig") & 1 ) |
| 989 | | mea8000_w( space, offset, data ); |
| 984 | { |
| 985 | const device_config* device = devtag_get_device(space->machine, MEA8000, "mea8000" ); |
| 986 | mea8000_w( device, offset, data ); |
| 987 | } |
| 990 | 988 | else |
| 991 | 989 | { |
| 992 | | switch ( offset ) { |
| 993 | | case 0: acia6850_ctrl_w( (device_config*)device_list_find_by_tag( space->machine->config->devicelist, ACIA6850, "acia_1"), 0, data ); break; |
| 994 | | case 1: acia6850_data_w( (device_config*)device_list_find_by_tag( space->machine->config->devicelist, ACIA6850, "acia_1"), 0, data ); break; |
| 990 | const device_config* device = devtag_get_device(space->machine, ACIA6850, "acia6850" ); |
| 991 | switch (offset) { |
| 992 | case 0: acia6850_ctrl_w( device, offset, data ); |
| 993 | case 1: acia6850_data_w( device, offset, data ); |
| 995 | 994 | } |
| 996 | 995 | } |
| 997 | 996 | } |
| r3854 | r3855 | |
| 1044 | 1043 | |
| 1045 | 1044 | |
| 1046 | 1045 | |
| 1047 | | static void to7_game_sound_update ( void ) |
| 1046 | static void to7_game_sound_update ( running_machine *machine ) |
| 1048 | 1047 | { |
| 1049 | 1048 | dac_data_w( THOM_SOUND_GAME, to7_game_mute ? 0 : (to7_game_sound << 2) ); |
| 1050 | 1049 | } |
| r3854 | r3855 | |
| 1123 | 1122 | { |
| 1124 | 1123 | /* 6-bit DAC sound */ |
| 1125 | 1124 | to7_game_sound = data & 0x3f; |
| 1126 | | to7_game_sound_update(); |
| 1125 | to7_game_sound_update(space->machine); |
| 1127 | 1126 | } |
| 1128 | 1127 | |
| 1129 | 1128 | |
| r3854 | r3855 | |
| 1182 | 1181 | { |
| 1183 | 1182 | LOG (( "to7_game_init called\n" )); |
| 1184 | 1183 | pia_config( THOM_PIA_GAME, &to7_game ); |
| 1185 | | to7_game_timer = timer_alloc(machine, to7_game_update_cb , NULL); |
| 1184 | to7_game_timer = timer_alloc( machine, to7_game_update_cb , NULL); |
| 1186 | 1185 | timer_adjust_periodic(to7_game_timer, TO7_GAME_POLL_PERIOD, 0, TO7_GAME_POLL_PERIOD); |
| 1187 | | state_save_register_global(machine, to7_game_sound ); |
| 1188 | | state_save_register_global(machine, to7_game_mute ); |
| 1186 | state_save_register_global( machine, to7_game_sound ); |
| 1187 | state_save_register_global( machine, to7_game_mute ); |
| 1189 | 1188 | } |
| 1190 | 1189 | |
| 1191 | 1190 | |
| 1192 | 1191 | |
| 1193 | | static void to7_game_reset ( void ) |
| 1192 | static void to7_game_reset ( running_machine *machine ) |
| 1194 | 1193 | { |
| 1195 | 1194 | LOG (( "to7_game_reset called\n" )); |
| 1196 | 1195 | pia_set_input_ca1( THOM_PIA_GAME, 0 ); |
| 1197 | 1196 | to7_game_sound = 0; |
| 1198 | 1197 | to7_game_mute = 0; |
| 1199 | | to7_game_sound_update(); |
| 1198 | to7_game_sound_update( machine ); |
| 1200 | 1199 | } |
| 1201 | 1200 | |
| 1202 | 1201 | |
| r3854 | r3855 | |
| 1238 | 1237 | |
| 1239 | 1238 | |
| 1240 | 1239 | |
| 1241 | | static void to7_midi_update_irq ( void ) |
| 1240 | static void to7_midi_update_irq ( running_machine *machine ) |
| 1242 | 1241 | { |
| 1243 | 1242 | if ( (to7_midi_intr & 4) && (to7_midi_status & ACIA_6850_RDRF) ) |
| 1244 | 1243 | to7_midi_status |= ACIA_6850_irq; /* byte received interrupt */ |
| r3854 | r3855 | |
| 1249 | 1248 | if ( (to7_midi_intr & 3) == 1 && (to7_midi_status & ACIA_6850_TDRE) ) |
| 1250 | 1249 | to7_midi_status |= ACIA_6850_irq; /* ready to transmit interrupt */ |
| 1251 | 1250 | |
| 1252 | | thom_irq_4( Machine, to7_midi_status & ACIA_6850_irq ); |
| 1251 | thom_irq_4( machine, to7_midi_status & ACIA_6850_irq ); |
| 1253 | 1252 | } |
| 1254 | 1253 | |
| 1255 | 1254 | |
| r3854 | r3855 | |
| 1259 | 1258 | to7_midi_status |= ACIA_6850_RDRF; |
| 1260 | 1259 | if ( s == CHARDEV_OVERFLOW ) |
| 1261 | 1260 | to7_midi_overrun = 1; |
| 1262 | | to7_midi_update_irq(); |
| 1261 | to7_midi_update_irq( machine ); |
| 1263 | 1262 | } |
| 1264 | 1263 | |
| 1265 | 1264 | |
| r3854 | r3855 | |
| 1267 | 1266 | static void to7_midi_ready_to_send_cb( running_machine *machine ) |
| 1268 | 1267 | { |
| 1269 | 1268 | to7_midi_status |= ACIA_6850_TDRE; |
| 1270 | | to7_midi_update_irq(); |
| 1269 | to7_midi_update_irq( machine ); |
| 1271 | 1270 | } |
| 1272 | 1271 | |
| 1273 | 1272 | |
| r3854 | r3855 | |
| 1289 | 1288 | /* bit 6: parity error (ignored) */ |
| 1290 | 1289 | /* bit 7: interrupt */ |
| 1291 | 1290 | LOG_MIDI(( "$%04x %f to7_midi_r: status $%02X (rdrf=%i, tdre=%i, ovrn=%i, irq=%i)\n", |
| 1292 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), to7_midi_status, |
| 1291 | cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), to7_midi_status, |
| 1293 | 1292 | (to7_midi_status & ACIA_6850_RDRF) ? 1 : 0, |
| 1294 | 1293 | (to7_midi_status & ACIA_6850_TDRE) ? 1 : 0, |
| 1295 | 1294 | (to7_midi_status & ACIA_6850_OVRN) ? 1 : 0, |
| r3854 | r3855 | |
| 1307 | 1306 | to7_midi_status &= ~ACIA_6850_OVRN; |
| 1308 | 1307 | to7_midi_overrun = 0; |
| 1309 | 1308 | LOG_MIDI(( "$%04x %f to7_midi_r: read data $%02X\n", |
| 1310 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data )); |
| 1311 | | to7_midi_update_irq(); |
| 1309 | cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data )); |
| 1310 | to7_midi_update_irq( space->machine ); |
| 1312 | 1311 | return data; |
| 1313 | 1312 | } |
| 1314 | 1313 | |
| 1315 | 1314 | |
| 1316 | 1315 | default: |
| 1317 | 1316 | logerror( "$%04x to7_midi_r: invalid offset %i\n", |
| 1318 | | cpu_get_previouspc(space->cpu), offset ); |
| 1317 | cpu_get_previouspc( space->machine->cpu[0] ), offset ); |
| 1319 | 1318 | return 0; |
| 1320 | 1319 | } |
| 1321 | 1320 | } |
| r3854 | r3855 | |
| 1334 | 1333 | if ( (data & 3) == 3 ) |
| 1335 | 1334 | { |
| 1336 | 1335 | /* reset */ |
| 1337 | | LOG_MIDI(( "$%04x %f to7_midi_w: reset (data=$%02X)\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data )); |
| 1336 | LOG_MIDI(( "$%04x %f to7_midi_w: reset (data=$%02X)\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data )); |
| 1338 | 1337 | to7_midi_overrun = 0; |
| 1339 | 1338 | to7_midi_status = 2; |
| 1340 | 1339 | to7_midi_intr = 0; |
| r3854 | r3855 | |
| 1351 | 1350 | static const int stop[8] = { 2,2,1,1,2,1,1,1 }; |
| 1352 | 1351 | static const char parity[8] = { 'e','o','e','o','-','-','e','o' }; |
| 1353 | 1352 | LOG_MIDI(( "$%04x %f to7_midi_w: set control to $%02X (bits=%i, stop=%i, parity=%c, intr in=%i out=%i)\n", |
| 1354 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), |
| 1353 | cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), |
| 1355 | 1354 | data, |
| 1356 | 1355 | bits[ (data >> 2) & 7 ], |
| 1357 | 1356 | stop[ (data >> 2) & 7 ], |
| r3854 | r3855 | |
| 1360 | 1359 | (to7_midi_intr & 3) ? 1 : 0)); |
| 1361 | 1360 | } |
| 1362 | 1361 | } |
| 1363 | | to7_midi_update_irq(); |
| 1362 | to7_midi_update_irq( space->machine ); |
| 1364 | 1363 | break; |
| 1365 | 1364 | |
| 1366 | 1365 | |
| 1367 | 1366 | case 1: /* output data */ |
| 1368 | | LOG_MIDI(( "$%04x %f to7_midi_w: write data $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data )); |
| 1367 | LOG_MIDI(( "$%04x %f to7_midi_w: write data $%02X\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data )); |
| 1369 | 1368 | if ( data == 0x55 ) |
| 1370 | 1369 | /* cable-detect: shortcut */ |
| 1371 | 1370 | chardev_fake_in( to7_midi_chardev, 0x55 ); |
| r3854 | r3855 | |
| 1379 | 1378 | |
| 1380 | 1379 | |
| 1381 | 1380 | default: |
| 1382 | | logerror( "$%04x to7_midi_w: invalid offset %i (data=$%02X) \n", cpu_get_previouspc(space->cpu), offset, data ); |
| 1381 | logerror( "$%04x to7_midi_w: invalid offset %i (data=$%02X) \n", cpu_get_previouspc( space->machine->cpu[0] ), offset, data ); |
| 1383 | 1382 | } |
| 1384 | 1383 | } |
| 1385 | 1384 | |
| r3854 | r3855 | |
| 1393 | 1392 | |
| 1394 | 1393 | |
| 1395 | 1394 | |
| 1396 | | static void to7_midi_reset( void ) |
| 1395 | static void to7_midi_reset( running_machine *machine ) |
| 1397 | 1396 | { |
| 1398 | 1397 | LOG (( "to7_midi_reset called\n" )); |
| 1399 | 1398 | to7_midi_overrun = 0; |
| r3854 | r3855 | |
| 1404 | 1403 | |
| 1405 | 1404 | |
| 1406 | 1405 | |
| 1407 | | static void to7_midi_init( void ) |
| 1406 | static void to7_midi_init( running_machine *machine ) |
| 1408 | 1407 | { |
| 1409 | 1408 | LOG (( "to7_midi_init\n" )); |
| 1410 | | to7_midi_chardev = chardev_open( Machine, "/dev/snd/midiC1D0", "/dev/snd/midiC1D1", &to7_midi_interface ); |
| 1411 | | state_save_register_global(machine, to7_midi_status ); |
| 1412 | | state_save_register_global(machine, to7_midi_overrun ); |
| 1413 | | state_save_register_global(machine, to7_midi_intr ); |
| 1409 | to7_midi_chardev = chardev_open( machine, "/dev/snd/midiC1D0", "/dev/snd/midiC1D1", &to7_midi_interface ); |
| 1410 | state_save_register_global( machine, to7_midi_status ); |
| 1411 | state_save_register_global( machine, to7_midi_overrun ); |
| 1412 | state_save_register_global( machine, to7_midi_intr ); |
| 1414 | 1413 | } |
| 1415 | 1414 | |
| 1416 | 1415 | |
| r3854 | r3855 | |
| 1434 | 1433 | |
| 1435 | 1434 | |
| 1436 | 1435 | |
| 1437 | | static void to7_midi_reset( void ) |
| 1436 | static void to7_midi_reset( running_machine *machine ) |
| 1438 | 1437 | { |
| 1439 | 1438 | logerror( "to7_midi_reset: not implemented\n" ); |
| 1440 | 1439 | } |
| 1441 | 1440 | |
| 1442 | 1441 | |
| 1443 | 1442 | |
| 1444 | | static void to7_midi_init( void ) |
| 1443 | static void to7_midi_init( running_machine *machine ) |
| 1445 | 1444 | { |
| 1446 | 1445 | logerror( "to7_midi_init: not implemented\n" ); |
| 1447 | 1446 | } |
| r3854 | r3855 | |
| 1463 | 1462 | /* subsystems */ |
| 1464 | 1463 | thom_irq_reset(machine); |
| 1465 | 1464 | pia_reset(); |
| 1466 | | mc6846_reset(); |
| 1467 | | to7_game_reset(); |
| 1465 | to7_game_reset(machine); |
| 1468 | 1466 | to7_floppy_reset(machine); |
| 1469 | 1467 | to7_io_reset(machine); |
| 1470 | | to7_modem_reset(); |
| 1471 | | to7_midi_reset(); |
| 1472 | | to7_rf57932_reset(); |
| 1473 | | mea8000_reset(machine); |
| 1468 | to7_modem_reset(machine); |
| 1469 | to7_midi_reset(machine); |
| 1474 | 1470 | |
| 1475 | 1471 | /* video */ |
| 1476 | | thom_set_video_mode( THOM_VMODE_TO770 ); |
| 1477 | | thom_set_init_callback( to7_set_init ); |
| 1478 | | thom_set_lightpen_callback(machine, 3, to7_lightpen_cb ); |
| 1472 | thom_set_video_mode( machine, THOM_VMODE_TO770 ); |
| 1473 | thom_set_init_callback( machine, to7_set_init ); |
| 1474 | thom_set_lightpen_callback( machine, 3, to7_lightpen_cb ); |
| 1479 | 1475 | thom_set_mode_point( machine, 0 ); |
| 1480 | | thom_set_border_color( 0 ); |
| 1476 | thom_set_border_color( machine, 0 ); |
| 1481 | 1477 | pia_set_input_cb1( THOM_PIA_SYS, 0 ); |
| 1482 | 1478 | |
| 1483 | 1479 | /* memory */ |
| r3854 | r3855 | |
| 1492 | 1488 | |
| 1493 | 1489 | MACHINE_START ( to7 ) |
| 1494 | 1490 | { |
| 1491 | const address_space* space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 1495 | 1492 | UINT8* mem = memory_region(machine, "main"); |
| 1496 | 1493 | |
| 1497 | 1494 | LOG (( "to7: machine start called\n" )); |
| r3854 | r3855 | |
| 1499 | 1496 | /* subsystems */ |
| 1500 | 1497 | thom_irq_init(machine); |
| 1501 | 1498 | pia_config( THOM_PIA_SYS, &to7_sys ); |
| 1502 | | mc6846_config( machine, &to7_timer ); |
| 1503 | 1499 | to7_game_init(machine); |
| 1504 | | to7_floppy_init( machine, mem + 0x20000 ); |
| 1505 | | to7_io_init(); |
| 1500 | to7_floppy_init(machine, mem + 0x20000); |
| 1501 | to7_io_init(machine); |
| 1506 | 1502 | to7_modem_init(machine); |
| 1507 | | to7_midi_init(); |
| 1508 | | mea8000_config( machine, THOM_SOUND_SPEECH, NULL ); |
| 1503 | to7_midi_init(machine); |
| 1509 | 1504 | |
| 1510 | 1505 | /* memory */ |
| 1511 | 1506 | thom_cart_bank = 0; |
| r3854 | r3855 | |
| 1522 | 1517 | /* install 16 KB or 16 KB + 8 KB memory extensions */ |
| 1523 | 1518 | /* BASIC instruction to see free memory: ?FRE(0) */ |
| 1524 | 1519 | int extram = mess_ram_size - 24*1024; |
| 1525 | | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x8000, 0x8000 + extram - 1, 0, 0, |
| 1526 | | (write8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) ); |
| 1527 | | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x8000, 0x8000 + extram - 1, 0, 0, |
| 1528 | | (read8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) ); |
| 1520 | memory_install_write8_handler(space, 0x8000, 0x8000 + extram - 1, 0, 0, (write8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) ); |
| 1521 | memory_install_read8_handler(space, 0x8000, 0x8000 + extram - 1, 0, 0, (read8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) ); |
| 1529 | 1522 | memory_configure_bank( machine, THOM_RAM_BANK, 0, 1, mess_ram + 0x6000, extram ); |
| 1530 | 1523 | memory_set_bank( machine, THOM_RAM_BANK, 0 ); |
| 1531 | 1524 | } |
| r3854 | r3855 | |
| 1534 | 1527 | memset( thom_vram + 0x2000, 0xc0, 0x2000 ); |
| 1535 | 1528 | |
| 1536 | 1529 | /* save-state */ |
| 1537 | | state_save_register_global(machine, thom_cart_nb_banks ); |
| 1538 | | state_save_register_global(machine, thom_cart_bank ); |
| 1539 | | state_save_register_global(machine, to7_lightpen ); |
| 1540 | | state_save_register_global(machine, to7_lightpen_step ); |
| 1541 | | state_save_register_global_pointer(machine, (mem + 0x10000), 0x10000 ); |
| 1542 | | state_save_register_postload(machine, to7_update_cart_bank_postload, NULL ); |
| 1530 | state_save_register_global( machine, thom_cart_nb_banks ); |
| 1531 | state_save_register_global( machine, thom_cart_bank ); |
| 1532 | state_save_register_global( machine, to7_lightpen ); |
| 1533 | state_save_register_global( machine, to7_lightpen_step ); |
| 1534 | state_save_register_global_pointer( machine, (mem + 0x10000), 0x10000 ); |
| 1535 | state_save_register_postload( machine, to7_update_cart_bank_postload, NULL ); |
| 1543 | 1536 | } |
| 1544 | 1537 | |
| 1545 | 1538 | |
| r3854 | r3855 | |
| 1555 | 1548 | static WRITE8_HANDLER ( to770_sys_cb2_out ) |
| 1556 | 1549 | { |
| 1557 | 1550 | /* video overlay: black pixels are transparent and show TV image underneath */ |
| 1558 | | LOG(( "$%04x to770_sys_cb2_out: video overlay %i\n", cpu_get_previouspc(space->cpu), data )); |
| 1551 | LOG(( "$%04x to770_sys_cb2_out: video overlay %i\n", cpu_get_previouspc( space->machine->cpu[0] ), data )); |
| 1559 | 1552 | } |
| 1560 | 1553 | |
| 1561 | 1554 | |
| r3854 | r3855 | |
| 1574 | 1567 | |
| 1575 | 1568 | static void to770_update_ram_bank(running_machine *machine) |
| 1576 | 1569 | { |
| 1570 | const address_space* space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 1577 | 1571 | UINT8 portb = pia_get_port_b_z_mask( THOM_PIA_SYS ); |
| 1578 | 1572 | static int old_bank = -1; |
| 1579 | 1573 | int bank; |
| r3854 | r3855 | |
| 1604 | 1598 | if ( mess_ram_size == 128*1024 || bank < 2 ) |
| 1605 | 1599 | { |
| 1606 | 1600 | memory_set_bank( machine, THOM_RAM_BANK, bank ); |
| 1607 | | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xdfff, 0, 0, (write8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) ); |
| 1601 | memory_install_write8_handler(space, 0xa000, 0xdfff, 0, 0, (write8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) ); |
| 1608 | 1602 | } |
| 1609 | 1603 | else |
| 1610 | 1604 | { |
| 1611 | | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xdfff, 0, 0, SMH_UNMAP ); |
| 1605 | memory_install_write8_handler(space, 0xa000, 0xdfff, 0, 0, SMH_UNMAP ); |
| 1612 | 1606 | } |
| 1613 | 1607 | |
| 1614 | 1608 | old_bank = bank; |
| r3854 | r3855 | |
| 1644 | 1638 | |
| 1645 | 1639 | |
| 1646 | 1640 | |
| 1647 | | static WRITE8_HANDLER ( to770_timer_port_out ) |
| 1641 | static WRITE8_DEVICE_HANDLER ( to770_timer_port_out ) |
| 1648 | 1642 | { |
| 1649 | | thom_set_mode_point( space->machine, data & 1 ); /* bit 0: video bank switch */ |
| 1650 | | thom_set_caps_led( (data & 8) ? 1 : 0 ) ; /* bit 3: keyboard led */ |
| 1651 | | thom_set_border_color( ((data & 0x10) ? 1 : 0) | /* 4-bit border color */ |
| 1643 | thom_set_mode_point( device->machine, data & 1 ); /* bit 0: video bank switch */ |
| 1644 | thom_set_caps_led( device->machine, (data & 8) ? 1 : 0 ) ; /* bit 3: keyboard led */ |
| 1645 | thom_set_border_color( device->machine, |
| 1646 | ((data & 0x10) ? 1 : 0) | /* 4-bit border color */ |
| 1652 | 1647 | ((data & 0x20) ? 2 : 0) | |
| 1653 | 1648 | ((data & 0x40) ? 4 : 0) | |
| 1654 | 1649 | ((data & 0x04) ? 0 : 8) ); |
| r3854 | r3855 | |
| 1656 | 1651 | |
| 1657 | 1652 | |
| 1658 | 1653 | |
| 1659 | | static const mc6846_interface to770_timer = |
| 1654 | mc6846_interface to770_timer = |
| 1660 | 1655 | { |
| 1661 | 1656 | to770_timer_port_out, NULL, to7_timer_cp2_out, |
| 1662 | 1657 | to7_timer_port_in, to7_timer_tco_out, |
| 1663 | | thom_irq_0 |
| 1658 | thom_dev_irq_0 |
| 1664 | 1659 | }; |
| 1665 | 1660 | |
| 1666 | 1661 | |
| r3854 | r3855 | |
| 1671 | 1666 | |
| 1672 | 1667 | READ8_HANDLER ( to770_gatearray_r ) |
| 1673 | 1668 | { |
| 1674 | | struct thom_vsignal v = thom_get_vsignal(); |
| 1669 | struct thom_vsignal v = thom_get_vsignal( space->machine ); |
| 1675 | 1670 | struct thom_vsignal l = thom_get_lightpen_vsignal( space->machine, TO7_LIGHTPEN_DECAL, to7_lightpen_step - 1, 0 ); |
| 1676 | 1671 | int count, inil, init, lt3; |
| 1677 | 1672 | count = to7_lightpen ? l.count : v.count; |
| r3854 | r3855 | |
| 1686 | 1681 | case 2: return (lt3 << 7) | (inil << 6); |
| 1687 | 1682 | case 3: return (init << 7); |
| 1688 | 1683 | default: |
| 1689 | | logerror( "$%04x to770_gatearray_r: invalid offset %i\n", cpu_get_previouspc(space->cpu), offset ); |
| 1684 | logerror( "$%04x to770_gatearray_r: invalid offset %i\n", cpu_get_previouspc( space->machine->cpu[0] ), offset ); |
| 1690 | 1685 | return 0; |
| 1691 | 1686 | } |
| 1692 | 1687 | } |
| r3854 | r3855 | |
| 1712 | 1707 | /* subsystems */ |
| 1713 | 1708 | thom_irq_reset(machine); |
| 1714 | 1709 | pia_reset(); |
| 1715 | | mc6846_reset(); |
| 1716 | | to7_game_reset(); |
| 1710 | to7_game_reset(machine); |
| 1717 | 1711 | to7_floppy_reset(machine); |
| 1718 | 1712 | to7_io_reset(machine); |
| 1719 | | to7_modem_reset(); |
| 1720 | | to7_midi_reset(); |
| 1721 | | to7_rf57932_reset(); |
| 1722 | | mea8000_reset(machine); |
| 1713 | to7_modem_reset(machine); |
| 1714 | to7_midi_reset(machine); |
| 1723 | 1715 | |
| 1724 | 1716 | /* video */ |
| 1725 | | thom_set_video_mode( THOM_VMODE_TO770 ); |
| 1726 | | thom_set_init_callback( to7_set_init ); |
| 1727 | | thom_set_lightpen_callback(machine, 3, to7_lightpen_cb ); |
| 1717 | thom_set_video_mode( machine, THOM_VMODE_TO770 ); |
| 1718 | thom_set_init_callback( machine, to7_set_init ); |
| 1719 | thom_set_lightpen_callback( machine, 3, to7_lightpen_cb ); |
| 1728 | 1720 | thom_set_mode_point( machine, 0 ); |
| 1729 | | thom_set_border_color( 8 ); |
| 1721 | thom_set_border_color( machine, 8 ); |
| 1730 | 1722 | pia_set_input_cb1( THOM_PIA_SYS, 0 ); |
| 1731 | 1723 | |
| 1732 | 1724 | /* memory */ |
| r3854 | r3855 | |
| 1749 | 1741 | /* subsystems */ |
| 1750 | 1742 | thom_irq_init(machine); |
| 1751 | 1743 | pia_config( THOM_PIA_SYS, &to770_sys ); |
| 1752 | | mc6846_config( machine, &to770_timer ); |
| 1753 | 1744 | to7_game_init(machine); |
| 1754 | 1745 | to7_floppy_init( machine, mem + 0x20000 ); |
| 1755 | | to7_io_init(); |
| 1746 | to7_io_init(machine); |
| 1756 | 1747 | to7_modem_init(machine); |
| 1757 | | to7_midi_init(); |
| 1758 | | mea8000_config( machine, THOM_SOUND_SPEECH, NULL ); |
| 1748 | to7_midi_init(machine); |
| 1759 | 1749 | |
| 1760 | 1750 | /* memory */ |
| 1761 | 1751 | thom_cart_bank = 0; |
| r3854 | r3855 | |
| 1770 | 1760 | memory_set_bank( machine, THOM_CART_BANK, 0 ); |
| 1771 | 1761 | |
| 1772 | 1762 | /* save-state */ |
| 1773 | | state_save_register_global(machine, thom_cart_nb_banks ); |
| 1774 | | state_save_register_global(machine, thom_cart_bank ); |
| 1775 | | state_save_register_global(machine, to7_lightpen ); |
| 1776 | | state_save_register_global(machine, to7_lightpen_step ); |
| 1777 | | state_save_register_global_pointer(machine, (mem + 0x10000), 0x10000 ); |
| 1778 | | state_save_register_postload(machine, to770_update_ram_bank_postload, NULL ); |
| 1779 | | state_save_register_postload(machine, to7_update_cart_bank_postload, NULL ); |
| 1763 | state_save_register_global( machine, thom_cart_nb_banks ); |
| 1764 | state_save_register_global( machine, thom_cart_bank ); |
| 1765 | state_save_register_global( machine, to7_lightpen ); |
| 1766 | state_save_register_global( machine, to7_lightpen_step ); |
| 1767 | state_save_register_global_pointer( machine, (mem + 0x10000), 0x10000 ); |
| 1768 | state_save_register_postload( machine, to770_update_ram_bank_postload, NULL ); |
| 1769 | state_save_register_postload( machine, to7_update_cart_bank_postload, NULL ); |
| 1780 | 1770 | } |
| 1781 | 1771 | |
| 1782 | 1772 | |
| r3854 | r3855 | |
| 1822 | 1812 | |
| 1823 | 1813 | |
| 1824 | 1814 | |
| 1825 | | static void mo5_init_timer(void) |
| 1815 | static void mo5_init_timer(running_machine *machine) |
| 1826 | 1816 | { |
| 1827 | 1817 | /* time is a little faster than 50 Hz to match video framerate */ |
| 1828 | 1818 | timer_adjust_periodic(mo5_periodic_timer, attotime_zero, 0, ATTOTIME_IN_USEC( 19968 )); |
| r3854 | r3855 | |
| 1836 | 1826 | |
| 1837 | 1827 | static WRITE8_HANDLER ( mo5_sys_porta_out ) |
| 1838 | 1828 | { |
| 1839 | | thom_set_mode_point( space->machine, data & 1 ); /* bit 0: video bank switch */ |
| 1840 | | thom_set_border_color( (data >> 1) & 15 ); /* bit 1-4: border color */ |
| 1841 | | mo5_set_cassette( space->machine, (data & 0x40) ? 1 : 0 ); /* bit 6: cassette output */ |
| 1829 | thom_set_mode_point( space->machine, data & 1 ); /* bit 0: video bank switch */ |
| 1830 | thom_set_border_color( space->machine, (data >> 1) & 15 ); /* bit 1-4: border color */ |
| 1831 | mo5_set_cassette( space->machine, (data & 0x40) ? 1 : 0 ); /* bit 6: cassette output */ |
| 1842 | 1832 | } |
| 1843 | 1833 | |
| 1844 | 1834 | |
| r3854 | r3855 | |
| 1893 | 1883 | |
| 1894 | 1884 | READ8_HANDLER ( mo5_gatearray_r ) |
| 1895 | 1885 | { |
| 1896 | | struct thom_vsignal v = thom_get_vsignal(); |
| 1886 | struct thom_vsignal v = thom_get_vsignal( space->machine ); |
| 1897 | 1887 | struct thom_vsignal l = thom_get_lightpen_vsignal( space->machine, MO5_LIGHTPEN_DECAL, to7_lightpen_step - 1, 0 ); |
| 1898 | 1888 | int count, inil, init, lt3; |
| 1899 | 1889 | count = to7_lightpen ? l.count : v.count; |
| r3854 | r3855 | |
| 1907 | 1897 | case 2: return (lt3 << 7) | (inil << 6); |
| 1908 | 1898 | case 3: return (init << 7); |
| 1909 | 1899 | default: |
| 1910 | | logerror( "$%04x mo5_gatearray_r: invalid offset %i\n", cpu_get_previouspc(space->cpu), offset ); |
| 1900 | logerror( "$%04x mo5_gatearray_r: invalid offset %i\n", cpu_get_previouspc( space->machine->cpu[0] ), offset ); |
| 1911 | 1901 | return 0; |
| 1912 | 1902 | } |
| 1913 | 1903 | } |
| r3854 | r3855 | |
| 1978 | 1968 | |
| 1979 | 1969 | static void mo5_update_cart_bank(running_machine *machine) |
| 1980 | 1970 | { |
| 1971 | const address_space* space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 1981 | 1972 | static int old_bank = -1; |
| 1982 | 1973 | int rom_is_ram = mo5_reg_cart & 4; |
| 1983 | 1974 | int bank = 0; |
| 1984 | 1975 | |
| 1985 | | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, |
| 1986 | | (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) ); |
| 1976 | memory_install_read8_handler( space, 0xb000, 0xefff, 0, 0, (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) ); |
| 1987 | 1977 | |
| 1988 | 1978 | if ( rom_is_ram && thom_cart_nb_banks == 4 ) |
| 1989 | 1979 | { |
| 1990 | 1980 | /* 64 KB ROM from "JANE" cartridge */ |
| 1991 | | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, SMH_NOP ); |
| 1981 | memory_install_write8_handler( space, 0xb000, 0xefff, 0, 0, SMH_NOP ); |
| 1992 | 1982 | bank = mo5_reg_cart & 3; |
| 1993 | 1983 | if ( bank != old_bank ) |
| 1994 | 1984 | LOG_BANK(( "mo5_update_cart_bank: CART is cartridge bank %i (A7CB style)\n", bank )); |
| r3854 | r3855 | |
| 1998 | 1988 | /* 64 KB RAM from network extension */ |
| 1999 | 1989 | int write_enable = mo5_reg_cart & 8; |
| 2000 | 1990 | bank = 4 + ( mo5_reg_cart & 3 ); |
| 2001 | | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, write_enable ? |
| 2002 | | (write8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) : SMH_NOP ); |
| 1991 | memory_install_write8_handler( space, 0xb000, 0xefff, 0, 0, write_enable ? (write8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) : SMH_NOP ); |
| 2003 | 1992 | if ( bank != old_bank ) |
| 2004 | 1993 | LOG_BANK(( "mo5_update_cart_bank: CART is nanonetwork RAM bank %i (write-enable=%i)\n", mo5_reg_cart & 3, write_enable ? 1 : 0 )); |
| 2005 | 1994 | } |
| 2006 | 1995 | else |
| 2007 | 1996 | { |
| 2008 | 1997 | /* regular cartridge bank switch */ |
| 2009 | | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, mo5_cartridge_w ); |
| 1998 | memory_install_write8_handler( space, 0xb000, 0xefff, 0, 0, mo5_cartridge_w ); |
| 2010 | 1999 | if ( thom_cart_nb_banks ) |
| 2011 | 2000 | { |
| 2012 | 2001 | bank = thom_cart_bank % thom_cart_nb_banks; |
| 2013 | | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xbffc, 0xbfff, 0, 0, mo5_cartridge_r ); |
| 2002 | memory_install_read8_handler( space, 0xbffc, 0xbfff, 0, 0, mo5_cartridge_r ); |
| 2014 | 2003 | } |
| 2015 | 2004 | if ( bank != old_bank ) |
| 2016 | 2005 | LOG_BANK(( "mo5_update_cart_bank: CART is internal / cartridge bank %i\n", thom_cart_bank )); |
| r3854 | r3855 | |
| 2073 | 2062 | thom_irq_reset(machine); |
| 2074 | 2063 | pia_reset(); |
| 2075 | 2064 | pia_set_port_a_z_mask( THOM_PIA_SYS, 0x5f ); |
| 2076 | | to7_game_reset(); |
| 2065 | to7_game_reset(machine); |
| 2077 | 2066 | to7_floppy_reset(machine); |
| 2078 | 2067 | to7_io_reset(machine); |
| 2079 | | to7_modem_reset(); |
| 2080 | | to7_midi_reset(); |
| 2081 | | to7_rf57932_reset(); |
| 2082 | | mo5_init_timer(); |
| 2083 | | mea8000_reset(machine); |
| 2068 | to7_modem_reset(machine); |
| 2069 | to7_midi_reset(machine); |
| 2070 | mo5_init_timer(machine); |
| 2084 | 2071 | |
| 2085 | 2072 | /* video */ |
| 2086 | | thom_set_video_mode( THOM_VMODE_MO5 ); |
| 2087 | | thom_set_lightpen_callback(machine, 3, mo5_lightpen_cb ); |
| 2073 | thom_set_video_mode( machine, THOM_VMODE_MO5 ); |
| 2074 | thom_set_lightpen_callback( machine, 3, mo5_lightpen_cb ); |
| 2088 | 2075 | thom_set_mode_point( machine, 0 ); |
| 2089 | | thom_set_border_color( 0 ); |
| 2076 | thom_set_border_color( machine, 0 ); |
| 2090 | 2077 | pia_set_input_ca1( THOM_PIA_SYS, 0 ); |
| 2091 | 2078 | |
| 2092 | 2079 | /* memory */ |
| r3854 | r3855 | |
| 2111 | 2098 | pia_config( THOM_PIA_SYS, &mo5_sys ); |
| 2112 | 2099 | to7_game_init(machine); |
| 2113 | 2100 | to7_floppy_init( machine, mem + 0x20000 ); |
| 2114 | | to7_io_init(); |
| 2101 | to7_io_init(machine); |
| 2115 | 2102 | to7_modem_init(machine); |
| 2116 | | to7_midi_init(); |
| 2117 | | mo5_periodic_timer = timer_alloc(machine, mo5_periodic_cb , NULL); |
| 2118 | | mea8000_config( machine, THOM_SOUND_SPEECH, NULL ); |
| 2103 | to7_midi_init(machine); |
| 2104 | mo5_periodic_timer = timer_alloc( machine, mo5_periodic_cb , NULL); |
| 2119 | 2105 | |
| 2120 | 2106 | /* memory */ |
| 2121 | 2107 | thom_cart_bank = 0; |
| r3854 | r3855 | |
| 2130 | 2116 | memory_set_bank( machine, THOM_VRAM_BANK, 0 ); |
| 2131 | 2117 | |
| 2132 | 2118 | /* save-state */ |
| 2133 | | state_save_register_global(machine, thom_cart_nb_banks ); |
| 2134 | | state_save_register_global(machine, thom_cart_bank ); |
| 2135 | | state_save_register_global(machine, to7_lightpen ); |
| 2136 | | state_save_register_global(machine, to7_lightpen_step ); |
| 2137 | | state_save_register_global(machine, mo5_reg_cart ); |
| 2138 | | state_save_register_global_pointer(machine, (mem + 0x10000), 0x10000 ); |
| 2139 | | state_save_register_postload(machine, mo5_update_cart_bank_postload, NULL ); |
| 2119 | state_save_register_global( machine, thom_cart_nb_banks ); |
| 2120 | state_save_register_global( machine, thom_cart_bank ); |
| 2121 | state_save_register_global( machine, to7_lightpen ); |
| 2122 | state_save_register_global( machine, to7_lightpen_step ); |
| 2123 | state_save_register_global( machine, mo5_reg_cart ); |
| 2124 | state_save_register_global_pointer( machine, (mem + 0x10000), 0x10000 ); |
| 2125 | state_save_register_postload( machine, mo5_update_cart_bank_postload, NULL ); |
| 2140 | 2126 | } |
| 2141 | 2127 | |
| 2142 | 2128 | |
| r3854 | r3855 | |
| 2155 | 2141 | |
| 2156 | 2142 | WRITE8_HANDLER ( to9_ieee_w ) |
| 2157 | 2143 | { |
| 2158 | | logerror( "$%04x %f to9_ieee_w: unhandled write $%02X to register %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data, offset ); |
| 2144 | logerror( "$%04x %f to9_ieee_w: unhandled write $%02X to register %i\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data, offset ); |
| 2159 | 2145 | } |
| 2160 | 2146 | |
| 2161 | 2147 | |
| 2162 | 2148 | |
| 2163 | 2149 | READ8_HANDLER ( to9_ieee_r ) |
| 2164 | 2150 | { |
| 2165 | | logerror( "$%04x %f to9_ieee_r: unhandled read from register %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), offset ); |
| 2151 | logerror( "$%04x %f to9_ieee_r: unhandled read from register %i\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), offset ); |
| 2166 | 2152 | return 0; |
| 2167 | 2153 | } |
| 2168 | 2154 | |
| r3854 | r3855 | |
| 2178 | 2164 | |
| 2179 | 2165 | READ8_HANDLER ( to9_gatearray_r ) |
| 2180 | 2166 | { |
| 2181 | | struct thom_vsignal v = thom_get_vsignal(); |
| 2167 | struct thom_vsignal v = thom_get_vsignal( space->machine ); |
| 2182 | 2168 | struct thom_vsignal l = thom_get_lightpen_vsignal( space->machine, TO9_LIGHTPEN_DECAL, to7_lightpen_step - 1, 0 ); |
| 2183 | 2169 | int count, inil, init, lt3; |
| 2184 | 2170 | count = to7_lightpen ? l.count : v.count; |
| r3854 | r3855 | |
| 2193 | 2179 | case 2: return (lt3 << 7) | (inil << 6); |
| 2194 | 2180 | case 3: return (v.init << 7) | (init << 6); /* != TO7/70 */ |
| 2195 | 2181 | default: |
| 2196 | | logerror( "$%04x to9_gatearray_r: invalid offset %i\n", cpu_get_previouspc(space->cpu), offset ); |
| 2182 | logerror( "$%04x to9_gatearray_r: invalid offset %i\n", cpu_get_previouspc( space->machine->cpu[0] ), offset ); |
| 2197 | 2183 | return 0; |
| 2198 | 2184 | } |
| 2199 | 2185 | } |
| r3854 | r3855 | |
| 2218 | 2204 | |
| 2219 | 2205 | |
| 2220 | 2206 | /* style: 0 => TO9, 1 => TO8/TO9, 2 => MO6 */ |
| 2221 | | static void to9_set_video_mode( UINT8 data, int style ) |
| 2207 | static void to9_set_video_mode( running_machine *machine, UINT8 data, int style ) |
| 2222 | 2208 | { |
| 2223 | 2209 | switch ( data & 0x7f ) |
| 2224 | 2210 | { |
| 2225 | 2211 | case 0x00: |
| 2226 | 2212 | if ( style == 2 ) |
| 2227 | | thom_set_video_mode( THOM_VMODE_MO5 ); |
| 2213 | thom_set_video_mode( machine, THOM_VMODE_MO5 ); |
| 2228 | 2214 | else if ( style == 1 ) |
| 2229 | | thom_set_video_mode( THOM_VMODE_TO770 ); |
| 2215 | thom_set_video_mode( machine, THOM_VMODE_TO770 ); |
| 2230 | 2216 | else |
| 2231 | | thom_set_video_mode( THOM_VMODE_TO9 ); |
| 2217 | thom_set_video_mode( machine, THOM_VMODE_TO9 ); |
| 2232 | 2218 | break; |
| 2233 | 2219 | |
| 2234 | | case 0x21: thom_set_video_mode( THOM_VMODE_BITMAP4 ); break; |
| 2220 | case 0x21: thom_set_video_mode( machine, THOM_VMODE_BITMAP4 ); break; |
| 2235 | 2221 | |
| 2236 | | case 0x41: thom_set_video_mode( THOM_VMODE_BITMAP4_ALT ); break; |
| 2222 | case 0x41: thom_set_video_mode( machine, THOM_VMODE_BITMAP4_ALT ); break; |
| 2237 | 2223 | |
| 2238 | 2224 | case 0x2a: |
| 2239 | 2225 | if ( style==0 ) |
| 2240 | | thom_set_video_mode( THOM_VMODE_80_TO9 ); |
| 2226 | thom_set_video_mode( machine, THOM_VMODE_80_TO9 ); |
| 2241 | 2227 | else |
| 2242 | | thom_set_video_mode( THOM_VMODE_80 ); |
| 2228 | thom_set_video_mode( machine, THOM_VMODE_80 ); |
| 2243 | 2229 | break; |
| 2244 | 2230 | |
| 2245 | | case 0x7b: thom_set_video_mode( THOM_VMODE_BITMAP16 ); break; |
| 2231 | case 0x7b: thom_set_video_mode( machine, THOM_VMODE_BITMAP16 ); break; |
| 2246 | 2232 | |
| 2247 | | case 0x24: thom_set_video_mode( THOM_VMODE_PAGE1 ); break; |
| 2233 | case 0x24: thom_set_video_mode( machine, THOM_VMODE_PAGE1 ); break; |
| 2248 | 2234 | |
| 2249 | | case 0x25: thom_set_video_mode( THOM_VMODE_PAGE2 ); break; |
| 2235 | case 0x25: thom_set_video_mode( machine, THOM_VMODE_PAGE2 ); break; |
| 2250 | 2236 | |
| 2251 | | case 0x26: thom_set_video_mode( THOM_VMODE_OVERLAY ); break; |
| 2237 | case 0x26: thom_set_video_mode( machine, THOM_VMODE_OVERLAY ); break; |
| 2252 | 2238 | |
| 2253 | | case 0x3f: thom_set_video_mode( THOM_VMODE_OVERLAY3 ); break; |
| 2239 | case 0x3f: thom_set_video_mode( machine, THOM_VMODE_OVERLAY3 ); break; |
| 2254 | 2240 | |
| 2255 | 2241 | default: |
| 2256 | 2242 | logerror( "to9_set_video_mode: unknown mode $%02X tr=%i phi=%i mod=%i\n", data, (data >> 5) & 3, (data >> 3) & 2, data & 7 ); |
| r3854 | r3855 | |
| 2288 | 2274 | |
| 2289 | 2275 | WRITE8_HANDLER ( to9_vreg_w ) |
| 2290 | 2276 | { |
| 2291 | | LOG_VIDEO(( "$%04x %f to9_vreg_w: off=%i ($%04X) data=$%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), offset, 0xe7da + offset, data )); |
| 2277 | LOG_VIDEO(( "$%04x %f to9_vreg_w: off=%i ($%04X) data=$%02X\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), offset, 0xe7da + offset, data )); |
| 2292 | 2278 | |
| 2293 | 2279 | switch ( offset ) |
| 2294 | 2280 | { |
| r3854 | r3855 | |
| 2300 | 2286 | idx = to9_palette_idx / 2; |
| 2301 | 2287 | color = to9_palette_data[ 2 * idx + 1 ]; |
| 2302 | 2288 | color = to9_palette_data[ 2 * idx ] | (color << 8); |
| 2303 | | thom_set_palette( idx ^ 8, color & 0x1fff ); |
| 2289 | thom_set_palette( space->machine, idx ^ 8, color & 0x1fff ); |
| 2304 | 2290 | |
| 2305 | 2291 | to9_palette_idx = ( to9_palette_idx + 1 ) & 31; |
| 2306 | 2292 | } |
| r3854 | r3855 | |
| 2311 | 2297 | break; |
| 2312 | 2298 | |
| 2313 | 2299 | case 2: /* video mode */ |
| 2314 | | to9_set_video_mode( data, 0 ); |
| 2300 | to9_set_video_mode( space->machine, data, 0 ); |
| 2315 | 2301 | break; |
| 2316 | 2302 | |
| 2317 | 2303 | case 3: /* border color */ |
| 2318 | | thom_set_border_color( data & 15 ); |
| 2304 | thom_set_border_color( space->machine, data & 15 ); |
| 2319 | 2305 | break; |
| 2320 | 2306 | |
| 2321 | 2307 | default: |
| r3854 | r3855 | |
| 2329 | 2315 | { |
| 2330 | 2316 | to9_palette_idx = 0; |
| 2331 | 2317 | memset( to9_palette_data, 0, sizeof( to9_palette_data ) ); |
| 2332 | | state_save_register_global(machine, to9_palette_idx ); |
| 2333 | | state_save_register_global_array(machine, to9_palette_data ); |
| 2318 | state_save_register_global( machine, to9_palette_idx ); |
| 2319 | state_save_register_global_array( machine, to9_palette_data ); |
| 2334 | 2320 | } |
| 2335 | 2321 | |
| 2336 | 2322 | |
| r3854 | r3855 | |
| 2343 | 2329 | |
| 2344 | 2330 | static void to9_update_cart_bank(running_machine *machine) |
| 2345 | 2331 | { |
| 2332 | const address_space* space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 2346 | 2333 | static int old_bank = -1; |
| 2347 | 2334 | int bank = 0; |
| 2348 | | int slot = ( mc6846_get_output_port(machine) >> 4 ) & 3; /* bits 4-5: ROM bank */ |
| 2335 | int slot = ( mc6846_get_output_port(devtag_get_device(machine, MC6846, "mc6846")) >> 4 ) & 3; /* bits 4-5: ROM bank */ |
| 2349 | 2336 | |
| 2350 | 2337 | /* reset cartridge read handler */ |
| 2351 | | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x0003, 0, 0, (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) ); |
| 2338 | memory_install_read8_handler( space, 0x0000, 0x0003, 0, 0, (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) ); |
| 2352 | 2339 | |
| 2353 | 2340 | switch ( slot ) |
| 2354 | 2341 | { |
| r3854 | r3855 | |
| 2375 | 2362 | if ( thom_cart_nb_banks ) |
| 2376 | 2363 | { |
| 2377 | 2364 | bank = thom_cart_bank % thom_cart_nb_banks; |
| 2378 | | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x0003, 0, 0, to7_cartridge_r ); |
| 2365 | memory_install_read8_handler( space, 0x0000, 0x0003, 0, 0, to7_cartridge_r ); |
| 2379 | 2366 | } |
| 2380 | 2367 | if ( bank != old_bank ) |
| 2381 | 2368 | LOG_BANK(( "to9_update_cart_bank: CART is cartridge bank %i\n", thom_cart_bank )); |
| r3854 | r3855 | |
| 2398 | 2385 | /* write signal to 0000-1fff generates a bank switch */ |
| 2399 | 2386 | WRITE8_HANDLER ( to9_cartridge_w ) |
| 2400 | 2387 | { |
| 2401 | | int slot = ( mc6846_get_output_port(space->machine) >> 4 ) & 3; /* bits 4-5: ROM bank */ |
| 2388 | int slot = ( mc6846_get_output_port(devtag_get_device(space->machine, MC6846, "mc6846")) >> 4 ) & 3; /* bits 4-5: ROM bank */ |
| 2402 | 2389 | |
| 2403 | 2390 | if ( offset >= 0x2000 ) |
| 2404 | 2391 | return; |
| r3854 | r3855 | |
| 2426 | 2413 | |
| 2427 | 2414 | static void to9_update_ram_bank (running_machine *machine) |
| 2428 | 2415 | { |
| 2416 | const address_space* space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 2429 | 2417 | static int old_bank = -1; |
| 2430 | | UINT8 port = mc6846_get_output_port(machine); |
| 2418 | UINT8 port = mc6846_get_output_port(devtag_get_device(machine, MC6846, "mc6846")); |
| 2431 | 2419 | UINT8 portb = pia_get_port_b_z_mask( THOM_PIA_SYS ); |
| 2432 | 2420 | UINT8 disk = ((port >> 2) & 1) | ((port >> 5) & 2); /* bits 6,2: RAM bank */ |
| 2433 | 2421 | int bank; |
| r3854 | r3855 | |
| 2459 | 2447 | if ( mess_ram_size == 192*1024 || bank < 6 ) |
| 2460 | 2448 | { |
| 2461 | 2449 | memory_set_bank( machine, THOM_RAM_BANK, bank ); |
| 2462 | | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xdfff, 0, 0, (write8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) ); |
| 2450 | memory_install_write8_handler( space, 0xa000, 0xdfff, 0, 0, (write8_space_func)(STATIC_BANK1 + THOM_RAM_BANK - 1) ); |
| 2463 | 2451 | } |
| 2464 | 2452 | else |
| 2465 | 2453 | { |
| 2466 | | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xdfff, 0, 0, SMH_NOP ); |
| 2454 | memory_install_write8_handler( space, 0xa000, 0xdfff, 0, 0, SMH_NOP ); |
| 2467 | 2455 | } |
| 2468 | 2456 | |
| 2469 | 2457 | old_bank = bank; |
| r3854 | r3855 | |
| 2583 | 2571 | /* bit 7: interrupt */ |
| 2584 | 2572 | |
| 2585 | 2573 | LOG_KBD(( "$%04x %f to9_kbd_r: status $%02X (rdrf=%i, tdre=%i, ovrn=%i, pe=%i, irq=%i)\n", |
| 2586 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), to9_kbd_status, |
| 2574 | cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), to9_kbd_status, |
| 2587 | 2575 | (to9_kbd_status & ACIA_6850_RDRF) ? 1 : 0, |
| 2588 | 2576 | (to9_kbd_status & ACIA_6850_TDRE) ? 1 : 0, |
| 2589 | 2577 | (to9_kbd_status & ACIA_6850_OVRN) ? 1 : 0, |
| r3854 | r3855 | |
| 2598 | 2586 | else |
| 2599 | 2587 | to9_kbd_status &= ~(ACIA_6850_OVRN | ACIA_6850_RDRF); |
| 2600 | 2588 | to9_kbd_overrun = 0; |
| 2601 | | LOG_KBD(( "$%04x %f to9_kbd_r: read data $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), to9_kbd_in )); |
| 2589 | LOG_KBD(( "$%04x %f to9_kbd_r: read data $%02X\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), to9_kbd_in )); |
| 2602 | 2590 | to9_kbd_update_irq(space->machine); |
| 2603 | 2591 | return to9_kbd_in; |
| 2604 | 2592 | |
| 2605 | 2593 | default: |
| 2606 | | logerror( "$%04x to9_kbd_r: invalid offset %i\n", cpu_get_previouspc(space->cpu), offset ); |
| 2594 | logerror( "$%04x to9_kbd_r: invalid offset %i\n", cpu_get_previouspc( space->machine->cpu[0] ), offset ); |
| 2607 | 2595 | return 0; |
| 2608 | 2596 | } |
| 2609 | 2597 | } |
| r3854 | r3855 | |
| 2625 | 2613 | to9_kbd_overrun = 0; |
| 2626 | 2614 | to9_kbd_status = ACIA_6850_TDRE; |
| 2627 | 2615 | to9_kbd_intr = 0; |
| 2628 | | LOG_KBD(( "$%04x %f to9_kbd_w: reset (data=$%02X)\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data )); |
| 2616 | LOG_KBD(( "$%04x %f to9_kbd_w: reset (data=$%02X)\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data )); |
| 2629 | 2617 | } |
| 2630 | 2618 | else |
| 2631 | 2619 | { |
| r3854 | r3855 | |
| 2639 | 2627 | to9_kbd_intr = data >> 5; |
| 2640 | 2628 | |
| 2641 | 2629 | LOG_KBD(( "$%04x %f to9_kbd_w: set control to $%02X (parity=%i, intr in=%i out=%i)\n", |
| 2642 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), |
| 2630 | cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), |
| 2643 | 2631 | data, to9_kbd_parity, to9_kbd_intr >> 2, |
| 2644 | 2632 | (to9_kbd_intr & 3) ? 1 : 0 )); |
| 2645 | 2633 | } |
| r3854 | r3855 | |
| 2670 | 2658 | case 0xFE: to9_kbd_periph = 0; break; |
| 2671 | 2659 | |
| 2672 | 2660 | default: |
| 2673 | | logerror( "$%04x %f to9_kbd_w: unknown kbd command %02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data ); |
| 2661 | logerror( "$%04x %f to9_kbd_w: unknown kbd command %02X\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data ); |
| 2674 | 2662 | } |
| 2675 | 2663 | |
| 2676 | | thom_set_caps_led( ! to9_kbd_caps ); |
| 2664 | thom_set_caps_led( space->machine, !to9_kbd_caps ); |
| 2677 | 2665 | |
| 2678 | 2666 | LOG(( "$%04x %f to9_kbd_w: kbd command %02X (caps=%i, pad=%i, periph=%i)\n", |
| 2679 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data, |
| 2667 | cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data, |
| 2680 | 2668 | to9_kbd_caps, to9_kbd_pad, to9_kbd_periph )); |
| 2681 | 2669 | |
| 2682 | 2670 | break; |
| 2683 | 2671 | |
| 2684 | 2672 | default: |
| 2685 | | logerror( "$%04x to9_kbd_w: invalid offset %i (data=$%02X) \n", cpu_get_previouspc(space->cpu), offset, data ); |
| 2673 | logerror( "$%04x to9_kbd_w: invalid offset %i (data=$%02X) \n", cpu_get_previouspc( space->machine->cpu[0] ), offset, data ); |
| 2686 | 2674 | } |
| 2687 | 2675 | } |
| 2688 | 2676 | |
| r3854 | r3855 | |
| 2756 | 2744 | |
| 2757 | 2745 | |
| 2758 | 2746 | /* returns the ASCII code for the key, or 0 for no key */ |
| 2759 | | static int to9_kbd_get_key( void ) |
| 2747 | static int to9_kbd_get_key( running_machine *machine ) |
| 2760 | 2748 | { |
| 2761 | | int control = ! (input_port_read(Machine, "keyboard_7") & 1); |
| 2762 | | int shift = ! (input_port_read(Machine, "keyboard_9") & 1); |
| 2749 | int control = ! (input_port_read(machine, "keyboard_7") & 1); |
| 2750 | int shift = ! (input_port_read(machine, "keyboard_9") & 1); |
| 2763 | 2751 | int key = -1, line, bit; |
| 2764 | 2752 | UINT8 port; |
| 2765 | 2753 | static const char *const keynames[] = { "keyboard_0", "keyboard_1", "keyboard_2", "keyboard_3", "keyboard_4", |
| r3854 | r3855 | |
| 2767 | 2755 | |
| 2768 | 2756 | for ( line = 0; line < 10; line++ ) |
| 2769 | 2757 | { |
| 2770 | | port = input_port_read(Machine, keynames[line]); |
| 2758 | port = input_port_read(machine, keynames[line]); |
| 2771 | 2759 | |
| 2772 | 2760 | if ( line == 7 || line == 9 ) |
| 2773 | 2761 | port |= 1; /* shift & control */ |
| r3854 | r3855 | |
| 2796 | 2784 | |
| 2797 | 2785 | to9_kbd_last_key = key; |
| 2798 | 2786 | to9_kbd_caps = !to9_kbd_caps; |
| 2799 | | thom_set_caps_led( ! to9_kbd_caps ); |
| 2787 | thom_set_caps_led( machine, !to9_kbd_caps ); |
| 2800 | 2788 | return 0; |
| 2801 | 2789 | } |
| 2802 | 2790 | else |
| r3854 | r3855 | |
| 2853 | 2841 | { |
| 2854 | 2842 | |
| 2855 | 2843 | case 0: /* key */ |
| 2856 | | to9_kbd_send( machine, to9_kbd_get_key(), 0 ); |
| 2844 | to9_kbd_send( machine, to9_kbd_get_key(machine), 0 ); |
| 2857 | 2845 | break; |
| 2858 | 2846 | |
| 2859 | 2847 | case 1: /* x axis */ |
| r3854 | r3855 | |
| 2891 | 2879 | } |
| 2892 | 2880 | else |
| 2893 | 2881 | { |
| 2894 | | int key = to9_kbd_get_key(); |
| 2882 | int key = to9_kbd_get_key(machine); |
| 2895 | 2883 | /* keyboard mode: send a byte only if a key is down */ |
| 2896 | 2884 | if ( key ) |
| 2897 | 2885 | to9_kbd_send( machine, key, 0 ); |
| r3854 | r3855 | |
| 2911 | 2899 | to9_kbd_periph = 0; |
| 2912 | 2900 | to9_kbd_pad = 0; |
| 2913 | 2901 | to9_kbd_byte_count = 0; |
| 2914 | | thom_set_caps_led( ! to9_kbd_caps ); |
| 2902 | thom_set_caps_led( machine, !to9_kbd_caps ); |
| 2915 | 2903 | to9_kbd_key_count = 0; |
| 2916 | 2904 | to9_kbd_last_key = 0xff; |
| 2917 | 2905 | to9_kbd_update_irq(machine); |
| r3854 | r3855 | |
| 2923 | 2911 | static void to9_kbd_init ( running_machine *machine ) |
| 2924 | 2912 | { |
| 2925 | 2913 | LOG(( "to9_kbd_init called\n" )); |
| 2926 | | to9_kbd_timer = timer_alloc(machine, to9_kbd_timer_cb , NULL); |
| 2927 | | state_save_register_global(machine, to9_kbd_parity ); |
| 2928 | | state_save_register_global(machine, to9_kbd_intr ); |
| 2929 | | state_save_register_global(machine, to9_kbd_in ); |
| 2930 | | state_save_register_global(machine, to9_kbd_status ); |
| 2931 | | state_save_register_global(machine, to9_kbd_overrun ); |
| 2932 | | state_save_register_global(machine, to9_kbd_last_key ); |
| 2933 | | state_save_register_global(machine, to9_kbd_key_count ); |
| 2934 | | state_save_register_global(machine, to9_kbd_caps ); |
| 2935 | | state_save_register_global(machine, to9_kbd_periph ); |
| 2936 | | state_save_register_global(machine, to9_kbd_pad ); |
| 2937 | | state_save_register_global(machine, to9_kbd_byte_count ); |
| 2938 | | state_save_register_global(machine, to9_mouse_x ); |
| 2939 | | state_save_register_global(machine, to9_mouse_y ); |
| 2914 | to9_kbd_timer = timer_alloc( machine, to9_kbd_timer_cb , NULL); |
| 2915 | state_save_register_global( machine, to9_kbd_parity ); |
| 2916 | state_save_register_global( machine, to9_kbd_intr ); |
| 2917 | state_save_register_global( machine, to9_kbd_in ); |
| 2918 | state_save_register_global( machine, to9_kbd_status ); |
| 2919 | state_save_register_global( machine, to9_kbd_overrun ); |
| 2920 | state_save_register_global( machine, to9_kbd_last_key ); |
| 2921 | state_save_register_global( machine, to9_kbd_key_count ); |
| 2922 | state_save_register_global( machine, to9_kbd_caps ); |
| 2923 | state_save_register_global( machine, to9_kbd_periph ); |
| 2924 | state_save_register_global( machine, to9_kbd_pad ); |
| 2925 | state_save_register_global( machine, to9_kbd_byte_count ); |
| 2926 | state_save_register_global( machine, to9_mouse_x ); |
| 2927 | state_save_register_global( machine, to9_mouse_y ); |
| 2940 | 2928 | } |
| 2941 | 2929 | |
| 2942 | 2930 | |
| r3854 | r3855 | |
| 2954 | 2942 | centronics_write_data( 0, data ); |
| 2955 | 2943 | centronics_write_handshake( 0, (b & 2) ? CENTRONICS_STROBE : 0, CENTRONICS_STROBE ); |
| 2956 | 2944 | |
| 2957 | | // LOG_IO(( "$%04x %f to9_update_centronics: data=$%02X strobe=%i\n", |
| 2958 | | // cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data, |
| 2959 | | // (b & 2) ? 1 : 0 )); |
| 2945 | LOG_IO(( "$%04x %f to9_update_centronics: data=$%02X strobe=%i\n", |
| 2946 | cpu_get_previouspc( machine->cpu[0] ), attotime_to_double(timer_get_time(machine)), data, |
| 2947 | (b & 2) ? 1 : 0 )); |
| 2960 | 2948 | } |
| 2961 | 2949 | |
| 2962 | 2950 | |
| r3854 | r3855 | |
| 3007 | 2995 | |
| 3008 | 2996 | |
| 3009 | 2997 | |
| 3010 | | static WRITE8_HANDLER ( to9_timer_port_out ) |
| 2998 | static WRITE8_DEVICE_HANDLER ( to9_timer_port_out ) |
| 3011 | 2999 | { |
| 3012 | | thom_set_mode_point( space->machine, data & 1 ); /* bit 0: video bank */ |
| 3013 | | to9_update_ram_bank(space->machine); |
| 3014 | | to9_update_cart_bank(space->machine); |
| 3000 | thom_set_mode_point( device->machine, data & 1 ); /* bit 0: video bank */ |
| 3001 | to9_update_ram_bank( device->machine ); |
| 3002 | to9_update_cart_bank( device->machine ); |
| 3015 | 3003 | } |
| 3016 | 3004 | |
| 3017 | 3005 | |
| 3018 | 3006 | |
| 3019 | | static const mc6846_interface to9_timer = |
| 3007 | mc6846_interface to9_timer = |
| 3020 | 3008 | { |
| 3021 | 3009 | to9_timer_port_out, NULL, to7_timer_cp2_out, |
| 3022 | 3010 | to7_timer_port_in, to7_timer_tco_out, |
| 3023 | | thom_irq_0 |
| 3011 | thom_dev_irq_0 |
| 3024 | 3012 | }; |
| 3025 | 3013 | |
| 3026 | 3014 | |
| r3854 | r3855 | |
| 3037 | 3025 | thom_irq_reset(machine); |
| 3038 | 3026 | pia_reset(); |
| 3039 | 3027 | pia_set_port_a_z_mask( THOM_PIA_SYS, 0xfe ); |
| 3040 | | mc6846_reset(); |
| 3041 | | to7_game_reset(); |
| 3028 | to7_game_reset(machine); |
| 3042 | 3029 | to9_floppy_reset(machine); |
| 3043 | 3030 | to9_kbd_reset(machine); |
| 3044 | | thom_centronics_reset(); |
| 3045 | | to7_modem_reset(); |
| 3046 | | to7_midi_reset(); |
| 3047 | | to7_rf57932_reset(); |
| 3048 | | mea8000_reset(machine); |
| 3031 | thom_centronics_reset(machine); |
| 3032 | to7_modem_reset(machine); |
| 3033 | to7_midi_reset(machine); |
| 3049 | 3034 | |
| 3050 | 3035 | /* video */ |
| 3051 | | thom_set_video_mode( THOM_VMODE_TO9 ); |
| 3052 | | thom_set_lightpen_callback(machine, 3, to7_lightpen_cb ); |
| 3053 | | thom_set_border_color( 8 ); |
| 3036 | thom_set_video_mode( machine, THOM_VMODE_TO9 ); |
| 3037 | thom_set_lightpen_callback( machine, 3, to7_lightpen_cb ); |
| 3038 | thom_set_border_color( machine, 8 ); |
| 3054 | 3039 | thom_set_mode_point( machine, 0 ); |
| 3055 | 3040 | pia_set_input_cb1( THOM_PIA_SYS, 0 ); |
| 3056 | 3041 | |
| r3854 | r3855 | |
| 3076 | 3061 | thom_irq_init(machine); |
| 3077 | 3062 | pia_config( THOM_PIA_SYS, &to9_sys ); |
| 3078 | 3063 | centronics_config( 0, &to9_centronics ); |
| 3079 | | mc6846_config( machine, &to9_timer ); |
| 3080 | 3064 | to7_game_init(machine); |
| 3081 | 3065 | to9_floppy_init( machine, mem + 0xe000, mem + 0x40000 ); |
| 3082 | 3066 | to9_kbd_init(machine); |
| 3083 | 3067 | to9_palette_init(machine); |
| 3084 | 3068 | to7_modem_init(machine); |
| 3085 | | to7_midi_init(); |
| 3086 | | mea8000_config( machine, THOM_SOUND_SPEECH, NULL ); |
| 3069 | to7_midi_init(machine); |
| 3087 | 3070 | |
| 3088 | 3071 | /* memory */ |
| 3089 | 3072 | thom_vram = mess_ram; |
| r3854 | r3855 | |
| 3098 | 3081 | memory_set_bank( machine, THOM_RAM_BANK, 0 ); |
| 3099 | 3082 | |
| 3100 | 3083 | /* save-state */ |
| 3101 | | state_save_register_global(machine, thom_cart_nb_banks ); |
| 3102 | | state_save_register_global(machine, thom_cart_bank ); |
| 3103 | | state_save_register_global(machine, to7_lightpen ); |
| 3104 | | state_save_register_global(machine, to7_lightpen_step ); |
| 3105 | | state_save_register_global(machine, to9_soft_bank ); |
| 3106 | | state_save_register_global_pointer(machine, (mem + 0x10000), 0x10000 ); |
| 3107 | | state_save_register_postload(machine, to9_update_ram_bank_postload, NULL ); |
| 3108 | | state_save_register_postload(machine, to9_update_cart_bank_postload, NULL ); |
| 3084 | state_save_register_global( machine, thom_cart_nb_banks ); |
| 3085 | state_save_register_global( machine, thom_cart_bank ); |
| 3086 | state_save_register_global( machine, to7_lightpen ); |
| 3087 | state_save_register_global( machine, to7_lightpen_step ); |
| 3088 | state_save_register_global( machine, to9_soft_bank ); |
| 3089 | state_save_register_global_pointer( machine, (mem + 0x10000), 0x10000 ); |
| 3090 | state_save_register_postload( machine, to9_update_ram_bank_postload, NULL ); |
| 3091 | state_save_register_postload( machine, to9_update_cart_bank_postload, NULL ); |
| 3109 | 3092 | } |
| 3110 | 3093 | |
| 3111 | 3094 | |
| r3854 | r3855 | |
| 3240 | 3223 | to8_kbd_caps = !to8_kbd_caps; |
| 3241 | 3224 | if ( to8_kbd_caps ) |
| 3242 | 3225 | key |= 0x080; /* auto-shift */ |
| 3243 | | thom_set_caps_led( ! to8_kbd_caps ); |
| 3226 | thom_set_caps_led( machine, !to8_kbd_caps ); |
| 3244 | 3227 | return key; |
| 3245 | 3228 | } |
| 3246 | 3229 | else if ( key == to8_kbd_last_key ) |
| r3854 | r3855 | |
| 3283 | 3266 | (helps avoiding CPU lock) |
| 3284 | 3267 | */ |
| 3285 | 3268 | if ( ! to8_kbd_ack ) |
| 3286 | | mc6846_set_input_cp1( machine, 0 ); |
| 3287 | | mc6846_set_input_cp1( machine, 1 ); |
| 3269 | mc6846_set_input_cp1( devtag_get_device(machine, MC6846, "mc6846"), 0 ); |
| 3270 | mc6846_set_input_cp1( devtag_get_device(machine, MC6846, "mc6846"), 1 ); |
| 3288 | 3271 | |
| 3289 | 3272 | if ( k == -1 ) |
| 3290 | 3273 | d = TO8_KBD_POLL_PERIOD; |
| r3854 | r3855 | |
| 3303 | 3286 | to8_kbd_last_key = 0xff; |
| 3304 | 3287 | to8_kbd_key_count = 0; |
| 3305 | 3288 | to8_kbd_step = 0; |
| 3306 | | mc6846_set_input_cp1( machine, 1 ); |
| 3289 | mc6846_set_input_cp1( devtag_get_device(machine, MC6846, "mc6846"), 1 ); |
| 3307 | 3290 | d = TO8_KBD_POLL_PERIOD; |
| 3308 | 3291 | } |
| 3309 | 3292 | else if ( to8_kbd_step == 1 ) |
| 3310 | 3293 | { |
| 3311 | 3294 | /* schedule timeout waiting for ack to go down */ |
| 3312 | | mc6846_set_input_cp1( machine, 0 ); |
| 3295 | mc6846_set_input_cp1( devtag_get_device(machine, MC6846, "mc6846"), 0 ); |
| 3313 | 3296 | to8_kbd_step = 255; |
| 3314 | 3297 | d = TO8_KBD_TIMEOUT; |
| 3315 | 3298 | } |
| 3316 | 3299 | else if ( to8_kbd_step == 117 ) |
| 3317 | 3300 | { |
| 3318 | 3301 | /* schedule timeout waiting for ack to go up */ |
| 3319 | | mc6846_set_input_cp1( machine, 0 ); |
| 3302 | mc6846_set_input_cp1( devtag_get_device(machine, MC6846, "mc6846"), 0 ); |
| 3320 | 3303 | to8_kbd_step = 255; |
| 3321 | 3304 | d = TO8_KBD_TIMEOUT; |
| 3322 | 3305 | } |
| 3323 | 3306 | else if ( to8_kbd_step & 1 ) |
| 3324 | 3307 | { |
| 3325 | 3308 | /* send silence between bits */ |
| 3326 | | mc6846_set_input_cp1( machine, 0 ); |
| 3309 | mc6846_set_input_cp1( devtag_get_device(machine, MC6846, "mc6846"), 0 ); |
| 3327 | 3310 | d = ATTOTIME_IN_USEC( 100 ); |
| 3328 | 3311 | to8_kbd_step++; |
| 3329 | 3312 | } |
| r3854 | r3855 | |
| 3332 | 3315 | /* send bit */ |
| 3333 | 3316 | int bpos = 8 - ( (to8_kbd_step - 100) / 2); |
| 3334 | 3317 | int bit = (to8_kbd_data >> bpos) & 1; |
| 3335 | | mc6846_set_input_cp1( machine, 1 ); |
| 3318 | mc6846_set_input_cp1( devtag_get_device(machine, MC6846, "mc6846"), 1 ); |
| 3336 | 3319 | d = ATTOTIME_IN_USEC( bit ? 56 : 38 ); |
| 3337 | 3320 | to8_kbd_step++; |
| 3338 | 3321 | } |
| r3854 | r3855 | |
| 3388 | 3371 | to8_kbd_caps = 0; |
| 3389 | 3372 | } |
| 3390 | 3373 | } |
| 3391 | | thom_set_caps_led( ! to8_kbd_caps ); |
| 3374 | thom_set_caps_led( machine, !to8_kbd_caps ); |
| 3392 | 3375 | } |
| 3393 | 3376 | else |
| 3394 | 3377 | { |
| r3854 | r3855 | |
| 3428 | 3411 | to8_kbd_data = 0; |
| 3429 | 3412 | to8_kbd_ack = 1; |
| 3430 | 3413 | to8_kbd_caps = 1; |
| 3431 | | thom_set_caps_led( ! to8_kbd_caps ); |
| 3414 | thom_set_caps_led( machine, !to8_kbd_caps ); |
| 3432 | 3415 | to8_kbd_timer_func(machine); |
| 3433 | 3416 | } |
| 3434 | 3417 | |
| r3854 | r3855 | |
| 3436 | 3419 | |
| 3437 | 3420 | static void to8_kbd_init ( running_machine *machine ) |
| 3438 | 3421 | { |
| 3439 | | to8_kbd_timer = timer_alloc(machine, to8_kbd_timer_cb , NULL); |
| 3440 | | to8_kbd_signal = timer_alloc(machine, NULL , NULL); |
| 3441 | | state_save_register_global(machine, to8_kbd_ack ); |
| 3442 | | state_save_register_global(machine, to8_kbd_data ); |
| 3443 | | state_save_register_global(machine, to8_kbd_step ); |
| 3444 | | state_save_register_global(machine, to8_kbd_last_key ); |
| 3445 | | state_save_register_global(machine, to8_kbd_key_count ); |
| 3446 | | state_save_register_global(machine, to8_kbd_caps ); |
| 3422 | to8_kbd_timer = timer_alloc( machine, to8_kbd_timer_cb , NULL); |
| 3423 | to8_kbd_signal = timer_alloc( machine, NULL , NULL); |
| 3424 | state_save_register_global( machine, to8_kbd_ack ); |
| 3425 | state_save_register_global( machine, to8_kbd_data ); |
| 3426 | state_save_register_global( machine, to8_kbd_step ); |
| 3427 | state_save_register_global( machine, to8_kbd_last_key ); |
| 3428 | state_save_register_global( machine, to8_kbd_key_count ); |
| 3429 | state_save_register_global( machine, to8_kbd_caps ); |
| 3447 | 3430 | } |
| 3448 | 3431 | |
| 3449 | 3432 | |
| r3854 | r3855 | |
| 3461 | 3444 | |
| 3462 | 3445 | |
| 3463 | 3446 | |
| 3464 | | static void to8_update_floppy_bank(running_machine *machine) |
| 3447 | static void to8_update_floppy_bank( running_machine *machine ) |
| 3465 | 3448 | { |
| 3466 | 3449 | static int old_bank = -1; |
| 3467 | 3450 | int bank = (to8_reg_sys1 & 0x80) ? to7_floppy_bank : (to8_bios_bank + TO7_NB_FLOP_BANK); |
| r3854 | r3855 | |
| 3485 | 3468 | |
| 3486 | 3469 | static void to8_update_ram_bank (running_machine *machine) |
| 3487 | 3470 | { |
| 3471 | const address_space* space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 3488 | 3472 | UINT8 bank = 0; |
| 3489 | 3473 | |
| 3490 | 3474 | if ( to8_reg_sys1 & 0x10 ) |
| r3854 | r3855 | |
| 3527 | 3511 | { |
| 3528 | 3512 | memory_set_bank( machine, TO8_DATA_LO, to8_data_vpage ); |
| 3529 | 3513 | memory_set_bank( machine, TO8_DATA_HI, to8_data_vpage ); |
| 3530 | | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xbfff, 0, 0, to8_data_vpage <= 4 ? to8_data_lo_w : (write8_space_func)(STATIC_BANK1 + TO8_DATA_LO - 1) ); |
| 3531 | | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xc000, 0xdfff, 0, 0, to8_data_vpage <= 4 ? to8_data_hi_w : (write8_space_func)(STATIC_BANK1 + TO8_DATA_HI - 1) ); |
| 3514 | memory_install_write8_handler( space, 0xa000, 0xbfff, 0, 0, to8_data_vpage <= 4 ? to8_data_lo_w : (write8_space_func)(STATIC_BANK1 + TO8_DATA_LO - 1) ); |
| 3515 | memory_install_write8_handler( space, 0xc000, 0xdfff, 0, 0, to8_data_vpage <= 4 ? to8_data_hi_w : (write8_space_func)(STATIC_BANK1 + TO8_DATA_HI - 1) ); |
| 3532 | 3516 | } |
| 3533 | 3517 | else |
| 3534 | 3518 | { |
| 3535 | | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xa000, 0xbfff, 0, 0, SMH_NOP ); |
| 3536 | | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xc000, 0xdfff, 0, 0, SMH_NOP ); |
| 3519 | memory_install_write8_handler( space, 0xa000, 0xbfff, 0, 0, SMH_NOP ); |
| 3520 | memory_install_write8_handler( space, 0xc000, 0xdfff, 0, 0, SMH_NOP ); |
| 3537 | 3521 | } |
| 3538 | 3522 | } |
| 3539 | 3523 | |
| r3854 | r3855 | |
| 3548 | 3532 | |
| 3549 | 3533 | static void to8_update_cart_bank (running_machine *machine) |
| 3550 | 3534 | { |
| 3535 | const address_space* space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 3551 | 3536 | static int old_bank = -1; |
| 3552 | 3537 | int bank = 0; |
| 3553 | 3538 | |
| 3554 | 3539 | /* reset bank switch */ |
| 3555 | | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x0003, 0, 0, (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) ); |
| 3540 | memory_install_read8_handler( space, 0x0000, 0x0003, 0, 0, (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) ); |
| 3556 | 3541 | |
| 3557 | 3542 | if ( to8_reg_cart & 0x20 ) |
| 3558 | 3543 | { |
| 3559 | 3544 | /* RAM space */ |
| 3560 | 3545 | to8_cart_vpage = to8_reg_cart & 31; |
| 3561 | 3546 | bank = 8 + to8_cart_vpage; |
| 3562 | | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x3fff, 0, 0, |
| 3547 | memory_install_write8_handler( space, 0x0000, 0x3fff, 0, 0, |
| 3563 | 3548 | ((to8_cart_vpage < 8 || mess_ram_size == 512*1024) && (to8_reg_cart & 0x40)) ? |
| 3564 | 3549 | (to8_cart_vpage <= 4) ? to8_vcart_w : |
| 3565 | 3550 | (write8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) : |
| r3854 | r3855 | |
| 3569 | 3554 | } |
| 3570 | 3555 | else |
| 3571 | 3556 | { |
| 3572 | | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x3fff, 0, 0, to8_cartridge_w ); |
| 3557 | memory_install_write8_handler( space, 0x0000, 0x3fff, 0, 0, to8_cartridge_w ); |
| 3573 | 3558 | if ( to8_soft_select ) |
| 3574 | 3559 | { |
| 3575 | 3560 | /* internal software ROM space */ |
| r3854 | r3855 | |
| 3584 | 3569 | if ( thom_cart_nb_banks ) |
| 3585 | 3570 | { |
| 3586 | 3571 | bank = thom_cart_bank % thom_cart_nb_banks; |
| 3587 | | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0x0000, 0x0003, 0, 0, to8_cartridge_r ); |
| 3572 | memory_install_read8_handler( space, 0x0000, 0x0003, 0, 0, to8_cartridge_r ); |
| 3588 | 3573 | |
| 3589 | 3574 | } |
| 3590 | 3575 | |
| r3854 | r3855 | |
| 3697 | 3682 | |
| 3698 | 3683 | READ8_HANDLER ( to8_gatearray_r ) |
| 3699 | 3684 | { |
| 3700 | | struct thom_vsignal v = thom_get_vsignal(); |
| 3685 | struct thom_vsignal v = thom_get_vsignal( space->machine ); |
| 3701 | 3686 | struct thom_vsignal l = thom_get_lightpen_vsignal( space->machine, TO8_LIGHTPEN_DECAL, to7_lightpen_step - 1, 6 ); |
| 3702 | 3687 | int count, inil, init, lt3; |
| 3703 | 3688 | UINT8 res; |
| r3854 | r3855 | |
| 3739 | 3724 | break; |
| 3740 | 3725 | |
| 3741 | 3726 | default: |
| 3742 | | logerror( "$%04x to8_gatearray_r: invalid offset %i\n", cpu_get_previouspc(space->cpu), offset ); |
| 3727 | logerror( "$%04x to8_gatearray_r: invalid offset %i\n", cpu_get_previouspc( space->machine->cpu[0] ), offset ); |
| 3743 | 3728 | res = 0; |
| 3744 | 3729 | } |
| 3745 | 3730 | |
| 3746 | 3731 | LOG_VIDEO(( "$%04x %f to8_gatearray_r: off=%i ($%04X) res=$%02X lightpen=%i\n", |
| 3747 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), |
| 3732 | cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), |
| 3748 | 3733 | offset, 0xe7e4 + offset, res, to7_lightpen )); |
| 3749 | 3734 | |
| 3750 | 3735 | return res; |
| r3854 | r3855 | |
| 3755 | 3740 | WRITE8_HANDLER ( to8_gatearray_w ) |
| 3756 | 3741 | { |
| 3757 | 3742 | LOG_VIDEO(( "$%04x %f to8_gatearray_w: off=%i ($%04X) data=$%02X\n", |
| 3758 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), |
| 3743 | cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), |
| 3759 | 3744 | offset, 0xe7e4 + offset, data )); |
| 3760 | 3745 | |
| 3761 | 3746 | switch ( offset ) |
| r3854 | r3855 | |
| 3787 | 3772 | |
| 3788 | 3773 | default: |
| 3789 | 3774 | logerror( "$%04x to8_gatearray_w: invalid offset %i (data=$%02X)\n", |
| 3790 | | cpu_get_previouspc(space->cpu), offset, data ); |
| 3775 | cpu_get_previouspc( space->machine->cpu[0] ), offset, data ); |
| 3791 | 3776 | } |
| 3792 | 3777 | } |
| 3793 | 3778 | |
| r3854 | r3855 | |
| 3836 | 3821 | WRITE8_HANDLER ( to8_vreg_w ) |
| 3837 | 3822 | { |
| 3838 | 3823 | LOG_VIDEO(( "$%04x %f to8_vreg_w: off=%i ($%04X) data=$%02X\n", |
| 3839 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), |
| 3824 | cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), |
| 3840 | 3825 | offset, 0xe7da + offset, data )); |
| 3841 | 3826 | |
| 3842 | 3827 | switch ( offset ) |
| r3854 | r3855 | |
| 3849 | 3834 | idx = to9_palette_idx / 2; |
| 3850 | 3835 | color = to9_palette_data[ 2 * idx + 1 ]; |
| 3851 | 3836 | color = to9_palette_data[ 2 * idx ] | (color << 8); |
| 3852 | | thom_set_palette( idx, color & 0x1fff ); |
| 3837 | thom_set_palette( space->machine, idx, color & 0x1fff ); |
| 3853 | 3838 | to9_palette_idx = ( to9_palette_idx + 1 ) & 31; |
| 3854 | 3839 | } |
| 3855 | 3840 | break; |
| r3854 | r3855 | |
| 3859 | 3844 | break; |
| 3860 | 3845 | |
| 3861 | 3846 | case 2: /* display register */ |
| 3862 | | to9_set_video_mode( data, 1 ); |
| 3847 | to9_set_video_mode( space->machine, data, 1 ); |
| 3863 | 3848 | break; |
| 3864 | 3849 | |
| 3865 | 3850 | case 3: /* system register 2 */ |
| r3854 | r3855 | |
| 3872 | 3857 | else |
| 3873 | 3858 | { |
| 3874 | 3859 | to8_reg_sys2 = data; |
| 3875 | | thom_set_video_page( data >> 6 ); |
| 3876 | | thom_set_border_color( data & 15 ); |
| 3860 | thom_set_video_page( space->machine, data >> 6 ); |
| 3861 | thom_set_border_color( space->machine, data & 15 ); |
| 3877 | 3862 | } |
| 3878 | 3863 | break; |
| 3879 | 3864 | |
| r3854 | r3855 | |
| 3892 | 3877 | { |
| 3893 | 3878 | int ktest = to8_kbd_ktest (space->machine); |
| 3894 | 3879 | |
| 3895 | | LOG_KBD(( "$%04x %f: to8_sys_porta_in ktest=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), ktest )); |
| 3880 | LOG_KBD(( "$%04x %f: to8_sys_porta_in ktest=%i\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), ktest )); |
| 3896 | 3881 | |
| 3897 | 3882 | return ktest; |
| 3898 | 3883 | } |
| r3854 | r3855 | |
| 3924 | 3909 | |
| 3925 | 3910 | |
| 3926 | 3911 | |
| 3927 | | static READ8_HANDLER ( to8_timer_port_in ) |
| 3912 | static READ8_DEVICE_HANDLER ( to8_timer_port_in ) |
| 3928 | 3913 | { |
| 3929 | | int lightpen = (input_port_read(space->machine, "lightpen_button") & 1) ? 2 : 0; |
| 3930 | | int cass = to7_get_cassette(space->machine) ? 0x80 : 0; |
| 3914 | int lightpen = (input_port_read(device->machine, "lightpen_button") & 1) ? 2 : 0; |
| 3915 | int cass = to7_get_cassette(device->machine) ? 0x80 : 0; |
| 3931 | 3916 | int dtr = (centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY) ? 0 : 0x40; |
| 3932 | 3917 | int lock = to8_kbd_caps ? 0 : 8; /* undocumented! */ |
| 3933 | 3918 | return lightpen | cass | dtr | lock; |
| r3854 | r3855 | |
| 3935 | 3920 | |
| 3936 | 3921 | |
| 3937 | 3922 | |
| 3938 | | static WRITE8_HANDLER ( to8_timer_port_out ) |
| 3923 | static WRITE8_DEVICE_HANDLER ( to8_timer_port_out ) |
| 3939 | 3924 | { |
| 3940 | 3925 | int ack = (data & 0x20) ? 1 : 0; /* bit 5: keyboard ACK */ |
| 3941 | 3926 | to8_bios_bank = (data & 0x10) ? 1 : 0; /* bit 4: BIOS bank*/ |
| 3942 | | thom_set_mode_point( space->machine, data & 1 ); /* bit 0: video bank switch */ |
| 3943 | | memory_set_bank( space->machine, TO8_BIOS_BANK, to8_bios_bank ); |
| 3927 | thom_set_mode_point( device->machine, data & 1 ); /* bit 0: video bank switch */ |
| 3928 | memory_set_bank( device->machine, TO8_BIOS_BANK, to8_bios_bank ); |
| 3944 | 3929 | to8_soft_select = (data & 0x04) ? 1 : 0; /* bit 2: internal ROM select */ |
| 3945 | | to8_update_floppy_bank(space->machine); |
| 3946 | | to8_update_cart_bank(space->machine); |
| 3947 | | to8_kbd_set_ack( space->machine, ack ); |
| 3930 | to8_update_floppy_bank(device->machine); |
| 3931 | to8_update_cart_bank(device->machine); |
| 3932 | to8_kbd_set_ack(device->machine, ack); |
| 3948 | 3933 | } |
| 3949 | 3934 | |
| 3950 | 3935 | |
| 3951 | 3936 | |
| 3952 | | static WRITE8_HANDLER ( to8_timer_cp2_out ) |
| 3937 | static WRITE8_DEVICE_HANDLER ( to8_timer_cp2_out ) |
| 3953 | 3938 | { |
| 3954 | 3939 | /* mute */ |
| 3955 | 3940 | to7_game_mute = data; |
| 3956 | | to7_game_sound_update(); |
| 3941 | to7_game_sound_update(device->machine); |
| 3957 | 3942 | } |
| 3958 | 3943 | |
| 3959 | 3944 | |
| 3960 | 3945 | |
| 3961 | | static const mc6846_interface to8_timer = |
| 3946 | mc6846_interface to8_timer = |
| 3962 | 3947 | { |
| 3963 | 3948 | to8_timer_port_out, NULL, to8_timer_cp2_out, |
| 3964 | 3949 | to8_timer_port_in, to7_timer_tco_out, |
| 3965 | | thom_irq_0 |
| 3950 | thom_dev_irq_0 |
| 3966 | 3951 | }; |
| 3967 | 3952 | |
| 3968 | 3953 | |
| r3854 | r3855 | |
| 3996 | 3981 | thom_irq_reset(machine); |
| 3997 | 3982 | pia_reset(); |
| 3998 | 3983 | pia_set_port_a_z_mask( THOM_PIA_SYS, 0xfe ); |
| 3999 | | mc6846_reset(); |
| 4000 | | to7_game_reset(); |
| 3984 | to7_game_reset(machine); |
| 4001 | 3985 | to8_floppy_reset(machine); |
| 4002 | 3986 | to8_kbd_reset(machine); |
| 4003 | | thom_centronics_reset(); |
| 4004 | | to7_modem_reset(); |
| 4005 | | to7_midi_reset(); |
| 4006 | | to7_rf57932_reset(); |
| 4007 | | mea8000_reset(machine); |
| 3987 | thom_centronics_reset(machine); |
| 3988 | to7_modem_reset(machine); |
| 3989 | to7_midi_reset(machine); |
| 4008 | 3990 | |
| 4009 | 3991 | /* gate-array */ |
| 4010 | 3992 | to7_lightpen = 0; |
| r3854 | r3855 | |
| 4016 | 3998 | to8_soft_select = 0; |
| 4017 | 3999 | |
| 4018 | 4000 | /* video */ |
| 4019 | | thom_set_video_mode( THOM_VMODE_TO770 ); |
| 4020 | | thom_set_lightpen_callback(machine, 4, to8_lightpen_cb ); |
| 4021 | | thom_set_border_color( 0 ); |
| 4001 | thom_set_video_mode( machine, THOM_VMODE_TO770 ); |
| 4002 | thom_set_lightpen_callback( machine, 4, to8_lightpen_cb ); |
| 4003 | thom_set_border_color( machine, 0 ); |
| 4022 | 4004 | thom_set_mode_point( machine, 0 ); |
| 4023 | 4005 | pia_set_input_cb1( THOM_PIA_SYS, 0 ); |
| 4024 | 4006 | |
| r3854 | r3855 | |
| 4046 | 4028 | thom_irq_init(machine); |
| 4047 | 4029 | pia_config( THOM_PIA_SYS, &to8_sys ); |
| 4048 | 4030 | centronics_config( 0, &to9_centronics ); |
| 4049 | | mc6846_config( machine, &to8_timer ); |
| 4050 | 4031 | to7_game_init(machine); |
| 4051 | | to8_floppy_init( machine ); |
| 4032 | to8_floppy_init(machine); |
| 4052 | 4033 | to8_kbd_init(machine); |
| 4053 | 4034 | to9_palette_init(machine); |
| 4054 | 4035 | to7_modem_init(machine); |
| 4055 | | to7_midi_init(); |
| 4056 | | mea8000_config( machine, THOM_SOUND_SPEECH, NULL ); |
| 4036 | to7_midi_init(machine); |
| 4057 | 4037 | |
| 4058 | 4038 | /* memory */ |
| 4059 | 4039 | thom_cart_bank = 0; |
| r3854 | r3855 | |
| 4075 | 4055 | memory_set_bank( machine, TO8_BIOS_BANK, 0 ); |
| 4076 | 4056 | |
| 4077 | 4057 | /* save-state */ |
| 4078 | | state_save_register_global(machine, thom_cart_nb_banks ); |
| 4079 | | state_save_register_global(machine, thom_cart_bank ); |
| 4080 | | state_save_register_global(machine, to7_lightpen ); |
| 4081 | | state_save_register_global(machine, to7_lightpen_step ); |
| 4082 | | state_save_register_global(machine, to8_reg_ram ); |
| 4083 | | state_save_register_global(machine, to8_reg_cart ); |
| 4084 | | state_save_register_global(machine, to8_reg_sys1 ); |
| 4085 | | state_save_register_global(machine, to8_reg_sys2 ); |
| 4086 | | state_save_register_global(machine, to8_soft_select ); |
| 4087 | | state_save_register_global(machine, to8_soft_bank ); |
| 4088 | | state_save_register_global(machine, to8_bios_bank ); |
| 4089 | | state_save_register_global(machine, to8_lightpen_intr ); |
| 4090 | | state_save_register_global(machine, to8_data_vpage ); |
| 4091 | | state_save_register_global(machine, to8_cart_vpage ); |
| 4092 | | state_save_register_global_pointer(machine, (mem + 0x10000), 0x10000 ); |
| 4093 | | state_save_register_postload(machine, to8_update_ram_bank_postload, NULL ); |
| 4094 | | state_save_register_postload(machine, to8_update_cart_bank_postload, NULL ); |
| 4095 | | state_save_register_postload(machine, to8_update_floppy_bank_postload, NULL ); |
| 4058 | state_save_register_global( machine, thom_cart_nb_banks ); |
| 4059 | state_save_register_global( machine, thom_cart_bank ); |
| 4060 | state_save_register_global( machine, to7_lightpen ); |
| 4061 | state_save_register_global( machine, to7_lightpen_step ); |
| 4062 | state_save_register_global( machine, to8_reg_ram ); |
| 4063 | state_save_register_global( machine, to8_reg_cart ); |
| 4064 | state_save_register_global( machine, to8_reg_sys1 ); |
| 4065 | state_save_register_global( machine, to8_reg_sys2 ); |
| 4066 | state_save_register_global( machine, to8_soft_select ); |
| 4067 | state_save_register_global( machine, to8_soft_bank ); |
| 4068 | state_save_register_global( machine, to8_bios_bank ); |
| 4069 | state_save_register_global( machine, to8_lightpen_intr ); |
| 4070 | state_save_register_global( machine, to8_data_vpage ); |
| 4071 | state_save_register_global( machine, to8_cart_vpage ); |
| 4072 | state_save_register_global_pointer( machine, (mem + 0x10000), 0x10000 ); |
| 4073 | state_save_register_postload( machine, to8_update_ram_bank_postload, NULL ); |
| 4074 | state_save_register_postload( machine, to8_update_cart_bank_postload, NULL ); |
| 4075 | state_save_register_postload( machine, to8_update_floppy_bank_postload, NULL ); |
| 4096 | 4076 | } |
| 4097 | 4077 | |
| 4098 | 4078 | |
| r3854 | r3855 | |
| 4119 | 4099 | |
| 4120 | 4100 | |
| 4121 | 4101 | |
| 4122 | | static READ8_HANDLER ( to9p_timer_port_in ) |
| 4102 | static READ8_DEVICE_HANDLER ( to9p_timer_port_in ) |
| 4123 | 4103 | { |
| 4124 | | int lightpen = (input_port_read(space->machine, "lightpen_button") & 1) ? 2 : 0; |
| 4125 | | int cass = to7_get_cassette(space->machine) ? 0x80 : 0; |
| 4104 | int lightpen = (input_port_read(device->machine, "lightpen_button") & 1) ? 2 : 0; |
| 4105 | int cass = to7_get_cassette(device->machine) ? 0x80 : 0; |
| 4126 | 4106 | int dtr = (centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY) ? 0 : 0x40; |
| 4127 | 4107 | return lightpen | cass | dtr; |
| 4128 | 4108 | } |
| 4129 | 4109 | |
| 4130 | 4110 | |
| 4131 | 4111 | |
| 4132 | | static WRITE8_HANDLER ( to9p_timer_port_out ) |
| 4112 | static WRITE8_DEVICE_HANDLER ( to9p_timer_port_out ) |
| 4133 | 4113 | { |
| 4134 | 4114 | int bios_bank = (data & 0x10) ? 1 : 0; /* bit 4: BIOS bank */ |
| 4135 | | thom_set_mode_point( space->machine, data & 1 ); /* bit 0: video bank switch */ |
| 4136 | | memory_set_bank( space->machine, TO8_BIOS_BANK, bios_bank ); |
| 4115 | thom_set_mode_point( device->machine, data & 1 ); /* bit 0: video bank switch */ |
| 4116 | memory_set_bank( device->machine, TO8_BIOS_BANK, bios_bank ); |
| 4137 | 4117 | to8_soft_select = (data & 0x04) ? 1 : 0; /* bit 2: internal ROM select */ |
| 4138 | | to8_update_floppy_bank(space->machine); |
| 4139 | | to8_update_cart_bank(space->machine); |
| 4118 | to8_update_floppy_bank(device->machine); |
| 4119 | to8_update_cart_bank(device->machine); |
| 4140 | 4120 | } |
| 4141 | 4121 | |
| 4142 | 4122 | |
| 4143 | 4123 | |
| 4144 | | static const mc6846_interface to9p_timer = |
| 4124 | mc6846_interface to9p_timer = |
| 4145 | 4125 | { |
| 4146 | 4126 | to9p_timer_port_out, NULL, to8_timer_cp2_out, |
| 4147 | 4127 | to9p_timer_port_in, to7_timer_tco_out, |
| 4148 | | thom_irq_0 |
| 4128 | thom_dev_irq_0 |
| 4149 | 4129 | }; |
| 4150 | 4130 | |
| 4151 | 4131 | |
| r3854 | r3855 | |
| 4162 | 4142 | thom_irq_reset(machine); |
| 4163 | 4143 | pia_reset(); |
| 4164 | 4144 | pia_set_port_a_z_mask( THOM_PIA_SYS, 0xfe ); |
| 4165 | | mc6846_reset(); |
| 4166 | | to7_game_reset(); |
| 4145 | to7_game_reset(machine); |
| 4167 | 4146 | to8_floppy_reset(machine); |
| 4168 | 4147 | to9_kbd_reset(machine); |
| 4169 | | thom_centronics_reset(); |
| 4170 | | to7_modem_reset(); |
| 4171 | | to7_midi_reset(); |
| 4172 | | to7_rf57932_reset(); |
| 4173 | | mea8000_reset(machine); |
| 4148 | thom_centronics_reset(machine); |
| 4149 | to7_modem_reset(machine); |
| 4150 | to7_midi_reset(machine); |
| 4174 | 4151 | |
| 4175 | 4152 | /* gate-array */ |
| 4176 | 4153 | to7_lightpen = 0; |
| r3854 | r3855 | |
| 4182 | 4159 | to8_soft_select = 0; |
| 4183 | 4160 | |
| 4184 | 4161 | /* video */ |
| 4185 | | thom_set_video_mode( THOM_VMODE_TO770 ); |
| 4186 | | thom_set_lightpen_callback(machine, 4, to8_lightpen_cb ); |
| 4187 | | thom_set_border_color( 0 ); |
| 4162 | thom_set_video_mode( machine, THOM_VMODE_TO770 ); |
| 4163 | thom_set_lightpen_callback( machine, 4, to8_lightpen_cb ); |
| 4164 | thom_set_border_color( machine, 0 ); |
| 4188 | 4165 | thom_set_mode_point( machine, 0 ); |
| 4189 | 4166 | pia_set_input_cb1( THOM_PIA_SYS, 0 ); |
| 4190 | 4167 | |
| r3854 | r3855 | |
| 4212 | 4189 | thom_irq_init(machine); |
| 4213 | 4190 | pia_config( THOM_PIA_SYS, &to9p_sys ); |
| 4214 | 4191 | centronics_config( 0, &to9_centronics ); |
| 4215 | | mc6846_config( machine, &to9p_timer ); |
| 4216 | 4192 | to7_game_init(machine); |
| 4217 | 4193 | to8_floppy_init( machine ); |
| 4218 | 4194 | to9_kbd_init(machine); |
| 4219 | 4195 | to9_palette_init(machine); |
| 4220 | 4196 | to7_modem_init(machine); |
| 4221 | | to7_midi_init(); |
| 4222 | | mea8000_config( machine, THOM_SOUND_SPEECH, NULL ); |
| 4197 | to7_midi_init(machine); |
| 4223 | 4198 | |
| 4224 | 4199 | /* memory */ |
| 4225 | 4200 | thom_cart_bank = 0; |
| r3854 | r3855 | |
| 4241 | 4216 | memory_set_bank( machine, TO8_BIOS_BANK, 0 ); |
| 4242 | 4217 | |
| 4243 | 4218 | /* save-state */ |
| 4244 | | state_save_register_global(machine, thom_cart_nb_banks ); |
| 4245 | | state_save_register_global(machine, thom_cart_bank ); |
| 4246 | | state_save_register_global(machine, to7_lightpen ); |
| 4247 | | state_save_register_global(machine, to7_lightpen_step ); |
| 4248 | | state_save_register_global(machine, to8_reg_ram ); |
| 4249 | | state_save_register_global(machine, to8_reg_cart ); |
| 4250 | | state_save_register_global(machine, to8_reg_sys1 ); |
| 4251 | | state_save_register_global(machine, to8_reg_sys2 ); |
| 4252 | | state_save_register_global(machine, to8_soft_select ); |
| 4253 | | state_save_register_global(machine, to8_soft_bank ); |
| 4254 | | state_save_register_global(machine, to8_bios_bank ); |
| 4255 | | state_save_register_global(machine, to8_lightpen_intr ); |
| 4256 | | state_save_register_global(machine, to8_data_vpage ); |
| 4257 | | state_save_register_global(machine, to8_cart_vpage ); |
| 4258 | | state_save_register_global_pointer(machine, (mem + 0x10000), 0x10000 ); |
| 4259 | | state_save_register_postload(machine, to8_update_ram_bank_postload, NULL ); |
| 4260 | | state_save_register_postload(machine, to8_update_cart_bank_postload, NULL ); |
| 4261 | | state_save_register_postload(machine, to8_update_floppy_bank_postload, NULL ); |
| 4219 | state_save_register_global( machine, thom_cart_nb_banks ); |
| 4220 | state_save_register_global( machine, thom_cart_bank ); |
| 4221 | state_save_register_global( machine, to7_lightpen ); |
| 4222 | state_save_register_global( machine, to7_lightpen_step ); |
| 4223 | state_save_register_global( machine, to8_reg_ram ); |
| 4224 | state_save_register_global( machine, to8_reg_cart ); |
| 4225 | state_save_register_global( machine, to8_reg_sys1 ); |
| 4226 | state_save_register_global( machine, to8_reg_sys2 ); |
| 4227 | state_save_register_global( machine, to8_soft_select ); |
| 4228 | state_save_register_global( machine, to8_soft_bank ); |
| 4229 | state_save_register_global( machine, to8_bios_bank ); |
| 4230 | state_save_register_global( machine, to8_lightpen_intr ); |
| 4231 | state_save_register_global( machine, to8_data_vpage ); |
| 4232 | state_save_register_global( machine, to8_cart_vpage ); |
| 4233 | state_save_register_global_pointer( machine, (mem + 0x10000), 0x10000 ); |
| 4234 | state_save_register_postload( machine, to8_update_ram_bank_postload, NULL ); |
| 4235 | state_save_register_postload( machine, to8_update_cart_bank_postload, NULL ); |
| 4236 | state_save_register_postload( machine, to8_update_floppy_bank_postload, NULL ); |
| 4262 | 4237 | } |
| 4263 | 4238 | |
| 4264 | 4239 | |
| r3854 | r3855 | |
| 4271 | 4246 | |
| 4272 | 4247 | |
| 4273 | 4248 | |
| 4274 | | static void mo6_update_ram_bank (running_machine *machine) |
| 4249 | static void mo6_update_ram_bank ( running_machine *machine ) |
| 4275 | 4250 | { |
| 4276 | 4251 | UINT8 bank = 0; |
| 4277 | 4252 | |
| r3854 | r3855 | |
| 4297 | 4272 | |
| 4298 | 4273 | static void mo6_update_cart_bank (running_machine *machine) |
| 4299 | 4274 | { |
| 4275 | const address_space* space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 4300 | 4276 | int b = (pia_get_output_a( THOM_PIA_SYS ) >> 5) & 1; |
| 4301 | 4277 | static int old_bank = -1; |
| 4302 | 4278 | int bank = 0; |
| 4303 | 4279 | |
| 4304 | | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) ); |
| 4280 | memory_install_read8_handler( space, 0xb000, 0xefff, 0, 0, (read8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) ); |
| 4305 | 4281 | |
| 4306 | 4282 | if ( ( ( to8_reg_sys1 & 0x40 ) && ( to8_reg_cart & 0x20 ) ) || ( ! ( to8_reg_sys1 & 0x40 ) && ( mo5_reg_cart & 4 ) ) ) |
| 4307 | 4283 | { |
| r3854 | r3855 | |
| 4311 | 4287 | /* use a7e6 */ |
| 4312 | 4288 | to8_cart_vpage = to8_reg_cart & 7; /* 128 KB RAM only = 8 pages */ |
| 4313 | 4289 | bank = 8 + to8_cart_vpage; |
| 4314 | | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, |
| 4290 | memory_install_write8_handler( space, 0xb000, 0xefff, 0, 0, |
| 4315 | 4291 | (to8_reg_cart & 0x40) ? (to8_cart_vpage <= 4) ? to8_vcart_w : |
| 4316 | 4292 | (write8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) : SMH_NOP ); |
| 4317 | 4293 | if ( bank != old_bank ) |
| r3854 | r3855 | |
| 4320 | 4296 | else if ( thom_cart_nb_banks == 4 ) |
| 4321 | 4297 | { |
| 4322 | 4298 | /* "JANE"-style cartridge bank switching */ |
| 4323 | | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, SMH_NOP ); |
| 4299 | memory_install_write8_handler( space, 0xb000, 0xefff, 0, 0, SMH_NOP ); |
| 4324 | 4300 | bank = mo5_reg_cart & 3; |
| 4325 | 4301 | if ( bank != old_bank ) |
| 4326 | 4302 | LOG_BANK(( "mo6_update_cart_bank: CART is external cartridge bank %i (A7CB style)\n", bank )); |
| r3854 | r3855 | |
| 4331 | 4307 | int write_enable = mo5_reg_cart & 8; |
| 4332 | 4308 | to8_cart_vpage = (mo5_reg_cart & 3) | 4; |
| 4333 | 4309 | bank = 8 + to8_cart_vpage; |
| 4334 | | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, write_enable ? |
| 4310 | memory_install_write8_handler( space, 0xb000, 0xefff, 0, 0, write_enable ? |
| 4335 | 4311 | (write8_space_func)(STATIC_BANK1 + THOM_CART_BANK - 1) : SMH_NOP ); |
| 4336 | 4312 | if ( bank != old_bank ) |
| 4337 | 4313 | LOG_BANK(( "mo6_update_cart_bank: CART is RAM bank %i (write-enable=%i) (MO5 compat.)\n", to8_cart_vpage, write_enable ? 1 : 0 )); |
| r3854 | r3855 | |
| 4340 | 4316 | else |
| 4341 | 4317 | { |
| 4342 | 4318 | /* ROM space */ |
| 4343 | | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, SMH_NOP ); |
| 4319 | memory_install_write8_handler( space, 0xb000, 0xefff, 0, 0, SMH_NOP ); |
| 4344 | 4320 | if ( to8_reg_sys2 & 0x20 ) |
| 4345 | 4321 | { |
| 4346 | 4322 | /* internal ROM */ |
| r3854 | r3855 | |
| 4354 | 4330 | else |
| 4355 | 4331 | { |
| 4356 | 4332 | /* cartridge */ |
| 4357 | | memory_install_write8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xb000, 0xefff, 0, 0, mo6_cartridge_w ); |
| 4333 | memory_install_write8_handler( space, 0xb000, 0xefff, 0, 0, mo6_cartridge_w ); |
| 4358 | 4334 | if ( thom_cart_nb_banks ) |
| 4359 | 4335 | { |
| 4360 | 4336 | bank = thom_cart_bank % thom_cart_nb_banks; |
| 4361 | | memory_install_read8_handler(cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM), 0xbffc, 0xbfff, 0, 0, mo6_cartridge_r ); |
| 4337 | memory_install_read8_handler( space, 0xbffc, 0xbfff, 0, 0, mo6_cartridge_r ); |
| 4362 | 4338 | } |
| 4363 | 4339 | if ( bank != old_bank ) |
| 4364 | 4340 | LOG_BANK(( "mo6_update_cart_bank: CART is external cartridge bank %i\n", bank )); |
| r3854 | r3855 | |
| 4421 | 4397 | static WRITE8_HANDLER ( mo6_game_porta_out ) |
| 4422 | 4398 | { |
| 4423 | 4399 | /* centronics data */ |
| 4424 | | LOG (( "$%04x %f mo6_game_porta_out: CENTRONICS set data=$%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data )); |
| 4400 | LOG (( "$%04x %f mo6_game_porta_out: CENTRONICS set data=$%02X\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data )); |
| 4425 | 4401 | centronics_write_data( 0, data ); |
| 4426 | 4402 | } |
| 4427 | 4403 | |
| r3854 | r3855 | |
| 4431 | 4407 | { |
| 4432 | 4408 | int dtr = ( centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY ) ? 0 : 1; |
| 4433 | 4409 | /* note: printer busy signal replaces button */ |
| 4434 | | LOG (( "$%04x %f mo6_game_cb1_in: CENTRONICS get dtr=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), dtr )); |
| 4410 | LOG (( "$%04x %f mo6_game_cb1_in: CENTRONICS get dtr=%i\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), dtr )); |
| 4435 | 4411 | return dtr; |
| 4436 | 4412 | } |
| 4437 | 4413 | |
| r3854 | r3855 | |
| 4440 | 4416 | static WRITE8_HANDLER ( mo6_game_cb2_out ) |
| 4441 | 4417 | { |
| 4442 | 4418 | /* centronics strobe */ |
| 4443 | | LOG (( "$%04x %f mo6_game_cb2_out: CENTRONICS set strobe=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data )); |
| 4444 | | centronics_write_handshake( 0, data ? CENTRONICS_STROBE : 0, |
| 4445 | | CENTRONICS_STROBE ); |
| 4419 | LOG (( "$%04x %f mo6_game_cb2_out: CENTRONICS set strobe=%i\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data )); |
| 4420 | centronics_write_handshake( 0, data ? CENTRONICS_STROBE : 0, CENTRONICS_STROBE ); |
| 4446 | 4421 | } |
| 4447 | 4422 | |
| 4448 | 4423 | |
| r3854 | r3855 | |
| 4481 | 4456 | { |
| 4482 | 4457 | LOG (( "mo6_game_init called\n" )); |
| 4483 | 4458 | pia_config( THOM_PIA_GAME, &mo6_game ); |
| 4484 | | to7_game_timer = timer_alloc(machine, mo6_game_update_cb , NULL); |
| 4459 | to7_game_timer = timer_alloc( machine, mo6_game_update_cb , NULL); |
| 4485 | 4460 | timer_adjust_periodic(to7_game_timer, TO7_GAME_POLL_PERIOD, 0, TO7_GAME_POLL_PERIOD); |
| 4486 | | state_save_register_global(machine, to7_game_sound ); |
| 4487 | | state_save_register_global(machine, to7_game_mute ); |
| 4461 | state_save_register_global( machine, to7_game_sound ); |
| 4462 | state_save_register_global( machine, to7_game_mute ); |
| 4488 | 4463 | } |
| 4489 | 4464 | |
| 4490 | 4465 | |
| 4491 | 4466 | |
| 4492 | | static void mo6_game_reset ( void ) |
| 4467 | static void mo6_game_reset ( running_machine *machine ) |
| 4493 | 4468 | { |
| 4494 | 4469 | LOG (( "mo6_game_reset called\n" )); |
| 4495 | 4470 | pia_set_input_ca1( THOM_PIA_GAME, 0 ); |
| 4496 | 4471 | to7_game_sound = 0; |
| 4497 | 4472 | to7_game_mute = 0; |
| 4498 | | to7_game_sound_update(); |
| 4473 | to7_game_sound_update(machine); |
| 4499 | 4474 | } |
| 4500 | 4475 | |
| 4501 | 4476 | |
| r3854 | r3855 | |
| 4537 | 4512 | |
| 4538 | 4513 | static WRITE8_HANDLER ( mo6_sys_porta_out ) |
| 4539 | 4514 | { |
| 4540 | | thom_set_mode_point( space->machine, data & 1 ); /* bit 0: video bank switch */ |
| 4541 | | to7_game_mute = data & 4; /* bit 2: sound mute */ |
| 4542 | | thom_set_caps_led( (data & 16) ? 0 : 1 ) ; /* bit 4: keyboard led */ |
| 4543 | | mo5_set_cassette( space->machine, (data & 0x40) ? 1 : 0 ); /* bit 6: cassette output */ |
| 4544 | | mo6_update_cart_bank(space->machine); /* bit 5: rom bank */ |
| 4545 | | to7_game_sound_update(); |
| 4515 | thom_set_mode_point( space->machine,data & 1 ); /* bit 0: video bank switch */ |
| 4516 | to7_game_mute = data & 4; /* bit 2: sound mute */ |
| 4517 | thom_set_caps_led( space->machine,(data & 16) ? 0 : 1 ) ; /* bit 4: keyboard led */ |
| 4518 | mo5_set_cassette( space->machine, (data & 0x40) ? 1 : 0 ); /* bit 6: cassette output */ |
| 4519 | mo6_update_cart_bank(space->machine); /* bit 5: rom bank */ |
| 4520 | to7_game_sound_update(space->machine); |
| 4546 | 4521 | } |
| 4547 | 4522 | |
| 4548 | 4523 | |
| r3854 | r3855 | |
| 4580 | 4555 | |
| 4581 | 4556 | READ8_HANDLER ( mo6_gatearray_r ) |
| 4582 | 4557 | { |
| 4583 | | struct thom_vsignal v = thom_get_vsignal(); |
| 4558 | struct thom_vsignal v = thom_get_vsignal( space->machine ); |
| 4584 | 4559 | struct thom_vsignal l = thom_get_lightpen_vsignal( space->machine, MO6_LIGHTPEN_DECAL, to7_lightpen_step - 1, 6 ); |
| 4585 | 4560 | int count, inil, init, lt3; |
| 4586 | 4561 | UINT8 res; |
| r3854 | r3855 | |
| 4622 | 4597 | break; |
| 4623 | 4598 | |
| 4624 | 4599 | default: |
| 4625 | | logerror( "$%04x mo6_gatearray_r: invalid offset %i\n", cpu_get_previouspc(space->cpu), offset ); |
| 4600 | logerror( "$%04x mo6_gatearray_r: invalid offset %i\n", cpu_get_previouspc( space->machine->cpu[0] ), offset ); |
| 4626 | 4601 | res = 0; |
| 4627 | 4602 | } |
| 4628 | 4603 | |
| 4629 | 4604 | LOG_VIDEO(( "$%04x %f mo6_gatearray_r: off=%i ($%04X) res=$%02X lightpen=%i\n", |
| 4630 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), |
| 4605 | cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), |
| 4631 | 4606 | offset, 0xa7e4 + offset, res, to7_lightpen )); |
| 4632 | 4607 | |
| 4633 | 4608 | return res; |
| r3854 | r3855 | |
| 4638 | 4613 | WRITE8_HANDLER ( mo6_gatearray_w ) |
| 4639 | 4614 | { |
| 4640 | 4615 | LOG_VIDEO(( "$%04x %f mo6_gatearray_w: off=%i ($%04X) data=$%02X\n", |
| 4641 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), |
| 4616 | cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), |
| 4642 | 4617 | offset, 0xa7e4 + offset, data )); |
| 4643 | 4618 | |
| 4644 | 4619 | switch ( offset ) |
| r3854 | r3855 | |
| 4668 | 4643 | break; |
| 4669 | 4644 | |
| 4670 | 4645 | default: |
| 4671 | | logerror( "$%04x mo6_gatearray_w: invalid offset %i (data=$%02X)\n", cpu_get_previouspc(space->cpu), offset, data ); |
| 4646 | logerror( "$%04x mo6_gatearray_w: invalid offset %i (data=$%02X)\n", cpu_get_previouspc( space->machine->cpu[0] ), offset, data ); |
| 4672 | 4647 | } |
| 4673 | 4648 | } |
| 4674 | 4649 | |
| r3854 | r3855 | |
| 4705 | 4680 | WRITE8_HANDLER ( mo6_vreg_w ) |
| 4706 | 4681 | { |
| 4707 | 4682 | LOG_VIDEO(( "$%04x %f mo6_vreg_w: off=%i ($%04X) data=$%02X\n", |
| 4708 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), |
| 4683 | cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), |
| 4709 | 4684 | offset, 0xa7da + offset, data )); |
| 4710 | 4685 | |
| 4711 | 4686 | switch ( offset ) |
| r3854 | r3855 | |
| 4720 | 4695 | if ( ( to8_reg_sys1 & 0x80 ) && ( to8_reg_ram & 0x80 ) ) |
| 4721 | 4696 | to7_floppy_w( space, 0xc, data ); |
| 4722 | 4697 | else |
| 4723 | | to9_set_video_mode( data, 2 ); |
| 4698 | to9_set_video_mode( space->machine, data, 2 ); |
| 4724 | 4699 | break; |
| 4725 | 4700 | |
| 4726 | 4701 | case 3: /* system register 2 */ |
| r3854 | r3855 | |
| 4730 | 4705 | else |
| 4731 | 4706 | { |
| 4732 | 4707 | to8_reg_sys2 = data; |
| 4733 | | thom_set_video_page( data >> 6 ); |
| 4734 | | thom_set_border_color( data & 15 ); |
| 4735 | | mo6_update_cart_bank(space->machine); |
| 4708 | thom_set_video_page( space->machine, data >> 6 ); |
| 4709 | thom_set_border_color( space->machine, data & 15 ); |
| 4710 | mo6_update_cart_bank( space->machine ); |
| 4736 | 4711 | } |
| 4737 | 4712 | break; |
| 4738 | 4713 | |
| r3854 | r3855 | |
| 4755 | 4730 | thom_irq_reset(machine); |
| 4756 | 4731 | pia_reset(); |
| 4757 | 4732 | pia_set_port_a_z_mask( THOM_PIA_SYS, 0x75 ); |
| 4758 | | mo6_game_reset(); |
| 4733 | mo6_game_reset(machine); |
| 4759 | 4734 | to7_floppy_reset(machine); |
| 4760 | | thom_centronics_reset(); |
| 4761 | | to7_modem_reset(); |
| 4762 | | to7_midi_reset(); |
| 4763 | | to7_rf57932_reset(); |
| 4764 | | mo5_init_timer(); |
| 4765 | | mea8000_reset(machine); |
| 4735 | thom_centronics_reset(machine); |
| 4736 | to7_modem_reset(machine); |
| 4737 | to7_midi_reset(machine); |
| 4738 | mo5_init_timer(machine); |
| 4766 | 4739 | |
| 4767 | 4740 | /* gate-array */ |
| 4768 | 4741 | to7_lightpen = 0; |
| r3854 | r3855 | |
| 4773 | 4746 | to8_lightpen_intr = 0; |
| 4774 | 4747 | |
| 4775 | 4748 | /* video */ |
| 4776 | | thom_set_video_mode( THOM_VMODE_MO5 ); |
| 4777 | | thom_set_lightpen_callback(machine, 3, to8_lightpen_cb ); |
| 4778 | | thom_set_border_color( 0 ); |
| 4749 | thom_set_video_mode( machine, THOM_VMODE_MO5 ); |
| 4750 | thom_set_lightpen_callback( machine, 3, to8_lightpen_cb ); |
| 4751 | thom_set_border_color( machine, 0 ); |
| 4779 | 4752 | thom_set_mode_point( machine, 0 ); |
| 4780 | 4753 | pia_set_input_ca1( THOM_PIA_SYS, 0 ); |
| 4781 | 4754 | |
| r3854 | r3855 | |
| 4804 | 4777 | to7_floppy_init( machine, mem + 0x30000 ); |
| 4805 | 4778 | to9_palette_init(machine); |
| 4806 | 4779 | to7_modem_init(machine); |
| 4807 | | to7_midi_init(); |
| 4808 | | mo5_periodic_timer = timer_alloc(machine, mo5_periodic_cb , NULL); |
| 4809 | | mea8000_config( machine, THOM_SOUND_SPEECH, NULL ); |
| 4780 | to7_midi_init(machine); |
| 4781 | mo5_periodic_timer = timer_alloc( machine, mo5_periodic_cb , NULL); |
| 4810 | 4782 | |
| 4811 | 4783 | /* memory */ |
| 4812 | 4784 | thom_cart_bank = 0; |
| r3854 | r3855 | |
| 4831 | 4803 | memory_set_bank( machine, TO8_BIOS_BANK, 0 ); |
| 4832 | 4804 | |
| 4833 | 4805 | /* save-state */ |
| 4834 | | state_save_register_global(machine, thom_cart_nb_banks ); |
| 4835 | | state_save_register_global(machine, thom_cart_bank ); |
| 4836 | | state_save_register_global(machine, to7_lightpen ); |
| 4837 | | state_save_register_global(machine, to7_lightpen_step ); |
| 4838 | | state_save_register_global(machine, to8_reg_ram ); |
| 4839 | | state_save_register_global(machine, to8_reg_cart ); |
| 4840 | | state_save_register_global(machine, to8_reg_sys1 ); |
| 4841 | | state_save_register_global(machine, to8_reg_sys2 ); |
| 4842 | | state_save_register_global(machine, to8_lightpen_intr ); |
| 4843 | | state_save_register_global(machine, to8_data_vpage ); |
| 4844 | | state_save_register_global(machine, to8_cart_vpage ); |
| 4845 | | state_save_register_global(machine, mo5_reg_cart ); |
| 4846 | | state_save_register_global_pointer(machine, (mem + 0x10000), 0x10000 ); |
| 4847 | | state_save_register_postload(machine, mo6_update_ram_bank_postload, NULL ); |
| 4848 | | state_save_register_postload(machine, mo6_update_cart_bank_postload, NULL ); |
| 4806 | state_save_register_global( machine, thom_cart_nb_banks ); |
| 4807 | state_save_register_global( machine, thom_cart_bank ); |
| 4808 | state_save_register_global( machine, to7_lightpen ); |
| 4809 | state_save_register_global( machine, to7_lightpen_step ); |
| 4810 | state_save_register_global( machine, to8_reg_ram ); |
| 4811 | state_save_register_global( machine, to8_reg_cart ); |
| 4812 | state_save_register_global( machine, to8_reg_sys1 ); |
| 4813 | state_save_register_global( machine, to8_reg_sys2 ); |
| 4814 | state_save_register_global( machine, to8_lightpen_intr ); |
| 4815 | state_save_register_global( machine, to8_data_vpage ); |
| 4816 | state_save_register_global( machine, to8_cart_vpage ); |
| 4817 | state_save_register_global( machine, mo5_reg_cart ); |
| 4818 | state_save_register_global_pointer( machine, (mem + 0x10000), 0x10000 ); |
| 4819 | state_save_register_postload( machine, mo6_update_ram_bank_postload, NULL ); |
| 4820 | state_save_register_postload( machine, mo6_update_cart_bank_postload, NULL ); |
| 4849 | 4821 | } |
| 4850 | 4822 | |
| 4851 | 4823 | |
| r3854 | r3855 | |
| 4863 | 4835 | if ( to7_controller_type ) |
| 4864 | 4836 | return to7_floppy_r ( space, offset ); |
| 4865 | 4837 | |
| 4866 | | logerror( "$%04x %f mo5nr_net_r: read from reg %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), offset ); |
| 4838 | logerror( "$%04x %f mo5nr_net_r: read from reg %i\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), offset ); |
| 4867 | 4839 | |
| 4868 | | if ( to7_controller_type ) |
| 4869 | | return to7_floppy_r ( space, offset ); |
| 4870 | | |
| 4871 | 4840 | return 0; |
| 4872 | 4841 | } |
| 4873 | 4842 | |
| r3854 | r3855 | |
| 4879 | 4848 | to7_floppy_w ( space, offset, data ); |
| 4880 | 4849 | else |
| 4881 | 4850 | logerror( "$%04x %f mo5nr_net_w: write $%02X to reg %i\n", |
| 4882 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data, offset ); |
| 4851 | cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), data, offset ); |
| 4883 | 4852 | } |
| 4884 | 4853 | |
| 4885 | 4854 | |
| r3854 | r3855 | |
| 4907 | 4876 | return 0x80; |
| 4908 | 4877 | |
| 4909 | 4878 | default: |
| 4910 | | logerror( "$%04x %f mo5nr_prn_r: unhandled read from reg %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), offset ); |
| 4879 | logerror( "$%04x %f mo5nr_prn_r: unhandled read from reg %i\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), offset ); |
| 4911 | 4880 | return 0; |
| 4912 | 4881 | } |
| 4913 | 4882 | } |
| r3854 | r3855 | |
| 4929 | 4898 | break; |
| 4930 | 4899 | |
| 4931 | 4900 | default: |
| 4932 | | logerror( "$%04x %f mo5nr_prn_w: unhandled to reg %i (data=$%02X)\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), offset, data ); |
| 4901 | logerror( "$%04x %f mo5nr_prn_w: unhandled to reg %i (data=$%02X)\n", cpu_get_previouspc( space->machine->cpu[0] ), attotime_to_double(timer_get_time(space->machine)), offset, data ); |
| 4933 | 4902 | } |
| 4934 | 4903 | } |
| 4935 | 4904 | |
| r3854 | r3855 | |
| 4957 | 4926 | static WRITE8_HANDLER ( mo5nr_sys_porta_out ) |
| 4958 | 4927 | { |
| 4959 | 4928 | /* no keyboard LED */ |
| 4960 | | thom_set_mode_point( space->machine, data & 1 ); /* bit 0: video bank switch */ |
| 4961 | | to7_game_mute = data & 4; /* bit 2: sound mute */ |
| 4929 | thom_set_mode_point( space->machine, data & 1 ); /* bit 0: video bank switch */ |
| 4930 | to7_game_mute = data & 4; /* bit 2: sound mute */ |
| 4962 | 4931 | mo5_set_cassette( space->machine, (data & 0x40) ? 1 : 0 ); /* bit 6: cassette output */ |
| 4963 | | mo6_update_cart_bank(space->machine); /* bit 5: rom bank */ |
| 4964 | | to7_game_sound_update(); |
| 4932 | mo6_update_cart_bank(space->machine); /* bit 5: rom bank */ |
| 4933 | to7_game_sound_update(space->machine); |
| 4965 | 4934 | } |
| 4966 | 4935 | |
| 4967 | 4936 | |
| r3854 | r3855 | |
| 4993 | 4962 | |
| 4994 | 4963 | |
| 4995 | 4964 | |
| 4996 | | static void mo5nr_game_init ( running_machine *machine ) |
| 4965 | static void mo5nr_game_init ( running_machine* machine ) |
| 4997 | 4966 | { |
| 4998 | 4967 | LOG (( "mo5nr_game_init called\n" )); |
| 4999 | 4968 | pia_config( THOM_PIA_GAME, &mo5nr_game ); |
| 5000 | | to7_game_timer = timer_alloc(machine, mo6_game_update_cb , NULL); |
| 5001 | | timer_adjust_periodic(to7_game_timer, TO7_GAME_POLL_PERIOD, 0, TO7_GAME_POLL_PERIOD); |
| 5002 | | state_save_register_global(machine, to7_game_sound ); |
| 5003 | | state_save_register_global(machine, to7_game_mute ); |
| 4969 | to7_game_timer = timer_alloc( machine, mo6_game_update_cb , NULL); |
| 4970 | timer_adjust_periodic( to7_game_timer, TO7_GAME_POLL_PERIOD, 0, TO7_GAME_POLL_PERIOD ); |
| 4971 | state_save_register_global( machine, to7_game_sound ); |
| 4972 | state_save_register_global( machine, to7_game_mute ); |
| 5004 | 4973 | } |
| 5005 | 4974 | |
| 5006 | 4975 | |
| 5007 | 4976 | |
| 5008 | | static void mo5nr_game_reset ( void ) |
| 4977 | static void mo5nr_game_reset ( running_machine* machine ) |
| 5009 | 4978 | { |
| 5010 | 4979 | LOG (( "mo5nr_game_reset called\n" )); |
| 5011 | 4980 | pia_set_input_ca1( THOM_PIA_GAME, 0 ); |
| 5012 | 4981 | to7_game_sound = 0; |
| 5013 | 4982 | to7_game_mute = 0; |
| 5014 | | to7_game_sound_update(); |
| 4983 | to7_game_sound_update(machine); |
| 5015 | 4984 | } |
| 5016 | 4985 | |
| 5017 | 4986 | |
| r3854 | r3855 | |
| 5028 | 4997 | thom_irq_reset(machine); |
| 5029 | 4998 | pia_reset(); |
| 5030 | 4999 | pia_set_port_a_z_mask( THOM_PIA_SYS, 0x65 ); |
| 5031 | | mo5nr_game_reset(); |
| 5000 | mo5nr_game_reset(machine); |
| 5032 | 5001 | to7_floppy_reset(machine); |
| 5033 | | thom_centronics_reset(); |
| 5034 | | to7_modem_reset(); |
| 5035 | | to7_midi_reset(); |
| 5036 | | to7_rf57932_reset(); |
| 5037 | | mo5_init_timer(); |
| 5038 | | mea8000_reset(machine); |
| 5002 | thom_centronics_reset(machine); |
| 5003 | to7_modem_reset(machine); |
| 5004 | to7_midi_reset(machine); |
| 5005 | mo5_init_timer(machine); |
| 5039 | 5006 | |
| 5040 | 5007 | /* gate-array */ |
| 5041 | 5008 | to7_lightpen = 0; |
| r3854 | r3855 | |
| 5046 | 5013 | to8_lightpen_intr = 0; |
| 5047 | 5014 | |
| 5048 | 5015 | /* video */ |
| 5049 | | thom_set_video_mode( THOM_VMODE_MO5 ); |
| 5050 | | thom_set_lightpen_callback(machine, 3, to8_lightpen_cb ); |
| 5051 | | thom_set_border_color( 0 ); |
| 5016 | thom_set_video_mode( machine, THOM_VMODE_MO5 ); |
| 5017 | thom_set_lightpen_callback( machine, 3, to8_lightpen_cb ); |
| 5018 | thom_set_border_color( machine, 0 ); |
| 5052 | 5019 | thom_set_mode_point( machine, 0 ); |
| 5053 | 5020 | pia_set_input_ca1( THOM_PIA_SYS, 0 ); |
| 5054 | 5021 | |
| r3854 | r3855 | |
| 5073 | 5040 | thom_irq_init(machine); |
| 5074 | 5041 | pia_config( THOM_PIA_SYS, &mo5nr_sys ); |
| 5075 | 5042 | centronics_config( 0, &to9_centronics ); |
| 5076 | | mo5nr_game_init( machine ); |
| 5043 | mo5nr_game_init(machine); |
| 5077 | 5044 | to7_floppy_init( machine, mem + 0x30000 ); |
| 5078 | 5045 | to9_palette_init(machine); |
| 5079 | 5046 | to7_modem_init(machine); |
| 5080 | | to7_midi_init(); |
| 5081 | | mo5_periodic_timer = timer_alloc(machine, mo5_periodic_cb , NULL); |
| 5082 | | mea8000_config( machine, THOM_SOUND_SPEECH, NULL ); |
| 5047 | to7_midi_init(machine); |
| 5048 | mo5_periodic_timer = timer_alloc( machine, mo5_periodic_cb , NULL); |
| 5083 | 5049 | |
| 5084 | 5050 | /* memory */ |
| 5085 | 5051 | thom_cart_bank = 0; |
| r3854 | r3855 | |
| 5104 | 5070 | memory_set_bank( machine, TO8_BIOS_BANK, 0 ); |
| 5105 | 5071 | |
| 5106 | 5072 | /* save-state */ |
| 5107 | | state_save_register_global(machine, thom_cart_nb_banks ); |
| 5108 | | state_save_register_global(machine, thom_cart_bank ); |
| 5109 | | state_save_register_global(machine, to7_lightpen ); |
| 5110 | | state_save_register_global(machine, to7_lightpen_step ); |
| 5111 | | state_save_register_global(machine, to8_reg_ram ); |
| 5112 | | state_save_register_global(machine, to8_reg_cart ); |
| 5113 | | state_save_register_global(machine, to8_reg_sys1 ); |
| 5114 | | state_save_register_global(machine, to8_reg_sys2 ); |
| 5115 | | state_save_register_global(machine, to8_lightpen_intr ); |
| 5116 | | state_save_register_global(machine, to8_data_vpage ); |
| 5117 | | state_save_register_global(machine, to8_cart_vpage ); |
| 5118 | | state_save_register_global(machine, mo5_reg_cart ); |
| 5119 | | state_save_register_global_pointer(machine, (mem + 0x10000), 0x10000 ); |
| 5120 | | state_save_register_postload(machine, mo6_update_ram_bank_postload, NULL ); |
| 5121 | | state_save_register_postload(machine, mo6_update_cart_bank_postload, NULL ); |
| 5073 | state_save_register_global( machine, thom_cart_nb_banks ); |
| 5074 | state_save_register_global( machine, thom_cart_bank ); |
| 5075 | state_save_register_global( machine, to7_lightpen ); |
| 5076 | state_save_register_global( machine, to7_lightpen_step ); |
| 5077 | state_save_register_global( machine, to8_reg_ram ); |
| 5078 | state_save_register_global( machine, to8_reg_cart ); |
| 5079 | state_save_register_global( machine, to8_reg_sys1 ); |
| 5080 | state_save_register_global( machine, to8_reg_sys2 ); |
| 5081 | state_save_register_global( machine, to8_lightpen_intr ); |
| 5082 | state_save_register_global( machine, to8_data_vpage ); |
| 5083 | state_save_register_global( machine, to8_cart_vpage ); |
| 5084 | state_save_register_global( machine, mo5_reg_cart ); |
| 5085 | state_save_register_global_pointer( machine, (mem + 0x10000), 0x10000 ); |
| 5086 | state_save_register_postload( machine, mo6_update_ram_bank_postload, NULL ); |
| 5087 | state_save_register_postload( machine, mo6_update_cart_bank_postload, NULL ); |
| 5122 | 5088 | } |
src/mess/devices/thomflop.c
| r3854 | r3855 | |
| 6 | 6 | |
| 7 | 7 | **********************************************************************/ |
| 8 | 8 | |
| 9 | | #include "driver.h" |
| 10 | 9 | #include "includes/thomson.h" |
| 11 | | #include "machine/wd17xx.h" |
| 12 | | #include "devices/flopdrv.h" |
| 13 | | #include "devices/thomflop.h" |
| 14 | | #include "formats/thom_dsk.h" |
| 15 | | #include "machine/mc6854.h" |
| 16 | | #include "machine/mc6843.h" |
| 17 | 10 | |
| 18 | 11 | |
| 19 | 12 | #define VERBOSE 0 /* 0, 1 or 2 */ |
| r3854 | r3855 | |
| 282 | 275 | else if ( offset == 8 ) |
| 283 | 276 | return to7_5p14_select; |
| 284 | 277 | else |
| 285 | | logerror ( "%f $%04x to7_5p14_r: invalid read offset %i\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset ); |
| 278 | logerror ( "%f $%04x to7_5p14_r: invalid read offset %i\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), offset ); |
| 286 | 279 | return 0; |
| 287 | 280 | } |
| 288 | 281 | |
| r3854 | r3855 | |
| 306 | 299 | case 4: drive = 2; side = 0; break; |
| 307 | 300 | case 5: drive = 3; side = 1; break; |
| 308 | 301 | default: |
| 309 | | logerror( "%f $%04x to7_5p14_w: invalid drive select pattern $%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data ); |
| 302 | logerror( "%f $%04x to7_5p14_w: invalid drive select pattern $%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data ); |
| 310 | 303 | } |
| 311 | 304 | |
| 312 | 305 | dens = (data & 0x80) ? DEN_FM_LO : DEN_MFM_LO; |
| r3854 | r3855 | |
| 317 | 310 | |
| 318 | 311 | if ( drive != -1 ) |
| 319 | 312 | { |
| 320 | | thom_floppy_active( 0 ); |
| 313 | thom_floppy_active( space->machine, 0 ); |
| 321 | 314 | wd17xx_set_drive( drive ); |
| 322 | 315 | wd17xx_set_side( side ); |
| 323 | 316 | LOG(( "%f $%04x to7_5p14_w: $%02X set drive=%i side=%i density=%s\n", |
| 324 | | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), |
| 317 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), |
| 325 | 318 | data, drive, side, (dens == DEN_FM_LO) ? "FM" : "MFM" )); |
| 326 | 319 | } |
| 327 | 320 | } |
| 328 | 321 | else |
| 329 | 322 | logerror ( "%f $%04x to7_5p14_w: invalid write offset %i (data=$%02X)\n", |
| 330 | | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset, data ); |
| 323 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), offset, data ); |
| 331 | 324 | } |
| 332 | 325 | |
| 333 | 326 | |
| r3854 | r3855 | |
| 353 | 346 | { |
| 354 | 347 | LOG(( "to7_5p14_init: CD 90-640 controller\n" )); |
| 355 | 348 | wd17xx_init( machine, WD_TYPE_2793, NULL, NULL ); |
| 356 | | state_save_register_global(machine, to7_5p14_select ); |
| 349 | state_save_register_global( machine, to7_5p14_select ); |
| 357 | 350 | } |
| 358 | 351 | |
| 359 | 352 | |
| r3854 | r3855 | |
| 375 | 368 | static READ8_HANDLER ( to7_5p14sd_r ) |
| 376 | 369 | { |
| 377 | 370 | if ( offset < 8 ) |
| 378 | | return mc6843_r( space, offset ); |
| 371 | return mc6843_r( devtag_get_device(space->machine, MC6843, "mc6843"), offset ); |
| 379 | 372 | else if ( offset >= 8 && offset <= 9 ) |
| 380 | 373 | return to7_5p14sd_select; |
| 381 | 374 | else |
| 382 | | logerror ( "%f $%04x to7_5p14sd_r: invalid read offset %i\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset ); |
| 375 | logerror ( "%f $%04x to7_5p14sd_r: invalid read offset %i\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), offset ); |
| 383 | 376 | return 0; |
| 384 | 377 | } |
| 385 | 378 | |
| r3854 | r3855 | |
| 388 | 381 | static WRITE8_HANDLER( to7_5p14sd_w ) |
| 389 | 382 | { |
| 390 | 383 | if ( offset < 8 ) |
| 391 | | mc6843_w( space, offset, data ); |
| 384 | mc6843_w( devtag_get_device(space->machine, MC6843, "mc6843"), offset, data ); |
| 392 | 385 | else if ( offset >= 8 && offset <= 9 ) |
| 393 | 386 | { |
| 394 | 387 | /* drive select */ |
| r3854 | r3855 | |
| 419 | 412 | |
| 420 | 413 | if ( drive != -1 ) |
| 421 | 414 | { |
| 422 | | thom_floppy_active( 0 ); |
| 423 | | mc6843_set_drive( drive ); |
| 424 | | mc6843_set_side( side ); |
| 415 | thom_floppy_active( space->machine, 0 ); |
| 416 | mc6843_set_drive( devtag_get_device(space->machine, MC6843, "mc6843"), drive ); |
| 417 | mc6843_set_side( devtag_get_device(space->machine, MC6843, "mc6843"), side ); |
| 425 | 418 | LOG(( "%f $%04x to7_5p14sd_w: $%02X set drive=%i side=%i\n", |
| 426 | | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, drive, side )); |
| 419 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data, drive, side )); |
| 427 | 420 | } |
| 428 | 421 | } |
| 429 | 422 | else |
| 430 | 423 | logerror ( "%f $%04x to7_5p14sd_w: invalid write offset %i (data=$%02X)\n", |
| 431 | | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset, data ); |
| 424 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), offset, data ); |
| 432 | 425 | } |
| 433 | 426 | |
| 427 | static void to7_5p14_index_pulse_callback( const device_config *device, int index_pulse ) |
| 428 | { |
| 429 | mc6843_set_index_pulse( devtag_get_device(device->machine, MC6843, "mc6843"), index_pulse ); |
| 430 | } |
| 434 | 431 | |
| 435 | | |
| 436 | 432 | static void to7_5p14sd_reset( running_machine *machine ) |
| 437 | 433 | { |
| 438 | 434 | int i; |
| 439 | 435 | LOG(( "to7_5p14sd_reset: CD 90-015 controller\n" )); |
| 440 | 436 | thom_floppy_set_density( DEN_FM_LO ); |
| 441 | | mc6843_reset(machine); |
| 442 | 437 | for ( i = 0; i < device_count( machine, IO_FLOPPY ); i++ ) |
| 443 | 438 | { |
| 444 | 439 | const device_config * img = image_from_devtype_and_index( IO_FLOPPY, i ); |
| 445 | 440 | floppy_drive_set_ready_state( img, FLOPPY_DRIVE_READY, 0 ); |
| 446 | 441 | floppy_drive_set_rpm( img, 300. ); |
| 447 | 442 | floppy_drive_seek( img, - floppy_drive_get_current_track( img ) ); |
| 443 | floppy_drive_set_index_pulse_callback( img, to7_5p14_index_pulse_callback ); |
| 444 | |
| 448 | 445 | } |
| 449 | 446 | } |
| 450 | 447 | |
| 451 | 448 | |
| 452 | 449 | |
| 453 | | static mc6843_interface to7_6843_itf = { NULL }; |
| 450 | mc6843_interface to7_6843_itf = { NULL }; |
| 454 | 451 | |
| 455 | 452 | |
| 456 | 453 | |
| 457 | 454 | static void to7_5p14sd_init( running_machine *machine ) |
| 458 | 455 | { |
| 459 | 456 | LOG(( "to7_5p14sd_init: CD 90-015 controller\n" )); |
| 460 | | mc6843_config( machine, &to7_6843_itf ); |
| 461 | | state_save_register_global(machine, to7_5p14sd_select ); |
| 457 | state_save_register_global( machine, to7_5p14sd_select ); |
| 462 | 458 | } |
| 463 | 459 | |
| 464 | 460 | |
| r3854 | r3855 | |
| 541 | 537 | to7qdd->data_size = 0; |
| 542 | 538 | } |
| 543 | 539 | |
| 544 | | //VLOG(( "%f to7_qdd_pulse_cb: state=%i\n", attotime_to_double(timer_get_time(machine)), state )); |
| 540 | VLOG(( "%f to7_qdd_pulse_cb: state=%i\n", attotime_to_double(timer_get_time(img->machine)), state )); |
| 545 | 541 | } |
| 546 | 542 | |
| 547 | 543 | |
| r3854 | r3855 | |
| 588 | 584 | |
| 589 | 585 | |
| 590 | 586 | |
| 591 | | static UINT8 to7_qdd_read_byte( void ) |
| 587 | static UINT8 to7_qdd_read_byte( running_machine *machine ) |
| 592 | 588 | { |
| 593 | 589 | UINT8 data; |
| 594 | 590 | |
| r3854 | r3855 | |
| 604 | 600 | else |
| 605 | 601 | data = to7qdd->data[ to7qdd->data_idx ]; |
| 606 | 602 | |
| 607 | | // VLOG(( "%f $%04x to7_qdd_read_byte: RDATA off=%i/%i data=$%02X\n", |
| 608 | | // attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), |
| 609 | | // to7qdd->data_idx, to7qdd->data_size, data )); |
| 603 | VLOG(( "%f $%04x to7_qdd_read_byte: RDATA off=%i/%i data=$%02X\n", |
| 604 | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ), |
| 605 | to7qdd->data_idx, to7qdd->data_size, data )); |
| 610 | 606 | |
| 611 | 607 | to7qdd->data_idx++; |
| 612 | 608 | to7qdd->start_idx = to7qdd->data_idx; |
| r3854 | r3855 | |
| 621 | 617 | * CPU write id field and data field => format |
| 622 | 618 | * CPU write data field after it has read an id field => sector write |
| 623 | 619 | */ |
| 624 | | static void to7_qdd_write_byte( UINT8 data ) |
| 620 | static void to7_qdd_write_byte( running_machine *machine, UINT8 data ) |
| 625 | 621 | { |
| 626 | 622 | int i; |
| 627 | 623 | |
| r3854 | r3855 | |
| 645 | 641 | to7qdd->data[ to7qdd->data_idx ] = data; |
| 646 | 642 | to7qdd->data_idx++; |
| 647 | 643 | |
| 648 | | // VLOG (( "%f $%04x to7_qdd_write_byte: got $%02X offs=%i-%i\n", |
| 649 | | // attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data, |
| 650 | | // to7qdd->start_idx, to7qdd->data_idx )); |
| 644 | VLOG (( "%f $%04x to7_qdd_write_byte: got $%02X offs=%i-%i\n", |
| 645 | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ), data, |
| 646 | to7qdd->start_idx, to7qdd->data_idx )); |
| 651 | 647 | |
| 652 | 648 | /* end of tentative id field */ |
| 653 | 649 | if ( to7qdd->data_idx == to7qdd->start_idx + 4 && |
| r3854 | r3855 | |
| 659 | 655 | int sector = (int) to7qdd->data[ to7qdd->start_idx + 1 ] * 256 + (int) to7qdd->data[ to7qdd->start_idx + 2 ]; |
| 660 | 656 | UINT8 filler = 0xff; |
| 661 | 657 | |
| 662 | | // LOG(( "%f $%04x to7_qdd_write_byte: got id field for sector=%i\n", |
| 663 | | // attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), sector )); |
| 658 | LOG(( "%f $%04x to7_qdd_write_byte: got id field for sector=%i\n", |
| 659 | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ), sector )); |
| 664 | 660 | |
| 665 | 661 | floppy_drive_format_sector( to7_qdd_image(), |
| 666 | 662 | 0, sector, 0, 0, sector, 128, filler ); |
| r3854 | r3855 | |
| 688 | 684 | /* got an id & a data field => write */ |
| 689 | 685 | int sector = (int) to7qdd->data[ i + 1 ] * 256 + (int) to7qdd->data[ i + 2 ]; |
| 690 | 686 | |
| 691 | | // LOG(( "%f $%04x to7_qdd_write_byte: goto data field for sector=%i\n", |
| 692 | | // attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), sector )); |
| 687 | LOG(( "%f $%04x to7_qdd_write_byte: goto data field for sector=%i\n", |
| 688 | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ), sector )); |
| 693 | 689 | |
| 694 | 690 | floppy_drive_write_sector_data( to7_qdd_image(), 0, sector, to7qdd->data + to7qdd->start_idx + 1, 128, 0 ); |
| 695 | 691 | } |
| r3854 | r3855 | |
| 711 | 707 | case 0: /* MC6852 status */ |
| 712 | 708 | to7_qdd_stat_update(); |
| 713 | 709 | VLOG(( "%f $%04x to7_qdd_r: STAT=$%02X irq=%i pe=%i ovr=%i und=%i tr=%i rd=%i ncts=%i\n", |
| 714 | | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), to7qdd->status, |
| 710 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), to7qdd->status, |
| 715 | 711 | to7qdd->status & QDD_S_IRQ ? 1 : 0, |
| 716 | 712 | to7qdd->status & QDD_S_PE ? 1 : 0, |
| 717 | 713 | to7qdd->status & QDD_S_OVR ? 1 : 0, |
| r3854 | r3855 | |
| 724 | 720 | case 1: /* MC6852 data input => read byte from disk */ |
| 725 | 721 | to7qdd->status &= ~(QDD_S_RDA | QDD_S_PE | QDD_S_OVR); |
| 726 | 722 | to7_qdd_stat_update(); |
| 727 | | return to7_qdd_read_byte(); |
| 723 | return to7_qdd_read_byte( space->machine ); |
| 728 | 724 | |
| 729 | 725 | case 8: /* floppy status */ |
| 730 | 726 | { |
| r3854 | r3855 | |
| 734 | 730 | data |= 0x40; /* disk present */ |
| 735 | 731 | if ( to7qdd->index_pulse ) |
| 736 | 732 | data |= 0x80; /* disk start */ |
| 737 | | VLOG(( "%f $%04x to7_qdd_r: STATUS8 $%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data )); |
| 733 | VLOG(( "%f $%04x to7_qdd_r: STATUS8 $%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data )); |
| 738 | 734 | return data; |
| 739 | 735 | } |
| 740 | 736 | |
| 741 | 737 | default: |
| 742 | | logerror ( "%f $%04x to7_qdd_r: invalid read offset %i\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset ); |
| 738 | logerror ( "%f $%04x to7_qdd_r: invalid read offset %i\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), offset ); |
| 743 | 739 | return 0; |
| 744 | 740 | } |
| 745 | 741 | } |
| r3854 | r3855 | |
| 761 | 757 | to7qdd->ctrl1 = ( data & ~(QDD_C1_RRESET | QDD_C1_TRESET) ) |( data & (QDD_C1_RRESET | QDD_C1_TRESET) & to7qdd->ctrl1 ); |
| 762 | 758 | to7_qdd_stat_update(); |
| 763 | 759 | VLOG(( "%f $%04x to7_qdd_w: CTRL1=$%02X reset=%c%c %s%sirq=%c%c\n", |
| 764 | | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, |
| 760 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data, |
| 765 | 761 | data & QDD_C1_RRESET ? 'r' : '-', data & QDD_C1_TRESET ? 't' : '-', |
| 766 | 762 | data & QDD_C1_STRIPSYNC ? "strip-sync " : "", |
| 767 | 763 | data & QDD_C1_CLRSYNC ? "clear-sync " : "", |
| r3854 | r3855 | |
| 785 | 781 | parity = par[ (data >> 3) & 7 ]; |
| 786 | 782 | to7_qdd_stat_update(); |
| 787 | 783 | VLOG(( "%f $%04x to7_qdd_w: CTRL2=$%02X bits=%i par=%s blen=%i under=%s%s\n", |
| 788 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data, |
| 784 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data, |
| 789 | 785 | bits, parname[ parity ], data & QDD_C2_BLEN ? 1 : 2, |
| 790 | 786 | data & QDD_C2_TSYNC ? "sync" : "ff", |
| 791 | 787 | data & QDD_C2_EIE ? "irq-err" : "" )); |
| r3854 | r3855 | |
| 803 | 799 | to7qdd->status &= ~QDD_S_NCTS; |
| 804 | 800 | to7_qdd_stat_update(); |
| 805 | 801 | VLOG(( "%f $%04x to7_qdd_w: CTRL3=$%02X %s%ssync-len=%i sync-mode=%s\n", |
| 806 | | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, |
| 802 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data, |
| 807 | 803 | data & QDD_C3_CLRTUF ? "clr-tuf " : "", |
| 808 | 804 | data & QDD_C3_CLRCTS ? "clr-cts " : "", |
| 809 | 805 | data & QDD_C3_SYNCLEN ? 1 : 2, |
| r3854 | r3855 | |
| 811 | 807 | break; |
| 812 | 808 | |
| 813 | 809 | case 2: /* MC6852 sync code => write byte to disk */ |
| 814 | | to7_qdd_write_byte( data ); |
| 810 | to7_qdd_write_byte( space->machine, data ); |
| 815 | 811 | break; |
| 816 | 812 | |
| 817 | 813 | case 3: /* MC6852 data out => does not seem to be used */ |
| 818 | | VLOG(( "%f $%04x to7_qdd_w: ignored WDATA=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data )); |
| 814 | VLOG(( "%f $%04x to7_qdd_w: ignored WDATA=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data )); |
| 819 | 815 | break; |
| 820 | 816 | |
| 821 | 817 | } |
| r3854 | r3855 | |
| 823 | 819 | |
| 824 | 820 | case 8: /* set drive */ |
| 825 | 821 | to7qdd->drive = data; |
| 826 | | VLOG(( "%f $%04x to7_qdd_w: DRIVE=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data )); |
| 822 | VLOG(( "%f $%04x to7_qdd_w: DRIVE=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data )); |
| 827 | 823 | break; |
| 828 | 824 | |
| 829 | 825 | case 12: /* motor pulse ? */ |
| 830 | | thom_floppy_active( 0 ); |
| 831 | | VLOG(( "%f $%04x to7_qdd_w: MOTOR=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data )); |
| 826 | thom_floppy_active( space->machine, 0 ); |
| 827 | VLOG(( "%f $%04x to7_qdd_w: MOTOR=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data )); |
| 832 | 828 | break; |
| 833 | 829 | |
| 834 | 830 | default: |
| 835 | | logerror ( "%f $%04x to7_qdd_w: invalid write offset %i (data=$%02X)\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset, data ); |
| 831 | logerror ( "%f $%04x to7_qdd_w: invalid write offset %i (data=$%02X)\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), offset, data ); |
| 836 | 832 | } |
| 837 | 833 | } |
| 838 | 834 | |
| r3854 | r3855 | |
| 872 | 868 | to7qdd = auto_malloc( sizeof( *to7qdd ) ); |
| 873 | 869 | assert( to7qdd ); |
| 874 | 870 | |
| 875 | | state_save_register_global(machine, to7qdd->status ); |
| 876 | | state_save_register_global(machine, to7qdd->ctrl1 ); |
| 877 | | state_save_register_global(machine, to7qdd->ctrl2 ); |
| 878 | | state_save_register_global(machine, to7qdd->ctrl3 ); |
| 879 | | state_save_register_global(machine, to7qdd->drive ); |
| 880 | | state_save_register_global(machine, to7qdd->data_idx ); |
| 881 | | state_save_register_global(machine, to7qdd->start_idx ); |
| 882 | | state_save_register_global(machine, to7qdd->data_size ); |
| 883 | | state_save_register_global(machine, to7qdd->data_crc ); |
| 884 | | state_save_register_global(machine, to7qdd->index_pulse ); |
| 885 | | state_save_register_global_array(machine, to7qdd->data ); |
| 871 | state_save_register_global( machine, to7qdd->status ); |
| 872 | state_save_register_global( machine, to7qdd->ctrl1 ); |
| 873 | state_save_register_global( machine, to7qdd->ctrl2 ); |
| 874 | state_save_register_global( machine, to7qdd->ctrl3 ); |
| 875 | state_save_register_global( machine, to7qdd->drive ); |
| 876 | state_save_register_global( machine, to7qdd->data_idx ); |
| 877 | state_save_register_global( machine, to7qdd->start_idx ); |
| 878 | state_save_register_global( machine, to7qdd->data_size ); |
| 879 | state_save_register_global( machine, to7qdd->data_crc ); |
| 880 | state_save_register_global( machine, to7qdd->index_pulse ); |
| 881 | state_save_register_global_array( machine, to7qdd->data ); |
| 886 | 882 | } |
| 887 | 883 | |
| 888 | 884 | |
| r3854 | r3855 | |
| 983 | 979 | thmfc1->data_raw_idx = 0; |
| 984 | 980 | } |
| 985 | 981 | |
| 986 | | //VLOG(( "%f thmfc_floppy_index_pulse_cb: state=%i\n", attotime_to_double(timer_get_time(machine)), state )); |
| 982 | VLOG(( "%f thmfc_floppy_index_pulse_cb: state=%i\n", attotime_to_double(timer_get_time(img->machine)), state )); |
| 987 | 983 | } |
| 988 | 984 | |
| 989 | 985 | |
| r3854 | r3855 | |
| 1025 | 1021 | |
| 1026 | 1022 | |
| 1027 | 1023 | /* complete command (by read, write, or timeout) */ |
| 1028 | | static void thmfc_floppy_cmd_complete(running_machine *machine) |
| 1024 | static void thmfc_floppy_cmd_complete( running_machine *machine ) |
| 1029 | 1025 | { |
| 1030 | 1026 | LOG (( "%f thmfc_floppy_cmd_complete_cb: cmd=%i off=%i/%i/%i\n", |
| 1031 | 1027 | attotime_to_double(timer_get_time(machine)), thmfc1->op, thmfc1->data_idx, |
| r3854 | r3855 | |
| 1048 | 1044 | |
| 1049 | 1045 | static TIMER_CALLBACK( thmfc_floppy_cmd_complete_cb ) |
| 1050 | 1046 | { |
| 1051 | | thmfc_floppy_cmd_complete(machine); |
| 1047 | thmfc_floppy_cmd_complete( machine ); |
| 1052 | 1048 | } |
| 1053 | 1049 | |
| 1054 | 1050 | |
| r3854 | r3855 | |
| 1058 | 1054 | { |
| 1059 | 1055 | UINT8 data = thmfc1->data[ thmfc1->data_idx ]; |
| 1060 | 1056 | |
| 1061 | | // VLOG(( "%f $%04x thmfc_floppy_read_byte: off=%i/%i/%i data=$%02X\n", |
| 1062 | | // attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), |
| 1063 | | // thmfc1->data_idx, thmfc1->data_finish - 1, thmfc1->data_size - 1, |
| 1064 | | // data )); |
| 1057 | VLOG(( "%f $%04x thmfc_floppy_read_byte: off=%i/%i/%i data=$%02X\n", |
| 1058 | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ), |
| 1059 | thmfc1->data_idx, thmfc1->data_finish - 1, thmfc1->data_size - 1, |
| 1060 | data )); |
| 1065 | 1061 | |
| 1066 | 1062 | if ( thmfc1->data_idx >= thmfc1->data_size - 1 ) |
| 1067 | | thmfc_floppy_cmd_complete(machine); |
| 1063 | thmfc_floppy_cmd_complete( machine ); |
| 1068 | 1064 | else |
| 1069 | 1065 | thmfc1->data_idx++; |
| 1070 | 1066 | |
| r3854 | r3855 | |
| 1077 | 1073 | |
| 1078 | 1074 | |
| 1079 | 1075 | /* dumb read: show whole track with field headers and gaps */ |
| 1080 | | static UINT8 thmfc_floppy_raw_read_byte ( void ) |
| 1076 | static UINT8 thmfc_floppy_raw_read_byte ( running_machine *machine ) |
| 1081 | 1077 | { |
| 1082 | 1078 | UINT8 data; |
| 1083 | 1079 | |
| r3854 | r3855 | |
| 1101 | 1097 | else |
| 1102 | 1098 | data = thmfc1->data[ thmfc1->data_raw_idx ]; |
| 1103 | 1099 | |
| 1104 | | // VLOG(( "%f $%04x thmfc_floppy_raw_read_byte: off=%i/%i data=$%02X\n", |
| 1105 | | // attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), |
| 1106 | | // thmfc1->data_raw_idx, thmfc1->data_raw_size, data )); |
| 1100 | VLOG(( "%f $%04x thmfc_floppy_raw_read_byte: off=%i/%i data=$%02X\n", |
| 1101 | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ), |
| 1102 | thmfc1->data_raw_idx, thmfc1->data_raw_size, data )); |
| 1107 | 1103 | |
| 1108 | 1104 | thmfc1->data_raw_idx++; |
| 1109 | 1105 | |
| r3854 | r3855 | |
| 1113 | 1109 | |
| 1114 | 1110 | |
| 1115 | 1111 | /* QDD writing / formating */ |
| 1116 | | static void thmfc_floppy_qdd_write_byte ( UINT8 data ) |
| 1112 | static void thmfc_floppy_qdd_write_byte ( running_machine *machine, UINT8 data ) |
| 1117 | 1113 | { |
| 1118 | 1114 | int i; |
| 1119 | 1115 | |
| r3854 | r3855 | |
| 1139 | 1135 | thmfc1->data_idx = thmfc1->data_raw_idx; |
| 1140 | 1136 | } |
| 1141 | 1137 | |
| 1142 | | // VLOG (( "%f $%04x thmfc_floppy_qdd_write_byte: $%02X offs=%i-%i\n", |
| 1143 | | // attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data, |
| 1144 | | // thmfc1->data_idx,thmfc1->data_raw_idx )); |
| 1138 | VLOG (( "%f $%04x thmfc_floppy_qdd_write_byte: $%02X offs=%i-%i\n", |
| 1139 | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ), data, |
| 1140 | thmfc1->data_idx,thmfc1->data_raw_idx )); |
| 1145 | 1141 | |
| 1146 | 1142 | if ( thmfc1->data_raw_idx == thmfc1->data_idx + 3 && |
| 1147 | 1143 | thmfc1->data[ thmfc1->data_idx - 1 ] == 0xA5 && |
| r3854 | r3855 | |
| 1152 | 1148 | int sector = (int) thmfc1->data[ thmfc1->data_idx ] * 256 + (int) thmfc1->data[ thmfc1->data_idx + 1 ]; |
| 1153 | 1149 | UINT8 filler = 0xff; |
| 1154 | 1150 | |
| 1155 | | // LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: id field, sector=%i\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), sector )); |
| 1151 | LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: id field, sector=%i\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ), sector )); |
| 1156 | 1152 | |
| 1157 | 1153 | floppy_drive_format_sector( thmfc_floppy_image(), 0, sector, 0, 0, sector, 128, filler ); |
| 1158 | 1154 | thmfc1->data_idx = 0; |
| r3854 | r3855 | |
| 1180 | 1176 | int sector = (int) thmfc1->data[ i + 1 ] * 256 + |
| 1181 | 1177 | (int) thmfc1->data[ i + 2 ]; |
| 1182 | 1178 | |
| 1183 | | // LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: data field, sector=%i\n", |
| 1184 | | // attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), sector )); |
| 1179 | LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: data field, sector=%i\n", |
| 1180 | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ), sector )); |
| 1185 | 1181 | |
| 1186 | 1182 | floppy_drive_write_sector_data( img, 0, sector, thmfc1->data + thmfc1->data_idx, 128, 0 ); |
| 1187 | 1183 | } |
| r3854 | r3855 | |
| 1195 | 1191 | else |
| 1196 | 1192 | { |
| 1197 | 1193 | thmfc1->data_raw_idx++; |
| 1198 | | // VLOG (( "%f $%04x thmfc_floppy_qdd_write_byte: ignored $%02X\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data )); |
| 1194 | VLOG (( "%f $%04x thmfc_floppy_qdd_write_byte: ignored $%02X\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ), data )); |
| 1199 | 1195 | } |
| 1200 | 1196 | |
| 1201 | 1197 | } |
| r3854 | r3855 | |
| 1205 | 1201 | /* intelligent writing */ |
| 1206 | 1202 | static void thmfc_floppy_write_byte ( running_machine *machine, UINT8 data ) |
| 1207 | 1203 | { |
| 1208 | | // VLOG (( "%f $%04x thmfc_floppy_write_byte: off=%i/%i data=$%02X\n", |
| 1209 | | // attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), |
| 1210 | | // thmfc1->data_idx, thmfc1->data_size - 1, data )); |
| 1204 | VLOG (( "%f $%04x thmfc_floppy_write_byte: off=%i/%i data=$%02X\n", |
| 1205 | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ), |
| 1206 | thmfc1->data_idx, thmfc1->data_size - 1, data )); |
| 1211 | 1207 | |
| 1212 | 1208 | thmfc1->data_raw_size = 0; |
| 1213 | 1209 | thmfc1->data[ thmfc1->data_idx ] = data; |
| 1214 | 1210 | if ( thmfc1->data_idx >= thmfc1->data_size - 1 ) |
| 1215 | | thmfc_floppy_cmd_complete(machine); |
| 1211 | thmfc_floppy_cmd_complete( machine ); |
| 1216 | 1212 | else |
| 1217 | 1213 | thmfc1->data_idx++; |
| 1218 | 1214 | } |
| 1219 | 1215 | |
| 1220 | 1216 | /* intelligent formatting */ |
| 1221 | | static void thmfc_floppy_format_byte ( UINT8 data ) |
| 1217 | static void thmfc_floppy_format_byte ( running_machine *machine, UINT8 data ) |
| 1222 | 1218 | { |
| 1223 | | // VLOG (( "%f $%04x thmfc_floppy_format_byte: $%02X\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data )); |
| 1219 | VLOG (( "%f $%04x thmfc_floppy_format_byte: $%02X\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc( machine->cpu[0] ), data )); |
| 1224 | 1220 | |
| 1225 | 1221 | thmfc1->data_raw_size = 0; |
| 1226 | 1222 | |
| r3854 | r3855 | |
| 1260 | 1256 | |
| 1261 | 1257 | case 0: /* STAT0 */ |
| 1262 | 1258 | thmfc1->stat0 ^= THMFC1_STAT0_SYNCHRO | THMFC1_STAT0_BYTE_READY_POL; |
| 1263 | | VLOG(( "%f $%04x thmfc_floppy_r: STAT0=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), thmfc1->stat0 )); |
| 1259 | VLOG(( "%f $%04x thmfc_floppy_r: STAT0=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), thmfc1->stat0 )); |
| 1264 | 1260 | return thmfc1->stat0; |
| 1265 | 1261 | |
| 1266 | 1262 | case 1: /* STAT1 */ |
| r3854 | r3855 | |
| 1291 | 1287 | data |= 0x10; |
| 1292 | 1288 | if ( flags & FLOPPY_DRIVE_DISK_WRITE_PROTECTED ) |
| 1293 | 1289 | data |= 0x04; |
| 1294 | | VLOG(( "%f $%04x thmfc_floppy_r: STAT1=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data )); |
| 1290 | VLOG(( "%f $%04x thmfc_floppy_r: STAT1=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data )); |
| 1295 | 1291 | return data; |
| 1296 | 1292 | } |
| 1297 | 1293 | |
| 1298 | 1294 | case 3: /* RDATA */ |
| 1299 | 1295 | |
| 1300 | 1296 | if ( thmfc1->op == THMFC1_OP_READ_SECT || thmfc1->op == THMFC1_OP_READ_ADDR ) |
| 1301 | | return thmfc_floppy_read_byte(space->machine); |
| 1297 | return thmfc_floppy_read_byte( space->machine ); |
| 1302 | 1298 | else |
| 1303 | | return thmfc_floppy_raw_read_byte(); |
| 1299 | return thmfc_floppy_raw_read_byte( space->machine ); |
| 1304 | 1300 | |
| 1305 | 1301 | case 6: |
| 1306 | 1302 | return 0; |
| r3854 | r3855 | |
| 1309 | 1305 | { |
| 1310 | 1306 | /* undocumented => emulate TO7 QDD controller ? */ |
| 1311 | 1307 | UINT8 data = thmfc1->ipl << 7; |
| 1312 | | VLOG(( "%f $%04x thmfc_floppy_r: STAT8=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data )); |
| 1308 | VLOG(( "%f $%04x thmfc_floppy_r: STAT8=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data )); |
| 1313 | 1309 | return data; |
| 1314 | 1310 | } |
| 1315 | 1311 | |
| 1316 | 1312 | default: |
| 1317 | | logerror ( "%f $%04x thmfc_floppy_r: invalid read offset %i\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset ); |
| 1313 | logerror ( "%f $%04x thmfc_floppy_r: invalid read offset %i\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), offset ); |
| 1318 | 1314 | return 0; |
| 1319 | 1315 | } |
| 1320 | 1316 | } |
| r3854 | r3855 | |
| 1334 | 1330 | thom_floppy_set_density( dens ); |
| 1335 | 1331 | thmfc1->formatting = (data >> 2) & 1; |
| 1336 | 1332 | LOG (( "%f $%04x thmfc_floppy_w: CMD0=$%02X dens=%s wsync=%i dsync=%i fmt=%i op=%i\n", |
| 1337 | | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, |
| 1333 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data, |
| 1338 | 1334 | (dens == DEN_FM_LO) ? "MF" : "MFM", |
| 1339 | 1335 | wsync, (data >> 3) & 1, |
| 1340 | 1336 | thmfc1->formatting, data & 3 )); |
| r3854 | r3855 | |
| 1419 | 1415 | if ( thmfc1->sector_size > 256 ) |
| 1420 | 1416 | { |
| 1421 | 1417 | logerror( "$%04x thmfc_floppy_w: sector size %i > 256 not handled\n", |
| 1422 | | cpu_get_previouspc(space->cpu), thmfc1->sector_size ); |
| 1418 | cpu_get_previouspc( space->machine->cpu[0] ), thmfc1->sector_size ); |
| 1423 | 1419 | thmfc1->sector_size = 256; |
| 1424 | 1420 | } |
| 1425 | 1421 | |
| 1426 | 1422 | LOG (( "%f $%04x thmfc_floppy_w: CMD1=$%02X sect-size=%i comp=%i head=%i\n", |
| 1427 | | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, |
| 1423 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data, |
| 1428 | 1424 | thmfc1->sector_size, (data >> 1) & 7, thmfc1->side )); |
| 1429 | 1425 | break; |
| 1430 | 1426 | |
| r3854 | r3855 | |
| 1449 | 1445 | } |
| 1450 | 1446 | |
| 1451 | 1447 | img = thmfc_floppy_image(); |
| 1452 | | thom_floppy_active( 0 ); |
| 1448 | thom_floppy_active( space->machine, 0 ); |
| 1453 | 1449 | |
| 1454 | 1450 | LOG (( "%f $%04x thmfc_floppy_w: CMD2=$%02X drv=%i step=%i motor=%i\n", |
| 1455 | | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, |
| 1451 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data, |
| 1456 | 1452 | thmfc1->drive, seek, motor )); |
| 1457 | 1453 | |
| 1458 | 1454 | if ( seek ) |
| r3854 | r3855 | |
| 1473 | 1469 | case 3: /* WDATA */ |
| 1474 | 1470 | thmfc1->wsync = data; |
| 1475 | 1471 | if ( thmfc_floppy_is_qdd() ) |
| 1476 | | thmfc_floppy_qdd_write_byte( data ); |
| 1472 | thmfc_floppy_qdd_write_byte( space->machine, data ); |
| 1477 | 1473 | else if ( thmfc1->op==THMFC1_OP_WRITE_SECT ) |
| 1478 | 1474 | thmfc_floppy_write_byte( space->machine, data ); |
| 1479 | 1475 | else if ( thmfc1->formatting ) |
| 1480 | | thmfc_floppy_format_byte( data ); |
| 1476 | thmfc_floppy_format_byte( space->machine, data ); |
| 1481 | 1477 | else |
| 1482 | 1478 | { |
| 1483 | 1479 | /* TODO: implement other forms of raw track writing */ |
| 1484 | 1480 | LOG (( "%f $%04x thmfc_floppy_w: ignored raw WDATA $%02X\n", |
| 1485 | | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data )); |
| 1481 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data )); |
| 1486 | 1482 | } |
| 1487 | 1483 | break; |
| 1488 | 1484 | |
| r3854 | r3855 | |
| 1490 | 1486 | case 4: /* WCLK (unemulated) */ |
| 1491 | 1487 | /* clock configuration: FF for data, 0A for synchro */ |
| 1492 | 1488 | LOG (( "%f $%04x thmfc_floppy_w: WCLK=$%02X (%s)\n", |
| 1493 | | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, |
| 1489 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data, |
| 1494 | 1490 | (data == 0xff) ? "data" : (data == 0x0A) ? "synchro" : "?" )); |
| 1495 | 1491 | break; |
| 1496 | 1492 | |
| 1497 | 1493 | case 5: /* WSECT */ |
| 1498 | 1494 | thmfc1->sector = data; |
| 1499 | 1495 | LOG (( "%f $%04x thmfc_floppy_w: WSECT=%i\n", |
| 1500 | | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data )); |
| 1496 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data )); |
| 1501 | 1497 | break; |
| 1502 | 1498 | |
| 1503 | 1499 | case 6: /* WTRCK */ |
| 1504 | 1500 | thmfc1->track = data; |
| 1505 | 1501 | LOG (( "%f $%04x thmfc_floppy_w: WTRCK=%i (real=%i)\n", |
| 1506 | | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, |
| 1502 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data, |
| 1507 | 1503 | floppy_drive_get_current_track( thmfc_floppy_image() ) )); |
| 1508 | 1504 | break; |
| 1509 | 1505 | |
| 1510 | 1506 | case 7: /* WCELL */ |
| 1511 | 1507 | /* precompensation (unemulated) */ |
| 1512 | 1508 | LOG (( "%f $%04x thmfc_floppy_w: WCELL=$%02X\n", |
| 1513 | | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data )); |
| 1509 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), data )); |
| 1514 | 1510 | break; |
| 1515 | 1511 | |
| 1516 | 1512 | default: |
| 1517 | 1513 | logerror ( "%f $%04x thmfc_floppy_w: invalid write offset %i (data=$%02X)\n", |
| 1518 | | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset, data ); |
| 1514 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), offset, data ); |
| 1519 | 1515 | } |
| 1520 | 1516 | } |
| 1521 | 1517 | |
| r3854 | r3855 | |
| 1561 | 1557 | thmfc1 = auto_malloc( sizeof( *thmfc1 ) ); |
| 1562 | 1558 | assert( thmfc1 ); |
| 1563 | 1559 | |
| 1564 | | thmfc_floppy_cmd = timer_alloc(machine, thmfc_floppy_cmd_complete_cb, NULL ); |
| 1560 | thmfc_floppy_cmd = timer_alloc( machine, thmfc_floppy_cmd_complete_cb, NULL ); |
| 1565 | 1561 | |
| 1566 | | state_save_register_global(machine, thmfc1->op ); |
| 1567 | | state_save_register_global(machine, thmfc1->sector ); |
| 1568 | | state_save_register_global(machine, thmfc1->track ); |
| 1569 | | state_save_register_global(machine, thmfc1->side ); |
| 1570 | | state_save_register_global(machine, thmfc1->drive ); |
| 1571 | | state_save_register_global(machine, thmfc1->sector_size ); |
| 1572 | | state_save_register_global(machine, thmfc1->formatting ); |
| 1573 | | state_save_register_global(machine, thmfc1->ipl ); |
| 1574 | | state_save_register_global(machine, thmfc1->data_idx ); |
| 1575 | | state_save_register_global(machine, thmfc1->data_size ); |
| 1576 | | state_save_register_global(machine, thmfc1->data_finish ); |
| 1577 | | state_save_register_global(machine, thmfc1->stat0 ); |
| 1578 | | state_save_register_global(machine, thmfc1->data_raw_idx ); |
| 1579 | | state_save_register_global(machine, thmfc1->data_raw_size ); |
| 1580 | | state_save_register_global(machine, thmfc1->data_crc ); |
| 1581 | | state_save_register_global(machine, thmfc1->wsync ); |
| 1582 | | state_save_register_global_array(machine, thmfc1->data ); |
| 1562 | state_save_register_global( machine, thmfc1->op ); |
| 1563 | state_save_register_global( machine, thmfc1->sector ); |
| 1564 | state_save_register_global( machine, thmfc1->track ); |
| 1565 | state_save_register_global( machine, thmfc1->side ); |
| 1566 | state_save_register_global( machine, thmfc1->drive ); |
| 1567 | state_save_register_global( machine, thmfc1->sector_size ); |
| 1568 | state_save_register_global( machine, thmfc1->formatting ); |
| 1569 | state_save_register_global( machine, thmfc1->ipl ); |
| 1570 | state_save_register_global( machine, thmfc1->data_idx ); |
| 1571 | state_save_register_global( machine, thmfc1->data_size ); |
| 1572 | state_save_register_global( machine, thmfc1->data_finish ); |
| 1573 | state_save_register_global( machine, thmfc1->stat0 ); |
| 1574 | state_save_register_global( machine, thmfc1->data_raw_idx ); |
| 1575 | state_save_register_global( machine, thmfc1->data_raw_size ); |
| 1576 | state_save_register_global( machine, thmfc1->data_crc ); |
| 1577 | state_save_register_global( machine, thmfc1->wsync ); |
| 1578 | state_save_register_global_array( machine, thmfc1->data ); |
| 1583 | 1579 | } |
| 1584 | 1580 | |
| 1585 | 1581 | |
| r3854 | r3855 | |
| 1600 | 1596 | static TIMER_CALLBACK( ans4 ) |
| 1601 | 1597 | { |
| 1602 | 1598 | LOG(( "%f ans4\n", attotime_to_double(timer_get_time(machine)) )); |
| 1603 | | mc6854_set_cts( 0 ); |
| 1599 | mc6854_set_cts( devtag_get_device(machine, MC6854, "mc6854"), 0 ); |
| 1604 | 1600 | } |
| 1605 | 1601 | |
| 1606 | 1602 | static TIMER_CALLBACK( ans3 ) |
| 1607 | 1603 | { |
| 1608 | 1604 | LOG(( "%f ans3\n", attotime_to_double(timer_get_time(machine)) )); |
| 1609 | | mc6854_set_cts( 1 ); |
| 1610 | | timer_set(machine, ATTOTIME_IN_USEC( 100 ), NULL, 0, ans4 ); |
| 1605 | mc6854_set_cts( devtag_get_device(machine, MC6854, "mc6854"), 1 ); |
| 1606 | timer_set( machine, ATTOTIME_IN_USEC( 100 ), NULL, 0, ans4 ); |
| 1611 | 1607 | } |
| 1612 | 1608 | |
| 1613 | 1609 | static TIMER_CALLBACK( ans2 ) |
| 1614 | 1610 | { |
| 1615 | 1611 | LOG(( "%f ans2\n", attotime_to_double(timer_get_time(machine)) )); |
| 1616 | | mc6854_set_cts( 0 ); |
| 1617 | | timer_set(machine, ATTOTIME_IN_USEC( 100 ), NULL, 0, ans3 ); |
| 1612 | mc6854_set_cts( devtag_get_device(machine, MC6854, "mc6854"), 0 ); |
| 1613 | timer_set( machine, ATTOTIME_IN_USEC( 100 ), NULL, 0, ans3 ); |
| 1618 | 1614 | } |
| 1619 | 1615 | |
| 1620 | 1616 | static TIMER_CALLBACK( ans ) |
| 1621 | 1617 | { |
| 1622 | 1618 | LOG(( "%f ans\n", attotime_to_double(timer_get_time(machine)) )); |
| 1623 | | mc6854_set_cts( 1 ); |
| 1624 | | timer_set(machine, ATTOTIME_IN_USEC( 100 ), NULL, 0, ans2 ); |
| 1619 | mc6854_set_cts( devtag_get_device(machine, MC6854, "mc6854"), 1 ); |
| 1620 | timer_set( machine, ATTOTIME_IN_USEC( 100 ), NULL, 0, ans2 ); |
| 1625 | 1621 | } |
| 1626 | 1622 | /* consigne DKBOOT |
| 1627 | 1623 | |
| r3854 | r3855 | |
| 1652 | 1648 | |
| 1653 | 1649 | */ |
| 1654 | 1650 | |
| 1655 | | static void to7_network_got_frame( running_machine *machine, UINT8* data, int length ) |
| 1651 | static void to7_network_got_frame( const device_config *device, UINT8* data, int length ) |
| 1656 | 1652 | { |
| 1657 | 1653 | int i; |
| 1658 | | LOG(( "%f to7_network_got_frame:", attotime_to_double(timer_get_time(machine)) )); |
| 1654 | LOG(( "%f to7_network_got_frame:", attotime_to_double(timer_get_time(device->machine)) )); |
| 1659 | 1655 | for ( i = 0; i < length; i++ ) |
| 1660 | 1656 | LOG(( " $%02X", data[i] )); |
| 1661 | 1657 | LOG(( "\n" )); |
| r3854 | r3855 | |
| 1663 | 1659 | if ( data[1] == 0xff ) |
| 1664 | 1660 | { |
| 1665 | 1661 | LOG(( "to7_network_got_frame: %i phones %i\n", data[2], data[0] )); |
| 1666 | | timer_set(machine, ATTOTIME_IN_USEC( 100 ), NULL, 0, ans ); |
| 1667 | | mc6854_set_cts( 0 ); |
| 1662 | timer_set( device->machine, ATTOTIME_IN_USEC( 100 ), NULL, 0, ans ); |
| 1663 | mc6854_set_cts( device, 0 ); |
| 1668 | 1664 | } |
| 1669 | 1665 | else if ( ! data[1] ) |
| 1670 | 1666 | { |
| r3854 | r3855 | |
| 1686 | 1682 | |
| 1687 | 1683 | |
| 1688 | 1684 | |
| 1689 | | static const mc6854_interface network_iface = { NULL, to7_network_got_frame, NULL, NULL }; |
| 1685 | mc6854_interface to7_network_iface = { NULL, to7_network_got_frame, NULL, NULL }; |
| 1690 | 1686 | |
| 1691 | 1687 | |
| 1692 | 1688 | |
| r3854 | r3855 | |
| 1694 | 1690 | { |
| 1695 | 1691 | LOG(( "to7_network_init: NR 07-005 network extension\n" )); |
| 1696 | 1692 | logerror( "to7_network_init: network not handled!\n" ); |
| 1697 | | mc6854_config( machine, &network_iface ); |
| 1698 | 1693 | } |
| 1699 | 1694 | |
| 1700 | 1695 | |
| 1701 | 1696 | |
| 1702 | | static void to7_network_reset( void ) |
| 1697 | static void to7_network_reset( running_machine *machine ) |
| 1703 | 1698 | { |
| 1704 | 1699 | LOG(( "to7_network_reset: NR 07-005 network extension\n" )); |
| 1705 | | mc6854_reset(); |
| 1706 | | mc6854_set_cts( 1 ); |
| 1700 | mc6854_set_cts( devtag_get_device(machine, MC6854, "mc6854"), 0 ); |
| 1701 | mc6854_set_cts( devtag_get_device(machine, MC6854, "mc6854"), 1 ); |
| 1707 | 1702 | } |
| 1708 | 1703 | |
| 1709 | 1704 | |
| r3854 | r3855 | |
| 1711 | 1706 | static READ8_HANDLER ( to7_network_r ) |
| 1712 | 1707 | { |
| 1713 | 1708 | if ( offset >= 0 && offset < 4 ) |
| 1714 | | return mc6854_r( space, offset ); |
| 1709 | return mc6854_r( devtag_get_device(space->machine, MC6854, "mc6854"), offset ); |
| 1715 | 1710 | |
| 1716 | 1711 | if ( offset == 8 ) |
| 1717 | 1712 | { |
| 1718 | 1713 | /* network ID of the computer */ |
| 1719 | 1714 | UINT8 id = input_port_read(space->machine, "fconfig") >> 3; |
| 1720 | | VLOG(( "%f $%04x to7_network_r: read id $%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), id )); |
| 1715 | VLOG(( "%f $%04x to7_network_r: read id $%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), id )); |
| 1721 | 1716 | return id; |
| 1722 | 1717 | } |
| 1723 | 1718 | |
| 1724 | | logerror( "%f $%04x to7_network_r: invalid read offset %i\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset ); |
| 1719 | logerror( "%f $%04x to7_network_r: invalid read offset %i\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), offset ); |
| 1725 | 1720 | return 0; |
| 1726 | 1721 | } |
| 1727 | 1722 | |
| r3854 | r3855 | |
| 1730 | 1725 | static WRITE8_HANDLER ( to7_network_w ) |
| 1731 | 1726 | { |
| 1732 | 1727 | if ( offset >= 0 && offset < 4 ) |
| 1733 | | mc6854_w( space, offset, data ); |
| 1728 | mc6854_w( devtag_get_device(space->machine, MC6854, "mc6854"), offset, data ); |
| 1734 | 1729 | else |
| 1735 | 1730 | { |
| 1736 | 1731 | logerror( "%f $%04x to7_network_w: invalid write offset %i (data=$%02X)\n", |
| 1737 | | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset, data ); |
| 1732 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc( space->machine->cpu[0] ), offset, data ); |
| 1738 | 1733 | } |
| 1739 | 1734 | } |
| 1740 | 1735 | |
| r3854 | r3855 | |
| 1761 | 1756 | void to7_floppy_init ( running_machine *machine, void* base ) |
| 1762 | 1757 | { |
| 1763 | 1758 | memory_configure_bank( machine, THOM_FLOP_BANK, 0, TO7_NB_FLOP_BANK, base, 0x800 ); |
| 1764 | | state_save_register_global(machine, to7_controller_type ); |
| 1765 | | state_save_register_global(machine, to7_floppy_bank ); |
| 1759 | state_save_register_global( machine, to7_controller_type ); |
| 1760 | state_save_register_global( machine, to7_floppy_bank ); |
| 1766 | 1761 | to7_5p14sd_init(machine); |
| 1767 | 1762 | to7_5p14_init(machine); |
| 1768 | 1763 | to7_qdd_init(machine); |
| r3854 | r3855 | |
| 1801 | 1796 | |
| 1802 | 1797 | case 5: |
| 1803 | 1798 | to7_floppy_bank = 8; |
| 1804 | | to7_network_reset(); |
| 1799 | to7_network_reset(machine); |
| 1805 | 1800 | break; |
| 1806 | 1801 | |
| 1807 | 1802 | default: |