Patch:Keen on map (Dreams)

From KeenWiki
Jump to navigation Jump to 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 (Dreams). See also Patch:Map Keen (Vorticons) and Patch:Keen on map (Galaxy).


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 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 type 1. This is the same as Keen's type in-level. However Map Keen cannot be killed as he uses a different sprite collision.

Keen Dreams

#Map Keen
%patch $69A9  [$01]


Sprite Actions

Map Keen has a complex action setup. Map Keen in all episodes is spawned 'standing'; a normal action that will, after a long period of time, go to the bored\waving sequence; an 8 frame sequence that ends with Keen napping until a key is pressed.

When a key is pressed standing 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 standing.

Keen Dreams Actions:
$0D3AW #Map Keen stand
$0D58W #Map Keen wave 1
$0D76W #Map Keen wave 2
$0D94W #Map Keen wave 3
$0DB2W #Map Keen wave 4
$0DD0W #Map Keen wave 5 (Goto nap)
$0DEEW #Map Keen nap 1
$0E0CW #Map Keen nap 2
$0E2AW #Map Keen nap 3 (Keep napping)
$0E48W #Map Keen moving

Map Keen sprite actions - Keen Dreams

#Spawn Map Keen
%patch $69FB  [$0D3AW]

#If key pressed while standing or napping, move
%patch $6AE8 [$0E48W]

#When keys NOT pressed while walking, stand still
%patch $6B51  [$0D3AW]

#If waiting too long go to waving
%patch $247C6 [$0D58W]

#Bored and waving-nap sequence
%patch $247E4 [$0D76W]
%patch $24802 [$0D94W]
%patch $24820 [$0DB2W]
%patch $2483E [$0DD0W]
%patch $2485C [$0DEEW] #Start napping
%patch $2487A [$0E0CW]
%patch $24898 [$0E2AW]

#While napping, keep napping
%patch $248B6 [$0E2AW]

#Moving Keen keeps moving
%patch $248D4 [$0E48W]


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.

Keen Dreams:
$05E80C57RL #Map Keen wait\wave
$05E80C8FRL #Map Keen walking

Keen Dreams

#Map Keen waiting
%patch $247BA $05E80C57RL

#Map Keen waving-napping
%patch $247D8 $05E80C57RL
%patch $247F6 $05E80C57RL
%patch $24814 $05E80C57RL
%patch $24832 $05E80C57RL
%patch $24850 $05E80C57RL
%patch $2486E $05E80C57RL
%patch $2488C $05E80C57RL
%patch $248AA $05E80C57RL

#Map Keen walking
%patch $248C8 $05E80C8FRL


Standing behavior code

This behavior is used by Keen when he is standing, waving and napping. The first line checks to see if any arrow key is being pressed (No keys pressed is a value of 8.) If any key is being pressed then the sprite's action is changed to moving and a misc variable set to 0 on line 2.

On line 3 the game checks to see if ctrl or alt is being pressed. If they are the 'enter level' code is run. (This of course only enters a level if the sprite is on one.)

Keen Dreams

#Map Keen stand behavior
%patch $6AD7 $55 $8B $EC $56 $8B $76 $06 $83 $3E {$7022W}  [$08] {$74} $12 $C7 $44
             $1E {$0E48W}  $C7 $44 $40 [$0000W]  $56 $9A $05E80C8FRL     $44 $44
             $83 $3E {$7016W}  [$00] {$75} $07 $83 $3E {$7018W}  [$00] {$74} $07 $56 $0E
             $E8 $FF02W  $44 $44 $5E $5D $CB


Walking behavior code

This behavior is used by Keen when he is moving. The first line stores Keen's vertical and horizontal directions and passes them to the sprite. (The reasons for this are complex.) The end of line 2 checks a misc variable, and if it is 4, sets it to 0. (This may be the number of animations or animation speed.) On line 3 the game checks to see if ctrl or alt is being pressed. If they are the 'enter level' code is run. (This of course only enters a level if the sprite is on one.)

On line 4 the game checks to see if any arrow key is being pressed (No keys pressed is a value of 8.) If no key is being pressed then the sprite's action is changed to standing and an animation is read off of the map animation list. (In this case entry 3, see animation section.)

On the sixth line another variable is stored and passed to misc sprite variable $3E (again the reasons are complex.) An animation is the read of the animation list. (This time it depends on the direction the sprite is moving.)

Keen Dreams

#Moving Map Keen behavior
%patch $6B0F $55 $8B $EC $56 $8B $76 $06 $A1 {$701EW}  $89 $44 $0E $A1 {$7020W}
             $89 $44 $10 $FF $44 $40 $8B $44 $40 $3D [$0004W]  {$75} $05 $C7 $44
             $40 [$0000W]  $83 $3E {$7016W}  [$00] {$75} $07 $83 $3E {$7018W}  [$00] {$74}
             $07 $56 $0E $E8 $FEC7W  $44 $44 $83 $3E {$7022W}  [$08] {$75} $13 $C7
             $44 $1E {$0D3AW}  $8B $5C $3E $D1 $E3 $8B $87 {$0E66W}  $05 [$0003W]
             $EB $18 $A1 {$7022W}  $89 $44 $3E $8B $5C $3E $D1 $E3 $8B $87 {$0E66W}
                 $8B $5C $40 $D1 $E3 $03 $87 $76 $0E $89 $44 $20 $5E $5D $CB


Speed

Map Keen's movement is covered by his animation motion. Keen only moves when walking What directions Keen will move in depends on his walking code.

Animation motion - Keen Dreams

#Map Keen waiting
%patch $247B6 [$0000W $0000W]

#Map Keen waving-napping
%patch $247D4 [$0000W $0000W]
%patch $247F2 [$0000W $0000W]
%patch $24810 [$0000W $0000W]
%patch $2482E [$0000W $0000W]
%patch $2484C [$0000W $0000W]
%patch $2486A [$0000W $0000W]
%patch $24888 [$0000W $0000W]
%patch $248A6 [$0000W $0000W]

#Map Keen walking
%patch $248C4 [$0010W $0010W]


Sprite Collision

Map Keen has no collision by default. This means that he cannot interact with other sprites at all. This can be changed by giving him normal Keen's collision.

Map Keen collision values - Keen Dreams

#Map Keen waiting
%patch $247BE $00000000L

#Map Keen waving-napping
%patch $247DC $00000000L
%patch $247FA $00000000L
%patch $24818 $00000000L
%patch $24836 $00000000L
%patch $24854 $00000000L
%patch $24872 $00000000L
%patch $24890 $00000000L
%patch $248AE $00000000L

#Map Keen walking
%patch $248CC $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.

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 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 is 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, $00DAW means 'Use frames $DB, $DC, and $DD.'

Keen's animation is also set when he is first spawned; before he is given one by the list. When Keen stops walking his animation is the 3rd entry of the animation list. This means there are two places the animation list is read from.

Map Keen cache

#Cache - Keen Dreams
%patch $23E76 $00D5W #Map Keen cache start
%patch $23EA2 $00F0W #Map Keen cache end

Map Keen animations

#Map Keen wait to wave, etc
%patch $247AA $0000W $0000W
%patch $247B4 $0168W        #Wait time

#Map Keen wave
%patch $247C8 $00EFW $00EFW
%patch $247D2 $0014W        #Animation speed
%patch $247E6 $00F0W $00F0W
%patch $247F0 $0014W        #Animation speed
%patch $24804 $00EFW $00EFW
%patch $2480E $0014W        #Animation speed
%patch $24822 $00F0W $00F0W
%patch $2482C $0014W        #Animation speed
%patch $24840 $00EFW $00EFW
%patch $2484A $0014W        #Animation speed

#Map Keen nap
%patch $2485E $00E0W $00E0W
%patch $24868 $0190W        #Animation speed
%patch $2487C $00EDW $00EDW
%patch $24886 $001EW        #Animation speed
%patch $2489A $00EEW $00EEW
%patch $248A4 $005AW        #Animation speed

#Map Keen move
%patch $248B8 $0000W $0000W
%patch $248C2 $0004W        #Walking frequency

Map Keen animation list

#List location
%patch $6B5A {$0E66W} #Going to standing
%patch $6B6E {$0E66W} #Walking

#Initial map animation
%patch $69F8 [$00D7W]

#List entry used for returning to standing
%patch $6B5D [$0003W]

#Map Keen moving
%patch $248D6 [$00DAW] #Up map sprite
%patch $248D8 [$00E9W] #Up right map sprite
%patch $248DA [$00D7W] #Right map sprite
%patch $248DC [$00E0W] #Down right map sprite
%patch $248DE [$00DDW] #Down map sprite
%patch $248E0 [$00E3W] #Down left map sprite
%patch $248E2 [$00D4W] #Left map sprite
%patch $248E4 [$00E6W] #Up left map sprite

#Number of animation frames for each sequence
%patch $248E8 [$0003W] #Number of frames 1
%patch $248EC [$0003W] #Number of frames 2


Walking on the Map Makes a Sound

Unlike in Keen Galaxy, Keen does not make any sounds on the map by default. This patch will cause him to make noise when walking. It relies, however, on a patch to make Keen make sound when walking in levels. Because of this, by default, both walking sounds will be identical.

As such an option exists to mute the walking sound in-level. If the last line of the patch is included then Keen will only make sound on the map, whereas if it is omitted he will make identical sounds on the map and in levels.

Two sounds are played in a 1-2-1-2 rhythm depending on a timer that is reset to zero after sound two plays. The timing between the two sounds is $0010W and $0020W here and the sounds used are $02 and $03. These parameters will probably need to be tweaked for a better walking sound.

Keen Dreams

#Keen makes a sound when he walks
%patch $7A17 $EB $4E $83 $7C $38 $00 $75 $06 $83 $7C $3C $00 $74 $1B $C7 $44
             $1A $0000W  $C7 $44 $1E $0ED8W  $A1 $0ED8W  $83 $7C $0E $01 $75
             $03 $A1 $0EDAW  $89 $44 $20 $EB $27 $FF $06 $0368W  $B8 [$0003W]
             $81 $3E $0368W  [$0010W]  $74 $10 $81 $3E $0368W  [$0020W]  $7C $10
             $33 $C0 $A3 $0368W  $B8 [$0002W]  $50 $9A $10BB1282RL     $44 $44
             $E9 $FF45W

#New MapKeen_Walk tcol, merges with Keen_Walk =$05E805D4RL
%patch $6454 $55 $8B $EC $56 $8B $76 $06 $E9 $15E2W  $90

#Change MapKeen_Walk tcol to make noise
%patch $248D0 $05E805D4RL

#Clear bad shot error
%patch $64A4 $05D2W $05A4W $05D2W $05B4W $05D2W

#Keen Walking in levels doesn't produce sound (OPTIONAL)
%patch $7A24 $42


Clipping and foreground

Only Map Keen's clipping can be patched.Like most sprites its value is set to 1 whenever it is spawned.

Keen Dreams

#Map Keen's clipping
%patch $69DF [$0001W]


Sprite-tile interaction

On the map Keen doesn't have to interact with tiles in any significant way aside from solid tiles blocking his progress. As such all of Keen's map actions use a generic 'do nothing' interaction that is also used by many other sprites.

Keen Dreams

#Map Keen waiting
%patch $247C2 $07C501DDRL

#Map Keen waving-napping
%patch $247E0 $07C501DDRL
%patch $247FE $07C501DDRL
%patch $2481C $07C501DDRL
%patch $2483A $07C501DDRL
%patch $24858 $07C501DDRL
%patch $24876 $07C501DDRL
%patch $24894 $07C501DDRL
%patch $248B2 $07C501DDRL

#Map Keen walking
%patch $248D0 $07C501DDRL


Action type

While waiting (and waving and napping) Keen needs to animate and react quickly, using type 3 actions. Oddly, Keen's map moving action is only type 1, allowing smooth movement but a slower reaction to the arrow keys.

Sprite action types

#Map Keen waiting
%patch $247AE [$0003W]

#Map Keen waving-napping
%patch $247CC [$0003W]
%patch $247EA [$0003W]
%patch $24808 [$0003W]
%patch $24826 [$0003W]
%patch $24844 [$0003W]
%patch $24862 [$0003W]
%patch $24880 [$0003W]
%patch $2489E [$0003W]

#Map Keen walking
%patch $248BC [$0001W]


Deprotect and stick to ground

While on the map Keen has no need for either of these variables and so has a value of 0 for both in all of his map actions.

Sprite deprotect, stick

#Map Keen waiting
%patch $247B0 [$0000W $0000W]

#Map Keen waving-napping
%patch $247CE [$0000W $0000W]
%patch $247EC [$0000W $0000W]
%patch $2480A [$0000W $0000W]
%patch $24828 [$0000W $0000W]
%patch $24846 [$0000W $0000W]
%patch $24864 [$0000W $0000W]
%patch $24882 [$0000W $0000W]
%patch $248A0 [$0000W $0000W]

#Map Keen walking
%patch $248BE [$0000W $0000W]


Sprite spawn code

The full Map Keen spawn code is quite complex. There is only one type of Map Keen. (He always spawns in the same place on any difficulty.) In the initiation code his cache is set in $C7 $06 $70BAW $0001W.

In the main spawning code Keen's type is set to 1 (But his clipping is not changed from normal.) Next 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. (These are the values $70EEW and $70F0W.)

Next Keen's activity is set at 2, and his clipping to 1. Horizontal and vertical direction are both set to 0, animation delay to 6, animation frame to 3, and current animation to $00D7W. 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.

Keen Dreams spawn code

#Map Keen pointer (At $47A4)
%patch $4A01 [$02D4W]

#Map Keen initiation code
%patch $47A4 $FF $36 $7052W  $FF $36 $7050W  $9A $05E80B20RL     $83 $C4 $04
             $C7 $06 $70BAW  $0001W  $E9 $020FW

#Map Keen spawn code
%patch $69A0 $55 $8B $EC $8B $1E $34 $70 $C7 $07 [$0001W]  $83 $3E {$70EEW}  [$00]
             {$75} $11 $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B $46 $08 $D3
             $E0 $EB $0D $8B $1E $34 $70 $A1 {$70EEW}  $89 $47 $0A $A1 {$70F0W}
             $89 $47 $0C $8B $1E $34 $70 $C7 $47 $02 [$0001W]  $C7 $47 $06 [$0001W]
                 $C7 $47 $0E [$0000W]  $C7 $47 $10 [$0000W]  $C7 $47 $3E [$0006W]
             $C7 $47 $40 [$0003W]  $C7 $47 $20 [$00D7W]  $B8 [$0D3AW]  $50 $FF $36
             $34 $70 $9A $044D1212RL     $83 $C4 $04 $5D $CB