// license:BSD-3-Clause
// copyright-holders:Fabio Priuli
/*********************************************************************
formats/fdd_dsk.h
PC98 FDD disk images
0xC3FC header, followed by track data
Sector map starts at offset 0xDC, with 12bytes for each sector
Each entry of the sector map has the following structure
- 0x0 = track number (if 0xff the sector/track is unformatted/unused)
- 0x1 = head number
- 0x2 = sector number
- 0x3 = sector size (128 << this byte)
- 0x4 = fill byte. if it's not 0xff, then this sector in the original
disk consisted of this single value repeated for the whole
sector size, and the sector is skipped in the .fdd file.
if it's 0xff, then this sector is wholly contained in the .fdd
file
- 0x5 = ??
- 0x6 = ??
- 0x7 = ??
- 0x8-0x0b = absolute offset of the data for this sector, or 0xfffffff
if the sector was skipped in the .fdd (and it has to be
filled with the value at 0x4)
TODO:
- Investigate remaining sector map bytes (maybe related to protections?)
*********************************************************************/
#include <assert.h>
#include "fdd_dsk.h"
fdd_format::fdd_format()
{
}
const char *fdd_format::name() const
{
return "fdd";
}
const char *fdd_format::description() const
{
return "FDD disk image";
}
const char *fdd_format::extensions() const
{
return "fdd";
}
int fdd_format::identify(io_generic *io, uint32_t form_factor)
{
uint8_t h[7];
io_generic_read(io, h, 0, 7);
if (strncmp((const char *)h, "VFD1.0", 6) == 0)
return 100;
return 0;
}
bool fdd_format::load(io_generic *io, uint32_t form_factor, floppy_image *image)
{
uint8_t hsec[0x0c];
// sector map
uint8_t num_secs[160];
uint8_t tracks[160 * 26];
uint8_t heads[160 * 26];
uint8_t secs[160 * 26];
uint8_t fill_vals[160 * 26];
uint32_t sec_offs[160 * 26];
uint8_t sec_sizes[160 * 26];
int pos = 0xdc;
for