( "Life" routine 9/27/83 )
forget it
: it ;

1 mode
0 0 10 color
10 vtab 10 htab
print " One moment, please ... "

0 variable noise
0 variable life.seg
400 string life.routine
2000 string tune
0 variable key.pressed

: locate.end 0 tune begin
  dup peek 0 <> while
  3 + repeat ;

: set.repeat
  0 tune ( address of beginning )
  locate.end 1 + ( address of end )
  pokew ; ( put address of beginning at end of music )

: clrkey begin getkey 0 = until ;

: check.key
  getkey if
  1 -> key.pressed then ;

: wait
  0 do
    0 begin
    1 + dup 1075 >
    check.key
    key.pressed
    or until drop
  loop ;

: do.life
  life.seg segment
    key.pressed 0 = if
    noise if 0 tune -> play then
    then
  0 begin
      0 call
      check.key
    1 +
    dup 400 >=
    key.pressed or
  until
  drop
  local segment ;

: life
  pad 126 + peek 78 =
  if 0 else 1 then -> noise
  clrkey
  0 -> key.pressed
  1 mode
  2 -> ax
  0 0 10 color cls
  11 38 9 24 window
  print " The Game of Life " cr cr
  print " Music: Bourree " cr cr
  print " BWV 996 J. S. Bach " cr cr
  print " Images: P. Lutus "
  0 39 0 24 window
  37 4 do
  4 vtab i htab 2 putc
  21 vtab i htab 2 putc
  loop
  22 4 do
  i vtab 4 htab 2 putc
  i vtab 36 htab 2 putc
  loop
  0 life.routine 16 / 1 + 
  dup local + -> life.seg
  16 * 370 memory read " life.com "
  0 tune 1900 memory read " bourree1.mus "
  set.repeat
  10 wait
  do.life
  pad 127 + peek 68 =
  if
  key.pressed if
  read " menu "
  else read " flederm " then
  else 4 mode
  then 0 -> play ;
close run
