Patch:Keen entering doors

From KeenWiki
Jump to navigation Jump to search

This page contains patches relating to Keen's door entering sequence in Keen Galaxy. The Galaxy games are the only ones with this mechanic by default. Patches governing doors themselves can be found at Patch:Keygem door and Patch:Keygems. This page does not cover Keen's 'gem placing' actions that are used to open keygem doors.


Sprite Actions

In Keen 4 and 6 the door entry sequence is rather simple. When Keen comes into contact with a door and presses the up key he first changes into the 'adjust position' action. This makes him slide across the screen until he is properly aligned with the door. (So that he doesn't 'miss' it and get sent somewhere incorrect.) Once this occurs he changes to the first door-entering action. This is a five action sequence that ends with Keen in his standing action.


Keen 4

Actions -Keen 4:
$098CW #Keen standing
$0E3CW #Keen adjust position
$0E5AW #Keen walks into door 1
$0E78W #Keen walks into door 2
$0E96W #Keen walks into door 3
$0EB4W #Keen walks into door 4
$0ED2W #Keen walks into door 5

Keen 4

#Keen slides into alignment with door
%patch $BA09 [$0E3CW]

#Keen starts door entry sequence
%patch $BA16 [$0E5AW]

#Door entry sequence
%patch $2FCE6 [$0E78W]
%patch $2FD04 [$0E96W]
%patch $2FD22 [$0EB4W]
%patch $2FD40 [$0ED2W]
%patch $2FD5E [$098CW]


Keen 5

In Keen 5 there is an additional complication; if Keen is attempting to enter a V-card door he uses a different action. If successful this starts the usual door entering sequence. This sequence is five actions long and the sixth and final action is only triggered if Keen is entering a normal door. (Otherwise he fails and returns to standing.)

Note that the 'adjust position' action is triggered before attempting to enter both regular and v-card doors, and before attempting to open a V-card door. The second 'Open V-card door' action is unused but appears to have been intended to be triggered when Keen didn't have a V-card.

Actions -Keen 5:
$0888W #Keen standing
$0CC0W #Keen adjust position
$0CDEW #Attempt to open V-card door
$0CFCW #Fail to open V-card door (Not used)
$0D1AW #Keen walks into door 1
$0D38W #Keen walks into door 2
$0D56W #Keen walks into door 3
$0D74W #Keen walks into door 4
$0D92W #Keen walks into door 5 (Can fail)
$0DB0W #Keen walks into door 6 (Succeed)

Keen 5

#Keen starts V-card door entry sequence
%patch $AD63 [$0CDEW]

#V-card sequence goes to regular entry sequence if uninterrupted
%patch $3103A [$0D1AW]

#Keen starts door entry sequence
%patch $ADA3 [$0D1AW]

#Door entry sequence
%patch $31076 [$0D38W]
%patch $31094 [$0D56W]
%patch $310B2 [$0D74W]
%patch $310D0 [$0D92W]
%patch $310EE [$0888W] #Fail to finish

#Keen ends door sequence successfully
%patch $B443 [$0DB0W]
%patch $B45A [$0DB0W]

#Ending entry sequence returns to standing
%patch $3110C [$0888W]


Keen 6

Actions -Keen 6:
$089AW #Keen standing
$0CB4W #Keen adjust position
$0CD2W #Keen walks into door 1
$0CF0W #Keen walks into door 2
$0D0EW #Keen walks into door 3
$0D2CW #Keen walks into door 4
$0D4AW #Keen walks into door 5

Keen 6

#Keen slides into alignment with door
%patch $AC1F [$0CB4W]

#Keen starts door entry sequence
%patch $AC2C [$0CD2W]

#Door entry sequence
%patch $31A00 [$0000W]
%patch $31A1E [$0CF0W]
%patch $31A3C [$0D0EW]
%patch $31A5A [$0D2CW]
%patch $31A78 [$0D4AW]
%patch $31A96 [$089AW]


Sprite Behavior

The first door-entering action has a complex behavior that reads Keen's destination. As this action is also used when placing gems altering it will affect gem placement too. Actions two to five have simple behaviors; they play a walking sound. (Sound 0 and sound 1.) Each behavior is used twice. The sixth behavior moves Keen to his destination.

Keen 4

#Adjust position
%patch $2FCBC $0B8007D8RL

#Door entering sequence
%patch $2FCDA $0B800234RL
%patch $2FCF8 $0B80024CRL
%patch $2FD16 $0B800234RL
%patch $2FD34 $0B80024CRL
%patch $2FD52 $0B800842RL

Keen 5

#Adjust position
%patch $31010 $0AAF08ADRL

#Attempt to open V-card door
%patch $3102E $00000000L

#Fail to open V-card door (Unused)
%patch $3104C $00000000L

#Door entering sequence
%patch $3106A $0AAF02FARL
%patch $31088 $0AAF0312RL
%patch $310A6 $0AAF02FARL
%patch $310C4 $0AAF0312RL
%patch $310E2 $0AAF0917RL
%patch $31100 $0AAF0917RL

Keen 6

#Adjust position
%patch $319F4 $0AA207C0RL

#Door entering sequence
%patch $31A12 $0AA20230RL
%patch $31A30 $0AA20240RL
%patch $31A4E $0AA20230RL
%patch $31A6C $0AA20240RL
%patch $31A8A $0AA20820RL


First entry behavior

This behavior simply plays sound 0 ($33 $C0) when called. It is called twice, by action 2 and action 4.

Keen 4

#First door entry behavior
%patch $BA34 $55 $8B $EC $56 $8B $76 $06 [$33 $C0] $50 $9A $187409F1RL     $83
             $C4 $02 $83 $C6 $4C $5E $5D $CB


Second entry behavior

This behavior simply plays sound 1 when called. It is called twice, by action 3 and action 5.

Keen 4

#Second door entry behavior
%patch $BA4C $55 $8B $EC $56 $8B $76 $06 $B8 [$0001W]  $50 $9A $187409F1RL
             $83 $C4 $02 $83 $C6 $4C $5E $5D $CB


Move behavior

This behavior is what causes Keen to move between doors. The first few lines read the infoplane value on the door tile. Next $0100W is removed from this and $000FW added. The sum total of this is to remove $00F1W or 15 pixels from the value. This is because of Keen's height; Keen's head will appear about 1 tile above the target destination, level with the ground.

Before moving Keen's foreground is set to 1 and his clipping turned off. After moving his clipping is turned on again.

Keen 4

#Third door entry behavior
%patch $C042 $55 $8B $EC $83 $EC $04 $56 $57 $8B $76 $06 $8B $5C $32 $D1 $E3
             $8B $87 $25 $C9 $D1 $E8 $D1 $E0 $8B $16 $EB $A7 $8B $5C $2C $D1
             $E3 $03 $C3 $89 $56 $FE $89 $46 $FC $C4 $5E $FC $26 $8B $3F $8B
             $C7 $25 $FF $00 $B1 $08 $D3 $E0 $2D [$0100W]  $05 [$000FW]  $89 $44
             $0C $8B $C7 $D3 $E8 $D3 $E0 $89 $44 $0A $C7 $44 $20 [$0001W]  $C7
             $44 $06 [$0000W]  $8B $5C $1C $FF $77 $1C $56 $9A $09DC120ARL
             $83 $C4 $04 $C7 $44 $06 [$0001W]  $56 $9A $06BD18A5RL     $83 $C4
             $02 $5F $5E $8B $E5 $5D $CB

Keen 6

#Third door entry behavior
%patch $B243 $55 $8B $EC $83 $EC $04 $56 $57 $8B $76 $06 $8B $5C $32 $D1 $E3
             $8B $87 $8B $CA $D1 $E8 $E0D1W  $8B $16 $79 $A9 $8B $5C $2C $D1
             $E3 $03 $C3 $89 $56 $FE $89 $46 $FC $C4 $5E $FC $26 $8B $3F $8B
             $C7 $25 $FF $00 $B1 $08 $D3 $E0 $2D [$0100W]  $05 [$000FW]  $89 $44
             $0C $8B $C7 $D3 $E8 $E0D3W  $89 $44 $0A $C7 $44 $20 [$0001W]  $C7
             $44 $06 [$0000W]  $8B $5C $1C $FF $77 $1C $56 $9A $08F41297RL    
             $83 $C4 $04 $C7 $44 $06 [$0001W]  $56 $9A $069A187CRL     $83 $C4
             $02 $5F $5E $8B $E5 $5D $CB


Speed

All of Keen's entering doors actions have a negative vertical speed that moves him slightly upwards at each step. This gives the illusion of Keen moving into the background.

Sprite speeds -Keen 4

#Adjust position
%patch $2FCB8 [$0000W $0000W]

#Enter doors
%patch $2FCD6 [$0000W $FFC0W]
%patch $2FCF4 [$0000W $FFC0W]
%patch $2FD12 [$0000W $FFC0W]
%patch $2FD30 [$0000W $FFC0W]
%patch $2FD4E [$0000W $FFC0W]

Sprite speeds -Keen 5

#Adjust position
%patch $3100C [$0000W $0000W]

#Attempt to open V-card door
%patch $3102A [$0000W $FFC0W]

#Enter V-doors 2 (Unused)
%patch $31048 [$0000W $0000W]

#Enter doors
%patch $31066 [$0000W $FFC0W]
%patch $31084 [$0000W $FFC0W]
%patch $310A2 [$0000W $FFC0W]
%patch $310C0 [$0000W $FFC0W]
%patch $310DE [$0000W $FFC0W]
%patch $310FC [$0000W $FFC0W]

Sprite speeds -Keen 6

#Adjust position
%patch $319F0 [$0000W $0000W]

#Enter doors
%patch $31A0E [$0000W $FFC0W]
%patch $31A2C [$0000W $FFC0W]
%patch $31A4A [$0000W $FFC0W]
%patch $31A68 [$0000W $FFC0W]
%patch $31A86 [$0000W $FFC0W]


Animations

These patches deal with Keen's animations as he enters a door. The first action is merely Keen turned, the same animation as used when he flicks switches. There is a notable pause Keen uses to align himself with the door tile, if this is changed it will affect his door entering.

The next six frames are just a sequence of entering the door. The animation speed controls how quickly Keen enters, though the first has no animation speed. The final action turns Keen invisible (-1 for his animation.) so he can 'teleport' to the door target.

Note that in Keen 5 the unused V-door entry action was meant to make Keen face the player, hands-on-hips, for forgetting to get a V-card.

Keen 4

#Enter door
%patch $2FCAC $00C4W $00C4W
%patch $2FCB6 $0000W
%patch $2FCCA $00C4W $00C4W
%patch $2FCD4 $0009W
%patch $2FCE8 $00C5W $00C5W
%patch $2FCF2 $0009W
%patch $2FD06 $00C6W $00C6W
%patch $2FD10 $0009W
%patch $2FD24 $00C7W $00C7W
%patch $2FD2E $0009W
%patch $2FD42 $00C8W $00C8W
%patch $2FD4C $0009W

Keen 5

#Adjust position
%patch $31000 $00AFW $00AFW
%patch $3100A $0000W

#Attempt to open V-card door
%patch $3101E $00AFW $00AFW
%patch $31028 $002DW

#Fail to open V-card door (Unused)
%patch $3103C $007EW $007EW
%patch $31046 $0000W

#Enter door
%patch $3105A $00AFW $00AFW
%patch $31064 $0009W
%patch $31078 $00B0W $00B0W
%patch $31082 $0009W
%patch $31096 $00B1W $00B1W
%patch $310A0 $0009W
%patch $310B4 $00B2W $00B2W
%patch $310BE $0009W
%patch $310D2 $00B3W $00B3W
%patch $310DC $0009W

#Move (Invisible)
%patch $310F0 $FFFFW $FFFFW
%patch $310FA $0009W

Keen 6

#Adjust position
%patch $319E4 $0076W $0076W
%patch $319EE $0000W

#Enter door
%patch $31A02 $0076W $0076W
%patch $31A0C $0009W
%patch $31A20 $0077W $0077W
%patch $31A2A $0009W
%patch $31A3E $0078W $0078W
%patch $31A48 $0009W
%patch $31A5C $0079W $0079W
%patch $31A66 $0009W
%patch $31A7A $007AW $007AW
%patch $31A84 $0009W


Clipping and foreground

When Keen first enters doors his foreground variable is set to the lowest possible value of 0. This makes sense since he is vanishing into the background. Keen's clipping is also set to 0 to allow him to move through walls to reach his destination. It is immediately set back to 1 when he arrives at the door target.

Keen 4

#Keen goes to background when entering a door
%patch $BA1B [$0000W]

#Change foreground back on exit
%patch $C08F [$0001W]

#Remove clipping when entering a door
%patch $C094 [$0000W]

#Return clipping when exiting a door
%patch $C0A8 [$0001W]

Keen 5

#Keen goes to background when entering a door
%patch $ADA8 [$0000W]

Keen 6

#Keen goes to background when entering a door
%patch $AC31 [$0000W]

#Change foreground back on exit
%patch $B290 [$0001W]

#Remove clipping when entering a door
%patch $B295 [$0000W]

#Return clipping when exiting a door
%patch $B2A9 [$0001W]


Sprite Collision

Keen has no sprite collision when entering doors. This has the effect of making him invulnerable to enemy sprites while doing so. It also leads to 'door immunity' where any enemy that is touching Keen when he appears from a door cannot hurt him when his collision returns, meaning he is invulnerable to that enemy for a short period of time.

Keen 4

#Adjust position
%patch $2FCC0 $00000000L

#Enter doors
%patch $2FCDE $00000000L
%patch $2FCFC $00000000L
%patch $2FD1A $00000000L
%patch $2FD38 $00000000L
%patch $2FD56 $00000000L

Keen 5

#Adjust position
%patch $31014 $00000000L

#Attempt to open V-door
%patch $31032 $00000000L

#Fail to open V-door
%patch $31050 $00000000L

#Enter doors
%patch $3106E $00000000L
%patch $3108C $00000000L
%patch $310AA $00000000L
%patch $310C8 $00000000L
%patch $310E6 $00000000L
%patch $31104 $00000000L

Keen 6

#Adjust position
%patch $319F8 $00000000L

#Enter doors
%patch $31A16 $00000000L
%patch $31A34 $00000000L
%patch $31A52 $00000000L
%patch $31A70 $00000000L
%patch $31A8E $00000000L


Sprite-tile interaction

In all door-related actions Keen uses a generic 'display sprite' tile interaction. This prevents the sequence being interrupted by anything as it unfolds.

Sprite tile interactions -Keen 4

#Adjust position
%patch $2FCC4 $09DC176ERL

#Enter doors
%patch $2FCE2 $09DC176ERL
%patch $2FD00 $09DC176ERL
%patch $2FD1E $09DC176ERL
%patch $2FD3C $09DC176ERL
%patch $2FD5A $09DC176ERL

Sprite tile interactions -Keen 5

#Adjust position
%patch $31018 $090B17B5RL

#Attempt to open V-door
%patch $31036 $090B17B5RL

#Fail to open V-door
%patch $31054 $090B17B5RL

#Enter doors
%patch $31072 $090B17B5RL
%patch $31090 $090B17B5RL
%patch $310AE $090B17B5RL
%patch $310CC $090B17B5RL
%patch $310EA $090B17B5RL
%patch $31108 $090B17B5RL

Sprite tile interactions -Keen 6

#Adjust position
%patch $319FC $08F4180ARL

#Enter doors
%patch $31A1A $08F4180ARL
%patch $31A38 $08F4180ARL
%patch $31A56 $08F4180ARL
%patch $31A74 $08F4180ARL
%patch $31A92 $08F4180ARL


Keen's position on emerging

$0100W is removed from the door target height and $000FW added. The sum total of this is to remove $00F1W or 15 pixels from the value. This is because of Keen's height; Keen's head will appear about 1 tile above the target destination, level with the ground. If Keen's height is changed then this value must be changed also.

Keen's door emergence height

#Keen's door emergence height -Keen 4
%patch $C07B [$0100W] #Up 1 tile
%patch $C07E [$000FW] #Down 1 pixel

#Keen's door emergence height -Keen 5
%patch $B46C [$0100W] #Up 1 tile
%patch $B46F [$000FW] #Down 1 pixel

#Keen's door emergence height -Keen 6
%patch $B27C [$0100W] #Up 1 tile
%patch $B27F [$000FW] #Down 1 pixel


Sounds

Two sounds are played as Keen enters doors in a 1-2-1-2 pattern. By default these are walking sounds, intended to make it sound as if Keen is walking into the doorway. The first sound is special, being sound 0 its patch is constructed differently and its value is hard to edit.

Keen 4

#Sounds
%patch $BA3B $C033W  #Keen enters doors sound 1 (Sound 0!)
%patch $BA54 [$01]     #Keen enters doors sound 2

#Don't play sounds
%patch $BA3B $EB $09 #Don't play Keen enters doors sound 1
%patch $BA53 $EB $0A #Don't play Keen enters doors sound 2

Keen 5

#Sounds
%patch $ADF1 $C033W  #Keen enters doors sound 1 (Sound 0!)
%patch $AE0A [$01]     #Keen enters doors sound 2

#Don't play sounds
%patch $ADF1 $EB $09 #Don't play Keen enters doors sound 1
%patch $AE09 $EB $0A #Don't play Keen enters doors sound 2

Keen 6

#Sounds
%patch $AC51 $C033W  #Keen enters doors sound 1 (Sound 0!)
%patch $AC6A [$01]     #Keen enters doors sound 2

#Don't play sounds
%patch $AC51 $EB $09 #Don't play Keen enters doors sound 1
%patch $AC69 $EB $0A #Don't play Keen enters doors sound 2


Action type

AdjustingKeen's position requires smooth movement and quick reaction, so this action is type 2. Keen's door-entering sequence is quite basic in function and thus made of type 0 actions.

Sprite action types -Keen 4

#Adjust position
%patch $2FCB0 [$0002W]

#Enter doors
%patch $2FCCE [$0000W]
%patch $2FCEC [$0000W]
%patch $2FD0A [$0000W]
%patch $2FD28 [$0000W]
%patch $2FD46 [$0000W]

Sprite action types -Keen 5

#Adjust position
%patch $31004 [$0002W]

#Attempt to open V-door
%patch $31022 [$0000W]

#Fail to open V-door
%patch $31040 [$0002W]

#Enter doors
%patch $3105E [$0000W]
%patch $3107C [$0000W]
%patch $3109A [$0000W]
%patch $310B8 [$0000W]
%patch $310D6 [$0000W]
%patch $310F4 [$0000W]

Sprite action types -Keen 6

#Adjust position
%patch $319E8 [$0002W]

#Enter doors
%patch $31A06 [$0000W]
%patch $31A24 [$0000W]
%patch $31A42 [$0000W]
%patch $31A60 [$0000W]
%patch $31A7E [$0000W]


Deprotect and stick to ground

Keen has no need for either of these variables when entering doors and so has a value of 0 for both in all of his actions.

Sprite deprotect, stick -Keen 4

#Adjust position
%patch $2FCB2 [$0000W $0000W]

#Enter doors
%patch $2FCD0 [$0000W $0000W]
%patch $2FCEE [$0000W $0000W]
%patch $2FD0C [$0000W $0000W]
%patch $2FD2A [$0000W $0000W]
%patch $2FD48 [$0000W $0000W]

Sprite deprotect, stick -Keen 5

#Adjust position
%patch $31006 [$0000W $0000W]

#Attempt to open V-door
%patch $31024 [$0000W $0000W]

#Fail to open V-door
%patch $31042 [$0000W $0000W]

#Enter doors
%patch $31060 [$0000W $0000W]
%patch $3107E [$0000W $0000W]
%patch $3109C [$0000W $0000W]
%patch $310BA [$0000W $0000W]
%patch $310D8 [$0000W $0000W]
%patch $310F6 [$0000W $0000W]

Sprite deprotect, stick -Keen 6

#Adjust position
%patch $319EA [$0000W $0000W]

#Enter doors
%patch $31A08 [$0000W $0000W]
%patch $31A26 [$0000W $0000W]
%patch $31A44 [$0000W $0000W]
%patch $31A62 [$0000W $0000W]
%patch $31A80 [$0000W $0000W]

Misc

Keen doesn't automatically enter V-card doors

This patch prevents Keen from automatically entering V-card doors when he has a card. Instead he will simply return to standing, allowing the player to choose whether to enter the door.

Keen 5

#Keen doesn't automatically enter V-card doors:
%patch $AD63 [$0C84W]