Patch:Lifewater
Lifewater is the system used in Keen 4 to allow the player to collect extra lives. There are two collectables that can be acquired; the first is lifewater drops, which are tiles that can be collected, 100 giving the player an extra life, the second collectable is the lifewater flask, both a tile and sprite that can be collected to give an extra life directly.
This page is divided into three sections. The first section relates to lifewater drop tiles, the second relates to lifewater flask tiles and the third to the splash and 1UP sprites produced when tiles are collected. This apge does not cover aptches relating to 1UP sprites; there are items and aptches relating to them can be found on the items page.
Lifewater drops
These are 16x16 foreground tiles with a specific property allowing the player to get them. When 100 are obtained an extra life is gained. The following patches relate to both getting a single drop and an extra life.
What the drops give
This is what is increased when the player obtains a drop. By default the drops counter is incremented by 1.
Keen 4
#What to increase
%patch $D075 $FF $06 {$7A5AW}
What is needed to get 1UP
This is what is required to obtain an extra life. By default this is exactly 100 drops. The game code is set up so that it is impossible for the player to get more than one drop at a time, but if this happened the player might not get an extra life and continue obtaining more drops.
Replacing the $75 with $EB will mean the player never gets an extra life (And can accumulate drops in perpetuity.) Replacing it with $90 $90 will mean the player gets an extra life with every drop.
Keen 4
#What is needed to get an extra life (100 drops)
%patch $D07A {$7A5AW} $3D [$0064W] {$75}
Can only get a maximum of x drops, no 1UP
This patch changes the game so that the player can only get a certain number of drops. After this their drops counter does not increase anymore. This effectively puts a 'cap' on drops. (And renders them useless, unless other patches make use of them.)
Keen 4
#Can only get a maximum of [x] drops, no 1UP
%patch $D075 $A1 {$7A5AW} $3D [$xxxxW] {$73} $04 $FF $06 {$7A5AW} $5F $5E $5D $CB
What is changed when 1UP obtained
Two things are changed when an extra life is obtained, firstly the player's life counter is incremented by 1, and secondly the drop counter is set to zero, requiring them to obtain another 100 drops.
Keen 4
#What to change
%patch $D083 {$7A5AW} [$0000W] #Set drops to 0
%patch $D093 $FF $06 {$7A6AW} #Increase Keen's life count
1UP decreases drops instead of setting; can have multi-drop items
This patch alters things so that drops can be increased in increments of more than 1. By default the 1UP code runs only when exactly 100 drops are obtained and it sets drops to 0 when it does so. In that case if a player were to have 99 drops and get an item that gave 20 drops (Total 119) the 1UP code would not trigger and they would be unable to get any more lives. Likewise if the 1UP code were triggered it would set the counter to 0 instead of the 19 'extra' drops the player should have.
This patch makes it so that any amount equal to or above 100 (the first blue value) triggers the code and that the count is decreased by 100 when this happens. (-100 = $FF9CW).
Keen 4
#Change 1UP to drop 100 instead of set, needs>100 to trigger
%patch $D07D [$0064W] {$72} $64 $81 $06 {$7A5AW} [$FF9CW]
Sounds played
There are two sounds played, one when the droplet is got, the other when an extra life is gained.
Keen 4
#Play sounds
%patch $D060 $000AW #Get drop
%patch $D088 $0011W #Get 1UP
Keen 4
#Don't play sounds
%patch $D05F $EB $0A #Get drop
%patch $D087 $EB $0A #Get 1UP
Drops are health (Hit points)
See Patch:Dead Keen.
Complete Lifewater code
This is the complete code run whenever a raindrop tile it touched by Keen. It is called by his tile code. The first two lines remove the tile; $1424W calls $30294 which replaces the tile with tile 0.
The third line plays sound $0A. On the fourth line Keen's drops variable is increased by 1, loaded into memory and compared with 100. If it is less the code skips to the end.
If however it is 100 then Keen's drops are set to 0 and sound $11 played. On the next line Keen's lives are increased by and a type 1 sprite is created. (The !UP sprite.) This sprite is given the sprite type 1, a foreground value of 3, vertical direction of -1 ($FFFFW or 'up'.) and the animation $DA. It uses action $1F28W (Item got) and has a clipping set to 0.
Keen 4
#Complete Lifewater got code
%patch $D03F $55 $8B $EC $56 $57 $8B $76 $06 $8B $7E $08 $B8 $0001W $50 $50
$57 $56 $50 $1E $B8 {$1424W} $50 $9A $16540F28RL $83 $C4 $0E
$B8 [$000AW] $50 $9A $187409F1RL $83 $C4 $02 $57 $56 $9A
$0FA8020CRL $83 $C4 $04 $FF $06 {$7A5AW} $A1 {$7A5AW} $3D [$0064W]
{$75} $64 $C7 $06 {$7A5AW} [$0000W] $B8 [$0011W] $50 $9A $187409F1RL
$83 $C4 $02 $FF $06 {$7A6AW} $B8 $0001W $50 $9A $06BD1E11RL
$83 $C4 $02 $8B $1E $D8 $A7 $C7 $07 [$0001W] $C7 $47 $20 [$0003W]
$8B $C6 $B1 $08 $D3 $E0 $89 $47 $0A $8B $C7 $48 $D3 $E0 $89
$47 $0C $C7 $47 $10 [$FFFFW] $B8 [$00DAW] $89 $47 $1E $89 $47 $40
$B8 [$1F28W] $50 $53 $9A $09DC118CRL $83 $C4 $04 $8B $1E $D8
$A7 $C7 $47 $06 [$0000W] $5F $5E $5D $CB
Lifewater flasks
These are either 16x16 foreground tiles with a specific property allowing the player to get them or item sprites that gives the player an extra life when the player touches them. As items proper, patches relating to them are covered on the items page. Any patches here are not item patches per se but rather additional patches relating to 'flask-like' items.
Create a 3 life item
This patch creates an item that gives the player three lives. It has two requirements; firstly it uses the EGAGRAPH check skip and so is incompatible with any other patches that also use it, secondly it requires Princess Lindsey to use only one animation since the 3-up item uses her graphics. (This can be changed.)
The 3-up sprite is spawned from the 'I Keen' sprite. To do so Lindsey's initiation code is overwritten and she is given a new initiation code overwriting part of her hovering behavior which is now no longer used. Lindsey is also given a new animation since all of hers are being used.
In the 3-up's spawn code there are four blue values. The first is the sprite's type, (1 or 'misc); the second is the sprite's activity; the third its foreground variable (0, or appear behind all tiles.) and the final value it the 3-up's initial action (The same action as Lindsey's now unused second action.)
The 3-up has three frames of animation plus a fourth 'got' animation used when Keen touches it. These are all Lindsey's frames.
The 3-up's sprite collision is what gives Keen things. It reacts to Keen's sprite type (2) and increases his life variable 3 times. It changes its own action to 'got' and its vertical direction to up (So the got item will move upwards like other got item sprites.) and finally plays sound $11.
Keen 4
#Disable EGAGRAPH check in Keen 4 (Frees 389 bytes at $3CF6)
%patch $3CE5 $90 $90
#Lindsey spawn caches just one animation, $00CDW
%patch $EE8F $3F31W #Lindsey (At $12821)
%patch $12821 $FF $76 $FC $57 $9A $11A20DB5RL $83 $C4 $04 $B8 $2A3ARW $8A
$16 $EC $7A $8E $C0 $26 $08 $16 [$00CDW] $E9 $C5BFW
#Lindsey has one frame, no hovering
%patch $3276A $00000000L
%patch $32776 $38EAW
%patch $3275A $00CDW $00CDW
#I Keen tile spawns 3-up
%patch $EECB $0122W
#3-up spawn code (Uses Lindsey cache at present)
%patch $EA17 $037D0526RL
#3-up spawn code = $037D0526RL
%patch $3CF6 $55 $8B $EC $33 $C0 $50 $9A $06BD1E11RL $83 $C4 $02 $8B $1E
$D8 $A7 $C7 $07 [$0001W] $C7 $47 $02 [$0001W] $C7 $47 $20 [$0000W]
$8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B $46 $08 $05 [$FFFDW]
$D3 $E0 $89 $47 $0C $B8 [$3908W] $50 $53 $9A $09DC118CRL $83
$C4 $04 $5D $CB
#3-up sprite collision (With Keen gives 3 lives, play 1-Up sound $11) = $037D056ARL
%patch $3D3A $55 $8B $EC $56 $57 $8B $76 $06 $8B $7E $08 $83 $3D [$02] {$75} $22
$FF $06 {$7A6AW} $FF $06 {$7A6AW} $FF $06 {$7A6AW} $C7 $44 $1C [$011FW]
$C7 $44 $10 [$FFFFW] $B8 [$0011W] $50 $9A $187409F1RL $83
$C4 $02 $5F $5E $5D $CB
#3-up actions, use 3 Lindsey actions: $3908W-$3944W; $0008W is anim speed
%patch $32778 $014AW $014AW $0000W $0000W $0000W $0008W $0000W $0000W
$00000000L $037D056ARL $09DC176ERL $3926W
%patch $32796 $014BW $014BW $0000W $0000W $0000W $0008W $0000W $0000W
$00000000L $037D056ARL $09DC176ERL $3944W
%patch $327B4 $014CW $014CW $0000W $0000W $0000W $0008W $0000W $0000W
$00000000L $037D056ARL $09DC176ERL $3908W
#3-up got action $011FW: acts like item got $0028W is appearance time, $0008W rise speed
%patch $2EF8F $0149W $0149W $0001W $0000W $0000W $0028W $0000W $0008W
$00000000L $00000000L $09DC176ERL $0000W
1UP and splash sprites
There are four lifewater-related sprites. The first is the 1UP produced when a 1UP item sprite is taken, patches relating to that sprite can be found on the items page. The second is the 1UP produced when a 1UP tile is obtained. These too are treated on the items page. The last two relate to drops tiles; the first is the 'drop splash' that appears when any drop is taken while the second is the 1UP produced when the 100th drop is taken.
Sprite Type
Both the splashes and 1UP sprites are type 1 or 'misc', not affecting anything in particular.
Keen 4
#Lifewater related sprite types
%patch $FCAB [$0001W] #Splash
%patch $D0A9 [$0001W] #1UP
Sprite Actions
Actions relating to these sprites are quite simple. Both are produced in only one situation. The drop splash is produced when drop tiles are obtained and proceeds to a three action sequence that then vanishes. The 1UP is a variation of the standard 'item got' sprite so altering what it becomes will alter other item got sprites.
Actions: $1F28W #Stuff got $1F46W #Raindrop splash 1 $1F64W #Raindrop splash 2 $1F82W #Raindrop splash 3
Keen 4
#Produce splash
%patch $FCC0 [$1F46W]
#Splash sequence
%patch $30DD2 [$1F64W]
%patch $30DF1 [$1F82W]
%patch $30E0E [$0000W]
#Produce 1UP
%patch $D0D0 [$1F28W]
#1UP sequence
%patch $30DB4 [$0000W]
Sprite Behavior
None of these sprite actions have any behavior. Changing the 1UP's behavior will also change the behavior of other 'items got' sprites.
Keen 4
#1UP
%patch $30DA8 $00000000L
#Splash
%patch $30DC6 $00000000L
%patch $30DE4 $00000000L
%patch $30E02 $00000000L
Speed and Jump Height
The splash sprite does not move. However the 1UP does. Since its direction is set as upwards its speed is reversed. Altering this speed will alter the speed of all 'item got' sprites. In the main this will alter how far up the sprite gets before vanishing.
Keen 4
#1UP initial direction
%patch $D0C4 [$FFFFW]
#1UP speed
%patch $30DA4 $0000W $0008W
#Splash speeds
%patch $30DC2 $0000W $0000W
%patch $30DE0 $0000W $0000W
%patch $30DFE $0000W $0000W
Sprite Collision
None of the sprite actions have any sprite collision.
Keen 4
#1UP
%patch $30DAC $00000000L
#Splash
%patch $30DCA $00000000L
%patch $30DE8 $00000000L
%patch $30E06 $00000000L
Animations
The splash and 1UP sprites are cached with in-level Keen when he spawns. The 1UP sprite's specific animation is set when it is created, its action itself has no animation of its own. (If one is given then it will change the animations of all other 'item got' sprites.) The splash however has its own animations, a different one for each action.
The animation speeds of the splash control how long it appears onscreen before vanishing. That of the 1UP controls how long it moves upwards before vanishing. (Changing it will change all other 'item got' sprites.)
As a item th lifewater flask comes in two types, tile and sprite based. The tile-based flask has a customizable appearance based on tileswhile the sprite-based flask uses two animations, the first of which is taken from the 'sprite animation list'. The animation for when both obtained is taken from the 'got item animations list' and by default is different from that which appears when 100 drops are obtained.
Keen 4
#1UP item sprite set
%patch $30E24 $00EFW
#100 drop 1UP sprite set
%patch $D0C7 $00DAW
#1UP item sprite set
%patch $30290 $00E1W
#1UP action has no animations
%patch $30D98 $0000W $0000W
#Splash
%patch $30DB6 $00D7W $00D7W
%patch $30DC0 $000AW #Animation speed
%patch $30DD4 $00D8W $00D8W
%patch $30DDE $000AW #Animation speed
%patch $30DF2 $00D9W $00D9W
%patch $30DFC $000AW #Animation speed
Sounds
There are two relevant sounds, one played when a drop is obtained and another when 100 drops are obtained. Both sounds can be disabled. Patches relating to these sounds can be found in the sounds section near the top of this page.
Clipping and foreground
Both the splash and 1UP sprites have a foreground value of 3 so that they will appear in front of all other sprites and tiles. (So the player can see what has happened.) and no clipping. (So they are not pushed about by tiles.) These can be altered apart from the usual 'item got' sprites.
Keen 4
#Drop Splash
%patch $FCA7 [$0003W] #Foreground
%patch $FCA2 [$0000W] #Clipping
#1UP
%patch $D0AE [$0003W] #Foreground
%patch $D0E3 [$0000W] #Clipping
Sprite-tile interaction
All the sprites use the 'sit' tile interaction; this means they do not specifically interact with tiles. Since they have no clipping they will not even be stopped by solid tiles. Altering the 1UPs collision will affect other 'item got' sprites.
Keen 4
#1UP
%patch $30DB0 $09DC176ERL
#Splash
%patch $30DCE $09DC176ERL
%patch $30DEC $09DC176ERL
%patch $30E0A $09DC176ERL
Action type
The 1UP uses type 1 for its action; this allows it to move smoothly. The splash by contrast uses type 0 since they do not have to move or use a behavior.
Keen 4
#Splash
%patch $30DBA [$0000W]
%patch $30DD8 [$0000W]
%patch $30DF6 [$0000W]
#1UP
%patch $30D9C [$0001W]
Deprotect and stick to ground
The splash and 1UP have no need for either of these variables and so have a value of 0 for both in all of their actions.
Keen 4
#Splash
%patch $30D9E [$0000W $0000W]
%patch $30DBC [$0000W $0000W]
%patch $30DDA [$0000W $0000W]
#1UP
%patch $30DF8 [$0000W $0000W]