Using disk drives
Programming Features - Using Disk Drives
Using Legacy Commodore Disk Drives
To access a file on a Commodore compatible disk drive, there are five parameters that define how the computer communicates with a disk device:
- Logical File Number
- Device Number
- Secondary Address
- Drive Number
- Filename
The OPEN command uses all these parameters and here is its syntax:
- OPEN <logical file #>, <device #>, <secondary address>, <file name>
The drive number is included in the file name. Here is an example of the use of all of these elements:
- OPEN 9, 8, 2, "0:TEST"
Nine (9) is the logical file number, Eight (8) is the device number, Two (2) is the secondary address, zero (0) is the drive number, and "TEST" is the file name. I will discuss the use of each of these elements in order of importance.
- Device Number
- Any device that plugs into the Commodore's serial port has a DEVICE NUMBER assigned to it, which allows the computer to distinguish between several different devices. A device can be a printer, plotter, disk drive, or any other device that can interface through the serial port. All the devices connected to the computer must have their own individual device number, or the computer will not be able to figure out which device is which.
- Traditionally, disk drives may have any device number from 8 to 30. The Commodore 1541 disk drive, for example, can be customized to a device number from 8 to 15, but other devices such as the CMD HD can be set to be any device number from 8 to 30. In the example command LOAD"0:FILE",8 the device number is 8.
- Drive Number
- Along with the device number, disk devices are also accessed by a DRIVE NUMBER. The drive number was designed to allow one device to access more than one disk (as with the MSD-SD2 dual disk drive). The 1541 disk drive has only one drive permanently set to drive 0. In the example command LOAD"0:FILE",8 the drive number is 0, because the drive number precedes the file name separated by a colon. For Lt. Kernal hard drives, the drive number is also referred to as the LU (logical unit).
- Secondary Address
- To communicate with a disk drive, the computer must open up a communications "channel". When the OPEN command is used, this channel is referred to as the SECONDARY ADDRESS. Channel numbers 0 and 1 are reserved for loading and saving programs. Channel number 15 is used as the "command channel". All the other channel numbers (up to 127) are free for use with common communications. Another thing to note is that when opening more than one file on a single device, each file must have its own individual channel number, because this is how the disk drive knows which file you want to access.
- The command channel is used to send special commands to the disk drive. Some of the more common commands are the initialize, validate, scratch, and copy commands. Other commands are specific to certain devices. For example, the Lt. Kernal drive has the "LG" command which is used to get information about the hard drive. When opening the command channel, a file name is not used. Instead, the text you use as the file name is sent to the channel as a drive command.
- Logical File Number
- The computer also uses a LOGICAL FILE NUMBER to keep track of all open files. Once you open a file, the file number is what you use with the PRINT# and INPUT# statements. This sure makes things a lot simpler than having to refer to the device number, drive number, etc. every time you want to send or receive information to or from a file. The file number is for the computer's own use and has nothing to do with actual device communications. This means that the file number and secondary address are completely independent of each other, although programmers traditionally make the secondary address the same as the logical file number (i.e. OPEN 8, DV, 8, DR$+FI$).
- File Name
- Finally, the last parameter needed is the FILE NAME. Each of the files on a drive has a unique name, which makes things easier to keep track of, especially since a file name can be up to 16 characters in length. Note that the drive number is included in the file name in the OPEN command. The drive number is first, followed by a colon, then the actual file name.
- Hard drive devices, such as the CMD and Lt. Kernal hard drives, have many more features than the traditional floppy devices. Most hard drives divide up their storage into units called "partitions". Sometimes, the computer can access these partitions by using the drive number. Otherwise, special commands must be sent to the HD to select a partition for use.
SD2IEC and Color 64 v8.1
Color 64 BBS v8.1 and 8.10a work fine running on only a SD2IEC drive or a combination of it and standard drives. This is advantageous when it comes to blocks free available to users for Uploads, messages stored on the system, and breaking the barrier of limited number of files for a directory. The key to successfully implementing SD2IEC is to ensure you have the right INIT command in your system setup when selecting your disk assignments while running +SETUP. If you track discussions on the internet regarding REL files and SD2IEC, I’ve had no problems. I believe it has to do with running the system with a normal folder structure on the SD card and not utilizing .D64/.D81 images.
As I hinted in the main text of this manual, I use the following setup on my system:
| Folder name on SD card | Functional area (or “Drive selection”) | Settings in +SETUP for Drive Assignment |
|---|---|---|
| Nothing (root folder) | Programs & Systems drive | Drive: 8
Device Init: 0:!cd// |
| HELP | Help & Text files | Drive: 8
Device Init: 0:!cd//help |
| PRIMSGS | Private Messages Drive | Drive: 8
Device Init: 0:!cd//primsgs |
| PUBMSGS | Public Messages Drive | Drive: 8
Device Init: 0:!cd//pubmsgs |
| AUX1 | Drive for AUX 1 | Drive: 8
Device Init: 0:!cd//aux1 |
| AUX2 | Drive for AUX 2 | Drive: 8
Device Init: 0:!cd//aux2 |
| AUX3 | Drive for AUX3 | Drive: 8
Device Init: 0:!cd//aux3 |
| UPLOADS | Uploads drive | Drive: 8
Device Init: 0:!cd//uploads |
| GAMES | Games Download folder | Drive: 8
Device Init: 0:!cd//games |
| USERS | User Profile area (applies to version 8.1a only) | Drive: 8
Device Init: 0:!cd//users |
There are more assignments for my system, but hopefully you get the idea. Color 64 will execute on this smartly! Use this same approach when using DOS Wedge and any other functions where the system will prompt you for Drive and Device – like Message Editor.
Note that for SD2IEC Sysops, Color 64 will kick out 2 errors at midnight – but it does not affect BBS operations. This is when the system performs a Validation command to the drive; something that SD2IEC does not understand. You will get syntax errors generated in your log, but the system just continues along. No harm, no foul.
Lt. Kernal or CMD HD
There's nothing particular for this specific section to discuss on Lt. Kernal or CMD Hard Drives, though you will definitely want to look at the next section, Drive Initialization Commands!
Next section: Drive Initialization Commands