Patch:Levels (Galaxy)

From KeenWiki
Jump to navigation Jump to search

This page deals with patches relating to levels in Keen galaxy and Dreams. As this is a complex topic there are a number of other pages relating to level patching:


Editing levels

A number of editors exist to edit Keen Galaxy levels. The oldest of these is the original, TED5. The newest and most advanced is Abiathar. In order to play modified Keen Galaxy levels patching is required. A 'map header' file must be patched into the executable. The name of the game maps themselves can be changed, but this is not necessary. Following are patches relating to patching custom levels in Keen Galaxy.

Keen Dreams has a slightly different setup, requiring the patching of both a maphead and (depending on editor being used.) a mapdict file.

Patch new levels into Keen Galaxy

#Keen 4 :
%maphead maphead.ck4

#Keen 5 :
%maphead maphead.ck5

#Keen 6 :
%maphead maphead.ck6

Keen Galaxy game maps filename

#Keen 4 :
%patch $1334F  [$3AE2W] #Text called from
%patch $32952 "GAMEMAPS.CK4" $00

#Keen 5 :
%patch $142EC  [$3238W] #Text called from
%patch $33578 "GAMEMAPS.CK5" $00

#Keen 6 :
%patch $12E80  [$34E2W] #Text called from
%patch $34212 "GAMEMAPS.CK6" $00


Level names

Level names are a type of text patch. Details on changing them can be found on the Level Entry Window page.


Lowest and highest levels accessible from map

There are two limits as to what levels the player can access from the main map. The first is the lowest level (By default level 0, meaning you can access the map from the map.) and the second is the highest level (by default level 18, even if this many levels aren't provided by the game.) The difference between these two values is the number of levels accessible on the map. See also Patch:Jump conditions. Keen Dreams works slightly differently but the concept is the same.

Range of levels Keen can enter from the map

#Range of levels Keen can enter from the map in Keen 4
%patch $DF56 [$C000W] {$76} #Minimum
%patch $DF5D [$C012W] {$77} #Maximum

#Range of levels Keen can enter from the map in Keen 5
%patch $D2BB [$C000W] {$76} #Minimum
%patch $D2C2 [$C012W] {$77} #Maximum

#Range of levels Keen can enter from the map in Keen 6
%patch $D01A [$C000W] {$76} #Minimum
%patch $D221 [$C012W] {$77} #Maximum

#Range of levels Keen can enter from the map in Keen Dreams
%patch $6A46 [$03] {$7C} #Minimum +3
%patch $6A4B [$12] {$7F} #Maximum +3


Extra levels

There are two limits to the number of levels in Keen Galaxy and Dreams. The first is a 'soft' limit' a simple check used to see if a level on the map can be entered. This is easily changed, allowing Keen to enter other levels. However the game will immediately crash if the level involved does not also have a valid name, level entry text and song. The second limit is a 'hard' limit of 25 levels determined by how the game's memory is set up. This is almost impossible to change. As such the following patch has additional sections setting up the level texts and songs. The extra levels will use the High Score level's name, entry and music. The example patch allows 24 levels in Keen 4 (The maximum possible without a more complex patch.)

For what the long lists mean see level text and Patch:Music. Note that adding extra levels does not affect the Bean-With-Bacon-Megarocket level numbers, this means the extra levels will likely be BWB-type. (Replayable) unless the BWB level(s) patch is altered.


Keen 4

Keen 4

#Allow 24 levels in Keen 4 v1.4:
#First increase the number of levels we can access from the map to maximum (+6)
%patch $DF5D [$18] #Number of levels enterable ($18 = 24)
%patch $8CA4 [$18] #Number of level song entries (24, see below)

#Give extra levels valid stuff:
#Level name pointers:
%patch $30764 $1F040000RL #Map
              $1F050000RL #Level 1
              $1F060000RL #Level 2
              $1F070000RL #Level 3
              $1F090000RL #Level 4...
              $1F0B0000RL
              $1F0C0000RL
              $1F0D0000RL
              $1F0E0000RL
              $1F0F0000RL
              $1F100000RL
              $1F110000RL
              $1F130000RL
              $1F150000RL
              $1F180000RL
              $1F1A0000RL
              $1F1B0000RL
              $1F1C0000RL
              $1F1D0000RL #Bwb Rocket
              $1F1C0000RL #Hall of fame
              $1F1C0000RL
              $1F1C0000RL
              $1F1C0000RL
              $1F1C0000RL
              $1F1C0000RL

#Level entrance text pointers
%patch $307C8 $1F1F0000RL #Map
              $1F210000RL #Level 1
              $1F240000RL #Level 2
              $1F260000RL #Level 3...
              $1F290000RL
              $1F2D0000RL
              $1F300000RL
              $1F330000RL
              $1F350000RL
              $1F380000RL
              $1F3A0000RL
              $1F3D0000RL
              $1F400000RL
              $1F430000RL
              $1F470000RL
              $1F4B0000RL
              $1F4E0000RL
              $1F510000RL
              $1F540000RL #Bwb Rocket
              $1F510000RL #Hall of fame
              $1F510000RL
              $1F510000RL
              $1F510000RL
              $1F510000RL
              $1F510000RL

#This is the music played in each level:
#             VALUE   LEVEL                 MUSIC PLAYED         LEVEL No
%patch $2F206 [$0000W]  #Map                  (Shadowlands)          0
              [$0004W]  #Border Village       (Kick in the Pants)    1
              [$0003W]  #Slug Village         (Slug Village)         2
              [$0003W]  #Perilous Pit         (Slug Village)         3
              [$0002W]  #Cave of Descendants  (Too Hot)              4
              [$0002W]  #Chasm of Chills      (Too Hot)              5
              [$0004W]  #Crystalus            (Kick in the Pants)    6
              [$0003W]  #Hiliville            (Slug Village)         7
              [$0001W]  #Sand Yego            (Eat your Veggies)     8
              [$0001W]  #Miragia              (Eat your Veggies)     9
              [$0001W]  #Lifwater Oasis       (Eat your Veggies)    10
              [$0002W]  #Pyramid of Moons     (Too Hot)             11
              [$0002W]  #Pyramid of Shadows   (Too Hot)             12
              [$0002W]  #Pyramid of Ancients  (Too Hot)             13
              [$0002W]  #Pyramid of Forbidden (Too Hot)             14
              [$0002W]  #Isle of Tar          (Too Hot)             15
              [$0002W]  #Isle of Fire         (Too Hot)             16
              [$0001W]  #Well of Wishes       (Eat your Veggies)    17
              [$0003W]  #Bwb Megarocket       (Slug Village)        18
              [$FFFFW]  #High scores          (No music, "Fanfare") 19
              [$FFFFW]  #Extra level 1        (No music, "Fanfare") 20
              [$FFFFW]  #Extra level 2        (No music, "Fanfare") 21
              [$FFFFW]  #Extra level 3        (No music, "Fanfare") 22
              [$FFFFW]  #Extra level 4        (No music, "Fanfare") 23
              [$FFFFW]  #Extra level 5        (No music, "Fanfare") 24


Keen 5

Keen 5

#Allow 24 levels in Keen 5 v1.4:
#First increase the number of levels we can access from the map to maximum (+6)
%patch $D2C2 [$18] #Number of levels enterable ($18 = 24)
%patch $8C20 [$18] #Number of level song entries (24, see below)

#Level name pointers:
%patch $31AB4 $20040000RL #Map
              $20050000RL #Level 1
              $20070000RL #Level 2
              $20080000RL #Level 3...
              $200A0000RL
              $200C0000RL
              $200E0000RL
              $20100000RL
              $20120000RL
              $20140000RL
              $20160000RL
              $20180000RL
              $201A0000RL
              $201C0000RL
              $201D0000RL
              $201E0000RL
              $20100000RL #High scores
              $00000000L  #Extra level 1
              $00000000L  #Extra level 2
              $00000000L  #Extra level 3
              $00000000L  #Extra level 4
              $00000000L  #Extra level 5
              $00000000L  #Extra level 6
              $00000000L  #Extra level 7
              $00000000L  #Extra level 8
              $00000000L  #Extra level 9

#Level entrance text pointers
%patch $31B18 $201F0000RL #Map
              $20220000RL #Level 1
              $20250000RL #Level 2
              $20280000RL #Level 3...
              $202B0000RL
              $202E0000RL
              $20310000RL
              $20340000RL
              $20370000RL
              $203A0000RL
              $203D0000RL
              $20400000RL
              $20440000RL
              $20470000RL
              $204A0000RL
              $204D0000RL
              $00000000L  #Extra level 1
              $00000000L  #Extra level 2
              $00000000L  #Extra level 3
              $00000000L  #Extra level 4
              $00000000L  #Extra level 5
              $00000000L  #Extra level 6
              $00000000L  #Extra level 7
              $00000000L  #Extra level 8
              $00000000L  #Extra level 9

#This is the music played in each level:
#             VALUE   LEVEL                      MUSIC PLAYED            LEVEL No
%patch $3067A [$000BW]  #Map                       (Omegamatic)              0
              [$0005W]  #Ion Ventilation System    (Wednesday on the Beach)  1
              [$0007W]  #Security Center           (Security Center)         2
              [$0009W]  #Defense Tunnel Vlook      (Be Sphereful)            3
              [$000AW]  #Energy Flow Systems       (Make it Tighter)         4
              [$0009W]  #Defense Tunnel Burrh      (Be Sphereful)            5
              [$000AW]  #Regulation Control Center (Make it Tighter)         6
              [$0009W]  #Defense Tunnel Sorra      (Be Sphereful)            7
              [$000AW]  #Neutrino Burst Injector   (Make it Tighter)         8
              [$0009W]  #Defense Tunnel Teln       (Be Sphereful)            9
              [$000AW]  #Brownian Motion Inducer   (Make it Tighter)         10
              [$0003W]  #Gravitational Damping Hub (Snooping)                11
              [$000DW]  #Quantum Explosion Dynamo  (QED)                     12
              [$0004W]  #Korath III Base           (Bagpipes)                13
              [$000CW]  #Ending\Level 14           (Fanfare)                 14
              [$0002W]  #High Scores               (High Scores)             15
%patch $3069C [$0001W]  #Scrolling Story\ L16      (Armageddon Machine)      16
              [$0000W]  #Game Over\ L17            (Came In)                 17
              [$0008W]  #Help\ L18                 (Help)                    18
              [$0002W]  #Extra level 1             (High Scores)             19
              [$0002W]  #Extra level 2             (High Scores)             20
              [$0002W]  #Extra level 3             (High Scores)             21
              [$0002W]  #Extra level 4             (High Scores)             22
              [$0002W]  #Extra level 5             (High Scores)             23


Keen 6

Keen 6

#Allow 24 levels in Keen 6 v1.4:
#First increase the number of levels we can access from the map to maximum (+6)
%patch $D221 [$18] #Number of levels enterable ($18 = 24)
%patch $8A88 [$18] #Number of level song entries (24, see below)

#Level entrance pointers
%patch $32516 $1EF40000RL #Level 0
              $1EF5000BRL #Level 1
              $1EF7000DRL #Level 2
              $1EF9000BRL #Level 3
              $1EFC0007RL #Level 4
              $1EFF0005RL #Level 5
              $1F010001RL #Level 6
              $1F040003RL #Level 7
              $1F060007RL #Level 8
              $1F08000FRL #Level 9
              $1F0B0000RL #Level 10
              $1F0F0001RL #Level 11
              $1F100006RL #Level 12
              $1F11000BRL #Level 13
              $1F130000RL #Level 14
              $1F140005RL #Level 15
              $1F15000ARL #Level 16
              $20100000RL #High scores
              $00000000L  #Extra level 1
              $00000000L  #Extra level 2
              $00000000L  #Extra level 3
              $00000000L  #Extra level 4
              $00000000L  #Extra level 5
              $00000000L  #Extra level 6
              $00000000L  #Extra level 7

#Level name pointers
%patch $324B2 $1F16000FRL #Level 0
              $1F17000CRL #Level 1
              $1EF8000DRL #Level 2
              $1F190001RL #Level 3
              $1EFD000FRL #Level 4
              $1F000007RL #Level 5
              $1F1A0002RL #Level 6
              $1F050006RL #Level 7
              $1F07000ERL #Level 8
              $1F0A0001RL #Level 9
              $1F1B0006RL #Level 10
              $1F0F000DRL #Level 11
              $1F110002RL #Level 12
              $1F120007RL #Level 13
              $1F13000CRL #Level 14
              $1F150001RL #Level 15
              $1F15000ARL #Level 16
              $20100000RL #High scores
              $00000000L  #Extra level 1
              $00000000L  #Extra level 2
              $00000000L  #Extra level 3
              $00000000L  #Extra level 4
              $00000000L  #Extra level 5 
              $00000000L  #Extra level 6
              $00000000L  #Extra level 7

#This is the music played in each level:
#             VALUE   LEVEL                      MUSIC PLAYED            LEVEL No
%patch $3103E [$0005W]  #Map                            (Aliens Ate My Babysitter)  0
              [$0003W]  #Bloogwaters Crossing           (Faster)                    1
              [$0001W]  #Guard Post One                 (Brer Tar)                  2
              [$0008W]  #First Dome of Darkness         (Mamba Snake)               3
              [$0008W]  #Second Dome of Darkness        (Mamba Snake)               4
              [$0008W]  #Bloogdome                      (Mamba Snake)               5
              [$0007W]  #Bloogton Manufacturing         (Metal)                     6
              [$0002W]  #Bloogton Tower                 (To the Future)             7
              [$0007W]  #Bloogfoods, Inc.               (Metal)                     8
              [$0001W]  #Guard Post 2                   (Brer Tar)                  9
              [$0003W]  #Bloogville                     (Faster)                    10
              [$0002W]  #BASA                           (To the Future)             11
              [$0001W]  #Guard Post 3                   (Brer Tar)                  12
              [$0004W]  #Bloogbase Recreational District(Space Funk)                13
              [$0004W]  #Bloogbase Management District  (Space Funk)                14
              [$0006W]  #Bloog Control Center           (Ominous)                   15
              [$0002W]  #Blooglab Space Station         (To the Future)             16
              [$0000W]  #Bean-with-Bacon Megarocket     (A World of Wonderment)     17
              [$0000W]  #High Scores                    (A World of Wonderment)     18
              [$0002W]  #Extra level 1                  (High Scores)               19
              [$0002W]  #Extra level 2                  (High Scores)               20
              [$0002W]  #Extra level 3                  (High Scores)               21
              [$0002W]  #Extra level 4                  (High Scores)               22
              [$0002W]  #Extra level 5                  (High Scores)               23


Display 'Level not available in demo' message

This patch adds to Keen 4 the demo release functionality that when Keen attempts to enter a level on the map that is not included in the demo a message appears telling the player that they cannot do this, before reloading the map level.

As a side effect entering levels produces no sound and the game's winning code does not work. This should not be an issue with demo releases however. In this patch the maximum enterable level is level 4. The line of $90s stops the music being set to the ending sequence music when the patch runs.

The final bit of code is optional and will cause the map's music to play uninterrupted while the message shows, rather than playing the default ending music.

Keen 4

#What to display with nonexistent levels
%patch $9CB8 $1288W #Text
%patch $9CC4 $9FFDW #Memory variable 1
%patch $9D7D $9FFDW #Memory variable 2

#Level state for entering nonexistent levels - Display image, reload map
%patch $6BCD $0EB2W #Got Foot state ($08)
%patch $6AF2 $0E $E8 $F150W  $9A $16540139RL     $9A $1D060999RL     $9A $09150B2DRL
             $C7 $06 $7A68W $0000W  $C7 $06 $7A70W $0002W  $EB $0B

#Trigger message for levels above 4
%patch $DF7C $83 $3E $7A68W  [$04] $76 $05 $83 $06 $7A70W  $05

#Don't stop music during message
%patch $9153 $90 $90 $90 $90
%patch $9CDA $90 $90 $90 $90 $90


Infinite replays of some or all levels

This allows a player to play the level as many times as they want. The level is not marked as completed when Keen exits it. These levels are known as 'BWB levels' as the only level this is noticeable in by default is the BWB. The patch uses jump conditions.

Keen 4

#BwB levels: all levels above 17
%patch $60FD $11 $77

Keen 5

#BwB levels: all levels above 17
%patch $60B3 $11 $77

Keen 6

#BwB levels: all levels above 16
%patch $5ECD $10 $77


Win game on entering a specific level from map

This patch causes the game to automatically be won when the player attempts to enter a certain level from the map. Instead of playing the level entry sound the player is taken directly to the ending sequence. As a side effect this moves the level entry sound, which becomes the final blue value in the patch.

The specific level is the first blue value, on line 1. Here it is level 13, $0D. The value $000FW is what wins the game and is the level state the game is set to.

Keen 5

#Automatically win game when entering level 13:
%patch $D2E6 $0F920545RL
%patch $FE65 $55 $8B $EC $56 $8B $76 $06 $83 $3E $6F68W  [$0D] {$75} $06 $C7 $06
             $6F70W [$000FW]   $EB $0C $B8 [$000CW]  $50 $9A $196E09EFRL     $83
             $C4 $02 $5E $5D $CB


Complete levels to win

Keen Galaxy has a 2-level demo trial parameter (/DEMO switch). By tweaking this code a little bit, it can be used to end the game after a certain level is beaten. If you want to make a "trial demo" of your own, you can patch this in as well. More than one level can be the 'win' level, see Patch:Jump conditions. The last line is not necessary and should be omitted except when making a trial demo.

Keen 4

#MAKE GAME END AFTER LEVEL X
#Always check to see if level X was beat, even if not in demo mode.
%patch $6B4E $90 $90

#Specify level that must be beaten to win game (default is 2)
%patch $6B54 [$02] {$75}

#Win the game instead of going to high scores
%patch $6B57 $EB $99

#Enable "2 level demo" parameter by default (Not necessary)
%patch $3E90 $90 $90


Tile replacement

By default when Keen completes a level all of the tiles that have a specific infoplane (sprite) value on them will be replaced with tile 0, essentially deleting them from the level. This is used to make obstacles on the map that vanish on level completion.


Marker sprite

By default the marker sprite value is $D0xx. The level number is taken away from the sprite value and if it equals $D000 the tile is replaced. Changing the jump To $EB will stop any tiles being replaced

Marker sprite

#D0xx Marker sprite - Keen 4
%patch $6120 [$D000W]  {$75}

#D0xx Marker sprite - Keen 5
%patch $60D6 [$D000W]  {$75}

#D0xx Marker sprite - Keen 6
%patch $5EF0 [$D000W]  {$75}


Replacement tile

By default the replacement tile is tile 0, which in effect deletes the tile. This is not necessarily the case however and the replacement tile can be any valid tile.

Replacement tile

#D0xx Replacement tile - Keen 4
%patch $6130 [$0000W]

#D0xx Replacement tile - Keen 5
%patch $60E6 [$0000W]

#D0xx Replacement tile - Keen 6
%patch $5F00 [$0000W]


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 (except Keen 5 where the player will start in the High Scores level due to the game lacking a BWB level proper.)

Note that this does not change what the map level is; on exiting levels Keen will return to the map (level 0) and only the map will do such things as mark levels as done.

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.

Keen 4

#Keen starts game in the BWB
%patch $5CBB {$7A68W} [$0012W]

Keen 5

#Keen starts game in the BWB
%patch $5C8F {$6F68W} [$000FW]

Keen 6

#Keen starts game in the BWB
%patch $58AF {$75A4W} [$0011W]

Keen dreams

#Keen starts game in the boss level
%patch $3C0C {$7124W} [$000FW]


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.)

Keen 4

#Level Keen returns to on completing a level
%patch $6B33 {$7A68W} [$0000W]


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.)

Keen 4

#Level Keen returns to on saving a Member
%patch $6AEB {$7A68W} [$0000W]


Which level can't be exited by going offscreen

Another feature of the map is that it cannot be exited when Keen wanders off the left and right sides. The first patches control which level(s) this is. The second patches eliminate this entirely, allowing the player to exit the map level as if it were a regular level.

Keen 4

#Level(s) that cannot be exited by going off level sides
%patch $9051 {$A7EDW}  [$00] {$74}

#Level 0 can be exited by going off level sides
%patch $904F $EB $05

Keen 5

#Level(s) that cannot be exited by going off level sides
%patch $8FC3 {$9E55W}  [$00] {$74}

#Level 0 can be exited by going off level sides
%patch $8FC1 $EB $05

Keen 6

#Level(s) that cannot be exited by going off level sides
%patch $8E2B {$A97BW}  [$00] {$74}

#Level 0 can be exited by going off level sides
%patch $8E29 $EB $05


Levels map tile code is used in

In Keen Galaxy and Dreams there are two 'player tile interactions' that are used by the current player sprite in addition to that sprite's own tile interaction code. The 'level tile code' is responsible for the player's interactions with items, gem holders and deadly tiles while the 'map tile code' is responsible for the player's interaction with map teleporters and water entrances.

By default only in level 0 does the player sprite use the map tile code; otherwise the level tile code is used instead. This can however be changed.

Levels map tile code is used in

#What level(s) Keen uses map tile interaction in -Keen 4
%patch $8FBC {$A7EDW} [$00] {$74}

#What level(s) Keen uses map tile interaction in -Keen 5
%patch $8F2E {$9E55W} [$00] {$74}

#What level(s) Keen uses map tile interaction in -Keen 6
%patch $8D96 {$A97BW} [$00] {$74}


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 section of this patch makes the map level behave like a regular level, Keen can get items in it and exit it normally. It is optional but probably a good idea to include as it allows level 0 to be used as a regular level.

Keen 4

#Winning level goes to next level
%patch $6B1E $FF $06 $7A20W  $90 $90 $90
%patch $6B31 $A1 $7A20W  $A3 $7A68W
%patch $6B3D $EB $0A

#Level 0 is a regular level
%patch $904F $EB $06
%patch $904F $EB $05


Misc

Keen can exit Well of Wishes by going offscreen

This patch relates to the Well Of Wishes in Keen 4. It changes the level so that Keen can exit it in the same way as normal levels, by going off the edge of the screen. Further patches can be found on the linked page. As a side effect the level scrolling is altered slightly.

Keen 4

#Keen can exit the well of wishes by going offscreen (like normal levels, changes scrolling)
%patch $905B $90 $90


Connect two levels in Keen 4

This patch connects two levels in Keen 4, that is to say, when Keen wins a certain level, instead of proceeding to the map level he proceeds to the next level. (In this patch the connected levels are level 2 and level 3.) This patch can be expanded so that several levels work this way, allowing Keen to enter a level and then proceed along a 'chain' of levels before at some point returning to the map.

The first line contains the linked level (here level 2) and conditions (here only level 2). Everything else is 'complete level' code moved to fit the patch and should not be altered. The exception is the final line, %patch $6AF0 $33; this line makes the patch also apply to the Council Member rescues; without the line Council members will return Keen to the map, with the line they can send him to the next level.

Note that on returning to the map only the latest completed level will have its flag appear in the holder, since only one flag can be placed per map appearance. Other completed levels will not be marked as done until Keen appears on the map a second time (Loads a game, dies, wins a level, etc.) but will not be reenterable.

Keen 4

#Level 2 leads to level 3 instead of map
%patch $6B25 $83 $3E {$A7EDW}  [$02] {$74} $06 $C7 $06 {$7A68W}  [$FFFFW]  $FF $06
          {$7A68W} $B8 [$000DW]  $50 $9A $187409F1RL     $83 $C4 $02 $A1 {$A7EDW}
             $A3 {$A7C2W}  $8B $1E {$A7EDW}  $D1 $E3 $C7 $87 {$7A1EW}  [$0001W]  $EB $46
%patch $6AF0 $33


Connect two levels in Keen 5

This somewhat convoluted patch creates two new sprites 'Up level', which sends Keen to the next level in the game, and 'Win level' which wins the current and previous level. Both sprites are 'activated' by Keen simply standing in the same place as they are. If the 'second' level is not linked in the map then it will be reachable only via this sprite. If the second level is won via the win level sprite then both levels will be in effect 'linked'; Keen will enter the first level, progress to the second, then exit and complete both.

These sprites can also be used singularly rather than in combination for other neat effects such as completing one level making another level inaccessible (Since it too will be completed.)

The patch breaks down as follows. The first section disables two to provide space for the patch, F10-C and F10-T. (The second leaves some spare patch space even with this patch that can be used.) The second section compacts Keen's spawning code to create sprite spawning space. The following section is pointers to the new sprites. (They are sprites $007D and $007E, represented by a flat yellow line and downward sloping yellow line in the default graphics, that is they are on the opposite end of the sprite row that contains the Korath.) None of this should be altered in any way.

The next two sections are the initiation codes for the new sprites. The blue value is the cached animation that will be sued by both sprites when they are place in-level. (It is possible to adjust the patch to use another, entire, sprite cache.) The two sections after that are the sprite spawning codes. The first blue value in each is the sprite's type; the second blue value is the sprite's action.

The next two sections are the sprite's action codes, The blue value is the animation the sprites use when in-level. (This is so Keen can touch them, the animation can be made invisible if wished.) Finally the last two sections are the uplevel and winlevel collision codes responsible for moving Keen up a level and winning two levels respectively. This uses level state code.

Keen 5

#Disable cheats for space
%patch $7401 $EB $19 #F10-C
%patch $7679 $EB $12 #F10-T

#Compact left\right Keen spawn to create space $EE96-EEBA
%patch $EEBB $B8 $0001W $EB $03
%patch $F4C6 $016BW             #Keen right uses compact spawn (At $EEBB

#Pointers to new sprites
%patch $F59C $0146W #Uplevel (At $EE96)
%patch $F59E $014FW #Winlevel (At $EE9F)

#New sprite spawn 1 (Goes to end of spawn 2)
%patch $EE96 $57 $56 $9A $06B90000RL    $EB $07

#New sprite spawn 2 both cache $0117
%patch $EE9F $57 $56 $9A $06B9003ARL     $83 $C4 $04 $B8 $2B7BRW  $8A $16
             $EC $6F $8E $C0 $26 $08 $16 [$0117W]  $E9 $04EDW

#Uplevel spawning code = $06B90000RL
%patch $6B90 $55 $8B $EC $33 $C0 $50 $9A $06B91DCDRL     $83 $C4 $02 $8B $1E
             $40 $9E $C7 $07 [$0001W]  $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A
             $8B $46 $08 $D3 $E0 $89 $47 $3E $89 $47 $0C $B8 [$00F2W]  $50 $53
             $9A $090B11C4RL     $83 $C4 $04 $5D $CB

#Winlevel spawning code = $06B9003ARL
%patch $6BCA $55 $8B $EC $33 $C0 $50 $9A $06B91DCDRL     $83 $C4 $02 $8B $1E
             $40 $9E $C7 $07 [$0001W]  $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A
             $8B $46 $08 $D3 $E0 $89 $47 $3E $89 $47 $0C $B8 [$0110W]  $50 $53
             $9A $090B11C4RL     $83 $C4 $04 $5D $CB

#Uplevel action = $00F2
%patch $30432 [$0117W $0117W] $0002W $0000W $0000W $0000W $0000W $0000W
              $00000000L    $06B9015ERL   $090B17B5RL   $00F2W

#Winlevel action = $0110
%patch $30450 [$0117W $0117W] $0002W $0000W $0000W $0000W $0000W $0000W
              $00000000L    $06B9017ERL   $090B17B5RL   $0110W

#Uplevel collision: increment curr_lev and set level state to restart level = $06B9015ERL
%patch $6CEE $55 $8B $EC $56 $57 $8B $7E $06 $8B $76 $08 $81 $7C $1C $0888W
             $75 $0A $FF $06 $6F68W  $C7 $06 $6F70W  $0003W  $5F $5E $5D $CB

#Winlevel collision: mark previous level as done and set level state to win level = $06B9017ERL
%patch $6D0E $55 $8B $EC $56 $57 $8B $7E $06 $8B $76 $08 $81 $7C $1C $0888W
             $75 $12 $8B $1E $55 $9E $D1 $E3 $C7 $87 $6F1AW  $0001W  $C7 $06
             $6F70W  $0002W $5F $5E $5D $CB


Automatically restart levels instead of having option to go to map

This patch changes things so that Keen is not given the opportunity to exit to the map level This patch uses jump conditions and Patch:Game stats. By default this only happens when a game over is triggered. (When Keen has no lives.) Changing the lives requirement to anything else means that below a certain number of lives he will be forced to replay the level until a game over. Changing the requirement from lives can cause Keen to have to replay the level until he gets a certain item. Changing the jump can eliminate the option to quit to the map entirely and more.

Keen 4

#Automatically restart a level when killed (No map option) if Keen has no lives
%patch $6684 {$7A6AW}  [$00] {$7D}