Bopotron Construction Set

Type
Utility
Category
Level editor that writes BASIC DATA lines
Author
Kyle Peacock
Published in
ANALOG Computing issue 24 (1984), with Bopotron; later on the BELLCOM public domain disks
Year
1984
Language
Atari BASIC
Requirements
Atari BASIC; the Bopotron game listing; a disk drive or cassette to hold the generated lines

About the program

Most early level editors drew on screen. This one writes program code. The Bopotron Construction Set came with the game Bopotron in ANALOG Computing #24. It asks you, one question at a time, for the contents of a level, then writes the answers out as numbered Atari BASIC DATA statements. Those lines use exactly the numbers Bopotron's own level tables use (2080+20×level, 3080+20×level and so on), so ENTERing them into the game adds a new level or replaces an old one. The screen header says "REFER TO ANALOG NO.24 FOR INSTRUCTION". The notes below come from what the program itself asks for.

What you need

Atari BASIC, a copy of Bopotron, and somewhere to put the output: a disk file (D:), cassette (C:), the printer (P:), or the screen (E: or S:) if you just want to look.

Typing it in

The listing is short and plain ASCII, with a few inverse-video headings. INPUT #16 is used everywhere instead of plain INPUT. It's a well-known trick: BASIC multiplies the channel number by 16 to find the I/O control block, and 16×16 = 256 wraps round to 0, the screen editor. The input still comes from the keyboard, but without the ? prompt, which makes the screens tidier. Line 470 jumps to the nonexistent line 32767 if you ask for more than 50 power packs. The TRAP 890 in line 180 catches the error and prints "ABNORMAL PROGRAM TERMINATION", so that's normal behaviour.

How to use it

RUN, then answer the prompts:

  1. Device filename, for example D:LEVEL6.LST. The first two characters must be C:, D:, P:, E: or S:.
  2. Level number, then Bopotron's start position (X,Y), initial power and maximum power, and the position of the exit girder. Entering 0,0 for the start skips those lines, so you can edit only the layout of an existing level.
  3. Girders (up to 50): start X, end X, Y for each one.
  4. Ladders (up to 50): start Y, end Y, X for each one.
  5. Power packs (batteries) and power units: the lower-left X,Y of each.
  6. Moving platforms (0–2): for each, 1–5 vectors, each one an origin X,Y, a destination X,Y and a speed.

The program writes the lines and ENDs. LOAD Bopotron, ENTER the file, and SAVE the result. The new level number must not be higher than Bopotron's MAXLEVEL (line 160), so raise that if you add levels beyond 5 (or 7).

How it works

All the answers are kept in arrays (G, L, B, P, V). Lines 800–860 then print them as BASIC text: a line number, the word DATA, and the numbers separated by commas, starting a new line every 25 values. Bopotron's level tables begin with a count, so line 810 prints the number of girders (or ladders, or packs) first. Because the output is plain listed text, the same file can be ENTERed, edited with the screen editor, or printed. That makes it an early example of a program that writes another program's source.

Listing

100 REM *****************************
110 REM *                           *
120 REM * BOPOTRON CONSTRUCTION SET *
130 REM *      BY KYLE PEACOCK      *
140 REM *  ANALOG COMPUTING NO. 24  *
150 REM *                           *
160 REM *****************************
170 REM 
180 TRAP 890
190 DIM FILE$(15),D$(6),X$(10),G(150),L(150),B(150),P(150),V(150),X(150)
200 REM *** OUTPUT DEVICE
210 D$=" DATA ":X$="C:D:P:E:S:"
220 GOSUB 870:? "DEVICE FILENAME IS ";:INPUT #16;FILE$
230 FOR X=1 TO 9:IF X$(X,X+1)=FILE$(1,2) THEN 260
240 NEXT X:GOTO 890
250 REM *** LEVEL
260 GOSUB 870:POSITION 16,1:? "{inv}POWER-UP{/inv}":?:? "LEVEL # ";:INPUT #16;LVL
270 REM *** BOPOTRON LOCATION
280 ?:? "BOPOTRON LOCATION (X,Y) :";:INPUT #16;BOPX,BOPY:IF BOPX=K0 AND BOPY=K0 THEN 310
290 ?:? "INITIAL POWER :";:INPUT #16;PWR:?:? "MAXIMUM POWER :";:INPUT #16;MAXPWR
300 ?:? "EXIT GIRDER POSITION (X,Y) :";:INPUT #16;XITX,XITY
310 REM *** GIRDER DRAW
320 GOSUB 870:POSITION 12,1:? "{inv}GIRDER PLACEMENT{/inv}":? 
330 ? "NUMBER OF GIRDERS :";:INPUT #16;GIRAMT:IF GIRAMT>50 THEN 330
340 IF GIRAMT<=0 THEN 380
350 ?:? "{inv}FORMAT:{/inv} STARTING X, ENDING X, Y":? 
360 ?:FOR X=1 TO GIRAMT:XX=(X-1)*3:? "GIRDER ";X;" POSITION :";:INPUT #16;A,B,C:G(XX+1)=A:G(XX+2)=B:G(XX+3)=C
370 NEXT X
380 REM *** LADDER DRAW
390 GOSUB 870:POSITION 12,1:? "{inv}LADDER PLACEMENT{/inv}":? 
400 ? "NUMBER OF LADDERS :";:INPUT #16;LADAMT:IF LADAMT>50 THEN 360
410 IF LADAMT<=0 THEN 450
420 ?:? "{inv}FORMAT:{/inv} STARTING Y, ENDING Y, X":? 
430 ?:FOR X=1 TO LADAMT:XX=(X-1)*3:? "LADDER ";X;" POSITION :";:INPUT #16;A,B,C:L(XX+1)=A:L(XX+2)=B:L(XX+3)=C
440 NEXT X
450 REM *** POWER PACK DRAW
460 GOSUB 870:POSITION 10,1:? "{inv}POWER PACK PLACEMENT{/inv}":? 
470 ? "NUMBER OF POWER PACKS :";:INPUT #16;BATAMT:IF BATAMT>50 THEN 32767
480 IF BATAMT<=0 THEN 510
490 ?:? "{inv}FORMAT:{/inv} LOWER LEFT X, LOWER LEFT Y":? 
500 ?:FOR X=1 TO BATAMT:XX=X*2-1:? "POWER PACK ";X;" POSITION :";:INPUT #16;A,B:B(XX)=A:B(XX+1)=B:NEXT X
510 REM *** POWER UNIT DRAW
520 GOSUB 870:POSITION 10,1:? "{inv}POWER UNIT PLACEMENT{/inv}":? 
530 ? "NUMBER OF POWER UNITS :";:INPUT #16;PWRAMT:IF PWRAMT>50 THEN 530
540 IF PWRAMT<=0 THEN 570
550 ?:? "{inv}FORMAT:{/inv} LOWER LEFT X, LOWER LEFT Y":? 
560 ?:FOR X=1 TO PWRAMT:XX=X*2-1:? "POWER UNIT ";X;" POSITION :";:INPUT #16;A,B:P(XX)=A:P(XX+1)=B:NEXT X
570 REM *** PLATFORM PROGRAMMING
580 GOSUB 870:POSITION 10,1:? "{inv}PLATFORM PROGRAMMING{/inv}":? 
590 V(1)=0:PLUS=1:? "NUMBER OF PLATFORMS :";:INPUT #16;PLRAMT:IF PLRAMT<0 OR PLRAMT>2 THEN 590
600 IF PLRAMT=0 THEN 690
610 V(PLUS)=PLRAMT:PLUS=PLUS+1
620 FOR X=1 TO PLRAMT:?:? "{inv}PLATFORM :{/inv}";X
630 ?:? "NUMBER OF VECTORS :";:INPUT #16;VEC:IF VEC<1 OR VEC>5 THEN 630
640 V(PLUS)=VEC:PLUS=PLUS+1
650 ?:? "{inv}FORMAT:{/inv} ORIGIN X, ORIGIN Y,":? "        DESTINATION X, DESTINATION Y,":? "        SPEED"
660 ?:FOR Y=1 TO VEC:? "VECTOR ";Y;" TRAJECTORY :";:INPUT #16;A,B,C,D,E
670 V(PLUS)=A:V(PLUS+1)=B:V(PLUS+2)=C:V(PLUS+3)=D:V(PLUS+4)=E:PLUS=PLUS+5
680 NEXT Y:NEXT X:HOLD=PLUS-1
690 REM *** DISPLAY OUTPUT
700 GOSUB 870:? "GENERATING OUTPUT, PLEASE WAIT...";:OPEN #1,8,0,FILE$
710 IF BOPX=K0 AND BOPY=K0 THEN 740
720 PRINT #1;2080+(20*LVL);D$;BOPX;",";BOPY;",";PWR;",";MAXPWR
730 PRINT #1;3080+(20*LVL);D$;XITX;",";XITY
740 OFF=4080:AMOUNT=GIRAMT:MAX=GIRAMT*3:FOR X=1 TO 150:X(X)=G(X):NEXT X:GOSUB 800
750 OFF=5080:AMOUNT=LADAMT:MAX=LADAMT*3:FOR X=1 TO 150:X(X)=L(X):NEXT X:GOSUB 800
760 OFF=6080:AMOUNT=BATAMT:MAX=BATAMT*2:FOR X=1 TO 150:X(X)=B(X):NEXT X:GOSUB 800
770 OFF=7080:AMOUNT=PWRAMT:MAX=PWRAMT*2:FOR X=1 TO 150:X(X)=P(X):NEXT X:GOSUB 800
780 OFF=8080:AMOUNT=V(1):MAX=HOLD:FOR X=1 TO 150:X(X)=V(X):NEXT X:GOSUB 800
790 END 
800 COUNT=0+1*(OFF=8080):IF AMOUNT=0 THEN 860
810 PLUS=0:GOSUB 880:PRINT #1;AMOUNT;",";
820 COUNT=COUNT+1:PRINT #1;X(COUNT);
830 IF COUNT/25=INT(COUNT/25) THEN PLUS=PLUS+1:IF COUNT<>GIRAMT*MAX THEN PRINT #1;"":GOSUB 880:GOTO 820
840 IF COUNT=MAX THEN PRINT #1;"":GOTO 860
850 PRINT #1;",";:GOTO 820
860 RETURN 
870 ? "{CLEAR}":POSITION 8,0:? "{inv}BOPOTRON CONSTRUCTION SET{/inv}":? "REFER TO ANALOG NO.24 FOR INSTRUCTION":?:RETURN 
880 PRINT #1;OFF+(20*LVL)+PLUS;" DATA ";:RETURN 
890 ? "{CLEAR}":POSITION 6,1:? "{inv}ABNORMAL PROGRAM TERMINATION{/inv}"

Credits