From 381dd2376cd86afd84c6968239e06196bcaa902c Mon Sep 17 00:00:00 2001 From: OBattler Date: Mon, 5 Mar 2018 23:35:01 +0100 Subject: [PATCH] Fixed the creation and exporting of thick track 86F images. --- src/floppy/fdd_86f.c | 20 +++++++++++++------- src/win/win_new_floppy.c | 10 +++++++--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/floppy/fdd_86f.c b/src/floppy/fdd_86f.c index c0350d6fc..a36b79e29 100644 --- a/src/floppy/fdd_86f.c +++ b/src/floppy/fdd_86f.c @@ -10,7 +10,7 @@ * data in the form of FM/MFM-encoded transitions) which also * forms the core of the emulator's floppy disk emulation. * - * Version: @(#)fdd_86f.c 1.0.14 2018/01/18 + * Version: @(#)fdd_86f.c 1.0.15 2018/03/05 * * Author: Miran Grca, * Copyright 2016-2018 Miran Grca. @@ -3390,6 +3390,8 @@ int d86f_export(int drive, wchar_t *fn) int tracks = 86; int i; + int inc = 1; + uint32_t magic = 0x46423638; uint16_t version = 0x020B; @@ -3411,13 +3413,17 @@ int d86f_export(int drive, wchar_t *fn) fwrite(tt, 1, ((d86f_get_sides(drive) == 2) ? 2048 : 1024), f); - /* Do this do teremine how many tracks to actually output. */ - fdd_do_seek(drive, 2); - if (d86f[drive].cur_track == 1) - tracks >>= 1; + /* In the case of a thick track drive, always increment track + by two, since two tracks are going to get output at once. */ + if (!fdd_doublestep_40(drive)) + inc = 2; - for (i = 0; i < tracks; i++) { - fdd_do_seek(drive, i); + for (i = 0; i < tracks; i += inc) { + if (inc == 2) + fdd_do_seek(drive, i >> 1); + else + fdd_do_seek(drive, i); + d86f[drive].cur_track = i; d86f_write_tracks(drive, &f, tt); } diff --git a/src/win/win_new_floppy.c b/src/win/win_new_floppy.c index 4384fcceb..e826a0d37 100644 --- a/src/win/win_new_floppy.c +++ b/src/win/win_new_floppy.c @@ -8,7 +8,7 @@ * * Handle the New Floppy Image dialog. * - * Version: @(#)win_new_floppy.c 1.0.2 2018/02/25 + * Version: @(#)win_new_floppy.c 1.0.3 2018/03/05 * * Authors: Miran Grca, * @@ -82,6 +82,7 @@ create_86f(WCHAR *file_name, disk_size_t disk_size, uint8_t rpm_mode) uint32_t array_size, array_size2; uint32_t track_base, track_size; int i; + uint32_t shift = 0; dflags = 0; /* Has surface data? - Assume no for now. */ dflags |= (disk_size.hole << 1); /* Hole */ @@ -153,12 +154,15 @@ create_86f(WCHAR *file_name, disk_size_t disk_size, uint8_t rpm_mode) track_base = 8 + ((disk_size.sides == 2) ? 2048 : 1024); - for (i = 0; i < disk_size.tracks * disk_size.sides; i++) + if (disk_size.tracks <= 43) + shift = 1; + + for (i = 0; i < (disk_size.tracks * disk_size.sides) << shift; i++) tarray[i] = track_base + (i * track_size); fwrite(tarray, 1, (disk_size.sides == 2) ? 2048 : 1024, f); - for (i = 0; i < disk_size.tracks * disk_size.sides; i++) { + for (i = 0; i < (disk_size.tracks * disk_size.sides) << shift; i++) { fwrite(&tflags, 2, 1, f); fwrite(&index_hole_pos, 4, 1, f); fwrite(empty, 1, array_size, f);