0 Members and 1 Guest are viewing this topic.
Shrug... this does not look like anything I would expect to find on a standard Amiga formatted floppy disk. Are you sure you are looking for MFM data? If this is the data structure layout, I would expect it to be a container format, not the contents.
You may not be able to see this pattern in the encoded MFM data at all. The thing is, this is a bit pattern, not a byte pattern. It can start in the MFM bit stream at virtually any position in the track buffer, but usually it's somewhere near the beginning of the buffer.
So, how do you find the bit position where it starts? The key is the 0xAAAA pattern, which either shows up as 0xAAAA in the MFM bit stream (if the header starts at an even bit position), or as 0x5555 (if it starts at an odd bit position).The first step to decoding is to find out where the 0xAAAA bit pattern shows up. Because it covers 32 bits, you should be able to find it by looking for any two consecutive bytes which either read as 0xAA or as 0x55....
; The CRC is computed not only over the actual data, but including; the SYNC mark (3 * $a1) and the 'ID/DATA - Address Mark' ($fe/$fb).
#!/usr/bin/perl# decode MFM TIM011 SECTOR SIZE= 1024bytes, sectors_per_track=5use strict;use warnings;use Digest::CRC qw(crc32 crcccitt crcccitt_hex crc16 crc16_hex crc_hex crc8_hex);use utf8;use bytes;# OFFSET Count TYPE Description# 0000h 8 byte UAE-1ADF# 0008h 4 byte trackcount# 000Eh 4 byte 0=amigados 1=raw mfm# 0010h 4 byte tracklength# 0014h 4 byte tracklength in bits# ..my ( $i, @tracks, $trackdata, $trackcount, $header, $bitdata, @sector, @track, $image, $data );my ( $file_in, $file_out ) = ( $ARGV[0], $ARGV[1] );my $syncbit = unpack "B*", "\xAA\xAA\xAA\xAA\x44\x89\x44\x89\x44\x89";my $sector_per_track = 5;my $sector_length = 1024;{local $/; open( FILE0, "< :raw :bytes", "$file_in" ) or die "Can't open for reading: $!\n"; $data = ; close(FILE0);}$header = substr ($data, 0, 2004); # header = 8+4+166*12 = 2004$trackcount = unpack "N", substr ($data, 8, 4);$trackdata = substr ($data, 12, 12*$trackcount);@tracks = $trackdata =~ /.{12}/gs;$data = substr ($data, 2004); # print "\n\ndatalen1=" . length $data . "\n";# exit;$bitdata = unpack "B*",$data;for my $i (0 .. 159) { #159 my $tracklenbit = unpack "N", substr ($tracks[$i], 8, 4); print "\ntrack=$i, tracklen=$tracklenbit \n"; my $trackdata = substr ($bitdata, 0, $tracklenbit); $bitdata = substr ($bitdata, $tracklenbit); for my $j (1 .. $sector_per_track) { # 5 my $pos = index ($trackdata, $syncbit)+length($syncbit); my $sector_id = substr ($trackdata, $pos, 16+ 4*8*2); #16:FE $sector_id =~ s/.(.)/$1/gs; #strip clock $sector_id = pack "B*",$sector_id; my ($track_num, $side_num, $sector_num, $sector_s ) = unpack("xc1c1c1c1", $sector_id); print " sector=$sector_num, sector size=$sector_s \n" ; $pos = index ($trackdata, $syncbit, $pos)+length($syncbit); my $sector_dat = substr ($trackdata, $pos+16, $sector_length*8*2+32); # 16:FB 32:CRC=C74C $trackdata = substr ($trackdata, $pos); $sector_dat =~ s/.(.)/$1/gs; #strip clock $sector[$sector_num] = pack "B*", substr ($sector_dat, 0, $sector_length*; my $crc = unpack "n*", pack "B*", substr ($sector_dat, $sector_length*; my $crc_chk = crcccitt( "\xA1\xA1\xA1\xFB" . $sector[$sector_num]); if ( $crc eq $crc_chk) { print "CRC OK!\n"; } else { print "CRC ERROR! , $crc, $crc_chk \n\n" ; exit; } } $track[$i] = join ("", $sector[17], $sector[18], $sector[19], $sector[20], $sector[21]);}$image = join ("", @track);{local $/; open( FILE0, "> :raw :bytes", "$file_out" ) or die "write err: $!\n"; print FILE0 $image; close(FILE0);} exit;
I'm testing with a normal OFS floppy...I did use the -r option... but the output is still ordinary bytes not encoded data