ALL AT SEA
by Eric Hutchinson

Christopher Columbus would have had an
easier life with Eric Hutchinson's program.


This program was designed by Eric as a specialist program
for yacht sailors to practice their navigation, but it
impressed me as being of great educational use and also
makes a fascinating simulation.

If you fancy your hand at round the world sailing, try this
program first! I'll let Eric tell you about it.

This is a navigation program designed for use by small
yachts. It is menu driven and has the following facilities:

1 Course and distance from a choice of present position, last
  fix or estimated position.
2 Estimated  position from course and speed entered in
  response to prompts.
3 Fix from horizontal sextant angles.
4 Keeps a constant record of the destination which may be
  changed at any time.

In use, the program works as follows:

The landmarks or beacons are entered into the array in
response to prompts. The program is then saved to tape. On
reloading the program the beacons are available for position
fixing. First, a course is asked for and the present
position and destination entered. A course and distance is
then produced. This is used by the program to find the
estimated position at any time. When a fix is required the
beacons to be used are entered from left to right. The
program will then ask for the left hand side horizontal
angle and then the right hand side. The program then
displays the position by bearing and distance from the
centre beacon and as Latitude and Longitude. It will also
update the arrays.


To use the program

On any spare evening set up your ZX81 and load the program.
Get out the charts of your cruising area and pick out
suitable landmarks for taking bearings. Write down the
latitude and longitude of each, numbering them from 1 as you
go. For convenience, the numbers could also be written
alongside the landmarks on the chart.

Follow the instruction for entering beacons (as I call all
landmarks) and when you have finished, list the beacons and
check all have been entered correctly. If all are correct
place a new, good quality cassette in the cassette recorder.
Plug the connecting wire into the sockets marked Mic, in the
cassette recorder and in the ZX81, and follow instructions
to save to tape. This cassette now holds the fixing system
and all the beacons you have entered.


Before the cruise

Set up the ZX81 and load your new cassette program. During
the cruise pick three suitable beacons and enter their
numbers from left to right as seen from seaward. Enter your
horizontal angles and remember to press NEWLINE after each
entry. The screen will show your present position as a
bearing and distance from your centre beacon and as a
Latitude and Longitude.

If at any time you see a mark you can use, which is not on
your list, simply go to (E to enter beacons) and enter lat
and long remembering to keep a note of the number, write it
alongside the mark, then list the beacons and check that the
number is correct. If you have entered extra beacons during
a cruise then follow the instructions to save to tape before
switching off.


A few comments

One or two points may be of interest:

1 The program was designed for the yachtsman to use
  rather than the computer hobbyist. To this end, as far as
  possible, I have tried to ensure that there are no breaks in the
  program.
2 In order to disable the break key all entries are strings backed
  by error catching routines.
3 Lines 5 to 40 check that the entry is a number, and reject
  anything else except a decimal point.
4 The PEEK in line 615 uses an unused variable to direct
  the course and distance routine to prompt for initial
  position. It is POKED on first loading the program.
5 In line 841 code T$ is used as I found that ... if T$ =
  ... does not work if the T$ (array) is empty.
6 Lines 1200 to 1210 change the mathematical angle which
  is measured from the X axis anticlockwise to a true bearing
  which is measured from the Y axis clockwise.
7 The PEEK in line 3130 checks the number of lines left
  in the display file and goes to the subroutine which allows
  the screen to be cleared and the listing continue without
  displaying an error code.
8 In lines 386 and 526 I found that in some circumstances
  the result could be > 1 thus giving an error code as no
  angle has a cosine > 1, hence these corrections.

Naturally, there is a great deal more that could be done but
I feel that, in BASIC, the program is reasonably complete.

To develop the idea further, I am currently working on a
machine code program which will take data direct from
various sources and produce a continuous estimated position
taking into account set and rate and leeway as well as poor
steering.


Shipping lines?

Here follows a breakdown of the structure of the program:


5-40      Subroutine to check input is a number or decimal point.
900-940   Program starts at line 900 which sets up the arrays to
          hold the navigational information, both as strings for
          printing and as values for calculation.
600-660   Input $ then jumps to relevant parts of the program.
          Input "S"
4000-4040 Simply the save routine from within the program thus
          making itself running on loading.
          Input "A"
2000-2170 Exchanges variables V and Y and then jumps to beacon
          entry routine at line 102.
          Input "B"
3000-3120 The routine for listing beacons already entered.
          Input "C"
950-967   Gives choice between three possible start positions for
          course and distance.
125-255   Entry subroutine for lat and long with error checking.
          Input "D"
800-815   Prints current status of position, course and speed and
          estimated position if any.
          Input "F"
300-550   Position fixing routine. This works by finding bearing
          and distance between beacons whose numbers are entered
          left to right, and,
1000-1235 using an almost exact trigonometric version of the
          geometrical construction used for horizontal sextant
          angle position fixing, finds the vessel's position.
1236-1294 Updates the current position in the arrays and, if a fix
          or entered position, clears the estimated position string
          array by GOSUB 1350.
1350-1360 The routine which clears the estimated position
          string array.
840-879   Works out estimated position from time elapsed and course
          and speed.
          This routine is also used if a course from an estimated
          position is asked for. The program, working out the
          estimated position, then asking for the destination and,
          finally, jumping to the course the distance finding routine
          at line 694, after entering the estimated position in
          the appropriate string at line 1236.
          Input "E"
100-110   The beacon entry and consecutive numbering routine.


Variables used

Y       Keeps count of the last beacon entered.
V       Used to hold the value of Y when altering an existing beacon.
L()     Latitude.
G()     Longitude.
T()     Time.
C()     Both course and speed.
VAR     Used to differentiate between fixes and estimated positions
        for data storage.
POS     Used similarly for GOTO instructions.


--
Another Fine Product transcribed by:
Jim Grimwood (jimg@globalnet.co.uk), Weardale, England
--
