src/mess/machine/mc6854.c
| r3775 | r3776 | |
| 538 | 538 | |
| 539 | 539 | |
| 540 | 540 | /* CPU pops the FIFO */ |
| 541 | | static UINT8 mc6854_rfifo_pop( void ) |
| 541 | static UINT8 mc6854_rfifo_pop( running_machine *machine ) |
| 542 | 542 | { |
| 543 | 543 | int i, data = mc6854->rfifo[ FIFO_SIZE - 1 ]; |
| 544 | 544 | |
| r3775 | r3776 | |
| 556 | 556 | /* auto-refill in frame mode */ |
| 557 | 557 | if ( mc6854->flen > 0 ) |
| 558 | 558 | { |
| 559 | | mc6854_rfifo_push( mc6854->frame[ mc6854->fpos++ ] ); |
| 559 | mc6854_rfifo_push( machine, mc6854->frame[ mc6854->fpos++ ] ); |
| 560 | 560 | if ( mc6854->fpos == mc6854->flen ) |
| 561 | 561 | mc6854_rfifo_terminate(); |
| 562 | 562 | } |
| r3775 | r3776 | |
| 566 | 566 | |
| 567 | 567 | |
| 568 | 568 | /* MC6854 makes fields from bits */ |
| 569 | | void mc6854_set_rx( int bit ) |
| 569 | void mc6854_set_rx( running_machine *machine, int bit ) |
| 570 | 570 | { |
| 571 | 571 | int fieldlen = ( mc6854->rstate < 6 ) ? 8 : RWL; |
| 572 | 572 | |
| r3775 | r3776 | |
| 593 | 593 | { |
| 594 | 594 | mc6854->rsize++; |
| 595 | 595 | if ( mc6854->rstate && mc6854->rsize >= fieldlen + 24 ) |
| 596 | | mc6854_rfifo_push( mc6854->rreg ); |
| 596 | mc6854_rfifo_push( machine, mc6854->rreg ); |
| 597 | 597 | } |
| 598 | 598 | } |
| 599 | 599 | else if ( mc6854->rones == 5 ) |
| r3775 | r3776 | |
| 614 | 614 | mc6854->rreg >>= 1; |
| 615 | 615 | mc6854->rsize++; |
| 616 | 616 | if ( mc6854->rsize >= fieldlen + 24 ) /* last field */ |
| 617 | | mc6854_rfifo_push( mc6854->rreg ); |
| 617 | mc6854_rfifo_push( machine, mc6854->rreg ); |
| 618 | 618 | mc6854_rfifo_terminate(); |
| 619 | 619 | LOG(( "%f mc6854_receive_bit: end of frame\n", attotime_to_double(timer_get_time(machine)) )); |
| 620 | 620 | } |
| r3775 | r3776 | |
| 627 | 627 | mc6854->rreg >>= 1; |
| 628 | 628 | mc6854->rsize++; |
| 629 | 629 | if ( mc6854->rstate && mc6854->rsize >= fieldlen + 24 ) |
| 630 | | mc6854_rfifo_push( mc6854->rreg ); |
| 630 | mc6854_rfifo_push( machine, mc6854->rreg ); |
| 631 | 631 | } |
| 632 | 632 | } |
| 633 | 633 | |
| r3775 | r3776 | |
| 645 | 645 | |
| 646 | 646 | |
| 647 | 647 | |
| 648 | | int mc6854_send_frame( UINT8* data, int len ) |
| 648 | int mc6854_send_frame( running_machine *machine, UINT8* data, int len ) |
| 649 | 649 | { |
| 650 | 650 | if ( mc6854->rstate > 1 || mc6854->tstate > 1 || RTS ) |
| 651 | 651 | return -1; /* busy */ |
| r3775 | r3776 | |
| 665 | 665 | mc6854->sr1 |= FD; |
| 666 | 666 | mc6854->flen = len; |
| 667 | 667 | mc6854->fpos = 0; |
| 668 | | mc6854_rfifo_push( mc6854->frame[ mc6854->fpos++ ] ); |
| 669 | | mc6854_rfifo_push( mc6854->frame[ mc6854->fpos++ ] ); |
| 668 | mc6854_rfifo_push( machine, mc6854->frame[ mc6854->fpos++ ] ); |
| 669 | mc6854_rfifo_push( machine, mc6854->frame[ mc6854->fpos++ ] ); |
| 670 | 670 | if ( mc6854->fpos == mc6854->flen ) |
| 671 | 671 | mc6854_rfifo_terminate(); |
| 672 | 672 | return 0; |
| r3775 | r3776 | |
| 777 | 777 | case 0: /* status register 1 */ |
| 778 | 778 | mc6854_update_sr1(); |
| 779 | 779 | LOG(( "%f $%04x mc6854_r: get SR1=$%02X (rda=%i,s2rq=%i,fd=%i,cts=%i,tu=%i,tdra=%i,irq=%i)\n", |
| 780 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), mc6854->sr1, |
| 780 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), mc6854->sr1, |
| 781 | 781 | ( mc6854->sr1 & RDA) ? 1 : 0, ( mc6854->sr1 & S2RQ) ? 1 : 0, |
| 782 | 782 | ( mc6854->sr1 & FD ) ? 1 : 0, ( mc6854->sr1 & CTS ) ? 1 : 0, |
| 783 | 783 | ( mc6854->sr1 & TU ) ? 1 : 0, ( mc6854->sr1 & TDRA) ? 1 : 0, |
| r3775 | r3776 | |
| 787 | 787 | case 1: /* status register 2 */ |
| 788 | 788 | mc6854_update_sr2(); |
| 789 | 789 | LOG(( "%f $%04x mc6854_r: get SR2=$%02X (ap=%i,fv=%i,ridle=%i,rabt=%i,err=%i,dcd=%i,ovrn=%i,rda2=%i)\n", |
| 790 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), mc6854->sr2, |
| 790 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), mc6854->sr2, |
| 791 | 791 | ( mc6854->sr2 & AP ) ? 1 : 0, ( mc6854->sr2 & FV ) ? 1 : 0, |
| 792 | 792 | ( mc6854->sr2 & RIDLE) ? 1 : 0, ( mc6854->sr2 & RABT) ? 1 : 0, |
| 793 | 793 | ( mc6854->sr2 & ERR ) ? 1 : 0, ( mc6854->sr2 & DCD ) ? 1 : 0, |
| r3775 | r3776 | |
| 797 | 797 | case 2: /* receiver data register */ |
| 798 | 798 | case 3: |
| 799 | 799 | { |
| 800 | | UINT8 data = mc6854_rfifo_pop(); |
| 800 | UINT8 data = mc6854_rfifo_pop(space->machine); |
| 801 | 801 | LOG(( "%f $%04x mc6854_r: get data $%02X\n", |
| 802 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data )); |
| 802 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data )); |
| 803 | 803 | return data; |
| 804 | 804 | } |
| 805 | 805 | |
| r3775 | r3776 | |
| 819 | 819 | case 0: /* control register 1 */ |
| 820 | 820 | mc6854->cr1 = data; |
| 821 | 821 | LOG(( "%f $%04x mc6854_w: set CR1=$%02X (ac=%i,irq=%c%c,%sreset=%c%c)\n", |
| 822 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), mc6854->cr1, |
| 822 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), mc6854->cr1, |
| 823 | 823 | AC ? 1 : 0, |
| 824 | 824 | RIE ? 'r' : '-', TIE ? 't' : '-', |
| 825 | 825 | DISCONTINUE ? "discontinue," : "", |
| r3775 | r3776 | |
| 856 | 856 | /* control register 3 */ |
| 857 | 857 | mc6854->cr3 = data; |
| 858 | 858 | LOG(( "%f $%04x mc6854_w: set CR3=$%02X (lcf=%i,aex=%i,idl=%i,fdse=%i,loop=%i,tst=%i,dtr=%i)\n", |
| 859 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), mc6854->cr3, |
| 859 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), mc6854->cr3, |
| 860 | 860 | LCF ? (CEX ? 16 : 8) : 0, AEX ? 1 : 0, |
| 861 | 861 | IDL0 ? 0 : 1, FDSE ? 1 : 0, LOOP ? 1 : 0, |
| 862 | 862 | TST ? 1 : 0, DTR ? 1 : 0 |
| r3775 | r3776 | |
| 875 | 875 | /* control register 2 */ |
| 876 | 876 | mc6854->cr2 = data; |
| 877 | 877 | LOG(( "%f $%04x mc6854_w: set CR2=$%02X (pse=%i,bytes=%i,fmidle=%i,%s,tlast=%i,clr=%c%c,rts=%i)\n", |
| 878 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), mc6854->cr2, |
| 878 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), mc6854->cr2, |
| 879 | 879 | PSE ? 1 : 0, TWOBYTES ? 2 : 1, FMIDLE ? 1 : 0, |
| 880 | 880 | FCTDRA ? "fc" : "tdra", TLAST ? 1 : 0, |
| 881 | 881 | data & 0x20 ? 'r' : '-', data & 0x40 ? 't' : '-', |
| r3775 | r3776 | |
| 906 | 906 | break; |
| 907 | 907 | |
| 908 | 908 | case 2: /* transmitter data: continue data */ |
| 909 | | LOG(( "%f $%04xmc6854_w: push data=$%02X\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data )); |
| 910 | | mc6854_tfifo_push( data ); |
| 909 | LOG(( "%f $%04xmc6854_w: push data=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data )); |
| 910 | mc6854_tfifo_push( space->machine, data ); |
| 911 | 911 | break; |
| 912 | 912 | |
| 913 | 913 | case 3: |
| r3775 | r3776 | |
| 915 | 915 | { |
| 916 | 916 | /* control register 4 */ |
| 917 | 917 | mc6854->cr4 = data; |
| 918 | | LOG(( "%f $%04x mc6854_w: set CR4=$%02X (interframe=%i,tlen=%i,rlen=%i,%s%s)\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), mc6854->cr4, |
| 918 | LOG(( "%f $%04x mc6854_w: set CR4=$%02X (interframe=%i,tlen=%i,rlen=%i,%s%s)\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), mc6854->cr4, |
| 919 | 919 | TWOINTER ? 2 : 1, |
| 920 | 920 | TWL, RWL, |
| 921 | 921 | ABT ? ( ABTEX ? "abort-ext," : "abort,") : "", |
| r3775 | r3776 | |
| 930 | 930 | else |
| 931 | 931 | { |
| 932 | 932 | /* transmitter data: last data */ |
| 933 | | LOG(( "%f $%04x mc6854_w: push last-data=$%02X\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data )); |
| 934 | | mc6854_tfifo_push( data ); |
| 933 | LOG(( "%f $%04x mc6854_w: push last-data=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data )); |
| 934 | mc6854_tfifo_push( space->machine, data ); |
| 935 | 935 | mc6854_tfifo_terminate(); |
| 936 | 936 | } |
| 937 | 937 | break; |
| r3775 | r3776 | |
| 968 | 968 | |
| 969 | 969 | |
| 970 | 970 | |
| 971 | | void mc6854_config ( const mc6854_interface* iface ) |
| 971 | void mc6854_config ( running_machine *machine, const mc6854_interface* iface ) |
| 972 | 972 | { |
| 973 | 973 | assert( iface ); |
| 974 | 974 | mc6854 = auto_malloc( sizeof( * mc6854 ) ); |
| r3775 | r3776 | |
| 984 | 984 | state_save_register_item(machine, "mc6854", NULL, 0, mc6854->cts ); |
| 985 | 985 | state_save_register_item(machine, "mc6854", NULL, 0, mc6854->dcd ); |
| 986 | 986 | state_save_register_item(machine, "mc6854", NULL, 0, mc6854->tstate ); |
| 987 | | state_save_register_item_array( "mc6854", NULL, 0, mc6854->tfifo ); |
| 987 | state_save_register_item_array( machine, "mc6854", NULL, 0, mc6854->tfifo ); |
| 988 | 988 | state_save_register_item(machine, "mc6854", NULL, 0, mc6854->tones ); |
| 989 | 989 | state_save_register_item(machine, "mc6854", NULL, 0, mc6854->rstate ); |
| 990 | 990 | state_save_register_item(machine, "mc6854", NULL, 0, mc6854->rreg ); |
| 991 | 991 | state_save_register_item(machine, "mc6854", NULL, 0, mc6854->rones ); |
| 992 | 992 | state_save_register_item(machine, "mc6854", NULL, 0, mc6854->rsize ); |
| 993 | | state_save_register_item_array( "mc6854", NULL, 0, mc6854->rfifo ); |
| 994 | | state_save_register_item_array( "mc6854", NULL, 0, mc6854->frame ); |
| 993 | state_save_register_item_array( machine, "mc6854", NULL, 0, mc6854->rfifo ); |
| 994 | state_save_register_item_array( machine, "mc6854", NULL, 0, mc6854->frame ); |
| 995 | 995 | state_save_register_item(machine, "mc6854", NULL, 0, mc6854->flen ); |
| 996 | 996 | state_save_register_item(machine, "mc6854", NULL, 0, mc6854->fpos ); |
| 997 | 997 | mc6854_reset(); |
src/mess/machine/thomson.c
| r3775 | r3776 | |
| 106 | 106 | if ( bitpos >= to7_k7_bitsize ) |
| 107 | 107 | bitpos = to7_k7_bitsize -1; |
| 108 | 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(machine)), state, pos, bitpos, |
| 109 | // cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), state, pos, bitpos, |
| 110 | 110 | // to7_k7_bits[ bitpos ] )); |
| 111 | 111 | return to7_k7_bits[ bitpos ]; |
| 112 | 112 | } |
| r3775 | r3776 | |
| 127 | 127 | } |
| 128 | 128 | k = ( chg >= 13 ) ? 1 : 0; |
| 129 | 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(machine)), state, pos, bitpos, |
| 130 | // cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), state, pos, bitpos, |
| 131 | 131 | // k, chg )); |
| 132 | 132 | return k; |
| 133 | 133 | } |
| r3775 | r3776 | |
| 155 | 155 | double pos = cassette_get_position(img); |
| 156 | 156 | |
| 157 | 157 | 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(machine)), data ? "off" : "on", |
| 158 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data ? "off" : "on", |
| 159 | 159 | (int) (pos / TO7_BIT_LENGTH) )); |
| 160 | 160 | |
| 161 | 161 | if ( (state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_DISABLED && !data && pos > 0.3 ) |
| r3775 | r3776 | |
| 205 | 205 | hbit = hbit >= 0; |
| 206 | 206 | |
| 207 | 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(machine)), state, pos, |
| 208 | // cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), state, pos, |
| 209 | 209 | // (int) (pos / MO5_HBIT_LENGTH), hbit )); |
| 210 | 210 | return hbit; |
| 211 | 211 | } |
| r3775 | r3776 | |
| 230 | 230 | double pos = cassette_get_position(img); |
| 231 | 231 | |
| 232 | 232 | 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(machine)), data ? "off" : "on", |
| 233 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data ? "off" : "on", |
| 234 | 234 | (int) (pos / MO5_HBIT_LENGTH) )); |
| 235 | 235 | |
| 236 | 236 | if ( (state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_DISABLED && !data && pos > 0.3 ) |
| r3775 | r3776 | |
| 308 | 308 | |
| 309 | 309 | |
| 310 | 310 | |
| 311 | | static void thom_irq_init ( void ) |
| 311 | static void thom_irq_init ( running_machine *machine ) |
| 312 | 312 | { |
| 313 | 313 | state_save_register_global(machine, thom_irq ); |
| 314 | 314 | state_save_register_global(machine, thom_firq ); |
| r3775 | r3776 | |
| 618 | 618 | |
| 619 | 619 | |
| 620 | 620 | |
| 621 | | static void to7_lightpen_cb ( int step ) |
| 621 | static void to7_lightpen_cb ( running_machine *machine, int step ) |
| 622 | 622 | { |
| 623 | 623 | if ( ! to7_lightpen ) |
| 624 | 624 | return; |
| r3775 | r3776 | |
| 635 | 635 | |
| 636 | 636 | |
| 637 | 637 | |
| 638 | | static void to7_set_init ( int init ) |
| 638 | static void to7_set_init ( running_machine *machine, int init ) |
| 639 | 639 | { |
| 640 | 640 | /* INIT signal wired to system PIA 6821 */ |
| 641 | 641 | |
| r3775 | r3776 | |
| 756 | 756 | { |
| 757 | 757 | /* acknowledge from centronics printer to PIA */ |
| 758 | 758 | 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 )); |
| 759 | //LOG (( "%f to7_io_ack: CENTRONICS new state $%02X (ack=%i)\n", attotime_to_double(timer_get_time(machine)), data, ack )); |
| 760 | 760 | pia_set_input_cb1( THOM_PIA_IO, ack ); |
| 761 | 761 | } |
| 762 | 762 | |
| r3775 | r3776 | |
| 767 | 767 | int tx = data & 1; |
| 768 | 768 | int dtr = ( data & 2 ) ? 1 : 0; |
| 769 | 769 | |
| 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(machine)), tx, dtr )); |
| 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 )); |
| 771 | 771 | if ( dtr ) |
| 772 | 772 | to7_io_line.State |= SERIAL_STATE_DTR; |
| 773 | 773 | else |
| r3775 | r3776 | |
| 790 | 790 | else |
| 791 | 791 | cts = ( centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY ) ? 1 : 0; |
| 792 | 792 | |
| 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(machine)), to7_io_mode(space->machine), cts, dsr, rd )); |
| 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 )); |
| 794 | 794 | |
| 795 | 795 | return (dsr ? 0x20 : 0) | (cts ? 0x40 : 0) | (rd ? 0x80: 0); |
| 796 | 796 | } |
| r3775 | r3776 | |
| 801 | 801 | { |
| 802 | 802 | /* set 8-bit data */ |
| 803 | 803 | |
| 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(machine)), data )); |
| 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 )); |
| 805 | 805 | |
| 806 | 806 | centronics_write_data( 0, data ); |
| 807 | 807 | } |
| r3775 | r3776 | |
| 812 | 812 | { |
| 813 | 813 | /* send STROBE to printer */ |
| 814 | 814 | |
| 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(machine)), data )); |
| 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 )); |
| 816 | 816 | |
| 817 | 817 | centronics_write_handshake( 0, data ? CENTRONICS_STROBE : 0, CENTRONICS_STROBE ); |
| 818 | 818 | } |
| r3775 | r3776 | |
| 824 | 824 | /* our peer's state has changed */ |
| 825 | 825 | to7_io_line.input_state = state; |
| 826 | 826 | |
| 827 | | LOG_IO(( "%f to7_io_in_callback: cts=%i dsr=%i rd=%i\n", attotime_to_double(timer_get_time(machine)), (state & SERIAL_STATE_CTS) ? 1 : 0, (state & SERIAL_STATE_DSR) ? 1 : 0, (int)get_in_data_bit( state ) )); |
| 827 | //LOG_IO(( "%f to7_io_in_callback: cts=%i dsr=%i rd=%i\n", attotime_to_double(timer_get_time(machine)), (state & SERIAL_STATE_CTS) ? 1 : 0, (state & SERIAL_STATE_DSR) ? 1 : 0, (int)get_in_data_bit( state ) )); |
| 828 | 828 | } |
| 829 | 829 | |
| 830 | 830 | |
| r3775 | r3776 | |
| 916 | 916 | |
| 917 | 917 | |
| 918 | 918 | |
| 919 | | static void to7_modem_cb( int state ) |
| 919 | static void to7_modem_cb(const device_config *device, int state ) |
| 920 | 920 | { |
| 921 | 921 | LOG(( "to7_modem_cb: called %i\n", state )); |
| 922 | 922 | } |
| r3775 | r3776 | |
| 932 | 932 | |
| 933 | 933 | |
| 934 | 934 | |
| 935 | | static const acia6850_interface to7_acia_modem = |
| 935 | const acia6850_interface to7_acia_modem = |
| 936 | 936 | { |
| 937 | 937 | 1200, 1200, /* 1200 bauds, might be divided by 16 */ |
| 938 | 938 | &to7_modem_rx, &to7_modem_tx, |
| r3775 | r3776 | |
| 953 | 953 | |
| 954 | 954 | |
| 955 | 955 | |
| 956 | | static void to7_modem_init( void ) |
| 956 | static void to7_modem_init( running_machine *machine ) |
| 957 | 957 | { |
| 958 | 958 | LOG (( "to7_modem_init: MODEM not implemented!\n" )); |
| 959 | 959 | pia_config( THOM_PIA_MODEM, &to7_pia_modem ); |
| 960 | | acia6850_config( 0, &to7_acia_modem ); |
| 961 | 960 | state_save_register_global(machine, to7_modem_rx ); |
| 962 | 961 | state_save_register_global(machine, to7_modem_tx ); |
| 963 | 962 | } |
| r3775 | r3776 | |
| 975 | 974 | else |
| 976 | 975 | { |
| 977 | 976 | switch ( offset ) { |
| 978 | | case 0: return acia6850_0_stat_r( space, 0 ); |
| 979 | | case 1: return acia6850_0_data_r( space, 0 ); |
| 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 ); |
| 980 | 979 | default: return 0; |
| 981 | 980 | } |
| 982 | 981 | } |
| r3775 | r3776 | |
| 991 | 990 | else |
| 992 | 991 | { |
| 993 | 992 | switch ( offset ) { |
| 994 | | case 0: acia6850_0_ctrl_w( space, 0, data ); break; |
| 995 | | case 1: acia6850_0_data_w( space, 0, data ); break; |
| 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; |
| 996 | 995 | } |
| 997 | 996 | } |
| 998 | 997 | } |
| r3775 | r3776 | |
| 1179 | 1178 | |
| 1180 | 1179 | |
| 1181 | 1180 | |
| 1182 | | static void to7_game_init ( void ) |
| 1181 | static void to7_game_init ( running_machine *machine ) |
| 1183 | 1182 | { |
| 1184 | 1183 | LOG (( "to7_game_init called\n" )); |
| 1185 | 1184 | pia_config( THOM_PIA_GAME, &to7_game ); |
| r3775 | r3776 | |
| 1290 | 1289 | /* bit 6: parity error (ignored) */ |
| 1291 | 1290 | /* bit 7: interrupt */ |
| 1292 | 1291 | LOG_MIDI(( "$%04x %f to7_midi_r: status $%02X (rdrf=%i, tdre=%i, ovrn=%i, irq=%i)\n", |
| 1293 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), to7_midi_status, |
| 1292 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), to7_midi_status, |
| 1294 | 1293 | (to7_midi_status & ACIA_6850_RDRF) ? 1 : 0, |
| 1295 | 1294 | (to7_midi_status & ACIA_6850_TDRE) ? 1 : 0, |
| 1296 | 1295 | (to7_midi_status & ACIA_6850_OVRN) ? 1 : 0, |
| r3775 | r3776 | |
| 1308 | 1307 | to7_midi_status &= ~ACIA_6850_OVRN; |
| 1309 | 1308 | to7_midi_overrun = 0; |
| 1310 | 1309 | LOG_MIDI(( "$%04x %f to7_midi_r: read data $%02X\n", |
| 1311 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), data )); |
| 1310 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data )); |
| 1312 | 1311 | to7_midi_update_irq(); |
| 1313 | 1312 | return data; |
| 1314 | 1313 | } |
| r3775 | r3776 | |
| 1335 | 1334 | if ( (data & 3) == 3 ) |
| 1336 | 1335 | { |
| 1337 | 1336 | /* reset */ |
| 1338 | | LOG_MIDI(( "$%04x %f to7_midi_w: reset (data=$%02X)\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), data )); |
| 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 )); |
| 1339 | 1338 | to7_midi_overrun = 0; |
| 1340 | 1339 | to7_midi_status = 2; |
| 1341 | 1340 | to7_midi_intr = 0; |
| r3775 | r3776 | |
| 1352 | 1351 | static const int stop[8] = { 2,2,1,1,2,1,1,1 }; |
| 1353 | 1352 | static const char parity[8] = { 'e','o','e','o','-','-','e','o' }; |
| 1354 | 1353 | LOG_MIDI(( "$%04x %f to7_midi_w: set control to $%02X (bits=%i, stop=%i, parity=%c, intr in=%i out=%i)\n", |
| 1355 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), |
| 1354 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), |
| 1356 | 1355 | data, |
| 1357 | 1356 | bits[ (data >> 2) & 7 ], |
| 1358 | 1357 | stop[ (data >> 2) & 7 ], |
| r3775 | r3776 | |
| 1366 | 1365 | |
| 1367 | 1366 | |
| 1368 | 1367 | case 1: /* output data */ |
| 1369 | | LOG_MIDI(( "$%04x %f to7_midi_w: write data $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), 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 )); |
| 1370 | 1369 | if ( data == 0x55 ) |
| 1371 | 1370 | /* cable-detect: shortcut */ |
| 1372 | 1371 | chardev_fake_in( to7_midi_chardev, 0x55 ); |
| r3775 | r3776 | |
| 1498 | 1497 | LOG (( "to7: machine start called\n" )); |
| 1499 | 1498 | |
| 1500 | 1499 | /* subsystems */ |
| 1501 | | thom_irq_init(); |
| 1500 | thom_irq_init(machine); |
| 1502 | 1501 | pia_config( THOM_PIA_SYS, &to7_sys ); |
| 1503 | 1502 | mc6846_config( machine, &to7_timer ); |
| 1504 | | to7_game_init(); |
| 1503 | to7_game_init(machine); |
| 1505 | 1504 | to7_floppy_init( machine, mem + 0x20000 ); |
| 1506 | 1505 | to7_io_init(); |
| 1507 | | to7_modem_init(); |
| 1506 | to7_modem_init(machine); |
| 1508 | 1507 | to7_midi_init(); |
| 1509 | 1508 | mea8000_config( machine, THOM_SOUND_SPEECH, NULL ); |
| 1510 | 1509 | |
| r3775 | r3776 | |
| 1748 | 1747 | LOG (( "to770: machine start called\n" )); |
| 1749 | 1748 | |
| 1750 | 1749 | /* subsystems */ |
| 1751 | | thom_irq_init(); |
| 1750 | thom_irq_init(machine); |
| 1752 | 1751 | pia_config( THOM_PIA_SYS, &to770_sys ); |
| 1753 | 1752 | mc6846_config( machine, &to770_timer ); |
| 1754 | | to7_game_init(); |
| 1753 | to7_game_init(machine); |
| 1755 | 1754 | to7_floppy_init( machine, mem + 0x20000 ); |
| 1756 | 1755 | to7_io_init(); |
| 1757 | | to7_modem_init(); |
| 1756 | to7_modem_init(machine); |
| 1758 | 1757 | to7_midi_init(); |
| 1759 | 1758 | mea8000_config( machine, THOM_SOUND_SPEECH, NULL ); |
| 1760 | 1759 | |
| r3775 | r3776 | |
| 1790 | 1789 | |
| 1791 | 1790 | |
| 1792 | 1791 | |
| 1793 | | static void mo5_lightpen_cb ( int step ) |
| 1792 | static void mo5_lightpen_cb ( running_machine *machine, int step ) |
| 1794 | 1793 | { |
| 1795 | 1794 | /* MO5 signals ca1 (TO7 signals cb1) */ |
| 1796 | 1795 | if ( ! to7_lightpen ) |
| r3775 | r3776 | |
| 2108 | 2107 | LOG (( "mo5: machine start called\n" )); |
| 2109 | 2108 | |
| 2110 | 2109 | /* subsystems */ |
| 2111 | | thom_irq_init(); |
| 2110 | thom_irq_init(machine); |
| 2112 | 2111 | pia_config( THOM_PIA_SYS, &mo5_sys ); |
| 2113 | | to7_game_init(); |
| 2112 | to7_game_init(machine); |
| 2114 | 2113 | to7_floppy_init( machine, mem + 0x20000 ); |
| 2115 | 2114 | to7_io_init(); |
| 2116 | | to7_modem_init(); |
| 2115 | to7_modem_init(machine); |
| 2117 | 2116 | to7_midi_init(); |
| 2118 | 2117 | mo5_periodic_timer = timer_alloc(machine, mo5_periodic_cb , NULL); |
| 2119 | 2118 | mea8000_config( machine, THOM_SOUND_SPEECH, NULL ); |
| r3775 | r3776 | |
| 2156 | 2155 | |
| 2157 | 2156 | WRITE8_HANDLER ( to9_ieee_w ) |
| 2158 | 2157 | { |
| 2159 | | logerror( "$%04x %f to9_ieee_w: unhandled write $%02X to register %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), data, offset ); |
| 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 ); |
| 2160 | 2159 | } |
| 2161 | 2160 | |
| 2162 | 2161 | |
| 2163 | 2162 | |
| 2164 | 2163 | READ8_HANDLER ( to9_ieee_r ) |
| 2165 | 2164 | { |
| 2166 | | logerror( "$%04x %f to9_ieee_r: unhandled read from register %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), offset ); |
| 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 ); |
| 2167 | 2166 | return 0; |
| 2168 | 2167 | } |
| 2169 | 2168 | |
| r3775 | r3776 | |
| 2289 | 2288 | |
| 2290 | 2289 | WRITE8_HANDLER ( to9_vreg_w ) |
| 2291 | 2290 | { |
| 2292 | | LOG_VIDEO(( "$%04x %f to9_vreg_w: off=%i ($%04X) data=$%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), offset, 0xe7da + offset, data )); |
| 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 )); |
| 2293 | 2292 | |
| 2294 | 2293 | switch ( offset ) |
| 2295 | 2294 | { |
| r3775 | r3776 | |
| 2326 | 2325 | |
| 2327 | 2326 | |
| 2328 | 2327 | |
| 2329 | | static void to9_palette_init ( void ) |
| 2328 | static void to9_palette_init ( running_machine *machine ) |
| 2330 | 2329 | { |
| 2331 | 2330 | to9_palette_idx = 0; |
| 2332 | 2331 | memset( to9_palette_data, 0, sizeof( to9_palette_data ) ); |
| r3775 | r3776 | |
| 2584 | 2583 | /* bit 7: interrupt */ |
| 2585 | 2584 | |
| 2586 | 2585 | LOG_KBD(( "$%04x %f to9_kbd_r: status $%02X (rdrf=%i, tdre=%i, ovrn=%i, pe=%i, irq=%i)\n", |
| 2587 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), to9_kbd_status, |
| 2586 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), to9_kbd_status, |
| 2588 | 2587 | (to9_kbd_status & ACIA_6850_RDRF) ? 1 : 0, |
| 2589 | 2588 | (to9_kbd_status & ACIA_6850_TDRE) ? 1 : 0, |
| 2590 | 2589 | (to9_kbd_status & ACIA_6850_OVRN) ? 1 : 0, |
| r3775 | r3776 | |
| 2599 | 2598 | else |
| 2600 | 2599 | to9_kbd_status &= ~(ACIA_6850_OVRN | ACIA_6850_RDRF); |
| 2601 | 2600 | to9_kbd_overrun = 0; |
| 2602 | | LOG_KBD(( "$%04x %f to9_kbd_r: read data $%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), to9_kbd_in )); |
| 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 )); |
| 2603 | 2602 | to9_kbd_update_irq(space->machine); |
| 2604 | 2603 | return to9_kbd_in; |
| 2605 | 2604 | |
| r3775 | r3776 | |
| 2626 | 2625 | to9_kbd_overrun = 0; |
| 2627 | 2626 | to9_kbd_status = ACIA_6850_TDRE; |
| 2628 | 2627 | to9_kbd_intr = 0; |
| 2629 | | LOG_KBD(( "$%04x %f to9_kbd_w: reset (data=$%02X)\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), data )); |
| 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 )); |
| 2630 | 2629 | } |
| 2631 | 2630 | else |
| 2632 | 2631 | { |
| r3775 | r3776 | |
| 2640 | 2639 | to9_kbd_intr = data >> 5; |
| 2641 | 2640 | |
| 2642 | 2641 | LOG_KBD(( "$%04x %f to9_kbd_w: set control to $%02X (parity=%i, intr in=%i out=%i)\n", |
| 2643 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), |
| 2642 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), |
| 2644 | 2643 | data, to9_kbd_parity, to9_kbd_intr >> 2, |
| 2645 | 2644 | (to9_kbd_intr & 3) ? 1 : 0 )); |
| 2646 | 2645 | } |
| r3775 | r3776 | |
| 2671 | 2670 | case 0xFE: to9_kbd_periph = 0; break; |
| 2672 | 2671 | |
| 2673 | 2672 | default: |
| 2674 | | logerror( "$%04x %f to9_kbd_w: unknown kbd command %02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), data ); |
| 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 ); |
| 2675 | 2674 | } |
| 2676 | 2675 | |
| 2677 | 2676 | thom_set_caps_led( ! to9_kbd_caps ); |
| 2678 | 2677 | |
| 2679 | 2678 | LOG(( "$%04x %f to9_kbd_w: kbd command %02X (caps=%i, pad=%i, periph=%i)\n", |
| 2680 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), data, |
| 2679 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data, |
| 2681 | 2680 | to9_kbd_caps, to9_kbd_pad, to9_kbd_periph )); |
| 2682 | 2681 | |
| 2683 | 2682 | break; |
| r3775 | r3776 | |
| 2921 | 2920 | |
| 2922 | 2921 | |
| 2923 | 2922 | |
| 2924 | | static void to9_kbd_init ( void ) |
| 2923 | static void to9_kbd_init ( running_machine *machine ) |
| 2925 | 2924 | { |
| 2926 | 2925 | LOG(( "to9_kbd_init called\n" )); |
| 2927 | 2926 | to9_kbd_timer = timer_alloc(machine, to9_kbd_timer_cb , NULL); |
| r3775 | r3776 | |
| 2956 | 2955 | centronics_write_handshake( 0, (b & 2) ? CENTRONICS_STROBE : 0, CENTRONICS_STROBE ); |
| 2957 | 2956 | |
| 2958 | 2957 | // LOG_IO(( "$%04x %f to9_update_centronics: data=$%02X strobe=%i\n", |
| 2959 | | // cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), data, |
| 2958 | // cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data, |
| 2960 | 2959 | // (b & 2) ? 1 : 0 )); |
| 2961 | 2960 | } |
| 2962 | 2961 | |
| r3775 | r3776 | |
| 3074 | 3073 | LOG (( "to9: machine start called\n" )); |
| 3075 | 3074 | |
| 3076 | 3075 | /* subsystems */ |
| 3077 | | thom_irq_init(); |
| 3076 | thom_irq_init(machine); |
| 3078 | 3077 | pia_config( THOM_PIA_SYS, &to9_sys ); |
| 3079 | 3078 | centronics_config( 0, &to9_centronics ); |
| 3080 | 3079 | mc6846_config( machine, &to9_timer ); |
| 3081 | | to7_game_init(); |
| 3080 | to7_game_init(machine); |
| 3082 | 3081 | to9_floppy_init( machine, mem + 0xe000, mem + 0x40000 ); |
| 3083 | | to9_kbd_init(); |
| 3084 | | to9_palette_init(); |
| 3085 | | to7_modem_init(); |
| 3082 | to9_kbd_init(machine); |
| 3083 | to9_palette_init(machine); |
| 3084 | to7_modem_init(machine); |
| 3086 | 3085 | to7_midi_init(); |
| 3087 | 3086 | mea8000_config( machine, THOM_SOUND_SPEECH, NULL ); |
| 3088 | 3087 | |
| r3775 | r3776 | |
| 3350 | 3349 | |
| 3351 | 3350 | |
| 3352 | 3351 | /* cpu <-> keyboard hand-check */ |
| 3353 | | static void to8_kbd_set_ack ( int data ) |
| 3352 | static void to8_kbd_set_ack ( running_machine *machine, int data ) |
| 3354 | 3353 | { |
| 3355 | 3354 | if ( data == to8_kbd_ack ) |
| 3356 | 3355 | return; |
| r3775 | r3776 | |
| 3435 | 3434 | |
| 3436 | 3435 | |
| 3437 | 3436 | |
| 3438 | | static void to8_kbd_init ( void ) |
| 3437 | static void to8_kbd_init ( running_machine *machine ) |
| 3439 | 3438 | { |
| 3440 | 3439 | to8_kbd_timer = timer_alloc(machine, to8_kbd_timer_cb , NULL); |
| 3441 | 3440 | to8_kbd_signal = timer_alloc(machine, NULL , NULL); |
| r3775 | r3776 | |
| 3745 | 3744 | } |
| 3746 | 3745 | |
| 3747 | 3746 | LOG_VIDEO(( "$%04x %f to8_gatearray_r: off=%i ($%04X) res=$%02X lightpen=%i\n", |
| 3748 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), |
| 3747 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), |
| 3749 | 3748 | offset, 0xe7e4 + offset, res, to7_lightpen )); |
| 3750 | 3749 | |
| 3751 | 3750 | return res; |
| r3775 | r3776 | |
| 3756 | 3755 | WRITE8_HANDLER ( to8_gatearray_w ) |
| 3757 | 3756 | { |
| 3758 | 3757 | LOG_VIDEO(( "$%04x %f to8_gatearray_w: off=%i ($%04X) data=$%02X\n", |
| 3759 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), |
| 3758 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), |
| 3760 | 3759 | offset, 0xe7e4 + offset, data )); |
| 3761 | 3760 | |
| 3762 | 3761 | switch ( offset ) |
| r3775 | r3776 | |
| 3837 | 3836 | WRITE8_HANDLER ( to8_vreg_w ) |
| 3838 | 3837 | { |
| 3839 | 3838 | LOG_VIDEO(( "$%04x %f to8_vreg_w: off=%i ($%04X) data=$%02X\n", |
| 3840 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), |
| 3839 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), |
| 3841 | 3840 | offset, 0xe7da + offset, data )); |
| 3842 | 3841 | |
| 3843 | 3842 | switch ( offset ) |
| r3775 | r3776 | |
| 3893 | 3892 | { |
| 3894 | 3893 | int ktest = to8_kbd_ktest (space->machine); |
| 3895 | 3894 | |
| 3896 | | LOG_KBD(( "$%04x %f: to8_sys_porta_in ktest=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), ktest )); |
| 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 )); |
| 3897 | 3896 | |
| 3898 | 3897 | return ktest; |
| 3899 | 3898 | } |
| r3775 | r3776 | |
| 3945 | 3944 | to8_soft_select = (data & 0x04) ? 1 : 0; /* bit 2: internal ROM select */ |
| 3946 | 3945 | to8_update_floppy_bank(space->machine); |
| 3947 | 3946 | to8_update_cart_bank(space->machine); |
| 3948 | | to8_kbd_set_ack( ack ); |
| 3947 | to8_kbd_set_ack( space->machine, ack ); |
| 3949 | 3948 | } |
| 3950 | 3949 | |
| 3951 | 3950 | |
| r3775 | r3776 | |
| 3973 | 3972 | |
| 3974 | 3973 | |
| 3975 | 3974 | /* direct connection to interrupt line instead of through a PIA */ |
| 3976 | | static void to8_lightpen_cb ( int step ) |
| 3975 | static void to8_lightpen_cb ( running_machine *machine, int step ) |
| 3977 | 3976 | { |
| 3978 | 3977 | if ( ! to7_lightpen ) |
| 3979 | 3978 | return; |
| 3980 | 3979 | |
| 3981 | | thom_firq_2( Machine, 1 ); |
| 3980 | thom_firq_2( machine, 1 ); |
| 3982 | 3981 | to7_lightpen_step = step; |
| 3983 | 3982 | to8_lightpen_intr = 1; |
| 3984 | 3983 | } |
| r3775 | r3776 | |
| 4044 | 4043 | LOG (( "to8: machine start called\n" )); |
| 4045 | 4044 | |
| 4046 | 4045 | /* subsystems */ |
| 4047 | | thom_irq_init(); |
| 4046 | thom_irq_init(machine); |
| 4048 | 4047 | pia_config( THOM_PIA_SYS, &to8_sys ); |
| 4049 | 4048 | centronics_config( 0, &to9_centronics ); |
| 4050 | 4049 | mc6846_config( machine, &to8_timer ); |
| 4051 | | to7_game_init(); |
| 4050 | to7_game_init(machine); |
| 4052 | 4051 | to8_floppy_init( machine ); |
| 4053 | | to8_kbd_init(); |
| 4054 | | to9_palette_init(); |
| 4055 | | to7_modem_init(); |
| 4052 | to8_kbd_init(machine); |
| 4053 | to9_palette_init(machine); |
| 4054 | to7_modem_init(machine); |
| 4056 | 4055 | to7_midi_init(); |
| 4057 | 4056 | mea8000_config( machine, THOM_SOUND_SPEECH, NULL ); |
| 4058 | 4057 | |
| r3775 | r3776 | |
| 4210 | 4209 | LOG (( "to9p: machine start called\n" )); |
| 4211 | 4210 | |
| 4212 | 4211 | /* subsystems */ |
| 4213 | | thom_irq_init(); |
| 4212 | thom_irq_init(machine); |
| 4214 | 4213 | pia_config( THOM_PIA_SYS, &to9p_sys ); |
| 4215 | 4214 | centronics_config( 0, &to9_centronics ); |
| 4216 | 4215 | mc6846_config( machine, &to9p_timer ); |
| 4217 | | to7_game_init(); |
| 4216 | to7_game_init(machine); |
| 4218 | 4217 | to8_floppy_init( machine ); |
| 4219 | | to9_kbd_init(); |
| 4220 | | to9_palette_init(); |
| 4221 | | to7_modem_init(); |
| 4218 | to9_kbd_init(machine); |
| 4219 | to9_palette_init(machine); |
| 4220 | to7_modem_init(machine); |
| 4222 | 4221 | to7_midi_init(); |
| 4223 | 4222 | mea8000_config( machine, THOM_SOUND_SPEECH, NULL ); |
| 4224 | 4223 | |
| r3775 | r3776 | |
| 4422 | 4421 | static WRITE8_HANDLER ( mo6_game_porta_out ) |
| 4423 | 4422 | { |
| 4424 | 4423 | /* centronics data */ |
| 4425 | | LOG (( "$%04x %f mo6_game_porta_out: CENTRONICS set data=$%02X\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), 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 )); |
| 4426 | 4425 | centronics_write_data( 0, data ); |
| 4427 | 4426 | } |
| 4428 | 4427 | |
| r3775 | r3776 | |
| 4432 | 4431 | { |
| 4433 | 4432 | int dtr = ( centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY ) ? 0 : 1; |
| 4434 | 4433 | /* note: printer busy signal replaces button */ |
| 4435 | | LOG (( "$%04x %f mo6_game_cb1_in: CENTRONICS get dtr=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), dtr )); |
| 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 )); |
| 4436 | 4435 | return dtr; |
| 4437 | 4436 | } |
| 4438 | 4437 | |
| r3775 | r3776 | |
| 4441 | 4440 | static WRITE8_HANDLER ( mo6_game_cb2_out ) |
| 4442 | 4441 | { |
| 4443 | 4442 | /* centronics strobe */ |
| 4444 | | LOG (( "$%04x %f mo6_game_cb2_out: CENTRONICS set strobe=%i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), data )); |
| 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 )); |
| 4445 | 4444 | centronics_write_handshake( 0, data ? CENTRONICS_STROBE : 0, |
| 4446 | 4445 | CENTRONICS_STROBE ); |
| 4447 | 4446 | } |
| r3775 | r3776 | |
| 4478 | 4477 | |
| 4479 | 4478 | |
| 4480 | 4479 | |
| 4481 | | static void mo6_game_init ( void ) |
| 4480 | static void mo6_game_init ( running_machine *machine ) |
| 4482 | 4481 | { |
| 4483 | 4482 | LOG (( "mo6_game_init called\n" )); |
| 4484 | 4483 | pia_config( THOM_PIA_GAME, &mo6_game ); |
| r3775 | r3776 | |
| 4628 | 4627 | } |
| 4629 | 4628 | |
| 4630 | 4629 | LOG_VIDEO(( "$%04x %f mo6_gatearray_r: off=%i ($%04X) res=$%02X lightpen=%i\n", |
| 4631 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), |
| 4630 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), |
| 4632 | 4631 | offset, 0xa7e4 + offset, res, to7_lightpen )); |
| 4633 | 4632 | |
| 4634 | 4633 | return res; |
| r3775 | r3776 | |
| 4639 | 4638 | WRITE8_HANDLER ( mo6_gatearray_w ) |
| 4640 | 4639 | { |
| 4641 | 4640 | LOG_VIDEO(( "$%04x %f mo6_gatearray_w: off=%i ($%04X) data=$%02X\n", |
| 4642 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), |
| 4641 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), |
| 4643 | 4642 | offset, 0xa7e4 + offset, data )); |
| 4644 | 4643 | |
| 4645 | 4644 | switch ( offset ) |
| r3775 | r3776 | |
| 4706 | 4705 | WRITE8_HANDLER ( mo6_vreg_w ) |
| 4707 | 4706 | { |
| 4708 | 4707 | LOG_VIDEO(( "$%04x %f mo6_vreg_w: off=%i ($%04X) data=$%02X\n", |
| 4709 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), |
| 4708 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), |
| 4710 | 4709 | offset, 0xa7da + offset, data )); |
| 4711 | 4710 | |
| 4712 | 4711 | switch ( offset ) |
| r3775 | r3776 | |
| 4798 | 4797 | LOG (( "mo6: machine start called\n" )); |
| 4799 | 4798 | |
| 4800 | 4799 | /* subsystems */ |
| 4801 | | thom_irq_init(); |
| 4800 | thom_irq_init(machine); |
| 4802 | 4801 | pia_config( THOM_PIA_SYS, &mo6_sys ); |
| 4803 | 4802 | centronics_config( 0, &to9_centronics ); |
| 4804 | | mo6_game_init(); |
| 4803 | mo6_game_init(machine); |
| 4805 | 4804 | to7_floppy_init( machine, mem + 0x30000 ); |
| 4806 | | to9_palette_init(); |
| 4807 | | to7_modem_init(); |
| 4805 | to9_palette_init(machine); |
| 4806 | to7_modem_init(machine); |
| 4808 | 4807 | to7_midi_init(); |
| 4809 | 4808 | mo5_periodic_timer = timer_alloc(machine, mo5_periodic_cb , NULL); |
| 4810 | 4809 | mea8000_config( machine, THOM_SOUND_SPEECH, NULL ); |
| r3775 | r3776 | |
| 4864 | 4863 | if ( to7_controller_type ) |
| 4865 | 4864 | return to7_floppy_r ( space, offset ); |
| 4866 | 4865 | |
| 4867 | | logerror( "$%04x %f mo5nr_net_r: read from reg %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), offset ); |
| 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 ); |
| 4868 | 4867 | |
| 4869 | 4868 | if ( to7_controller_type ) |
| 4870 | 4869 | return to7_floppy_r ( space, offset ); |
| r3775 | r3776 | |
| 4880 | 4879 | to7_floppy_w ( space, offset, data ); |
| 4881 | 4880 | else |
| 4882 | 4881 | logerror( "$%04x %f mo5nr_net_w: write $%02X to reg %i\n", |
| 4883 | | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), data, offset ); |
| 4882 | cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(space->machine)), data, offset ); |
| 4884 | 4883 | } |
| 4885 | 4884 | |
| 4886 | 4885 | |
| r3775 | r3776 | |
| 4908 | 4907 | return 0x80; |
| 4909 | 4908 | |
| 4910 | 4909 | default: |
| 4911 | | logerror( "$%04x %f mo5nr_prn_r: unhandled read from reg %i\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), offset ); |
| 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 ); |
| 4912 | 4911 | return 0; |
| 4913 | 4912 | } |
| 4914 | 4913 | } |
| r3775 | r3776 | |
| 4930 | 4929 | break; |
| 4931 | 4930 | |
| 4932 | 4931 | default: |
| 4933 | | logerror( "$%04x %f mo5nr_prn_w: unhandled to reg %i (data=$%02X)\n", cpu_get_previouspc(space->cpu), attotime_to_double(timer_get_time(machine)), offset, data ); |
| 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 ); |
| 4934 | 4933 | } |
| 4935 | 4934 | } |
| 4936 | 4935 | |
| r3775 | r3776 | |
| 4994 | 4993 | |
| 4995 | 4994 | |
| 4996 | 4995 | |
| 4997 | | static void mo5nr_game_init ( void ) |
| 4996 | static void mo5nr_game_init ( running_machine *machine ) |
| 4998 | 4997 | { |
| 4999 | 4998 | LOG (( "mo5nr_game_init called\n" )); |
| 5000 | 4999 | pia_config( THOM_PIA_GAME, &mo5nr_game ); |
| r3775 | r3776 | |
| 5071 | 5070 | LOG (( "mo5nr: machine start called\n" )); |
| 5072 | 5071 | |
| 5073 | 5072 | /* subsystems */ |
| 5074 | | thom_irq_init(); |
| 5073 | thom_irq_init(machine); |
| 5075 | 5074 | pia_config( THOM_PIA_SYS, &mo5nr_sys ); |
| 5076 | 5075 | centronics_config( 0, &to9_centronics ); |
| 5077 | | mo5nr_game_init(); |
| 5076 | mo5nr_game_init( machine ); |
| 5078 | 5077 | to7_floppy_init( machine, mem + 0x30000 ); |
| 5079 | | to9_palette_init(); |
| 5080 | | to7_modem_init(); |
| 5078 | to9_palette_init(machine); |
| 5079 | to7_modem_init(machine); |
| 5081 | 5080 | to7_midi_init(); |
| 5082 | 5081 | mo5_periodic_timer = timer_alloc(machine, mo5_periodic_cb , NULL); |
| 5083 | 5082 | mea8000_config( machine, THOM_SOUND_SPEECH, NULL ); |
src/mess/devices/thomflop.c
| r3775 | r3776 | |
| 282 | 282 | else if ( offset == 8 ) |
| 283 | 283 | return to7_5p14_select; |
| 284 | 284 | else |
| 285 | | logerror ( "%f $%04x to7_5p14_r: invalid read offset %i\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), offset ); |
| 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 ); |
| 286 | 286 | return 0; |
| 287 | 287 | } |
| 288 | 288 | |
| r3775 | r3776 | |
| 306 | 306 | case 4: drive = 2; side = 0; break; |
| 307 | 307 | case 5: drive = 3; side = 1; break; |
| 308 | 308 | default: |
| 309 | | logerror( "%f $%04x to7_5p14_w: invalid drive select pattern $%02X\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data ); |
| 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 ); |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | dens = (data & 0x80) ? DEN_FM_LO : DEN_MFM_LO; |
| r3775 | r3776 | |
| 321 | 321 | wd17xx_set_drive( drive ); |
| 322 | 322 | wd17xx_set_side( side ); |
| 323 | 323 | LOG(( "%f $%04x to7_5p14_w: $%02X set drive=%i side=%i density=%s\n", |
| 324 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), |
| 324 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), |
| 325 | 325 | data, drive, side, (dens == DEN_FM_LO) ? "FM" : "MFM" )); |
| 326 | 326 | } |
| 327 | 327 | } |
| 328 | 328 | else |
| 329 | 329 | logerror ( "%f $%04x to7_5p14_w: invalid write offset %i (data=$%02X)\n", |
| 330 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), offset, data ); |
| 330 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset, data ); |
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | |
| r3775 | r3776 | |
| 379 | 379 | else if ( offset >= 8 && offset <= 9 ) |
| 380 | 380 | return to7_5p14sd_select; |
| 381 | 381 | else |
| 382 | | logerror ( "%f $%04x to7_5p14sd_r: invalid read offset %i\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), offset ); |
| 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 ); |
| 383 | 383 | return 0; |
| 384 | 384 | } |
| 385 | 385 | |
| r3775 | r3776 | |
| 423 | 423 | mc6843_set_drive( drive ); |
| 424 | 424 | mc6843_set_side( side ); |
| 425 | 425 | LOG(( "%f $%04x to7_5p14sd_w: $%02X set drive=%i side=%i\n", |
| 426 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data, drive, side )); |
| 426 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, drive, side )); |
| 427 | 427 | } |
| 428 | 428 | } |
| 429 | 429 | else |
| 430 | 430 | logerror ( "%f $%04x to7_5p14sd_w: invalid write offset %i (data=$%02X)\n", |
| 431 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), offset, data ); |
| 431 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset, data ); |
| 432 | 432 | } |
| 433 | 433 | |
| 434 | 434 | |
| r3775 | r3776 | |
| 541 | 541 | to7qdd->data_size = 0; |
| 542 | 542 | } |
| 543 | 543 | |
| 544 | | VLOG(( "%f to7_qdd_pulse_cb: state=%i\n", attotime_to_double(timer_get_time(machine)), state )); |
| 544 | //VLOG(( "%f to7_qdd_pulse_cb: state=%i\n", attotime_to_double(timer_get_time(machine)), state )); |
| 545 | 545 | } |
| 546 | 546 | |
| 547 | 547 | |
| r3775 | r3776 | |
| 711 | 711 | case 0: /* MC6852 status */ |
| 712 | 712 | to7_qdd_stat_update(); |
| 713 | 713 | 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(machine)), cpu_get_previouspc(space->cpu), to7qdd->status, |
| 714 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), to7qdd->status, |
| 715 | 715 | to7qdd->status & QDD_S_IRQ ? 1 : 0, |
| 716 | 716 | to7qdd->status & QDD_S_PE ? 1 : 0, |
| 717 | 717 | to7qdd->status & QDD_S_OVR ? 1 : 0, |
| r3775 | r3776 | |
| 734 | 734 | data |= 0x40; /* disk present */ |
| 735 | 735 | if ( to7qdd->index_pulse ) |
| 736 | 736 | data |= 0x80; /* disk start */ |
| 737 | | VLOG(( "%f $%04x to7_qdd_r: STATUS8 $%02X\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data )); |
| 737 | VLOG(( "%f $%04x to7_qdd_r: STATUS8 $%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data )); |
| 738 | 738 | return data; |
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | default: |
| 742 | | logerror ( "%f $%04x to7_qdd_r: invalid read offset %i\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), offset ); |
| 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 ); |
| 743 | 743 | return 0; |
| 744 | 744 | } |
| 745 | 745 | } |
| r3775 | r3776 | |
| 761 | 761 | to7qdd->ctrl1 = ( data & ~(QDD_C1_RRESET | QDD_C1_TRESET) ) |( data & (QDD_C1_RRESET | QDD_C1_TRESET) & to7qdd->ctrl1 ); |
| 762 | 762 | to7_qdd_stat_update(); |
| 763 | 763 | VLOG(( "%f $%04x to7_qdd_w: CTRL1=$%02X reset=%c%c %s%sirq=%c%c\n", |
| 764 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data, |
| 764 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, |
| 765 | 765 | data & QDD_C1_RRESET ? 'r' : '-', data & QDD_C1_TRESET ? 't' : '-', |
| 766 | 766 | data & QDD_C1_STRIPSYNC ? "strip-sync " : "", |
| 767 | 767 | data & QDD_C1_CLRSYNC ? "clear-sync " : "", |
| r3775 | r3776 | |
| 803 | 803 | to7qdd->status &= ~QDD_S_NCTS; |
| 804 | 804 | to7_qdd_stat_update(); |
| 805 | 805 | VLOG(( "%f $%04x to7_qdd_w: CTRL3=$%02X %s%ssync-len=%i sync-mode=%s\n", |
| 806 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data, |
| 806 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, |
| 807 | 807 | data & QDD_C3_CLRTUF ? "clr-tuf " : "", |
| 808 | 808 | data & QDD_C3_CLRCTS ? "clr-cts " : "", |
| 809 | 809 | data & QDD_C3_SYNCLEN ? 1 : 2, |
| r3775 | r3776 | |
| 815 | 815 | break; |
| 816 | 816 | |
| 817 | 817 | 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(machine)), cpu_get_previouspc(space->cpu), data )); |
| 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 )); |
| 819 | 819 | break; |
| 820 | 820 | |
| 821 | 821 | } |
| r3775 | r3776 | |
| 823 | 823 | |
| 824 | 824 | case 8: /* set drive */ |
| 825 | 825 | to7qdd->drive = data; |
| 826 | | VLOG(( "%f $%04x to7_qdd_w: DRIVE=$%02X\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), 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 )); |
| 827 | 827 | break; |
| 828 | 828 | |
| 829 | 829 | case 12: /* motor pulse ? */ |
| 830 | 830 | thom_floppy_active( 0 ); |
| 831 | | VLOG(( "%f $%04x to7_qdd_w: MOTOR=$%02X\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data )); |
| 831 | VLOG(( "%f $%04x to7_qdd_w: MOTOR=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data )); |
| 832 | 832 | break; |
| 833 | 833 | |
| 834 | 834 | default: |
| 835 | | logerror ( "%f $%04x to7_qdd_w: invalid write offset %i (data=$%02X)\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), offset, data ); |
| 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 ); |
| 836 | 836 | } |
| 837 | 837 | } |
| 838 | 838 | |
| r3775 | r3776 | |
| 865 | 865 | |
| 866 | 866 | |
| 867 | 867 | |
| 868 | | static void to7_qdd_init( void ) |
| 868 | static void to7_qdd_init( running_machine *machine ) |
| 869 | 869 | { |
| 870 | 870 | LOG(( "to7_qdd_init: CQ 90-028 controller\n" )); |
| 871 | 871 | |
| r3775 | r3776 | |
| 983 | 983 | thmfc1->data_raw_idx = 0; |
| 984 | 984 | } |
| 985 | 985 | |
| 986 | | VLOG(( "%f thmfc_floppy_index_pulse_cb: state=%i\n", attotime_to_double(timer_get_time(machine)), state )); |
| 986 | //VLOG(( "%f thmfc_floppy_index_pulse_cb: state=%i\n", attotime_to_double(timer_get_time(machine)), state )); |
| 987 | 987 | } |
| 988 | 988 | |
| 989 | 989 | |
| r3775 | r3776 | |
| 1025 | 1025 | |
| 1026 | 1026 | |
| 1027 | 1027 | /* complete command (by read, write, or timeout) */ |
| 1028 | | static void thmfc_floppy_cmd_complete(void) |
| 1028 | static void thmfc_floppy_cmd_complete(running_machine *machine) |
| 1029 | 1029 | { |
| 1030 | 1030 | LOG (( "%f thmfc_floppy_cmd_complete_cb: cmd=%i off=%i/%i/%i\n", |
| 1031 | 1031 | attotime_to_double(timer_get_time(machine)), thmfc1->op, thmfc1->data_idx, |
| r3775 | r3776 | |
| 1048 | 1048 | |
| 1049 | 1049 | static TIMER_CALLBACK( thmfc_floppy_cmd_complete_cb ) |
| 1050 | 1050 | { |
| 1051 | | thmfc_floppy_cmd_complete(); |
| 1051 | thmfc_floppy_cmd_complete(machine); |
| 1052 | 1052 | } |
| 1053 | 1053 | |
| 1054 | 1054 | |
| 1055 | 1055 | |
| 1056 | 1056 | /* intelligent read: show just one field, skip header */ |
| 1057 | | static UINT8 thmfc_floppy_read_byte ( void ) |
| 1057 | static UINT8 thmfc_floppy_read_byte ( running_machine *machine ) |
| 1058 | 1058 | { |
| 1059 | 1059 | UINT8 data = thmfc1->data[ thmfc1->data_idx ]; |
| 1060 | 1060 | |
| r3775 | r3776 | |
| 1064 | 1064 | // data )); |
| 1065 | 1065 | |
| 1066 | 1066 | if ( thmfc1->data_idx >= thmfc1->data_size - 1 ) |
| 1067 | | thmfc_floppy_cmd_complete(); |
| 1067 | thmfc_floppy_cmd_complete(machine); |
| 1068 | 1068 | else |
| 1069 | 1069 | thmfc1->data_idx++; |
| 1070 | 1070 | |
| r3775 | r3776 | |
| 1203 | 1203 | |
| 1204 | 1204 | |
| 1205 | 1205 | /* intelligent writing */ |
| 1206 | | static void thmfc_floppy_write_byte ( UINT8 data ) |
| 1206 | static void thmfc_floppy_write_byte ( running_machine *machine, UINT8 data ) |
| 1207 | 1207 | { |
| 1208 | 1208 | // VLOG (( "%f $%04x thmfc_floppy_write_byte: off=%i/%i data=$%02X\n", |
| 1209 | 1209 | // attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), |
| r3775 | r3776 | |
| 1212 | 1212 | thmfc1->data_raw_size = 0; |
| 1213 | 1213 | thmfc1->data[ thmfc1->data_idx ] = data; |
| 1214 | 1214 | if ( thmfc1->data_idx >= thmfc1->data_size - 1 ) |
| 1215 | | thmfc_floppy_cmd_complete(); |
| 1215 | thmfc_floppy_cmd_complete(machine); |
| 1216 | 1216 | else |
| 1217 | 1217 | thmfc1->data_idx++; |
| 1218 | 1218 | } |
| r3775 | r3776 | |
| 1260 | 1260 | |
| 1261 | 1261 | case 0: /* STAT0 */ |
| 1262 | 1262 | 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(machine)), cpu_get_previouspc(space->cpu), thmfc1->stat0 )); |
| 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 )); |
| 1264 | 1264 | return thmfc1->stat0; |
| 1265 | 1265 | |
| 1266 | 1266 | case 1: /* STAT1 */ |
| r3775 | r3776 | |
| 1291 | 1291 | data |= 0x10; |
| 1292 | 1292 | if ( flags & FLOPPY_DRIVE_DISK_WRITE_PROTECTED ) |
| 1293 | 1293 | data |= 0x04; |
| 1294 | | VLOG(( "%f $%04x thmfc_floppy_r: STAT1=$%02X\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data )); |
| 1294 | VLOG(( "%f $%04x thmfc_floppy_r: STAT1=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data )); |
| 1295 | 1295 | return data; |
| 1296 | 1296 | } |
| 1297 | 1297 | |
| 1298 | 1298 | case 3: /* RDATA */ |
| 1299 | 1299 | |
| 1300 | 1300 | if ( thmfc1->op == THMFC1_OP_READ_SECT || thmfc1->op == THMFC1_OP_READ_ADDR ) |
| 1301 | | return thmfc_floppy_read_byte(); |
| 1301 | return thmfc_floppy_read_byte(space->machine); |
| 1302 | 1302 | else |
| 1303 | 1303 | return thmfc_floppy_raw_read_byte(); |
| 1304 | 1304 | |
| r3775 | r3776 | |
| 1309 | 1309 | { |
| 1310 | 1310 | /* undocumented => emulate TO7 QDD controller ? */ |
| 1311 | 1311 | UINT8 data = thmfc1->ipl << 7; |
| 1312 | | VLOG(( "%f $%04x thmfc_floppy_r: STAT8=$%02X\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data )); |
| 1312 | VLOG(( "%f $%04x thmfc_floppy_r: STAT8=$%02X\n", attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data )); |
| 1313 | 1313 | return data; |
| 1314 | 1314 | } |
| 1315 | 1315 | |
| 1316 | 1316 | default: |
| 1317 | | logerror ( "%f $%04x thmfc_floppy_r: invalid read offset %i\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), offset ); |
| 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 ); |
| 1318 | 1318 | return 0; |
| 1319 | 1319 | } |
| 1320 | 1320 | } |
| r3775 | r3776 | |
| 1334 | 1334 | thom_floppy_set_density( dens ); |
| 1335 | 1335 | thmfc1->formatting = (data >> 2) & 1; |
| 1336 | 1336 | 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(machine)), cpu_get_previouspc(space->cpu), data, |
| 1337 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, |
| 1338 | 1338 | (dens == DEN_FM_LO) ? "MF" : "MFM", |
| 1339 | 1339 | wsync, (data >> 3) & 1, |
| 1340 | 1340 | thmfc1->formatting, data & 3 )); |
| r3775 | r3776 | |
| 1424 | 1424 | } |
| 1425 | 1425 | |
| 1426 | 1426 | LOG (( "%f $%04x thmfc_floppy_w: CMD1=$%02X sect-size=%i comp=%i head=%i\n", |
| 1427 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data, |
| 1427 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, |
| 1428 | 1428 | thmfc1->sector_size, (data >> 1) & 7, thmfc1->side )); |
| 1429 | 1429 | break; |
| 1430 | 1430 | |
| r3775 | r3776 | |
| 1452 | 1452 | thom_floppy_active( 0 ); |
| 1453 | 1453 | |
| 1454 | 1454 | LOG (( "%f $%04x thmfc_floppy_w: CMD2=$%02X drv=%i step=%i motor=%i\n", |
| 1455 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data, |
| 1455 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, |
| 1456 | 1456 | thmfc1->drive, seek, motor )); |
| 1457 | 1457 | |
| 1458 | 1458 | if ( seek ) |
| r3775 | r3776 | |
| 1475 | 1475 | if ( thmfc_floppy_is_qdd() ) |
| 1476 | 1476 | thmfc_floppy_qdd_write_byte( data ); |
| 1477 | 1477 | else if ( thmfc1->op==THMFC1_OP_WRITE_SECT ) |
| 1478 | | thmfc_floppy_write_byte( data ); |
| 1478 | thmfc_floppy_write_byte( space->machine, data ); |
| 1479 | 1479 | else if ( thmfc1->formatting ) |
| 1480 | 1480 | thmfc_floppy_format_byte( data ); |
| 1481 | 1481 | else |
| 1482 | 1482 | { |
| 1483 | 1483 | /* TODO: implement other forms of raw track writing */ |
| 1484 | 1484 | LOG (( "%f $%04x thmfc_floppy_w: ignored raw WDATA $%02X\n", |
| 1485 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data )); |
| 1485 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data )); |
| 1486 | 1486 | } |
| 1487 | 1487 | break; |
| 1488 | 1488 | |
| r3775 | r3776 | |
| 1490 | 1490 | case 4: /* WCLK (unemulated) */ |
| 1491 | 1491 | /* clock configuration: FF for data, 0A for synchro */ |
| 1492 | 1492 | LOG (( "%f $%04x thmfc_floppy_w: WCLK=$%02X (%s)\n", |
| 1493 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data, |
| 1493 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, |
| 1494 | 1494 | (data == 0xff) ? "data" : (data == 0x0A) ? "synchro" : "?" )); |
| 1495 | 1495 | break; |
| 1496 | 1496 | |
| 1497 | 1497 | case 5: /* WSECT */ |
| 1498 | 1498 | thmfc1->sector = data; |
| 1499 | 1499 | LOG (( "%f $%04x thmfc_floppy_w: WSECT=%i\n", |
| 1500 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data )); |
| 1500 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data )); |
| 1501 | 1501 | break; |
| 1502 | 1502 | |
| 1503 | 1503 | case 6: /* WTRCK */ |
| 1504 | 1504 | thmfc1->track = data; |
| 1505 | 1505 | LOG (( "%f $%04x thmfc_floppy_w: WTRCK=%i (real=%i)\n", |
| 1506 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data, |
| 1506 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data, |
| 1507 | 1507 | floppy_drive_get_current_track( thmfc_floppy_image() ) )); |
| 1508 | 1508 | break; |
| 1509 | 1509 | |
| 1510 | 1510 | case 7: /* WCELL */ |
| 1511 | 1511 | /* precompensation (unemulated) */ |
| 1512 | 1512 | LOG (( "%f $%04x thmfc_floppy_w: WCELL=$%02X\n", |
| 1513 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), data )); |
| 1513 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), data )); |
| 1514 | 1514 | break; |
| 1515 | 1515 | |
| 1516 | 1516 | default: |
| 1517 | 1517 | logerror ( "%f $%04x thmfc_floppy_w: invalid write offset %i (data=$%02X)\n", |
| 1518 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), offset, data ); |
| 1518 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset, data ); |
| 1519 | 1519 | } |
| 1520 | 1520 | } |
| 1521 | 1521 | |
| r3775 | r3776 | |
| 1554 | 1554 | |
| 1555 | 1555 | |
| 1556 | 1556 | |
| 1557 | | void thmfc_floppy_init( void ) |
| 1557 | void thmfc_floppy_init( running_machine *machine ) |
| 1558 | 1558 | { |
| 1559 | 1559 | LOG(( "thmfc_floppy_init: THMFC1 controller\n" )); |
| 1560 | 1560 | |
| r3775 | r3776 | |
| 1652 | 1652 | |
| 1653 | 1653 | */ |
| 1654 | 1654 | |
| 1655 | | static void to7_network_got_frame( UINT8* data, int length ) |
| 1655 | static void to7_network_got_frame( running_machine *machine, UINT8* data, int length ) |
| 1656 | 1656 | { |
| 1657 | 1657 | int i; |
| 1658 | 1658 | LOG(( "%f to7_network_got_frame:", attotime_to_double(timer_get_time(machine)) )); |
| r3775 | r3776 | |
| 1690 | 1690 | |
| 1691 | 1691 | |
| 1692 | 1692 | |
| 1693 | | static void to7_network_init( void ) |
| 1693 | static void to7_network_init( running_machine *machine ) |
| 1694 | 1694 | { |
| 1695 | 1695 | LOG(( "to7_network_init: NR 07-005 network extension\n" )); |
| 1696 | 1696 | logerror( "to7_network_init: network not handled!\n" ); |
| 1697 | | mc6854_config( &network_iface ); |
| 1697 | mc6854_config( machine, &network_iface ); |
| 1698 | 1698 | } |
| 1699 | 1699 | |
| 1700 | 1700 | |
| r3775 | r3776 | |
| 1717 | 1717 | { |
| 1718 | 1718 | /* network ID of the computer */ |
| 1719 | 1719 | 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(machine)), cpu_get_previouspc(space->cpu), id )); |
| 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 )); |
| 1721 | 1721 | return id; |
| 1722 | 1722 | } |
| 1723 | 1723 | |
| 1724 | | logerror( "%f $%04x to7_network_r: invalid read offset %i\n", attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), offset ); |
| 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 ); |
| 1725 | 1725 | return 0; |
| 1726 | 1726 | } |
| 1727 | 1727 | |
| r3775 | r3776 | |
| 1734 | 1734 | else |
| 1735 | 1735 | { |
| 1736 | 1736 | logerror( "%f $%04x to7_network_w: invalid write offset %i (data=$%02X)\n", |
| 1737 | | attotime_to_double(timer_get_time(machine)), cpu_get_previouspc(space->cpu), offset, data ); |
| 1737 | attotime_to_double(timer_get_time(space->machine)), cpu_get_previouspc(space->cpu), offset, data ); |
| 1738 | 1738 | } |
| 1739 | 1739 | } |
| 1740 | 1740 | |
| r3775 | r3776 | |
| 1765 | 1765 | state_save_register_global(machine, to7_floppy_bank ); |
| 1766 | 1766 | to7_5p14sd_init(machine); |
| 1767 | 1767 | to7_5p14_init(machine); |
| 1768 | | to7_qdd_init(); |
| 1769 | | thmfc_floppy_init(); |
| 1770 | | to7_network_init(); |
| 1768 | to7_qdd_init(machine); |
| 1769 | thmfc_floppy_init(machine); |
| 1770 | to7_network_init(machine); |
| 1771 | 1771 | } |
| 1772 | 1772 | |
| 1773 | 1773 | |