Tin Pan Alley Cats

Type
Game
Category
Shooting gallery (kick cans at cats on a fence)
Author
Rick Bloom and Rob Glassman
Published in
The Best of Antic, Volume 1 (Antic Publishing)
Year
1983
Language
Atari BASIC (with small machine-language routines)
Requirements
16K RAM, Atari BASIC, joystick in port 1
A green cat on a blue fence with a moon above, the player's square-headed figure below, and SCORE and CANS counters at the top

About the program

You've worked hard all day and programmed all night, and now three alley cats are howling on your back fence. Every so often one jumps up where you can hit it with a tin can, if you're quick. That's the story of Tin Pan Alley Cats, a one-player game from The Best of Antic, Volume 1. (The title screen calls it "Tin Can Alley Cats".)

The cats are Greensleeves (50 points), Frisky White (100) and the Pink Panther (200). The pinker the cat, the faster it disappears. You have 25 cans and the cats appear 35 times, and the pace quickens as your cans run out. At 2,000 points you get five extra cans and five extra cats, and the bonus is repeated at 3,000 and 4,000. The best score of the session is kept. The book's article thanks Stan Ockers for the vertical blank interrupt idea and Jerry White for the sound ideas, both from earlier issues of Antic.

Typing it in

{CLEAR} in line 50 is ESC then SHIFT-CLEAR. {inv}…{/inv} is inverse video (press the Atari key before and after). Most of it is in REMs, where it only makes the headings stand out. In the GRAPHICS 2 screens, inverse and lower-case letters print in different colours, so type the PRINT strings in lines 870–1210 exactly. Lines 140–150, 1690–1700 and the other DATA lines are machine code and graphics, so check them carefully. The program uses MOVX as a variable name. That's fine in Atari BASIC, but some later BASICs treat it as a keyword.

How to play

Move left and right along the bottom with the joystick and press the button to kick a can upward. A cat sits on the fence only briefly, so line up underneath it and fire. When the cans or the cats run out, you get the "MEOW !!!" screen with your score. Press the trigger for another game. To make it harder or easier, change the TUF values in lines 590–620 (the book refers to them as lines 280–310). TUF sets how long each cat stays up.

How it works

  • Strings as player memory. Line 100 DIMs P0$…P3$ and M$ first. Lines 1490–1570 then rewrite their entries in BASIC's variable value table (whose address is in locations 134–135) so that each string points straight at player/missile memory. After that, P0$(FENCE,FENCE+SIZE-1)=D0$ copies a cat shape into a player at machine speed.
  • A VBI joystick. A 47-byte routine at page 6 (lines 130–150) installs itself as a deferred vertical blank interrupt. Sixty times a second it reads the stick and moves player 3 by changing its horizontal position register, so your movement stays smooth while BASIC is busy.
  • A missile mover. The 37-byte MOVX$ routine shifts the can (missile 3) up the screen, and the missile-to-player collision register (53259) tells the program when a cat has been hit.
  • Music. The song routine times its notes with system timer 1 (location 540), which counts down every frame.

Changes from the published listing

One change, so the program also runs under Altirra BASIC, the free replacement BASIC built into many emulators. Altirra BASIC adds a command called MOVE, so it rejected the published lines that use that word as the start of a variable name. The variable is renamed everywhere in the program. The new name is the same length, so the memory layout is unchanged and the program behaves exactly as published on genuine Atari BASIC. If you type it in from the magazine, the original names work fine on a real Atari.

Published Now Lines
MOVE MOVX 480, 1660
MOVE$ MOVX$ 1660, 1680

Listing

10 REM ******** TIN PAN ALLEY CATS ********
20 REM BY RICK BLOOM AND ROB GLASSMAN 1983
50 ? "{CLEAR}":POKE 752,1
100 DIM P0$(1),P1$(1),P2$(1),P3$(1),M$(1)
110 VTAB=PEEK(134)+256*PEEK(135):ATAB=PEEK(140)+256*PEEK(141)
120 REM {inv}**** VBI JOYSTICK ROUTINE *** {/inv}
130 FOR A=1536 TO 1582:READ ML:POKE A,ML:NEXT A
140 DATA 104,160,10,162,6,169,7,76,92,228,173,120,2,201,7,240,9,173,120,2,201,11,240,13,208
150 DATA 18,230,209,166,209,142,3,208,144,9,176,7,198,209,166,209,142,3,208,76,98,228
155 GOSUB 870:GOSUB 960
160 GRAPHICS 17:POSITION 4,10:? #6;"{inv}get ready !!!{/inv}"
170 FOR X=1 TO 600:NEXT X
180 BONUS=0:HSCOR=0:X=USR(1536):GOTO 1250
190 REM {inv}CAT HIT SOUND{/inv}
200 FOR X=40 TO 20 STEP -5
205 FOR J=704 TO 706:POKE J,X:NEXT J
210 SOUND 1,X,12,10
220 FOR Z=1 TO 10:NEXT Z
230 NEXT X
240 FOR Y=15 TO 55 STEP 5
245 FOR J=704 TO 706:POKE J,Y:NEXT J
250 SOUND 1,Y,12,10
260 FOR A=1 TO 8:NEXT A
270 NEXT Y
280 SOUND 1,0,0,0:RETURN
290 REM {inv}*****SONG ROUTINE *****{/inv}
300 IF X=-1 THEN SOUND 0,0,0,0:SOUND 1,0,0,0:FOR W=1 TO 100:NEXT W:RETURN
310 READ X,Y,Z:IF X=0 THEN 340
320 IF Y=0 THEN SOUND 1,0,0,0
330 GOTO 380
340 IF Y=0 THEN SOUND 1,0,0,0
350 POKE 540,Z
360 IF PEEK(540)<>0 THEN 360
370 GOTO 300
380 POKE 540,Z
390 Z=PEEK(540):IF Z=0 THEN 410
400 SOUND 0,X,10,12:SOUND 1,Y,10,8:GOTO 390
410 SOUND 0,0,0,0:GOTO 300
420 DATA 81,162,6,0,162,3,85,162,6,0,162,3,96,217,6,0,217,3,102,217,6,0,217,3,108,162,6,0,162,3,102,162,6,0,162,3
430 DATA 96,217,12,0,217,6,108,162,6,0,162,3,108,162,3,102,162,6,0,162,3,96,217,6,0,217,3,91,217,6,0,217,3
440 DATA 85,173,30,0,0,9,0,173,3,81,173,6,0,217,3,85,173,6,0,173,3,96,217,6,0,217,3,102,217,6,0,173,3,108,173,6
450 DATA 0,173,3,102,173,6,0,173,3,96,217,12,0,173,3,108,173,6,0,173,3,108,173,3,102,173,6,0,173,3,96,217,6
460 DATA 0,217,3,85,217,6,0,217,3,81,162,26,-1,-1,0
470 REM {inv}*** MISSILE MOVE ROUTINE ***{/inv}
480 Z=USR(MOVX,M+YM3+DYM3,DM3,LM3,63):Z=USR(MOVX,M+YM3+LM3+DYM3,B,-DYM3,63)
490 YM3=YM3+DYM3:XM3=XM3+DXM3:DXM3=0:DYM3=0:RETURN
500 REM {inv}*** THE MAIN LOOP!!! ***{/inv}
510 REM
520 YM3=93:XM3=0:POKE 53278,1:POKE 53251,PEEK(209):POKE 53255,0:TIME=0:SETCOLOR 4,0,INT(CNS/5)
530 REM {inv} RANDOMLY POKE CAT TO SCREEN {/inv}
540 A=(3*RND(0))+1:ON A GOTO 550,560,570
550 TIME=1:X=(150*RND(0))+45:POKE 53248,X:GOTO 580
560 TIME=2:X=(150*RND(0))+45:POKE 53249,X:GOTO 580
570 TIME=3:X=(150*RND(0))+45:POKE 53250,X
580 N=INT((20*RND(0))+20):FOR X=1 TO 25:SOUND 3,N,10,8:NEXT X:SOUND 3,0,0,0
590 TUF=25:IF CNS<=20 THEN TUF=TUF-2
600 IF CNS<=15 THEN TUF=TUF-4
610 IF CNS<=10 THEN TUF=TUF-6
620 IF CNS<=5 THEN TUF=TUF-8
630 GOSUB 750
640 POKE 53248,0:POKE 53249,0:POKE 53250,0
650 POKE 704,72:POKE 705,14:POKE 706,184
660 FOR X=1 TO 150:NEXT X:GOSUB 1070:IF CNS=0 THEN 1100
670 KIT=KIT-1:IF KIT=0 THEN 1100
680 POKE 77,0:GOTO 510
689 REM {inv}*** COLLISION ROUTINE ***{/inv}
690 REM
700 GOSUB 200:D3$=D02$:P3$(YP3,YP3+LP3-1)=D3$:M$=" ":M$(128)=M$:M$(2)=M$
710 ON TIME GOTO 720,730,740
720 SCOR=SCOR+200:RETURN
730 SCOR=SCOR+100:RETURN
740 SCOR=SCOR+50:RETURN
749 REM {inv}*** FIRE MISSILE ***{/inv}
750 FOR Z=1 TO TUF:RB=PEEK(209)+14
760 IF STRIG(0)=0 THEN D3$=D03$:P3$(YP3,YP3+LP3-1)=D3$:SOUND 0,60,12,12:M$(YM3,YM3+LM3-1)=DM3$:GOTO 820
770 D3$=D02$:P3$(YP3,YP3+LP3-1)=D3$
780 ON TIME GOTO 790,800,810
790 FOR X=1 TO 5:NEXT X:NEXT Z:RETURN
800 FOR X=1 TO 10:NEXT X:NEXT Z:RETURN
810 FOR X=1 TO 20:NEXT X:NEXT Z:RETURN
820 MMR=1:CNS=CNS-1:SOUND 0,0,0,0
825 IF RB>=210 OR RB<=40 THEN RETURN
830 POKE 53255,RB:DYM3=-6:GOSUB 470:IF PEEK(53259)<>0 THEN POKE 53255,0:GOTO 690
840 MMR=MMR+1:IF MMR=20 THEN 770
850 GOTO 830
860 REM {inv}*** TITLE SCREEN ***{/inv}
870 GRAPHICS 2+16:POSITION 1,4:? #6;"TIN CAN {inv}ALLEY CATS{/inv}":POSITION 0,8:? #6;"  by {inv}rick {/inv}BLOOM"
880 POSITION 2,9:? #6;"  {inv}AND{/inv} rob {inv}glassman{/inv}"
890 C1=8:C2=166:C3=86:C4=52:C5=0:CNT=1
900 POKE 708,C1:POKE 709,C2:POKE 710,C3:POKE 711,C4:POKE 712,C5
910 CNT=CNT+1:IF CNT=10 THEN 930
920 TEMP=C1:C1=C2:C2=C3:C3=C4:C4=TEMP:FOR X=1 TO 100:NEXT X:GOTO 900
930 RESTORE 420:GOSUB 300
940 RETURN
950 REM {inv}*** TITLE SCREEN #2 ***{/inv}
960 GRAPHICS 18:POSITION 0,1:? #6;"{inv}starring{/inv}...":POSITION 1,3:? #6;"GREENSLEEVES":POSITION 8,4:? #6;"...{inv}50 POINTS{/inv}"
970 POKE 708,72:POKE 709,198:POKE 710,120:POKE 711,12:POKE 712,0
980 POSITION 1,5:? #6;"FRISKY WHITE":POSITION 8,6:? #6;"..{inv}100 POINTS{/inv}":POSITION 1,7:? #6;"PINK PANTHER"
990 POSITION 7,8:? #6;" ..{inv}200 POINTS{/inv}"
1000 RESTORE 420:GOSUB 310
1010 POSITION 0,10:? #6;"AND {inv}you{/inv} AS...{inv}CAN CAN  {/inv}"
1020 RESTORE 420:GOSUB 310:RETURN
1030 REM {inv}*** DISPLAY LIST ***{/inv}
1040 GRAPHICS 21
1050 ST=PEEK(560)+PEEK(561)*256+4:POKE ST-1,70:POKE ST+48,65:POKE ST+49,PEEK(560):POKE ST+50,PEEK(561)
1060 NON=PEEK(559):POKE 559,0:CNS=25
1070 POKE 87,1:POSITION 0,0:? #6;"{inv}score{/inv}:";SCOR
1075 IF SCOR>=2000 AND BONUS=0 THEN GOSUB 2000
1076 IF SCOR>=3000 AND BONUS=1 THEN GOSUB 2100
1077 IF SCOR>=4000 AND BONUS=2 THEN GOSUB 2200
1080 IF CNS<10 THEN POSITION 13,0:? #6;"{inv}cans{/inv}:0";CNS:RETURN
1090 POSITION 13,0:? #6;"{inv}cans{/inv}:";CNS:RETURN
1100 REM {inv}*** END OF GAME ***{/inv}
1110 POKE 209,0:POKE 53251,0
1115 POKE 53277,0:POKE 559,2
1130 GRAPHICS 2+16:POSITION 6,2:? #6;"{inv}meow{/inv} {inv}!!!{/inv}":POSITION 2,4:? #6;"FINAL SCORE ";SCOR
1140 NU=SCOR
1150 IF NU>HSCOR THEN HSCOR=NU:FOR X=1 TO 5:POSITION 0,6:? #6;"new high score ";HSCOR:FOR W=1 TO 50:NEXT W:GOTO 1170
1160 GOTO 1195
1170 POSITION 0,6:? #6;"NEW HIGH SCORE ";HSCOR:FOR W=1 TO 50:SOUND 2,W,10,10:NEXT W
1180 POSITION 0,6:? #6;"{inv}new high score{/inv} ";HSCOR:FOR W=1 TO 50:NEXT W:POSITION 0,6:? #6;"{inv}NEW HIGH SCORE {/inv}";HSCOR
1190 FOR W=1 TO 50:SOUND 2,51-W,10,10:NEXT W:NEXT X:SOUND 2,0,0,0:GOTO 1200
1195 POSITION 2,6:? #6;"{inv}HIGH SCORE  {/inv}";HSCOR
1200 POSITION 1,8:? #6;"press trigger for"
1205 POSITION 4,10:? #6;"another game"
1210 IF STRIG(0)=0 THEN SCOR=0:BONUS=0:GOSUB 1040:POKE 53277,3:GOTO 1800
1220 GOTO 1210
1230 REM {inv}*** COUNTDOWN! ***{/inv}
1240 GRAPHICS 18:POSITION 10,6:? #6;N:RETURN
1249 REM {inv}*** SET UP PMG STRINGS ***{/inv}
1250 GRAPHICS 21
1260 PMBASE=PEEK(106)-12:POKE 54279,PMBASE:PMBASE=PMBASE*256
1270 N=3:GOSUB 1240
1280 POKE 623,17:POKE 704,72:POKE 705,14:POKE 706,184:POKE 707,138:POKE 53256,1:POKE 53257,1
1290 POKE 53258,1:POKE 53259,1:POKE 53260,64:POKE 53248,0:POKE 53249,0:POKE 53250,0:POKE 209,120:POKE 53251,0
1300 FENCE=40:SIZE=17
1310 DIM D0$(SIZE)
1320 RESTORE 1330:FOR I=1 TO SIZE:READ BYTE:D0$(I,I)=CHR$(BYTE):NEXT I
1330 DATA 248,248,32,248,32,216,80,126,31,31,18,18,18,18,18,18,54
1340 DIM D1$(SIZE)
1350 RESTORE 1360:FOR I=1 TO SIZE:READ BYTE:D1$(I,I)=CHR$(BYTE):NEXT I
1360 DATA 248,248,32,248,32,216,80,112,248,249,115,118,124,120,80,80,80
1370 DIM D2$(SIZE)
1380 RESTORE 1390:FOR I=1 TO SIZE:READ BYTE:D2$(I,I)=CHR$(BYTE):NEXT I
1390 DATA 62,62,8,62,8,54,20,28,28,62,62,28,28,180,84,20,54
1400 YP3=101:LP3=16
1410 N=2:GOSUB 1240
1420 DIM D3$(LP3)
1430 RESTORE 1440:FOR I=1 TO LP3:READ BYTE:D3$(I,I)=CHR$(BYTE):NEXT I
1440 DATA 254,130,170,130,186,198,56,56,254,186,186,186,186,40,40,108
1450 YM3=93:LM3=4:REM VERTICAL POSITION AND LENGTH OF MISSILE3
1460 DIM DM3$(LM3)
1470 RESTORE 1480:FOR I=1 TO LM3:READ BYTE:DM3$(I,I)=CHR$(BYTE):NEXT I:DM3=ADR(DM3$)
1480 DATA 192,192,192,192
1490 OFFSET=PMBASE+512-ATAB
1500 FOR I=0 TO 4
1510 V3=INT(OFFSET/256):V2=OFFSET-256*V3
1520 POKE VTAB+2,V2:POKE VTAB+3,V3
1530 POKE VTAB+4,128:POKE VTAB+5,0
1540 POKE VTAB+6,128:POKE VTAB+7,0
1550 VTAB=VTAB+8:OFFSET=OFFSET+128
1560 IF I=3 THEN OFFSET=PMBASE+384-ATAB
1570 NEXT I
1580 P0$(FENCE,FENCE+SIZE-1)=D0$
1590 P1$(FENCE,FENCE+SIZE-1)=D1$
1600 P2$(FENCE,FENCE+SIZE-1)=D2$
1610 P3$(YP3,YP3+LP3-1)=D3$
1620 M$(YM3,YM3+LM3-1)=DM3$
1630 FOR I=1 TO LM3:X=YM3+I-1:M$(X,X)=CHR$(ASC(M$(X,X))+ASC(DM3$(I,I))):NEXT I
1640 DIM B$(17):FOR I=1 TO 17:B$(I,I)=CHR$(0):NEXT I:B=ADR(B$)
1650 N=1:GOSUB 1240
1659 REM {inv}MACHINE LANGUAGE MOVE ROUTINE{/inv}
1660 DIM MOVX$(38):MOVX=ADR(MOVX$):M=ADR(M$)-1
1670 RESTORE 1690
1680 FOR I=1 TO 37:READ BYTE:MOVX$(I,I)=CHR$(BYTE):NEXT I
1690 DATA 104,104,133,204,104,133,203,104,133,206,104,133,205,104,104,133,207,104,104,133,208
1700 DATA 160,0,177,203,37,208,113,205,145,203,200,196,207,208,243,96
1710 GOSUB 1040
1720 DIM D01$(16),D02$(16),D03$(16)
1730 D01$=D3$
1740 RESTORE 1780
1750 FOR I=1 TO 16:READ BYTE:D02$(I,I)=CHR$(BYTE):NEXT I
1760 FOR I=1 TO 16:READ BYTE:D03$(I,I)=CHR$(BYTE):NEXT I
1770 D3$=D02$:P3$(YP3,YP3+LP3-1)=D3$
1780 DATA 254,130,170,130,186,198,56,56,254,186,186,186,40,40,40,108
1790 DATA 254,130,170,130,186,198,56,56,254,57,57,63,63,32,32,224
1800 REM {inv}*** SET UP SCREEN ***{/inv}
1810 POKE 87,5:COLOR 3:FOR X=19 TO 29:PLOT 0,X:DRAWTO 79,X:NEXT X
1820 COLOR 1:PLOT 10,2:DRAWTO 12,2:PLOT 9,3:DRAWTO 13,3:PLOT 8,4:DRAWTO 14,4:PLOT 8,5:DRAWTO 14,5:PLOT 9,6
1830 DRAWTO 13,6:PLOT 10,7:DRAWTO 12,7
1840 COLOR 2:FOR X=5 TO 75 STEP 5:PLOT X,19:DRAWTO X,29:NEXT X:SETCOLOR 4,0,4:SCOR=0:KIT=35
1850 POKE 711,86:POKE 53277,3:POKE 209,120:POKE 559,46:GOTO 510
2000 CNS=CNS+5:KIT=KIT+5:BONUS=1
2005 FOR X=1 TO 5:SOUND 0,50,10,10:FOR Y=1 TO 10:NEXT Y:SOUND 0,0,0,0:NEXT X
2010 FOR Z=1 TO 20:NEXT Z:RETURN
2100 CNS=CNS+5:KIT=KIT+5:BONUS=2
2105 FOR X=1 TO 5:SOUND 0,50,10,10:FOR Y=1 TO 10:NEXT Y:SOUND 0,0,0,0:NEXT X
2110 FOR Z=1 TO 20:NEXT Z:RETURN
2200 CNS=CNS+5:KIT=KIT+5:BONUS=3
2205 FOR X=1 TO 5:SOUND 0,50,10,10:FOR Y=1 TO 10:NEXT Y:SOUND 0,0,0,0:NEXT X
2210 FOR Z=1 TO 20:NEXT Z:RETURN

Download

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

Credits