Commodore Autoboot
David W. Martin
This utility makes loading and running programs quick and easy, and can also be used as a form of copy protection. For the VIC-20 and Commodore 64 with a disk drive.
Have you ever wondered how some commercial programs run automatically after they're loaded? "Autoboot" enables you to add this convenient feature to your own programs.
Type in and SAVE Autoboot. VIC users should substitute the following for lines 481 and 491 before saving:
481 DATA 165, 175, 133, 46, 165, 174, 133, 45, 32, 89, 198, 32 : rem 234 491 DATA 142, 198, 76, 174, 199 : rem 77
To use Autoboot, first load the BASIC program that you want to make bootable. Then enter POKE 43,0:POKE 44,1 and SAVE the program using a different filename. This version of the program will be used by Autoboot. Now load and run Autoboot and enter the name of the modified version when prompted. Autoboot will then turn it into an autoboot program by directly changing certain disk sectors. The sector numbers are displayed on the screen as Autoboot runs.
Since the VIC and 64 automatically relocate programs when loading, all autobooted programs must be loaded using a nonrelocatable load as follows:
LOAD "filename", 8, 1
Of course, any BASIC program can be made to load and run from disk just by typing:
LOAD "filename", 8:
and pressing SHIFT-RUN/STOP instead of RETURN. But the power of Autoboot lies in the copy protection it provides. To copy protect your autorun programs, add POKE 808,100 (VIC), or POKE 808,234 (64) as the first line in your program before saving the modified version to be used by Autoboot. This will disable the RUN/STOP key, the RESTORE key, and the LIST command as soon as the program runs. Since the autobooted program will run as soon as it's loaded, the user won't be able to break out of the program to SAVE it.
Autoboot
Refer to the "Automatic Proofreader" article before typing this program in.
100 PRINT "{CLR} AUTOBOOT " : T = 18 : S = 1 : D$ = "0" : OPEN15, 8, 15, "I" + D$ : rem 248 110 OPEN2, 8, 2, "#" + "0" : rem 234 120 REM **** LOCATE TARGET : rem 158 130 INPUT "FILENAME" ; NA$ : LN = LEN(NA$) : rem 139 140 GOSUB210 : GOSUB300 : rem 245 150 IFT = 0 THENPRINTNA$" NOT FOUND" : GOTO540 : rem 18 160 GOTO140 : rem 101 170 GOTO540 : rem 106 180 REM ***POINT TO BYTE AND GET IT INTO {SPACE}X. : rem 108 190 PRINT#15, "B-P :" 2, L : GET#2, A$ : IFA$ = ""THENA$ = CHR$(0) : rem 197 200 X = ASC(A$) : RETURN : rem 206 210 PRINT "TRACK"T" SECTOR"S : rem 148 220 PRINT#15, "U1 : "2 ; D$ ; T ;S : rem 204 230 L = 0 : GOSUB180 : T = X : L = 1 : GOSUB180 : S = X : RETURN : rem 71 240 REM *** CHECK FOR FULL MATCH : rem 221 250 FORJ = ITOI + LN : L = J : GOSUB180 : IFX = 0 ORX = 160THEN270 : rem 130 260 X$ = X$ + CHR$(X) : NEXTJ : rem 101 270 IFX$<>NA$THENX$ = "" : RETURN : rem 23 280 L = I-2 : GOSUB180 : TT = X : L = I - 1 : GOSUB180 : SS = X : PRINT : rem 142 290 GOTO340 : rem 107 300 REM *** CHECK THROUGH ONE BLOCK FOR NAME MATCH : rem 54 310 FORI = 5TO230STEP32 : rem 15 320 L = I : GOSUB180 : IFCHR$(X) = LEFT$(NA$, 1)THENGOSUB240 : rem 95330 NEXTI : RETURN : rem 56 340 REM *** ACCESS 1ST SECTOR OF TARGET PROGRAM : rem 199 350 T = TT : S = SS : GOSUB210 : rem 142 360 L = 2 : GOSUB180 : AL = X : L = 3 : GOSUB180 : AH = X : SA = AL + AH * 256 : rem 183 370 IFSA <> 256THENPRINT : PRINTNA$" IS NOT PREPARED FOR AUTOBOOT" : GOTO540 : rem 142 380 REM *** ESTABLISH FALSE STACK : rem 125 400 PRINT#15, "U1 : "2 ; DR ; TT ; SS : PRINT : rem 104 410 FORPB = 173TO254STEP2 : PRINT#15, "B - P : "2 ; PB : rem 74 420 PRINT#2, CHR$(96) ; :rem 160 430 PRINT#15, "B - P : "2 ; PB + 1 : rem 113 440 PRINT#2, CHR$ (3) ; : PRINT "*" ; : NEXT : PRINT : rem 22 450 PRINT#15, "U2 :" 2 ; DR ; TT ; SS : rem 167 460 GOSUB210, PRINT : rem 116 470 REM *** PUT AUTOBOOT CODE ONTO PAGE 3 : rem 14 481 DATA165, 175, 133, 46, 165, 174, 133, 45, 32, 89, 166, 32 : rem 67 491 DATA 142, 166, 76, 174, 167 : rem 67 500 PRINT#15, "U1:" 2 ; DR ; T ; S : rem 251 510 FORPB = 105TO121 : READBY : PRINT#15, "B - P : " 2 ; PB : rem 194 520 PRINT#2, CHR$ (BY) ; : PRINT "." ; : NEXT : PRINT : PRINTNA$" CAN NOW BOOT ITSELF" : rem 0 530 PRINT#15, "U2 : " 2 ; DR ; T ; S : rem 255 540 CLOSE2 : CLOSE15 : rem 87