Patch:Berkeloid
This page covers patches relating to the Berkeloids in Keen 4. The Berkeloids appear in only one level, the Isle of Fire. They are known for throwing balls of fire that become taller when they hit the ground before vanishing.
Sprite Type
Berkeloids use sprite type 14 which is used only by the Berkeloid and its flame and doesn't affect anything else. When an Berkeloid throws a flame, its sprite type must also be set. This doesn't have to be the same as the Berkeloid.
Keen 4
#Berkeloid sprite type
%patch $10BAF $0E #Berkeloid
%patch $10CC2 $0E #Berkeloid flame
Sprite Actions
The Berkeloid has a large number of actions, for various reasons. The Berkeloid is spawned floating, and does so in a four frame cycle. While floating it can randomly begin the fireball sequence. Midway through the flaming sequence an airborne flame is created.
The airborne flame will remain the same until it lands, at which point it will turn into a landed flame. This will initially be big, but then grow smaller and eventually vanish.
Actions: $2AF8W #Berkeloid moving $2B16W #Berkeloid moving $2B34W #Berkeloid moving $2B52W #Berkeloid moving $2B70W #Berkeloid ready to flame $2B8EW #Berkeloid flaming $2BACW #Berkeloid flaming $2BCAW #Berkeloid flaming $2BE8W #Berkeloid flaming $2C06W #Berkeloid flaming $2C24W #Berkeloid after throwing flame $2C42W #Berkeloid after throwing flame $2C60W #Berkeloid after throwing flame $2C7EW #Berkeloid after throwing flame $2C9CW #Berkeloid after throwing flame $2CBAW #Berkeloid after throwing flame $2CD8W #Berkeloid tossed flame $2CF6W #Berkeloid tossed flame $2D14W #Berkeloid landed flame $2D32W #Berkeloid landed flame $2D50W #Berkeloid landed flame $2D6EW #Berkeloid landed flame $2D8CW #Berkeloid landed flame $2DAAW #Berkeloid landed flame $2DAAW #Berkeloid landed flame $2DE6W #Berkeloid landed flame $2E04W #Berkeloid landed flame
Keen 4
#Spawn
%patch $10BFD [$2AF8W]
#While floating
%patch $10C44 [$2B70W] #Make Berkeloid flame (Random)
%patch $10C90 [$2B70W] #Make Berkeloid flame (Random)
#Floating cycle
%patch $31984 [$2B16W] #Berkeloid moving 1
%patch $319A2 [$2B34W] #Berkeloid moving 2
%patch $319C0 [$2B52W] #Berkeloid moving 3
%patch $319DE [$2AF8W] #Berkeloid moving 4
#Flaming sequence
%patch $319FC [$2B8EW] #Berkeloid flaming 1
%patch $31A1A [$2BACW] #Berkeloid flaming 2
%patch $31A38 [$2BCAW] #Berkeloid flaming 3
%patch $31A56 [$2BE8W] #Berkeloid flaming 4
%patch $31A74 [$2C06W] #Berkeloid flaming 5
%patch $31A92 [$2C24W] #Berkeloid flaming 6 (Flame spawned and thrown)
%patch $31AB0 [$2C42W] #Berkeloid flaming 7
%patch $31ACE [$2C60W] #Berkeloid flaming 8
%patch $31AEC [$2C7EW] #Berkeloid flaming 9
%patch $31B0A [$2C9CW] #Berkeloid flaming 10
%patch $31B28 [$2CBAW] #Berkeloid flaming 11
%patch $31B46 [$2AF8W] #Berkeloid flaming 12
#Create flame
%patch $10D05 [$2CD8W] #Spawn Berkeloid flame
#Flame in air cycle
%patch $31B64 [$2CF6W] #Berkeloid tossed flame 1
%patch $31B82 [$2CD8W] #Berkeloid tossed flame 2
#When flame lands
%patch $10D89 [$2D14W] #Flame on ground
#Flame on ground sequence
%patch $31BA0 [$2D32W] #Berkeloid landed flame 1
%patch $31BBE [$2D50W] #Berkeloid landed flame 2
%patch $31BDC [$2D6EW] #Berkeloid landed flame 3
%patch $31BFA [$2D8CW] #Berkeloid landed flame 4
%patch $31C18 [$2DAAW] #Berkeloid landed flame 5
%patch $31C36 [$2DC8W] #Berkeloid landed flame 6
%patch $31C54 [$2DE6W] #Berkeloid landed flame 7
%patch $31C72 [$2E04W] #Berkeloid landed flame 8
%patch $31C90 [$0000W] #Berkeloid landed flame 9
Sprite Behavior
The Berkeloid's behaviors are interesting. The floating Berkeloid has its own behavior where it can attack Keen. The attacking Berkeloid uses a generic 'float' behavior, except for when it is producing a fireball to throw at keen. Just before returning to floating it uses a 'start floating again' behavior to avoid floating bugs. The Berkeloid's flame uses a generic 'move through the air and hit the ground' behavior while airborne, and no behavior at all when it has landed.
Behaviors: $09DC16E5RL #Berkeloid flame $09DC171FRL #Float $1080040BRL #Berkeloid floating $108004A4RL #Berkeloid make flame $1080051CRL #Berkeloid after flaming
Keen 4
#Floating
%patch $31978 $1080040BRL #Berkeloid floating
%patch $31996 $1080040BRL #Berkeloid floating
%patch $319B4 $1080040BRL #Berkeloid floating
%patch $319D2 $1080040BRL #Berkeloid floating
#Flame Keen
%patch $319F0 $09DC171FRL #Float (Ready)
%patch $31A0E $09DC171FRL #Float (Tossing)
%patch $31A2C $09DC171FRL #Float
%patch $31A4A $09DC171FRL #Float
%patch $31A68 $09DC171FRL #Float
%patch $31A86 $108004A4RL #Berkeloid make flame
%patch $31AA4 $09DC171FRL #Float (Done flaming)
%patch $31AC2 $09DC171FRL #Float
%patch $31AE0 $09DC171FRL #Float
%patch $31AFE $09DC171FRL #Float
%patch $31B1C $09DC171FRL #Float
%patch $31B3A $1080051CRL #Berkeloid after flame
#Flame
%patch $31B58 $09DC16E5RL #Berkeloid flame (In air)
%patch $31B76 $09DC16E5RL #Berkeloid flame
%patch $31B94 $00000000L #Nothing (On ground)
%patch $31BB2 $00000000L #Nothing
%patch $31BD0 $00000000L #Nothing
%patch $31BEE $00000000L #Nothing
%patch $31C0C $00000000L #Nothing
%patch $31C2A $00000000L #Nothing
%patch $31C48 $00000000L #Nothing
%patch $31C66 $00000000L #Nothing
%patch $31C84 $00000000L #Nothing
Make flame code
This is the complete code for the Berkeloid producing a flame. On the second line the flame's activity is set to 3, ensuring it will stay active offscreen and not surprise the player. Its sprite type is set as $0E. On the third line the flame's vertical spawn position is set as half a tie (8 pixels or $0080W) down from the top of the Berkeloid and its vertical speed is set as -8 ($FFF8W or slightly upwards.)
On line 4 the game checks to see which way the Berkeloid is facing, if it is facing right then the flame's Vertical speed is set to 48 ($0030W), it is spawned 2 tiles right ($05 $0200W) of the Berkeloid's left edge and its horizontal direction is set to 1. Otherwise its speed is set to -48 ($FFD0W), it is spawned one tile left ($2D $0100W) of the Berkeloid's left edge and its horizontal direction is set to -1.
On the last lines the flame's action is set ($2CD8W) and the Berkeloid's Misc C variable is set to 1, important for its hovering above the ground code.
Keen seeking
#Berkeloid make flame code
%patch $10CA4 $55 $8B $EC $56 $8B $76 $06 $B8 $0001W $50 $9A $06BD1E11RL
$83 $C4 $02 $8B $1E $D8 $A7 $C7 $47 $02 [$0003W] $C7 $07 [$000EW]
$8B $44 $0C $05 [$0080W] $89 $47 $0C $C7 $47 $18 [$FFF8W] $83 $7C
{$0E} [$01] {$75} $15 $C7 $47 $16 [$0030W] $8B $44 $0A $05 [$0200W] $89
$47 $0A $C7 $47 $0E [$0001W] $EB $17 $8B $1E $D8 $A7 $C7 $47 $16
[$FFD0W] $8B $44 $0A $2D [$0100W] $89 $47 $0A $C7 $47 $0E [$FFFFW]
$B8 [$2CD8W] $50 $FF $36 $D8 $A7 $9A $09DC118CRL $83 $C4 $04
$C7 $44 $04 [$0001W] $5E $5D $CB
Seeking Keen
Berkeloids will randomly head towards Keen. If Keen is close enough they will also throw significantly more fireballs.
Keen seeking
#Randomly turn and head towards Keen
%patch $10C2D [$FFFFW]
%patch $10C32 [$0001W]
#V distance next to Keen to throw more fireballs:
%patch $10C6D [$FF00W] #-1 tile
%patch $10C75 [$0100W] #+1 tile
Berkeloids ignore Keen
It is possible for the Berkeloids to ignore Keen when he is behind them, or ignore him completely. They will still throw the occasional fireball, but will not chase him. There are two patches, each independent for this.
Keen seeking
#Ignore Keen behind Berkeloids
%patch $10C1C $00
#Ignore Keen totally
%patch $10C32 $FFFFW
Berkeloids ignore gravity
This patch stops the Berkeloids responding to gravity; they will float across cliffs and cannot move down hills, instead floating into the air.
Berkeloids ignore gravity
#Berkeloids ignore gravity
%patch $10E7D $EB
Berkeloid's shots move horizontally
This patch makes the Berkeloid's shots move horizontally, like Keen's. They will also smash on walls. The first section alters the Berkeloid's shots actions; wiping its 'fall' behavior, changing the way it moves and giving it a horizontal speed. The second section alters its tile interaction so that it will smash on walls instead of sticking to them. Omitting it will cause the Berkeloid's shots to not be destroyed if they hit a wall, staying there indefinitely and possibly crashing the game.
Berkeloid's shots move horizontally
#Berkeloid shots fly horizontally
%patch $31B58 $00000000L
%patch $31B76 $00000000L
%patch $31B4C $0001W
%patch $31B6A $0001W
%patch $31B54 [$0040W] #Speed 1
%patch $31B72 [$0040W] #Speed 2
#Berkeloid flames smash on walls as well as floors
%patch $10D5E $55 $8B $EC $56 $8B $76 $06 $83 $7C $38 [$00] {$75} $0C $83 $7C $3C
[$00] {$75} $06 $83 $7C {$36} [$00] {$74} $19 $B8 [$0028W]
$50 $9A $187409F1RL $83 $C4 $02 $B8 [$2D14W] $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
Speed and Jump Height
Nearly all of the motion that affects Berkeloids is found in their behavior, the horizontal floating speed is determined in this way though. Berkeloid hovering is complex. They hover an average of 1 tile up, moving between a lower height of 8 pixels lower and an upper height of 0 pixels difference from this. (Matching the total hover range of 8 pixels.)
Flame's horizontal speeds depend on what direction it is fired (Either right or left.) the horizontal speed reduces to 0 when it hits a wall. Flames are given an upwards speed as well.
Animation motion
#Floating
%patch $31974 [$0008 $0000W] #Speed 1
%patch $31992 [$0008 $0000W] #Speed 2
%patch $319B0 [$0008 $0000W] #Speed 3
%patch $319CE [$0008 $0000W] #Speed 4
#Tossing fire
%patch $319EC [$0000W $0000W] #Speed 1
%patch $31A0A [$0000W $0000W] #Speed 2
%patch $31A28 [$0000W $0000W] #Speed 3
%patch $31A46 [$0000W $0000W] #Speed 4
%patch $31A64 [$0000W $0000W] #Speed 5
%patch $31A82 [$0000W $0000W] #Speed 6 (Flame has been tossed)
%patch $31AA0 [$0000W $0000W] #Speed 7
%patch $31ABE [$0000W $0000W] #Speed 8
%patch $31ADC [$0000W $0000W] #Speed 9
%patch $31AFA [$0000W $0000W] #Speed 10
%patch $31B18 [$0000W $0000W] #Speed 11
%patch $31B36 [$0000W $0000W] #Speed 12 (Go to floating)
#Flame while in air
%patch $31B54 [$0000W $0000W] #Speed 1
%patch $31B72 [$0000W $0000W] #Speed 2
#Flame landed on ground
%patch $31B90 [$0000W $0000W] #Speed 1 (Starts off 'tall')
%patch $31BAE [$0000W $0000W] #Speed 2
%patch $31BCC [$0000W $0000W] #Speed 3
%patch $31BEA [$0000W $0000W] #Speed 4
%patch $31C08 [$0000W $0000W] #Speed 5
%patch $31C26 [$0000W $0000W] #Speed 6 (Shrinks)
%patch $31C44 [$0000W $0000W] #Speed 7
%patch $31C62 [$0000W $0000W] #Speed 8
%patch $31C80 [$0000W $0000W] #Speed 9 (Disappears)
Other speeds
#How much Berkeloids hover
%patch $10DE7 [$FF00W] #Float level (1 tile up)
%patch $10DEC [$0008W] #Hover up/down range (8)
%patch $10DD4 [$0000W] #Min hover bound (0)
%patch $10DD9 [$FFF8W] #Max hover bound (-8)
#Berkeloid flame speeds:
%patch $10CDB [$0030W] #Right
%patch $10CF4 [$FFD0W] #Left
%patch $10CD0 [$FFF8W] #Vertical (Up.)
%patch $10D74 [$0000W] #When hits walls (Fall down, don't bounce off)
Berkeloid doesn't float
This patch stops the Berkeloid floating, instead it will walk back and forth like most sprites.
Berkeloid walks instead of floating
#Berkeloid walks instead of floating
%patch $10DB5 $55 $8B $EC $56 $8B $76 $06 $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
Sprite Collision
The Berkeloid collision is simple, it blocks Keen's shots while also killing him.
Collision values
The Berkeloid uses its own special collision that blocks Keen's shots and kills him. The airborne flame uses a generic 'kill Keen' collision also used by other sprites.
Keen 4 collision values
#Walking
%patch $3197C $10800530RL #Berkeloid
%patch $3199A $10800530RL #Berkeloid
%patch $319B8 $10800530RL #Berkeloid
%patch $319D6 $10800530RL #Berkeloid
#Tossing flame
%patch $319F4 $10800530RL #Berkeloid
%patch $31A12 $10800530RL #Berkeloid
%patch $31A30 $10800530RL #Berkeloid
%patch $31A4E $10800530RL #Berkeloid
%patch $31A6C $10800530RL #Berkeloid
%patch $31A8A $10800530RL #Berkeloid
%patch $31AA8 $10800530RL #Berkeloid
%patch $31AC6 $10800530RL #Berkeloid
%patch $31AE4 $10800530RL #Berkeloid
%patch $31B02 $10800530RL #Berkeloid
%patch $31B20 $10800530RL #Berkeloid
%patch $31B3E $10800530RL #Berkeloid
#Flame in air
%patch $31B5C $09DC1752RL #Misc kill
%patch $31B7A $09DC1752RL #Misc kill
#Flame on ground (Collide like a Berkeloid)
%patch $31B98 $10800530RL #Berkeloid
%patch $31BB6 $10800530RL #Berkeloid
%patch $31BD4 $10800530RL #Berkeloid
%patch $31BF2 $10800530RL #Berkeloid
%patch $31C10 $10800530RL #Berkeloid
%patch $31C2E $10800530RL #Berkeloid
%patch $31C4C $10800530RL #Berkeloid
%patch $31C6A $10800530RL #Berkeloid
%patch $31C88 $10800530RL #Berkeloid
Berkeloid doesn't harm Keen
The following patch stops the Berkeloid killing Keen on contact. (Its flames are still lethal and it will still block his shots.)
Berkeloid doesn't harm Keen
#Berkeloid doesn't harm Keen
%patch $10D42 $09
Berkeloid is stunnable
This patch changes the Berkeloid's collision code so that it kills Keen but can be shot. In this patch it merely vanishes after being shot, transforming into a raindrop splash, but a custom stunned action can easily be crated.
Keen 4
#Modify collision code to be stunnable
%patch $10D30 $55 $8B $EC $56 $57 $8B $76 $06 $8B $7E $08 $83 $3D [$02] {$75} $07
$9A $0B8013E9RL $EB $13 $83 $3D [$03] {$75} $0E $B8 [$1F46W] $50
$57 $56 $9A $09DC1695RL $83 $C4 $06 $5F $5E $5D $CB
Collision code
This is the complete collision code for the Berkeloid. On the second line it checks for Keen's shots, if found the shot is smashed. On the third line it checks for Keen,if found the 'kill Keen' code is called.
Keen 4
#Berkeloid collision code
%patch $10D30 $55 $8B $EC $56 $57 $8B $7E $06 $8B $76 $08 $83 $C7 $4C $83 $3C
[$03] {$75} $0D $56 $9A $0D8F0D43RL $83 $C4 $02 $5F $5E $5D $CB
$83 $3C [$02] {$75} $05 $9A $0B8013E9RL $5F $5E $5D $CB
Animations
There is little to say about the Berkeloid's animations except that the landed flame uses some of the same animations as the airborne flame and that the floating animation speed can also affect the floating horizontal speed.
Keen 4
#Cache
%patch $3070A $01F7W #Berkeloid Cache start
%patch $30754 $0206W #Berkeloid cache end
#Berkeloid floating
%patch $31968 $01F7W $01FBW
%patch $31972 $0006W #Animation speed
%patch $31986 $01F8W $01FCW
%patch $31990 $0006W #Animation speed
%patch $319A4 $01F9W $01FDW
%patch $319AE $0006W #Animation speed
%patch $319C2 $01FAW $01FEW
%patch $319CC $0006W #Animation speed
#Flaming
%patch $319E0 $01FFW $0201W
%patch $319EA $0006W #Animation speed
%patch $319FE $01FFW $0201W
%patch $31A08 $0006W #Animation speed
%patch $31A1C $01FFW $0201W
%patch $31A26 $0006W #Animation speed
%patch $31A3A $01FFW $0201W
%patch $31A44 $0006W #Animation speed
%patch $31A58 $01FFW $0201W
%patch $31A62 $0006W #Animation speed
#Done flaming
%patch $31A76 $01FFW $0201W
%patch $31A80 $0006W #Animation speed
%patch $31A94 $0200W $0202W
%patch $31A9E $0006W #Animation speed
%patch $31AB2 $0200W $0202W
%patch $31ABC $0006W #Animation speed
%patch $31AD0 $0200W $0202W
%patch $31ADA $0006W #Animation speed
%patch $31AEE $0200W $0202W
%patch $31AF8 $0006W #Animation speed
%patch $31B0C $0200W $0202W
%patch $31B16 $0006W #Animation speed
%patch $31B2A $0200W $0202W
%patch $31B34 $0006W #Animation speed
#Berkeloid tossed flame in air
%patch $31B48 $0203W $0203W
%patch $31B52 $0006W #Animation speed
%patch $31B66 $0204W $0204W
%patch $31B70 $0006W #Animation speed
#Landed flame
%patch $31B84 $0203W $0203W #Start small
%patch $31B8E $0006W #Animation speed
%patch $31BA2 $0205W $0205W #Go large
%patch $31BAC $000CW #Animation speed
%patch $31BC0 $0206W $0206W
%patch $31BCA $000CW #Animation speed
%patch $31BDE $0205W $0205W
%patch $31BE8 $000CW #Animation speed
%patch $31BFC $0206W $0206W
%patch $31C06 $000CW #Animation speed
%patch $31C1A $0203W $0203W #Go small again
%patch $31C24 $000CW #Animation speed
%patch $31C38 $0204W $0204W
%patch $31C42 $000CW #Animation speed
%patch $31C56 $0203W $0203W
%patch $31C60 $000CW #Animation speed
%patch $31C74 $0204W $0204W
%patch $31C7E $000CW #Animation speed
Sprite positioning and landing on the ground
Berkeloids spawn one tile up from where they are placed. Flames' origin points are also specified since the left and right flames must be seen to emanate from the Berkeloid's outstretched hand.
Keen 4
#Berkeloid spawn height
%patch $10BCB $FE00W #1 tile up
#Flame origin points
%patch $10CC8 $0080W #Flame height (8 pixels down)
%patch $10CFA $0100W #Left flame left position (REVERSED, 1 tile left)
%patch $10CE1 $0200W #Right flame right position (2 tiles right)
Sounds
The Berkeloid makes two sounds, one when it fires a flame and another when that flame hits the ground. Both sounds can be blocked.
Berkeloid sounds
#Berkeloid sounds
%patch $10C93 $21 #Berkeloid launches flame
%patch $10D7D $28 #Berkeloid flame hits ground
Don't play Berkeloid sounds
#Don't play Berkeloid sounds
%patch $10C92 $EB $0A #Don't play Berkeloid launches flame
%patch $10D7C $EB $0A #Don't play Berkeloid flame hits ground
Clipping and foreground
The Berkeloid's foreground value is set on spawning at 2. This makes it appear in front of most sprites and foreground tiles (Excepting those set to be in front of all sprites.) This is useful since it must float close to many types of ground.
Keen 4
#BB Foreground variable
%patch $10BB9 $0002W #Berkeloid
Sprite-tile interaction
The floating Berkeloid has its own special collision allowing it to float up and down hills and not over edges. When throwing fire it uses a related collision that allows it to maintain floating while not moving. The airborne flame has a third collision that transforms it into a landed flame when it hits floors. (As well as allowing it to hit walls.) Finally the landed flame uses a generic 'sit' collision, ignoring most tiles.
Keen 4
#Berkeloid float
%patch $31980 $10800610RL #Floating
%patch $3199E $10800610RL #Floating
%patch $319BC $10800610RL #Floating
%patch $319DA $10800610RL #Floating
#Flame
%patch $319F8 $108005B5RL #Ready to flame
%patch $31A16 $108005B5RL #Flaming
%patch $31A34 $108005B5RL #Flaming
%patch $31A52 $108005B5RL #Flaming
%patch $31A70 $108005B5RL #Flaming
%patch $31A8E $108005B5RL #Flaming
%patch $31AAC $108005B5RL #Flaming
%patch $31ACA $108005B5RL #Flaming
%patch $31AE8 $108005B5RL #Flaming
%patch $31B06 $108005B5RL #Flaming
%patch $31B24 $108005B5RL #Flaming
%patch $31B42 $108005B5RL #Flaming
#Airborne flame
%patch $31B60 $1080055ERL #Tossed flame
%patch $31B7E $1080055ERL #Tossed flame
#Landed flame
%patch $31B9C $09DC176ERL #Sit
%patch $31BBA $09DC176ERL #Sit
%patch $31BD8 $09DC176ERL #Sit
%patch $31BF6 $09DC176ERL #Sit
%patch $31C14 $09DC176ERL #Sit
%patch $31C32 $09DC176ERL #Sit
%patch $31C50 $09DC176ERL #Sit
%patch $31C6E $09DC176ERL #Sit
%patch $31C8C $09DC176ERL #Sit
Flame interaction code
This is the tile interaction code for the Berkeloid's flame. The first line checks if the tile is blocking right; if it is then the next check is skipped. The next check on line two checks if the tile is blocking left; if not the next segment of code is skipped. The next segment of code is thus run if the sprite is touching a tile that is blocking either right or left. (That is, a wall.) The code sets the sprite's horizontal speed to zero (So it falls straight down.) At the end of line two a third check is made to see if the tile is upwards blocking. If it is then sound $28 plays and the sprite's action changes to that of a landed flame (Both variables marked in blue.) This is the flame landing. The last three lines can be ignored; they simply draw the Berkeloid.
Keen 4
#Berkeloid flame tile interaction code
%patch $10D5E $55 $8B $EC $56 $8B $76 $06 $83 $7C {$38} [$00] {$75} $06 $83 $7C {$3C}
[$00] {$74} $05 $C7 $44 $16 [$0000W] $83 $7C {$36} [$00] {$74} $19 $B8 [$0028W]
$50 $9A $187409F1RL $83 $C4 $02 $B8 [$2D14W] $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
Tossing interaction code
This is the tile interaction code for the Berkeloid tossing a flame. It is also called by the Berkeloid's floating tile interaction, so anything affecting this will also have an effect on the floating Berkeloid. Notably this interaction code controls the Berkeloid's floating limits, such as how high up it floats and how much.
On the second line the Berkeloid's Misc Variable B is checked, if it is larger than 0 then it is reset to 0 and the hover direction is set to -8 ($FFF8W). Otherwise the same variable is checked again on line 3 and, if it is less than -256 ($FF00W) then it is set to -256 and the hover direction set to +8. Taken together this sets the minimum and maximum hover bounds (0 and -256) and also the hover rate (+/-8) the Berkeloid uses.
The remaining two or so lines simply draw the Berkeloid sprite.
Keen 4
#Berkeloid tossing flames interaction code
%patch $10DB5 $55 $8B $EC $56 $8B $76 $06 $8B $44 $40 $F7 $2E $A54CW $8B $54
$3E $03 $D0 $89 $54 $3E $83 $7C $3E [$00] {$7E} $0C $C7 $44 $3E [$0000W]
$C7 $44 $40 [$FFF8W] $EB $11 $81 $7C $3E [$FF00W] {$7D} $0A $C7
$44 $3E [$FF00W] $C7 $44 $40 [$0008W] $33 $C0 $50 $50 $FF $74 $1E
$8B $44 $0C $03 $44 $3E $50 $FF $74 $0A $8B $C6 $05 $46 $00 $50
$9A $16541641RL $83 $C4 $0C $5E $5D $CB
Float interaction code
This is the tile interaction code for the Berkeloid floating. On the first line the Berkeloid's horizontal movement direction is checked; if it is not moving right the next check is skipped. The next check is for right walls. If the Berkeloid has hit a right wall it turns left. On line 4 the same two checks occur, this time checking if the Berkeloid is moving left and, if so, whether it has hit a left wall in which case it turns right.
On line 7 the Berkeloid checks for floors; if absent then the Berkeloid will turn around. This code is complex and opaque. Note however that the code $56 $0E $E8 $FF09W $83 $C4 $02 at the end calls the Berkeloid's flaming code.
Keen 4
#Berkeloid float tile interaction
%patch $10E10 $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 $5F $83 $7C {$0E} [$FF] {$75} $2B $83 $7C
$38 [$00] {$74} $25 $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 $EB $2E $83 $7C $36 [$00] {$75} $28 $8B
$44 $12 $D1 $E0 $29 $44 $0A $8B $44 $0E $F7 $D8 $89 $44 $0E $9A
$1D02002ARL $B1 $05 $D3 $F8 $89 $44 $08 $FF $74 $1C $56 $9A
$09DC120ARL $83 $C4 $04 $56 $0E $E8 $FF09W $83 $C4 $02 $5E
$5D $CB
Action type
The Berkeloid uses type 0 for all its actions except when it is floating, which is type 1 to ensure smooth movement. Likewise falling flames are type 3, allowing smooth movement and instant reaction to hitting the ground.
Keen 4
%patch $3196C {$0001W} #Berkeloid moving 1
%patch $3198A {$0001W} #Berkeloid moving 2
%patch $319A8 {$0001W} #Berkeloid moving 3
%patch $319C6 {$0001W} #Berkeloid moving 4
%patch $319E2 {$0000W} #Berkeloid flaming 1
%patch $31A02 {$0000W} #Berkeloid flaming 2
%patch $31A20 {$0000W} #Berkeloid flaming 3
%patch $31A3E {$0000W} #Berkeloid flaming 4
%patch $31A5C {$0000W} #Berkeloid flaming 5
%patch $31A7A {$0000W} #Berkeloid flamed 1
%patch $31A98 {$0000W} #Berkeloid flamed 2
%patch $31AB6 {$0000W} #Berkeloid flamed 3
%patch $31AD4 {$0000W} #Berkeloid flamed 4
%patch $31AF2 {$0000W} #Berkeloid flamed 5
%patch $31B10 {$0000W} #Berkeloid flamed 6
%patch $31B2E {$0000W} #Berkeloid flamed 7
%patch $31B4C {$0003W} #Berkeloid tossed flame 1
%patch $31B6A {$0003W} #Berkeloid tossed flame 2
%patch $31B88 {$0000W} #Berkeloid landed flame 1
%patch $31BA6 {$0000W} #Berkeloid landed flame 2
%patch $31BC4 {$0000W} #Berkeloid landed flame 3
%patch $31BE2 {$0000W} #Berkeloid landed flame 4
%patch $31C00 {$0000W} #Berkeloid landed flame 5
%patch $31C1E {$0000W} #Berkeloid landed flame 6
%patch $31C3C {$0000W} #Berkeloid landed flame 7
%patch $31C5A {$0000W} #Berkeloid landed flame 8
%patch $31C78 {$0000W} #Berkeloid landed flame 9
Deprotect and stick to ground
The Berkeloid uses the stick to ground value of 1 to float up and down hills. At all other times and all other actions, this value is 0.
Keen 4
%patch $3196E [$0000W $0001W] #Walking 1
%patch $3198C [$0000W $0001W] #Walking 2
%patch $319AA [$0000W $0001W] #Walking 3
%patch $319C8 [$0000W $0001W] #Walking 4
%patch $319E6 [$0000W $0000W] #Flame tossing 1
%patch $31A04 [$0000W $0000W] #Flame tossing 2
%patch $31A22 [$0000W $0000W] #Flame tossing 3
%patch $31A40 [$0000W $0000W] #Flame tossing 4
%patch $31A5E [$0000W $0000W] #Flame tossing 5
%patch $31A7C [$0000W $0000W] #Flame tossing 6
%patch $31A9A [$0000W $0000W] #Flame tossing 7
%patch $31AB8 [$0000W $0000W] #Flame tossing 8
%patch $31AD6 [$0000W $0000W] #Flame tossing 9
%patch $31AF4 [$0000W $0000W] #Flame tossing 10
%patch $31B12 [$0000W $0000W] #Flame tossing 11
%patch $31B30 [$0000W $0000W] #Flame tossing 12
#Flame airborne
%patch $31B4E [$0000W $0000W] #In air 1
%patch $31B6C [$0000W $0000W] #In air 2
#Flame landed
%patch $31B8A [$0000W $0000W] #Landed 1
%patch $31BA8 [$0000W $0000W] #Landed 2
%patch $31BC6 [$0000W $0000W] #Landed 3
%patch $31BE4 [$0000W $0000W] #Landed 4
%patch $31C02 [$0000W $0000W] #Landed 5
%patch $31C20 [$0000W $0000W] #Landed 6
%patch $31C3E [$0000W $0000W] #Landed 7
%patch $31C5C [$0000W $0000W] #Landed 8
%patch $31C7A [$0000W $0000W] #Landed 9
Probability and randomness
There are three random events that affect the Berkeloid. The first is the chance of the Berkeloid spawning facing left, this is 50%. The second is the chance that the Berkeloid will randomly turn to face Keen and chase him, this is 12.5%. Finally there is the probability that the Berkeloid will throw fireballs at Keen, this is about 3% if Keen is far away, but 25% if Keen is close.
Keen 4
#Spawn right or left
%patch $10BD6 $80
#Randomly turn to face Keen
%patch $10C1C $20
#Flame throwing frequency
%patch $10C3D $08 #Normally
%patch $10C52 $40 #If Keen is close and Berk is facing him
Sprite spawn code
In the initiation code notice the Berkeloid cache being set ($C7 $06 $CB75W $0001W.) Also notice the three difficulties of Berkeloid that are possible.
In the spawning code the last blue highlighted value is the sprite action the Berkeloid uses as it proceeds to act in-level. $C7 $02 $xxxxW sets the sprite activity, $C7 $47 $06 $xxxxW sets the clipping, $C7 $07 $xxxxW sets the sprite type, $C7 $20 $xxxxW sets the foreground value., Finally $D3 $E0 $05 $xxxx is how far down (Or actually up) the Berkeloid is spawned from where it is placed. This is necessary because it 'walks' on the ground but can only be placed in the level at multiples of 16 pixels high while its actual sprite height can vary.
$C7 $47 $0E $xxxxW is the horizontal direction the Berkeloid starts moving in, either $0001W (Facing right), $FFFFW (Facing left) or $0000W (Neither, never used.) $C7 $47 $10 $xxxxW is the vertical direction and works similarly. The Berkeloid has a probability check to determine which way it faces this is always 50:50 (Though it needn't be.) and the code responsible for this is $9A $1D02002ARL $3D $0080W
Keen 4
#Location of initiation code
%patch $EE8D [$010DW] #Easy Berkeloid (At $E9FD)
%patch $EEE5 [$0103W] #Medium Berkeloid (At $E9F3)
%patch $EEE7 [$00F9W] #Hard Berkeloid (At $E9E9)
#Berkeloid Initiation code
%patch $EAE9 $83 $3E [$7A6CW] {$03 $7D} $03 $E9 $040AW $83 $3E [$7A6CW] {$02 $7D}
$03 $E9 $0400W $FF $76 $FC $57 $9A {$1080039BRL} $83 $C4 $04
$C7 $06 $CB75W $0001W $E9 $03EBW
#Berkeloid spawn code
%patch $10B9B $55 $8B $EC $33 $C0 $50 $9A $06BD1E11RL $83 $C4 $02 $8B $1E
$D8 $A7 $C7 $07 [$000EW] $C7 $47 $02 [$0001W] $C7 $47 $20 [$0002W]
$8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B $46 $08 $D3 $E0 $05
[$FE00W] $89 $47 $0C $9A $1D02002ARL $3D [$0080W] $7D $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] $C7 $47 $40 [$0008W]
$B8 [$2AF8W] $50 $53 $9A $09DC118CRL $83 $C4 $04 $5D $CB