Patch:Ankh
The Ankh is an object in Keen 3 that gives Keen invulnerability to hazards for a period of time, much like a temporary god mode. It is tile based, like the raygun. This page deals with patches relating to the effects of getting the Ankh, such as the sound it makes, time given or immortality. Patches relating to god mode proper are under Patch:G O D Cheat, patches relating to the sprite shown with Keen when he is protected are also found at Patch:Keen (Keen 3).
The page is divided into three sections; the Ankh as a tile, Ankh time, and the Ankh shield sprite.
Making other things give Keen Ankh time is treated under their own articles such as Patch:Raygun. This page relies heavily on Patch:Jump conditions and Patch:Game stats
Ankh tile and Ankh time
This section of the page contains patches that relate to the Ankh as a tile-based item and what happens when Keen acquires it, as well as Ankh time itself.
What is given by Ankh
This is what the Ankh tile gives when Keen collects it. By default this is 15 seconds of 'ankh time', where the game goes through 144 ticks of time per second. This patch related to Patch:Game stats.
Keen 3
#What Ankh gives (15s of time)
%patch $7BA1 {$9946W} [$0578W]
Keen has Ankh time every level start
Ankh time is paused on the level map, and reset whenever a level is started. It is possible to make the game give the player a fixed amount of Ankh time at the start of any level. This is done by overwriting the 'turn off Godmode' at level start. (See also Patch:Level start.)
Keen 3
#Set Ankh to this at level start
#SIDE EFFECT: Godmode doesn't turn off at level start
%patch $81CE $C7 $06 {$9946W} [$00FAW]
Ankh got sound
This is the sound the Ankh tile makes when got.
Keen 3
#Ankh got sound
%patch $7BA6 $2A
#Don't play sound
%patch $7BA5 $EB $06
Ankh time, God mode and which shield appears
This section covers the two different Ankh shields (Solid and flashing) and what causes either (or neither) to appear. (For how much Ankh time is given, see first section.)
God mode and shields
These patches affect how God mode affects the bubble sprite. By default if Keen has God mode then a flashing sprite will appear. Looking at the below default patch it can be seen that if god =\= 0 then the code small jumps ($75 $03) over a large jump ($E9 $0092W) to 'nothing' (That is, if Keen DOESN'T have god mode take the big jump and don't show anything.) See Patch:Jump conditions and Patch:Game stats. This again can make the Ankh bubble appear under different circumstances, such as Keen having a keycard.
Keen has flashing shield with God mode
#Keen has flashing shield with God mode (Default)
%patch $84F2 {$5FD6W} [$00] $75 $03 $E9 $0092W
This example patch alters things so Keen has the flashing shield when he has no shots:
Keen has flashing shield with God mode
#Flashing bubble when Keen has no shots
%patch $84F2 {$9D48W} [$00] $74 $03 $E9 $0092W
No God mode shield
This patch stops Keen having any type of shield with God mode. (He is still invincible though.)
No God mode shield
#No God mode shield
%patch $84F2 {$5FD6W} [$00] $90 $90 $E9 $0092W
Solid shield with God mode
Solid shield with God mode
#Solid bubble with God mode (None without)
%patch $84F2 {$5FD6W} [$00] $75 $0A $E9 $0092W
Ankh time and shields
These patches relate to the Ankh time and how it determines which shield is shown. Note that Ankh time itself does not have to be the determiner here, it can be changed to anything.
Solid shield check
This patch changes the check for Ankh time, if it is disabled (change $75 to $EB) then God mode alone defines when the bubble sprite appears. (This can be used with the above patches.) If it is set to always ($EB) then God mode has no effect, and if it is set to respond to something other than God mode, other things will affect the sprite.
Keen 3
#Default Ankh time check
%patch $84EB {$9946W} [$00] $75
Flashing shield check
This changes when the bubble will flash. Changing the jump condition can be used to make the sprite flash only when Keen has plenty of time. It can also be used in combination with the following patch. The time can be adjusted, and even what affects it, (the sprite may flash only when Keen has a keycard for example.)
Keen 3
#Ankh flashing time
%patch $84FC {$9946W} [$00FAW] $7E
Flashing shield is solid or invisible
These two patches change the flashing Ankh shield, no matter how it is being used. The first patch makes the shield solid all the time. This means there is no difference between the normal and flashing shield. The second patch makes it invisible, though Keen is still invulnerable. Combined with other patches this can make a different shield for godmode, or make the Ankh shield completely invisible.
Keen 3
#Flashing shield doesn't flash
%patch $8542 $90 $90
Keen 3
#Flashing shield is invisible
%patch $8542 $EB
Ankh shield sprite
This section contains patches relating to the visible effect of the Ankh, a bubble sprite that appears over Keen, flashing or solid depending on current situation. The sprite appears centered on Keen and flashes when Ankh time is low. If Keen has no Ankh time then the game checks for God mode.
The two time situations, plenty of time and time running out, are different and have different sprites, though by default they are the same. The 'time running out' shield is also used for God mode.
Images used
The Ankh uses two frames, in the normal shield these animate normally, in the flashing shield they are broken up with pauses when no sprite appears.
Keen 3
#Solid shield
%patch $850D [$003DW] #Sprite used
%patch $850A [$0000W] #Frames used
#Flashing shield
%patch $854F [$003DW] #Sprite used
%patch $854C [$0001W] #Frames used
Shied positions
The Ankh is not at the same location as Keen, but above and to the left of him. This requires that both shields have their horizontal and vertical positioning specified in the same way other Vorticons position patches work.
Position can be considered a two-part three-byte value with the top left of Keen's sprite being 0,0. The first is a one byte value giving the number of pixels in the position. The second is a two byte value where each 1 change is worth 256 pixels.
By default the shield appears at $FFFFF8, $FFFFF8 relative to the player's sprite (That is, 8 pixels above and 8 pixels left of the player.) Notice how the two values add together; this is important. A naive patcher may think that in order to make the shield appear 8 pixels down and left of the player all they would need to do would be to change $F8 to $08. However this would make both values $FFFF08, or 248 pixels left and above the player, far offscreen. Instead the $FFFFW should be changed to $0000W To give both variables the value of $000008W.
Keen 3
#Solid shield
%patch $851A [$F8] #Vertical position
%patch $851C [$FFFFW]
%patch $852A [$F8] #Horizontal position
%patch $852C [$FFFFW]
#Flashing shield
%patch $855C [$F8] #Vertical position
%patch $855E [$FFFFW]
%patch $856C [$F8] #Horizontal position
%patch $856E [$FFFFW]
Remove sprite
This allows you to remove either the flashing or solid bubble sprite (Or both). Only one of the following three patches should be used. Note that God mode uses the flashing shield
Keen 3
#Remove...
%patch $8500 $EB $76 #Bubble sprite completely
%patch $8502 $EB $74 #Solid bubble
%patch $8538 $EB $3E #Flashing bubble
Ankh effects
These patches allow you to change what causes the Ankh effects and even disable them entirely.
Invincibility
This is what makes Keen invulnerable to tile and sprite hazards. By default if Keen has Ankh time, he's invulnerable. ($74->$EB disables invulnerability.)
Keen 3
#Ankh and invincibility
%patch $7915 {$9946W} [$00] $74
Youths stunning Keen
This is what makes Keen invulnerable to being stunned by youths. By default if Keen has Ankh time, he's invulnerable. ($74->$EB disables invulnerability.)
Keen 3
#Ankh and stunning youths
%patch $7C87 {$9946W} [$00] $74
Youths stun Keen even with Ankh
As expected this patch allows the Youths to stun Keen even if he has Ankh time remaining.
Keen 3
#Youths stun Keen even with Ankh
%patch $7C8A $EB
Misc
Pogo flies only with Ankh time
See also Patch:Keen (Keen 3). This changes things so that the Ankh time not God mode controls whether or not the pogo flies.
Keen 3
#Make pogo only fly if Keen has Ankh-time.
%patch $75F0 {$9946W} [$00] $74
Die when out of time
This patch was the crux of Xky Keen 3 and has some side effects. When the Ankh time runs out, Keen will die unless he is on a message popup tile. Deadly tiles are deadly all the time.
Keen 3
# Make Keen die when ankh time runs out
#SIDE EFFECT: Tile property 'Message popup' becomes 'nothing'
#SIDE EFFECT: Tile property 'nothing' becomes 'kills when Keen has no time'
%patch $7A1C $E9 $4E $01
%patch $7B6D $83 $3E {$9946W} [$00] $7F $03 $E9 $BB $FE $E9 $89 $00
%patch $7C45 $03 $7C