Patch:Keen Flipping Switches

From KeenWiki
Jump to: navigation, search

This page contains patches relating to Keen flipping switches in Keen 4 and Keen 5. That is, such things as the sprites used, the speeds and sounds. It does not cover patches relating to bridges and switches themselves or the tiles used. These can be found at Patch:Bridges and switches. This page 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.

While Keen can also flip switches in Vorticons, Dreams and Keen 6; but this does not involve any novel sprite behaviors so no patches relating to these games are found here.

Sprite Actions

The switch flipping sequence consists of two actions, one preparing to flip and one that flips before returning to normal.

Keen 4

Keen's switch flipping can be difficult to understand. On initially looking up in front of a switch tile Keen starts his 'adjust position' action. This lines him up with the switch tile so he can properly animate it and get the switch co-ordinates. This action has a next action but this is overridden by the game. Instead Keen enters the flip switch sequence.

The flipping sequence has two actions, starting and finishing. When finished Keen is returned to his standing action. The second action is in fact shared with Keen finishing opening doors.

$098CW #Keen standing
$0DE2W #Keen starts flicking switches
$0E00W #Keen finishes flicking switches\placing gems
$0E3CW #Keen adjust position

Patch: Keen 4
#Move into position on tile
%patch $B994 $0E3CW
#Positioning sequence (Not used)
%patch $2FCC8 $0E5CW
#Start flipping the switch tile
%patch $B99B $0DE2W
#Flipping sequence
%patch $2FC6E $0E00W %patch $2FC8C $098CW

Sprite Behavior

There is only one behavior relating to Keen flipping switches, it is used by the first flipping action. The second action has no behavior and acts as a 'pauser' to lengthen the sequence.

$0B8008B9RL #Flick switches

Patch: Keen 4 behaviors
#Flicking sequence
%patch $2FC62 $0B8008B9RL %patch $2FC80 $00000000L

Behavior code

This is the complete code for Keen flipping switches. The first part of the code reads the switches infoplane value behind the switch. Next up the switch tile itself is animated, followed by the switch sound. After this the code splits in two, one section for bridge switches, another for platform switches.

Patch: Keen 4 behaviors
#Keen flip switches behavior =0B8008B9RL
%patch $C0B9 $55 $8B $EC $83 $EC $16 $56 $57 $8B $5E $06 $8B $5F $2E $D1 $E3 $8B $87 $25 $C9 $D1 $E8 $5E8BW $06 $03 $47 $34 $89 $46 $F2 $8B $5E $F2 $D1 $E3 $8E $06 $E9 $26A7W $8B $07 $89 $46 $FC $8B $5E $FC $8E $06 $A1 $C8 $26 $8A $87 $42 $39 $98 $8B $56 $FC $03 $D0 $89 $56 $FA $8B $5E $F2 $D1 $E3 $8E $06 $EB $A7 $26 $8B $07 $89 $46 $F8 $B1 $08 $D3 $E8 $4689W $F6 $8B $46 $F8 $25 $FF $00 $89 $46 $F4 $8B $5E $FC $8E $06 $A1 $C8 $26 $8A $87 $A6 $44 $B4 $00 $89 $46 $FE $B8 $0001W $50 $50 $8B $5E $06 $FF $77 $2E $FF $77
#Animate switch
$34 $50 $16 $8D $46 $FA $50 $9A $16540F28RL $83 $C4 $0E $B8
$0015W $50 $9A $187409F1RL $83 $C4 $02 $83 $7E $FE $0F $74
#Bridge switch jump
$03 $E9 $00A4W $8B $7E $F4 $E9 $008BW $8B $DF $D1 $E3 $8B $87 $25 $C9 $D1 $E8 $E0D1W $8B $16 $E9 $8BA7W $5E $F6 $D1 $E3 $03 $C3 $52 $50 $3B $7E $F4 $74 $05 $B8 $0001W $EB $02 $33 $C0 $D1 $E0 $5A $2B $D0 $58 $89 $46 $F0 $89 $56 $EE $3B $7E $F4 $74 $05 $B8 $0001W $EB $02 $33 $C0 $8B $56 $F6 $2B $D0 $8B $F2 $EB $3E $C4 $5E $EE $26 $8B $07 $89 $46 $EC $83 $46 $EE $02 $8B $5E $EC $8E $06 $A1 $C8 $26 $8A $87 $42 $39 $88 $46 $EB $98 $0B $C0 $74 $23 $8A $46 $EB $98 $01 $46 $EC $B8 $0001W $50 $50 $57 $56 $50 $16 $8D $46 $EC $50 $9A $16540F28RL $83 $C4 $0E $46 $3B $36 $E4 $A7 $72 $BC $47 $8B $46 $F4 $05 $02 $00 $3B $C7 $76 $03 $E9 $FF68W $5F $5E $8B $E5 $5D $CB $8B $5E $F4 $D1 $E3 $8B $87 $25
#B switch
$C9 $D1 $E8 $E0D1W $8B $16 $EB $A7 $8B $5E $F6 $D1 $E3 $03 $C3 $89 $56 $F0 $89 $46 $EE $C4 $5E $EE $26 $8B $07 $89 $46 $EC $35 $001FW $26 $89 $07 $5F $5E $8B $E5 $5D $CB

Speed and Jump Height

Keen does not move while flipping switches, to do so would misalign him with the switch and cause the flip to fail.

Patch: Keen 4 action speeds
#Flipping switches
%patch $2FC5E $0000W $0000W %patch $2FC7C $0000W $0000W

Sprite Collision

Keen uses no sprite collision when flipping switches. This means he cannot interact with point items and a few other things while doing so.

Patch: Keen 4 sprite collisions
#Flipping switches
%patch $2FC66 $00000000L %patch $2FC84 $00000000L


Keen uses one animation when flipping switches the 'facing away from screen' animation.

Patch: Keen 4
#Flicking switches
%patch $2FC52 $00C4W $00C4W %patch $2FC5C $0008W
#Pause before flip
%patch $2FC70 $00C4W $00C4W %patch $2FC7A $0008W
#Pause before done

Sprite-tile interaction

Keen uses the same tile collision as he does when standing or doing other 'normal' things.

Patch: Keen 4 tile collisions
#Flicking switches
%patch $2FC6A $0B801AA2RL %patch $2FC88 $0B801AA2RL

Action type

Keen's flipping actions are type 0, meaning their behaviors and movement are called only once during the action. This prevents 'multiple flipping' when Keen flips a switch.

Patch: Keen 4
#Flip switches
%patch $2FC56 $0000W %patch $2FC74 $0000W

Deprotect and stick to ground

Both of Keen's flipping actions use the 'deprotect animation' variable for complex and subtle reasons.

Patch: Keen 4
#Flip switches
%patch $2FC58 $0000W $0001W %patch $2FC76 $0000W $0001W