2017-05-30 03:38:38 +02:00
|
|
|
/*
|
2019-12-05 21:36:28 +01:00
|
|
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
|
|
|
|
* running old operating systems and software designed for IBM
|
|
|
|
|
* PC systems and compatibles from 1981 through fairly recent
|
|
|
|
|
* system designs based on the PCI bus.
|
2017-05-30 03:38:38 +02:00
|
|
|
*
|
2019-12-05 21:36:28 +01:00
|
|
|
* This file is part of the 86Box distribution.
|
2017-05-30 03:38:38 +02:00
|
|
|
*
|
|
|
|
|
* Implementation of the FDI floppy stream image format
|
|
|
|
|
* interface to the FDI2RAW module.
|
|
|
|
|
*
|
2018-10-19 00:39:32 +02:00
|
|
|
* Version: @(#)fdd_fdi.c 1.0.4 2018/10/18
|
2017-05-30 03:38:38 +02:00
|
|
|
*
|
2019-12-05 21:36:28 +01:00
|
|
|
* Authors: Sarah Walker, <tommowalker@tommowalker.co.uk>
|
2017-05-30 03:38:38 +02:00
|
|
|
* Miran Grca, <mgrca8@gmail.com>
|
2019-12-05 21:36:28 +01:00
|
|
|
* Fred N. van Kempen, <decwiz@yahoo.com>
|
2017-10-12 14:25:17 -04:00
|
|
|
*
|
2018-03-19 01:02:04 +01:00
|
|
|
* Copyright 2008-2018 Sarah Walker.
|
2019-12-05 21:36:28 +01:00
|
|
|
* Copyright 2016-2018 Miran Grca.
|
|
|
|
|
* Copyright 2018 Fred N. van Kempen.
|
2017-05-30 03:38:38 +02:00
|
|
|
*/
|
2018-05-21 19:04:05 +02:00
|
|
|
#include <stdarg.h>
|
2016-06-26 00:34:39 +02:00
|
|
|
#include <stdint.h>
|
2018-05-21 19:04:05 +02:00
|
|
|
#include <stdio.h>
|
2017-09-25 04:31:20 -04:00
|
|
|
#include <string.h>
|
2018-03-19 01:02:04 +01:00
|
|
|
#include <stdlib.h>
|
2017-05-05 22:36:10 +02:00
|
|
|
#include <wchar.h>
|
2018-05-21 19:04:05 +02:00
|
|
|
#define HAVE_STDARG_H
|
2017-10-17 01:59:09 -04:00
|
|
|
#include "../86box.h"
|
Added the IBM 5161 ISA expansion for PC and XT;
Cleaned up the parallel port emulation, added IRQ support, and made enabling/disabling per port;
Added the Award 430NX and the Intel Classic/PCI (Alfredo, 420TX);
Finished the 586MC1;
Added 8087 emulation;
Moved Cyrix 6x86'es to the Dev branch;
Sanitized/cleaned up memregs.c/h and intel.c/h;
Split the chipsets from machines and sanitized Port 92 emulation;
Added support for the 15bpp mode to the Compaq ATI 28800;
Moved the MR 386DX and 486 machines to the Dev branch;
Ported the new dynamic recompiler from PCem, but it remains in Dev branch until after v2.00;
Ported the new timer code from PCem;
Cleaned up the CPU table of unused stuff and better optimized its structure;
Ported the Open-XT and Open-AT from VARCem, the Open-AT is in the Dev branch;
Ported the XT MFM controller rewrite and adding of more controllers (incl. two RLL ones), from VARCem;
Added the AHA-1540A and the BusTek BT-542B;
Moved the Sumo SCSI-AT to the Dev branch;
Minor IDE, FDC, and floppy drive code clean-ups;
Made NCR 5380/53C400-based cards' BIOS address configurable;
Got rid of the legacy romset variable;
Unified (video) buffer and buffer32 into one and make the unified buffer 32-bit;
Added the Amstead PPC512 per PCem patch by John Elliott;
Switched memory mapping granularity from 16k to 4k (less than 1k not possible due to internal pages);
Rewrote the CL-GD 54xx blitter, fixes Win-OS/2 on the 54x6 among other thing;
Added the Image Manager 1024 and Professional Graphics Controller per PCem patch by John Elliott and work done on VARCem;
Added Headland HT-216, GC-205 and Video 7 VGA 1024i emulation based on PCem commit;
Implemented the fuction keys for the Toshiba T1000/T1200/T3100 enhancement;
Amstrad MegaPC does now works correctly with non-internal graphics card;
The SLiRP code no longer casts a packed struct type to a non-packed struct type;
The Xi8088 and PB410a no longer hang on 86Box when PS/2 mouse is not present;
The S3 Virge on BeOS is no longer broken (was broken by build #1591);
OS/2 2.0 build 6.167 now sees key presses again;
Xi8088 now work on CGA again;
86F images converted from either the old or new variants of the HxC MFM format now work correctly;
Hardware interrupts with a vector of 0xFF are now handled correctly;
OPTi 495SX boards no longer incorrectly have 64 MB maximum RAM when 32 MB is correct;
Fixed VNC keyboard input bugs;
Fixed AT RTC periodic interrupt - Chicago 58s / 73f / 73g / 81 MIDI play no longer hangs with the build's own VTD driver;
Fixed mouse polling with internal mice - Amstrad and Olivetti mice now work correctly;
Triones ATAPI DMA driver now correctly reads a file at the end of a CD image with a sectors number not divisible by 4;
Compaq Portable now works with all graphics cards;
Fixed various MDSI Genius bugs;
Added segment limit checks and improved page fault checks for several CPU instructions - Memphis 15xx WINSETUP and Chicago 58s WINDISK.CPL no longer issue a GPF, and some S3 drivers that used to have glitches, now work correctly;
Further improved the 808x emulation, also fixes the noticably choppy sound when using 808x CPU's, also fixes #355;
OS/2 installer no logner locks up on splash screen on PS/2 Model 70 and 80, fixes #400.
Fixed several Amstead bugs, GEM no longer crashes on the Amstrad 1640, fixes #391.
Ported John Elliott's Amstrad fixes and improvement from PCem, and fixed the default language so it's correctly Engliish, fixes #278, fixes #389.
Fixed a minor IDE timing bug, fixes #388.
Fixed Toshiba T1000 RAM issues, fixes #379.
Fixed EGA/(S)VGA overscan border handling, fixes #378;
Got rid of the now long useless IDE channel 2 auto-removal, fixes #370;
Fixed the BIOS files used by the AMSTRAD PC1512, fixes #366;
Ported the Unicode CD image file name fix from VARCem, fixes #365;
Fixed high density floppy disks on the Xi8088, fixes #359;
Fixed some bugs in the Hercules emulation, fixes #346, fixes #358;
Fixed the SCSI hard disk mode sense pages, fixes #356;
Removed the AMI Unknown 386SX because of impossibility to identify the chipset, closes #349;
Fixed bugs in the serial mouse emulation, fixes #344;
Compiled 86Box binaries now include all the required .DLL's, fixes #341;
Made some combo boxes in the Settings dialog slightly wider, fixes #276.
2019-09-20 14:02:30 +02:00
|
|
|
#include "../timer.h"
|
2017-10-12 14:25:17 -04:00
|
|
|
#include "../plat.h"
|
2016-11-02 22:39:07 +01:00
|
|
|
#include "fdd.h"
|
2018-01-17 18:43:36 +01:00
|
|
|
#include "fdd_86f.h"
|
|
|
|
|
#include "fdd_img.h"
|
|
|
|
|
#include "fdd_fdi.h"
|
|
|
|
|
#include "fdc.h"
|
2016-06-26 00:34:39 +02:00
|
|
|
#include "fdi2raw.h"
|
|
|
|
|
|
2017-09-04 01:52:29 -04:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
typedef struct {
|
|
|
|
|
FILE *f;
|
|
|
|
|
FDI *h;
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
int lasttrack;
|
|
|
|
|
int sides;
|
|
|
|
|
int track;
|
|
|
|
|
int tracklen[2][4];
|
|
|
|
|
int trackindex[2][4];
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
uint8_t track_data[2][4][256*1024];
|
|
|
|
|
uint8_t track_timing[2][4][256*1024];
|
|
|
|
|
} fdi_t;
|
2016-06-26 00:34:39 +02:00
|
|
|
|
|
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
static fdi_t *fdi[FDD_NUM];
|
|
|
|
|
static fdc_t *fdi_fdc;
|
|
|
|
|
|
|
|
|
|
|
2018-05-21 19:04:05 +02:00
|
|
|
#ifdef ENABLE_FDI_LOG
|
|
|
|
|
int fdi_do_log = ENABLE_FDI_LOG;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
fdi_log(const char *fmt, ...)
|
|
|
|
|
{
|
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
|
|
if (fdi_do_log)
|
|
|
|
|
{
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
|
pclog_ex(fmt, ap);
|
|
|
|
|
va_end(ap);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-10-19 00:39:32 +02:00
|
|
|
#else
|
|
|
|
|
#define fdi_log(fmt, ...)
|
|
|
|
|
#endif
|
2018-05-21 19:04:05 +02:00
|
|
|
|
|
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
static uint16_t
|
|
|
|
|
disk_flags(int drive)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
2018-03-19 01:02:04 +01:00
|
|
|
fdi_t *dev = fdi[drive];
|
|
|
|
|
uint16_t temp_disk_flags = 0x80; /* We ALWAYS claim to have extra bit cells, even if the actual amount is 0. */
|
|
|
|
|
|
|
|
|
|
switch (fdi2raw_get_bit_rate(dev->h)) {
|
|
|
|
|
case 500:
|
|
|
|
|
temp_disk_flags |= 2;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 300:
|
|
|
|
|
case 250:
|
|
|
|
|
temp_disk_flags |= 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 1000:
|
|
|
|
|
temp_disk_flags |= 4;
|
|
|
|
|
break;
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
default:
|
|
|
|
|
temp_disk_flags |= 0;
|
|
|
|
|
}
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
if (dev->sides == 2)
|
|
|
|
|
temp_disk_flags |= 8;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Tell the 86F handler that we will handle our
|
|
|
|
|
* data to handle it in reverse byte endianness.
|
|
|
|
|
*/
|
|
|
|
|
temp_disk_flags |= 0x800;
|
|
|
|
|
|
|
|
|
|
return(temp_disk_flags);
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
|
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
|
|
|
|
|
static uint16_t
|
|
|
|
|
side_flags(int drive)
|
2016-11-07 06:39:20 +01:00
|
|
|
{
|
2018-03-19 01:02:04 +01:00
|
|
|
fdi_t *dev = fdi[drive];
|
|
|
|
|
uint16_t temp_side_flags = 0;
|
2016-11-07 06:39:20 +01:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
switch (fdi2raw_get_bit_rate(dev->h)) {
|
|
|
|
|
case 500:
|
|
|
|
|
temp_side_flags = 0;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 300:
|
|
|
|
|
temp_side_flags = 1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 250:
|
|
|
|
|
temp_side_flags = 2;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 1000:
|
|
|
|
|
temp_side_flags = 3;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
temp_side_flags = 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (fdi2raw_get_rotation(dev->h) == 360)
|
|
|
|
|
temp_side_flags |= 0x20;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Set the encoding value to match that provided by the FDC.
|
|
|
|
|
* Then if it's wrong, it will sector not found anyway.
|
|
|
|
|
*/
|
|
|
|
|
temp_side_flags |= 0x08;
|
|
|
|
|
|
|
|
|
|
return(temp_side_flags);
|
2016-11-07 06:39:20 +01:00
|
|
|
}
|
|
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
fdi_density(void)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
2018-03-19 01:02:04 +01:00
|
|
|
if (! fdc_is_mfm(fdi_fdc)) return(0);
|
|
|
|
|
|
|
|
|
|
switch (fdc_get_bit_rate(fdi_fdc)) {
|
|
|
|
|
case 0:
|
|
|
|
|
return(2);
|
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
return(1);
|
|
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
return(1);
|
2016-11-02 22:39:07 +01:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
case 3:
|
|
|
|
|
case 5:
|
|
|
|
|
return(3);
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return(1);
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
|
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
|
|
|
|
|
static int32_t
|
|
|
|
|
extra_bit_cells(int drive, int side)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
2018-03-19 01:02:04 +01:00
|
|
|
fdi_t *dev = fdi[drive];
|
|
|
|
|
int density = 0;
|
|
|
|
|
int raw_size = 0;
|
|
|
|
|
int is_300_rpm = 0;
|
|
|
|
|
|
|
|
|
|
density = fdi_density();
|
|
|
|
|
|
|
|
|
|
is_300_rpm = (fdd_getrpm(drive) == 300);
|
|
|
|
|
|
|
|
|
|
switch (fdc_get_bit_rate(fdi_fdc)) {
|
|
|
|
|
case 0:
|
|
|
|
|
raw_size = is_300_rpm ? 200000 : 166666;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
|
raw_size = is_300_rpm ? 120000 : 100000;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
|
raw_size = is_300_rpm ? 100000 : 83333;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
|
case 5:
|
|
|
|
|
raw_size = is_300_rpm ? 400000 : 333333;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
raw_size = is_300_rpm ? 100000 : 83333;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return((dev->tracklen[side][density] - raw_size));
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
|
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
read_revolution(int drive)
|
2016-11-02 22:39:07 +01:00
|
|
|
{
|
2018-03-19 01:02:04 +01:00
|
|
|
fdi_t *dev = fdi[drive];
|
|
|
|
|
int c, den, side;
|
|
|
|
|
int track = dev->track;
|
|
|
|
|
|
|
|
|
|
if (track > dev->lasttrack) {
|
|
|
|
|
for (den = 0; den < 4; den++) {
|
|
|
|
|
memset(dev->track_data[0][den], 0, 106096);
|
|
|
|
|
memset(dev->track_data[1][den], 0, 106096);
|
|
|
|
|
dev->tracklen[0][den] = dev->tracklen[1][den] = 100000;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (den = 0; den < 4; den++) {
|
|
|
|
|
for (side = 0; side < dev->sides; side++) {
|
|
|
|
|
c = fdi2raw_loadtrack(dev->h,
|
|
|
|
|
(uint16_t *)dev->track_data[side][den],
|
|
|
|
|
(uint16_t *)dev->track_timing[side][den],
|
|
|
|
|
(track * dev->sides) + side,
|
|
|
|
|
&dev->tracklen[side][den],
|
|
|
|
|
&dev->trackindex[side][den], NULL, den);
|
|
|
|
|
if (! c)
|
|
|
|
|
memset(dev->track_data[side][den], 0, dev->tracklen[side][den]);
|
2016-11-02 22:39:07 +01:00
|
|
|
}
|
|
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
if (dev->sides == 1) {
|
|
|
|
|
memset(dev->track_data[1][den], 0, 106096);
|
|
|
|
|
dev->tracklen[1][den] = 100000;
|
2016-11-02 22:39:07 +01:00
|
|
|
}
|
2018-03-19 01:02:04 +01:00
|
|
|
}
|
2016-11-02 22:39:07 +01:00
|
|
|
}
|
|
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
|
|
|
|
|
static uint32_t
|
|
|
|
|
index_hole_pos(int drive, int side)
|
2016-11-02 22:39:07 +01:00
|
|
|
{
|
2018-03-19 01:02:04 +01:00
|
|
|
fdi_t *dev = fdi[drive];
|
|
|
|
|
int density;
|
2016-11-02 22:39:07 +01:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
density = fdi_density();
|
2016-11-02 22:39:07 +01:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
return(dev->trackindex[side][density]);
|
2016-11-02 22:39:07 +01:00
|
|
|
}
|
|
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
|
|
|
|
|
static uint32_t
|
|
|
|
|
get_raw_size(int drive, int side)
|
2016-11-02 22:39:07 +01:00
|
|
|
{
|
2018-03-19 01:02:04 +01:00
|
|
|
fdi_t *dev = fdi[drive];
|
|
|
|
|
int density;
|
2016-11-02 22:39:07 +01:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
density = fdi_density();
|
2016-11-02 22:39:07 +01:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
return(dev->tracklen[side][density]);
|
2016-11-02 22:39:07 +01:00
|
|
|
}
|
|
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
|
|
|
|
|
static uint16_t *
|
|
|
|
|
encoded_data(int drive, int side)
|
2016-11-02 22:39:07 +01:00
|
|
|
{
|
2018-03-19 01:02:04 +01:00
|
|
|
fdi_t *dev = fdi[drive];
|
|
|
|
|
int density = 0;
|
2016-11-02 22:39:07 +01:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
density = fdi_density();
|
2016-11-02 22:39:07 +01:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
return((uint16_t *)dev->track_data[side][density]);
|
2016-11-02 22:39:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
void
|
|
|
|
|
fdi_seek(int drive, int track)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
2018-03-19 01:02:04 +01:00
|
|
|
fdi_t *dev = fdi[drive];
|
2016-08-15 03:26:37 +02:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
if (fdd_doublestep_40(drive)) {
|
|
|
|
|
if (fdi2raw_get_tpi(dev->h) < 2)
|
|
|
|
|
track /= 2;
|
|
|
|
|
}
|
2016-08-15 03:26:37 +02:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
d86f_set_cur_track(drive, track);
|
2016-11-02 22:39:07 +01:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
if (dev->f == NULL) return;
|
2016-11-02 22:39:07 +01:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
if (track < 0)
|
|
|
|
|
track = 0;
|
2016-11-02 22:39:07 +01:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
#if 0
|
|
|
|
|
if (track > dev->lasttrack)
|
|
|
|
|
track = dev->lasttrack - 1;
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
dev->track = track;
|
|
|
|
|
|
|
|
|
|
read_revolution(drive);
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
|
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
fdi_load(int drive, wchar_t *fn)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
2018-03-19 01:02:04 +01:00
|
|
|
char header[26];
|
|
|
|
|
fdi_t *dev;
|
|
|
|
|
|
|
|
|
|
writeprot[drive] = fwriteprot[drive] = 1;
|
|
|
|
|
|
|
|
|
|
/* Allocate a drive block. */
|
|
|
|
|
dev = (fdi_t *)malloc(sizeof(fdi_t));
|
|
|
|
|
memset(dev, 0x00, sizeof(fdi_t));
|
|
|
|
|
|
|
|
|
|
if (dev == NULL) {
|
|
|
|
|
free(dev);
|
|
|
|
|
memset(floppyfns[drive], 0, sizeof(floppyfns[drive]));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
d86f_unregister(drive);
|
|
|
|
|
|
2020-01-15 04:58:28 +01:00
|
|
|
dev->f = plat_fopen(fn, L"rb");
|
|
|
|
|
if (fread(header, 1, 25, dev->f) != 25)
|
|
|
|
|
fatal("fdi_load(): Error reading header\n");
|
|
|
|
|
if (fseek(dev->f, 0, SEEK_SET) == -1)
|
|
|
|
|
fatal("fdi_load(): Error seeking to the beginning of the file\n");
|
2018-03-19 01:02:04 +01:00
|
|
|
header[25] = 0;
|
|
|
|
|
if (strcmp(header, "Formatted Disk Image file") != 0) {
|
|
|
|
|
/* This is a Japanese FDI file. */
|
2018-05-21 19:04:05 +02:00
|
|
|
fdi_log("fdi_load(): Japanese FDI file detected, redirecting to IMG loader\n");
|
2018-03-19 01:02:04 +01:00
|
|
|
fclose(dev->f);
|
|
|
|
|
free(dev);
|
|
|
|
|
img_load(drive, fn);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Set up the drive unit. */
|
|
|
|
|
fdi[drive] = dev;
|
|
|
|
|
|
|
|
|
|
dev->h = fdi2raw_header(dev->f);
|
|
|
|
|
dev->lasttrack = fdi2raw_get_last_track(dev->h);
|
|
|
|
|
dev->sides = fdi2raw_get_last_head(dev->h) + 1;
|
|
|
|
|
|
|
|
|
|
/* Attach this format to the D86F engine. */
|
|
|
|
|
d86f_handler[drive].disk_flags = disk_flags;
|
|
|
|
|
d86f_handler[drive].side_flags = side_flags;
|
|
|
|
|
d86f_handler[drive].writeback = null_writeback;
|
|
|
|
|
d86f_handler[drive].set_sector = null_set_sector;
|
|
|
|
|
d86f_handler[drive].write_data = null_write_data;
|
|
|
|
|
d86f_handler[drive].format_conditions = null_format_conditions;
|
|
|
|
|
d86f_handler[drive].extra_bit_cells = extra_bit_cells;
|
|
|
|
|
d86f_handler[drive].encoded_data = encoded_data;
|
|
|
|
|
d86f_handler[drive].read_revolution = read_revolution;
|
|
|
|
|
d86f_handler[drive].index_hole_pos = index_hole_pos;
|
|
|
|
|
d86f_handler[drive].get_raw_size = get_raw_size;
|
|
|
|
|
d86f_handler[drive].check_crc = 1;
|
|
|
|
|
d86f_set_version(drive, D86FVER);
|
|
|
|
|
|
|
|
|
|
d86f_common_handlers(drive);
|
|
|
|
|
|
|
|
|
|
drives[drive].seek = fdi_seek;
|
|
|
|
|
|
2018-05-21 19:04:05 +02:00
|
|
|
fdi_log("Loaded as FDI\n");
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
|
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
fdi_close(int drive)
|
2016-06-26 00:34:39 +02:00
|
|
|
{
|
2018-03-19 01:02:04 +01:00
|
|
|
fdi_t *dev = fdi[drive];
|
2018-01-17 18:43:36 +01:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
if (dev == NULL) return;
|
2018-01-17 18:43:36 +01:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
d86f_unregister(drive);
|
|
|
|
|
|
|
|
|
|
drives[drive].seek = NULL;
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
if (dev->h)
|
|
|
|
|
fdi2raw_header_free(dev->h);
|
2016-06-26 00:34:39 +02:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
if (dev->f)
|
|
|
|
|
fclose(dev->f);
|
|
|
|
|
|
|
|
|
|
/* Release the memory. */
|
|
|
|
|
free(dev);
|
|
|
|
|
fdi[drive] = NULL;
|
2016-06-26 00:34:39 +02:00
|
|
|
}
|
2018-01-17 18:43:36 +01:00
|
|
|
|
2018-03-19 01:02:04 +01:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
fdi_set_fdc(void *fdc)
|
2018-01-17 18:43:36 +01:00
|
|
|
{
|
2018-03-19 01:02:04 +01:00
|
|
|
fdi_fdc = (fdc_t *)fdc;
|
2018-01-17 18:43:36 +01:00
|
|
|
}
|