This afternoon I decided to put together the scenario to dump a whole disk with IECHost and my Commodore 1571 drive. I collected track data in a mixed-content log (commands + data) and parsed it to build a G64 disk image.
The script I came up with for this purpose is quite simple. Bear in mind that WordPress’ block editor behaves oddly (at least in Google Chrome, which is what I am using) when it comes to inserting code snippets into posts: I usually have to replace blank spaces with ALT+255 otherwise they are removed; ‘#’ and ‘*’ characters get removed systematically. Therefore, the below might have been altered when I pasted into this code block: you have been warned!
#!/bin/bash
function int2dword() {
local i=$1
local f
printf -v f '\\x%02x\\x%02x\\x%02x\\x%02x' $((i&255)) $((i >> 8 & 255)) $((i >> 16 & 255)) $((i >> 24 & 255))
printf "$f"
}
# File signature
echo -n "GCR-1541" > output.g64
# Version, track count and bytes in each track
echo -n -e "\\x00\\x54\\x00\\x20" >> output.g64
# Track data absolute offsets
for track in {1..84}; do
tt=$(( ${track} - 1 ))
if (( (${tt} % 2) == 0 && ${track} <= 35*2 ))
then
int2dword $(( 684+8194*(${tt}/2) )) >> output.g64
else
int2dword 0 >> output.g64
fi
done
# Density map
for track in {1..84}; do
density=$(( 3 - (${track} >= 18*2) - (${track} >= 25*2) - (${track} >= 31*2) ))
int2dword ${density} >> output.g64
done
# Track data
for ofs in $(grep -obUaP "\x3E\x20\x6E\x72\x0D" track_1_35.log | awk -F":" {'print $1'}); do
echo -n -e "\\x00\\x20" >> output.g64
skp=$(( ${ofs} + 10 ))
dd bs=1 skip=${skp} count=8192 if=track_1_35.log >> output.g64
done
I tried to attach the G64 file in VICE and here’s what the image decoder showed:
I have to do some troubleshooting now as the image itself doesn’t load as it should, but that’s my next job 🙂
Stay tuned for more!
Pingback: IECHost track nibbling with a 1571 drive: troubleshooting successful | Luigi Di Fraia's e-Footsteps
Pingback: IECHost track nibbling with a 1571 drive: NIB file format creation | Luigi Di Fraia's e-Footsteps