Electronic Birthday Card
- Type
- Demo
- Category
- Animated greeting card with music
- Author
- John Slaby
- Published in
- Antic, April 1984 (Vol. 3, No. 1)
- Year
- 1984
- Language
- Atari BASIC
- Requirements
- Any Atari 8-bit with at least 16K RAM, Atari BASIC; 410 or 1010 program recorder for the optional recorded message
About the program
John Slaby wrote this computer birthday card for his son's first birthday. Antic printed it in April 1984, its own second-birthday issue. You type in the birthday person's name, age, sex and birthday. The card then plays a short show: a multicoloured title page, a wrapped present with the date, and a portrait beside a cake with the right number of candles. Happy Birthday plays in three-part harmony, the candles are blown out, and the greeting changes to "LET'S EAT CAKE".
With a 410 or 1010 program recorder, you can add a spoken message. It plays through the TV speaker while the present is on screen and can be up to 18 minutes long. The article also explains how to send the whole card on tape to a friend who has an Atari. You CSAVE the program and record your message straight after it. Then change GOSUB 700 in line 10 to GOSUB 730, put your details in line 730, set TIME in line 5 to the message length in seconds divided by four, rewind and CSAVE again.
Typing it in
It's ordinary BASIC with a few inverse characters ({inv}…{/inv}: use the Atari or inverse key). These are the coloured lowercase letters on the title page, in "hApPy", and in the ordinal suffixes in lines 5010–5040. In GRAPHICS 2, inverse and lowercase characters are shown in different colours. {CLEAR} is ESC then SHIFT-CLEAR. Line 520 says COLOR O with the letter O, not zero. O is a variable that's never set, so it's 0 and the line works anyway.
How to use it
RUN it and answer O to replay the built-in card (for Stephen, born 6 February 1982) or N to make a new one. For N, enter the name, M or F, the age and the date, for example APRIL 1984. Then say whether to play a recorded message, and if so give its length in seconds. Make sure PLAY is pressed down on the recorder. Press any key to start the show, and any key at the end to see it again.
How it works
- Text and pictures on one screen. Line 4010 opens a full-screen GRAPHICS 7+16 display (160 × 96, four colours). Lines 2010–2015 then rewrite its display list. The first two lines and one near the bottom become ANTIC mode 7 (GRAPHICS 2 text), and a jump instruction (65) ends the list early. Before printing, the program
POKEs 87 (DINDEX) with 2 so the OS treats the screen as GRAPHICS 2, then sets it back to 7 for drawing. - Coloured lettering. The "HAPPY BIRTHDAY" banner is
POKEd into screen memory as character codes that already include the colour bits (DATA in lines 1055 and 2050). Lines 790–890 colour the date the same way, adding 128, 160 or 96 to letters in turn. - Solid shapes. The present and the cake are outlined and then filled with
XIO 18(the OS FILL command), using location 765 to choose the fill colour. - Music in time. Each note in lines 300–450 gives three pitches and a length. Line 220 zeroes the real-time clock (location 20), and the loop waits until the clock reaches the note's length, so the tempo doesn't depend on how fast BASIC is running.
- Candles. Lines 82–90 space up to 30 candles evenly across the cake. The puff of breath and the flames going out are drawn and erased in lines 500–540.
- The tape message. Lines 8010–8030 switch the cassette motor on with
POKE 54018,52and off again with 60. Location 19 counts in units of about four seconds, which is whyTIMEis the length divided by four.
Variations to try
Rewrite the tune DATA for a different song, give the portrait a different face in lines 6000–6140, or change the "O" data in line 730 so the card is ready for someone in your family.
Listing
1 REM BIRTHDAY CARD
2 REM BY JOHN SLABY
3 REM ANTIC MAGAZINE
5 DIM NAME$(20),PRF$(2),SEX$(4),ST$(20),DATE$(20):TIME=0
10 GOSUB 700:POKE 764,255:? "{CLEAR}":? "PRESS ANY KEY TO RUN."
15 IF PEEK(764)=255 THEN 15
20 GOSUB 7000:POKE 764,255:OUT=0:GOSUB 5000:SETCOLOR 0,0,14:GOSUB 2000
25 GOSUB 1000:SETCOLOR 0,0,14:SETCOLOR 1,3,6:GOSUB 6000
30 REM DRAW CAKE
35 POKE 765,1:COLOR 1:PLOT 112,78:DRAWTO 112,40:DRAWTO 50,40
40 POSITION 50,78:XIO 18,#6,0,0,"S:"
50 REM DRAW ICING
60 COLOR 2:FOR S=40 TO 45 STEP 5:PLOT 50,S:DRAWTO 112,S:NEXT S:PLOT 50,60:DRAWTO 112,60:PLOT 50,61:DRAWTO 112,61
70 FOR X=50 TO 110 STEP 10:PLOT X,42:PLOT X+2,42:PLOT X+1,43:PLOT X,44:PLOT X+2,44:NEXT X
80 REM DRAW CANDLES
82 GE=AGE:IF AGE>30 THEN GE=30
85 PLACE=62/(GE+1):P=112-PLACE
90 FOR I=1 TO GE:COLOR 3:PLOT P,30:DRAWTO P,40:COLOR 1:PLOT P,26:DRAWTO P,28:P=P-PLACE:NEXT I
99 GOTO 200
100 XIO 18,#6,0,0,"S:":RETURN
110 TRAP 40000:GOTO 755
120 TRAP 40000:GOTO 925
200 REM PLAY SONG
205 RESTORE 300
210 FOR X=1 TO 50:READ V1,V2,V3,BEAT
220 POKE 20,0
230 SOUND 1,V1,10,8:SOUND 2,V2,10,7:SOUND 3,V3,10,7
240 IF PEEK(20)<BEAT THEN 240
250 NEXT X
300 DATA 81,96,121,15,0,96,121,3,81,96,121,15
310 DATA 0,0,0,3,72,91,121,30,0,0,0,3
320 DATA 81,96,121,30,0,0,0,3,60,72,91,30
330 DATA 0,0,0,1,64,81,108,60,0,0,0,3
340 DATA 81,96,121,15,0,96,121,3,81,96,121,15
350 DATA 0,0,0,3,72,91,121,30,0,0,0,3
360 DATA 81,96,121,30,0,0,0,3,53,64,81,30
370 DATA 0,0,0,3,60,81,96,60,0,0,0,3
380 DATA 81,96,121,15,0,96,121,3,81,96,121,15
390 DATA 0,0,0,3,40,0,60,30,0,0,0,3
400 DATA 47,60,72,30,0,0,0,3,60,81,96,30
410 DATA 0,0,0,3,64,81,108,30,0,0,0,3
420 DATA 72,91,121,30,0,0,0,3,45,60,72,15
430 DATA 0,60,72,3,45,60,72,15,0,00,0,3
440 DATA 47,60,72,30,0,0,0,3,60,81,96,30
450 DATA 0,0,0,3,53,64,91,30,0,0,0,3,60,81,96,60,0,0,0,0
500 REM BLOW OUT CANDLES
505 COLOR 1:SOUND 0,30,8,1
510 PLOT 28,28:DRAWTO 24,28:DRAWTO 22,26:IF OUT=1 THEN COLOR 2:GOTO 525
520 COLOR O
525 PLOT 28,27:PLOT 29,28:DRAWTO 32,28:IF OUT=1 THEN GOTO 600
530 COLOR 0:FOR I=0 TO GE:PLOT P,26:DRAWTO P,28:FOR X=1 TO 40:NEXT X:P=P+PLACE:NEXT I
540 OUT=1:COLOR 0:SOUND 0,0,0,0:GOTO 510
600 REM CHANGE WORDS
610 RESTORE 620:GOTO 1040
620 DATA 64,64,64,64,64,64,64,64,64,64,64,64,64,64,64
630 ST$=NAME$:NAME$="LET'S EAT CAKE":GOSUB 1070
640 NAME$=ST$:POKE 764,255
650 IF PEEK(764)=255 THEN 650
660 GOTO 20
670 END
700 REM INITILIZE STRINGS
710 ? "{CLEAR}":? "OLD OR NEW (O/N)":INPUT SEX$:IF SEX$(1,1)="N" THEN GOTO 740
720 IF SEX$(1,1)<>"O" THEN GOTO 710
730 NAME$="STEPHEN":ST$="FEBRUARY 6,1982":SEX$="MALE":AGE=1:GOSUB 790:RETURN
740 ? "{CLEAR}":? "NAME OF BIRTHDAY PERSON";:INPUT NAME$
750 ? "SEX (M/F)";:INPUT SEX$:IF SEX$(1,1)<>"M" AND SEX$(1,1)<>"F" THEN 750
755 TRAP 110
760 ? "AGE ";:INPUT AGE
770 ? "DATE OF UPCOMING BIRTHDAY ":INPUT ST$
780 GOSUB 790:GOTO 900
790 Q=LEN(ST$):ROT=0:CT=1
800 FOR I=1 TO Q:IF ASC(ST$(I,I))=32 THEN ROT=0:GOTO 815
805 IF ASC(ST$(I,I))<65 AND ASC(ST$(I,I))>31 THEN GOSUB 860:GOTO 815
810 GOSUB 820
815 DATE$(I,I)=CHR$(ASC(ST$(I,I))+ROT):NEXT I:RETURN
820 IF CT=1 THEN ROT=128:GOTO 850
830 IF CT=2 THEN ROT=160:CT=0
850 CT=CT+1:RETURN
860 IF CT=1 THEN ROT=128:GOTO 890
870 IF CT=2 THEN ROT=96:CT=0
890 CT=CT+1:RETURN
900 ? "{CLEAR}":? " DO YOU WISH TO PLAY A RECORDED MESSAGE (Y/N).";:INPUT ST$
910 IF ST$(1,1)="N" THEN RETURN
920 IF ST$(1,1)<>"Y" THEN 900
925 TRAP 120
930 ? :? "WHAT IS LENGTH OF MESSAGE IN SECONDS":INPUT TIME:TIME=TIME/4:RETURN
1000 REM MODIFY DISPLAY LIST
1010 GOSUB 4000:POKE START+81,7:GOSUB 3000
1020 REM PRINT GREETING
1030 MEMST=PEEK(START)+PEEK(START+1)*256:CHRPOS=MEMST+3200
1035 RESTORE 1055
1040 FOR X=1 TO 14:READ MES:POKE CHRPOS+X+2,MES:NEXT X:IF OUT=1 THEN 620
1055 DATA 168,225,176,240,185,64,226,169,242,180,232,164,225,185
1060 REM PRINT NAME
1070 Q=LEN(NAME$):Z=(20-Q)/2
1080 FOR I=1 TO Q:POKE CHRPOS+19+I+Z,ASC(NAME$(I,I))+32:NEXT I
1090 POKE 87,7:RETURN
2000 REM MODIFY DISPLAY LIST
2010 GOSUB 4000:POKE START-1,71:POKE START+2,7:POKE START+75,7
2015 POKE START+76,65:POKE START+77,PEEK(560):POKE START+78,PEEK(561)
2020 POKE 87,2:POSITION 0,0:? #6;" {inv}hApPy{/inv} ";AGE;PRF$
2025 X=(20-LEN(DATE$))/2:POSITION X,1:? #6;DATE$
2030 MEMST=PEEK(START)+PEEK(START+1)*256:CHRPOS=MEMST+2926
2035 RESTORE 2050
2040 FOR I=1 TO 8:READ MES:POKE CHRPOS+I-1,MES:NEXT I
2050 DATA 226,169,242,180,232,164,225,185
2055 REM PLAY TUNE
2056 READ AA,BB:SOUND 0,AA,10,10:POKE 20,0
2057 IF PEEK(20)<BB THEN 2057
2058 SOUND 0,0,0,0:IF AA>10 THEN 2056
2059 DATA 130,10,100,10,80,10,65,22,80,10,65,33,5,0
2060 REM DRAW PRESENT
2065 POKE 87,7:POKE 765,1:COLOR 1
2070 PLOT 120,62:DRAWTO 120,20:DRAWTO 40,20:POSITION 40,62:GOSUB 100:COLOR 3
2075 FOR Y=20 TO 62:PLOT 80,Y:DRAWTO 90,Y:NEXT Y
2080 FOR X=40 TO 120:PLOT X,46:DRAWTO X,36:NEXT X
2085 SETCOLOR 1,4,6:COLOR 2:Z=11:A=19
2090 FOR X=0 TO Z:PLOT 75+X,A:PLOT 95-X,A:NEXT X
2100 Z=Z-2:A=A-1:IF Z>0 THEN 2090
2110 IF TIME>0 THEN GOSUB 8000:RETURN
2120 FOR I=1 TO 500:NEXT I:RETURN
3000 REM JUMP,ADDRESS AND LAST GR.2
3010 POKE START+82,7:POKE START+83,65:POKE START+84,PEEK(560):POKE START+85,PEEK(561):RETURN
4000 REM GR. AND START
4010 GRAPHICS 7+16:START=PEEK(560)+PEEK(561)*256+4:RETURN
5000 PR=AGE-(INT(AGE/10)*10)
5010 IF PR=1 AND AGE<>11 THEN PRF$="{inv}St{/inv}":RETURN
5020 IF PR=2 AND AGE<>12 THEN PRF$="{inv}Nd{/inv}":RETURN
5030 IF PR=3 AND AGE<>13 THEN PRF$="{inv}Rd{/inv}":RETURN
5040 PRF$="{inv}Th{/inv}":RETURN
6000 REM DRAW FACE
6010 COLOR 1:PLOT 33,12:DRAWTO 33,14:PLOT 32,15:PLOT 32,16:DRAWTO 34,24:DRAWTO 30,24:PLOT 32,25:DRAWTO 32,27
6020 COLOR 2:PLOT 28,27:PLOT 29,28:DRAWTO 32,28:PLOT 32,27:PLOT 33,27:PLOT 32,29:PLOT 33,29
6030 COLOR 1:PLOT 32,30:DRAWTO 33,33:DRAWTO 32,35:DRAWTO 20,35:DRAWTO 17,33:PLOT 24,36:DRAWTO 24,46:PLOT 6,33
6035 PLOT 7,34:DRAWTO 7,41
6040 REM DRAW SHIRT/TOP
6050 COLOR 3:PLOT 2,56:DRAWTO 2,45:DRAWTO 6,42:DRAWTO 27,48:DRAWTO 29,56
6060 IF SEX$(1,1)="M" THEN 6100
6070 REM DRAW HAIR & EYE-GIRL
6075 COLOR 0:PLOT 6,33:PLOT 7,34:DRAWTO 7,36
6080 COLOR 3:PLOT 27,14:PLOT 28,14:PLOT 29,13:PLOT 28,16:COLOR 2:PLOT 1,35:DRAWTO 3,36
6090 DRAWTO 12,36:DRAWTO 19,22:DRAWTO 19,16:DRAWTO 25,11:DRAWTO 36,11:DRAWTO 34,4:DRAWTO 5,4:DRAWTO 1,11
6095 DRAWTO 1,35:RETURN
6100 REM DRAW HAIR,EYE,AND EAR -BOY
6110 COLOR 2:PLOT 4,31:PLOT 5,32:DRAWTO 10,32:DRAWTO 12,28:DRAWTO 12,17:DRAWTO 18,17:DRAWTO 18,22:PLOT 19,22
6115 DRAWTO 19,17:DRAWTO 25,11
6120 DRAWTO 33,11:DRAWTO 33,6:DRAWTO 29,4:DRAWTO 9,4:DRAWTO 3,10:DRAWTO 4,31
6130 COLOR 1:PLOT 16,24:DRAWTO 14,24:PLOT 13,23:DRAWTO 13,18:PLOT 14,17:DRAWTO 16,17:PLOT 17,18:PLOT 17,19
6140 COLOR 3:PLOT 16,21:PLOT 27,19:PLOT 26,17:DRAWTO 30,17:RETURN
7000 REM TITLE PAGE
7010 GRAPHICS 2:SETCOLOR 2,0,0:SETCOLOR 0,2,6:SETCOLOR 1,12,6:A=2:B=12:C=4:N=0
7020 POSITION 8,1:? #6;"Ha{inv}p{/inv}Py"
7030 POSITION 6,3:? #6;"Bi{inv}r{/inv}Th{inv}d{/inv}Ay"
7040 POSITION 6,5:? #6;"Co{inv}m{/inv}Pu{inv}t{/inv}Er"
7050 POSITION 8,7:? #6;"Ca{inv}r{/inv}D"
7060 POKE 752,1:? :? "by John Slaby"
7080 REM ROTATE COLORS
7090 FOR I=1 TO 40
7100 SETCOLOR 0,A,6:SETCOLOR 1,B,6:SETCOLOR 3,C,6:N=N+1:IF N>3 THEN N=1
7110 IF N=1 THEN A=12:B=4:C=2
7120 IF N=2 THEN A=4:B=2:C=12
7130 IF N=3 THEN A=2:B=12:C=4
7140 FOR J=1 TO 10:NEXT J:NEXT I:RETURN
8000 REM ALLOW CASSETTE TO PLAY MESSAGE
8005 REM TIME IS IN UNITS OF 4 SECONDS.
8010 POKE 19,0:POKE 54018,52
8020 IF TIME>PEEK(19) THEN 8020
8030 POKE 54018,60:RETURN
Download
The original program from the Antic disk, to LOAD or ENTER instead of typing it: BDAYCARD.BAS.
Credits
- Program listing: Electronic Birthday Card — program listing (Antic, April 1984 (Vol. 3, No. 1)) — John Slaby
- Picture: The card personalised for Antic's second birthday: two candles, and the song about to play. — John Slaby (program); screenshot by the site
- Antic magazine scan (OCR text layer), April 1984, contents (p. 5) and article (PDF pp. 72-73): Birthday Card, by John Slaby — Erik Wolpaw; Internet Archive, 1984
- Antic Software Archive — April 1984 - Vol. 3 No. 1 disk: BDAYCARD.BAS — John Slaby, 1984
