trunk/src/emu/imagedev/floppy.h
| r19240 | r19241 | |
| 49 | 49 | typedef delegate<int (floppy_image_device *)> load_cb; |
| 50 | 50 | typedef delegate<void (floppy_image_device *)> unload_cb; |
| 51 | 51 | typedef delegate<void (floppy_image_device *, int)> index_pulse_cb; |
| 52 | typedef delegate<void (floppy_image_device *, int)> ready_cb; |
| 52 | 53 | |
| 53 | 54 | // construction/destruction |
| 54 | 55 | floppy_image_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock); |
| r19240 | r19241 | |
| 83 | 84 | void setup_load_cb(load_cb cb); |
| 84 | 85 | void setup_unload_cb(unload_cb cb); |
| 85 | 86 | void setup_index_pulse_cb(index_pulse_cb cb); |
| 87 | void setup_ready_cb(ready_cb cb); |
| 86 | 88 | |
| 87 | 89 | UINT32* get_buffer() { return image->get_buffer(cyl, ss); } |
| 88 | 90 | UINT32 get_len() { return image->get_track_size(cyl, ss); } |
| r19240 | r19241 | |
| 149 | 151 | int wpt; /* write protect */ |
| 150 | 152 | int rdy; /* ready */ |
| 151 | 153 | int dskchg; /* disk changed */ |
| 154 | bool ready; |
| 152 | 155 | |
| 153 | 156 | /* rotation per minute => gives index pulse frequency */ |
| 154 | 157 | float rpm; |
| r19240 | r19241 | |
| 158 | 161 | int cyl; |
| 159 | 162 | |
| 160 | 163 | bool image_dirty; |
| 164 | int ready_counter; |
| 161 | 165 | |
| 162 | 166 | load_cb cur_load_cb; |
| 163 | 167 | unload_cb cur_unload_cb; |
| 164 | 168 | index_pulse_cb cur_index_pulse_cb; |
| 169 | ready_cb cur_ready_cb; |
| 165 | 170 | |
| 166 | 171 | UINT32 find_position(attotime &base, attotime when); |
| 167 | 172 | int find_index(UINT32 position, const UINT32 *buf, int buf_size); |
trunk/src/emu/imagedev/floppy.c
| r19240 | r19241 | |
| 108 | 108 | cur_index_pulse_cb = cb; |
| 109 | 109 | } |
| 110 | 110 | |
| 111 | void floppy_image_device::setup_ready_cb(ready_cb cb) |
| 112 | { |
| 113 | cur_ready_cb = cb; |
| 114 | } |
| 115 | |
| 111 | 116 | void floppy_image_device::set_formats(const floppy_format_type *formats) |
| 112 | 117 | { |
| 113 | 118 | image_device_format **formatptr; |
| r19240 | r19241 | |
| 205 | 210 | dskchg = exists() ? 1 : 0; |
| 206 | 211 | index_timer = timer_alloc(0); |
| 207 | 212 | image_dirty = false; |
| 213 | ready = true; |
| 214 | ready_counter = 0; |
| 208 | 215 | } |
| 209 | 216 | |
| 210 | 217 | void floppy_image_device::device_reset() |
| r19240 | r19241 | |
| 212 | 219 | revolution_start_time = attotime::never; |
| 213 | 220 | revolution_count = 0; |
| 214 | 221 | mon = 1; |
| 222 | if(!ready) { |
| 223 | ready = true; |
| 224 | if(!cur_ready_cb.isnull()) |
| 225 | cur_ready_cb(this, ready); |
| 226 | } |
| 215 | 227 | if(motor_always_on) |
| 216 | 228 | mon_w(0); |
| 217 | 229 | } |
| r19240 | r19241 | |
| 280 | 292 | |
| 281 | 293 | if (!cur_load_cb.isnull()) |
| 282 | 294 | return cur_load_cb(this); |
| 295 | |
| 296 | if(motor_always_on || !mon) |
| 297 | ready_counter = 2; |
| 298 | |
| 283 | 299 | return IMAGE_INIT_PASS; |
| 284 | 300 | } |
| 285 | 301 | |
| r19240 | r19241 | |
| 295 | 311 | } |
| 296 | 312 | if (!cur_unload_cb.isnull()) |
| 297 | 313 | cur_unload_cb(this); |
| 314 | if(!ready) { |
| 315 | ready = true; |
| 316 | if(!cur_ready_cb.isnull()) |
| 317 | cur_ready_cb(this, ready); |
| 318 | } |
| 298 | 319 | } |
| 299 | 320 | |
| 300 | 321 | bool floppy_image_device::call_create(int format_type, option_resolution *format_options) |
| r19240 | r19241 | |
| 316 | 337 | if (!mon && image) |
| 317 | 338 | { |
| 318 | 339 | revolution_start_time = machine().time(); |
| 340 | ready_counter = 2; |
| 319 | 341 | index_resync(); |
| 320 | 342 | } |
| 321 | 343 | |
| r19240 | r19241 | |
| 325 | 347 | commit_image(); |
| 326 | 348 | revolution_start_time = attotime::never; |
| 327 | 349 | index_timer->adjust(attotime::zero); |
| 350 | if(!ready) { |
| 351 | ready = true; |
| 352 | if(!cur_ready_cb.isnull()) |
| 353 | cur_ready_cb(this, ready); |
| 354 | } |
| 328 | 355 | } |
| 329 | 356 | } |
| 330 | 357 | |
| r19240 | r19241 | |
| 365 | 392 | |
| 366 | 393 | if(new_idx != idx) { |
| 367 | 394 | idx = new_idx; |
| 368 | | |
| 395 | if(idx && ready) { |
| 396 | ready_counter--; |
| 397 | if(!ready_counter) { |
| 398 | ready = false; |
| 399 | if(!cur_ready_cb.isnull()) |
| 400 | cur_ready_cb(this, ready); |
| 401 | } |
| 402 | } |
| 369 | 403 | if (!cur_index_pulse_cb.isnull()) |
| 370 | 404 | cur_index_pulse_cb(this, idx); |
| 371 | 405 | } |
| r19240 | r19241 | |
| 373 | 407 | |
| 374 | 408 | bool floppy_image_device::ready_r() |
| 375 | 409 | { |
| 376 | | if (exists()) |
| 377 | | { |
| 378 | | if (mon == 0) |
| 379 | | { |
| 380 | | return 0; |
| 381 | | } |
| 382 | | } |
| 383 | | return 1; |
| 410 | return ready; |
| 384 | 411 | } |
| 385 | 412 | |
| 386 | 413 | double floppy_image_device::get_pos() |