From 6274befb0e574a7d182b04c6c691d270efbff3aa Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Mon, 27 Jul 2015 19:24:50 +0300 Subject: [PATCH] x86 bridgeboard floppy drive support. --- disk.cpp | 67 ++++++++++++++++++++++++++++++++------------------ include/disk.h | 5 +++- 2 files changed, 47 insertions(+), 25 deletions(-) diff --git a/disk.cpp b/disk.cpp index d6c0995a..d680cee9 100644 --- a/disk.cpp +++ b/disk.cpp @@ -609,7 +609,8 @@ static void drive_settype_id (drive *drv) drv->drive_id = DRIVE_ID_525SD; break; case DRV_NONE: - case DRV_PC_ONLY: + case DRV_PC_ONLY_40: + case DRV_PC_ONLY_80: drv->drive_id = DRIVE_ID_NONE; break; } @@ -692,9 +693,9 @@ static void reset_drive (int num) drv->lastdataacesstrack = -1; disabled &= ~(1 << num); reserved &= ~(1 << num); - if (currprefs.floppyslots[num].dfxtype < 0 || currprefs.floppyslots[num].dfxtype >= DRV_PC_ONLY) + if (currprefs.floppyslots[num].dfxtype < 0 || currprefs.floppyslots[num].dfxtype >= DRV_PC_ONLY_40) disabled |= 1 << num; - if (currprefs.floppyslots[num].dfxtype >= DRV_PC_ONLY) + if (currprefs.floppyslots[num].dfxtype >= DRV_PC_ONLY_40) reserved |= 1 << num; reset_drive_gui (num); /* most internal Amiga floppy drives won't enable @@ -1138,6 +1139,9 @@ static int drive_insert (drive * drv, struct uae_prefs *p, int dnum, const TCHAR canauto = 1; if (!canauto && drv->diskfile && isrecognizedext (zfile_getname (drv->diskfile))) canauto = 1; + // if PC-only drive, make sure PC-like floppies are alwayss detected + if (!canauto && currprefs.floppyslots[dnum].dfxtype >= DRV_PC_ONLY_40) + canauto = 1; if (drv->catweasel) { @@ -4668,7 +4672,7 @@ int getdebug(void) return floppy[0].mfmpos; } -void disk_reserved_setinfo(int num, int cyl, int head, int motor) +static int get_reserved_id(int num) { for (int i = 0; i < MAX_FLOPPY_DRIVES; i++) { if (reserved & (1 << i)) { @@ -4676,32 +4680,47 @@ void disk_reserved_setinfo(int num, int cyl, int head, int motor) num--; continue; } - drive *drv = &floppy[i]; - reserved_side = head; - drv->cyl = cyl; - drv->state = motor; - update_drive_gui(i, false); + return i; } } + return -1; +} + +void disk_reserved_setinfo(int num, int cyl, int head, int motor) +{ + int i = get_reserved_id(num); + if (i >= 0) { + drive *drv = &floppy[i]; + reserved_side = head; + drv->cyl = cyl; + drv->state = motor; + update_drive_gui(i, false); + } } bool disk_reserved_getinfo(int num, struct floppy_reserved *fr) { - for (int i = 0; i < MAX_FLOPPY_DRIVES; i++) { - if (reserved & (1 << i)) { - if (num > 0) { - num--; - continue; - } - drive *drv = &floppy[i]; - fr->img = drv->diskfile; - fr->wrprot = drv->wrprot; - fr->cyl = drv->cyl; - fr->cyls = drv->num_tracks / 2; - fr->secs = drv->num_secs; - fr->heads = 2; - return true; - } + int i = get_reserved_id(num); + if (i >= 0) { + drive *drv = &floppy[i]; + fr->img = drv->diskfile; + fr->wrprot = drv->wrprot; + fr->cyl = drv->cyl; + fr->cyls = drv->num_tracks / 2; + fr->drive_cyls = currprefs.floppyslots[i].dfxtype == DRV_PC_ONLY_40 ? 40 : 80; + fr->secs = drv->num_secs; + fr->heads = 2; + fr->disk_changed = drv->dskchange || fr->img == NULL; + return true; } return false; } + +void disk_reserved_reset_disk_change(int num) +{ + int i = get_reserved_id(num); + if (i >= 0) { + drive *drv = &floppy[i]; + drv->dskchange = false; + } +} \ No newline at end of file diff --git a/include/disk.h b/include/disk.h index 8d8bb342..933f05cc 100644 --- a/include/disk.h +++ b/include/disk.h @@ -6,7 +6,7 @@ * (c) 1995 Bernd Schmidt */ -typedef enum { DRV_NONE = -1, DRV_35_DD = 0, DRV_35_HD, DRV_525_SD, DRV_35_DD_ESCOM, DRV_PC_ONLY } drive_type; +typedef enum { DRV_NONE = -1, DRV_35_DD = 0, DRV_35_HD, DRV_525_SD, DRV_35_DD_ESCOM, DRV_PC_ONLY_40, DRV_PC_ONLY_80 } drive_type; #define HISTORY_FLOPPY 0 #define HISTORY_CD 1 @@ -35,9 +35,12 @@ struct floppy_reserved int cyls; int heads; int secs; + int drive_cyls; + bool disk_changed; }; void disk_reserved_setinfo(int num, int cyl, int head, int motor); bool disk_reserved_getinfo(int num, struct floppy_reserved *fr); +void disk_reserved_reset_disk_change(int num); extern void DISK_init (void); extern void DISK_free (void); -- 2.47.3