Patch:Keen (Keen 5)
This page contains patches relating to Keen as a sprite in Keen 5. That is, such things as the sprites used, the speeds and sounds. It does not cover patches relating to gameplay such as those that make levels scroll or change keys. Those can be found at Patch:Gameplay (Keen Galaxy). It is divided into sections relating to the various sprite properties the patches involved. Being fluent with various sprite patch pages will help when working with these patches.
As little is known about Keen, there is less information here than for most sprites.
Keen behaviors with their own pages
The following pages have been created for specific Keen actions that have a significant number of patches, necessitating them being kept separate for clarity:
- Patch:Keen bored
- Patch:Keen dying (Galaxy)
- Patch:Keen jumping (Galaxy)
- Patch:Keen look down
- Patch:Keen look up
- Patch:Keen on map (Galaxy)
- Patch:Keen on Platforms
- Patch:Keen on poles
- Patch:Keen shooting (Galaxy)
- Patch:Keen's shot (Galaxy)
- Patch:Keen walking (Galaxy)
Sprite Actions
This is a complete list of Keen's actions, both in-level and on the map. t provides links to some pages that discuss specific actions in further detail but a discussion of all of Keen's actions is too complex to host on this page.
Actions: $0888W #Keen standing $08A6W #Keen on Platforms $08C4W #Keen looks up (Bored) $08E2W #Keen shrugs 1 (Bored more) $0900W #Keen shrugs 2 $091EW #Keen shrugs 3 $093CW #Keen shrugs 4 $095AW #Keen shrugs 5 $0978W #Keen shrugs 6 $0996W #Keen starts reading book 1 $09B4W #Keen starts reading book 2 $09D2W #Keen starts reading book 3 $09F0W #Keen starts reading book 4 $0A0EW #Keen reads book 1 $0A2CW #Keen reads book 2 $0A4AW #Keen reads book 3 $0A68W #Keen stops reading book 1 $0A86W #Keen stops reading book 2 $0AA4W #Keen stops reading book 3 $0AC2W #Keen looking up $0AE0W #Keen keep looking up $0AFEW #Keen looks down start $0B1CW #Keen looks down $0B3AW #Keen keep looking down $0B58W #Keen stops looking down $0B76W #Keen stops looking down start (Screen has moved) $0B94W #Defunct dead action $0BB2W #Keen dies sprawled (Restarts level if offscreen.) $0BD0W #Keen dies clutched (Restarts level if offscreen.) $0BEEW #Keen shooting horizontally start $0C0CW #Keen shooting horizontally $0C2AW #Keen shooting up start $0C48W #Keen shooting up $0C66W #Keen flicking switches $0C84W #Keen flicking switches $0CA2W #Keen places gem $0CC0W #Keen start interaction with gem holders/ walk-in doors $0CDEW #Keen walks into doors $0CFCW #Keen walks into doors $0D1AW #Keen walks into doors $0D38W #Keen walks into doors $0D56W #Keen walks into doors $0D74W #Keen walks into doors $0D92W #Keen walks into doors $0DB0W #Keen walks into doors $0DCEW #Keen still on a pole $0DECW #Keen going up a pole $0E0AW #Keen going up a pole $0E28W #Keen going up a pole $0E46W #Keen going down a pole $0E64W #Keen going down a pole $0E82W #Keen going down a pole $0EA0W #Keen going down a pole $0EBEW #Keen shooting horizontally on a pole start $0EDCW #Keen shooting horizontally on a pole $0EFAW #Keen shoots up on pole start $0F18W #Keen shoots up on pole $0F36W #Keen shooting down on a pole start $0F54W #Keen shooting down on a pole $0F72W #Keen walking $0F90W #Keen walking $0FAEW #Keen walking $0FCCW #Keen walking $0FEAW #Keen start pogoing $1008W #Keen pogoing $1026W #Keen pogoing $1044W #Keen jumping 1 $1062W #Keen jumping 2 $1080W #Keen falling 1 $109EW #Keen falling 2 $10BCW #Keen shoot horizontally in air start $10DAW #Keen shoot horizontally in air (Make shot) $10F8W #Keen shoot horizontally in air $1116W #Keen shoot up in air start $1134W #Keen shoot up in air (Make shot) $1152W #Keen shoot up in air $1170W #Keen shoot down in air start $118EW #Keen shoot down in air (Make shot) $11ACW #Keen shoot down in air $11CAW #Keen gripping ledge start $11E8W #Keen gripping ledge $1206W #Keen pulls himself up from ledgegripping 1 $1224W #Keen pulls himself up from ledgegripping 2 $1242W #Keen pulls himself up from ledgegripping 3 $1260W #Keen pulls himself up from ledgegripping 4 $127EW #Keen stands back up $137AW #Map Keen standing (clear walking animations) $1398W #Map Keen wait (Maintain existing animation until keypress) $13B6W #Map Keen wave 1 $13D4W #Map Keen wave 2 $13F2W #Map Keen wave 3 $1410W #Map Keen wave 4 $142EW #Map Keen wave 5 $144CW #Map Keen moving
Impossible bullet in Keen 5
This patch allows Keen to perform the impossible bullet glitch in Keen 5. Note that Keen will take his platform stance when performing this trick, which looks even more unusual than in Keen 6. It works by making Keen's shot acquire the Platform sprite property when it hits tiles.
Keen 4
#Keen can 'impossible bullet' in Keen 5
%patch $DD6C $0006W
Sprite Collision
Keen has several sprite collisions used in a variety of circumstances. As such this section does not list the collision values of Keen's actions but instead deals with the more general collision codes.
For patches that affect what collision a specific action uses, see that action's page. (For example Patch:Keen on poles.)
Collision 1 code
This collision, often known as KeenSpriteCollision is used under a variety of circumstances. Keen uses this collision when doing such things as being bored, looking up or down and mooning the player. The collision is exceedingly complex and is notable for using a pointer list that is utterly pointless.
The first section is the 'hub' separating the two basic sprite types Keen reacts to. The first is platforms (Type 6) and the second items (Type 5). Interestingly though the item jump is last, its code is section 2.
The second, largest, section deals with the various kinds of items Keen encounters. The first part deals with how many kinds of items there are; it skips the item code if an item's 'kind' is larger than 12 (Giving a total of 13 different types of item.) It calls a list at $C155 ($AAF0 + $1665W) which in this case is a trivial list pointing to $C0B2 ($AAF0 + $15C2W).
What is done to all item sprites is covered right after the list setup (Line 3 and onwards). First a 'got item' sound is played based on the list located at $30340 + $12BAW = $315FA. Then the sprite's sprite type is set to 1, the 'misc sprite' type. Then its foreground variable is set to 3 so it appears in front of all tiles. (So the player can see all the items they get.) After this the sprite's animation changes based on the 'got item animation list' at $30340 + $12EE = $3162E and the player's score increases by an amount given in the list located at $30340 + $12D4 = $31614. This is the same basic code for all items.
After this code more specific to various types of items is run. On line 6 a check is made for the keygems which adds a gem to the player's gem counter (The first counter is shown, depending on gem this or the next three counters will be affected.) After this a check is made for the 1UP item type which increases the player's life counter by 1. Following that is the ammo type check which increases the player's ammo counter ($6F6CW) by an amount that depends on the difficulty ($6F56W) using a list of values found at dataseg $12B2W. Finally there is a check for the V card item, which if contacted sets the card variable to 1. Following this the last thing done is for the sprite's action to be changed to that of the got item.
The third section deals with platforms. Platforms have no effect if an unknown variable is 0 but otherwise allow Keen to stand on them.
Keen Collision 1 code
#Keen sprite collision: First section, jumps
%patch $C087 $55 $8B $EC $56 $8B $76 $08 $8B $04 $3D [$0005W] {$74} $0B $3D [$0006W]
{$75} $03 $E9 $009EW $5E $5D $CB
#Second section, items
$8B $5C $3E $83 $FB [$0C] {$76}
$03 $E9 $00A6W $D1 $E3 $2E $FF $A7 {$1665W} $8B $5C $3E $D1 $E3
$FF $B7 {$12BAW} $9A $196E09EFRL $83 $C4 $02 $C7 $04 [$0001W]
$C7 $44 $20 [$0003W] $8B $5C $3E $D1 $E3 $8B $87 {$12EEW} $89 $44
$1E $8B $5C $3E $D1 $E3 $FF $B7 {$12D4W} $9A $06B91EAERL $83
$C4 $02 $83 $7C $3E [$04] {$7D} $0B $8B $5C $3E $D1 $E3 $FF $87 {$6F60W}
$EB $2E $83 $7C $3E [$0A] {$75} $06 $FF $06 {$6F6AW} $EB $22 $83
$7C $3E [$0B] {$75} $10 $8B $1E {$6F6CW} $D1 $E3 $8B $87 {$12B2W} $01
$06 {$6F56W} $EB $0C $83 $7C $3E [$0C] {$75} $06 $C7 $06 {$6F5AW} [$0001W]
$B8 [$19BEW] $50 $56 $9A $090B1242RL $83 $C4 $04 $5E $5D
$CB $5E $5D $CB
#Third section, Platforms
$83 $3E {$6F6EW} [$00] {$75} $0F $56 $FF $76 $06 $9A
$090B0D6BRL $83 $C4 $04 $5E $5D $CB $5E $5D $CB
#Pointless Keen-item collision list
%patch $C155 [$15C2W] #Red Gem (At $C0B2)
%patch $C157 [$15C2W] #Yellow Gem (At $C0B2)
%patch $C159 [$15C2W] #Blue Gem (At $C0B2)
%patch $C15B [$15C2W] #Green Gem (At $C0B2)
%patch $C15D [$15C2W] #100 points (At $C0B2)
%patch $C15F [$15C2W] #200 points (At $C0B2)
%patch $C161 [$15C2W] #500 points (At $C0B2)
%patch $C163 [$15C2W] #1000 points (At $C0B2)
%patch $C165 [$15C2W] #2000 points (At $C0B2)
%patch $C167 [$15C2W] #5000 points (At $C0B2)
%patch $C169 [$15C2W] #1UP (At $C0B2)
%patch $C16B [$15C2W] #Ammo (At $C0B2)
%patch $C16D [$15C2W] #V card (At $C0B2)
Collision 2 code
This collision, often known as KeenOnPolesSpriteCollision is actually used under a variety of circumstances. Keen uses this collision when looking up or down, climbing poles and gripping ledges. The collision is far simpler than the first sprite collision, ignoring many sprite types. Unlike Keen's first sprite collision it doesn't use a pointer list.
The first thing checked for is sprites of type 6, Moving Platforms. If this type is found then the code jumps the next two checks and goes to line 3. The next two checks check for types $0E and $17; types that push Keen around. (The Little Ampton and Korath respectively.) If found then the code jumps to the second section, otherwise the collision ends.
The second section, starting on line 3, is the 'platform section' Keen's clipping is set to 1 and he is knocked back to his standing or falling action depending on whether he is in the air or not. $090B0D6BRL 'Push Keen vertically' is also run so that Keen will be picked up by a passing Platform.
The last section deals with Keen being pushed about by Koraths and Amptons; it is similar to the code dealing with Platforms except Keen's foreground variable is set to 1 and 'Push Keen vertically' is not run.
Keen Collision 2 code
#Keen sprite collision code:
%patch $C16F $55 $8B $EC $56 $57 $8B $76 $06 $8B $7E $08 $8B $05 $3D [$0006W]
$74 $0E $3D [$000EW] $74 $34 $3D [$0017W] $74 $2F $5F $5E $5D $CB
$C7 $44 $06 [$0001W] $B8 {$1080W} $50 $56 $9A $090B1242RL $83
$C4 $04 $33 $C0 $89 $44 $18 $89 $44 $16 $A3 $C181W $57 $56 $9A
$090B0D6BRL $83 $C4 $04 $5F $5E $5D $CB
$C7 $44 $20 [$0001W]
$C7 $44 $06 [$0001W] $B8 {$1080W} $50 $56 $9A $090B1242RL $83
$C4 $04 $33 $C0 $89 $44 $18 $89 $44 $16 $A3 $C181W $5F $5E $5D
$CB
Sprite-tile interaction
The player's tile interaction, the game tile code is not in fact part of Keen's tile interaction. Instead it is run by the designated player sprite whatever its current tile interaction may be. Keen in fact has several tile interactions depending on what he is doing.
Move switches one tile down
This patch for Keen 5 moves switches one tile down; that is, instead of working at the height of Keen's head they are located by his feet. (Unless Keen is made taller than 2 tiles.) However the patch is not 'complete'; only the animation is moved down, a switch tile is still required at Keen's head height (One tile above where the tile will animate.) However if this tile is made invisible and nonanimating, it will at least appear that the switch has been moved down a tile.
Keen 5
#Move switches one tile down (Almost)
%patch $B4AA $C8 $0016W $00 $56 $57 $8B $5E $06 $8B $5F $2E $43 $53
%patch $B51D $59 $B8 $0001W $50 $50 $8B $5E $06 $51 $90
Sprite spawn code
There are two initiation codes, one for Keen facing left and one for Keen facing right. Both are nearly identical except for Keen's starting direction. Both use the same spawning code. The call $0CCB0007RL is used to mark the sprite as the player.
In the initiation code notice the Keen's cache being set ($C7 $06 $C269W $0001W.) Also notice that both initiation codes cache the scoreboard image ($00EBW) separately.
In the spawning code the last blue highlighted value is the sprite action the sprite uses as it proceeds to act in-level. $C7 $02 $xxxxW sets the clipping, $C7 $07 $xxxxW sets the sprite type, $C7 $20 $xxxxW sets the foreground value. Finally $D3 $E0 $05 $xxxx is how far down (Or more usually up) the sprite is spawned from where it is placed. This is necessary for sprites that walk on the ground as they can only be placed in the level at multiples of 16 pixels high while their actual height can be anything.
Keen's horizontal direction depends on his initiation code. (It is the first blue variable.) He always starts the level 'facing down' however, though this is of little importance. $C7 $47 $10 $xxxxW is the vertical direction the sprite starts moving in, either $0001W (Facing down), $FFFFW (Facing up) or $0000W (Neither, never used.) Keen's sprite type is important, if it is not $0002W then he will be invulnerable to enemy sprites since this sprite type is used to identify 'killable players'
Keen 5
#Location of initiation codes
%patch $F4C6 [$0146W] #Keen right (At $EE96)
%patch $F4C8 [$0170W] #Keen left (At $EEC0)
#Right facing Keen Initiation code
%patch $EE96 $B8 [$0001W] $50 $57 $56 $9A {$0AAF0000RL} $83 $C4 $06 $9A #Keen's direction is +1
{$0CCB0007RL} $C7 $06 $C269W $0001W $B8 $2B7BRW $8A $16 $EC $6F #Cache scoreboard too
$8E $C0 $26 $08 $16 [$00EBW] $E9 $04E7W
#Left facing Keen Initiation code
%patch $EEC0 $B8 [$FFFFW] $50 $57 $56 $9A {$0AAF0000RL} $83 $C4 $06 $9A #Keen's direction is -1
{$0CCB0007RL} $C7 $06 $C269W $0001W $B8 $2B7BRW $8A $16 $EC $6F #Cache scoreboard too
$8E $C0 $26 $08 $16 [$00EBW] $E9 $04BDW
#Normal Keen spawning code
%patch $AAF0 $55 $8B $EC $8B $1E $9E3EW $C7 $07 [$0002W] $C7 $47 $02 [$0002W]
$C7 $47 $20 [$0001W] $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B
$46 $08 $D3 $E0 $05 [$FF0FW] $89 $47 $0C $8B $46 $0A $89 $47 $0E
$C7 $47 $10 [$0001W] $B8 [$0888W] $50 $53 $9A $13B511C4RL $83
$C4 $04 $5D $CB
Keen's spawn height and changing Keen's height
This simple patch alters how high Keen spawns above where he is placed in a level. By default this is 16 pixels up,suitable for a Keen sprite 32 pixels high. If Keen's height is changed, this should be changed to reflect that. It is part of the above spawning code patch and shouldn't be used in conjunction with it.
Keen 5
#Keen's spawn height
%patch $AB15 [$FF0FW] #16 pixels up