
Invasion of the Body Snatchas  11/18/1996
-----------------------------

This is Crystal's Defender clone and it doesn't seem to be too bad.
I've included two versions here:  one for the TS2068 and one for
the 128K Spectrum.  The original was written to work with the
Fuller box and its built in joystick and AY chip.  I just modified
it a bit to use the correct joystick and sound chip port addresses
for each machine.

Thanks to Rob <rjfm2> for suggesting the conversion.  See below for
details of the changes made to the original snap.

Alvin <albrecht@freenet.calgary.ab.ca>

PS.  It doesn't matter whether you answer yes or no when the game
     asks if you have a Fuller box connected - it's been modified
     to have the same result.

*******************************************************************

After some snooping around in the snap, I gathered that the Fuller
box has a single joystick port and a built in AY-3-8912 sound chip
responding to the following port addresses:

AY SOUND CHIP      Fuller       128K Spectrum      TS2068
  register          #3F             #FFFD             #F5
  data              #5F             #BFFD             #F6

FULLER JOYSTICK
  port #7F, byte read looks like   F ? ? ? R L D U, active low

********************************************************************

TS2068 VERSION

- Fuller sound chip addresses changed to ts2068 chip addresses
- Fuller joystick changed to either ts2068 joystick


ORG 40497
JP Z,40502        ; Ignore Fuller box question at start of game

ORG 44941
DEFM /TS2068 Version Selected/  ; Change message after answering question
DEFS 20*space,0,40*space

ORG 40700                       ; Change Fuller joystick read
LD A,4                          ; to bit mask, then jump to ts2068
JP 40656                        ; joystick read
LD A,8
JP 40656
LD A,1
JP 40656
LD A,2
JP 40656
LD A,128
JP 40656

ORG 40656
PUSH BC
LD B,A                         ; Save bit mask
LD A,7                         ; Prepare to read ts2068 joysticks
OUT (#F5),A
IN A,(#F6)
AND #BF
OUT (#F6),A
LD A,14
OUT (#F5),A
LD A,3                         ; Read both joysticks at once
IN A,(#F6)
AND B                          ; Bit mask
POP BC
RET

; Replace all instances of OUT (#3F),A with OUT (#F5),A and
; all instances of OUT (#5f),A with OUT (#f6),A

************************************************************************

SPECTRUM 128K VERSION

- Fuller sound chip addresses changed to 128K chip addresses
- Fuller joystick changed to Kempston joystick


ORG 40497
JP Z,40502                     ; Ignore Fuller question

ORG 44941
DEFM /Spectrum 128 Version Selected/  ; Change message after question
DEFS 14*space,0,40*space

ORG 40700                      ; Change Fuller joystick read
LD A,2                         ; to mask and jump to Kempston read
JP 40656
LD A,1
JP 40656
LD A,8
JP 40656
LD A,4
JP 40656
LD A,16
JP 40656

ORG 40656                      ; Kempston joystick read
PUSH BC
LD B,A                         ; Save bit mask
IN A,(31)                      ; Read Kempston
CPL                            ; Change to active low
AND B                          ; Do mask
POP BC
RET


ORG 40664                      ; AY chip output subroutine
PUSH BC                        ; D=AY register, E=AY data
LD BC,#FFFD
OUT (C),D
LD B,#BF
OUT (C),E
POP BC
RET

ORG 40676                      ; See comments following
PUSH DE
LD D,A
LD E,(HL)
CALL 40664
POP DE
RET

; The instruction sequence 'OUT (#3F),A; LD A,(HL); OUT (#5F),A' is
; found at 43188,43232,43240,43259,43267,43307,43315 and is replaced
; with 'CALL 40676; NOP; NOP'

; The following replace some simple sound register writes

ORG 43297
PUSH DE
LD DE,#0501
CALL 40664
POP DE

ORG 43326                      ; Replaces a command setting AY
NOP                            ; register to 15 (not present on
NOP                            ; AY-3-8912 chip - probably used to 
                               ; protect contents of other AY
                               ; registers???)

ORG 43338
PUSH DE
LD DE,#0800
CALL 40664
INC D
CALL 40664
INC D
CALL 40664
POP DE
RET

ORG 43379
PUSH DE
LD DE,#0D09
CALL 40664
LD DE,#07E1
CALL 40664
POP DE
RET

ORG 43361
PUSH DE
LD DE,#0D09
CALL 40664
LD DE,#07E0
CALL 40664
POP DE
RET

**********************************************************************

the end :-)

