From 8acb3b29e3fb2e41b8bd101dcf73d241eaa7c651 Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Sun, 7 Apr 2013 12:43:54 -0700 Subject: [PATCH] Fixed disk creation logic to avoid writing a zero sector to the first and last sector of a newly created disk if the disk's contents were copied from another disk. This solves the last details in issue #35 --- sim_disk.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sim_disk.c b/sim_disk.c index 77549e9e..12072bc7 100644 --- a/sim_disk.c +++ b/sim_disk.c @@ -821,7 +821,7 @@ FILE *(*open_function)(const char *filename, const char *mode) = sim_fopen; FILE *(*create_function)(const char *filename, t_offset desiredsize) = NULL; t_offset (*size_function)(FILE *file); t_stat (*storage_function)(FILE *file, uint32 *sector_size, uint32 *removable) = NULL; -t_bool created = FALSE; +t_bool created = FALSE, copied = FALSE; t_bool auto_format = FALSE; t_offset capac; @@ -978,6 +978,7 @@ if (sim_switches & SWMASK ('C')) { /* create vhd disk & cop sim_disk_detach (uptr); if (r == SCPE_OK) { created = TRUE; + copied = TRUE; strcpy (cptr, gbuf); sim_disk_set_fmt (uptr, 0, "VHD", NULL); sim_switches = saved_sim_switches; @@ -1098,7 +1099,7 @@ uptr->pos = 0; if (storage_function) storage_function (uptr->fileref, &ctx->storage_sector_size, &ctx->removable); -if (created) { +if ((created) && (!copied)) { t_stat r = SCPE_OK; uint8 *secbuf = calloc (1, ctx->sector_size); /* alloc temp sector buf */