Patch:Stunned sprite stars

From KeenWiki
Jump to navigation Jump to search

The stunned sprite stars are small white stars that appear over (some) stunned sprites in Keen Galaxy to indicate that they are now harmless. They are not sprites in themselves but rather an addition to the sprite's image that is drawn over top. As such only a limited number of properties can be altered.


Don't display stun stars

This patch stops the stun stars appearing on all stunned sprites. (To remove them selectively from some stunned sprites is more difficult.)

Keen 4

#Stop the stun stars appearing
%patch $B739  $5F $5E $8B $E5 $5D $CB

Keen 5

#Stop the stun stars appearing
%patch $AA70  $5F $5E $8B $E5 $5D $CB

Keen 6

#Stop the stun stars appearing
%patch $A955  $5F $5E $8B $E5 $5D $CB


Star animations

The stun stars use three animations, less can be used, but not more (or the stars will not appear.)

Keen 4

#Star animations
%patch $B7BD [$00A4W] #Animation used
%patch $B7B3 [$0003W] #Number of frames

Keen 5

#Star animations
%patch $AACC [$008FW] #Animation used
%patch $AAC2 [$0003W] #Number of frames

Keen 6

#Star animations
%patch $A9DB [$0056W] #Animation used
%patch $A9D1 [$0003W] #Number of frames


Keen must restart level when he shoots something

This patch causes the level to restart (Keen does not lose a life.) if Keen shoots any sprite that can stun. The patch may be unstable in certain situations however.

Keen 4

#Keen must restart the level each time he shoots something
%patch $B6D3  $8B $76 $06 $FF $74 $20 $33 $C0 $50 $FF $74 $1E
              $FF $74 $0C $FF $74 $0A $8B $C6 $05 $46 $00 $50 $9A $16541641RL
              $83 $C4 $0C $5F $5E $8B $E5 $5D $CB


Star positioning

Depending on sprite size and 'head' location the stars should be positioned differently. There are two main ways of doing this depending on which game is being patched.


Keen 4

In Keen 4 the sprite's type variable is used to read from a list of position code locations. The code at that location is then run. Most sprite types use a default 'type 9' positioning; these are usually enemies that can't be stunned by default. The end result of this is that there are a far more limited set of star positions than there are sprite types. Also note that the first (or zeroth) entry on the list starts at type = 5.

As an example the Poison Slug has a value of 5 - 5 = 0 for this variable, reading the first (zeroth) value off the list, or $19CB. This points to code at $19CB + $9DC0 = $B78B, or type 8 stars. Either horizontal, vertical or both positions can be altered away from 0,0 in the positioning code. $BF $xxxxW alters vertical positioning while $C7 $46 $FE $xxxxW alters horizontal. Note that type 9 stars are unpatchable as they have no code to alter.

Keen 4

#List location (Values + 9DC0)
%patch $B750 [$1A22W]

#List length
%patch $B748 [$15]

#List starts at
%patch $B745 [$05]

#List
%patch $B7E2 [$19CBW] #Poison slug: type 8
%patch $B7E4 [$19CEW] #Council member: type 9
%patch $B7E6 [$19CEW] #Unused: type 9
%patch $B7E8 [$1997W] #Egg: type 2
%patch $B7EA [$19CEW] #Mad Mushroom: type 9
%patch $B7EC [$19CEW] #Arachnut: type 9
%patch $B7EE [$19CEW] #Skypest: type 9
%patch $B7F0 [$19B2W] #Wormouth: type 5
%patch $B7F2 [$19CEW] #Cloud: type 9
%patch $B7F4 [$19CEW] #Berkeloid: type 9
%patch $B7F6 [$19A8W] #Bounder: type 4
%patch $B7F8 [$19C1W] #Inchworm: type 7
%patch $B7FA [$19CEW] #The Foot: type 9
%patch $B7FC [$19BCW] #Lick: type 6
%patch $B7FE [$1992W] #Mimrock: type 1
%patch $B800 [$19CEW] #Platform: type 9
%patch $B802 [$19CEW] #Dopefish: type 9
%patch $B804 [$19CEW] #Schoolfish: type 9
%patch $B806 [$19CEW] #Sprite: type 9
%patch $B808 [$19CEW] #Lindsey: type 9
%patch $B80A [$19CEW] #Cloud Lightning: type 9
%patch $B80C [$19A1W] #Smirky: type 3

#Type 1
%patch $B752 $BF [$FFC0W]  $EB $37

#Type 2
%patch $B757 $C7 $46 $FE [$0080W]  $BF [$FF80W]  $EB $2D

#Type 3
%patch $B761 $C7 $46 $FE [$0080W] $EB $26

#Type 4
%patch $B768 $C7 $46 $FE [$0040W]  $BF [$FF80W] $EB $1C

#Type 5
%patch $B772 $C7 $46 $FE [$0040W]  $BF $FEA2W]  $EB $12

#Type 6
%patch $B77C $BF [$FF80W]  $EB $0D

#Type 7
%patch $B781 $C7 $46 $FE [$FFC0W]  $BF [$FF80W]  $EB $03

#Type 8 (Same as type 6)
%patch $B78B $BF [$FF80W]


Keen 5

Needing far less variety Keen 5 dispenses with the pointer list and simply applies the same positioning to all sprites with several exceptions. These exceptions are according to a sprite's type.

By default all sprites use 'type 0' that is the stun stars appear at 0,0 relative to the stunned sprite. There are three exceptions two of which are in fact the same. (Type 2 and type 3; type 2 also has an 'extra $EB $xx jump that serves no purpose.) This severely limits a modder's ability to alter star positions.

Either horizontal, vertical or both positions can be altered away from 0,0 in the positioning code. $BF alters vertical positioning while $EF alters horizontal. Patches alter either 1 or 2 bytes being of the form $83 $46 $yy $xx or $81 $xx [$yyyyW

Type 2 and type 3 alter the vertical position of the stun stars, a larger value moves them downwards. Type 2 alters the horizontal position, but does this very poorly.

Keen 5

#Exceptions
%patch $AA7A $3D [$0009W]  {$74} $0C #Sparky\Shelley goto type 1
%patch $AA7F $3D [$000EW]  {$74} $0D #Ampton goto type 2
%patch $AA84 $3D [$0017W]  {$74} $10 #Korath goto type 3
%patch $AA89 $EB $12             #Else skip

#Type 1
%patch $AA8B $83 $46 $FE [$40] $EB $0C

#Type 2
%patch $AA91 $81 $EF [$0080W]  $EB $06 $EB $04

#Type 3
%patch $AA99 $81 $EF [$0080W]


Keen 6

In Keen 6 the sprite's type variable is used to read from a list of position code locations, much like Keen 4. The code at that location is then run. Most sprite types use a default 'type 9' positioning; these are usually enemies that can't be stunned by default. The end result of this is that there are a far more limited set of star positions than there are sprite types. Also note that the first (or zeroth) entry on the list starts at type = 7.

As an example the Bloog has a value of 7 - 7 = 0 for this variable, reading the first (zeroth) value off the list, or $1A42W. This points to code at $1A42W + $8F40 = $A982, or type 8 stars. Either horizontal, vertical or both positions can be altered away from 0,0 in the positioning code. $BF $xxxxW alters vertical positioning while $C7 $46 $FE $xxxxW alters horizontal. Note that type 9 stars are unpatchable as they have no code to alter.

Note that type 7 is an error, seen only in Keen 6, which occurs when an 'invalid' type tries to display stars. There is no reason for this to be so, which is why it is removed in the other two Galaxy games. Replacing an invalid entry with $1A6CW will give it a 'type 0' positioning (0,0, otherwise another type can be used.)

Keen 6

#List location (Values + 8F40)
%patch $B750 [$1AC0W]

#List length
%patch $A964 [$11]

#List starts at
%patch $B745 [$07]

#List
%patch $AA00 [$1A42W] #Bloog: type 3
%patch $AA02 [$1A4CW] #Blooglet: type 4
%patch $AA04 [$1A60W] #Unused: Error
%patch $AA06 [$1A51W] #Fleex: type 5
%patch $AA08 [$1A60W] #Unused: Error
%patch $AA0A [$1A60W] #Molly: Error
%patch $AA0C [$1A4CW] #Babobba: type 4
%patch $AA0E [$1A60W] #Bobba: Error
%patch $AA10 [$1A60W] #Unused: Error
%patch $AA12 [$1A42W] #Nospike: type 3
%patch $AA14 [$1A60W] #Gik: Error
%patch $AA16 [$1A60W] #Enemy gun: Error
%patch $AA18 [$1A60W] #Orbatrix: Error
%patch $AA1A [$1A60W] #Bip: Error
%patch $AA1C [$1A38W] #Flect: type 2
%patch $AA1E [$1A60W] #Blorb: Error
%patch $AA20 [$1A5BW] #Ceilick: type 6
%patch $AA22 [$1A2EW] #Blooguard: type 1

#Type 1
%patch $A96E $C7 $46 $FE [$0100W]  $BF [$FFC0W]  $EB $34

#Type 2
%patch $A978 $C7 $46 $FE [$0040W]  $BF [$FFC0W]  $EB $2A

#Type 3
%patch $A982 $C7 $46 $FE [$0080W]  $BF [$FFC0W]  $EB $20

#Type 4
%patch $A98C $BF [$FF80W]  $EB $1B

#Type 5
%patch $A991 $C7 $46 $FE [$0100W]  $BF [$0080W]  $EB $11

#Type 6
%patch $A99B $BF [$00C0W] $EB $0C

#Type 7 (Error)
%patch $A9A0 $B8 [$07F0W]  $50 $9A $037B0230RL    $83 $C4 $02


Complete star display code

This is the complete code for displaying the stun stars in-game. It is in fact a tile interaction code that is used by stunned sprites. As such the first tree lines deal with tile detection, stopping the stunned sprite moving if it hits ceilings or walls.

Actual star-drawing doesn't start until line 8 where the various types and positions are detailed. The last few lines control the number of frames in the stun stars.

Keen 5

#Stunned sprite tile collision -Keen 5
%patch $AA0A $55 $8B $EC $83 $EC $02 $56 $57 $8B $76 $06 $83 $7C {$3C} [$00] {$75}
             $06 $83 $7C {$38} [$00] {$74} $05 $C7 $44 $16 [$0000W]  $83 $7C {$3A} [$00]
             {$74} $05 $C7 $44 $18 [$0000W]  $83 $7C {$36} [$00] {$74} $1C $33 $C0 $89
             $44 $18 $89 $44 $16 $8B $5C $1C $83 $7F $1C $00 $74 $0B $FF $77
             $1C $56 $0E $E8 $F8A2W  $83 $C4 $04 $FF $74 $20 $33 $C0 $50 $FF
             $74 $1E $FF $74 $0C $FF $74 $0A $8B $C6 $05 $46 $00 $50 $9A
         $174E163ERL     $83 $C4 $0C $33 $C0 $8B $F8 $89 $46 $FE $8B $44 $44
             $3D [$0009W]  {$74} $0C $3D [$000EW]  {$74} $0D $3D [$0017W]  {$74} $10 $EB
             $12 $83 $46 $FE [$40] $EB $0C $81 $EF [$0080W]  $EB $06 $EB $04 $81
             $EF [$0080W]  $8B $44 $3E $03 $06 $B4 $9B $89 $44 $3E $83 $7C $3E
             $0A $7E $14 $83 $6C $3E $0A $FF $44 $40 $8B $44 $40 $3D [$0003W]
             $75 $05 $C7 $44 $40 [$0000W] $B8 [$0003W]  $50 $33 $C0 $50 $8B $44
             $40 $05 [$008FW]  $50 $8B $44 $0C $03 $C7 $50 $8B $44 $0A $03 $46
             $FE $50 $8B $C6 $05 $42 $00 $50 $9A $174E163ERL     $83 $C4 $0C
             $5F $5E $8B $E5 $5D $CB