www.jupiter-ace.co.uk


Listings Index > Antarctica from Personal Computer World August 1983


Personal Computer World August 1983 page 322

Jupiter Ace Antarctica
by David F Corner
Although we're beginning to receive programs written in Forth, and I confidently expect these to arrive in increasing numbers as the popularity of the language grows, 'Antarctica' is the first program I've received that was written on the Jupiter Ace. With the comments omitted, the program just fits into the unexpanded machine.
You are an intrepid explorer off on a little stroll around the South Pole. Unfortunately, you're being pursued by three Yetti look-alikes who enjoy nothing more than tucking into a nice, juicy Antarctic explorer.
Your only hope is to try to trap the Yettis into falling into the freezing water while remaining safely on the ice yourself. You use the numbered keys 1-4 to control your speed, and 5-8 for your direction. Relying on the Jupiter's pixel graphics. the screen display is not quite up to arcade standard but what do you expect in 3k? If you want to up the pace a hit, try running it in FAST mode.
One word of warning: there's no room to perform an EDIT, so if you want to play around with it the author suggests you FORGET RUN, carry out your edit and then type in RUN again.
		
( all numbers are in hex, you should start with : )
16 BASE C!

( data areas contain 8 bytes :
  0,1	increment value - controls speed
  2,3	counter value
  4	x position
  5	y position
  6	x increment
  7	y increment
 one data area for each line     )

CREATE A$ 8 ALLOT 
CREATE B$ 8 ALLOT 
CREATE C$ 8 ALLOT 
CREATE U$ 8 ALLOT

: LD ( loads a data area  


Personal Computer World August 1983 page 323
	parameters 4 data words, data area )
4 0 DO
		DUP >R ! R> 2+
	LOOP
DROP
;

CREATE DL ( array of 4 direction vectors
		each word is a pair of bytes
		byte 0 x increment
		byte 1 y increment
		each byte takes values 0, 1, 2
		representing	-1, 0, 1)
102 ,	( right )
  1 ,	( down  )
100 ,	( left  )
201 ,	( up    )  

123 VARIABLE RS (seed for random number generator
		pick your own favourite number! )  
		
: 4R ( returns a random number
	it will be masked to give only 0,2,4 or 6)
  RS @ 12B9 U*
  SWAP 1+ RS !
;
: IL ( Init a line of the screen )
  EMIT
  1F 1 DO			(NB one-F not IF)
          DUP EMIT
       LOOP
  DROP
  EMIT
;

: IS ( initialise the whole screen )
  CLS
  151 147 20 IL
  16 1 DO
    148 144 21 IL
  LOOP
  18 19  17 IL
;  

( at tis point you can check that you are
  setting up the screen correctly.
  If you type
  INVIS IS
  you should find you have a white screen
  with a black border.
  Don't forget to type VIS before continuing ) 
  
: ?K ( test if a key is depressed
  if so sets direction in U$ )
  INKEY ASCII 1 -
  DUP F8 AND	( test for range 1-8 )
  IF
	DROP
  ELSE
	DUP 4 AND
IF

Personal Computer World August 1983 page 324
		
  DUP DUP + XOR 6 AND
  DL + @		( fetch code from DL )
  U$ 6 +
  OVER OVER @ + 202 =
  IF		( don't allow backwards )
      DROP DROP
    ELSE
      !
    THEN
   ELSE
      1+ 1371 * U$ !	( change speed )
   THEN
  THEN
;

CREATE ?P ( assembly code routine to test
		if a pixel can be unplotted
		input: x-coord y-coord
		returns: flag
		 0: pixel has been changed
		 1: no change
		uses ROM PLOT code)	 

 1 C,    B ,   ( LD BC,000B ) ( NB entered with HL      )
 9 C,          ( ADD HL,BC  ) ( = entry address         )
E5 C,          ( PUSH HL    )
FD C, E3 C ,   ( EX [SP],IY ) ( IY points into code     )
48 C,          ( LD C,B     ) ( BC = 0 meaning unplot   )
C3 C, B4F  ,   ( JP B4F     ) ( enter ROM - will return
                                by JP [IY] )
FD C, El C ,   ( POP IY     ) ( restore original IY     )
AB C,          ( XOR E      ) ( A = 0 if no change      )
C3 C, C1F ,    ( JP C1F     ) ( sets flag and returns   )

0 VARIABLE T
: CC ( data area - flag )
     ( 1: increments the count in the data area
       2: if the count overflows,
          tries to move the line forward
       3: if successful, stores the new screen
          position and returns 0
       4: if the line cannot move forward,
          returns non-zero
       5: if the count did not overflow,
          returns 0  )
DUP @ 0
ROT 2+
DUP >R
@ 0 D+                     ( stack = count,overflow )
SWAP I !
R> SWAP
IF                         ( if there has been overflow ... )
  2+ >R
  I @
  I 2+ @ 101 - +
  T  !                     ( now have new x, new y)
  T C@ T 1+ C@ ?P CALL
  IF                       ( no good )
    R>                     ( address is non-zero )
  ELSE
    T @ R> !


Personal Computer World August 1983 page 325
		
    O                      ( successful call )
   THEN
  ELSE                     ( no overflow )
    0=                     ( always returns 0 )
  THEN

( WARNING ?P and GG are dangerous.
  double check your typing!
  If you get them wrong, you may have to
  power off and on again to restart! )

: MV ( data area - flag )
     ( moves along a line in its set direction.
       if it cannot proceed,
       or at a random point
       a new direction is chosen at random.
       if there is no possible direction,
       the line is dead!
       the flag returns 1 if the line is dead )
  >R I GG
  I 2+ @ RS @ XOR
    7FF AND 0=           ( the random test )
  OR
  IF
    4R >R                ( random start point )
    A  >R                ( counter - goes to zero
                           after all directions tested )
    BEGIN
      R> 2- >R           ( decrement counter )
      I I' + RS C@ XOR
        6 AND            ( select a direction )
      DL + @
      J6 + !             ( store it )
      -1 J 2+ !          ( force overflow in GG )
      J GG 0=
      I 0=  OR           ( stop if good direction )
    UNTIL                ( or count expired       )
   R>
   R> DROP
   IF                   ( count non-zero )
      R> 0=             ( return zero    )
   ELSE
    O R> ! 1            ( set dead and return 1 )
   THEN
  ELSE                  ( normal or already dead )
    R> @ 0=             ( test for dead )
  THEN
;

: RUN                   ( the word to run the complete game )
  IS
  100 163D
    RS @ -7857 - 4763 A$ LD
                 ( there should be a direction change
                   in the middle of this line )
  100 133C 3457 DUP B$ LD
  100 193C 3541 DUP C$ LD
  102 1602 3A55 DUP U$ LD
  BEGIN


Personal Computer World August 1983 page 326
		
  ?K
  A$ MV
  B$ MV AND
  C$ MV AND             ( true only if all three are dead )
  U$ CC OR              ( or you've hit something         )
UNTIL
-1 U$ !
US GG
IF                      ( you're still alive - you win! )
  400
ELSE                    ( you're dead - you lost !      )
  88
THEN
300 BEEP
;


Personal Computer World August 1983 Cover
   Personal Computer World August 1983 page 322

Personal Computer World August 1983 page 323
   Personal Computer World August 1983 page 324

Personal Computer World August 1983 page 325
   Personal Computer World August 1983 page 326



Valid HTML 4.01 Transitional