[Coco] MAME FDC Issue that can cause corruption

Barry Nelson barry.nelson at amobiledevice.com
Wed Aug 2 22:16:04 EDT 2017


> David Ladd davidwladd at gmail.com  <mailto:coco%40maltedmedia.com?Subject=Re%3A%20%5BCoco%5D%20MAME%20FDC%20Issue%20that%20can%20cause%20corruption&In-Reply-To=%3CCAHW2jkC32VP4p6706RUKjkJjwKsLFWaptgwKGSyF5ud2rn685Q%40mail.gmail.com%3E>
> Wed Aug 2 19:57:59 EDT 2017
> 
> Ciaran,
> 
> I applied your patch to my local sources of MAME and built it.
> 
> I loaded disk basic with the same setup in Disk Basic and had no issues.
> 
> I then decided to try my OS-9 environment that I had originally found this
> issue with before.  I ran my stuff and both drive 0 and drive 1 were being
> banged away on for roughly 15 minutes without it crashing.  Where before
> this fix OS-9 or NitrOS-9 would crash within seconds.
> 
> So thank you Ciaran for finding a workable fix for this.

I have updated my compiled version of MacMAME on Google Drive to fix this serious data corruption issue. Hopefully Tim Linder can post this updated binary to www.macmess.org <http://www.macmess.org/> soon as well. Right now it is available here:

https://drive.google.com/file/d/0B8RnV5G0TZFZbDBFZXhQQWhKTHc/view?usp=sharing <https://drive.google.com/file/d/0B8RnV5G0TZFZbDBFZXhQQWhKTHc/view?usp=sharing>

I also added the ability to select single or double sided double density drives as well as MAME’s current default of quad density drives and added a bunch of comments to explain the code. The patch I applied is below…

--- src/devices/bus/coco/coco_fdc.cpp	2017-08-02 01:36:40.000000000 -0400
+++ src/devices/bus/coco/coco_fdc.cpp	2017-08-02 22:13:09.000000000 -0400
@@ -118,6 +118,8 @@
 FLOPPY_FORMATS_END
 
 static SLOT_INTERFACE_START( coco_fdc_floppies )
+        SLOT_INTERFACE("ssdd", FLOPPY_525_SSDD)
+        SLOT_INTERFACE("dsdd", FLOPPY_525_DD)
 	SLOT_INTERFACE("qd", FLOPPY_525_QD)
 SLOT_INTERFACE_END
 
@@ -130,7 +132,7 @@
 	MCFG_FLOPPY_DRIVE_SOUND(true)
 	MCFG_FLOPPY_DRIVE_ADD(WD_TAG ":1", coco_fdc_floppies, "qd", coco_fdc_device_base::floppy_formats)
 	MCFG_FLOPPY_DRIVE_SOUND(true)
-	MCFG_FLOPPY_DRIVE_ADD(WD_TAG ":2", coco_fdc_floppies, nullptr, coco_fdc_device_base::floppy_formats)
+	MCFG_FLOPPY_DRIVE_ADD(WD_TAG ":2", coco_fdc_floppies, "qd", coco_fdc_device_base::floppy_formats)
 	MCFG_FLOPPY_DRIVE_SOUND(true)
 	MCFG_FLOPPY_DRIVE_ADD(WD_TAG ":3", coco_fdc_floppies, nullptr, coco_fdc_device_base::floppy_formats)
 	MCFG_FLOPPY_DRIVE_SOUND(true)
@@ -273,25 +275,32 @@
 	else if (data & 0x40)
 		drive = 3;
 
+	// Enable/disable the motor line for all drives since it is common
+	// to all drives.
 	for (int i = 0; i < 4; i++)
 	{
 		floppy_image_device *floppy = m_floppies[i]->get_device();
 		if (floppy)
-			floppy->mon_w(((i == drive) && (data & 0x08)) ? CLEAR_LINE : ASSERT_LINE);
+			floppy->mon_w((data & 0x08) ? CLEAR_LINE : ASSERT_LINE);
 	}
 
+	// Determine the value of the head (side) select line.
 	head = ((data & 0x40) && (drive != 3)) ? 1 : 0;
 
+	// Update the floppy controller register
 	set_dskreg(data);
 
 	update_lines();
 
+	// Select the floppy drive that is active.
 	floppy_image_device *selected_floppy = m_floppies[drive]->get_device();
 	m_wd17xx->set_floppy(selected_floppy);
 
+	// Apply the side select value.
 	if (selected_floppy)
 		selected_floppy->ss_w(head);
 
+	// Set the density
 	m_wd17xx->dden_w(!BIT(dskreg(), 5));
 }
 



More information about the Coco mailing list