Patch:Mimrock
Mimrocks are enemies in Keen 4 known for their sneakiness and ability to protect themselves from Keen by hiding.
Sprite Type
Mimrocks use type 19, which is used only by them and does not affect other sprites in any way.
Keen 4
#Mimrock sprite type
%patch $112DC $13
Sprite Actions
Mimrock actions can be divided into four main classes. The Mimrock is spawned sitting still. By itself the still Mimrock will loop, doing nothing. However it's behavior checks if Keen is level vertically with it, then it checks if Keen is right or left of it before making the Mimrock walk.
Walking Mimrock's regularly loop back to sitting if nothing else changed, and it's behavior makes it instantly return to sitting still if Keen is facing it. So a walking Mimrock will regularly pause, but keep walking if Keen is near.
If Keen is very close then the walking Mimrock will jump at him. This is another loop which will eventually lead to it bouncing on the ground and returning to waiting. The first action is the start of the jump, the next two are falling and loop, and the third is bouncing and occurs when the Mimrock hits the ground. After bouncing it returns to sitting still.
When shot the Mimrock has a falling stunned action that then becomes a sitting stunned action when it hits the ground.
Actions $343AW #Mimrock stuck to ground $3458W #Mimrock sneaking 1 $3476W #Mimrock sneaking 2 $3494W #Mimrock sneaking 3 $34B2W #Mimrock sneaking 4 $34D0W #Mimrock sneaking 5 $34EEW #Mimrock sneaking 6 $350CW #Mimrock jumping 1 - start jump $352AW #Mimrock jumping 2 $3548W #Mimrock jumping 3 $3566W #Mimrock upside down bouncing $3584W #Shot Mimrock $35A2W #Stunned Mimrock
Keen 4
#Spawn Mimrock in-level
%patch $11EA6 [$343AW] #Mimrock stuck to ground
#What waiting Mimrock does if Keen is...
%patch $11EF9 [$3458W] #...right of rock (Sneak left)
%patch $11F13 [$3458W] #...left of rock (Sneak right)
#What walking Mimrock does if Keen is...
%patch $11F3E [$343AW] #...above or below Mimrock (Mimrock stuck to ground)
#Waiting Mimrock keeps waiting until something changes
%patch $322C6 [$343AW] #Mimrock stuck to ground
#Sneaking Mimrock
%patch $322E4 [$3476W] #Mimrock sneaking 2
%patch $32302 [$3494W] #Mimrock sneaking 3
%patch $32320 [$34B2W] #Mimrock sneaking 4
%patch $3233E [$34D0W] #Mimrock sneaking 5
%patch $3235C [$34EEW] #Mimrock sneaking 6
%patch $3237A [$343AW] #Mimrock stuck to ground
#When Keen is very close to walking Mimrocks
%patch $11F74 [$350CW] #Mimrock jumping 1
#Jumping Mimrock
%patch $32398 [$352AW] #Mimrock jumping 2
%patch $323B6 [$3548W] #Mimrock jumping 3
%patch $323D4 [$352AW] #Mimrock jumping 2 (Loops back to previous action)
#Falling Mimrock hits ground
%patch $12000 [$3566W] #Mimrock upside down bouncing
#Bouncing Mimrock
%patch $323F2 [$0000W] #Do nothing (Tile collision controls next action)
%patch $12068 [$343AW] #Mimrock stuck to ground (After hitting ground a second time)
#When shot
%patch $11FAB [$3584W] #Shot Mimrock
#Stunned Mimrock
%patch $32410 [$35A2W] #Stunned Mimrock
%patch $3242E [$0000W] #Do nothing (Stay stunned)
Sprite Behavior
The Mimrock's behaviors are only half the story, no other sprite in Keen galaxy relies so heavily on tile collision code. The Mimrock has two 'generic' behaviors, the 'Berkeloid flame' behavior, used when it is moving through the air and the 'shot sprite' behavior used when it is bouncing along the ground and when it is (of course) stunned.
The two unique behaviors are the 'look for Keen' behavior used by sitting Mimrock (Which cheeks if Keen is level with the Mimrock and facing away then send the Mimrock walking in the right direction if this is so.) and the 'look to jump' behavior used by walking Mimrocks (Which checks to see if Keen is facing the Mimrock and makes it sit if this is so, or if Keen is near and makes the Mimrock jump at him if this is so.)
Behaviors: $09DC16C9RL #Shot sprite $09DC16E5RL #Berkeloid flame $11A20494RL #Mimrock look for Keen to walk to him $11A204F8RL #Mimrock look for Keen to jump at him
Keen 4
#Waiting
%patch $322BA $11A20494RL #Mimrock look to walk
#Sneaking
%patch $322D8 $11A204F8RL #Look to wait\jump
%patch $322F6 $11A204F8RL #Look to wait\jump
%patch $32314 $11A204F8RL #Look to wait\jump
%patch $32332 $11A204F8RL #Look to wait\jump
%patch $32350 $11A204F8RL #Look to wait\jump
%patch $3236E $11A204F8RL #Look to wait\jump
#Jumping
%patch $3238C $09DC16E5RL #Berkeloid flame
%patch $323AA $09DC16E5RL #Berkeloid flame
%patch $323C8 $09DC16E5RL #Berkeloid flame
#Bouncing on ground
%patch $323E6 $09DC16C9RL #Shot sprite
#Stunned
%patch $32404 $09DC16C9RL #Shot sprite
%patch $32422 $09DC16C9RL #Shot sprite
Seeking Keen, sneak range and attack range
There are three aspects to the Mimrock's ability to seek Keen. The first is its sneaking directions; by default the Mimrock sneaks in different directions depending on what direction the player is facing. By default it sneaks in the same direction as the player faces, 'chasing' them.
The second and third aspects are the sneak\attack ranges. Mimrocks will sneak after Keen is further away than a certain distance both horizontally and vertically and will attack Keen if closer than a certain distance, again, horizontally and vertically.
Keen seeking and attack range
#Sneak directions:
%patch $11EEE $FF #If Keen is facing left,
%patch $11EF4 $FFFFW #Mimrocks sneak left
%patch $11F08 $01 #If Keen is facing right
%patch $11F0E $0001W #Mimrocks sneak right
#Sneak after Keen if:
%patch $11ECB $0500W #Less than 5 tiles above or below Keen AND,
%patch $11EDF $0300W #Further than 3 tiles l/r of Keen
#Jump on Keen if:
%patch $11F2F $0500W #Less than 5 tiles above or below Keen AND,
%patch $11F53 $0400W #Less than than 4 tiles l/r of Keen
Mimrock never jumps
This patch stops the Mimrock jumping thought it will still stop walking if Keen is far away. If stopping the walking is not a problem this can also be done by changing the walking Mimrock's behavior to $00000000L.
Keen 4
#Mimrock will never jump
%patch $11F43 $5E $5D $CB
Mimrock always chases Keen
This patch makes the Mimrock continually chase Keen instead of stopping regularly. It will also not hide when Keen faces it. Eliminating the third line will make the Mimrock regularly pause its sneaking behavior to stop, eliminating the second will add further pauses.
Keen 4
#Mimrocks always pursue Keen
%patch $11EA6 $3458W #Mimrocks spawned chasing Keen
%patch $322C6 $3458W #If waiting, chase
%patch $3237A $3458W #Mimrock doesn't slam back down, once activated.
%patch $11EEB $EB $04 #Ditch the first "Is Keen facing the Mimrock?" check
%patch $11F05 $EB $04 #Ditch the second "Is Keen facing the Mimrock?" check
%patch $11F3B $EB $06 #Don't make the Mimrock slam down if he spies Keen
Speed and Jump Height
There are several sets of speeds governing the Mimrock. The animation motion controls the Mimrock's sneaking speed. All other speeds are defined in the Mimrock's code. The first two of note are the attack jump's height and left\right width. The second set of speeds is the small bounce height the Mimrock uses when it is falling after attacking and hits the ground.
The next set of speeds are used when the Mimrock collides with ceilings or walls. There are two subsets of speed, one for the attacking Mimrock and the other for the bouncing-off-the-ground Mimrock. By default they halt vertical\horizontal speed when the Mimrock hits solid tiles, giving a brief pause before the Mimrock succumbs to gravity. (This doing things like making the 'hit ceiling' speed negative will make the Mimrock begin to 'stick' to ceilings.)
Finally the Mimrock is given a 'kick' down when shot, which interrupts its jumps.
Jump height
#Attack jump
%patch $11F65 [$FFD8W] #Jump height
%patch $11F5B [$0014W] #Jump length
#Small bounce height when lands on ground
%patch $11FFD [$FFECW] #Land bounce height
#When hitting stuff
%patch $1202C [$0000W] #Stop moving vertically when hitting ceiling
%patch $1208E [$0000W] #Stop moving vertically when bouncing and hitting ceiling [Increase these to make rock 'stick'
%patch $1201B [$0000W] #Vertical speed when hit walls (Fall straight down)
%patch $12083 [$0000W] #Horizontal speed when bouncing hit walls (Increase to make rocks 'bounce off')
#Downwards speed when shot
%patch $11FBA [$10]
Animation motion
#Sleeping
%patch $322B6 [$0000W $0000W] #Speed
#Sneaking
%patch $322D4 [$0040W $0000W]
%patch $322F2 [$0040W $0000W]
%patch $32310 [$0040W $0000W]
%patch $32330 [$0040W $0000W]
%patch $3234C [$0040W $0000W]
%patch $3236A [$0040W $0000W]
#Pouncing
%patch $32388 [$0000W $0000W]
%patch $323A6 [$0000W $0000W]
%patch $323C4 [$0000W $0000W]
%patch $323E2 [$0000W $0000W]
#Stunned in air
%patch $32400 [$0000W $0000W]
#Stunned on ground
%patch $3241E [$0000W $0000W]
Sprite Collision
The Mimrock has two collisions; one lethal to Keen and one 'safe'. However these two collision are tied together; the deadly collision uses the safe collision as part of itself.
Collision values
The Mimrock is interesting in that it cannot be shot while sitting; Keen's shots (And Keen himself) will pass by it harmlessly. While the Mimrock can be shot while sneaking, it instantly goes to sitting when Keen turns to face it, so this is very tricky to do. (One way is to turn, shoot the Mimrock then rapidly turn around again, so the Mimrock starts sneaking again, running into Keen's shot.) It is easiest to shoot the Mimrock when it is jumping as it cannot alter its course.
A different collision is sued when the Mimrock is jumping and falling; this is the only time it is lethal to Keen.
Keen 4
#Sitting
%patch $322BE $00000000L #No collision
#Sneaking
%patch $322DC $11A20559RL #Mimrock
%patch $322FA $11A20559RL #Mimrock
%patch $32318 $11A20559RL #Mimrock
%patch $32336 $11A20559RL #Mimrock
%patch $32354 $11A20559RL #Mimrock
%patch $32372 $11A20559RL #Mimrock
#Pouncing
%patch $32390 $11A2059FRL #Mimrock
%patch $323AE $11A2059FRL #Mimrock deadly
%patch $323CC $11A2059FRL #Mimrock deadly
#Bouncing on the ground
%patch $323EA $11A20559RL #Mimrock
#Stunned
%patch $32408 $00000000L #No collision (In air)
%patch $32426 $00000000L #No collision (On ground)
Collision code
This is the complete code for both of the Mimrock's collisions; the simplest appears to be the 'deadly to Keen' collision. This checks for Keen and if it finds him runs his death code. However it also contains the string $56 $FF $76 $06 $0E $E8 $FF9EW $83 $C4 $04 which calls the entire safe collision code which means that anything and everything in the safe collision code is also run.
The safe collision code checks for Keen's shot type. If this is detected a number of (unimportant) variables are set to 0, the sprite type is set to $21 (Stunned), the Mimrock's action is set to $3584W (Stunned Mimrock.) and the Mimrock is given an upwards boost of $10
Keen 4
#Mimrock harmless collision
%patch $11F79 $55 $8B $EC $56 $57 $8B $76 $06 $8B $7E $08 $83 $3D [$03] {$75} $32
$C7 $44 $3E [$0000W] $C7 $44 $40 [$0000W] $C7 $44 $42 [$0000W] $8B
$04 $89 $44 $44 $C7 $04 [$0021W] $57 $9A $0D8F0D43RL $83 $C4
$02 $B8 [$3584W] $50 $56 $9A $09DC120ARL $83 $C4 $04 $83 $6C
$18 [$10] $5F $5E $5D $CB
#Mimrock deadly collision (Calls harmless collision)
%patch $14DBF $55 $8B $EC $56 $8B $76 $08 $83 $3C [$02]
{$75} $08 $9A $0B8013E9RL $5E $5D $CB $56 $FF $76 $06 $0E $E8
$FF9EW $83 $C4 $04 $5E $5D $CB
Don't stop bullet
This patch allows Keen's shot to pass straight through the Mimrock without stopping, while still stunning the Mimrock.
Keen 4
#Mimrock doesn't stop Keen's shots
%patch $11FA2 $90 $90 $90 $90 $90
Infinite shootability
This patch allows Keen to shoot the Mimrock as many times as he wishes; wach time he will produce a stunned Mimrock, but the original will keep going. This can crash the game if shot enough. (There will be not sprite space left.) It is also incompatible with the above bullet patch.
Keen 4
#Infinite shootability
%patch $11F7E $90 $90 $90
Win game if shot 40 times (Boss)
This collision gives the Mimrock a 'health' of 40. Deadly to Keen it will stop his shots and win the game if shot 40 times. The game is won immediately, the Mimrock doesn't stun. The last three lines make this collision apply to the pouncing Mimrock, this is necessary to avoid bugs.
The Mimrock's health is 40 in this example ($28, highlighted in blue.) The collision contains two checks, on for Keen's shot and another for Keen himself. Due to the way the 'health counter' works saving then loading a game will reset the Mimrock's health to maximum as will dying. To make an effective boss it is recommended that the 'always chase Keen' behavior patch at the top of this page be used as well.
Keen 4
#Boss collision, shoot 40 times to win game, else deadly
%patch $11F79 $55 $8B $EC $56 $57 $8B $7E $06 $8B $76 $08 $83 $C7 $4C $83 $3C
[$03] {$75} $1C $56 $9A $0D8F0D43RL $83 $C4 $02 $FF $06 $CB53W
$83 $3E $CB53W [$28] $7C $12 $C7 $06 {$7A70W} [$000DW] $EB $0A $83
$3C [$02] {$75} $05 $9A $0B8013E9RL $5F $5E $5D $CB
#State 13 wins game
%patch $6BD9 $0EB2W
#Jumping Mimrock uses collision while pouncing
%patch $32390 $11A20559RL
%patch $323AE $11A20559RL
%patch $323CC $11A20559RL
Animations
These are the Mimrock's animations. There are a few things to note. Firstly the sneaking animation speeds also influence the sneaking speed as well as how fast the Mimrock ca stop sneaking. Secondly the stunned Mimrock's animations speeds don't count.
Keen 4
#Cache
%patch $306F6 [$0184W] #Mimrock Cache start
%patch $30740 [$0193W] #Mimrock cache end
#Mimrock sitting
%patch $322AA $0184W $0184W
%patch $322B4 $0014W #Reaction speed
#Mimrock walking
%patch $322C8 $0189W $0185W
%patch $322D2 $0006W #Animation speed
%patch $322E6 $018AW $0186W
%patch $322F0 $0006W #Animation speed
%patch $32304 $018BW $0187W
%patch $3230E $0006W #Animation speed
%patch $32322 $018CW $0188W
%patch $3232C $0006W #Animation speed
%patch $32340 $0189W $0185W
%patch $3234A $0006W #Animation speed
%patch $3235E $018AW $0186W
%patch $32368 $0006W #Animation speed
#Mimrock jumping
%patch $3237C $0190W $018DW #Launch
%patch $32386 $0018W #Animation speed
%patch $3239A $0191W $018EW #Flip
%patch $323A4 $000AW #Animation speed
%patch $323B8 $0192W $018FW #Flip
%patch $323C2 $000AW #Animation speed
%patch $323D6 $0192W $018FW #Upside down
%patch $323E0 $000AW #Animation speed
#Stunned
%patch $323F4 $0192W $0192W #Shot in air
%patch $323FE $000CW #Animation speed
%patch $32412 $0193W $0193W #Shot on ground
%patch $3241C $000CW #Animation speed
Sounds
The Mimrock makes two sounds. The first occurs when it is attacking and hits the ground for the first time. The second occurs when this 'rebounding' Mimrock hits the ground a second time and stops moving. both sounds can be blocked.
Keen 4
#Mimrock sounds
%patch $11FEF $0F #Mimrock bonk on ground 1st time
%patch $1205C $0F #Mimrock bonk on ground 2nd time
#Don't play Mimrock sounds
%patch $11FEE $EB $0A #Don't play Mimrock bonk on ground 1st time
%patch $1205B $EB $0A #Don't play Mimrock bonk on ground 2nd time
Sprite positioning
The Mimrock spawns 13 pixels higher than where it is placed in level due to its sprite height. This is vital to prevent the Mimrock sitting in the air and so this value must be changed if the Mimrock's sprite height is changed.
Keen 4
#Spawn height:
%patch $11E97 $FF30W #13 pixels up
Clipping and foreground
The Mimrock uses default clipping which cannot be patched. It does however use a foreground variable of 3, putting it in front of all sprites and tiles, useful since it must blend in with rocks, which appear to be in front of solid ground.
Keen 4
#Mimrock foreground variable
%patch $11E85 $0003W
Sprite-tile interaction
The Mimrock's tile interaction is responsible for nearly all of its behavior. While sitting and sneaking it uses a generic 'turn around at walls\platform edges' collision that is used by many sprites in the game. However when attacking it uses its first unique collision that lets i bounce of walls, floors and ceilings. After bouncing once it switches to a second unique collision that also lets it bounce of walls, floors and ceilings, (See speed section.) but stop bouncing when it hits the ground. Finally, when stunned, it uses a generic 'stunned sprite' interaction.
Keen 4
%patch $322C2 $09DC1795RL #Waiting
%patch $322E0 $09DC1795RL #Sneaking
%patch $322FE $09DC1795RL #Sneaking
%patch $3231C $09DC1795RL #Sneaking
%patch $3233A $09DC1795RL #Sneaking
%patch $32358 $09DC1795RL #Sneaking
%patch $32376 $09DC1795RL #Sneaking
%patch $32394 $11A205C1RL #Jumping
%patch $323B2 $11A205C1RL #Jumping
%patch $323D0 $11A205C1RL #Jumping
%patch $323EE $11A2062ERL #Bouncing
%patch $3240C $09DC1913RL #Shot
%patch $3242A $09DC1913RL #Stunned
Jumping tile interaction
This is the complete tile interaction code for the jumping Mimrock. On the first line floors are checked for; if found sound $0F is played, the Mimrock's vertical speed is set to -20 (A slight upwards bounce) and its action set to 'upside-down bouncing'.
After this walls are checked for. If either left or right walls are found the Mimrock's horizontal speed is set to zero. Finally ceilings and floors are checked for; if found the Mimrock's vertical speed is set to zero. (This results in two floor checks, which is redundant.)
Keen 4
#Jumping Mimrock tile interaction
%patch $11FE1 $55 $8B $EC $56 $8B $76 $06 $83 $7C $36 $00 $74 $1E $B8 [$000FW]
$50 $9A $187409F1RL $83 $C4 $02 $C7 $44 $18 [$FFECW] $B8 [$3566W]
$50 $56 $9A $09DC120ARL $83 $C4 $04 $83 $7C $38 $00 $75
$06 $83 $7C $3C $00 $74 $05 $C7 $44 $16 [$0000W] $83 $7C $36 $00
$75 $06 $83 $7C $3A $00 $74 $05 $C7 $44 $18 [$0000W] $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
Bouncing tile interaction
This is the complete tile interaction code for the bouncing Mimrock. It is almost the same as the jumping interaction above, except it doesn't check for ceilings. On the first line floors are checked for; if found sound $0F is played and its action set to 'sit'.
After this walls are checked for. If either left or right walls are found the Mimrock's horizontal speed is set to zero. Finally and floors are checked for once more; if found the Mimrock's vertical speed is set to zero. (This results in two floor checks, which is redundant.)
Keen 4
#Mimrock bouncing tile interaction
%patch $1204E $55 $8B $EC $56 $8B $76 $06 $83 $7C $36 $00 $74 $19 $B8 [$000FW]
$50 $9A $187409F1RL $83 $C4 $02 $B8 [$343AW] $50 $56 $9A
$09DC120ARL $83 $C4 $04 $83 $7C $38 $00 $75 $06 $83 $7C $3C $00
$74 $05 $C7 $44 $16 [$0000W] $83 $7C $36 $00 $74 $05 $C7 $44 $18
[$0000W] $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 Mimrock's action types are quite important. While sitting or sneaking it uses type 0 actions, technically making its motion slightly jerky, though this is not noticeable. When attacking it initially uses type 3 actions, allowing it to move smoothly through the air and react quickly, but when falling or stunned it uses type 2 actions. (All four actions involve falling.)
Keen 4
#Sitting
%patch $322AC [$0000W]
#Sneaking
%patch $322CC [$0000W]
%patch $322EA [$0000W]
%patch $32308 [$0000W]
%patch $32326 [$0000W]
%patch $32344 [$0000W]
%patch $32362 [$0000W]
#Mimrock jumping
%patch $32380 [$0003W]
%patch $3239E [$0003W]
%patch $323BC [$0002W]
%patch $323DA [$0002W]
#Stunned Mimrock in air
%patch $323F8 [$0002W]
#Stunned Mimrock on ground
%patch $32416 [$0002W]
Deprotect and stick to ground
The Mimrock uses the stick-to-ground variable when sitting and sneaking since those frames require it to move on slopes.
Keen 4
#Sitting
%patch $322B0 [$0000W $0001W]
#Sneaking
%patch $322CE [$0000W $0001W]
%patch $322EC [$0000W $0001W]
%patch $3230A [$0000W $0001W]
%patch $32328 [$0000W $0001W]
%patch $32346 [$0000W $0001W]
%patch $32364 [$0000W $0001W]
#Attacking
%patch $32382 [$0000W $0000W]
%patch $323A0 [$0000W $0000W]
%patch $323BE [$0000W $0000W]
%patch $323DC [$0000W $0000W]
#Stunned in air
%patch $323FA [$0000W $0000W]
#Stunned on ground
%patch $32418 [$0000W $0000W]
Sprite spawn code
In the initiation code notice the Mimrock cache being set ($C7 $06 $CB61W $0001W.)
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 Mimrock always starts the level moving down. (Odd, it has no reason to.) $47 $0C $xxxxW is the vertical direction the sprite starts moving in, either $0001W (Facing down), $FFFFW (Facing up) or $0000W (Neither, never used.)
Keen 4
#Location of initiation code
%patch $EEA9 [$02D1W] #Mimrock (At $EBC1)
#Mimrock Initiation code
%patch $EBC1 $FF $76 $FC $57 $9A {$11A20447RL} $83 $C4 $04 $C7 $06 $CB61W
$0001W $E9 $0227W
#Mimrock Spawning code
%patch $11E67 $55 $8B $EC $33 $C0 $50 $9A $06BD1E11RL $83 $C4 $02 $8B $1E
$D8 $A7 $C7 $07 [$0013W] $C7 $47 $02 [$0001W] $C7 $47 $20 [$0003W]
$8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B $46 $08 $D3 $E0 $05
[$FF30W] $89 $47 $0C $B8 [$0001W] $89 $47 $0E $89 $47 $10 $B8 [$343AW]
$50 $53 $9A $09DC118CRL $83 $C4 $04 $5D $CB