Patch:V Card Door

From KeenWiki
Jump to navigation Jump to search

The V card door is a special type of door found in Keen 5. It requires a "V card" to be opened. If Keen has no card, a denial noise will sound when Keen tries to enter it. If he possesses the card then an acceptance noise will play, the door tiles will animate four frames and Keen will enter the door. Keen will then be able to use the door like a regular keygem door.

There is also a special door value that causes Keen to win the level if the door in question uses it. For some patches you may wish to see Patch:Jump conditions. Patches relating to the V Card as a sprite can be found on Patch: V Card.


Keen doesn't automatically enter V-card doors

This patch prevents Keen from automatically entering V-card doors when he has a card. Instead he will simply return to standing, allowing the player to choose whether to enter the door.

Keen 5

#Keen doesn't automatically enter V-card doors:
%patch $AD63 [$0C84W]


Don't lose V card on opening a door

This patch prevents Keen from losing any V cards he has when opening a door. This means once he gets a card he can use it as many times as he wants in a level.

Keen 5

#Don't lose V card on opening a door
%patch $AD12 $EB $04


Win level value

As mentioned above there is a special pointer value (What is placed over the 'door property' tiles of a door to tell the game the x,y location in the level Keen will go to when he enters the door.) that will cause Keen to win the level. In previous games a door with a value of $0000W would do this, transporting Keen out outside the level, where he would win. This however also moved the screen, making it a little odd to use. This value skips everything and simply wins the level. (A value of $0000W can still be used however.)

Note that this applies to all doors in Keen 5, not just the V-Card door.

Keen 5

#Pointer value for doors that wins level:
%patch $B44D $B1B1W


Win level code

This is the code executed when Keen enters a door marked with the win level pointer value. The first few bytes are a check for this value, which can be anything. (Due to level size limits $B1B1 is guaranteed to not be useable by normally functioning doors.) If the value is found then the level state is set to 2 (Win level, see link for other values.) and Keen's sprite action is set to $DB0W (Enter door)

Keen 5

#Win level door pointer code
%patch $B44B $81 $FF [$B1B1W]  {$75} $11 $C7 $06 {$6F70W}  [$0002W]  $C7 $44 $1C [$0DB0W]
                 $5F $5E $8B $E5 $5D $CB


Door animation and V-door tile type

Door animation is properly controlled by the door sprite behavior below. However it is possible to not produce the door sprite at all, thus disabling V-door animation. The check as to whether or not to animate the door depends on the tile property of the door tile, which can also be patched.

Keen 5

#What tile property(ies) cause Keen to animate a door when walking through it:
%patch $AD05  [$20] {$74}


Size of door

By default the V-door must be square, the same height as width.

Keen 5

#Size of door
%patch $E08B $0004W


Number of tile animation frames

This is the number of tile animations that the door uses. However there is a second variable, the width of the door in the tileset. For keygem doors this is one tile wide, that is the door tiles are right next to each other. For V-doors this is four tiles wide; even if only one column of door is used it will look for a column of tiles four away in the tileset, unless this is patched.

This means that, as can be seen in the Keen 5 tileset, each door tile must animate to one four tiles away.

Keen 5

#Number of tile animation frames
%patch $E0B3 $0003W

Keen 5

#Width of door in tileset
%patch $E06C $0004W


Disable V-door animation

Keen 5

#Do not animate card door when exiting:
%patch $AD06  $90 $90


Door sprite

As with keygem doors, the actual door opening tile changes are effected by an invisible metasprite placed in the level (and later removed) specifically for this purpose. In the case of the V-door the sprite is placed at a relative location from where the player is when they open the door, rather than where the keygem holder points to. This means that all V-doors must open close to the player.


Sprite Actions

The V-door sprite is placed into the level as the v-door is opened, along with the acceptance sound and Keen entering it. It then loops constantly to itself, that is, by itself it will not go away, but continue animating tiles. Fortunately its own behavior eventually removes it from the level by setting its action to zero.

Actions
$1610W #Animate tiles

Keen 5

#Place V-door in level
%patch $AD54  [$1610W]

#V-door keeps itself going
%patch $3196C [$1610W]

#Remove V-door from level
%patch $E0BA  [$0000W]


Sprite Behavior

The V-door sprite can have only one behavior, and this is the 'replace a section of tiles' behavior.

Behaviors
$0CCB1373RL #Open V-door

Keen 5

#V-Door behavior
%patch $31960 $0CCB1373RL


Door animation code

This is the complete door animation behavior code used by the V-door sprite. Notice that V-door tile replacement areas must be square, that is, the same height and width. It also contains the number of door animation frames; after a certain number of 'counts' the V-door sprite is replaced by 'nothing' (Sprite value $0000W) which effectively removes the sprite and stops the door animating further.

This code patch can be used for other things, like keygem doors. It is incompatible with (as it contains) the number of frames patch, door size patch and 'remove door action' patch also on this page.

Keen 5

#Complete V-door opening code
%patch $E023 $55 $8B $EC $83 $EC $26 $56 $57 $8D $46 $DA $8B $F8 $8B $5E $06
             $8B $5F $0C $D1 $E3 $8B $87 $87 $BF $D1 $E8 $D1 $E0 $8B $16 $51
             $9E $8B $5E $06 $8B $5F $0A $D1 $E3 $03 $C3 $89 $56 $FC $89 $46
             $FA $C7 $46 $FE $00 $00 $EB $29 $33 $F6 $EB $15 $8B $C6 $D1 $E0
             $C4 $5E $FA $03 $D8 $26 $8B $07 $2D [$0004W]  $89 $05 $83 $C7 $02 #Door width in tileset
             $46 $83 $FE $04 $7C $E6 $FF $46 $FE $A1 $4C $9E $D1 $E0 $01 $46
             $FA $83 $7E $FE $04 $7C $D1 $B8 [$0004W]  $50 $50 $8B $5E $06 $FF #Door size h AND v
             $77 $0C $FF $77 $0A $B8 $0001W  $50 $16 $8D $46 $DA $50 $9A
         $174E0F25RL     $83 $C4 $0E $8B $5E $06 $FF $47 $3E $8B $47 $3E $3D
             [$0003W]  {$75 $05} $C7 $47 $1C [$0000W]  $5F $5E $8B $E5 $5D $CB    #Remove door action after 3 frames

Speed and Jump Height

The V-door sprite does not move.

Keen 5

#V-door movement speed
%patch $3195C [$0000W $0000W]


Sprite Collision

The V-door sprite has no sprite collision; it does not interact with anything.

Keen 5

#V-doorsprite collision
%patch $31964 $00000000L


Animations

The V-door sprite is invisible and cannot display an animation due to how it is created. However it's animation speed is important; it is how fast the door tiles animate.

Keen 5

#V card door animations
%patch $31950 [$0000W $0000W]
%patch $31950 [$000FW]        #Animation speed


Sprite positioning

As mentioned above the V-door sprite is placed in the level relative to the player when they open the door. (Specifically relative to the rightmost of the two door pointer values.) There are two values to consider, the horizontal and vertical position, and, although these are positive, they are up and left of the player.

Keen 5

#Location of animation square start (From rightmost door value)
%patch $AD33  $0002W #Horizontal
%patch $AD40  $0004W #Vertical


Sprite-tile interaction

The V-door sprite doesn't interact with tiles at all.

Keen 5

#V card door tile collision
%patch $31968 $00000000L


Action type

The V-door sprite is type 0, meaning it uses its behavior, namely animating tiles, once every time it animates.

Keen 5

#V card door tile collision
%patch $31954 $0000W


Deprotect and stick to ground

The V-door sprite uses neither parameter as it has no need for them.

Keen 5

#V card door tile collision
%patch $31956 $0000W $0000W


Sounds

These are the sounds V-doors use in the games.

Keen 5

%patch $AD19  $12 #Card door open
%patch $AD7A  $0E #Cannot enter V card door

#Don't play sounds
%patch $AD1C  $90 $90 $90 $90 $90 #Card door open
%patch $AD7D  $90 $90 $90 $90 $90 #Cannot enter V card door