Patch:Underwater mines

From KeenWiki
(Redirected from Patch:Mines)
Jump to navigation Jump to search

This page covers patches relating to the Underwater Mines in Keen 4. They are only found in the Well of Wishes, though they could be placed in other levels. They self destruct when they hit Keen.


Sprite Type

Underwater Mines use sprite type 32 which is used only by the Underwater Mines and doesn't affect anything else.

Keen 4

#Underwater Mines sprite type
%patch $12720 $20 #Mines placed in level


Sprite Actions

Underwater Mines have only one action, to move. Moving mines continue to move. When Keen touches them they enter a two stage destruction loop before vanishing.

Actions:
$3890W #Mine moving
$38AEW #Mine explodes 1
$38CCW #Mine explodes 2

Keen 4

#Underwater Mines placed in-level
%patch $1278C [$3890W]

#Moving Mine
%patch $3271C [$3890W]

#When touched by Keen
%patch $127B3 [$38AEW]

#Exploding sequence
%patch $3273A [$38CCW] #Mine explodes 1
%patch $32758 [$0000W] #Mine explodes 2 (Disappear)


Sprite Behavior

The Underwater Mines do not have their own unique behavior, instead they behave like moving Platforms. When destructing they have no behavior at all.

Behaviors:
$10800D44RL #Moving airboard

Keen 4

#Move
%patch $32710 {$10800D44RL} #Moving airboard

#Exploding
%patch $3272E {$00000000L}  #Nothing
%patch $3274C {$00000000L}  #Nothing


Speed

As noted above, Mines use the Platform behavior, and as such the only ways to change their speed is to give them a new behavior or alter the speed of all moving Platforms. The Mine's animation motion does not count at all while it is using the moving Platform behavior.

Animation motion

#Normal
%patch $3270C $0000W $0000W #Speed 

#Explodes
%patch $3272A $0000W $0000W #Speed 1
%patch $32748 $0000W $0000W #Speed 2 (Disappear)


Sprite Collision

The Underwater Mines collision is simple, when Keen hits it, it explodes and kills him.


Collision values

The Underwater Mines uses its own collision which, when Keen hits it, transforms the Mine into an exploding Mine and kills Keen. Exploding Mines have no collision. (Are harmless, but Keen is already dead by then.)

Keen 4 collision values

%patch $32714 $11A20D86RL #Moving

%patch $32732 $00000000L #Exploding 1
%patch $32750 $00000000L #Exploding 2


Collision code

This is the complete code for the Mine's sprite collision. It checks for Keen's sprite type and, if found, does several things. Firstly it changes its action to that of an exploding Mine. Secondly it plays sound $25 and finally it runs the 'kill Keen' code.

Keen 4 collision code

#Underwater Mine collision code
%patch $127A6 $55 $8B $EC $56 $8B $76 $08 $83 $3C [$02] {$75} $20 $B8 [$38AEW]  $50
              $FF $76 $06 $9A $09DC120ARL     $83 $C4 $04 $B8 [$0025W]  $50 $9A
              $187409F1RL     $83 $C4 $02 $9A $0B8013E9RL     $5E $5D $CB


Animations

There is little to say about Underwater Mines animations, there are three, one for the moving Mines and one for each of the two exploding Mine frames. All actions use the same animation no matter what direction they move in. The animation speeds of the exploding mine control how long it is visible for.

Keen 4

#Cache
%patch $30714 [$01B8W] #Underwater Mines Cache start
%patch $3075E [$01BAW] #Underwater Mines cache end

#Moving Mine
%patch $32700 $01B8W $01B8W
%patch $3270A $000AW        #Animation speed

#Mine explodes
%patch $3271E $01B9W $01B9W
%patch $32728 $001EW        #Animation speed
%patch $3273C $01BAW $01BAW
%patch $32746 $001EW        #Animation speed (Vanishes)


Sounds

The only sound the Mines make is when they detonate. This sound can be blocked.

Keen 4

#Mine detonation sound
%patch $127C2 $25

#Don't play detonation sound
%patch $127C1 $9A $0B8013E9RL $5E $5D $CB


Clipping and foreground

The Underwater Mine's clipping cannot currently be patched. it has a foreground value of 0, appearing behind all fore tiles. This is helpful since it must bump into solid ground occasionally.

Keen 4

#Mine Foreground variable
%patch $1272A $0000W


Sprite-tile interaction

The Mine uses a generic 'appear' tile collision and will simply bump into tiles unless prevented from doing so by 'B' sprites, like Moving Platforms are. This can be used to make Mines that are sitting still.

Keen 4

%patch $32718 $09DC176ERL #Floating

%patch $32736 $09DC176ERL #Exploding
%patch $32754 $09DC176ERL #Exploding


Action type

The Mine uses action type 2 when moving, allowing it to move smoothly and respond quickly, just like the Moving Platform. When exploding it uses type 0, as it doesn't need to move.

Keen 4

%patch $32704 {$0002W} #Mine move

%patch $32722 {$0000W} #Mine explodes 1
%patch $32740 {$0000W} #Mine explodes 2


Deprotect and stick to ground

The Underwater Mine floats, so doesn't need a stick to ground variable. Both values are 0 for all three of its actions.

Keen 4

#Moving
%patch $32706 [$0000W $0000W]

#Exploding
%patch $32724 [$0000W $0000W] #Exploding 1
%patch $32742 [$0000W $0000W] #Exploding 2


Sprite spawn code

Only partial spawn code is available for the underwater Mines. All four types of mine use the same initiation code. In the initiation code notice the Mine cache being set ($C7 $06 $CB7FW $0001W.) The highlighted blue value defines the first infoplane value that is a mine. (This is $FFFFW - $FFBBW = $44 or 68.) This is part of what differentiates the different mine spawns from each other. Note that there are no up Mines in the default Keen 4 game, so their icon is absent even though it still works.

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; in this case 'always active', so Mines will keep moving even when offscreen. $C7 $07 $xxxxW sets the sprite type, and $C7 $20 $xxxxW sets the foreground value. The Mines' initial directions are read off a list at $11A20 + $0D7EW = $$1279E and the list is $03 + 1 = 4 items long. Each entry is for a line of code following the list. (For example the first entry is for $11A20 + $0D2DW = $1274D.)

The next four lines control initial irection. $C7 $47 $0E $xxxxW is the horizontal direction the sprite 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.

Keen 4

#Location of initiation code
%patch $EF0D [$04CAW] #Up Mine (At $EDBA)
%patch $EF0F [$04CAW] #Right Mine (At $EDBA)
%patch $EF11 [$04CAW] #Down Mine (At $EDBA)
%patch $EF13 [$04CAW] #Left Mine (At $EDBA)

#Underwater Mine Initiation code
%patch $EDBA $8B $46 $F8 $05 [$FFBBW]  $50 $FF $76 $FC $57 $9A {$11A20CECRL}
             $83 $C4 $06 $C7 $06 $CB7FW  $0001W  $EB $28

#Underwater Mine spawning code
%patch $1270C $55 $8B $EC $33 $C0 $50 $9A $06BD1E11RL     $83 $C4 $02 $8B $1E
              $D8 $A7 $C7 $07 [$0020W]  $C7 $47 $02 [$0002W]  $C7 $47 $20 [$0000W]
              $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B $46 $08 $D3 $E0 $89
              $47 $0C $8B $5E $0A $83 $FB [$03] $77 $45 $D1 $E3 $2E $FF $A7 [$0D7EW]
                  $8B $1E $D8 $A7 $C7 $47 $0E [$0000W]  $C7 $47 $10 [$FFFFW]  $EB
              $2E $8B $1E $D8 $A7 $C7 $47 $0E [$0001W]  $C7 $47 $10 [$0000W]  $EB
              $1E $8B $1E $D8 $A7 $C7 $47 $0E [$0000W]  $C7 $47 $10 [$0001W]  $EB
              $0E $8B $1E $D8 $A7 $C7 $47 $0E [$FFFFW]  $C7 $47 $10 [$0000W]  $B8
              [$3890W]  $50 $FF $36 $D8 $A7 $9A $09DC118CRL     $83 $C4 $04 $5D
              $CB

#Direction list
%patch $1279E [$0D2DW] #Up
              [$0D3DW] #Right
              [$0D4DW] #Down
              [$0D5DW] #Left