RAM used / corrupted by +3DOS
=============================
15.Jan.2013
Here's the
[url=http://www.users.globalnet.co.uk/~jg27paw4/pourri/spacegunplus3.zip]Space
Gun conversion[/url] for +3 disk. The DSK image contains: a one-line BASIC
loader "DISK"; the patch code "SGPATCH" (669 bytes, although only 336 bytes
are used during the game); the 26 packed data files from Biotoxin's TAP
version, but all given their correct names as used in the program. The
files just fit on a 180kb disk. I've played it right through to the end (or
one of the ends, anyway) using the infy poke.


[center][img]http://www.users.globalnet.co.uk/~jg27paw4/pourri/sgexplodey.gif[/img]
:
[img]http://www.users.globalnet.co.uk/~jg27paw4/pourri/sghiscore.gif[/img][/center]

Once I'd worked out what needed doing, what needed doing wasn't all that
much, as there was a handy chunk of about 600 bytes in page 4 which could
be discarded and replaced with the in-game disk loader. After that the main
complication was that I missed an absolute "JP PE,..." in the unpack
routine which needed to be altered for when the routine was relocated, and
it took me three days to work out why half the graphics were all jumbled up
- and ZXSpin trashing my DSK file didn't help - one minute it's OK, the
next "No files found". I set the file attribute to read-only after that.

The only DOS data I needed to save was the 256 bytes from $5b00, plus I
needed to save whatever the program had put at $db00->$e7ff whenever I
wanted to load a level from disk. The former I could put in the handy space
mentioned above, the latter I just bunged on the screen as the game blanked
it between levels anyway. There were a couple of complications with files
MAIN1 and BANK7; these are explained in the assembler listing.

DOS_INITIALISE rebuilds the workspace from the ROM, so in place of that I
just used this cut-down version prior to using any DOS routines:
[code]
DOSInit:ld   hl,$db00
        ld   de,$db01
        ld   bc,$09ff
        ld   (hl),$00
        ldir                ; clear DOS workspace variables
        call $1f32          ; DD_INIT
        call $17d0          ; initialise A: & B: extended XDPBs
        ld   hl,$0000       ; no RAMdisk, no cache
        ld   d,h
        ld   e,l
        push de
        call $1820          ; initialise RAMdisk
        pop  de
        call $1539          ; setup cache
        jp   $0500          ; set default drive and exit
[/code]
So the main DOS level load procedure can be summarised as:
[list=a]
[*]switch to ROM 2, RAMpage 7
[*]clear the screen
[*]swap the $5b00 area with whatever happens to be there
[*]save the $db00 area to the blank screen
[*]run DOSInit
[*]for each file, call DOS: OPEN, READ (header), READ (data), CLOSE; unpack
[*]restore the $db00 area from the blank screen
[*]swap the $5b00 area with whatever happened to be there
[*]switch to ROM 3, RAMpage 4
[/list]

The BASIC loader is just:
[code]CLEAR 32767: LOAD "SGPATCH" CODE 32768,669: RANDOMIZE USR 32768[/code]
The annotated assembler listing is in the ZIP file. There's also a couple
of other programs which I used for transferring the files from TAP to DSK
and for unpacking them to a separate TAP file (although the latter wasn't
needed, as I used the packed versions anyway).

The reason I had so much space available was that the program uses a chunk
of page 4 to copy in various routines, including its level loader, a copy
of which resides in high memory. I just put my routine there instead and
the program dutifully copied it into the active area and ran it each time
it changed levels. The one other thing I had to change was the SP location.
The primary position used by the game is $c000, which is invalid for DOS,
which reserves the top 30 bytes of page 2. It turned out that $bfbe worked.



RAM used / corrupted by +3DOS
=============================
15.Jan.2013
Fixed the +3e version; the DOSInit routine needs to be replaced with this
slightly different version:
[code]
DOSInit:LD A, ($E42E)
        PUSH AF
        LD HL, $DB00
        LD DE, $DB01
        LD BC, $09FF
        LD (HL), $00
        LDIR
        CALL $1F23
        CALL $17B7
        LD HL, $0000
        LD DE, $0000
        PUSH DE
        CALL $1818
        POP DE
        CALL $1525
        CALL $0510
        POP AF
        LD ($E42E), A
        JP $28B5
[/code]
Although the game plays at about the same speed, the levels take twice as
long to load on the +3e (emulation with ZXSpin).


##########


Space Gun TAP directory


JPs to $0562 (LD_BYTES+12)
-------------------------
"sg"      : 33090 ($8142)
"MAIN2"   : 43436 ($a9ac) page 2 (active)
"MAIN2"   : 58028 ($e2ac) page 4 (inactive)

LDIR at 29064 ($7188) copies 2560 ($a00) bytes (offset 14592 ($3900))
    from 4:57090-59649 ($df02-$e901) to 42498-45057 ($a602-$b001)

setup:
	* load MAIN1 @ 39680 then move to 23296+256 after unpacking (exluding first 256 bytes)
    * save first 256 bytes
	* load BANK7 @ 49152 then move to 56064 after unpacking & DOS disabled
    * swap +3 256 bytes system area @ $5b00 with remainder of MAIN1
	* active patch location within $a915->$ab47 can be replaced (= $232 (562) bytes) (redundant area)
	* install in page 4 at address $a915+$3900=$e215
    * apply other page 4 mods at this time
main game patch to:
    * swap +3 256 bytes system area @ $5b00 with remainder of MAIN1
	* save page 7:$db00->$e7ff to page 5 screen
    * call DOS_INITIALISE but using zero DOS & RAM buffers
    * call DOS_OPEN, DOS_READ, DOS_CLOSE for each file
    * restore page 7:$db00->$e7ff from page 5 screen
    * swap +3 256 bytes system area @ $5b00 with remainder of MAIN1

Program: "SPACEGUN"   LINE 1      Data:   332 bytes
Bytes:   "c"          CODE 36864        +  40
Bytes:   "sg"         CODE 32768        + 882 =  1254

                           $8000 ..... + $372 = $8372  <.space.> $9000 (36864)
                                                         $0c8e

  33382 ... 90... 92... 94... 96...
                len       checksum
            pack  unpk   data  head     start  pack    unpk
A:SCREE   : 07 16 00 1b 83 b5 64 74   : 16384, 5639 :  6912
B:MAIN1   : cc 21 00 25 65 68 36 31   : 23296, 8652 :  9472 = 32768
C:MAIN2   : e9 3f 00 60 1c 9c 05 d6   : 40960,16361 : 24576 : 40960 - 32768 = 8192 ($2000)
D:BANK1   : 29 3d 00 40 86 1e 7d 47   : 49152,15657 : 16384
E:BANK3   : 55 38 00 40 2d a4 ca 33   : 49152,14421 : 16384
F:BANK4   : 36 20 00 21 42 bd e8 8c   : 57088, 8246 :  8488
G:BANK6   : 6c 37 00 40 5d 8b f9 2e   : 49152,14188 : 16384
H:BANK7   : 85 15 00 25 c1 df 3d f9   : 56064, 5509 :  9472 :
	< stop	ROM 3; RAM 5,2,4; screen 5: BANK7 overwrites DOS workspace
                                      : load @ 49152 then move to 56064 after unpacking
	select controls, switch to side 2
	level headers load @ $aad0, lookup table @ $a6b9
    jumps to LD_BYTES+12 @ $a9ac

In page 7 DOS uses 56064->59391 ($db00->$e7ff) = 3328 ($d60)  bytes
shadow screen uses $c000->$daff

I:L1INTRO : fa 1b 1a 1c 0c 28 99 a2   : 49152, 7162 : 4 :  7194 = 56346 ($dc1a)
J:L1CTRL  : b3 03 1a 04 1e d6 10 4a   : 50176,  947 : 0 :  1050 = 51226 ($c81a)
K:NORMCHRS: a8 1e 78 1f 17 ba d9 aa   : 32768, 7848 : 0 :  8056 = 40824 ($9f78)
	< stop	ROM 3; RAM 5,2,0; screen 7
L:L2INTRO : fe 0a 27 0b 65 ff 22 1c   : 49152, 2814 : 4 :  2855
M:L2CTRL  : c5 06 36 07 7c ea 24 d5   : 50176, 1733 : 0 :  1846
N:L2BCKDRP: 0c 08 02 13 21 ae 1f b9   : 49152, 2060 : 4 :  4866
	< stop	ROM 3; RAM 5,2,5; screen 7
O:L3INTRO : b7 1d d7 1e 77 38 59 e3   : 49152, 7607 : 4 :  7895
P:L3CTRL  : 22 05 50 05 d3 28 89 d9   : 50176, 1314 : 0 :  1360
	< stop	ROM 3; RAM 5,2,1; screen 5
Q:L4INTRO : 53 0b b6 0b 53 0a d1 36   : 49152, 2899 : 4 :  2998
R:L4CTRL  : 35 06 02 07 a7 c6 d8 01   : 50176, 1589 : 0 :  1794
S:L4BCKDRP: c5 09 02 13 ff df 69 32   : 49152, 2501 : 4 :  4866
	< stop	ROM 3; RAM 5,2,0; screen 5
T:L5INTRO : 11 0b fa 0b b2 b3 3d a6   : 49152, 2833 : 4 :  3066
U:L5CTRL  : 24 09 af 09 5a 21 c3 5e   : 50176, 2340 : 0 :  2479
	< stop	ROM 3; RAM 5,2,7; screen 5
V:L6INTRO : c0 08 3b 0a ed df d5 27   : 49152, 2240 : 4 :  2619
W:L6CTRL  : e0 01 ef 01 4c e6 99 ec   : 50176,  480 : 0 :   495
X:L6BCKDRP: 0e 10 92 14 b9 55 bc bd   : 49152, 4110 : 4 :  5266
	< stop	ROM 3; RAM 5,2,7; screen 7
Y:ENDSEQ1 : 3d 1c 00 20 2d a5 6c a6   : 32768, 7229 : 0 :  8192
	< stop	ROM 3; RAM 5,2,7; screen 7
Y:ENDSEQ1 : 3d 1c 00 20 2d a5 6c a6   : 32768, 7229 : 0 :  8192
Z:ENDSEQ2 : 63 1b 00 20 f0 23 cf 6b   : 32768, 7011 : 0 :  8192
	< stop	ROM 3; RAM 5,2,4; screen 5
               = 416                          = 153390


page 0 : 63565,0 infinite energy


SPACE GUN
Ocean


SCENARIO

In the year 2039AD man has begun deep space exploration. However, throughout
the deep expanse of space there are many unknown dangers awaiting weary
travellers and explorers.
From a crippled ship a distress call is transmitted. You have received the
message. Will you be able to rescue the helpless hostages from the clutches of
the astral hijackers?
Travel through corridors and rooms packed with aliens of all sizes, searching
for survivors, and out onto the planet surface to more dangerous regions.


LOADING

COMMODORE CASSETTE
Position the cassette in your Commodore recorder with the printed side upwards
and make sure that it is rewound to the beginning. Ensure that all the leads
are connected. Press the SHIFT key and the RUN/STOP key simultaneously. Follow
the on-screen instructions - PRESS PLAY ON TAPE. This program will then load
automatically. For C128 loading type GO 64 (RETURN), then follow C64
instructions.

DISK
Select 64 mode (if using Commodore 128). Turn on the disk drive, insert the
program into the drive with the label facing upwards. Type LOAD "*",8,1
(RETURN). The introductory screen will appear and the program will then load
automatically.

SPECTRUM 128/+2/+2A/+3 (128K ONLY) CASSETTE
Place the cassette in the recorder, ensuring that it is fully rewound. Select
LOADER option and press the ENTER key. Follow on-screen instructions.


CONTROLS

C64/CONSOLE
This is a one-player game controlled by a joystick in Port 2. During the
titles use the joystick to select music or sound effects and press Fire to
start the game.
During the game the joystick will move the gunsight and the Fire button will
fire. If a second fire button exists it will select a weapon from the
available arsenal.
On a C64 the following keys are used:
	SPACE        SELECT WEAPON
	RUN/STOP     PAUSE (Fire to resume or Q to quit)

SPECTRUM
This is a one-player game playable with a Sinclair 2, Kempston or Cursor
joystick. To use a Kempston joystick press K during the titles. If none of
these joysticks is available the following keys can be used:
	Q	UP
	A	DOWN
	O	LEFT
	P	RIGHT
	SPACE	FIRE
The following keys are used with all joysticks and keyboard:
	M	SELECT WEAPON
	H	PAUSE GAME (H to resume)
During the game the appropriate controller will move the gunsight and the fire
button will fire. The M key will select a weapon from the available arsenal.


GAMEPLAY

Travel through the corridors of the spaceship and the barren planet surface
searching for trapped hostages who must be rescued. As you pass walls
flashing lights may appear and firing at these will produce one of the
following pickups which can be collected by shooting them:

a flame thrower - scorch those aliens!
a grenade - blow 'em to smithereens!
a blade - cut 'em in two!
a freeze gun - leave 'em standing!
body armour - protect yourself!
red tube - refresh yourself with some energy units
yellow tube - restore yourself to full energy

If a weapon is continually fired its recharge rate will drop and its
firepower will become less and less effective. The weapon's recharge rate
will increase if firing is ceased.

In some parts of the complex you will encounter large guardians which must
be conquered before you can continue.

You will fail in your mission if you lose all your energy or lose all
your hostages.

On some implementations you may have a choice of direction to travel at
certain points in the complex. Select a direction by shooting the
appropriate arrow which will appear.


STATUS AND SCORING

At the top of the screen are the scores for the players taking part, the
time remaining to complete the current section of the complex and the number
of hostages in that section. A hostage icon will be blank if they have not
been found, filled if they have been rescued or crossed out if they have
been killed.

At the bottom of the screen is a radar display which will reveal some of the
aliens in the vicinity and, for each player taking part, a display
indicating the current number of special weapons in their arsenal and which
weapon is currently selected, the current energy available to the player
shown as a segmented bar and the current weapon recharge rate.


HINTS AND TIPS

Concentrate on large aliens first. Use special weapons on large groups for
best results. Collect as many different weapons as possible. Remember that
not all aliens will appear on the radar. Don't get the blues or life will
become tricky!


CREDITS

(c) 1991 Taito Corp. All Rights Reserved.
Conversion by Images Software Ltd.
C64 Programmed by Tom Pinnock
Graphics by Andy Pang, Chris Edwards
Spectrum Programmed by Damian Stones
Graphics by Steve B.
Music by Sonic Projects
Produced by D.C. Ward
(c) 1992 Ocean Software Ltd.