Commodore 8-Bit Diskette Basics
-------------------------------
By Larry Anderson (foxnhare@goldrush.com)
Silicon Realms BBS - (209) 754-1363 300-2400 baud
Sending commands to the disk:
To send a command to the disk, you have to open a command channel, send the
command then close the channel. In BASIC it would look like this:
OPEN 15,8,15,"(command)":CLOSE 15
(command) stands for the disk command that you need to execute.
If you are using a disk utility such as a wedge or fastloader, the command
are sent easier by typing:
@(command) or >(command)
Below describe the various commands, keep in mind that you have to add the
statemets above with the commands in order to send the command to the disk
drive.
Preparing a disk:
To set up a new diskette so you can write to it is called formatting. What
the format does is writes a map on the disk for the disk drive to store, keep
track of, and retrieve data. The command to format a disk is:
N0:(name),(id)
(name) is a 16 character name for the disk, its only purpose is for notation,
when you view the directory this will be the first line.
(id) is a two character identifier, using any numbers or letters. This one's
VERY important. Whenever you place a disk in the drive, the computer checks
the disk's id with the previous disks, if they are the same it assumes the same
isk is in the drive, and can cause problems when writing data to another disk
with the same ID. If the disk has been previously formatted, you can omit the
commaand id, to speed up re-formatting.
Initializing a disk:
Sometimes, you may need to initialize or reset the disk drive, such as when a
copy-protected program sets your disk drive off-track and other disks wont read,
or when you have to use another disk that has the same ID. The initialize
command is:
I0
If after issuing the command the drive light blinks, either there is no disk
in the drive or there is a problem with the disk in the drive, or the disk has
not yet been formatted.
Validating a disk:
If you use a disk constantly and write, erase, and re-write files, after
awhile the disk needs to be checked in order to see if everything is accounted
for, to do this you validate a disk. Also if for some reason a file appears on
your directory with an * near the file type it has to be validated to remove
the file properly. The validate command is:
V0
The command takes a while to run, as it checks each file on the disk. If the
disk is a protected commercial disk or a GEOS disk DO NOT validate the disk
unless the software manual says it's ok! Sometimes data can be lost on
commercial disks.
Erasing a file:
In order to erase or scratch a file you have to send the disk a scratch
command:
S0:(file name)
(file name) is the name of the file you want to remove, exactly as it appears
in the directory. This command can scratch more than one file by using
wildcards and/or by separating each file name with a comma.
Re-naming a file:
To change the name of a file, you issue a re-name command:
R0:(new name)=(old name)
(new name) is the name you want the file to be, and (old name) is how it
currently appears in the directory.
Reading a Diskette's Directory:
To read in a directory on the 64, there are two ways, one if you have no
fastloader or wedge utility present. The first and main way is to load the
directory as if it were a program, to do this enter:
LOAD"$",8
The dollar sign is the special name the disk drive gives its directory. After
loading the directory you view it by entering:
LIST
If the directory is larger than the screen you can slow the scrolling down by
holding down the CTRL key or stopping it by pressing the RUN/STOP key.
The main problem with this method is it overwrites any program currently in
memory, so if you were looking for a disk with room, look for it before entering
the program.
If you have a wedge or fastloader this command may work:
$ or @$
The benefit with this method is that the fastloader prevents the directory
from wiping out your program. On some fastloaders and wedges you can use the
space bar to suspend the listing of the directory, and pressing it again resumes
the listing.
Sending the Directory to the Printer:
To send the directory to the printer, first you have to use the first method
of getting the directory, by loading it into memory:
LOAD"$",8
Next the printer must be on and ready, once so, enter this command:
OPEN 4,4:CMD 4:LIST
if you wish the directory to be in upper & lower case enter this instead:
OPEN 4,4,7:CMD 4:LIST
The directory should list out onto your paper, after it finishes you must type
one more command to finish:
PRINT#4:CLOSE 4
Remember this process will wipe out any program in memory, so make sure your
program (if any) is safely SAVEd on a disk.
Exploring the directory:
Lets look at a sample directory:
*0 "JOE'S GAMES " 01 2A!
33 "PACGUY" PRG
1 "TIC-TAC-BOOT" PRG
44 "3-D TIC-TAC-TOE" PRG
5 "TIC-TAC-DOX" SEQ
2 "HI SCORES" REL
89 "LEVELS" USR
490 BLOCKS FREE.
The top line is the title that was given to the disk during the format
procedure, also on that line is the ID given to it as well as the format version
(don't worry about that now).
The next 6 lines are the files contained on the diskette going across each
line are the file size (in blocks), the file name, and the file type.
The bottom line is the number of unused blocks on the disk.
Files:
Files are data on a disk, sometimes they are programs. All files are recorded
in chunks of 254 characters, these are called blocks. a 2 character file will
use 254 characters or 1 block. a 265 character file, 2 blocks, and so on. A
computer picture takes about 40 blocks. There are six file types, two of which
do not appear on the directory:
DEL - deleted files:
These are files that have been scratched or removed during validation. They a
re tagged deleted so they can be overwritten when another file is added to the d
isk. Deleted files are in the directory, but are not displayed by the disk driv
e.
SEQ - sequential data files:
For the most part these are data files to be read by other programs, sometimes
containing text (as this sequential file you are reading now).
PRG - program files:
Program files can be many things, BASIC programs, recordings of an area of
memory, a picture file or some data used by another program. Some programs such
as the first one are complete in one file while others like the second one use
several files. Usually the first file in the set is the one that loads or
'boots' the program.
REL - relative files:
This is a datafile that is divided into equal sized chunks or records, and can
be accessed at different points by a record number. Relative files are used
primarily for database applications. These are by far the hardest files to
copy, and you must use a special copier to move them from disk to disk.
USR - user files:
This could be anything, from text to a special file structure (as in GEOS's
USR file), user stands for user defined, almost always used by a specific
program.
Random files:
This type of file is not listed on the directory, it is data recorded directly
to areas of the disk, bypassing the directory. Validating a disk can cause
problems to these files. Commercial programs use random files a lot.
Using Wildcards:
When loading and scratching files and reading directories there are special
symbols you can use to locate a file or groups of files faster, they are called
wildcards. Wildcards are the characters ?, *, and =:
? - Question Mark
This wild card can be used in place of a character it stands for any
character. Let's say you have a file called POINTS, being a not so hot typist
you could have named it PIONTS, so by calling it P??NTS you should find the file
easier. this can also be used to locate say all 5 character files by using:
LOAD"$?????
",8.
* - Asterisk
This is a cutoff indicator, say you name a file MISCALLANY but you don't want
to type that all the time so you enter LOAD"MISC*",8 and the disk drive will
look for the first file that starts with MISC. You can use it in a directory to
look for all the files that include something. Such as pictures that start with
GG you can enter LOAD"$GG*",8 and get ony the files starting with GG in the
directory. This can be combined with the ? wildcard as well as a comma to add
other conditions.
= - Equal to
This one is one of those tricks you find by accident. This one will allow you
to locate a certain 'type' of file. it has to be used with one of the above
wildcards and a letter as well. An example would be, to list all sequential
files on a disk enter: LOAD"$*=S",8 and the directory will list ALL files that
are sequential (if any). The different letters are:
S=SEQ U=USR
P=PRG R=REL
(There seems to be no easy way of looking at DEL files...)
Wildcards are not allowed when renaming or saving files.
Loading and Saving programs:
There are some who need clarification on loading and saving programs, also there
are some things that may have been told to you that are no-nos now.
Adding a '0:':
If you wish to initialize a disk before loading/saving a file put a 0: (example
LOAD"0:PACGUY",8) before the name of the file and the disk drive will run the
initialize routine then load/save your file. Sometimes when my drive gets too
hot I have to use it in order to get the drive to save my programs.
Loading a File:
To load a file you type:
LOAD"(file name)",8 or LOAD"(file name)",8,1
(file name) is the name of the file, which can include wildcards. The ,8
tells the computer to access device # 8 for the function, Device 8 is the disk
drive. If you have two drives, usually the second one is device # 9. When you
just the ,8 the computer treats the file as if it were a BASIC program, by
loading it to the start of the BASIC program memory, regardless of where it may
need to go. If you cannot get the program to operate by loading it that way try
,8,1. ,8,1 lets the computer load the program into the same place it was
recorded from. Sometimes there are special programs that start up the main
program and need to be loaded by ,8,1. If both methods do not work, it may be
that the file you were trying to load is data for another program file. If you
are sure it is a runnable file, have someone with more disk knowledge look at
it.
Saving a File:
Saving BASIC programs are a breeze, all there is to it is to type:
SAVE"(program name)",8
Where (program name) is the name of the program up to 16 characters and
contains no , " ? * or :s, no ,1s are needed either. Though there is one thing
you MUST NOT do, and that is the save with replace. Saving and replacing a file
(example SAVE"@(file name)",8) has a bug in most of the 1541 drives and can
cause other files to be lost. If you wish to save a file with the same name as
a previous file do this:
OPEN 15,8,15,"S0:(file name)":CLOSE 15 (scratch the old one)
SAVE"(file name)",8 (save the new one)
I call it Scratch & Save, and it's easier to remember that way...
Well that's the basics, anything else would require special programs, and a
bit more knowledge in the workings of the computer & disk drive. Hope this
helps you folks out.