From 25574788e8c7a3aa1c7771c592a906d39551f957 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Tue, 28 Jan 2020 08:24:55 +0000 Subject: [PATCH] Support "Head Over Heels" which uses a minor variant of Special FX format. Refs #73 --- disk-analyse/formats | 4 ++++ libdisk/format/amiga/special_fx.c | 33 +++++++++++++++++++++++---- libdisk/include/libdisk/track_types.h | 1 + 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/disk-analyse/formats b/disk-analyse/formats index 74f57fbc..2f7fc87a 100644 --- a/disk-analyse/formats +++ b/disk-analyse/formats @@ -770,6 +770,10 @@ probe_amiga # Harpoon, Secenario Editor and All Battleset Disks! "Harpoon" = amigados +"Head Over Heels" # Tracks 82+ may be empty + 0-1 amigados_long_102200 + * head_over_heels + "Heart Of China" = amigados "Heimdall" = amigados_copylock diff --git a/libdisk/format/amiga/special_fx.c b/libdisk/format/amiga/special_fx.c index 93d0ff05..bcec257a 100644 --- a/libdisk/format/amiga/special_fx.c +++ b/libdisk/format/amiga/special_fx.c @@ -47,6 +47,22 @@ static uint32_t checksum(uint16_t *dat) return sum; } +static void init_hdr( + const struct track_info *ti, unsigned int tracknr, struct hdr *hdr) +{ + memset(hdr, 0, sizeof(*hdr)); + switch (ti->type) { + case TRKTYP_head_over_heels: + hdr->track = tracknr-2; + hdr->mbz = 1; + break; + default: + hdr->track = (tracknr-2)^1; + hdr->mbz = 0; + break; + } +} + static void *special_fx_write_raw( struct disk *d, unsigned int tracknr, struct stream *s) { @@ -59,7 +75,7 @@ static void *special_fx_write_raw( while ((stream_next_bit(s) != -1) && (nr_valid_blocks != ti->nr_sectors)) { - struct hdr hdr; + struct hdr hdr, exp; uint32_t csum, idx_off; uint16_t dat[512]; @@ -72,8 +88,9 @@ static void *special_fx_write_raw( break; mfm_decode_bytes(bc_mfm_even_odd, 4, dat, &hdr); - if ((hdr.track != ((tracknr-2)^1)) || - (hdr.mbz != 0) || + init_hdr(ti, tracknr, &exp); + if ((hdr.track != exp.track) || + (hdr.mbz != exp.mbz) || (hdr.to_gap < 1) || (hdr.to_gap > 12) || (hdr.sector >= ti->nr_sectors) || (is_valid_sector(ti, hdr.sector))) @@ -129,10 +146,9 @@ static void special_fx_read_raw( /* filler */ tbuf_bits(tbuf, SPEED_AVG, bc_mfm, 8, 0); /* header info */ - hdr.track = (tracknr-2)^1; + init_hdr(ti, tracknr, &hdr); hdr.sector = (first_sector + i) % 12; hdr.to_gap = 12-i; - hdr.mbz = 0; tbuf_bytes(tbuf, SPEED_AVG, bc_mfm_even_odd, 4, &hdr); /* data checksum */ dat = (uint16_t *)&ti->dat[512*hdr.sector]; @@ -154,6 +170,13 @@ struct track_handler special_fx_handler = { .read_raw = special_fx_read_raw }; +struct track_handler head_over_heels_handler = { + .bytes_per_sector = 512, + .nr_sectors = 12, + .write_raw = special_fx_write_raw, + .read_raw = special_fx_read_raw +}; + /* * Local variables: * mode: C diff --git a/libdisk/include/libdisk/track_types.h b/libdisk/include/libdisk/track_types.h index e3ca94cd..d325108c 100644 --- a/libdisk/include/libdisk/track_types.h +++ b/libdisk/include/libdisk/track_types.h @@ -205,3 +205,4 @@ X(herndon_hls, "Herndon HLS") X(turrican_3a, "Turrican 3 A") X(turrican_3b, "Turrican 3 B") X(turrican_3c, "Turrican 3 C") +X(head_over_heels, "Head Over Heels (Special FX)")