DISK DRIVE
Version L3F
FOR THE TIMEX/SINCLAIR 2068
(ZX Spectrum 48K Emulator ROM & Zebra OS-64 ROM Compatible)
By Larry Kenny
Edited And Annotated By
David Solly
HTMLized And Edited By
William McBrine
David Solly
Ottawa, Canada
October 8, 1998
It supports all token key words -- CAT, ERASE, LOAD, SAVE, MERGE, OPEN#, CLOSE# and also GO TO and PRINT -- that were intended to be used with an external mass storage device. The FORMAT command and the MOVE command are supplied on the System Disk as programs that run in RAM.
The way these commands are implemented by the Larken Disk Operating System (LKDOS) is to precede them with a RANDOMIZE USR 100:
Example: RANDOMIZE USR 100: OPEN# 4, "dd"
For easier typing and shorter command the PRINT #4: command may be used instead of RANDOMIZE USR 100:. To use PRINT #4: you must first open channel 4 to the disk drive with:
RANDOMIZE USR 100: OPEN# 4, "dd"
You may now proceed all LKDOS and Extended BASIC commands with PRINT #4:
Example: PRINT #4: LOAD "filename.ex"
If the PRINT #4 command is used before it has been initialized, an O - Invalid Stream error will result.
LKDOS uses a file name that contains a program name up to 6 characters followed by a two-character extension. A period separates the program name from the extension. The first element of the extension tells the DOS what type of file it is. It must be an «A», «B» or «C».
«.A» for Arrays
«.B» for BASIC
«.C» for Code
For BASIC Programs & Code Blocks:
Every LKDOS extension must have a second element after
«A», «B» or «C». For «B» and
«C» it may be any character with the exception of «^»
which has been reserved for doing wild card searches with the
CAT command. It should be noted that LKDOS treats a
SCREEN$ file, which is really a special part of RAM called the
«Display File», as a code file. Examples of valid file name are
given below.
For Arrays saved as DATA:
There is a further restriction for the choice of a second element for the
extension «A» which is used when saving arrays as data. (This,
however, does not apply to SCREEN$ saves which LKDOS treats as code
files.) If the array to be saved is alpha-numeric then the second element
must be «$» thus «.A$». Should any other character be
used for the second element after «A» when saving an
alpha-numeric array, then LKDOS will attempt to save the array as a
numeric array which will generate a V - Wrong File
Type error and the computer will halt.
Rule of Thumb: If the name of the variable to be saved as DATA contains a
«$» then the LKDOS extension must be «.A$» otherwise,
(with the exception of «^» - see above), any character may be
used with «A» for the second element.
Examples of Valid File Names:
| Program.B1 | - A BASIC program |
| zeus.Cx | - A code file |
| Names.A$ | - An Alpha-Numeric array |
| Numbers.A1 | - A numeric array |
Example: PRINT #4: SAVE a$ (TO 6)+".CT" CODE Start, End-Start
All versions of the TOS commands are supported:
| PRINT #4: SAVE "Prog.B1" | - BASIC program |
| PRINT #4: SAVE "Prog.B1" LINE 100 | - BASIC Auto-run |
| PRINT #4: SAVE "Prog.C1" CODE start, length | - Code block save. |
| PRINT #4: SAVE "Prog.C1" SCREEN$ | - Screen save |
| PRINT #4: SAVE "Numbers.A1" DATA () | - Numeric array |
| PRINT #4: SAVE "Names.A$" DATA a$() | - Alpha-numeric array |
Before saving, make sure that the write protect notch on the disk is not
covered by a protect sticker, that the disk is in the drive properly, and
that the disk drive door closed.
LOAD
Similarly, all the TOS load commands are supported.
A special feature in the LOAD command will allow your BASIC program to
continue even when a T - File Not Found error
has occurred. If you POKE 23728, 100 before doing a load command, your
program will not stop with T - File Not Found error if LKDOS can
not find the file. Instead, LKDOS will print NO FILE on the VDU
in the current print position and return to your BASIC program. It will
also change the value at address 23728 to 101 to indicate that it did not
find the file. This feature was added for programs such as word
processors and similar programs that load and save text or work files from
within themselves.
MERGE
The LKDOS MERGE command differs from the TOS MERGE in a few ways.
Programs are not automatically stopped when merged, as the TOS does.
This allows BASIC overlays, which means that a BASIC program can be far
larger than what can be loaded into the computer at once. You can have
parts of a program merged into your main controlling program when
necessary.
Two rules determine from what line number the program will continue from after a merge command.
The MERGE command does not merge program variables -- only the program
lines. This makes your BASIC overlay programs easier to program.
CAT (Catalog)
The CAT command displays the following:
Example: PRINT #4: CAT ".Bz" would print all the files that had «.Bz» in them.
The «^» (power or up-arrow) is used as a wild card character and can be substituted for any character.
Example: If a disk had files called prog1.B*, Prog1.B*., Prog2.BB, and Prog2.B* on it and the command was PRINT #4: CAT "Prog^.B*", then the files the CAT command would find would be: Prog1.B* and Prog2.B*.
The ZX Spectrum does not allow the search function because its command line is PRINT #4: CAT .
To send a copy of the catalog to the printer, you must first open
channel 2 to the printer, then execute the CAT command. To open a channel
to the Timex/Sinclair 2040 printer, enter OPEN #2, "p"; or for a
line printer, enter PRINT #4: OPEN #2, "lp" . When finished, use
the LKDOS CLOSE command to close channel 2. (See the
section on Extended BASIC for more details on the
use of the OPEN command.)
ERASE
The ERASE command deletes the file on the disk. The blocks used by the
file will be made available again for new programs. ERASE requires a
comma after the file name, thus:
PRINT #4: ERASE "AnyFile.ex", .
GO TO
The GO TO command is used to select which disk drive is to be used for the
next disk commands. The Larken disk interface will support up to 4
drives, numbered 0 through 3. GO TO 4 is reserved for the RAM disk.
PRINT
The PRINT #4: PRINT "File.Cx" command, which is unique to LKDOS, displays
the file on the VDU or sends it to the printer directly from the disk
without altering program memory. It can be used to search a disk for a
program, or even to examine an NMI save to see the
contents of memory. The listing of BASIC programs will not print line
numbers, but word processor files and text are fairly accurate. This
command was inspired by the CPM type command.
VERIFY
Unlike its TOS counterpart, PRINT #4: VERIFY is used to examine the state
of the disk's recording surface rather than the state of a particular file
recorded on the disk. When the command is called, all blocks of the disk
are read to see if the disk has any bad blocks. The CRC error followed by
the block number will be printed if a block can not be read. This
command, however, does not mark any of the bad blocks it finds. This is
done with the Disk Editor program which is supplied on the System Disk.
MOVE
Because of the size of the MOVE command, there was not room to burn it
into the LKDOS EPROM. However, it is supplied with documentation on the
System Disk as part of the Disk Editor program. The MOVE command requires
that you have two disk drive hooked up to your Timex/Sinclair 2068, and is
used to copy files from one disk to another. This process does not
destroy or delete the file on the originating disk.
| S - Protect Error: | The disk can not be written to because it has a write protect sticker on it. |
| T - File Not Found: | The requested file is not in the catalog. This can be overridden; see under the LOAD command. |
| U - Disk Full: |
|
| V - Wrong File Type: |
There is a mismatch between the file type as indicated by the file's
extension and the syntax of the LKDOS command. This error usually
indicates:
|
| W - Invalid Command: | The command following the PRINT #4: is not used by LKDOS. |
| X - CAT Data Error: | The disk's catalog can not be read properly, so the command is aborted. |
| - CRC Error (num): | A CRC error will be printed on the VDU when LKDOS can not read a block after 10 tries. The number following the CRC error is the block number. |
Note: Never use the TOS CLOSE command to close a channel opened by LKDOS.
PRINT #4: INPUT #[window], top, left pos, right pos,
bottom pos
This command defines a window's size, position and color. The range for
window is 0 through 2. Other parameters are standard print positions in
absolute numbers.
Example: PRINT #4: INPUT #1, 0, 10, 20, 8
This would define window #1 to have its upper left corner at print position 0, 10 and the window would be 10 units wide (20-10) and 8 unites deep.
The VDU colors that are being used when the window is defined will stay
with that window.
PRINT #4: CLEAR window
This will clear the window and restore the print position to the top of
the window. It will also recolor the window. The value for window is 0
through 2.
After that, to use the window (or a line printer) you can use the standard commands of the Timex/Sinclair 2068 or ZX Spectrum (not preceded with the LKDOS switch) such as PRINT #n or LIST #n.
Example: If channel #10 has been opened to a window then PRINT #10;"test" would print to it or LIST #10 would list your program to it.
The computer uses channel 2 as the channel for standard PRINT commands to the main VDU. You can open channel #2 to a window or printer; then all standard PRINT or LIST operations will be directed to the selected device. Also, the computer uses channel #3 for LLIST or LPRINT commands, so if you OPEN #3, "lp" then these commands will activate the line printer.
You can send the disk directory to the line printer by entering: PRINT #4: OPEN #2, "lp": PRINT #4: CAT "", (or just CAT in the case of the ZX Spectrum).
When any or all of the windows or line printer channels are used, 38 bytes (total) of memory is added to the channel table. This may cause a problem for a program that has machine code in a REM statement.
10 REM **** WINDOW DEMO **** 20 PRINT USR 100: OPEN# 4, "dd" 25 CLS: INK 7: PAPER 0 30 PRINT #4: OPEN# 5, "w0" 40 PRINT #4: INPUT #0, 3, 3, 15, 10 50 INK 0: PAPER 4 60 PRINT #4: OPEN# 6, "w1" 70 PRINT #4: INPUT #1, 12, 10, 30, 20 80 INK 0: PAPER 7: CLS 100 PRINT #4: CLEAR 0: PRINT #4: CLEAR 1 110 PRINT #0; "Press Enter for 'SCROLL ??'" 120 LIST #5: LIST #6: LIST #5: LIST #6: LIST #5
10 REM **** DRAW DEMO **** 20 RANDOMIZE USR 100: OPEN# 4, "dd" 30 LET x = INT (RND * 200): LET y = INT (RND 150) 40 PLOT x, y: PRINT #4: DRAW 40, 40, 1 50 PLOT x + 2, y + 2: DRAW 36, 36, INT (RND * 8) + 1 100 GO TO 30
10 REM **** FILL DEMO **** 15 REM ----- Draw House ----- 20 RANDOMIZE USR 100: OPEN# 4, "dd" 30 PLOT 30, 20: DRAW 70, 0: DRAW 60, 50: DRAW 0, 50: DRAW -35, 35 40 DRAW -60, 60, DRAW 35, -35: DRAW 60, 60, DRAW -60, -60: DRAW 0, -50 50 DRAW -70, 0: DRAW 0, 50: DRAW 35, 35: DRAW -35, -35: DRAW 70, 0 60 REM ----- Fill House ----- 70 PRINT #4: CIRCLE 50, 50, 8 80 PRINT #4: CIRCLE 100, 100, 2 90 PRINT #4: CIRCLE 130, 60, 6 100 REM ----- UDP for Pattern 10 ----- 102 RESTORE 105 FOR a = 23540 TO 23547 110 READ b: POKE a, b 120 NEXT a 130 DATA 15, 240, 15, 240, 15, 240, 15, 240 140 PRINT #4: CIRCLE 80, 80, 10 150 REM ----- Cut Door ----- 160 PLOT 60, 20: PRINT #4: DRAW 10, 20, 1 170 PLOT 61, 20: PRINT #4: DRAW 8, 19, 0
To transfer a program from tape to disk, load the program from tape. It is best to trigger the push-button just before the title screen appears. In the case of games, you may have to play the game once and trigger the push-button just before the title screen reappears. The push-button can also save the game at any point or be used to pause.
When the NMI push-button is triggered, the computer will play a tune and then pause. The program in memory can be saved by pressing keys 1 to 5 which will name the file NMI-S[1-5].CM . It does not save the display file but saves from the start of the attributes file on up. The display file can be saved as SCREEN.CM by pressing the «s» key. Also the «a» key will attempt to stop the program by a RST 8. Pressing «Enter» will return you to your program.
To load the saved program you need to load it as a CODE file thus: PRINT #4: LOAD "NMI-S4.CM" CODE .
Only press the push-button once. It is best to squeeze the button from both sides of the disk interface than to push just from the left. This precaution will prevent you from accidentally pushing the disk interface off the edge connector which will short out your computer causing irreparable damage. A few programs may require a few attempts to save them. This may be because the program uses a complex interrupt scheme.
For machine code programmers, the push-button can be used to break normally unbreakable loops and crashes by pressing the «a» key.
To save an auto-run program, you may reduce the size of the disk space used by lowering RAMTOP until you have 150 to 200 free bytes. Use PRINT FREE (which is not found on the ZX Spectrum!) to see the amount of free memory. Then enter: RANDOMIZE USR 102: RUN or RANDOMIZE USR 102: GO TO [line number] . This will cause an NMI type save.
After the tune plays, press the «d» key. This will save your program from the start of the attribute file to RAMTOP.
This program will auto-run when the computer is switched on with the Enter Key depressed. The memory above RAMTOP will be clear, that is, there will be no User Defined Graphics (UDG). UDGs can be loaded, if necessary, as a CODE file.
The line on the bottom of the VDU is actually all the Z80 registers, interrupt information and stack pointers.
Some ZX Spectrum 48K Emulators need to be turned on by the command OUT 244, 3. To make this type of emulator be able to auto-run a program, you need to add this small machine code routine. The best place for this routine is in the printer buffer at location 23300 (decimal).
CALL 102 ;(decimal)
LD A,3
OUT (244),A
RET
After this program has been loaded, you can save your auto-run program by
RANDOMIZE USR 23300: RUN .
The DOS bank is activated when the cartridge senses a USR call (M1 cycle) at address 98 to 110 (decimal). For LKDOS commands, only the address 100 is used. Address 102 is used for saving an auto-run file. The other addresses are used by the DOS as entry points for the PRINT #4: command and windows.
The DOS bank is deactivated when a read or write is made to this area of memory.
The command RANDOMIZE USR 100: OPEN# 4, "dd" is used to initialize the PRINT #4; command to point to the LKDOS cartridge. PRINT #4: is easier to type than RANDOMIZE USR 100: and there is no chance of accidentally typing a wrong USR address. The "dd" means «disk drive».
LKDOS manages all disk space allocation by using a track map. The map is created by the format program and resides in track 0 along with the catalog. By using the map, the DOS keeps track of the used and unused areas of the disk.
The catalog may contain up to 100 file names. A record of the blocks used by each file is also kept in the catalog.
The rear-mounded board is the Disk Drive Interface (IF). This board controls the drive motors and the data transfer to and from the disk drive(s). It can control up to 4 drives -- 3 inch, 3½ inch and 5¼ inch drives. The disk format used by LKDOS is double-density with 10 sectors of 512 bytes per track (or 5120 bytes per track).
On a double-sided, 40-track drive this will give a capacity of over 400K per disk. On a single-sided, 40-track drive you will have 200K per disk and on a double-sided, 80-track drive you will have 800K per disk.
Also on the board is a push-button which will trigger the NMI line on the Z80. This is used to capture any program to disk.
The joystick can by accessed by the command IN 31. Numbers from 0 to 31 represent the joystick position.
The FORMAT command is not on the LKDOS cartridge, but on the supplied cassette or System Disk. If you have received the cassette then you will have to do the following:
LKDOS numbers the blocks starting from track 0, side 0. Block 1 is track 0, side 1. Block 2 is track 1, side 0. Block 3 is track 1, side on and so on.
The format program creates a track map on the directory track (block 0) that corresponds to the number of tracks and the number of sides that were entered.
When you format a single-sided disk, the format program creates a track map on the disk that has all side 1 tracks set as in use.
Because LKDOS reads tracks from side-to-side, you can not read a double-sided disk with a single-sided drive. Also, because of the track density, disks formatted on an 80-track drive can not be read from 35- or 40-track drives.
You can, however, read single-sided disks with a double-sided drive. So if you have a double-sided drive and you would like to transfer files to someone with a single-sided drive, you can format your disk as a single-sided disk.
All software from Larken Electronics will be supplied on single-sided, 40-track disks unless requested otherwise.
In addition to the Larken boards, you will need a disk drive or drives, a disk drive cable and a disk drive power supply. The disk drive interface can control any floppy drive except an 8 inch drive.
The power supply needs to supply 5 volts and 12 volts. The current rating depends on the number of drives but a general rule is 1 ampere (on 5 volts and 12 volts) per drive.
When using more than one drive, set the drive select jumpers on each drive as drive 0 to 3 respectively. Also, make sure that all terminator resistor packs are removed from the drives EXCEPT the drive that is connected closest to the end of the drive cable.
Connect the cartridge and the disk drive interface to the Timex/Sinclair 2068. The drives should not turn on. If they do, you may have the drive cable reversed.
To test to see if the drives are connected properly, insert a disk into drive 0. Type: PRINT USR 100: CAT "", . Drive 0 should turn on (LED and motor) an then after approximately 15 seconds turn off. Use the command: PRINT USR 100: GO TO [drive number 1 to 3] , then use the cataloging command to activate the drive.
If you did not purchase the disk drive cable, you can make you own using 2
feet of 34-conductor ribbon cable and 2 or more 34-position ribbon cable
edge card connectors. The best way to attach the connectors to the cable
is to use a vise to squeeze the connector. The connector on the interface
end should be mounted opposite to the dive connector(s). If you use more
than one drive, space the drive connectors 3 inches apart. Attaching the
cable backwards will not cause any damage, but the drives will turn on.
Set-Up Diagram
+----+ +----+
+------------------+ Cable | | | | | |
| |--------------| | |--------| | |
| Disk | | | | | | |
| Drive | +-+--+ +-+--+
| Interface | Drive 1 Drive 0
| | (w/ terminator)
+------------------+