Patch:Horizontal-Vertical Platform (Keen 6)

From KeenWiki
Jump to navigation Jump to search

Platforms in Keen 6 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 6 that moves either vertically or horizontally back and forth in a straight line. The platforms that follow a complex path are known as Goplats. Patches relating to other Keen 6 platforms can be found at Patch:Platform (Keen 6). 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 5).


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 6

#Horizontal-Vertical Platform sprite type
%patch $100EA $06


Sprite Actions

There is only one action associated with the Horizontal-Vertical Platform. The platform is spawned using this action, doing nothing else indefinitely.

Actions:
$1DD8W #Horizontal-Vertical Platform

Keen 6

#Spawn Horizontal-Vertical Platforms:
%patch $10156 [$1DD8W]

#Horizontal-Vertical Platform does nothing:
%patch $$32B24 [$0000W]


Sprite Behavior

The Horizontal-Vertical Platform has only one behavior. This is what makes it react to [B] sprites.

Behaviors:
$0EFC11B0RL #Horizontal-Vertical Platform

Keen 6 Platform behaviors

#Horizontal-Vertical Platform behavior
%patch $32B18 $0EFC11B0RL


Speed and [B] sprites

The speed of Platforms is controlled entirely by their code and not their animation motion.

Motion

#Platform's speeds
%patch $1017F [$000CW] #Horizontal speed
%patch $1018E [$000CW] #Vertical speed

Animation motion

#Horizontal-Vertical Platform
%patch $32B14 [$0000W $0000W]


Moving Platform initial directions

The number of different platforms is 4 (3 + 1), which can be changed in the code. The types are differentiated by their placement value, so if more platform types are added, they should be added directly after the existing types.

The Moving Platforms have four directions they may start the level moving in. These are combinations of $C7 $47 $10 $xxxxW (The vertical direction the sprite starts moving in, either $0001W (Facing down), $FFFFW (Facing up) or $0000W, none.) and) $C7 $47 $0E $xxxxW, the horizontal direction (Same values for right, left or none.) As an example to start the level moving left a platform needs a vertical value of 0 and a horizontal value of -1.

It is possible for platforms to move both horizontally and vertically (that is, diagonally.) This can be difficult to make work but is possible.

Keen 6

#Number of different platform types
%patch $1010D $03

#Location of direction list
%patch $114EA $11A8W

#Platform direction list
%patch $10168 [$1157W] #Up (At $10117)
%patch $1016A [$1167W] #Right (At $10127)
%patch $1016C [$1177W] #Down (At $10137)
%patch $1016E [$1187W] #Left (At $10147)

#Platform directions
#Up platform
%patch $1011D $0E [$0000W]
%patch $10122 $10 [$FFFFW]

#Right platform
%patch $1012D $0E [$0001W]
%patch $10132 $10 [$0000W]

#Down platform
%patch $1013D $0E [$0000W]
%patch $10142 $10 [$0001W]

#Left platform
%patch $1014D $0E [$FFFFW]
%patch $10152 $10 [$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 6 collision values

#Horizontal-Vertical Platform
%patch $32B1C $00000000L  #Nothing


Animations

The Horizontal-Vertical Platforms use one animation by default. 'It's' cache is not however used only by them; instead it is used by all other Platforms as well. This means that changing them will affect the other platforms and cause either memory issues or an uncached sprite error. This makes editing the Horizontal-Vertical Platform's animations difficult.

Keen 6 Caches

#Cache
%patch $32436 {$01A8W} #Platforms cache start
%patch $32486 {$01B0W} #Cache end

#Horizontal-Vertical Platform
%patch $32B08 $01A8W $01A8W
%patch $32B12 $0000W


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.

Keen 6

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


Change Moving Platform's clipping

This patch allows the modder to change the Moving Platform's clipping. It does this by overwriting the Platform's foreground values (Which was 0 anyway.) This patch results in the platform having no clipping and thus being able to pass through tiles. This is of course incompatible with the above M.P. foreground patch.

Keen 6

#Horizontal-Vertical Platform has no clipping
%patch $100F3 $06 $0000W


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 6

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


Sprite-tile interaction

The Horizontal-Vertical Platforms do not interact with tiles at all. (Tiles will block them by default due to their clipping.)

Keen 6

#Horizontal-Vertical Platform
%patch $32B20 $08F4180ARL


Action type

The Horizontal-Vertical Platforms need to be instantly responsive, as such they use type 2 for their action.

Keen 6

#Horizontal-Vertical Red Platform action type
%patch $32B0C [$0002W]


Deprotect and stick to ground

The Horizontal-Vertical Platforms need neither of these variables and so both are set to 0 in its action.

Keen 6

#Horizontal-Vertical Red Platform
%patch $32B0E [$0000W $0000W]


Sprite spawn code

The first thing to note is that there are five different initiation pointers involved with Platforms. Each of the four different Platform direction requires a different sprite (Heading to the same spawn code however.) The 'B' sprite goes directly to the 'nothing' spawn code, since its job is just to act as a placeholder to affect things in levels.

In the initiation code notice the Platform cache being set ($C7 $06 $CD23W $0001W). The same cache is set by the Dropping Platform.

In the spawning code the last blue highlighted value is the sprite action the sprite 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.

Note that $C7 $02 $xxxxW sets the sprite activity; this must be 2 for the moving platform since it allows he sprite to function when not onscreen. (The game by default would be unbeatable if Platforms vanished offscreen never to return unless Keen found a way to get close to them.)

The Moving Platforms have four directions they may start the level moving in. These are combinations of $C7 $47 $10 $xxxxW (The vertical direction the sprite starts moving in, either $0001W (Facing down), $FFFFW (Facing up) or $0000W, none.) and) $C7 $47 $0E $xxxxW, the horizontal direction (Same values for right, left or none.) As an example to start the level moving left a platform needs a vertical value of 0 and a horizontal value of -1.

It is possible for platforms to move both horizontally and vertically (that is, diagonally.) This can be difficult to make work but is possible. The spawning code patch contains, and is thus incompatible with, a number of other patches on this page, such as the sprite type, clipping and initial directions patches. It should be a simple matter to see where these patches are located in the spawn code.

The number of different platforms is 4 (3 + 1), which can be changed in the code. The types are differentiated by their placement value, so if more platform types are added, they should be added directly after the existing types.

Keen 6

#Location of initiation code
%patch $E98E [$04A7W] #B sprite (At $E8C7)

Keen 6

#Location of initiation codes
%patch $E986 [$01B4W] #Platform up (At $E5D4)
%patch $E988 [$01B4W] #Platform right (At $E5D4)
%patch $E98A [$01B4W] #Platform down (At $E5D4)
%patch $E98C [$01B4W] #Platform left (At $E5D4)

#Horizontal-Vertical Platform initiation code
%patch $E5D4 $8B $46 $FA $05 [$FFE5W]  $50 $57 $56 $9A {$0EFC1116RL}    $83 $C4
             $06 $C7 $06 $CD23W  $0001W  $E9 $02D9W

#Horizontal-Vertical Platform spawn code
%patch $100D6 $55 $8B $EC $33 $C0 $50 $9A $069A1E25RL     $83 $C4 $02 $8B $1E
              $66 $A9 $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     #3 + 1 Platform types
          {$11A8W}  $8B $1E $66 $A9 $C7 $47 $0E [$0000W]  $C7 $47 $10 [$FFFFW]  $EB #List location, up code
              $2E $8B $1E $66 $A9 $C7 $47 $0E [$0001W]  $C7 $47 $10 [$0000W]  $EB #Right code
              $1E $8B $1E $66 $A9 $C7 $47 $0E [$0000W]  $C7 $47 $10 [$0001W]  $EB #Down code
              $0E $8B $1E $66 $A9 $C7 $47 $0E [$FFFFW]  $C7 $47 $10 [$0000W]  $B8 #Left code
              [$1DD8W]  $50 $FF $36 $66 $A9 $9A $08F41219RL     $83 $C4 $04 $5D
              $CB

#Direction list
%patch $10168 [$1157W] #Up (At $10117)
%patch $1016A [$1167W] #Right (At $10127)
%patch $1016C [$1177W] #Down (At $10137)
%patch $1016E [$1187W] #Left (At $10147)