trunk/src/devices/machine/wozfdc.cpp
r250329 | r250330 | |
186 | 186 | |
187 | 187 | READ8_MEMBER(wozfdc_device::read) |
188 | 188 | { |
| 189 | lss_sync(); |
189 | 190 | control(offset); |
190 | 191 | |
191 | 192 | if(!(offset & 1)) { |
192 | | lss_sync(); |
193 | 193 | return data_reg; |
194 | 194 | } |
195 | 195 | return 0xff; |
r250329 | r250330 | |
202 | 202 | |
203 | 203 | WRITE8_MEMBER(wozfdc_device::write) |
204 | 204 | { |
205 | | control(offset); |
206 | 205 | lss_sync(); |
| 206 | control(offset); |
207 | 207 | last_6502_write = data; |
208 | 208 | } |
209 | 209 | |
r250329 | r250330 | |
220 | 220 | |
221 | 221 | void wozfdc_device::control(int offset) |
222 | 222 | { |
223 | | if(offset < 8) { |
224 | | if(active) |
225 | | lss_sync(); |
| 223 | if(offset < 8) |
226 | 224 | phase(offset >> 1, offset & 1); |
227 | 225 | |
228 | | } else |
| 226 | else |
229 | 227 | switch(offset) { |
230 | 228 | case 0x8: |
231 | 229 | if(active == MODE_ACTIVE) { |
232 | | lss_sync(); |
233 | 230 | delay_timer->adjust(attotime::from_seconds(1)); |
234 | 231 | active = MODE_DELAY; |
235 | 232 | } |
r250329 | r250330 | |
252 | 249 | case 0xa: |
253 | 250 | external_io_select = false; |
254 | 251 | if(floppy != floppy0->get_device()) { |
255 | | if(active) { |
256 | | lss_sync(); |
| 252 | if(active) |
257 | 253 | floppy->mon_w(true); |
258 | | } |
259 | 254 | floppy = floppy0->get_device(); |
260 | 255 | if(active) |
261 | 256 | floppy->mon_w(false); |
r250329 | r250330 | |
267 | 262 | { |
268 | 263 | if (floppy != floppy1->get_device()) |
269 | 264 | { |
270 | | if(active) { |
271 | | lss_sync(); |
| 265 | if(active) |
272 | 266 | floppy->mon_w(true); |
273 | | } |
274 | 267 | floppy = floppy1->get_device(); |
275 | 268 | if(active) |
276 | 269 | floppy->mon_w(false); |
r250329 | r250330 | |
283 | 276 | break; |
284 | 277 | case 0xc: |
285 | 278 | if(mode_load) { |
286 | | if(active) { |
287 | | lss_sync(); |
| 279 | if(active) |
288 | 280 | address &= ~0x04; |
289 | | } |
290 | 281 | mode_load = false; |
291 | 282 | } |
292 | 283 | break; |
293 | 284 | case 0xd: |
294 | 285 | if(!mode_load) { |
295 | | if(active) { |
296 | | lss_sync(); |
| 286 | if(active) |
297 | 287 | address |= 0x04; |
298 | | } |
299 | 288 | mode_load = true; |
300 | 289 | } |
301 | 290 | break; |
302 | 291 | case 0xe: |
303 | 292 | if(mode_write) { |
304 | | if(active) { |
305 | | lss_sync(); |
| 293 | if(active) |
306 | 294 | address &= ~0x08; |
307 | | } |
308 | 295 | mode_write = false; |
| 296 | attotime now = machine().time(); |
| 297 | if(floppy) |
| 298 | floppy->write_flux(write_start_time, now, write_position, write_buffer); |
309 | 299 | } |
310 | 300 | break; |
311 | 301 | case 0xf: |
312 | 302 | if(!mode_write) { |
313 | 303 | if(active) { |
314 | | lss_sync(); |
315 | 304 | address |= 0x08; |
316 | 305 | write_start_time = machine().time(); |
| 306 | write_position = 0; |
317 | 307 | if(floppy) |
318 | 308 | floppy->set_write_splice(write_start_time); |
319 | 309 | } |
r250329 | r250330 | |
355 | 345 | if(!active) |
356 | 346 | return; |
357 | 347 | |
358 | | attotime next_flux = floppy ? floppy->get_next_transition(cycles_to_time(cycles) - attotime::from_usec(1)) : attotime::never; |
| 348 | attotime next_flux = floppy ? floppy->get_next_transition(cycles_to_time(cycles-1)) : attotime::never; |
359 | 349 | |
360 | 350 | UINT64 cycles_limit = time_to_cycles(machine().time()); |
361 | 351 | UINT64 cycles_next_flux = next_flux != attotime::never ? time_to_cycles(next_flux) : UINT64(-1); |
r250329 | r250330 | |
382 | 372 | write_line_active = !write_line_active; |
383 | 373 | assert(write_position != 32); |
384 | 374 | write_buffer[write_position++] = cycles_to_time(cycles); |
| 375 | } else if(write_position >= 30) { |
| 376 | attotime now = cycles_to_time(cycles); |
| 377 | if(floppy) |
| 378 | floppy->write_flux(write_start_time, now, write_position, write_buffer); |
| 379 | write_start_time = now; |
| 380 | write_position = 0; |
385 | 381 | } |
386 | 382 | } |
387 | 383 | |