Skip to content

Commit

Permalink
Support "Head Over Heels" which uses a minor variant of Special FX fo…
Browse files Browse the repository at this point in the history
…rmat.

Refs #73
  • Loading branch information
keirf committed Jan 28, 2020
1 parent 7f5394a commit 2557478
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 5 deletions.
4 changes: 4 additions & 0 deletions disk-analyse/formats
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
33 changes: 28 additions & 5 deletions libdisk/format/amiga/special_fx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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];

Expand All @@ -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)))
Expand Down Expand Up @@ -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];
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions libdisk/include/libdisk/track_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)")

0 comments on commit 2557478

Please sign in to comment.