From dc0236bc7753aa94114f9f9c6f8cc49d8f3fc509 Mon Sep 17 00:00:00 2001 From: "Howard M. Harte" Date: Sun, 17 Jan 2021 09:29:00 -0800 Subject: [PATCH] AltairZ80: vfdhd: Fix unit detach. --- AltairZ80/vfdhd.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/AltairZ80/vfdhd.c b/AltairZ80/vfdhd.c index e8fbf2e5..fa220f3e 100644 --- a/AltairZ80/vfdhd.c +++ b/AltairZ80/vfdhd.c @@ -1,9 +1,7 @@ /************************************************************************* * * - * $Id: vfdhd.c 1995 2008-07-15 03:59:13Z hharte $ * - * * - * Copyright (c) 2007-2008 Howard M. Harte. * - * http://www.hartetec.com * + * Copyright (c) 2007-2021 Howard M. Harte. * + * https://github.com/hharte * * * * Permission is hereby granted, free of charge, to any person obtaining * * a copy of this software and associated documentation files (the * @@ -32,10 +30,10 @@ * SIMH Interface based on altairz80_hdsk.c, by Peter Schorn. * * * * Module Description: * - * Micropolis FDC module for SIMH * + * Micropolis FD/HD Controller module for SIMH * * * - * Environment: * - * User mode only * + * Controller Documentation: * + * http://bitsavers.org/pdf/vectorGraphic/hardware/7200-1200-01-1_Dual-Mode_Disk_Controller_Board_Rev_2.0_Feb81.pdf * * *************************************************************************/ @@ -321,28 +319,23 @@ static t_stat vfdhd_attach(UNIT *uptr, CONST char *cptr) /* Detach routine */ static t_stat vfdhd_detach(UNIT *uptr) { - t_stat r; int8 i; - for(i = 0; i < VFDHD_MAX_DRIVES; i++) { + for (i = 0; i < VFDHD_MAX_DRIVES; i++) { if(vfdhd_dev.units[i].fileref == uptr->fileref) { break; } } - if(i == VFDHD_MAX_DRIVES) { + if (i == VFDHD_MAX_DRIVES) { return (SCPE_IERR); } DBG_PRINT(("Detach VFDHD%d\n", i)); - r = diskClose(&vfdhd_info->drive[i].imd); - if (r != SCPE_OK) - return r; + if (uptr->u3 == IMAGE_TYPE_IMD) { + diskClose(&vfdhd_info->drive[i].imd); + } - r = detach_unit(uptr); /* detach unit */ - if (r != SCPE_OK) - return r; - - return SCPE_OK; + return detach_unit(uptr); /* detach unit */ }