Patch:Horizontal-Vertical Platform (Keen 5)

From KeenWiki
Jump to navigation Jump to search

Platforms in Keen 5 are sprites that Keen can stand on and sometimes be carried places on. This page lists patches relating to a specific Platform sprite, the Horizontal-Vertical 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.

The Horizontal-Vertical Platform referred to on this page is the platform in Keen 5 that moves either vertically or horizontally back and forth in a straight line. The platforms that follow a complex path are known as Goplats. The Horizontal-Vertical Platform comes in two types, red and purple. For all intents and purposes they are identical.

Patches relating to other Keen 5 platforms can be found at Patch:Platform (Keen 5). Patches relating to the Horizontal-Vertical Platform in other Keen games can be found at Patch:Horizontal-Vertical Platform (Keen 4) and Patch:Horizontal-Vertical Platform (Keen 6).


Sprite Type

Horizontal-Vertical Platforms use type 6, 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 Horizontal-Vertical Platform uses the same value as all other platforms.

Keen 5

#Horizontal-Vertical Platform sprite type
%patch $FFF0  $06


Sprite Actions

There are three actions associated with the Horizontal-Vertical Platform; one of these is for the red version of the platform, the other two for the purple version. Aside from appearances they are identical.

In both cases the platform is spawned using its first action. The red Platform does nothing further while the purple Platform loops between its two actions indefinitely.

Actions:
$1B5EW #Horizontal-Vertical Red Platform
$1B7CW #u/d/l/r Purple plat
$1B9AW #u/d/l/r Purple plat

Keen 5

#Spawn Horizontal-Vertical Platforms:
%patch $1006E {$1B7CW} #Purple
%patch $1007D {$1B5EW} #Red

#Horizontal-Vertical Red Platform
%patch $31EBA {$0000W}

##Horizontal-Vertical Purple Platform
%patch $31ED8 {$1B9AW}
%patch $31EF6 {$1B7CW}


Sprite Behavior

Each of the two Horizontal-Vertical Platform types have a different behavior used by their respective actions. This is because one of the platforms must animate while the other does not.

Note that the red Platform's behavior is shared by the Slicestar.

Behaviors:
$0F920776RL #Horizontal-Vertical Red Platform
$0F92099CRL #Horizontal-Vertical Purple Platform

Keen 5 Platform behaviors

#Horizontal-Vertical Red Platform
%patch $31EAE $0F920776RL #Horizontal-Vertical Red Platform

#Horizontal-Vertical Purple Platform
%patch $31ECC $0F92099CRL #Horizontal-Vertical Purple Platform
%patch $31EEA $0F92099CRL #Horizontal-Vertical Purple Platform


Speed and [B] sprites

The speed of both Platforms are controlled entirely by their code and not their animation motion. Since both have different behaviors both have different speeds. Note that the red Platform's speeds are shared by the Slicestar and so altering them will alter the Slicestar's speeds.

Motion

#Red Platform\Slicestar's speeds
%patch $100B9 [$000CW] #Horizontal speed
%patch $100C8 [$000CW] #Vertical speed

#Purple Platform speeds
%patch $102DF [$000CW] #Horizontal speed
%patch $102EE [$000CW] #Vertical speed

Animation motion

#Horizontal-Vertical Red Platform
%patch $31EAA [$0000W $0000W]

#Horizontal-Vertical Purple Platform
%patch $31EC8 [$0000W $0000W]
%patch $31EE6 [$0000W $0000W]


Sprite Collision

Horizontal-Vertical Platforms have no sprite collision. They do not interact with any sprites.


Collision values

Horizontal-Vertical 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 5 collision values

#Horizontal-Vertical Red Platform
%patch $31EB2 $00000000L  #Nothing

#Horizontal-Vertical Purple Platform
%patch $31ED0 $00000000L  #Nothing
%patch $31EEE $00000000L  #Nothing


Animations

The Horizontal-Vertical Platforms use one or two animations by default; a different one for each action. 'Their' caches are not however used only by them; instead it is used by all red\purple platforms. This means that changing them will affect the other red\purple platforms and cause either memory issues or an uncached sprite error. This makes editing the Horizontal-Vertical Platform's animations difficult.

Keen 5 Caches

#Caches
%patch $31A44 {$01A6W} #Purple plat cache start
%patch $31A98 {$01A7W} #Cache end

%patch $31A4A {$01BEW} #Red plat cache start
%patch $31A9E {$01BEW} #Cache end

Keen 5

#Horizontal-Vertical Red Platform
%patch $31E9E $01BEW $01BEW #Red plat
%patch $31EA8 $0000W        #Wait

#Horizontal-Vertical Purple Platform
%patch $31EBC $01A6W $01A6W #Purple Plat
%patch $31EC6 $0000W        #Wait
%patch $31EDA $01A7W $01A7W #Purple Plat
%patch $31EE4 $0000W        #Wait


Moving Platform Activity

The Moving Platform must be active when offscreen, so it specifically has its activity variable set to 2. If it is any other value the Platform will stop moving when Keen cannot see it, meaning that they are much, much harder to use. (If for example Keen is stuck at the bottom of a deep pit and the platform to get out moves up offscreen, it will not come back down.)

Keen 5

#Horizontal-Vertical Platform activity variable
%patch $FFF5 $0002W


Clipping and foreground

The Horizontal-Vertical Platforms have a foreground variable of 0, meaning they appears behind all sprites and foreground tiles. The clipping cannot be patched by default; having no clipping allowing them to fall through solid tiles. Note that one patch affects both red and purple platforms.

Keen 5

#Horizontal-Vertical Platform foreground variable
%patch $FFFA  $0000W


Sprite-tile interaction

The Horizontal-Vertical Platforms do not interact with tiles at all, their tile interaction is simply to ensure it stays visible. (Tiles will block them by default due to their clipping.)

Keen 5

#Horizontal-Vertical Red Platform
%patch $31EB6 $090B17B5RL

#Horizontal-Vertical Purple Platform
%patch $31ED4 $090B17B5RL
%patch $31EF2 $090B17B5RL


Action type

Both platforms need to be instantly responsive. The Red Platform does not need to animate and thus uses type 2 for its action. The Purple Platforms do however and must use type 3.

Keen 5

#Horizontal-Vertical Red Platform
%patch $31EA2 [$0002W]

#Horizontal-Vertical Purple Platform
%patch $31EC0 [$0003W]
%patch $31EDE [$0003W]


Deprotect and stick to ground

The Horizontal-Vertical Platforms need neither of these variables and so both are set to 0 in all of their actions.

Keen 5

#Horizontal-Vertical Red Platform
%patch $31EA4 [$0000W $0000W]

#Horizontal-Vertical Purple Platform
%patch $31EC2 [$0000W $0000W]
%patch $31EE0 [$0000W $0000W]


Sprite spawn code

Both Red and Purple platforms have four types of initiation pointer. In each case all four pointers use the same initiation code. Notice that there are two different caches; one for each platform type. The cache is set in $C7 $06 $C2xxW $0001W. The [B] sprite has no initiation code, it is merely a special case of 'do nothing' sprite.

The initiation code is where the platforms' directions are set. Notice that both Red and Purple platform initiation codes use the same spawning code. They do however send a different value to it (o and 1 respectively) that let's the game change their initial action.

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. Notice that there are two actions in the code; as noted above Red and Purple platforms send a different value to the spawning code letting it 'pick' this one difference between the two platforms. Otherwise their spawning is the same.

$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.) $C7 $47 $0E $xxxxW is the horizontal direction.

Depending on their initial spawn value the Red or Purple platforms will jump to a certain spot in their spawning code that sets their initial directions. This list is 4 items long and located at $076E in the segment ($1008E in the code.) Each of the four options given will set one direction to zero.

The spawn code contains and is thus incompatible with a number of patches elsewhere on this page.

Keen 5 spawning

%patch $F4FA [$030AW] #Up Horizontal-Vertical Red Platform (At $F05A)
%patch $F4FC [$030AW] #Right Horizontal-Vertical Red Platform (At $F05A)
%patch $F4FE [$030AW] #Down Horizontal-Vertical Red Platform (At $F05A)
%patch $F500 [$030AW] #Left Horizontal-Vertical Red Platform (At $F05A)

%patch $F502 [$657W] #[B} sprite (At $F3A7)

%patch $F56C [$059BW] #Up Horizontal-Vertical Purple Platform (At $F2EB)
%patch $F56E [$059BW] #Right Horizontal-Vertical Purple Platform (At $F2EB)
%patch $F570 [$059BW] #Down Horizontal-Vertical Purple Platform (At $F2EB)
%patch $F572 [$059BW] #Left Horizontal-Vertical Purple Platform (At $F2EB))

#Red Horizontal-Vertical Platform initiation code
%patch $F05A $33 $C0 $50 $8B $46 $FA $05 $FFE5W  $50 $57 $56 $9A {$0F9206BCRL}
                 $83 $C4 $08 $C7 $06 $C29DW  $0001W  $E9 $0330W

#Purple Horizontal-Vertical Platform initiation code
%patch $F2EB $B8 [$0001W]  $50 $8B $46 $FA $05 $FFACW  $50 $57 $56 $9A {$0F9206BCRL}
                     $83 $C4 $08 $C7 $06 $C297W  $0001W  $E9 $009EW

#Horizontal-Vertical Red\Purple Platform spawning code
%patch $FFDC  $55 $8B $EC $33 $C0 $50 $9A $06B91DCDRL     $83 $C4 $02 $8B $1E
              $40 $9E $C7 $07 [$0006W]  $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 $0C $8B $5E $0A $83 $FB [$03] $77 $45 $D1 $E3 $2E $FF $A7 [$076EW]
               $8B $1E $40 $9E $C7 $47 $0E [$0000W]  $C7 $47 $10 [$FFFFW] $EB
              $2E $8B $1E $40 $9E $C7 $47 $0E [$0001W] $C7 $47 $10 [$0000W] $EB
              $1E $8B $1E $40 $9E $C7 $47 $0E [$0000W] $C7 $47 $10 [$0001W] $EB
              $0E $8B $1E $40 $9E $C7 $47 $0E [$FFFFW] $C7 $47 $10 [$0000W] $83
              $7E $0C $00 $74 $1B $8B $1E $40 $9E $83 $47 $0A $40 $83 $47 $0C
              $40 $B8 [$1B7CW]  $50 $53 $9A $090B11C4RL     $83 $C4 $04 $5D $CB
              $B8 [$1B5EW]  $50 $FF $36 $40 $9E $9A $090B11C4RL    $83 $C4 $04
              $5D $CB

#Platform direction list
%patch $1008E $6FDW #Up (At $1001D)
%patch $10090 $70DW #Right (At $1002D)
%patch $10092 $71DW #Down (At $1003D)
%patch $10094 $72DW #Left (At $1004D)