Retro Computing

Commodore 64 Blue Box Program Source Code

I wrote this in the 80s.

10 REM ****************************
20 REM * BLUE BOX DEMO *
30 REM * *
40 REM * BRIAN K. PERRY *
50 REM * BKP@BKP.NET *
60 REM * *
70 REM ****************************
100 REM CLEAR SID REGISTERS
110 FOR R=54272 TO 54296 : POKE R,0 : NEXT
120 REM SET VOLUME TO MAX
130 POKE 54296,15
140 REM - INITIALIZE VOICE 1
150 POKE 54275,8 : POKE 54277,0 : POKE 54278,240
160 REM - INITIALIZE VOICE 2
170 POKE 54282,8 : POKE 54284, 0 : POKE 54285,240
180 REM SET UP MF TONE ARRAYS
181 DIM Z(9,1)
190 Z(0,0)=1300 : Z(0,1)=1500
191 Z(1,0)=700 : Z(1,1)=900
192 Z(2,0)=700 : Z(2,1)=1100
193 Z(3,0)=900 : Z(3,1)=1100
194 Z(4,0)=700 : Z(4,1)=1300
195 Z(5,0)=900 : Z(5,1)=1300
196 Z(6,0)=1100 : Z(6,1)=1300
197 Z(7,0)=700 : Z(7,1)=1500
198 Z(8,0)=900 : Z(8,1)=1500
199 Z(9,0)=1100 : Z(9,1)=1500
200 REM - DISPLAY HELP INFO
210 PRINT CHR$(147) + "BLUE BOX DEMO"
220 PRINT ""
230 PRINT "DEPRESS KEYS:"
240 PRINT ""
250 PRINT "2600 TONE: W"
260 PRINT "KP TONE: K"
270 PRINT "ST TONE: S"
280 PRINT "MF DIGITS: 0-9"
290 PRINT ""
295 PRINT "EXIT: X"
296 PRINT
298 PRINT "ENTERED: ";
300 REM KEY PRESS RESPONSE LOOP
310 GET K$ : IF K$="" THEN 310
315 PRINT K$;
320 IF K$="X" THEN PRINT : GOTO 999
330 IF K$="K" THEN F=1100 : G=1700 : D=150 : GOSUB 1000
340 IF K$="S" THEN F=1500 : G=1700 : D=150 : GOSUB 1000
350 IF K$="W" THEN F=2600 : G=2600 : D=500 : GOSUB 1000
360 IF K$>="0" AND K$<="9" THEN F=Z(VAL(K$),0):G=Z(VAL(K$),1):D=150:GOSUB 1000
399 GOTO 300
999 END
1000 REM - PLAY FREQ F ON VOICE 1, G ON VOICE 2 WITH DELAY D
1010 REM - COMPUTE VALUES FOR VOICE 1
1011 A = F / 0.06097
1012 H = INT(A/256)
1013 L = A-(H*256)
1014 POKE 54272, L : POKE 54273, H
1020 REM - COMPUTE VALUES FOR VOICE 2
1021 A = G / 0.06097
1022 H = INT(A/256)
1023 L = A-(H*256)
1024 POKE 54279, L : POKE 54280, H
1030 REM - PLAY TONES
1035 POKE 54276, 65 : REM - ENABLE VOICE 1
1036 POKE 54283, 65 : REM - ENABLE VOICE 2
1040 REM - DELAY FOR TONES TO PLAY
1045 FOR R=0 TO D : NEXT
1050 REM - TURN OFF TONES
1055 POKE 54276, 64 : REM - DISABLE VOICE 1
1056 POKE 54283, 64 : REM - DISABLE VOICE 2
1060 RETURN

Leave a Reply