The Museum of HP Calculators


Space War for the HP-67

This program is Copyright © 1976 by Hewlett-Packard and is used here by permission. This program was originally published in the HP-67 Games Pac.

This program is supplied without representation or warranty of any kind. The author and The Museum of HP Calculators therefore assume no responsibility and shall have no liability, consequential or otherwise, of any kind arising from the use of this program material or any part thereof.

Card Labels

Space War 1

Shift

->Days

 

 

 

 

Label

Start: s->

       

Long Scan

   

Move: thetaEnt r->

Key

A

B

C

D

E

Card Labels

Space War 2

Shift

->En.Torp

       
Label

Short Scn

       

Torp: theta->

Phaser: EN->

Dock

Key

A

B

C

D

E

Overview

You are the commander of the Nuclear Powered Reconnoiterer (NPR) Kittyhawk. The NPR Kittyhawk is the sole guardian of justice in a vast galaxy that measures 10 quadrants by 10 quadrants. Within the galaxy somewhere, anchored among the blazing stars, lie three agents of evil: the vile Alglogs, known throughout space as interstellar thieves and creators of cosmic mischief. Your mission as commander of the NPR Kittyhawk is to search out and destroy the fearsome Alglogs within 18 stardays.

Also within the galaxy somewhere is a Base, a haven to which your ship may return in order to resupply itself. The weapons carried by the Kittyhawk are torpedoes, which are fired in a straight line, and phasers, which send out an omnidirectional burst of energy. In addition, your starship is equipped with short- and long-range sensors which can detect the presence of Alglogs or the Base in nearby space. One starday is used whenever the Kittyhawk changes its position, i.e., when a move is made. Details of the operation of the NPR Kittyhawk are given below.

POWER ON (Card 1)

The Kittyhawk is started by supplying a seed s (0 <=s <=1) to the routine START (Card 1). This routine positions the three Alglogs, the Base, and the Kittyhawk randomly in the galaxy. For best results, the seed s should contain all the digits but 0 and end in a 1, 3, 7, or 9. Remember that the galaxy is a 10 x 10 grid of quadrants; within each quadrant is a 10 x 10 grid of smaller areas called sectors. The quadrants are numbered 00 through 99, as are the sectors. The position of an object, then, may be specified by giving its quadrant and sector (QQ.SS). Examples of allowable positions are 23.68, 10.99, 7.01, and 85.00. No two objects may occupy the same position. At the end of the routine START, the calculator displays the starting position of the NPR Kittvhawk.

LONG-RANGE SCAN (Card 1)

The long-range scan covers all quadrants adjacent to and including that of the Kittyhawk itself. This scan will detect and report the presence of Alglogs or the Base in those quadrants. Suppose objects are located in the quadrants as below.

Long Range Scan

The long-range scan would include the quadrants adjacent to quadrant 53 (Q53). The output of the scan would be three lines as follows:

63.00400401
53.10400400
43.00400400

The first line shows the contents of quadrants 62, 63, and 64. Two digits are allocated to each quadrant, with the "4's" merely indicating separation of the quadrants. The Base would appear in the right-hand of the two digits, an Alglog in the left-hand digit. Notice that the Base appears in the top line (Q64) and an Alglog in the second line (Q52). The Alglog in quadrant 65 is beyond the range of the sensors and does not show up. The numbers 63, 53, and 43 refer to the middle quadrant of each line.

The contents of nine squares are displayed with each long-range scan. If the Kittyhawk is at or near the edge of the galaxy, some of this information may be meaningless.

MOVE (Card 1)

If the Kittyhawk were in the position shown in the long-range scan above, a logical move would be to go to quadrant 52 to attack the Alglog. To make a move, one specifies the angle theta and distance r to be covered. Orientation of angles is shown in the diagram below. Angles must be input in degrees.

Directions

The distance is specified in terms of quadrants. To move exactly one quadrant's width, specify an r of 1. To move from Q53 to Q52, then, select theta = 180° and r = 1. Suppose one wished to move from Q53 to Q64. This would require an angle of 45° and a distance of SQRT(2) The output at the end of the move routine is the Kittyhawk's new position.

Each move uses 1 starday. If a move is taken when no stardays remain, the display will flash zeros to indicate that the mission has failed.

Caution must be observed near the edges of the galaxy. Moving beyond an edge can result in the Kittyhawk's being lost in space.

SHORT-RANGE SCAN (Card 2)

The short-range scan gives a detailed picture of the quadrant the Kittyhawk is presently in. The output is 10 lines of information output by PRINTx commands, each line representing a row of the quadrant. The rows are output in the order 9, 8, 7, ..., 0. Each line consists of 10 digits that represent the ten sectors in the row. A "0" in a line means that that sector is unoccupied; a "3" marks the location of the Kittyhawk, a "4" an Alglog, and a "7" the Base. Suppose the output of a short-range scan were as shown below:

	Row 9	0.000000000
	Row 8	0.040000000
	Row 7	0.000000000
	Row 6	0.000000000
	Row 5	0.000000003
	Row 4	0.000000000
	Row 3	0.000000000
	Row 2	7.000000000
	Row 1	0.000000000
	Row 0	0.000400000

This scan indicates the presence of Alglogs in sectors 04 and 82, the Kittyhawk in sector 59, and the Base in sector 20.

TORPEDO (Card 2)

The Kittyhawk begins its mission with 3 torpedoes. A torpedo may be fired at an Alglog within the same quadrant. If the torpedo passes within 1° of the Alglog, the Alglog is destroyed and the torpedo is spent. To fire a torpedo, simply specify the angle of fire in degrees.

If no torpedoes remain and you attempt to fire a torpedo, the display will show "Error."

PHASERS (Card 2)

At the start of the mission, 1000 units of energy are available for firing phasers. Unlike torpedoes, phasers fire equally in all directions and can destroy as many Alglogs as are within range. Only Alglogs within the same quadrant as the Kittyhawk may be fired on. The closer the Alglog, the less energy is required to destroy it. A minimum of 105 units and a maximum of 275 units may be needed to destroy an Alglog. To fire phasers, simply specify the amount of energy to be used.

Whenever an Alglog is fired on with phasers, there is a danger that the fire will be returned. Accordingly, the Kittyhawk uses another 100 units of energy to maintain shields against each Alglog within the quadrant.

If more energy is needed than is available, flashing zeros will be displayed to indicate that the mission has failed.

DOCK (Card 2)

The Kittyhawk may dock at the Base by moving into a sector adjacent to that of the base and executing the routine DOCK. If the docking is successful, the Kittyhawk's supply of torpedoes and energy are replenished to their initial level: 3 torpedoes, 1000 units of energy. The display at the end of this routine shows the current supply of energy and torpedoes.

STATUS

Two routines are available for providing information on the status of the mission. Either of these routines may be executed at any time.

The first, on card 1, shows the number of days remaining in the mission. Simply press f A and the number of days will be displayed.

The second, on card 2, shows the remaining energy and torpedoes. Both values are output in a single display as Energy.Torpedoes. For example, a supply of 500 energy units and 2 torpedoes would be displayed as 500.2. This information is available by pressing f A on card 2.

Reference:
This program is based on an HP-65 Users' Library program written by Lee Gregory, Jr.

Instructions

Step

Instructions

Input Data/Units

Keys

Output Data/Units

1

Load side 1 and side 2 of Space War 1

     

2

To Initialize, key in a seed (0<= seed <=1). Output is the starting position of the Kittyhawk

 seed

A

QQ.SS

3

You have 18 stardays. Your options are outlined below.  Be sure the appropriate card is loaded for each option.

 

 

 

 

Long Range Scan (card 1)

 

 

 

 4

Output 3 lines of scan. KH is in center. QQ refers to middle quadrant of each line. Digits AB refer to Alglogs and Base.

 

C

QQ.AB4AB4AB

  Move (card 1)    

 

5

 Key in direction and distance (in quadrants) of desired move; output new position of Kittyhawk. (Flashing zeros means all stardays used; mission failed.)

directiontheta

ENTER

 

distance (r)

E

QQ.SS

  Short Range Scan (card 2)      

6

Output 10 rows of present quadrant in order 9, 8, ..., 0. Kittyhawk = 3, Alglog = 4, Base = 7

 

A

x.xxxxxxxxx

  Torpedo (card 2)    

 

7

To fire a torpedo, key in angle of fire; output number of Alglogs remaining. ("Error means no torpedoes remain.; use phasers.)

directiontheta

C

# Alglogs 

  Phaser (card 2)      

8

To fire phasers, key in units of energy expended in fire; output number of Alglogs remaining. (Flashing zeros mean all energy used; mission failed.)

energy

D

# Alglogs 

   Dock (card 2)    

 

9

You may dock from any square adjacent to Base. Output is present Energy.Torpedoes.

 

E

En.Torps

  Status      

10

With card 1, display number of days remaining

(card 1)

f A

Days

11

With card 2, display present Energy.Torpedoes

(card 2)

f A

En.Torp  

Example

From the log of the NPR Kittyhawk:
Load side 1 and side 2 of Space War 1.

Keystrokes                     Outputs
.63154897 A                      50.53      (KH position)
C                          60.00400400 ***
                           50.00400400 ***  (long Scan)
                           40.00400400 ***

Current map of the galaxy:
map

Dots indicate quadrants known to contain neither Alglogs nor Base.
Move in direction -45°.

Keystrokes                     Outputs
45 CHS ENTER
5.5 E                            14.62     (new position)
C                          24.00400400 ***
                            4.00400401 *** (Long scan)
                            4.00400410 ***

Current map of the galaxy:

map

Move to Q05 to attack.

Keystrokes                   Outputs
45 CHS ENTER 2 SQRT E           5.62 (Now in Q05)
Load side 1 and side 2 of Space War 2.
A                        0.000000000 *** (short scan)
                         0.000000000 ***
                         0.000000000 ***
                         0.030000000 *** (KH in S62)
                         0.000000000 ***
                         0.000000000 ***
                         0.000000000 ***
                         0.000000000 ***
                         0.000000000 ***
                         0.004000000 *** (Alglog in S03)

Current map of the galaxy:

map

Fire a torpedo in direction -80

Keystrokes                   Outputs
45 CHS C                 2.000000000     (2 Alglogs left)

The Program (Card 1)

LINE  KEYS
001  *LBLA      Initialize 
002   CLRG      If seed = 0, use PI
003   X=0?
004     Pi
005   STO9
006      1
007      0
008   STO4
009      2      Point to RA and prepare to compute random
010      0      starting positions
011   STOI      (The I is case sensitive!)

012  *LBL9      --------------------------------
013   GSB1      Compute a position.  Check not 
014   GSB8      occupied
015    F2?
016   GTO9
017   STOi      Store Position (Note STOI is different than STOi)
018   ISZI
019   RCLI
020      2
021      5      Exit loop after filling RE
022   X!=Y?
023   GTO9
024    EEX
025      3
026   STO6      Energy = 1000
027      3
028   STO7      Torpedoes = 3
029   STO9
030      1
031      8
032   STO8      Days = 18
033   RCLE      Display position of Kittyhawk
034    RTN      --------------------------------

035  *LBL1      Generate one starting position in the 
036   RCL9      form QQ.SS where WW is the quadrant and
037      9      SS is the sector
038      9
039      7
040     x
041    FRC
042   STO9
043    EEX
044      4
045     x
046    INT
047   GSB5
048   GSB5
049    RTN      --------------------------------

050  *LBL8      Routine tests to see if position in X-register
051   RCLA      is already occupied
052   X=Y?
053    SF2
054    CLX
055   RCLB
056   X=Y?
057    SF2
058    CLX
059   RCLC
060   X=Y?
061    SF2
062    CLX
063   RCLD
064   X=Y?
065    SF2      Set flag 2 is position is occupied
066   roll dn
067    RTN      --------------------------------

068  *LBLC      Long Scan
069      4
070    FIX
071      9
072      9
073      9      Store constant 0.00400400
074     ÷
075   STO2
076   DSP8
077    SPC
078   RCLE
079    INT
080   STO0
081   RCL4
082     +       Scan line above KH
083   GSB3
084   RCL0
085   GSB3      Scan line with KH
086   RCL0
087   RCL4
088     -       Scan line below KH
089   GSB3
090    RTN      --------------------------------

091  *LBL3      Routine scans one line, i.e., 3 quadrants
092   RCL2
093   STO1
094   roll dn
095   STO3
096   ST+1      R1=QQ.00400400,
097      1      where QQ refers to the middle quadrant
098     -
099   GSB0
100   GSB5
101   GSB5      First Quadrant
102   ST+1
103   RCL3
104   GSB0
105    EEX
106      5      Middle Quadrant
107     ÷
108   ST+1
109   RCL3
110      1
111     +
112   GSB0
113    EEX
114      8      Last Quadrant
115     ÷
116   ST+1
117   RCL1
118   PRTX      Print line
119    RTN      --------------------------------

120  *LBL0      Routine checks one quadrant for presence of Alglogs
121      0      or base
122   STO5
123   roll dn
124   RCLA
125    INT      Forms a two-digit number AB, where A is no. of
126   X=Y?      Alglogs, B no. of Bases in quadrant
127   GSB1
128    CLX
129   RCLB
130    INT
131   X=Y?
132   GSB1
133    CLX
134   RCLC
135    INT
136   X=Y?
137   GSB1
138    CLX
139   RCLD
140    INT
141   X=Y?
142   GSB2
143   RCL5
144    RTN      --------------------------------

145  *LBL1      Alglog detected - add 10 to R5
146   RCL4
147   ST+5
148    RTN      --------------------------------

149  *LBL2      Base found - add 1 to R5
150      1
151   ST+5
152    RTN      --------------------------------

153  *LBLE      Move
154    ->R      Convert(r,theta) to (delta x, delta y)
155    FIX
156   DSP1
157    RND
158   STO0      delta Qx.delta Sx
159   X<>Y
160    RND      delta Qy.delta Sy
161   DSP2
162   RCLE
163   GSB5
164   STO3
165    INT
166   RCLE
167   GSB4
168   STO2
169    INT
170   GSB5
171    FRC
172     +       Qy.Sy
173     +       (Qy + delta Qy)*(Sy + delta Sy)
174    FRC
175   LSTX
176    INT
177   GSB4
178     +       Qy O.Sy (new Y-position)
179   RCL2
180    FRC
181   RCL3
182    FRC
183   GSB4
184    INT
185     +       Qx.Sx
186   RCL0
187     +       (Qx + delta Qx)*(Sx + delta Sx)
188    INT
189   LSTX
190    FRC
191   GSB5
192     +       Qx.OSx

193  *LBL7      --------------------------------
194     +       QyQx.SySx (QQ.SS)
195   GSB8      Test not occupied
196    F2?
197   GTO0
198   STOE
199      1
200   ST-8      Decrement number of days remaining
201   RCL8
202   X<0?      If negative,, game over
203   GTO6      Otherwise display new position
204   RCLE
205    RTN      --------------------------------

206  *LBL6      Ran out of days-flash zeros
207    CLX
208    PSE
209   GTO6      --------------------------------

210  *LBL4      Multiple by 10
211   RCL4
212     X
213    RTN      --------------------------------

214  *LBL5      Divide by 10
215   RCL4
216     ÷
217    RTN      --------------------------------

218  *LBL0      Position occupied - add 0.1 and
219      .      try again
220      1
221   GTO7

222  *LBLa      --------------------------------
223   RCL8      Display Remaining Days
224    RTN

The Program (Card 2)

LINE  KEYS
001  *LBLA      Short Scan
002    FIX
003   DSP9
004    SPC      A "3" marks KH, "4" marks Alglog
005   P<>S      "7" marks base
006      9
007   STOI      (NOT STOi!)
008      0      --------------------------------

009  *LBL9      Clear RS0-RS9 to hold scans or rows 0-9
010   STOi      respectively
011   DSZI
012   GTO9
013   STO0
014      3
015   RCLE      Locate Kittyhawk in quadrant
016   GSB0
017      4
018   RCLA      Check Alglog 1
019   GSB0
020      4
021   RCLB      Check Alglog 2
022   GSB0
023      4
024   RCLC      Check Alglog 3
025   GSB0
026      7
027   RCLD      Check for base
028   GSB0
029      9
030   STOI

031  *LBL8      --------------------------------
032   RCLi      Print RS9,RS8, ..., RS0 as rows 9,8, ..., 0
033   PRTX
034   DSZI
035   GTO8
036   RCL0
037   PRTX
038   P<>S
039    RTN      --------------------------------

040  *LBL0      Routine tests whether an object is in KH's
041   ENTER     Quadrant
042    INT
043   RCLE
044    INT      If not, return
045   X!=Y?
046    RTN
047   roll dn   If so, locate 3, 4, or 7 in proper sector
048   roll dn   of proper row, represented by RS0-RS9
049    FRC
050   GSB5
051    INT
052   STOI
053    CLX
054   LSTX
055    FRC
056   GSB5
057    CHS
058    10X
059     x
060   ST+i
061    RTN      --------------------------------

062  *LBLC      Torpedo
063    CF0
064   STO0      Save angle
065   RCL7
066      1      If no torpedoes remain, display "Error"
067   X>Y?
068   GTOB      Otherwise subtract one from number of torpedoes
069     -
070   STO7
071      1
072      9
073   STOI
074   GSB1      Check is Alglog 1, 2, and 3 are in the path of the
075   GSB1      Torpedo
076   GSB1
077   RCL9      Display number of Alglogs left
078    CF0
079    RTN      --------------------------------

080  *LBL1      Routine tests if Alglog will be hit by torpedo
081   ISZI
082    F0?      If F0 set, an Alglog has been hit - return
083    RTN
084   RCLi      If Alglog not in same quadrant as KH return
085    INT
086   RCLE
087    INT
088   X!=Y?
089    RTN
090   GSB7      Find angle to Alglog
091   CLX
092   RCL0      Compare angle of fire
093     -
094    ABS
095      1      If Alglog 1 degree or more away - no hit
096   X<=Y?
097    RTN
098      1      If hit, store -1 as Alglog's position
099    CHS
100   STOi
101    SF0      F0 set to indicated torpedo is spent
102      1
103   ST-9      Decrement number of Alglogs
104    RTN      --------------------------------

105  *LBL7      Routine finds angle and distance from
106   RCLi      KH to alglog
107    FRC
108   GSB5
109   STO1
110    INT
111   RCLE
112    FRC
113   GSB5
114    INT
115     -
116   RCL1
117    FRC
118   RCLE
119   GSB5
120    FRC
121     -
122   GSB5
123    ->P      Return r in X, theta in Y
124    RTN      --------------------------------

125  *LBLD      Phaser
126   STO0      Save energy ans subtract from total
127   ST-6
128      1
129      9
130   STOI
131   GSB4      Check is Alglog 1, 2, and 3 are in range
132   GSB4
133   GSB4
134   RCL9      Display number of Alglogs left
135    RTN      --------------------------------

136  *LBL4      Test is Alglog hit by phaser
137   RCL6
138   X<0?
139   GTO6      If energy < 0, exit
140   ISZI
141   RCLi
142    INT      If Alglog not in KH's quadrant, return
143   RCLE
144    INT
145   X!=Y?
146    RTN
147    EEX      Deduct 100 for shields
148      2
149   ST-6
150   GSB7      Find distance to Alglog
151   X2 
152    EEX
153      2      Energy input must be greater than
154     +       r2 + 100
155   RCL0
156   X<=Y?
157    RTN
158      1      If hit, store -1 as Alglog's position
159    CHS
160   STOi
161      1
162   ST-9      Decrement number of Alglogs.
163    RTN      --------------------------------

164  *LBL6      Out of energy - flash zeros
165    CLX
166    PSE
167   GTO6      --------------------------------

168  *LBLE      Dock
169   RCLD
170    INT      If base and Kittyhawk not in same
171   RCLE      quadrant, display En.Torp
172    INT
173   X!=Y?
174   GTOa
175   RCLD
176    FRC
177   GSB5
178   STO0
179    INT
180   RCLE
181    FRC
182   GSB5
183   STO1
184    INT
185     -       Kittyhawk must be within 1 sector
186    ABS      of base in Y-direction
187      2
188   X<=Y?
189   GTOa
190   RCL0
191    FRC
192   GSB5
193   RCL1
194    FRC
195   GSB5
196     -
197    ABS      Must also be within 1 sector of base
198      2      in X-direction
199   X<=Y?
200   GTOa
201    EEX      If successful, get 1000 units of energy and 
202      3      3 torpedoes
203   STO6
204      3
205   STO7
206   GTO0      --------------------------------

207  *LBLa      If failed, display old energy and torpedoes
208   RCL6
209   RCL7      --------------------------------

210  *LBL0      
211      1      Form display
212      0      Energy.Torpedoes
213     ÷
214   X<>Y
215    INT
216     +
217    FIX
218   DSP1
219    RTN

220  *LBL5      --------------------------------
221      1      Multiply by 10
222      0
223     X
224    RTN

Register Use (card 1)

R0  Used
R1  Used
R2  Used
R3  Used
R4  10 
R5  Used 
R6  Energy 
R7  Torpedoes
R8  Days
R9  Alglogs
A   Alglog 1
B   Alglog 2
C   Alglog 3
D   Base
E   Kittyhawk
I   Pointer

Register Use (card 2)

R0  Used
R1  Used 
R4  10 
R6  Energy 
R7  Torpedoes
R8  Days
R9  Alglogs
S0  Row 0
S1  Row 1 
S2  Row 2
S3  Row 3
S4  Row 4
S5  Row 5
S6  Row 6
S7  Row 7
S8  Row 8
S9  Row 9
A   Alglog 1
B   Alglog 2   
C   Alglog 3
D   Base
E   Kittyhawk
I   Pointer

Go back to the software library
Go back to the main exhibit hall