Tuning Your Atari

Type
Education
Category
Musical toy for children
Author
Linda M. Schreiber
Published in
Antic, October/November 1982 (Vol. 1, No. 4); reprinted in The Best of Antic, Volume 1
Year
1982
Language
Atari BASIC
Requirements
Any Atari 8-bit, Atari BASIC
A GRAPHICS 2 screen with a purple menu (1. PLAY KEYBOARD, 2. REPEAT MELODY, 3. PLAY EXAMPLE), the green note names C D E F G A B C, and eight little orange figures standing on bellows

About the program

Linda Schreiber wrote a series of teaching games for Antic's early issues. This one was inspired by a toy piano with a built-in tape recorder that her daughter loved: children could make a tune and then hear it played back. Tuning Your Atari puts eight little figures on bellows across the screen, with a note name above each one from low C to high C. Press a number key from 1 to 8 and that figure jumps on its bellows, flapping its arms, and the note sounds. The program remembers what you play and can repeat it. Schreiber hoped the note letters would sink in quietly, and warned parents not to be surprised to hear their child singing "A-G-F-G-A-A-A".

What you need

Any Atari with Atari BASIC.

Typing it in

Line 70 is the hard part. P1$ is a 20-byte machine-code routine that copies the ROM character set into RAM. The article spelled it out character by character: lower-case h, an inverse quote, CTRL-D, an inverse space, CTRL-comma, then inverse 1M, inverse CTRL-Q, inverse KHPyfNfLJPr, and finally CTRL-period. In this listing {inv}…{/inv} marks inverse video (the Atari key), and {CTRL-D}, {CTRL-,}, {CTRL-Q} and {CTRL-.} mean hold CTRL and press the key. The menu text in lines 170–190 is also inverse. The REMs can be left out.

How to use it

RUN, then choose from the menu:

  1. Play keyboard. Press 1 to 8 to play notes, up to 100 of them. Press ESC to go back to the menu.
  2. Repeat melody. Plays back what you entered.
  3. Play example. Plays a well-known tune stored in line 520 as the string "11556654433221".

How it works

  • Line 60 stores the high bytes of the RAM and ROM fonts in zero-page locations 204 and 206, so the routine in P1$ knows where to copy from and to. Line 80 then points CHBAS (756) at the copy.
  • Lines 90–120 redefine the eight characters from ! to ( as the bellows and the figure at different stages of the jump. The animation in lines 430–490 prints them in turn, partly as inverse characters (CHR$(130) to CHR$(136)), which GRAPHICS 2 shows in a different colour.
  • The melody is just a string of digits, M$. Each key is stored with STR$ and read back with VAL.
  • GOTO TONE and GOSUB WAIT use variables as line numbers, which Atari BASIC allows. It is a neat way to give subroutines names.
  • Lines 210 and 290 undo the inverse key if a child presses it by mistake (POKE 694,0).

Listing

10 REM ******** TUNING YOUR ATARI ********
20 REM BY L.M.SCHREIBER FOR ANTIC AUGUST 1982
40 DIM P1$(20),M$(100)
50 GRAPHICS 18:POKE 711,PEEK(710):POKE 710,100
60 A=PEEK(106)-8:POKE 204,A:POKE 206,224:REM STORE THE BEGINNING OF NEW & OLD CHARACTER SETS
70 P1$="h{inv}"{/inv}{CTRL-D}{inv} {/inv}{CTRL-,}{inv}1M{CTRL-Q}KHPyfNfLJPr{/inv}{CTRL-.}":TONE=430:WAIT=500:REM MACHINE LANGUAGE SUBROUTINE MOVES THE CHARACTER SET
80 Q=USR(ADR(P1$)):CHBS=A*256:POKE 756,A:REM INSTALL NEW CHARACTER SET
90 FOR X=CHBS+8 TO CHBS+71:READ C:POKE X,C:NEXT X:REM CHANGE THE CHARACTERS FROM ! TO $
100 DATA 0,254,124,254,124,254,124,254,108,0,254,254,124,254,124,254,40,108,0,254,254,254,124,254
110 DATA 186,40,108,0,254,254,254,254,56,108,56,16,254,56,40,108,0,56,108,56,146,124,56,40
120 DATA 0,0,56,108,56,16,254,56,0,0,0,56,108,56,16,124
130 OPEN #2,4,0,"K:":REM OPEN THE KEYBOARD FOR READ
140 POSITION 2,9:? #6;"! ! ! ! ! ! ! !":POSITION 2,8:? #6;"% % % % % % % %":REM THE ! AND % ARE THE NEW CHARACTERS
150 POSITION 2,6:? #6;"c d e f g a b c":REM PLACE THE TONE NAMES
160 POKE 710,100:REM RESTORE THE MENU
170 POSITION 2,0:? #6;"{inv}1.{/inv} {inv}PLAY KEYBOARD{/inv}"
180 POSITION 2,2:? #6;"{inv}2.{/inv} {inv}REPEAT MELODY{/inv}"
190 POSITION 2,4:? #6;"{inv}3.{/inv} {inv}PLAY EXAMPLE{/inv}"
200 K=0:GET #2,C:POKE 710,0:REM GET THE KEY PRESSED-REMOVE THE MENU
210 IF C>127 THEN C=C-128:POKE 694,0:REM INVERSE FLAG IS ON RESET IT TO NORMAL
220 IF C<49 OR C>52 THEN POKE 764,255:GOTO 200:REM NOT A NUMBER FROM 1 TO 4
230 C=C-48:REM GET THEN NUMBER
240 ON C GOTO 250,540,520,560
250 M$="":REM REMOVE CONTENTS OF THE STRING
260 ROUTINE=260:K=K+1:IF K=101 THEN 160:REM ONLY ACCEPT 100 NOTES
280 GET #2,C:IF C=27 THEN 160:REM GET THE KEY PRESSED-RETURN TO MENU ON ESCAPE KEY
290 IF C>127 THEN C=C-128:POKE 694,0:REM INVERSE FLAG IS ON RESET IT TO NORMAL
300 IF C<49 OR C>56 THEN POKE 764,255:GOTO 200:REM NOT A NUMBER FROM 1 TO 8
310 C=C-48:M$(K,K)=STR$(C):REM GET THEN NUMBER-PUT IT IN THE STRING
320 C=C*2:REM OFFSET IT FOR THE PROPER POSITION
330 ON C/2 GOSUB 350,360,370,380,390,400,410,420
340 GOTO ROUTINE
350 T=121:GOTO TONE:REM 'C'
360 T=108:GOTO TONE:REM 'D'
370 T=96:GOTO TONE:REM 'E'
380 T=91:GOTO TONE:REM 'F'
390 T=81:GOTO TONE:REM 'G'
400 T=72:GOTO TONE:REM 'A'
410 T=64:GOTO TONE:REM 'B'
420 T=60:REM 'C'
425 REM LINES 430-450 MAKE THE CHARACTER APPEAR TO PUSH DOWN ON THE BELLOW AND MAKE THE TONE
430 TL=10:POSITION C,8:? #6;CHR$(134):POSITION C,9:? #6;CHR$(130):SOUND 0,T,10,6:GOSUB WAIT
440 POSITION C,8:? #6;CHR$(135):POSITION C,9:? #6;CHR$(131):SOUND 0,T,10,8:GOSUB WAIT
450 POSITION C,8:? #6;CHR$(136):POSITION C,9:? #6;CHR$(132):GOSUB WAIT
460 SOUND 0,T,10,10
470 POSITION C,8:? #6;CHR$(135):POSITION C,9:? #6;CHR$(131):SOUND 0,T,10,8:GOSUB WAIT
475 REM LINES 470-490 RETURN THE CHARACTER AND BELLOW TO THE CORRECT POSITION
480 POSITION C,8:? #6;CHR$(134):POSITION C,9:? #6;CHR$(162):SOUND 0,T,10,6:GOSUB WAIT
490 POSITION C,8:? #6;"%":POSITION C,9:? #6;"!":SOUND 0,0,0,0:RETURN
500 FOR X=1 TO TL:NEXT X:RETURN :REM TIMING LOOP
510 REM PLAY A SAMPLE TUNE
520 M$="11556654433221"
530 REM ROUTINE TO PLAY BACK THE MELODY ENTERED
540 ROUTINE=540:K=K+1:IF K<=LEN(M$) THEN C=VAL(M$(K,K)):GOTO 320:REM KEEP PLAYING UNTIL THE END OF THE STRING
550 GOTO 160
560 END

Download

The original program from the Antic disk, to LOAD or ENTER instead of typing it: TUNE.BAS, TUNE.BAS.

Credits