Patch:Keen (Keen Dreams)
This page contains patches relating to Keen as a sprite in Keen Dreams. That is, such things as the sprites used, the speeds and sounds. It does not cover patches relating to gameplay such as those that make levels scroll or change keys. Those can be found at Patch:Gameplay (Keen Dreams). It 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.
As little is known about Keen, there is less information here than for most sprites.
Keen behaviors with their own pages
The following pages have been created for specific Keen actions that have a significant number of patches, necessitating them being kept separate for clarity:
Keen's type is 1. This has no effect on any sprites at all; things in Keen Dreams happen when Keen reacts to stuff.
|Patch: Keen Dreams|
Keen's actions are complex and only poorly understood at this time.
Actions: $0ED8W #Keen stand
|Patch: Keen Dreams|
Keen's sprite collision, along with that of the Flower Power, is responsible for the bulk of sprite interactions. Nearly all enemy sprites have no sprite collision and instead it is the player's response to them which matters. As such the player's sprite collision is exceedingly complex. This collision is used by Keen in nearly all of his actions.
The first segment of the sprite collision is the 'hub'; this is what decides what is done next. First a value of 3 is subtracted from the sprite's infoplane value; this skips over both normal Keens and the map Keen. (The infoplane value is the value of the sprite's 'tile' in the level. For example $0001W is Keen right and $0003W is the Horseradish Hill map entrance.) On the start of line 2 all sprites with an remaining value of 15 or less are excluded, they do not interact with Keen because they are level entrances.
In the middle of line 3 is another limit, $0B. Any sprite with an infoplane value higher than $15 + $0B (By default $20 or past the Items.) will have its sprite collision determined by its sprite type instead of its infoplane value. The two lists used for this are highlighted in brown. Of spacial note is that items have their sprite type set to $19 on first collision. This means they will only use the item collision once which is important since otherwise they would interact multiple times. (So a key could give a key 10 times in a row before vanishing say.)
What code the player runs is determined by a list whose location is marked in brown in the hub patch. (Its absolute location is this value plus the segment value of $5E80.) The sprite list is placed after all of the other code but is included with the hub here for simplicity.
The points collision code has four variables. The first is the sound played when points are got, $07. The second is the start of the points got animations $C7 or 199. The third is the start of the points given list at $23A70 + $16AA by default. Finally there is the 'got points' action $198AW which is what points become.
The 1UP code is similar to the points code except there is no need for the points got list location, only the sound, sprite and action values. The code also adds 1 to $7126W or the life variable.
The Eye code is more complex. It too plays sound $12 and sets the new sprite animation on its first line. On the second line it adds 3 to the life counter and 8 to the Flower Power counter as well as 20'000 points. On the third line it sets the eye got action.
The Flower Power got code is similar to the 1Up code. It plays sound $06 and sets the new animation on the first line, adds 1 to the Flower Power counter and sets the new sprite action on the second line. The Flower Pot code is nearly identical except that it adds 5 to the Flower Power counter.
The Boobus Bomb code is again very similar, playing sound 8 but adding to two counters, the Flower Power and temporary Boobus Bomb variables. (This is so that should Keen die in the level he will loose all of the bombs he obtained. Only after winning the level do the bombs become 'permanent'.) Likewise the key code which plays sound $17 and adds 1 to the key variable.
The door code is rather complex. On the first line the game checks to see if Keen has any keys, if not it skips the next three lines. If Keen does have keys then the game checks to see if the Door is already opening (Action $1750.), if so the entire code is skipped to avoid 'double opening' a door. The second line is the door opening code, sound $13 is played and the key counter decreased by 1. The door's action is changed to opening on line 3. Lines 4-5 are the 'door blocking' code; sound $0E is played and Keen's movement blocked.
The Tater Trooper code checks to see if the Trooper's single deadly action is in use. If so then Keen will be killed, otherwise the code is skipped.
The Carrot code pushes Keen. First it checks Keen's clipping, if he has none (such as when he is on a pole.) the code is skipped. Else sound $19 is played, Keen's clipping is set to 1, Keen's action set to his third jumping frame ($1568W), and his draw variable is set to 1. Some other game variable is set to 0.
The Carts. is simple; it calls the push code with value 1. The result of this is it will push Keen unless Keen is against a wall in which case he'll die. This is separate from and different to the Carrot\Squasher push codes.
The Broccolash code checks to see if either of the Broccolash's two deadly actions are in use. If so the code jumps to the 'deadly' sprite code, otherwise it skips everything and nothing happens.
The Squasher code checks to see if the Squasher's single deadly action is in use. If so then it jumps to the deadly code. Otherwise it runs 'push Keen' code. This is nearly identical to the Carrot Courier's pushing code discussed above.
The Grape's code checks to see if its single deadly action is i use. If so then it jumps to the deadly code, otherwise it skips everything and nothing happens.
The deadly sprite code simply runs the 'kill Keen' code. It is jumped to by a few other sprites as well as being used directly.
|Patch: Keen Dreams|
Keen has two caches, one for his map sprites and one for his in-level sprites. These caches cover not only the player, but also things like collectable items, the door and Patch:Wilted Flowers that Keen will (nearly) always encounter in any level. There are a large number of animation cycles for the player and only the player-related cycles are shown here.
|Patch: Map Keen|
|Patch: Level Keen|
There are two initiation codes, one for Keen facing left and one for Keen facing right. Both are nearly identical except for Keen's starting direction. Both use the same spawning code. There is no cache, Keen's sprites are automatically cached in every level.
In the spawning code the last blue highlighted value is the sprite action the sprite uses as it proceeds to act in-level. $C7 $02 $xxxxW sets the clipping, $C7 $07 $xxxxW sets the sprite type. 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.
Keen's horizontal direction depends on his initiation code. (It is the first blue variable.) He always starts the level 'facing down' however, though this is of little importance. $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.) Keen's sprite type is important, if it is not $0002W then he will be invulnerable to enemy sprites since this sprite type is used to identify 'killable players'
|Patch: Keen Dreams|
Keen's spawn height and changing Keen's height
This simple patch alters how high Keen spawns above where he is placed in a level. By default this is 17 pixels up,suitable for a Keen sprite 33 pixels high. If Keen's height is changed, this should be changed to reflect that. It is part of the above spawning code patch and shouldn't be used in conjunction with it.
|Patch: Keen Dreams|