
Spectrum Globeplotter
=====================

        Then...
	
	The program is called Globeplotter and it transposes a Spectrum
        screen onto the surface of a sphere. In fact it transposes half
        the screen onto the surface of the sphere then repeats moving a
        predetermined step across the screen, producing the effect of a
        spinning globe. The main routine of the program is in machine
        code, but uses look-up tables calculated by the Basic part of the
        program.

        -------

        This program transposes any Spectrum screen onto the surface
        of a sphere and replots it at intervals shifted by a number of
        pixels. This produces the effect of spinning globe animation
        at a speed dependent on the radius of the sphere.
        The program installs various machine code routines, and displays
        a menu allowing the user to select parameters and load in source
        and background screens.

        The program can handle
        Normal i.e. Unprojected latitude and longitude maps, and,
        Lambert Cylindrical Equivalent Projections.
        With unprojected maps the detail at the equator of the sphere will
        be enlarged and chunky, while detail at the poles will be reduced.
        Lambert projections retain detail to a greater extent.

        The machine code plotting routines rely on a table produced by
        the Basic program which starts at location 64256 and grows upwards.
        For each line of the globe there are three addresses - six bytes -
        in high-low order. The table is terminated by a zero end-marker.

        The first address is of the cosine table to be used; the second is
        where plotting is to start; and the third is the left-hand location
        of the screen line to be used as source data.

        Both the source and the background screens are located above RAMTOP.
        The backdrop and it's attributes are stored at 49664.
        The source screen - bitmaps only is stored at 43520.

        The cosine table begins at 64255 and grows downward. There is a
        separate table for each line of a hemisphere. The same tables are
        used to plot both hemispheres and both right and left halves so
        each cosine table is used four times and the number of tables needed
        will be equal to the radius.

        The machine code begins at 39000. Interrupts are disabled to gain
        speed and to free the IY register. The HL' register is preserved
        on the machine stack.
        Register use is as follows -
        HL - vector to pixel routine. H will hold a plotting or testing page.
        DE - plotting address on backplane.
        BC - reads cosine table.
        A - pixel count.
        A' - if H holds plot page then point page stored here and vice versa.
        HL' - point address on source screen.
        DE' - constants to speed up comparisons.
        BC' - Not used.
        IX - return address from Point routine, constant.
        IY - return address from Plot routine, constant.

        ...Personal Computing World, June 1986.

	Now...

	Unlike some Mickey-Mouse animation systems, which use stored frames,
	Globeplotter 'plots' each picture as you see it.
	It can manage 1 -2 frames per second, depending on radius, and needs to
	process about 50,000 pixels a second.
	It achieves this using the machine-code equivalent of the computed GOTO,
	JP (HL), to invoke 64 customized pixel routines -
	16 Plot routines.
	16 Unplot routines.
	16 Test routines.
	16 Already found a lit pixel so just update the pointer H routines.

	Each of these sixteen routines is divided into two groups of 8 for
	handling a specific pixel in either LH or RH direction.
	This method of programming is known as the cascade method and indeed
	I got the idea after reading a section on BASIC cascade animation in
	"Advanced Graphics with the Sinclair ZX Spectrum" by
	I.O. Angell and B.J. Jones. 1983. Macmillan.

	An improved version of the program with better maths and register use 
	and fully 128 compatible, was published on Outlet microdrive magazine
	in 1988. It was however only slightly faster and while preparing 
	that for submission here I noticed room for improvement and so will be
	revisiting the program one more time.

	The program was submitted before the launch of the 128 spectrum and
	uses the only 48K Rom routine that can't be called from 128K Basic,
	the ZX Printer COPY routine. Indeed some Alphacom 32 printouts appeared
	alongside the original program. So if you use it in 128K Basic pressing the 
	'P' key will crash the machine. In fact after the launch of the 128K a number
	of my 1985 submissions started appearing in magazines and all crashed it.

	At the time of original submission I was experimenting with using cylindrical
	projections but I've remarked those lines out as it's not worth
	pursuing. 

	You can, of course use any screen for foreground and backdrop.
	Use your favourite loading screen as a Windows desktop ornament.
	( With appropriate emulator ).
	I've included two source screens and four backdrops on the tap file.
	f1.s 	- an improvable map, please upload if you do.
	f2.s 	- a loading screen.
	b1.s	- An Outlet cover screen.
	b2.s    - Tumbling Worlds.
	b3.s	- Mona.
	b4.s	- A different view of f2.s

	I have a bit of an obsession with these spheres and all the backdrops
	were produced with another Spectrum program - "Other Worlds" - which
	once got a mention in Computer Shopper.

	I'll be preparing that for upload here and I hope it doesn't take as long.

	... Geoff Wearmouth Oct 1997.			geoff@wearall.demom.co.uk
		
