Category Archives: Commodore 64

Commodore SD2IEC

When using a SD2IEC and a 1541 floppy drive together it is possible to have a device id conflict. The SD2IEC defaults to device#8. The 1541 floppy drive defaults to device#8 as well.

To change the device id on the SD2IEC, power on the C64 but not the 1541. Then open a connection to the SD2IEC

OPEN 15,8,15

Then send a command to change the device controller ID.

PRINT#15,”U0>”+CHR$(9)

The SD2IEC should now be using ID 9. To test, load the directory.

LOAD”$”,9

Now power on the 1541 floppy drive. It should startup and work as device#8 as normal.

LOAD”$”,8

Commodore 1541 Floppy drive commands

Getting back in to playing with my old Commodore 64 and 1541 floppy drive. I had to relearn how to use the floppy drive. Just a simple task such as formatting a floppy disk took me a little while to find the commands. So to make it easier for myself I thought I would list a bunch of the commands that I would be using now in the future.

Format a disk (NEW)
OPEN 1,8,15,"N0:Diskname,ID": CLOSE 1
or
OPEN 1,8,15: PRINT#1,"N0:Diskname,ID": CLOSE 1
The disk name has a maximum of 16 chars and the ID requires 2 chars.

Initialize drive (INITIALIZE)
e.g. to detect a disk change
OPEN 1,8,15,"I0":CLOSE 1

Validate a disk (VALIDATE)
Checks and fixes the disk’s meta-data structures (directory, block availability map, etc.)
OPEN 1,8,15,"V0": CLOSE 1

Copy files (COPY)
OPEN 1,8,15,"C0:NewFile=OldFile": CLOSE 1

Copy disk (COPY)
OPEN 1,8,15,"C0=C1": CLOSE 1
Copy the whole disk on a double drive from drive 1 to drive 0.

Concatenate files (COMBINE)
OPEN 1,8,15,"C0:NewFile=OldFile1,OldFile2,...": CLOSE 1
The command string is limited to 40 chars in length!

Rename a file (RENAME)
OPEN 1,8,15,"R0:New_Name=Old_Name":CLOSE 1
The command string is limited to 40 chars in length!

Delete a file (SCRATCH)
OPEN 1,8,15,"S0:filename": CLOSE 1
Wildcards such as * (matches all the remaining chars) or ? (matches one char) are supported.For example: OPEN 1,8,15,"S0:*":CLOSE 1 all files of a disk will be deleted (“scratched”).With comma (,) more than one file or wildcard mask can be given and multiple matching files actually could be subject of the deletion.

Overwrite a file (REPLACE)
SAVE"@0:filename",8
or
OPEN 1,8,15,"@0:filename,S,W": CLOSE 1.
The REPLACE command is especially prone to triggering the above mentioned bug on the original 1541 (fixed in the 1541C and the 1541-II) – it may fail with some regularity and one could lose all data on a disk. Unless the user knows for certain that the drive in question will not be an original 1541, the better way is to first to use SCRATCH and after that the BASIC command SAVE.