Classic Computer Magazine Archive COMPUTE! ISSUE 77 / OCTOBER 1986 / PAGE 79

Boot 64 For 128

Mike Tranchemontagne

Most Commodore 128 owners know that their computer can automatically load and run any 128 program from disk. This easy-to-use program adds the same convenience for Commodore 64 programs as well, allowing the 128 to load and run any 64 program automatically when you boot the system. A disk drive is required.

The Commodore 128 has many outstanding features, not the least of which is its ability to run thousands of excellent Commodore 64 programs and games. The 128 can automatically load and run any program written for 128 mode or CP/M mode. Although there are programs for the 64 that automatically run after loading from disk, it's still necessary to type in a command like LOAD "PROGRAM", 8, 1 to activate the disk drive in 64 mode. "Boot 64 For 128" automates this process so that you can load and run any Commodore 64 program simply by putting the disk in the drive and turning on the computer. This feature is ideal for younger members of the family or infrequent computer users. Even experienced programmers will appreciate the extra convenience it affords.

Creating An Autoboot Disk

Type in Programs 1, 2, and 3, and save copies of all three programs. For the boot sector created by Program 2 to work properly, you must use the filename 128BOOT64 when saving Program 1. To create an autobooting disk for 64 mode, follow these three steps:

1. Select the disk which will contain the 64 program you want to load and run automatically. Load Program 2, insert the disk in the drive, and run the program. When Program 2 is finished, the disk contains a 128 boot sector that will cause the computer to load and run a program named 128BOOT64. (You do not need to save Program 2 on the target disk.)

2. Load Program 1 and save it on the disk. Remember, you must save this program with the file-name 128BOOT64.

3. Load the 64 program which you want to load and run automatically; then save it on the disk using the filename BOOT64. You must save the program with this filename.

Once you've performed all three steps, place the disk in the drive and reboot by turning the power off and on or by pressing the reset switch. If the computer does not load and run the desired program, check Programs 1 and 2 for typing errors and repeat the process. Keep in mind that the process won't work unless you use the filenames noted above.

Autobooting ML Programs

With this technique, you can load and run any Commodore 64 BASIC program. The same is true of any machine language program that runs like BASIC. For instance, SpeedScript, COMPUTE!'s word processor, ordinarily starts with LOAD"SPEEDSCRIPT", 8 and RUN. To autoboot and run SpeedScript, simply save SpeedScript to disk with the filename BOOT64 as described in Step 3.

You can also autoboot and start a machine language program that normally loads with ,8,1 and starts with SYS instead of RUN. Program 3 is a very short BASIC loader which loads an ML program into memory, then activates it with SYS. As listed, the program loads and starts DOS 5.1, the DOS Wedge program supplied on the 1541/1571 Test/Demo disk. To load a different ML program, replace the name DOS 5.1 in line 20 with the filename of your program, and replace the address 52224 in line 30 with the correct SYS address for the program. When that's done, perform steps 1 and 2 as described earlier; then save Program 3 on the disk with the filename BOOT64. Of course, you must also copy the ML program to the same disk, using the filename you specified in line 20 of Program 3.

How Autobooting Works

When you turn on the 128 (or reboot by pressing the reset button), the computer automatically performs several checks to determine which mode it will operate in. If an autostart cartridge is plugged into the cartridge port, the cartridge takes control. If the Commodore key is pressed, the computer enters 64 mode. If the STOP key is pressed, the 128 enters the built-in machine language monitor.

If none of these conditions applies, the 128 looks on sector 0 of track 1 of the current disk (known as the boot sector) to see whether it contains a boot header. If no boot header is found, the computer simply starts BASIC, which produces the familiar READY prompt. However, if the boot header information is present, the 128 automatically loads and runs the program indicated in the boot sector. This process works equally well with a 1571 or 1541 disk drive.

In 128 mode, the 128 can switch to 64 mode by performing the command GO64. However, there is no provision for loading and running a program after you enter 64 mode. To achieve the same effect, this program creates a boot sector that tells the computer to load and run the program 128BOOT64. That program, in turn, stores a short machine language program and cartridge-identifier bytes in the special memory area where Commodore 64 autostarting cartridges normally reside. The ML program causes the computer (now in 64 mode) to perform a normal reset. When the reset occurs, the computer detects the cartridge-identifier bytes, concludes that a cartridge is present, and runs the ML routine found at the cartridge start address. This program, in turn, uses the dynamic keyboard technique to load and run a program named BOOT64 from disk. The process may seem complicated, but it all happens very quickly, and you need not understand the details in order to take advantage of it.

For instructions on entering these listings, please refer to "COMPUTE!'s Guide to Typing In Programs" in this issue of COMPUTE!.

Program 1: 128BOOT64

XK 20 READ D$: IF D$ = "-1" THEN GO64
HR 30 POKE A, DEC (D$):A = A + 1: GO TO 20
PH 40 DATA 09, 80, 5E, FE, C3, C2, CD, 38, 30
HM 50 DATA 8E, 16, D0, 20, A3, FD, 20, 50, FD
QX 60 DATA 20, 15, FD, 20, 5B, FF, 58
QH 70 DATA 20, 53, E4, 20, BF, E3, 20, 22, E4
CQ 80 DATA A2, FB, 9A
PH 90 DATA A2, 00, BD, 41, 80, F0, 06
AK 100 DATA 20, D2, FF, E8, D0, F5
HA 110 DATA A9, 0D, 8D, 77, 02, 8D, 78, 02
FG 120 DATA A9, 02, 85, C6
JA 130 DATA 4C, 74, A4
BR 140 DATA 0D, 4C, 4F, 41, 44, 22, 42, 4F, 4F, 54, 36, 34, 22, 2C, 38
BQ 150 DATA 0D, 0D, 0D, 0D, 0D, 52, 55, 4E, 91, 91, 91, 91, 91, 91, 91, 0, -1

Program 2: Boot sector Maker

JF 20 DCLEAR: OPEN 15, 8, 15: OPEN 2, 8, 2, "#": PRINT# 15, "B-P:2, 0"
RR 30 READ D$: D = DEC(D$): IF D>255 THEN 50
EE 40 PRINT# 2, CHR$(D); : GOTO {SPACE} 30
RJ 50 PRINT# 15, "U2;2, 0, 1, 0"
XG 70 DATA 43, 42, 4D, 00, 00, 00, 00, 31, 32, 38, 42, 4F, 4F, 54, 36, 34, 00, 00, A2, 18
RM 80 DATA A0, 0B, 4C, A5, AF, 52, 55, 4E, 22, 31, 32, 38, 42, 4F, 4F, 54, 36, 34, 00, 100

Program 3: ML Loader

KM 20 IF A = 0 THEN A = 1: LOAD "DOS 5.1", 8, 1