Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Commodore 1581? #74

Open
tokudan opened this issue Feb 11, 2020 · 5 comments
Open

Support for Commodore 1581? #74

tokudan opened this issue Feb 11, 2020 · 5 comments

Comments

@tokudan
Copy link

tokudan commented Feb 11, 2020

I've got a 1581 with a couple of disks and can provide an image from the 1581 Demo Disk and maybe other disks.
Are you interested in adding support for this format?

@keirf
Copy link
Owner

keirf commented Feb 12, 2020

Probably already supported: Try passing a dump into disk-analyse with --format=ibm_mfm_dd

@tokudan
Copy link
Author

tokudan commented Feb 12, 2020

That produces an image that is exactly the correct size and I'm able to find some strings from the BASIC programs stored on the disk.
I'm unable to find the directory track, which should be at track 40 (starting at position 0005f000 in the resulting image) and I cannot find the usual "BLOCKS FREE" text anywhere on the disk
It's quite possible that the d81 format has some quirks that I don't know about yet, so I'll have a closer look probably during the upcoming weekend.

@tokudan
Copy link
Author

tokudan commented Feb 17, 2020

I think I've managed to make sense of the issues I have with the disk image produced by the disk analyzer.
The commodore 64 and it's 1581 uses 256 byte "sectors", with 80 tracks (1 to 80) and 40 sectors (0 to 39) per track.
Renaming the *.img file to *.d81 results int the sectors being offset by exactly half a track (20 256-byte sectors or 10 512-byte sectors).
For example (using Commodore 1581 tracks,sectors in decimal numbers):
Expected location of directory blocks:
40,0 disk header
40,1-2 block allocation map
40,3 start of directory
Actual location in the image:
40,20 disk header
40,23 start of directory

Same for a random file that I tried to read, according to the directory and the linked blocks:
47,28 to 39 PARTITION AID
Actual locations on the image:
47,08 to 19 PARTITION AID

I used some basic shell scripting to swap the two halves of each track:

source=converted-ibm_mfm_dd.img
target=converted-ibm_mfm_dd_fixed.d81
halftracks=160
halftracksize=$((20*256))
rc=0;
t=0
while [ $t -lt $halftracks ]; do
dd if=${source} ibs=$(($halftracksize)) of=${target} obs=$(($halftracksize)) conv=notrunc skip=$(($t +1)) seek=$(($t)) count=1
dd if=${source} ibs=$(($halftracksize)) of=${target} obs=$(($halftracksize)) conv=notrunc skip=$(($t)) seek=$(($t +1)) count=1
t=$(($t + 2))
done

As a result the image loads fine now. I haven't verified this completely yet, so there may still be some hidden issues.

So adding the d81 as an output format would basically mean to swap around the two halves of the tracks.
I want to verify this with a couple other disks first, though.

@tokudan
Copy link
Author

tokudan commented Feb 18, 2020

I've created a basic test disk on my 1581 that contains the logical track and sector numbers. The tests show that the two halves of each track are swapped.
I'm not sure if that means that e.g. the top and bottom side of the disk are swapped on a 1581 or if there's something else going on.
Are you interested in having d81 as a supported output format? Would you need me to write a pull request?

@keirf
Copy link
Owner

keirf commented Feb 19, 2020

Yes disk sides are swapped on d81 images. That's the only oddity (I know as I support this image format in Flashfloppy).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants