IECHost track nibbling with a 1571 drive: full disk nibbled

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:

IECHost: G64 file created with a 1571 drive by Luigi Di Fraia
IECHost: G64 file created with a 1571 drive

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!

About Luigi Di Fraia

I am a Senior DevOps Engineer so I get to work with the latest technologies and open-source software. However, in my private time I enjoy retro-computing.
This entry was posted in Retrocomputing, Reverse Engineering, Technical and tagged , , , , , , , . Bookmark the permalink.

2 Responses to IECHost track nibbling with a 1571 drive: full disk nibbled

  1. Pingback: IECHost track nibbling with a 1571 drive: troubleshooting successful | Luigi Di Fraia's e-Footsteps

  2. Pingback: IECHost track nibbling with a 1571 drive: NIB file format creation | Luigi Di Fraia's e-Footsteps

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s