
prgmCASTLEA uses the following variables:
  A,B,C - scratch space for prgmZSRL
  D - boolean: Describe current room this turn?
  F - boolean: Front door oiled?
  G - Gloves location (-1=worn, 0=carried, 1..9=dropped)
  H - cHest location (0=carried, 1..9=dropped)
  I - Inventory: 0=none, 1=chest, 2=oil, 3=mask, 4=gloves
  J - boolean: verb takes a noun?; scratch space during movement
  L - boolean: hands are sLippery?
  M - Mask location (-1=worn, 0=carried, 1..9=dropped)
  N - currently selected Noun
  O - Oil location (0=carried, 1..9=dropped)
  P - boolean: something can be Picked up here?
  Q - bitflags: guard status (1=seen you without mask, 2=with mask)
  R - current Room (1..9)
  S - boolean: Side door oiled?
  T - Time counter (0..5 outside, 1..7 inside)
  U - boolean: has Used mask?
  V - currently selected Verb
  W - boolean: Window oiled?

0\->\Xmin:94\->\Xmax
0\->\Ymax:\(-)\62\->\Ymin
AxesOff:FnOff 
PlotsOff :Full
ClrDraw
Horizontal \(-)\9
" : : : : : :\->\Str9
"      
Ans+Ans+Ans+Ans
Ans+Ans+Ans+Ans\->\Str8
DelVar FDelVar SDelVar LDelVar W1\->\R
DelVar IDelVar U1\->\D
DelVar QDelVar T9\->\M:8\->\G:7\->\H:3\->\O

While 1
  max(R={H,O,M,G\->\P
  If D:Then
    Text(1,3,sub("AT GATE  GARDEN   TOOL SHEDAT WINDOWSIDE DOORCORRIDOR TREASURY ARMORY   FOYER    ",9R-8,9),Str8
    If R<4:Then
      "YOU ARE AT THE FRONT OF THE CASTLE. THE DOOR TO THE NORTH IS SHUT. A BUTTON IS NEXT TO THE DOOR.
      If R=2:"THERE IS A SHED IN THE GARDEN'S WEST CORNER.
      If R=3:"THE SHED IS DARK AND CRAMPED.
    Else
      If R<7:Then
        "A WINDOW IN THE CASTLE WALL. PATHS LEAD NORTH AND WEST.
        If R=5:"YOU ARE AT THE SIDE ENTRANCE,  A DOOR TO THE WEST.
        If R=6:"HALLS LEAD IN ALL DIRECTIONS.
      Else
        "THE KING'S TREASURE -- WHAT A MAGNIFICENT SIGHT!
        If R=8:"THE DOOR LEADS NORTH. A WINDOW TO THE SOUTH IS CLOSED.
        If R=9:"FESTIVE STREAMERS ADORN THE FRONT DOOR TO THE SOUTH.
      End
    End
    Ans\->\Str7
    If P:Then
      ":
      If G=R:Ans+"A PAIR OF GLOVES IS HERE. 
      If O=R:Ans+"THERE IS AN OILCAN HERE. 
      If M=R:Ans+"A MASK IS DISCARDED NEARBY. 
      If H=R:Ans+"A HEAVY TREASURE CHEST IS HERE! 
      If Ans\!=\":
      Str7+Ans\->\Str7
      Str7
    End
    If R=5 and not(T:Ans+":A GUARD BLOCKS THE DOOR.
    prgmZSRL
    Lbl V
  End
  P or I or M<0 or G<0\->\P
  Text(57,3,">
  Repeat Ans\!=\".
    Repeat Ans:getKey\->\V:End:".
    If V=51 and P:"DROP
    If V=52:"EAST
    If V=54:"GET
    If V=61:"INVENTORY
    If V=64:"LOOK
    If V=71:"NORTH
    If V=72 and not(O:"OIL
    If V=73 and I>1:"PUT
    If V=73 and (R=1 or R=5:"PUSH
    If V=74:"QUIT
    If V=75:"RESTORE
    If V=81:"SOUTH
    If V=82:Then
      If P:"TAKE
      If R=5 and not(T:DelVar V"TALK
    End
    If V=85:"WEST
    If V=85 and I>2:"WEAR
    If V=93:"WAIT
  End
  Text(57,9,Ans
  Ans\->\Str7
  max(V={0,51,54,72,73,82\->\J
  If V=85:Then
    I>2\->\J
    Lbl N
  End
  Repeat Ans\!=\".
    Repeat Ans:getKey\->\N:End:".
    If N=24:"X
    If N=25:Then
      If V=73:Then
        If I>1:"PUT
        If Str7=Ans and (R=1 or R=5 and not(T:"PUSH
      End
      If V=81:Then
        "SAVE
        If Str7=Ans:"SOUTH
      End
      If V=82:Then
        If R=5 and not(T:DelVar V"TALK
      Else
        If not(V:Then
          82\->\V
          "TAKE
        End
      End
      If V=85:Then
        I>2 and not(J\->\J
        "WEST
        If J:"WEAR
      End
      If Ans\!=\".
      Then
        Ans\->\Str7
        Text(57,9,Ans,Str8
        ".
      End
    End
    If J:Then
      If Str7="PUSH
      Then
        If N=42 and R=1:"BUTTON
        If N=54 and R=5 and not(T:"GUARD
        If N=85 and (R=4 or R=8:"WINDOW
        If N=51 and max(R={1,5,9:"DOOR
      Else
        If N=54:Then
          If Str7="PUT
          Then
            If not(G:"ON GLOVES
          Else
            If G\<=\0 or G=R:"GLOVES
            If V=82 and G<0:"OFF "+Ans
            If not(V:"TO GUARD
          End
        Else
          If V:Then
            If N=65 and (M\<=\0 or M=R:Then
              If Str7="PUT
              Then
                If not(M:"ON MASK
              Else
                If M\<=\0 or M=R:"MASK
                If V=82 and M<0:"OFF "+Ans
              End
            End
            If inString(Str7,"OI
            Then
              If N=42 and R=1:"BUTTON
              If N=85 and (R=4 or R=8:"WINDOW
              If N=51 and max(R={1,5,9:"DOOR
            Else
              If N=72 and (O=R or not(O:Then
                If V\!=\85:"OIL
                If V=73:Then
                  " OIL ON
                  Text(57,21,Ans
                  Str7+Ans\->\Str7
                  ".
                End
              End
            End
            If H=R or not(H:Then
              If N=82:"TREASURE
              If N=43:"CHEST
            End
          End
        End
      End
    Else
      If N=105:" 
    End
  End
  If N=24:Then
    Text(57,9,Str8
    Goto V
  End
  If Ans\!=\" 
  Then
    Str7+" "+Ans\->\Str7
    Text(57,9,Ans
    Repeat Ans=105 or Ans=24
      getKey
    End
    If Ans=24:Then
      sub(Str7,1,inString(Str7," ")-1\->\Str7
      Text(57,9,Ans,Str8
      DelVar DEnd
      Goto N
    End
  End
  ">  "+Str7
  prgmZSRL
  DelVar DText(57,3,Str8
  N(N>30 and N<99
  Ans+(V=93)+39(Ans=43\->\N
  If inString(Str7,"L O
  72\->\V
  If inString(Str7,"T ON
  85\->\V
  V-28(V=82)-inString(Str7,"OF\->\V
  If N:Then
    If not(V:Then
      "THE GUARD GRUMBLES.
      prgmZSRL
    Else
      If V=73:Then
        "DONE.
        If N=42 and not(T:Then
          1\->\T
          "YOU HEAR SOMEONE APPROACHING.
        End
        If N=54:Then
          "YOU PICKED YOUR LAST FIGHT!:YOU LOSE.
          Goto Q
        End
        If N=51:"IT DOESN'T BUDGE.
        If N=51 and R=5 and not(T:"HE WON'T LET YOU NEAR IT!
        prgmZSRL
      Else
**    If V=54:Then
        N={82,72,65,54
        If max(Ans>(R={H,O,M,G:Then
          "YOU ALREADY HAVE IT.
        Else
          If I:Then
            "DROP SOMETHING FIRST.
          Else
            If N=54:0\->\G
            If N=65:DelVar M1\->\U
            If N=72:0\->\O
            If N=82:0\->\H
            "TAKEN.
          End
        End
        prgmZSRL
      Else
***   If V=48:Then
        If I:Then
          Goto D
        End
        If N=54:DelVar GIf 0
        0\->\M
        "OKAY.
        prgmZSRL
      End
***   If V=51:Then
        0\>=\{H,O,M,G
        If max(N={82,72,65,54}>Ans:Then
          "YOU DON'T HAVE IT.
        Else
          Lbl D
          If N=54:R\->\G
          If N=65:R\->\M
          If N=72:R\->\O
          If N=82:R\->\H
          "DROPPED.
        End
        prgmZSRL
      Else
***     If V=85:Then
          If not(G:DS<(G,G
          \(-)\1\->\M
          "YOU PUT ON THE GLOVES.
          If I=3:"NO ONE WILL RECOGNIZE YOU.
          prgmZSRL
        Else
****    If V=72:Then
          If O:Then
            "YOU DON'T HAVE THE OILCAN!
          Else
            "DON'T BE SILLY!
            If N=51 or N=85:Then
              If R=1:"IT DOESN'T NEED OILING. IT'S LOCKED.
              If R=5 and not(T:"HE WON'T LET YOU NEAR THE DOOR!
              If R=4:"IT'S TOO HIGH TO REACH.
              If inString(Ans,"B
              Then
                If L and G\>=\0:Then
                  R\->\O
                  "THE CAN SLIPS FROM YOUR OILY HANDS.
                Else
                 If R=5:1\->\S
                  If R=8:1\->\W
                  If R=9:1\->\F
                  1\->\L
                  "DONE.
                End
              End
            End
            prgmZSRL
          End
        End
      End:End:End
      max({1,2,3,4}not({H,O,M,G\->\I
    End:End
  End

  T+(N and T\->\T
  If N and Ans<2:End

  If not(N:Then
    V-inString(Str7,"SA\->\V
    If max(Ans={71,81,52,85:Then
      T+not(not(T\->\T
      "\pi\00507060
      If V=81:"0000486\pi\\pi\
      If V=52:"41200\pi\006
      If V=85:"2301\pi\9000
      expr(sub(Ans,R,1\->\J
      If fPart(Ans:Then
        If R=1:Then
          "THE DOOR IS LOCKED FROM THE INSIDE.
          prgmZSRL
        End
        If R=6:Then
          "THE GUARD IS BACK. YOU CAN'T EXIT THAT WAY NOW.
          prgmZSRL
        End
        If R=5:Then
          "YOU ENTER THE CASTLE.
          If not(S:"THE DOOR IS RUSTED SHUT!
          If not(T:"HE WON'T LET YOU NEAR THE DOOR!
          prgmZSRL
          If ST:Then
            6\->\R:2\->\T:1\->\D
          End
        End
        If R=8:Then
          If WH:Then
            4\->\R:DelVar T1\->\D
          Else
            "THE CHEST WON'T FIT OUT THE WINDOW!
            If not(W:"THE WINDOW IS RUSTED SHUT!
            prgmZSRL
          End
        End
        If R=9:Then
          ".
          If H:"YOU FORGOT THE TREASURE!
          If not(F:"THE DOOR IS RUSTED SHUT!
          If Ans=".
          Goto W
          prgmZSRL
        End
      Else
        If Ans:Then
          Ans\!=\R\->\D
          J\->\R
        Else
          "YOU CAN'T GO "+Str7+" FROM HERE.
          prgmZSRL
        End
      End
    Else
      If V=61:Then
        "YOU ARE WEARING 
        If G<0:Then
          Ans+"GLOVES
          If M<0:Ans+" AND 
        End
        If M<0:Ans+"A MASK
        Ans+".
        If M<0 or G<0:prgmZSRL
        "NOTHING
        If I=1:"THE KING'S TREASURE
        If I=2:"AN OILCAN
        If I=3:"A MASK
        If I=4:"GLOVES
        "YOU ARE CARRYING "+Ans+".
        prgmZSRL
      End
      If V=64:1\->\D
      If V=74:Then
        "GOODBYE.
        Goto Q
      End
      If V=80:Then
        {0,F,G,H,I,L,M,O,Q,R,S,T,W\->\\L\CASTL
        "SAVED.
        prgmZSRL
      End
      If V=75:Then
        0\->\\L\CASTL(1
        \L\CASTL
        If 13\!=\dim(Ans:Then
          "I CAN'T.
          prgmZSRL
        Else
          Ans(2\->\F
          \L\CASTL(3\->\G
          \L\CASTL(4\->\H
          \L\CASTL(5\->\I
          \L\CASTL(6\->\L
          \L\CASTL(7\->\M
          \L\CASTL(8\->\O
          \L\CASTL(9\->\Q
          \L\CASTL(10\->\R
          \L\CASTL(11\->\S
          \L\CASTL(12\->\T
          \L\CASTL(13\->\W
          1\->\D
        End
      End
    End
  End

  If T<5-(R=1:End

  ".
  If T=5:Then
    If R=1:"THE GUARD TELLS YOU TO GO AWAY.
    If R=5:"THE GUARD RETURNS.
    If R\<=\5:DelVar TIf 0
    "UH-OH! SOMEONE IS COMING!
  Else
    If T=6:"YOU'D BETTER GET OUT OF HERE!
    If T=4:"YOU HEAR GRUMBLING.
    If T=7:Then
      "A GUARD RUSHES INTO THE ROOM. YOU HAVE BEEN CAPTURED!
      prgmZSRL
      ".
      If H=R or not(H:"THIEF
      If Q=3 or M<0=Q-1:"AGAIN
      If 5=length(Ans:Then
        "YOU "+Ans+"... I HOPE YOU LIKE DUNGEONS!:YOU LOSE.
        Goto Q
      End
      Q+1+(M<0\->\Q
      DelVar T1\->\R:1\->\D
      "THE GUARDS KICK YOU OUT.
    End
  End
  If Ans\!=\".
  prgmZSRL
End

Lbl W
"YOU BEAT THE GAME!
If U:"YOU HAVE RECOVERED THE TREASURE!  ...BUT CAN YOU WIN WITHOUT THE MASK?
"CONGRATULATIONS! "+Ans

Lbl Q
prgmZSRL
Pause 
