From d17380913eb2b3e5e0654a79a6b84f3e3f9dd4e0 Mon Sep 17 00:00:00 2001 From: OBattler Date: Sat, 28 Apr 2018 15:37:26 +0200 Subject: [PATCH] Added (read-only) support for DDI floppy images. --- src/floppy/fdd.c | 3 ++- src/floppy/fdd_img.c | 33 +++++++++++++++++++++++---------- src/win/86Box.rc | 4 ++-- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/floppy/fdd.c b/src/floppy/fdd.c index 61e445243..831f3b39f 100644 --- a/src/floppy/fdd.c +++ b/src/floppy/fdd.c @@ -8,7 +8,7 @@ * * Implementation of the floppy drive emulation. * - * Version: @(#)fdd.c 1.0.6 2018/04/10 + * Version: @(#)fdd.c 1.0.7 2018/04/28 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -114,6 +114,7 @@ static const struct {L"BIN", img_load, img_close, -1}, {L"CQ", img_load, img_close, -1}, {L"CQM", img_load, img_close, -1}, + {L"DDI", img_load, img_close, -1}, {L"DSK", img_load, img_close, -1}, {L"FDI", fdi_load, fdi_close, -1}, {L"FDF", img_load, img_close, -1}, diff --git a/src/floppy/fdd_img.c b/src/floppy/fdd_img.c index ce9dd4837..222d8ad1f 100644 --- a/src/floppy/fdd_img.c +++ b/src/floppy/fdd_img.c @@ -13,7 +13,7 @@ * re-merged with the other files. Much of it is generic to * all formats. * - * Version: @(#)fdd_img.c 1.0.5 2018/03/17 + * Version: @(#)fdd_img.c 1.0.6 2018/04/28 * * Authors: Fred N. van Kempen, * Miran Grca, @@ -605,7 +605,7 @@ img_load(int drive, wchar_t *fn) uint8_t bpb_mid; /* Media type ID. */ uint8_t bpb_sectors; uint8_t bpb_sides; - uint8_t fdi, cqm, fdf; + uint8_t fdi, cqm, fdf, ddi; uint16_t comment_len = 0; int16_t block_len = 0; uint32_t cur_pos = 0; @@ -646,10 +646,16 @@ img_load(int drive, wchar_t *fn) writeprot[drive] = 1; fwriteprot[drive] = writeprot[drive]; - fdi = cqm = 0; + fdi = cqm = ddi = 0; dev->interleave = dev->skew = 0; + if (! wcscasecmp(ext, L"DDI")) { + ddi = 1; + dev->base = 0x2400; + } else + dev->base = 0; + if (! wcscasecmp(ext, L"FDI")) { /* This is a Japanese FDI image, so let's read the header */ pclog("img_load(): File is a Japanese FDI image...\n"); @@ -903,16 +909,20 @@ img_load(int drive, wchar_t *fn) } else { dev->disk_at_once = 0; /* Read the BPB */ - pclog("img_load(): File is a raw image...\n"); - fseek(dev->f, 0x0B, SEEK_SET); + if (ddi) { + pclog("img_load(): File is a DDI image...\n"); + fwriteprot[drive] = writeprot[drive] = 1; + } else + pclog("img_load(): File is a raw image...\n"); + fseek(dev->f, dev->base + 0x0B, SEEK_SET); fread(&bpb_bps, 1, 2, dev->f); - fseek(dev->f, 0x13, SEEK_SET); + fseek(dev->f, dev->base + 0x13, SEEK_SET); fread(&bpb_total, 1, 2, dev->f); - fseek(dev->f, 0x15, SEEK_SET); + fseek(dev->f, dev->base + 0x15, SEEK_SET); bpb_mid = fgetc(dev->f); - fseek(dev->f, 0x18, SEEK_SET); + fseek(dev->f, dev->base + 0x18, SEEK_SET); bpb_sectors = fgetc(dev->f); - fseek(dev->f, 0x1A, SEEK_SET); + fseek(dev->f, dev->base + 0x1A, SEEK_SET); bpb_sides = fgetc(dev->f); cqm = 0; @@ -920,9 +930,12 @@ img_load(int drive, wchar_t *fn) fseek(dev->f, -1, SEEK_END); size = ftell(dev->f) + 1; + if (ddi) + size -= 0x2400; jump_if_fdf: - dev->base = 0; + if (!ddi) + dev->base = 0; fdi = 0; } diff --git a/src/win/86Box.rc b/src/win/86Box.rc index 1def56cfa..b5503ec9a 100644 --- a/src/win/86Box.rc +++ b/src/win/86Box.rc @@ -8,7 +8,7 @@ * * Application resource script for Windows. * - * Version: @(#)86Box.rc 1.0.34 2018/04/26 + * Version: @(#)86Box.rc 1.0.35 2018/04/28 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -934,7 +934,7 @@ BEGIN IDS_2156 "%u" IDS_2157 "%u MB (CHS: %i, %i, %i)" IDS_2158 "Floppy %i (%s): %ls" - IDS_2159 "All images (*.0??;*.1??;*.360;*.720;*.86F;*.BIN;*.CQ?;*.DSK;*.FLP;*.HDM;*.IM?;*.JSON;*.TD0;*.*FD?;*.XDF)\0*.0??;*.1??;*.360;*.720;*.86F;*.BIN;*.CQ?;*.DSK;*.FLP;*.HDM;*.IM?;*.JSON;*.TD0;*.*FD?;*.XDF\0Advanced sector images (*.IMD;*.JSON;*.TD0)\0*.IMD;*.JSON;*.TD0\0Basic sector images (*.0??;*.1??;*.360;*.720;*.BIN;*.CQ?;*.DSK;*.FLP;*.HDM;*.IM?;*.XDF;*.*FD?)\0*.0??;*.1??;*.360;*.720;*.BIN;*.CQ?;*.DSK;*.FLP;*.HDM;*.IM?;*.XDF;*.*FD?\0Flux images (*.FDI)\0*.FDI\0Surface images (*.86F)\0*.86F\0All files (*.*)\0*.*\0" + IDS_2159 "All images (*.0??;*.1??;*.??0;*.86F;*.BIN;*.CQ?;*.DDI;*.DSK;*.FLP;*.HDM;*.IM?;*.JSON;*.TD0;*.*FD?;*.XDF)\0*.0??;*.1??;*.??0;*.86F;*.BIN;*.CQ?;*.DDI;*.DSK;*.FLP;*.HDM;*.IM?;*.JSON;*.TD0;*.*FD?;*.XDF\0Advanced sector images (*.IMD;*.JSON;*.TD0)\0*.IMD;*.JSON;*.TD0\0Basic sector images (*.0??;*.1??;*.??0;*.BIN;*.CQ?;*.DDI;*.DSK;*.FLP;*.HDM;*.IM?;*.XDF;*.*FD?)\0*.0??;*.1??;*.??0;*.BIN;*.CQ?;*.DDI;*.DSK;*.FLP;*.HDM;*.IM?;*.XDF;*.*FD?\0Flux images (*.FDI)\0*.FDI\0Surface images (*.86F)\0*.86F\0All files (*.*)\0*.*\0" IDS_2160 "Configuration files (*.CFG)\0*.CFG\0All files (*.*)\0*.*\0" IDS_2161 "&New image..." IDS_2162 "&Existing image..."