www.jupiter-ace.co.uk
Previous Page > Listing Index > Antarctica listing.
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-a likes 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 bit, 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.
On the left a screen shot of the game.

The listing below can be found in the Archive as a tap, wav and txt file.

A PDF of the scanned magazine pages of the listing is also available for download.


: ( ASCII ) WORD DROP ; IMMEDIATE

( The above word removes comments )
( for spooling into an emulator   )
( Not in the original listing     )
( ------------------------------- )
( Antarctica from PWC magazine    )
( ------------------------------- )

( use RUN to start the game      )
( use keys 5 for Left, 6 for Up, )
( 7 for Down and 8 for right     )
( keys 1-4 will change speed     )
( 1 is slowest and 4 is fastest  )

( 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 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 l y increment             )
          ( each byte taken 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
  97 93 14 IL     ( note original ASCII x words )
  16 1            ( where changed into numbers )
    DO            ( for spooling into emulator )
      95 90 15 IL
    LOOP
  12 13 11 IL
;

(  at this 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 -  ( keys 1-8>0-7* )
 DUP F8 AND  ( test for range 1-8 )
  IF
    DROP     ( invalid key* )
  ELSE
    DUP 4 AND ( test keys 5-8*)
    IF
      DUP DUP + XOR 6 AND ( 4>4 5>6 6>2 7>0*)
      DL + @ ( fetch code from DL )
      U$ 6 + ( point to x,y increment *)
      OVER OVER @ + 202 =
        IF ( don't allow backwards )
          DROP DROP
        ELSE
          ! ( new direction* )
        THEN
    ELSE
      1+ 1371 * U$ ! ( key 1-4 change speed )
    THEN
  THEN
;

CREATE ?P     ( assembly code routine to test )
              ( if a pixel can be un-plotted  )
              ( input: x-coord y-coord        )
              ( Q 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 H 0 meaning un-plot  )
 C3 C, B4F , ( JP B4F ) ( enter ROM - will return )
             ( by JP [IY] )
 FD C, E1 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

: GG ( 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 I 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> !
        0                ( successful call  )
      THEN
    ELSE
      0=                ( no overflow       )
    THEN                ( always returns 0  )
;

( Warning ?p and GG are dangerous.       )
( double check your typing!              )
( If you get then 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     )
     ( 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 )
    BEGIN
       R> 2- >R     ( decrement counter      )
       I I' + RS C@ XOR
         6 and      ( select a direction     )
         DL + @
         J 6 + !    ( 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
        0 R> ! 1    ( set dead and return 1  )
      THEN
  ELSE              ( normal or already dead )
    R> @ 0=         ( test of 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
    ?K
    A$ MV
    B$ MV AND
    C$ MV AND
    U$ GG OR
  UNTIL
  -1 U$ !
  U$ GG
  IF
    400
  ELSE
    88
  THEN
  300 BEEP
;

PCW cover page August 1983   page 232

page 233   page 234

page 235   page 236