Scatters about 100 inverse asterisks inside a solid border and sends a marker travelling across the field, steered with the cursor keys 5, 6, 7 and 8. The marker keeps moving in the last direction chosen, collecting every asterisk it passes over and erasing its path as it goes. Running into the border ends the game, and the program reports the number of asterisks collected and the number of moves taken.
Program Analysis
Program Structure
Lines 10–110 read the display file address from D_FILE (PEEK 16396+256*PEEK 16397), draw the border with full-block characters and place the asterisks at random positions. The marker is not drawn with PRINT. Instead Y holds a display-file address, starting at X+48 on the second screen row, and the game works directly on that memory.
The main loop is split into four nearly identical blocks, one per direction: down at 1000, up at 2000, left at 3000 and right at 4000. Each block checks the other three direction keys, tests the byte under the marker (151 is an inverse asterisk, which adds a point; 128 is the black border, which ends the game), counts the move, flashes the cell with POKE Y,136 followed by POKE Y,0, and steps Y by +33, −33, −1 or +1. The step of 33 is one screen row: 32 characters plus the end-of-line byte.
Notable Techniques
- Movement, collision detection and erasing are all done by
PEEKandPOKEon the display file, which is faster than redrawing withPRINT AT. - Giving each direction its own copy of the loop avoids a direction variable and a calculated step, at the cost of repeated code.
PAUSE 40000at line 150 holds the finished field on screen until a key is pressed to start.
Potential Issues
RANDis called inside the placement loop (line 90), reseeding from the frame counter on every pass. Successive positions are therefore correlated, and the asterisks tend to fall in diagonal runs and clusters, as the screenshot shows.- Asterisks can land on top of each other, so the field usually holds fewer than 100.
- Each key test calls
INKEY$separately, so a keypress can be missed between tests.
Source Code
10 LET X=PEEK 16396+256*PEEK 16397
20 FOR N=0 TO 31
30 PRINT AT 0,N;"█";AT 21,N;"█"
40 NEXT N
50 FOR N=1 TO 20
60 PRINT AT N,0;"█";AT N,31;"█"
70 NEXT N
80 FOR N=1 TO 100
90 RAND
100 PRINT AT 1+19*RND,1+29*RND;"[*]"
110 NEXT N
120 LET Y=X+48
130 LET Z=0
140 LET M=0
150 PAUSE 40000
1000 IF INKEY$ ="7" THEN GOTO 2000
1010 IF INKEY$ ="5" THEN GOTO 3000
1020 IF INKEY$ ="8" THEN GOTO 4000
1030 IF PEEK Y=151 THEN LET Z=Z+1
1040 IF PEEK Y=128 THEN GOTO 5000
1050 LET M=M+1
1130 POKE Y,136
1140 POKE Y,0
1150 LET Y=Y+33
1160 GOTO 1000
2000 IF INKEY$ ="5" THEN GOTO 3000
2010 IF INKEY$ ="6" THEN GOTO 1000
2020 IF INKEY$ ="8" THEN GOTO 4000
2030 IF PEEK Y=151 THEN LET Z=Z+1
2040 IF PEEK Y=128 THEN GOTO 5000
2050 LET M=M+1
2130 POKE Y,136
2140 POKE Y,0
2150 LET Y=Y-33
2160 GOTO 2000
3000 IF INKEY$ ="7" THEN GOTO 2000
3010 IF INKEY$ ="6" THEN GOTO 1000
3020 IF INKEY$ ="8" THEN GOTO 4000
3030 IF PEEK Y=151 THEN LET Z=Z+1
3040 IF PEEK Y=128 THEN GOTO 5000
3050 LET M=M+1
3130 POKE Y,136
3140 POKE Y,0
3150 LET Y=Y-1
3160 GOTO 3000
4000 IF INKEY$ ="5" THEN GOTO 3000
4010 IF INKEY$ ="6" THEN GOTO 1000
4020 IF INKEY$ ="7" THEN GOTO 2000
4030 IF PEEK Y=151 THEN LET Z=Z+1
4040 IF PEEK Y=128 THEN GOTO 5000
4050 LET M=M+1
4130 POKE Y,136
4140 POKE Y,0
4150 LET Y=Y+1
4160 GOTO 4000
5000 CLS
5010 PRINT AT 10,0;"YOU GOT ";Z
5020 PRINT " AND TOOK ";M;" MOVES."
5030 PAUSE 40000
5040 CLS
5050 RUN
9997 STOP
9998 SAVE "BUMPE[R]"
9999 RUNNote: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
