

SANTA'S POSTAL SERVICE
by David Lawrence
from Popular Computing Weekly 16th December 1982


Many of the most intriguing games that can be played on a micro depend
for their fascination on the effective simulation of a very natural
phenomenon like the curve of the thrown ball. This simple Christmas
game depends upon the simulation of presents thrown from a height into
chimneys of varying elevation. In a flush of the Christmas spirit, the
game is offered for both the 16K Spectrum and the Dragon 32.

It needs only a very cursory examination to see that the game is, in
fact, very short in terms of the sections needed to actually play.
But, in both versions these parts are almost doubled by the lines
needed to provide the instructions and to set up the simple graphics
initially. It is in relation to the graphics that the major
differences arise between the two versions.

In the Spectrum game, the chimneys down which presents are to be
tossed are each made up of four user defined characters, loaded into
the memory by the module at line 3000. Since the user defined
character facility is not available on the Dragon, and to DRAW the 98
chimneys would be too slow, the five different chimney types (actually
dice faces) are loaded into arrays using the GET command and simply
printed to the screen using PUT. This procedure is made more
cumbersome by the fact that a separate array must be declared for each
of the five types of chimneys.

Once the graphics are set up, the Spectrum is far more economical in
the manner in which it can print the graphics to the screen in the
module at line 3500. On the other hand, the Dragon's flexible DRAW
command allows small touches like the representation of the presents
remaining by tiny 4*4 pixel squares.

Both versions of the game share some simple calculations, relating to
direction of throw and speed (modules at 2000 and 2200) and the rate
of descent compared with horizontal distance covered (2500).

In both versions the game is played on a screen completely devoid of
text. The chimneys are displayed in the form of an 11*9 grid of dice
faces. Each turn begins with a line being drawn around the grid,
starting in the bottom left-hand corner. The line can be stopped at
any point by pressing a key - this determines the direction of the
throw from the centre of the screen.

This is followed by the generation of a horizontal line between two
markers on either side of the screen. This line, too, is stopped by
pressing any key - it represents the initial velocity of the throw.
The meaning of the actual values represented will only become apparent
as you play.

Having entered the direction and the velocity, the horizontal track of
the throw will begin to be plotted on the grid. On the right of the
screen, a line descending from the top indicates the height of the
present as it falls. Six marks at the bottom right of the screen
indicate the floor and the relative heights of the five chimney types.

If the horizontal track is over a type five chimney when the height
line hits the top marker then the present has landed in that chimney.
Chimneys can only be entered from the top, so that if the height
marker is at less than the level of a type five chimney when the
horizontal track tries to enter a type five square, the present
crashes and is lost.

Each time a present enters a chimney which has not been entered
before, two things happen. Firstly, the player's score is incremented
by six minus the type of the chimney - that is to say the lowest
chimneys score highest. Secondly, on each subsequent turn the
representation of that chimney will be inverted and will not score if
it is entered on subsequent turns. One final complication is that the
height from which the presents are thrown decreases with every second
turn. This makes it increasingly difficult to hit low chimneys on the
outside of the grid which are masked by higher chimneys. Such
inaccessible chimneys need to be attempted early on, as you have only
40 presents per game.

The object of the game is to get as many points as possible with the
40 presents; it's as simple - and as difficult - as that.


Commentary

The lines of both versions are untidily numbered, since
to renumber either or both would disturb the correspondence
between the line numbers of the two versions.

Lines

1000	The module beginning at this line simply distri-
	butes tasks among the other sections of the
	program during play and displays the score at
	the end.

1200	This module sets up the array of chimneys. Note
	that in the Dragon version you cannot enter this
	module by means of a GO SUB since the RETURN
	destination is lost when the memory is cleared.

2000	The purpose of this module is simply to draw the
	direction indicator line around the array of
	chimneys.

2200	The angle of the direction in relation to the
	centre of the grid is calculated. Lines 2250 and
	2260 simply determine the relative proportions
	of the increments to horizontal and vertical
	coordinates every time a point is plotted on the
	trajectory. Whichever is the greater is made
	equal to 1 so that when the trajectory comes to
	be printed by a loop, every repetition of the loop
	PLOTs (or PSETs) a fresh pixel.

2310	The loop commencing here draws the line
	indicating the velocity of the throw.

2500	In this module the trajectory of the present is
	plotted. Various tests are performed to ensure
	that the trajectory has not passed off the screen
	and that the present has not landed. The
	variables X1 and Y1, calculated by the module at
	line 4000, indicate the array element in A which
	is represented by the current screen position. X2
	and Y2 simply record the array element in which
	the last point fell in. If a landing is made and
	X2,Y2 are not equal to X1,Y1 then the present
	has actually crashed into the wall of a chimney.
	The formula at 2580 simulates the effect of
	gravity on the present. If a valid landing is made
	the value of the array element is multiplied by -1.

3000	(Dragon) In this module three things happen.
	Firstly, five arrays are dimensioned to hold the
	five dice faces. This is clumsy but unfortunately a
	three-dimensional array of the form B(5,16,16) is
	not permitted. Secondly, strings are defined
	which will draw the square surrounding the dice
	face and the dots. Thirdly, the five combinations
	are drawn onto a graphics page (they are not
	seen on the screen since we have not called up
	the graphics screen yet) and put into the five
	arrays using GET. Note the use of the qualifier 'G'
	in the use of the GET command - this is because
	the resulting pictures stored in the arrays will be
	sometimes printed in inverse form and tend to
	produce unexpected results if the optional 'G' is
	not used.

3000	(Spectrum) A fairly standard module for loading
	user defined characters into the memory. Each
	group of four data lines defines a single dice
	face.

3500	(Dragon) In this module the graphics screen is
	cleared of the dice faces which were placed on
	to it in the last module and called up. Dice faces
	corresponding to the value in each element of
	the array A are PUT onto the screen at 16-pixel
	intervals horizontally and vertically.

3500	(Spectrum) A much simpler module since it is
	possible to manipulate the character to be
	printed by reference to the value contained in the
	relevant element of the array A without recourse
	to ON...GOSUB.

4000	This module simply calculates the array element
	corresponding to the current position of the
	present on the screen.
