Patch:Dropping Platform (Keen 4)
Platforms in Keen 4 are sprites that Keen can stand on and sometimes be carried places on. This page lists patches relating to a specific Platform sprite, the Dropping or Falling Platform. The 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.
Patches relating to other Keen 4 platforms can be found at Patch:Platform (Keen 4). Patches relating to the Dropping Platform in other Keen games can be found at Patch:Dropping Platform (Keen 5) and Patch:Dropping Platform (Keen 6).
Sprite Type
Dropping Platforms use type 20, one of the types that lets Keen stand on a sprite. Changing this may make it impossible for Keen to stand on the platforms. The Dropping Platform uses the same value as all other platforms.
Keen 4
#Dropping Platform sprite type
%patch $11910 $14
Sprite Actions
The Dropping Platform's actions are quite simple. The Dropping Platform is spawned sitting. This action waits until Keen disturbs it by standing on it too long. When this happens it goes to the falling action.
When falling the Dropping Platform waits to hit a [B] sprite, then it stops moving. If at any time Keen jumps off the Dropping Platform it will go to its rising action. The rising action will go to the sitting action when the Dropping Platform is back in its original location.
Something to note is that if Keen lands on a rising Dropping Platform it will return to falling.
Actions: $3188W #Platform still $31A6W #Platform fall $31C4W #Platform rise
Keen 4
#Spawn Dropping Platform
%patch $11941 [$3188W]
#Dropping Platform sit - waits for Keen
%patch $32014 [$0000W]
#Keen stands too long on sitting Dropping Platform
%patch $1197D [$31A6W]
#Keen falls onto a rising Dropping Platform
%patch $11A10 [$31A6W]
#Dropping Dropping Platform is allowed to rise
%patch $119F3 [$31C4W]
#Dropping Platform fall - waits for Keen
%patch $32032 [$0000W]
#Rising Platform reaches its original location
%patch $11A29 [$3188W]
#Dropping Platform rising
%patch $32050 [$0000W]
Sprite Behavior
The Dropping Platform has three behaviors, one for each of its actions. They are quite self-explanatory.
Behaviors: $1080114FRL #Sitting Platform $10801182RL #Falling Platform $108011FBRL #Rising Platform
Keen 4 Platform behaviors
#Platform sit
%patch $32008 $1080114FRL
#Platform fall
%patch $32026 $10801182RL
#Platform rise
%patch $32044 $108011FBRL
Number of pogos before falling
The falling platform will let Keen pogo on it four times before it falls. This is due to a 'lenience height' that will let the platform fall a bit without dropping away fully. It is made of four $20 values. Notice that when doing this the platform does not check for solid tiles; it can be used to push a platform into the floor. If Keen just lands on the platform, it will fall at half speed while in this range. (This can be used to give the platforms some inertia)
Keen 4
#Platform 'lenience height'
%patch $11976 [$0080W]
Speed
There are three speed values of use. The first occurs when a rising platform stops; it is used to align the platform with normal 'ground level' when it stops rising, and may need changing if the platform's size or hitbox is changed. The two remaining values are the platform's speed immediately after Keen lands on it; by default they are zero, so the platform pauses (Sits still) for a short time before falling. Making this negative will make falling platforms harder to jump on, making it positive is... interesting.
The only relevant animation motion is that which controls how fast the rising Platform rises.
Motion
#Falling Platform
%patch $1199A [$00F0W] #If speed is less than this...
%patch $119A2 [$00F0W] #...change it to this
#When rising and hitting a 'B' sprite, move up this much (Then stop)
%patch $B0AB [$0046W]
#When Keen lands on Platform
%patch $11969 [$0000W] #Sit when Keen lands on sitting platform
%patch $11A0B [$0000W] #Sit when Keen lands on rising platform
Animation motion
#Platform sit
%patch $32004 [$0000W $0000W]
#Platform fall
%patch $32022 [$0000W $0000W]
#Platform rise
%patch $32040 [$0000W $FFE0W]
Sprite Collision
Platforms have no sprite collision. They do not interact with any sprites.
Collision values
Platforms have no collision at all. They do not interact with any sprites. (Keen being able to stand on them is part of his collision, not the Platform's.) Giving the Platform a collision can make them more interesting. (Destructible for instance.)
Keen 4 collision values
#Platform sit
%patch $3200C $00000000L
#Platform fall
%patch $3202A $00000000L
#Platform rise
%patch $32048 $00000000L
Animations
The Dropping Platform uses only one animation by default for all of its frames. 'It's' cache is not however used only by itself; instead it is used by all red platforms. This means that changing it will affect the other red platforms and cause either memory issues or an uncached sprite error. This makes editing the Dropping Platform's animations difficult.
Keen 4
#Cache
%patch $30704 {$01E4W} #Cache start
%patch $3074E {$01EAW} #Cache end
#Platform sit
%patch $31FF8 $01E4W $01E4W
%patch $32002 $0000W #Wait
#Platform fall
%patch $32016 $01E4W $01E4W
%patch $32020 $0000W #Wait
#Platform rise
%patch $32034 $01E4W $01E4W
%patch $3203E $0000W #Wait
Clipping and foreground
The Platforms have a foreground variable of 0, meaning they appears behind all sprites and foreground tiles. The clipping cannot be patched by default. They also have no clipping allowing them to fall through solid tiles.
Keen 4
#Foreground variable
%patch $1191A $0000W
Keen 4
#Clipping variable
%patch $1193E $0000W
Sprite-tile interaction
The Dropping Platform does not interact with tiles at all, it can pass right through them. Its tile interaction is simply to ensure it stays visible.
Keen 4
#Platform sit
%patch $32010 $09DC176ERL
#Platform fall
%patch $3202E $09DC176ERL
#Platform rise
%patch $3204C $09DC176ERL
Action type
The Dropping Platform must be instantly responsive, so it uses type 2 for its actions. The exception is the rising action which must also move smoothly upwards. This thus uses type 4. As a side effect of this all of the Platform's next actions are defined in its code.
Keen 4
#Platform sit
%patch $31FFC [$0002W]
#Platform fall
%patch $3201A [$0002W]
#Platform rise
%patch $32038 [$0004W]
Deprotect and stick to ground
The Dropping Platform needs neither of these variables and so both are set to 0.
Keen 4
#Platform sit
%patch $31FFE [$0000W $0000W]
#Platform fall
%patch $3201C [$0000W $0000W]
#Platform rise
%patch $3203A [$0000W $0000W]
Sprite spawn code
There is one initiation code for the Dropping Platform. Notice that there are three types, one for each difficulty level. The cache is set in $C7 $06 $CB6FW $0001W
The spawning code is more complex. In the spawning code the last blue highlighted value is the sprite action the Platform uses as it proceeds to act in-level. $C7 $06 $xxxxW sets the clipping, $C7 $07 $xxxxW sets the sprite type, $C7 $20 $xxxxW sets the foreground value. Finally $D3 $E0 $05 $xxxx is how far down (Or more usually up) the sprite is spawned from where it is placed. This is necessary for sprites that walk on the ground as they can only be placed in the level at multiples of 16 pixels high while their actual height can be anything.
$C7 $02 $xxxxW sets the sprite activity, $C7 $47 $10 $xxxxW is the vertical direction the sprite starts moving in, either $0001W (Facing down), $FFFFW (Facing up) or $0000W (Neither, never used.) $C7 $47 $0E $xxxxW is the horizontal direction. The Dropping Platform always starts the level moving down but with no horizontal direction. (As expected.)
The spawn code contains and is thus incompatible with a number of patches elsewhere on this page.
Keen 4 spawn code
#Location of initiation code
%patch $EEC3 [$038EW] #Dropping Platform (At $EC7E)
#Dropping Platform Initiation code
%patch $EC7E $FF $76 $FC $57 $9A {$108010FCRL} $83 $C4 $04 $C7 $06 $CB6FW
$0001W $E9 $016AW
#Dropping Platform Spawning code
%patch $118FC $55 $8B $EC $33 $C0 $50 $9A $06BD1E11RL $83 $C4 $02 $8B $1E
$D8 $A7 $C7 $07 [$0014W] $C7 $47 $02 [$0002W] $C7 $47 $20 [$0000W]
$8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B $46 $08 $D3 $E0 $89
$47 $3E $89 $47 $0C $C7 $47 $0E [$0000W] $C7 $47 $10 [$0001W] $C7
$47 $06 [$0000W] $B8 [$3188W] $50 $53 $9A $09DC118CRL $83 $C4
$04 $5D $CB