Patch:Shikadi Mine

From KeenWiki
Jump to navigation Jump to search

Shikadi Mines are oblong black enemies found in Keen 5. They are notable for being indestructible and following Keen, detonating when close enough to produce a hail of fragments. Mine also relate to the Q.E.D, as a Shikadi Mine fragment is needed to break it and win the game.


Sprite Type

Shikadi Mines use sprite type 10 which is used only by the Shikadi Mine and doesn't affect anything else. Their fragments use a different and as yet unknown sprite type.

Keen 5

#Shikadi Mine's sprite type
%patch $11C56 $0A #Mines placed in level

Sprite Activity

Shikadi Mines have sprite activity 1, being active only when on screen.

Keen 5

#Shikadi Mine's sprite activity
%patch $11C5B $01 #Normal activity

Sprite Actions

The Shikadi Mine is placed in the level changing directions, which is uses to immediately track Keen. It will then go to sitting. When sitting its next action is determined in its code, not action and occurs after a pause. After sitting it goes to its movement sequence, which will go to its direction changing action again.

The Mine will detonate under three circumstances, Keen is close vertically, Keen is close horizontally, or Keen touches the Shikadi Mine. (The third condition is used when the Shikadi Mine is not actively detecting Keen, such as when it is changing direction.) A detonating Mine produces six fragments that move away as speed. The detonation sequence is six actions long. Shikadi Mine fragments quickly vanish.

Actions:
$2608W #Shikadi Mine sit
$2626W #Shikadi Mine move
$2644W #Shikadi Mine change direction
$2662W #Shikadi Mine detonate 1
$2680W #Shikadi Mine detonate 2
$269EW #Shikadi Mine detonate 3
$26BCW #Shikadi Mine detonate 4
$26DAW #Shikadi Mine detonate 5
$26F8W #Shikadi Mine detonate 6
$2716W #Shikadi Mine fragments

Keen 5

#Spawn Mine
%patch $11C82 {$2644W} #Shikadi Mine change direction

#After sitting
%patch $1205B {$2626W} #Mine move

#While sitting
%patch $32964 {$0000W} #Nothing

#While moving
%patch $32982 {$2644W} #Shikadi Mine change direction

#While changing direction
%patch $329A0 {$2608W} #Shikadi Mine sit

#When in-range
%patch $11FF5 {$2662W} #Mine detonate (Touches Keen)
%patch $12187 {$2662W} #Shikadi Mine detonate (When near Keen vertically)
%patch $122A6 {$2662W} #Shikadi Mine detonate (When near Keen horizontally)

#Spawn fragment when detonating
%patch $1240C {$2716W} #Shikadi Mine fragments (When Mine explodes)
%patch $1244F {$2716W} #Shikadi Mine fragments (When Mine explodes)
%patch $12490 {$2716W} #Shikadi Mine fragments (When Mine explodes)
%patch $124D6 {$2716W} #Shikadi Mine fragments (When Mine explodes)
%patch $12509 {$2716W} #Shikadi Mine fragments (When Mine explodes)
%patch $1253F {$2716W} #Shikadi Mine fragments (When Mine explodes)

#While detonating
%patch $329BE {$2680W} #Shikadi Mine detonate
%patch $329DC {$269EW} #Shikadi Mine detonate
%patch $329FA {$26BCW} #Shikadi Mine detonate
%patch $32A18 {$26DAW} #Shikadi Mine detonate
%patch $32A36 {$26F8W} #Shikadi Mine detonate
%patch $32A54 {$0000W} #Shikadi Mine detonate

#Fragment behavior
%patch $32A72 {$0000W} #Shikadi Mine fragments


Sprite Behavior

The Shikadi Mine has four behaviors. The first is sitting; this is used only when the Shikadi Mine is sitting. The second behavior is used by the moving Shikadi Mine only and moves the Shikadi Mine through the air. The third is used when changing directions to get closer to Keen. Finally the fourth destroys the Shikadi Mine and produces its fragments. This is used by the fourth frame of the detonating Shikadi Mine only. Finally the Shikadi Mine fragments themselves use a generic 'fall through the air' behavior.

Behaviors:
$11C4036ARL #Shikadi Mine sit
$11C40507RL #Shikadi Mine move
$11C40626RL #Shikadi Mine change directions
$11C40783RL #Shikadi Mine explode

Keen 5

#Shikadi Mine sit
%patch $32958 $11C4036ARL #Shikadi Mine sit

#Shikadi Mine move
%patch $32976 $11C40507RL #Shikadi Mine move

#Shikadi Mine 
%patch $32994 $11C40626RL #Shikadi Mine change directions

#Shikadi Mine explode
%patch $329B2 $00000000L  #Nothing (Warning animations)
%patch $329D0 $00000000L  #Nothing
%patch $329EE $00000000L  #Nothing
%patch $32A0C $11C40783RL #Shikadi Mine explode
%patch $32A2A $00000000L  #Nothing
%patch $32A48 $00000000L  #Nothing

#Fragments
%patch $32A66 $090B1710RL #Fall


Seeking Keen

The Shikadi Mine can move in four directions to chase Keen. These consist of a pair of directions, one vertical, one horizontal. At least ONE must be zero in each direction or problems occur. Reversing all of the direction pairs will make the Mine avoid Keen, reversing only the first (Or second) two pairs will make the Mine's movements rather random and hard to predict.

Keen seeking

#Seek Keen up
%patch $11D84 $0000W #Horizontal
%patch $11D89 $FFFFW #Vertical

#Seek Keen right
%patch $11DB1 $0001W #Horizontal
%patch $11DB6 $0000W #Vertical

#Seek Keen down
%patch $11DDD $0000W #Horizontal
%patch $11DE2 $0001W #Vertical

#Seek Keen left
%patch $11DDD $0000W #Horizontal
%patch $11DE2 $0001W #Vertical


No fragments when Mine explodes

This patch makes the Shikadi Mine simply vanish when detonating, no Shikadi Mine fragments are produced.

Keen 5

#No fragments when Shikadi Mine explodes
%patch $12406 $5E $5D $CB


Speed

The Shikadi Mine's speeds are set in its code and cannot yet be patched. Its animation motion is unused. See also the 'seek Keen' section above for what makes the Mine chase Keen.

Animation motion

#Shikadi Mine sit
%patch $32954 [$0000W $0000W]

#Shikadi Mine move
%patch $32972 [$0000W $0000W]

#Shikadi Mine change directions
%patch $32990 [$0000W $0000W]

#Shikadi Mine detonate
%patch $329AE [$0000W $0000W]
%patch $329CC [$0000W $0000W]
%patch $329EA [$0000W $0000W]
%patch $32A08 [$0000W $0000W]
%patch $32A26 [$0000W $0000W]
%patch $32A44 [$0000W $0000W]

#Fragments
%patch $32A62 [$0000W $0000W]


Stop Mine moving

This patch makes the Mine sit perfectly still at all times.

Stop Mine moving

#Stop Mine moving
%patch $11D1B $90 $90


Sprite Collision

The Mine's collision is quite simple and it what lets it explode if Keen touches it quickly. If its collision is removed or replaced with a generic lethal one it is less dangerous.


Collision values

The Shikadi Mine uses its own special collision for everything except after it has exploded, when it uses a generic 'kill Keen and block his shots' collision. Notice however that the Shikadi Mine fragments have their own special collision, one that can destroy the Q.E.D and win the game. If this is changed the game may become unwinnable.

Keen 5 collision values

#Shikadi Mine sit
%patch $3295C $11C4043ERL #Shikadi mine

#Shikadi Mine move
%patch $3297A $11C4043ERL #Shikadi mine

#Shikadi Mine change direction
%patch $32998 $11C4043ERL #Shikadi mine

#Shikadi Mine explode
%patch $329B6 $11C4043ERL #Shikadi mine
%patch $329D4 $11C4043ERL #Shikadi mine
%patch $329F2 $11C4043ERL #Shikadi mine
%patch $32A10 $11C4043ERL #Shikadi mine (Explodes here)
%patch $32A2E $11C40D61RL #Kill and block shots
%patch $32A4C $11C40D61RL #Kill and block shots

#Shikadi Mine fragments
%patch $32A6A $11C40456RL #Shikadi mine fragments (Destroys Q.E.D)


Collision codes

The only thing that the moving Shikadi Mine reacts to is Keen's shot, destroying it. (The Mine is actually safe to touch until its detonation sequence.)

The exploding Mine is similar except it reacts also to Keen, killing him on contact.

Moving Mine collision

#Moving Mine collision code
%patch $1207E $55 $8B $EC $56 $8B $76 $08 $83 $3C [$03] {$75} $09 $56 $9A $0CCB10B3RL
                      $83 $C4 $02 $5E $5D $CB

Exploding Mine collision

#Exploding Mine collision code
%patch $129A1 $55 $8B $EC $56 $8B $76 $08 $83 $3C [$03] {$75} $0C $56 $9A $0CCB10B3RL
              $83 $C4 $02 $5E $5D $CB $83 $3C [$02] {$75} $05 $9A $0AAF1517RL
                      $5E $5D $CB


Mine Fragment collision code

This is the Shikadi Mine Fragment's collision, it wins the game. On the first line Keen's shot is checked for; if found the Fragment blocks it. On the third line Keen is searched for, if found the 'kill Keen' code is run.

On the fourth line the QED's type is checked for. If a Fragment hits the QED it will win the game (Or if not in the QED level, smash a fuse and win the level.) The first few lines produce four smashed fuse sprites at different locations in a square pattern.

On line 8 the QED's tiles are replaced in two chunks. Each calls a 2x4 chunk of tiles copied from 0x0 and 0x4 placed at Bx10 and Dx10 in the level. After that the QED sprite is erased and the 'Fuse\QED bust' code called to win the level or game.

Mine Fragment Collision

#Mine fragment collision
%patch $12096 $55 $8B $EC $56 $8B $76 $08 $83 $3C [$03] {$75} $0C $56 $9A $0CCB10B3RL
                      $83 $C4 $02 $5E $5D $CB
                      $83 $3C [$02] {$75} $08 $9A $0AAF1517RL     $5E $5D $CB
                                  $83 $3C [$19] {$74} $03 $E9 $0081W  $FF $74 [$2E]
              $FF $74 [$2C] $9A $0F920628RL     $83 $C4 $04 $FF $74 [$2E] $FF $74
              [$30] $9A $0F920628RL     $83 $C4 $04 $FF $74 [$32] $FF $74 [$2C] $9A
              $0F920628RL     $83 $C4 $04 $FF $74 [$32] $FF $74 [$30] $9A $0F920628RL
                  $83 $C4 $04 $B8 [$0002W]  $50 $B8 [$0004W]  $50 $B8 [$000BW] 
              $50 $B8 [$0010W]  $50 $33 $C0 $50 $50 $9A $174E0D75RL     $83 $C4
              $0C $B8 [$0002W]  $50 $B8 [$0004W]  $50 $B8 [$000DW]  $50 $B8 [$0010W] 
              $50 $33 $C0 $50 $B8 [$0004W]  $50 $9A $174E0D75RL     $83 $C4 $0C
              $9A $0F920677RL     $56 $9A $06B91E47RL     $83 $C4 $02 $5E $5D
              $CB


Animations

The Shikadi Mine's animations are simple, yet complex. The Mine itself is a single animation for all of its actions until it detonates. Then it uses two different animations as it prepares to explode followed by two more as it explodes. Mine fragments use a single animation. The animation speeds of the detonation sequence control how long Keen has to escape a detonating Mine.

The Mine's eye is a secondary animation and it works in a poorly understood manner. See the 'sprite positioning' section below.

Keen 5

#Cache
%patch $31A38 [$017AW] #Mine cache start
%patch $31A8C [$0180W] #Cache end


#Shikadi Mine eye animation:
%patch $1257A [$017BW]

#Shikadi mine sit
%patch $32948 $017AW $017AW #Shikadi mine
%patch $32952 $0008W        #Reaction speed

#Shikadi mine move
%patch $32966 $017AW $017AW #Shikadi mine
%patch $32970 $0000W        #Wait

#Shikadi mine change directions
%patch $32984 $017AW $017AW #Shikadi mine
%patch $3298E $0000W        #Wait

#Shikadi mine explode
%patch $329A2 $017CW $017CW
%patch $329AC $000AW        #Animation speed
%patch $329C0 $017DW $017DW
%patch $329CA $000AW        #Animation speed
%patch $329DE $017CW $017CW
%patch $329E8 $000AW        #Animation speed
%patch $329FC $017DW $017DW
%patch $32A06 $000AW        #Animation speed
%patch $32A1A $017EW $017EW #Shikadi mine explodes here
%patch $32A24 $0014W        #Animation speed
%patch $32A38 $017FW $017FW
%patch $32A42 $0014W        #Animation speed

#Mine fragments
%patch $32A56 $0180W $0180W
%patch $32A60 $0008W        #Animation speed


Only the Mine's eye appears

This patch removes the 'primary' Mine animations, leaving only the Mine's eye animation. It may cause some problems. Notice also that the Mine's primary animation still matters, it must be cached and determines the eye positions (See section below.) Setting it to say, Keen's standing frame works well.

Only the Mine's eye appears

#Only the Mine's eye appears
%patch $12562 $75


Exploding Mine leaves empty Mine animation behind

This patch makes it such that when the Mine explodes, its explosion frames appear behind an eyeless moving Mine frame, which is left suspended in the air after the Mine has exploded, unmoving and inactive. (Not deadly.) It may have unusual side effects.

Exploding Mine leaves empty Mine animation behind

#Exploding Mine leaves empty Mine animation behind
%patch $12567 $00


Mine's eye remains after it explodes

This patch is similar to the above, except it is the Mine's eye that is left behind after it explodes.

Mine's eye remains after it explodes

#Mine's eye remains after it explodes
%patch $1218F $90 $90 $90 $90 $90
%patch $122AE $90 $90 $90 $90 $90


Don't show Mine's eye

This patch removes the Mine's eye. Alternatively the Mine's tile interactions can be changed to $090B17B5RL, freeing up $1254E-$1259B.

Don't show Mine's eye

#Don't show Mine's eye
%patch $12572 $5E $5D $CB


Sounds

The Shikadi Mine makes two identical sounds, the first when Keen triggers its exploding and the second when it actually detonates. If the player listens carefully he can hear this '1-2' pattern. It is possible that the developers intended to have the Mine make an 'activated' sound to warn the player before detonating.

Keen 5

#Shikadi Mine explode sounds
%patch $11FE7 $05     #When activated
%patch $123CB $05     #When exploding

#Don't play Shikadi Mine explode sounds
%patch $11FE6 $EB $0A #When activated
%patch $123CA $EB $0A #When exploding


Sprite positioning

The Mine spawns 15 pixels higher than where it is placed. This is important as it 'aligns' the Mine with tiles so that it can seek Keen correctly. If it is otherwise the Mine will need to 'correct' itself when placed, which takes time.

Keen 5

#Spawn height
%patch $11C72 $FF0FW #15 pixels up


Mine's eye positions

The Mine's eye's position is important. There are several positions that the eye sits in when the Mine is moving in various directions (Or turning.) While the eye is moving between positions the Mine cannot move, if something is patched wrong and the eye cannot move to a position, the Mine will freeze.

The main thing to remember is that there are two sets of three positions, left-mid-right and up-mid-down. The middle value of both these triplets must be the the exact mid value of the two other values. These mid values must then be used for the horizontal and vertical turning positions respectively. (and should, but not must, be used for the initial eye positions.)

An example triplet is the left-mid-right triplet. ($0050 + $0150) / 2 = $00D0. The positions are from the top left of the Mine's primary animation, in pixels. The less an eye moves, the faster the Mine turns. It is often simple to simply halve, double, add $10 to all values instead of starting from scratch when altering eye movement amounts.

Keen 5

#Initial: (Don't actually have to be midpoints, but are by default)
%patch $11C7A [$0100W] #Horizontal (Is l/r midpoint)
%patch $11C7F [$00D0W] #Vertical (Is u/d midpoint)

#Turning (Eye moves here before moving to new position, must be midpoints)
%patch $121A3 [$0100W] #Horizontal (Is l/r midpoint)
%patch $121A8 [$00D0W] #Vertical (Is u/d midpoint)

#When chasing Keen horizontally
%patch $122D5 [$0080W] #Moving left
%patch $122DA [$0100W] #Midpoint, l/r
%patch $122DF [$0180W] #Moving right

#When chasing Keen vertically
%patch $122F7 [$0050W] #Moving up
%patch $122FE [$00D0W] #Midpoint, u/d
%patch $12305 [$0150W] #Moving down


Sprite-tile interaction

The Shikadi Mine has three tile collisions, The main collision is used for the Mine sitting, moving and turning. This is responsible for drawing its eye. When detonating it uses a generic 'blocked by solid tiles' collision. Finally the Mine fragments have their own special collision allowing them to bounce off of solid tiles.

Keen 5

#Shikadi Mine sit
%patch $32960 $11C4090ERL #Shikadi Mine

#Shikadi Mine move
%patch $3297E $11C4090ERL #Shikadi Mine

#Shikadi Mine changing direction
%patch $3299C $11C4090ERL #Shikadi Mine

#Detonate
%patch $329BA $090B17B5RL #Solid
%patch $329D8 $090B17B5RL #Solid
%patch $329F6 $090B17B5RL #Solid
%patch $32A14 $090B17B5RL #Solid
%patch $32A32 $090B17B5RL #Solid
%patch $32A50 $090B17B5RL #Solid

#Fragments
%patch $32A6E $0F920119RL #Explosion fragments


Action type

The Mine uses type 2 for all its moving actions, since it must respond instantly to Keen and move smoothly. This is used by the Mine fragments as well. The exploding Mine uses type 0, since all it has to do is sit there.

Keen 5 Motion

#Shikadi Mine sit
%patch $3294C [$0002W]

#Shikadi Mine move
%patch $3296A [$0002W]

#Shikadi Mine change direction
%patch $32988 [$0002W]

#Shikadi Mine explode
%patch $329A6 [$0000W]
%patch $329C4 [$0000W]
%patch $329E2 [$0000W]
%patch $32A00 [$0000W]
%patch $32A1E [$0000W]
%patch $32A3C [$0000W]

#Shikadi Mine Fragments
%patch $32A5A [$0002W]


Deprotect and stick to ground

The Shikadi Mine uses values of 0 for both these parameters as it does not need either of them.

Keen 5 Change Motion

#Shikadi Mine sit
%patch $3294E $0000W $0000W

#Shikadi Mine move
%patch $3296C $0000W $0000W

#Shikadi Mine change direction
%patch $3298A $0000W $0000W

#Shikadi Mine explode
%patch $329A8 $0000W $0000W
%patch $329C6 $0000W $0000W
%patch $329E4 $0000W $0000W
%patch $32A02 $0000W $0000W
%patch $32A20 $0000W $0000W
%patch $32A3E $0000W $0000W

#Shikadi Mine Fragments
%patch $32A5C $0000W $0000W


Sprite spawn code

Only partial spawning code is available for the Mine. Notice there are three types of Mine, one for each difficulty. The cache is set in $C7 $06 $C28BW $0001W.

The last blue highlighted value is the sprite action the sprite uses as it proceeds to act in-level. $C7 $47 $02 $xxxxW sets the sprite activity, $C7 $47 $06 $xxxxW sets the clipping, $C7 $07 $xxxxW sets the sprite type, 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 Mine is unusual in that after it is spawned there is code that sets up its initial direction and eye position, in effect initializing it to move.

Keen 5

#Location of initiation code
%patch $F4D2 [$21CW]  #Easy Mine (At $EF6C)
%patch $F4D4 [$212W]  #Normal Mine (At $EF62)
%patch $F4D6 [$208W]  #Hard Mine (At $EF58)

#Mine Initiation code
%patch $EF58 $83 $3E {$6F6CW}  [$03] {$7D} $03 $E9 $0445W $83 $3E {$6F6CW}  [$02] {$7D}
             $03 $E9 $043BW $57 $56 $9A $11C40001RL    $83 $C4 $04 $C7 $06
             $C28BW  $0001W  $E9 $0428W

#Mine spawning code
%patch $11C41 $55 $8B $EC $56 $33 $C0 $50 $9A $06B91DCDRL     $83 $C4 $02 $8B
              $1E $40 $9E $C7 $07 [$000AW]  $C7 $47 $02 [$0001W]  $C7 $47 $06 [$0000W]
                  $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B $46 $08 $D3 $E0
              $05 [$FF0FW]  $89 $47 $0C $C7 $47 $40 [$0100W]  $C7 $47 $42 [$00D0W]
              $B8 [$2644W]  $50 $53 $9A $090B11C4RL     $83 $C4 $04 $8B $1E $40
              $9E $C7 $47 $16 [$0100W]  $33 $F6 $EB $12 $56 $FF $36 $40 $9E $90
              $0E $E8 $0095W  $83 $C4 $04 $0B $C0 $75 $06 $46 $83 $FE $03 $7E
              $E9 $5E $5D $CB


Walk: Bad dir

This error occurs when a Mine moves in an 'incorrect' direction. This should only occur if the default Shikadi Mine code has been tampered with somehow or another patch is massively incorrect. It causes the game to cash with an error message.

Shikadi Mine error

#Keen 5 :
%patch $11E23  [$31A4W] #Text called from
%patch $334E4 "Walk: Bad dir" $00