Patch:Bridges and switches

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

The Keen games use bridges and switches in every episode except Dreams. Bridge switches change the tiles in a level, namely by adding\removing solid tiles Keen can walk across (bridges.) Keen Vorticons has a unique 'light switch' to change the level's palette and Keen Galaxy has unique 'platform switches' that alter the paths of moving platforms.

This page contains a section on how various games use bridges and switches, followed by sections containing various patches. See also Patch:Earth Explodes for when a Tantalus switch is flipped and Patch:Keen Flipping Switches for sprite patches relating to Keen when he flips switches in Galaxy.


How switches and bridges work

There are two types of bridge\switch, those in Keen 1-3 and those in Keen 4-6. Keen Dreams does not support bridges and switches.


Keen 1-3

A switch tile is a tile that, when Keen presses pogo while touching it, will cause a bridge to extend\retract in the level. A bridge consists of a row of a single tile, the 'bridge block' When Keen flicks a switch, it animates and the bridge is affected. Switches can be turned 'on' and 'off' (or vice versa).

In order to work correctly a switch needs several things. Firstly it needs TWO tiles, on and off. These tiles should be given the correct tile property, 'Switch on' and 'Switch off' (See Tileinfo) These two tiles should also be patched to animate into each other (See below.) If a switch is not patched to animate, it will not do so, but bridges will still be affected by it.

A bridge starts off absent. When a switch is flicked the bridge begins to grow. It will grow to replace all tiles to the right of its starting tile that are the SAME as its starting tile. (Unless patched.) This is seen in most levels as a bridge growing across between two walls, but even non-solid tile will 'block' a bridge. When a bridge is retracted it will do the opposite, replacing the replaced tiles with the same tile as its starting tile used to be.

There are complications to this. A bridge does not remember what was 'behind' it, it only remembers where it started, where it ended and what tile was originally at its start point. When a bridge retracts it looks at its end point and starts replacing tiles to the left of it with the same tile as was at its starting point until it can find no more bridge tiles. This means that if a bridge has bridge blocks to the left of its start point, when retracted it will replace them too, 'undershooting' its start point. (This can be used to make bridges that 'start out' extended.)

On rare occasions a bridge may grow left instead of right, usually when the only 'same' tiles are to the left of its start point. If a bridge manages to move off the right edge of the level (The level edge blocks must be the same tile as the bridge is growing through!) it will appear on the other side of the level, one row down.

The location of a switches bridge depends on the value of the sprite placed over the switch. The switch is seen as 0,0 and an 'unsprited' switch will simply turn into a bridge tile. Every tile right counts as +1 and every row down as +256 (Left -1, up -256) This means bridges are 'limited' to +-256 tiles in all directions. This also means that moving a switch moves the bridge too. (As with all hex numbers, a negative value is 65536 - value.) A simple example is a value of 513 ($201) will make a bridge at Keen's feet, 1 tile right of the switch.


Keen 4 and 5

In Keen 4-6 any tile can be a switch as long as it has the switch property. Switches are activated the same was as in Keen 1-3. Like Keen 1-3 a sprite placed over the switch determines where the switch's effects ar felt. However the system is simpler than in Keen 1-3; the value of the sprite in hex determines the x and y position of the tile affected by the switch. Thus a sprite value of 4660 ($1234) will affect a tile at 18,52 ($12,$34) on the map.

In Keen galaxy the switch animates foreground tiles in an interesting manner. A 'switchable' tile will be set as animating, but have no animation time. Thus in the game it will not animate. When a switch is flipped however they will animate one frame. By default this is used to make bridges by having one frame of a tile as invisible and fall through, while the second frame is a visible bridge and solid. Flicking the switch animates between the two making the bridge appear or disappear.

The same sort of tiles make up the switch, it animates once every time it is clicked. It is possible to make a switch animate to a tile that has no switch property, so the switch can only be used once. It is also possible for a bridge to have more than 2 frames, doing different things every time the switch is flicked, or even not be a bridge at all, but be used for some other effect.

A switch will affect a rectangle of tiles, starting at the switch location and extending down and right. The rectangle extends until there are no more 'switchable' tiles. Most bridges are two rows high and any number of columns wide.


Keen 6

Keen 6 switches work exactly like Keen 4 and 5. There are two types of switch tile, 'on' and 'off' 'On' switch tiles are activated by jumping or pogoing onto them, 'off' switch tiles are activated by hitting your head against them from beneath.


Switch tile

Only Keen 2 has a working switch tile, but modders may want to change even this. To work the 'switch on' tile must be patched to animate into the 'switch off' tile and must have the tile property 'switch on' (The same is true foe the 'switch off' tile.) This makes a switch that can be flicked any number of times, animating each time.

Patch: Keen 1
#Change the animating switch
%patch $36DB $01E0W
#This tile when flipped becomes...
%patch $36E0 $01EDW
#This tile and...
%patch $36FC $01EDW
#This tile when flipped becomes...
%patch $3716 $01E0W
#This tile.

Patch: Keen 2
#Change the animating switch
%patch $651D $01E0W
#This tile when flipped becomes...
%patch $6522 $01EDW
#This tile and...
%patch $653E $01EDW
#This tile when flipped becomes...
%patch $6558 $01E0W
#This tile.

Patch: Keen 3
#Change the animating switch
%patch $6D7B $01E0W
#This tile when flipped becomes...
%patch $6D80 $01EDW
#This tile and...
%patch $6D9C $01EDW
#This tile when flipped becomes...
%patch $6DB6 $01E0W
#This tile.


Bridge tile and extension speed

These patches change what tile the bridge is made of and how fast it 'grows'

Patch: Keen 1
#Bridge block
%patch $4AEE $010EW
#When building
%patch $4B3D $010EW
#When removing
#Bridge extension time (Per block, set both the same)
%patch $4AA0 $0C %patch $4AA6 $0C
#Bridge retraction time (Per block, set both the same)
%patch $4B0F $0C %patch $4B15 $0C

Patch: Keen 2
#Change the bridge block (in this it's changed to tile 480)
%patch $7852 $01E0W
#When building
%patch $78A1 $01E0W
#When removing
#Bridge extension time (set both the same)
%patch $7804 $0C %patch $780A $0C
#Bridge retraction time (set both the same)
%patch $7873 $0C %patch $7879 $0C

Patch: Keen 3
#Change the bridge block (in this it's changed to tile 480)
%patch $80F5 $01E0W
#When building
%patch $8146 $01E0W
#When removing
#Bridge extension time (set both the same)
%patch $80A5 $0C %patch $80AD $0C
#Bridge retraction time (set both the same)
%patch $8116 $0C %patch $811E $0C


Tantalus Switches

'Tantalus switches' are switches that initiate the 'earth explodes' sequence in Keen 2. They are also present in the other Vorticons episodes but not used. They are switches that have a specific tile at a specific location relative to them.


No Tantalus switches

This patch makes it so that there is no such thing as a Tantalus switch; all switches behave the same, that is, as bridge switches.

Patch: No Tantalus switches
#No Tantalus switches -Keen 1
%patch $3603 $90 $90
#No Tantalus switches -Keen 2
%patch $6445 $90 $90
#No Tantalus switches -Keen 3
%patch $6CA5 $90 $90


Screen shake and oops

This section contains patches that relate to the screen shaking and the 'oops' textbox which occurs in the same location Keen was in when he accidentally flips a Tantalus switch.


Skip shake and oops

In Keen 2 this patch skips the shake and 'oops' textbox; the game goes straight to the Vortiship firing sequence, in other episode it renders the switch useless.

Patch: Keen 2
#Skip shake and oops box -Keen 1
%patch $3608 $E9 $00A8
#Skip shake and oops box -Keen 2
%patch $644A $E9 $00A8W
#Skip shake and oops box -Keen 3
%patch $6CAA $E9 $00A3


Shake strength

There are two variables that control he severity of the screen shaking. One horizontal, one vertical. The sequence works best when both are the same. The amount of shaking is in tiles * $10, so the default is 4 tiles both ways.

Patch: Keen 1
#Screen shake strength
%patch $362B $0040W
#Horizontal
%patch $364E $0040W
#Vertical

Patch: Keen 2
#Screen shake strength
%patch $646D $0040W
#Horizontal
%patch $6490 $0040W
#Vertical

Patch: Keen 3
#Screen shake strength
%patch $6CCD $0040W
#Horizontal
%patch $6CEF $0040W
#Vertical


No shake

These patches stop the screen shaking. The first holds the screen still for some time while the second simply brings up the 'oops' textbox immediately, no pause.

Patch: Keen 1
#No screen shake: long pause
%patch $3651 $90 $90 $90 %patch $362E $90 $90 $90
#No screen shake: no pause
%patch $3626 $6C

Patch: Keen 2
#No screen shake: long pause
%patch $6493 $90 $90 $90 %patch $6470 $90 $90 $90
#No screen shake: no pause
%patch $6468 $6C

Patch: Keen 3
#No screen shake: long pause
%patch $6CF2 $90 $90 $90 %patch $6CD0 $90 $90 $90
#No screen shake: no pause
%patch $6CC8 $6A


Shake duration

This patch controls how long the screen shakes for. By default this is $50 ticks. The maximum value is $7F ticks, the minimum 1.

Patch: Screen shake duration
#Screen shake duration -Keen 1
%patch $3690 $50
#Screen shake duration -Keen 2
%patch $64D2 $50
#Screen shake duration -Keen 3
%patch $6D30 $50


Text box

This appears after the screen stops shaking, presumably the Tantalus has fired and Keen has realized what he's done.

Patch: Keen 1
%patch $3694 $0001W 
#Oops box bottom
%patch $3698 $0005W
#Right side
%patch $36A2 $2444W
#Text is read from...
%patch $36AB $0064W
#Pause before box vanishes\ship fires
#Text
%patch $15494 "Oops." $00

Patch: Keen 2
%patch $64D6 $0001W 
#Oops box bottom
%patch $64DA $0005W
#Right side
%patch $64E4 $2CF0W
#Text is read from...
%patch $64ED $0064W
#Pause before box vanishes\ship fires
#Text
%patch $1A470 "Oops." $00

Patch: Keen 3
%patch $6D34 $0001W 
#Oops box bottom
%patch $6D38 $0005W
#Right side
%patch $6D41 $2D2AW
#Text is read from...
%patch $6D49 $0064W
#Pause before box vanishes\ship fires
#Text
%patch $1C54A "Oops." $00


No text box

This patch removes the 'oops' textbox entirely leaving just the shaking and then (after a pause) proceeding to the Vortiship firing.

Patch: No 'oops' box
#No 'oops' box -Keen 1
%patch $3693 $EB $15
#No 'oops' box -Keen 2
%patch $64D5 $EB $15
#No 'oops' box -Keen 3
%patch $6D33 $EB $13


Misc

These are miscellaneous patches that have a variety of effects.

Switch becomes next tile

This patch allows any tile to be a switch tiles (And doesn't affect light switches.) When a switch is flipped it turns into the next tile. This allows many different working switches in a tileset, but means each switch can really only be used once. (There is no way to turn a switch 'back')

Patch: Keen 1
#Switch tiles change to the next in the tileset when flipped
%patch $36D5 $05 $0001W $26 $89 $07 $90 $90 $90 $90 $90 $90 $90 $90 $90


When bridges stop growing

These two patches alter the stop condition of the bridge. By default bridges stop growing when they hit a tile that is not the same as the last tile. This means that only one kind of tile per bridge can be built over. The patches below modify this so a range of tiles can be overwritten. (Which will be erased when the bridge is removed.) Use only one of the following patches.

Patch: Keen 1
#Bridges stop growing ONLY when they find a tile...
%patch $4ACB $7D
#Less than the one they started on
%patch $4ACB $7C
#Greater than the one they started on


Disable bridges

This disables bridges entirely, but switches still work; they can be flipped and make a sound.

Patch: Keen 1
#Disable bridges, but switches still animate, etc
%patch $4ACB $90 $90


Bridges 'nibble'

Both of these patches allow bridges to become one tile longer each time they are used. The first will make the bridge one tile longer when it extends, the second when it is retracted. This can be dangerous because the bridge can be flipped repeatedly, wrapping around the level and eventually erasing all of it. For this reason it may be best to put the switch in the bridges way so it can only be flipped a certain number of times.

Patch: Keen 1
#Bridges 'nibble' the first non-same tile they encounter
%patch $4AD2 $90 $90

Patch: Keen 1
#Bridges 'nibble' a tile when retracted
%patch $4B46 $90 $90


Disable bridge retraction

The first patch here stops bridges from retracting; Keen can extend the bridge, but then it is stuck there and cannot be removed. The second allows a bridge to be extended and removed, but not extended again.

Patch: Keen 1
#Disable bridge retraction
%patch $4B3F $7C

Patch: Keen 1
#One shot bridge
%patch $4B43 $40


Move switches one tile down

This patch for Keen 5 moves switches one tile down; that is, instead of working at the height of Keen's head they are located by his feet. (Unless Keen is made taller than 2 tiles.) However the patch is not 'complete'; only the animation is moved down, a switch tile is still required at Keen's head height (One tile above where the tile will animate.) However if this tile is made invisible and nonanimating, it will at least appear that the switch has been moved down a tile.

Patch: Keen 5
#Move switches one tile down (Almost)
%patch $B4AA $C8 $0016W $00 $56 $57 $8B $5E $06 $8B $5F $2E $43 $53 %patch $B51D $59 $B8 $0001W $50 $50 $8B $5E $06 $51 $90


Bridge thickness

These patches control how many rows of tiles constitute a bridge. In Keen Galaxy this is two rows of tiles by default.

Patch: Number of rows that make a bridge
#Keen 4
%patch $C1F2 $0002W
#Keen 5
%patch $B5E3 $0002W
#Keen 6
%patch $B3F3 $0002W


Switch sounds

This sound is also used for the light switches in Keen Vorticons.

Patch: Keen 1
%patch $35DB $19     
#Keen flip switch sound
%patch $35DA $EB $07
#Keen flip switch sound disabled

Patch: Keen 2
%patch $641D $19     
#Keen flip switch sound
%patch $641C $EB $07
#Keen flip switch sound disabled

Patch: Keen 3
%patch $6C7E $19     
#Keen flip switch sound
%patch $6C7D $EB $06
#Keen flip switch sound disabled