Patch:Tantalus ray
The Tantalus ray is a sprite in Keen 2 and the main focus of them game. Keen must destroy eight rays, each pointed at a major Earth city to win the game. While a sprite, the Tantalus behaves more like a machine or a construct of tiles. Patches involving activating a ray and destroying Earth can be found at Patch:Earth Explodes. Patches relating to the cities the rays target can be found at Patch:Cities and patches involving winning the game by destroying all the rays can be found at Patch:Ending sequence (Keen 2).
How the Tantalus works
The Tantalus ray is in essence a sprite. It appears as a small purple spark by default, and it is this Keen must shoot to destroy the ray. The presence of this sprite affects a number of tiles, most notably when the Tantalus is shot.
Keen can interact with the Tantalus in two ways, by flipping its switch, which causes the Tantalus to detonate, and by touching\shooting the Tantalus spark, which destroys it and saves a city. This page is divided into several sections, the sprite properties of the Tantalus, the destruction sequence of the Tantalus (when Keen shoots it) and miscellaneous patches. Patches involving the destruction of Earth are located at Patch:Earth Explodes
What is needed to win the game
By default the game is won when 8 cities are saved. The number of cities can be altered. Changing the value to 0 wins the game when any level is exited. Note however that if Keen somehow saves more cities than this value he will never be able to win the game. (This will happen if for example it is set to 0 but Keen saves a city.)
The game does this by starting at a certain variable and checking the next 8 to see if they have a value of 1. Each value of 1 is added to a total, and if that total is exactly 8 the game is won.
There are two other repeats of this process; the first occurs when Keen gets a high score; to tell the player how many cities were saved. The second is in the High score screen itself to list the cities saved by each score entry.
Number of saved cities needed to win
#Number of cities needed to win
%patch $8430 {$9AF4W} #Start checking here...
%patch $8438 [$08] #...check next 8 variables to see...
%patch $8432 [$01] #...if they're 1...
%patch $843E [$08] {$75} #...if exactly 8 are, win
#Check cities saved when entering a score
%patch $86D8 {$9AF4W} #Start checking here...
%patch $86E0 [$08] #...check next 8 variables to see...
%patch $86DA [$01] #...if they're 1
#Check cities saved when showing highscores
%patch $887E {$9AF4W} #Start checking here...
%patch $8886 [$08] #...check next 8 variables to see...
%patch $8880 [$01] #...if they're 1
Sprite Type
Tantalus rays are type 8, which doesn't really do anything by default. There is also the property of the zap\zot sprites produced when the Tantalus is destroyed, type 13, which also doesn't do much. (Thought it may be useful for complex patching.)
Keen 2
#Yorp sprite type:
%patch $3DE7 $08 #Tantalus
%patch $4807 $0D #Tantalus destroyed zaps
Sprite Behavior
The Tantalus ray's default behavior is to sit, animate and wait for Keen to shoot it. This behavior never changes. The Tantalus ray collision is the most complex in the game and thus has its own section.
Behaviors: $46DFW Sit and animate $4716W Tantalus ray collision
When spawned
%patch $3E0A {$46DFW}
%patch $3E0F $4716W #Tantalus ray collision
Animations
When spawned
%patch $3E14 [$0080W] #Start
In level
%patch $46F0 [$0080W] #Sprite
%patch $46ED [$0003W] #Frames used -1
Sounds
The Tantalus ray has one sound associated with it, this is the sound made when the Tantalus is shot and tiles are being replaced.
Keen 2
%patch $47F3 $25 #Sound of tiles being replaced
#Don't make sounds:
%patch $47F6 $90 $90 $90
Sprite Collision
The sequence of events that occur when the Tantalus is shot by Keen is one of the most complex sprite collisions in Keen Vorticons. It involves multiple tile replacements in a series of steps that give the impression the machine is blowing up. It also gives the player 20'000 points.
The ray will respond to contact from any sprite, including Keen himself, by saving its associated city. It will only be destroyed however by Keen's shot type. This is an interesting bug in the game that means that in some circumstances Keen doesn't have to destroy a Tantalus Ray to win a level.
In level
#Tantalus Ray sprite collision
%patch $3E0F {$4716W}
#What ray responds to (Keen's shot)
%patch $4774 [$0A] {$75}
#Points given
%patch $477C [$2710W]
Tantalus destruction
This section is part of the Tantalus Ray's sprite collision dealing with what happens after it is shot. It is divided into various sections relating to the various 'parts' of the machine that are destroyed, in sequence. Each section deals with the replacement tiles, location and disabling in that order.
Destruction speed\timing
The Ray's destruction can be divided up into a number of steps (See next section.) Each of these is spaced a certain time apart, plus there is a pause after the Ray has been shot but before the first step of destruction begins. These two pauses can be patched; given any value from $00 to $7F.
Keen 2
#Pause before destruction begins
%patch $4878 [$28]
#Pause between steps of destruction
%patch $4884 [$28]
Destruction location
These patches control the location of the entire Tantalus destruction sequence; while patches in each section below alter the position of some part of the destruction, these patches will move all parts of the destruction at once.
Keen 2
#Move destruction 8 tiles left
%patch $4798 $05
#Move destruction 20 tiles left
%patch $479A $0B
Destruction list
A large part of the destruction itself actually works off of a list that consists of 9 parts. By changing these values to $4A0F each of these parts can be selectively disabled. The list shows exactly what parts of the destruction it controls and what order they appear in.
Note that disabling an entry still leaves a pause for its destruction as well as playing an explosion sound. Note also that the destruction code is in fact called 11 times; the last time replaces the city screen, which is not on the destruction list. (Instead the game simply skips straight to it.)
Keen 2
#List location
%patch $48A1 {$4A15W}
#List length
%patch $4896 [$09]
#Destruction list
%patch $4A15 [$48A3W] #Dome, switch (At $48A3)
[$4957W] #Left antenna (At $4957)
[$496CW] #Right antenna (At $496C)
[$4980W] #Purple tile 1 (At $4980)
[$4980W] #Purple tile 2 (At $4980)
[$4980W] #Purple tile 3 (At $4980)
[$4999W] #Orange glowers 1 (At $4999)
[$4999W] #Orange glowers 2 (At $4999)
[$4999W] #Orange glowers 3 (At $4999)
[$4999W] #Orange glowers 4 (At $4999)
Disable
These patches disable certain broad parts of the Ray's destruction. (To completely disable the process simply change the Ray's sprite collision in the section above.)
Keen 2
#No tiles replaced, explosion sounds still occur
%patch $479B $90 $90 $90
#Purple and orange tiles not replaced, no zap\zots for replaced tiles
%patch $47EE $C3
Tantalus dome and switch
The Tantalus dome is a 2x3 array of tiles that surrounds the Tantalus spark and is the closest part of the machine to it. It is also the first part to be destroyed. It is destroyed all at once in a single step. It is possible to patch the replacement tiles and also slightly adjust the location of the replacement. The topmost row of the dome is replaced with background tiles. The location adjustment patch will move the whole dome down a tile.
Along with the dome the Tantalus switch is also replaced at this time; it is a single tile replacement 4 tiles down and 3 tiles left of the spark. (04, FD according to the game.) Both its tile and position can be adjusted. It is also possible to not replace individual dome tiles.
Keen 2
#Replacement tiles:
%patch $48BB [$008FW] #Top left dome replacement tile
%patch $48D2 [$008FW] #Top middle
%patch $48EC [$008FW] #Top right
%patch $4905 [$0222W] #Bottom left
%patch $491B [$0223W] #Bottom middle
%patch $4934 [$0224W] #Bottom right
%patch $4952 [$01FAW] #Switch replacement tile
#Move dome down 1 tile
%patch $48D6 $47
#Switch position
%patch $4939 [$0004W] #Vertical
%patch $4946 [$FD] #Horizontal
#Don't alter...
%patch $4A15 [$4A0FW] #Dome and switch
%patch $4A15 $4936W #Dome
%patch $4936 $E9 $00D6W #Switch
#Don't replace individual dome tiles:
%patch $48BA $00 #Top left of dome
%patch $48D1 $00 #Middle top
%patch $48EB $00 #Right top
%patch $4904 $00 #Bottom left
%patch $491A $00 #Bottom middle
%patch $4933 $00 #Bottom right
Tantalus antennae
Following the dome the Ray's two antennae are replaced, left first then right. Both are a single tile that is two tiles left or right of the spark. As such the horizontal position of both can be adjusted. For the rightmost antenna the position patch is slightly more complicated since its default position is set in an unintuitive manner.
Both antennae's changes can be disabled.
Keen 2
#Left Tantalus antenna
%patch $4958 [$010CW] #Replacement tile
%patch $4960 [$FFFEW] #Horizontal position
#Right Tantalus antenna
%patch $496D [$010CW] #Replacement tile
%patch $4974 $05
[$0002W] #Horizontal position
$50 $EB $E9
#Don't alter...
%patch $4A17 [$4A0FW] #Left antenna
%patch $4A19 [$4A0FW] #Right antenna
Tantalus purple column
Following the two antennae a 1x3 column of animating purple tiles is replaced, one tile at a time, from top to bottom. Each tile uses the same code, so all patches affect all three tiles. The column is directly below the Tantalus spark and its location is very difficult to alter. The change can be disabled by changing the three entries in the destruction list that point to it; each entry disabled (It doesn't matter which specific ones.) decreases the number of tiles replaced.
Keen 2
#Replacement tile
%patch $4981 [$01F9W]
#Move column down one tile
%patch $498C $47
Tantalus orange square and city screen
Following the purple animated column the game calls the orange tile replacement code four times, with the final call also replacing the city screen. The most tricky thing to work with is the orange column's locations, which also control its size. Starting from 3 tiles left of the spark (-3 = $FFFCW) a column of tiles starting 3 down and ending 6 down is replaced. (Total height 3 tiles.) Each call to the code moves right one tile.
The city screen works similarly; both its left and right side are left of the spark, so require negative values for their position. The top is two tiles down, which by default is two $40 bytes; replacing one or both with $90 moves the screen top up one (or two) tiles.
Note that the city screen will be replaced after the destruction code has been called more than 9 times (The length of the destruction list minus 1); so disabling an orange column in the destruction list will not affect its replacement.
Keen 2
#Orange replacement tile
%patch $49A3 [$0225W]
#Location and size
%patch $499C [$0003W] #Column starts 3 down from spark
%patch $49BE [$0006W] #Column ends 6 down from spark (Total height 6-3 tiles)
%patch $49B1 [$FFFCW] #Leftmost column 3 tiles left of spark
#1 column replaced 4 times (Instead of 4 once.)
%patch $49A9 $03
Keen 2
#City screen replacement tile
%patch $49ED [$0215W]
#Location and size
%patch $49CA [$FFF9W] #Left side
%patch $4A00 [$FFFCW] #Right side
%patch $49D3 $40 $40 #Top ($40 = +1 down)
%patch $49F3 [$0005W] #Bottom
#Don't replace screen
%patch $489A $73