I must admit it’s been a while since I’ve loaded files from a C64 and the 1541 Floppy Drive – let alone save programs back to disk.
Here’s a quick reference how we did things 30 years ago:
The C64 BASIC v2 did not have built-in commands for talking to the drive. Instead, we used the standard LOAD command to bring things into memory, appending the disk drive number (which was 8 by default).
If you don’t specify the drive number the system assumes “1” which is the Datasette (tape drive) and will prompt you to “PRESS PLAY ON TAPE”.
Loading a BASIC programme from Floppy Disk is done like this:
// load to the start of BASIC LOAD "YOURFILE",8 // load to where it was originally in memory LOAD "YOURFILE",8,1
Another lightly annoying habit was that to look at the disk directory, you had to load its contents into the BASIC memory – overwriting any programme you were currently working on.
Here’s how to load the directory and LIST it:
// load directory from drive 8 LOAD"$",8 // then list its contents LIST
The later BASIC versions 3.5, 4 and 7 all had the DIRECTORY command which would do this without killing your programme in memory.
To store your current programme on Floppy Disk you specify the name of the file and the drive number, like so:
// save a file on disk SAVE"YOURFILE",8
Since you can’t show the directory on the C64, this may result in a red flashing light on the drive, telling you that the file already exists. The good news is that you can overwrite a file using
Note that this will write the file first, and then delete the original. On one hand it’s a great safety mechanism, on the other you may encounter a “full disk” error. Those were the days!
The C64 also had a VERIFY command which would compare byte by byte that what’s on the floppy is indeed what is in memory.
VERIFY"YOURFILE",8 // or VERIFY"YOURFILE",8,1
The later BASIC versions 3.5, 4 and 7 implemented the DLOAD, DSAVE and DVERIFY commands which would let you do such things without specifying the drive number. Those would assume you’re using drive 8.
Saving arbitrary blocks of memory onto disk
The above commands are all great if you’re saving BASIC programs: in essence, everything from 2048 to the end of the current programme in memory will be saved to disk. BASIC uses a pointer which specifies where it’s stopped using memory. But if you’ve added some machine or binary code somewhere in memory you may want to save other parts of the memory too.
It’s not easy – but here’s how to do that from BASIC v2:
S = 828 E = 900 SH% = S/256 SL = S - SH%*256 EH% = E/256 EL = E-EH%*256 SYS 57812("YOURFILE"),8,1 POKE 193,SL POKE 194,SH% POKE 174,EL POKE 175,EH% SYS 62957
Modify the S and E to suit the Start and End of the memory you’d like to save. The routine then calculates and sets the high and low byte of your block, sets a file name, and finally calls a save subroutine. Here’s a mote compact copy-and-paste version:
s=828:e=900:sh%=s/256:sl=s-sh%*256:eh%=e/256:el=e-eh%*256 sys57812("filename"),8,1:poke193,sl:poke194,sh% poke174,el:poke175,eh%:sys62957
Thanks to buzbard from the Lemon64 forum for this snippet!