Patch:Keen dying (Keen 5)

From KeenWiki
Jump to navigation Jump to search

This page contains patches relating to Keen's death in Keen 5, its causes and effects as well as patches that affect dying Keen's sprite. Other pages relating to Keen's death in other games can be found at Patch:Dead Keen.

In Keen 5 Keen can die in a number of ways, the three most basic being: falling out of the level bottom, lethal sprites and lethal tiles. In all cases Keen will use the same 'death code'. Keen has a choice of two death actions, chosen at random. While dead keen can be 'killed' again changing his death action. This can result in humorous sequences where Keen 'bounces' across the screen, repeatedly hitting lethal objects.

This page is split into two sections; the first is Keen's death code itself, the second containing patches relating to dead Keen's sprites.


Death code

This section contains patches that alter Keen's death code, that is, the circumstances in which he becomes dead.


Default death code

This is the code run each time Keen is killed. A number of things will be noticed. Firstly there are some conditions under which Keen cannot die. The first is the PlayLoop timer (which has several functions.) It is set to $1E when Keen successfully dies. The second checks if god mode is enabled and the third and final check is whether Keen is using a defunct exception action. (Oddly there is no place in the game that sets this action so this check is pointless.)

Secondly a number of variables are set; clipping is turned off (So dead Keen doesn't get stuck.), foreground is set to 3 (So dead Keen always appears in front of tiles and doesn't look odd.) Keen's 'mooning value' is set to 0 so that if he dies after mooning he can do so again, despite the fact that Keen does not moon in Keen 5. Two other variables are set, one may be the sprite type, the other is the screen scroll variable (This stops the screen scrolling when Keen dies and is needed to prevent bugs.)

There are two possible actions Keen may die into, dead 'sprawled' dead 'clutched'. It can be seen that there is a 50% chance of Keen being either sprawled or clutched, this is controlled by a random check of value 80. (50\50) Setting the value to zero will make Keen only die using one action. Finally near the end of the code sound 17 is played and Keen's speed is set to jump up slightly and move right.

This code contains a number of smaller patches listed on this page and may not be compatible with them if placed after them in the patch file.

Keen 5

#Kill Keen code
%patch $C007 $55 $8B $EC $83 $3E {$BC39W}  [$00] {$75} $74 $83 $3E {$BC91W}  [$00] {$75} #Check for godmode, PlayLoop timer
             $6D $8B $1E $3E $9E $81 $7F $1C [$0B94W]  {$74} $62 $C7 $06 {$C17BW}  #Check action, set mooning = 0
             [$0000W]  $C7 $06 {$BC39W}  [$001EW]  $C7 $06 $9E42W  [$0001W]  $C7 $47 #Set PlayLoop, scrolling
             $06 [$0000W]  $C7 $47 $20 [$0003W]  $9A $1DFB0036RL     $3D [$0080W]  #Set clipping and foreground, random check
             $7D $12 $B8 [$0BB2W]  $50 $FF $36 $3E $9E $9A $090B1242RL     $83 #Dead Keen 1
             $C4 $04 $EB $10 $B8 [$0BD0W]  $50 $FF $36 $3E $9E $9A $090B1242RL #Dead Keen 2
                 $83 $C4 $04 $B8 [$0017W]  $50 $9A $196E09EFRL     $83 $C4 $02 #Play sound
             $8B $1E $3E $9E $C7 $47 $18 [$FFD8W]  $C7 $47 $16 [$0010W]  $5D $CB #Set speed to -24 V, 16 H


Probability and randomness

This patch alters the probability that Keen will die using one death frame as opposed to the other. By default this is 50:50, meaning that each time Keen dies he has an equal chance of dying in either of two possible death frames.

Keen 5

#Probability of dying sprawled
%patch $C045 [$80]


Dead Keen uses only one animation

This patch substantially reduces the size of the kill Keen code, making it far easier to copy and thus allow multiple Keen deaths. It also ensures Keen dies the same way every time, useful if something novel is to be done with dead Keen. Here Keen dies and only uses the 'normal sprawled' frame. The first patch makes keen just fall offscreen, the second makes him 'bounce' like he does by default.

Keen 5

#Kill Keen code, die only one way - no bounce
%patch $C007 $55 $8B $EC $83 $3E {$BC39W}  [$00] {$75} $4A $83 $3E {$BC91W}  [$00] {$75} #Check for godmode, PlayLoop timer
             $43 $8B $1E $3E $9E $81 $7F $1C [$0B94W]  {$74} $38 $C7 $06 {$C17BW}  #Check action, set mooning = 0
             [$0000W]  $C7 $06 {$BC39W}  [$001EW]  $C7 $06 $9E42W  [$0001W]  $C7 $47 #Set PlayLoop, scrolling
             $06 [$0000W]  $C7 $47 $20 [$0003W]  $B8 [$0BD0W]  $50 $FF $36 $3E $9E #Set clipping and foreground, dead action
             $9A $090B1242RL    $83 $C4 $04 $B8 [$0017W]  $50 $9A $196E09EFRL  #Play sound
             $83 $C4 $02 $5D $CB

Keen 5

#Kill Keen code, die only one way - bounce
%patch $C007 $55 $8B $EC $83 $3E {$BC39W}  [$00] {$75} $58 $83 $3E {$BC91W}  [$00] {$75} #Check for godmode, PlayLoop timer
             $51 $8B $1E $3E $9E $81 $7F $1C [$0B94W]  {$74} $46 $C7 $06 {$C17BW}  #Check action, set mooning = 0
             [$0000W]  $C7 $06 {$BC39W}  [$001EW]  $C7 $06 $9E42W  [$0001W]  $C7 $47 #Set PlayLoop, scrolling
             $06 [$0000W]  $C7 $47 $20 [$0003W]  $B8 [$0BD0W]  $50 $FF $36 $3E $9E #Set clipping and foreground, dead action
             $9A $090B1242RL    $83 $C4 $04 $B8 [$0017W]  $50 $9A $196E09EFRL  #Play sound
             $83 $C4 $02 $8B $1E $3E $9E $C7 $47 $18 [$FFD8W]  $C7 $47 $16     #Set speed to -24 V, 16 H
         [$0010W]  $5D $CB


Dead Keen doesn't fall

This patch will stop Keen from responding to gravity, that is falling offscreen when he dies. Since however the level can only be restarted when he leaves the screen, some other form of movement must be implemented. By default he will move sideways off the screen if this patch is used.

Keen 5

#Dead Keen doesn't fall
%patch $BFDF $90 $90 $90 $90 $90


God mode doesn't prevent dying

This patch stops God mode from making Keen immortal, effectively rendering it useless. It does this by skipping the God mode check in the death code.

Keen 5

#Skip godmode check
%patch $C011 $EB $05


Keen can also die on map

This is a tweak to the game's code that creates a third death action that appears only on the map. It does this by repurposing an (apparently) unused door entering action and flag-flipping sprite. The special level here is shown in blue. (If it is not the map level than some other sprite must be used for the death action since the flag is only cached on the map.)

This patch works with the default death code and changes the two default death actions, so is incompatible with any patch on this page that alters or limits them.

Keen 5

#Keen can die on map
%patch $3103C $010CW $010CW $0002W $0000W $0000W $0064W $0000W $0000W
              $0AAF14E7RL   $00000000L    $090B17B5RL   $0CFCW
%patch $C048 $05 $B8 $0BB2W  $EB $03 $B8 $0BD0W  $83 $3E {$9E55W}  [$00] {$75} $03
             $B8 $0CFCW  $50 $90 $90 $90


Dead Keen's sprite frames

This section contains patches that relate to Keen after he has died, his death animations and how they act.


Sprite Actions

There are only a few actions associated with Keen's death. One of these is the 'defunct' action originally meant to stop Keen 're-dying' when already dead. This was dropped however and although the action exists there is no way for Keen to use it. It is checked for however in keen's death code.

There are two possible death actions chosen at random when Keen dies. Both of these actions continue to animate to themselves, not changing action at all. (Though they can 're-die' and change actions that way.)

Actions:
$0B94W #Defunct action (Not used)
$0BB2W #Keen dies sprawled (Exits level if offscreen.)
$0BD0W #Keen dies clutched (Exits level if offscreen.)

Keen 5

#Don't die if using this action
%patch $C01F [$0B94W]

#When dying become one of these two actions
%patch $C04A [$0BB2W]
%patch $C05C [$0BD0W]

#When dead sprawled
%patch $30F0E [$0BB2W]

#When dead clutched
%patch $30F2C [$0D10W]


Sprite Behavior

The defunct action has no behavior and it does not matter if it is given one. There is one unique dead Keen behavior that is used by both of Keen's dead frames. This behavior loses the level if the sprite goes offscreen.

Behaviors:
$00000000L  #Nothing
$0AAF14E7RL #Lose level if offscreen

Keen 5

#Defunct action
%patch $30EE4 $00000000L

#Dead Keen
%patch $30F02 $0AAF14E7RL #Sprawled
%patch $30F20 $0AAF14E7RL #Clutched


Speed

There are two main sets of speeds relating to dead Keen. The first is the 'bounce' Keen gets when killed. This is both upwards and rightwards to ensure that Keen will quickly move off of any hazard he is touching and not get stuck in an 'infinite death loop'

The other set of speeds involve animation motion. None of dead keen's actions use these speeds at all.

Dead Keen 'bounce' speeds

#Dead Keen 'bounce' speeds
%patch $C07E [$FFD8W] #Up
%patch $C083 [$0010W] #Right

Animation motion

#Defunct action
%patch $30EE0 [$0000W $0000W]

#Dead Keen
%patch $30EFE [$0000W $0000W]
%patch $30F1C [$0000W $0000W]


Sprite Collision

None of Keen's dead actions have any collision. They do not interact with sprites, though they may still trigger the 'Keen die' code when sprites react to them.

Keen 5

#Defunct action
%patch $30EE8 $00000000L

#Dead Keen
%patch $30F06 $00000000L #Keen dies
%patch $30F24 $00000000L #Keen dies


Animations

There are two animations each for Keen dying normally, or underwater. There is also a separate, invisible frame that brings up the 'Didn't make it past window'. Finally when Keen is eaten by a Dopefish there is a two frame sequence that results in an invisible dead Keen similar to the 'restart level' action.

Keen 5

#Defunct action
%patch $30ED4 $FFFFW $FFFFW #Invisible
%patch $30EDE $000AW        #Animation speed

#Dead Keen
%patch $30EF2 $008CW $008CW #Sprawled
%patch $30EFC $0064W        #Animation speed
%patch $30F10 $008DW $008DW #Clutched
%patch $30F1A $0064W        #Animation speed


Sounds

Keen makes a sound each time he dies. This is the only death related sound and it can be blocked.

Keen 5

#Keen dies sound
%patch $C06C $17

#Don't play Keen dies sound
%patch $C06B $EB $0A


Clipping and foreground

When Keen dies his clipping is set to 0 (So he can pass through tiles offscreen and doesn't get stuck in a block.) and foreground is set to 3 (So he appears in front of all tiles and most sprites, making him appear very prominent.)

Clipping

#Dead Keen clipping
%patch $C038  $0000W #Keen dies

Foreground

#Dead Keen foreground
%patch $C03D  $0003W #Keen dies


Sprite-tile interaction

All of dead Keen's actions use the basic 'draw' tile collision that doesn't interact with any tiles in any way. (Though if their clipping is 1 or higher tiles will still bock them.)

Sprite-tile interaction

#Defunct action
%patch $30EEC $090B17B5RL

#Dead Keen
%patch $30F0A $090B17B5RL
%patch $30F28 $090B17B5RL


Action type

All of dead Keen's actions are type 2 meaning they ignore their animation timer but react instantly to outside influences. The exception is invisible dead Keen which is type 0, allowing it to wait until its animation timer runs out before losing the level.

Keen 5

#Defunct action
%patch $30ED8 [$0002W]

#Dead Keen
%patch $30EF6 [$0002W]
%patch $30F14 [$0002W]


Deprotect and stick to ground

None of Dead Keen's actions need to stick to the ground and so neither of these variables is used by any of the actions.

Keen 5

#Defunct action
%patch $30EDA [$0000W $0000W]

#Dead Keen
%patch $30EF8 [$0000W $0000W]
%patch $30F16 [$0000W $0000W]


Probability and randomness

See above in the first section of this page for patches relating to the probability of Keen dying with a certain action.