Patch:Blue Bird

From KeenWiki
Jump to: navigation, search

This page covers patches relating to the Blue Birds in Keen 4. The birds appear in several levels and are notable in that they can also be produced when Keen breaks a Blue Bird Egg. Birds are also notable in that they cannot be permanently stunned, eventually recovering from being shot.

Patches relating to the egg are found on its page, as well a patches relating to the hatching of a bird from an egg. See also Patch:Egg


Sprite Type

Blue birds use sprite type 28 which is used only by the Blue bird and doesn't affect anything else. When an Blue bird hatches from an egg, its sprite type must also be set. This doesn't have to be the same as the 'normal' Blue bird. By default all sprite properties don't affect anything.

Patch: Keen 4
#Blue bird sprite type
%patch $10034 $1B
#Birds placed in level
%patch $100F5 $1B
#Birds hatched from eggs


Sprite Actions

Blue birds have several sets of actions. The wait action is closely related to the egg sprite. There are 4 walking and flying actions, a stunned action and 4 unstunning actions. There is also an unknown action that may be the bird landing.

Birds are spawned waiting and will then walk. A walking bird will fly if Keen moves above it. A flying bird will land if Keen is standing below it. A stunned bird will unstun and return to walking. The 'landing' action seems to wait until the bird touches the ground. The stunned actions are treated more fully under the sprite collision section.

If the bird's flying actions are changed to walking ones then the bird will not be able to fly. Likewise if the landing-walking actions are changed to flying ones, the bird will not be able to land and walk.

Actions:
$21B6W #Bluebird wait
$21D4W #Bluebird walking 1
$21F2W #Bluebird walking 2
$2210W #Bluebird walking 3
$222EW #Bluebird walking 4
$224CW #Bluebird flying 1
$226AW #Bluebird flying 2
$2288W #Bluebird flying 3
$22A6W #Bluebird flying 4
$22C4W #Bluebird go to land?
$22E2W #Stunned Bluebird
$2300W #Bluebird unstunning 1
$231EW #Bluebird unstunning 2
$233CW #Bluebird unstunning 3
$235AW #Bluebird unstunning 4

Patch: Keen 4
#Blue bird placed in-level
%patch $10099 $21B6W
#Bluebird wait
%patch $10135 $21B6W
#Bluebird wait (Hatching from eggs)
#Waiting bluebird
%patch $31042 $21D4W
#Bluebird walking 1
#Walking bluebird
%patch $1022F $224CW
#Bluebird flying 1 (Check the BB is NOT doing this before trying to fly)
%patch $10242 $224CW
#Bluebird flying 1 (Do this if Keen is standing above the walking bird)
%patch $10399 $224CW
#Bluebird flying 1 (Do this if walking bird is NOT standing on ground)
#Bluebird walking loop
%patch $31060 $21F2W
#Bluebird walking 2
%patch $3107E $2210W
#Bluebird walking 3
%patch $3109C $222EW
#Bluebird walking 4
%patch $310BA $21D4W
#Bluebird walking 1
#Flying bluebird
%patch $103D3 $21D4W
#Bluebird walking 1 (Land when Keen is standing level with bird)
%patch $10499 $21D4W
#Bluebird walking 1 (Land when Keen is standing below bird and bird is touching ground)
#Bluebird flying loop
%patch $310D8 $226AW
#Bluebird flying 2
%patch $310F6 $2288W
#Bluebird flying 3
%patch $31114 $22A6W
#Bluebird flying 4
%patch $31132 $224CW
#Bluebird flying 1
#Stunned bird and unstun loop
%patch $3116E $2300W
#Bluebird unstunning 1 (Stunned bird unstuns)
%patch $31132 $231EW
#Bluebird unstunning 2
%patch $311AA $233CW
#Bluebird unstunning 3
%patch $311C8 $235AW
#Bluebird unstunning 4
%patch $311E6 $21D4W
#Bluebird walking 1 (After unstunning, walk off)
#Landing bird
%patch $31150 $0000W
#Nothing (Become walking bird when ground is touched)


Sprite Behavior

The Blue bird's behaviors are interesting. The waiting bird does nothing, and the walking bird looks for Keen for only 1 of its 4 walking frames. (This makes it slower to respond to Keen moving, making it easier to get past.) The flying bird in contrast is more agile. The landing bird uses the same behavior as the Berkeloid's flame, letting it fall until it hits a solid surface, similarly the stunned bird uses a shot sprite behavior so it can fall to the ground. The last unstunning action uses the 'recover' behavior to get the bird up and about.

Behaviors:
$09DC16C9RL #Shot sprite
$09DC16E5RL #Berkeloid flame
$0FA805ABRL #Bird recover
$0FA80779RL #Walking bird look for Keen
$0FA807D7RL #Flying Bird

Patch: Keen 4
#Waiting bird
%patch $31036 $00000000L
#Nothing
#Walking
%patch $31054 $00000000L
#Nothing
%patch $31072 $00000000L
#Nothing
%patch $31090 $00000000L
#Nothing
%patch $310AE $0FA80779RL
#Bird look for Keen
#Flying
%patch $310CC $0FA807D7RL
#Bird fly
%patch $310EA $0FA807D7RL
#Bird fly
%patch $31108 $0FA807D7RL
#Bird fly
%patch $31126 $0FA807D7RL
#Bird fly
#Landing
%patch $31144 $09DC16E5RL
#Berkeloid flame (Bird lands on ground)
#Stunned
%patch $31162 $09DC16C9RL
#Shot sprite (Fall to ground when shot)
%patch $31180 $00000000L
#Nothing
%patch $3119E $00000000L
#Nothing
%patch $311BC $00000000L
#Nothing
%patch $311DA $0FA805ABRL
#Bird recover


Seeking Keen

The bird seeks Keen under many circumstances, each of which is separate. See also the sprite positioning section below. Notice that if the vertical seeking when flying is reversed (So the birds flee Keen) then they will often get stuck in the ground.

Birds also randomly change horizontal direction if they are flying and can't get at Keen, as a way to try and find new ways to get to him. This is treated in the randomness section below, but works the same way as the patches here.

Patch: Keen seeking
#When placed in level, face Keen
%patch $10082 $0001W %patch $1008D $FFFFW
#When hatched from egg, face Keen
%patch $1011E $0001W %patch $10129 $FFFFW
#Seek Keen on ground
%patch $10210 $0001W %patch $10217 $FFFFW
#Seek Keen horizontally while flying
%patch $10273 $0001W %patch $1027A $FFFFW
#Seek Keen vertically when flying
%patch $1029D $FFFFW %patch $102B1 $0001W


Bird never lands

This patch, composed of two smaller patches, stops the Bird from ever landing when Chasing Keen. (It can be shot and will recover as a standing Bird, but the flying Bird will never land.) The first patch stops the Bird landing and walking towards Keen when he is standing on ground the Bird can fly to. The second stops it landing when it it above ground and heading down towards Keen. For a more complex patch that makes the Flying and Walking Birds two different enemies see the last section this page.

Patch: Bird never lands
#Bird doesn't land when Keen is standing on ground level with it
%patch $103D0 $EB
#Don't land when Keen below it and Bird near ground
%patch $1048B $EB


Bird never flies

This patch stops the Bird from ever flying. Instead it will walk back and forth across the ground chasing Keen. (The only Keen seeking patches that now apply are 'seek Keen on ground'.) Even Birds placed in air will try to walk and anything that becomes a flying Bird will turn permanently to walking once it lands or is stunned.

The first few lines of the patch change the Bird's tile collision to use a simple 'go back and forth' instead of 'fly if not on the ground' and the final line removes the 'fly if Keen is above' segment from the walking Bird's behavior. For a more complex patch that makes the Flying and Walking Birds two different enemies see the last section this page.

Patch: Bird never flies
#Bird never flies
%patch $3103E $09DC1795RL %patch $3105C $09DC1795RL %patch $3107A $09DC1795RL %patch $31098 $09DC1795RL %patch $310B6 $09DC1795RL %patch $10219 $5F $5E $5D $CB


Bird recover behavior

This is the complete Bird recovery behavior. It does nothing aside from change the Bird's sprite type back to $1B. (It was changed when the Bird was stunned.)

Patch: Bird recover behavior
#Bird recover behavior
%patch $1002B $55 $8B $EC $56 $8B $76 $06 $C7 $04 $001BW $5E $5D $CB


Walking and flying speed

The blue bird shows a distinct split between its walking and flying speeds. Walking speeds are governed by animation motion in a series of steps. This includes any action that may lead to walking such as waiting or landing. The stunned bird does not move. The flying bird in contrast has no animation motion, but relies on speed adjustments made by its flying behavior, letting is smoothly chase after Keen. (The way the flying behavior works means that the bird must slow down before it can change direction.)

The bird has to 'taking flight' speeds. The first is when it is walking and wants to take off after Keen. It moves up slightly to get off the ground. This speed is negative, if it is made positive the bird will be 'stuck' to the ground for a short while before it can chase Keen. The second speed is for when the bird wants to start flying left, right or down towards Keen. It is even more negative because the bird must be kept further off the ground (Since it won't fly up.) If this is made positive the bird will have difficulty flying after Keen if he is not above it.

The flying speeds are accelerations, they control how quickly the bird gets up to speed. Although they are all positive they involve speeds in different directions. If the speeds are made negative the bird will run from Keen. If they are made less the bird will float more slowly, like a balloon. If they are made larger the bird will whiz about. If the horizontal acceleration is set to 0 then the bird will only be able to move up and down, if the up and down are set to 0 then the bird will only be able to fly left and right. (And will not be able to take off!)

For complicated reasons involving the landing action Birds tend to get stuck in left walls near ground level.

Patch: Animation motion
#Walking
%patch $31050 $0080W $0000W %patch $31066 $0080W $0000W %patch $3108C $0080W $0000W %patch $310AA $0080W $0000W
#Bird wait (Speed is same as walking speed)
%patch $31032 $0080W $0000W
#Landing bird
%patch $31140 $0080W $0000W
#Stunned
%patch $3115E $0000W $0000W
#Unstunning
%patch $3117C $0000W $0000W %patch $3119A $0000W $0000W %patch $311B8 $0000W $0000W %patch $311D6 $0000W $0000W
#Flying (Speed depends on flying behavior)
%patch $310C8 $0000W $0000W %patch $310E6 $0000W $0000W %patch $31104 $0000W $0000W %patch $31122 $0000W $0000W

Patch: Flying speeds
%patch $1024C $FFF8W 
#Speed up when launching up off ground
%patch $10391 $FFF0W
#Speed up when starting left, right or down off ground
%patch $1027D $0010W
#Left\right ACCELERATION when flying
%patch $10299 $0010W
#Up ACCELERATION when flying
%patch $102AD $0010W
#Down ACCELERATION when flying


Sprite Collision

The Blue bird collision is complex. There are two basic collisions, that of the bird and that of the stunned bird. They are the same, excepting that the stunned bird is not dangerous to Keen. The stunned bird is interesting in that it is set up so that eventually it will 'unstun' and come after Keen again.


Collision values

The Blue bird uses the 'dangerous' collision when walking, flying and landing. Everything else uses the 'safe' collision. (Notice the bird is safe for Keen to touch when it is waiting, otherwise Keen would die when he stood on an egg.)

Patch: Keen 4 collision values
#Waiting
%patch $3103A $0FA8087ARL
#Stunned Bird
#Walking
%patch $31058 $0FA80840RL
#Bird
%patch $31076 $0FA80840RL
#Bird
%patch $31094 $0FA80840RL
#Bird
%patch $310B2 $0FA80840RL
#Bird
#Flying
%patch $310D0 $0FA80840RL
#Bird
%patch $310EE $0FA80840RL
#Bird
%patch $3110C $0FA80840RL
#Bird
%patch $3112A $0FA80840RL
#Bird
#Landing
%patch $31148 $0FA80840RL
#Bird
#Stunned
%patch $31166 $0FA8087ARL
#Stunned Bird
#Unstunning
%patch $31184 $0FA8087ARL
#Stunned Bird
%patch $311A2 $0FA8087ARL
#Stunned Bird
%patch $311C0 $0FA8087ARL
#Stunned Bird
%patch $311DE $0FA8087ARL
#Stunned Bird


Collision code

Blue bird

This is used by the bird when it is dangerous to Keen, walking and flying. It reacts to Keen by running the 'kill Keen' code and to Keen's shots by removing the shot and becoming a stunned bird. The first and second blue values are what sprite type to react to ($02 is Keen, $03 is his shot.) The first and third brown values (Both $75) are the jump conditions, in this case react ONLY to that sprite type and nothing else. The first brown $9A string is the 'kill Keen' code, the second is the 'remove shot' code. Replacing either of them with '$90 $90 $90 $90 $90' will stop them working. (The first case will stop the normal bird killing Keen, which is better done by changing the collision values in the previous section all to 'stunned bird'; the second will stop Keen's shot being destroyed when it hits the bird.) The $0001 value is the Blue Bird's clipping (See section below); it is set to 1 so the falling bird can land (If it is set to 0 stunned birds will ghost through the foreground and fall out of the level!) The remaining blue value is unknown, but related to the 'remove shot' code.

Notice the value 22E2W, this is the 'stunned bird' action value, and what the bird becomes.

Patch: Blue bird collision
%patch $102C0 $55 $8B $EC $56 $57 $8B $76 $06 $8B $7E $08 $83 $3D $02 $75 $09
              $9A $0B8013E9RL     $5F $5E $5D $CB $83 $3D $03 $75 $18 $C7 $44
              $16 $0000W  $C7 $44 $06 $0001W  $B8 $22E2W  $50 $57 $56 $9A $09DC1695RL
                          $83 $C4 $06 $5F $5E $5D $CB


Stunned Blue bird

This is used by the bird when it is harmless to Keen. It reacts only to Keen's shot ($03 $75) It can be seen that is is very similar to the second part of the collision above.

Patch: Blue bird collision
%patch $102FA $55 $8B $EC $56 $57 $8B $76 $06 $8B $7E $08 $83 $3D $03 $75 $13
              $C7 $44 $16 $0000W  $B8 $22E2W  $50 $57 $56 $9A $09DC1695RL
              $83 $C4 $06 $5F $5E $5D $CB


Blue bird can be shot multiple times

This code allows Keen to shoot the Blue bird as many times as he wants, each time it will produce a stunned Blue bird This code can be combined with any of the above codes except if the 'don't stop bullet' code is disabled. (They are incompatible, the bullet will be stopped when the below code is included.)

A side effect is that the shot will vanish instead of smashing. Notice that this code replaces the three byte string $8B $76 $06 in the above patches with $90 $90 $90.

It is possible to change what is spawned by changing the 'stunned bird' action value in the code above. Be careful when using this patch; the player can use it to spawn infinite sprites and crash the game. There must be some way to stop this happening. (If the spawned sprites vanish by themselves, destroy each other or are dangerous enough to Kill Keen this should work.)

Patch: Keen 4 infinite shootability
#Flying and walking bird
%patch $102C5 $90 $90 $90
#Stunned bird
%patch $102FF $90 $90 $90


Bluebird stuns permanently

This patch makes the Birds stun permanently when they are shot. It works by altering the properties of the stunned Bird to make it behave like a permanently shot sprite.

Patch: Keen 4 Bird stunned permanently
#Bird stunned
%patch $31152 $017BW $017BW $0002W $0000W $0000W $0000W $0000W $0000W $09DC16C9RL $00000000L $09DC1913RL $0000W


Animations

There is little to say about Blue bird animations except that they are separate from Egg's ones. A bird can be placed in a level without an egg and no problems will occur however. Notice the waiting bird uses the same animation as the first walking action and the landing bird uses the same animations as the last flying action.

The animation speed of the waiting bird is how long it will wait before going after Keen, the stunned bird's is how long it remains stunned before unstunning, and the combined animation speeds of the unstunning actions is how long the bird spends unstunning.

Patch: Keen 4
#Cache
%patch $306F4 $016FW
#Blue bird Cache start
%patch $3073E $017BW
#Blue bird cache end
#Waiting bird
%patch $31026 $0173W $016FW %patch $31030 $0078W
#Waiting time
#Bird walking
%patch $31044 $0173W $016FW %patch $3104E $0007W
#Animation speed
%patch $31062 $0174W $0170W %patch $3106C $0007W
#Animation speed
%patch $31080 $0175W $0171W %patch $3108A $0007W
#Animation speed
%patch $3109E $0176W $0172W %patch $310A8 $0007W
#Animation speed
#Bird flying
%patch $310BC $0177W $0177W %patch $310C6 $0008W
#Animation speed
%patch $310DA $0178W $0178W %patch $310E4 $0008W
#Animation speed
%patch $310F8 $0179W $0179W %patch $31102 $0008W
#Animation speed
%patch $31116 $017AW $017AW %patch $31120 $0008W
#Animation speed
#Bird landing
%patch $31134 $017AW $017AW %patch $3113E $0008W
#Animation speed
#Bird stunned
%patch $31152 $017BW $017BW %patch $3115C $00F0W
#Stunned time
#Bird unstunning
%patch $31170 $0173W $016FW %patch $3117A $0014W
#Animation speed
%patch $3118E $017BW $017BW %patch $31198 $0014W
#Animation speed
%patch $311AC $0173W $016FW %patch $311B6 $0014W
#Animation speed
%patch $311CA $017BW $017BW %patch $311D4 $0014W
#Animation speed


Sprite positioning and landing on the ground

The bird spawns 15 pixels higher then where it is placed in-level. This must be changed with its sprite height.

How far off the ground the bird must be before it can walk on it is a slightly complex patch in that two variables need to be altered. The first is the height, in pixels, by default this is $0080 or 8 pixels above the ground. The second is a 'clip check'; this must be increased by $8 every $20 the first variable is increased (So if the bird is patched to walk when 12 pixels ($00C0W) off the ground, the second value must be 16 or $10.)

The second positioning patch is the opposite, how far above the birds Keen must be before the bird will chase him by flying into the air. By default this is 3 tiles above the bird.

Patch: Keen 4
#Blue bird spawn height
%patch $1006A $FF0FW
#15 pixels upwards
#Height above ground Bird must be before starting walking (8 pixels)
%patch $10489 $0080W %patch $1038B $00
#How far above birds Keen must be before birds fly after him
%patch $10221 $0300W


Clipping and foreground

The Blue bird's clipping variable is one of the most complex in the game, possibly more complex even than Keen's. Birds have a clipping value of 2 most of the time, this is set to 1 when the bird is stunned (but not when the stunned bird is shot.) The clipping is set to 2 when the bird starts flying or recovers from being stunned. The bird temporarily sets its clipping to 1 when landing, if the first value is set to 0, the bird cannot land on ground, only fly. If the second is set to 0 then the bird while become 'ghostly' when it tries to land, allowing it to move through ground.

The bird's foreground value is set on spawning at 2.

Patch: Keen 4
#BB Foreground variable
%patch $10058 $0002W
#Blue bird

Patch: Keen 4
#BB clipping values
%patch $10247 $0002W
#Bird flying (Set when leaving ground)
%patch $102E6 $0001W
#Stunned bird (Set when bird stunned)
%patch $10396 $0002W
#Bird walking (Set when recovering)
%patch $10496 $0001W
#Bird landing 1
%patch $104C3 $0001W
#Bird landing 2


Sprite-tile interaction

There are three different sprite-tile interactions that belong entirely to the bird. The first is the walking bird, this makes the bird turn when it reaches walls or the end of platforms. The second is the landing bird, which lets the bird become a walking bird when it lands. The third is the flying bird which stops the flying bird from entering walls and ceilings (And tells it to land when it is near ground.) The stunned and unstunning birds use the 'sit' collision used by most stunned sprites.

Patch: Keen 4
#Bird wait
%patch $3103E $0FA808A1RL
#Walking Bird
#Bird walk
%patch $3105C $0FA808A1RL
#Walking Bird
%patch $3107A $0FA808A1RL
#Walking Bird
%patch $31098 $0FA808A1RL
#Walking Bird
%patch $310B6 $0FA808A1RL
#Walking Bird
#Bird fly
%patch $310D4 $0FA809B4RL
#Flying
%patch $310F2 $0FA809B4RL
#Flying
%patch $31110 $0FA809B4RL
#Flying
%patch $3112E $0FA809B4RL
#Flying
#Landing bird
%patch $3114C $0FA80945RL
#Landing Bird
#Stunned
%patch $3116A $09DC176ERL
#Sit
#Unstunning
%patch $31188 $09DC176ERL
#Sit
%patch $311A6 $09DC176ERL
#Sit
%patch $311C4 $09DC176ERL
#Sit
%patch $311E2 $09DC176ERL
#Sit


Walking Bird tile interaction code

This is the tile interaction code for the walking Blue Bird. This walks back and forth, turning at walls and flying if there is no floor beneath it.

On the first line the game checks if the Bird's horizontal direction is right (1); if so the Bird checks to see if it is touching a tile with a left blocking property. (A left wall) If it is then its horizontal direction changes to left. (The Bird turns around.)

On line 4 the opposite occurs, the direction checked for is left (FF), right walls are checked for and if found the Bird's horizontal direction is changed to right.

On line 6 the floor is checked for; if the Bird is not touching a tile with a solid top then it will start flying. First its upwards speed is set to $FFF0W. Its clipping is set to 2 and its action to flying. The last two lines draw the Bird.

Patch: Walking Bird tile collision code
#Walking Bird tile collision code
%patch $10321 $55 $8B $EC $56 $8B $76 $06 $83 $7C $0E $01 $75 $2B $83 $7C $3C $00 $74 $25 $8B $44 $12 $29 $44 $0A $C7 $44 $0E $FFFFW $9A $1D02002ARL $B1 $05 $D3 $F8 $89 $44 $08 $FF $74 $1C $56 $9A $09DC120ARL $83 $C4 $04 $EB $2F $83 $7C $0E $FF $75 $29 $83 $7C $38 $00 $74 $23 $8B $44 $12 $29 $44 $0A $C7 $44 $0E $0001W $9A $1D02002ARL $B1 $05 $D3 $F8 $89 $44 $08 $FF $74 $1C $56 $9A $09DC120ARL $83 $C4 $04 $83 $7C $36 $00 $75 $17 $C7 $44 $18 $FFF0W $C7 $44 $06 $0002W $B8 $224CW $50 $56 $9A $09DC120ARL $83 $C4 $04 $FF $74 $20 $33 $C0 $50 $FF $74 $1E $FF $74 $0C $FF $74 $0A $8B $C6 $05 $46 $00 $50 $9A $16541641RL $83 $C4 $0C $5E $5D $CB


Action type

The bird is unique in Keen 4 for using all possible values of the action parameter except $0001. The waiting, walking and unstunning action use type 0, like most walking sprites. The landing bird uses $0002 (Like a shot sprite does, so it can move until it hits the ground; this also means that it can take as long as it needs to land.) The stunned bird uses $0003, similar to the landing bird, except it cannot take as long as it wants to fall, eventually it will unstun. Finally the flying bird uses $0004, the only sprite in the game to do so. This allows them to respond instantly and smoothly to Keen's movement while still animating regularly.

Patch: Keen 4
#Bird wait
%patch $3102A $0000W
#Bird land
%patch $31138 $0002W
#Bird stunned
%patch $31156 $0003W
#Bird walk
%patch $31048 $0000W %patch $31066 $0000W %patch $31084 $0000W %patch $310A2 $0000W
#Bird fly
%patch $310C0 $0004W %patch $310DE $0004W %patch $310FC $0004W %patch $3111A $0004W
#Bird unstun
%patch $31174 $0000W %patch $31192 $0000W %patch $311B0 $0000W %patch $311CE $0000W


Deprotect and stick to ground

The Blue bird has a stick to ground value of 1 whenever it is doing something that needs it to move along the ground. (As you'd expect.) this includes waiting, walking and unstunning.

Patch: Keen 4
#Blue birds
%patch $30F96 $0000W $0001W
#Waiting
%patch $3102C $0000W $0001W
#Walking
%patch $3104A $0000W $0001W %patch $31068 $0000W $0001W %patch $31086 $0000W $0001W %patch $310A4 $0000W $0001W
#Flying
%patch $310C2 $0000W $0000W %patch $310E0 $0000W $0000W %patch $310FE $0000W $0000W %patch $3111C $0000W $0000W
#Landing
%patch $3113A $0000W $0000W
#Stunned
%patch $31158 $0000W $0000W
#Unstunning
%patch $31176 $0000W $0001W %patch $31194 $0000W $0001W %patch $311B2 $0000W $0001W %patch $311D0 $0000W $0001W


Probability and randomness

There is only one random event birds can do, and that is land. The chance of landing controls how long it will be before the bird lands. At its default value this is no more than a second or so, but if this is made much smaller birds can take far longer, and if it is set to zero, the bird will not land on the ground at all. (Under most circumstances.)

The 'randomly change direction while flying' patch works differently, though it is partly random. It is set up similar to a seeking Keen patch.

Patch: Keen 4
#Chance of landing
%patch $10489 $80
#Randomly change direction when can't get to Keen while flying
%patch $1033D $FFFFW %patch $1036E $0001W


Sprite spawn code

In the initiation code notice the Bird cache being set ($C7 $06 $CB5FW $0001W.) Also notice the three difficulties of Bird that are possible.

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 sprite activity, $C7 $07 $xxxxW sets the sprite type, $C7 $20 $xxxxW sets the foreground value. 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.

The Bird always starts the level moving down. It seeks Keen however and will start off facing in his direction. $C7 $47 $10 $xxxxW is the vertical direction the sprite starts moving in, either $0001W (Facing down), $FFFFW (Facing up) or $0000W (Neither, seldom used.) $C7 $47 $0E $xxxxW is the horizontal direction.

Patch: Keen 4
#Location of initiation code
%patch $EF1B $04FBW
#Easy Bird(At $EDEB)
%patch $EF1D $04F4W
#Medium Bird (At $EDE4)
%patch $EF1F $04EDW
#Hard Bird (At $EDDD)
#Blue Bird initiation code
%patch $EDDD $83 $3E $7A6CW $03 $7C $19 $83 $3E $7A6CW $02 $7C $12 $FF $76 $FC $57 $9A $0FA805B9RL $83 $C4 $04 $C7 $06 $CB5FW $0001W
#Blue Bird spawning code
%patch $10039 $55 $8B $EC $B8 $01 $00 $50 $9A $06BD1E11RL $83 $C4 $02 $8B $1E $D8 $A7 $C7 $07 $001BW $C7 $47 $02 $0001W $C7 $47 $20 $0002W $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B $46 $08 $D3 $E0 $05 $FF0FW $89 $47 $0C $8B $47 $0A $8B $1E $D6 $A7 $3B $47 $0A $73 $0B $8B $1E $D8 $A7 $C7 $47 $0E $0001W $EB $09 $8B $1E $D8 $A7 $C7 $47 $0E $FFFFW $8B $1E $D8 $A7 $C7 $47 $10 $0001W $B8 $21B6W $50 $53 $9A $09DC118CRL $83 $C4 $04 $5D $CB


Bird spawned not facing Keen

This patch is the spawning code, but without the code that makes the Bird always face Keen when spawned. Instead it will always face left. This is hardly noticeable since the bird will quickly chase after Keen when spawned but may be useful if performing sprite spawning aptches.

Patch: Keen 4
#Blue Bird spawning code - doesn't always face Keen
%patch $10039 $55 $8B $EC $B8 $01 $00 $50 $9A $06BD1E11RL $83 $C4 $02 $8B $1E $D8 $A7 $C7 $07 $001BW $C7 $47 $02 $0001W $C7 $47 $20 $0002W $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B $46 $08 $D3 $E0 $05 $FF1FW $89 $47 $0C $B8 $21B6W $50 $53 $9A $09DC118CRL $83 $C4 $04 $5D $CB


Flying and walking birds are separate enemies

This patch makes the walking and flying birds separate enemies that do not mix. The walking birds chase Keen, walking back and forth with speed $0080W. They will experience an error if they reach platform edges, spinning in the air, which means they must be kept between two walls at all times. (Even if those walls are only 1 tile high.) Walking birds are lethal to Keen and block his shots, but cannot be stunned.

Flaying birds hatch from eggs, can be stunned (stunned birds will unstun to flying.) and never land. Easy birds are spawned by the 'I' Keen sprite icon, medium by the 'Mom' icon and hard by the 'Dad' icon.

If the walking bird's sprite height is changed then the 'fix spawn height' patch will need to be adjusted, otherwise they will sit, spinning in the air.

Patch: Keen 4
#Walking birds (easy, medium, hard) are separate from flying birds
#Spawn points
%patch $EECB $1A84W
#'I Keen' (Easy bird)
%patch $EECD $1A7DW
#'Mom' (Normal bird)
%patch $EECF $1A76W
#'Dad' (Hard bird)
#Initiation code at + $1A76
%patch $10366 $83 $3E $7A6CW $03 $7C $19 $83 $3E $7A6CW $02 $7C $12 $FF $76 $FC $57 $9A $0FA808A1RL $83 $C4 $04 $C7 $06 $5F $CB $0001W $E9 $EA74W
#Flying bird spawn code = $0FA808A1RL
%patch $10321 $55 $8B $EC $B8 $01 $00 $50 $9A $06BD1E11RL $83 $C4 $02 $8B $1E $D8 $A7 $C7 $07 $001BW $C7 $47 $02 $0001W $C7 $47 $20 $0002W $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B $46 $08 $D3 $E0 $05 $FF1FW $89 $47 $0C $B8 $224CW $50 $53 $9A $09DC118CRL $83 $C4 $04 $5D $CB
#Stop the flying birds becoming walking birds:
%patch $103D0 $EB
#Bird doesn't land when Keen is standing on ground level with it
%patch $1048B $EB
#Don't land when Keen below it and Bird near ground
#Stop the walking birds flying or going to stunned bird
%patch $31026 $0173W $016FW $0000W $0000W $0001W $0078W $0080W $0000W
#Waiting bird
$00000000L $0FA804BERL $09DC1795RL $21F2W
%patch $31044 $0173W $016FW $0000W $0000W $0001W $0007W $0080W $0000W
#Walking birds
$00000000L $0FA804BERL $09DC1795RL $21F2W
%patch $31062 $0174W $0170W $0000W $0000W $0001W $0007W $0080W $0000W $00000000L $0FA804BERL $09DC1795RL $2210W %patch $31080 $0175W $0171W $0000W $0000W $0001W $0007W $0080W $0000W $00000000L $0FA804BERL $09DC1795RL $222EW %patch $3109E $0176W $0172W $0000W $0000W $0001W $0007W $0080W $0000W $10800770RL $0FA804BERL $09DC1795RL $21D4W
#Eggs hatch to flying birds
%patch $10135 $224CW
#Stunned birds unstun to flying
%patch $311E6 $224CW
#Fix walking spawn height (Stop it floating in air)
%patch $1006A $FF1FW