Patch:Keen stunned (Vorticons)

From KeenWiki
Jump to navigation Jump to search

This page contains patches that cover Keen being stunned\frozen and recovering, as well as his shots in Keen games. Patches for individual episodes that relate to the player can be found at Patch:Keen (Keen 1), Patch:Keen (Keen 2) and Patch:Keen (Keen 3).

The only difference between Keen being frozen in Keen 1 and stunned in Keen 2\3 is his appearance. As such frozen Keen is covered on this page and all references to Keen being frozen instead refer to him being stunned.


How stunning works

In Keen Vorticons stunning relates to player-sprite collision. When Keen touches a sprite of any type various code is run. In the case of certain types that code will stun Keen. once stunned keen will use a unique behavior that prevents the player controlling him until a specified amount of time runs out; after which he will execute a 'recover' sequence, still not under the player's control.

Sprites that induce stunning are the Vortikid (Vorticon Youth) in Keen 2 and Keen 3.


Stun\recovery time

This is how long the player is stunned for. There is also an additional time, the 'recovery time' when the player cannot control Keen, but Keen's animation is different. This time is calculated in an unusual fashion; it is a negative time when Keen's stun counter drops below zero. For example in Keen 2 and 3 this is -40, or $D8. The maximum value is thus $80 or -128 unless a patch is used.

Keen 1

#Frozen time
%patch $468E [$0300W]

#Keen defrosting time
%patch $271C [$C0]

Keen 2

#Stun time
%patch $73FA [$0190W]

#Keen unstunning time
%patch $4A54 [$D8]

Keen 3

#Stun time
%patch $7CA2 [$0190W]

#Keen unstunning time
%patch $5581 [$D8]


Longer recovery time

This patch tweaks the way Keen's stun counter works to allow Keen to use the recovery animation for longer. By default when Keen's counter reaches zero he starts to recover, staying in that animation until the counter reaches a negative value. (See above.) This patch changes things so that this can happen before the counter reaches zero.

Here the default values are used; recovery starts when the counter is less than zero and stops when it is less than -40. By increasing the first blue value (To a maximum of $7F.) and decreasing the second (To a minimum of $80.) Keen's recovery time can be made longer.

Keen 2

#Longer stun recovery time (Between 00-D8)
%patch $4A3C $83 $06 $96EAW  $F8 $90 $90 $83 $3E $96EAW  [$00] $7D
%patch $4A54 [$D8]


Keen dies instead of recovering

This patch causes Keen to die instead of recovering when his stun time is up. It has two parts, the first line stops Keen from re-stunning or interacting with any other sprites until the level is reloaded. The second line runs his death code instead of his recover code.

Keen 3

#Keen dies instead of recovering from stunning
%patch $557D $C7 $06 $44 $99 {$6A00W} $90
%patch $5588 {$789EW}


Keen dies instead of recovering - reset score tweak

The above patch is incompatible however with the 'dying removes any points got in level' patch in that if Keen dies after being stunned his score will not be reset. The following patch includes the score reset patch with the side effect that Keen will move slightly differently when stunned. (His motion will stop entirely.)

Removing the two other score resets will make only Keen's stun-death resetting the score. Note that the blue $0800Ws are the alignments for Keen's death sprite.

Keen 3

#Save score on level load
%patch $81B7 $66 $A1 $9D4AW  $66 $A3 $AF00W  $66 $33 $C0 $66 $A3 $5361W  $66
             $A3 $586AW  $A3 $5D40W  $90

#Reset score on death A
%patch $7928 $66 $81 $06 $0E $71 [$0800W]  $0000W  $66 $A1 $AF00W  $66 $A3 $9D4AW  $90 $90

#Reset score on death B
%patch $7965 $66 $81 $06 $0E $71 [$0800W]  $0000W  $66 $A1 $AF00W  $66 $A3 $9D4AW  $90 $90

#Keen dies instead of recovering from stunning -reset score C
%patch $5576 $1D $C7 $06 $44 $99 $6A00W  $C7 $06 $42 $99 $789EW  $66 $81 $06
             $0E $71 [$0800W]  $0000W  $66 $A1 $AF00W  $66 $A3 $9D4AW  $C7 $06
             $9930W  $0000W  $E8 $0D17W  $E8 $0D57W  $E8 $1462W  $5D $C3


Stunning, freezing and sounds

When Keen is frozen in Keen 1 a sound is played. This is not the case for the other two episodes.

Keen 1

#Keen frozen sound
%patch $4691 $28


Don't play a sound when Keen is frozen

This patch for Keen 1 stops the freeze sound being played.

Keen 1

#Keen frozen sound disabled
%patch $4690 $EB $07


Play a sound when Keen is stunned

This patch plays a sound every time keen is stunned. it may have some side effects as it overwrites some of the stunning code. The brown value is Keen's stun behavior, the first blue value his stunned time and the second the sound to play.

Keen 3

#Play a sound when Keen is stunned
%patch $7C8E $C7 $44 $32 {$5553W}  $C7 $44 $2A [$0190W]  $B8 [$0003W] $50 $E8 $4CCAW
             $59 $EB $12


Complete Keen being stunned codes

This is the complete code run when Keen contacts a sprite of a stunning type. (See the relevant game's Keen page for details.) The two details of interest are the brown variable, which is the new behavior Keen uses (Being stunned) while the blue variable is how log he will be stunned for. It is not known what the rest of the code does.

These patches contain, and are thus incompatible with, other patches on this page.


Keen 1

This is the complete code run when Keen is frozen in Keen 1. The first thing done is to set Keen's behavior is to $26FEW and his stun time set at $0320W. After this sound $28 is played.

Keen 1

#Keen be stunned code
%patch $467A $C7 $44 $32 {$26FEW}  $8B $45 $20 $89 $44 $20 $8B $45 $22 $89 $44
             $22 $C7 $44 $2A [$0320W]  $B8 [$0028W]  $50 $E8 $785CW  $44 $44


Keen 2

The code for Keen 2 is the simplest of all Vorticons codes. The first thing done is to check Keen's behavior, if it is $4A29W, that is, if Keen is already stunned, then the stun code is skipped. Otherwise Keen's behavior is set to $4A29W and his stun time set at $0190W, along with some code to give Keen the speed of the sprite that stunned him.

Keen 2

#Keen be stunned code
%patch $73DF $81 $7C $32 {$4A29W}  {$74} $1B $C7 $44 $32 {$4A29W}  $8B $45 $20 $89
             $44 $20 $8B $45 $22 $89 $44 $22 $C7 $44 $2A [$0190W]


Keen 3

The code for Keen 3 is quite simple. On the first line Keen's behavior is checked. (The brown $32 is the sprite parameter to check.) If he is using the stunned behavior $5553W then the entire code is skipped (Stunned Keen cannot be re-stunned.) The next thing checked is the GOD mode status. (If Keen has god mode on he will not stun. See Patch:Game stats.)

The third thing checked is the Ankh time; if Keen has anything but 0 Ankh time he will not stun. Finally the stun code itself is reached. Keen's behavior is set to $5553W and his stun time is set to $0190W.

Keen 3

#Keen be stunned code
%patch $7C77 $81 $7C {$32} [$5553W]  {$74} $0E $83 $3E {$5FD6W}  [$00] {$75} $07 $83 $3E
             {$9946W}  [$00] {$74} $02 $EB $26 $C7 $44 $32 {$5553W}  $8B $45 $20 $89
             $44 $20 $8B $45 $22 $89 $44 $22 $C7 $44 $2A [$0190W]


Complete Keen stunned codes

These patches contain the complete stunned code (the code run when Keen is uncontrollable) for various games.


Keen 1

Frozen Keen's behavior sets his frozen and unfreezing animations as well as the code that is used when Keen returns to normal ($3867W, normal Keen behavior, highlighted in brown.) The last three $E8 $xxxxW code segments call gravity, clipping and movement code. Replacing the first with $90 $90 $90 will stop frozen Keen from falling (he will float.), the second will make him fall through tiles like a ghost (And likely die.) and the third will stop him moving completely.

Keen 1

#Frozen Keen behavior 
%patch $26FE $55 $8B $EC $A1 $5135W  $B1 {$05} $D3 $E8 $25 {$0001W}  $05 [$001CW]  #Frozen sprite animation speed, frames and sprite
             $A3 $8248W  $A1 $824AW  $2B $06 $5B14W  $A3 $824AW  $0B [$C0] $7D #Check time remaining
             $13 $C7 $06 $8248W  [$001FW]  $83 $3E $824AW  [$CE] $7D $06 $C7 $06 #Unfreezing sprite
             $8252W  {$3867W}  $E8 {$04F5W}  $E8 {$0535W}  $E8 {$0C2AW}  $5D $C3     #Unfreeze. Call gravity, stand on tiles and movement


Keen 2

This is the complete Keen 2 stunned code. It is rather complex. On the first line Keen's animation speed, animation frames and first stunned animation are set (Here each marked in blue and in that order.)

On the second line Keen's stunned counter ticks down in an interesting way; each cycle $5AF0W is taken away from it. This is 6 by default so his stun counter drops 6 each cycle. When the counter is less than zero ($0B [$C0] $7D) Keen's animation is set to $001FW, his recovering frame. The counter continues to drop lower however and when it is below -40 ($D8) Keen's behavior changes to normal. ($66A9W.) This means that the longest 'stun recovery' occurs when the counter check is $80 or -128, and also that the recovery time adds to Keen's total stunned time.

The rest of the code makes Keen slide to a halt. First his direction of movement is checked, if it is less than zero (Moving left) then a left slow is performed. Here a value of -3 ($FFFDW.) is sent to the 'slow speed' subroutine which then slows Keen's speed a little each cycle. After this the game checks to see if Keen's speed is greater than zero; that is if he has been slowed so much he's moving right. If it is, his speed is set to zero.

The net result of all this is to slow Keen's speed by 3 each cycle until it changes direction, at which point it is set to zero and no more change occurs. After this the same check is made for if Keen is moving right; this time slowing his speed by +3 ($0003W.) Finally the three brown $E8 $xxxxWs in the last row are the gravity, tile collision and movement checks. Replacing the first with $90 $90 $90 will make stunned Keen float, replacing the second will make him ghost through tiles (And likely fall offscreen and die.) and replacing the third will stop him moving completely when stunned.

Keen 2

#Complete Keen 2 stunned code
%patch $4A29 $55 $8B $EC $A1 $5111W  $B1 [$05] $D3 $E8 $25 [$0001W]  $05 [$001CW]     #Stunned animation
             $A3 $96E8W  $A1 $96EAW  $2B $06 $5AF0W  $A3 {$96EAW}  $0B $C0 $7D    #Check time remaining
             $13 $C7 $06 $96E8W  [$001FW]  $83 $3E {$96EAW}  [$D8] {$7D} $06 $C7 $06    #If <0, go to recovering stunned animation
             $96F2W  {$66A9W}  $83 $3E {$96E0W}  [$00] {$7E} $18 $B8 [$FFFDW]  $50 $E8    #If <-40, change behavior, check slide direction, slow
             $0F71W  $44 $44 $83 $3E {$96E0W}  [$00] {$7D} $25 $C7 $06 {$96E0W}  [$0000W] #If moving right set speed = 0
                 $EB $1D $83 $3E {$96E0W}  [$00] {$7D} $16 $B8 [$0003W]  $50 $E8 $0F52W #Check slide direction, slow
                 $44 $44 $83 $3E {$96E0W}  [$00] {$7E} $06 $C7 $06 {$96E0W}  [$0000W]     #If moving left set speed = 0
             $E8 {$0FD0W}  $E8 {$1010W}  $E8 {$1705W}  $5D $C3                        #Unstun. Call gravity, stand on tiles and movement


Keen 3

This is the complete Keen 3 stunned code. It is rather complex. On the first line Keen's stunned animation and number of stunned frames are set (Marked in blue.) On the second line the amount of time remaining is checked, on the third line if it is zero Keen's animation changes to that of recovering. A second check sets the recovery time ($D8 by default.) On the fourth line Keen will recover if the recovery time is up by changing his sprite behavior. On the same line Keen's speed is checked, if it is rightwards he will receive a small leftwards kick and have his speed set to zero. If it is left he will receive a small positive kick and have his speed set to zero. Finally the two brown $E8 $xxxxWs in the last row are the gravity and tile collision checks, replacing the first with $90 $90 $90 will make stunned Keen float, replacing the second will make him ghost through tiles (And likely fall offscreen and die.) and replacing the third will stop him moving completely when stunned.

Keen 3

#Complete Keen 3 stunned code
%patch $5553 $55 $8B $EC $A1 $5361W  $B1 $05 $D3 $E8 $25 [$0001W]  $05 [$001CW]     #Stunned animation
             $A3 $9938W  $A1 $993AW  $2B $06 $5D40W  $A3 $993AW  $83 $3E {$993AW} #Check time remaining
                 [$00] {$7D} $13 $C7 $06 $9938W  [$001EW]  $83 $3E $993AW  [$D8] {$7D}    #If 0, go to recovering stunned animation
             $06 $C7 $06 $9942W  {$6F07W}  $83 $3E {$9930W}  [$00] {$7E} $17 $B8 [$FFFDW] #If recovered change behavior, check movement direction
                 $50 $E8 $0C90W  $59 $83 $3E {$9930W}  [$00] {$7D} $06 $C7 $06 {$9930W} #If moving right set speed = 0
                 [$0000W]  $EB $1C $83 $3E {$9930W}  [$00] {$7D} $15 $B8 [$0003W]  $50    #If moving left set speed = 0
             $E8 $0C72W  $59 $83 $3E {$9930W}  [$00] {$7E} $06 $C7 $06 {$9930W}  [$0000W]
                 {$E8 $0CEDW  $E8 $0D2DW}  $E8 {$1438W}  $5D $C3                    #Unstun. Call gravity, stand on tiles and movement

Unfreezing Keen has two frames

#Extra frame when unstunning - Keen 1
%patch $2730 $0AF2W
%patch $0AF2 $55 $8B $EC $C7 $06 $8248W  $001EW  $A1 $824AW  $03 $06 $5B14W
             $A3 $824AW  $3D $0014W  $7E $06 $C7 $06 $8252W  $3867W  $5D $C3

Stunned Keen can be 're-stunned'

These patch remove the behavior checks. This means that when Keen is stunned\frozen he can be 're-stunned'; resetting his stun time. This makes stunning even more aggravating as enemies can continually re-stun Keen, possibly trapping the player in an infinite loop. This does not apply to Keen 1, where frozen Keen can be re-frozen, resetting his stun time to 0.

Stunned Keen can be 're-stunned'

#Stunned Keen can be 're-stunned' - Keen 2
%patch $7407 $73E6W

#Stunned Keen can be 're-stunned' - Keen 3
%patch $7CBA $7C7EW


Still be stunned with GOD mode

This patch allows Keen to always be stunned by the Vortikid (Vorticon Youth) in Keen 3, even if he has GOD mode enabled. In Keen 1 and 2 Keen can always be frozen\stunned whether or not he has GOD mode.

Keen can still be stunned by Youths with GOD mode

#Keen can still be stunned by Youths with GOD mode - Keen 3
%patch $7C83 $90 $90


Youths stun Keen even with Ankh

As expected this patch allows the Youths to stun Keen even if he has Ankh time remaining. There is no equivalent patch for Icecubes. or Youths in Keen 2.

Keen 3

#Youths stun Keen even with Ankh
%patch $7C8A $EB


Keen's animations

Keen has a two animation loop when stunned that continues until recovery. The recovery frame does not animate but quickly changes when the player recovers.

Keen stunned\frozen animations

#Keen 1
%patch $270C $1C #Frozen
%patch $2709 $01 #Frames used -1
%patch $2705 $05 #Animation speed
%patch $2723 $1F #Keen unfreezing

#Keen 2
%patch $4A37 $1C #Keen stunned
%patch $4A34 $01 #Frames used -1
%patch $4A30 $05 #Animation speed
%patch $4A4E $1F #Keen recovering

#Keen 3
%patch $5561 $1C #Keen stunned
%patch $555E $01 #Frames used
%patch $555A $05 #Animation speed
%patch $557B $1E #Keen recovering


Keen wins the level instead of stunning

This patch makes Keen win the level instead of being stunned. The level is exited instantly. This code replaces Keen's behavior so all the restrictions relating to ankh time and god mode are still in place. (Keen cannot win the level this was if cheating, by default.)

Keen wins the level instead of stunning

#Keen wins the level instead of stunning - Keen 3
%patch $7C93 $C7 $06 $6E8CW  $0001W


Keen wins the level instead of recovering from stunning

This patch is similar to the above, except keen wins the level when he recovers.

Keen wins the level instead of recovering from stunning

#Keen wins the level instead of recovering from stunning - Keen 3
%patch $5577 $C7 $06 $8C $6E $0001W