Bootmaker For VIC, PET, And 64
M. G. Ryschkewitsch
Here's a good, short boot routine that's going to simplify your programming efforts. This general technique can be applied to many different boots (programs that load other programs). A timesaver for any Commodore computer.
How many times have you turned on your computer and wished that you didn't have to go through the tedium of loading utility programs or remembering where to PEEK, POKE, or SYS to link them in?
I'd like to describe a booting system which uses the "dynamic keyboard" technique and a modified version of the "Universal Wedge."
This particular boot can be used to simplify setting up your computer for the graphing utility which follows, but the general technique is simple and useful for a wide variety of boots. A similar technique can be used, for example, to ask a user questions in order to initialize a printer prior to loading a word processing program. If your PET has BASIC 4.0 and you put your boot on a diskette as the first program, the process is particularly simple. Press SHIFT/RUN, and the hard part is done by the computer.
The Dynamic Keyboard Technique
The dynamic keyboard technique involves fooling the computer into thinking the user is entering data from the keyboard. This is particularly easy with the PET. It involves printing messages on the screen and POKEing two locations in PET memory, the keyboard buffer at decimal addresses 623-632 and location 158, which normally contains the current number of characters in the buffer.
Your BASIC program must print all the entries you'd normally make on the screen in the proper locations (to leave room for the normal PET messages such as LOADING, etc.) and then return the cursor to the home position. If you then POKE the number of carriage returns (character 13) that you'd normally enter beginning with location 623 and that number also into location 158, here's what happens.
After the PET finishes executing your boot, it will wake up with the cursor in the home position and believe you've pushed the RETURN key a number of times. The first RETURN will cause it to execute the line that the cursor is on, and, after printing any appropriate messages, it will execute as many subsequent lines as there are RETURNS in the buffer. The only catch is that each line that you want it to execute must be in the right place or you will get no response or a SYNTAX ERROR. Study the example in Program 1 to see exactly what is necessary.
Note that Program 1 is merely an example of setting up a boot program using the dynamic keyboard technique. If the files INVISIBLE WEDGE, PRINTER, and WORD PROC existed on a disk, the program would first enable the use of the Invisible Wedge utility as described below. It would then load and execute a printer setup routine called PRINTER. Finally, it would load and run a word processing program with the file name WORD PROC.
Sleight Of Hand
There is a hitch to this procedure if you want to use the Universal Wedge. That program clears the screen and prints a message when it's executed, wiping out your carefully laid out screen. The part of the Wedge that prints the message is fortunately in BASIC, but it requires a bit of sleight of hand to modify since the BASIC line editor will change the machine code that does the work unless you protect it.
If you load the Universal Wedge without running it and use the Monitor (SYS 54386 for 4.0), you will find what looks like a BASIC program from locations hexadecimal $0400 to $0496, terminated by the usual set of triple double zeros. Starting at $0500 and $0700, there are two blocks of machine code that do the actual work. If you also PEEK at the contents of decimal 42 and 43 (which store the location of the end of the BASIC text and the start of variable storage), you will find that they point to a location at the end of the second block of machine code ($B8 and $08).
Now POKE42,131 and POKE43,4 and type CLR. This tells the editor that BASIC really doesn't include the two blocks of machine code. You can then change the BASIC program as long as you don't increase it by more than 106 characters. Try to use less than this just to be safe. In Program 2, two UP CURSORs replace the CLEAR/HOME and all the CURSOR DOWNs in the original.
You can now use the Monitor to save everything up to the address hexadecimal $08B8. And from now on you can load this version of the Wedge just as you would load the original.
This same technique is equally applicable to the VIC-20 and Commodore 64 (see Program 3). For both these machines, the keyboard buffer is located in memory locations 631-640 decimal, and the number of characters in the buffer is contained in location 198 decimal. The VIC's narrow screen width must be taken into account when formatting the program. Some of the messages may run over onto a second line.
A small investment in bootmaking now can pay big dividends later by causing fewer errors, saving time and making the computer easier for others to use.
Program 1: Sample Boot Program
100 QO$ = CHR$ (34) : REM DEFINE QUOTE FOR PRI NTING 110 REM PRINT ENTRIES TO THE SCREEN IN PRO PER SPOTS 120 PRINT" {CLEAR} {03 DOWN} LOAD"; QO$; "INVIS IBLE WEDGE"; QO$; ",8" 130 PRINT"{04 DOWN} RUN" 140 PRINT"{DOWN} LOAD"; QO$; "PRINTER"; QO$;", 8" 150 PRINT"{04 DOWN}RUN" 160 PRINT "{02 DOWN}LOAD"; QO$; "WORD PROC"; Q O$;", 8" 170 PRINT"{04 DOWN}RUN{HOME}" 180 REM POKE SIX RETURNS INTO KEYBOARD BUF FER 190 REM POKE # OF RETURNS INTO LOC. 158 200 FORI = 1TO6 : POKE622 + I, 13 : NEXT : POKE158, 6
Program 2: Invisible Wedge
5 A = 12 * 16 ^ 3 : REM $C000 10 IFPEEK(A)<>76THEN SYS1639 : REM BASIC 2 15 IFPEEK(A) = 76 THEN SYS2151 : REM BASIC 4 20 PRINT" {02 UP}UNIVERSAL DOS SUPPORT LOADED " 25 NEW 100 QO$ = CHR$(34) : REM DEFINE QUOTE FOR PRINTING 110 REM PRINT ENTRIES TO THE SCREEN IN PRO PER SPOTS 120 PRINT" {CLEAR} {03 DOWN}LOAD" ;QO$; "PRINT ER" ; QO$;",8" 130 PRINT"{04 DOWN}RUN" 140 PRINT"{02 DOWN}LOAD" ;QO$; "WORD PROC";Q O$;",8" 150 PRINT"{05 DOWN}RUN{HOME}" 160 REM POKE FOUR RETURNS TO KEYBOARD BUFF ER 170 REM POKE # OF RETURNS TO LOC. 198 180 FORI=1TO4 : POKE630 + I, 13 : NEXT : POKE198, 4