]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
x86 bridgeboard disk density emulation.
authorToni Wilen <twilen@winuae.net>
Sun, 16 Aug 2015 17:12:40 +0000 (20:12 +0300)
committerToni Wilen <twilen@winuae.net>
Sun, 16 Aug 2015 17:12:40 +0000 (20:12 +0300)
disk.cpp
include/disk.h
x86.cpp

index e22d74e34a7ce1fa94cda46717fd68607bc5d2f7..a0fa597f5a20b6445aa02414e4885acee9148115 100644 (file)
--- a/disk.cpp
+++ b/disk.cpp
@@ -4712,6 +4712,19 @@ bool disk_reserved_getinfo(int num, struct floppy_reserved *fr)
                fr->secs = drv->num_secs;
                fr->heads = 2;
                fr->disk_changed = drv->dskchange || fr->img == NULL;
+               if (currprefs.floppyslots[i].dfxtype == DRV_PC_ONLY_80) {
+                       if (fr->cyls < 80) {
+                               // 360k in 80 track drive
+                               fr->rate = FLOPPY_RATE_300K;
+                       } else {
+                               if (drv->num_secs > 14)
+                                       fr->rate = FLOPPY_RATE_500K; // 1.4M
+                               else
+                                       fr->rate = FLOPPY_RATE_250K; // 720K
+                       }
+               } else {
+                       fr->rate = FLOPPY_RATE_300K;
+               }
                return true;
        }
        return false;
index 27111d2ed59147283f19a1d50764d1cd61b9334b..b4c724a2589033325a0ec4445069fab61a22fef9 100644 (file)
@@ -27,6 +27,11 @@ struct diskinfo
        TCHAR diskname[110];
 };
 
+#define FLOPPY_RATE_500K 0
+#define FLOPPY_RATE_300K 1
+#define FLOPPY_RATE_250K 2
+#define FLOPPY_RATE_1M 3
+
 struct floppy_reserved
 {
        int num;
@@ -38,6 +43,7 @@ struct floppy_reserved
        int secs;
        int drive_cyls;
        bool disk_changed;
+       int rate;
 };
 void disk_reserved_setinfo(int num, int cyl, int head, int motor);
 bool disk_reserved_getinfo(int num, struct floppy_reserved *fr);
diff --git a/x86.cpp b/x86.cpp
index 27734839c07159d8f5ea03883b950749e0969f87..d9e7d25b5746ff1cec00afbba1da27930860feaa 100644 (file)
--- a/x86.cpp
+++ b/x86.cpp
@@ -909,6 +909,7 @@ static uae_u8 floppy_seekcyl[4];
 static int floppy_delay_hsync;
 static bool floppy_did_reset;
 static bool floppy_irq;
+static uae_u8 floppy_rate;
 
 #define PC_SEEK_DELAY 50
 
@@ -920,6 +921,13 @@ static void floppy_reset(void)
        floppy_did_reset = true;
 }
 
+static void floppy_hardreset(void)
+{
+       floppy_rate = FLOPPY_RATE_300K;
+       floppy_reset();
+}
+
+
 static void do_floppy_irq2(void)
 {
        write_log(_T("floppy%d irq (enable=%d)\n"), floppy_num, (floppy_dpc & 8) != 0);
@@ -1026,6 +1034,11 @@ static int floppy_selected(void)
        return -1;
 }
 
+static bool floppy_valid_rate(struct floppy_reserved *fr)
+{
+       return fr->rate == floppy_rate;
+}
+
 static void floppy_do_cmd(struct x86_bridge *xb)
 {
        uae_u8 cmd = floppy_cmd[0];
@@ -1175,7 +1188,9 @@ static void floppy_do_cmd(struct x86_bridge *xb)
                        int cyl = pcf->cyl;
                        bool nodata = false;
                        if (valid_floppy) {
-                               if (fr.img && pcf->cyl != floppy_cmd[2]) {
+                               if (!floppy_valid_rate(&fr)) {
+                                       nodata = true;
+                               } else if (fr.img && pcf->cyl != floppy_cmd[2]) {
                                        floppy_status[0] |= 0x40; // abnormal termination
                                        floppy_status[2] |= 0x20; // wrong cylinder
                                } else if (fr.img) {
@@ -1240,7 +1255,7 @@ static void floppy_do_cmd(struct x86_bridge *xb)
 
                case 10:
                write_log(_T("Floppy read ID\n"));
-               if (!valid_floppy || !fr.img) {
+               if (!valid_floppy || !fr.img || !floppy_valid_rate(&fr)) {
                        floppy_status[0] |= 0x40; // abnormal termination
                        floppy_status[1] |= 0x04; // no data
                }
@@ -1412,6 +1427,9 @@ static void outfloppy(struct x86_bridge *xb, int portnum, uae_u8 v)
                case 0x3f7: // configuration control
                if (xb->type >= TYPE_2286) {
                        write_log(_T("FDC Control Register %02x\n"), v);
+                       floppy_rate = v & 3;
+               } else {
+                       floppy_rate = FLOPPY_RATE_300K;
                }
                break;
        }
@@ -2837,6 +2855,7 @@ static void bridge_reset(struct x86_bridge *xb)
        }
 
        inittiming();
+       floppy_hardreset();
 }
 
 int is_x86_cpu(struct uae_prefs *p)