trunk/src/emu/machine/wd_fdc.c
| r19173 | r19174 | |
| 44 | 44 | const device_type WD1772x = &device_creator<wd1772_t>; |
| 45 | 45 | const device_type WD1773x = &device_creator<wd1773_t>; |
| 46 | 46 | |
| 47 | | wd177x_t::wd177x_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) : |
| 47 | wd_fdc_t::wd_fdc_t(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock) : |
| 48 | 48 | device_t(mconfig, type, name, tag, owner, clock) |
| 49 | 49 | { |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | | void wd177x_t::device_start() |
| 52 | void wd_fdc_t::device_start() |
| 53 | 53 | { |
| 54 | 54 | t_gen = timer_alloc(TM_GEN); |
| 55 | 55 | t_cmd = timer_alloc(TM_CMD); |
| r19173 | r19174 | |
| 73 | 73 | save_item(NAME(last_dir)); |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | | void wd177x_t::device_reset() |
| 76 | void wd_fdc_t::device_reset() |
| 77 | 77 | { |
| 78 | 78 | command = 0x00; |
| 79 | 79 | main_state = IDLE; |
| r19173 | r19174 | |
| 93 | 93 | live_abort(); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | | void wd177x_t::set_floppy(floppy_image_device *_floppy) |
| 96 | void wd_fdc_t::set_floppy(floppy_image_device *_floppy) |
| 97 | 97 | { |
| 98 | 98 | if(floppy == _floppy) |
| 99 | 99 | return; |
| r19173 | r19174 | |
| 108 | 108 | if(floppy) { |
| 109 | 109 | if(has_motor()) |
| 110 | 110 | floppy->mon_w(status & S_MON ? 0 : 1); |
| 111 | | floppy->setup_index_pulse_cb(floppy_image_device::index_pulse_cb(FUNC(wd177x_t::index_callback), this)); |
| 111 | floppy->setup_index_pulse_cb(floppy_image_device::index_pulse_cb(FUNC(wd_fdc_t::index_callback), this)); |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | | void wd177x_t::setup_intrq_cb(line_cb cb) |
| 115 | void wd_fdc_t::setup_intrq_cb(line_cb cb) |
| 116 | 116 | { |
| 117 | 117 | intrq_cb = cb; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | | void wd177x_t::setup_drq_cb(line_cb cb) |
| 120 | void wd_fdc_t::setup_drq_cb(line_cb cb) |
| 121 | 121 | { |
| 122 | 122 | drq_cb = cb; |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | | void wd177x_t::setup_hld_cb(line_cb cb) |
| 125 | void wd_fdc_t::setup_hld_cb(line_cb cb) |
| 126 | 126 | { |
| 127 | 127 | hld_cb = cb; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | | void wd177x_t::setup_enp_cb(line_cb cb) |
| 130 | void wd_fdc_t::setup_enp_cb(line_cb cb) |
| 131 | 131 | { |
| 132 | 132 | enp_cb = cb; |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | | void wd177x_t::dden_w(bool _dden) |
| 135 | void wd_fdc_t::dden_w(bool _dden) |
| 136 | 136 | { |
| 137 | 137 | dden = _dden; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | | astring wd177x_t::tts(attotime t) |
| 140 | astring wd_fdc_t::tts(attotime t) |
| 141 | 141 | { |
| 142 | 142 | char buf[256]; |
| 143 | 143 | int nsec = t.attoseconds / ATTOSECONDS_PER_NANOSECOND; |
| r19173 | r19174 | |
| 145 | 145 | return buf; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | | astring wd177x_t::ttsn() |
| 148 | astring wd_fdc_t::ttsn() |
| 149 | 149 | { |
| 150 | 150 | return tts(machine().time()); |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | | void wd177x_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 153 | void wd_fdc_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 154 | 154 | { |
| 155 | 155 | live_sync(); |
| 156 | 156 | |
| r19173 | r19174 | |
| 164 | 164 | general_continue(); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | | void wd177x_t::command_end() |
| 167 | void wd_fdc_t::command_end() |
| 168 | 168 | { |
| 169 | 169 | main_state = sub_state = IDLE; |
| 170 | 170 | status &= ~S_BUSY; |
| r19173 | r19174 | |
| 174 | 174 | intrq_cb(intrq); |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | | void wd177x_t::seek_start(int state) |
| 177 | void wd_fdc_t::seek_start(int state) |
| 178 | 178 | { |
| 179 | 179 | main_state = state; |
| 180 | 180 | status = (status & ~(S_CRC|S_RNF|S_SPIN)) | S_BUSY; |
| r19173 | r19174 | |
| 190 | 190 | seek_continue(); |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | | void wd177x_t::seek_continue() |
| 193 | void wd_fdc_t::seek_continue() |
| 194 | 194 | { |
| 195 | 195 | for(;;) { |
| 196 | 196 | switch(sub_state) { |
| r19173 | r19174 | |
| 317 | 317 | } |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | | bool wd177x_t::sector_matches() const |
| 320 | bool wd_fdc_t::sector_matches() const |
| 321 | 321 | { |
| 322 | 322 | if(cur_live.idbuf[0] != track || cur_live.idbuf[2] != sector) |
| 323 | 323 | return false; |
| r19173 | r19174 | |
| 329 | 329 | return !(cur_live.idbuf[1] & 1); |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | | bool wd177x_t::is_ready() |
| 332 | bool wd_fdc_t::is_ready() |
| 333 | 333 | { |
| 334 | 334 | return (floppy && !floppy->ready_r()); |
| 335 | 335 | } |
| 336 | 336 | |
| 337 | | void wd177x_t::read_sector_start() |
| 337 | void wd_fdc_t::read_sector_start() |
| 338 | 338 | { |
| 339 | 339 | if(has_ready() && !is_ready()) |
| 340 | 340 | command_end(); |
| r19173 | r19174 | |
| 349 | 349 | read_sector_continue(); |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | | void wd177x_t::read_sector_continue() |
| 352 | void wd_fdc_t::read_sector_continue() |
| 353 | 353 | { |
| 354 | 354 | for(;;) { |
| 355 | 355 | switch(sub_state) { |
| r19173 | r19174 | |
| 424 | 424 | } |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | | void wd177x_t::read_track_start() |
| 427 | void wd_fdc_t::read_track_start() |
| 428 | 428 | { |
| 429 | 429 | if(has_ready() && !is_ready()) |
| 430 | 430 | command_end(); |
| r19173 | r19174 | |
| 439 | 439 | read_track_continue(); |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | | void wd177x_t::read_track_continue() |
| 442 | void wd_fdc_t::read_track_continue() |
| 443 | 443 | { |
| 444 | 444 | for(;;) { |
| 445 | 445 | switch(sub_state) { |
| r19173 | r19174 | |
| 491 | 491 | } |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | | void wd177x_t::read_id_start() |
| 494 | void wd_fdc_t::read_id_start() |
| 495 | 495 | { |
| 496 | 496 | if(has_ready() && !is_ready()) |
| 497 | 497 | command_end(); |
| r19173 | r19174 | |
| 506 | 506 | read_id_continue(); |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | | void wd177x_t::read_id_continue() |
| 509 | void wd_fdc_t::read_id_continue() |
| 510 | 510 | { |
| 511 | 511 | for(;;) { |
| 512 | 512 | switch(sub_state) { |
| r19173 | r19174 | |
| 556 | 556 | } |
| 557 | 557 | } |
| 558 | 558 | |
| 559 | | void wd177x_t::write_track_start() |
| 559 | void wd_fdc_t::write_track_start() |
| 560 | 560 | { |
| 561 | 561 | if(has_ready() && !is_ready()) |
| 562 | 562 | command_end(); |
| r19173 | r19174 | |
| 571 | 571 | write_track_continue(); |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | | void wd177x_t::write_track_continue() |
| 574 | void wd_fdc_t::write_track_continue() |
| 575 | 575 | { |
| 576 | 576 | for(;;) { |
| 577 | 577 | switch(sub_state) { |
| r19173 | r19174 | |
| 638 | 638 | } |
| 639 | 639 | |
| 640 | 640 | |
| 641 | | void wd177x_t::write_sector_start() |
| 641 | void wd_fdc_t::write_sector_start() |
| 642 | 642 | { |
| 643 | 643 | if(has_ready() && !is_ready()) |
| 644 | 644 | command_end(); |
| r19173 | r19174 | |
| 653 | 653 | write_sector_continue(); |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | | void wd177x_t::write_sector_continue() |
| 656 | void wd_fdc_t::write_sector_continue() |
| 657 | 657 | { |
| 658 | 658 | for(;;) { |
| 659 | 659 | switch(sub_state) { |
| r19173 | r19174 | |
| 725 | 725 | } |
| 726 | 726 | } |
| 727 | 727 | |
| 728 | | void wd177x_t::interrupt_start() |
| 728 | void wd_fdc_t::interrupt_start() |
| 729 | 729 | { |
| 730 | 730 | if(status & S_BUSY) { |
| 731 | 731 | main_state = sub_state = cur_live.state = IDLE; |
| r19173 | r19174 | |
| 752 | 752 | } |
| 753 | 753 | } |
| 754 | 754 | |
| 755 | | void wd177x_t::general_continue() |
| 755 | void wd_fdc_t::general_continue() |
| 756 | 756 | { |
| 757 | 757 | if(cur_live.state != IDLE) { |
| 758 | 758 | live_run(); |
| r19173 | r19174 | |
| 787 | 787 | } |
| 788 | 788 | } |
| 789 | 789 | |
| 790 | | void wd177x_t::do_generic() |
| 790 | void wd_fdc_t::do_generic() |
| 791 | 791 | { |
| 792 | 792 | switch(sub_state) { |
| 793 | 793 | case IDLE: |
| r19173 | r19174 | |
| 818 | 818 | } |
| 819 | 819 | } |
| 820 | 820 | |
| 821 | | void wd177x_t::do_cmd_w() |
| 821 | void wd_fdc_t::do_cmd_w() |
| 822 | 822 | { |
| 823 | 823 | // fprintf(stderr, "%s: command %02x\n", ttsn().cstr(), cmd_buffer); |
| 824 | 824 | |
| r19173 | r19174 | |
| 845 | 845 | } |
| 846 | 846 | } |
| 847 | 847 | |
| 848 | | void wd177x_t::cmd_w(UINT8 val) |
| 848 | void wd_fdc_t::cmd_w(UINT8 val) |
| 849 | 849 | { |
| 850 | 850 | logerror("wd1772 cmd: %02x\n", val); |
| 851 | 851 | |
| r19173 | r19174 | |
| 864 | 864 | delay_cycles(t_cmd, dden ? 384 : 184); |
| 865 | 865 | } |
| 866 | 866 | |
| 867 | | UINT8 wd177x_t::status_r() |
| 867 | UINT8 wd_fdc_t::status_r() |
| 868 | 868 | { |
| 869 | 869 | if(intrq && !(intrq_cond & I_IMM)) { |
| 870 | 870 | intrq = false; |
| r19173 | r19174 | |
| 904 | 904 | return status; |
| 905 | 905 | } |
| 906 | 906 | |
| 907 | | void wd177x_t::do_track_w() |
| 907 | void wd_fdc_t::do_track_w() |
| 908 | 908 | { |
| 909 | 909 | track = track_buffer; |
| 910 | 910 | track_buffer = -1; |
| 911 | 911 | } |
| 912 | 912 | |
| 913 | | void wd177x_t::track_w(UINT8 val) |
| 913 | void wd_fdc_t::track_w(UINT8 val) |
| 914 | 914 | { |
| 915 | 915 | // No more than one write in flight |
| 916 | 916 | if(track_buffer != -1) |
| r19173 | r19174 | |
| 920 | 920 | delay_cycles(t_track, dden ? 256 : 128); |
| 921 | 921 | } |
| 922 | 922 | |
| 923 | | UINT8 wd177x_t::track_r() |
| 923 | UINT8 wd_fdc_t::track_r() |
| 924 | 924 | { |
| 925 | 925 | return track; |
| 926 | 926 | } |
| 927 | 927 | |
| 928 | | void wd177x_t::do_sector_w() |
| 928 | void wd_fdc_t::do_sector_w() |
| 929 | 929 | { |
| 930 | 930 | sector = sector_buffer; |
| 931 | 931 | sector_buffer = -1; |
| 932 | 932 | } |
| 933 | 933 | |
| 934 | | void wd177x_t::sector_w(UINT8 val) |
| 934 | void wd_fdc_t::sector_w(UINT8 val) |
| 935 | 935 | { |
| 936 | 936 | // No more than one write in flight |
| 937 | 937 | if(sector_buffer != -1) |
| r19173 | r19174 | |
| 941 | 941 | delay_cycles(t_sector, dden ? 256 : 128); |
| 942 | 942 | } |
| 943 | 943 | |
| 944 | | UINT8 wd177x_t::sector_r() |
| 944 | UINT8 wd_fdc_t::sector_r() |
| 945 | 945 | { |
| 946 | 946 | return sector; |
| 947 | 947 | } |
| 948 | 948 | |
| 949 | | void wd177x_t::data_w(UINT8 val) |
| 949 | void wd_fdc_t::data_w(UINT8 val) |
| 950 | 950 | { |
| 951 | 951 | data = val; |
| 952 | 952 | drop_drq(); |
| 953 | 953 | } |
| 954 | 954 | |
| 955 | | UINT8 wd177x_t::data_r() |
| 955 | UINT8 wd_fdc_t::data_r() |
| 956 | 956 | { |
| 957 | 957 | drop_drq(); |
| 958 | 958 | return data; |
| 959 | 959 | } |
| 960 | 960 | |
| 961 | | void wd177x_t::gen_w(int reg, UINT8 val) |
| 961 | void wd_fdc_t::gen_w(int reg, UINT8 val) |
| 962 | 962 | { |
| 963 | 963 | switch(reg) { |
| 964 | 964 | case 0: cmd_w(val); break; |
| r19173 | r19174 | |
| 968 | 968 | } |
| 969 | 969 | } |
| 970 | 970 | |
| 971 | | UINT8 wd177x_t::gen_r(int reg) |
| 971 | UINT8 wd_fdc_t::gen_r(int reg) |
| 972 | 972 | { |
| 973 | 973 | switch(reg) { |
| 974 | 974 | case 0: return status_r(); break; |
| r19173 | r19174 | |
| 979 | 979 | return 0xff; |
| 980 | 980 | } |
| 981 | 981 | |
| 982 | | void wd177x_t::delay_cycles(emu_timer *tm, int cycles) |
| 982 | void wd_fdc_t::delay_cycles(emu_timer *tm, int cycles) |
| 983 | 983 | { |
| 984 | 984 | tm->adjust(clocks_to_attotime(cycles)); |
| 985 | 985 | } |
| 986 | 986 | |
| 987 | | void wd177x_t::spinup() |
| 987 | void wd_fdc_t::spinup() |
| 988 | 988 | { |
| 989 | 989 | if(command & 0x08) |
| 990 | 990 | sub_state = SPINUP_DONE; |
| r19173 | r19174 | |
| 999 | 999 | |
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | | void wd177x_t::index_callback(floppy_image_device *floppy, int state) |
| 1002 | void wd_fdc_t::index_callback(floppy_image_device *floppy, int state) |
| 1003 | 1003 | { |
| 1004 | 1004 | live_sync(); |
| 1005 | 1005 | |
| r19173 | r19174 | |
| 1079 | 1079 | general_continue(); |
| 1080 | 1080 | } |
| 1081 | 1081 | |
| 1082 | | bool wd177x_t::intrq_r() |
| 1082 | bool wd_fdc_t::intrq_r() |
| 1083 | 1083 | { |
| 1084 | 1084 | return intrq; |
| 1085 | 1085 | } |
| 1086 | 1086 | |
| 1087 | | bool wd177x_t::drq_r() |
| 1087 | bool wd_fdc_t::drq_r() |
| 1088 | 1088 | { |
| 1089 | 1089 | return drq; |
| 1090 | 1090 | } |
| 1091 | 1091 | |
| 1092 | | bool wd177x_t::hld_r() |
| 1092 | bool wd_fdc_t::hld_r() |
| 1093 | 1093 | { |
| 1094 | 1094 | return hld; |
| 1095 | 1095 | } |
| 1096 | 1096 | |
| 1097 | | void wd177x_t::hlt_w(bool state) |
| 1097 | void wd_fdc_t::hlt_w(bool state) |
| 1098 | 1098 | { |
| 1099 | 1099 | hlt = state; |
| 1100 | 1100 | } |
| 1101 | 1101 | |
| 1102 | | bool wd177x_t::enp_r() |
| 1102 | bool wd_fdc_t::enp_r() |
| 1103 | 1103 | { |
| 1104 | 1104 | return enp; |
| 1105 | 1105 | } |
| 1106 | 1106 | |
| 1107 | | void wd177x_t::live_start(int state) |
| 1107 | void wd_fdc_t::live_start(int state) |
| 1108 | 1108 | { |
| 1109 | 1109 | cur_live.tm = machine().time(); |
| 1110 | 1110 | cur_live.state = state; |
| r19173 | r19174 | |
| 1124 | 1124 | live_run(); |
| 1125 | 1125 | } |
| 1126 | 1126 | |
| 1127 | | void wd177x_t::checkpoint() |
| 1127 | void wd_fdc_t::checkpoint() |
| 1128 | 1128 | { |
| 1129 | 1129 | cur_live.pll.commit(floppy, cur_live.tm); |
| 1130 | 1130 | checkpoint_live = cur_live; |
| 1131 | 1131 | } |
| 1132 | 1132 | |
| 1133 | | void wd177x_t::rollback() |
| 1133 | void wd_fdc_t::rollback() |
| 1134 | 1134 | { |
| 1135 | 1135 | cur_live = checkpoint_live; |
| 1136 | 1136 | } |
| 1137 | 1137 | |
| 1138 | | void wd177x_t::live_delay(int state) |
| 1138 | void wd_fdc_t::live_delay(int state) |
| 1139 | 1139 | { |
| 1140 | 1140 | cur_live.next_state = state; |
| 1141 | 1141 | t_gen->adjust(cur_live.tm - machine().time()); |
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | | void wd177x_t::live_sync() |
| 1144 | void wd_fdc_t::live_sync() |
| 1145 | 1145 | { |
| 1146 | 1146 | if(!cur_live.tm.is_never()) { |
| 1147 | 1147 | if(cur_live.tm > machine().time()) { |
| r19173 | r19174 | |
| 1166 | 1166 | } |
| 1167 | 1167 | } |
| 1168 | 1168 | |
| 1169 | | void wd177x_t::live_abort() |
| 1169 | void wd_fdc_t::live_abort() |
| 1170 | 1170 | { |
| 1171 | 1171 | if(!cur_live.tm.is_never() && cur_live.tm > machine().time()) { |
| 1172 | 1172 | rollback(); |
| r19173 | r19174 | |
| 1179 | 1179 | cur_live.next_state = -1; |
| 1180 | 1180 | } |
| 1181 | 1181 | |
| 1182 | | bool wd177x_t::read_one_bit(attotime limit) |
| 1182 | bool wd_fdc_t::read_one_bit(attotime limit) |
| 1183 | 1183 | { |
| 1184 | 1184 | int bit = cur_live.pll.get_next_bit(cur_live.tm, floppy, limit); |
| 1185 | 1185 | if(bit < 0) |
| r19173 | r19174 | |
| 1197 | 1197 | return false; |
| 1198 | 1198 | } |
| 1199 | 1199 | |
| 1200 | | bool wd177x_t::write_one_bit(attotime limit) |
| 1200 | bool wd_fdc_t::write_one_bit(attotime limit) |
| 1201 | 1201 | { |
| 1202 | 1202 | bool bit = cur_live.shift_reg & 0x8000; |
| 1203 | 1203 | if(cur_live.pll.write_next_bit(bit, cur_live.tm, floppy, limit)) |
| r19173 | r19174 | |
| 1213 | 1213 | return false; |
| 1214 | 1214 | } |
| 1215 | 1215 | |
| 1216 | | void wd177x_t::live_write_raw(UINT16 raw) |
| 1216 | void wd_fdc_t::live_write_raw(UINT16 raw) |
| 1217 | 1217 | { |
| 1218 | 1218 | // logerror("write %04x %04x\n", raw, cur_live.crc); |
| 1219 | 1219 | cur_live.shift_reg = raw; |
| 1220 | 1220 | cur_live.data_bit_context = raw & 1; |
| 1221 | 1221 | } |
| 1222 | 1222 | |
| 1223 | | void wd177x_t::live_write_mfm(UINT8 mfm) |
| 1223 | void wd_fdc_t::live_write_mfm(UINT8 mfm) |
| 1224 | 1224 | { |
| 1225 | 1225 | bool context = cur_live.data_bit_context; |
| 1226 | 1226 | UINT16 raw = 0; |
| r19173 | r19174 | |
| 1237 | 1237 | // logerror("write %02x %04x %04x\n", mfm, cur_live.crc, raw); |
| 1238 | 1238 | } |
| 1239 | 1239 | |
| 1240 | | void wd177x_t::live_run(attotime limit) |
| 1240 | void wd_fdc_t::live_run(attotime limit) |
| 1241 | 1241 | { |
| 1242 | 1242 | if(cur_live.state == IDLE || cur_live.next_state != -1) |
| 1243 | 1243 | return; |
| r19173 | r19174 | |
| 1647 | 1647 | } |
| 1648 | 1648 | } |
| 1649 | 1649 | |
| 1650 | | void wd177x_t::set_drq() |
| 1650 | void wd_fdc_t::set_drq() |
| 1651 | 1651 | { |
| 1652 | 1652 | if(drq) |
| 1653 | 1653 | status |= S_LOST; |
| r19173 | r19174 | |
| 1658 | 1658 | } |
| 1659 | 1659 | } |
| 1660 | 1660 | |
| 1661 | | void wd177x_t::drop_drq() |
| 1661 | void wd_fdc_t::drop_drq() |
| 1662 | 1662 | { |
| 1663 | 1663 | if(drq) { |
| 1664 | 1664 | drq = false; |
| r19173 | r19174 | |
| 1667 | 1667 | } |
| 1668 | 1668 | } |
| 1669 | 1669 | |
| 1670 | | void wd177x_t::pll_t::set_clock(attotime period) |
| 1670 | void wd_fdc_t::pll_t::set_clock(attotime period) |
| 1671 | 1671 | { |
| 1672 | 1672 | for(int i=0; i<42; i++) |
| 1673 | 1673 | delays[i] = period*(i+1); |
| 1674 | 1674 | } |
| 1675 | 1675 | |
| 1676 | | void wd177x_t::pll_t::reset(attotime when) |
| 1676 | void wd_fdc_t::pll_t::reset(attotime when) |
| 1677 | 1677 | { |
| 1678 | 1678 | counter = 0; |
| 1679 | 1679 | increment = 128; |
| r19173 | r19174 | |
| 1689 | 1689 | write_start_time = attotime::never; |
| 1690 | 1690 | } |
| 1691 | 1691 | |
| 1692 | | int wd177x_t::pll_t::get_next_bit(attotime &tm, floppy_image_device *floppy, attotime limit) |
| 1692 | int wd_fdc_t::pll_t::get_next_bit(attotime &tm, floppy_image_device *floppy, attotime limit) |
| 1693 | 1693 | { |
| 1694 | 1694 | attotime when = floppy ? floppy->get_next_transition(ctime) : attotime::never; |
| 1695 | 1695 | #if 0 |
| r19173 | r19174 | |
| 1769 | 1769 | return bit; |
| 1770 | 1770 | } |
| 1771 | 1771 | |
| 1772 | | void wd177x_t::pll_t::start_writing(attotime tm) |
| 1772 | void wd_fdc_t::pll_t::start_writing(attotime tm) |
| 1773 | 1773 | { |
| 1774 | 1774 | write_start_time = tm; |
| 1775 | 1775 | write_position = 0; |
| 1776 | 1776 | } |
| 1777 | 1777 | |
| 1778 | | void wd177x_t::pll_t::stop_writing(floppy_image_device *floppy, attotime tm) |
| 1778 | void wd_fdc_t::pll_t::stop_writing(floppy_image_device *floppy, attotime tm) |
| 1779 | 1779 | { |
| 1780 | 1780 | commit(floppy, tm); |
| 1781 | 1781 | write_start_time = attotime::never; |
| 1782 | 1782 | } |
| 1783 | 1783 | |
| 1784 | | bool wd177x_t::pll_t::write_next_bit(bool bit, attotime &tm, floppy_image_device *floppy, attotime limit) |
| 1784 | bool wd_fdc_t::pll_t::write_next_bit(bool bit, attotime &tm, floppy_image_device *floppy, attotime limit) |
| 1785 | 1785 | { |
| 1786 | 1786 | if(write_start_time.is_never()) { |
| 1787 | 1787 | write_start_time = ctime; |
| r19173 | r19174 | |
| 1811 | 1811 | return false; |
| 1812 | 1812 | } |
| 1813 | 1813 | |
| 1814 | | void wd177x_t::pll_t::commit(floppy_image_device *floppy, attotime tm) |
| 1814 | void wd_fdc_t::pll_t::commit(floppy_image_device *floppy, attotime tm) |
| 1815 | 1815 | { |
| 1816 | 1816 | if(write_start_time.is_never() || tm == write_start_time) |
| 1817 | 1817 | return; |
| r19173 | r19174 | |
| 1822 | 1822 | write_position = 0; |
| 1823 | 1823 | } |
| 1824 | 1824 | |
| 1825 | | int wd177x_t::step_time(int mode) const |
| 1825 | int wd_fdc_t::step_time(int mode) const |
| 1826 | 1826 | { |
| 1827 | 1827 | const static int step_times[4] = { 48000, 96000, 160000, 240000 }; |
| 1828 | 1828 | return step_times[mode]; |
| 1829 | 1829 | } |
| 1830 | 1830 | |
| 1831 | | int wd177x_t::settle_time() const |
| 1831 | int wd_fdc_t::settle_time() const |
| 1832 | 1832 | { |
| 1833 | 1833 | return 240000; |
| 1834 | 1834 | } |
| 1835 | 1835 | |
| 1836 | | bool wd177x_t::has_ready() const |
| 1836 | bool wd_fdc_t::has_ready() const |
| 1837 | 1837 | { |
| 1838 | 1838 | return false; |
| 1839 | 1839 | } |
| 1840 | 1840 | |
| 1841 | | bool wd177x_t::has_head_load() const |
| 1841 | bool wd_fdc_t::has_head_load() const |
| 1842 | 1842 | { |
| 1843 | 1843 | return false; |
| 1844 | 1844 | } |
| 1845 | 1845 | |
| 1846 | | bool wd177x_t::has_side_check() const |
| 1846 | bool wd_fdc_t::has_side_check() const |
| 1847 | 1847 | { |
| 1848 | 1848 | return false; |
| 1849 | 1849 | } |
| 1850 | 1850 | |
| 1851 | | bool wd177x_t::has_side_select() const |
| 1851 | bool wd_fdc_t::has_side_select() const |
| 1852 | 1852 | { |
| 1853 | 1853 | return false; |
| 1854 | 1854 | } |
| 1855 | 1855 | |
| 1856 | | bool wd177x_t::has_sector_length_select() const |
| 1856 | bool wd_fdc_t::has_sector_length_select() const |
| 1857 | 1857 | { |
| 1858 | 1858 | return false; |
| 1859 | 1859 | } |
| 1860 | 1860 | |
| 1861 | | bool wd177x_t::has_precompensation() const |
| 1861 | bool wd_fdc_t::has_precompensation() const |
| 1862 | 1862 | { |
| 1863 | 1863 | return false; |
| 1864 | 1864 | } |
| 1865 | 1865 | |
| 1866 | | fd1771_t::fd1771_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd177x_t(mconfig, FD1771x, "FD1771", tag, owner, clock) |
| 1866 | fd1771_t::fd1771_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_t(mconfig, FD1771x, "FD1771", tag, owner, clock) |
| 1867 | 1867 | { |
| 1868 | 1868 | } |
| 1869 | 1869 | |
| 1870 | | fd1793_t::fd1793_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd177x_t(mconfig, FD1793x, "FD1793", tag, owner, clock) |
| 1870 | fd1793_t::fd1793_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_t(mconfig, FD1793x, "FD1793", tag, owner, clock) |
| 1871 | 1871 | { |
| 1872 | 1872 | } |
| 1873 | 1873 | |
| 1874 | | fd1797_t::fd1797_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd177x_t(mconfig, FD1797x, "FD1797", tag, owner, clock) |
| 1874 | fd1797_t::fd1797_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_t(mconfig, FD1797x, "FD1797", tag, owner, clock) |
| 1875 | 1875 | { |
| 1876 | 1876 | } |
| 1877 | 1877 | |
| 1878 | | wd2793_t::wd2793_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd177x_t(mconfig, WD2793x, "WD2793", tag, owner, clock) |
| 1878 | wd2793_t::wd2793_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_t(mconfig, WD2793x, "WD2793", tag, owner, clock) |
| 1879 | 1879 | { |
| 1880 | 1880 | } |
| 1881 | 1881 | |
| 1882 | | wd2797_t::wd2797_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd177x_t(mconfig, WD2797x, "WD2797", tag, owner, clock) |
| 1882 | wd2797_t::wd2797_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_t(mconfig, WD2797x, "WD2797", tag, owner, clock) |
| 1883 | 1883 | { |
| 1884 | 1884 | } |
| 1885 | 1885 | |
| 1886 | | wd1770_t::wd1770_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd177x_t(mconfig, WD1770x, "WD1770", tag, owner, clock) |
| 1886 | wd1770_t::wd1770_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_t(mconfig, WD1770x, "WD1770", tag, owner, clock) |
| 1887 | 1887 | { |
| 1888 | 1888 | } |
| 1889 | 1889 | |
| 1890 | | wd1772_t::wd1772_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd177x_t(mconfig, WD1772x, "WD1772", tag, owner, clock) |
| 1890 | wd1772_t::wd1772_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_t(mconfig, WD1772x, "WD1772", tag, owner, clock) |
| 1891 | 1891 | { |
| 1892 | 1892 | } |
| 1893 | 1893 | |
| r19173 | r19174 | |
| 1902 | 1902 | return 120000; |
| 1903 | 1903 | } |
| 1904 | 1904 | |
| 1905 | | wd1773_t::wd1773_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd177x_t(mconfig, WD1773x, "WD1773", tag, owner, clock) |
| 1905 | wd1773_t::wd1773_t(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : wd_fdc_t(mconfig, WD1773x, "WD1773", tag, owner, clock) |
| 1906 | 1906 | { |
| 1907 | 1907 | } |