ap_dsk35: support .2MG images in the new-style apple_gcr_format [R. Belmont]

This commit is contained in:
arbee 2021-02-04 19:27:34 -05:00
parent 15d09a130d
commit 9a4421810c
2 changed files with 29 additions and 1 deletions

View File

@ -1378,6 +1378,8 @@ const floppy_format_type FLOPPY_DC42_FORMAT = &floppy_image_format_creator<dc42_
apple_gcr_format::apple_gcr_format() : floppy_image_format_t()
{
m_bIs2MG = false;
m_u2MGOffset = 0;
}
const char *apple_gcr_format::name() const
@ -1405,6 +1407,14 @@ int apple_gcr_format::identify(io_generic *io, uint32_t form_factor, const std::
uint64_t size = io_generic_size(io);
if(size == 409600 || size == 819200)
return 50;
uint8_t signature[4];
io_generic_read(io, signature, 0, 4);
if (!strncmp(reinterpret_cast<char *>(signature), "2IMG", 4))
{
return 100;
}
return 0;
}
@ -1415,8 +1425,17 @@ bool apple_gcr_format::load(io_generic *io, uint32_t form_factor, const std::vec
int pos_data = 0;
uint8_t header[64];
io_generic_read(io, header, 0, 64);
m_bIs2MG = false;
if (!strncmp(reinterpret_cast<char *>(header), "2IMG", 4))
{
m_u2MGOffset = pos_data = header[0x18] | (header[0x19] << 8) | (header[0x1a] << 16) | (header[0x1b] << 24);
m_bIs2MG = true;
}
uint64_t size = io_generic_size(io);
int head_count = size == 409600 ? 1 : size == 819200 ? 2 : 0;
int head_count = size == 409600 ? 1 : size >= 819200 ? 2 : 0;
if(!head_count)
return false;
@ -1455,6 +1474,11 @@ bool apple_gcr_format::save(io_generic *io, const std::vector<uint32_t> &variant
int pos_data = 0;
if (m_bIs2MG)
{
pos_data = m_u2MGOffset;
}
for(int track=0; track < 80; track++) {
for(int head=0; head < g_heads; head++) {
auto sectors = extract_sectors_from_track_mac_gcr6(head, track, image);

View File

@ -57,6 +57,10 @@ public:
virtual const char *description() const override;
virtual const char *extensions() const override;
virtual bool supports_save() const override;
private:
bool m_bIs2MG;
uint32_t m_u2MGOffset;
};
extern const floppy_format_type FLOPPY_APPLE_GCR_FORMAT;