Lightning
Renumber
For Atari
Raymond Citak
Renumber
For Atari
Raymond Citak
This fast, convenient utility renumbers any BASIC program. It runs on any Atari 400, 800, XL, or XE with at least 48K RAM.
If you write BASIC programs, you know how frustrating it can be to run out of space to insert program lines, especially when the program is nearly finished. Since Atari BASIC has no RENUMBER command, you may be forced to renumber dozens of lines manually, creating the risk that you'll inadvertently delete or misnumber a line. "Lightning Renumber" removes that worry and saves a lot of time, too. It can handle any Atari BASIC program, and it renumbers internal line references as well as the lines themselves. Because it uses a machine language (ML) routine, it does the job in only a few seconds. But it's easy enough for anyone to use, even if you don't know anything about machine language.
Type in and save Lightning Renumber as listed below, then run it. The program offers two options. You can either write the ML routine as a binary (machine language) file to disk, or POKE it directly into memory. The binary file option is straightforward: After you designate the drive number, the program creates and locks a binary file named RENUMBER.OBJ on your disk. The binary file can then be loaded into memory and called with a USR statement (see below) whenever you like. If you don't have a disk drive, select the second option to POKE the ML into memory.
Call It With USR
Once the ML routine is in memory, enter NEW and load the BASIC program you want to renumber. Now you can call the ML routine by typing in a USR statement and pressing RETURN. The USR statement must include three numbers: the address of the routine (always 38900), the starting line number, and the line increment value. For example, the statement U=USR (38900,10,10) renumbers a program so the first line is 10 and the rest are numbered in increments of 10 (20, 30, and so on). To start with line 1000 and renumber in increments of 100, use the statement U=USR(38900,1000,100), and so on. When the message **RENUMBERED** appears, the job is complete. At this point, you should resave the renumbered program.
The routine checks for several errors. First, it makes sure the renumbered program will not have line numbers above 32767. If the values you specify in the USR statement would create a line number greater than 32767, you'll get the message ERROR - CHANGE YOUR USR ARGUMENTS. Enter a new USR statement with appropriate values.
Incorrect line references are detected as well. For instance, your program may contain the statement GOTO 300 when no line 300 exists. When such an error occurs, you'll see the message ERROR - LINE # MISMATCH. Mismatched line references (300 in this example) are replaced by 55555, and the rest of the program is renumbered as usual. When this error message appears, you must LIST the program and change any 55555 line references to the correct line numbers before resaving the program.
TRAP statements (except for TRAP 40000) are also renumbered by this routine. However, it cannot change computed line references (GOTOs or GOSUBs that use a variable to refer to a line number). If your program uses computed line references, LIST the program and change them yourself after the rest of the program is renumbered.
Possible Memory Conflicts
Although Lightning Renumber is designed to be reliable, it's possible to disrupt it by running BASIC programs. The ML normally resides in high memory just beneath the display list in GRAPHICS 0. Running a BASIC program that's very long or that uses the same memory area for other graphics modes, player-missile data, etc., may overwrite and destroy the ML. When that occurs, trying to call the routine may crash the computer (and destroy your program). When in doubt, save your BASIC program and reload the binary file (RENUMBER.OBJ) from disk; then reload the BASIC program and call the routine with USR.
If you use this routine frequently, you may want to include the USR call within the BASIC program itself. Since line 32767 will never be renumbered, place the USR statement in that line. Then you can renumber the program at any time by entering GOTO 32767.
You could also create an AUTORUN.SYS file that loads Lightning Renumber into memory automatically when the disk is booted. If you already have an AUTORUN.SYS file on the disk, you can append the renumber file to it from the DOS menu. Choose the Binary Save option, then type in AUTORUN.SYS/A,97F4,9BFF. Lightning Renumber will be appended to the existing AUTORUN.SYS file and will load automatically when you boot that disk.
If you want to save typing, send a blank disk or tape, a selfaddressed postage-paid mailer, and $3 to:
Raymond Citak
1514 Park Avenue
Laramie, WY 82070
Special thanks to W. A. Bell for his useful line dump routine which appears in COMPUTE!'s First Book of Atari.
Lightning Renumber
For instructions on entering this listing, please
refer to " C:OMPUTE!'s Guide to Typing In
Progrums" published bimonthly in COMPUTE!.
JP 10 DIM DRIVE$(2),A$(15):P
OKE 709,0:POKE 710,168
:POKE 712,146
OD 20 ? CHR$(125):? :? "
{9 SPACES}{RVS} RENUMBER BA
SIC {OFF}"
HG 30 ? "TO LOAD THIS OBJECT
FILE DIRECTLY
{5 SPACES}INTO MEMORY
AND NOT TO DISK, PRESS
"
EE 40 "KEY ";CHR$(34);"L";
CHR$(34);". REQUIRES
48K MEMORY.":? "PRESS
ANY KEY FOR DISK WRITE
."
CB 50 OPEN #4,4,0,"K":GET #4
,Z:lF Z=76 THEN 1440
DD 60 CLOSE #4
IM 70 ? CHR$(125):? :? :? "
{6 SPACES}{RVS} RENUMBER.OB
J - LOADER {OFF}"
NJ 80 ? :? "**REQUIRES 48K M
EMORY AND DOS v.2.**"
NJ 90 ? :? "To which disk dr
ive would you like the
file written to (D1,D2
,D3,or D4)";
LP 100 INPUT DRIVES
NO 110 GOSUB 1380
LC 120 ? :? "One moment whil
e I write the file to
":? DRIVE$;"..."
IN 130 A$(1,2)=DRIVE$:A$(3,1
5)=":RENUMBER.OBJ"
HB 140 TRAP 300:OPEN #2,8,0,
A$
GG 150 TRAP 180
OL 160 READ B:PUT #2,B
GI 170 GOTO 160
GE 180 CLOSE #2
PH 196 OPEN #l,12,0,A$:XIO 3
5,#1,0,0,A$
FN 200 CLOSE #1
DF 210 ? CHR$(125):?
DN 220 ? "File is now writte
n to ";DRIVE#;"."
PK 230 ? "You may now use th
e DOS menu selection'
L' to place the renum
ber program "
EK 240 ? "into memory. Retu
rn to BASIC, load
{3 SPACES}file to be
renumbered, and use"
ON 250 ? "U=USR(38900, start
ing line number,
{4 SPACES}incroment)
to renumber your prop
ram."
GE 260 ? "Or place the USR s
tatement into your p
rogram at line 32767.
Watch for"
PN 270 ? "possible overwrite
of the renumber
{4 SPACES}program if
RUNning a BASIC progr
am"
GG 280 ? "that changes GRAPH
ICS modes, or uses o
ther high memory."
GE 290 POKE 709,202:POKE 710
,148:POKE 712,0:END
HH 300 ? CHRS(125):? :? "ERR
OR #";:? PEEK(195);:?
" trying to write th
e file...":FOR I=1 TO
500:NEXT I:RUN
KJ 310 REM THIS DATA FOR DIS
K WRITE ONLY
CL 320 DATA 255,255,244,151,
255,155
BL 330 REM THIS DATA FOR MEM
ORY 38900($97F4) TO 3
9935($9BFF)
ML 340 DATA 76,80,153,165,13
6,133,203,165,137,133
KA 350 DATA 204,169,0,133,20
5,133,206,133,207,96
GF 360 DATA 201,14,240,1,96,
152,141,243,151,136
GN 370 DATA 177,203,32,61,15
2,165,207,208,10,32
DL 380 DATA 101,152,165,207,
208,3,76,40,152,32
NG 390 DATA 148,152,172,243,
151,169,0,133,205,133
BA 400 DATA 206,133,207,141,
243,151,200,200,200,2
00
DC 410 DATA 200,200,96,201,1
8,240,1,96,136,152
JH 420 DATA 201,3,240,249,17
7,203,201,14,208,244
IK 430 DATA 136,177,203,201,
23,240,11,201,24,240
EH 440 DATA 7,201,4,240,3,76
,66,152,169,1
AJ 458 DATA 133,207,96,172,2
43,151,136,177,203,20
1
CA 460 DATA 10,240,32,201,12
,240,28,201,23,240
BP 470 DATA 24,201,24,240,20
,201,13,240,16,201
MK 480 DATA 4,240,12,201,27,
240,8,201,35,240
OG 490 DATA 1,96,32,226,154,
169,1,133.207,96
DD 500 DATA 172,243,151,138,
141,242,151,165,136,1
33
CL 510 DATA 205,165,137,133,
206,200,177,203,133,2
12
CE 520 DATA 200,177,203,133,
213,200,177,203,133,2
14
CJ 530 DATA 200,177,203,133,
215,200,177,203,133,2
16
MP 540 DATA 200,177,203,133,
217,32,198,154,32,210
MI 550 DATA 217,169,0,141,24
0,151,141,241,151,160
HF 560 DATA 0,177,205,200,19
7,212,208,6,177,205
EC 570 DATA 197,213,240,30,3
2,90,154,160,2,177
IP 580 DATA 205,24,101,205,1
33,205,144,2,230,206
NH 590 DATA 238,240,151,173,
240,151,208,3,238,241
PP 600 DATA 151,76,207,152,1
73,240,151,141,234,15
1
CK 610 DATA 173,241,151,141,
235,151,173,230,151,1
41
NL 620 DATA 236,151,173,231,
151,141,237,151,32,41
AI 630 DATA 155,24,173,238,1
51,109,228,151,133,21
2
AI 640 DATA 173,239,151,109,
229,151,133,213,32,17
0
DD 650 DATA 217,172,243,151,
174,242,151,200,165,2
12
CJ 660 DATA 145,203,200,165,
213,145,203,200,165,2
14
CO 670 DATA 145,203,200,165,
215,145,203,200,165,2
16
AD 680 DATA 145,203,200,165,
217,145,203,96,104,10
4
CO 690 DATA 141,229,151,104,
141,228,151,104,141,2
31
MH 700 DATA 151,104,141,230,
151,173,6,228,170,232
DC 710 DATA 138,141,154,153,
141,114,154,141,171,1
54
NG 720 DATA 141,252,154,173,
7,228,141,155,153,141
DF 730 DATA 115,154,141,172,
154,141,253,154,173,2
30
EG 740 DATA 151,208,8,173,23
1,151,208,3,76,244
LG 750 DATA 154,32,138,155,1
62,13,138,72,189,244
JN 760 DATA 153,32,176,242,1
04,170,202,16,243,32
JN 770 DATA 247,151,160,0,17
7,203,201,255,240,14
JC 780 DATA 201,0,208,20,200
,177,203,201,128,208
HA 790 DATA 13,76,2,154,200,
177,203,201,127,208
NB 800 DATA 3,76,2,154,160,2
,177,203,170,200
LK 810 DATA 200,177,203,201,
22,240,22,201,155,240
AO 820 DATA 6,32,8,152,76,20
2,153,152,133,208
KF 830 DATA 230,208,228,208,
240,3,76,202,153,138
FO 840 DATA 24,.101,203,133,2
03,144,2,230,204,76
KH 850 DATA 164,153,155,155,
46,46,46,103,110,105
NL 860 DATA 107,114,111,87,1
55,125,32,247,151,173
DL 870 DATA 228,151,133,205,
173,229,151,133,206,1
60
DB 880 DATA 0,177,203,201,25
5,240,14,201,0,208
KC 890 DATA 20,200,177,203,2
01,128,208,13,76,163
KA 900 DATA 154,200,177,203,
201,127,208,3,76,163
NJ 910 DATA 154,160,0,165,20
5,145,203,200,165,206
PL 920 DATA 145,203,200,177,
203,170,173,230,151,2
4
CC 930 DATA 101,205,133,205,
173,231,151,101,206,1
33
JA 940 DATA 206,138,24,101,2
03,133,203,144,2,230
AH 950 DATA 204,76,15,154,16
0,0,177,205,201,0
EL 960 DATA 208,7,200,169,12
8,209,205,240,1,96
LE 970 DATA 162,22,138,72,18
9,140,154,32,176,242
OA 980 DATA 104,170,202,16,2
43,169,66,133,212,169
KJ 990 DATA 5,133,213,169,85
,133,214,133,215,104
BP 1000 DATA 104,76,43,153,1
55,72,67,84,65,77
JC 1010 DATA 83,73,77,32,35,
69,78,73,76,32
MI 1020 DATA 45,32,210,207,2
10,210,197,162,18,13
8
AM 1030 DATA 72,189,179,154,
32,176,242,104,170,2
02
BO 1040 DATA 16,243,96,155,1
55,42,42,32,68,69
JP 1050 DATA 82,69,66,77,85,
78,69,82,32,42
NA 1060 DATA 42,155,165,212,
201,66,208,15,165,21
3
DE 1070 DATA 201,4,208,9,165
,214,208,5,104,104
DN 1080 DATA 76,43,153,96,13
6,152,201,3,240,13
CI 1090 DATA 177,203,201,54,
208,244,104,104,104,
104
JG 1100 DATA 76,40,152,96,10
4,104,104,104,162,36
KH 1110 DATA 138,72,189,4,15
5,32,176,242,104,170
FD 1120 DATA 202,16,243,96,1
55,155,46,83,84,78
JJ 1130 DATA 69,77,85,71,82,
65,32,82,83,85
JP 1140 DATA 32,82,85,79,89,
32,69,71,78,65
GJ 1150 DATA 72,67,32,45,32,
210,207,210,210,197
PI 1160 DATA 155,169,0,141,2
32,151,141,233,151,1
41
NN 1170 DATA 238,151,141,239
,151,162,16,24,78,23
5
FL 1180 DATA 151,110,234,151
,144,40,24,173,238,1
51
HB 1190 DATA 109,236,151,141
,238,151,173,239,151
,109
GN 1200 DATA 237,151,141,239
,151,176,153,173,238
,151
DC 1210 DATA 24,109,232,151,
141,238,151,173,239,
151
PM 1220 DATA 109,233,151,141
,239,151,24,14,236,1
51
GJ 1230 DATA 46,237,151,144,
13,24,14,232,151,46
AD 1240 DATA 233,151,238,232
,151,76,134,155,14,2
32
BF 1250 DATA 151,46,233,151,
202,208,176,96,169,2
55
CG 1260 DATA 141,240,151,141
,241,151,32,247,151,
160
JJ 1270 DATA 0,177,203,208,7
,200,177,203,201,128
JD 1280 DATA 240,29,160,2,17
7,203,24,101,203,133
PG 1290 DATA 203,165,204,105
,0,133,204,238,240,1
51
NF 1300 DATA 173,240,151,208
,3,238,241,151,76,14
9
FN 1310 DATA 155,173,240,151
,141,234,151,173,241
,151
FN 1320 DATA 141,235,151,173
,230,151,141,236,151
,173
MJ 1330 DATA 231,151,141,237
,151,32,41,155,24,17
3
NC 1340 DATA 238,151,109,228
,151,141,238,151,173
,239
AN 1350 DATA 151,109,229,151
,141,239,151,176,14,
56
IG 1360 DATA 169,254,237,238
,151,169,127,237,239
,151
GM 1370 DATA 48,1,96,76,242,
154
NJ 1380 REM CK FOR CORRECT E
NTRY
KN 1390 IF DRIVE$(1,1)<>"D"
OR LEN(DRIVE$)=1 THE
N 1410
PI 1400 IF DRIVE$(2,2)="1" O
R DRIVE$(2,2)="2" OR
DRIVE$(2,2)="3" OR
DRIVE$(2,2)="4" THEN
1430
PF 1410 POP :? :? "Error in
entry. Try again...
"
CD 1420 FOR Q=1 TO 300:NEXT
Q:? CHR$(125):? :GOT
O 70
KI 1430 RETURN
PK 1440 REM LOAD DATA INTO M
EMORY
IC 1450 CLOSE #4:? :? "Loadi
ng DATA into memory.
.."
EE 1460 RESTORE 340:FOR I=38
900 TO 38900+1035:RE
AD A:POKE I,A:NEXT I
FD 1470 ? :? "Load complete.
NEW this program,
and LOAD or ENTER yo
ur BASIC program to"
IE 1480 ? "be renumbered. T
hen use U=USR(38900,
first line number,
increment) to"
OI 1490 ? "renumber the prop
ram. All error
{6 SPACES}checking i
s done by the renumb
er pro- gram."
IP 1500 POKE 709,202:POKE 71
0,148:POKE 712,0:END