Patch:Keen's shot (Dreams)

From KeenWiki
Jump to navigation Jump to search

In Keen Dreams Keen's shot is either a Flower Power or Boobus Bomb depending on circumstance. It that can be shot in four directions while Keen is standing, jumping or on a pole. Both types of projectile are identical in nearly everything but appearance. King Boobus Tuber can, for example, be defeated using Flower Power.

This page deals with the properties of Keen's shots, be they Bombs or Flower Powers. It does not contain patches relating to the shooting player; such patches can be found on the Player Shooting page. This page also does not contain patches that relate to having or needing shots. As such patches (such as those that affect how many Bombs Keen needs to enter the boss level) can be found on the Flower Power or Boobus Bomb pages. Finally this page does not deal with Bombs or Flowers as items, that is, things that Keen can acquire in a level.

As a rough guide Keen's shooting page contains patches relating to his shooting animations and speed, the items page contains patches relating to what Keen will get when he picks up a Bomb or Flower and the Boobus Bomb and Flower Power pages contain patches relating to gameplay such as their appearance in the status window.

Sprite Type

Keen's shots are type 2; this has no effect on anything, enemy stunning is handled by the Flower Power's sprite collision code. They do however affect how Keen reacts to them; it is possible to make Keen's shot lethal to him for example. This patch affects both Flower Power and Boobus Bombs

Keen Dreams

#Keen's shot sprite type
%patch $63DC [$02]

Shot item type (What Keen recovers)

When Keen's shots 'land' they become obtainable again; Flower Power give a Flower Power and Bombs give a bomb. This is controlled by the projectile's 'sprite type'. This is simply the number of item desired. (See Patch:Items for a full list.)

Keen Dreams

#Keen's shot item type
%patch $646D [$08] #Flower Power
%patch $647D [$0A] #Boobus Bomb

Sprite Actions

The Flower Power is quite simple, it is spawned by Keen when he shoots in the first frame of its thrown cycle. It then animates between two 'thrown' actions until it hits a solid tile and lands on the ground. This causes it to change to its landed cycle. It will then remain in this cycle for a specified amount of time before vanishing.

The Boobus Bomb works similarly, however when it lands it converts into an item instead of vanishing, allowing Keen to retrieve it. It also explodes on hitting King Boobus Tuber; the explosion sequence is six frames long and ends with the explosion vanishing.

Boobus Bombs that are thrown by the player and don't hit anything will return to an item-like state so they can be picked up and reused. This is the only other case of item spawning in the game.

$0BD2W #Flower power thrown 1
$0BF0W #Flower power thrown 2
$0C0EW #Boobus bombs thrown 1
$0C2CW #Boobus bombs thrown 2
$0C4AW #Boobus Bomb explode 1
$0C68W #Boobus Bomb explode 2
$0C86W #Boobus Bomb explode 3
$0CA4W #Boobus Bomb explode 4
$0CC2W #Boobus Bomb explode 5
$0CE0W #Boobus Bomb explode 6
$0CFEW #Flower power landed 1
$0D1CW #Flower power landed 2 (Invisible)

Keen Dreams

#Make Flower Power
%patch $6472 [$0BD2W]

#Flower Power thrown cycle
%patch $2465E [$0BF0W]
%patch $2467C [$0BD2W]

#When Flower Power lands
%patch $6964 [$0CFEW]

#Landed Flower Power cycle
%patch $2478A [$0D1CW]
%patch $247A8 [$0CFEW]

#Make Boobus Bomb
%patch $6482 [$0C0EW]

#Boobus Bomb thrown cycle
%patch $2469A [$0C2CW]
%patch $246B8 [$0C0EW]

#Dropped Boobus Bombs turn into items
%patch $6955 [$196CW]

#Boobus Bomb explode on hitting enemies
%patch $65B2 [$0C4AW]

#Boobus Bomb explosion sequence
%patch $246D6 [$0C68W]
%patch $246F4 [$0C86W]
%patch $24712 [$0C4AW]
%patch $24730 [$0CC2W]
%patch $2474E [$0CE0W]
%patch $2476C [$0000W]

Boobus Bombs are always dangerous to the boss

This patch alters things so that Boobus Bombs do not revert to being items when they hit the ground. Instead they remain constantly dangerous no matter how long they sit. (Keen will still be able to re-acquire them however.)

Keen Dreams

#Boobus Bombs always dangerous
%patch $6939 $EB $3F

Sprite Behavior

The Flower Power has two behaviors, falling through the air (also used by many other sprites like Grapes.) and vanishing after a certain period (exclusive to the Flower Power.)

The Boobus Bombs have the exact same behavior as the Flower Power when thrown. Their explosion sequence uses no behavior.

$07C501A4RL #Fall
$05E80630RL #Vanish after a time

Keen Dreams

#Thrown Flower Power
%patch $24652 $07C501A4RL
%patch $24670 $07C501A4RL

#Landed Flower Power
%patch $2477E $05E80630RL
%patch $2479C $05E80630RL

#Thrown Bomb
%patch $2468E $07C501A4RL
%patch $246AC $07C501A4RL

#Bomb explosion
%patch $246CA $00000000L
%patch $246E8 $00000000L
%patch $24706 $00000000L
%patch $24724 $00000000L
%patch $24742 $00000000L
%patch $24760 $00000000L

Time before Flower Power vanishes

This patch controls the time before landed Flowers vanish. The maximum value is $7F, and values above this will cause problems.

Time before Flower Power vanishes

#Time before Flower Power vanishes
%patch $64C9 [$32]

Flower Power don't vanish

This patch stops landed Flowers from vanishing. Instead they merely sit, blinking, until the player picks them up again.

Landed Flower Power don't vanish

#Landed Flower Power don't vanish
%patch $64CA $EB

Landed Flower Power behavior code

This is the complete behavior code for landed Flower Power. The first line ticks up the Flower's Misc Variable and on the second line the game checks to see if this is larger than $32. If it is, the Flower is erased.

The first blue value on line 2 is what the Flower's graphic is set to, in this case 0 (Invisible.) This lets it blink in and out of existence before it vanishes.

Landed Flower Power behavior code

#Landed Flower Power behavior code
%patch $64B0 $55 $8B $EC $56 $8B $76 $06 $8B $44 $40 $03 $06 $BDD4W  $89 $44
             $40 $C7 $44 $20 [$0000W]  $83 $7C $40 [$32] {$7E} $08 $56 $9A $044D0240RL
                     $44 $44 $5E $5D $CB

Shot speed

The Flower Power gets its speeds when it is produced, its direction and speed being set together. These speeds constantly change change under the 'fall' behavior, leading it ever groundwards. This makes the shots curve as they fly through the air, though this can be altered. (See the behavior section.)

Shot direction

There are two aspects to shot direction. The first is the actual directions themselves. These are differentiated by giving different values of horizontal and vertical speed to a shot. However this code must be pointed to, and this is done with a pointer list that gets its value from what direction the player is facing.

There are eight possible directions for a shot to go (Up, up right, up left, left...) of which seven are on the list and only four are valid. (It is usually impossible to spawn an invalid shot, but it can happen.) Values on the list point to a location in code equal to their value plus $5E80. Actual shot speed values for each 'type' of shot are colored blue.

This patch affects Bombs and Flowers equally by default.

Keen Dreams

#Location of pointer list (5E80 + 622 = 64A2)
%patch $6412 [$0622W]

#Length of list
%patch $640A [$06]

#Spawnshot pointer list
%patch $64A2 [$0594W] #Upwards
             [$05D4W] #INVALID
             [$05A4W] #Rightwards
             [$05D4W] #INVALID
             [$05B4W] #Downwards
             [$05D4W] #INVALID
             [$05C4W] #Leftwards

#Vertical direction of all shots
%patch $6403 [$FFFFW]

#Shooting upwards
%patch $641B [$0000W] #Horizontal speed
%patch $6420 [$FFC0W] #Vertical speed

#Shooting right
%patch $642B [$0040W] #Horizontal speed
%patch $6430 [$FFECW] #Vertical speed

#Shooting down
%patch $643B [$0000W] #Horizontal speed
%patch $6440 [$0040W] #Vertical speed

#Shooting left
%patch $644B [$FFC0W] #Horizontal speed
%patch $6450 [$FFECW] #Vertical speed

Animation motion

All shots also have animation motion and this does not matter unless the 'fall' behavior is disabled in which case animation motion determines how fast they move in straight lines. As such this subsection is irrelevant in the default game.

Keen Dreams

#Thrown Flower Power
%patch $2464E [$0000W $0000W]
%patch $2466C [$0000W $0000W]

#Landed Flower Power
%patch $2477A [$0000W $0000W]
%patch $24798 [$0000W $0000W]

#Thrown Bomb
%patch $2468A [$0000W $0000W]
%patch $246A8 [$0000W $0000W]

#Bomb explosion
%patch $246C6 [$0000W $0000W]
%patch $246E4 [$0000W $0000W]
%patch $24702 [$0000W $0000W]
%patch $24720 [$0000W $0000W]
%patch $2473E [$0000W $0000W]
%patch $2475C [$0000W $0000W]

Flower Power Move in Straight Lines

This patch makes Flower Power move in straight lines, like Keen's shots in galaxy. it does affect Boobus Bombs, slowing their speeds but not making them move in straight lines. The only other side effect is that those thrown up will stick to ceilings and remain there forever. To prevent this a patch stopping Keen shooting up can be included. (but is not vital.)

The speed is a product of the animation speed and h\v speed, highlighted in blue in the first and third line of the patch. This patch uses a speed of $40 and an animation speed of $6. The shot directions depend on the following lines, and can be diagonal or even sit still.

The sixth line makes the shot vanish instantly when it hits walls and floors, so the player can't get it again. If removed then the flower power will blink a bit before vanishing instead. The first four lines stop Keen shooting up, since upwards shots do not vanish when they hit ceilings.

Keen Dreams

#Stop Keen throwing Flower Power (Optional)
%patch $6D29 $1130W #Upwards
%patch $71B0 $152CW #Upwards while jumping
%patch $7275 $11A8W #Upwards on a pole

#Vanish when hitting solid tiles (Optional)
%patch $6964 $0000W

#Flower power move in straight lines
%patch $24642 $00A2W $00A2W $0001W $0000W $0000W [$0006W $0040W $0040W]
%patch $24660 $00A3W $00A3W $0001W $0000W $0000W [$0006W $0040W $0040W]

%patch $641A $10 $FFFFW
%patch $641F $0E $0000W

%patch $642A $10 $0000W
%patch $642F $0E $0001W

%patch $643A $10 $0001W
%patch $643F $0E $0000W

%patch $644A $10 $0000W
%patch $644F $0E $FFFFW

Flower Power sit when produced

This patch makes the Flower Power Keen produces just sit in place, like mines. They will never vanish but will sit, waiting for an enemy to bump into them. Keen cannot pick them up again however.

This patch does not affect Boobus Bombs at all.

Keen Dreams

#Flower power don't move
%patch $24652 $00000000L
%patch $24670 $00000000L

Sprite collision

Unlike nearly all sprites in Keen Dreams the Flower Power\Boobus Bomb actually has its own sprite collision. This is used to react to all enemy sprites. (Details are covered in the code section below.)

The collision is used only by the thrown Flower Power and not those that have landed on the ground. (Though it can be if desired.) Notice that Boobus Bombs use the same collision as Flower Power

Keen Dreams

#Thrown Flower Power
%patch $24656 $05E806C7RL
%patch $24674 $05E806C7RL

#Landed Flower Power
%patch $24782 $00000000L
%patch $247A0 $00000000L

#Thrown Bomb
%patch $24692 $05E806C7RL
%patch $246B0 $05E806C7RL

#Bomb explosion
%patch $246CE $00000000L
%patch $246EC $00000000L
%patch $2470A $00000000L
%patch $24728 $00000000L
%patch $24746 $00000000L
%patch $24764 $00000000L

Sprite collision code

This is the complete code for the Flower Power and Boobus Bomb's sprite collision. It uses a list of pointers to do different things depending on the other sprite's sprite type. Flower Power interact with any sprite types between $05-$17. This excludes 'misc', Keen, Doors, items (Types $01-$04) and enemy projectiles (Type $18) There are three possible interactions; the first is to do nothing, the second to produce a Wilted Flower and the third to explode. (Used in the boss fight.) On the first line the lowest sprite type ($05) is set. On the second line the list length is given. ($12, so the highest entry is $12 + $05 = $17.)

At the end of the second line the 'stun' code begins. First the 'form Flower' sub is run then another sub which removes the Flower Power itself. Both pieces of code are located elsewhere.

At the end of line 3 the Boobus Tuber code begins. First is a check to see if Boobus has any health. If not 50'000 points is added to Keen's score twice. This is followed by Boobus' sprite type being set to $19, the same as defeated enemies. (This stops him harming Keen while dying.) His action is changed to dying and his sprite timer reset. (To time his death.) The code after this occurs whenever Boobus is hit, dying or not. Sound $15 plays and Keen's shot turns into an exploding bomb.

The third type of interaction 'do nothing' has no code. By default $06E3W is 'stun', $06F5W is 'Boobus' and $073EW 'do nothing'.

Keen Dreams

#Flower Power sprite collision
%patch $6547 $55 $8B $EC $56 $57 $8B $7E $06 $8B $76 $08 $8B $1C $83 $EB [$05]
             $83 $FB [$12] $77 $62 $D1 $E3 $2E $FF $A7 [$0742W]  $56 $9A $07C50381RL
                     $44 $44 $57 $9A $044D0240RL     $44 $44 $EB $49 $FF $4C
             $44 {$75} $2C $B8 [$C350W]  $50 $9A $044D090ERL     $44 $44 $B8 [$C350W]
                 $50 $9A $044D090ERL     $44 $44 $C7 $04 [$0019W]  $B8 [$246AW]
             $50 $56 $9A $07C50255RL     $83 $C4 $04 $C7 $44 $3E [$0000W]  $B8
             [$0015W]  $50 $9A $10BB1282RL     $44 $44 $B8 [$0C4AW]  $50 $57 $9A
             $07C50255RL     $83 $C4 $04 $5F $5E $5D $CB

#Flower Power pointer list             
%patch $65C2 [$06E3W] #Broccolash
%patch $65C4 [$06E3W] #Tomatooth
%patch $65C6 [$06E3W] #Carrot
%patch $65C8 [$06E3W] #Unused
%patch $65CA [$06E3W] #Asparagusto
%patch $65CC [$073EW] #Grape
%patch $65CE [$06E3W] #Tater Trooper
%patch $65D0 [$073EW] #Cart
%patch $65D2 [$06E3W] #Frenchy
%patch $65D4 [$073EW] #Melon
%patch $65D6 [$073EW] #Unused
%patch $65D8 [$073EW] #Unused
%patch $65DA [$073EW] #Unused
%patch $65DC [$073EW] #Unused
%patch $65DE [$06E3W] #Squasher
%patch $65E0 [$06E3W] #Apel
%patch $65E2 [$06E3W] #Pea Pod
%patch $65E4 [$06E3W] #Pea brain
%patch $65E6 [$06F5W] #Boobus Tuber


Flower Power do not have their own cache, being cached with Keen himself. As well as an item animation (which automatically uses the next animation as well.) they have two animation cycles which cover the two different types, the sitting collectables and the thrown pellet. The second frame of the thrown pellet is $FFFFW, or invisible.

Bombs are similar, they have an item animation and there are two frames used for a thrown Bomb. Bombs that hit King Boobus Tuber explode in a six animation sequence (using only two different animations.) There is a unique 'dropped bomb' animation however that determines what a Boobus Bomb looks like when shot and landed on the ground. This should match the item animation.

Keen Dreams

#Flower power item
%patch $25428 $00A4W

#Thrown Flower Power
%patch $24642 $00A2W $00A2W
%patch $2464C $000AW        #Animation speed
%patch $24660 $00A3W $00A3W
%patch $2466A $000AW        #Animation speed

#Flower power (Thrown, going to vanish)
%patch $2476E $00A2W $00A2W
%patch $24778 $0005W        #Animation speed
%patch $2478C $FFFFW $FFFFW
%patch $24796 $0005W        #Animation speed

#Bomb item
%patch $2542C $00C0W #Item
%patch $693F  $00C0W #Landed bomb

#Bomb thrown
%patch $2467E $00C0W $00C0W
%patch $24688 $0005W        #Animation speed
%patch $2469C $00C2W $00C2W
%patch $246A6 $0005W        #Animation speed

#Bomb explode
%patch $246BA $00C3W $00C3W
%patch $246C4 $0005W        #Animation speed
%patch $246D8 $00C4W $00C4W
%patch $246E2 $0005W        #Animation speed
%patch $246F6 $00C3W $00C3W
%patch $24700 $0005W        #Animation speed
%patch $24714 $00C4W $00C4W
%patch $2471E $0005W        #Animation speed
%patch $24732 $00C3W $00C3W
%patch $2473C $0005W        #Animation speed
%patch $24750 $00C4W $00C4W
%patch $2475A $0005W        #Animation speed


There are a number of sounds relating to the Flower Power (and Boobus Bomb.) Two identical sounds play if Keen does not have any Flowers or Bombs; two different sounds play when Keen throws a Bomb or Flower. Finally Bombs make a special sound when they detonate.

Keen Dreams

%patch $6385 $0E     #No Boobus Bombs sound
%patch $6393 $14     #Throw Boobus Bombs sound
%patch $63AF $0E     #No Flower Power sound
%patch $63BD $04     #Throw Flower Power sound
%patch $65A7 $15     #Boobus Bomb explode sound

#Don't make sounds:
%patch $6384 $EB $09 #Don't play No Boobus Bombs sound
%patch $6392 $EB $09 #Don't play Throw Boobus Bombs sound
%patch $63AE $EB $09 #Don't play No Flower Power sound
%patch $63BC $EB $09 #Don't play Throw Flower Power sound
%patch $65A6 $EB $09 #Don't play Boobus Bomb explode sound

Sprite positioning

Patches relating to where Keen's shots appear relative to him when he shoots are covered on the Keen Shooting page.

Clipping and foreground

Keen Dreams has a poorly developed foreground system that relies on specific code to make certain items foreground or not. As such very few sprites can be altered in this fashion. While both Bombs and Flowers can have their foreground altered, this applies only while they are in the air, so anything other than the default value can look strange.

Clipping cannot be altered at all, it's part of a standard sprite creation setup.

Keen's shots foreground variable

#Keen's shots foreground variable
%patch $65F4 [$0001W]

Sprite-tile interaction

There is one main tile interaction used by Keen's airborne projectiles, both Bombs and Flowers. It is complex but allows them to bounce off of solid tiles until they come to a stop, at which point they will either go to 'blinking' (Flower Power) or become an item (Boobus Bombs.)

Blinking Flowers use a general 'do nothing' tile interaction, as does the Bomb explosion. Sitting Boobus Bombs are items and thus use the same code as items do.

Keen Dreams

#Thrown Flower Power
%patch $2465A $05E80768RL
%patch $24678 $05E80768RL

#Vanishing Flower Power
%patch $24786 $07C501DDRL
%patch $247A4 $07C501DDRL

#Thrown Bomb
%patch $24696 $05E80768RL
%patch $246B4 $05E80768RL

#Bomb explosion
%patch $246D2 $07C501DDRL
%patch $246F0 $07C501DDRL
%patch $2470E $07C501DDRL
%patch $2472C $07C501DDRL
%patch $2474A $07C501DDRL
%patch $24768 $07C501DDRL

Action type

Both Bombs and Flowers use action type 3 when in the air, allowing them to run their behavior smoothly while still animating. Both the bomb explosion and landed Flowers use action type 0 since they don't have to do much but sit.

Keen Dreams

#Flower power (thrown)
%patch $24646 [$0003W]
%patch $24664 [$0003W]

#Flower power (Thrown, going to vanish)
%patch $24772 [$0000W]
%patch $24790 [$0000W]

#Bomb sit
%patch $24682 [$0003W]
%patch $246A0 [$0003W]

#Bomb explosion
%patch $246BE [$0000W]
%patch $246DC [$0000W]
%patch $246FA [$0000W]
%patch $24718 [$0000W]
%patch $24736 [$0000W]
%patch $24754 [$0000W]

Deprotect and stick to ground

At no point do Bombs or Flowers need to do anything relating to slopes or tricky animation. As such these variables are zero in all cases.

Keen Dreams

#Flower power (thrown)
%patch $24648 [$0000W] [$0000W]
%patch $24666 [$0000W] [$0000W]

#Flower power (Thrown, going to vanish)
%patch $24774 [$0000W] [$0000W]
%patch $24792 [$0000W] [$0000W]

#Bomb sit
%patch $24684 [$0000W] [$0000W]
%patch $246A2 [$0000W] [$0000W]

#Bomb explosion
%patch $246C0 [$0000W] [$0000W]
%patch $246DE [$0000W] [$0000W]
%patch $246FC [$0000W] [$0000W]
%patch $2471A [$0000W] [$0000W]
%patch $24738 [$0000W] [$0000W]
%patch $24756 [$0000W] [$0000W]