Floppy fixes to handle TD0 and IMD images with some kinds of copy protection, fixes eg. F-19 Stealth Fighter from 1988.
This commit is contained in:
@@ -1,39 +1,21 @@
|
|||||||
/*
|
/*
|
||||||
* VARCem Virtual ARchaeological Computer EMulator.
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||||
* An emulator of (mostly) x86-based PC systems and devices,
|
* running old operating systems and software designed for IBM
|
||||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
* PC systems and compatibles from 1981 through fairly recent
|
||||||
* spanning the era between 1981 and 1995.
|
* system designs based on the PCI bus.
|
||||||
*
|
*
|
||||||
* This file is part of the VARCem Project.
|
* This file is part of the 86Box distribution.
|
||||||
*
|
*
|
||||||
* Implementation of the NEC uPD-765 and compatible floppy disk
|
* Implementation of the NEC uPD-765 and compatible floppy disk
|
||||||
* controller.
|
* controller.
|
||||||
*
|
*
|
||||||
* Version: @(#)fdc.c 1.0.21 2019/10/20
|
* Version: @(#)fdc.c 1.0.21 2019/10/20
|
||||||
*
|
*
|
||||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
* Authors: Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
*
|
*
|
||||||
* Copyright 2016-2019 Miran Grca.
|
|
||||||
* Copyright 2008-2019 Sarah Walker.
|
* Copyright 2008-2019 Sarah Walker.
|
||||||
*
|
* Copyright 2016-2019 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.
|
|
||||||
*/
|
*/
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|||||||
@@ -1,41 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* VARCem Virtual ARchaeological Computer EMulator.
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||||
* An emulator of (mostly) x86-based PC systems and devices,
|
* running old operating systems and software designed for IBM
|
||||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
* PC systems and compatibles from 1981 through fairly recent
|
||||||
* spanning the era between 1981 and 1995.
|
* system designs based on the PCI bus.
|
||||||
*
|
*
|
||||||
* This file is part of the VARCem Project.
|
* This file is part of the 86Box distribution.
|
||||||
*
|
*
|
||||||
* Implementation of the NEC uPD-765 and compatible floppy disk
|
* Implementation of the NEC uPD-765 and compatible floppy disk
|
||||||
* controller.
|
* controller.
|
||||||
*
|
*
|
||||||
* Version: @(#)fdc.h 1.0.8 2019/10/20
|
* Version: @(#)fdc.h 1.0.8 2019/10/20
|
||||||
*
|
*
|
||||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
* Authors: Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
*
|
*
|
||||||
* Copyright 2016-2019 Miran Grca.
|
|
||||||
* Copyright 2008-2019 Sarah Walker.
|
* Copyright 2008-2019 Sarah Walker.
|
||||||
|
* Copyright 2016-2019 Miran Grca.
|
||||||
* Copyright 2018,2019 Fred N. van Kempen.
|
* Copyright 2018,2019 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 EMU_FDC_H
|
#ifndef EMU_FDC_H
|
||||||
# define EMU_FDC_H
|
# define EMU_FDC_H
|
||||||
|
|||||||
@@ -1,40 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
* VARCem Virtual ARchaeological Computer EMulator.
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||||
* An emulator of (mostly) x86-based PC systems and devices,
|
* running old operating systems and software designed for IBM
|
||||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
* PC systems and compatibles from 1981 through fairly recent
|
||||||
* spanning the era between 1981 and 1995.
|
* system designs based on the PCI bus.
|
||||||
*
|
*
|
||||||
* This file is part of the VARCem Project.
|
* This file is part of the 86Box distribution.
|
||||||
*
|
*
|
||||||
* Implementation of the floppy drive emulation.
|
* Implementation of the floppy drive emulation.
|
||||||
*
|
*
|
||||||
* Version: @(#)fdd.c 1.0.15 2019/10/20
|
* Version: @(#)fdd.c 1.0.15 2019/10/20
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
*
|
*
|
||||||
* Copyright 2018,2019 Fred N. van Kempen.
|
|
||||||
* Copyright 2016-2019 Miran Grca.
|
|
||||||
* Copyright 2008-2019 Sarah Walker.
|
* Copyright 2008-2019 Sarah Walker.
|
||||||
*
|
* Copyright 2016-2019 Miran Grca.
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* Copyright 2018,2019 Fred N. van Kempen.
|
||||||
* 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 <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|||||||
@@ -1,40 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
* VARCem Virtual ARchaeological Computer EMulator.
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||||
* An emulator of (mostly) x86-based PC systems and devices,
|
* running old operating systems and software designed for IBM
|
||||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
* PC systems and compatibles from 1981 through fairly recent
|
||||||
* spanning the era between 1981 and 1995.
|
* system designs based on the PCI bus.
|
||||||
*
|
*
|
||||||
* This file is part of the VARCem Project.
|
* This file is part of the 86Box distribution.
|
||||||
*
|
*
|
||||||
* Definitions for the floppy drive emulation.
|
* Definitions for the floppy drive emulation.
|
||||||
*
|
*
|
||||||
* Version: @(#)fdd.h 1.0.6 2019/02/11
|
* Version: @(#)fdd.h 1.0.7 2019/12/05
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
*
|
*
|
||||||
* Copyright 2018 Fred N. van Kempen.
|
|
||||||
* Copyright 2016-2018 Miran Grca.
|
|
||||||
* Copyright 2008-2018 Sarah Walker.
|
* Copyright 2008-2018 Sarah Walker.
|
||||||
*
|
* Copyright 2016-2018 Miran Grca.
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* Copyright 2018 Fred N. van Kempen.
|
||||||
* 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
|
#ifndef EMU_FDD_H
|
||||||
# define EMU_FDD_H
|
# define EMU_FDD_H
|
||||||
@@ -174,39 +156,6 @@ typedef struct {
|
|||||||
} d86f_handler_t;
|
} d86f_handler_t;
|
||||||
|
|
||||||
extern const int gap3_sizes[5][8][48];
|
extern const int gap3_sizes[5][8][48];
|
||||||
extern d86f_handler_t d86f_handler[FDD_NUM];
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
extern const uint8_t dmf_r[21];
|
extern const uint8_t dmf_r[21];
|
||||||
extern const uint8_t xdf_physical_sectors[2][2];
|
extern const uint8_t xdf_physical_sectors[2][2];
|
||||||
|
|||||||
@@ -1,40 +1,22 @@
|
|||||||
/*
|
/*
|
||||||
* VARCem Virtual ARchaeological Computer EMulator.
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||||
* An emulator of (mostly) x86-based PC systems and devices,
|
* running old operating systems and software designed for IBM
|
||||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
* PC systems and compatibles from 1981 through fairly recent
|
||||||
* spanning the era between 1981 and 1995.
|
* system designs based on the PCI bus.
|
||||||
*
|
*
|
||||||
* This file is part of the VARCem Project.
|
* This file is part of the 86Box distribution.
|
||||||
*
|
*
|
||||||
* Implementation of the 86F floppy image format (stores the
|
* Implementation of the 86F floppy image format (stores the
|
||||||
* data in the form of FM/MFM-encoded transitions) which also
|
* data in the form of FM/MFM-encoded transitions) which also
|
||||||
* forms the core of the emulator's floppy disk emulation.
|
* forms the core of the emulator's floppy disk emulation.
|
||||||
*
|
*
|
||||||
* Version: @(#)fdd_86f.c 1.0.18 2019/11/08
|
* Version: @(#)fdd_86f.c 1.0.19 2019/12/05
|
||||||
*
|
*
|
||||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||||
* Fred N. van Kempen, <decwiz@yahoo.com>
|
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
*
|
*
|
||||||
* Copyright 2016-2019 Miran Grca.
|
* Copyright 2016-2019 Miran Grca.
|
||||||
* Copyright 2018,2019 Fred N. van Kempen.
|
* Copyright 2018,2019 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 <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -174,6 +156,7 @@ typedef union {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t c, h, r, n;
|
uint8_t c, h, r, n;
|
||||||
|
uint8_t flags, pad, pad0, pad1;
|
||||||
void *prev;
|
void *prev;
|
||||||
} sector_t;
|
} sector_t;
|
||||||
|
|
||||||
@@ -1601,14 +1584,17 @@ d86f_read_sector_data(int drive, int side)
|
|||||||
/* We've got a byte. */
|
/* We've got a byte. */
|
||||||
d86f_log("86F: We've got a byte.\n");
|
d86f_log("86F: We've got a byte.\n");
|
||||||
if (dev->data_find.bytes_obtained < sector_len) {
|
if (dev->data_find.bytes_obtained < sector_len) {
|
||||||
|
if (d86f_handler[drive].read_data != NULL)
|
||||||
|
data = d86f_handler[drive].read_data(drive, side, dev->data_find.bytes_obtained);
|
||||||
|
else {
|
||||||
#ifdef HACK_FOR_DBASE_III
|
#ifdef HACK_FOR_DBASE_III
|
||||||
if ((dev->last_sector.id.c == 39) && (dev->last_sector.id.h == 0) &&
|
if ((dev->last_sector.id.c == 39) && (dev->last_sector.id.h == 0) &&
|
||||||
(dev->last_sector.id.r == 5) && (dev->data_find.bytes_obtained >= 272)) {
|
(dev->last_sector.id.r == 5) && (dev->data_find.bytes_obtained >= 272))
|
||||||
pclog("Randomly generating sector 39,0,5 byte %i...\n", dev->data_find.bytes_obtained);
|
|
||||||
data = (random_generate() & 0xff);
|
data = (random_generate() & 0xff);
|
||||||
} else
|
else
|
||||||
#endif
|
#endif
|
||||||
data = decodefm(drive, dev->last_word[side]);
|
data = decodefm(drive, dev->last_word[side]);
|
||||||
|
}
|
||||||
if (dev->state == STATE_11_SCAN_DATA) {
|
if (dev->state == STATE_11_SCAN_DATA) {
|
||||||
/* Scan/compare command. */
|
/* Scan/compare command. */
|
||||||
recv_data = d86f_get_data(drive, 0);
|
recv_data = d86f_get_data(drive, 0);
|
||||||
@@ -1643,7 +1629,7 @@ d86f_read_sector_data(int drive, int side)
|
|||||||
fdc_track_finishread(d86f_fdc, dev->error_condition);
|
fdc_track_finishread(d86f_fdc, dev->error_condition);
|
||||||
} else {
|
} else {
|
||||||
/* CRC is valid. */
|
/* CRC is valid. */
|
||||||
d86f_log("86F: Data CRC OK: %04X != %04X (%08X)\n", dev->track_crc.word, dev->calc_crc.word, dev->last_sector.dword);
|
d86f_log("86F: Data CRC OK: %04X == %04X (%08X)\n", dev->track_crc.word, dev->calc_crc.word, dev->last_sector.dword);
|
||||||
dev->data_find.sync_marks = dev->data_find.bits_obtained = dev->data_find.bytes_obtained = 0;
|
dev->data_find.sync_marks = dev->data_find.bits_obtained = dev->data_find.bytes_obtained = 0;
|
||||||
dev->error_condition = 0;
|
dev->error_condition = 0;
|
||||||
dev->state = STATE_IDLE;
|
dev->state = STATE_IDLE;
|
||||||
@@ -2149,6 +2135,28 @@ d86f_initialize_last_sector_id(int drive, int c, int h, int r, int n)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static uint8_t
|
||||||
|
d86f_sector_flags(int drive, int side, uint8_t c, uint8_t h, uint8_t r, uint8_t n)
|
||||||
|
{
|
||||||
|
d86f_t *dev = d86f[drive];
|
||||||
|
sector_t *s, *t;
|
||||||
|
|
||||||
|
if (dev->last_side_sector[side]) {
|
||||||
|
s = dev->last_side_sector[side];
|
||||||
|
while (s) {
|
||||||
|
if ((s->c == c) && (s->h == h) && (s->r == r) && (s->n == n))
|
||||||
|
return s->flags;
|
||||||
|
if (! s->prev)
|
||||||
|
break;
|
||||||
|
t = s->prev;
|
||||||
|
s = t;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
d86f_turbo_read(int drive, int side)
|
d86f_turbo_read(int drive, int side)
|
||||||
{
|
{
|
||||||
@@ -2156,8 +2164,12 @@ d86f_turbo_read(int drive, int side)
|
|||||||
uint8_t dat = 0;
|
uint8_t dat = 0;
|
||||||
int recv_data = 0;
|
int recv_data = 0;
|
||||||
int read_status = 0;
|
int read_status = 0;
|
||||||
|
uint8_t flags = d86f_sector_flags(drive, side, dev->req_sector.id.c, dev->req_sector.id.h, dev->req_sector.id.r, dev->req_sector.id.n);
|
||||||
|
|
||||||
|
if (d86f_handler[drive].read_data != NULL)
|
||||||
dat = d86f_handler[drive].read_data(drive, side, dev->turbo_pos);
|
dat = d86f_handler[drive].read_data(drive, side, dev->turbo_pos);
|
||||||
|
else
|
||||||
|
dat = (random_generate() & 0xff);
|
||||||
dev->turbo_pos++;
|
dev->turbo_pos++;
|
||||||
|
|
||||||
if (dev->state == STATE_11_SCAN_DATA) {
|
if (dev->state == STATE_11_SCAN_DATA) {
|
||||||
@@ -2175,14 +2187,29 @@ d86f_turbo_read(int drive, int side)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dev->turbo_pos >= (128 << dev->last_sector.id.n)) {
|
if (dev->turbo_pos >= (128 << dev->last_sector.id.n)) {
|
||||||
/* CRC is valid. */
|
|
||||||
dev->data_find.sync_marks = dev->data_find.bits_obtained = dev->data_find.bytes_obtained = 0;
|
dev->data_find.sync_marks = dev->data_find.bits_obtained = dev->data_find.bytes_obtained = 0;
|
||||||
|
if ((flags & SECTOR_CRC_ERROR) && (dev->state != STATE_02_READ_DATA)) {
|
||||||
|
#ifdef ENABLE_D86F_LOG
|
||||||
|
d86f_log("86F: Data CRC error in turbo mode\n");
|
||||||
|
#endif
|
||||||
dev->error_condition = 0;
|
dev->error_condition = 0;
|
||||||
if (dev->state == STATE_11_SCAN_DATA) {
|
|
||||||
dev->state = STATE_IDLE;
|
dev->state = STATE_IDLE;
|
||||||
fdc_sector_finishcompare(d86f_fdc, (dev->satisfying_bytes == ((128 << ((uint32_t) dev->last_sector.id.n)) - 1)) ? 1 : 0);
|
fdc_finishread(d86f_fdc);
|
||||||
|
fdc_datacrcerror(d86f_fdc);
|
||||||
|
} else if ((dev->calc_crc.word != dev->track_crc.word) && (dev->state == STATE_02_READ_DATA)) {
|
||||||
|
dev->error_condition |= 2; /* Mark that there was a data error. */
|
||||||
|
dev->state = STATE_IDLE;
|
||||||
|
fdc_track_finishread(d86f_fdc, dev->error_condition);
|
||||||
} else {
|
} else {
|
||||||
|
/* CRC is valid. */
|
||||||
|
#ifdef ENABLE_D86F_LOG
|
||||||
|
d86f_log("86F: Data CRC OK error in turbo mode\n");
|
||||||
|
#endif
|
||||||
|
dev->error_condition = 0;
|
||||||
dev->state = STATE_IDLE;
|
dev->state = STATE_IDLE;
|
||||||
|
if (dev->state == STATE_11_SCAN_DATA)
|
||||||
|
fdc_sector_finishcompare(d86f_fdc, (dev->satisfying_bytes == ((128 << ((uint32_t) dev->last_sector.id.n)) - 1)) ? 1 : 0);
|
||||||
|
else
|
||||||
fdc_sector_finishread(d86f_fdc);
|
fdc_sector_finishread(d86f_fdc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2307,11 +2334,8 @@ d86f_turbo_poll(int drive, int side)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
case STATE_02_FIND_ID:
|
case STATE_02_FIND_ID:
|
||||||
if (! d86f_sector_is_present(drive, side,
|
if (! d86f_sector_is_present(drive, side, fdc_get_read_track_sector(d86f_fdc).id.c, fdc_get_read_track_sector(d86f_fdc).id.h,
|
||||||
fdc_get_read_track_sector(d86f_fdc).id.c,
|
fdc_get_read_track_sector(d86f_fdc).id.r, fdc_get_read_track_sector(d86f_fdc).id.n)) {
|
||||||
fdc_get_read_track_sector(d86f_fdc).id.h,
|
|
||||||
fdc_get_read_track_sector(d86f_fdc).id.r,
|
|
||||||
fdc_get_read_track_sector(d86f_fdc).id.n)) {
|
|
||||||
dev->id_find.sync_marks = dev->id_find.bits_obtained = dev->id_find.bytes_obtained = dev->error_condition = 0;
|
dev->id_find.sync_marks = dev->id_find.bits_obtained = dev->id_find.bytes_obtained = dev->error_condition = 0;
|
||||||
fdc_nosector(d86f_fdc);
|
fdc_nosector(d86f_fdc);
|
||||||
dev->state = STATE_IDLE;
|
dev->state = STATE_IDLE;
|
||||||
@@ -2332,15 +2356,16 @@ d86f_turbo_poll(int drive, int side)
|
|||||||
case STATE_0C_FIND_ID:
|
case STATE_0C_FIND_ID:
|
||||||
case STATE_11_FIND_ID:
|
case STATE_11_FIND_ID:
|
||||||
case STATE_16_FIND_ID:
|
case STATE_16_FIND_ID:
|
||||||
if (! d86f_sector_is_present(drive, side,
|
if (! d86f_sector_is_present(drive, side, dev->req_sector.id.c, dev->req_sector.id.h, dev->req_sector.id.r, dev->req_sector.id.n)) {
|
||||||
dev->req_sector.id.c,
|
|
||||||
dev->req_sector.id.h,
|
|
||||||
dev->req_sector.id.r,
|
|
||||||
dev->req_sector.id.n)) {
|
|
||||||
dev->id_find.sync_marks = dev->id_find.bits_obtained = dev->id_find.bytes_obtained = dev->error_condition = 0;
|
dev->id_find.sync_marks = dev->id_find.bits_obtained = dev->id_find.bytes_obtained = dev->error_condition = 0;
|
||||||
fdc_nosector(d86f_fdc);
|
fdc_nosector(d86f_fdc);
|
||||||
dev->state = STATE_IDLE;
|
dev->state = STATE_IDLE;
|
||||||
return;
|
return;
|
||||||
|
} else if (d86f_sector_flags(drive, side, dev->req_sector.id.c, dev->req_sector.id.h, dev->req_sector.id.r, dev->req_sector.id.n) & SECTOR_NO_ID) {
|
||||||
|
dev->id_find.sync_marks = dev->id_find.bits_obtained = dev->id_find.bytes_obtained = dev->error_condition = 0;
|
||||||
|
fdc_noidam(d86f_fdc);
|
||||||
|
dev->state = STATE_IDLE;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
dev->last_sector.id.c = dev->req_sector.id.c;
|
dev->last_sector.id.c = dev->req_sector.id.c;
|
||||||
dev->last_sector.id.h = dev->req_sector.id.h;
|
dev->last_sector.id.h = dev->req_sector.id.h;
|
||||||
@@ -2567,7 +2592,6 @@ d86f_poll(int drive)
|
|||||||
case STATE_05_FIND_DATA:
|
case STATE_05_FIND_DATA:
|
||||||
case STATE_09_FIND_DATA:
|
case STATE_09_FIND_DATA:
|
||||||
case STATE_0C_FIND_DATA:
|
case STATE_0C_FIND_DATA:
|
||||||
|
|
||||||
dev->state = STATE_IDLE;
|
dev->state = STATE_IDLE;
|
||||||
fdc_nodataam(d86f_fdc);
|
fdc_nodataam(d86f_fdc);
|
||||||
break;
|
break;
|
||||||
@@ -2597,9 +2621,8 @@ d86f_poll(int drive)
|
|||||||
fdc_nosector(d86f_fdc);
|
fdc_nosector(d86f_fdc);
|
||||||
} else
|
} else
|
||||||
fdc_nosector(d86f_fdc);
|
fdc_nosector(d86f_fdc);
|
||||||
} else {
|
} else
|
||||||
fdc_noidam(d86f_fdc);
|
fdc_noidam(d86f_fdc);
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2679,7 +2702,7 @@ d86f_prepare_pretrack(int drive, int side, int iso)
|
|||||||
|
|
||||||
|
|
||||||
uint16_t
|
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)
|
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 flags)
|
||||||
{
|
{
|
||||||
d86f_t *dev = d86f[drive];
|
d86f_t *dev = d86f[drive];
|
||||||
uint16_t pos;
|
uint16_t pos;
|
||||||
@@ -2706,6 +2729,7 @@ d86f_prepare_sector(int drive, int side, int prev_pos, uint8_t *id_buf, uint8_t
|
|||||||
s->h = id_buf[1];
|
s->h = id_buf[1];
|
||||||
s->r = id_buf[2];
|
s->r = id_buf[2];
|
||||||
s->n = id_buf[3];
|
s->n = id_buf[3];
|
||||||
|
s->flags = flags;
|
||||||
if (dev->last_side_sector[side])
|
if (dev->last_side_sector[side])
|
||||||
s->prev = dev->last_side_sector[side];
|
s->prev = dev->last_side_sector[side];
|
||||||
dev->last_side_sector[side] = s;
|
dev->last_side_sector[side] = s;
|
||||||
@@ -2724,10 +2748,12 @@ d86f_prepare_sector(int drive, int side, int prev_pos, uint8_t *id_buf, uint8_t
|
|||||||
|
|
||||||
sync_len = mfm ? 12 : 6;
|
sync_len = mfm ? 12 : 6;
|
||||||
|
|
||||||
|
if (!(flags & SECTOR_NO_ID)) {
|
||||||
for (i = 0; i < sync_len; i++) {
|
for (i = 0; i < sync_len; i++) {
|
||||||
d86f_write_direct_common(drive, side, 0, 0, pos);
|
d86f_write_direct_common(drive, side, 0, 0, pos);
|
||||||
pos = (pos + 1) % raw_size;
|
pos = (pos + 1) % raw_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
dev->calc_crc.word = 0xffff;
|
dev->calc_crc.word = 0xffff;
|
||||||
if (mfm) {
|
if (mfm) {
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
@@ -2752,6 +2778,9 @@ d86f_prepare_sector(int drive, int side, int prev_pos, uint8_t *id_buf, uint8_t
|
|||||||
d86f_write_direct_common(drive, side, gap_fill, 0, pos);
|
d86f_write_direct_common(drive, side, gap_fill, 0, pos);
|
||||||
pos = (pos + 1) % raw_size;
|
pos = (pos + 1) % raw_size;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(flags & SECTOR_NO_DATA)) {
|
||||||
for (i = 0; i < sync_len; i++) {
|
for (i = 0; i < sync_len; i++) {
|
||||||
d86f_write_direct_common(drive, side, 0, 0, pos);
|
d86f_write_direct_common(drive, side, 0, 0, pos);
|
||||||
pos = (pos + 1) % raw_size;
|
pos = (pos + 1) % raw_size;
|
||||||
@@ -2764,24 +2793,27 @@ d86f_prepare_sector(int drive, int side, int prev_pos, uint8_t *id_buf, uint8_t
|
|||||||
d86f_calccrc(dev, 0xA1);
|
d86f_calccrc(dev, 0xA1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
d86f_write_direct_common(drive, side, mfm ? (deleted ? datadam_mfm : dataam_mfm) : (deleted ? datadam_fm : dataam_fm), 1, pos);
|
d86f_write_direct_common(drive, side, mfm ? ((flags & SECTOR_DELETED_DATA) ? datadam_mfm : dataam_mfm) : ((flags & SECTOR_DELETED_DATA) ? datadam_fm : dataam_fm), 1, pos);
|
||||||
pos = (pos + 1) % raw_size;
|
pos = (pos + 1) % raw_size;
|
||||||
d86f_calccrc(dev, deleted ? 0xF8 : 0xFB);
|
d86f_calccrc(dev, (flags & SECTOR_DELETED_DATA) ? 0xF8 : 0xFB);
|
||||||
|
if (data_len > 0) {
|
||||||
for (i = 0; i < data_len; i++) {
|
for (i = 0; i < data_len; i++) {
|
||||||
d86f_write_direct_common(drive, side, data_buf[i], 0, pos);
|
d86f_write_direct_common(drive, side, data_buf[i], 0, pos);
|
||||||
pos = (pos + 1) % raw_size;
|
pos = (pos + 1) % raw_size;
|
||||||
d86f_calccrc(dev, data_buf[i]);
|
d86f_calccrc(dev, data_buf[i]);
|
||||||
}
|
}
|
||||||
if (bad_crc)
|
if (!(flags & SECTOR_CRC_ERROR)) {
|
||||||
dev->calc_crc.word ^= 0xffff;
|
|
||||||
for (i = 1; i >= 0; i--) {
|
for (i = 1; i >= 0; i--) {
|
||||||
d86f_write_direct_common(drive, side, dev->calc_crc.bytes[i], 0, pos);
|
d86f_write_direct_common(drive, side, dev->calc_crc.bytes[i], 0, pos);
|
||||||
pos = (pos + 1) % raw_size;
|
pos = (pos + 1) % raw_size;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (i = 0; i < real_gap3_len; i++) {
|
for (i = 0; i < real_gap3_len; i++) {
|
||||||
d86f_write_direct_common(drive, side, gap_fill, 0, pos);
|
d86f_write_direct_common(drive, side, gap_fill, 0, pos);
|
||||||
pos = (pos + 1) % raw_size;
|
pos = (pos + 1) % raw_size;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
@@ -2798,9 +2830,9 @@ d86f_prepare_sector(int drive, int side, int prev_pos, uint8_t *id_buf, uint8_t
|
|||||||
* - One is regular and one is fuzzy -> Output is fuzzy;
|
* - One is regular and one is fuzzy -> Output is fuzzy;
|
||||||
* - Both are fuzzy -> Output is fuzzy;
|
* - Both are fuzzy -> Output is fuzzy;
|
||||||
* - Both are physical holes -> Output is a physical hole;
|
* - Both are physical holes -> Output is a physical hole;
|
||||||
* - One is regular and one is a physical hole -> Output is puzzy,
|
* - One is regular and one is a physical hole -> Output is fuzzy,
|
||||||
* the hole half is handled appropriately on writeback;
|
* the hole half is handled appropriately on writeback;
|
||||||
* - One is fuzzy and one is a physical hole -> Output is puzzy,
|
* - One is fuzzy and one is a physical hole -> Output is fuzzy,
|
||||||
* the hole half is handled appropriately on writeback;
|
* the hole half is handled appropriately on writeback;
|
||||||
* - On write back, apart from the above notes, the final two tracks
|
* - On write back, apart from the above notes, the final two tracks
|
||||||
* are written;
|
* are written;
|
||||||
@@ -3199,13 +3231,12 @@ d86f_common_command(int drive, int sector, int track, int side, int rate, int se
|
|||||||
|
|
||||||
dev->req_sector.id.c = track;
|
dev->req_sector.id.c = track;
|
||||||
dev->req_sector.id.h = side;
|
dev->req_sector.id.h = side;
|
||||||
if (sector == SECTOR_FIRST) {
|
if (sector == SECTOR_FIRST)
|
||||||
dev->req_sector.id.r = 1;
|
dev->req_sector.id.r = 1;
|
||||||
} else if (sector == SECTOR_NEXT) {
|
else if (sector == SECTOR_NEXT)
|
||||||
dev->req_sector.id.r++;
|
dev->req_sector.id.r++;
|
||||||
} else {
|
else
|
||||||
dev->req_sector.id.r = sector;
|
dev->req_sector.id.r = sector;
|
||||||
}
|
|
||||||
dev->req_sector.id.n = sector_size;
|
dev->req_sector.id.n = sector_size;
|
||||||
|
|
||||||
if (fdd_get_head(drive) && (d86f_get_sides(drive) == 1)) {
|
if (fdd_get_head(drive) && (d86f_get_sides(drive) == 1)) {
|
||||||
@@ -3926,4 +3957,6 @@ d86f_destroy(int drive)
|
|||||||
|
|
||||||
free(d86f[drive]);
|
free(d86f[drive]);
|
||||||
d86f[drive] = NULL;
|
d86f[drive] = NULL;
|
||||||
|
|
||||||
|
d86f_handler[drive].read_data = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,38 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
* VARCem Virtual ARchaeological Computer EMulator.
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||||
* An emulator of (mostly) x86-based PC systems and devices,
|
* running old operating systems and software designed for IBM
|
||||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
* PC systems and compatibles from 1981 through fairly recent
|
||||||
* spanning the era between 1981 and 1995.
|
* system designs based on the PCI bus.
|
||||||
*
|
*
|
||||||
* This file is part of the VARCem Project.
|
* This file is part of the 86Box distribution.
|
||||||
*
|
*
|
||||||
* Definitions for the 86F floppy image format.
|
* Definitions for the 86F floppy image format.
|
||||||
*
|
*
|
||||||
* Version: @(#)floppy_86f.h 1.0.5 2018/11/14
|
* Version: @(#)floppy_86f.h 1.0.6 2019/12/05
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
*
|
*
|
||||||
* Copyright 2018 Fred N. van Kempen.
|
* Copyright 2016-2019 Miran Grca.
|
||||||
* Copyright 2016-2018 Miran Grca.
|
* Copyright 2018,2019 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 EMU_FLOPPY_86F_H
|
#ifndef EMU_FLOPPY_86F_H
|
||||||
# define EMU_FLOPPY_86F_H
|
# define EMU_FLOPPY_86F_H
|
||||||
@@ -40,6 +22,36 @@
|
|||||||
|
|
||||||
#define D86FVER 0x020C
|
#define D86FVER 0x020C
|
||||||
|
|
||||||
|
/* Thesere were borrowed from TeleDisk. */
|
||||||
|
#define SECTOR_DUPLICATED 0x01
|
||||||
|
#define SECTOR_CRC_ERROR 0x02
|
||||||
|
#define SECTOR_DELETED_DATA 0x04
|
||||||
|
#define SECTOR_DATA_SKIPPED 0x10
|
||||||
|
#define SECTOR_NO_DATA 0x20
|
||||||
|
#define SECTOR_NO_ID 0x40
|
||||||
|
|
||||||
|
#define length_gap0 80
|
||||||
|
#define length_gap1 50
|
||||||
|
#define length_sync 12
|
||||||
|
#define length_am 4
|
||||||
|
#define length_crc 2
|
||||||
|
|
||||||
|
#define IBM
|
||||||
|
#define MFM
|
||||||
|
#ifdef IBM
|
||||||
|
#define pre_gap1 length_gap0 + length_sync + length_am
|
||||||
|
#else
|
||||||
|
#define pre_gap1 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define pre_track pre_gap1 + length_gap1
|
||||||
|
#define pre_gap length_sync + length_am + 4 + length_crc
|
||||||
|
#define pre_data length_sync + length_am
|
||||||
|
#define post_gap length_crc
|
||||||
|
|
||||||
|
|
||||||
|
extern d86f_handler_t d86f_handler[FDD_NUM];
|
||||||
|
|
||||||
|
|
||||||
extern void d86f_init(void);
|
extern void d86f_init(void);
|
||||||
extern void d86f_load(int drive, wchar_t *fn);
|
extern void d86f_load(int drive, wchar_t *fn);
|
||||||
@@ -61,29 +73,38 @@ extern void d86f_prepare_track_layout(int drive, int side);
|
|||||||
extern void d86f_set_version(int drive, uint16_t version);
|
extern void d86f_set_version(int drive, uint16_t version);
|
||||||
extern uint16_t d86f_side_flags(int drive);
|
extern uint16_t d86f_side_flags(int drive);
|
||||||
extern uint16_t d86f_track_flags(int drive);
|
extern uint16_t d86f_track_flags(int drive);
|
||||||
extern void d86f_initialize_last_sector_id(int drive, int c, int h,
|
extern void d86f_initialize_last_sector_id(int drive, int c, int h, int r, int n);
|
||||||
int r, int n);
|
|
||||||
extern void d86f_initialize_linked_lists(int drive);
|
extern void d86f_initialize_linked_lists(int drive);
|
||||||
extern void d86f_destroy_linked_lists(int drive, int side);
|
extern void d86f_destroy_linked_lists(int drive, int side);
|
||||||
|
|
||||||
#define length_gap0 80
|
extern uint16_t d86f_prepare_sector(int drive, int side, int prev_pos, uint8_t *id_buf, uint8_t *data_buf,
|
||||||
#define length_gap1 50
|
int data_len, int gap2, int gap3, int flags);
|
||||||
#define length_sync 12
|
extern void d86f_setup(int drive);
|
||||||
#define length_am 4
|
extern void d86f_destroy(int drive);
|
||||||
#define length_crc 2
|
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 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);
|
||||||
|
|
||||||
#define IBM
|
extern uint16_t *common_encoded_data(int drive, int side);
|
||||||
#define MFM
|
extern void common_read_revolution(int drive);
|
||||||
#ifdef IBM
|
extern uint32_t common_get_raw_size(int drive, int side);
|
||||||
#define pre_gap1 length_gap0 + length_sync + length_am
|
|
||||||
#else
|
|
||||||
#define pre_gap1 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define pre_track pre_gap1 + length_gap1
|
extern void null_writeback(int drive);
|
||||||
#define pre_gap length_sync + length_am + 4 + length_crc
|
extern void null_write_data(int drive, int side, uint16_t pos, uint8_t data);
|
||||||
#define pre_data length_sync + length_am
|
extern int null_format_conditions(int drive);
|
||||||
#define post_gap length_crc
|
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);
|
||||||
|
|
||||||
|
|
||||||
#endif /*EMU_FLOPPY_86F_H*/
|
#endif /*EMU_FLOPPY_86F_H*/
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* VARCem Virtual ARchaeological Computer EMulator.
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||||
* An emulator of (mostly) x86-based PC systems and devices,
|
* running old operating systems and software designed for IBM
|
||||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
* PC systems and compatibles from 1981 through fairly recent
|
||||||
* spanning the era between 1981 and 1995.
|
* system designs based on the PCI bus.
|
||||||
*
|
*
|
||||||
* This file is part of the VARCem Project.
|
* This file is part of the 86Box distribution.
|
||||||
*
|
*
|
||||||
* Shared code for all the floppy modules.
|
* Shared code for all the floppy modules.
|
||||||
*
|
*
|
||||||
@@ -13,24 +13,6 @@
|
|||||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
*
|
*
|
||||||
* Copyright 2017,2018 Fred N. van Kempen.
|
* 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 <stdio.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* VARCem Virtual ARchaeological Computer EMulator.
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||||
* An emulator of (mostly) x86-based PC systems and devices,
|
* running old operating systems and software designed for IBM
|
||||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
* PC systems and compatibles from 1981 through fairly recent
|
||||||
* spanning the era between 1981 and 1995.
|
* system designs based on the PCI bus.
|
||||||
*
|
*
|
||||||
* This file is part of the VARCem Project.
|
* This file is part of the 86Box distribution.
|
||||||
*
|
*
|
||||||
* Shared code for all the floppy modules.
|
* Shared code for all the floppy modules.
|
||||||
*
|
*
|
||||||
@@ -13,24 +13,6 @@
|
|||||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
*
|
*
|
||||||
* Copyright 2017,2018 Fred N. van Kempen.
|
* 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
|
#ifndef FDD_COMMON_H
|
||||||
# define FDD_COMMON_H
|
# define FDD_COMMON_H
|
||||||
|
|||||||
@@ -1,41 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* VARCem Virtual ARchaeological Computer EMulator.
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||||
* An emulator of (mostly) x86-based PC systems and devices,
|
* running old operating systems and software designed for IBM
|
||||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
* PC systems and compatibles from 1981 through fairly recent
|
||||||
* spanning the era between 1981 and 1995.
|
* system designs based on the PCI bus.
|
||||||
*
|
*
|
||||||
* This file is part of the VARCem Project.
|
* This file is part of the 86Box distribution.
|
||||||
*
|
*
|
||||||
* Implementation of the FDI floppy stream image format
|
* Implementation of the FDI floppy stream image format
|
||||||
* interface to the FDI2RAW module.
|
* interface to the FDI2RAW module.
|
||||||
*
|
*
|
||||||
* Version: @(#)fdd_fdi.c 1.0.4 2018/10/18
|
* Version: @(#)fdd_fdi.c 1.0.4 2018/10/18
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
*
|
*
|
||||||
* Copyright 2018 Fred N. van Kempen.
|
|
||||||
* Copyright 2016-2018 Miran Grca.
|
|
||||||
* Copyright 2008-2018 Sarah Walker.
|
* Copyright 2008-2018 Sarah Walker.
|
||||||
*
|
* Copyright 2016-2018 Miran Grca.
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* Copyright 2018 Fred N. van Kempen.
|
||||||
* 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 <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|||||||
@@ -1,41 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* VARCem Virtual ARchaeological Computer EMulator.
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||||
* An emulator of (mostly) x86-based PC systems and devices,
|
* running old operating systems and software designed for IBM
|
||||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
* PC systems and compatibles from 1981 through fairly recent
|
||||||
* spanning the era between 1981 and 1995.
|
* system designs based on the PCI bus.
|
||||||
*
|
*
|
||||||
* This file is part of the VARCem Project.
|
* This file is part of the 86Box distribution.
|
||||||
*
|
*
|
||||||
* Implementation of the FDI floppy stream image format
|
* Implementation of the FDI floppy stream image format
|
||||||
* interface to the FDI2RAW module.
|
* interface to the FDI2RAW module.
|
||||||
*
|
*
|
||||||
* Version: @(#)floppy_fdi.h 1.0.2 2018/03/17
|
* Version: @(#)floppy_fdi.h 1.0.2 2018/03/17
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
*
|
*
|
||||||
* Copyright 2018 Fred N. van Kempen.
|
|
||||||
* Copyright 2016-2018 Miran Grca.
|
|
||||||
* Copyright 2008-2018 Sarah Walker.
|
* Copyright 2008-2018 Sarah Walker.
|
||||||
*
|
* Copyright 2016-2018 Miran Grca.
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* Copyright 2018 Fred N. van Kempen.
|
||||||
* 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
|
#ifndef EMU_FLOPPY_FDI_H
|
||||||
# define EMU_FLOPPY_FDI_H
|
# define EMU_FLOPPY_FDI_H
|
||||||
|
|||||||
@@ -1,38 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
* VARCem Virtual ARchaeological Computer EMulator.
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||||
* An emulator of (mostly) x86-based PC systems and devices,
|
* running old operating systems and software designed for IBM
|
||||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
* PC systems and compatibles from 1981 through fairly recent
|
||||||
* spanning the era between 1981 and 1995.
|
* system designs based on the PCI bus.
|
||||||
*
|
*
|
||||||
* This file is part of the VARCem Project.
|
* This file is part of the 86Box distribution.
|
||||||
*
|
*
|
||||||
* Implementation of the IMD floppy image format.
|
* Implementation of the IMD floppy image format.
|
||||||
*
|
*
|
||||||
* Version: @(#)fdd_imd.c 1.0.8 2018/10/18
|
* Version: @(#)fdd_imd.c 1.0.9 2019/12/05
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
*
|
*
|
||||||
* Copyright 2018 Fred N. van Kempen.
|
* Copyright 2016-2019 Miran Grca.
|
||||||
* Copyright 2016-2018 Miran Grca.
|
* Copyright 2018,2019 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 <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -45,6 +27,7 @@
|
|||||||
#include "../timer.h"
|
#include "../timer.h"
|
||||||
#include "../plat.h"
|
#include "../plat.h"
|
||||||
#include "fdd.h"
|
#include "fdd.h"
|
||||||
|
#include "fdd_86f.h"
|
||||||
#include "fdd_imd.h"
|
#include "fdd_imd.h"
|
||||||
#include "fdc.h"
|
#include "fdc.h"
|
||||||
|
|
||||||
@@ -62,6 +45,7 @@ typedef struct {
|
|||||||
uint32_t sector_data_size[255];
|
uint32_t sector_data_size[255];
|
||||||
uint32_t gap3_len;
|
uint32_t gap3_len;
|
||||||
uint16_t side_flags;
|
uint16_t side_flags;
|
||||||
|
uint8_t max_sector_size;
|
||||||
} imd_track_t;
|
} imd_track_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@@ -301,7 +285,7 @@ imd_seek(int drive, int track)
|
|||||||
{
|
{
|
||||||
uint32_t track_buf_pos[2] = { 0, 0 };
|
uint32_t track_buf_pos[2] = { 0, 0 };
|
||||||
uint8_t id[4] = { 0, 0, 0, 0 };
|
uint8_t id[4] = { 0, 0, 0, 0 };
|
||||||
uint8_t type, deleted, bad_crc;
|
uint8_t type;
|
||||||
imd_t *dev = imd[drive];
|
imd_t *dev = imd[drive];
|
||||||
int sector, current_pos;
|
int sector, current_pos;
|
||||||
int side, c = 0, h, n;
|
int side, c = 0, h, n;
|
||||||
@@ -322,6 +306,7 @@ imd_seek(int drive, int track)
|
|||||||
char *r_map;
|
char *r_map;
|
||||||
char *n_map = NULL;
|
char *n_map = NULL;
|
||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
|
int flags = 0x00;
|
||||||
|
|
||||||
if (dev->f == NULL) return;
|
if (dev->f == NULL) return;
|
||||||
|
|
||||||
@@ -395,16 +380,22 @@ imd_seek(int drive, int track)
|
|||||||
id[1] = (h & 0x40) ? h_map[actual_sector] : (h & 1);
|
id[1] = (h & 0x40) ? h_map[actual_sector] : (h & 1);
|
||||||
id[2] = real_sector;
|
id[2] = real_sector;
|
||||||
id[3] = (n == 0xFF) ? n_map[actual_sector] : n;
|
id[3] = (n == 0xFF) ? n_map[actual_sector] : n;
|
||||||
ssize = 128 << ((uint32_t) id[3]);
|
|
||||||
data = dev->track_buffer[side] + track_buf_pos[side];
|
data = dev->track_buffer[side] + track_buf_pos[side];
|
||||||
type = dev->buffer[dev->tracks[track][side].sector_data_offs[actual_sector]];
|
type = dev->buffer[dev->tracks[track][side].sector_data_offs[actual_sector]];
|
||||||
type = (type >> 1) & 7;
|
type = (type >> 1) & 7;
|
||||||
deleted = bad_crc = 0;
|
flags = 0x00;
|
||||||
if ((type == 2) || (type == 4)) deleted = 1;
|
if ((type == 2) || (type == 4))
|
||||||
if ((type == 3) || (type == 4)) bad_crc = 1;
|
flags |= SECTOR_DELETED_DATA;
|
||||||
|
if ((type == 3) || (type == 4))
|
||||||
|
flags |= SECTOR_CRC_ERROR;
|
||||||
|
|
||||||
|
if (((flags & 0x02) || (id[3] > dev->tracks[track][side].max_sector_size)) && !fdd_get_turbo(drive))
|
||||||
|
ssize = 3;
|
||||||
|
else
|
||||||
|
ssize = 128 << ((uint32_t) id[3]);
|
||||||
|
|
||||||
sector_to_buffer(drive, track, side, data, actual_sector, ssize);
|
sector_to_buffer(drive, track, side, data, actual_sector, ssize);
|
||||||
current_pos = d86f_prepare_sector(drive, side, current_pos, id, data, ssize, 22, track_gap3, deleted, bad_crc);
|
current_pos = d86f_prepare_sector(drive, side, current_pos, id, data, ssize, 22, track_gap3, flags);
|
||||||
track_buf_pos[side] += ssize;
|
track_buf_pos[side] += ssize;
|
||||||
|
|
||||||
if (sector == 0)
|
if (sector == 0)
|
||||||
@@ -419,21 +410,28 @@ imd_seek(int drive, int track)
|
|||||||
id[1] = side;
|
id[1] = side;
|
||||||
id[2] = xdf_disk_layout[xdf_type][is_trackx][xdf_sector].id.r;
|
id[2] = xdf_disk_layout[xdf_type][is_trackx][xdf_sector].id.r;
|
||||||
id[3] = is_trackx ? (id[2] & 7) : 2;
|
id[3] = is_trackx ? (id[2] & 7) : 2;
|
||||||
ssize = 128 << ((uint32_t) id[3]);
|
|
||||||
ordered_pos = dev->xdf_ordered_pos[id[2]][side];
|
ordered_pos = dev->xdf_ordered_pos[id[2]][side];
|
||||||
|
|
||||||
data = dev->track_buffer[side] + track_buf_pos[side];
|
data = dev->track_buffer[side] + track_buf_pos[side];
|
||||||
type = dev->buffer[dev->tracks[track][side].sector_data_offs[ordered_pos]];
|
type = dev->buffer[dev->tracks[track][side].sector_data_offs[ordered_pos]];
|
||||||
type = (type >> 1) & 7;
|
type = (type >> 1) & 7;
|
||||||
deleted = bad_crc = 0;
|
flags = 0x00;
|
||||||
if ((type == 2) || (type == 4)) deleted = 1;
|
if ((type == 2) || (type == 4))
|
||||||
if ((type == 3) || (type == 4)) bad_crc = 1;
|
flags |= SECTOR_DELETED_DATA;
|
||||||
|
if ((type == 3) || (type == 4))
|
||||||
|
flags |= SECTOR_CRC_ERROR;
|
||||||
|
|
||||||
|
if (((flags & 0x02) || (id[3] > dev->tracks[track][side].max_sector_size)) && !fdd_get_turbo(drive))
|
||||||
|
ssize = 3;
|
||||||
|
else
|
||||||
|
ssize = 128 << ((uint32_t) id[3]);
|
||||||
|
|
||||||
sector_to_buffer(drive, track, side, data, ordered_pos, ssize);
|
sector_to_buffer(drive, track, side, data, ordered_pos, ssize);
|
||||||
|
|
||||||
if (is_trackx)
|
if (is_trackx)
|
||||||
current_pos = d86f_prepare_sector(drive, side, xdf_trackx_spos[xdf_type][xdf_sector], id, data, ssize, track_gap2, xdf_gap3_sizes[xdf_type][is_trackx], deleted, bad_crc);
|
current_pos = d86f_prepare_sector(drive, side, xdf_trackx_spos[xdf_type][xdf_sector], id, data, ssize, track_gap2, xdf_gap3_sizes[xdf_type][is_trackx], flags);
|
||||||
else
|
else
|
||||||
current_pos = d86f_prepare_sector(drive, side, current_pos, id, data, ssize, track_gap2, xdf_gap3_sizes[xdf_type][is_trackx], deleted, bad_crc);
|
current_pos = d86f_prepare_sector(drive, side, current_pos, id, data, ssize, track_gap2, xdf_gap3_sizes[xdf_type][is_trackx], flags);
|
||||||
|
|
||||||
track_buf_pos[side] += ssize;
|
track_buf_pos[side] += ssize;
|
||||||
|
|
||||||
@@ -615,6 +613,8 @@ imd_load(int drive, wchar_t *fn)
|
|||||||
uint32_t minimum_gap3 = 0;
|
uint32_t minimum_gap3 = 0;
|
||||||
uint32_t minimum_gap4 = 0;
|
uint32_t minimum_gap4 = 0;
|
||||||
uint8_t converted_rate;
|
uint8_t converted_rate;
|
||||||
|
uint8_t type;
|
||||||
|
int size_diff, gap_sum;
|
||||||
|
|
||||||
d86f_unregister(drive);
|
d86f_unregister(drive);
|
||||||
|
|
||||||
@@ -643,12 +643,11 @@ imd_load(int drive, wchar_t *fn)
|
|||||||
if (magic != 0x20444D49) {
|
if (magic != 0x20444D49) {
|
||||||
imd_log("IMD: Not a valid ImageDisk image\n");
|
imd_log("IMD: Not a valid ImageDisk image\n");
|
||||||
fclose(dev->f);
|
fclose(dev->f);
|
||||||
free(dev);;
|
free(dev);
|
||||||
memset(floppyfns[drive], 0, sizeof(floppyfns[drive]));
|
memset(floppyfns[drive], 0, sizeof(floppyfns[drive]));
|
||||||
return;
|
return;
|
||||||
} else {
|
} else
|
||||||
imd_log("IMD: Valid ImageDisk image\n");
|
imd_log("IMD: Valid ImageDisk image\n");
|
||||||
}
|
|
||||||
|
|
||||||
fseek(dev->f, 0, SEEK_END);
|
fseek(dev->f, 0, SEEK_END);
|
||||||
fsize = ftell(dev->f);
|
fsize = ftell(dev->f);
|
||||||
@@ -715,6 +714,12 @@ imd_load(int drive, wchar_t *fn)
|
|||||||
dev->tracks[track][side].side_flags |= 0x20;
|
dev->tracks[track][side].side_flags |= 0x20;
|
||||||
if ((dev->tracks[track][side].side_flags & 7) == 1)
|
if ((dev->tracks[track][side].side_flags & 7) == 1)
|
||||||
dev->tracks[track][side].side_flags |= 0x20;
|
dev->tracks[track][side].side_flags |= 0x20;
|
||||||
|
if ((dev->tracks[track][side].side_flags & 0x07) == 0x00)
|
||||||
|
dev->tracks[track][side].max_sector_size = 6;
|
||||||
|
else
|
||||||
|
dev->tracks[track][side].max_sector_size = 5;
|
||||||
|
if (!mfm)
|
||||||
|
dev->tracks[track][side].max_sector_size--;
|
||||||
/* imd_log("Side flags for (%02i)(%01i): %02X\n", track, side, dev->tracks[track][side].side_flags); */
|
/* imd_log("Side flags for (%02i)(%01i): %02X\n", track, side, dev->tracks[track][side].side_flags); */
|
||||||
dev->tracks[track][side].is_present = 1;
|
dev->tracks[track][side].is_present = 1;
|
||||||
dev->tracks[track][side].file_offs = (buffer2 - buffer);
|
dev->tracks[track][side].file_offs = (buffer2 - buffer);
|
||||||
@@ -749,6 +754,11 @@ imd_load(int drive, wchar_t *fn)
|
|||||||
last_offset += dev->tracks[track][side].sector_data_size[i];
|
last_offset += dev->tracks[track][side].sector_data_size[i];
|
||||||
if (!(buffer[dev->tracks[track][side].sector_data_offs[i]] & 1))
|
if (!(buffer[dev->tracks[track][side].sector_data_offs[i]] & 1))
|
||||||
fwriteprot[drive] = writeprot[drive] = 1;
|
fwriteprot[drive] = writeprot[drive] = 1;
|
||||||
|
type = dev->buffer[dev->tracks[track][side].sector_data_offs[i]];
|
||||||
|
type = (type >> 1) & 7;
|
||||||
|
if ((type == 3) || (type == 4) || (data_size > (128 << dev->tracks[track][side].max_sector_size)))
|
||||||
|
track_total += (pre_sector + 3);
|
||||||
|
else
|
||||||
track_total += (pre_sector + data_size + 2);
|
track_total += (pre_sector + data_size + 2);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -764,6 +774,11 @@ imd_load(int drive, wchar_t *fn)
|
|||||||
last_offset += dev->tracks[track][side].sector_data_size[i];
|
last_offset += dev->tracks[track][side].sector_data_size[i];
|
||||||
if (!(buffer[dev->tracks[track][side].sector_data_offs[i]] & 1))
|
if (!(buffer[dev->tracks[track][side].sector_data_offs[i]] & 1))
|
||||||
fwriteprot[drive] = writeprot[drive] = 1;
|
fwriteprot[drive] = writeprot[drive] = 1;
|
||||||
|
type = dev->buffer[dev->tracks[track][side].sector_data_offs[i]];
|
||||||
|
type = (type >> 1) & 7;
|
||||||
|
if ((type == 3) || (type == 4) || (sector_size > dev->tracks[track][side].max_sector_size))
|
||||||
|
track_total += (pre_sector + 3);
|
||||||
|
else
|
||||||
track_total += (pre_sector + data_size + 2);
|
track_total += (pre_sector + data_size + 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -783,12 +798,15 @@ imd_load(int drive, wchar_t *fn)
|
|||||||
converted_rate = dev->tracks[track][side].side_flags & 0x03;
|
converted_rate = dev->tracks[track][side].side_flags & 0x03;
|
||||||
|
|
||||||
if (gap3_sizes[converted_rate][sector_size][track_spt] == 0x00) {
|
if (gap3_sizes[converted_rate][sector_size][track_spt] == 0x00) {
|
||||||
if ((raw_tsize - track_total + (mfm ? 146 : 73)) < (minimum_gap3 + minimum_gap4)) {
|
size_diff = raw_tsize - track_total;
|
||||||
|
gap_sum = minimum_gap3 + minimum_gap4;
|
||||||
|
if (size_diff < gap_sum) {
|
||||||
/* If we can't fit the sectors with a reasonable minimum gap at perfect RPM, let's try 2% slower. */
|
/* If we can't fit the sectors with a reasonable minimum gap at perfect RPM, let's try 2% slower. */
|
||||||
raw_tsize = get_raw_tsize(dev->tracks[track][side].side_flags, 1);
|
raw_tsize = get_raw_tsize(dev->tracks[track][side].side_flags, 1);
|
||||||
/* Set disk flags so that rotation speed is 2% slower. */
|
/* Set disk flags so that rotation speed is 2% slower. */
|
||||||
dev->disk_flags |= (3 << 5);
|
dev->disk_flags |= (3 << 5);
|
||||||
if ((raw_tsize - track_total + (mfm ? 146 : 73)) < (minimum_gap3 + minimum_gap4)) {
|
size_diff = raw_tsize - track_total;
|
||||||
|
if (size_diff < gap_sum) {
|
||||||
/* If we can't fit the sectors with a reasonable minimum gap even at 2% slower RPM, abort. */
|
/* If we can't fit the sectors with a reasonable minimum gap even at 2% slower RPM, abort. */
|
||||||
imd_log("IMD: Unable to fit the %i sectors in a track\n", track_spt);
|
imd_log("IMD: Unable to fit the %i sectors in a track\n", track_spt);
|
||||||
fclose(dev->f);
|
fclose(dev->f);
|
||||||
@@ -799,7 +817,7 @@ imd_load(int drive, wchar_t *fn)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dev->tracks[track][side].gap3_len = (raw_tsize - track_total - minimum_gap4 + (mfm ? 146 : 73)) / track_spt;
|
dev->tracks[track][side].gap3_len = (size_diff - minimum_gap4) / track_spt;
|
||||||
} else if (gap3_sizes[converted_rate][sector_size][track_spt] != 0x00)
|
} else if (gap3_sizes[converted_rate][sector_size][track_spt] != 0x00)
|
||||||
dev->tracks[track][side].gap3_len = gap3_sizes[converted_rate][sector_size][track_spt];
|
dev->tracks[track][side].gap3_len = gap3_sizes[converted_rate][sector_size][track_spt];
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
* VARCem Virtual ARchaeological Computer EMulator.
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||||
* An emulator of (mostly) x86-based PC systems and devices,
|
* running old operating systems and software designed for IBM
|
||||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
* PC systems and compatibles from 1981 through fairly recent
|
||||||
* spanning the era between 1981 and 1995.
|
* system designs based on the PCI bus.
|
||||||
*
|
*
|
||||||
* This file is part of the VARCem Project.
|
* This file is part of the 86Box distribution.
|
||||||
*
|
*
|
||||||
* Definitions for the IMD floppy image format.
|
* Definitions for the IMD floppy image format.
|
||||||
*
|
*
|
||||||
* Version: @(#)floppy_imd.h 1.0.2 2018/03/17
|
* Version: @(#)floppy_imd.h 1.0.2 2018/03/17
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
*
|
*
|
||||||
* Copyright 2018 Fred N. van Kempen.
|
|
||||||
* Copyright 2016-2018 Miran Grca.
|
* Copyright 2016-2018 Miran Grca.
|
||||||
|
* Copyright 2018 Fred N. van Kempen.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* VARCem Virtual ARchaeological Computer EMulator.
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||||
* An emulator of (mostly) x86-based PC systems and devices,
|
* running old operating systems and software designed for IBM
|
||||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
* PC systems and compatibles from 1981 through fairly recent
|
||||||
* spanning the era between 1981 and 1995.
|
* system designs based on the PCI bus.
|
||||||
*
|
*
|
||||||
* This file is part of the VARCem Project.
|
* This file is part of the 86Box distribution.
|
||||||
*
|
*
|
||||||
* Implementation of the raw sector-based floppy image format,
|
* Implementation of the raw sector-based floppy image format,
|
||||||
* as well as the Japanese FDI, CopyQM, and FDF formats.
|
* as well as the Japanese FDI, CopyQM, and FDF formats.
|
||||||
@@ -13,33 +13,15 @@
|
|||||||
* re-merged with the other files. Much of it is generic to
|
* re-merged with the other files. Much of it is generic to
|
||||||
* all formats.
|
* all formats.
|
||||||
*
|
*
|
||||||
* Version: @(#)fdd_img.c 1.0.9 2018/10/18
|
* Version: @(#)fdd_img.c 1.0.10 2018/12/05
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
*
|
*
|
||||||
* Copyright 2018 Fred N. van Kempen.
|
* Copyright 2008-2019 Sarah Walker.
|
||||||
* Copyright 2016-2018 Miran Grca.
|
* Copyright 2016-2019 Miran Grca.
|
||||||
* Copyright 2008-2018 Sarah Walker.
|
* Copyright 2018,2019 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 <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -53,6 +35,7 @@
|
|||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#include "../plat.h"
|
#include "../plat.h"
|
||||||
#include "fdd.h"
|
#include "fdd.h"
|
||||||
|
#include "fdd_86f.h"
|
||||||
#include "fdd_img.h"
|
#include "fdd_img.h"
|
||||||
#include "fdc.h"
|
#include "fdc.h"
|
||||||
|
|
||||||
@@ -554,7 +537,7 @@ img_seek(int drive, int track)
|
|||||||
id[3] = dev->sector_size;
|
id[3] = dev->sector_size;
|
||||||
dev->sector_pos_side[side][sr] = side;
|
dev->sector_pos_side[side][sr] = side;
|
||||||
dev->sector_pos[side][sr] = (sr - 1) * ssize;
|
dev->sector_pos[side][sr] = (sr - 1) * ssize;
|
||||||
current_pos = d86f_prepare_sector(drive, side, current_pos, id, &dev->track_data[side][(sr - 1) * ssize], ssize, dev->gap2_size, dev->gap3_size, 0, 0);
|
current_pos = d86f_prepare_sector(drive, side, current_pos, id, &dev->track_data[side][(sr - 1) * ssize], ssize, dev->gap2_size, dev->gap3_size, 0);
|
||||||
|
|
||||||
if (sector == 0)
|
if (sector == 0)
|
||||||
d86f_initialize_last_sector_id(drive, id[0], id[1], id[2], id[3]);
|
d86f_initialize_last_sector_id(drive, id[0], id[1], id[2], id[3]);
|
||||||
@@ -599,11 +582,11 @@ img_seek(int drive, int track)
|
|||||||
|
|
||||||
if (is_t0) {
|
if (is_t0) {
|
||||||
id[3] = 2;
|
id[3] = 2;
|
||||||
current_pos = d86f_prepare_sector(drive, side, current_pos, id, &dev->track_data[buf_side][buf_pos], ssize, dev->gap2_size, xdf_gap3_sizes[current_xdft][!is_t0], 0, 0);
|
current_pos = d86f_prepare_sector(drive, side, current_pos, id, &dev->track_data[buf_side][buf_pos], ssize, dev->gap2_size, xdf_gap3_sizes[current_xdft][!is_t0], 0);
|
||||||
} else {
|
} else {
|
||||||
id[3] = id[2] & 7;
|
id[3] = id[2] & 7;
|
||||||
ssize = (128 << id[3]);
|
ssize = (128 << id[3]);
|
||||||
current_pos = d86f_prepare_sector(drive, side, xdf_trackx_spos[current_xdft][array_sector], id, &dev->track_data[buf_side][buf_pos], ssize, dev->gap2_size, xdf_gap3_sizes[current_xdft][!is_t0], 0, 0);
|
current_pos = d86f_prepare_sector(drive, side, xdf_trackx_spos[current_xdft][array_sector], id, &dev->track_data[buf_side][buf_pos], ssize, dev->gap2_size, xdf_gap3_sizes[current_xdft][!is_t0], 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sector == 0)
|
if (sector == 0)
|
||||||
|
|||||||
@@ -1,41 +1,23 @@
|
|||||||
/*
|
/*
|
||||||
* VARCem Virtual ARchaeological Computer EMulator.
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||||
* An emulator of (mostly) x86-based PC systems and devices,
|
* running old operating systems and software designed for IBM
|
||||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
* PC systems and compatibles from 1981 through fairly recent
|
||||||
* spanning the era between 1981 and 1995.
|
* system designs based on the PCI bus.
|
||||||
*
|
*
|
||||||
* This file is part of the VARCem Project.
|
* This file is part of the 86Box distribution.
|
||||||
*
|
*
|
||||||
* Implementation of the raw sector-based floppy image format,
|
* Implementation of the raw sector-based floppy image format,
|
||||||
* as well as the Japanese FDI, CopyQM, and FDF formats.
|
* as well as the Japanese FDI, CopyQM, and FDF formats.
|
||||||
*
|
*
|
||||||
* Version: @(#)floppy_img.h 1.0.2 2018/03/17
|
* Version: @(#)floppy_img.h 1.0.2 2018/03/17
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Sarah Walker, <tommowalker@tommowalker.co.uk>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
* Sarah Walker, <tommowalker@tommowalker.co.uk>
|
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
*
|
*
|
||||||
* Copyright 2018 Fred N. van Kempen.
|
|
||||||
* Copyright 2016-2018 Miran Grca.
|
|
||||||
* Copyright 2008-2018 Sarah Walker.
|
* Copyright 2008-2018 Sarah Walker.
|
||||||
*
|
* Copyright 2016-2018 Miran Grca.
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* Copyright 2018 Fred N. van Kempen.
|
||||||
* 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
|
#ifndef EMU_FLOPPY_IMG_H
|
||||||
# define EMU_FLOPPY_IMG_H
|
# define EMU_FLOPPY_IMG_H
|
||||||
|
|||||||
@@ -8,11 +8,11 @@
|
|||||||
*
|
*
|
||||||
* Implementation of the PCjs JSON floppy image format.
|
* Implementation of the PCjs JSON floppy image format.
|
||||||
*
|
*
|
||||||
* Version: @(#)fdd_json.c 1.0.6 2018/10/18
|
* Version: @(#)fdd_json.c 1.0.7 2019/12/05
|
||||||
*
|
*
|
||||||
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Author: Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
*
|
*
|
||||||
* Copyright 2017,2018 Fred N. van Kempen.
|
* Copyright 2017-2019 Fred N. van Kempen.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with
|
* Redistribution and use in source and binary forms, with
|
||||||
* or without modification, are permitted provided that the
|
* or without modification, are permitted provided that the
|
||||||
@@ -55,6 +55,7 @@
|
|||||||
#include "../timer.h"
|
#include "../timer.h"
|
||||||
#include "../plat.h"
|
#include "../plat.h"
|
||||||
#include "fdd.h"
|
#include "fdd.h"
|
||||||
|
#include "fdd_86f.h"
|
||||||
#include "fdc.h"
|
#include "fdc.h"
|
||||||
#include "fdd_common.h"
|
#include "fdd_common.h"
|
||||||
#include "fdd_json.h"
|
#include "fdd_json.h"
|
||||||
@@ -456,8 +457,7 @@ json_seek(int drive, int track)
|
|||||||
drive, side, pos, id,
|
drive, side, pos, id,
|
||||||
dev->sects[track][side][asec].data,
|
dev->sects[track][side][asec].data,
|
||||||
ssize, gap2, gap3,
|
ssize, gap2, gap3,
|
||||||
0, /*deleted flag*/
|
0 /*flags*/
|
||||||
0 /*bad_crc flag*/
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (sector == 0)
|
if (sector == 0)
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
* Implementation of the HxC MFM image format.
|
* Implementation of the HxC MFM image format.
|
||||||
*
|
*
|
||||||
* Version: @(#)fdd_mfm.c 1.0.1 2019/03/02
|
* Version: @(#)fdd_mfm.c 1.0.2 2019/12/05
|
||||||
*
|
*
|
||||||
* Authors: Miran Grca, <mgrca8@gmail.com>
|
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,50 +1,32 @@
|
|||||||
/*
|
/*
|
||||||
* VARCem Virtual ARchaeological Computer EMulator.
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||||
* An emulator of (mostly) x86-based PC systems and devices,
|
* running old operating systems and software designed for IBM
|
||||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
* PC systems and compatibles from 1981 through fairly recent
|
||||||
* spanning the era between 1981 and 1995.
|
* system designs based on the PCI bus.
|
||||||
*
|
*
|
||||||
* This file is part of the VARCem Project.
|
* This file is part of the 86Box distribution.
|
||||||
*
|
*
|
||||||
* Implementation of the Teledisk floppy image format.
|
* Implementation of the Teledisk floppy image format.
|
||||||
*
|
*
|
||||||
* Version: @(#)fdd_td0.c 1.0.8 2018/10/24
|
* Version: @(#)fdd_td0.c 1.0.9 2019/12/05
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Milodrag Milanovic,
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
|
||||||
* Milodrag Milanovic,
|
|
||||||
* Haruhiko OKUMURA,
|
* Haruhiko OKUMURA,
|
||||||
* Haruyasu YOSHIZAKI,
|
* Haruyasu YOSHIZAKI,
|
||||||
* Kenji RIKITAKE,
|
* Kenji RIKITAKE,
|
||||||
|
* Miran Grca, <mgrca8@gmail.com>
|
||||||
|
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
*
|
*
|
||||||
* Based on Japanese version 29-NOV-1988
|
* Based on Japanese version 29-NOV-1988
|
||||||
* LZSS coded by Haruhiko OKUMURA
|
* LZSS coded by Haruhiko OKUMURA
|
||||||
* Adaptive Huffman Coding coded by Haruyasu YOSHIZAKI
|
* Adaptive Huffman Coding coded by Haruyasu YOSHIZAKI
|
||||||
* Edited and translated to English by Kenji RIKITAKE
|
* Edited and translated to English by Kenji RIKITAKE
|
||||||
*
|
*
|
||||||
* Copyright 2016-2018 Miran Grca.
|
* Copyright 2013-2019 Milodrag Milanovic.
|
||||||
* Copyright 2013-2018 Milodrag Milanovic.
|
* Copyright 1988-2019 Haruhiko OKUMURA.
|
||||||
* Copyright 1988-2018 Haruhiko OKUMURA.
|
* Copyright 1988-2019 Haruyasu YOSHIZAKI.
|
||||||
* Copyright 1988-2018 Haruyasu YOSHIZAKI.
|
* Copyright 1988-2019 Kenji RIKITAKE.
|
||||||
* Copyright 1988-2018 Kenji RIKITAKE.
|
* Copyright 2016-2019 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.
|
|
||||||
*/
|
*/
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -57,6 +39,7 @@
|
|||||||
#include "../timer.h"
|
#include "../timer.h"
|
||||||
#include "../plat.h"
|
#include "../plat.h"
|
||||||
#include "fdd.h"
|
#include "fdd.h"
|
||||||
|
#include "fdd_86f.h"
|
||||||
#include "fdd_td0.h"
|
#include "fdd_td0.h"
|
||||||
#include "fdc.h"
|
#include "fdc.h"
|
||||||
|
|
||||||
@@ -113,8 +96,8 @@ typedef struct {
|
|||||||
uint8_t head;
|
uint8_t head;
|
||||||
uint8_t sector;
|
uint8_t sector;
|
||||||
uint8_t size;
|
uint8_t size;
|
||||||
uint8_t deleted;
|
uint8_t flags;
|
||||||
uint8_t bad_crc;
|
uint8_t fm;
|
||||||
uint8_t *data;
|
uint8_t *data;
|
||||||
} td0_sector_t;
|
} td0_sector_t;
|
||||||
|
|
||||||
@@ -127,6 +110,7 @@ typedef struct {
|
|||||||
uint16_t disk_flags;
|
uint16_t disk_flags;
|
||||||
uint16_t default_track_flags;
|
uint16_t default_track_flags;
|
||||||
uint16_t side_flags[256][2];
|
uint16_t side_flags[256][2];
|
||||||
|
uint8_t max_sector_size;
|
||||||
uint8_t track_in_file[256][2];
|
uint8_t track_in_file[256][2];
|
||||||
td0_sector_t sects[256][2][256];
|
td0_sector_t sects[256][2][256];
|
||||||
uint8_t track_spt[256][2];
|
uint8_t track_spt[256][2];
|
||||||
@@ -618,7 +602,7 @@ td0_initialize(int drive)
|
|||||||
int fm, head, track;
|
int fm, head, track;
|
||||||
int track_count = 0;
|
int track_count = 0;
|
||||||
int head_count = 0;
|
int head_count = 0;
|
||||||
int track_spt;
|
int track_spt, track_spt_adjusted;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
int density = 0;
|
int density = 0;
|
||||||
int temp_rate = 0;
|
int temp_rate = 0;
|
||||||
@@ -629,12 +613,14 @@ td0_initialize(int drive)
|
|||||||
uint16_t size;
|
uint16_t size;
|
||||||
uint8_t *dbuf = dev->processed_buf;
|
uint8_t *dbuf = dev->processed_buf;
|
||||||
uint32_t total_size = 0;
|
uint32_t total_size = 0;
|
||||||
|
uint32_t id_field = 0;
|
||||||
uint32_t pre_sector = 0;
|
uint32_t pre_sector = 0;
|
||||||
uint32_t track_size = 0;
|
int32_t track_size = 0;
|
||||||
uint32_t raw_tsize = 0;
|
int32_t raw_tsize = 0;
|
||||||
uint32_t minimum_gap3 = 0;
|
uint32_t minimum_gap3 = 0;
|
||||||
uint32_t minimum_gap4 = 0;
|
uint32_t minimum_gap4 = 0;
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
|
int size_diff, gap_sum;
|
||||||
|
|
||||||
if (dev->f == NULL) {
|
if (dev->f == NULL) {
|
||||||
td0_log("TD0: Attempted to initialize without loading a file first\n");
|
td0_log("TD0: Attempted to initialize without loading a file first\n");
|
||||||
@@ -699,19 +685,23 @@ td0_initialize(int drive)
|
|||||||
case 2: /* 5.25" 1.2M 360 rpm */
|
case 2: /* 5.25" 1.2M 360 rpm */
|
||||||
case 5: /* 8"/5.25"/3.5" 1.25M 360 rpm */
|
case 5: /* 8"/5.25"/3.5" 1.25M 360 rpm */
|
||||||
dev->default_track_flags = (density == 1) ? 0x20 : 0x21;
|
dev->default_track_flags = (density == 1) ? 0x20 : 0x21;
|
||||||
|
dev->max_sector_size = (density == 1) ? 6 : 5; /* 8192 or 4096 bytes. */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: /* 5.25" 360k: 300 rpm */
|
case 1: /* 5.25" 360k: 300 rpm */
|
||||||
case 3: /* 3.5" 720k: 300 rpm */
|
case 3: /* 3.5" 720k: 300 rpm */
|
||||||
dev->default_track_flags = 0x02;
|
dev->default_track_flags = 0x02;
|
||||||
|
dev->max_sector_size = 5; /* 4096 bytes. */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4: /* 3.5" 1.44M: 300 rpm */
|
case 4: /* 3.5" 1.44M: 300 rpm */
|
||||||
dev->default_track_flags = (density == 1) ? 0x00 : 0x02;
|
dev->default_track_flags = (density == 1) ? 0x00 : 0x02;
|
||||||
|
dev->max_sector_size = (density == 1) ? 6 : 5; /* 8192 or 4096 bytes. */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6: /* 3.5" 2.88M: 300 rpm */
|
case 6: /* 3.5" 2.88M: 300 rpm */
|
||||||
dev->default_track_flags = (density == 1) ? 0x00 : ((density == 2) ? 0x03 : 0x02);
|
dev->default_track_flags = (density == 1) ? 0x00 : ((density == 2) ? 0x03 : 0x02);
|
||||||
|
dev->max_sector_size = (density == 1) ? 6 : ((density == 2) ? 7 : 5); /* 16384, 8192, or 4096 bytes. */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -728,6 +718,8 @@ td0_initialize(int drive)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (track_spt != 255) {
|
while (track_spt != 255) {
|
||||||
|
track_spt_adjusted = track_spt;
|
||||||
|
|
||||||
track = dev->imagebuf[offset + 1];
|
track = dev->imagebuf[offset + 1];
|
||||||
head = dev->imagebuf[offset + 2] & 1;
|
head = dev->imagebuf[offset + 2] & 1;
|
||||||
fm = (header[5] & 0x80) || (dev->imagebuf[offset + 2] & 0x80); /* ? */
|
fm = (header[5] & 0x80) || (dev->imagebuf[offset + 2] & 0x80); /* ? */
|
||||||
@@ -735,7 +727,11 @@ td0_initialize(int drive)
|
|||||||
dev->track_in_file[track][head] = 1;
|
dev->track_in_file[track][head] = 1;
|
||||||
offset += 4;
|
offset += 4;
|
||||||
track_size = fm ? 73 : 146;
|
track_size = fm ? 73 : 146;
|
||||||
pre_sector = fm ? 42 : 60;
|
if (density == 2)
|
||||||
|
id_field = fm ? 54 : 63;
|
||||||
|
else
|
||||||
|
id_field = fm ? 35 : 44;
|
||||||
|
pre_sector = id_field + (fm ? 7 : 16);
|
||||||
|
|
||||||
for (i = 0; i < track_spt; i++) {
|
for (i = 0; i < track_spt; i++) {
|
||||||
hs = &dev->imagebuf[offset];
|
hs = &dev->imagebuf[offset];
|
||||||
@@ -745,8 +741,8 @@ td0_initialize(int drive)
|
|||||||
dev->sects[track][head][i].head = hs[1];
|
dev->sects[track][head][i].head = hs[1];
|
||||||
dev->sects[track][head][i].sector = hs[2];
|
dev->sects[track][head][i].sector = hs[2];
|
||||||
dev->sects[track][head][i].size = hs[3];
|
dev->sects[track][head][i].size = hs[3];
|
||||||
dev->sects[track][head][i].deleted = (hs[4] & 4) == 4;
|
dev->sects[track][head][i].flags = hs[4];
|
||||||
dev->sects[track][head][i].bad_crc = (hs[4] & 2) == 2;
|
dev->sects[track][head][i].fm = !!fm;
|
||||||
dev->sects[track][head][i].data = dbuf;
|
dev->sects[track][head][i].data = dbuf;
|
||||||
|
|
||||||
size = 128 << hs[3];
|
size = 128 << hs[3];
|
||||||
@@ -755,9 +751,9 @@ td0_initialize(int drive)
|
|||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hs[4] & 0x30) {
|
if (hs[4] & 0x30)
|
||||||
memset(dbuf, 0, size);
|
memset(dbuf, (hs[4] & 0x10) ? 0xf6 : 0x00, size);
|
||||||
} else {
|
else {
|
||||||
offset += 3;
|
offset += 3;
|
||||||
switch (hs[8]) {
|
switch (hs[8]) {
|
||||||
default:
|
default:
|
||||||
@@ -807,8 +803,19 @@ td0_initialize(int drive)
|
|||||||
|
|
||||||
dbuf += size;
|
dbuf += size;
|
||||||
total_size += size;
|
total_size += size;
|
||||||
|
|
||||||
|
if (hs[4] & 0x20) {
|
||||||
|
track_size += id_field;
|
||||||
|
track_spt_adjusted--;
|
||||||
|
} else if (hs[4] & 0x40)
|
||||||
|
track_size += (pre_sector - id_field + size + 2);
|
||||||
|
else {
|
||||||
|
if ((hs[4] & 0x02) || (hs[3] > (dev->max_sector_size - fm)))
|
||||||
|
track_size += (pre_sector + 3);
|
||||||
|
else
|
||||||
track_size += (pre_sector + size + 2);
|
track_size += (pre_sector + size + 2);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (track > track_count)
|
if (track > track_count)
|
||||||
track_count = track;
|
track_count = track;
|
||||||
@@ -816,24 +823,26 @@ td0_initialize(int drive)
|
|||||||
if (track_spt != 255) {
|
if (track_spt != 255) {
|
||||||
dev->track_spt[track][head] = track_spt;
|
dev->track_spt[track][head] = track_spt;
|
||||||
|
|
||||||
if ((dev->track_spt[track][head] == 8) && (dev->sects[track][head][0].size == 3)) {
|
if ((dev->track_spt[track][head] == 8) && (dev->sects[track][head][0].size == 3))
|
||||||
dev->side_flags[track][head] |= 0x20;
|
dev->side_flags[track][head] = (dev->side_flags[track][head] & ~0x67) | 0x20;
|
||||||
}
|
|
||||||
|
|
||||||
raw_tsize = get_raw_tsize(dev->side_flags[track][head], 0);
|
raw_tsize = get_raw_tsize(dev->side_flags[track][head], 0);
|
||||||
minimum_gap3 = 12 * track_spt;
|
minimum_gap3 = 12 * track_spt_adjusted;
|
||||||
if ((raw_tsize - track_size + (fm ? 73 : 146)) < (minimum_gap3 + minimum_gap4)) {
|
size_diff = raw_tsize - track_size;
|
||||||
|
gap_sum = minimum_gap3 + minimum_gap4;
|
||||||
|
if (size_diff < gap_sum) {
|
||||||
/* If we can't fit the sectors with a reasonable minimum gap at perfect RPM, let's try 2% slower. */
|
/* If we can't fit the sectors with a reasonable minimum gap at perfect RPM, let's try 2% slower. */
|
||||||
raw_tsize = get_raw_tsize(dev->side_flags[track][head], 1);
|
raw_tsize = get_raw_tsize(dev->side_flags[track][head], 1);
|
||||||
/* Set disk flags so that rotation speed is 2% slower. */
|
/* Set disk flags so that rotation speed is 2% slower. */
|
||||||
dev->disk_flags |= (3 << 5);
|
dev->disk_flags |= (3 << 5);
|
||||||
if ((raw_tsize - track_size + (fm ? 73 : 146)) < (minimum_gap3 + minimum_gap4)) {
|
size_diff = raw_tsize - track_size;
|
||||||
|
if (size_diff < gap_sum) {
|
||||||
/* If we can't fit the sectors with a reasonable minimum gap even at 2% slower RPM, abort. */
|
/* If we can't fit the sectors with a reasonable minimum gap even at 2% slower RPM, abort. */
|
||||||
td0_log("TD0: Unable to fit the %i sectors in a track\n", track_spt);
|
td0_log("TD0: Unable to fit the %i sectors in a track\n", track_spt_adjusted);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dev->calculated_gap3_lengths[track][head] = (raw_tsize - track_size - minimum_gap4 + (fm ? 73 : 146)) / track_spt;
|
dev->calculated_gap3_lengths[track][head] = (size_diff - minimum_gap4) / track_spt_adjusted;
|
||||||
|
|
||||||
track_spt = dev->imagebuf[offset];
|
track_spt = dev->imagebuf[offset];
|
||||||
}
|
}
|
||||||
@@ -1046,6 +1055,7 @@ td0_seek(int drive, int track)
|
|||||||
int ordered_pos = 0;
|
int ordered_pos = 0;
|
||||||
int real_sector = 0;
|
int real_sector = 0;
|
||||||
int actual_sector = 0;
|
int actual_sector = 0;
|
||||||
|
int fm;
|
||||||
|
|
||||||
if (dev->f == NULL) return;
|
if (dev->f == NULL) return;
|
||||||
|
|
||||||
@@ -1101,8 +1111,12 @@ td0_seek(int drive, int track)
|
|||||||
id[1] = dev->sects[track][side][actual_sector].head;
|
id[1] = dev->sects[track][side][actual_sector].head;
|
||||||
id[2] = real_sector;
|
id[2] = real_sector;
|
||||||
id[3] = dev->sects[track][side][actual_sector].size;
|
id[3] = dev->sects[track][side][actual_sector].size;
|
||||||
ssize = 128 << ((uint32_t) dev->sects[track][side][actual_sector].size);
|
fm = dev->sects[track][side][actual_sector].fm;
|
||||||
current_pos = d86f_prepare_sector(drive, side, current_pos, id, dev->sects[track][side][actual_sector].data, ssize, track_gap2, track_gap3, dev->sects[track][side][actual_sector].deleted, dev->sects[track][side][actual_sector].bad_crc);
|
if (((dev->sects[track][side][actual_sector].flags & 0x02) || (id[3] > (dev->max_sector_size - fm))) && !fdd_get_turbo(drive))
|
||||||
|
ssize = 3;
|
||||||
|
else
|
||||||
|
ssize = 128 << ((uint32_t) id[3]);
|
||||||
|
current_pos = d86f_prepare_sector(drive, side, current_pos, id, dev->sects[track][side][actual_sector].data, ssize, track_gap2, track_gap3, dev->sects[track][side][actual_sector].flags);
|
||||||
|
|
||||||
if (sector == 0)
|
if (sector == 0)
|
||||||
d86f_initialize_last_sector_id(drive, id[0], id[1], id[2], id[3]);
|
d86f_initialize_last_sector_id(drive, id[0], id[1], id[2], id[3]);
|
||||||
@@ -1116,13 +1130,16 @@ td0_seek(int drive, int track)
|
|||||||
id[1] = side;
|
id[1] = side;
|
||||||
id[2] = xdf_disk_layout[xdf_type][is_trackx][xdf_sector].id.r;
|
id[2] = xdf_disk_layout[xdf_type][is_trackx][xdf_sector].id.r;
|
||||||
id[3] = is_trackx ? (id[2] & 7) : 2;
|
id[3] = is_trackx ? (id[2] & 7) : 2;
|
||||||
ssize = 128 << ((uint32_t) id[3]);
|
|
||||||
ordered_pos = dev->xdf_ordered_pos[id[2]][side];
|
ordered_pos = dev->xdf_ordered_pos[id[2]][side];
|
||||||
if (is_trackx) {
|
fm = dev->sects[track][side][ordered_pos].fm;
|
||||||
current_pos = d86f_prepare_sector(drive, side, xdf_trackx_spos[xdf_type][xdf_sector], id, dev->sects[track][side][ordered_pos].data, ssize, track_gap2, xdf_gap3_sizes[xdf_type][is_trackx], dev->sects[track][side][ordered_pos].deleted, dev->sects[track][side][ordered_pos].bad_crc);
|
if (((dev->sects[track][side][ordered_pos].flags & 0x02) || (id[3] > (dev->max_sector_size - fm))) && !fdd_get_turbo(drive))
|
||||||
} else {
|
ssize = 3;
|
||||||
current_pos = d86f_prepare_sector(drive, side, current_pos, id, dev->sects[track][side][ordered_pos].data, ssize, track_gap2, xdf_gap3_sizes[xdf_type][is_trackx], dev->sects[track][side][ordered_pos].deleted, dev->sects[track][side][ordered_pos].bad_crc);
|
else
|
||||||
}
|
ssize = 128 << ((uint32_t) id[3]);
|
||||||
|
if (is_trackx)
|
||||||
|
current_pos = d86f_prepare_sector(drive, side, xdf_trackx_spos[xdf_type][xdf_sector], id, dev->sects[track][side][ordered_pos].data, ssize, track_gap2, xdf_gap3_sizes[xdf_type][is_trackx], dev->sects[track][side][ordered_pos].flags);
|
||||||
|
else
|
||||||
|
current_pos = d86f_prepare_sector(drive, side, current_pos, id, dev->sects[track][side][ordered_pos].data, ssize, track_gap2, xdf_gap3_sizes[xdf_type][is_trackx], dev->sects[track][side][ordered_pos].flags);
|
||||||
|
|
||||||
if (sector == 0)
|
if (sector == 0)
|
||||||
d86f_initialize_last_sector_id(drive, id[0], id[1], id[2], id[3]);
|
d86f_initialize_last_sector_id(drive, id[0], id[1], id[2], id[3]);
|
||||||
|
|||||||
@@ -1,38 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
* VARCem Virtual ARchaeological Computer EMulator.
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||||
* An emulator of (mostly) x86-based PC systems and devices,
|
* running old operating systems and software designed for IBM
|
||||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
* PC systems and compatibles from 1981 through fairly recent
|
||||||
* spanning the era between 1981 and 1995.
|
* system designs based on the PCI bus.
|
||||||
*
|
*
|
||||||
* This file is part of the VARCem Project.
|
* This file is part of the 86Box distribution.
|
||||||
*
|
*
|
||||||
* Definitions for the Teledisk floppy image format.
|
* Definitions for the Teledisk floppy image format.
|
||||||
*
|
*
|
||||||
* Version: @(#)floppy_td0.h 1.0.2 2018/03/17
|
* Version: @(#)floppy_td0.h 1.0.2 2018/03/17
|
||||||
*
|
*
|
||||||
* Authors: Fred N. van Kempen, <decwiz@yahoo.com>
|
* Authors: Miran Grca, <mgrca8@gmail.com>
|
||||||
* Miran Grca, <mgrca8@gmail.com>
|
* Fred N. van Kempen, <decwiz@yahoo.com>
|
||||||
*
|
*
|
||||||
* Copyright 2017,2018 Fred N. van Kempen.
|
|
||||||
* Copyright 2016-2018 Miran Grca.
|
* Copyright 2016-2018 Miran Grca.
|
||||||
*
|
* 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 EMU_FLOPPY_TD0_H
|
#ifndef EMU_FLOPPY_TD0_H
|
||||||
# define EMU_FLOPPY_TD0_H
|
# define EMU_FLOPPY_TD0_H
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* VARCem Virtual ARchaeological Computer EMulator.
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||||
* An emulator of (mostly) x86-based PC systems and devices,
|
* running old operating systems and software designed for IBM
|
||||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
* PC systems and compatibles from 1981 through fairly recent
|
||||||
* spanning the era between 1981 and 1995.
|
* system designs based on the PCI bus.
|
||||||
*
|
*
|
||||||
* This file is part of the VARCem Project.
|
* This file is part of the 86Box distribution.
|
||||||
*
|
*
|
||||||
* FDI to raw bit stream converter
|
* FDI to raw bit stream converter
|
||||||
* FDI format created by Vincent "ApH" Joguin
|
* FDI format created by Vincent "ApH" Joguin
|
||||||
@@ -21,24 +21,6 @@
|
|||||||
* Copyright 2001-2004 Toni Wilen.
|
* Copyright 2001-2004 Toni Wilen.
|
||||||
* Copyright 2001-2004 Vincent Joguin.
|
* Copyright 2001-2004 Vincent Joguin.
|
||||||
* Copyright 2001 Thomas Harte.
|
* 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
|
#define STATIC_INLINE
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* VARCem Virtual ARchaeological Computer EMulator.
|
* 86Box A hypervisor and IBM PC system emulator that specializes in
|
||||||
* An emulator of (mostly) x86-based PC systems and devices,
|
* running old operating systems and software designed for IBM
|
||||||
* using the ISA,EISA,VLB,MCA and PCI system buses, roughly
|
* PC systems and compatibles from 1981 through fairly recent
|
||||||
* spanning the era between 1981 and 1995.
|
* system designs based on the PCI bus.
|
||||||
*
|
*
|
||||||
* This file is part of the VARCem Project.
|
* This file is part of the 86Box distribution.
|
||||||
*
|
*
|
||||||
* Definitions for the FDI floppy file format.
|
* Definitions for the FDI floppy file format.
|
||||||
*
|
*
|
||||||
@@ -17,24 +17,6 @@
|
|||||||
* Copyright 2001-2004 Toni Wilen.
|
* Copyright 2001-2004 Toni Wilen.
|
||||||
* Copyright 2001-2004 Vincent Joguin.
|
* Copyright 2001-2004 Vincent Joguin.
|
||||||
* Copyright 2001 Thomas Harte.
|
* 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
|
#ifndef __FDI2RAW_H
|
||||||
#define __FDI2RAW_H
|
#define __FDI2RAW_H
|
||||||
|
|||||||
Reference in New Issue
Block a user