Patch:Keen opening doors

From KeenWiki
Jump to navigation Jump to search

This page contains sprite patches relating to Keen as he opens keygem type doors. It does not contain patches relating to keygems, keyholders or doors themselves.


Sprite Actions

When Keen first contacts a keyholder tile the game will check to see if he is already performing the 'open door' action. If he is then it skips the code to start doing so to avoid an infinite loop. Next Keen turns away from the screen and adjusts his position so that he will align with the keyholder. This is required so Keen will properly register the door location. Finally, once in position, he will start his gem placing sequence.

The gem placing sequence is two actions long and afterwards Keen returns to standing. The second action is unnecessary and merely serves to lengthen the sequence. It is in fact shared with Keen flipping switches sequence.


Keen 4

Actions:
$098CW #Keen standing
$0E00W #Keen pause after placing gem
$0E1EW #Keen placing gem
$0E3CW #Keen adjust position

Keen 4

#Check to see if Keen is already doing this
%patch $D19D  [$0E1EW]

#Keen adjust position to holder
%patch $D1D3  [$0E3CW]

#Start door opening sequence
%patch $D1E8  [$0E1EW]

#Gem placing sequence
%patch $2FCAA [$0E00W]
%patch $2FC8C [$098CW]


Sprite Behavior

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

Behaviors:
$0B800A34RL #Placing gem

Keen 4 behaviors

#Placing sequence
%patch $2FC9E $0B800A34RL
%patch $2FC80 $00000000L


Behavior code

This is the complete placing gem behavior code. The first sections deals with the keyholder, reading the infoplane for the keyholder's destination. (This is 16 pixels or $00FFW up from keen's feet.) Starting at the end of line 5 the 'animate tile' code is run, animating the keyholder so it contains a gem. Sound $12 is played on line 7. The rest of the code creates a door metasprite and places it in the level.

After being spawned on line 6 the door sprite's location is set to that of the keyholder destination. This is then checked four times to see if it is outside the level borders. (The first check is whether its horizontal position exceeds the level width variable, the second whether it is less than 2 tiles (the level border.), the third whether its vertical position exceeds the level height and the fourth whether it is less than 2 tiles.) If nay of these checks fail the 'Keyholder points to bad spot' code is run and the game crashes.

The final part of the code sets the door sprite's properties. It has no clipping so that it won't be affected by tiles, a type of 1 or 'misc' and an action variable of 2 or 'always active no matter how far away from Keen.'

Keen 4

#Keen place gem code
%patch $C234 $55 $8B $EC $83 $EC $10 $56 $57 $8B $76 $06 $8B $5C $32 $D1 $E3
             $8B $87 $25 $C9 $D1 $E8 $03 $44 $34 $89 $46 $F6 $8B $5E $F6 $D1
             $E3 $8E $06 $E9 $A7 $26 $8B $07 $05 [$0012W]  $89 $46 $FE $8B $5E
             $F6 $D1 $E3 $8E $06 $EB $A7 $26 $8B $07 $89 $46 $FC $B1 $08 $D3
             $E8 $4689W  $FA $8B $46 $FC $25 [$00FFW]  $89 $46 $F8 $B8 $0001W 
             $50 $50 $FF $74 $32 $FF $74 $34 $50 $16 $8D $46 $FE $50 $9A
         $16540F28RL     $83 $C4 $0E $B8 [$0012W]  $50 $9A $187409F1RL     $83
             $C4 $02 $33 $C0 $50 $9A $06BD1E11RL     $83 $C4 $02 $8B $1E $D8
             $A7 $8B $46 $FA $89 $47 $0A $8B $46 $F8 $89 $47 $0C $8B $46 $FA
             $3B $06 [$A7E4W]  {$77} $15 $83 $7E $FA [$02] {$72} $0F $8B $46 $F8 $3B
             $06 [$A7E2W]  {$77} $06 $83 $7E $F8 [$02] {$73} $0C $B8 [$1426W]  $50 $9A
             $037D022FRL     $83 $C4 $02 $8B $5E $F8 $D1 $E3 $8B $87 $25 $C9
             $D1 $E8 $E0D1W  $8B $16 $E9 $8BA7W  $5E $FA $D1 $E3 $03 $C3 $89
             $56 $F4 $89 $46 $F2 $C4 $5E $F2 $26 $8B $07 $89 $46 $F0 $BF $01
             $00 $A1 $E4 $A7 $D1 $E0 $01 $46 $F2 $EB $09 $47 $A1 $E4 $A7 $D1
             $E0 $01 $46 $F2 $C4 $5E $F2 $26 $8B $07 $3B $46 $F0 $74 $EC $8B
             $1E $D8 $A7 $89 $7F $3E $C7 $47 $02 [$0002W]  $C7 $47 $06 [$0000W]
             $C7 $07 [$0001W]  $B8 [$17ECW]  $50 $53 $9A $09DC118CRL     $83 $C4
             $04 $5F $5E $8B $E5 $5D $CB


Speed and Jump Height

Keen does not move while placing gems, to do so would misalign him with the gem holder and cause the placement to fail.

Keen 4 action speeds

#Placing keygems
%patch $2FC9A [$0000W $0000W]
%patch $2FC7C [$0000W $0000W]


Sprite Collision

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

Keen 4 sprite collisions

#Placing keygems
%patch $2FCA2 $00000000L
%patch $2FC84 $00000000L


Animations

Keen uses one animation when placing gems the 'facing away from screen' animation.

Keen 4

#Placing keygems
%patch $2FC8E $00C4W $00C4W
%patch $2FC98 $0006W        #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.

Keen 4 tile collisions

#Placing keygems
%patch $2FCA6 $0B801AA2RL
%patch $2FC88 $0B801AA2RL


Action type

Keen's gem placing actions are type 0, meaning their behaviors and movement are called only once during the action. This prevents 'multiple opening' when Keen activates a door.

Keen 4

#Placing keygems
%patch $2FC92 [$0000W]
%patch $2FC74 [$0000W]


Deprotect and stick to ground

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

Keen 4

#Placing keygems
%patch $2FC94 [$0000W $0001W]
%patch $2FC76 [$0000W $0001W]