U-BOAT HUNT
by Rod Hopkins
from Your Computer, August 1983


SUBMARINE MISSION

You are on the bridge of your submarine when radar picks up an
enemy U-boat recharging on the surface. Destroy it before it
destroys you in Rod Hopkins' fight to the finish.



Two submarines seek each other's destruction in this tough and tense
World War Two scenario. I certainly do not find it easy to make a
kill, with all the advantage of inside information.

A Second World War S-type submarine was a fairly small craft which
could manage about 16 knots on the surface and about nine knots
submerged. Radar might well have been on board, certainly Asdic and
echo sounder. Optimum periscope depth was about 34 feet. Surfacing and
submerging was managed with the two pairs of hydroplanes and a number
of ballast tanks. Hydroplanes were simply balanced horizontal rudders
which used engine power to deflect the course of the submarine upwards
or downwards.

There are three major displays: first, the control room; to the left
of the display is the main ballast tank indicator, filled or vented to
alter buoyancy. Below is a representation of the forward starboard
hydroplane. Common sense will tell you which inclination will help the
boat to rise. Next to the hydroplane tell- tale is a digital depth
indicator. The large wheel to its left is one of the type which used
to be needed to adjust the hydroplanes.


Raise periscope

In the centre, the periscope can be raised and lowered. For our
purposes, it must be up in order to look through it. A panel of
digital readouts displays rudder angle, heading, engine revs and
battery charge in that order. The battery is automatically charged on
the surface, incidentally. Care should be taken when submerged, that
sufficient charge always remains to resurface.

Beside the panel, another instrument shows whether diesel or electric
motors are in use, and flashes a warning if the boat begins to go
under with the diesels running. The torpedo count, top right, is
self-explanatory. Our Asdic set displays a north-up true bearing for
targets within a four-mile range. It comes on automatically at depths
greater than 10 feet. On the surface, the radar set is switched on
instead. It has a greater range - 22 miles - and again is a north-up,
PPI display, on which each sweep of the antennae is seen. Finally, the
echo-sounder indicates the depth of water below the keel. Thus, if the
boat is rising, the trace falls, as it does when the submarine remains
level while the sea-bottom shelves off. It reads from 200 feet up to
zero.

[See Fig.1 Seabed contour chart - U-BOAT.GIF]

The second display shows the chart room: this is really part of the
control room; when accessed, the control room proper slides across,
making room for the chart display as it goes; this simulates the
skipper walking across to the chart table. Sounder and Asdic sets both
remain in view, now on the left, and both continue to work. On the
chart itself, apart from local coastline, there is a large compass
rose, the boundaries of a continuous coastal minefield - m - and a
longitude - latitude grid calibrated at bottom and right. Inverse
figures give degrees, the others, minutes.

For simplicity's sake, a minute is taken to be a nautical mile on both
axes. At the top left of the chart, a short line radiating from a
small circle points in the direction of the tidestream. Your own
position is pointed to by a miniature submarine - at the left- hand
end. Below the chart can be found tide strength, speed through the
water, and the enemy's reported position at the start of the game. The
enemy is always surfaced for the solo game, and always starts off from
some point on the eastern side of the chart, steaming a course with a
lot of west in it, at a random speed up to about four knots. Your own
position is not updated while the chartroom is accessed.

The third display shows the periscope view: this shows as a framework,
the brass flange surrounding the periscope viewing window. Below, a
panel gives updated readings of periscope angle, heading, enemy
distance and torpedo count.

Taking these in order: the periscope may be rotated full circle, and
the angle indicated relates to the keel, reading 0 when the periscope
is looking along the bows. Heading is simply the direction in which
the vessel is pointing, and not necessarily the direction in which it
is actually moving. Enemy distance is read from the radar; life would
be quite difficult without it. Torpedo count keeps track of torpedoes
running, since salvos may be fired. Salvos must be fired in line,
spread in time, not angle. Torpedoes run at 45 knots, and have a range
of three miles, being fired only through bow tubes. If the periscope
angle is other than zero on firing, it will automatically swing to,
and lock on zero.


Torpedoes running

The rest of the display also locks until a torpedo strikes home, or
until all have run themselves out. If a miss has clearly been made,
the salvo may be aborted. A bubble track gives some indication of the
progress of torpedoes, though not giving any actual position for the
torpedo, of course. Torpedoes cannot be fired unless the rudder is
straight and the boat is maintaining a steady depth less than or equal
to maximum periscope depth. The latter ranges from zero to about 37
feet, the horizon rising up the window as the submarine sinks.

From such a low vantage point as another submarine, and in potentially
hostile waters, all you can hope to spot is the conning tower of an
enemy U-boat. This conning tower varies in size with distance, and
moves in high resolution, flicker-free increments along the horizon
according to the relative motions of the two subs. Range of vision is
affected by the depth of the viewer.

A fourth display is the boot-up screen. This stems from an early idea,
since abandoned, to allow the skipper to carry out a simulated sextant
reading to establish his own position.

And now to business, Commander. Screen constructions: figure 3 gives
three listings required to build up the major displays. The
recommended procedure is as follows: in turn, type in and run each
listing, saving the result as a screen$ on tape, along with the
construction program itself. The latter is not needed directly, but is
worthwhile saving in case of problems, or to satisfy a later craving
for customising. Consult figure 2 to discover the final destination of
each display. When the time comes to load them into their proper
places, a command of this type:
	LOAD "" CODE ADDRESS
will load any of the screen$ into the address specified, rather than
into the screen RAM. Note that, in the case of both the control room
and the chartroom, the machine-code paint routine must be present in
line 1 of the construction program; it could be entered separately and
merged with each listing in turn. The routine is worth keeping as a
utility in its own right, anyway. Referring now to the periscope print
routine in the control room listing, the strings of letters A-N are
all of graphic-shifted characters, of course.

Machine code and tables: see figure 5. Clear 60415 before entering
anything, and then use the loader routine of figure 4 to enter each
block in turn. Save intermediate stages on tape and reload before
starting again:
	SAVE "FILENAME" CODE 60416,5120
When this little task has been accomplished and the results saved,
then, with the machine code resident in RAM, type:
	CLEAR 32767
and load each of the three screen displays into their allotted spaces
using the procedure outlined earlier. Save the total as:
	SAVE "Uboat CODE" CODE 32786,32768
There is a 6K + gap; it is more convenient to load the 32K block in
toto. The gap is used as a dynamic store for the control room display.

Basic: figure 6 gives the main Basic program which should be saved on
tape immediately following the 32K of code. Do not forget to verify at
any stage at which a significant amount of labour would be wasted in
the event of a saving problem. Make the Basic autorun by typing:
	SAVE "UBOAT HUNT" LINE 1

Finally, concoct a short header-cum-loader program displaying your
family crest or whatever, making sure it ends with these lines:
	200 PAPER 0: INK 7: BORDER 0: CLEAR 32767
	210 LOAD "" CODE: LOAD ""
Save the loader, in autorun mode, in a space conveniently left before
the 32K block of code on tape.

A small word of warning; do not try running anything without securing
it on tape first. The most piffling error in a lot of the machine code
could prove devastating. In the Basic program, moreover, check the
initialisation routine - lines 9900 onwards carefully, as in some
cases even the order of assignment of variables is critical. Do not
delete any variables because they apparently appear only in this
routine. They are used by the machine-code routines, in all
likelihood.

In a later issue I hope to publish details of program additions needed
to use the program on two linked computers, and also of the modest
hardware involved. The age of networking fast approaching, it would
seem an obvious and exciting direction for home computing to branch
into. Copies of this program are available on cassette from Protech
for #5.99. Also included on the tape is the two-computer version for
which you will need extra hardware. Protech is at [address removed],
Scotland.


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Table 1. Keyboard controls.

Key	Function
---	--------
5	rudder left
6	hydroplane down
7	hydroplane up
8	rudder right
A	abort salvo
B	blow ballast
C	go to chartroom
E	electric motors on/off
F	fire second and subsequent torpedoes
I	decrease periscope angle by six degrees
J	decrease revs
K	increase revs
N	flood tanks (negative buoyancy)
O	increase periscope angle 36 degrees
P	periscope up/down
T	prime torpedo tubes and fire first torpedo
V	view through periscope
X	exit from chartroom


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 


KEYING IN

* Type in 1 REM followed by 95 characters. Follow this with lines 20 to
  40 of the machine-code loader program, figure 4. Run the program and
  enter the 95 bytes in the Paint Routine, giving the start address as
  23760. Now type in the rest of the Draw Control Room program, over-
  writing or deleting lines 20 to 40 of the loader program.

* Run the program and save the display to tape, line 50. Repeat the 
  process above with the Draw Chartroom program. Type in and run the 
  Draw Periscope program, again saving the display to tape.

* Type CLEAR 60415 and then enter the machine-code loader program again.
  Run the loader and enter the 10 blocks of machine-code in figure 5.
  Although it would be possible to enter and save all 10 blocks in one
  go it is better to save each block as it is entered. Thus to save
  Block 1 which contains 115 bytes type SAVE "BLOCK1" CODE 60416,115.
  When all the code is in save it as one machine [code] file by 
  SAVE "FILENAME" CODE 60416,520.

* Reload the three screen displays at the addresses given in figure 2.
  For example, to load the Control Room display LOAD "" CODE 39680.
  Now save the screen displays and the machine code together by
  SAVE "Uboat CODE" CODE 32768,32768. Type in and save the Basic program
  in figure 6. Create the header-cum-loader program described on page
  112 and save it at the front of the tape.


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 


Figure 2. RAM allocation.

23755-32767 main Basic program
32768-39679 chartroom screen$
39680-46591 control room screen$
46592-53503 periscope screen$
53504-60415 dynamic control room store
60416-65535 tables and machine code, UDGs


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 


