mirror of
https://github.com/holub/mame
synced 2025-05-10 16:21:42 +03:00
mess sync (nw)
This commit is contained in:
parent
517ae1369f
commit
f659a7f5ff
@ -0,0 +1,112 @@
|
|||||||
|
#include "emu.h"
|
||||||
|
#include "dfi_dsk.h"
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
|
dfi_format::dfi_format() : floppy_image_format_t()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *dfi_format::name() const
|
||||||
|
{
|
||||||
|
return "dfi";
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *dfi_format::description() const
|
||||||
|
{
|
||||||
|
return "Diskferret flux dump format";
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *dfi_format::extensions() const
|
||||||
|
{
|
||||||
|
return "dfi";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dfi_format::supports_save() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int dfi_format::identify(io_generic *io, UINT32 form_factor)
|
||||||
|
{
|
||||||
|
char sign[4];
|
||||||
|
io_generic_read(io, sign, 0, 4);
|
||||||
|
return memcmp(sign, "DFE2", 4) ? 0 : 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool dfi_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
|
||||||
|
{
|
||||||
|
int size = io_generic_size(io);
|
||||||
|
int pos = 4;
|
||||||
|
UINT8 *data = 0;
|
||||||
|
int data_size = 0;
|
||||||
|
|
||||||
|
while(pos < size) {
|
||||||
|
UINT8 h[10];
|
||||||
|
io_generic_read(io, h, pos, 10);
|
||||||
|
UINT16 track = (h[0] << 8) | h[1];
|
||||||
|
UINT16 head = (h[2] << 8) | h[3];
|
||||||
|
// Ignore sector
|
||||||
|
UINT32 tsize = (h[6] << 24) | (h[7] << 16) | (h[8] << 8) | h[9];
|
||||||
|
|
||||||
|
if(pos+tsize+10 > size) {
|
||||||
|
if(data)
|
||||||
|
global_free(data);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tsize > data_size) {
|
||||||
|
if(data)
|
||||||
|
global_free(data);
|
||||||
|
data_size = tsize;
|
||||||
|
data = global_alloc_array(UINT8, data_size);
|
||||||
|
}
|
||||||
|
|
||||||
|
io_generic_read(io, data, pos+16, tsize);
|
||||||
|
pos += tsize+10;
|
||||||
|
tsize--; // Drop the extra 0x00 at the end
|
||||||
|
|
||||||
|
int index_time = 0;
|
||||||
|
int total_time = 0;
|
||||||
|
for(int i=0; i<tsize; i++) {
|
||||||
|
UINT8 v = data[i];
|
||||||
|
if((v & 0x7f) == 0x7f)
|
||||||
|
total_time += 0x7f;
|
||||||
|
else {
|
||||||
|
total_time += v & 0x7f;
|
||||||
|
if((v & 0x80) && !index_time)
|
||||||
|
index_time = total_time;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!index_time)
|
||||||
|
index_time = total_time;
|
||||||
|
|
||||||
|
image->set_track_size(track, head, tsize);
|
||||||
|
|
||||||
|
int cur_time = 0;
|
||||||
|
UINT32 mg = floppy_image::MG_A;
|
||||||
|
UINT32 *buf = image->get_buffer(track, head);
|
||||||
|
int tpos = 0;
|
||||||
|
buf[tpos++] = mg;
|
||||||
|
for(int i=0; i<tsize; i++) {
|
||||||
|
UINT8 v = data[i];
|
||||||
|
if((v & 0x7f) == 0x7f)
|
||||||
|
cur_time += 0x7f;
|
||||||
|
else {
|
||||||
|
cur_time += v & 0x7f;
|
||||||
|
if(v & 0x80)
|
||||||
|
break;
|
||||||
|
mg = mg == floppy_image::MG_A ? floppy_image::MG_B : floppy_image::MG_A;
|
||||||
|
buf[tpos++] = mg | UINT32(200000000ULL*cur_time/index_time);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
image->set_track_size(track, head, tpos);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(data)
|
||||||
|
global_free(data);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const floppy_format_type FLOPPY_DFI_FORMAT = &floppy_image_format_creator<dfi_format>;
|
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef DFI_DSK_H
|
||||||
|
#define DFI_DSK_H
|
||||||
|
|
||||||
|
#include "flopimg.h"
|
||||||
|
|
||||||
|
class dfi_format : public floppy_image_format_t
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
dfi_format();
|
||||||
|
|
||||||
|
virtual int identify(io_generic *io, UINT32 form_factor);
|
||||||
|
virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image);
|
||||||
|
// virtual bool save(io_generic *io, floppy_image *image);
|
||||||
|
|
||||||
|
virtual const char *name() const;
|
||||||
|
virtual const char *description() const;
|
||||||
|
virtual const char *extensions() const;
|
||||||
|
virtual bool supports_save() const;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern const floppy_format_type FLOPPY_DFI_FORMAT;
|
||||||
|
|
||||||
|
#endif /* DFI_DSK_H */
|
@ -2018,6 +2018,7 @@ void floppy_image_format_t::extract_sectors_from_bitstream_mfm_pc(const UINT8 *b
|
|||||||
UINT8 head = sbyte_mfm_r(bitstream, pos, track_size);
|
UINT8 head = sbyte_mfm_r(bitstream, pos, track_size);
|
||||||
UINT8 sector = sbyte_mfm_r(bitstream, pos, track_size);
|
UINT8 sector = sbyte_mfm_r(bitstream, pos, track_size);
|
||||||
UINT8 size = sbyte_mfm_r(bitstream, pos, track_size);
|
UINT8 size = sbyte_mfm_r(bitstream, pos, track_size);
|
||||||
|
|
||||||
if(size >= 8)
|
if(size >= 8)
|
||||||
continue;
|
continue;
|
||||||
int ssize = 128 << size;
|
int ssize = 128 << size;
|
||||||
@ -2027,13 +2028,13 @@ void floppy_image_format_t::extract_sectors_from_bitstream_mfm_pc(const UINT8 *b
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Start of IDAM and DAM are supposed to be exactly 704 cells
|
// Start of IDAM and DAM are supposed to be exactly 704 cells
|
||||||
// apart. Of course the hardware is tolerant, but not that
|
// apart. Of course the hardware is tolerant. Accept +/- 128
|
||||||
// tolerant. Accept +/- 32 cells of shift.
|
// cells of shift.
|
||||||
|
|
||||||
int d_index;
|
int d_index;
|
||||||
for(d_index = 0; d_index < dblk_count; d_index++) {
|
for(d_index = 0; d_index < dblk_count; d_index++) {
|
||||||
int delta = dblk[d_index] - idblk[i];
|
int delta = dblk[d_index] - idblk[i];
|
||||||
if(delta >= 704-32 && delta <= 704+32)
|
if(delta >= 704-128 && delta <= 704+128)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if(d_index == dblk_count)
|
if(d_index == dblk_count)
|
||||||
|
@ -135,3 +135,142 @@ LEGACY_FLOPPY_OPTIONS_START( pc )
|
|||||||
TRACKS(40/[80])
|
TRACKS(40/[80])
|
||||||
SECTORS(8/[9]/10/15/18/36))
|
SECTORS(8/[9]/10/15/18/36))
|
||||||
LEGACY_FLOPPY_OPTIONS_END
|
LEGACY_FLOPPY_OPTIONS_END
|
||||||
|
|
||||||
|
|
||||||
|
const floppy_image_format_t::desc_e pc_format::pc_desc[] = {
|
||||||
|
{ MFM, 0x4e, 80 },
|
||||||
|
{ MFM, 0x00, 12 },
|
||||||
|
{ RAW, 0x5224, 3 },
|
||||||
|
{ MFM, 0xfc, 1 },
|
||||||
|
{ MFM, 0x4e, 50 },
|
||||||
|
{ MFM, 0x00, 12 },
|
||||||
|
{ SECTOR_LOOP_START, 0, 17 },
|
||||||
|
{ CRC_CCITT_START, 1 },
|
||||||
|
{ RAW, 0x4489, 3 },
|
||||||
|
{ MFM, 0xfe, 1 },
|
||||||
|
{ TRACK_ID },
|
||||||
|
{ HEAD_ID },
|
||||||
|
{ SECTOR_ID },
|
||||||
|
{ SIZE_ID },
|
||||||
|
{ CRC_END, 1 },
|
||||||
|
{ CRC, 1 },
|
||||||
|
{ MFM, 0x4e, 22 },
|
||||||
|
{ MFM, 0x00, 12 },
|
||||||
|
{ CRC_CCITT_START, 2 },
|
||||||
|
{ RAW, 0x4489, 3 },
|
||||||
|
{ MFM, 0xfb, 1 },
|
||||||
|
{ SECTOR_DATA, -1 },
|
||||||
|
{ CRC_END, 2 },
|
||||||
|
{ CRC, 2 },
|
||||||
|
{ MFM, 0x4e, 84 },
|
||||||
|
{ MFM, 0x00, 12 },
|
||||||
|
{ SECTOR_LOOP_END },
|
||||||
|
{ MFM, 0x4e, 498 },
|
||||||
|
{ END }
|
||||||
|
};
|
||||||
|
|
||||||
|
pc_format::pc_format()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *pc_format::name() const
|
||||||
|
{
|
||||||
|
return "pc";
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *pc_format::description() const
|
||||||
|
{
|
||||||
|
return "PC floppy disk image";
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *pc_format::extensions() const
|
||||||
|
{
|
||||||
|
return "dsk,ima,img,ufi,360";
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pc_format::supports_save() const
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void pc_format::find_size(io_generic *io, UINT32 form_factor, int &track_count, int &head_count, int §or_count)
|
||||||
|
{
|
||||||
|
int size = io_generic_size(io);
|
||||||
|
if(size == 512*18*2*80) {
|
||||||
|
track_count = 80;
|
||||||
|
head_count = 2;
|
||||||
|
sector_count = 18;
|
||||||
|
} else
|
||||||
|
track_count = head_count = sector_count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int pc_format::identify(io_generic *io, UINT32 form_factor)
|
||||||
|
{
|
||||||
|
int track_count, head_count, sector_count;
|
||||||
|
find_size(io, form_factor, track_count, head_count, sector_count);
|
||||||
|
|
||||||
|
if(track_count)
|
||||||
|
return 50;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pc_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
|
||||||
|
{
|
||||||
|
int track_count, head_count, sector_count;
|
||||||
|
find_size(io, form_factor, track_count, head_count, sector_count);
|
||||||
|
|
||||||
|
UINT8 sectdata[36*512];
|
||||||
|
desc_s sectors[36];
|
||||||
|
for(int i=0; i<sector_count; i++) {
|
||||||
|
sectors[i].data = sectdata + 512*i;
|
||||||
|
sectors[i].size = 512;
|
||||||
|
sectors[i].sector_id = i + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int track_size = sector_count*512;
|
||||||
|
for(int track=0; track < track_count; track++) {
|
||||||
|
for(int head=0; head < head_count; head++) {
|
||||||
|
io_generic_read(io, sectdata, (track*head_count + head)*track_size, track_size);
|
||||||
|
generate_track(pc_desc,
|
||||||
|
track, head, sectors, sector_count, 200000, image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
image->set_variant(floppy_image::DSHD);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool pc_format::save(io_generic *io, floppy_image *image)
|
||||||
|
{
|
||||||
|
int track_count, head_count, sector_count;
|
||||||
|
get_geometry_mfm_pc(image, 1000, track_count, head_count, sector_count);
|
||||||
|
|
||||||
|
if(track_count < 80)
|
||||||
|
track_count = 80;
|
||||||
|
else if(track_count > 82)
|
||||||
|
track_count = 82;
|
||||||
|
|
||||||
|
// Happens for a fully unformatted floppy
|
||||||
|
if(!head_count)
|
||||||
|
head_count = 1;
|
||||||
|
|
||||||
|
if(sector_count > 36)
|
||||||
|
sector_count = 36;
|
||||||
|
else if(sector_count < 9)
|
||||||
|
sector_count = 9;
|
||||||
|
|
||||||
|
UINT8 sectdata[36*512];
|
||||||
|
int track_size = sector_count*512;
|
||||||
|
|
||||||
|
for(int track=0; track < track_count; track++) {
|
||||||
|
for(int head=0; head < head_count; head++) {
|
||||||
|
get_track_data_mfm_pc(track, head, image, 1000, 512, sector_count, sectdata);
|
||||||
|
io_generic_write(io, sectdata, (track*head_count + head)*track_size, track_size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
const floppy_format_type FLOPPY_PC_FORMAT = &floppy_image_format_creator<pc_format>;
|
||||||
|
@ -16,4 +16,27 @@
|
|||||||
|
|
||||||
LEGACY_FLOPPY_OPTIONS_EXTERN(pc);
|
LEGACY_FLOPPY_OPTIONS_EXTERN(pc);
|
||||||
|
|
||||||
|
|
||||||
|
class pc_format : public floppy_image_format_t
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
pc_format();
|
||||||
|
|
||||||
|
virtual int identify(io_generic *io, UINT32 form_factor);
|
||||||
|
virtual bool load(io_generic *io, UINT32 form_factor, floppy_image *image);
|
||||||
|
virtual bool save(io_generic *io, floppy_image *image);
|
||||||
|
|
||||||
|
virtual const char *name() const;
|
||||||
|
virtual const char *description() const;
|
||||||
|
virtual const char *extensions() const;
|
||||||
|
virtual bool supports_save() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static const desc_e pc_desc[];
|
||||||
|
|
||||||
|
void find_size(io_generic *io, UINT32 form_factor, int &track_count, int &head_count, int §or_count);
|
||||||
|
};
|
||||||
|
|
||||||
|
extern const floppy_format_type FLOPPY_PC_FORMAT;
|
||||||
|
|
||||||
#endif /* PC_DSK_H */
|
#endif /* PC_DSK_H */
|
||||||
|
@ -107,6 +107,7 @@ FORMATSOBJS = \
|
|||||||
$(LIBOBJ)/formats/d64_dsk.o \
|
$(LIBOBJ)/formats/d64_dsk.o \
|
||||||
$(LIBOBJ)/formats/d81_dsk.o \
|
$(LIBOBJ)/formats/d81_dsk.o \
|
||||||
$(LIBOBJ)/formats/d88_dsk.o \
|
$(LIBOBJ)/formats/d88_dsk.o \
|
||||||
|
$(LIBOBJ)/formats/dfi_dsk.o \
|
||||||
$(LIBOBJ)/formats/dim_dsk.o \
|
$(LIBOBJ)/formats/dim_dsk.o \
|
||||||
$(LIBOBJ)/formats/dsk_dsk.o \
|
$(LIBOBJ)/formats/dsk_dsk.o \
|
||||||
$(LIBOBJ)/formats/fdi_dsk.o \
|
$(LIBOBJ)/formats/fdi_dsk.o \
|
||||||
|
Loading…
Reference in New Issue
Block a user