1
0
mirror of https://github.com/pevans/erc-c.git synced 2024-10-09 15:54:24 +00:00

Don't do certain operations if the drive is offline

This commit is contained in:
Peter Evans 2018-03-30 16:26:24 -05:00
parent d129ffed99
commit a23c7321f5

View File

@ -138,6 +138,7 @@ apple2_dd_insert(apple2dd *drive, FILE *stream, int type)
// If we have any data, get rid of it. We'll start fresh here.
apple2_dd_eject(drive);
drive->online = true;
drive->image = vm_segment_create(finfo.st_size);
drive->track_pos = 0;
drive->sector_pos = 0;
@ -439,8 +440,7 @@ apple2_dd_turn_on(apple2dd *drive, bool online)
void
apple2_dd_write(apple2dd *drive)
{
// If there's no disk in the drive, then we can't write anything
if (drive->data == NULL) {
if (drive->data == NULL || !drive->online) {
return;
}
@ -592,6 +592,10 @@ SEGMENT_READER(apple2_dd_switch_read)
if (drive == NULL) {
drive = mach->drive1;
}
if (!drive->online) {
return 0x00;
}
// In the first if block, we will handle 0x0..0x8; in the second if,
// we'll do 0x9..0xB, 0xE, and 0xF.
@ -633,6 +637,10 @@ SEGMENT_WRITER(apple2_dd_switch_write)
drive = mach->drive1;
}
if (!drive->online) {
return;
}
if (nib < 0x8) {
apple2_dd_switch_phase(drive, nib);
} else if (nib < 0xC || nib > 0xD) {