Patch:Doors (Dreams)

From KeenWiki
Jump to navigation Jump to search

This page contains patches relating to the doors in Keen Dreams. Unlike both Keen Vorticons and Keen Galaxy, doors in Keen Dreams are sprites, like enemies or the player. (As opposed to metasprites.)


Keys

There are three places in the game where keys are important, obtaining a key, opening a door and dying. (Keys are not reset if you load a game or win a level meaning that this can be exploited to get 'extra' keys.) Keys are increased by one when a key is obtained and decreased by one when opening doors. Key sprites themselves are an item and patches relating to them are covered under Patch:Items.


What dying sets keys to

If Keen dies his keys are set to zero by default.

Keen Dreams

#On dying set keys to 0
%patch $5DC6 {$7122W}  [$0000W]


The F10-I cheat

The items cheat gives Keen 99 keys by default.

Keen Dreams

#On dying set keys to 0
%patch $383B {$7122W}  [$0063W]


Door sprites

This section deals with door sprites. These are actual sprites like enemies that block Keen moving past them.


Sprite Type

Doors are type 3 which blocks Keen from passing unless he has a key.

Keen Dreams

#Door sprite type
%patch $7F86 [$03]


Sprite Actions

The Door has two actions, sitting and opening. The Door is spawned sitting and only opens when Keen touches it with a key. The opening Door exists for a while but then vanishes.

Actions:
$1732W #Door sit
$1750W #Door open

Keen Dreams

#Door spawned
%patch $7FAD  [$1732W]

#Sitting Doors keep sitting
%patch $251BE [$1732W]

#Door opens when Keen touches it
%patch $77DD  [$1750W]

#Opening Doors vanish
%patch $251DC [$0000W]


Sprite Behavior

The Door uses no behavior at all, both when sitting and opening.

Keen Dreams

#Door sit
%patch $251B2 $00000000L

#Door open
%patch $251D0 $00000000L


Sprite collision

Unlike most sprites in Keen Dreams the Door actually has a sprite collision. This makes it act solid towards other sprites so that they cannot pass it as well as open if Keen has a key. (However the bulk of the opening code depends on Keen's collision code.)

Keen Dreams

#Door sit
%patch $251B6 $07C5036ERL

#Door open
%patch $251D4 $07C5036ERL


Speed

The Door's speed is controlled by its animation motion. When opening it moves upwards.

Keen Dreams

#Door sitting
%patch $251AE [$0000W $0000W]

#Door opening
%patch $251CC [$0000W $0020W]


Animations

Doors have no cache of their own, being cached with Keen himself. They have two frames, sitting and opening. The opening door will move upwards two tiles before vanishing. (This is controlled by its animation speed.)

Keen Dreams

#Door sit
%patch $251A2 $00D3W $00D3W
%patch $251AC $0000W        #Animation speed

#Door open
%patch $251C0 $00D3W $00D3W
%patch $251CA $0018W        #Animation speed


Sprite-tile interaction

The Door uses a general 'sit' tile interaction, not really interacting with any tiles at all, both when sitting and opening. Because it has no clipping it doesn't notice solid tiles by default.

Keen Dreams

#Door sit
%patch $251BA $07C501DDRL

#Door opening
%patch $251D8 $07C501DDRL


Action type

The sitting Door must react quickly so uses a type 2 action. When opening it has to move smoothly and so uses a type 1 action.

Sprite action types

#Door sit
%patch $251A6 [$0002W]

#Door opening
%patch $251C4 [$0001W]


Deprotect and stick to ground

The Door has no need for either of these variables and so has a value of 0 for both in all of its actions.

Sprite deprotect, stick

#Door sit
%patch $251A8 [$0000W $0000W]

#Door opening
%patch $251C6 [$0000W $0000W]


Sprite spawn code

There is one type of Door. In its initiation code no cache is set; the Door's animations appear to be always cached in every level.

The last blue highlighted value is the sprite action the sprite uses as it proceeds to act in-level. $C7 $07 $xxxxW sets the sprite type, $C7 $47 $06 $xxxxW sets the |clipping, and $C7 $47 $0E $xxxxW is the horizontal direction the sprite starts moving in, either $0001W (Facing right), $FFFFW (Facing left) or $0000W (Neither, seldom used.) $C7 $47 $10 $xxxxW is the vertical direction and works similarly. The Door has no clipping and spawns facing up and right.

Finally $D3 $E0 $05 $xxxxW 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. The Door spawns 16 pixels or 1 tile higher than where it is placed.

Keen Dreams

#Door initiation pointer
%patch $4A1D $0316W #Door (At $47E6)

#Door initiation code
%patch $47E6 $FF $36 $7052W  $FF $36 $7050W  $9A $07C50323RL     $83 $C4 $04
             $8B $1E $3E $70 $C7 $47 $02 $0000W  $E9 $01CAW

#Door spawn code
%patch $7F73 $55 $8B $EC $33 $C0 $50 $9A $044D01C9RL     $44 $44 $8B $1E $3E
             $70 $C7 $07 [$0003W]  $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B
             $46 $08 $D3 $E0 $05 [$FF00W]  $89 $47 $0C $C7 $47 $0E [$0001W]  $C7
             $47 $10 [$FFFFW]  $C7 $47 $06 [$0000W]  $B8 [$1732W]  $50 $FF $36 $3E
             $70 $9A $044D1212RL     $83 $C4 $04 $5D $CB