Patch:Teleporter

From KeenWiki
Jump to: navigation, search

This covers patches relating to both the in-level and map teleporters of Keen 1, 3, 5 and 6. It also has information on how the teleporters in Keen 1 and 3's maps work. While not patches exactly, they are vital for doing anything with the map teleporters. The page is thus divided into teleporter patches and teleporter tutorials. See also Patch:Map, Patch:Elevators and Patch:Tiles.

It is possible in Keen 4 to change the Miragia sprite into a teleporter. This patch can be found on the Keen 4 map page.


Patching teleporters

This section involves patches to the teleporters themselves.


Disable teleporters

These patches stop Keen being able to use teleporters on the map. This may be wanted if using the done marker flag patch where Keen can sometimes walk on tiles that act like teleporters, or just to free up patch space if they're not being used.

This patch stops the teleporters entirely, Keen does nothing when he stands on a teleporter sprite and presses keys.

Patch: Keen 1
#Disable teleporters- teleporters inactive
%patch $AF2C $8B $E5 $5D $C3

Patch: Keen 3
#Disable teleporters- teleporters inactive
%patch $B987 $5F $5E $8B $E5 $5D $C3


Teleporters are level entrances

This patch is similar to that in the above section except that it simply makes the teleporter sprites act like level entrances. This could cause problems with the flag patch mentioned above, but allows Keen to use extra levels if he so wishes.

Patch: Keen 1
#Disable teleporters- teleporters are level entrance
%patch $AF27 $90 $90


Teleporters in-level

This patch for Keen 1 allows Keen to teleport around the level. When he touches a teleport tile, he will teleport to the x,y location that, if the teleport were a switch, a bridge would appear. This means that you can change his arrival location by placing a different sprite value on the teleport tile. For how switches and bridges work see Patch:Bridges and switches

There are a few things to note. First, that as with switches, the area affected is Keen's head, only the topmost teleport tile affects Keen, and his head will be transported to the arrival location. If your teleporter makes Keen fall into the ground, you have forgotten this. Also teleporters with no sprite value will teleport Keen to themselves, in an infinite loop. Teleporting is instant and can be quite jarring. It can also cause small tile bugs if Keen teleports too close to the level edges. Finally, Keen's speed is not affected, if he is rushing left when he teleports, he will still be moving left on arrival, problems can occur if a teleport or hazard is nearby and Keen walks into it, unawares.

Patch: Keen 1
#Change the teleporter so it works within the level
%patch $8919 $89 $F0 $F7 $2E $08 $6C $01 $F8 $D1 $E0 $C4 $1E $4C $6C $01 $C3 $26 $8B $07 $50 $88 $E0 $98 $99 $01 $F0 $83 $D2 $00 $B1 $0C $E8 $16 $58 $89 $16 $E4 $6E $A3 $E2 $6E $05 $00 $B0 $83 $D2 $FF $A3 $D4 $6E $89 $16 $D6 $6E $58 $98 $99 $01 $F8 $83 $D2 $00 $B1 $0C $E8 $F5 $57 $89 $16 $E0 $6E $A3 $DE $6E $05 $00 $70 $83 $D2 $FF $A3 $D0 $6E $89 $16 $D2 $6E $C3 %patch $4572 $E8 $A4 $43 $EB $13 $90


Teleport in-level when pressing a key

This is a modified version of the above patch that only teleports Keen when he presses a key, in this case the up arrow or numberpad 8. The first section is the same as the above patch. The main difference is the second section; first it checks for the up key's scancode and, if this is not zero, runs the teleporter code. Otherwise this is skipped. It is possible to modify the patch to play a teleport sound as well.

This patch overwrites some of the Ship Parts tile code, specifically it makes the part tile replacement the same as that for the ammo and raygun. This is an issue with the 'Keen 3 style backgrounds' patch; the line %patch $4482 $E9 $74 $FF #Affect ship parts will need to be deleted to avoid any issues.

Patch: Keen 1
#Change the teleporter so it works within the level
%patch $8919 $89 $F0 $F7 $2E $08 $6C $01 $F8 $D1 $E0 $C4 $1E $4C $6C $01 $C3 $26 $8B $07 $50 $88 $E0 $98 $99 $01 $F0 $83 $D2 $00 $B1 $0C $E8 $16 $58 $89 $16 $E4 $6E $A3 $E2 $6E $05 $00 $B0 $83 $D2 $FF $A3 $D4 $6E $89 $16 $D6 $6E $58 $98 $99 $01 $F8 $83 $D2 $00 $B1 $0C $E8 $F5 $57 $89 $16 $E0 $6E $A3 $DE $6E $05 $00 $70 $83 $D2 $FF $A3 $D0 $6E $89 $16 $D2 $6E $C3
#Free up space near ship parts code, new teleporter code
%patch $447D $EB $36 $83 $3E $5074W $00 $74 $09 $E8 $4490W $5F $5E $8B $E5 $5D $C3 $E9 $00E6W
#Redirect teleporter to space
%patch $45BE $447FW


Teleport to secret level on death

When Keen dies he teleports to the secret level teleporter. This patch is INCOMPATIBLE with the teleport in-level patch and uses the (sometimes buggy!) 'complete x+1 levels to win' patch. (The number of levels needed to win the game is in blue.)

Patch: Keen 1
#Keen teleports on death to secret level location
%patch $8041 $E8 $E8 $FF $90 %patch $802C $FF $0E $C6 $AA $E8 $E6 $08 $C3 %patch $8020 $83 $BF $A6 $AA $01 $75 $1E $E8 $62 $01 $EB $29


Change map teleporter locations

In Keen 1, Keen can teleport FROM anywhere, but only to three specific locations. (Left, right and secret level) The values to be patches are in pixels. Since c map tile is 16 ($10) pixels the values become x\y co-ordinates * 16 in tiles. In the hex used for patches, this means 'times 10' (so 13, or $0D $00 becomes $D0 $00) The 0,0 point is the top left of the level (2 tiles offscreen.) and each tile in the level is 16x16 pixels. (A level editor may be handy, especially if it displays the x,y location of the cursor.)

Patch: Keen 1
#Change the teleporter locations
#Location 1 (left side of planet: 28,6)
%patch $158DF $01C0W %patch $158E3 $0060W
#Location 2 (right side of planet: 36, 5)
%patch $158E9 $0240W %patch $158ED $0050W
#Location 3 (secret level: 62,37)
%patch $158F3 $03E0W %patch $158F7 $0250W


Teleporting wins a level

This patch for keen 1 will win level 13 when Keen uses the in-level teleport. Since in the default game this is located in level 13, using this patch means he cannot replay the level by teleporting out of it. Looking at Patch:Game stats will allow the modder to change what level is marked as done, or even let it do things like reset Keen's score.

Note that this patch will need to be modified if using the 32 level patch. This patch, and all that are built on it is incompatible with all other $0AF2 using patches.

Patch: Keen 1
#Teleporting wins level 13
%patch $801D $E9 $8AD2W
#Mark level as done, call teleporter
%patch $0AF2 $C7 $87 $AAB8W $0001W $E8 $7E1EW $E9 $7522W


Map teleporter sprites

This is the value that indicates a Keen 1 map sprite is a teleporter. Both the values in this patch must be the same. By default this is $20, that is $21 is teleporter type 1 and so on.

Patch: Keen 1
#Value that makes a map sprite a teleporter
%patch $AF22 $0020W %patch $AF25 $0020W


Map teleporter tiles and sounds

Keen 1

For Keen 1 there are two parts to consider, departure and destination. Each has its own sequence and is split into 'snow' and 'dirt' as detailed in the tutorials below. The 'animation frames' thing is complicated. The teleporter tiles animate, so this is actually a sort of randomizer, the number of tiles frames the game picks from, which can be seen if the tile animation is removed. This means if animation is involved, it can make a teleporter use more than 4 tiles for its animation (By picking say, tiles from two 4-tile animations.) It is also possible to disable certain parts of the teleportation, but this has slight side effects.

Patch: Keen 1
#Teleport sound
%patch $AF6C $12
#Don't play teleport sound
%patch $AF6B $EB $07
#Arrival tiles used by teleporters:
%patch $AF69 $0156W
#Snow, departure animation
%patch $B0A4 $0156W
#Snow, destination animation
%patch $AFD7 $0062W
#Snow, departure replacement
%patch $B109 $0062W
#Snow, arrival replacement
#Departure tiles used by teleporters:
%patch $AF53 $0152W
#Dirt, departure animation
%patch $B08E $0152W
#Dirt, destination animation
%patch $AFC1 $0145W
#Dirt, departure replacement
%patch $B0F3 $0145W
#Dirt, arrival replacement
#Frames used in all animations (See notes above)
%patch $AF91 $0003W

Patch: Keen 1 teleporter tile patches
#Departure doesn't animate:
%patch $AF9A $EB $08
#Departure teleport is instant
%patch $AF9A $EB $26
#Departure tile not replaced (Stays as animation) best used with above patch
%patch $AFBE $EB $18
#Destination doesn't animate:
%patch $B0CC $EB $08
#Destination teleport is instant
%patch $B0CC $EB $26
#Departure tile not replaced (Stays as animation) best used with above patch
%patch $B0F0 $EB $18


Keen 3

For keen 3 the animation sequence will occur twice at *each* teleporter (four times in total), Keen will be invisible while it does. The 'frames' of the animation are the difference between the start and end values of the animation. (The second value MUST be larger than the first!)

Notice also Keen 3 has two teleporter sounds instead of one.

Patch: Keen 3
#Teleporter sounds
%patch $B988 $12
#Teleport go sound
%patch $BAEC $12
#Teleport arrive sound
#Don't play teleporter sounds
%patch $B987 $EB $06
#Teleport go sound disabled
%patch $BAEB $EB $06
#Teleport arrive sound disabled
#Change the tiles and animation:
%patch $B990 $0082W
#Start of animation sequence at teleporter Keen starts at
%patch $BA03 $0086W
#End of animation sequence at teleporter Keen starts at
%patch $B9F9 $0004W
#Animation speed
%patch $BAF4 $0082W
#Start of animation sequence at teleporter Keen arrives at
%patch $BB67 $0086W
#End of animation sequence at teleporter Keen arrives at
%patch $BB5D $0004W
#Animation speed
%patch $BA45 $0086W
#Tile appearing at teleport Keen left (after animation)
%patch $BBA9 $0086W
#Tile appearing at teleport Keen arrives at (after animation)


Keen 5

Patch: Keen 5
#Sounds
%patch $D40D $29
#Teleport leave sound
%patch $D645 $29
#Teleport arrive sound
%patch $D861 $3F
#Elevator leave sound
%patch $DA79 $3F
#Elevator arrive sound
#Don't play sounds
%patch $D40C $EB $0A
#Don't play Teleport leave sound
%patch $D644 $EB $0A
#Don't play Teleport arrive sound
%patch $D860 $EB $0A
#Don't play Elevator leave sound
%patch $DA78 $EB $0A
#Don't play Elevator arrive sound


Keen 6

Patch: Keen 6
#Sounds
%patch $D16C $29
#Teleport leave sound
%patch $D3A4 $29
#Teleport arrive sound
#Don't play sounds
%patch $D16B $EB $0A
#Don't play Teleport leave sound
%patch $D3A3 $EB $0A
#Don't play Teleport arrive sound


Keycards teleport Keen

This patch causes keycards to act like |teleporters, taking Keen to the map when obtained. Keen will have the keycard when he teleports. Difficulties may occur if this is used with the 'teleport in level' patch.

Patch: Keen 1
#Keycards teleport Keen
%patch $4513 $C7 $06 $6C60W $0002W $EB $5C


Tutorials

The map teleporters in Keen 1, 3 and 6 can be complicated, even when unpatched. The following information is to help modders use them correctly.


Keen 1 map teleporters

Keen 1 map teleporters are comparatively simple. There are only a six 'valid' sprite values for teleporters, two sets of three destinations. The teleporter locations have been detailed above, the teleporter 'style' is the tiles it uses when and after animating; these appear either 'white' or 'red' in the default Keen tileset.

              Sprite Number    Teleporter Style    Destination Number 
                 $21 (33)            Snow                  1 
                 $22 (34)            Snow                  2 
                 $23 (35)            Snow                  3 
                 $2D (45)            Dirt                  1 
                 $2E (46)            Dirt                  2 
                 $2F (47)            Dirt                  3 


Keen 3 map teleporters

Keen 3 map teleporters are considerably complex. In the game there are 16 'different types' of teleporter, based on the hex number system. Sadly this means to do any decent work on them you'll need to know how to convert numbers into hexadecimal.

A teleporter requires the correct sprite value in order to work. This is a value between 3840-4095 ($0F00-$0FFF) From now on we'll work with the hexadecimal numbers. A teleporter value has three important digits, $0Fxy. The first digit, F, tells the game it is dealing with a teleporter. The second digit tells the game which teleport the teleport IS. The third digit tells the game which teleport it teleports TO.

As an example the teleport value $0F02 means teleporter(F) zero (0) that will teleport to teleporter two(2). In decimal the value of a teleporter is 3840 + [type# * 16] + [arrival#].

Things get more complicated from here. The game works such that when Keen is teleported, it scans the level for the first teleporter value that matches. Thus if you have two teleporters of type 5 in the level, the top-leftmost will be the arrival point of ANY teleporters going to type 5 ALL THE TIME. (If you try to teleport to a type that is not on the map, the game will crash.)

In the original game all sixteen types are used as follows:


 #  Dec   Hex     Goes to...
 0: 3842 [F02]    Goes to 2
 1: 3859 [F13]    Goes to 3
 2: 3877 [F25]    Goes to 5
 3: 3889 [F31]    Goes to 1
 4: 3911 [F47]    Goes to 7
 5: 3922 [F52]    Goes to 2
 6: 3947 [F6B]    Goes to 11
 7: 3955 [F73]    Goes to 3
 8: 3980 [F8C]    Goes to 12
 9: 3988 [F94]    Goes to 4
10: 4014 [FAE]    Goes to 14
11: 4025 [FB9]    Goes to 9
12: 4032 [FC0]    Goes to 0
13: 4063 [FDF]    Goes to 15
14: 4072 [FE8]    Goes to 8
15: 4094 [FFE]    Goes to 14


We can see that at default, there are only 13 locations Keen can teleport to, how unlucky. (2, 3 and 14 are repeated twice) Whenever building 'teleporter puzzles' in Keen 3, keep the following in mind:


  • You can have as many teleporters as you wish (leaving destinations) BUT-
  • You can have only 16 arrival destinations.
  • If there ARE multiple copies of a teleporter type, only the top-leftmost is an arrival destination.
  • If a teleport points TO a type it MUST be in the level
  • Bottom-right teleporters then may be one-way (Can teleport from, but not TO)
  • You can have a 'hidden' teleport by placing a sprite, but not the tile (Can only be teleported to, at first.)


Keen 5 map teleporters

These are technically teleporters but covered under Patch:Elevators


Keen 6 map teleporters

Keen 6 teleporters are relatively simple, behaving much like the doors in the game. They consist of a special teleporter tile and a sprite value. When Keen touches the tile the teleportation sequence begins. This involves Keen animating and moving upwards, a special teleporter zap animation and Keen moving to the teleporter location. Keen then moves downwards under another teleporter zap animation.

The only thing governing where Keen goes is the value of the sprite on the teleport tile (In hex) so a value of 4660 ($1234) will send Keen to 18,52 ($12,$34) on the map. This can be a bit confusing if the map editor being used doesn't support hexadecimal.

By default there are four map teleporters connected into two pairs. It is possible to have as many teleporters as you wish going to any locations.