Skip to content

How Far Can You Hold?

Put it together: rounds that grow, an echo checked each round, a score that's just the length you held, and a key to play again. Number the panels so the player knows the keys. Your finished Bleeper — the SID, an array, and live input as one game.

  • Commodore 64
  • BASIC

Every piece is built — growing rounds, the echo, the check. The last unit assembles them into a game with a beginning and an end: play a round, read the echo, and if it’s right, grow and go again; if it’s wrong, show how far the player got and offer another go.

bleeper.bas
10 POKE 53281,0
20 DIM PR(4),PC(4),PK(4),PF(4),S(99)
30 PR(1)=4:PC(1)=7:PK(1)=2:PF(1)=30
40 PR(2)=4:PC(2)=21:PK(2)=3:PF(2)=40
50 PR(3)=14:PC(3)=7:PK(3)=5:PF(3)=50
60 PR(4)=14:PC(4)=21:PK(4)=7:PF(4)=60
70 POKE 54296,15:POKE 54277,0:POKE 54278,240
80 PRINT CHR$(147)
90 FOR P=1 TO 4:GOSUB 1000:NEXT P
100 GOSUB 2000
110 N=0
120 N=N+1:S(N)=INT(RND(1)*4)+1
130 PRINT CHR$(19);"ROUND";N
140 FOR I=1 TO N:P=S(I):GOSUB 1100:FOR T=1 TO 80:NEXT T:NEXT I
150 FOR I=1 TO N
160 GET A$:IF A$="" THEN 160
170 P=VAL(A$):IF P<1 OR P>4 THEN 160
180 GOSUB 1100
190 IF P<>S(I) THEN 400
200 NEXT I
210 FOR T=1 TO 400:NEXT T
220 GOTO 120
400 PRINT CHR$(19);"YOU HELD";N-1;"  "
410 POKE 54273,8:POKE 54272,0:POKE 54276,33
420 FOR T=1 TO 400:NEXT T:POKE 54276,32
430 PRINT "PRESS A KEY TO PLAY AGAIN"
440 GET A$:IF A$="" THEN 440
450 GOTO 80
1000 RP=PR(P):CP=PC(P)
1010 FOR Y=0 TO 7:FOR X=0 TO 11
1020 POKE 1024+(RP+Y)*40+CP+X,160
1030 POKE 55296+(RP+Y)*40+CP+X,PK(P)
1040 NEXT X:NEXT Y
1050 RETURN
1100 RP=PR(P):CP=PC(P)
1110 FOR Y=0 TO 7:FOR X=0 TO 11:POKE 55296+(RP+Y)*40+CP+X,1:NEXT X:NEXT Y
1120 POKE 54273,PF(P):POKE 54272,0:POKE 54276,17
1130 FOR T=1 TO 200:NEXT T
1140 POKE 54276,16
1150 FOR Y=0 TO 7:FOR X=0 TO 11:POKE 55296+(RP+Y)*40+CP+X,PK(P):NEXT X:NEXT Y
1160 RETURN
2000 FOR P=1 TO 4
2010 POKE 1024+(PR(P)-1)*40+PC(P),P+48
2020 POKE 55296+(PR(P)-1)*40+PC(P),1
2030 NEXT P
2040 RETURN
A C64 screen, black background: four numbered colour panels with YOU HELD 2 and PRESS A KEY TO PLAY AGAIN above them.
The finished game. The panels are numbered so the player knows which key is which; this run held two steps before a wrong key, and a press starts a fresh sequence.

The structure is a loop inside a loop. The round loop (lines 120–220) grows the sequence, plays it, then runs the echo loop (lines 150–200) to read the player back. A correct echo falls through to line 210’s pause and line 220’s GOTO 120 — another round, one longer. A wrong press jumps to line 400: PRINT "YOU HELD"; N-1 shows the score — the length of the last sequence the player completed — with a harsh tone, then PRESS A KEY TO PLAY AGAIN waits and loops back to a fresh game.

Two touches finish it. The new routine at line 2000 numbers the panels 1–4 by POKEing a digit above each, so the player knows red is key 1, cyan key 2, and so on. And the score is phrased to respect the player: YOU HELD 2 acknowledges what they managed, where a blunt WRONG would just scold. The score is the length, the length is the depth, and the depth is the whole game.

That’s Bleeper. Four panels with four SID voices, a sequence stored in an array that grows each round, an echo read with GET and checked press by press, and a score that’s just how far you held. The SID, an array, and live input — three tools you met apart — working as one game.

Try this

  • Raise the stakes. Quicken the playback (FOR T=1 TO 80 in line 140) as the rounds climb, so speed piles onto length. A small change; a big jump in difficulty.
  • Keep a best. Add a variable that remembers the highest N-1 across games and print it on the game-over screen — “BEST SO FAR” — so each go has something to beat.

What’s next

You’ve built memory and feedback into a game. Next in Volume 1 comes Safe Cracker — the machine hides a number and you close in on it, guess by guess, with the screen telling you warmer or colder.

Run it here

This unit's program, built for you.

Program
bleeper.prg
Machine
Commodore 64 (PAL Breadbin)

Download bleeper.prg