Patch:Keen on map (Galaxy)

From KeenWiki
Jump to: navigation, search

This page contains patches relating to the player sprite on the map. This is different from the player sprite in levels. The map sprite does not feel gravity and can enter levels, as well as do a number of more specialized things (Such as teleport) in certain games. Patches on this page relate only to the map sprite, its appearance and behavior. patches relating to the map level are located at Patch:Map (Keen 4), Patch:Map (Keen 5) and Patch:Map (Keen 6). See also Patch:Map Keen (Vorticons) and Patch:Keen on map (Dreams).

Other pages that contain patches related to ones here are Patch:Wetsuit, Patch:Miragia Patch:Flags and Patch:Foot.


How Map Keen sprites work

For the most part the Map Keen sprite is much like other sprites, albeit with a unique behavior. The waving Map Keen for example behaves exactly as expected.

However the walking (And in Keen 4, swimming) Keen action is different. Rather than have a whole slew of actions for each direction of movement, including diagonals, there is a single action for Map Keen both standing still and moving in any direction. The animations however are read not from the action itself, but from a 'direction list' that has an entry for each direction Map Keen can move. This greatly simplifies things, but makes them harder to understand.


Sprite Type

Map Keen uses sprite type 2 in every episode. This is the same as Keen's type in-level which means that if Map Keen hits any deadly sprite then Keen will die. In Keen 4 there are two types. The first is for when Keen spawns normally on the map (Starting a game, exiting levels.) and the second is for when he has the Foot.

In Keen 6 Keen needs to be type 2 in order to use the Grappling hook and the Satellite.

Patch: Map Keen Sprite Types
#Keen 4
%patch $DE12 $02
#Map Keen riding foot
%patch $DEB6 $02
#Map Keen
#Keen 5
%patch $AAF9 $02
#Keen 6
%patch $CF7A $02


Sprite Actions

Map Keen has a complex action setup. Map Keen in all episodes is spawned 'waiting'; a normal action that will, after a long period of time, go to the bored\waving sequence; a 5 frame sequence that ends with Keen returning to standing. (This and the waiting action in fact form a 6 frame bored-waiting loop.)

When a key is pressed waiting Keen will go to walking, a single frame loop that continues walking until a key is not pressed. When a key is not pressed walking Keen will go to waiting.

In Keen 4 Keen ca also spawn riding the Foot if he has exited the level by touching it. Keen will move across the map using a two-frame flying-foot loop. When Keen is dropped off by the Foot he is returned to standing still.

When walking or swimming Keen will respond to water entrance tiles. When this happens a action check is made. (Actually two.) If Keen is already swimming he will be returned to walking; otherwise he will start swimming. Swimming works identically to walking except that it does not 'stop'; swimming Keen will always animate and make a noise even if not moving.

In Keen 5 there is an 'invisible' action. This is used when Keen uses the Elevators or the Korath transporters. In this action he invisibly moves across the map to reappear elsewhere. If this is fiddled with then map transport is often broken. Keen also spawns slightly differently normally (Game start, exiting levels.) and on Korath (after using the Korath transporters.)

In Keen 6 Keen can do a number of other things, teleport, grab the Satellite or the Grappling rope for example.

Keen 4 Actions:
$1492W #Map Keen riding foot
$14B0W #Map Keen riding foot
$14CEW #Map Keen swimming
$14ECW #Map Keen standing still
$150AW #Map Keen waving when bored 1
$1528W #Map Keen waving when bored 2
$1546W #Map Keen waving when bored 3
$1564W #Map Keen waving when bored 4
$1582W #Map Keen waving when bored 5
$15A0W #Map Keen walking

Patch: Map Keen sprite actions - Keen 4
#Spawn Map Keen
%patch $DF10 $14ECW
#When key pressed, walk
%patch $DFB0 $15A0W
#While walking, keep walking
%patch $3042C $15A0W
#When keys NOT pressed while walking, stand still
%patch $E033 $14ECW
#Waiting action, if left long enough go to bored
%patch $30378 $150AW
#Bored and waving sequence
%patch $30396 $1528W %patch $303B4 $1546W %patch $303D2 $1564W %patch $303F0 $1582W %patch $3040E $14ECW
#Spawn Map Keen riding Foot
%patch $DE9F $1492W
#Flying foot loop
%patch $3031E $14B0W %patch $3033C $1492W
#Dropped off by Foot
%patch $E107 $14ECW
#Start swimming when entering water
%patch $E2CD $14CEW
#Swimming checks for exiting water
%patch $E25B $14CEW
#On entrance if swimming already don't go to swimming
%patch $E2B5 $14CEW
#On exit if swimming go to walking
#When swimming keep swimming
%patch $3035A $14CEW


Keen 5 Actions:
$137AW #Map Keen invisible
$1398W #Map Keen wait
$13B6W #Map Keen wave 1
$13D4W #Map Keen wave 2
$13F2W #Map Keen wave 3
$1410W #Map Keen wave 4
$142EW #Map Keen wave 5
$144CW #Map Keen moving

Patch: Map Keen sprite actions - Keen 5
#Map Keen spawned
%patch $D221 $1398W
#Map Keen spawned on Korath
%patch $D221 $1398W
#Waiting action, if left long enough go to bored
%patch $316F4 $13B6W
#Bored-wave sequence
%patch $31712 $13D4W %patch $31730 $13F2W %patch $3174E $1410W %patch $3176C $142EW %patch $3178A $1398W
#When key pressed, walk
%patch $D315 $144CW
#While walking, keep walking
%patch $317A8 $144CW
#When keys NOT pressed while walking, stand still
%patch $D398 $1398W
#Become invisible when on elevators, transporter
%patch DB8D $137AW
#Invisible Map Keen - wait to change back
%patch $316D6 $0000W
#Map Keen return to waiting after exiting elevators\teleporters
%patch $D802 $1398W


Keen 6 Actions:
$130AW  #Map Keen stand
$1328W  #Map Keen waves
$1346W  #Map Keen waves
$1364W  #Map Keen waves
$1382W  #Map Keen waves
$13A0W  #Map Keen waves
$13BEW  #Map Keen moving

Patch: Map Keen sprite actions - Keen 6
#Map Keen spawned
%patch $CFD4 $130AW
#When keys NOT pressed while walking, stand still
%patch $D0F7 $130AW
#Map Keen stand (After climbing rope)
%patch $FB75 $130AW
#Map Keen stand (After leaving rocket)
%patch $F992 $130AW
#Map Keen stand (After leaving satellite)
%patch $FE94 $130AW


Sprite Behavior

Map Keen's behaviors are somewhat simpler. The first behavior is that of Keen waiting or waving. This lets Keen go to walking when keys are pressed. The second behavior is when Keen walks; this lets him stop walking when keys are not being pressed. These two behaviors are shared by all three episodes of Keen Galaxy.

Keen 4 has unique behaviors for Keen riding on the Foot; this behavior lets him find a location to be dropped off and return to waiting. There is also a swimming behavior similar to his walking behavior.

Keen 5 has a separate behavior for Keen going invisible in elevators and transporters.

Keen 4:
$0D8F06AFRL #Map Keen wait\wave
$0D8F06F0RL #Map Keen walking
$0D8F07ABRL #Map Keen on Foot
$0D8F0826RL #Map Keen swimming

Patch: Keen 4
#Map Keen on foot
%patch $30312 $0D8F07ABRL %patch $30330 $0D8F07ABRL
#Map Keen swimming
%patch $3034E $0D8F0826RL
#Map Keen waiting
%patch $3036C $0D8F06AFRL
#Map Keen waving
%patch $3038A $0D8F06AFRL %patch $303A8 $0D8F06AFRL %patch $303C6 $0D8F06AFRL %patch $303E4 $0D8F06AFRL %patch $30402 $0D8F06F0RL
#Map Keen walking
%patch $30420 $0D8F06F0RL


Keen 5:
$0CCB0654RL #Map Keen wave
$0CCB0695RL #Map Keen move
$0CCB0A69RL #Map Keen invisible

Patch: Keen 5
#Invisible Map Keen
%patch $316CA $0CCB0A69RL
#Map Keen waiting
%patch $316E8 $0CCB0654RL
#Map Keen wave
%patch $31706 $0CCB0654RL %patch $31724 $0CCB0654RL %patch $31742 $0CCB0654RL %patch $31760 $0CCB0654RL %patch $3177D $0CCB0695RL
#Map Keen move
%patch $3179C $0CCB0695RL


Keen 6:
$0CA60603RL #Map Keen wait\wave
$0CA60644RL #Map Keen move
$0EFC0B35RL #Rope climb 1
$0EFC0B8ARL #Rope climb 2

Patch: Keen 6
#Map Keen waiting
%patch $3204A $0CA60603RL
#Map Keen wave
%patch $32068 $0CA60603RL %patch $32086 $0CA60603RL %patch $320A4 $0CA60603RL %patch $320C2 $0CA60603RL %patch $320E0 $0CA60644RL
#Map Keen move
%patch $320FE $0CA60644RL
#Map Keen on satellite
%patch $329B0 $00000000L
#Map Keen climbing rope
%patch $328DE $00000000L %patch $328FC $0EFC0B35RL %patch $3291A $00000000L %patch $32938 $0EFC0B8ARL


Waiting behavior code

This is the complete behavior code for Keen sitting on the map. It basically checks for keypresses. On the first line Keen checks to see if any arrow keys are being pressed. If they are it changes his action to walking, resets Keen's waiting variable and runs the walking code. (The same code that acts as walking Map Keen's behavior.)

On the third line three checks are made. Keen checks for the pressing of Ctrl, Alt, or Space and if any of these are pressed the 'check level entrance' code is run.

Patch: Map Keen waiting code
#Map Keen waiting code - Keen 4
%patch $DF9F $55 $8B $EC $56 $8B $76 $06 $83 $3E $A7D2W $08 $74 $13 $C7 $44 $1C $15A0W $C7 $44 $40 $0000W $56 $90 $0E $E8 $0023W $83 $C4 $02 $83 $3E $C5C9W $00 $75 $0E $83 $3E $C5C5W $00 $75 $07 $83 $3E $C5C1W $00 $74 $08 $56 $0E $E8 $FF44W $83 $C4 $02 $5E $5D $CB


Moving behavior code

This is the moving Map Keen code run by Keen when he is moving on the map. The first two lines deal with whether Keen needs to animate by checking his Mask variable. If he does need to animate then the next section of code is skipped. The animation speed here is $04. (This is also reset in line 9, in the second section.)

On line 3 Keen moves by updating his horizontal and vertical position ($0E and $10) using the two memory variables $A7CEW and $A7D0W. This also allows him to appear where he did before entering a level when he exits. Line 4 checks whether the Ctrl, Alt or Space keys are being pressed; if so the 'check level entrance' code will be run. If not Keen checks to see if any arrow keys are being pressed; if none are then Keen's action will change to 'waiting Map Keen', his animation list is reset ($15BEW, frame 3.) and the code ends.

The second section of code animates walking Keen. First Keen's Misc C variable is stored in memory (for unknown reasons.) followed by an increase in his sprite draw variable. The number of animations in Keen's walking sequence is $04, resetting to 0. Next are the pointers to Keen's animation-direction list and his animation-frame list. ($15BEW and $15CEW respectively.) On line 11 Keen's draw variable is checked and if 1 sound 0 ($33 $C0) is played. Else it checks if the value is 3, if so sound $01 is played. This creates a 'pit pat' alternating sound every odd step.

Patch: Map Keen moving code
#Map Keen moving code -Keen 4
%patch $DFE0 $55 $8B $EC $56 $8B $76 $06 $83 $7C $42 $00 $74 $13 $83 $6C $42 $04 $83 $7C $42 $00 $7D $56 $C7 $44 $42 $0000W $EB $4F $EB $4D $A1 $A7CEW $89 $44 $0E $A1 $A7D0W $89 $44 $10 $83 $3E $C5C5W $00 $75 $0E $83 $3E $C5C1W $00 $75 $07 $83 $3E $C5C9W $00 $74 $08 $56 $0E $E8 $FEF8W $83 $C4 $02 $83 $3E $A7D2W $08 $75 $17 $C7 $44 $1C $14ECW $8B $5C $3E $D1 $E3 $8B $87 $15BEW $05 $0003W $89 $44 $1E $5E $5D $CB $A1 $A7D2W $89 $44 $3E $FF $44 $40 $8B $44 $40 $3D $0004W $75 $05 $C7 $44 $40 $0000W $8B $5C $3E $D1 $E3 $8B $87 $15BEW $8B $5C $40 $D1 $E3 $03 $87 $15CEW $89 $44 $1E $83 $7C $40 $01 $75 $0E $33 $C0 $50 $9A $187409F1RL $83 $C4 $02 $5E $5D $CB $83 $7C $40 $03 $75 $0C $B8 $0001W $50 $9A $187409F1RL $83 $C4 $02 $5E $5D $CB


Level entrance check code

This is the check level entrance code run when the player presses Ctrl, Alt or Space on the map. This is run wherever Keen is. On the first two lines a number of checks are run to see if the player is sitting on an infoplane value. On the fourth line the game checks whether the infoplane value is a valid level entry. (Between $C000W and $C012W by default, a total of 18 levels.) If these two tests are passed then the 'enter level' code is run.

First Keen's horizontal and vertical location on the map are stored in variables $7A1AW and $7A1CW. Next $C000W is removed from the infoplane value, giving the level number, which is stored in variable $7A68W. The level state is changed to 2 (Reload level.) and sound $0C is played.

Patch: Check level entrance code
#Check level entrance code - Keen 4
%patch $DF1E $55 $8B $EC $83 $EC $04 $56 $57 $8B $76 $06 $8B $44 $2E $89 $46 $FE $EB $60 $8B $7C $2C $EB $53 $8B $5E $FE $D1 $E3 $8B $9F $25 $C9 $D1 $EB $D1 $E3 $8E $06 $EB $A7 $8B $C7 $D1 $E0 $03 $D8 $26 $8B $07 $89 $46 $FC $81 $7E $FC $C000W $76 $2E $81 $7E $FC $C012W $77 $27 $8B $44 $0A $A3 $7A1AW $8B $44 $0C $A3 $7A1CW $8B $46 $FC $2D $C000W $A3 $7A68W $C7 $06 $7A70W $0002W $B8 $000CW $50 $9A $187409F1RL $83 $C4 $02 $47 $39 $7C $30 $73 $A8 $FF $46 $FE $8B $44 $32 $3B $46 $FE $73 $98 $5F $5E $8B $E5 $5D $CB


Map Swimming behavior

This is the complete code for Keen's map swimming behavior. On the first line Keen's 'sprite draw' variable is checked, if it isn't zero six is added to it then the variable checked again. Then if it is zero or larger the game jumps to line 5. Otherwise the variable is set to 0 then the code jumps to line 5. There is another jump, $EB $20 that does nothing.

On line 3 the player's horizontal and vertical directions are loaded to $A7CEW and $A7D0W respectively. At the end of the line these variables are checked to see if one of them isn't zero. (That is, the player is moving.) If so Keen's Misc Variable B is loaded to $A7D2W.

Line 5 onwards deals with animation. The player's animation list is located at $2EE70W + $15D6W = $30446. The current animation is stored in Keen's 'masked variable', $40. The upshot of this is that Keen's swimming animations have an initial frame plus $0002W extra frames. (Totaling a 3 image sequence.) On line 7 this variable is checked, if zero sound $1A is played, otherwise $1B is played.

Patch: Map Swimming code
#Swimming Map Keen's behavior
%patch $E116 $55 $8B $EC $56 $8B $76 $06 $83 $7C $42 $00 $74 $13 $83 $6C $42 $06 $83 $7C $42 $00 $7D $29 $C7 $44 $42 $0000W $EB $22 $EB $20 $A1 $A7CEW $89 $44 $0E $A1 $A7D0W $89 $44 $10 $83 $3E $A7CEW $00 $75 $07 $83 $3E $A7D0W $00 $74 $06 $A1 $A7D2W $89 $44 $3E $8B $5C $3E $D1 $E3 $8B $87 $15D6W $03 $44 $40 $89 $44 $1E $FF $44 $40 $8B $44 $40 $3D $0002W $75 $05 $C7 $44 $40 $0000W $83 $7C $40 $00 $75 $0F $B8 $001AW $50 $9A $187409F1RL $83 $C4 $02 $5E $5D $CB $B8 $001BW $50 $9A $187409F1RL $83 $C4 $02 $5E $5D $CB


Speed

Map Keen's movement is covered by his animation motion. Keen only moves when walking (Or in Keen 4, swimming; swimming at 2/3 his walking speed by default.) What directions Keen will move in depends on his walking code.

In Keen 5 Keen has a speed while invisible, though how this relates to his actual speed when teleporting is unknown. In Keen 6 Keen doesn't seem to use his animation motion at all.

Patch: Animation motion - Keen 4
#Map Keen on foot
%patch $3030E $0000W $0000W %patch $3032C $0000W $0000W
#Map Keen swimming
%patch $3034A $0010W $0010W
#Map Keen waiting
%patch $30368 $0000W $0000W
#Map Keen waving
%patch $30386 $0000W $0000W %patch $303A4 $0000W $0000W %patch $303C2 $0000W $0000W %patch $303E0 $0000W $0000W %patch $303FE $0000W $0000W
#Map Keen walking
%patch $3041C $0018W $0018W

Patch: Animation motion - Keen 5
#Invisible Map Keen
%patch $316C6 $0010W $0010W
#Map Keen waiting
%patch $316E4 $0000W $0000W
#Map Keen waving
%patch $31702 $0000W $0000W %patch $31720 $0000W $0000W %patch $3173E $0000W $0000W %patch $3175C $0000W $0000W %patch $3177A $0000W $0000W
#Map Keen walking
%patch $31798 $0018W $0018W

Patch: Animation motion - Keen 6
#Map Keen waiting
%patch $32046 $0000W $0000W
#Map Keen waving
%patch $32064 $0000W $0000W %patch $32082 $0000W $0000W %patch $320A0 $0000W $0000W %patch $320BE $0000W $0000W %patch $320DC $0000W $0000W
#Map Keen walking
%patch $320FA $0018W $0018W


Sprite Collision

Map Keen has no collision by default. This means that he cannot interact with things like Princess Lindsey or the Oracle Council Members. (This can be changed by giving Map Keen normal Keen's collision.) Keen can still be killed on the map.

Patch: Map Keen collision values - Keen 4
#Map Keen on foot
%patch $30316 $00000000L %patch $30334 $00000000L
#Map Keen swimming
%patch $30352 $00000000L
#Map Keen waiting
%patch $30370 $00000000L
#Map Keen waving
%patch $3038E $00000000L %patch $303AC $00000000L %patch $303CA $00000000L %patch $303E8 $00000000L %patch $30406 $00000000L
#Map Keen walking
%patch $30424 $00000000L

Patch: Map Keen collision values - Keen 5
#Invisible Map Keen
%patch $316CE $00000000L
#Map Keen waiting
%patch $316EC $00000000L
#Map Keen waving
%patch $3170A $00000000L %patch $31728 $00000000L %patch $31746 $00000000L %patch $31764 $00000000L %patch $31782 $00000000L
#Map Keen walking
%patch $317A0 $00000000L

Patch: Map Keen collision values - Keen 6
#Map Keen waiting
%patch $3204E $00000000L
#Map Keen waving
%patch $3206C $00000000L %patch $3208A $00000000L %patch $320A8 $00000000L %patch $320C6 $00000000L %patch $320E4 $00000000L
#Map Keen walking
%patch $32102 $00000000L
#Map Keen on satellite
%patch $329B4 $00000000L
#Map Keen throwing rope
%patch $328E2 $00000000L %patch $32900 $00000000L
#Map Keen climbing rope
%patch $3291E $00000000L %patch $3293C $00000000L


Animations

The animations of map Keen are complex and can be broken down into three parts. The first part is the cache. This holds all the animations used on the map, not only map Keen's, but those sued by Flags and other map objects.

The second section involves 'action animations', that is those used by Map Keen's actions. For things like Keen waving when bored these work identically to other sprites, each action having a unique right and left animation. Keen's walking and waiting (and swimming) actions however have no animations since they use an animation taken from a list. Also notable is that the 'animation speed' for Keen's waiting action is how long it takes him to become bored.

The third section involves the animation list used by moving Keen. The animations used by moving Map Keen are read from a list. The value in the list is the first animation of that sequence minus one, and the number of frames used for each sequence is controlled by two variables. Thus the first entry, $0103W means 'Use frames $104, $105, and $106.' Note that if Keen stops moving he will use, (while standing still) the animation given in the direction list for that direction. For example, if Keen 4 Map Keen stops walking upwards, he will sit still and use animation $104.

The specific animation displayed for any given frame is taken from the 'animation-frame' list. Each entry controls the animation for a single frame of moving Keen. By default this pattern is 2-3-1-3 (These numbers are added to the initial animation from the first list.)

There are also animations for when map Keen first appears. These are required because initially map Keen has no direction to face.


Keen 4

Map Keen in Keen 4 has two animation lists, one for walking and one for swimming. They both behave the exact same way. Map Keen's animation is also reset when he has ridden the Foot on the map and is dropped off by it. The sprite used by default is the same as Map Keen facing right, but this can be changed.

Patch: Map Keen cache
#Keen 4
%patch $306E4 $00FEW
#Map Keen Cache start
%patch $3072E $0134W
#Map Keen cache end

Patch: Map Keen animations
#Walking
%patch $30410 $0000W $0000W
#Don't change animation
%patch $3041A $0004W
#walking frequency
#Swimming
%patch $3033E $0000W $0000W
#Don't change animation
%patch $30348 $0006W
#Animation speed
#Waiting
%patch $3035C $0000W $0000W
#Don't change animation
%patch $30366 $0168W
#Pause before waving
#Bored
%patch $3037A $0116W $0116W %patch $30384 $0014W
#Animation speed
%patch $30398 $0117W $0117W %patch $303A2 $0014W
#Animation speed
%patch $303B6 $0116W $0116W %patch $303C0 $0014W
#Animation speed
%patch $303D4 $0117W $0117W %patch $303DE $0014W
#Animation speed
%patch $303F2 $0116W $0116W %patch $303FC $0014W
#Animation speed
#Map Keen riding foot
%patch $30302 $0118W $0118W %patch $3030C $001EW
#Animation speed
%patch $30320 $0119W $0119W %patch $3032A $001EW
#Animation speed

Patch: Keen 4 Map Keen animations
#Map Keen walking animations
%patch $3042E $0103W
#Up map sprite
%patch $30430 $0112W
#Up right map sprite
%patch $30432 $0100W
#Right map sprite
%patch $30434 $0109W
#Down right map sprite
%patch $30436 $0106W
#Down map sprite
%patch $30438 $010CW
#Down left map sprite
%patch $3043A $00FDW
#Left map sprite
%patch $3043C $010FW
#Up left map sprite
#Map Keen swimming animations
%patch $30446 $0118W
#Up map sprite
%patch $30448 $0120W
#Up right map sprite
%patch $3044A $011AW
#Right map sprite
%patch $3044C $0122W
#Down right map sprite
%patch $3044E $011CW
#Down map sprite
%patch $30450 $0124W
#Down left map sprite
%patch $30452 $011EW
#Left map sprite
%patch $30454 $0126W
#Up left map sprite
#Animation-frame sequence
%patch $3043E $0002W $0003W $0001W $0003W
#Reset map Keen's animations
%patch $DF0D $0100W
#When first appearing on map
%patch $E10C $0100W
#When dropped off by the Foot


Keen 5

Notice that in Keen 5 there is an 'invisible map Keen' which uses -1 for its animations so that Keen returns to using a list animation after performing certain actions. It is not entirely clear why this is required.

Patch: Map Keen cache
#Cache - Keen 5
%patch $31A2C $00F2W
#Map Keen cache start
%patch $31A80 $011AW
#Cache end

Patch: Map Keen animations
#Invisible Map Keen
%patch $316BA $FFFFW $FFFFW
#Clear animation
%patch $316C4 $0006W
#Reaction speed
#Waiting
%patch $316D8 $0000W $0000W
#Don't change animation
%patch $316E2 $0168W
#Pause before bored
#Waving
%patch $316F6 $010AW $010AW %patch $31700 $0014W
#Animation speed
%patch $31714 $010BW $010BW %patch $3171E $0014W
#Animation speed
%patch $31732 $010AW $010AW %patch $3173C $0014W
#Animation speed
%patch $31750 $010BW $010BW %patch $3175A $0014W
#Animation speed
%patch $3176E $010AW $010AW %patch $31778 $0014W
#Animation speed
#Walking
%patch $3178C $0000W $0000W
#Don't change animation
%patch $31796 $0004W
#Walking frequency

Patch: Keen 5 Map Keen animations
#Map Keen moving
%patch $317AA $00F7W
#Up map sprite
%patch $317AC $0106W
#Up right map sprite
%patch $317AE $00F4W
#Right map sprite
%patch $317B0 $00FDW
#Down right map sprite
%patch $317B2 $00FAW
#Down map sprite
%patch $317B4 $0100W
#Down left map sprite
%patch $317B6 $00F1W
#Left map sprite
%patch $317B8 $0103W
#Up left map sprite
#Animation-frame sequence
%patch $317BA $0002W $0003W $0001W $0003W
#Reset map Keen's animations
%patch $D21E $00F4W
#When first appearing on map
%patch $D272 $00F4W
#Unknown


Keen 6

Keen 6's map Keen is the most complex, performing the most varied kinds of actions. It thus has considerably more actions.

Patch: Map Keen cache
#Cache - Keen 6
%patch $32428 $00B8W
#Map Keen cache start
%patch $32478 $00EEW
#Map Keen cache end

Patch: Map Keen animations
#Waiting
%patch $3203A $0000W $0000W
#Don't change animation
%patch $32044 $0168W
#Pause needed before bored
#Walking
%patch $320EE $0000W $0000W
#Don't change animation
%patch $320F8 $0004W
#Pause needed before bored
#Waving
%patch $32058 $00D0W $00D0W %patch $32062 $0014W
#Animation speed
%patch $32076 $00D1W $00D1W %patch $32080 $0014W
#Animation speed
%patch $32094 $00D0W $00D0W %patch $3209E $0014W
#Animation speed
%patch $320B2 $00D1W $00D1W %patch $320BC $0014W
#Animation speed
%patch $320D0 $00D0W $00D0W %patch $320DA $0014W
#Animation speed
#Keen throws grapnel
%patch $328CE $00DDW $00DDW %patch $328D8 $000AW
#Animation speed
%patch $328EC $00DEW $00DEW %patch $328F6 $0008W
#Animation speed
#Map Keen climbing rope
%patch $3290A $00DFW $00DFW %patch $32914 $0004W
#Animation speed
%patch $32928 $00E0W $00E0W %patch $32932 $0004W
#Animation speed
#Rope and hook
%patch $32946 $00E2W $00E2W %patch $32950 $0000W
#Animation speed
#Rope being thrown (Not used)
%patch $32964 $00E1W $00E1W %patch $3296E $000AW
#Animation speed
#Map Keen hanging from satellite
%patch $329A0 $00E3W $00E3W %patch $329AA $0000W
#Animation speed

Patch: Keen 6 Map Keen animations
#Map Keen moving
%patch $3210C $00BDW
#Up map sprite
%patch $3210E $00CCW
#Up right map sprite
%patch $32120 $00BAW
#Right map sprite
%patch $32112 $00C3W
#Down right map sprite
%patch $32114 $00C0W
#Down map sprite
%patch $32116 $00C6W
#Down left map sprite
%patch $32118 $00B7W
#Left map sprite
%patch $3211A $00C9W
#Up left map sprite
#Animation-frame sequence
%patch $3211C $0002W $0003W $0001W $0003W
#Number of animation frames for each sequence
%patch $320F8 $0004W
#Animation speed
#Reset map Keen's animations
%patch $CFD1 $00BAW
#When first appearing on map


Sounds

There are a number of sounds related to the map. The two most basic are Map Keen's walking sounds, sound 0 and sound 1. Sound 0 has a different patch structure and is hard to alter.

The remaining sounds relate to other map actions. All sounds can be silenced.

Patch: Keen 4
#Sounds
%patch $E078 $C033W
#Map Keen walking sound 1 (Sound 0)
%patch $E08D $01
#Map Keen walking sound 2
%patch $E17C $1A
#Map Keen swim 1 sound
%patch $E18B $1B
#Map Keen swim 2 sound
%patch $E20E $0E
#Keen can't swim sound
#Don't play sounds
%patch $E078 $EB $09
#Don't play Map Keen walking sound 1
%patch $E08C $EB $0A
#Don't play Map Keen walking sound 2
%patch $E17B $EB $0A
#Don't play Map Keen swim 1 sound
%patch $E18A $EB $0A
#Don't play Map Keen swim 2 sound
%patch $E20D $EB $0A
#Don't play Keen can't swim sound

Patch: Keen 5
#Sounds
%patch $D3DD $C033W
#Map Keen walking sound 1 (Sound 0)
%patch $D3F2 $01
#Map Keen walking sound 2
%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 $D3DD $EB $09
#Don't play Map Keen walking sound 1
%patch $D3F1 $EB $0A
#Don't play Map Keen walking sound 2
%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

Patch: Keen 6
#Sounds
%patch $D13C $C033W
#Map Keen walking sound 1 (Sound 0)
%patch $D151 $01
#Map Keen walking sound 2
%patch $D16C $29
#Teleport leave sound
%patch $D3A4 $29
#Teleport arrive sound
#Don't play sounds
%patch $D13C $EB $09
#Don't play Map Keen walking sound 1
%patch $D150 $EB $0A
#Don't play Map Keen walking sound 2
%patch $D16B $EB $0A
#Don't play Teleport leave sound
%patch $D3A3 $EB $0A
#Don't play Teleport arrive sound


Clipping and foreground

Because of the complexity of these two subjects they have been divided into their own sections on this page.


Clipping

Keen is spawned on the map with a clipping value of 1 so that he is blocked by solid tiles. Whenever he must teleport or transport his clipping must be set to 0 and reset to 1 when he has finished. A good example is the Foot in Keen 4. When spawned riding it Keen's clipping is set to 0, when he is dropped off it is set to 1 again.

Patch: Keen Clipping
#Keen 4
%patch $8A4B $0001W
#Keen on map
%patch $DE0E $0000W
#Keen riding Foot on map
%patch $E111 $0001W
#Map Keen after Foot drops him off
#Keen 5
%patch $89C7 $0001W
#Keen on map


Foreground

Keen is spawned on the map with a foreground value of 1, appearing behind the appropriate for tiles and most other sprites. In Keen 4 Keen can also spawn riding the Foot, in which case he has a foreground value of 3, appearing in front of all foreground tiles. (As expected since he is in the air above them.)

Patch: Keen Foreground
#Keen 4
%patch $DE28 $0003W
#Map Keen on Foot
%patch $E0E5 $0001W
#Map Keen
#Keen 5
%patch $D200 $0001W
#Map Keen


Sprite-tile interaction

Map Keen uses the 'sit' tile collision which suggests that only his clipping determines what happens However since Keen is the 'player sprite' an entirely different tile code is run all the time, in addition to that used here. This collision is treated on the tiles page.

Patch: Keen 4
#Map on foot
%patch $30308 $09DC176ERL %patch $30326 $09DC176ERL
#Map swimming
%patch $30344 $09DC176ERL
#Map waiting
%patch $30362 $09DC176ERL
#Map waving
%patch $30380 $09DC176ERL %patch $3039E $09DC176ERL %patch $303BC $09DC176ERL %patch $303DA $09DC176ERL %patch $303F8 $09DC176ERL
#Map walking
%patch $30416 $09DC176ERL

Patch: Keen 5
%patch $316D2 $090B17B5RL

#Waiting
%patch $316F0 $090B17B5RL
#Waving
%patch $3170E $090B17B5RL %patch $3172C $090B17B5RL %patch $3174A $090B17B5RL %patch $31768 $090B17B5RL %patch $31786 $090B17B5RL
#Walking
%patch $317A4 $090B17B5RL


Levels map tile code is used in

By default only in level 0 does the player sprite use the map tile code; otherwise the level tile code is used instead. (See Patch:Tiles.) This can however be changed. Note that the level tile code is responsible for the player's interactions with items, gem holders and deadly tiles.

Patch: 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


Action type

When walking on the map Keen uses action type 1. When waiting or waving he uses action type 3, allowing instant response to keypresses. most other actions are type 2, waiting for something to happen.

Patch: Keen 4
#Map Keen riding foot
%patch $30306 $0002W %patch $30324 $0002W
#Map Keen swimming
%patch $30342 $0001W
#Map Keen waiting
%patch $30360 $0003W
#Map Keen waving
%patch $3037E $0003W %patch $3039C $0003W %patch $303BA $0003W %patch $303D8 $0003W %patch $303F6 $0003W
#Map Keen walking
%patch $30414 $0001W

Patch: Keen 5
#Invisible Map Keen
%patch $316BE $0002W
#Map Keen waiting
%patch $316DC $0003W
#Map Keen waving
%patch $316FA $0003W %patch $31718 $0003W %patch $31736 $0003W %patch $31754 $0003W %patch $31772 $0003W
#Map Keen walking
%patch $31790 $0001W


Deprotect and stick to ground

Map Keen does not use the stick-to-ground variable at all since there is no gravity on the map. However walking Keen and related actions use the deprotect animation variable; it relates to the fact that they use list animations unlike normal actions.

Patch: Keen 4
#Walking
%patch $30416 $0001W $0000W
#Swimming
%patch $30344 $0001W $0000W
#Riding foot
%patch $30308 $0000W $0000W %patch $30326 $0000W $0000W
#Waiting
%patch $30362 $0000W $0000W
#Waving
%patch $30380 $0000W $0000W %patch $3039E $0000W $0000W %patch $303BC $0000W $0000W %patch $303DA $0000W $0000W %patch $303F8 $0000W $0000W

Patch: Keen 5
#Invisible Map Keen
%patch $316C0 $0001W $0000W
#Wait
%patch $316DE $0000W $0000W
#Wave
%patch $316FC $0000W $0000W %patch $3171A $0000W $0000W %patch $31738 $0000W $0000W %patch $31756 $0000W $0000W %patch $31774 $0000W $0000W
#Walking
%patch $31792 $0001W $0000W


Sprite spawn code

The Map Keen spawn code is quite complex and only partially available. There s only one difficulty of Keen, he always spawns int he same place. In the initiation code his cache is set in $C7 $06 $CxxxW $0001W However Map Keen also caches the scorebox bitmap which is also coded blue in the initiation.

In Keen 5 there is a further addition, if the level state is 13 then further code is run, this transports Keen to Korath. (The level state is set to this when Keen exits a level using the teleporter.

Map Keen's spawn code is complex in Keen 4. It is in fact two different spawns depending on whether Keen exited the previous level on the Foot (State 7). This check is made in the first line and if so, the first section of code is run, otherwise the second section is.

In the first section Keen's clipping is set to 0 (allowing him to pass through solid map tiles to secret areas.) and his sprite type to 2. The game then loads his previous map position from memory. ($7A1A loads to horizontal position, $7A1C loads to vertical.) On line 3 Keen's sprite activity is set to 2 (Always active.), foreground to 3 (In front of all tiles) and his horizontal and vertical directions to 0 (Not facing any particular direction.)

At the end of line 3 Keen's vertical position is checked from memory. If it is greater than 20 tiles down from the map to ($1400W) then the next 3 lines are skipped. This works to give Keen two Foot destinations depending on where, vertically, on the map he starts. Lines 4-7 deal with Keen's downwards-left Foot journey. The destination is $1E,$37 moving at a speed of $0118W horizontally and vertically. At the start of line 8 three lines are skipped.(The second Foot journey.)

Lines 8-10 deal with the second Foot journey. The destination is $10,$2F moving at a speed of $008CW horizontally and vertically. On line 11 Keen's Foot riding action is spawned.

The second section is he normal spawning code. Keen's type is set to 2 (But his clipping is not changed from normal.) A check is made to see if Keen has a stored previous map position. (This is not the case if he has just started a new game.) If not, Keen's position is taken from the spawn point in the game map, otherwise it is loaded from memory in the same way as his Foot-riding spawn above.

Again Keen's activity is set at 2, but his foreground is set at 1 (Behind foreground tiles.) Horizontal and vertical position are set to 0, animation delay to 6. animation frame to 3, mask to 0 and animation to $0100W. These serve to make Keen animate correctly when the player chooses to move. Finally Keen's waiting map action is spawned on the last line.

Patch: Keen 4
#Location of initiation code
%patch $EE89 $00BCW
#Map Keen (At $E9AC)
#Map Keen initiation code
%patch $E9AC $FF $76 $FC $57 $9A $0D8F050ARL $83 $C4 $04 $9A $0D8F0003RL $C7 $06 $CB4FW $0001W $B8 $2A3ARW $8A $16 $EC $7A $8E $C0 $26 $08 $16 $00FDW $E9 $0429W
#Map Keen spawning code
%patch $DDFA $55 $8B $EC $83 $3E $7A70W $07 $74 $03 $E9 $00A9W $8B $1E $D6 $A7 $C7 $47 $06 $0000W $C7 $07 $0002W $A1 $7A1AW $89 $47 $0A $A1 $7A1CW $89 $47 $0C $C7 $47 $02 $0002W $C7 $47 $20 $0003W $C7 $47 $0E $0000W $C7 $47 $10 $0000W $81 $3E $7A1AW $1400W $73 $31 $C7 $47 $3E $0118W $B8 $1E00W $2B $47 $0A $BB $0118W $33 $D2 $F7 $F3 $40 $8B $1E $A7D6W $89 $47 $16 $B8 $3700W $2B $47 $0C $BB $0118W $33 $D2 $F7 $F3 $40 $8B $1E $A7D6W $89 $47 $18 $EB $31 $8B $1E $A7D6W $C7 $47 $3E $008CW $B8 $1000W $2B $47 $0A $BB $008CW $99 $F7 $FB $40 $8B $1E $A7D6W $89 $47 $16 $B8 $2F00W $2B $47 $0C $BB $008CW $99 $F7 $FB $40 $8B $1E $D6 $A7 $89 $47 $18 $B8 $1492W $50 $FF $36 $D6 $A7 $9A $09DC118CRL $83 $C4 $04 $5D $CB $8B $1E $A7D6W $C7 $07 $0002W $83 $3E $7A1AW $00 $75 $14 $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B $46 $08 $D3 $E0 $89 $47 $0C $EB $10 $8B $1E $A7D6W $A1 $7A1AW $89 $47 $0A $A1 $7A1CW $89 $47 $0C $8B $1E $A7D6W $C7 $47 $02 $0002W $C7 $47 $20 $0001W $C7 $47 $0E $0000W $C7 $47 $10 $0000W $C7 $47 $3E $0006W $C7 $47 $40 $0003W $C7 $47 $42 $0000W $C7 $47 $1E $0100W $B8 $14ECW $50 $53 $9A $09DC118CRL $83 $C4 $04 $5D $CB

Patch: Keen 5
#Location of initiation code
%patch $F4CA $19AW
#Map Keen (At $EEEA)
#Map Keen initiation code
%patch $EEEA $9A $0CCB0007RL $C7 $06 $C27FW $0001W $B8 $2B7BRW $8A $16 $EC $6F $8E $C0 $26 $08 $16 $00EBW $83 $3E $6F70W $0D $75 $03 $E9 $049AW $57 $56 $9A $0CCB050ERL $83 $C4 $04 $E9 $048DW

Patch: Keen 6
#Location of initiation code
%patch $E956 $00BCW
#Map Keen (At $E4DC)
#Map Keen initiation code
%patch $E4DC $57 $56 $9A $0CA60511RL $83 $C4 $04 $9A $0CA6000ARL $C7 $06 $CD15W $0001W $B8 $2BF3RW $8A $16 $28 $76 $8E $C0 $26 $08 $16 $00AFW $E9 $03C5W


Keen swimming on the map

In Keen 4 Keen can swim on the map if he has the Wetsuit. (Otherwise he displays an 'I can't swim' message.) The various aspects of Keen's swimming actions (Their animations, action type, etc.) are covered in other sections. This section deals with patches that affect what circumstances Keen can start swimming under and what happens when he does.


What triggers 'can't swim' message

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
#Swimsuit map trigger:
%patch $E208 $7A5C $00 $75


Keen can never swim on map

This patch makes it so that Keen can never enter water on the map, the 'can't swim' message will always play, even if he has the Wetsuit.

Patch: Keen can never swim on map
#Keen can never swim on map
%patch $E206 $EB $05


Keen walks instead of swimming

This patch changes things so that instead of swimming Keen just walks. Thus water acts as a simple block to Keen, without the Wetsuit he cannot pass but with it he can walk across the tiles.

Patch: Keen walks instead of swimming
#Keen walks instead of swimming
%patch $E20C $37


Can use message, block in normal levels

This patch allows Keen to be blocked by water entrance tiles in regular levels as well as the map. A side effect of this is that Keen will not go to swimming on the map when he has the Wetsuit, instead he will just continue walking through. In regular levels the blocking will bring up the message, turn Keen around and make him stand.

Note that this patch will cause issues with regular doors, once Keen has triggered the message he cannot enter a regular door correctly. It is unknown why this conflict occurs.

Patch: Keen 4
#Keen can use "can't swim" blocks in levels
%patch $D257 $2A06W
#Top water: nothing (At $D21E)
%patch $D259 $2A06W
#Right water: nothing (At $D21E)
%patch $D25B $2A06W
#Bottom water: nothing (At $D21E)
%patch $D25D $2A06W
#Left water: nothing (At $D21E)
%patch $E20C $37

Misc

These patches do not fit in any of the above sections.


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
#Disable Ctrl to enter levels
%patch $DFC5 $90 $90
#When still
%patch $E011 $90 $90
#When moving
#Disable Alt to enter levels
%patch $DFCC $90 $90
#When still
%patch $E018 $90 $90
#When moving
#Disable space to enter levels
%patch $DFD3 $EB
#When still
%patch $E01F $EB
#When moving
#Disable entering levels completely
%patch $DFC0 $5E $5D $CB
#When still
%patch $E00C $EB $1B
#When moving