pc_dsk: Support 360K images with 512-byte header, found in some softlist entries. [Justin Kerk]

This commit is contained in:
Justin Kerk 2016-12-29 14:44:50 -08:00 committed by angelosa
parent 54ae9d208b
commit a8ef9c2521
5 changed files with 21 additions and 7 deletions

View File

@ -3202,8 +3202,7 @@ Known PC Booter Games Not Dumped, Or Dumped and Lost when Demonlord's Site went
</part>
</software>
<!-- Fatal error: Device 5.25" double density floppy drive load failed: Unable to identify the image format -->
<software name="msdos33" supported="no">
<software name="msdos33">
<description>MS-DOS (Version 3.30)</description>
<year>1987</year>
<publisher>Microsoft</publisher>
@ -3296,8 +3295,7 @@ Known PC Booter Games Not Dumped, Or Dumped and Lost when Demonlord's Site went
</part>
</software>
<!-- Fatal error: Device 5.25" double density floppy drive load failed: Unable to identify the image format -->
<software name="msdos401m" cloneof="msdos401" supported="no">
<software name="msdos401m" cloneof="msdos401">
<description>MS-DOS (Version 4.01, 5.25")</description>
<year>1988</year>
<publisher>Microsoft</publisher>

View File

@ -159,6 +159,18 @@ const char *pc_format::extensions() const
return "dsk,ima,img,ufi,360";
}
int pc_format::identify(io_generic *io, uint32_t form_factor)
{
uint64_t size = io_generic_size(io);
/* some 360K images have a 512-byte header */
if (size == 368640 + 0x200) {
file_header_skip_bytes = 0x200;
}
return upd765_format::identify(io, form_factor);
}
const pc_format::format pc_format::formats[] = {
{ /* 160K 5 1/4 inch double density single sided */
floppy_image::FF_525, floppy_image::SSDD, floppy_image::MFM,

View File

@ -24,6 +24,8 @@ class pc_format : public upd765_format
public:
pc_format();
virtual int identify(io_generic *io, uint32_t form_factor) override;
virtual const char *name() const override;
virtual const char *description() const override;
virtual const char *extensions() const override;

View File

@ -11,7 +11,7 @@
#include "emu.h" // emu_fatalerror
#include "formats/upd765_dsk.h"
upd765_format::upd765_format(const format *_formats)
upd765_format::upd765_format(const format *_formats) : file_header_skip_bytes(0)
{
formats = _formats;
}
@ -24,7 +24,7 @@ int upd765_format::find_size(io_generic *io, uint32_t form_factor) const
if(form_factor != floppy_image::FF_UNKNOWN && form_factor != f.form_factor)
continue;
if(size == (uint64_t) compute_track_size(f) * f.track_count * f.head_count)
if(size == file_header_skip_bytes + (uint64_t) compute_track_size(f) * f.track_count * f.head_count)
return i;
}
return -1;
@ -220,7 +220,7 @@ bool upd765_format::load(io_generic *io, uint32_t form_factor, floppy_image *ima
for(int track=0; track < f.track_count; track++)
for(int head=0; head < f.head_count; head++) {
build_sector_description(f, sectdata, sectors, track, head);
io_generic_read(io, sectdata, (track*f.head_count + head)*track_size, track_size);
io_generic_read(io, sectdata, file_header_skip_bytes + (track*f.head_count + head)*track_size, track_size);
generate_track(desc, track, head, sectors, f.sector_count, total_size, image);
}

View File

@ -44,6 +44,8 @@ public:
virtual bool supports_save() const override;
protected:
uint64_t file_header_skip_bytes;
floppy_image_format_t::desc_e* get_desc_fm(const format &f, int &current_size, int &end_gap_index);
floppy_image_format_t::desc_e* get_desc_mfm(const format &f, int &current_size, int &end_gap_index);
int find_size(io_generic *io, uint32_t form_factor) const;