Applied a whole slew of patches, getting RAM usage down by a further 10 MB.
This commit is contained in:
@@ -1,21 +1,39 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the NEC uPD-765 and compatible floppy disk
|
||||
* controller.
|
||||
*
|
||||
* Version: @(#)fdc->c 1.0.18 2018/03/08
|
||||
* Version: @(#)fdc.c 1.0.5 2018/03/16
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -42,7 +60,7 @@
|
||||
extern int64_t motoron[FDD_NUM];
|
||||
|
||||
|
||||
int command_has_drivesel[256] = {
|
||||
const int command_has_drivesel[256] = {
|
||||
0, 0,
|
||||
1, /* READ TRACK */
|
||||
0,
|
||||
@@ -1147,7 +1165,6 @@ fdc_read(uint16_t addr, void *priv)
|
||||
{
|
||||
fdc_t *fdc = (fdc_t *) priv;
|
||||
uint8_t ret;
|
||||
|
||||
int drive;
|
||||
|
||||
cycles -= ISA_CYCLES(8);
|
||||
@@ -2020,7 +2037,7 @@ fdc_close(void *priv)
|
||||
|
||||
|
||||
static void *
|
||||
fdc_init(device_t *info)
|
||||
fdc_init(const device_t *info)
|
||||
{
|
||||
fdc_t *fdc = (fdc_t *) malloc(sizeof(fdc_t));
|
||||
memset(fdc, 0, sizeof(fdc_t));
|
||||
@@ -2058,7 +2075,7 @@ fdc_3f1_enable(fdc_t *fdc, int enable)
|
||||
}
|
||||
|
||||
|
||||
device_t fdc_xt_device = {
|
||||
const device_t fdc_xt_device = {
|
||||
"PC/XT Floppy Drive Controller",
|
||||
0,
|
||||
0,
|
||||
@@ -2068,7 +2085,7 @@ device_t fdc_xt_device = {
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t fdc_pcjr_device = {
|
||||
const device_t fdc_pcjr_device = {
|
||||
"PCjr Floppy Drive Controller",
|
||||
0,
|
||||
FDC_FLAG_PCJR,
|
||||
@@ -2078,7 +2095,7 @@ device_t fdc_pcjr_device = {
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t fdc_at_device = {
|
||||
const device_t fdc_at_device = {
|
||||
"PC/AT Floppy Drive Controller",
|
||||
0,
|
||||
FDC_FLAG_AT,
|
||||
@@ -2088,7 +2105,7 @@ device_t fdc_at_device = {
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t fdc_at_actlow_device = {
|
||||
const device_t fdc_at_actlow_device = {
|
||||
"PC/AT Floppy Drive Controller (Active low)",
|
||||
0,
|
||||
FDC_FLAG_DISKCHG_ACTLOW | FDC_FLAG_AT,
|
||||
@@ -2098,7 +2115,7 @@ device_t fdc_at_actlow_device = {
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t fdc_at_ps1_device = {
|
||||
const device_t fdc_at_ps1_device = {
|
||||
"PC/AT Floppy Drive Controller (PS/1, PS/2 ISA)",
|
||||
0,
|
||||
FDC_FLAG_DISKCHG_ACTLOW | FDC_FLAG_AT | FDC_FLAG_PS1,
|
||||
@@ -2108,7 +2125,7 @@ device_t fdc_at_ps1_device = {
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t fdc_at_smc_device = {
|
||||
const device_t fdc_at_smc_device = {
|
||||
"PC/AT Floppy Drive Controller (SM(s)C FDC37Cxxx)",
|
||||
0,
|
||||
FDC_FLAG_AT | FDC_FLAG_SUPERIO,
|
||||
@@ -2118,7 +2135,7 @@ device_t fdc_at_smc_device = {
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t fdc_at_winbond_device = {
|
||||
const device_t fdc_at_winbond_device = {
|
||||
"PC/AT Floppy Drive Controller (Winbond W83x77F)",
|
||||
0,
|
||||
FDC_FLAG_AT | FDC_FLAG_SUPERIO | FDC_FLAG_START_RWC_1 | FDC_FLAG_MORE_TRACKS,
|
||||
@@ -2128,7 +2145,7 @@ device_t fdc_at_winbond_device = {
|
||||
NULL, NULL, NULL, NULL
|
||||
};
|
||||
|
||||
device_t fdc_at_nsc_device = {
|
||||
const device_t fdc_at_nsc_device = {
|
||||
"PC/AT Floppy Drive Controller (NSC PC8730x)",
|
||||
0,
|
||||
FDC_FLAG_AT | FDC_FLAG_MORE_TRACKS | FDC_FLAG_NSC,
|
||||
|
||||
@@ -1,20 +1,41 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the NEC uPD-765 and compatible floppy disk
|
||||
* controller.
|
||||
*
|
||||
* Version: @(#)fdc.h 1.0.5 2018/03/02
|
||||
* Version: @(#)fdc.h 1.0.3 2018/03/17
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef EMU_FDC_H
|
||||
# define EMU_FDC_H
|
||||
@@ -29,8 +50,8 @@
|
||||
#define FDC_FLAG_MORE_TRACKS 0x40 /* W83877F, W83977F, PC87306, PC87309 */
|
||||
#define FDC_FLAG_NSC 0x80 /* PC87306, PC87309 */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
typedef struct {
|
||||
uint8_t dor, stat, command, dat, st0, swap;
|
||||
uint8_t swwp, disable_write;
|
||||
uint8_t params[256], res[256];
|
||||
@@ -79,6 +100,7 @@ typedef struct
|
||||
int64_t watchdog_timer, watchdog_count;
|
||||
} fdc_t;
|
||||
|
||||
|
||||
extern void fdc_remove(fdc_t *fdc);
|
||||
extern void fdc_poll(fdc_t *fdc);
|
||||
extern void fdc_abort(fdc_t *fdc);
|
||||
@@ -148,7 +170,9 @@ extern void fdc_set_base(fdc_t *fdc, int base);
|
||||
extern int fdc_getdata(fdc_t *fdc, int last);
|
||||
extern int fdc_data(fdc_t *fdc, uint8_t data);
|
||||
|
||||
extern void fdc_sectorid(fdc_t *fdc, uint8_t track, uint8_t side, uint8_t sector, uint8_t size, uint8_t crc1, uint8_t crc2);
|
||||
extern void fdc_sectorid(fdc_t *fdc, uint8_t track, uint8_t side,
|
||||
uint8_t sector, uint8_t size, uint8_t crc1,
|
||||
uint8_t crc2);
|
||||
|
||||
extern uint8_t fdc_read(uint16_t addr, void *priv);
|
||||
extern void fdc_reset(void *priv);
|
||||
@@ -156,14 +180,14 @@ extern void fdc_reset(void *priv);
|
||||
extern uint8_t fdc_ps1_525(void);
|
||||
|
||||
#ifdef EMU_DEVICE_H
|
||||
extern device_t fdc_xt_device;
|
||||
extern device_t fdc_pcjr_device;
|
||||
extern device_t fdc_at_device;
|
||||
extern device_t fdc_at_actlow_device;
|
||||
extern device_t fdc_at_ps1_device;
|
||||
extern device_t fdc_at_smc_device;
|
||||
extern device_t fdc_at_winbond_device;
|
||||
extern device_t fdc_at_nsc_device;
|
||||
extern const device_t fdc_xt_device;
|
||||
extern const device_t fdc_pcjr_device;
|
||||
extern const device_t fdc_at_device;
|
||||
extern const device_t fdc_at_actlow_device;
|
||||
extern const device_t fdc_at_ps1_device;
|
||||
extern const device_t fdc_at_smc_device;
|
||||
extern const device_t fdc_at_winbond_device;
|
||||
extern const device_t fdc_at_nsc_device;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -1,20 +1,40 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the floppy drive emulation.
|
||||
*
|
||||
* Version: @(#)fdd.c 1.0.9 2018/03/14
|
||||
* Version: @(#)fdd.c 1.0.5 2018/03/16
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -66,8 +86,9 @@ int fdc_indexcount = 52;
|
||||
|
||||
fdc_t *fdd_fdc;
|
||||
|
||||
d86f_handler_t d86f_handler[FDD_NUM];
|
||||
|
||||
static struct
|
||||
static const struct
|
||||
{
|
||||
wchar_t *ext;
|
||||
void (*load)(int drive, wchar_t *fn);
|
||||
@@ -150,7 +171,7 @@ int ui_writeprot[FDD_NUM] = {0, 0, 0, 0};
|
||||
#define FLAG_IGNORE_DENSEL 512
|
||||
#define FLAG_PS2 1024
|
||||
|
||||
static struct
|
||||
static const struct
|
||||
{
|
||||
int max_track;
|
||||
int flags;
|
||||
@@ -207,12 +228,12 @@ static struct
|
||||
|
||||
char *fdd_getname(int type)
|
||||
{
|
||||
return drive_types[type].name;
|
||||
return (char *)drive_types[type].name;
|
||||
}
|
||||
|
||||
char *fdd_get_internal_name(int type)
|
||||
{
|
||||
return drive_types[type].internal_name;
|
||||
return (char *)drive_types[type].internal_name;
|
||||
}
|
||||
|
||||
int fdd_get_from_internal_name(char *s)
|
||||
@@ -221,7 +242,7 @@ int fdd_get_from_internal_name(char *s)
|
||||
|
||||
while (strlen(drive_types[c].internal_name))
|
||||
{
|
||||
if (!strcmp(drive_types[c].internal_name, s))
|
||||
if (!strcmp((char *)drive_types[c].internal_name, s))
|
||||
return c;
|
||||
c++;
|
||||
}
|
||||
@@ -433,6 +454,9 @@ void fdd_load(int drive, wchar_t *fn)
|
||||
int c = 0, size;
|
||||
wchar_t *p;
|
||||
FILE *f;
|
||||
|
||||
pclog("FDD: loading drive %d with '%ls'\n", drive, fn);
|
||||
|
||||
if (!fn) return;
|
||||
p = plat_get_extension(fn);
|
||||
if (!p) return;
|
||||
@@ -447,7 +471,7 @@ void fdd_load(int drive, wchar_t *fn)
|
||||
{
|
||||
driveloaders[drive] = c;
|
||||
memcpy(floppyfns[drive], fn, (wcslen(fn) << 1) + 2);
|
||||
d86f_initialize_linked_lists(drive);
|
||||
d86f_setup(drive);
|
||||
loaders[c].load(drive, floppyfns[drive]);
|
||||
drive_empty[drive] = 0;
|
||||
fdd_forced_seek(drive, 0);
|
||||
@@ -456,7 +480,7 @@ void fdd_load(int drive, wchar_t *fn)
|
||||
}
|
||||
c++;
|
||||
}
|
||||
pclog("Couldn't load %ls %s\n",fn,p);
|
||||
pclog("FDD: could not load '%ls' %s\n",fn,p);
|
||||
drive_empty[drive] = 1;
|
||||
fdd_set_head(drive, 0);
|
||||
memset(floppyfns[drive], 0, sizeof(floppyfns[drive]));
|
||||
@@ -465,12 +489,13 @@ void fdd_load(int drive, wchar_t *fn)
|
||||
|
||||
void fdd_close(int drive)
|
||||
{
|
||||
pclog("FDD: closing drive %d\n", drive);
|
||||
|
||||
if (loaders[driveloaders[drive]].close) loaders[driveloaders[drive]].close(drive);
|
||||
drive_empty[drive] = 1;
|
||||
fdd_set_head(drive, 0);
|
||||
floppyfns[drive][0] = 0;
|
||||
d86f_destroy_linked_lists(drive, 0);
|
||||
d86f_destroy_linked_lists(drive, 1);
|
||||
d86f_destroy(drive);
|
||||
drives[drive].hole = NULL;
|
||||
drives[drive].poll = NULL;
|
||||
drives[drive].seek = NULL;
|
||||
@@ -526,18 +551,7 @@ double fdd_real_period(int drive)
|
||||
return (32.0 * dusec);
|
||||
}
|
||||
|
||||
#if defined(DEV_BRANCH) && defined(USE_MRTHOR)
|
||||
if (romset == ROM_MRTHOR)
|
||||
{
|
||||
return (ddbp * dusec) / 4.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (ddbp * dusec);
|
||||
}
|
||||
#else
|
||||
return (ddbp * dusec);
|
||||
#endif
|
||||
}
|
||||
|
||||
void fdd_poll(int drive)
|
||||
@@ -705,6 +719,7 @@ void fdd_init(void)
|
||||
d86f_init();
|
||||
td0_init();
|
||||
imd_init();
|
||||
json_init();
|
||||
|
||||
fdd_load(0, floppyfns[0]);
|
||||
fdd_load(1, floppyfns[1]);
|
||||
|
||||
271
src/floppy/fdd.h
271
src/floppy/fdd.h
@@ -1,34 +1,54 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the floppy drive emulation.
|
||||
* Definitions for the floppy drive emulation.
|
||||
*
|
||||
* Version: @(#)fdd.h 1.0.5 2018/01/18
|
||||
* Version: @(#)fdd.h 1.0.3 2018/03/17
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef EMU_FDD_H
|
||||
# define EMU_FDD_H
|
||||
|
||||
|
||||
#define FDD_NUM 4
|
||||
#define SEEK_RECALIBRATE -999
|
||||
#define FDD_NUM 4
|
||||
#define SEEK_RECALIBRATE -999
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern int fdd_swap;
|
||||
extern int fdd_swap;
|
||||
|
||||
|
||||
extern void fdd_do_seek(int drive, int track);
|
||||
@@ -65,16 +85,19 @@ extern int fdd_current_track(int drive);
|
||||
|
||||
|
||||
typedef struct {
|
||||
void (*seek)(int drive, int track);
|
||||
void (*readsector)(int drive, int sector, int track, int side, int density, int sector_size);
|
||||
void (*writesector)(int drive, int sector, int track, int side, int density, int sector_size);
|
||||
void (*comparesector)(int drive, int sector, int track, int side, int density, int sector_size);
|
||||
void (*readaddress)(int drive, int side, int density);
|
||||
void (*format)(int drive, int side, int density, uint8_t fill);
|
||||
int (*hole)(int drive);
|
||||
double (*byteperiod)(int drive);
|
||||
void (*stop)(int drive);
|
||||
void (*poll)(int drive);
|
||||
void (*seek)(int drive, int track);
|
||||
void (*readsector)(int drive, int sector, int track, int side,
|
||||
int density, int sector_size);
|
||||
void (*writesector)(int drive, int sector, int track, int side,
|
||||
int density, int sector_size);
|
||||
void (*comparesector)(int drive, int sector, int track, int side,
|
||||
int density, int sector_size);
|
||||
void (*readaddress)(int drive, int side, int density);
|
||||
void (*format)(int drive, int side, int density, uint8_t fill);
|
||||
int (*hole)(int drive);
|
||||
double (*byteperiod)(int drive);
|
||||
void (*stop)(int drive);
|
||||
void (*poll)(int drive);
|
||||
} DRIVE;
|
||||
|
||||
|
||||
@@ -115,60 +138,24 @@ extern void fdd_stop(int drive);
|
||||
extern int fdd_empty(int drive);
|
||||
extern void fdd_set_rate(int drive, int drvden, int rate);
|
||||
|
||||
extern int motorspin;
|
||||
extern int64_t motoron[FDD_NUM];
|
||||
extern int motorspin;
|
||||
extern int64_t motoron[FDD_NUM];
|
||||
|
||||
extern int swwp;
|
||||
extern int disable_write;
|
||||
extern int swwp;
|
||||
extern int disable_write;
|
||||
|
||||
extern int defaultwriteprot;
|
||||
extern int defaultwriteprot;
|
||||
|
||||
extern int writeprot[FDD_NUM], fwriteprot[FDD_NUM];
|
||||
extern int fdd_cur_track[FDD_NUM];
|
||||
extern int fdd_changed[FDD_NUM];
|
||||
extern int drive_empty[FDD_NUM];
|
||||
extern int drive_type[FDD_NUM];
|
||||
extern int writeprot[FDD_NUM], fwriteprot[FDD_NUM];
|
||||
extern int fdd_cur_track[FDD_NUM];
|
||||
extern int fdd_changed[FDD_NUM];
|
||||
extern int drive_empty[FDD_NUM];
|
||||
extern int drive_type[FDD_NUM];
|
||||
|
||||
/*Used in the Read A Track command. Only valid for fdd_readsector(). */
|
||||
#define SECTOR_FIRST -2
|
||||
#define SECTOR_NEXT -1
|
||||
|
||||
#if 0
|
||||
/* Bits 0-3 define byte type, bit 5 defines whether it is a per-track (0) or per-sector (1) byte, if bit 7 is set, the byte is the index hole. */
|
||||
#define BYTE_GAP0 0x00
|
||||
#define BYTE_GAP1 0x10
|
||||
#define BYTE_GAP4 0x20
|
||||
#define BYTE_GAP2 0x40
|
||||
#define BYTE_GAP3 0x50
|
||||
#define BYTE_I_SYNC 0x01
|
||||
#define BYTE_ID_SYNC 0x41
|
||||
#define BYTE_DATA_SYNC 0x51
|
||||
#define BYTE_IAM_SYNC 0x02
|
||||
#define BYTE_IDAM_SYNC 0x42
|
||||
#define BYTE_DATAAM_SYNC 0x52
|
||||
#define BYTE_IAM 0x03
|
||||
#define BYTE_IDAM 0x43
|
||||
#define BYTE_DATAAM 0x53
|
||||
#define BYTE_ID 0x44
|
||||
#define BYTE_DATA 0x54
|
||||
#define BYTE_ID_CRC 0x45
|
||||
#define BYTE_DATA_CRC 0x55
|
||||
|
||||
#define BYTE_IS_FUZZY 0x80
|
||||
#define BYTE_INDEX_HOLE 0x80 /* 1 = index hole, 0 = regular byte */
|
||||
#define BYTE_IS_SECTOR 0x40 /* 1 = per-sector, 0 = per-track */
|
||||
#define BYTE_IS_POST_TRACK 0x20 /* 1 = after all sectors, 0 = before or during all sectors */
|
||||
#define BYTE_IS_DATA 0x10 /* 1 = data, 0 = id */
|
||||
#define BYTE_TYPE 0x0F /* 5 = crc, 4 = data, 3 = address mark, 2 = address mark sync, 1 = sync, 0 = gap */
|
||||
|
||||
#define BYTE_TYPE_GAP 0x00
|
||||
#define BYTE_TYPE_SYNC 0x01
|
||||
#define BYTE_TYPE_AM_SYNC 0x02
|
||||
#define BYTE_TYPE_AM 0x03
|
||||
#define BYTE_TYPE_DATA 0x04
|
||||
#define BYTE_TYPE_CRC 0x05
|
||||
#endif
|
||||
|
||||
typedef union {
|
||||
uint16_t word;
|
||||
uint8_t bytes[2];
|
||||
@@ -176,94 +163,92 @@ typedef union {
|
||||
|
||||
void fdd_calccrc(uint8_t byte, crc_t *crc_var);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t (*disk_flags)(int drive);
|
||||
uint16_t (*side_flags)(int drive);
|
||||
void (*writeback)(int drive);
|
||||
void (*set_sector)(int drive, int side, uint8_t c, uint8_t h, uint8_t r, uint8_t n);
|
||||
uint8_t (*read_data)(int drive, int side, uint16_t pos);
|
||||
void (*write_data)(int drive, int side, uint16_t pos, uint8_t data);
|
||||
int (*format_conditions)(int drive);
|
||||
int32_t (*extra_bit_cells)(int drive, int side);
|
||||
uint16_t* (*encoded_data)(int drive, int side);
|
||||
void (*read_revolution)(int drive);
|
||||
uint32_t (*index_hole_pos)(int drive, int side);
|
||||
uint32_t (*get_raw_size)(int drive, int side);
|
||||
uint8_t check_crc;
|
||||
typedef struct {
|
||||
uint16_t (*disk_flags)(int drive);
|
||||
uint16_t (*side_flags)(int drive);
|
||||
void (*writeback)(int drive);
|
||||
void (*set_sector)(int drive, int side, uint8_t c, uint8_t h,
|
||||
uint8_t r, uint8_t n);
|
||||
uint8_t (*read_data)(int drive, int side, uint16_t pos);
|
||||
void (*write_data)(int drive, int side, uint16_t pos,
|
||||
uint8_t data);
|
||||
int (*format_conditions)(int drive);
|
||||
int32_t (*extra_bit_cells)(int drive, int side);
|
||||
uint16_t* (*encoded_data)(int drive, int side);
|
||||
void (*read_revolution)(int drive);
|
||||
uint32_t (*index_hole_pos)(int drive, int side);
|
||||
uint32_t (*get_raw_size)(int drive, int side);
|
||||
|
||||
uint8_t check_crc;
|
||||
} d86f_handler_t;
|
||||
|
||||
d86f_handler_t d86f_handler[FDD_NUM];
|
||||
extern const int gap3_sizes[5][8][48];
|
||||
extern d86f_handler_t d86f_handler[FDD_NUM];
|
||||
|
||||
void d86f_common_handlers(int drive);
|
||||
extern void d86f_setup(int drive);
|
||||
extern void d86f_destroy(int drive);
|
||||
extern int d86f_export(int drive, wchar_t *fn);
|
||||
extern void d86f_unregister(int drive);
|
||||
extern void d86f_common_handlers(int drive);
|
||||
extern void d86f_set_version(int drive, uint16_t version);
|
||||
extern int d86f_is_40_track(int drive);
|
||||
extern void d86f_reset_index_hole_pos(int drive, int side);
|
||||
extern uint16_t d86f_prepare_pretrack(int drive, int side, int iso);
|
||||
extern uint16_t d86f_prepare_sector(int drive, int side, int prev_pos,
|
||||
uint8_t *id_buf, uint8_t *data_buf,
|
||||
int data_len, int gap2, int gap3,
|
||||
int deleted, int bad_crc);
|
||||
extern void d86f_set_track_pos(int drive, uint32_t track_pos);
|
||||
extern void d86f_set_cur_track(int drive, int track);
|
||||
extern void d86f_zero_track(int drive);
|
||||
extern void d86f_initialize_last_sector_id(int drive, int c, int h,
|
||||
int r, int n);
|
||||
extern void d86f_initialize_linked_lists(int drive);
|
||||
extern void d86f_destroy_linked_lists(int drive, int side);
|
||||
extern uint16_t *common_encoded_data(int drive, int side);
|
||||
extern void common_read_revolution(int drive);
|
||||
extern uint32_t common_get_raw_size(int drive, int side);
|
||||
extern void null_writeback(int drive);
|
||||
extern void null_write_data(int drive, int side, uint16_t pos,
|
||||
uint8_t data);
|
||||
extern int null_format_conditions(int drive);
|
||||
extern int32_t null_extra_bit_cells(int drive, int side);
|
||||
extern void null_set_sector(int drive, int side, uint8_t c, uint8_t h,
|
||||
uint8_t r, uint8_t n);
|
||||
extern uint32_t null_index_hole_pos(int drive, int side);
|
||||
|
||||
int d86f_is_40_track(int drive);
|
||||
extern const uint8_t dmf_r[21];
|
||||
extern const uint8_t xdf_physical_sectors[2][2];
|
||||
extern const uint8_t xdf_gap3_sizes[2][2];
|
||||
extern const uint16_t xdf_trackx_spos[2][8];
|
||||
|
||||
void d86f_reset_index_hole_pos(int drive, int side);
|
||||
|
||||
uint16_t d86f_prepare_pretrack(int drive, int side, int iso);
|
||||
uint16_t d86f_prepare_sector(int drive, int side, int prev_pos, uint8_t *id_buf, uint8_t *data_buf, int data_len, int gap2, int gap3, int deleted, int bad_crc);
|
||||
|
||||
extern int gap3_sizes[5][8][48];
|
||||
|
||||
void null_writeback(int drive);
|
||||
void null_write_data(int drive, int side, uint16_t pos, uint8_t data);
|
||||
int null_format_conditions(int drive);
|
||||
void d86f_unregister(int drive);
|
||||
|
||||
extern uint8_t dmf_r[21];
|
||||
extern uint8_t xdf_physical_sectors[2][2];
|
||||
extern uint8_t xdf_gap3_sizes[2][2];
|
||||
extern uint16_t xdf_trackx_spos[2][8];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t h;
|
||||
uint8_t r;
|
||||
typedef struct {
|
||||
uint8_t h;
|
||||
uint8_t r;
|
||||
} xdf_id_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint16_t word;
|
||||
xdf_id_t id;
|
||||
typedef union {
|
||||
uint16_t word;
|
||||
xdf_id_t id;
|
||||
} xdf_sector_t;
|
||||
|
||||
extern xdf_sector_t xdf_img_layout[2][2][46];
|
||||
extern xdf_sector_t xdf_disk_layout[2][2][38];
|
||||
extern const xdf_sector_t xdf_img_layout[2][2][46];
|
||||
extern const xdf_sector_t xdf_disk_layout[2][2][38];
|
||||
|
||||
uint32_t td0_get_raw_tsize(int side_flags, int slower_rpm);
|
||||
|
||||
void d86f_set_track_pos(int drive, uint32_t track_pos);
|
||||
|
||||
int32_t null_extra_bit_cells(int drive, int side);
|
||||
uint16_t* common_encoded_data(int drive, int side);
|
||||
|
||||
void common_read_revolution(int drive);
|
||||
void null_set_sector(int drive, int side, uint8_t c, uint8_t h, uint8_t r, uint8_t n);
|
||||
|
||||
uint32_t null_index_hole_pos(int drive, int side);
|
||||
|
||||
uint32_t common_get_raw_size(int drive, int side);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t c;
|
||||
uint8_t h;
|
||||
uint8_t r;
|
||||
uint8_t n;
|
||||
typedef struct {
|
||||
uint8_t c;
|
||||
uint8_t h;
|
||||
uint8_t r;
|
||||
uint8_t n;
|
||||
} sector_id_fields_t;
|
||||
|
||||
typedef union
|
||||
{
|
||||
uint32_t dword;
|
||||
uint8_t byte_array[4];
|
||||
sector_id_fields_t id;
|
||||
typedef union {
|
||||
uint32_t dword;
|
||||
uint8_t byte_array[4];
|
||||
sector_id_fields_t id;
|
||||
} sector_id_t;
|
||||
|
||||
void d86f_set_version(int drive, uint16_t version);
|
||||
|
||||
void d86f_initialize_last_sector_id(int drive, int c, int h, int r, int n);
|
||||
void d86f_destroy_linked_lists(int drive, int side);
|
||||
|
||||
void d86f_set_fdc(void *fdc);
|
||||
void fdi_set_fdc(void *fdc);
|
||||
@@ -271,10 +256,6 @@ void fdd_set_fdc(void *fdc);
|
||||
void imd_set_fdc(void *fdc);
|
||||
void img_set_fdc(void *fdc);
|
||||
|
||||
extern void d86f_set_cur_track(int drive, int track);
|
||||
extern void d86f_zero_track(int drive);
|
||||
|
||||
extern int d86f_export(int drive, wchar_t *fn);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
6932
src/floppy/fdd_86f.c
6932
src/floppy/fdd_86f.c
File diff suppressed because it is too large
Load Diff
@@ -1,24 +1,46 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the 86F floppy image format (stores the
|
||||
* data in the form of FM/MFM-encoded transitions) which also
|
||||
* forms the core of the emulator's floppy disk emulation.
|
||||
* Definitions for the 86F floppy image format.
|
||||
*
|
||||
* Version: @(#)floppy_86f.h 1.0.5 2018/03/14
|
||||
* Version: @(#)floppy_86f.h 1.0.4 2018/03/17
|
||||
*
|
||||
* Author: Miran Grca, <mgrca8@gmail.com>
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef EMU_FLOPPY_86F_H
|
||||
# define EMU_FLOPPY_86F_H
|
||||
|
||||
|
||||
#define D86FVER 0x020B
|
||||
|
||||
|
||||
extern void d86f_init(void);
|
||||
extern void d86f_load(int drive, wchar_t *fn);
|
||||
extern void d86f_close(int drive);
|
||||
@@ -39,6 +61,10 @@ extern void d86f_prepare_track_layout(int drive, int side);
|
||||
extern void d86f_set_version(int drive, uint16_t version);
|
||||
extern uint16_t d86f_side_flags(int drive);
|
||||
extern uint16_t d86f_track_flags(int drive);
|
||||
extern void d86f_initialize_last_sector_id(int drive, int c, int h,
|
||||
int r, int n);
|
||||
extern void d86f_initialize_linked_lists(int drive);
|
||||
extern void d86f_destroy_linked_lists(int drive, int side);
|
||||
|
||||
#define length_gap0 80
|
||||
#define length_gap1 50
|
||||
@@ -59,19 +85,5 @@ extern uint16_t d86f_track_flags(int drive);
|
||||
#define pre_data length_sync + length_am
|
||||
#define post_gap length_crc
|
||||
|
||||
#if 0
|
||||
extern int raw_tsize[2];
|
||||
extern int gap2_size[2];
|
||||
extern int gap3_size[2];
|
||||
extern int gap4_size[2];
|
||||
#endif
|
||||
|
||||
#define D86FVER 0x020B
|
||||
|
||||
extern void d86f_initialize_last_sector_id(int drive, int c, int h, int r, int n);
|
||||
|
||||
extern void d86f_initialize_linked_lists(int drive);
|
||||
extern void d86f_destroy_linked_lists(int drive, int side);
|
||||
|
||||
|
||||
#endif /*EMU_FLOPPY_86F_H*/
|
||||
|
||||
@@ -1,17 +1,36 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Shared code for all the floppy modules.
|
||||
*
|
||||
* Version: @(#)fdd_common.c 1.0.5 2018/01/16
|
||||
* Version: @(#)fdd_common.c 1.0.2 2018/03/16
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -23,11 +42,11 @@
|
||||
#include "fdd_common.h"
|
||||
|
||||
|
||||
uint8_t fdd_holes[6] = { 0, 0, 0, 1, 1, 2 };
|
||||
const uint8_t fdd_holes[6] = { 0, 0, 0, 1, 1, 2 };
|
||||
|
||||
uint8_t fdd_rates[6] = { 2, 2, 1, 4, 0, 3 };
|
||||
const uint8_t fdd_rates[6] = { 2, 2, 1, 4, 0, 3 };
|
||||
|
||||
double fdd_bit_rates_300[6] = {
|
||||
const double fdd_bit_rates_300[6] = {
|
||||
(250.0 * 300.0) / 360.0,
|
||||
250.0,
|
||||
300.0,
|
||||
@@ -46,7 +65,7 @@ double fdd_bit_rates_300[6] = {
|
||||
* Disks formatted at 300 kbps @ 300 RPM can be read with any 300 RPM
|
||||
* single-RPM drive by setting the rate to 300 kbps.
|
||||
*/
|
||||
uint8_t fdd_max_sectors[8][6] = {
|
||||
const uint8_t fdd_max_sectors[8][6] = {
|
||||
{ 26, 31, 38, 53, 64, 118 }, /* 128 */
|
||||
{ 15, 19, 23, 32, 38, 73 }, /* 256 */
|
||||
{ 7, 10, 12, 17, 22, 41 }, /* 512 */
|
||||
@@ -57,12 +76,12 @@ uint8_t fdd_max_sectors[8][6] = {
|
||||
{ 0, 0, 0, 0, 0, 1 } /* 16384 */
|
||||
};
|
||||
|
||||
uint8_t fdd_dmf_r[21] = {
|
||||
const uint8_t fdd_dmf_r[21] = {
|
||||
12,2,13,3,14,4,15,5,16,6,17,7,18,8,19,9,20,10,21,11,1
|
||||
};
|
||||
|
||||
|
||||
static uint8_t fdd_gap3_sizes[5][8][48] = {
|
||||
static const uint8_t fdd_gap3_sizes[5][8][48] = {
|
||||
{ { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* [0][0] */
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
@@ -346,7 +365,6 @@ static uint8_t fdd_gap3_sizes[5][8][48] = {
|
||||
};
|
||||
|
||||
|
||||
|
||||
int
|
||||
fdd_get_gap3_size(int rate, int size, int sector)
|
||||
{
|
||||
|
||||
@@ -1,27 +1,46 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Shared code for all the floppy modules.
|
||||
*
|
||||
* Version: @(#)fdd_common.h 1.0.2 2018/01/16
|
||||
* Version: @(#)fdd_common.h 1.0.2 2018/03/16
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef fdd_COMMON_H
|
||||
# define fdd_COMMON_H
|
||||
#ifndef FDD_COMMON_H
|
||||
# define FDD_COMMON_H
|
||||
|
||||
|
||||
extern uint8_t fdd_holes[6];
|
||||
extern uint8_t fdd_rates[6];
|
||||
extern double fdd_bit_rates_300[6];
|
||||
extern uint8_t fdd_max_sectors[8][6];
|
||||
extern uint8_t fdd_dmf_r[21];
|
||||
extern const uint8_t fdd_holes[6];
|
||||
extern const uint8_t fdd_rates[6];
|
||||
extern const double fdd_bit_rates_300[6];
|
||||
extern const uint8_t fdd_max_sectors[8][6];
|
||||
extern const uint8_t fdd_dmf_r[21];
|
||||
|
||||
|
||||
extern int fdd_get_gap3_size(int rate, int size, int sector);
|
||||
@@ -31,4 +50,4 @@ extern int fdd_bps_valid(uint16_t bps);
|
||||
extern int fdd_interleave(int sector, int skew, int spt);
|
||||
|
||||
|
||||
#endif /*fdd_COMMON_H*/
|
||||
#endif /*FDD_COMMON_H*/
|
||||
|
||||
@@ -1,25 +1,46 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the FDI floppy stream image format
|
||||
* interface to the FDI2RAW module.
|
||||
*
|
||||
* Version: @(#)fdd_fdi.c 1.0.7 2018/01/16
|
||||
* Version: @(#)fdd_fdi.c 1.0.2 2018/03/17
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include "../86box.h"
|
||||
#include "../plat.h"
|
||||
@@ -31,317 +52,355 @@
|
||||
#include "fdi2raw.h"
|
||||
|
||||
|
||||
static struct
|
||||
typedef struct {
|
||||
FILE *f;
|
||||
FDI *h;
|
||||
|
||||
int lasttrack;
|
||||
int sides;
|
||||
int track;
|
||||
int tracklen[2][4];
|
||||
int trackindex[2][4];
|
||||
|
||||
uint8_t track_data[2][4][256*1024];
|
||||
uint8_t track_timing[2][4][256*1024];
|
||||
} fdi_t;
|
||||
|
||||
|
||||
static fdi_t *fdi[FDD_NUM];
|
||||
static fdc_t *fdi_fdc;
|
||||
|
||||
|
||||
static uint16_t
|
||||
disk_flags(int drive)
|
||||
{
|
||||
FILE *f;
|
||||
FDI *h;
|
||||
uint8_t track_data[2][4][256*1024];
|
||||
uint8_t track_timing[2][4][256*1024];
|
||||
|
||||
int sides;
|
||||
int track;
|
||||
int tracklen[2][4];
|
||||
int trackindex[2][4];
|
||||
|
||||
int lasttrack;
|
||||
} fdi[FDD_NUM];
|
||||
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. */
|
||||
|
||||
static fdc_t *fdi_fdc;
|
||||
switch (fdi2raw_get_bit_rate(dev->h)) {
|
||||
case 500:
|
||||
temp_disk_flags |= 2;
|
||||
break;
|
||||
|
||||
uint16_t fdi_disk_flags(int drive)
|
||||
{
|
||||
uint16_t temp_disk_flags = 0x80; /* We ALWAYS claim to have extra bit cells, even if the actual amount is 0. */
|
||||
case 300:
|
||||
case 250:
|
||||
temp_disk_flags |= 0;
|
||||
break;
|
||||
|
||||
switch (fdi2raw_get_bit_rate(fdi[drive].h))
|
||||
{
|
||||
case 500:
|
||||
temp_disk_flags |= 2;
|
||||
break;
|
||||
case 300:
|
||||
case 250:
|
||||
temp_disk_flags |= 0;
|
||||
break;
|
||||
case 1000:
|
||||
temp_disk_flags |= 4;
|
||||
break;
|
||||
default:
|
||||
temp_disk_flags |= 0;
|
||||
}
|
||||
case 1000:
|
||||
temp_disk_flags |= 4;
|
||||
break;
|
||||
|
||||
if (fdi[drive].sides == 2)
|
||||
{
|
||||
temp_disk_flags |= 8;
|
||||
}
|
||||
default:
|
||||
temp_disk_flags |= 0;
|
||||
}
|
||||
|
||||
/* Tell the 86F handler that will handle our data to handle it in reverse byte endianness. */
|
||||
temp_disk_flags |= 0x800;
|
||||
if (dev->sides == 2)
|
||||
temp_disk_flags |= 8;
|
||||
|
||||
return temp_disk_flags;
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
|
||||
uint16_t fdi_side_flags(int drive)
|
||||
|
||||
static uint16_t
|
||||
side_flags(int drive)
|
||||
{
|
||||
uint16_t temp_side_flags = 0;
|
||||
switch (fdi2raw_get_bit_rate(fdi[drive].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(fdi[drive].h) == 360)
|
||||
{
|
||||
temp_side_flags |= 0x20;
|
||||
}
|
||||
fdi_t *dev = fdi[drive];
|
||||
uint16_t temp_side_flags = 0;
|
||||
|
||||
/* 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;
|
||||
switch (fdi2raw_get_bit_rate(dev->h)) {
|
||||
case 500:
|
||||
temp_side_flags = 0;
|
||||
break;
|
||||
|
||||
return temp_side_flags;
|
||||
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);
|
||||
}
|
||||
|
||||
int fdi_density()
|
||||
{
|
||||
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;
|
||||
case 3:
|
||||
case 5:
|
||||
return 3;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
static int
|
||||
fdi_density(void)
|
||||
{
|
||||
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);
|
||||
|
||||
case 3:
|
||||
case 5:
|
||||
return(3);
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return(1);
|
||||
}
|
||||
|
||||
int32_t fdi_extra_bit_cells(int drive, int side)
|
||||
|
||||
static int32_t
|
||||
extra_bit_cells(int drive, int side)
|
||||
{
|
||||
int density = 0;
|
||||
fdi_t *dev = fdi[drive];
|
||||
int density = 0;
|
||||
int raw_size = 0;
|
||||
int is_300_rpm = 0;
|
||||
|
||||
int raw_size = 0;
|
||||
density = fdi_density();
|
||||
|
||||
int is_300_rpm = 0;
|
||||
is_300_rpm = (fdd_getrpm(drive) == 300);
|
||||
|
||||
density = fdi_density();
|
||||
switch (fdc_get_bit_rate(fdi_fdc)) {
|
||||
case 0:
|
||||
raw_size = is_300_rpm ? 200000 : 166666;
|
||||
break;
|
||||
|
||||
is_300_rpm = (fdd_getrpm(drive) == 300);
|
||||
case 1:
|
||||
raw_size = is_300_rpm ? 120000 : 100000;
|
||||
break;
|
||||
|
||||
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;
|
||||
case 3:
|
||||
case 5:
|
||||
raw_size = is_300_rpm ? 400000 : 333333;
|
||||
break;
|
||||
default:
|
||||
raw_size = is_300_rpm ? 100000 : 83333;
|
||||
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));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
read_revolution(int drive)
|
||||
{
|
||||
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]);
|
||||
}
|
||||
|
||||
return (fdi[drive].tracklen[side][density] - raw_size);
|
||||
}
|
||||
|
||||
int fdi_hole(int drive)
|
||||
{
|
||||
switch (fdi2raw_get_bit_rate(fdi[drive].h))
|
||||
{
|
||||
case 1000:
|
||||
return 2;
|
||||
case 500:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
if (dev->sides == 1) {
|
||||
memset(dev->track_data[1][den], 0, 106096);
|
||||
dev->tracklen[1][den] = 100000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void fdi_read_revolution(int drive)
|
||||
|
||||
static uint32_t
|
||||
index_hole_pos(int drive, int side)
|
||||
{
|
||||
int density;
|
||||
int track = fdi[drive].track;
|
||||
fdi_t *dev = fdi[drive];
|
||||
int density;
|
||||
|
||||
int side = 0;
|
||||
density = fdi_density();
|
||||
|
||||
if (track > fdi[drive].lasttrack)
|
||||
{
|
||||
for (density = 0; density < 4; density++)
|
||||
{
|
||||
memset(fdi[drive].track_data[0][density], 0, 106096);
|
||||
memset(fdi[drive].track_data[1][density], 0, 106096);
|
||||
fdi[drive].tracklen[0][density] = fdi[drive].tracklen[1][density] = 100000;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
for (density = 0; density < 4; density++)
|
||||
{
|
||||
for (side = 0; side < fdi[drive].sides; side++)
|
||||
{
|
||||
int c = fdi2raw_loadtrack(fdi[drive].h, (uint16_t *)fdi[drive].track_data[side][density],
|
||||
(uint16_t *)fdi[drive].track_timing[side][density],
|
||||
(track * fdi[drive].sides) + side,
|
||||
&fdi[drive].tracklen[side][density],
|
||||
&fdi[drive].trackindex[side][density], NULL, density);
|
||||
if (!c)
|
||||
memset(fdi[drive].track_data[side][density], 0, fdi[drive].tracklen[side][density]);
|
||||
}
|
||||
|
||||
if (fdi[drive].sides == 1)
|
||||
{
|
||||
memset(fdi[drive].track_data[1][density], 0, 106096);
|
||||
fdi[drive].tracklen[1][density] = 100000;
|
||||
}
|
||||
}
|
||||
return(dev->trackindex[side][density]);
|
||||
}
|
||||
|
||||
uint32_t fdi_index_hole_pos(int drive, int side)
|
||||
|
||||
static uint32_t
|
||||
get_raw_size(int drive, int side)
|
||||
{
|
||||
int density;
|
||||
fdi_t *dev = fdi[drive];
|
||||
int density;
|
||||
|
||||
density = fdi_density();
|
||||
density = fdi_density();
|
||||
|
||||
return fdi[drive].trackindex[side][density];
|
||||
return(dev->tracklen[side][density]);
|
||||
}
|
||||
|
||||
uint32_t fdi_get_raw_size(int drive, int side)
|
||||
|
||||
static uint16_t *
|
||||
encoded_data(int drive, int side)
|
||||
{
|
||||
int density;
|
||||
fdi_t *dev = fdi[drive];
|
||||
int density = 0;
|
||||
|
||||
density = fdi_density();
|
||||
density = fdi_density();
|
||||
|
||||
return fdi[drive].tracklen[side][density];
|
||||
return((uint16_t *)dev->track_data[side][density]);
|
||||
}
|
||||
|
||||
uint16_t* fdi_encoded_data(int drive, int side)
|
||||
|
||||
void
|
||||
fdi_seek(int drive, int track)
|
||||
{
|
||||
int density = 0;
|
||||
fdi_t *dev = fdi[drive];
|
||||
|
||||
density = fdi_density();
|
||||
if (fdd_doublestep_40(drive)) {
|
||||
if (fdi2raw_get_tpi(dev->h) < 2)
|
||||
track /= 2;
|
||||
}
|
||||
|
||||
return (uint16_t *)fdi[drive].track_data[side][density];
|
||||
}
|
||||
d86f_set_cur_track(drive, track);
|
||||
|
||||
void d86f_register_fdi(int drive)
|
||||
{
|
||||
d86f_handler[drive].disk_flags = fdi_disk_flags;
|
||||
d86f_handler[drive].side_flags = fdi_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 = fdi_extra_bit_cells;
|
||||
d86f_handler[drive].encoded_data = fdi_encoded_data;
|
||||
d86f_handler[drive].read_revolution = fdi_read_revolution;
|
||||
d86f_handler[drive].index_hole_pos = fdi_index_hole_pos;
|
||||
d86f_handler[drive].get_raw_size = fdi_get_raw_size;
|
||||
d86f_handler[drive].check_crc = 1;
|
||||
d86f_set_version(drive, D86FVER);
|
||||
}
|
||||
if (dev->f == NULL) return;
|
||||
|
||||
void fdi_load(int drive, wchar_t *fn)
|
||||
{
|
||||
char header[26];
|
||||
|
||||
writeprot[drive] = fwriteprot[drive] = 1;
|
||||
fdi[drive].f = plat_fopen(fn, L"rb");
|
||||
if (!fdi[drive].f)
|
||||
{
|
||||
memset(floppyfns[drive], 0, sizeof(floppyfns[drive]));
|
||||
return;
|
||||
}
|
||||
|
||||
d86f_unregister(drive);
|
||||
|
||||
fread(header, 1, 25, fdi[drive].f);
|
||||
fseek(fdi[drive].f, 0, SEEK_SET);
|
||||
header[25] = 0;
|
||||
if (strcmp(header, "Formatted Disk Image file") != 0)
|
||||
{
|
||||
/* This is a Japanese FDI file. */
|
||||
pclog("fdi_load(): Japanese FDI file detected, redirecting to IMG loader\n");
|
||||
fclose(fdi[drive].f);
|
||||
fdi[drive].f = NULL;
|
||||
img_load(drive, fn);
|
||||
return;
|
||||
}
|
||||
|
||||
fdi[drive].h = fdi2raw_header(fdi[drive].f);
|
||||
fdi[drive].lasttrack = fdi2raw_get_last_track(fdi[drive].h);
|
||||
fdi[drive].sides = fdi2raw_get_last_head(fdi[drive].h) + 1;
|
||||
|
||||
d86f_register_fdi(drive);
|
||||
|
||||
drives[drive].seek = fdi_seek;
|
||||
d86f_common_handlers(drive);
|
||||
|
||||
pclog("Loaded as FDI\n");
|
||||
}
|
||||
|
||||
void fdi_close(int drive)
|
||||
{
|
||||
d86f_unregister(drive);
|
||||
drives[drive].seek = NULL;
|
||||
if (fdi[drive].h)
|
||||
fdi2raw_header_free(fdi[drive].h);
|
||||
if (fdi[drive].f)
|
||||
{
|
||||
fclose(fdi[drive].f);
|
||||
fdi[drive].f = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void fdi_seek(int drive, int track)
|
||||
{
|
||||
if (fdd_doublestep_40(drive))
|
||||
{
|
||||
if (fdi2raw_get_tpi(fdi[drive].h) < 2)
|
||||
{
|
||||
track /= 2;
|
||||
}
|
||||
}
|
||||
|
||||
d86f_set_cur_track(drive, track);
|
||||
|
||||
if (!fdi[drive].f)
|
||||
return;
|
||||
if (track < 0)
|
||||
track = 0;
|
||||
if (track < 0)
|
||||
track = 0;
|
||||
|
||||
#if 0
|
||||
if (track > fdi[drive].lasttrack)
|
||||
track = fdi[drive].lasttrack - 1;
|
||||
if (track > dev->lasttrack)
|
||||
track = dev->lasttrack - 1;
|
||||
#endif
|
||||
|
||||
fdi[drive].track = track;
|
||||
dev->track = track;
|
||||
|
||||
fdi_read_revolution(drive);
|
||||
read_revolution(drive);
|
||||
}
|
||||
|
||||
void fdi_set_fdc(void *fdc)
|
||||
|
||||
void
|
||||
fdi_load(int drive, wchar_t *fn)
|
||||
{
|
||||
fdi_fdc = (fdc_t *) fdc;
|
||||
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));
|
||||
|
||||
dev->f = plat_fopen(fn, L"rb");
|
||||
if (dev == NULL) {
|
||||
free(dev);
|
||||
memset(floppyfns[drive], 0, sizeof(floppyfns[drive]));
|
||||
return;
|
||||
}
|
||||
|
||||
d86f_unregister(drive);
|
||||
|
||||
fread(header, 1, 25, dev->f);
|
||||
fseek(dev->f, 0, SEEK_SET);
|
||||
header[25] = 0;
|
||||
if (strcmp(header, "Formatted Disk Image file") != 0) {
|
||||
/* This is a Japanese FDI file. */
|
||||
pclog("fdi_load(): Japanese FDI file detected, redirecting to IMG loader\n");
|
||||
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;
|
||||
|
||||
pclog("Loaded as FDI\n");
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
fdi_close(int drive)
|
||||
{
|
||||
fdi_t *dev = fdi[drive];
|
||||
|
||||
if (dev == NULL) return;
|
||||
|
||||
d86f_unregister(drive);
|
||||
|
||||
drives[drive].seek = NULL;
|
||||
|
||||
if (dev->h)
|
||||
fdi2raw_header_free(dev->h);
|
||||
|
||||
if (dev->f)
|
||||
fclose(dev->f);
|
||||
|
||||
/* Release the memory. */
|
||||
free(dev);
|
||||
fdi[drive] = NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
fdi_set_fdc(void *fdc)
|
||||
{
|
||||
fdi_fdc = (fdc_t *)fdc;
|
||||
}
|
||||
|
||||
@@ -1,38 +1,49 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the FDI floppy stream image format
|
||||
* interface to the FDI2RAW module.
|
||||
*
|
||||
* Version: @(#)floppy_fdi.h 1.0.3 2017/12/14
|
||||
* Version: @(#)floppy_fdi.h 1.0.2 2018/03/17
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2008-2017 Sarah Walker.
|
||||
* Copyright 2016,2017 Miran Grca.
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef EMU_FLOPPY_FDI_H
|
||||
# define EMU_FLOPPY_FDI_H
|
||||
|
||||
|
||||
extern void fdi_load(int drive, wchar_t *fn);
|
||||
extern void fdi_close(int drive);
|
||||
extern void fdi_seek(int drive, int track);
|
||||
extern void fdi_readsector(int drive, int sector, int track, int side, int density, int sector_size);
|
||||
extern void fdi_writesector(int drive, int sector, int track, int side, int density, int sector_size);
|
||||
extern void fdi_comparesector(int drive, int sector, int track, int side, int density, int sector_size);
|
||||
extern void fdi_readaddress(int drive, int sector, int side, int density);
|
||||
extern void fdi_format(int drive, int sector, int side, int density, uint8_t fill);
|
||||
extern int fdi_hole(int drive);
|
||||
extern double fdi_byteperiod(int drive);
|
||||
extern void fdi_stop(void);
|
||||
extern void fdi_poll(void);
|
||||
extern void fdi_seek(int drive, int track);
|
||||
extern void fdi_load(int drive, wchar_t *fn);
|
||||
extern void fdi_close(int drive);
|
||||
|
||||
|
||||
#endif /*EMU_FLOPPY_FDI_H*/
|
||||
|
||||
1483
src/floppy/fdd_imd.c
1483
src/floppy/fdd_imd.c
File diff suppressed because it is too large
Load Diff
@@ -1,17 +1,38 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the IMD floppy image format.
|
||||
* Definitions for the IMD floppy image format.
|
||||
*
|
||||
* Version: @(#)floppy_imd.h 1.0.2 2017/09/03
|
||||
* Version: @(#)floppy_imd.h 1.0.2 2018/03/17
|
||||
*
|
||||
* Author: Miran Grca, <mgrca8@gmail.com>
|
||||
* Copyright 2016,2017 Miran Grca.
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
*
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef EMU_FLOPPY_IMD_H
|
||||
# define EMU_FLOPPY_IMD_H
|
||||
@@ -20,7 +41,6 @@
|
||||
extern void imd_init(void);
|
||||
extern void imd_load(int drive, wchar_t *fn);
|
||||
extern void imd_close(int drive);
|
||||
extern void imd_seek(int drive, int track);
|
||||
|
||||
|
||||
#endif /*EMU_FLOPPY_IMD_H*/
|
||||
|
||||
1888
src/floppy/fdd_img.c
1888
src/floppy/fdd_img.c
File diff suppressed because it is too large
Load Diff
@@ -1,29 +1,49 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the raw sector-based floppy image format,
|
||||
* as well as the Japanese FDI, CopyQM, and FDF formats.
|
||||
*
|
||||
* Version: @(#)floppy_img.h 1.0.2 2017/09/03
|
||||
* Version: @(#)floppy_img.h 1.0.2 2018/03/17
|
||||
*
|
||||
* Authors: Sarah Walker, <http://pcem-emulator.co.uk/>
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Copyright 2008-2017 Sarah Walker.
|
||||
* Copyright 2016,2017 Miran Grca.
|
||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||
*
|
||||
* Copyright 2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
* Copyright 2008-2018 Sarah Walker.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef EMU_FLOPPY_IMG_H
|
||||
# define EMU_FLOPPY_IMG_H
|
||||
|
||||
|
||||
extern void img_init(void);
|
||||
extern void img_load(int drive, wchar_t *fn);
|
||||
extern void img_close(int drive);
|
||||
extern void img_seek(int drive, int track);
|
||||
extern void img_init(void);
|
||||
extern void img_load(int drive, wchar_t *fn);
|
||||
extern void img_close(int drive);
|
||||
|
||||
|
||||
#endif /*EMU_FLOPPY_IMG_H*/
|
||||
|
||||
@@ -1,18 +1,48 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the PCjs JSON floppy image format.
|
||||
*
|
||||
* Version: @(#)fdd_json.c 1.0.11 2018/03/14
|
||||
* Version: @(#)fdd_json.c 1.0.4 2018/03/17
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
*
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with
|
||||
* or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the entire
|
||||
* above notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names
|
||||
* of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific
|
||||
* prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -71,11 +101,11 @@ typedef struct {
|
||||
} json_t;
|
||||
|
||||
|
||||
static json_t images[FDD_NUM];
|
||||
static json_t *images[FDD_NUM];
|
||||
|
||||
|
||||
static void
|
||||
handle(json_t *img, char *name, char *str)
|
||||
handle(json_t *dev, char *name, char *str)
|
||||
{
|
||||
sector_t *sec = NULL;
|
||||
uint32_t l, pat;
|
||||
@@ -84,7 +114,7 @@ handle(json_t *img, char *name, char *str)
|
||||
int i, s;
|
||||
|
||||
/* Point to the currently selected sector. */
|
||||
sec = &img->sects[img->track][img->side][img->dmf-1];
|
||||
sec = &dev->sects[dev->track][dev->side][dev->dmf-1];
|
||||
|
||||
/* If no name given, assume sector is done. */
|
||||
if (name == NULL) {
|
||||
@@ -98,8 +128,8 @@ handle(json_t *img, char *name, char *str)
|
||||
sec->size = fdd_sector_size_code(sec->size);
|
||||
|
||||
/* Set up the rest of the Sector ID. */
|
||||
sec->track = img->track;
|
||||
sec->side = img->side;
|
||||
sec->track = dev->track;
|
||||
sec->side = dev->side;
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -159,13 +189,13 @@ unexpect(int c, int state, int level)
|
||||
|
||||
|
||||
static int
|
||||
load_image(json_t *img)
|
||||
load_image(json_t *dev)
|
||||
{
|
||||
char buff[4096], name[32];
|
||||
int c, i, j, state, level;
|
||||
char *ptr;
|
||||
|
||||
if (img->f == NULL) {
|
||||
if (dev->f == NULL) {
|
||||
pclog("JSON: no file loaded!\n");
|
||||
return(0);
|
||||
}
|
||||
@@ -173,17 +203,17 @@ load_image(json_t *img)
|
||||
/* Initialize. */
|
||||
for (i=0; i<NTRACKS; i++) {
|
||||
for (j=0; j<NSIDES; j++)
|
||||
memset(img->sects[i][j], 0x00, sizeof(sector_t));
|
||||
memset(dev->sects[i][j], 0x00, sizeof(sector_t));
|
||||
}
|
||||
img->track = img->side = img->dmf = 0; /* "dmf" is "sector#" */
|
||||
dev->track = dev->side = dev->dmf = 0; /* "dmf" is "sector#" */
|
||||
|
||||
/* Now run the state machine. */
|
||||
ptr = NULL;
|
||||
level = state = 0;
|
||||
while (state >= 0) {
|
||||
/* Get a character from the input. */
|
||||
c = fgetc(img->f);
|
||||
if ((c == EOF) || ferror(img->f)) {
|
||||
c = fgetc(dev->f);
|
||||
if ((c == EOF) || ferror(dev->f)) {
|
||||
state = -1;
|
||||
break;
|
||||
}
|
||||
@@ -191,7 +221,7 @@ load_image(json_t *img)
|
||||
/* Process it. */
|
||||
switch(state) {
|
||||
case 0: /* read level header */
|
||||
img->dmf = 1;
|
||||
dev->dmf = 1;
|
||||
if (c != '[') {
|
||||
state = unexpect(c, state, level);
|
||||
} else {
|
||||
@@ -239,7 +269,7 @@ load_image(json_t *img)
|
||||
case ',':
|
||||
case '}':
|
||||
*ptr = '\0';
|
||||
handle(img, name, buff);
|
||||
handle(dev, name, buff);
|
||||
|
||||
if (c == '}')
|
||||
state = 7; /* done */
|
||||
@@ -264,10 +294,10 @@ load_image(json_t *img)
|
||||
break;
|
||||
|
||||
case 7: /* sector done */
|
||||
handle(img, NULL, NULL);
|
||||
handle(dev, NULL, NULL);
|
||||
switch(c) {
|
||||
case ',': /* next sector */
|
||||
img->dmf++;
|
||||
dev->dmf++;
|
||||
state = 1;
|
||||
break;
|
||||
|
||||
@@ -297,14 +327,14 @@ load_image(json_t *img)
|
||||
default:
|
||||
state = unexpect(c, state, level);
|
||||
}
|
||||
img->spt[img->track][img->side] = img->dmf;
|
||||
img->side++;
|
||||
dev->spt[dev->track][dev->side] = dev->dmf;
|
||||
dev->side++;
|
||||
break;
|
||||
|
||||
case 9: /* track done */
|
||||
switch(c) {
|
||||
case ',': /* next track */
|
||||
img->side = 0;
|
||||
dev->side = 0;
|
||||
state = 0;
|
||||
break;
|
||||
|
||||
@@ -317,15 +347,15 @@ load_image(json_t *img)
|
||||
default:
|
||||
state = unexpect(c, state, level);
|
||||
}
|
||||
img->track++;
|
||||
dev->track++;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Save derived values. */
|
||||
img->tracks = img->track;
|
||||
img->sides = img->side;
|
||||
dev->tracks = dev->track;
|
||||
dev->sides = dev->side;
|
||||
|
||||
return(1);
|
||||
}
|
||||
@@ -336,69 +366,71 @@ static void
|
||||
json_seek(int drive, int track)
|
||||
{
|
||||
uint8_t id[4] = { 0,0,0,0 };
|
||||
json_t *img = &images[drive];
|
||||
json_t *dev = images[drive];
|
||||
int side, sector;
|
||||
int rate, gap2, gap3, pos;
|
||||
int ssize, rsec, asec;
|
||||
int interleave_type;
|
||||
|
||||
if (img->f == NULL) {
|
||||
if (dev->f == NULL) {
|
||||
pclog("JSON: seek: no file loaded!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Allow for doublestepping tracks. */
|
||||
if (! img->track_width && fdd_doublestep_40(drive)) track /= 2;
|
||||
if (! dev->track_width && fdd_doublestep_40(drive)) track /= 2;
|
||||
|
||||
/* Set the new track. */
|
||||
img->track = track;
|
||||
dev->track = track;
|
||||
d86f_set_cur_track(drive, track);
|
||||
|
||||
/* Reset the 86F state machine. */
|
||||
d86f_reset_index_hole_pos(drive, 0);
|
||||
d86f_reset_index_hole_pos(drive, 1);
|
||||
d86f_destroy_linked_lists(drive, 0);
|
||||
d86f_reset_index_hole_pos(drive, 1);
|
||||
d86f_destroy_linked_lists(drive, 1);
|
||||
|
||||
interleave_type = 0;
|
||||
|
||||
if (track > img->tracks) {
|
||||
if (track > dev->tracks) {
|
||||
d86f_zero_track(drive);
|
||||
return;
|
||||
}
|
||||
|
||||
for (side=0; side<img->sides; side++) {
|
||||
for (side=0; side<dev->sides; side++) {
|
||||
/* Get transfer rate for this side. */
|
||||
rate = img->track_flags & 0x07;
|
||||
if (!rate && (img->track_flags & 0x20)) rate = 4;
|
||||
rate = dev->track_flags & 0x07;
|
||||
if (!rate && (dev->track_flags & 0x20)) rate = 4;
|
||||
|
||||
/* Get correct GAP3 value for this side. */
|
||||
gap3 = fdd_get_gap3_size(rate,
|
||||
img->sects[track][side][0].size,
|
||||
img->spt[track][side]);
|
||||
dev->sects[track][side][0].size,
|
||||
dev->spt[track][side]);
|
||||
|
||||
/* Get correct GAP2 value for this side. */
|
||||
gap2 = ((img->track_flags & 0x07) >= 3) ? 41 : 22;
|
||||
gap2 = ((dev->track_flags & 0x07) >= 3) ? 41 : 22;
|
||||
|
||||
pos = d86f_prepare_pretrack(drive, side, 0);
|
||||
|
||||
for (sector=0; sector<img->spt[track][side]; sector++) {
|
||||
for (sector=0; sector<dev->spt[track][side]; sector++) {
|
||||
if (interleave_type == 0) {
|
||||
rsec = img->sects[track][side][sector].sector;
|
||||
rsec = dev->sects[track][side][sector].sector;
|
||||
asec = sector;
|
||||
} else {
|
||||
rsec = fdd_dmf_r[sector];
|
||||
asec = img->interleave_ordered[rsec][side];
|
||||
asec = dev->interleave_ordered[rsec][side];
|
||||
}
|
||||
id[0] = track;
|
||||
id[1] = side;
|
||||
id[2] = rsec;
|
||||
id[3] = img->sects[track][side][asec].size;
|
||||
ssize = fdd_sector_code_size(img->sects[track][side][asec].size);
|
||||
if (dev->sects[track][side][asec].size > 255)
|
||||
perror("fdd_json.c: json_seek: sector size too big.");
|
||||
id[3] = dev->sects[track][side][asec].size & 0xff;
|
||||
ssize = fdd_sector_code_size(dev->sects[track][side][asec].size & 0xff);
|
||||
|
||||
pos = d86f_prepare_sector(
|
||||
drive, side, pos, id,
|
||||
img->sects[track][side][asec].data,
|
||||
dev->sects[track][side][asec].data,
|
||||
ssize, gap2, gap3,
|
||||
0, /*deleted flag*/
|
||||
0 /*bad_crc flag*/
|
||||
@@ -414,38 +446,42 @@ json_seek(int drive, int track)
|
||||
static uint16_t
|
||||
disk_flags(int drive)
|
||||
{
|
||||
return(images[drive].disk_flags);
|
||||
json_t *dev = images[drive];
|
||||
|
||||
return(dev->disk_flags);
|
||||
}
|
||||
|
||||
|
||||
static uint16_t
|
||||
track_flags(int drive)
|
||||
{
|
||||
return(images[drive].track_flags);
|
||||
json_t *dev = images[drive];
|
||||
|
||||
return(dev->track_flags);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
set_sector(int drive, int side, uint8_t c, uint8_t h, uint8_t r, uint8_t n)
|
||||
{
|
||||
json_t *img = &images[drive];
|
||||
json_t *dev = images[drive];
|
||||
int i;
|
||||
|
||||
img->sector[side] = 0;
|
||||
dev->sector[side] = 0;
|
||||
|
||||
/* Make sure we are on the desired track. */
|
||||
if (c != img->track) return;
|
||||
if (c != dev->track) return;
|
||||
|
||||
/* Set the desired side. */
|
||||
img->side = side;
|
||||
dev->side = side;
|
||||
|
||||
/* Now loop over all sector ID's on this side to find our sector. */
|
||||
for (i=0; i<img->spt[c][side]; i++) {
|
||||
if ((img->sects[img->track][side][i].track == c) &&
|
||||
(img->sects[img->track][side][i].side == h) &&
|
||||
(img->sects[img->track][side][i].sector == r) &&
|
||||
(img->sects[img->track][side][i].size == n)) {
|
||||
img->sector[side] = i;
|
||||
for (i=0; i<dev->spt[c][side]; i++) {
|
||||
if ((dev->sects[dev->track][side][i].track == c) &&
|
||||
(dev->sects[dev->track][side][i].side == h) &&
|
||||
(dev->sects[dev->track][side][i].sector == r) &&
|
||||
(dev->sects[dev->track][side][i].size == n)) {
|
||||
dev->sector[side] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -454,10 +490,10 @@ set_sector(int drive, int side, uint8_t c, uint8_t h, uint8_t r, uint8_t n)
|
||||
static uint8_t
|
||||
poll_read_data(int drive, int side, uint16_t pos)
|
||||
{
|
||||
json_t *img = &images[drive];
|
||||
uint8_t sec = img->sector[side];
|
||||
json_t *dev = images[drive];
|
||||
uint8_t sec = dev->sector[side];
|
||||
|
||||
return(img->sects[img->track][side][sec].data[pos]);
|
||||
return(dev->sects[dev->track][side][sec].data[pos]);
|
||||
}
|
||||
|
||||
|
||||
@@ -471,21 +507,23 @@ json_init(void)
|
||||
void
|
||||
json_load(int drive, wchar_t *fn)
|
||||
{
|
||||
json_t *img = &images[drive];
|
||||
sector_t *sec;
|
||||
double bit_rate;
|
||||
int temp_rate;
|
||||
sector_t *sec;
|
||||
json_t *dev;
|
||||
int i;
|
||||
|
||||
/* Just in case- remove ourselves from 86F. */
|
||||
d86f_unregister(drive);
|
||||
|
||||
/* Zap any old data. */
|
||||
memset(img, 0x00, sizeof(json_t));
|
||||
/* Allocate a drive block. */
|
||||
dev = (json_t *)malloc(sizeof(json_t));
|
||||
memset(dev, 0x00, sizeof(json_t));
|
||||
|
||||
/* Open the image file. */
|
||||
img->f = plat_fopen(fn, L"rb");
|
||||
if (img->f == NULL) {
|
||||
dev->f = plat_fopen(fn, L"rb");
|
||||
if (dev->f == NULL) {
|
||||
free(dev);
|
||||
memset(fn, 0x00, sizeof(wchar_t));
|
||||
return;
|
||||
}
|
||||
@@ -493,66 +531,70 @@ json_load(int drive, wchar_t *fn)
|
||||
/* Our images are always RO. */
|
||||
writeprot[drive] = 1;
|
||||
|
||||
/* Set up the drive unit. */
|
||||
images[drive] = dev;
|
||||
|
||||
/* Load all sectors from the image file. */
|
||||
if (! load_image(img)) {
|
||||
if (! load_image(dev)) {
|
||||
pclog("JSON: failed to initialize\n");
|
||||
(void)fclose(img->f);
|
||||
img->f = NULL;
|
||||
(void)fclose(dev->f);
|
||||
free(dev);
|
||||
images[drive] = NULL;
|
||||
memset(fn, 0x00, sizeof(wchar_t));
|
||||
return;
|
||||
}
|
||||
|
||||
pclog("JSON(%d): %ls (%i tracks, %i sides, %i sectors)\n",
|
||||
drive, fn, img->tracks, img->sides, img->spt[0][0]);
|
||||
drive, fn, dev->tracks, dev->sides, dev->spt[0][0]);
|
||||
|
||||
/*
|
||||
* If the image has more than 43 tracks, then
|
||||
* the tracks are thin (96 tpi).
|
||||
*/
|
||||
img->track_width = (img->tracks > 43) ? 1 : 0;
|
||||
dev->track_width = (dev->tracks > 43) ? 1 : 0;
|
||||
|
||||
/* If the image has 2 sides, mark it as such. */
|
||||
img->disk_flags = 0x00;
|
||||
if (img->sides == 2)
|
||||
img->disk_flags |= 0x08;
|
||||
dev->disk_flags = 0x00;
|
||||
if (dev->sides == 2)
|
||||
dev->disk_flags |= 0x08;
|
||||
|
||||
/* JSON files are always assumed to be MFM-encoded. */
|
||||
img->track_flags = 0x08;
|
||||
dev->track_flags = 0x08;
|
||||
|
||||
img->interleave = 0;
|
||||
dev->interleave = 0;
|
||||
#if 0
|
||||
img->skew = 0;
|
||||
dev->skew = 0;
|
||||
#endif
|
||||
|
||||
temp_rate = 0xff;
|
||||
sec = &img->sects[0][0][0];
|
||||
sec = &dev->sects[0][0][0];
|
||||
for (i=0; i<6; i++) {
|
||||
if (img->spt[0][0] > fdd_max_sectors[sec->size][i]) continue;
|
||||
if (dev->spt[0][0] > fdd_max_sectors[sec->size][i]) continue;
|
||||
|
||||
bit_rate = fdd_bit_rates_300[i];
|
||||
temp_rate = fdd_rates[i];
|
||||
img->disk_flags |= (fdd_holes[i] << 1);
|
||||
dev->disk_flags |= (fdd_holes[i] << 1);
|
||||
|
||||
if ((bit_rate == 500.0) && (img->spt[0][0] == 21) &&
|
||||
(sec->size == 2) && (img->tracks >= 80) &&
|
||||
(img->tracks <= 82) && (img->sides == 2)) {
|
||||
if ((bit_rate == 500.0) && (dev->spt[0][0] == 21) &&
|
||||
(sec->size == 2) && (dev->tracks >= 80) &&
|
||||
(dev->tracks <= 82) && (dev->sides == 2)) {
|
||||
/*
|
||||
* This is a DMF floppy, set the flag so
|
||||
* we know to interleave the sectors.
|
||||
*/
|
||||
img->dmf = 1;
|
||||
dev->dmf = 1;
|
||||
} else {
|
||||
if ((bit_rate == 500.0) && (img->spt[0][0] == 22) &&
|
||||
(sec->size == 2) && (img->tracks >= 80) &&
|
||||
(img->tracks <= 82) && (img->sides == 2)) {
|
||||
if ((bit_rate == 500.0) && (dev->spt[0][0] == 22) &&
|
||||
(sec->size == 2) && (dev->tracks >= 80) &&
|
||||
(dev->tracks <= 82) && (dev->sides == 2)) {
|
||||
/*
|
||||
* This is marked specially because of the
|
||||
* track flag (a RPM slow down is needed).
|
||||
*/
|
||||
img->interleave = 2;
|
||||
dev->interleave = 2;
|
||||
}
|
||||
|
||||
img->dmf = 0;
|
||||
dev->dmf = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -560,41 +602,44 @@ json_load(int drive, wchar_t *fn)
|
||||
|
||||
if (temp_rate == 0xff) {
|
||||
pclog("JSON: invalid image (temp_rate=0xff)\n");
|
||||
(void)fclose(img->f);
|
||||
img->f = NULL;
|
||||
(void)fclose(dev->f);
|
||||
dev->f = NULL;
|
||||
free(dev);
|
||||
images[drive] = NULL;
|
||||
memset(fn, 0x00, sizeof(wchar_t));
|
||||
return;
|
||||
}
|
||||
|
||||
if (img->interleave == 2) {
|
||||
img->interleave = 1;
|
||||
img->disk_flags |= 0x60;
|
||||
if (dev->interleave == 2) {
|
||||
dev->interleave = 1;
|
||||
dev->disk_flags |= 0x60;
|
||||
}
|
||||
|
||||
img->gap2_len = (temp_rate == 3) ? 41 : 22;
|
||||
if (img->dmf) {
|
||||
img->gap3_len = 8;
|
||||
} else {
|
||||
img->gap3_len = fdd_get_gap3_size(temp_rate,sec->size,img->spt[0][0]);
|
||||
}
|
||||
dev->gap2_len = (temp_rate == 3) ? 41 : 22;
|
||||
if (dev->dmf)
|
||||
dev->gap3_len = 8;
|
||||
else
|
||||
dev->gap3_len = fdd_get_gap3_size(temp_rate,sec->size,dev->spt[0][0]);
|
||||
|
||||
if (! img->gap3_len) {
|
||||
if (! dev->gap3_len) {
|
||||
pclog("JSON: image of unknown format was inserted into drive %c:!\n",
|
||||
'C'+drive);
|
||||
(void)fclose(img->f);
|
||||
img->f = NULL;
|
||||
(void)fclose(dev->f);
|
||||
dev->f = NULL;
|
||||
free(dev);
|
||||
images[drive] = NULL;
|
||||
memset(fn, 0x00, sizeof(wchar_t));
|
||||
return;
|
||||
}
|
||||
|
||||
img->track_flags |= (temp_rate & 0x03); /* data rate */
|
||||
dev->track_flags |= (temp_rate & 0x03); /* data rate */
|
||||
if (temp_rate & 0x04)
|
||||
img->track_flags |= 0x20; /* RPM */
|
||||
dev->track_flags |= 0x20; /* RPM */
|
||||
|
||||
pclog(" disk_flags: 0x%02x, track_flags: 0x%02x, GAP3 length: %i\n",
|
||||
img->disk_flags, img->track_flags, img->gap3_len);
|
||||
dev->disk_flags, dev->track_flags, dev->gap3_len);
|
||||
pclog(" bit rate 300: %.2f, temporary rate: %i, hole: %i, DMF: %i\n",
|
||||
bit_rate, temp_rate, (img->disk_flags >> 1), img->dmf);
|
||||
bit_rate, temp_rate, (dev->disk_flags >> 1), dev->dmf);
|
||||
|
||||
/* Set up handlers for 86F layer. */
|
||||
d86f_handler[drive].disk_flags = disk_flags;
|
||||
@@ -622,26 +667,30 @@ json_load(int drive, wchar_t *fn)
|
||||
void
|
||||
json_close(int drive)
|
||||
{
|
||||
json_t *img = &images[drive];
|
||||
json_t *dev = images[drive];
|
||||
int t, h, s;
|
||||
|
||||
if (dev == NULL) return;
|
||||
|
||||
/* Unlink image from the system. */
|
||||
d86f_unregister(drive);
|
||||
|
||||
/* Release all the sector buffers. */
|
||||
for (t=0; t<256; t++) {
|
||||
for (h=0; h<2; h++) {
|
||||
memset(img->sects[t][h], 0x00, sizeof(sector_t));
|
||||
memset(dev->sects[t][h], 0x00, sizeof(sector_t));
|
||||
for (s=0; s<256; s++) {
|
||||
if (img->sects[t][h][s].data != NULL)
|
||||
free(img->sects[t][h][s].data);
|
||||
img->sects[t][h][s].data = NULL;
|
||||
if (dev->sects[t][h][s].data != NULL)
|
||||
free(dev->sects[t][h][s].data);
|
||||
dev->sects[t][h][s].data = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (img->f != NULL) {
|
||||
(void)fclose(img->f);
|
||||
img->f = NULL;
|
||||
}
|
||||
if (dev->f != NULL)
|
||||
(void)fclose(dev->f);
|
||||
|
||||
/* Release the memory. */
|
||||
free(dev);
|
||||
images[drive] = NULL;
|
||||
}
|
||||
|
||||
@@ -1,26 +1,56 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the PCjs JSON floppy image format.
|
||||
* Definitions for the PCjs JSON floppy image format.
|
||||
*
|
||||
* Version: @(#)floppy_json.h 1.0.1 2017/09/06
|
||||
* Version: @(#)floppy_json.h 1.0.2 2018/03/17
|
||||
*
|
||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Copyright 2017 Fred N. van Kempen.
|
||||
*
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with
|
||||
* or without modification, are permitted provided that the
|
||||
* following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the entire
|
||||
* above notice, this list of conditions and the following
|
||||
* disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer in the documentation and/or other
|
||||
* materials provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names
|
||||
* of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific
|
||||
* prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#ifndef EMU_FLOPPY_JSON_H
|
||||
# define EMU_FLOPPY_JSON_H
|
||||
|
||||
|
||||
//extern void json_init(void);
|
||||
extern void json_init(void);
|
||||
extern void json_load(int drive, wchar_t *fn);
|
||||
extern void json_close(int drive);
|
||||
//extern void json_seek(int drive, int track);
|
||||
|
||||
|
||||
#endif /*EMU_FLOPPY_JSON_H*/
|
||||
|
||||
2129
src/floppy/fdd_td0.c
2129
src/floppy/fdd_td0.c
File diff suppressed because it is too large
Load Diff
@@ -1,25 +1,38 @@
|
||||
/*
|
||||
* 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.
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the 86Box distribution.
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Implementation of the Teledisk floppy image format.
|
||||
* Definitions for the Teledisk floppy image format.
|
||||
*
|
||||
* Version: @(#)floppy_td0.h 1.0.2 2017/09/03
|
||||
* Version: @(#)floppy_td0.h 1.0.2 2018/03/17
|
||||
*
|
||||
* Authors: Milodrag Milanovic,
|
||||
* Haruhiko OKUMURA,
|
||||
* Haruyasu YOSHIZAKI,
|
||||
* Kenji RIKITAKE,
|
||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||
* Miran Grca, <mgrca8@gmail.com>
|
||||
* Copyright 1988-2017 Haruhiko OKUMURA.
|
||||
* Copyright 1988-2017 Haruyasu YOSHIZAKI.
|
||||
* Copyright 1988-2017 Kenji RIKITAKE.
|
||||
* Copyright 2013-2017 Milodrag Milanovic.
|
||||
* Copyright 2016,2017 Miran Grca.
|
||||
*
|
||||
* Copyright 2017,2018 Fred N. van Kempen.
|
||||
* Copyright 2016-2018 Miran Grca.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef EMU_FLOPPY_TD0_H
|
||||
# define EMU_FLOPPY_TD0_H
|
||||
@@ -28,7 +41,6 @@
|
||||
extern void td0_init(void);
|
||||
extern void td0_load(int drive, wchar_t *fn);
|
||||
extern void td0_close(int drive);
|
||||
extern void td0_seek(int drive, int track);
|
||||
|
||||
|
||||
#endif /*EMU_FLOPPY_TD0_H*/
|
||||
|
||||
@@ -1,22 +1,45 @@
|
||||
/* Copyright holders: Toni Wilen
|
||||
see COPYING for more details
|
||||
*/
|
||||
/*
|
||||
|
||||
FDI to raw bit stream converter
|
||||
Copyright (c) 2001 by Toni Wilen <twilen@arabuusimiehet.com>
|
||||
FDI 2.0 support
|
||||
Copyright (c) 2003-2004 by Toni Wilen <twilen@arabuusimiehet.com>
|
||||
and Vincent Joguin
|
||||
|
||||
FDI format created by Vincent "ApH" Joguin
|
||||
|
||||
Tiny changes - function type fixes, multiple drives, addition of
|
||||
get_last_head and C++ callability - by Thomas Harte, 2001,
|
||||
T.Harte@excite.co.uk
|
||||
|
||||
*/
|
||||
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* FDI to raw bit stream converter
|
||||
* FDI format created by Vincent "ApH" Joguin
|
||||
* Tiny changes - function type fixes, multiple drives,
|
||||
* addition of get_last_head and C++ callability by Thomas
|
||||
* Harte.
|
||||
*
|
||||
* Version: @(#)fdi2raw.c 1.0.2 2018/03/12
|
||||
*
|
||||
* Authors: Toni Wilen, <twilen@arabuusimiehet.com>
|
||||
* and Vincent Joguin,
|
||||
* Thomas Harte, <T.Harte@excite.co.uk>
|
||||
*
|
||||
* Copyright 2001-2004 Toni Wilen.
|
||||
* Copyright 2001-2004 Vincent Joguin.
|
||||
* Copyright 2001 Thomas Harte.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#define STATIC_INLINE
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
@@ -1857,7 +1880,7 @@ static int decode_lowlevel_track (FDI *fdi, int track, struct fdi_cache *cache)
|
||||
indexoffset = 0;
|
||||
p1 = idxp;
|
||||
for (i = 0; i < pulses; i++) {
|
||||
if (p1[idx_off1] + p1[idx_off2] > maxidx)
|
||||
if ((uint32_t)p1[idx_off1] + (uint32_t)p1[idx_off2] > maxidx)
|
||||
maxidx = p1[idx_off1] + p1[idx_off2];
|
||||
p1 += idx_off3;
|
||||
}
|
||||
@@ -1893,7 +1916,7 @@ static int decode_lowlevel_track (FDI *fdi, int track, struct fdi_cache *cache)
|
||||
totalavg = 0;
|
||||
weakbits = 0;
|
||||
for (i = 0; i < pulses; i++) {
|
||||
int sum = p1[idx_off1] + p1[idx_off2];
|
||||
uint32_t sum = p1[idx_off1] + p1[idx_off2];
|
||||
if (sum >= maxidx) {
|
||||
totalavg += *p2;
|
||||
} else {
|
||||
|
||||
@@ -1,6 +1,41 @@
|
||||
/* Copyright holders: Toni Wilen
|
||||
see COPYING for more details
|
||||
*/
|
||||
/*
|
||||
* VARCem Virtual ARchaeological Computer EMulator.
|
||||
* An emulator of (mostly) x86-based PC systems and devices,
|
||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
||||
* spanning the era between 1981 and 1995.
|
||||
*
|
||||
* This file is part of the VARCem Project.
|
||||
*
|
||||
* Definitions for the FDI floppy file format.
|
||||
*
|
||||
* Version: @(#)fdi2raw.h 1.0.1 2018/02/14
|
||||
*
|
||||
* Authors: Toni Wilen, <twilen@arabuusimiehet.com>
|
||||
* and Vincent Joguin,
|
||||
* Thomas Harte, <T.Harte@excite.co.uk>
|
||||
*
|
||||
* Copyright 2001-2004 Toni Wilen.
|
||||
* Copyright 2001-2004 Vincent Joguin.
|
||||
* Copyright 2001 Thomas Harte.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the:
|
||||
*
|
||||
* Free Software Foundation, Inc.
|
||||
* 59 Temple Place - Suite 330
|
||||
* Boston, MA 02111-1307
|
||||
* USA.
|
||||
*/
|
||||
#ifndef __FDI2RAW_H
|
||||
#define __FDI2RAW_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user