www.jupiter-ace.co.uk

Previous Page > Listings Index > Forth surround Your Computer June 1983


Forth surround
by A R Weaver
THIS PROGRAM for the unexpanded Jupiter Ace is the legendary Surround program translated into Forth with sound and high-resolution graphics. Your task is to control the man who runs around the screen trying to avoid the randomly-produced blocks which appear next to him. You must avoid having to run into a block for as long as possible and the computer keeps count of how many times you have moved. My best is 207.
A hint: try to stay in one area as long as it is safe in order to fill up as much of that part of the screen as possible.
There are three variables : a, which is your position on the screen; s, which is used to produce the random numbers; and sc which keeps count of your moves.
The words ss and rnd produce a random number. Set draws a boundary around the screen; fin is the end of the game.
Mv moves your man around the screen and check to see if you have hit a block, bk prints a block randomly next to you on the screen. Go sets up the variable and uses a Begin-Until loop to continuously keep the game going until it reaches fin. Man stores the data for the character; game starts the game.

0 variable a
0 variable s
0 variable sc

: ss
  s @ 75 u* 75 0 d+ over over u< - - 1- dup s ! ;

: rnd
  ss u* swap drop ;

: set
  cls
  31 1 do 1 i at 160 emit 20 i at 160 emit loop
  21 1 do i 1 at 160 emit i 30 at 160 emit loop ;

: fin
  20 200 do i 100 beep -10 +loop
  10 1 do 1 a @ c! 999 1 do loop
  129 a @ c! 999 1 do loop loop
  cls 10 10 at ." Score:" sc @ . abort ;

: mv begin inkey dup 0= if drop 0 else 1 then until
  100 100 beep 32 a @ c! dup dup dup
  53 = if a @ 1- a ! then
  54 = if a @ 32 - a ! then
  55 = if a @ 32 + a ! then
  56 = if a @ 1 + a ! then
  a @ c@ 160 = if fin then
  sc @ 1+ sc ! 1 a @ c! ;

: bk 4 rnd dup dup dup
  0= if 160 a @ 1+ c! then
  1 = if 160 a @ 1- c! then
  2 = if 160 a @ 32 + c! then
  3 = if 160 a @ 32 - c! then
  400 50 beep ;

: go 9550 a ! 0 sc ! set 1 a @ c!
  begin bk mv 2000 1 do loop 0 until ;

: gr 8 * 11263 + dup 8 + do i c! -1 +loop ;

: man 24 24 60 90 219 24 36 102 1 gr ;

: game man go ;

game


You can down load surround as a wav, Ace and tap file.