Reads RAMTOP, asks how many bytes your routine needs, and prints the new RAMTOP in a box with the two numbers to POKE into 16388 and 16389. Answer Y and it POKEs them and does NEW, so the space is protected; N leaves things as they are. Run it before loading or typing your own program.
The article also suggests using it to speed up a program by lowering RAMTOP by the memory the program doesn’t use. SAVE it before you run it, since line 995 wipes it out.
Published in Syntax August 1983 (Set RAMTOP Automatically).
Source Code
5 SLOW
10 LET RT=PEEK 16388+256*PEEK 16389
20 PRINT TAB 10;"RAMTOP=";RT
30 PRINT
35 PRINT "HOW MANY BYTES IS YOUR ROUTINE?"
40 INPUT BYTES
45 PRINT
50 PRINT TAB 10;"BYTES LONG=";BYTES
55 LET NA=RT-BYTES
60 LET A=NA/256
63 PRINT
65 PRINT "MAKE RAMTOP=";NA
70 LET A$=STR$ A
100 FOR X=1 TO LEN A$
110 IF A$(X)="." THEN GOTO 200
120 NEXT X
200 LET A$=A$( TO X-1)
210 LET A=VAL A$
230 LET RE=NA-256*A
800 PRINT AT 8,3;"▛▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▜"
810 PRINT AT 9,3;"▌";AT 9,21;"▐"
820 PRINT AT 10,3;"▙▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▟"
830 PRINT AT 9,4;NA;"=";RE;"+256*";A
840 PRINT
850 PRINT
860 PRINT "DO YOU WANT MEMORY SET TO ",NA;"?"
870 LET Q$=INKEY$
880 IF Q$="Y" THEN GOTO 950
890 IF Q$="N" THEN GOTO 999
900 GOTO 870
950 PRINT
960 PRINT TAB 11;"DONE"
970 PAUSE 80
980 POKE 16388,RE
990 POKE 16389,A
995 NEWNote: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
