Dale's Home Page

Dale’s Atari 800 Games › Stan Ockers

Charlie Chicken

By Stan Ockers, in the ACE newsletter of July/August 1986.

Play Charlie Chicken

The program’s instructions

Stan didn’t write an article for this one; this is what the program itself shows on the screen.

Stan didn't write a separate article for this one. The issue's “News and Reviews” column (page 2) introduced it: “In this issue, we will feature a new, very original Stan Ockers Game, Charlie Chicken Adventure #1. This is a wonderful game for children, written in Action.” —Mike Dunn. These are the instructions the program shows when you press OPTION:

Charlie needs your help to get hatched. You must find out what egg he is in and have mother hen sit on him overnight. You locate Charlie by spinning eggs. They will point in his direction when they stop. Don't spin Charlie though, you will scramble him!

The SPACEBAR puts Mom Hen on the egg under the cursor or takes her off. Don't move around in the dark. You break eggs that way!

Every once in a while eggs will disappear. If a fox visits at night things get re-arranged. You can ask for a score at the end.

The program

The listing, “CHARLIE CHICKEN ADVENTURE #1 by Stan Ockers”, is on pages 7, 8, 9, 10 of the issue. Stan wrote it in Action!, the compiled language from Optimized Systems Software, and readers needed the Action! cartridge to type it in and compile it. There is no Action! compiler here, so the game page runs a hand translation of the listing into JavaScript: one function for each of Stan’s procedures, with his variable names, sizes and memory addresses, driving the same emulated Atari 800 (its screen, player-missile graphics, collisions and sound) that runs the BASIC games.

Where this copy came from: Written in Action!. The listing was transcribed by hand from the scan (pages 7-10; there is no typed-in copy), and its character set, egg positions, sun and moon shapes, three tunes and every message were checked byte for byte against a compiled copy of the game from the Atari archives. The game page runs a hand translation of the listing into JavaScript; Stan's own vertical blank routine, which counts down all of the game's timers, runs in the emulated Atari's vertical blank.

Show the listing
; ********************************
; * CHARLIE CHICKEN ADVENTURE #1 *
; ********************************

BYTE RAMTOP=106,curpos,loseflg,
   ccpos,ccspin,ccsit,sndflg,
   sunpos=[48],timeflg,sndpos=[0],
   spincnt,brkcnt,goodcnt,winflg,
   ccx,ccy,CONSOL=53279,foxflg,
   msgflg,snaflg,sunspeed,sitflg,
   sitpos,svpos,taken,spinmax=[10]
CARD pmbase
BYTE ARRAY tmr(45),max(36),stat(36),
  dir(36),pnt(36),sndray,
  cset1=[0 3 7 7 15 15 15 15 0 192 224
   224 240 240 240 240 15 15 15 7 7 3 3
   1 240 240 240 224 224 192 192 128 0 0
   7 15 31 63 127 127 0 0 128 192 224
   224 240 240 127 127 63 63 31 15 7 0
   240 240 240 224 224 192 128 0 1 3 3 7
   7 15 15 15 128 192 192 224 224 240
   240 240 15 15 15 15 7 7 3 0 240 240
   240 240 224 224 192 0 0 0 1 3 7 7 15
   15 0 0 224 240 248 252 254 254 15 15
   15 7 7 3 1 0 254 254 252 252 248 240
   224 0 0 12 24 24 62 56 56 62 0 240
   120 120 28 124 124 252 30 31 15 15 7
   7 3 1 248 120 176 112 224 224 192 128
   0 3 5 130 193 97 113 63 0 192 160 65
   131 134 142 252 63 63 63 31 31 7 0 0
   252 252 252 248 248 224 0 0 0 1 32 17
   8 5 2 84 0 0 132 8 144 32 64 42 40 2
   5 8 17 32 1 0 20 64 32 144 8 132 0 0
   255 255 255 255 255 255 255 255],
  cset2=[0 54 127 127 62 28 8 0 0 0 60
   126 126 126 60 0 0 0 0 0 0 0 24 0 1 2
   5 9 9 5 2 1 128 64 160 144 144 160 64
   128],
  ex=[2 5 8 11 14 17 2 5 8 11 14 17
      2 5 8 11 14 17 2 5 8 11 14 17
      2 5 8 11 14 17 2 5 8 11 14 17],
  ey=[5 5 5 5 5 5 8 8 8 8 8 8 11 11 11
      11 11 11 14 14 14 14 14 14 17
      17 17 17 17 17 20 20 20 20 20 20],
  sun=[0 24 60 126 126 255 255 255 255
      126 126 60 24 0],
  moon=[0 24 60 118 98 225 225 225 225
      98 118 60 24 0],
  straw=[10 72 81 91 0 91 0 91 0 133 136
      121 0 121 0 121 0 91 81 72 0 72 0
      72 81 91 81 72 0 81 0 81 1],
  foxsnd=[14 162 0 136 0 108 0 81 0 42 102
      14 0 7 108 0 121 0 136 0 144 0 1],
  losesnd=[40 243 243 10 243 40 243 204
      10 217 40 217 10 243 40 243
      10 255 60 243 1]

PROC Vblank()
BYTE j
  FOR j=0 TO 44 DO
    IF tmr(j)>0 THEN tmr(j)==-1 FI OD
  [ $4C $62 $E4 ]

PROC Setvect=$E45C(BYTE areg,xreg,yreg)

PROC Init()
  RAMTOP==-9 pmbase=(RAMTOP+1)*256
  SetBlock(pmbase,8*256,0)
  MoveBlock(pmbase,$E000,512)
  MoveBlock(pmbase+16,cset1,232)
  MoveBlock(pmbase+472,cset2,40)
  Poke(54279,RAMTOP+1) Poke(704,0)
  Poke(705,33) Poke(706,30)
  Poke(53275,2) SndRst()
  Setvect(7,Vblank RSH 8,Vblank & $FF)
RETURN

PROC Instr()
  Graphics(0) Print("{inv} *** INSTRUCTIONS *** {/inv}")
  PutE() PutE() Poke(752,1)
  PrintE("Charlie needs your help to get")
  PrintE("hatched.  You must find out  ")
  PrintE("what egg he is in and have")
  PrintE("mother hen sit on him overnight.")
  PrintE("You locate Charlie by spinning")
  PrintE("eggs.  They will point in his")
  PrintE("direction when they stop.  Don't")
  PrintE("spin Charlie though, you will")
  PrintE("scramble him!")
  PutE()
  PrintE("The {inv}SPACEBAR{/inv} puts Mom Hen on the")
  PrintE("egg under the cursor or takes her")
  PrintE("off.  Don't move around in the dark.")
  PrintE("You break eggs that way!") PutE()
  PrintE("Every once in a while eggs will")
  PrintE("disappear.  If a fox visits at")
  PrintE("night things get re-arranged.  You")
  PrintE("can ask for a score at the end.")
  PutE() Print("Press {inv}START{/inv} to begin")
RETURN

PROC Snd()
BYTE sel,dur
  IF sndflg>0 THEN
    IF tmr(38)=0 THEN
      tmr(38)=dur
      sel=sndray(sndpos)
      IF sel<61 THEN
        IF sel=0 THEN SndRst()
        ELSEIF sel=1 THEN
          sndflg=0 SndRst() sndpos=0

        ELSE dur=sel tmr(38)=0 FI
      FI
      sndpos==+1
    FI
    IF tmr(38)<12 THEN
      Sound(0,sel,10,tmr(38))
    ELSE Sound(0,sel,10,10)
    FI
  FI
RETURN

PROC Title()
CARD dlist,delay
  Graphics(2) Poke(752,1) Poke(712,33)
  dlist=PeekC($230) Poke(dlist+6,2)
  Poke(dlist+11,6) Poke(710,160)
  Position(7,1)
  PrintD(6,"{inv}    The Adventures Of    {/inv}")
  Position(2,4) PrintD(6,"CHARLIE CHICKEN")
  Position(6,6) PrintD(6,"part i")
  Position(3,8) PrintD(6,"{inv}the hatching{/inv}")
  PrintE("         {inv} By Stan Ockers {/inv}")
  PutE()
  Print("        {inv} Written in Action! {/inv}")
  FOR delay=1 TO 60000 DO OD
  PutE() PutE() PutE()
  PrintE("       {inv} OPTION {/inv} - Instructions")
  PrintE("        {inv} START {/inv} - Begin game")
  sndray=straw
  sndflg=1 tmr(38)=0
  DO
    IF CONSOL=3 THEN Instr() FI
    Snd()
    IF sndflg=0 Then sndflg=1 FI
  UNTIL CONSOL=6
  OD
  SndRst() sndflg=0 sndpos=0
RETURN

PROC Begin()
BYTE j
  FOR j=0 TO 35 DO
    tmr(j)=0 max(j)=16 stat(j)=1
  OD
  tmr(36)=0 ccspin=0 ccsit=0 spincnt=0
  brkcnt=0 goodcnt=36 winflg=0
  loseflg=0 sndflg=0 msgflg=0 snaflg=0
  SetBlock(pmbase+1280,512,0)
  sitflg=0 foxflg=0 svpos=58 timeflg=1
  sunpos=48 sunspeed=10 taken=0
  sndpos=0 SndRst()
RETURN

PROC Draw4(BYTE j,strt)
    Position(ex(j),ey(j))
    PutD(6,strt) PutD(6,strt+1)
    Position(ex(j),ey(j)+1)
    PutD(6,strt+2) PutD(6,strt+3)
RETURN

PROC Egg(BYTE j,dir)
  BYTE ARRAY eggdir=[2 6 10 14]
  Draw4(j,eggdir(dir))
RETURN

PROC Blkegg(BYTE j)
    Position(ex(j),ey(j))
    PutD(6,32) PutD(6,32)
    Position(ex(j),ey(j)+1)
    PutD(6,32) PutD(6,32)
RETURN

PROC Spin()
BYTE j,r,HPOSP1=53249
CARD pos,fill
  FOR j=0 TO 35 DO
    IF stat(j)=1 THEN
      IF tmr(j)=0 THEN
        IF max(j)<spinmax THEN
          dir(j)==+1
          IF dir(j)=4 THEN dir(j)=0 FI
          Egg(j,dir(j))
          IF j=ccpos THEN
            r=Rand(4) ccspin=1
            HPOSP1=ccx*24+68
            pos=pmbase+1356+24*ccy
            fill=$E200+8*(28+r)
            MoveBlock(pos,fill,8)
          FI
          IF Rand(3)=1 THEN
            max(j)==+1 FI
          IF max(j)=spinmax THEN
            IF dir(j)<>pnt(j) THEN
              max(j)=spinmax-1
            ELSE dir(j)=pnt(j) FI
          FI
          tmr(j)=max(j)
          IF max(ccpos)=spinmax AND ccspin=1
            THEN loseflg=1 FI
        FI
      FI
    FI
  OD
RETURN

PROC Startspin()
BYTE j
  IF max(curpos)>=spinmax THEN
    IF Strig(0)=0 AND timeflg=1 THEN
      tmr(curpos)=1 max(curpos)=1
      spincnt==+1
    FI
  FI
RETURN

PROC Shuffle(BYTE nbr1,nbr2)
BYTE j,r
  FOR j=0 TO 35 DO
    stat(j)=0 dir(j)=Rand(4) OD
  FOR j=1 TO nbr1 DO
    DO r=Rand(36)
    UNTIL stat(r)=0 OD
    stat(r)=1
  OD
  FOR j=1 TO nbr2 DO
    DO r=Rand(36)
    UNTIL stat(r)=0 OD
    stat(r)=2
  OD
RETURN

PROC Fillpnt()
BYTE x,y,j,pnt1,pnt2
  DO ccpos=Rand(36)
  UNTIL stat(ccpos)=1
  OD
  ccx=ccpos MOD 6 ccy=ccpos/6
  FOR j=0 TO 35 DO
    x=j MOD 6 y=j/6
    IF x<ccx THEN pnt1=3
    ELSEIF x>ccx THEN pnt1=1
    ELSE pnt1=4
    FI
    IF y>ccy THEN pnt2=2
    ELSEIF y<ccy THEN pnt2=0
    ELSE pnt2=4
    FI
    IF j=ccpos THEN pnt(j)=Rand(4)
    ELSE
      IF Rand(2)=0 THEN
        IF pnt1<4 THEN pnt(j)=pnt1
        ELSE pnt(j)=pnt2 FI
      ELSE
        IF pnt2<4 THEN pnt(j)=pnt2
        ELSE pnt(j)=pnt1 FI
      FI
    FI
  OD
RETURN

PROC Draweggs()
BYTE j
  FOR j=0 TO 35 DO
    IF stat(j)=1 THEN
      Egg(j,dir(j))
    ELSEIF stat(j)=2 THEN Draw4(j,18)
    ELSEIF stat(j)=3 THEN Draw4(j,54)
    ELSE Blkegg(j)
    FI
  OD
RETURN

PROC Msg1(BYTE ARRAY msg)
  Position (9-msg(0)/2,1) PrintD(6,msg)
RETURN

PROC Msg2(BYTE ARRAY msg)
  Position (9-msg(0)/2,2) PrintD(6,msg)
RETURN

PROC Msg3(BYTE ARRAY msg)
  Position (9-msg(0)/2,3) PrintD(6,msg)
RETURN

PROC Msgclr()
BYTE ARRAY blnks="                  "
  Position(1,1) PrintD(6,blnks)
  Position(1,2) PrintD(6,blnks)
  Position(1,3) PrintD(6,blnks)
RETURN

PROC Msgset(BYTE time)
  tmr(39)=time msgflg=1
RETURN

PROC Msgdly()
  IF msgflg=1 THEN
    IF tmr(39)=0 THEN
      msgflg=0 Msgclr() FI
  FI
RETURN

PROC Playfld()
BYTE j
  Graphics(17) Poke(756,RAMTOP+1)
  Draweggs()
  FOR j=1 TO 18 DO
    Position(j,0) PutD(6,62)
    Position(j,4) PutD(6,62)
    Position(j,23) PutD(6,62)
  OD
  FOR j=0 TO 23 DO
    Position(0,j) PutD(6,62)
    Position(19,j) PutD(6,62)
  OD
  Poke(559,62) Poke(53277,2)
  Poke(708,56) Poke(711,72)
  Poke(710,152)
  Poke(712,32) Poke(709,0)
RETURN

PROC Foxset()
  IF Rand(6)=0 THEN foxflg=1
    tmr(41)=155+Rand(100) FI
RETURN

PROC Crack(BYTE j)
BYTE k,r
  IF stat(j)=1 THEN
    stat(j)=2 Msgclr()
    Msg2("{inv}crack!{/inv}") Msgset(60)
    FOR k=1 to 250 DO
      r=Rand(50) Sound(1,r+50,2,12)
    OD SndRst()
    brkcnt==+1 goodcnt==-1
    IF j=ccpos THEN loseflg=2 FI
  FI
RETURN

PROC Movesun()
BYTE bkgcol,eggcol,r
  IF tmr(36)=0 THEN
    tmr(36)=sunspeed sunpos==+1
    Poke(53250,sunpos)
    IF sunpos MOD 5 =0 THEN
      bkgcol=Peek(712) eggcol=Peek(709)
      IF timeflg=1 THEN
        IF sunpos<100 THEN
          IF bkgcol<35 THEN
            Poke(712,bkgcol+1)
            Poke(709,eggcol+4) FI
        ELSEIF sunpos>175 THEN
          IF bkgcol>32 THEN
            Poke(712,bkgcol-1)
            Poke(709,eggcol-4) FI
        FI
      FI
    FI
    IF (sunpos MOD 3)=0 THEN
      IF sunpos<124 THEN svpos==-1
      ELSE svpos==+1 FI
      IF timeflg=1 THEN
       MoveBlock(pmbase+1536+svpos,sun,14)
      ELSE
       MoveBlock(pmbase+1536+svpos,moon,14)
      FI
    FI
    IF sunpos=200 THEN sunpos=48
      IF timeflg=0 THEN timeflg=1
        Draweggs() sunspeed=10
        IF ccsit=1 THEN winflg=1 FI

        tmr(40)=155+Rand(100)
        snaflg=1 Poke(712,32)
      ELSE timeflg=0 Poke(712,0)
        foxset() sunspeed=5
        IF sitflg=1 THEN
          blkegg(sitpos) FI
        IF Rand(3)=0 THEN
          r=Rand(36) Crack(r) FI
      FI
    FI
  FI
RETURN

PROC Cursor()
  BYTE stkdir,crow=[0],ccol=[0],
       HPOSP0=53248,curspd=[10],j,r
  BYTE ARRAY curs=[24 24 255 24 24]
  IF tmr(37)=0 THEN
    stkdir=Stick(0)
    SetBlock(pmbase+1110+24*crow,5,0)
    IF (stkdir=14) AND (crow>0) THEN
      crow==-1
    ELSEIF (stkdir=13) AND (crow<5) THEN
      crow==+1
    ELSEIF (stkdir=11) AND (ccol>0) THEN
      ccol==-1
    ELSEIF (stkdir=7) AND (ccol<5) THEN
      ccol==+1
    FI
    curpos=6*crow+ccol
    IF timeflg=0 AND stkdir<>15 THEN
      Crack(curpos) FI
    MoveBlock(pmbase+1110+24*crow,curs,5)
    HPOSP0=68+24*ccol tmr(37)=curspd
  FI
RETURN

PROC Snatch1()
BYTE j,p
CARD k
  IF snaflg=1 THEN
    IF tmr(40)=0 THEN snaflg=0
      DO j=Rand(36)
      UNTIL stat(j)=1
      OD
      Msg1("ONE") Msg2("egg mcmuffin!")
      Msg3("PLEASE")
      FOR k=1 TO 400 DO
        Movesun() Spin()
      OD Draw4(j,26)
      FOR p=1 TO 25 DO
        Sound(1,75-p,10,12)
        Movesun() Spin()
        Movesun() Spin()
      OD
      SndRst() Msgset(100)
      Blkegg(j) goodcnt==-1 stat(j)=0
      taken==+1
      IF j=ccpos THEN loseflg=3 FI
    FI
  FI
RETURN

PROC Fox()
BYTE row,col
  IF foxflg=1 THEN
    IF tmr(41)=0 THEN foxflg=0
      Msg1("FOX") Msg2("IN THE")
      Msg3("HENHOUSE!") sndray=foxsnd
      Msgset(200) sndflg=1
      WHILE sunpos<150 DO
        row=5+Rand(15) col=1+Rand(15)
        Position(col,row) PrintD(6,"{inv}^_^_{/inv}")
        tmr(42)=30+Rand(100)
        DO Movesun() Snd()
        UNTIL tmr(42)=0
        OD Position(col,row)
        PrintD(6,"    ")
        tmr(42)=30+Rand(100)
        DO Movesun() Snd()
        UNTIL tmr(42)=0 OD
      OD
      Shuffle(goodcnt,brkcnt)
      Fillpnt() Draweggs() sitflg=0
    FI
  FI
RETURN

PROC Hensit()
BYTE savest,key
  key=Peek(764)
  IF key=33 AND timeflg=1 THEN
    IF sitflg=0 THEN sitflg=1
      savest=stat(curpos) stat(curpos)=3
      Draw4(curpos,54) sitpos=curpos
      IF savest=2 THEN
        Msgclr() Msg2("{inv}YUCH!!{/inv}")
        Sound(1,111,12,14) tmr(43)=40
        DO Spin() Movesun()
        UNTIL tmr(43)=0 OD
        SndRst() Msgclr() FI
      IF curpos=ccpos THEN ccsit=1 FI
      Poke(764,255)
    ELSE
      sitflg=0 stat(sitpos)=savest ccsit=0
      IF savest=1 THEN
        Egg(sitpos,dir(sitpos))
      ELSEIF savest=2 THEN
        Draw4(sitpos,18)
      ELSE Blkegg(sitpos) FI
      Poke(764,255)
    FI
  FI
RETURN

PROC Lose()

  IF loseflg>0 THEN sndray=losesnd
    sndflg=1 Msgclr() FI
  IF loseflg=1 THEN
    Msg1("{inv}YOU{/inv}") Msg2("SCRAMBLED")
    Msg3("CHARLIE!")
  ELSEIF loseflg=2 THEN Msg1("{inv}charlie{/inv}")
    Msg2("{inv}got{/inv}") Msg3("{inv}cracked!{/inv}")
  ELSEIF Loseflg=3 THEN
    Msg2("CHARLIE") Msg3("GOT TAKEN!")
  FI
  Msgset(255)
  DO
    Msgdly() Snd()
    IF msgflg=0 THEN
      Msg2("{inv}press START{/inv}") FI
  UNTIL CONSOL=6
  OD
RETURN

PROC Score()
BYTE total
  PutD(6,125) Poke(756,224)
  PrintDE(6,"*** {inv}final score{/inv} ***")
  PutDE(6)
  PrintDE(6,"starting pnts  100")
  PutDE(6)
  PrintD(6,"-2 * SPINS   -")
  PrintBD(6,spincnt*2) PutDE(6)
  PrintD(6,"-3 * CRACKED -")
  PrintBD(6,brkcnt*3) PutDE(6)
  PrintD(6,"-3 * TAKEN   -")
  PrintBD(6,taken*3) PutDE(6)
  total=100-2*spincnt-3*brkcnt-3*taken
  PrintD(6,"{inv}FINAL SCORE ={/inv}")
  PrintBD(6,total) PutDE(6) PutDE(6)

  PrintD(6,"  press {inv}start{/inv}")
  DO Snd() UNTIL CONSOL=6 OD
RETURN

PROC Win()
BYTE row,col,r
BYTE ARRAY hearts=[251 219 123 91]
  Poke(709,14) FOR r=0 TO 35 DO
    Blkegg(r) OD
  Msg1("{inv}charlie{/inv}") Msg2("{inv}is{/inv}")
  Msg3("{inv}hatched{/inv}!") tmr(42)=255
  sndray=straw sndflg=1
  DO
    row=5+Rand(17) col=1+Rand(18)
    Position(col,row) r=Rand(10)
    IF r<4 THEN PutD(6,hearts(r))
    ELSE PutD(6,32) FI
    IF tmr(42)=1 THEN
      Msg1("{inv}OPTION{/inv} for {inv}score{/inv}")
      Msg2("    ")
      Msg3("{inv}START{/inv} to play")
    FI
    IF sndflg=0 THEN sndflg=1 FI
    Snd()
  UNTIL CONSOL=6 OR CONSOL=3
  OD
  IF CONSOL=3 THEN Score() FI
RETURN

PROC Main()
Init() Title()
DO Begin()
  Shuffle(goodcnt,brkcnt) Fillpnt()

  Playfld() tmr(37)=10
  DO
    Cursor() Spin() Movesun() Hensit()
    Startspin()
    Snatch1() Msgdly() Fox()
  UNTIL loseflg>0 OR winflg>0
  OD
  IF loseflg>0 THEN Lose()
  ELSE Win() FI
OD
RETURN

Play Charlie Chicken