Patch:Keen on map (Dreams)

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 (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 is type 1. This is the same as Keen's type in-level. However Keen cannot be killed on the map.

Patch: Keen Dreams
#Map Keen
%patch $66A9 $02


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

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

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

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

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

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

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

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

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

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