Patch:Platform (Keen 3)

From KeenWiki
(Redirected from Patch:Platform(Keen 3))
Jump to navigation Jump to search

Platforms are useful sprites found in Keen 2 and Keen 3. This page lists patches relating to Platform sprites in Keen 3, both the horizontal and vertical moving platforms. It is divided into sections relating to the various sprite properties the patches involve. Being fluent with various sprite patch pages will help when working with these patches.

While the h and v platforms are technically two different sprites, they are grouped together here for convenience.


Sprite Type

Platforms use sprite type 10 which means they push Keen about and Keen can stand on them. They also keep moving when off-screen, unlike most sprites, which means that the patterns they move in cannot be disrupted by Keen in any fashion.

Keen 3

#Platform sprite type:
%patch $3F81 $0A #H platform
%patch $3FC9 $0A #V platform


Sprite Behavior

The behaviors of platforms are rather more complex than they appear, there are two functions, the first is the movement behavior, which makes the platforms move until they hit a solid tile of some kind, the second is the pause behavior which makes the platform sit still for a moment then move in the opposite direction. Both platform sprites use the same behavior, the only difference is the direction they move. This means any patches affecting the platform behaviors will affect both platforms.

It is notable that platforms do not pause when they hit the floor. Changing the other 'pause' behaviors to 'move' will also remove the pauses in various situations.

The platform collision is 'do nothing' meaning that they do not interact with any other sprites unless this is changed.


Behaviors:
$4C47W Move and reverse direction when hitting stuff
$4CCAW Pause
$6A00W Platform collision

When spawned

%patch $3FAA {$4C47W} #Move (H platform)
%patch $3FEC {$4C47W} #Move (V platform)

In level

%patch $4C7B {$4CCAW} #Pause, (If hits left walls)
%patch $4C9A {$4CCAW} #Pause, (If hits right walls)
%patch $4CB7 {$4CCAW} #Pause, (If hits ceilings)
%patch $4CEE {$4C47W} #After pausing

%patch $3FAF {$6A00W} #H Platform collision
%patch $3FF1 {$6A00W} #V Platform collision


Platform turning time

This patch controls how long the Platform pauses before it turns. There will always be a slight pause, but this can be made very short. The longest the Platform can pause is $FF ticks.

Platform turning time

%patch $4CDB [$4B]


Complete Platform movement code

The Platform's movement code is relatively simple to understand. On the first line the number of animation frames and animation are set (highlighted in blue). The following lines check for walls, floors and ceilings. In each case the speed is changed (blue), then the action changed to 'Platform turn'; except for the case of floors, where only the speed is changed.

Complete Platform movement code

#Platform behavior
%patch $4C47 $55 $8B $EC $56 $A1 $61 $53 $B1 $05 $D3 $E8 $25 [$0001W]  $05 [$006BW]
                 $A3 $38 $99 $E8 $1699W  $8B $F0 $F7 $C6 $01 $00 $74 $19 $C7
             $06 $3C $99 [$004BW]  $33 $C0 $A3 $30 $99 $A3 $3E $99 $A3 $3A $99
             $C7 $06 $42 $99 {$4CCAW}  $EB $1D $F7 $C6 $04 $00 $74 $17 $C7 $06
             $3C $99 [$FFB5W]  $33 $C0 $A3 $30 $99 $A3 $3E $99 $A3 $3A $99 $C7
             $06 $42 $99 {$4CCAW}  $F7 $C6 $08 $00 $74 $19 $C7 $06 $3E $99 [$004BW]
                 $33 $C0 $A3 $32 $99 $A3 $3C $99 $A3 $3A $99 $C7 $06 $42 $99
             {$4CCAW}  $EB $0C $F7 $C6 $02 $00 $74 $06 $C7 $06 $32 $99 [$FFB5W]
             $5E $5D $C3


Complete Platform turn code

The Platform's turning code is quite simple also. It does little except ait for a certain amount of time (in blue) before changing its action to 'moving Platform' (in brown.)

Complete Platform turn code

#Platform pause behavior
%patch $4CCA $55 $8B $EC $A1 $3A $99 $03 $06 $40 $5D $A3 $3A $99 $83 $3E $3A
             $99 [$4B] $7E $12 $A1 $3C $99 $A3 $30 $99 $A1 $3E $99 $A3 $32 $99
             $C7 $06 $42 $99 {$4C47W}  $5D $C3


Platform changes direction without pausing\turning

This patch alters the Platform's movement code so it doesn't use its turning action, making it change direction instantly when it hits solid tiles. The first two blue tiles are number of animation frames and start animation respectively,t he remaining blue values are the vertical and horizontal speeds (Two speeds of differing directions each.)

Platform changes direction without pausing\turning

#Platform changes direction without pausing\turning
%patch $4C47 $55 $8B $EC $56 $A1 $61 $53 $B1 $05 $D3 $E8 $25 [$0001W]  $05 [$006BW]
                 $A3 $38 $99 $E8 $1699W  $8B $F0 $F7 $C6 $02 $00 $74 $06 $C7
             $06 $32 $99 [$FFB5W]  $F7 $C6 $08 $00 $74 $06 $C7 $06 $32 $99 [$004BW] 
                 $F7 $C6 $04 $00 $74 $06 $C7 $06 $30 $99 [$FFB5W]  $F7 $C6 $01
             $00 $74 $06 $C7 $06 $30 $99 [$004BW]  $5E $5D $C3


Speed and Jump Height

The default speed of Platforms is +-75. When spawned Platforms will head right or down depending on what they are. The speeds are changed in the movement behavior, NOT the pausing behavior (The speed is changed just before the platform pauses.)

Here the speed follows its direction, horizontal speeds are $32 $99 $xxxxW while vertical speeds are $3C $99 $xxxxW. (Initial speeds are $20 for h, $22 for v) This allows a modder to change the directions platforms turn. When done correctly it can have very interesting results.

Starting speeds

%patch $3FB8 $20 [$004BW] #H plat, move right
%patch $3FFA $22 [$004BW] #V plat, move down

In level

%patch $4C68 $3C $99 [$004BW] #Platform hit left walls (Move right)
%patch $4C87 $3C $99 [$FFB5W] #Platform hit right walls (Move left)
%patch $4CA4 $32 $99 [$004BW] #Platform hit ceiling (Move down)
%patch $4CC3 $32 $99 [$FFB5W] #Platform hit floor (Move up)


Sprite Collision

Platforms use the 'do nothing' collision, which means they do not interact with any sprites and rely on other sprites to interact with them.

Keen 3

%patch $3FAF {$6A00W} #H Platform collision
%patch $3FF1 {$6A00W} #V Platform collision


Animations

Since both platforms use the same behavior, they also use the same animations.

When spawned

%patch $3FB9 [$006BW] #H Start
%patch $3FF6 [$006BW] #V Start

In level

%patch $4C56 [$006BW] #Both platforms moving
%patch $4C53 $01    #And next frame


Sprite positioning

The horizontal platform (but not the vertical platform) spawns three pixels higher than where it is placed in the level. This keeps it slightly out of level with solid tile tops which subtly alters gameplay. (For example, Keen cannot simply walk onto it from a falt surface, he must always jump onto it.)

Horizontal platform spawn height

#Horizontal platform spawn height
%patch $3F9C [$FC00W]


Sprite spawning

This is the complete codes for the Platforms' spawning. As they contain many patches elsewhere on this page, they are incompatible with them.

The Platforms have a rather short spawn code, lacking several things that more complex sprites contain. The two spawn codes are also nearly identical. Both their sprite type are set to 3, their behavior to 'moving platform' and their collision to 'nothing'. They differ however in their speeds and spawn height, one moves vertically, the other horizontally, while the horizontal platform only has a spawn height of 3 pixels higher than where it is placed.

Platform spawn

#Platform initiation pointers
%patch $3C0A [$3B2FW] #H Platform
%patch $3C0C [$3B39W] #V Platform

#Initiation - Platforms
%patch $3B2F $56 $57 $E8 $0442W  $59 $59 $E9 $0081W	#Goes to H Platform (Code at $3B2F + $442 + 5 = $3F76)
%patch $3B39 $56 $57 $E8 $0480W  $59 $59 $EB $78	#Goes to V Platform (Code at $3B39 + $480 + 5 = $3FBE)

#H Platform spawn code
%patch $3F76 $55 $8B $EC $56 $E8 $2040W  $8B $F0 $C7 $04 [$000AW]  $8B $46 $04 #Sprite type = 10
             $99 $B1 $0C $E8 $AC35W  $89 $44 $04 $89 $54 $06 $8B $46 $06 $99
             $B1 $0C $E8 $AC26W  $05 [$FC00W]  $83 $D2 $FF $89 $44 $08 $89 $54 #Spawn height is 3 pixels up
             $0A $C7 $44 $32 {$4C47W}  $C7 $44 $34 {$6A00W} $C7 $44 $28 [$006BW]   #Behavior = $4C47, Collision $6A00 Sprite = 6B
             $C7 $44 $20 [$004BW]  $5E $5D $C3                                 #Speed = +76

#V Platform spawn code
%patch $3FBE $55 $8B $EC $56 $E8 $1FF8W  $8B $F0 $C7 $04 [$000AW]  $8B $46 $04 #Sprite type = 10
             $99 $B1 $0C $E8 $ABEDW  $89 $44 $04 $89 $54 $06 $8B $46 $06 $99
             $B1 $0C $E8 $ABDEW  $89 $44 $08 $89 $54 $0A $C7 $44 $32 {$4C47W}  #Behavior = $4C47
             $C7 $44 $34 {$6A00W} $C7 $44 $28 [$006BW]  $C7 $44 $22 [$004BW] $5E   #Collision $6A00, Sprite = 6B, Speed = +76
             $5D $C3