Dale’s Atari 800 Games › Stan Ockers

Chicken

By Stan Ockers, in the ACE newsletter of February 1982.

Play Chicken

Stan’s write-up

If you’ve been following this column for a while you’ve probably noticed a number of attempts at generalized player missile graphics routines. Hopefully each attempt is an improvement. The object is to be able to control player missiles from Basic simply, without writing a lot of code. This month we look at a new approach which offers quite a bit of flexibility.

The routines are put in two strings, LD$ and VB$. LD$ is used in loading players into PM areas and is used as A=USR(LD,X,ADDR) where LD=ADR(LD$), X is the player number (0-3) and ADDR is the address where player data is located (data must end with a 0). VB$ is a routine inserted in the vertical blank routine. It is quite complicated and uses a number of locations in page 6. I will try to describe the approach used.

Each joystick is associated with one player. If you do not want to use the joystick to move a certain player, that player can be ‘masked’ out. Individual directions of movement can also be ‘masked’. For example, a player can be made to respond only horizontally or only vertically to a joystick. Orthogonal movement (only vert. or horiz.) is also an option.

The orthogonal movement can be such that a player moves only when the joystick is pushed or the joystick can be used only to change directions of moving objects. Beyond movement by joystick, a continuous movement in a certain direction can be forced with or without joystick control ‘on top of’ this background movement. Finally, the speed of the object can be controlled by poking a single byte.

Here is a list of Page 6 reserved locations and their purpose:

(ALL FOR PLAYERS 0 THRU 3 IN ORDER)
1556 (0614)-1559 (0617) HORIZONTAL POSITIONS
1560 (0618)-1563 (061B) VERTICAL POSITIONS
1564 (061C)-1567 (061F) DIRECTION BYTES
1568 (0620)-1571 (0623) LOW BYTE PLYR AREA POINTER
1572 (0624)-1575 (0627) HIGH BYTE PLYR AREA POINTER
1576 (0628)-1579 (062B) REPETITIONS (SPEED)
1580 (062C)-1583 (062F) MASKS FOR JOYSTICKS
1584 (0630)-1587 (0633) FORCED DIRECTIONS

Direction bytes are like those produced by the joysticks (Fig. 10.3 Basic Manual). They could be poked directly into locations 1564-1567. Values other than 15 give motion in the direction indicated. Position is updated every vertical blank period so at the slowest speed a player will cross the screen in about 3 seconds. To move faster poke increasing numbers in the speed bytes. Motion can also be stopped by poking zero in the speed byte.

Masks are ‘ORED’ with bytes from the joysticks. Since a one bit represents a no for a particular direction, a 15 (HEX 0F) will cut out all directions (eliminate that joystick). Other useful masks are:

12 - ONLY VERTICAL MOTION
 3 - ONLY HORIZONTAL MOTION
 0 - NO RESTRICTIONS ON MOTION

Directions are also ‘ANDED’ with forced direction bytes. Zero’s represent yes directions so a 15 has no effect and other directions are as those produced by the joystick.

Orthogonal movement can’t be handled by masks alone so a routine is included for this option. Line 54 tells the change necessary to skip this option. Also, when in the orthagonal mode, you can choose continuous motion with the joystick used only to change directions. Line 55 has the change required.

Working with interrupts is tricky. To insure no conflicts, our VBI routine should be taken out before doing machine language routines other than single pokes. A routine to do this is located in page 6 [A=USR(1546)]. A=USR(1536) inserts our VBI routine again. For sake of speed, the load player routine contains these other two routines at the beginning and end. This means A LOAD OF PLAYER WILL AUTOMATICALLY INSERT OUR VBI ROUTINE! I found out the hard way that a load of players has to follow initalization of PM graphics. Also init. of PM graphics (line 370) has to follow any graphics mode change.

When getting out of the program to Basic, USE THE RESET KEY to take out our VBI routine. If you use the break key and do anything else before hitting reset the system will crash.

Necessary page 6 data (masks, speeds, pointers etc.) could be read in as in lines 45-55 but some of this will depend on size of memory etc. and should be initialized seperately as in lines 210-212. The pertinent sections (roughly lines 10-270 and 370-390) can be ‘listed’ to cassette and ‘entered’ when starting a new program. If no player is required it is still a good idea to clear the player area with A=USR(LD,X,ADDR) where ADDR points to a zero data byte.

Collision routines are meant to be placed at the end of our VBI routine. As it stands only a very simple routine is provided. More complex routines are in the works. The routine provided simply stops both players that collide (by setting their speed to zero). Detection of collision (line 510) and resetting of the collision register and speed bytes is done in Basic.

Enough of this heavy stuff! What about the game?

Why does a chicken cross the road? To score points of course! Just move him with joystick 0, watching out for passing cars. The car speed goes roughly with difficulty (DIF) and DIF will increase each time you get across. DIF will decrease each time you’re hit.

You start with 50 points and that score is increased by ten times the DIF value each time you cross the road. Each time you’re hit your score decreases by twenty points. You have about 2 minutes to start (each count is about 4 sec.) and 40 seconds will be added for each 300 points you score. Be the first on your block to reach 10,000 chicken points!

—Stan Ockers

The start of Stan Ockers' Chicken article in the February 1982 ACE newsletter
As printed: page 6 of the February 1982 issue.

The program

The listing, “CHICKEN by Stan Ockers”, is on pages 7, 11 of the issue. The game page runs it line by line in an emulated Atari 800, just as typed in.

Where this copy came from: Typed-in copy from Atarimania (Chicken_Stan_Ockers_ACE_Newsletter.zip), proofread against the February 1982 issue in ACE Volume 1 (pages 164-169 of Kay Savetz's scan). The copy was a later, edited version: someone had renumbered the header and the first lines and, in the load-player routine (lines 100-120), replaced Stan's calls that switch the VBI off and on while a player is loaded with NOPs and moved its zero-page addresses. Those lines are restored exactly as Stan printed them; everything else matched. Stan's 'Chicken Update' (page 175) came later and isn't applied here.

Reprinted in Antic, April 1982 (In the Public Domain); Antic, July 1987 (Chicken XL, Hall of Fame).

Show the listing
2 REM ******************
4 REM **   CHICKEN   **
6 REM **  STAN OCKERS **
7 REM **    12/81    **
8 REM ******************
9 REM ******************
10 REM **ACE NEWSLETTER**
11 REM *3662 VINE MAPLE *
12 REM *EUGENE, OR 97405*
13 REM **   FEB 1981   **
14 REM ******************
15 REM
18 OPEN #1,4,0,"K:":DIM L$(20),S$(20),C$(20)
19 ? "INITIALIZING ..."
20 REM ** PAGE 6 ROUTINES AND DATA **
40 FOR I=1536 TO 1587:READ A:POKE I,A:NEXT I
41 REM ** VERTICAL BLANK ROUTINE **
42 DIM VB$(210):FOR I=1 TO 210:READ A:VB$(I)=CHR$(A):NEXT I
43 REM ** LOAD PLAYER ROUTINE **
45 DIM LD$(73):FOR I=1 TO 73:READ A:LD$(I)=CHR$(A):NEXT I
47 REM ** INSERT ADDRESS OF ROUT. IN PAGE 6 **
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 ** LINE 56 - CHANGE 24 TO 56 TO SKIP ORTHO. **
55 REM ** LINE 56 - CHANGE 28 TO 34 FOR CONT. MOV. **
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 32,11,6,104,104,104,170,189,32,6,133,203,189,36,6,133,204,104,133,206,104,133,205
110 DATA 189,24,6,133,207,169,0,168,192,255,176,35,196,207,240,5,145,203,200,208,243,162,0,161,205,240,11
120 DATA 145,203,230,205,200,192,255,176,11,208,241,169,0,145,203,200,192,255,144,249,76,1,6
150 REM ** CAR COLOR DATA **
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 ** DEFINE PM AREA - SINGLE LINE RESOL. **
200 A=PEEK(106)-16:POKE 54279,A:PM=256*A
205 REM ** PLAYER MISSILE POINTERS **
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 ** DATA FOR PLAYER IMAGES **
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,219,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 ** INIT. HORIZ. AND VERT. POS. **
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 ** INIT COLORS **
290 DIF=3:BONUS=300:POKE 704,40:CP=0:FOR I=1 TO 3:POKE 704+I,ASC(C$(CP+I)):NEXT I:CP=3:BPOS=5
295 REM ** DRAW ROADS - SET PRIORITY **
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 ** INIT. AND PRINT INFO. - RESET TIMER **
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 77,0:POKE 19,0:POKE 20,0
365 REM ** INIT. PM GR. - FLAGS **
370 POKE 559,62:POKE 53277,3:I1=68:I2=88:FL=I1
375 REM ** LOAD PLAYERS - SET COLORS - PLAYER SIZES **
380 LD=ADR(LD$):A=USR(LD,0,PM):A=USR(LD,1,PM+21):A=USR(LD,2,PM+21):A=USR(LD,3,PM+21)
385 A=USR(1536):REM * INSERT VBI ROUTINE 
390 POKE 53257,1:POKE 53258,1:POKE 53259,1:POKE 623,1
393 REM ** INIT. SPEEDS **
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 ** IF CARS OFF SCREEN, CHANGE LANES **
410 IF PEEK(1557)<15 AND PEEK(1561)=57 THEN POKE 1561,193:A=USR(LD,1,PM+36):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+21):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+36):POKE 1586,7:GOSUB 1000:POKE 706,C
440 IF PEEK(1558)>240 AND PEEK(1562)=169 THEN POKE 1562,81:A=USR(LD,2,PM+21):POKE 1586,11:GOSUB 1000:POKE 706,C
450 IF PEEK(1559)<15 AND PEEK(1563)=105 THEN POKE 1563,145:A=USR(LD,3,PM+36):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+21):POKE 1587,11:GOSUB 1000:POKE 707,C
465 REM ** PRINT TIME - CK. FOR TIME UP **
470 TIME=30-PEEK(19):POSITION 16,0:? #6;TIME;" ":IF TIME<=0 THEN 910
472 REM ** RESET SOU. - HORN ROUT. **
473 SOUND 0,0,0,0
475 IF RND(0)>0.5 THEN SOUND 1,0,0,0
480 IF RND(0)<0.05 THEN SOUND 1,7,12,10
482 REM ** CHICKEN STOMP **
485 P=PEEK(1564):IF P>15 OR P<13 THEN 500
490 IF P=15 THEN A=USR(LD,0,PM):GOTO 500
492 IF FL=I1 THEN FL=I2:SOUND 0,16,6,8:GOTO 496
494 IF FL=I2 THEN FL=I1:SOUND 0,22,6,8
495 REM ** CK. FOR REACHING BOTTOM **
496 A=USR(LD,0,PM+FL)
500 IF PEEK(1560)>230 THEN 810
505 REM ** CK. FOR COLLISION **
510 IF PEEK(53260)=0 THEN 410
515 REM ** SPLAT **
520 A=USR(LD,0,PM+51):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 ** DECREASE SCORE - CK FOR 0 **
530 SCORE=SCORE-20:POSITION 0,0:? #6;SCORE;"   ":IF SCORE<=0 THEN 702
533 REM ** MOVE UP - RELOAD BIRD - RESET COLL. **
535 POKE 1560,PEEK(1560)-24:A=USR(LD,0,PM):IF DIF>1 THEN DIF=DIF-1
590 POKE 53278,0:GOTO 395
700 REM ** SCORE = ZERO **
702 POSITION 3,2:? #6;"{inv}CHICKEN'S{/inv} {inv}DEAD{/inv}"
704 REM ** AMBULANCE **
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 ** NEW HIGH SCORE? **
720 A=USR(1546):IF SCORE>HIGH THEN HIGH=SCORE:POSITION 15,22:? #6;HIGH
730 POSITION 2,6:? #6;"{inv}press{/inv} {inv}FIRE{/inv} {inv}button{/inv}":POSITION 4,7:? #6;"{inv}to{/inv} {inv}play{/inv} {inv}again{/inv}"
732 FOR I=53248 TO 53251:POKE I,0:NEXT I:SOUND 0,0,0,0:SOUND 1,0,0,0
735 REM ** WAIT FOR BUTTON **
740 IF STRIG(0)=1 THEN 740
745 REM ** PM GRAPHICS OFF **
750 POKE 53278,0:POKE 53277,0:A=USR(1546):GOTO 280
800 REM ** BK TO TOP - STOP MOVEMENT OF BIRD **
810 POKE 1560,30:A=USR(LD,0,PM):POKE 1576,0
815 REM ** SIGNAL AND INCREMENT SCORE **
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):FOR J=1 TO RND(0)*30:NEXT J:A=USR(LD,0,PM+88)
830 SCORE=SCORE+DIF*2:POSITION 0,0:? #6;SCORE;"   ":NEXT I
840 IF DIF<9 THEN DIF=DIF+1
841 REM ** CK FOR BONUS **
842 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,13:? #6;"{inv}*{/inv}":BPOS=BPOS+1
850 GOTO 390
900 REM ** TIME'S UP ROUTINE **
910 POSITION 5,2:? #6;"{inv}TIME'S{/inv} {inv}UP{/inv}"
920 GOTO 720
990 REM ** CHANGE CAR COLOR SUB.**
1000 CP=CP+1:IF CP=20 THEN CP=1
1010 C=ASC(C$(CP)):RETURN 

Play Chicken