Patch:Map (Keen 4)
This page contains patches that relate to the map in Keen 4, that is, things that can only be done on the map.
- 1 What level is the map
- 2 Keen can exit the map level by going offscreen
- 3 No flipping flags\No flags
- 4 Foot on map
- 5 Wetsuit and swim message
- 6 Teleporters on the map
- 7 Stop Ctrl, Alt, Space entering levels
What level is the map
These patches alter what level the map is. There are several aspects to this which potentially allows multiple map levels.
Level game starts in
This patch causes the player to start the game in a different level than the map. (Level 0) The values of the level variable given here will start the game in the default BWB level.
There is one minor side effect to this patch; the high word of the Extra Keen At score is not set to 0. What this means is that the game cannot start with an Extra Keen At score of more than 65'000 or so without a slightly more complicated patch being used.
|Patch: Keen 4|
Level Keen returns to on completing a level
This patch changes what level the player returns to when he completes any level. (Including level 0, the default map.) By default this is level 0, but it can be any other game level if desired. If the starting level is not changed, (See above) then the game will in effect have a 'starting map' that may never be accessed again after a level is entered.
This doesn't affect what level Keen goes to when he rescues a Council Member however. (See below.)
|Patch: Keen 4|
Level Keen returns to on saving a Member
This patch changes what level the player returns to when he rescues a Council Member. By default this is level 0, but it can be any other game level if desired. This can allow a 'special map' that can only be accessed by saving a member.
This doesn't affect what level Keen goes to when he completes a level however. (See above.)
|Patch: Keen 4|
Level with map-type scrolling
This patch allows the modder to change what levels behave as map-type levels. By default both the map (level 0) and the Well Of Wishes;(level 17) are map-type levels. map-type levels scroll differently and cannot be 'won' by moving off the left or right sides of the level. They also don't directly kill Keen when he leaves the top or the bottom; another piece of code does this.
The patch below has three parts, first what is checked for in brown ($A7EDW, the current level); second the value in blue ($00 = 0, so level 0); and thirdly the jump, again in brown. ($74, only jump if...) The net result is that if the current level is 17 or 0, the 'normal level' code is skipped.
|Patch: Keen 4|
No map, just go to next level
This patch alters the 'complete level' code so that Keen will not return to the map but instead moves to the next level A side effect of this is that Keen can complete level 0 and go to level 1. (No map.) Levels are not marked as done, but this has no effect in the default game.
This also means the 'one moment' window will not appear when exiting the original map level. (Level 0.) It is compatible with most other patches on this wiki. Note that Keen will go to the map (Level 0) if he rescues a Council Member.
The second version of the patch sets a 'maximum level' (marked in blue) that Keen cannot advance past; finishing this level simply causes it to reload. The third version of the patch is the same, except that Keen is sent back to level 0 on finishing the highest level.
|Patch: Keen 4|
Keen can exit the map level by going offscreen
This patch changes things so that Keen can 'win' the map level by going offscreen. (by default nothing happens, Keen can wander offscreen as far as he likes.) When winning Keen will be sent back to the map by default, basically restarting the level.
|Patch: Keen 4|
No flipping flags\No flags
In Keen 4 the flags 'flip' toward the level flag holder when (and only when) the level is first completed. The first patch here makes it so that flags always spawn in holders, with no flipping. The second makes it so nothing is spawned when levels are first completed.
|Patch: Keen 4: No flipping flags|
The first patch here makes flags always flip, due to the way this works, the flag of the lowest level Keen has completed will flip normally, the other levels will have no flipping flag, but a flag will appear in the holder about a second after the level is exited. This is a bit odd, but may be useful. The second patch prevents sitting flags appearing on levels Keen has already completed but keeps the flipping flag (and thus sitting flag produced) that appears when a level is first done. Finally the third patch completely removes flags from the map.
|Patch: Keen 4: No sitting flags|
Foot on map
When Keen exits a level by touching the foot, he will appear on the map as the 'riding the foot' sprite. Depending on what level he just left he will then move to one of two locations. Patches relating to the foot itself can be found at Patch:Foot.
This disables the foot entirely so that Keen appears on the map as normal if he wins a level with the foot.
|Patch: Keen 4|
This changes the destination the foot moves to. Which destination depends on the level Keen has just played. If it is the secret level then he will go to destination 2, otherwise to destination 1. The first trip moves in a downwards direction, if the level where Keen can get the foot is below this destination, problems can arise. The second is in an upwards direction and trouble can arise if the secret level is below this.
There is also a patch that makes the foot take Keen to a relative location, but it may have undesirable side effects.
|Patch: Keen 4|
Wetsuit and swim message
This relates to the wetsuit and the 'I can't swim' message.
This message is displayed whenever something with the 'map Keen tile collision' hits a tile with one of the 'water entrance' properties. It is thus possible to get other things than Keen to produce the message and not only on the map. However, using other sprites tends to produce the dreaded 'infinitely repeating message' problem.
Using this patch requires knowledge of Patch:Game stats and Patch:Text patches. When the window is opened it stores a graphic chunk in memory, then displays it in the window. The image is right aligned (its rightmost edge touches the right side of the window.) according to the 'image width' variable. This doesn't have to be the actual width of the image and can be used to position the image in the window. (For example, by default the displayed image is 48 pixels wide and the width value keeps it on the right of the window. If the value is made larger than the actual image width then the image appears more left in the window.) A matching value is the ' horizontal text alignment' variable which stops the text from spilling over onto the image. By default it matches the image width. Finally there is the 'vertical text alignment' which controls how far down from the top of the window the text appears.
In this case only one chunk is cached and displayed, so the two values MUST be the same. Note also there is a pause before the window can be dismissed. Any key pressed during this time 'won't count'.
|Patch: Keen 4|
Complete window code
This is the complete swim window code. On the first line chunk 111 is cached for display. On the second line the window's height and width are set. On the third line chunk 111 is displayed in the window. The fourth line contains the 'image width variable' used to position the text in the window along with the image.
The text itself is called at the end of line 5.It is positioned $0C pixels down from the window top and $30 pixels left on the window's right side. At the start of line 7 is a pause where the window can't be dismissed. (Vital to stop the player accidentally skipping it.)
|Patch: Complete Can't swim window code|
What triggers 'can't swim'
This is what the map looks for when either letting Keen swim or not. By default if the suit variable is NOT equal to 0 then Keen can swim. It is thus possible to make the trigger something like a gem or completed level. Looking at Patch:Jump conditions will allow you to make it so Keen can always or never swim on the map.
|Patch: Map suit check|
Keen doesn't interact with map water
This patches makes it so that Keen doesn't interact with water entrances or exits at all.
|Patch: Keen doesn't interact with map water|
Levels Keen uses map tile interaction in
This patch controls what levels the player sprite uses the map tile interaction in. By default this is only in level 0, the map. Noe that if Keen uses this code he cannot use the 'normal' tile interaction that allows him to pick up item tiles.
|Patch: What level(s) Keen uses map tile interaction in|
Teleporters on the map
It is possible to overwrite the Miragia sprite with a teleporter. This will utterly erase the sprite's original function but allow Keen to teleport around the map.
As set up by the patch below the teleport consists of a 3x3 square of tiles with a teleporter sprite in the middle (The sprite will resemble Map Keen.) Keen must touch the teleport sprite (Located at the middle tile, tile 5) to initiate a teleport. He will be 'frozen while the start teleport square animates four frames before becoming invisible and moving with the screen. When Keen reaches his destination he will appear a tile below it and move down slightly. A sound also plays on teleport.
Keen cannot teleport to an area of the map blocked by a scrollbar as the camera moves with him. The 3x3 tiles must be animating with a delay of 0, just like door tiles. The teleport should be set up as follows, with at least two teleporters being placed in the level:
S I 1 2 3 4 5 6 7 8 9
Here the numbers are the 3x3 animating square, 'S' is where the Miragia sprite is placed in the level and 'I' is the destination ($XXYYW) that the teleporter will send Keen to. Each teleporter can only send Keen to one destination. Teleporters can be adapted for either the map or normal levels, but not both. (Since the teleporting Keen actions will either return Keen to map Keen or in-level Keen.) The patch is as follows with brief explanation to follow.
For a thorough breakdown of the patch, including a working mod set up to use it see https://dl.dropboxusercontent.com/u/3786745/telepatch.zip
|Patch: Compact Miragia teleport sprite patch|
The first part of the patch deals with sprite actions; six are needed for the teleporter and two for Keen. The first action is the 'resting' action for the teleporter; what it does when nothing else is happening. It animates to itself, uses one of Map Keen's animations and also a special collision that is triggered when Keen touches it. The next four actions are used when the teleporter is 'active'; each action does nothing more than animate a 3x3 block of tiles one frame. Finally the sixth action teleports Keen which uses a special behavior to move Keen across the map.
Keen meanwhile has two actions. Neither 'do' anything, they merely sit there and stop the player from moving during the teleport sequence. They return Keen to the 'stand on map' action. Changing $15A0W to 'standing Keen' will make the patch work in normal levels but not on the map.
Following this is the spawn code for the teleporter, which places it in the level. The sprite is given type 1, activity 2, an action of $1DFCW (The resting teleporter action.) and no clipping. It is also spawned $0200W,$0200W from where it is placed, or 2 tiles down and two tiles right, as reflected in the tile-sprite setup for this patch.
Next is the resting teleport's sprite collision. This reacts to Keen's sprite type. This means Keen must touch the teleport sprite to activate it. When he does so sound 7 plays, the teleporter's action is changed to $1E1AW (Active teleporter) and Keen's action is changed to $1EB0W (Teleporting Keen 1).
The second to last block involves the teleporter's teleporting Keen behavior; this is used by the teleporter and not by Keen. It takes Keen and first sets his foreground to 1 and removes his clipping; this is so he can pass through solid tiles while teleporting and not look odd. It also changes his action (to teleporting Keen 2) When Keen arrives at his destination his clipping is set to 1 (So he doesn't walk through solid stuff.) and his vertical direction is set to 1. (On the map this makes him move down, away from the teleporter destination slightly.)
The final and largest part of the patch deals with the active teleporter's behavior. This animates a 3x3 block of tiles. The size of the block can be changed by altering the two blue $0003Ws in the patch. The second blue $0001W alters the foreground tiles, setting this to 0 makes it alter the background tiles instead. (The first marks the fact that 1x1 tiles will be altered each time, it is best not to interfere with this.)
Teleporter patch without tile animation
This version of the above patch Teleports Keen without animating the map tiles or teleporter sprite. This allows the teleporter to be much more compact and versatile, if less showy. it works nearly identically to the patch above and all notes also apply here. Note that the 'pause' action is used to allow a small pause between Keen touching the teleporter and being teleported, otherwise he teleports instantly.
The one difference is that the teleporter spawns exactly where placed on the map instead of two tiles down and left.
|Patch: Compact Miragia teleport sprite patch less tile animation|
Stop Ctrl, Alt, Space entering levels
These patches disable various keys on the map so that the player cannot use them to enter levels. Different lines are needed for when Keen is sitting still or moving. It is also possible to disable entering levels completely, in which case some other way for Keen to enter levels will be required.
|Patch: Keen 4|