More INPUT on AUTOSTART and other Larken Thoughts

See all articles from Update July 1993
Author(s): Bob Swoger
Publication: Update Magazine
Pub Details: Update July 1993
Date: July 1993
Pages: 7-9

In the January 1993 Update! Magazine page 20, Peter Hyman gave a good clue to writing a better AUTOSTART program for the LarKen disk system. Like Peter, I have seen AUTOSTARTs that use two tracks. They are usually made from another program on the disk, sometimes called Menu.B1. Menu.B1 is provided to allow changes to the AUTOSTART program and is, therefore, identical to it. Three tracks on the disk now contain the same program!

AUTOSTART programs instruct the computer what to do when the machine is turned ON with the ENTER key held down or when the RAND USR 100: NEW sequence is typed in on either the TS2068 or SPECTRUM systems. Here are a few simple rules:

RULE 1

The ULTIMATE AUTOSTART should do little more than reset RAMTOP, call another program from the disk (LOAD the program and RUN it) and save itself to that disk.

RULE 2

The ULTIMATE AUTOSTART should be 5089 bytes long. Using the CHAMBERS UTILITIES disk, you will find that an AUTOSTART made in both the TS2068 mode and the SPECTRUM mode will always start at address 22490 and contain 5089 bytes.

RULE 3

The ULTIMATE CLEAR number for both TS2068 and SPECTRUM is 27577. One need not execute the PRINT 65536-FREE misprinted in the UPDATE! article to find the lowest point to move RAMTOP, just use 27577 instead. The area saved will always be one track long, 5090-1 bytes.

Since many menu programs are too long to fit on a single track as an AUTOSTART SAVE in the TS2068 mode, (SPECTRUM gives us 2955 bytes more) I submit the following subprogram that could be included in any menu program to create AUTOSTART. Since this is the AUTOSTART program included within the lines of the LogiCall program, it is numbered accordingly:

 49 LET H=CODE "d": LET Z=PEEK (PI+PI)=CODE "1"
110 GO TO VAL "460-(30*Z)"
400 CLEAR VAL "65367"
410 REM RANDOMIZE USR CODE "d": OPEN # VAL "4","dd"
420 RANDOMIZE USR CODE "d": LOAD "L.B1"
430 DELETE RND,VAL "399"
440 DELETE VAL "461",VAL "9999"
450 DELETE VAL "421",VAL "459"
460 CLEAR VAL "27577": RANDOMIZE USR CODE "f": GO TO VAL "400"

In line 49, H is assigned the value 100 to save RAM space when subsequent needs for the value 100 are needed. The heavy use of VAL and CODE is to save RAM space and will be explained later in this article.

LET Z=PEEK(PI+PI)=CODE “1” reduces down to LET Z=(PEEK 6=49) assigning Z the value 1 if the software finds itself running on the TS2068 and 0 if running on the SPECTRUM. EXPLANATION: If the TS2068 ROM is operating the system, byte 6 hold the value 49. The SPECTRUM ROM holds 203. Therefore, if the TS2068 ROM is operating, the boolean operator (PEEK 6=49) will be true and Z will equal 1. If the SPECTRUM ROM is operating, the boolean operator (PEEK 6=49) will be false and Z will equal 0.

Line 110 bypasses lines 430 to 450 in the Spec’y mode thus avoiding a crash since the SPECTRUM does not have a delete command.

Line 400 sets RAM TOP to a place compatible to fonts and other favorite machine code. You may choose any other number you like up to 65535.

Line 410 is included in case one MUST open stream/channel 4. Since opening stream/channel 4 conflicts with ZEBRA Talkers and eats up precious RAM space, it is REMarked out. Opening stream/channel 4 really has no added programming value in most cases. Just edit REM out if you need to open stream/channel 4.

Line 420 calls the start-up program.

Lines 430 to 450 delete all un-needed lines on the TS2068 from the program which contained this AUTOSTART sub-program thus keeping the required space to one track. This is not required on the SPECTRUM because: 1) not having a DELETE command in its vocabulary it can’t delete lines! and 2) SPECTRUM gives us 2955 more bytes of program space on an AUTOSTART save.

Finally, line 460 sets RAM TOP to the ULTIMATE value which will save exactly 5089 bytes, exactly the size of one LarKen track, the AUTOSTART save routine is called, and 400 is given to the AUTOSTART header as the line to auto RUN once this program is loaded.

To use this sub-program, simply merge it into your favorite menu program using the appropriate re-numbering of the statements and cause some keyboard action to send it to the beginning statement of this sub-program. If you use it as a stand alone program, the DELETE statements can probably be removed. When the sub-program is executed, the NMI tone will sound and you will either have to press the ‘D’ key to continue the save to disk or the ‘A’ key to interrupt the program to change ‘L.B1’ to ‘Menu.B1’ in line 420 if you want to call Menu.B1 instead of LogiCall when you boot the disk. Next type GOTO 460 <ENTER> and ‘D’ after the tone to save the modified AUTOSTART.

My concern, however, is that you have not yet discovered LogiCall! Many folks who now use LogiCall have discovered that without it on every disk, LKDOS is a ‘NAKED’ system which requires you to do a lot of typing (i.e. RAND USR 100: GOTO 1: RAND USR 100: LOAD “filenm.B1” as an example of LOADing “filenm.B1” on drive 1). LogiCall creates the ULTIMATE AUTOSTART for you simply by pressing the ‘A’ key <ENTER> and ‘D’ at the ‘Program?’ prompt. Get and use LogiCall!

Because the AUTOSTART programs others have written often use two tracks, I have usually been able to find room on even a full disk to add LogiCall (L.B1) by using LogiCall’s embedded AUTOSTART program to call the other person’s Menu.B1 program on boot-up and the disk still works the way it did before I added LogiCall!

Don Lambert wrote stating that being a less experienced programmer he could not understand why I used statements with RND, VAL and CODE in them. The answer, of course, is to save RAM space. Just a couple of bytes saved can sometimes save a whole disk track of 5090 bytes! My favorite example is opening up stream #4 to access LKDOS calls because PRINT # 4 is supposed to be easier to type [less key strokes] than RAND USR 100″. [page 11 of the V3 manual] Larry Kenny suggested that it uses less RAM space in a program. The fact is it uses up MORE RAM space! (My real problem with opening stream #4 is that it is also the stream assigned to my ZEBRA Talker.)

To illustrate the RAM savings, let us consider a short program to load LogiCall. Sit down at your machine and do the following:

Turn on your TS2068 and type PRINT FREE <ENTER> . You get 38652. This is our free RAM space. Now enter the following two lines:

10 RANDOMIZE USE 100: OPEN #4, "dd"
20 PRINT #4: LOAD "L.B1"

Now type PRINT FREE <ENTER>. You get 38600. Strange, 29 key-strokes used up 52 bytes!

Now EDIT the lines and put VAL with quotes around the 100 and the two 4s. The program now reads:

10 RANDOMIZE USE VAL"100": OPEN # VAL"4", "dd"
20 PRINT # VAL"4": LOAD "L.B1"

Now type PRINT FREE <ENTER>. You get 38609. Strange, you just added 9 keystrokes to the program and saved 9 bytes of RAM!

Now for the ultimate RAM saving trick. Most numbers over 31 can be expressed in the program as CODE. Let’s change VAL”100″ to CODE “d”, the two are equivalent. (See page 242 in the TS2068 manual or type ‘PRINT CODE “d” and check the response.) The program now reads:

10 RANDOMIZE USE CODE"d": OPEN # VAL"4", "dd"
20 PRINT # VAL"4": LOAD "L.B1"

Now type PRINT FREE <ENTER> . You get 38611. Losing the two zeros bought us two bytes. Notice that the following statements all mean the same thing.

RANDOMIZE USR 100
RANDOMIZE USR VAL "100"
RANDOMIZE USR CODE "d"

But what about OPENing stream #4 to save RAM space. Type in the program:

10 LET h=CODE "d"
20 RANDOMIZE USR h: LOAD "L.B1"

Now type PRINT FREE <ENTER>. You get 38624.

Both programs will LOAD LogiCall but the busiest stream #4 call uses 41 bytes while the USR call uses only 28. Also, for the record, RAND USR h is six bytes shorter than PRINT # 4 and just as easy to type, so,

WHY OPEN STREAM #4?

Here are a few of my favorite RAM saving Substitutes to ponder:

Instead of:  Try using:    Instead of:    Try using:
PRINT #0;    PRINT #RND;   GOTO 3         GOTO PI
PRINT #1;    PRINT #RND;   GOTO 6         GOTO PI+PI
0            NOT PI        GOTO 10        GOTO PI*PI
1            SGN PI        GOTO 8000      GOTO VAL "8e3"
100          CODE "d"      POKE 23658,0   POKE VAL"23658",NOT PI
INK 3        INK INT PI

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.