Chicken

Type
Game
Category
Road-crossing action game
Author
Stan Ockers (revised by Guy A. Hurt)
Published in
Antic, April 1982 (Vol. 1, No. 1); revised version in The Best of Antic, Volume 1
Year
1982
Language
Atari BASIC
Requirements
16K RAM, joystick in port 1, Atari BASIC; a disk drive for the high-score file (or edit three lines, see below)

About the program

Chicken was the very first program in the very first Antic. The April 1982 issue ran it in its "In the Public Domain" section, crediting Stan Ockers, who wrote it in BASIC and assembly language, and the A.C.E. newsletter in Eugene, Oregon, which had printed it first in February 1982. Antic's editors later called it "a fine game then and now", and they reprinted it in The Best of Antic, Volume 1.

The idea is as old as the joke. Your chicken has to get across a road of four lanes. Each crossing scores points, but the traffic gets faster. A hit costs points and slows the traffic down a little. The game ends when the clock runs out, or when your score or the difficulty level falls to zero.

The listing here is the one from the Antic disk, which is the revised version by Guy A. Hurt. It adds an instruction screen (press OPTION), a high score saved to disk, a "wow!" flash every 500 points, and a row of bonus stars that trigger surprises: odd-coloured cars, wider cars, ambulances in the traffic and a shorter clock. The April 1982 magazine printed Ockers' simpler original.

What you need

A joystick in port 1 and 16K. Line 11 reads the high score from D:HI2.DAT with no TRAP, so on a disk system create that file first with a zero in it (OPEN #2,8,0,"D:HI2.DAT":PRINT #2;0:CLOSE #2). Without a disk, turn lines 11, 725 and 742 into REMs, as the inverse-video REMs in lines 12–16 explain. The listing here runs on genuine Atari BASIC and on the Altirra BASIC replacement used by many emulators (see Changes from the published listing).

Typing it in

The only special characters are inverse-video text, shown as {inv}…{/inv}. Press the Atari (inverse) key before and after it. Almost all of it is inside REMs and title screens. Lines 50–120 hold the machine code as DATA, and one wrong number there will crash the computer. Check them carefully and SAVE before you RUN.

How to play

Press the trigger at the title screen. Move the chicken down the screen with the joystick. When it reaches the far side it flaps back to the top, and you score twice the difficulty level, five times over. Being hit costs a point and lowers the level by one. Every 300 points earns a star and extra time.

How it works

  • Line 200 puts player/missile memory 4K below the top of RAM (PEEK(106)-16) and line 370 turns on single-line players.
  • The 52 bytes at 1536 (page 6) hold tables of positions, speeds and directions plus a short routine that installs VB$ as a vertical-blank interrupt with SETVBV ($E45C). Every 60th of a second it reads the joystick and moves all four players, so BASIC only has to change lanes, colours and shapes.
  • LD$ is a loader called as USR(LD,player,address) to copy a shape into a player's memory. Cars, the squashed chicken and the ambulance are just different shapes at different offsets.
  • PEEK(53260) (player 0 collisions) detects the hit, and PEEK(19), which ticks about every 4.3 seconds, is the countdown.

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 CP, 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
CP KP 290, 1000, 1005, 1010

Listing

4 REM ***** CHICKEN *****
5 REM BY STAN OCKERS REVISED BY GUY HURT
9 C1=4:C2=0:C3=0:SCOREONE=500:RN3=36:RN4=21:W=7:U=11:BSW=0:GOSUB 15000
10 OPEN #1,4,0,"K:":DIM L$(20),S$(20),C$(20),Z$(5):Z$(1)="/":Z$(2)="@":Z$(3)="%":Z$(4)="$":Z$(5)=" "
11 OPEN #2,4,0,"D:HI2.DAT":INPUT #2,HIGH:CLOSE #2
12 REM {inv}DEAR OWNER:IF YOU OWN A DISK {/inv}
13 REM {inv}CREATE A FILE CALLED HI2.DAT {/inv}
14 REM {inv}AND STORE A ZERO IN IT       {/inv}
15 REM {inv}ELSE MAKE STMTS 11,725&742   {/inv}
16 REM {inv}REM's UNTIL YOU OWN A DISK   {/inv}
19 POSITION 0,16:? #6;"INITIALIZING...":Q2=0
20 REM {inv}PAGE 6 ROUTINES AND DATA{/inv}
40 FOR I=1536 TO 1587:READ A:POKE I,A:NEXT I
41 REM {inv}VERTICAL BLANK RTNE.{/inv}
42 DIM VB$(210):FOR I=1 TO 210:READ A:VB$(I)=CHR$(A):NEXT I
43 REM {inv}LOAD PLAYER RTNE.{/inv}
45 DIM LD$(73):FOR I=1 TO 73:READ A:LD$(I)=CHR$(A):NEXT I
47 REM {inv}INSERT ADR. OF ROUT. IN PAGE 6{/inv}
48 A=ADR(VB$):B=INT(A/256):POKE 1540,B:POKE 1538,A-256*B
50 DATA 104,160,52,162,6,169,7,76,92,228,104,160,98,162,228,169,7,76,92,228
52 DATA 120,120,120,120,30,57,81,105,15,15,15,15,0,0,0,0,52,53,54,55,2,2,3,4,12,0,0,0,15,11,11,11
54 REM {inv}LINE56-CHANGE 24TO56TOSKIP ORTH.{/inv}
55 REM {inv}LINE56 CHANGE 28 TO 34 FOR CONT. MOVEM.{/inv}
56 DATA 72,138,72,152,72,162,0,189,120,2,29,44,6,160,15,24,176,32,201,15,240,28,201,14,208,2,160,13,201,13
57 DATA 208,2,160,14,201,11,208,2,160,7,201,7,208,2,160,11,192,15,240,6,61,48,6,157,28,6,152,61,44,6,157,44,6
58 DATA 232,224,4,144,195
60 DATA 162,0,189,32,6,133,203,189,36,6,133,204,189,40,6,133,209,198,209,16,7,232,224,4
65 DATA 144,232,176,91,189,28,6,133,207
70 DATA 70,207,176,26,188,24,6,192,1,240,19,208,1,200,177
75 DATA 203,240,6,136,145,203,200,208,245,136,145,203,222,24,6,70,207,176,29,188,24,6,200,192,254,176,21
80 DATA 177,203,208,247,136,177,203,240,6,200,145,203,136,208,245,200,145,203,254,24,6,70,207,176,3,222,20
85 DATA 6,70,207,176,3,254,20,6,189,20,6,157,0,208
90 DATA 24,144,154,162,4,189,11,208,240,5,169,0,157,39,6,202,208,243,104,168,104,170,104,76,98,228
100 DATA 234,234,234,104,104,104,170,189,32,6,133,186,189,36,6,133,187,104,133,213,104,133,212
110 DATA 189,24,6,133,195,169,0,168,192,255,176,35,196,195,240,5,145,186,200,208,243,162,0,161,212,240,11
120 DATA 145,186,230,212,200,192,255,176,11,208,241,169,0,145,186,200,192,255,144,249,96,234,234
150 REM {inv}CAR COLOR DATA {/inv}
160 FOR I=1 TO 20:READ A:C$(I)=CHR$(A):NEXT I
170 DATA 24,60,218,68,90,186,70,150,54,232,74,168,88,154,21,252,200,76,228,28
190 REM {inv}DEFINE PM AREA-SINGLE LINE RES{/inv}
200 A=PEEK(106)-16:POKE 54279,A:PM=256*A
205 REM {inv}PLAY MISSILE POINTERS{/inv}
210 FOR I=4 TO 7:POKE 1568+I,A+I:NEXT I
212 FOR I=1568 TO 1571:POKE I,0:NEXT I
218 REM {inv}DATA FOR PLAYER IMAGES{/inv}
220 FOR I=PM TO PM+121:READ A:POKE I,A:NEXT I
230 DATA 16,56,16,56,40,16,16,16,146,254,254,124,56,56,40,40,40,40,40,108,0
232 DATA 126,195,219,219,91,219,219,219,219,91,219,219,195,126,0
234 DATA 126,195,210,219,218,219,219,219,219,218,219,219,195,126,0
236 DATA 33,34,150,84,57,30,60,123,159,30,52,86,151,36,194,193,0
238 DATA 16,56,16,56,40,16,16,56,124,254,186,56,56,40,40,40,44,32,96,0
240 DATA 16,56,16,56,40,16,16,146,214,124,56,56,40,40,40,104,8,12,0
242 DATA 126,255,173,173,239,199,199,199,199,239,173,173,255,126,0
270 REM {inv}INIT HORIZ.& VERT. POSTN.{/inv}
280 RESTORE 282:FOR I=1556 TO 1563:READ A:POKE I,A:NEXT I
282 DATA 120,120,120,120,30,57,81,105
288 REM {inv}INIT. COLORS{/inv}
290 DIF=3:BONUS=300:POKE 704,40:KP=0:FOR I=1 TO 3:POKE 704+I,ASC(C$(KP+I)):NEXT I:KP=3:BPOS=1
295 REM {inv}DRAW ROAD SET PRIORITY{/inv}
300 GRAPHICS 17:FOR I=1 TO 20:L$(I)="-":NEXT I
305 FOR I=2 TO 20 STEP 2:S$(I)="-":S$(I-1)=" ":NEXT I
310 POSITION 0,2:? #6;L$:POSITION 0,11:? #6;L$:POSITION 0,13:? #6;L$:POSITION 0,22:? #6;L$
312 POSITION 0,5:? #6;S$:POSITION 0,8:? #6;S$:POSITION 0,16:? #6;S$:POSITION 0,19:? #6;S$:POKE 710,90
340 REM {inv}INIT & PRINT INFO-RESET TIMER{/inv}
350 SCORE=50:POSITION 0,1:? #6;"score           time":POSITION 0,23:? #6;"dif             high";
360 POSITION 0,0:? #6;SCORE:POSITION 15,22:? #6;HIGH:POKE 19,0:POKE 20,0
365 REM {inv}INIT PM GR.-FLAGS{/inv}
370 POKE 559,62:POKE 53277,3:I1=68:I2=88:FL=I1
375 REM {inv}LOAD PLAYERS-SETCOLORS-PLAYERS SIZES{/inv}
380 LD=ADR(LD$):A=USR(LD,0,PM+RN5):A=USR(LD,1,PM+21):A=USR(LD,2,PM+21):A=USR(LD,3,PM+21)
385 A=USR(1536):REM {inv}INSERT VBI RTNE.{/inv}
390 POKE 53257,1:POKE 53258,1:POKE 53259,1:POKE 623,1
391 IF BPOS=18 THEN POKE 53257,3:POKE 53258,3:POKE 53259,3
393 REM {inv}INIT SPEEDS{/inv}
395 POKE 1576,2:FOR I=1577 TO 1579:POKE I,RND(0)*DIF+1:NEXT I
398 POSITION 1,22:? #6;DIF
400 REM {inv}IF CARS OFF-SCREEN.CHANGE LANES{/inv}
410 IF PEEK(1557)<15 AND PEEK(1561)=57 THEN POKE 1561,193:A=USR(LD,1,PM+RN3):POKE 1585,7:GOSUB 1000:POKE 705,C
420 IF PEEK(1557)>240 AND PEEK(1561)=193 THEN POKE 1561,57:A=USR(LD,1,PM+RN4):POKE 1585,11:GOSUB 1000:POKE 705,C
430 IF PEEK(1558)<15 AND PEEK(1562)=81 THEN POKE 1562,169:A=USR(LD,2,PM+RN3):POKE 1586,W:GOSUB 1000:POKE 706,C
440 IF PEEK(1558)>240 AND PEEK(1562)=169 THEN POKE 1562,81:A=USR(LD,2,PM+RN4):POKE 1586,U:GOSUB 1000:POKE 706,C
450 IF PEEK(1559)<15 AND PEEK(1563)=105 THEN POKE 1563,145:A=USR(LD,3,PM+RN3):POKE 1587,7:GOSUB 1000:POKE 707,C
460 IF PEEK(1559)>240 AND PEEK(1563)=145 THEN POKE 1563,105:A=USR(LD,3,PM+RN4):POKE 1587,11:GOSUB 1000:POKE 707,C
465 REM {inv}PRINT TIME-CHECK FOR TIMEUP{/inv}
470 TIME=15-PEEK(19):POSITION 16,0:? #6;TIME;" ":IF TIME<=0 THEN 910
471 GOSUB 1200
472 REM {inv}RESET SOUND-HORN RTNE.{/inv}
473 SOUND 0,0,0,0
475 IF RND(0)>0.5 THEN SOUND 1,0,0,0
480 IF RND(0)<0.05*RN2 THEN SOUND 1,7,12,10
484 REM {inv}CHICKEN STOMP{/inv}
485 P=PEEK(1564):IF P>15 OR P<35 THEN 500
490 IF P=15 THEN A=USR(LD,0,PM+RN5):GOTO 500
492 IF FL=I1 THEN FL=I2:SOUND 0,16*RN,6,8:GOTO 496
494 IF FL=I2 THEN FL=I1:SOUND 0,22*RN,6,8
495 REM {inv}CHECK FOR REACHING BOTTOM{/inv}
496 A=USR(LD,0,PM+FL+RN5)
500 IF PEEK(1560)>230 THEN 810
501 RN=INT(RND(0)*15+1):IF BPOS<>4 AND BPOS<>19 THEN RN=1
505 REM {inv}CHECK FOR COLLISION{/inv}
510 IF PEEK(53260)=0 THEN 410
515 REM {inv}SPLAT !{/inv}
520 A=USR(LD,0,PM+51+RN5):FOR J=1 TO 3:SOUND 0,RND(0)*255,8,8:SOUND 1,RND(0)*255,8,8
525 POKE 704,PEEK(704)+8:FOR I=1 TO 30:NEXT I:NEXT J:SOUND 0,0,0,0:SOUND 1,0,0,0:POKE 704,40
527 REM {inv}DECREASE SCORE-CHECK FOR 0{/inv}
530 SCORE=SCORE-1:POSITION 0,0:? #6;SCORE;"  ":IF SCORE<=0 THEN 702
533 REM {inv}MOVE UP, RELOAD BIRD-RESET COLL{/inv}
535 POKE 1560,PEEK(1560)-24:A=USR(LD,0,PM+RN5):IF DIF>0 THEN DIF=DIF-1
550 IF DIF=0 THEN GOTO 700
590 POKE 53278,0:GOTO 395
700 REM {inv}SCORE=0{/inv}
702 POSITION 3,2:? #6;"CHICKEN'S DEAD!"
704 REM {inv}AMBULANCE{/inv}
705 C=1
706 IF PEEK(1576+C)=0 THEN C=C+1:GOTO 706
707 IF C>3 THEN C=1
713 POKE 1576+C,1:POKE 1560+C,PEEK(1560):POKE 1556+C,220:A=USR(LD,C,PM+107)
715 FOR J=1 TO 6:FOR P=60 TO 40 STEP -2:SOUND 0,P,10,8:FOR I=1 TO 6:NEXT I
716 NEXT P:FOR P=40 TO 60 STEP 2:SOUND 0,P,10,8:FOR I=1 TO 6:NEXT I:NEXT P:NEXT J:SOUND 0,0,0,0
718 REM {inv}NEW HIGH SCORE{/inv}
720 A=USR(1546):IF SCORE<=HIGH THEN 730
721 HIGH=SCORE:FOR Q=1 TO 7:POSITION 11,23:? #6;HIGH;"  ":POSITION 15,22:? #6;"high":SOUND 0,40,10,15
722 FOR Q2=1 TO 50:NEXT Q2
723 POSITION 11,23:? #6;"high":POSITION 15,22:? #6;HIGH;"-":SOUND 0,50,10,15:FOR Q2=1 TO 50:NEXT Q2
724 NEXT Q:SOUND 0,0,0,0
725 TRAP 1300:OPEN #2,8,0,"D:HI2.DAT":PRINT #2,HIGH:CLOSE #2
730 POSITION 2,6:? #6;"press FIRE button ":POSITION 4,7:? #6;"to play again"
732 FOR I=53248 TO 53251:POKE I,0:NEXT I:SOUND 0,0,0,0:SOUND 1,0,0,0
735 REM {inv}WAIT FOR BUTTON{/inv}
740 IF STRIG(0)=1 THEN 740
741 C1=4:C2=0:C3=0:SCOREONE=500:BSW=0
742 OPEN #2,4,0,"D:HI2.DAT":INPUT #2,HIGH:CLOSE #2
745 REM {inv}PM GRAPHICS OFF{/inv}
750 POKE 53278,0:POKE 53277,0:A=USR(1546):GOTO 280
800 REM {inv}BACK TO TOP-STOP BIRDMOVMNT.{/inv}
810 POKE 1560,30:A=USR(LD,0,PM+RN5):POKE 1576,0
815 REM {inv}SIGNAL AND INCREMENT SCORE{/inv}
820 FOR I=1 TO 5:FOR J=10 TO 5 STEP -1:SOUND 0,J,14,8:SOUND 1,J,2,8:NEXT J:SOUND 0,0,0,0:SOUND 1,0,0,0
825 A=USR(LD,0,PM+68+RN5):FOR J=1 TO RND(0)*30:NEXT J:A=USR(LD,0,PM+88+RN5)
830 SCORE=SCORE+DIF*2:POSITION 0,0:? #6;SCORE;"  ":NEXT I
831 IF SCORE>=SCOREONE THEN 833
832 GOTO 840
833 FOR I=1 TO 3:POSITION 0,0:? #6;"wow!":GOSUB 835:POSITION 0,0:? #6;SCORE:GOSUB 835:NEXT I
834 SCOREONE=SCOREONE+500:GOTO 840
835 FOR Q=20 TO 1 STEP -4:SOUND 1,Q*5,10,15:NEXT Q:SOUND 1,0,0,0:RETURN
840 IF DIF<9 THEN DIF=DIF+1:IF DIF=9 THEN C1=4:C2=10:C3=0
841 IF DIF<>9 THEN C1=4:C2=0:C3=0
842 REM {inv}CHECK FOR BONUS{/inv}
843 IF SCORE<BONUS THEN 850
844 SOUND 0,25,10,10:BONUS=BONUS+300:P=PEEK(19):IF P<11 THEN POKE 19,0:GOTO 848
846 POKE 19,P-10
848 POSITION BPOS,12:? #6;"*":BPOS=BPOS+1:BSW=BSW+1:IF BPOS>19 THEN BPOS=0
849 IF BPOS<>0 THEN W=7:U=11
850 IF BPOS=7 THEN RN2=17:GOTO 390
851 IF BPOS<>7 THEN RN2=1
852 IF BPOS=13 THEN RN3=107:RN4=107:GOTO 390
853 IF BPOS<>13 THEN RN3=36:RN4=21
854 IF BPOS=0 THEN W=11:U=7
855 IF BPOS=16 THEN RN3=0:RN4=0:RN5=21:GOTO 390
856 IF BPOS<>16 THEN RN3=36:RN4=21:RN5=0
857 IF BPOS=19 THEN RN2=18:RN3=107:RN4=0
858 IF BPOS<>19 THEN RN2=1:RN3=36:RN4=21
859 IF BPOS=1 AND BSW>0 THEN GOSUB 1400:GOTO 9000
869 GOTO 390
900 REM {inv}TIME'SUP RTNE.{/inv}
910 POSITION 5,2:? #6;"TIME'S UP!"
920 GOTO 720
990 REM {inv}CHANGE CAR COLOR RTNE.{/inv}
1000 IF BPOS=10 OR BPOS=19 THEN KP=KP-1
1005 KP=KP+1:IF KP=20 THEN KP=1
1010 POKE 77,0:C=ASC(C$(KP)):RETURN
1200 IF TIME=10 THEN SETCOLOR 4,12,2:FOR K=1 TO 10:SOUND 3,K,10,10:NEXT K:SOUND 3,0,0,0
1210 IF TIME<>10 THEN SETCOLOR C1,C2,C3
1220 RETURN
1300 GRAPHICS 0:SOUND 1,55,10,15:? "DISK PROBLEM.....HIGH SCORE WAS NOT SAVED...":FOR I=1 TO 500:NEXT I
1310 SOUND 0,0,0,0:? "TYPE RUN TO PLAY AGAIN"
1320 TRAP 1300
1400 FOR I=1 TO 255:SOUND 0,I,12,12:SETCOLOR 4,I,10:NEXT I
1410 FOR BPO=1 TO 5:FOR BPOT=0 TO 19:SOUND 0,BPOT*BPO,10,12
1420 POSITION BPOT,12:? #6;Z$(BPO):NEXT BPOT:NEXT BPO
1425 SOUND 0,0,0,0
1426 POSITION 0,12:? #6;"&"
1427 POSITION 0,13:? #6;L$
1428 BSW=0
1430 RETURN
9000 FOR I=1 TO 150:NEXT I:POKE 19,99:GOTO 470
15000 GRAPHICS 17:POSITION 0,0:? #6;"{inv}PRESS OPTION FOR{/inv}":POSITION 0,1:? #6;"{inv}OBJECTIVE{/inv}":POSITION 0,2
15010 ? #6;"{inv}PRESS TRIGGER{/inv}":POSITION 0,3:? #6;"{inv}BUTTON TO PLAY{/inv}"
15020 IF PEEK(53279)=3 THEN 15050
15030 IF STRIG(0)=0 THEN 16000
15040 GOTO 15020
15050 GRAPHICS 17:POSITION 0,0:? #6;"YOUR OBJECTIVE??":POSITION 0,1:? #6;"SIMPLE. JUST GET THE"
15055 POSITION 0,2:? #6;"chicken SAFELY":POSITION 0,3:? #6;"ACROSS THE ROAD"
15060 POSITION 0,4:? #6;"without GETTING HIT":POSITION 0,5:? #6;"BY {inv}CARS{/inv}."
15070 POSITION 0,7:? #6;"YOU MUST LEARN THE":POSITION 0,8:? #6;"{inv}SCORING SYSTEM{/inv}."
15080 POSITION 0,10:? #6;"{inv}all sorts of neat{/inv}":POSITION 0,11:? #6;"{inv}surprises are in{/inv}":POSITION 0,12
15090 ? #6;"{inv}store for the{/inv}":POSITION 0,13:? #6;"{inv}advanced player{/inv}."
15100 POSITION 0,15:? #6;"PLEASE PRESS OPTION."
15160 IF PEEK(53279)=3 THEN 16000
15170 GOTO 15160
16000 GRAPHICS 17:POSITION 6,6:? #6;"C{inv}H{/inv}i{inv}C{/inv}KeN":POSITION 0,7
16100 FOR I=1 TO 4:SOUND 0,16,6,8:FOR J=1 TO 20:NEXT J:SOUND 0,22,6,8:FOR J=1 TO 20:NEXT J
16150 NEXT I:SOUND 0,0,0,0
16200 ? #6;"{inv}written by {/inv}":POSITION 4,8:? #6;"{inv}STAN OCKERS{/inv}":POSITION 0,9:Q2=0
16205 REM {inv}D&D{/inv} {inv}BUGGED{/inv}
16210 ? #6;"REVISED BY":FOR I=1 TO 200:NEXT I:POSITION 4,10:? #6;"{inv}GUY A. HURT{/inv}":MK=50
16220 FOR I=1 TO 250:NEXT I
16230 FOR I=1 TO 5:FOR J=10 TO 5 STEP -1:SOUND 0,J,14,8:SOUND 1,J,2,8:NEXT J:SOUND 0,0,0,0:SOUND 1,0,0,0
16240 FOR K=1 TO MK:NEXT K:MK=MK-10:NEXT I
16250 RETURN

Download

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

Credits