Patch:Fuses

From KeenWiki
Jump to: navigation, search

This page relates to patches that involve the Keen 5 fuses. When all four fuses are broken, the main elevator shaft will open for Keen to get to the Q.E.D.

Fuses are a tile-based phenomenon; when Keen pogos high onto a specific tile property the fuse code is activated, which involves a sound, some tile replacement, a window with a message and the winning and exiting of the level with a special fuse value. Level values are from memory and are 28 + [2 * level number]. Patches that relate to the fuse as a sprite are actually Q.E.D. patches.

There is a special Korath fuse, which, if it is broken, a special ending plays when Keen wins the game. See also Patch:Elevators and Patch:Korath.


Fuse levels

These are the levels which, when completed, activate an elevator. Fuses are not necessary in these levels, if the level is completed by any means, the elevator will be activated. However by default, breaking fuses is the means this is done. The variable here is the 'level complete' value, starting at $6F1C for level 0. The value for any level can be found on the Patch:Game stats page or calculated by adding 2 * the level number to level 0's value.

Patch: Keen 5
#Levels elevator activating fuses are found:
#NOTE: Levels just need to be finished, the fuse does not need to be broken!
%patch $F470 $6F24
#Level 4 ($6F1C + 8)
%patch $F477 $6F28
#Level 6 ($6F1C + 12)
%patch $F47E $6F2C
#Level 8 ($6F1C + 16)
%patch $F485 $6F30
#Level 10 ($6F1C + 20)


Korath fuse

To get the special ending, the game checks the "completed" value for the Korath level. If it is 15 (special fuse value), then it plays the special ending, otherwise the normal one. In the patches below, 0 is incomplete and 1 is normal complete. It pays off to know something about Patch:Jump conditions.

Patch: Keen 5
#Korath level
%patch $EC31 $36
#Level 13 (28 + (2 * 13) = 36


Get special ending by just completing Korath level

This patch alters things so that the special ending of the game plays if the player has completed the Korath level in nay way, wither by breaking the fuse or just exiting.

Patch: Keen 5
#You get the Korath fuse ending just for completing Korath, fuse or not
%patch $EC33 $01 $72 %patch $EC31 $36
#Level 13 (28 + (2 * 13) = 36)

The Korath fuse is also special. It can only be broken with a very high pogo jump, that is, only on easy by default. The only way to fix this is to alter the fuse to not be special, or to alter Keen's pogo height so that it is the same on all three difficulties.


Level Korath message appears in

The level that the Korath fuse text appears in is separate from that checked for the game ending, though by default they are the same.

Patch: Keen 5
#Level that causes Korath text to be read:
%patch $F8AC $0D $75


Breaking fuses and tile replacement

When a fuse is broken, the first thing that happens is the fuse tiles are replaced and a sound is played. When all fuses in a level are broken, a window will appear and the level will be won. It is impossible to patch where the replacement fuse tiles come from, it is always (0,0) in the level, and both background AND foreground tiles are replaced.

Patch: Keen 5
#When fuse breaks, don't have...
%patch $6A97 $90 $90 $90 $90 $90
#Fuse windows
%patch $CACA $90 $90 $90 $90 $90
#Sound or sparks
%patch $FF81 $90 $90 $90 $90 $90
#Sparks
%patch $CAD8 $90 $90 $90 $90 $90
#Winning the level (And thus opening elevator shaft)
#When fuse breaks replace:
%patch $CADE $02 $00
#Two rows
%patch $CAE2 $01 $00
#of 1 tile
#(Back AND fore, from 0,0 in level)
#Fuses do not smash, they are "pogo slippery" instead:
%patch $CAA7 $CB


Fuse breaking tile replacement code

This is the complete fuse code, as well as a patch that reduces the fuse code to simple tile replacement (Do not win the level or us sparks and breaking sound.) It relates somewhat to the patches above.

Patch: Keen 5
#Complete fuse code
%patch $CAA7 $55 $8B $EC $83 $EC $04 $56 $57 $8B $76 $06 $8B $7E $08 $A1 $0C $13 $8B $16 $0A $13 $89 $46 $FE $89 $56 $FC $8B $46 $FC $BA $0004W $57 $56 $9A $0F920628RL $83 $C4 $04 $FF $0E $6F5EW $75 $05 $9A $0F920677RL $B8 $0002W $50 $B8 $0001W $50 $57 $56
#Replace 2 rows of 1 tile
$50 $16 $8D $46 $FC $50 $9A $174E0F25RL $83 $C4 $0E $5F $5E $8B $E5 $5D $CB


Fuses only replace tiles, no sound or level winning

This patch removes the fuse breaking sound, fuse window and winning the level. When fuses are broken they simply replace tiles. This also means any number of fuses can be broken in a level.

Patch: Keen 5
#Fuses only replace tiles, they don't make sounds or exit the level
%patch $CAA7 $55 $8B $EC $83 $EC $04 $56 $57 $8B $76 $06 $8B $7E $08 $A1 $0C $13 $8B $16 $0A $13 $89 $46 $FE $89 $56 $FC $8B $46 $FC $B8 $0002W
#Replace 2 rows of 1 tile
$50 $B8 $0001W $50 $57 $56 $50 $16 $8D $46 $FC $50 $9A $174E0F25RL $83 $C4 $0E $5F $5E $8B $E5 $5D $CB


Sounds

There are two sounds relating to the Fuses; the first is the sound of the Fuses breaking and the second the sound made when the Fuse window appears. Both can be blocked.

Patch: Keen 5
#Fuse sounds
%patch $6A7A $0D
#Fuse smashed window appears sound
%patch $FF8A $34
#Fuse smash sound
#Don't play Fuse sounds
%patch $6A79 $EB $0A
#Fuse smashed window appears sound
%patch $FF89 $EB $0A
#Fuse smash sound


Fuses and pogo

By default the Korath fuse can only be broken with the highest of pogo bounces. This means on hard difficulty Keen cannot break the Korath fuse.

Patch: Keen 5
#Change Keen's pogo height so...
%patch $B97D $90 $90
#Keen cannot break Korath fuse even on hard
%patch $B97D $EB
#Keen can always break Korath fuse
#Cannot destroy any fuses with small pogo hops
#SIDE EFFECT: No broken fuse spark
%patch $FF48 $CB
#Fuses do not smash, they are "pogo slippery" instead:
%patch $CAA7 $CB


Fuse window

These patches relate to the fuse window specifically which appears after Keen has broken all the fuses in the level.


Window text

There are two fuse messages, which one appears depends on what level Keen is in at the time.

Patch: Keen 5
#Fuse texts:
%patch $F8B0 $18BBW
#Korath fuse text read from
%patch $F8BE $18E0W
#Normal fuse text read from
#Level that causes Korath text to be read:
%patch $F8AC $0D $75
#What Keen says when he breaks a fuse
%patch $31C20 "One of the four" $0A "machines protecting the" $0A "main elevator shaft--" $0A "toast!" $0A $00
#What Keen says when he breaks the secret fuse
%patch $31BFB "I wonder what that" $0A "fuse was for...." $0A $00


Only need to press one key to dismiss Fuse window

This patch removes the requirement to press any key twice to dismiss the Fuse message window. The second image is not displayed and the window is dismissed as soon as a key is pressed.

Patch: Keen 5
#Fuse window takes only one keypress to dismiss
%patch $F8D2 $9A $1F030ADFRL $83 $C4 $02 $9A $155A08A5RL $9A $155A0EDCRL $9A $13A014EARL $9A $06B9204ERL $5D $CB


Complete fuse window code

This is the compelte code for the fuse window. This displays an image and one of two messages depending on what level the player is in. When a key is pressed another image replaces the first and the window closes.

On the second and third lines the two images displayed are cached. (They are $005AW and $005BW.) On the fourth line the window's size is set. On line 5 the first image is displayed and on line 7 the current level is checked, at the end of lines 7 and 8 the first and second text calls are set.

On line 9 there is a pause of $001EW during which time the window cannot be cleared. After this a key can be pressed. On line 11 the second image replaces the first. (By default this is Keen's thumbs up.) Then there is another $001EW pause before the window can be dismissed. This is what the remainder of the code does.

Patch: Keen 5
#Complete fuse window code
%patch $F844 $55 $8B $EC $9A $196E0AFBRL $9A $13A014CARL $B8 $2B7BRW $8A $16 $EC $6F $8E $C0 $26 $08 $16 $005AW $8E $C0 $26 $08 $16 $005BW $33 $C0 $50 $9A $13A01848RL $83 $C4 $02 $9A $1E000995RL $B8 $0008W $50 $B8 $001AW $50 $9A $1A2B106ERL $83 $C4 $04 $83 $2E $99 $9B $30 $B8 $005AW $50 $FF $36 $46 $9E $A1 $9B $9B $03 $06 $99 $9B $50 $9A $1E000C75RL $83 $C4 $06 $83 $06 $9D $9B $0C $83 $3E $6F68W $0D $75 $0E $B8 $18BBW $50 $9A $1A2B0EBBRL $83 $C4 $02 $EB $0C $B8 $18E0W $50 $9A $1A2B0EBBRL $83 $C4 $02 $9A $1E000A97RL $B8 $001EW $50 $9A $1F030ADFRL $83 $C4 $02 $9A $155A08A5RL $9A $155A0EDCRL $B8 $005BW $50 $FF $36 $46 $9E $A1 $9B $9B $03 $06 $99 $9B $50 $9A $1E000C75RL $83 $C4 $06 $9A $1E000A97RL $B8 $001EW $50 $9A $1F030ADFRL $83 $C4 $02 $9A $155A08A5RL $9A $155A0EDCRL $9A $13A014EARL $9A $06B9204ERL $5D $CB


3/4 possible fuse messages

This patch alters the Fuse window code so that three or four unique Fuse messages are possible. This is done by using space more efficiently and removing the second the press key pause from the code. The patch here provides for three unique messages, but there is enough space to add a fourth with little difficulty.

The window code is by and large the same as the default window code above with the differences starting in line 7. Here two checks are made instead of one. (The additional check is whether the level is level 1.) This also necessitates reversing the jumps from $75 to $74. The end result is that level 1 displays the third message, level 13 the second and other levels the first. (The two specific levels can be changed, and with some ingenuity changed to a range of levels.)

Patch: Keen 5
#Complete fuse window code: 3 unique messages
%patch $F844 $55 $8B $EC $9A $196E0AFBRL $9A $13A014CARL $B8 $2B7BRW $8A $16 $EC $6F $8E $C0 $26 $08 $16 $005AW $8E $C0 $26 $08 $16 $005BW $33 $C0 $50 $9A $13A01848RL $83 $C4 $02 $9A $1E000995RL $B8 $0008W $50 $B8 $001AW $50 $9A $1A2B106ERL $83 $C4 $04 $83 $2E $99 $9B $30 $B8 $005AW $50 $FF $36 $46 $9E $A1 $9B $9B $03 $06 $99 $9B $50 $9A $1E000C75RL $83 $C4 $06 $83 $06 $9D $9B $0C $83 $3E $6F68W $01 $74 $11 $83 $3E $6F68W $0D $74 $05 $B8 $18E0W $EB $08 $B8 $18BBW $EB $03 $B8 $18E2W $50 $9A $1A2B0EBBRL $83 $C4 $02 $9A $1E000A97RL $B8 $001EW $50 $9A $1F030ADFRL $83 $C4 $02 $9A $155A08A5RL $9A $155A0EDCRL $B8 $005BW $50 $FF $36 $46 $9E $A1 $9B $9B $03 $06 $99 $9B $50 $9A $1E000C75RL $83 $C4 $06 $9A $1E000A97RL $9A $155A08A5RL $9A $155A0EDCRL $9A $13A014EARL $9A $06B9204ERL $5D $CB


Fuse level state code

This is the level state code for when Keen breaks a fuse. (That is level state $0E.) On the first line sound $0D is played and the 'mapon' variable is copied to another, unknown variable on line 2. Also on line 2 the 'player Y position' variable is set to $0E (What this does is mark the current level as completed via Fuse breaking.) Finally on the third line the fuse window code is called ($9A $0ED50AF4RL) and the current level variable is set to 0 (The map.) The level then restarts which sends Keen to the map.

Patch: Keen 5
%patch $6A79 $B8 $000DW  $50 $9A $196E09EFRL     $83 $C4 $02 $A1 $9E55W  $A3
             $9E2AW  $8B $1E $55 $9E $D1 $E3 $C7 $87 $6F1CW  $000EW  $9A
          $0ED50AF4RL    $C7 $06 $6F68W  $0000W  $E9 $00A7W


Keen needs to destroy multiple Q.E.D.s with health to win game

This patch can be found on the Q.E.D. page, it is affected by and affects the number of Fuses that need to be destroyed.


Q.E.D.\Fuse sprite brings up 4 messages to Keen when touched

This large and complex patch turns the Fuse\Q.E.D. into a 'contact point'; when Keen touches the sprite it brings up a text window which can contains any one of four different messages and images depending on what level Keen is in at the time. The patch is as follows with an explanation afterwards.

Patch: Keen 5
#Q.E.D\Fuse appears on all levels
%patch $F10C $90 $90
#Q.E.D\Fuse action - invisible
%patch $334C6 $FFFFW $FFFFW $0001W $00000000L $0008W $0000W $0000W $00000000L $0AAF1FB7RL $11C418CBRL $3186W
#Q.E.D\Fuse collision, if Keen touches not on level 15 play sound 3, do window, vanish
%patch $CAA7 $55 $8B $EC $56 $57 $8B $76 $06 $8B $7E $08 $83 $3D $02 $75 $22 $83 $3E $9E55W $0F $74 $1B $B8 $0003W $50 $9A $196E09EFRL $83 $C4 $02 $9A $06B9018BRL $9A $174E0D56RL $C7 $44 $1C $0000W $5F $5E $5D $CB
#Fuse window, 4 messages, cache 5 bitmaps
%patch $6D1B $55 $8B $EC $9A $196E0AFBRL $B8 $2B7BRW $8A $16 $EC $6F $8E $C0 $26 $08 $16 $002CW $8E $C0 $26 $08 $16 $002DW $8E $C0 $26 $08 $16 $002EW $8E $C0 $26 $08 $16 $002FW $8E $C0 $26 $08 $16 $005BW $33 $C0 $50 $9A $13A01848RL $83 $C4 $02 $9A $1E000995RL $B8 $0008W $50 $B8 $001AW $50 $9A $1A2B106ERL $83 $C4 $04 $83 $3E $6F68W $05 $75 $1C $83 $2E $99 $9B $30 $B8 $002EW $50 $FF $36 $46 $9E $A1 $9B $9B $03 $06 $99 $9B $50 $9A $1E000C75RL $EB $60 $83 $3E $6F68W $0B $75 $1C $83 $2E $99 $9B $30 $B8 $002CW $50 $FF $36 $46 $9E $A1 $9B $9B $03 $06 $99 $9B $50 $9A $1E000C75RL $EB $3D $83 $3E $6F68W $02 $75 $1C $83 $2E $99 $9B $30 $B8 $002FW $50 $FF $36 $46 $9E $A1 $9B $9B $03 $06 $99 $9B $50 $9A $1E000C75RL $EB $1A $83 $2E $99 $9B $30 $B8 $002DW $50 $FF $36 $46 $9E $A1 $9B $9B $03 $06 $99 $9B $50 %patch $6DEB $9A $1E000C75RL $83 $C4 $06 $83 $06 $9D $9B $0C $83 $3E $6F68W $05 $75 $0E $B8 $3766W $50 $9A $1A2B0EBBRL $83 $C4 $02 $EB $36 $83 $3E $6F68W $0B $75 $0E $B8 $37C1W $50 $9A $1A2B0EBBRL $83 $C4 $02 $EB $21 $83 $3E $6F68W $02 $75 $0E $B8 $37F8W $50 $9A $1A2B0EBBRL $83 $C4 $02 $EB $0C $B8 $18BBW $50 $9A $1A2B0EBBRL $83 $C4 $02 $9A $1E000A97RL $B8 $001EW $50 $9A $1F030ADFRL $83 $C4 $02 $9A $155A08A5RL $9A $155A0EDCRL $B8 $005BW $50 $FF $36 $46 $9E $A1 $9B $9B $03 $06 $99 $9B $50 $9A $1E000C75RL $83 $C4 $06 $9A $1E000A97RL $B8 $001EW $50 $9A $1F030ADFRL $83 $C4 $02 $9A $155A08A5RL $9A $155A0EDCRL $5D $CB
#Level 5
%patch $33AA6 "Princess Lindsey says:" $0A $0A "You won't be able to " $0A "defeat Mortimer with" $0A "your stunner alone!" $00
#Level 11
%patch $33B01 "Lt. Barker says:" $0A $0A "Beware of the" $0A "Krodacian Overlords!" $00
#Level 2
%patch $33B38 "Spot says:" $0A $0A "The Shikadi are" $0A "invincible while" $0A "climbing poles!" $00
#Any other level
%patch $31BFB "Oracle Janitor says:" $0A $0A "There's something" $0A "mysterious beneath the" $0A "giant crater." $00

The first section causes the Q.E.D. to spawn in all levels instead of just level 12. (By default the Fuse is not a sprite and does not spawn in non-Q.E.D. levels. This changes that.) A side effect is that if an exploded Shikadi Mine's fragment touches the contact point the Q.E.D. smash code will run and the game will be won.

The second section is the contact point's action. This makes it sit in the level doing nothing and waiting for Keen to touch it. In this patch it uses image -1, that is, it is invisible. This allows it to be placed in a level without needing a sprite image that needs to be cached. This also allows it to be an invisible contact point for Keen to walk into. This can be changed however and the action can use one of the Fuse\Q.E.D. explosion images ($011BW-$011DW) or another image entirely. The invisible nature of the sprite means that when testing in-game it can be hard to figure out where it is It should be placed at ground level where Keen can walk into it.

The third section is the contact point's sprite collision. ($0AAF1FB7RL in the sprite action which overwrites the Fuse counter code.) On the first line it checks for Keen's sprite type (See also Patch:Jump conditions.) It thus reacts only when Keen touches it (Again this can be changed.) On the second line it checks what level the paler is currently in. If the level is the Q.E.D. level (Here level $0F or 15.) then nothing will happen. (No message will be displayed; this prevents Keen from seeing a message and deleting the Q.E.D. instead of winning the game.) Otherwisesound $3A is played and the fuse window appears. This will cause the contact point to vanish (Its action is set to $0000W.) so the message only appears once per level playthrough. (Unless multiple contact points are placed in-level.)

As a side-effect of this Fuses are not counted; they cannot be used to open the main elevator shaft.

The fourth and largest section is the entire message window code. The first four lines cache bitmaps $002C-$002F and also bitmap $005B so that they can be displayed in the message windows later on. On line 5 the message window's size is set. (Here it is 8x1A.) Next different message images are selected by checking the current level $6F68W. Four different checks are made, 3 for specific levels (Levels 2, 5 and 12) each displaying a different bitmap image while the fourth image appears in any other levels.) It is a simple matter to change what levels a certain bitmap appears in and even make them appear on multiple levels. Notice that all four bitmaps referred to in these lines are the same as the four cached earlier. If one is changed then it's cache counterpart must be changed also.

After this is the second part of the fourth section. This displays a different text message for each of the specific levels. Notice that in this patch the text's level checks are exactly the same as for the bitmaps. This means that each unique bitmap will also have a unique image to go with it. (This does not have to be the case.) The $xxxxW pointers in blue correspond to calls to the message text.

The game then waits for the player to press a key. It waits $001EW ticks before switching the window image with that of Keen ($005B in this patch.) There is then another $001EW pause and the window is removed, returning to normal gameplay.

Finally the patch contains the message text. Here an example is used from Battle of the Brains for which a similar patch was made.