Patch:Bridges and switches

From KeenWiki
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.

Because of the fundamentally different ways in which the Vorticons and Galaxy games treat bridges and switches this page is divided into two main sections. The first deals with the Vorticons games while the second deals with the Galaxy games. There is also a section providing links to related pages.


Related pages

.


Switches and bridges in Keen Vorticons

How switches and bridges work

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.


Switch tile

Only Keen 2 has a working switch tile set up by default, but this is easily changed in other games. 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.

The simplest way to add switches to Keen 1 and Keen 3 is just to edit the tile properties of the same tiles as are used in the Keen 2 tileset. This won't even require any patching.

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.


Switch becomes next tile

This patch allows any tile to be a switch tile. (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 generally means they can only be used once as there is no way to reverse the process. The blue value is the number of tiles to 'jump', and this doesn't have to be 1.

Patch: Switch tiles change to the next in the tileset when flipped
#Switch tiles change to the next in the tileset when flipped -Keen 1
%patch $36DA $05 $0001W $26 $89 $07 $EB $4B
#Switch tiles change to the next in the tileset when flipped -Keen 2
%patch $651C $05 $0001W $26 $89 $07 $EB $4B
#Switch tiles change to the next in the tileset when flipped -Keen 3
%patch $6D7A $05 $0001W $26 $89 $07 $EB $4A


Bridge tile and extension speed

These patches change what tile the bridge is made of and how fast it 'grows'. As noted an extended bridge is composed of only one tile and a retracting bridge can only remove one tile.

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


Bridges can cover multiple different tiles

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.

When using only one of the following patches a bridge will be able to pass through any number of different tiles until it encounters one that is before or after the bridges first (origin) tile. When the bridge is retracted these diverse tiles will not be replaced, causing the bridge to 'erase' them.

Patch: Keen 1
#Bridges stop growing ONLY when they find a tile...
%patch $4ACB $7D
#Before the origin tile in the tileset
%patch $4ACB $7C
#After the origin tile in the tileset

Patch: Keen 2
#Bridges stop growing ONLY when they find a tile...
%patch $782F $7D
#Before the origin tile in the tileset
%patch $782F $7C
#After the origin tile in the tileset

Patch: Keen 3
#Bridges stop growing ONLY when they find a tile...
%patch $80D2 $7D
#Before the origin tile in the tileset
%patch $80D2 $7C
#After the origin tile in the tileset


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


Disable bridges

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

Patch: Disable bridges but not switches
#Disable bridges but not switches -Keen 1
%patch $4ACB $90 $90
#Disable bridges but not switches -Keen 2
%patch $782F $90 $90
#Disable bridges but not switches -Keen 3
%patch $80D2 $90 $90


Disable bridge retraction

This patch stops bridges from retracting; Keen can extend the bridge, but then it is stuck there and cannot be removed.

Patch: Keen 1
#Disable bridge retraction -Keen 1
%patch $4B3F $7C
#Disable bridge retraction -Keen 2
%patch $78A3 $7C
#Disable bridge retraction -Keen 3
%patch $8148 $7C


Bridges work only once

This patch allows a bridge to be extended and removed, but not extended again.

Patch: One shot bridges
#One shot bridges -Keen 1
%patch $4B43 $40
#One shot bridges -Keen 2
%patch $78A7 $40
#One shot bridges -Keen 3
%patch $814C $40


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


Switches and bridges in Keen Galaxy

How switches and bridges work

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 are 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 level 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 and will have a special 'bridge tile' property. 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 tiles with the bridge switch property. Most bridges are two rows high and any number of columns wide.

Keen 6 switches work exactly like Keen 4 and 5 once flipped but are activated differently. There are two types of switch tile, 'on' and 'off', as in Keen 4/5. However Keen does not flip them by standing in front of them and pressing the up arrow key. Instead 'on' switch tiles are activated by jumping or pogoing down onto them and 'off' switch tiles are activated by hitting Keen's head against them from beneath.


Switch tile property

In Keen Galaxy any tile can be a switch for bridges or platforms if it has the right property. It needs to animate to another tile to avoid the game producing gibberish graphics when the switch is flipped.

There are three switch properties. Two of these deal with moving platforms, turning their inforplane pathways on or off. The third is for bridges where activating a switch will 'flip' a bridge no matter what state it is in.

Note that in Keen 6 the bridge switch tile property is invalid; instead there are two properties for a tile's top and bottom sides that let Keen flip switches by bumping into them.

Patch: Keen 4
#Switch tile properties
%patch $B96E $05
#Platform switch off
%patch $B976 $06
#Platform switch on
%patch $B97A $0F
#Bridge switch

Patch: Keen 5
#Switch tile properties
%patch $AC50 $05
#Platform switch off
%patch $AC56 $06
#Platform switch on
%patch $AC5C $0F
#Bridge switch

Patch: Keen 6
#Switch tile properties
%patch $AB84 $05
#Platform switch off
%patch $AB8A $06
#Platform switch on
%patch $AB90 $0F
#Bridge switch


Bridge tile property

Unlike Keen Vorticons, Galaxy bridges have their own special tile type. This tells the game which tiles can be flipped when a bridge is activated. This will also set a limit on how wide a bridge is as tiles will be flipped in horizontal rows until no more of the correct type are found. This property is the same across all Galaxy games.

It should be noted that this property is on Keen's tile property list as 'do nothing' by default. If it is altered and Keen's tile list is not taken into account then unexpected things can happen. (Such as the bridge being collectable as items.)

Patch: Bridge tile properties
#Bridge tile property -Keen 4
%patch $94B5 $0012W
#Bridge tile property -Keen 5
%patch $E41D $0012W
#Bridge tile property -Keen 6
%patch $DF3D $0012W


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
#Number of rows that make a bridge -Keen 4
%patch $C1F2 $0002W
#Number of rows that make a bridge -Keen 5
%patch $B5E3 $0002W
#Number of rows that make a bridge -Keen 6
%patch $B3F3 $0002W


Switches work at Keen's feet

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