~ubuntu-branches/ubuntu/maverick/vice/maverick

« back to all changes in this revision

Viewing changes to src/drive/drive.c

  • Committer: Bazaar Package Importer
  • Author(s): Zed Pobre
  • Date: 2005-02-01 11:30:26 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20050201113026-3eyakzsmmheclvjg
Tags: 1.16-1
* New upstream version
* Fixes crash on 64-bit architectures (closes: #287640)
* x128 working again (closes: #286767)
* Works fine with /dev/dsp in use (not in the main changelog, but tested
  on my local machine as working).  Presumably, this also takes care of
  the issue with dsp being held.  I'm not sure if this is because I'm
  testing it on a 2.6 kernel now -- if you are still having problems
  with /dev/dsp, please reopen the bugs. (closes: #152952, #207942)
* Don't kill Makefile.in on clean

Show diffs side-by-side

added added

removed removed

Lines of Context:
140
140
    if (rom_loaded)
141
141
        return 0;
142
142
 
143
 
    drive_rom_init();
 
143
    driverom_init();
144
144
    drive_image_init();
145
145
 
146
146
    drive_log = log_open("Drive");
158
158
        drive->mynumber = dnr;
159
159
    }
160
160
 
161
 
    if (drive_rom_load_images() < 0) {
 
161
    if (driverom_load_images() < 0) {
162
162
        resources_set_value("Drive8Type", (resource_value_t)DRIVE_TYPE_NONE);
163
163
        resources_set_value("Drive9Type", (resource_value_t)DRIVE_TYPE_NONE);
164
164
        return -1;
219
219
 
220
220
    for (dnr = 0; dnr < DRIVE_NUM; dnr++) {
221
221
        drive = drive_context[dnr]->drive;
222
 
        drive_rom_initialize_traps(drive);
 
222
        driverom_initialize_traps(drive);
223
223
 
224
 
        drive_sync_clock_frequency(drive->type, drive);
 
224
        drivesync_clock_frequency(drive->type, drive);
225
225
 
226
226
        rotation_init((drive->clock_frequency == 2) ? 1 : 0, dnr);
227
227
 
228
 
        drive_cpu_init(drive_context[dnr], drive->type);
 
228
        drivecpu_init(drive_context[dnr], drive->type);
229
229
 
230
230
        /* Make sure the sync factor is acknowledged correctly.  */
231
 
        drive_sync_factor(drive_context[dnr]);
 
231
        drivesync_factor(drive_context[dnr]);
232
232
 
233
233
        /* Make sure the traps are moved as needed.  */
234
234
        if (drive->enable)
243
243
    unsigned int dnr;
244
244
 
245
245
    for (dnr = 0; dnr < DRIVE_NUM; dnr++) {
246
 
        drive_cpu_shutdown(drive_context[dnr]);
 
246
        drivecpu_shutdown(drive_context[dnr]);
247
247
        gcr_destroy_image(drive_context[dnr]->drive->gcr);
248
248
    }
249
249
 
293
293
    if (drv->drive->byte_ready_active == 0x06)
294
294
        rotation_rotate_disk(drv->drive);
295
295
 
296
 
    drive_sync_clock_frequency(type, drv->drive);
 
296
    drivesync_clock_frequency(type, drv->drive);
297
297
 
298
298
    rotation_init(0, dnr);
299
299
    drv->drive->type = type;
300
300
    drv->drive->side = 0;
301
301
    machine_drive_rom_setup_image(dnr);
302
 
    drive_sync_factor(drv);
 
302
    drivesync_factor(drv);
303
303
    drive_set_active_led_color(type, dnr);
304
304
 
305
 
    drive_cpu_init(drv, type);
 
305
    drivecpu_init(drv, type);
306
306
 
307
307
    return 0;
308
308
}
337
337
    if (drive->image != NULL)
338
338
        drive_image_attach(drive->image, dnr + 8);
339
339
 
340
 
    drive_cpu_wake_up(drv);
 
340
    drivecpu_wake_up(drv);
341
341
 
342
342
    /* Make sure the UI is updated.  */
343
343
    for (i = 0; i < DRIVE_NUM; i++) {
387
387
    resources_get_value("DriveTrueEmulation", (void *)&drive_true_emulation);
388
388
 
389
389
    if (rom_loaded) {
390
 
        drive_cpu_sleep(drv);
 
390
        drivecpu_sleep(drv);
391
391
        machine_drive_port_default(drv);
392
392
 
393
393
        drive_gcr_data_writeback(drive);
430
430
    unsigned int dnr;
431
431
 
432
432
    for (dnr = 0; dnr < DRIVE_NUM; dnr++)
433
 
        drive_cpu_reset(drive_context[dnr]);
434
 
}
435
 
 
436
 
/*-------------------------------------------------------------------------- */
437
 
 
438
 
/* The following functions are time critical.  */
 
433
        drivecpu_reset(drive_context[dnr]);
 
434
}
 
435
 
 
436
void drive_current_track_size_set(drive_t *dptr)
 
437
{
 
438
    dptr->GCR_current_track_size =
 
439
        dptr->gcr->track_size[dptr->current_half_track / 2 - 1];
 
440
}
439
441
 
440
442
/* Move the head to half track `num'.  */
441
443
void drive_set_half_track(int num, drive_t *dptr)
468
470
    else
469
471
        dptr->GCR_head_offset = 0;
470
472
 
471
 
    dptr->GCR_current_track_size =
472
 
        dptr->gcr->track_size[dptr->current_half_track / 2 - 1];
473
 
}
474
 
 
475
 
/* Return the write protect sense status. */
476
 
inline BYTE drive_write_protect_sense(drive_t *dptr)
477
 
{
478
 
    /* Clear the write protection bit for the time the disk is pulled out on
479
 
       detach.  */
480
 
    if (dptr->detach_clk != (CLOCK)0) {
481
 
        if (*(dptr->clk) - dptr->detach_clk < DRIVE_DETACH_DELAY)
482
 
            return 0x0;
483
 
        dptr->detach_clk = (CLOCK)0;
484
 
    }
485
 
    /* Set the write protection bit for the minimum time until a new disk
486
 
       can be inserted.  */
487
 
    if (dptr->attach_detach_clk != (CLOCK)0) {
488
 
        if (*(dptr->clk) - dptr->attach_detach_clk
489
 
            < DRIVE_ATTACH_DETACH_DELAY)
490
 
            return 0x10;
491
 
        dptr->attach_detach_clk = (CLOCK)0;
492
 
    }
493
 
    /* Clear the write protection bit for the time the disk is put in on
494
 
       attach.  */
495
 
    if (dptr->attach_clk != (CLOCK)0) {
496
 
        if (*(dptr->clk) - dptr->attach_clk < DRIVE_ATTACH_DELAY)
497
 
            return 0x0;
498
 
        dptr->attach_clk = (CLOCK)0;
499
 
    }
500
 
 
501
 
    if (dptr->GCR_image_loaded == 0) {
502
 
        /* No disk in drive, write protection is off. */
503
 
        return 0x10;
504
 
    } else {
505
 
        return dptr->read_only ? 0x0 : 0x10;
506
 
    }
507
 
}
508
 
 
509
 
/* End of time critical functions.  */
 
473
    drive_current_track_size_set(dptr);
 
474
}
 
475
 
510
476
/*-------------------------------------------------------------------------- */
511
477
 
512
478
/* Increment the head position by `step' half-tracks. Valid values
638
604
    }
639
605
}
640
606
 
 
607
void drive_gcr_data_writeback_all(void)
 
608
{
 
609
    drive_t *drive;
 
610
    unsigned int i;
 
611
 
 
612
    for (i = 0; i < DRIVE_NUM; i++) {
 
613
        drive = drive_context[i]->drive;
 
614
        drive_gcr_data_writeback(drive);
 
615
    }
 
616
}
 
617
 
641
618
static void drive_extend_disk_image(drive_t *drive)
642
619
{
643
620
    int rc;
744
721
    drv->drive = lib_calloc(1, sizeof(drive_t));
745
722
    drv->clk_ptr = &drive_clk[dnr];
746
723
 
747
 
    drive_cpu_setup_context(drv);
 
724
    drivecpu_setup_context(drv);
748
725
    machine_drive_setup_context(drv);
749
726
}
750
727