Patch:Keen walking (Vorticons)

From KeenWiki
Jump to navigation Jump to search

This page contains patches that cover Keen walking and his speed animation and behavior while doing so Keen Vorticons. Some patches will overlap other game actions, such as patches relating to Keen stopping walking and going to standing, or jumping. Since the three Vorticons games are so similar patches for all three are treated together on this page. 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). Patches relating to walking on the map are covered under Patch:Keen on map (Vorticons)

Keen's walking behavior is also his standing behavior. As such both are covered on this page.

Sprite Behavior

Keen's walking and standing behavior is rather complex as there are several things Keen can do while standing\walking. Keen also 'returns' to standing under several circumstances, such as after being frozen\stunned, after landing on ground or rideable sprites and after shooting.

Keen 1

#After recovering from freezing
%patch $2730 {$3867W}

#When landing on ground
%patch $3D72 {$3867W}

#After shooting
%patch $3E7F {$3867W}

%patch $4B7B {$3867W}

#While riding a sprite
%patch $3111 {$3867W}

Behavior code

This is the complete walking\standing behavior code. On the first line the game checks Keen's Misc Variable D, if it is not 0 then the game will skip the next six lines of code. The next three lines seem to store Keen's hitbox for use when colliding with other sprites. Lines 4-7 are unknown.

Line 8 involves jumping; $7FCCW is the 'Keen's action' variable. If it is 0 then Keen is jumping. The first thing done is storing Keen's current speed in Misc variable C so that it can be used by the jumping behavior, then sets his speed, Misc variable B and animation timer to 0. $604CW is checked (This relates to which way keen is facing) and sets Keen's Misc variable A to 8 or 14. This is the starting jumping animations for facing right and left respectively. Finally Keen's behavior is set to 'jumping'.

The next section relates to walking; Keen's action variable is checked and if 3 then variable $7FCAW is checked. This refers to a list of length 6 at $3B7DW. Values 0-3 run code at $392B, 4-6 code at $3943W and 3 $3959W These codes send +2 or -2 to a subroutine and if Keen is moving in the right direction also changes $7FCAW to 8, or in the case of $3959W, skip the section entirely. This makes Keen walk left, right or not at all. Changing the list values to $3959W, will stop Keen being able to start walking left\right while standing. (He can still jump and pogo though.)

The fourth section relates to stopping walking. If the Keen action variable is 1 then $7FCAW is checked. If it is 8 (Which it will be if it has been set by the previous section.) the Keen's speed is checked. If Keen's speed is leftwards then -3 is sent to a subroutine then the speed checked again. If rightwards it is set to 0 and the rest of the code skipped. If Keen's speed is rightwards 3 is sent to a subroutine then it is checked again If leftwards it is set to 0. In essence +/-3 are how fast Keen stops walking.

The fifth section relates to initial walking speed. This is a boost Keen gets when he starts walking. First Keen's action variable is checked to see if he is indeed walking (State 3) If so his direction is checked ($604CW) and his horizontal speed set to +-180.

Section 6 deals with Keen's standing and walking animations. First the game checks Keen's speed, if not 0 this section is skipped. else keen's direction ($604CW) is checked and his sprite animation set to 0 or 4. If on the other hand his speed is not 0 then his direction is checked. Both walking directions have an initial animation of 0 or 4 with 3 other frames and an animation speed of 4. On the last line Keen's movement speed is stored in $604CW for continued use by the code.

Section 7 deals with walking sounds. First the game checks to see if Keen is moving. If so a check is made to see if a sound should play then a second check to see what that sound should be (4 or 1E.) The sound is then played.

Section 8 deals with tile collision. First the sprite movement, gravity and tile collision subs are run. The first three lines check to see if Keen is walking into a left or right wall, if so, and it is time to play a sound, the blocked sound (5) is played. Next floors are checked for. If not found and Keen's Misc Variable D is 0 then sound $1B is played and Keen's behavior set to 'fall' ($3C99W). All the rest of the code is then skipped.

Section 9 deals with jumping while walking. Keen's action variable is checked; if it is 0 (standing) then the section is skipped. If not Keen's speed is stored in Misc variable C then set to 0, as is Misc variable B and the animation timer.$604CW (Keen's stored direction) is checked and Misc variable A set to either 8 or E This is what Keen's animation will change to. The behavior is then set to 'jumping'.

Section 10 is pogoing. On the first line two unknown keys are checked for. If both are being pressed then the 'Keen pogoing' variable is checked, if Keen is still pogoing nothing happens. Otherwise the frame timer is set to 0, Keen's current speed is stored in Misc variable B before being set to 0. This stops Keen moving. A final check to see if Keen has the pogo is performed and if so his behavior is set to 'pogo'.

The final section deals with shooting. There are four conditions needed before Keen can shoot. If all are passed then Keen's behavior is set to 'shoot'. His horizontal direction, Misc variable B and animation timer are all set to 0. his behavior is then set to 'shoot' a second time. (Redundant code.) Keen's direction ($604CW) is checked and his animation set to $14 or $15 accordingly. The last line is unrelated to shooting but decreases Misc variable D by one if it is not already 0.

Keen 1

#Keen standing\walking code
%patch $3867 $55 $8B $EC $83 $EC $0A $56 $57 $83 $3E {$8250W}  [$00] {$74} $05 $BF
             [$0001W]  $EB $60 $8B $16 {$822EW}  $A1 $822CW  $B1 $0C $E8 $A8EBW
             $89 $46 $FC $8B $16 {$8236W}  $A1 {$8234W}  $B1 $0C $E8 $A8DCW  $89
             $46 $FA $8B $16 {$823AW}  $A1 {$8238W}  $B1 $0C $E8 $A8CDW  $40 $89
             $46 $F8 $BF [$0001W]  $8B $76 $FC $EB $25 $8B $46 $F8 $F7 $2E $08
             $6C $03 $C6 $D1 $E0 $C4 $1E $48 $6C $03 $D8 $26 $8B $1F $D1 $E3
             $8B $87 $34 $0A $89 $46 $F6 $3D [$0001W]  {$7E} $02 $8B $F8 $46 $3B
             $76 $FA $7E $D6

%patch $38DB                 $83 $3E {$7FCCW}  [$00] {$74} $33 $A1 {$824EW}  $A3 $824EW
                 $C7 $06 $824EW  [$0000W]  $C7 $06 $824CW  [$0000W]  $C7 $06 $824AW
                 [$0000W]  $83 $3E {$604CW}  [$00] {$7C} $08 $C7 $06 $8246W  [$0008W]
             $EB $06 $C7 $06 $8246W  [$000EW]  $C7 $06 $8252W  {$3B8BW}

#Walking start
%patch $3915                                                         $83 $FF
             [$03] {$7D} $3F $8B $1E {$7FCAW}  $4B $83 $FB [$06] {$77} $35 $D1 $E3 $2E
             $FF $A7 [$3B7DW]  $B8 [$0002W]  $50 $E8 $F268W  $44 $44 $83 $3E {$824EW}
                 [$00] {$7D} $1E $C7 $06 $7FCAW  [$0008W]  $EB $16 $B8 [$FFFEW]  $50
             $E8 $F250W  $44 $44 $83 $3E {$824EW}  [$00] {$7E} $06 $C7 $06 $7FCAW

#Walking stop
%patch $3959         $83 $FF [$01] {$75} $43 $83 $3E {$7FCAW}  [$08] {$75} $3C $83 $3E
             {$824EW}  [$00] {$7E} $18 $B8 [$FFFDW]  $50 $E8 $F227W  $44 $44 $83 $3E
             {$824EW}  [$00] {$7D} $25 $C7 $06 $824EW  [$0000W]  $EB $1D $83 $3E {$8240W}
                 [$00] {$7D} $16 $B8 [$0003W]  $50 $E8 $F208W  $44 $44 $83 $3E {$824EW}
                 [$00] {$7E} $06 $C7 $06 $824EW  [$0000W]

#Walking speed (initial)
%patch $39A1                                         $83 $FF [$03] {$75} $1C $83
             $3E {$604CW}  [$00] {$7E} $08 $C7 $06 $824EW  [$00B4W]  $EB $0D $83 $3E
             {$604CW}  [$00] {$7D} $06 $C7 $06 $824EW  [$FF4CW]

#Animations- standing and walking
%patch $39C2                                             $83 $3E {$824EW}  [$00]
             {$75} $17 $83 $3E {$604CW}  [$00] {$7C} $08 $C7 $06 $8248W  [$0000W]  $EB
             $57 $C7 $06 $8248W  [$0004W]  $EB $4F $83 $3E {$824EW}  [$00] {$7E} $23
             $C7 $06 $8248W  [$0000W]  $83 $FF [$03] {$7D} $16 $A1 $5135W  $B1 [$04]
             $D3 $E8 $25 [$0003W]  $8B $16 $8248W  $03 $D0 $89 $16 $8248W  $EB
             $21 $EB $1F $C7 $06 $8248W  [$0004W]  $83 $FF [$03] {$7D} $14 $A1 $5135W
                 $B1 [$04] $D3 $E8 $25 [$0003W]  $8B $16 $8248W  $03 $D0 $89 $16
             $8248W  $A1 {$824EW}  $A3 {$604CW}

#Walking sounds
%patch $3A2F                                 $83 $3E {$824EW}  [$00] {$74} $2B $A1
             $5135W  $B1 $04 $D3 $E8 $A9 [$0001W]  {$74} $1F $83 $FF [$03] {$7D} $1A
             $A1 $5135W  $B1 $05 $D3 $E8 $A9 [$0001W]  {$74} $05 $B8 [$001EW]  $EB
             $03 $B8 [$0004W]  $50 $E8 $8494W  $44 $44

#Tile collision, walls and floors
%patch $3A61                                         $E8 $F1C6W  $E8 $F206W 
             $89 $46 $FE $E8 $F8F8W  $F7 $46 $FE {$04} [$00] {$75} $07 $F7 $46 $FE
             {$01} [$00] {$74} $15 $A1 $5135W  $B1 $04 $D3 $E8 $A9 [$0001W]  {$74} $09
             $B8 [$0005W]  $50 $E8 $8465W  $44 $44 $F7 $46 $FE {$02} [$00] {$75} $19
             $83 $3E {$8250W}  [$00] {$75} $12 $C7 $06 $8252W  {$3C99W}  $B8 [$001BW]
             $50 $E8 $8448W  $44 $44 $E9 $00C6W

#Jumping while walking
%patch $3AB0                                     $83 $3E {$7FCCW}  [$00] {$74} $33
             $A1 {$824EW}  $A3 {$824EW}  $C7 $06 $824EW  [$0000W]  $C7 $06 $824CW 
             [$0000W]  $C7 $06 $824AW  [$0000W]  $83 $3E {$604CW}  [$00] {$7C} $08 $C7
             $06 $8246W  [$0008W]  $EB $06 $C7 $06 $8246W  [$000EW]  $C7 $06 $52
             $82 {$3B8BW}

%patch $3AEA             $83 $3E {$7FCEW}  [$00] {$74} $32 $83 $3E {$7FD4W}  [$00] {$75}
             $2B $83 $3E {$8258W}  [$00] {$74} $05 $E8 $FAD0W  $EB $1F $C7 $06 $824AW
                 [$0000W]  $A1 {$824EW}  $A3 {$824CW}  $C7 $06 {$824EW}  [$0000W]  $83
             $3E {$AA9AW}  [$00] {$74} $06 $C7 $06 $8252W  {$4054W}

%patch $3B23                                                 $83 $3E {$7FCCW}
             [$00] {$74} $41 $83 $3E {$7FCEW}  [$00] {$74} $3A $83 $3E {$7FD2W}  [$00] {$75}
             $33 $83 $3E {$7FD4W}  [$00] {$75} $2C $C7 $06 $8252W  {$3E12W}  $33 $C0
             $A3 {$823CW}  $A3 {$824CW}  $A3 {$824AW}  $C7 $06 $8252W  {$3E12W}  $83
             $3E {$604CW}  [$00] {$7E} $08 $C7 $06 $8248W  [$0014W]  $EB $06 $C7 $06
             $8248W  [$0015W]  $83 $3E {$8250W}  [$00] {$74} $04 $FF $0E {$8250W}  $5F
             $5E $8B $E5 $5D $C3

#Walking direction list
%patch $3B7D $392BW #Right 1
             $392BW #Right 2
             $392BW #Right 3
             $3959W #Still
             $3943W #Left 1
             $3943W #Left 2
             $3943W #Left 3


Keen's walking speed can vary, being anything less than a maximum value. For Keen's speed when sliding on ice see Patch:Ice tiles and Patch:Slippery tiles. Keen also has an 'initial' walking speed, a 'boost' given to him when he first starts walking. This has very little effect on his actual walking speed however.

Keen's walking speeds

#Walking speeds - Keen 1
%patch $39C0 [$FF4CW] #Left -initial
%patch $39B1 [$00B4W] #Right -initial
%patch $2BC5 [$FF88W] #Left
%patch $2BB6 [$0078W] #Right

#Walking speeds - Keen 2
%patch $6802 [$FF4CW] #Left -initial
%patch $67F3 [$00B4W] #Right -initial
%patch $5A07 [$FF88W] #Left
%patch $59F8 [$0078W] #Right

#Walking speeds - Keen 3
%patch $7060 [$FF4CW] #Left -initial
%patch $7051 [$00B4W] #Right -initial
%patch $6252 [$FF88W] #Left
%patch $6243 [$0078W] #Right

How fast keen stops walking

These patches control how fast Keen stops walking. By default this is +/-3. If set to 0 Keen will not stop walking once he starts if the arrow key isn't pressed. (Jumping, falling, etc and pressing the opposite arrow key will alter his speed though.) Values of +/-1 or 2 will make Keen stop slower than usual.

Keen's walking speeds

#Walking deceleration speeds - Keen 1
%patch $396D [$FFFDW] #Left
%patch $398C [$0003W] #Right

#Walking deceleration speeds - Keen 2
%patch $67AF [$FFFDW] #Left
%patch $67CE [$0003W] #Right

#Walking deceleration speeds - Keen 3
%patch $700F [$FFFDW] #Left
%patch $702D [$0003W] #Right


Keen's walking animation is set up in a unique way, intertwined with Ice tiles; Keen will use an animation when walking left or right, but on ice tiles will not actually animate. Since his default walking animations start with his standing animations, it looks like Keen is simply standing when sliding on ice tiles. (This becomes evident if Keen's starting walking animation is changed.) For more patches involving ice tiles see Patch:Ice tiles.

Keen 1

%patch $39D4 [$0000W] #Keen facing right
%patch $39DC [$0004W] #Keen facing left

#Walking right
%patch $39EB [$0000W] #Walking right
%patch $39FA $03    #And next 3 frames
%patch $39F6 $04    #Animation speed

#Walking left
%patch $3A0E [$0008W] #Walking left
%patch $3A1D $03    #And next 3 frames
%patch $3A19 $04    #Animation speed

Keen 2

%patch $6816 [$0000W] #Keen facing right
%patch $681E [$0004W] #Keen facing left

#Walking right
%patch $682D [$0000W] #Walking right
%patch $683C $03    #Frames used -1
%patch $6838 $04    #Animation speed

#Walking left
%patch $6850 [$0004W] #Walking left
%patch $685F $03    #Frames used -1
%patch $685B $04    #Animation speed

Keen 3

%patch $7074 [$0000W] #Keen facing right
%patch $707C [$0004W] #Keen facing left

#Walking right
%patch $708B [$0000W] #Walking right
%patch $709A $03    #Frames used -1
%patch $7096 $04    #Animation speed

#Walking left
%patch $70B2 [$0004W] #Walking left
%patch $70C1 $03    #Frames used -1
%patch $70BD $04    #Animation speed


Keen's walking sound is composed of two distinct sounds that are played alternatively. These sounds are used when walking across various tile types. It is the same sounds whether he is walking across normal ground of slippery tiles. There is a separate sound that plays if Keen is blocked by a wall.

Keen 1

#Keen's walking sounds
%patch $3A54 $1E     #Keen walking sound 1
%patch $3A53 $EB $0C #Keen walking sound 1 disabled

%patch $3A59 $04     #Keen walking sound 2
%patch $3A58 $EB $07 #Keen walking sound 2 disabled

%patch $3A88 $05     #Keen blocked by wall sound
%patch $3A87 $EB $07 #Keen blocked by wall sound disabled

Keen 2

#Keen's walking sounds
%patch $6896 $1E     #Keen walking sound 1
%patch $6895 $EB $0C #Keen walking sound 1 disabled

%patch $689B $04     #Keen walking sound 2
%patch $689A $EB $07 #Keen walking sound 2 disabled

%patch $68CA $05     #Keen blocked sound
%patch $68C9 $EB $06 #Keen blocked sound disabled

Keen 3

#Keen's walking sounds
%patch $70F8 $1E     #Keen walking sound 1
%patch $70F7 $EB $10 #Keen walking sound 1 disabled

%patch $7102 $04     #Keen walking sound 2
%patch $7101 $EB $06 #Keen walking sound 2 disabled

%patch $7130 $05     #Keen blocked sound
%patch $712F $EB $06 #Keen blocked sound disabled

Only one walking sound

Blocking just one walking sound results in periods of silence when Keen is walking. It is possible however to have only one sound (The second sound) play whenever Keen walks. (Alternatively both sounds could be made the same.)

Keen 1

#Keen's walking sounds
%patch $3A51 $EB

Keen 2

#Keen's walking sounds
%patch $6893 $EB

Keen 3

#Keen's walking sounds
%patch $70F5 $EB

Keen ducks when pressing down

The following patch makes Keen switch from sprites 0\4; 4 frames animation to sprites 24\26; 2 frames animation when he walks while pressing the down key, as well as changing his standing animations. If the new animations used are crawling animations, Keen will crawl when walking and pressing down. This also affects walking\sliding on slippery AND ice tiles.

The first blue value, $04 is how fast Keen's walking and ducked cycles animate. Larger values give slower animation. The blue marked values in the jump tables are in order: normal walking left animation, ducking left animation, normal walking right animation, ducking right animation, normal number of walking frames - 1 and number of ducking frames - 1. The default patches make Keen use his pogoing animations, but this can be changed.

There are two options, differing depending on what 'jump table' is used; the first option makes keen duck only when the down arrow is pressed; he will immediately return to normal if the key is not pressed. In the second option Keen will duck when the down arrow is pressed, and will remain so even after jumping, pogoing, etc, only returning to normal when the up key is pressed. To use the patch below one of the jump tables should be deleted.

This patch as it is is incompatible with the animate while on ice tiles patch as well as several other ice tiles related patches as it alters a piece of ice-tile related walking code. The incompatibility can be fixed however, see Patch:Incompatible patches.

Keen 1

#More efficient Ice-normal slide-walk code
%patch $39E6 $08 $C7 $06 $48 $82 $0000W  $EB $06 $C7 $06 $48 $82 $0004W  $83
             $FF $03 $7D $2F $A1 $5135W  $B1 [$04] $D3 $E8 $25 $0003W  $8B $16
             $48 $82 $03 $D0 $89 $16 $48 $82 $EB $19

#Keen ducks when he presses the down key
%patch $55EF $2E $A1 $46EEW  $8B $1E $CA $7F $D1 $E3 $2E $FF $A7 $4A48W  $2E
             $A1 $4A5CW  $2E $A3 $39EBW  $2E $A3 $39D4W  $2E $A1 $4A60W  $2E
             $A3 $39F3W  $2E $A3 $39DCW  $2E $A1 $4A64W  $2E $A3 $3A02W  $EB $1B

#Unduck code
%patch $0AF2 $2E $A1 $4A5AW  $2E $A3 $39EBW  $2E $A3 $39D4W  $2E $A1 $4A5EW
             $2E $A3 $39F3W  $2E $A3 $39DCW  $2E $A1 $4A62W  $2E $A3 $3A02W
             $E9 $4B26W

#Jump table: Need to use up arrow to unduck
%patch $4A45 $C3 $0AF2W  $0AF2W  $0AF2W  $563BW  $55FEW  $55FEW
                 $55FEW  $563BW  $0AF2W  $563BW  [$0000W  $0018W]
                 [$0004W  $001AW  $0003W  $0001W]

#Jump table: Unduck whenever not pressing down arrow
%patch $4A45 $C3 $0AF2W  $0AF2W  $0AF2W  $0AF2W  $55FEW  $55FEW
                 $55FEW  $0AF2W  $0AF2W  $0AF2W  [$0000W  $0018W]
                 [$0004W  $001AW  $0003W  $0001W]