Skip to content

Four Panels, Four Notes

One panel becomes four — red, cyan, green, yellow — each with its own pitch. The flash-and-tone code moves into a GOSUB routine you call by panel number, so the same six lines light any panel. That reusable routine is the engine of the whole game.

  • Commodore 64
  • BASIC

Simon has four pads, so Bleeper has four panels — red, cyan, green, yellow — each with its own note. You could copy the draw-and-flash code four times, but that’s four times the bugs. Instead, write it once and call it with a panel number. That’s what GOSUB is for.

panels.bas
10 POKE 53281,0
20 PRINT CHR$(147)
30 DIM PR(4),PC(4),PK(4),PF(4)
40 PR(1)=4:PC(1)=7:PK(1)=2:PF(1)=30
50 PR(2)=4:PC(2)=21:PK(2)=3:PF(2)=40
60 PR(3)=14:PC(3)=7:PK(3)=5:PF(3)=50
70 PR(4)=14:PC(4)=21:PK(4)=7:PF(4)=60
80 POKE 54296,15:POKE 54277,0:POKE 54278,240
90 FOR P=1 TO 4:GOSUB 1000:NEXT P
100 FOR P=1 TO 4:GOSUB 1100:FOR T=1 TO 100:NEXT T:NEXT P
110 END
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
A C64 screen, black background: four solid colour panels in a 2x2 grid — red top-left, cyan top-right, green bottom-left, yellow bottom-right.
The board: four panels, each its own colour and pitch. As the program ran, each lit and sounded in turn — proof the one routine handles all four.

The panel data now fills out all four (lines 40–70): each gets a row, column, colour and a distinct pitch, spread far enough apart that the ear tells them straight away. Line 90 draws them all with a FOR P=1 TO 4 loop calling the draw routine, and line 100 flashes each in turn.

The key idea is the subroutine. GOSUB 1100 jumps to the flash-and-tone code; RETURN at its end jumps back to where you called from. Because the routine reads the panel’s details from the arrays using P, the same lines light any panel — set P to 2 and GOSUB 1100 flashes cyan and sounds cyan’s note. Write it once, call it forever. That one routine is the engine the rest of Bleeper drives.

Try this

  • Tune the four. The pitches are PF(1) to PF(4) — 30, 40, 50, 60. Spread them wider (20, 40, 60, 80) or pack them close, and listen to how memorable each set is.
  • Play a chord of sorts. Call the panels in a different order in line 100 — 4,3,2,1 — and hear the scale run the other way.

What’s next

You have four panels and a routine to light any of them. In Unit 3 you store a sequence of panels in an array and let the machine play it back — the performance the player must repeat.

Run it here

This unit's program, built for you.

Program
panels.prg
Machine
Commodore 64 (PAL Breadbin)

Download panels.prg