Patch:Broccolash
Broccolash are green, fast-moving creatures found in many levels in Tuberia in Keen Dreams. They will follow Keen, moving slightly slower than he does, and attempt to smash him with their heads.
Sprite Type
Broccolash use type 5 which has no impact on any other sprites save for making them transform into Wilted Flowers properly. It also affects how Keen reacts to it.
Keen Dreams
#Broccolash sprite type
%patch $81A9 [$05]
Sprite Actions
The Broccolash has a simple, if extensive, set of actions. It is spawned in the first frame of its running cycle and continues running until too close to Keen. It attacks Keen at close range by slamming its head against he ground. This sequence is nine frames long and ends with the Broccolash returning to running.
Due to the Broccolash's sprite type it it harmless to Keen except for two actions, its third and fourth headslamming actions. Only those two actions are deadly by default.
Actions: $19C0W #Broccolash run 1 $19DEW #Broccolash run 2 $19FCW #Broccolash run 3 $1A1AW #Broccolash run 4 $1A38W #Broccolash headslam 1 $1A56W #Broccolash headslam 2 $1A74W #Broccolash headslam 3 $1A92W #Broccolash headslam 4 $1AB0W #Broccolash headslam 5 $1ACEW #Broccolash headslam 6 $1AECW #Broccolash headslam 7 $1B0AW #Broccolash headslam 8 $1B28W #Broccolash headslam 9
Keen Dreams
#Place Broccolash in level
%patch $81C6 [$19C0W]
#Running cycle
%patch $2544C [$19DEW]
%patch $2546A [$19FCW]
%patch $25488 [$1A1AW]
%patch $254A6 [$19C0W]
#When attacking Keen
%patch $824A [$1A38W]
#Headslamming sequence
%patch $254C4 [$1A56W]
%patch $254E2 [$1A74W]
%patch $25500 [$1A92W]
%patch $2551E [$1AB0W]
%patch $2553C [$1ACEW]
%patch $2555A [$1AECW]
%patch $25578 [$1B0AW]
%patch $25596 [$1B28W]
%patch $255B4 [$19C0W]
#Actions that are deadly to Keen
%patch $7885 [$1A74W]
%patch $788C [$1A92W]
Deadly action range
As noted above only two actions are deadly to Keen by default. It is possible to use jump conditions to make this a range of actions or to make the Broccolash harmless.
Keen Dreams
#Actions that are deadly to Keen
%patch $7885 [$1A74W] {$74}
%patch $788C [$1A92W] {$75}
Sprite Behavior
The Broccolash has two unique behaviors. The first is used when it runs; this allows it to chase and attack Keen. The second is used only by the eighth frame of its attacking sequence. The rest of the attacking sequence use no behavior at all.
Behaviors: $07C50596RL #Broccolash run $07C50587RL #Broccolash attack
Keen Dreams
#Broccolash run
%patch $25440 $07C50596RL
%patch $2545E $07C50596RL
%patch $2547C $07C50596RL
%patch $2549A $07C50596RL
#Broccolash attack
%patch $254B8 $00000000L
%patch $254D6 $00000000L
%patch $254F4 $00000000L
%patch $25512 $00000000L
%patch $25530 $00000000L
%patch $2554E $00000000L
%patch $2556C $00000000L
%patch $2558A $07C50587RL
%patch $255A8 $00000000L
Start attacking behavior code
This is the Broccolash's attacking behavior. On the first and second lines the Broccolash checks to see if it is vertically equal with Keen. (That is, it is not above or below him.) If not, nothing is done.
If however the Broccolash is standing equal with Keen then it checks which way it is facing on line 3. If it is facing left then it checks to see if Keen is more than 3 tiles left ($FD00) of it. If so nothing happens. If he is a second check is performed to see if Keen is less than 8 pixels right ($0080) of it. If not, it turns to face Keen at the end of line 4. If however Keen is closer the code skips to the start of line 5 ($EB $1E) which makes it jump to the attack code. (An odd way of doing things.)
Lines 5 and 6 deal with the same sort of checks, except for right-facing Broccolash. The limits here are 3 tiles right ($0300W) and 8 pixels left ($80, using a 1-byte check, another odd feature.) Again if Keen is too far away nothing happens. closer the Broccolash turns to face him, and very close it attacks.
The attack code starts at line 7 and changes three variables; the sprite's action (Changed to attacking), clipping (Changed to 'none') and another, unknown, variable.
Keen Dreams
#Broccolash behavior
%patch $81E6 $55 $8B $EC $56 $57 $8B $76 $06 $8B $44 $24 $8B $1E $34 $70 $3B
$47 $28 {$77} $5C $8B $44 $28 $3B $47 $24 {$72} $54 $8B $1E $34 $70
$8B $47 $0A $2B $44 $0A $8B $F8 $83 $7C {$0E} [$FF] {$75} $15 $81 $FF
[$FD00W] {$7C} $3C $81 $FF [$0080W] {$7E} $07 $C7 $44 $0E [$0001W] $EB
$2F $EB $1E $8B $1E $34 $70 $8B $47 $22 $2B $44 $26 $8B $F8 $81
$FF [$0300W] {$7F} $1B $83 $FF [$80] {$7D} $07 $C7 $44 $0E [$FFFFW] $EB
$0F $C7 $44 $1E [$1A38W] $C7 $44 $06 [$0000W] $C7 $44 $12 [$0000W]
$5F $5E $5D $CB
Compact behavior code
This version of the Broccolash behavior is 3 bytes shorter due to eliminating unnecessary code. (Note also the first $0080W has been changed to $7F to avoid a problem.)
Keen Dreams
#Compact Broccolash behavior
%patch $81E6 $55 $8B $EC $56 $57 $8B $76 $06 $8B $44 $24 $8B $1E $34 $70 $3B
$47 $28 {$77} $59 $8B $44 $28 $3B $47 $24 {$72} $51 $8B $1E $34 $70
$8B $47 $0A $2B $44 $0A $8B $F8 $83 $7C {$0E} [$FF] {$75} $12 $81 $FF
[$FD00W] {$7C} $39 $83 $FF [$7F] {$7E} $25 $C7 $44 $0E [$0001W] $EB $2D
$8B $1E $34 $70 $8B $47 $22 $2B $44 $26 $8B $F8 $81 $FF [$0300W]
{$7F} $1B $83 $FF [$80] {$7D} $07 $C7 $44 $0E $FFFFW $EB $0F $C7 $44
$1E [$1A38W] $C7 $44 $06 [$0000W] $C7 $44 $12 [$0000W] $5F $5E $5D
$CB
Stop attacking behavior code
This behavior acts to restore the Broccolash's clipping after an attack has been performed. This is the only thing the behavior does. This behavior is important as without it the Broccolash will have no clipping after attacking and will 'sink down.' As such this behavior must be used by an action in its attacking sequence.
Keen Dreams
#Broccolash stop attacking behavior
%patch $81D7 $55 $8B $EC $56 $8B $76 $06 $C7 $44 $06 [$0001W] $5E $5D $CB
Broccolash attacks randomly
These two patches cause the Broccolash to attack randomly. The first requires Keen to be level with the enemy while the second causes it to attack wherever Keen is. The blue value is the probability of attack, a higher value meaning more frequent attacks.
Keen Dreams
#Broccolash attacks randomly when Keen is level with it
%patch $820E $9A $16C40026RL $3D [$0028W] $7E $2F $5F $5E $5D $CB
#Broccolash attacks randomly
%patch $81EE $9A $16C40026RL $3D [$0028W] $7E $4F $5F $5E $5D $CB
Broccolash attacks randomly and makes sound
These two patches cause the Broccolash to attack randomly as well as playing a sound when it attacks. The first requires Keen to be level with the enemy while the second causes it to attack wherever Keen is. The blue value is the probability of attack, a higher value meaning more frequent attacks.
The last blue value in each patch is the sound played when it attacks. Here the Tater Trooper's attack sound is used.
Keen Dreams
#Broccolash attacks randomly when Keen is level with it -With sound
%patch $820E $9A $16C40026RL $3D [$0028W] $7E $24 $5F $5E $5D $CB
%patch $823C $B8 [$0010W] $50 $9A $10BB1282RL $44 $44
#Broccolash attacks randomly -With sound
%patch $81EE $9A $16C40026RL $3D [$0028W] $7E $44 $5F $5E $5D $CB
%patch $823C $B8 [$0010W] $50 $9A $10BB1282RL $44 $44
Speed and Jump Height
The Broccolash's motion is entirely related to its animation. It moves while running and also in the very last frame of its attack.
Animation motion
#Broccolash run
%patch $2543C [$0080W $0000W]
%patch $2545A [$0080W $0000W]
%patch $25478 [$0080W $0000W]
%patch $25496 [$0080W $0000W]
#Broccolash attack
%patch $254B4 [$0000W $0000W]
%patch $254D2 [$0000W $0000W]
%patch $254F0 [$0000W $0000W]
%patch $2550E [$0000W $0000W]
%patch $2552C [$0000W $0000W]
%patch $2554A [$0000W $0000W]
%patch $25568 [$0000W $0000W]
%patch $25586 [$0000W $0000W]
%patch $255A4 [$0080W $0000W]
Sprite collision
Like nearly all sprites in Keen Dreams the Broccolash does not have a sprite collision. Instead Keen and his shots react to them and their sprite types.
Keen Dreams
#Broccolash run
%patch $25444 $00000000L
%patch $25462 $00000000L
%patch $25480 $00000000L
%patch $2549E $00000000L
#Broccolash attack
%patch $254BC $00000000L
%patch $254DA $00000000L
%patch $254F8 $00000000L
%patch $25516 $00000000L
%patch $25534 $00000000L
%patch $25552 $00000000L
%patch $25570 $00000000L
%patch $2558E $00000000L
%patch $255AC $00000000L
Animations
The Broccolash has two animation cycles, running and slamming.
Keen Dreams
#Cache
%patch $23E78 $00F1W #Broccolash cache start
%patch $23EA4 $0100W #Broccolash cache end
#Broccolash run
%patch $25430 $00F1W $00F9W
%patch $2543A $0007W #Animation speed
%patch $2544E $00F2W $00FAW
%patch $25458 $0007W #Animation speed
%patch $2546C $00F3W $00FBW
%patch $25476 $0007W #Animation speed
%patch $2548A $00F4W $00FCW
%patch $25494 $0007W #Animation speed
#Broccolash headslam
%patch $254A8 $00F5W $00FDW
%patch $254B2 $0003W #Animation speed
%patch $254C6 $00F6W $00FEW
%patch $254D0 $0003W #Animation speed
%patch $254E4 $00F7W $00FFW
%patch $254EE $0003W #Animation speed
%patch $25502 $00F8W $0100W
%patch $2550C $0007W #Animation speed
%patch $25520 $00F7W $00FFW
%patch $2552A $0006W #Animation speed
%patch $2553E $00F6W $00FEW
%patch $25548 $0006W #Animation speed
%patch $2555C $00F5W $00FDW
%patch $25566 $0006W #Animation speed
%patch $2557A $00F1W $00F9W
%patch $25584 $0006W #Animation speed
%patch $25598 $00F1W $00F9W
%patch $255A2 $0006W #Animation speed
Sprite positioning and attack range
The Broccolash spawns 16 pixels (1 tile) higher then where it is placed in-level. This must be changed with its sprite height as it is used to make the Broccolash move along the ground.
The Broccolash will only attack Keen if it is vertically equal with him. If Keen is further than 3 tiles away nothing will happen. If he is between 3-0.5 tiles it will turn to face him. If he is closer than that it will attack. For some reason the second right attack range is one byte instead of two, which makes it trickier to change. (It is short for $FF80, not $0080.) See also Jump conditions.
Keen Dreams
#Broccolash spawn height
%patch $81BB [$FF00W] #16 pixels upwards
Keen Dreams
#If Broccolash is facing left
%patch $8216 [$FD00W] {$7C} #3 tiles left
%patch $821C [$0080W] {$7E} #8 pixels left
#If Broccolash is facing right
%patch $8237 [$0300W] {$7F} #3 tiles right
%patch $823D [$80] {$7D} #8 pixels right
Clipping and foreground
The Broccolash does something interesting when it attacks; it sets its clipping to nothing, setting it back to 1 after it has finished attacking. This is due to the nature of its attack, which involves changing its position from mostly vertical to mostly horizontal.
Keen Dreams
#Broccolash clipping
%patch $824F [$0000W] #When starting to attack
%patch $81E1 [$0001W] #When stopping attack
Sprite-tile interaction
The Broccolash uses two generic tile interactions. The first, used when running and also in the last frame of its headslam sequence causes it to turn at platform edges and walls and also go up and down hills. The other simply draws the sprite and is used during headslamming.
Keen Dreams
#Broccolash running
%patch $25448 $07C50299RL
%patch $25466 $07C50299RL
%patch $25484 $07C50299RL
%patch $254A2 $07C50299RL
#Broccolash headslam
%patch $254C0 $07C501DDRL
%patch $254DE $07C501DDRL
%patch $254FC $07C501DDRL
%patch $2551A $07C501DDRL
%patch $25538 $07C501DDRL
%patch $25556 $07C501DDRL
%patch $25574 $07C501DDRL
%patch $25592 $07C501DDRL
%patch $255B0 $07C50299RL
Action type
The Broccolash is a basic enemy that just moves back and forth. All of its actions are type 0.
Sprite action types
#Broccolash running
%patch $25434 [$0000W]
%patch $25452 [$0000W]
%patch $25470 [$0000W]
%patch $2548E [$0000W]
#Broccolash headslam
%patch $254AC [$0000W]
%patch $254CA [$0000W]
%patch $254E8 [$0000W]
%patch $25506 [$0000W]
%patch $25524 [$0000W]
%patch $25542 [$0000W]
%patch $25560 [$0000W]
%patch $2557E [$0000W]
%patch $2559C [$0000W]
Deprotect and stick to ground
The Broccolash needs to stick to the ground while walking and thus uses a value of 1 for this variable in its running actions. It's attacking actions set this to zero but deprotect its animations.
Sprite deprotect, stick
#Broccolash running
%patch $25436 [$0000W $0001W]
%patch $25454 [$0000W $0001W]
%patch $25472 [$0000W $0001W]
%patch $25490 [$0000W $0001W]
#Broccolash headslam
%patch $254AE [$0001W $0000W]
%patch $254CC [$0001W $0000W]
%patch $254EA [$0001W $0000W]
%patch $25508 [$0000W $0000W]
%patch $25526 [$0001W $0000W]
%patch $25544 [$0001W $0000W]
%patch $25562 [$0001W $0000W]
%patch $25580 [$0001W $0000W]
%patch $2559E [$0001W $0000W]
Sprite spawn code
There is one type of Broccolash. In its initiation code its cache is set in $C7 $06 $70BCW $0001W.
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 Broccolash spawns facing 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 Broccolash spawns 16 pixels or 1 tile higher than where it is placed, this needs to be changed if its sprite height changes.
Keen Dreams
#Broccolash initiation pointer
%patch $4A2D $0332W #Broccolash (At $4802)
#Broccolash initiation code
%patch $4802 $FF $36 $7052W $FF $36 $7050W $9A $07C50546RL $83 $C4 $04
$8B $1E $3E $70 $C7 $47 $02 $0000W $C7 $06 $70BCW $0001W $E9
$01A8W
#Broccolash spawn code
%patch $8196 $55 $8B $EC $33 $C0 $50 $9A $044D01C9RL $44 $44 $8B $1E $3E
$70 $C7 $07 [$0005W] $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B
$46 $08 $D3 $E0 $05 [$FF00W] $89 $47 $0C $C7 $47 $0E [$0001W] $B8
[$19C0W] $50 $FF $36 $3E $70 $9A $044D1212RL $83 $C4 $04 $5D
$CB