From KeenWiki
(Redirected from Patch:Keen grabs ledge)
Jump to: navigation, search

This page contains patches that relate to Keen grabbing ledges and pulling himself up from them in Keen Galaxy as well as the circumstances under which he does so. The page can be divided into two sections, the first dealing with what triggers Keen's ledge grabbing the second section dealing with Keen's ledge-related sprites, their properties, actions and suchlike. Related patches can be found in Patch:Keen (Keen 4), Patch:Keen (Keen 5) and Patch:Keen (Keen 6).

When Keen grabs ledges

Disable ledge gripping

These patches stop Keen being able to grip ledges either right or left (Or both.)

Patch: Keen 4
#Keen cannot grip ledges...
%patch $D5D3 $EB
%patch $D6B9 $EB

Ledge-related sprites

This section deals with the properties of Keen's ledge-related sprites, their behavior, actions and suchlike. Patches in this section do not alter how Keen starts mooning, but rather what happens when he does or what happens afterwards. The ledge-recovery sequence consists of seven actions (Using five animations.)

Sprite Actions

Keen's ledge sequence starts when he is falling past a ledge and moving in its direction. As such there are two ways for him to start gripping a ledge; one when moving left and one when moving right. The 'start gripping' action goes directly to Keen's gripping action which will do nothing without the player's input.

When ledge gripping the player can move down or away from the ledge, which will cause Keen to fall or can move up or towards the ledge which will cause him to pull himself up. The pulling up sequence is five actions long and ends with Keen returning to standing.

When gripping ledges or pulling himself up and thus using his second sprite collision Keen can be disturbed by Platforms or Bounders; in both cases he will revert to his falling action.

Finally the in-level camera has certain exceptions that stop it following the player; this stops the ledge gripping and recovery sequence appearing 'jerky' (Since the camera relies on the position of Keen's head.) each single action is excepted from this except for ledge gripping itself. (Since the game would look odd if Keen could grip a ledge and freeze the camera.)

For a complete list of Keen's actions see Patch:Keen (Keen 4)#Sprite_Actions.

$12ECW #Keen start gripping ledge
$130AW #Keen gripping ledge
$1328W #Keen pulls himself up from ledgegripping 1
$1346W #Keen pulls himself up from ledgegripping 2
$1364W #Keen pulls himself up from ledgegripping 3
$1382W #Keen pulls himself up from ledgegripping 4
$13A0W #Keen standing on air (After pulling himself up. Doesn't fall)

Patch: Keen 4
#When Keen starts gripping ledges
%patch $D752 $12ECW
#Keen starts gripping ledge left
%patch $D67B $12ECW
#Keen starts gripping ledge right
#What Keen starting to grip ledges does
%patch $30178 $130AW
#What Keen gripping a ledge does by himself
%patch $30196 $0000W
#What the player can do while gripping a ledge
%patch $C98A $11A2W
#Move away from ledge (Fall)
%patch $C8FB $1328W
#Move towards ledge (Pull Keen up)
#Keen pull himself up sequence
%patch $301B4 $1346W %patch $301D2 $1364W %patch $301F0 $1382W %patch $3020E $13A0W %patch $3022C $098CW
#Be disturbed by
%patch $CE54 $11A2W
%patch $CE8C $11A2W
#Camera exceptions
%patch $87BF $12ECW
#Gripping ledge
%patch $87C9 $1328W
#Pulling up from a ledge 1
%patch $87D3 $1346W
#Pulling up from a ledge 2
%patch $87DD $1364W
#Pulling up from a ledge 3
%patch $87E7 $1382W
#Pulling up from a ledge 4

Sprite Behavior

Keen has too many possible behaviors to list here. However they can be found by clicking this section's title. The first frame of ledge gripping has no behavior, meaning once Keen starts gripping a ledge he cannot be interrupted. The same thing applies to the last frame of picking himself up. Every other frame of the pulling up sequence is the same (can't be interrupted.) but has its own behavior.

Patch: Mooning Keen behaviors
#Ledgegripping start
%patch $3016C $00000000L
%patch $3018A $0B8010E0RL
#Keen pull himself up sequence
%patch $301A8 $0B80134ARL %patch $301C6 $0B801369RL %patch $301E4 $0B801394RL %patch $30202 $0B80139FRL %patch $30220 $00000000L

Ledge gripping behavior

This behavior is the most complex ledge-related behavior; it deals with the various inputs hanging Keen responds to. As noted above they fall into two broad categories, those that make him fall and those that make him climb up. The climbing up action is highlighted in blue on the second line, falling down on the second to last line in the second section.

On the first line a check is made to see if the up key ($A7D0W = $FF) is being pressed. If so the next check is skipped. (Keen goes to climbing up.) If not then a comparison is made involving Keen's horizontal direction and the left\right arrow keys ($A7CEW) If Keen is moving in the same way he is facing (That is, towards the ledge) he will climb up, else he will fall down. The total sum of these checks is to make Keen fall if he pressed down or moves away from the edge or climb up if pressing up or towards the ledge.

On the end of the second line and start of the third a horizontal direction check is made. This has an unknown function but it is followed on the sixth line by a second direction check. This changes Keen's position when he pulls himself up (Which of course depends on whether he is facing left or right.) A final check occurs that determines whether Keen's foreground variable should be set to 3 (Appear in front of all tiles.) so as not to look odd.

In the second section dealing with Keen going to falling is far simpler. Three checks are made, the first is the check for the down key which if being passed will skip the next two checks. The next two checks relate to the left\right arrow keys since the third is the same check as was performed in the first line of the behavior. The second check ensures that the arrow keys are being pressed (Are not 0) and the third (unnecessarily) checks that Keen is moving away from the ledge.

If Keen is going to fall his clipping variable is set to 1 and his action to falling.

Patch: Keen 4
#Complete ledge gripping behavior - Keen 4
%patch $C8E0 $55 $8B $EC $56 $57 $8B $7E $06 $83 $3E $A7D0W $FF $74 $09 $8B $45 $0E $3B $06 $A7CEW $75 $78 $C7 $45 $1C $1328W $83 $7D $0E $01 $75 $1E $8B $5D $2E $4B $D1 $E3 $8B $9F $25 $C9 $D1 $EB $D1 $E3 $8E $06 $E9 $A7 $8B $45 $30 $D1 $E0 $03 $D8 $26 $8B $17 $EB $1C $8B $5D $2E $4B $D1 $E3 $8B $9F $25 $C9 $D1 $EB $D1 $E3 $8E $06 $E9 $A7 $8B $45 $2C $D1 $E0 $03 $D8 $26 $8B $17 $83 $7D $0E $01 $75 $08 $C7 $06 $C921W $FF00W $EB $06 $C7 $06 $C921W $FF80W $8B $DA $8E $06 $A1 $C8 $26 $8A $87 $A6 $44 $B4 $00 $80A9W $00 $75 $2E $C7 $45 $20 $0003W $5F $5E $5D $CB $5F $5E $5D $CB
#Falling section
$83 $3E $A7D0W $01 $74 $10 $83 $3E $A7CEW $00 $74 $13 $8B $45 $0E $3B $06 $A7CEW $74 $0A $C7 $45 $1C $11A2W $C7 $45 $06 $0001W $5F $5E $5D $CB

Keen can't fall from gripping by pressing down

This patch removes the ability to press down to let go of a ledge. Only moving away from the ledge will work.

Patch: Keen 4
#Keen can't fall from gripping by pressing down
%patch $C975 $90 $90

Ledge pull 1 behavior

This behavior is used by the first frame of Keen pulling himself up from a ledge. It is quite simple; Keen's direction is checked and his position adjusted accordingly. This allows him to gradually move from the ledge up to solid ground as he pulls himself up.

Patch: Keen 4
#Keen ledge pull 1 behavior code
%patch $CB4A $55 $8B $EC $56 $8B $76 $06 $83 $7C $0E $01 $75 $09 $C7 $06 $C923W $0080W $5E $5D $CB $C7 $06 $C921W $FF80W $5E $5D $CB

Ledge pull 2 behavior

This behavior is used by the second frame of Keen pulling himself up from a ledge. It is very similar to the first pull up behavior except both horizontal and vertical position are changed for both directions.

Patch: Keen 4
#Keen ledge pull 2 behavior code
%patch $CB69 $55 $8B $EC $56 $8B $76 $06 $83 $7C $0E $01 $75 $0F $C7 $06 $C923W $0080W $C7 $06 $C921W $FF80W $5E $5D $CB $C7 $06 $C923W $FF80W $C7 $06 $C921W $FF80W $5E $5D $CB

Ledge pull 3 behavior

This behavior is used by the third frame of Keen pulling himself up from a ledge. It is the simplest, changing Keen's vertical position. (The same amount for either direction, no checks made.)

Patch: Keen 4
#Keen ledge pull 3 behavior code
%patch $CB94 $55 $8B $EC $C7 $06 $C921W $FF80W $5D $CB

Ledge pull 4 behavior

This behavior is used by the fourth frame of Keen pulling himself up from a ledge. It prepares Keen for standing, setting his clipping to 1 (It was 0 previously.) and his foreground variable to 1 (It was formerly 3, making him appear in front of all tiles.) as well as adjusting his vertical position.

Patch: Keen 4
#Keen ledge pull 4 behavior code
%patch $CB9F $55 $8B $EC $56 $8B $76 $06 $C7 $44 $06 $0001W $C7 $44 $20 $0001W $C7 $06 $C921W $0080W $5E $5D $CB

Speed and Jump Height

Keen gripping a ledge is still by default, not using any motion. His position changes but this is not motion.

Patch: Keen 4 animation motion
#Starting ledge gripping
%patch $30168 $0000W $0000W
#Ledge gripping
%patch $30186 $0000W $0000W
#Pull up sequence
%patch $301A4 $0000W $0000W %patch $301C2 $0000W $0000W %patch $301E0 $0000W $0000W %patch $301FE $0000W $0000W %patch $3021C $0000W $0000W


Five sprite bitmaps are used in seven frames. These frames are cached with the normal Keen frames. The first animation speed doubles as a delay since Keen cannot pull himself up until he moves onto the ledge gripping action. This has no animation speed as it waits for a keypress. The remaining frames have animation speeds that control the pacing of the pull-up sequence.

Patch: Ledge gripping Keen 4 animations
#Keen starts gripping a ledge
%patch $3015C $00C9W $00CAW %patch $30166 $000CW
#Pause before Keen can pull himself up
#Keen gripping ledge
%patch $3017A $00C9W $00CAW %patch $30184 $0000W
#Wait for keypress
#Keen pulls himself up sequence
%patch $30198 $00CBW $00CFW %patch $301A2 $000AW %patch $301B6 $00CCW $00D0W %patch $301C0 $000AW %patch $301D4 $00CDW $00D1W %patch $301DE $000AW %patch $301F2 $00CEW $00D2W %patch $301FC $000AW %patch $30210 $008AW $0082W %patch $3021A $0006W

Sprite positioning

Keen must be carefully positioned so that he can be in a good looking position when grabbing a ledge and then be in the right location as he pulls himself up. As such each frame of his ledge gripping sequence has its own vertical and horizontal positioning, as well as there being positioning when Keen grabs a ledge. The change in positions can be seen in the sprite behavior codes above.

When Keen first grabs a ledge he is moved $40 or 4 pixels up. Depending on whether he is facing left or right he moves right either 8 or 16 pixels. This is also dependent on the number of sprite shifts the ledge gripping frame has in the graphics files. (Either 2 or 4.)

Patch: Ledge gripping Keen 4 positions
#Keen's repositioning when grabbing a ledge
%patch $D664 $0080W
#Right (Adjust horizontal)
%patch $D66D $0040W
#Right (Adjust vertical)
%patch $D73B $0100W
#Left (Adjust horizontal)
%patch $D744 $0040W
#Left (Adjust vertical)
#Horizontal repositioning when Keen starting to pull up
%patch $C947 $FF00W
#Right (Adjust horizontal)
%patch $C94F $FF80W
#Left (Adjust horizontal)
#Repositioning when Keen on first ledge pull
%patch $CB5B $0080W
#Right (Adjust vertical)
%patch $CB64 $FF80W
#Left (Adjust horizontal)
#Repositioning when Keen on second ledge pull
%patch $CB7A $0080W
#Right (Adjust vertical)
%patch $CB80 $FF80W
#Right (Adjust horizontal)
%patch $CB89 $FF80W
#Left (Adjust vertical)
%patch $CB8F $FF80W
#Left (Adjust horizontal)
#Repositioning when Keen on third ledge pull
%patch $CB9B $FF80W
#Left\right (Adjust horizontal)
#Repositioning when Keen on fourth ledge pull
%patch $CBB4 $0080W
#Left\right (Adjust horizontal)