trunk/src/lib/formats/victor9k_dsk.c
r241714 | r241715 | |
36 | 36 | 7 71-79 63-74 12 149.6 401 |
37 | 37 | 8 unused 75-79 11 144.0 417 |
38 | 38 | |
| 39 | Interleave factor 3 |
| 40 | |
39 | 41 | */ |
40 | 42 | |
41 | 43 | #include "emu.h" |
r241714 | r241715 | |
60 | 62 | return "img"; |
61 | 63 | } |
62 | 64 | |
| 65 | int victor9k_format::find_size(io_generic *io, UINT32 form_factor) |
| 66 | { |
| 67 | UINT64 size = io_generic_size(io); |
| 68 | for(int i=0; formats[i].sector_count; i++) { |
| 69 | const format &f = formats[i]; |
| 70 | if(size == (UINT32) f.sector_count*f.sector_base_size*f.head_count) |
| 71 | return i; |
| 72 | } |
| 73 | return -1; |
| 74 | } |
| 75 | |
63 | 76 | int victor9k_format::identify(io_generic *io, UINT32 form_factor) |
64 | 77 | { |
| 78 | int type = find_size(io, form_factor); |
| 79 | |
| 80 | if (type != -1) |
| 81 | return 50; |
| 82 | |
65 | 83 | return 0; |
66 | 84 | } |
67 | 85 | |
| 86 | floppy_image_format_t::desc_e* victor9k_format::get_sector_desc(const format &f, int ¤t_size, int sector_count, UINT8 id1, UINT8 id2, int gap_2) |
| 87 | { |
| 88 | static floppy_image_format_t::desc_e desc[] = { |
| 89 | /* 00 */ { SECTOR_LOOP_START, 0, -1 }, |
| 90 | /* 01 */ { RAWBYTE, 0xff, 5 }, |
| 91 | /* 02 */ { GCR5, 0x08, 1 }, |
| 92 | /* 03 */ { CRC, 1 }, |
| 93 | /* 04 */ { CRC_CBM_START, 1 }, |
| 94 | /* 05 */ { SECTOR_ID_GCR5 }, |
| 95 | /* 06 */ { TRACK_ID_DOS2_GCR5 }, |
| 96 | /* 07 */ { GCR5, id2, 1 }, |
| 97 | /* 08 */ { GCR5, id1, 1 }, |
| 98 | /* 09 */ { CRC_END, 1 }, |
| 99 | /* 10 */ { GCR5, 0x0f, 2 }, |
| 100 | /* 11 */ { RAWBYTE, 0x55, f.gap_1 }, |
| 101 | /* 12 */ { RAWBYTE, 0xff, 5 }, |
| 102 | /* 13 */ { GCR5, 0x07, 1 }, |
| 103 | /* 14 */ { CRC_CBM_START, 2 }, |
| 104 | /* 15 */ { SECTOR_DATA_GCR5, -1 }, |
| 105 | /* 16 */ { CRC_END, 2 }, |
| 106 | /* 17 */ { CRC, 2 }, |
| 107 | /* 18 */ { GCR5, 0x00, 2 }, |
| 108 | /* 19 */ { RAWBYTE, 0x55, gap_2 }, |
| 109 | /* 20 */ { SECTOR_LOOP_END }, |
| 110 | /* 21 */ { RAWBYTE, 0x55, 0 }, |
| 111 | /* 22 */ { RAWBITS, 0x5555, 0 }, |
| 112 | /* 23 */ { END } |
| 113 | }; |
| 114 | |
| 115 | current_size = 40 + (1+1+4+2)*10 + (f.gap_1)*8 + 40 + (1+f.sector_base_size+1+2)*10 + gap_2*8; |
| 116 | |
| 117 | current_size *= sector_count; |
| 118 | return desc; |
| 119 | } |
| 120 | |
| 121 | void victor9k_format::build_sector_description(const format &f, UINT8 *sectdata, offs_t sect_offs, desc_s *sectors, int sector_count) const |
| 122 | { |
| 123 | for (int i = 0; i < sector_count; i++) { |
| 124 | sectors[i].data = sectdata + sect_offs; |
| 125 | sectors[i].size = f.sector_base_size; |
| 126 | sectors[i].sector_id = i; |
| 127 | |
| 128 | sect_offs += sectors[i].size; |
| 129 | } |
| 130 | } |
| 131 | |
68 | 132 | bool victor9k_format::load(io_generic *io, UINT32 form_factor, floppy_image *image) |
69 | 133 | { |
70 | | return false; |
| 134 | int type = find_size(io, form_factor); |
| 135 | if(type == -1) |
| 136 | return false; |
| 137 | |
| 138 | const format &f = formats[type]; |
| 139 | |
| 140 | UINT64 size = io_generic_size(io); |
| 141 | dynamic_buffer img; |
| 142 | img.resize(size); |
| 143 | |
| 144 | io_generic_read(io, img, 0, size); |
| 145 | |
| 146 | int track_offset = 0; |
| 147 | |
| 148 | UINT8 id1 = 0xde, id2 = 0xad; // TODO |
| 149 | |
| 150 | for (int head = 0; head < f.head_count; head++) { |
| 151 | for (int track = 0; track < f.track_count; track++) { |
| 152 | int current_size = 0; |
| 153 | int total_size = 200000000./cell_size[speed_zone[head][track]]; |
| 154 | int sector_count = sectors_per_track[head][track]; |
| 155 | int track_size = sector_count*f.sector_base_size; |
| 156 | |
| 157 | floppy_image_format_t::desc_e *desc = get_sector_desc(f, current_size, sector_count, id1, id2, f.gap_2); |
| 158 | |
| 159 | int remaining_size = total_size - current_size; |
| 160 | if(remaining_size < 0) |
| 161 | throw emu_fatalerror("victor9k_format: Incorrect track layout, max_size=%d, current_size=%d", total_size, current_size); |
| 162 | |
| 163 | // Fixup the end gap |
| 164 | desc[21].p2 = remaining_size / 8; |
| 165 | desc[22].p2 = remaining_size & 7; |
| 166 | desc[22].p1 >>= remaining_size & 0x01; |
| 167 | |
| 168 | desc_s sectors[40]; |
| 169 | |
| 170 | build_sector_description(f, img, track_offset, sectors, sector_count); |
| 171 | generate_track(desc, track, head, sectors, sector_count, total_size, image); |
| 172 | |
| 173 | track_offset += track_size; |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | image->set_variant(f.variant); |
| 178 | |
| 179 | return true; |
71 | 180 | } |
72 | 181 | |
73 | 182 | bool victor9k_format::supports_save() const |
r241714 | r241715 | |
77 | 186 | |
78 | 187 | const victor9k_format::format victor9k_format::formats[] = { |
79 | 188 | { // |
80 | | floppy_image::FF_525, floppy_image::SSDD, 80, 1, 512 |
| 189 | floppy_image::FF_525, floppy_image::SSDD, 1224, 80, 1, 512, 9, 8 |
81 | 190 | }, |
82 | 191 | { // |
83 | | floppy_image::FF_525, floppy_image::DSDD, 80, 2, 512 |
| 192 | floppy_image::FF_525, floppy_image::DSDD, 2448, 80, 2, 512, 9, 8 |
84 | 193 | }, |
85 | 194 | {} |
86 | 195 | }; |
trunk/src/mess/drivers/victor9k.c
r241714 | r241715 | |
38 | 38 | |
39 | 39 | static ADDRESS_MAP_START( victor9k_mem, AS_PROGRAM, 8, victor9k_state ) |
40 | 40 | // AM_RANGE(0x00000, 0xdffff) AM_RAM |
| 41 | AM_RANGE(0x20000, 0xdffff) AM_NOP |
41 | 42 | AM_RANGE(0xe0000, 0xe0001) AM_DEVREADWRITE(I8259A_TAG, pic8259_device, read, write) |
42 | 43 | AM_RANGE(0xe0020, 0xe0023) AM_DEVREADWRITE(I8253_TAG, pit8253_device, read, write) |
43 | 44 | AM_RANGE(0xe0040, 0xe0043) AM_DEVREADWRITE(UPD7201_TAG, upd7201_device, cd_ba_r, cd_ba_w) |
44 | | AM_RANGE(0xe8000, 0xe8000) AM_DEVREADWRITE(HD46505S_TAG, mc6845_device, status_r, address_w) |
45 | | AM_RANGE(0xe8001, 0xe8001) AM_DEVREADWRITE(HD46505S_TAG, mc6845_device, register_r, register_w) |
46 | | AM_RANGE(0xe8020, 0xe802f) AM_DEVREADWRITE(M6522_1_TAG, via6522_device, read, write) |
47 | | AM_RANGE(0xe8040, 0xe804f) AM_DEVREADWRITE(M6522_2_TAG, via6522_device, read, write) |
48 | | AM_RANGE(0xe8060, 0xe8061) AM_DEVREADWRITE(MC6852_TAG, mc6852_device, read, write) |
49 | | AM_RANGE(0xe8080, 0xe808f) AM_DEVREADWRITE(M6522_3_TAG, via6522_device, read, write) |
50 | | AM_RANGE(0xe80a0, 0xe80af) AM_DEVREADWRITE(FDC_TAG, victor_9000_fdc_t, cs5_r, cs5_w) |
51 | | AM_RANGE(0xe80c0, 0xe80cf) AM_DEVREADWRITE(FDC_TAG, victor_9000_fdc_t, cs6_r, cs6_w) |
52 | | AM_RANGE(0xe80e0, 0xe80ef) AM_DEVREADWRITE(FDC_TAG, victor_9000_fdc_t, cs7_r, cs7_w) |
| 45 | AM_RANGE(0xe8000, 0xe8000) AM_MIRROR(0x7f00) AM_DEVREADWRITE(HD46505S_TAG, mc6845_device, status_r, address_w) |
| 46 | AM_RANGE(0xe8001, 0xe8001) AM_MIRROR(0x7f00) AM_DEVREADWRITE(HD46505S_TAG, mc6845_device, register_r, register_w) |
| 47 | AM_RANGE(0xe8020, 0xe802f) AM_MIRROR(0x7f00) AM_DEVREADWRITE(M6522_1_TAG, via6522_device, read, write) |
| 48 | AM_RANGE(0xe8040, 0xe804f) AM_MIRROR(0x7f00) AM_DEVREADWRITE(M6522_2_TAG, via6522_device, read, write) |
| 49 | AM_RANGE(0xe8060, 0xe8061) AM_MIRROR(0x7f00) AM_DEVREADWRITE(MC6852_TAG, mc6852_device, read, write) |
| 50 | AM_RANGE(0xe8080, 0xe808f) AM_MIRROR(0x7f00) AM_DEVREADWRITE(M6522_3_TAG, via6522_device, read, write) |
| 51 | AM_RANGE(0xe80a0, 0xe80af) AM_MIRROR(0x7f00) AM_DEVREADWRITE(FDC_TAG, victor_9000_fdc_t, cs5_r, cs5_w) |
| 52 | AM_RANGE(0xe80c0, 0xe80cf) AM_MIRROR(0x7f00) AM_DEVREADWRITE(FDC_TAG, victor_9000_fdc_t, cs6_r, cs6_w) |
| 53 | AM_RANGE(0xe80e0, 0xe80ef) AM_MIRROR(0x7f00) AM_DEVREADWRITE(FDC_TAG, victor_9000_fdc_t, cs7_r, cs7_w) |
53 | 54 | AM_RANGE(0xf0000, 0xf0fff) AM_MIRROR(0x1000) AM_RAM AM_SHARE("video_ram") |
54 | 55 | AM_RANGE(0xfe000, 0xfffff) AM_ROM AM_REGION(I8088_TAG, 0) |
55 | 56 | ADDRESS_MAP_END |
trunk/src/mess/machine/victor9k_fdc.c
r241714 | r241715 | |
15 | 15 | |
16 | 16 | - floppy format |
17 | 17 | - spindle speed |
18 | | - stepper |
19 | 18 | - read PLL |
20 | 19 | - write logic |
21 | 20 | |
r241714 | r241715 | |
29 | 28 | // MACROS / CONSTANTS |
30 | 29 | //************************************************************************** |
31 | 30 | |
32 | | #define LOG 0 |
| 31 | #define LOG 1 |
33 | 32 | |
34 | 33 | #define I8048_TAG "5d" |
35 | 34 | #define M6522_4_TAG "1f" |
r241714 | r241715 | |
85 | 84 | // SLOT_INTERFACE( victor9k_floppies ) |
86 | 85 | //------------------------------------------------- |
87 | 86 | |
88 | | void victor_9000_fdc_t::ready0_cb(floppy_image_device *device, int state) |
89 | | { |
90 | | m_rdy0 = state; |
91 | | |
92 | | m_via5->write_ca2(m_rdy0); |
93 | | } |
94 | | |
95 | 87 | int victor_9000_fdc_t::load0_cb(floppy_image_device *device) |
96 | 88 | { |
97 | | m_ds0 = 0; |
| 89 | m_via4->write_ca1(0); |
98 | 90 | |
99 | | m_via4->write_ca1(m_ds0); |
100 | | |
101 | 91 | return IMAGE_INIT_PASS; |
102 | 92 | } |
103 | 93 | |
104 | 94 | void victor_9000_fdc_t::unload0_cb(floppy_image_device *device) |
105 | 95 | { |
106 | | m_ds0 = 1; |
107 | | |
108 | | m_via4->write_ca1(m_ds0); |
| 96 | m_via4->write_ca1(1); |
109 | 97 | } |
110 | 98 | |
111 | | void victor_9000_fdc_t::index0_cb(floppy_image_device *device, int state) |
112 | | { |
113 | | m_tach0 = state; |
114 | | } |
115 | | |
116 | | void victor_9000_fdc_t::ready1_cb(floppy_image_device *device, int state) |
117 | | { |
118 | | m_rdy1 = state; |
119 | | |
120 | | m_via5->write_cb2(m_rdy1); |
121 | | } |
122 | | |
123 | 99 | int victor_9000_fdc_t::load1_cb(floppy_image_device *device) |
124 | 100 | { |
125 | | m_ds1 = 0; |
| 101 | m_via4->write_cb1(0); |
126 | 102 | |
127 | | m_via4->write_cb1(m_ds1); |
128 | | |
129 | 103 | return IMAGE_INIT_PASS; |
130 | 104 | } |
131 | 105 | |
132 | 106 | void victor_9000_fdc_t::unload1_cb(floppy_image_device *device) |
133 | 107 | { |
134 | | m_ds1 = 1; |
135 | | |
136 | | m_via4->write_cb1(m_ds1); |
| 108 | m_via4->write_cb1(1); |
137 | 109 | } |
138 | 110 | |
139 | | void victor_9000_fdc_t::index1_cb(floppy_image_device *device, int state) |
140 | | { |
141 | | m_tach1 = state; |
142 | | } |
143 | | |
144 | 111 | static SLOT_INTERFACE_START( victor9k_floppies ) |
145 | 112 | SLOT_INTERFACE( "525ssqd", FLOPPY_525_SSQD ) // Tandon TM100-3 with custom electronics |
146 | 113 | SLOT_INTERFACE( "525qd", FLOPPY_525_QD ) // Tandon TM100-4 with custom electronics |
r241714 | r241715 | |
215 | 182 | m_via6(*this, M6522_6_TAG), |
216 | 183 | m_floppy0(*this, I8048_TAG":0:525qd"), |
217 | 184 | m_floppy1(*this, I8048_TAG":1:525qd"), |
| 185 | m_rom(*this, I8048_TAG), |
218 | 186 | m_gcr_rom(*this, "gcr"), |
219 | 187 | m_da(0), |
220 | 188 | m_da0(0), |
221 | 189 | m_da1(0), |
| 190 | m_start0(1), |
| 191 | m_stop0(1), |
| 192 | m_start1(1), |
| 193 | m_stop1(1), |
222 | 194 | m_sel0(0), |
223 | 195 | m_sel1(0), |
224 | 196 | m_tach0(0), |
225 | 197 | m_tach1(0), |
226 | 198 | m_rdy0(0), |
227 | 199 | m_rdy1(0), |
228 | | m_ds0(1), |
229 | | m_ds1(1), |
230 | 200 | m_l0ms(0), |
231 | 201 | m_l1ms(0), |
232 | 202 | m_st0(0), |
r241714 | r241715 | |
256 | 226 | void victor_9000_fdc_t::device_start() |
257 | 227 | { |
258 | 228 | // allocate timer |
259 | | t_gen = timer_alloc(0); |
| 229 | t_gen = timer_alloc(TM_GEN); |
| 230 | t_tach0 = timer_alloc(TM_TACH0); |
| 231 | t_tach1 = timer_alloc(TM_TACH1); |
260 | 232 | |
261 | 233 | // state saving |
262 | 234 | save_item(NAME(m_da)); |
263 | 235 | save_item(NAME(m_da0)); |
264 | 236 | save_item(NAME(m_da1)); |
| 237 | save_item(NAME(m_start0)); |
| 238 | save_item(NAME(m_stop0)); |
| 239 | save_item(NAME(m_start1)); |
| 240 | save_item(NAME(m_stop1)); |
265 | 241 | save_item(NAME(m_sel0)); |
266 | 242 | save_item(NAME(m_sel1)); |
267 | 243 | save_item(NAME(m_tach0)); |
268 | 244 | save_item(NAME(m_tach1)); |
269 | 245 | save_item(NAME(m_rdy0)); |
270 | 246 | save_item(NAME(m_rdy1)); |
271 | | save_item(NAME(m_ds0)); |
272 | | save_item(NAME(m_ds1)); |
273 | 247 | save_item(NAME(m_l0ms)); |
274 | 248 | save_item(NAME(m_l1ms)); |
275 | 249 | save_item(NAME(m_st0)); |
r241714 | r241715 | |
307 | 281 | m_via6->reset(); |
308 | 282 | |
309 | 283 | // set floppy callbacks |
310 | | m_floppy0->setup_ready_cb(floppy_image_device::ready_cb(FUNC(victor_9000_fdc_t::ready0_cb), this)); |
311 | 284 | m_floppy0->setup_load_cb(floppy_image_device::load_cb(FUNC(victor_9000_fdc_t::load0_cb), this)); |
312 | 285 | m_floppy0->setup_unload_cb(floppy_image_device::unload_cb(FUNC(victor_9000_fdc_t::unload0_cb), this)); |
313 | | m_floppy0->setup_index_pulse_cb(floppy_image_device::index_pulse_cb(FUNC(victor_9000_fdc_t::index0_cb), this)); |
314 | | m_floppy1->setup_ready_cb(floppy_image_device::ready_cb(FUNC(victor_9000_fdc_t::ready1_cb), this)); |
| 286 | |
315 | 287 | m_floppy1->setup_load_cb(floppy_image_device::load_cb(FUNC(victor_9000_fdc_t::load1_cb), this)); |
316 | 288 | m_floppy1->setup_unload_cb(floppy_image_device::unload_cb(FUNC(victor_9000_fdc_t::unload1_cb), this)); |
317 | | m_floppy1->setup_index_pulse_cb(floppy_image_device::index_pulse_cb(FUNC(victor_9000_fdc_t::index1_cb), this)); |
318 | 289 | } |
319 | 290 | |
320 | 291 | |
r241714 | r241715 | |
324 | 295 | |
325 | 296 | void victor_9000_fdc_t::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
326 | 297 | { |
327 | | live_sync(); |
328 | | live_run(); |
| 298 | switch (id) |
| 299 | { |
| 300 | case TM_GEN: |
| 301 | live_sync(); |
| 302 | live_run(); |
| 303 | break; |
| 304 | |
| 305 | case TM_TACH0: |
| 306 | m_tach0 = 1; |
| 307 | break; |
| 308 | |
| 309 | case TM_TACH1: |
| 310 | m_tach1 = 1; |
| 311 | break; |
| 312 | } |
329 | 313 | } |
330 | 314 | |
331 | 315 | |
r241714 | r241715 | |
360 | 344 | |
361 | 345 | READ8_MEMBER( victor_9000_fdc_t::floppy_p2_r ) |
362 | 346 | { |
363 | | /* |
364 | | |
365 | | bit description |
366 | | |
367 | | 0 |
368 | | 1 |
369 | | 2 |
370 | | 3 |
371 | | 4 |
372 | | 5 |
373 | | 6 RDY0 |
374 | | 7 RDY1 |
375 | | |
376 | | */ |
377 | | |
378 | | UINT8 data = 0; |
379 | | |
380 | | data |= m_rdy0 << 6; |
381 | | data |= m_rdy1 << 7; |
382 | | |
383 | | return data; |
| 347 | return m_p2; // TODO needed because of ORL/ANL P2, should be in mcs48.c |
384 | 348 | } |
385 | 349 | |
386 | 350 | |
r241714 | r241715 | |
400 | 364 | 3 STOP1 |
401 | 365 | 4 SEL1 |
402 | 366 | 5 SEL0 |
403 | | 6 |
404 | | 7 |
| 367 | 6 RDY0 |
| 368 | 7 RDY1 |
405 | 369 | |
406 | 370 | */ |
407 | 371 | |
| 372 | m_p2 = data; |
| 373 | |
408 | 374 | bool sync = false; |
409 | 375 | |
410 | | int mtr0 = m_mtr0; |
411 | | if ((data & 0x03) == 0x01) mtr0 = 0; |
412 | | if ((data & 0x03) == 0x02) mtr0 = 1; |
413 | | if (m_mtr0 != mtr0) sync = true; |
| 376 | int start0 = BIT(data, 0); |
| 377 | if (m_start0 != start0) sync = true; |
414 | 378 | |
415 | | int mtr1 = m_mtr1; |
416 | | if ((data & 0x0c) == 0x04) mtr1 = 0; |
417 | | if ((data & 0x0c) == 0x08) mtr1 = 1; |
418 | | if (m_mtr1 != mtr1) sync = true; |
| 379 | int stop0 = BIT(data, 1); |
| 380 | if (m_stop0 != stop0) sync = true; |
419 | 381 | |
| 382 | int start1 = BIT(data, 2); |
| 383 | if (m_start1 != start1) sync = true; |
| 384 | |
| 385 | int stop1 = BIT(data, 3); |
| 386 | if (m_stop1 != stop1) sync = true; |
| 387 | |
420 | 388 | int sel0 = BIT(data, 5); |
421 | 389 | if (m_sel0 != sel0) sync = true; |
422 | 390 | |
423 | 391 | int sel1 = BIT(data, 4); |
424 | 392 | if (m_sel1 != sel1) sync = true; |
425 | 393 | |
| 394 | m_rdy0 = BIT(data, 6); |
| 395 | m_rdy1 = BIT(data, 7); |
| 396 | |
| 397 | if (LOG) logerror("%s %s START0/STOP0/SEL0/RDY0 %u/%u/%u/%u START1/STOP1/SEL1/RDY1 %u/%u/%u/%u\n", machine().time().as_string(), machine().describe_context(), start0, stop0, sel0, m_rdy0, start1, stop1, sel1, m_rdy1); |
| 398 | |
426 | 399 | if (sync) |
427 | 400 | { |
428 | 401 | live_sync(); |
429 | 402 | |
430 | | m_mtr0 = mtr0; |
431 | | m_mtr1 = mtr1; |
| 403 | m_start0 = start0; |
| 404 | m_stop0 = stop0; |
432 | 405 | m_sel0 = sel0; |
| 406 | update_spindle_motor(m_floppy0, t_tach0, m_start0, m_stop0, m_sel0, m_da0); |
| 407 | |
| 408 | m_start1 = start1; |
| 409 | m_stop1 = stop1; |
433 | 410 | m_sel1 = sel1; |
| 411 | update_spindle_motor(m_floppy1, t_tach1, m_start1, m_stop1, m_sel1, m_da1); |
434 | 412 | |
435 | | if (LOG) logerror("%s MTR0 %u MTR1 %u SEL0 %u SEL1 %u\n", machine().time().as_string(), m_mtr0, m_mtr1, m_sel0, m_sel1); |
436 | | |
437 | | update_spindle_motor(); |
438 | 413 | checkpoint(); |
439 | 414 | |
440 | | if (!m_mtr0 || !m_mtr1) { |
| 415 | if (!m_floppy0->mon_r() || !m_floppy1->mon_r()) { |
441 | 416 | if(cur_live.state == IDLE) { |
442 | 417 | live_start(); |
443 | 418 | } |
r241714 | r241715 | |
456 | 431 | |
457 | 432 | READ8_MEMBER( victor_9000_fdc_t::tach0_r ) |
458 | 433 | { |
459 | | return m_tach0; |
| 434 | int tach0 = m_tach0; |
| 435 | |
| 436 | m_tach0 = 0; |
| 437 | |
| 438 | return tach0; |
460 | 439 | } |
461 | 440 | |
462 | 441 | |
r241714 | r241715 | |
466 | 445 | |
467 | 446 | READ8_MEMBER( victor_9000_fdc_t::tach1_r ) |
468 | 447 | { |
469 | | return m_tach1; |
| 448 | int tach1 = m_tach1; |
| 449 | |
| 450 | m_tach1 = 0; |
| 451 | |
| 452 | return tach1; |
470 | 453 | } |
471 | 454 | |
472 | 455 | |
473 | 456 | void victor_9000_fdc_t::update_stepper_motor(floppy_image_device *floppy, int stp, int old_st, int st) |
474 | 457 | { |
475 | | // TODO |
| 458 | if (stp) return; |
| 459 | |
| 460 | int tracks = 0; |
| 461 | |
| 462 | switch (old_st) |
| 463 | { |
| 464 | case 6: if (st == 0xa) tracks++; else if (st == 5) tracks--; break; |
| 465 | case 5: if (st == 6) tracks++; else if (st == 9) tracks--; break; |
| 466 | case 9: if (st == 5) tracks++; else if (st == 0xa) tracks--; break; |
| 467 | case 0xa: if (st == 9) tracks++; else if (st == 6) tracks--; break; |
| 468 | } |
| 469 | |
| 470 | if (tracks == -1) |
| 471 | { |
| 472 | floppy->dir_w(1); |
| 473 | floppy->stp_w(1); |
| 474 | floppy->stp_w(0); |
| 475 | } |
| 476 | else if (tracks == 1) |
| 477 | { |
| 478 | floppy->dir_w(0); |
| 479 | floppy->stp_w(1); |
| 480 | floppy->stp_w(0); |
| 481 | } |
476 | 482 | } |
477 | 483 | |
478 | | void victor_9000_fdc_t::update_spindle_motor() |
| 484 | void victor_9000_fdc_t::update_spindle_motor(floppy_image_device *floppy, emu_timer *t_tach, bool start, bool stop, bool sel, UINT8 &da) |
479 | 485 | { |
480 | | if (m_sel0) m_da0 = m_da; |
481 | | m_floppy0->mon_w(m_mtr0); |
482 | | m_floppy0->set_rpm(300); // TODO |
| 486 | if (!start && !stop && floppy->mon_r()) { |
| 487 | if (LOG) logerror("%s: motor start\n", floppy->tag()); |
| 488 | floppy->mon_w(0); |
| 489 | } else if (stop && !floppy->mon_r()) { |
| 490 | if (LOG) logerror("%s: motor stop\n", floppy->tag()); |
| 491 | floppy->mon_w(1); |
| 492 | } |
483 | 493 | |
484 | | if (m_sel1) m_da1 = m_da; |
485 | | m_floppy1->mon_w(m_mtr1); |
486 | | m_floppy1->set_rpm(300); // TODO |
| 494 | if (sel) { |
| 495 | da = m_da; |
| 496 | } |
| 497 | |
| 498 | floppy->set_rpm(300); // TODO |
| 499 | t_tach->adjust(attotime::from_hz(5)); // TODO |
487 | 500 | } |
488 | 501 | |
489 | 502 | |
r241714 | r241715 | |
497 | 510 | { |
498 | 511 | live_sync(); |
499 | 512 | m_da = data; |
500 | | update_spindle_motor(); |
| 513 | if (LOG) logerror("%s %s DA %02x\n", machine().time().as_string(), machine().describe_context(), data); |
| 514 | update_spindle_motor(m_floppy0, t_tach0, m_start0, m_stop0, m_sel0, m_da0); |
| 515 | update_spindle_motor(m_floppy1, t_tach1, m_start1, m_stop1, m_sel1, m_da1); |
501 | 516 | checkpoint(); |
502 | 517 | live_run(); |
503 | 518 | } |
r241714 | r241715 | |
529 | 544 | live_sync(); |
530 | 545 | update_stepper_motor(m_floppy0, m_stp0, st0, m_st0); |
531 | 546 | m_st0 = st0; |
| 547 | if (LOG) logerror("%s %s L0MS %01x ST0 %01x\n", machine().time().as_string(), machine().describe_context(), m_l0ms, st0); |
532 | 548 | checkpoint(); |
533 | 549 | live_run(); |
534 | 550 | } |
r241714 | r241715 | |
560 | 576 | live_sync(); |
561 | 577 | update_stepper_motor(m_floppy1, m_stp1, st1, m_st1); |
562 | 578 | m_st1 = st1; |
| 579 | if (LOG) logerror("%s %s L1MS %01x ST1 %01x\n", machine().time().as_string(), machine().describe_context(), m_l1ms, st1); |
563 | 580 | checkpoint(); |
564 | 581 | live_run(); |
565 | 582 | } |
r241714 | r241715 | |
627 | 644 | if (m_wd != data) |
628 | 645 | { |
629 | 646 | live_sync(); |
630 | | m_wd = data; |
631 | | cur_live.wd = data; |
| 647 | m_wd = cur_live.wd = data; |
| 648 | if (LOG) logerror("%s %s WD %02x\n", machine().time().as_string(), machine().describe_context(), data); |
632 | 649 | checkpoint(); |
633 | 650 | live_run(); |
634 | 651 | } |
r241714 | r241715 | |
659 | 676 | |
660 | 677 | */ |
661 | 678 | |
| 679 | if (LOG) logerror("%s %s TRK0D0 %u TRK0D1 %u\n", machine().time().as_string(), machine().describe_context(), m_floppy0->trk00_r(),m_floppy1->trk00_r()); |
| 680 | |
662 | 681 | UINT8 data = 0; |
663 | 682 | |
664 | 683 | // track 0 drive A sense |
r241714 | r241715 | |
721 | 740 | m_drive = drive; |
722 | 741 | cur_live.drive = drive; |
723 | 742 | |
| 743 | if (LOG) logerror("%s %s SIDE %u DRIVE %u\n", machine().time().as_string(), machine().describe_context(), side, drive); |
| 744 | |
724 | 745 | checkpoint(); |
725 | 746 | live_run(); |
726 | 747 | } |
r241714 | r241715 | |
752 | 773 | data |= m_rdy1 << 1; |
753 | 774 | |
754 | 775 | // door B sense |
755 | | data |= m_ds1 << 3; |
| 776 | data |= (m_floppy1->exists() ? 0 : 1) << 3; |
756 | 777 | |
757 | 778 | // door A sense |
758 | | data |= m_ds0 << 4; |
| 779 | data |= (m_floppy0->exists() ? 0 : 1) << 4; |
759 | 780 | |
760 | 781 | // single/double sided |
761 | 782 | data |= (m_drive ? m_floppy1->twosid_r() : m_floppy0->twosid_r()) << 5; |
r241714 | r241715 | |
804 | 825 | m_stp1 = stp1; |
805 | 826 | update_stepper_motor(m_floppy1, m_stp1, m_st1, m_st1); |
806 | 827 | |
| 828 | if (LOG) logerror("%s %s STP0 %u STP1 %u\n", machine().time().as_string(), machine().describe_context(), stp0, stp1); |
| 829 | |
807 | 830 | checkpoint(); |
808 | 831 | live_run(); |
809 | 832 | } |
r241714 | r241715 | |
816 | 839 | live_sync(); |
817 | 840 | m_drw = cur_live.drw = state; |
818 | 841 | checkpoint(); |
819 | | if (LOG) logerror("%s DRW %u\n", machine().time().as_string(), state); |
| 842 | if (LOG) logerror("%s %s DRW %u\n", machine().time().as_string(), machine().describe_context(), state); |
820 | 843 | if (state) { |
821 | 844 | stop_writing(machine().time()); |
822 | 845 | } else { |
r241714 | r241715 | |
833 | 856 | live_sync(); |
834 | 857 | m_erase = cur_live.erase = state; |
835 | 858 | checkpoint(); |
836 | | if (LOG) logerror("%s ERASE %u\n", machine().time().as_string(), state); |
| 859 | if (LOG) logerror("%s %s ERASE %u\n", machine().time().as_string(), machine().describe_context(), state); |
837 | 860 | live_run(); |
838 | 861 | } |
839 | 862 | } |
r241714 | r241715 | |
851 | 874 | { |
852 | 875 | live_sync(); |
853 | 876 | cur_live.lbrdy = 1; |
| 877 | if (LOG) logerror("%s %s LBRDY 1\n", machine().time().as_string(), machine().describe_context()); |
854 | 878 | m_lbrdy_cb(1); |
855 | 879 | checkpoint(); |
856 | 880 | live_run(); |
r241714 | r241715 | |
865 | 889 | { |
866 | 890 | live_sync(); |
867 | 891 | cur_live.lbrdy = 1; |
| 892 | if (LOG) logerror("%s %s LBRDY 1\n", machine().time().as_string(), machine().describe_context()); |
868 | 893 | m_lbrdy_cb(1); |
869 | 894 | checkpoint(); |
870 | 895 | live_run(); |