Patch:Flags

From KeenWiki
Jump to: navigation, search

Flags are used to mark levels as done in Keen 4, Keen 5 and Keen 6; though the 'flags' in Keen 5 are sign-like in appearance. In all cases they are sprites that appear over map tiles. This page is split into two major sections. The first contains patches that relate tot he flags being created and placed; the second section relates to the properties of flags as sprites.

Related pages are Patch:Done markers and Patch:Done sign as well as Patch:Map (Keen 4), Patch:Map (Keen 5) and Patch:Map (Keen 6).


Flag creation

This section of the page deals with the conditions under which flags are created, but not any of their properties. (Those are covered in the following section.)


No flags in certain conditions

These patches will stop flags (either flipping or sitting) being created under various circumstances.


No flags

This patch eliminates the flags entirely. Levels will not be marked by a flag sprite under any circumstances.

Patch: No flags
#No flags - Keen 4
%patch $6134 $EB $25
#No flags - Keen 5
%patch $60EA $EB $11
#No flags - Keen 6
%patch $5F04 $EB $25


No flipping flags

This patch alters things so that the flags are not spawned the first time Keen completes a level. That is the level remains unmarked until he returns to the map via some method. (This includes saving the game then loading it.) This patch cannot apply to Keen 5 as it has no flipping flags.

Patch: No flipping flags
#No flipping flags - Keen 4
%patch $6141 $EB $0C
#No flipping flags - Keen 6
%patch $5F11 $EB $0C


No sitting flags

This patch eliminates sitting flags. For Keen 5 this is just the 'no flags' patch above. For Keen 4\6 a flipping flag will appear when Keen first completes a level but never again for that level after that.

Patch: No sitting flags
#No sitting flags - Keen 4
%patch $614F $EB $0A
#No flags - Keen 5
%patch $60EA $EB $11
#No sitting flags - Keen 6
%patch $5F1F $EB $0A


When flags flip or sit

These patches affect when flags flip into holders or sit in holders. This only applies to Keen 4\6 since in Keen 5 flags always sit.


Flags always sit

This patch changes things so that when Keen first completes a level a flag appears in its holder instead of flipping. This is exactly how Keen 5 handles flags so the patch does not apply to it.

Patch: Flags always appear sitting
#Flags are always sitting - Keen 4
%patch $613F $EB
#Flags are always sitting - Keen 6
%patch $5F0F $EB


Flags always flip

This patch makes flags always flip when Keen goes to the map, due to the way this works, the flag of the lowest level Keen has completed will flip normally; the other levels will have no flipping flag but a flag will appear in the holder about a second after the level is exited. This is a bit odd, but may be useful.

This only applies to Keen 4\6 as Keen 5 has no flipping code.

Patch: Flags always flip
#Flags always flip - Keen 4
%patch $613F $90 $90
#Flags always flip - Keen 6
%patch $5F0F $90 $90


Flag holder sprites

These patches alter what infoplane (sprite) values int he map level have flags placed on them.


Default flag holder marker

By default the value $F0xx acts as a flag holder marker. (So $F001 is the flag holder marker for level 1) In the default check the value has the level number taken away and the remainder is checked. If the $75 is changed to $Eb then there are no flags.

Patch: Default flag holder marker
#Default flag holder marker - Keen 4
%patch $6137 $F000W $75
#Default flag holder marker - Keen 5
%patch $60ED $F000W $75
#Default flag holder marker - Keen 6
%patch $5F07 $F000W $75


Flags appear on holders AND level entry sprites

This patch removes the flag holder check, meaning that both flag holder sprites ($F0xxW) and level entry sprites ($C0xxW) will be marked by flags.

Patch: Flags appear on holders AND level entry sprites
#Flags appear on holders AND level entry sprites - Keen 4
%patch $6139 $90 $90
#Flags appear on holders AND level entry sprites - Keen 5
%patch $60EF $90 $90
#Flags appear on holders AND level entry sprites - Keen 6
%patch $5F09 $90 $90


Flag sprites

This section of the page covers all of the sprite properties of flags such as their animation, collision and sounds produced.


Sprite Type

The Flag\Sign uses sprite type 35\8, (In Keen 4 and Keen 5 respectively) which is a miscellaneous and has no real interactions with any other sprites by default.

Patch: Keen 4
#Flag sprite type
%patch $E30B $22
#Sitting
%patch $E36D $22
#Flipping

Patch: Keen 5
#Sign sprite type
%patch $DC55 $08


Sprite Actions

There are four flag\sign sitting actions, just one animation loop. Keen 4 has seven flag flipping actions where the flag flips into the flag holder. The flag flipping actions use several behaviors and variables and are reasonably complex.

Actions, Keen 4:
$15EEW #Keen K flag waving 1
$160CW #Keen K flag waving 2
$162AW #Keen K flag waving 3
$1648W #Keen K flag waving 4
$1666W #Keen flag flips into holder 1
$1684W #Keen flag flips into holder 2
$16A2W #Keen flag flips into holder 3
$16C0W #Keen flag flips into holder 4
$16DEW #Keen flag flips into holder 5
$16FCW #Keen flag flips into holder 6
$171AW #Keen flag flips into holder 7
Actions, Keen 5:
$148AW #Keen K sign 1
$14A8W #Keen K sign 2
$14C6W #Keen K sign 3
$14E4W #Keen K sign 4

Patch: Keen 4
#Spawn flags
%patch $E4A0 $1666W
#Flipping flag (When a level is first completed)
%patch $E33D $15EEW
#Spawn waving flag (Whenever Keen arrives on map)
#Flipping flag
%patch $304F2 $1684W
#Keen flag flips into holder 1
%patch $30510 $16A2W
#Keen flag flips into holder 2
%patch $3052E $16C0W
#Keen flag flips into holder 3
%patch $3054C $16DEW
#Keen flag flips into holder 4
%patch $3056A $16FCW
#Keen flag flips into holder 5
%patch $30588 $171AW
#Keen flag flips into holder 6
%patch $305A6 $15EEW
#Place waving flag
#Sitting flag
%patch $3047A $160CW
#Keen K flag waving 1
%patch $30498 $162AW
#Keen K flag waving 2
%patch $304B6 $1648W
#Keen K flag waving 3
%patch $304D4 $15EEW
#Keen K flag waving 4, loop to 1]


Patch: Keen 5
#Sign spawned
%patch $DC87 $148AW
#Keen K sign 1
#Sitting sign
%patch $317E6 $14A8W
#Keen K sign 1
%patch $31804 $14C6W
#Keen K sign 2
%patch $31822 $14E4W
#Keen K sign 3
%patch $31840 $148AW
#Keen K sign 4


Sprite Behavior

Still flags do not have any behavior, they just sit and animate. In Keen 4 there are three flag behaviors for the flipping flag; one to appear with a sound, one to move towards the flag holder and one to make a noise as the flag 'lands'

Behaviors (Keen 4):
$0D8F0BC4RL #Appear with a pop sound
$0D8F0BEFRL #Head toward level marker
$0D8F0C51RL #Land in level marker with a thud sound

Patch: Keen 4
#Still flag
%patch $3046E $00000000L
#Nothing
%patch $3048C $00000000L
#Nothing
%patch $304AA $00000000L
#Nothing
%patch $304C8 $00000000L
#Nothing
#Flipping flag
%patch $304E6 $0D8F0BC4RL
#Appear with a pop sound
%patch $30504 $0D8F0BEFRL
#Head toward level marker
%patch $30522 $0D8F0BEFRL
#Head toward level marker
%patch $30540 $0D8F0BEFRL
#Head toward level marker
%patch $3055E $0D8F0BEFRL
#Head toward level marker
%patch $3057C $0D8F0BEFRL
#Head toward level marker
%patch $3059A $0D8F0C51RL
#Land in level marker with a thud sound

Patch: Keen 5
%patch $317DA $00000000L  
#Nothing
%patch $317F8 $00000000L
#Nothing
%patch $31816 $00000000L
#Nothing
%patch $31834 $00000000L
#Nothing


Speed and Jump Height

Flag sprites do not move, though moving flags hold interesting possibilities, since they respawn each time Keen enters the map. The movement seen in Keen 4 depends on the flag's behavior.

Patch: Keen 4
#Flag flips into holder
%patch $304E2 $0000W $0000W
#Speed 1
%patch $30500 $0000W $0000W
#Speed 2
%patch $3051E $0000W $0000W
#Speed 3
%patch $3053C $0000W $0000W
#Speed 4
%patch $3055A $0000W $0000W
#Speed 5
%patch $30578 $0000W $0000W
#Speed 6
%patch $30596 $0000W $0000W
#Speed 7
#Flag in holder, waving
%patch $3046A $0000W $0000W
#Speed 1
%patch $30488 $0000W $0000W
#Speed 2
%patch $304A6 $0000W $0000W
#Speed 3
%patch $304C4 $0000W $0000W
#Speed 4

Patch: Keen 5
%patch $317D6 $0000W $0000W 
#Speed 1
%patch $317F4 $0000W $0000W
#Speed 2
%patch $31812 $0000W $0000W
#Speed 3
%patch $31830 $0000W $0000W
#Speed 4


Sprite Collision

Flags have no collision, since the map is quite uneventful, but there is potential.

Patch: Keen 4 collision values
#Flipping flag
%patch $332EA $00000000L
#No collision
%patch $33308 $00000000L
#No collision
%patch $33326 $00000000L
#No collision
%patch $33344 $00000000L
#No collision
%patch $33362 $00000000L
#No collision
%patch $33380 $00000000L
#No collision
%patch $3339E $00000000L
#No collision
#Still flag
%patch $33272 $00000000L
#No collision
%patch $33290 $00000000L
#No collision
%patch $332AE $00000000L
#No collision
%patch $332CC $00000000L
#No collision

Patch: Keen 5 collision values
#Map sign
%patch $317DE $00000000L
#No collision
%patch $317FC $00000000L
#No collision
%patch $3181A $00000000L
#No collision
%patch $31838 $00000000L
#No collision


Animations

Flag animations are pretty simple and self explanatory. For the flipping flag in Keen 4 the last entry doesn't use the animation speed, but lasts as long as it takes to reach the flag holder.

Patch: Keen 4
#Flipping into holder
%patch $304D6 $012AW $012AW
#Map flag flip
%patch $304E0 $0006W
#Animation speed
%patch $304F4 $012AW $012AW
#Map flag flip 2
%patch $304FE $000CW
#Animation speed
%patch $30512 $012BW $012BW
#Map flag flip 3
%patch $3051C $000CW
#Animation speed
%patch $30530 $012CW $012CW
#Map flag flip 4
%patch $3053A $000CW
#Animation speed
%patch $3054E $012DW $012DW
#Map flag flip 5
%patch $30558 $000CW
#Animation speed
%patch $3056C $012FW $012FW
#Map flag fall
%patch $30576 $000CW
#Animation speed
%patch $3058A $012FW $012FW
#Map flag fall
%patch $30594 $0001W
#Animation speed
#Keen K flag waving
%patch $3045E $0131W $0131W %patch $30468 $000AW
#Animation speed
%patch $3047C $0132W $0132W %patch $30486 $000AW
#Animation speed
%patch $3049A $0133W $0133W %patch $304A4 $000AW
#Animation speed
%patch $304B8 $0134W $0134W %patch $304C2 $000AW
#Animation speed

Patch: Keen 5
#Keen K sign
%patch $317CA $0113W $0113W %patch $317D4 $000AW
#Animation speed
%patch $317E8 $0114W $0114W %patch $317F2 $000AW
#Animation speed
%patch $31806 $0115W $0115W %patch $31810 $000AW
#Animation speed
%patch $31824 $0116W $0116W %patch $3182E $000AW
#Animation speed

Patch: Keen 6
#Flipping into holder
%patch $3219C $00E4W $00E4W
#Keen K flag to holder 1 (Fly up)
%patch $321A6 $0006W
#Animation speed
%patch $321BA $00E4W $00E4W
#Keen K flag to holder 2 (Move along)
%patch $321C4 $000CW
#Animation speed
%patch $321D8 $00E5W $00E5W
#Keen K flag to holder 3
%patch $321E2 $000CW
#Animation speed
%patch $321F6 $00E6W $00E6W
#Keen K flag to holder 4
%patch $32200 $000CW
#Animation speed
%patch $32214 $00E7W $00E7W
#Keen K flag to holder 5 (Fall into holder)
%patch $3221E $000CW
#Animation speed
%patch $32232 $00E9W $00E9W
#Keen K flag to holder 6
%patch $3223C $000CW
#Animation speed
%patch $32250 $00E9W $00E9W
#Keen K flag to holder 7
%patch $3225A $0001W
#Animation speed
#Keen K flag waving
%patch $32124 $00EBW $00EBW %patch $3212E $000AW
#Animation speed
%patch $32142 $00ECW $00ECW %patch $3214C $000AW
#Animation speed
%patch $32160 $00EDW $00EDW %patch $3216A $000AW
#Animation speed
%patch $3217E $00EEW $00EEW %patch $32188 $000AW
#Animation speed


Sprite positioning

Flipping flags spawn 16 pixels (or tile) up and right of Keen's location when he entered the level. Its target is the flag holder, where it will start to 'fall' 6 pixels right and 40 pixels (2.5 tiles) above the target. (This affects its final destination too.)

The Sign is positioned differently since it is a different size and never 'flips'.

Patch: Keen 4
#Spawn position:
%patch $E378 $0100W
#16 pixels right
%patch $E381 $0100W
#16 pixels up
#Target position:
%patch $E38E $0060W
#6 pixels right
%patch $E399 $0FD0W
#40 pixels up

Patch: Keen 5
#Spawn position:
%patch $DC64 $FFB0W
#5 pixels right
%patch $DC6F $FE20W
#30 pixels up


Sounds

There are two Flag-related sounds, one for Flags being spawned when Keen wins a level, another when it lands in a holder. This is only for Keen 4 and Keen 6, Keen 5's system is soundless.

Patch: Keen 4
%patch $E4C8 $2B     
#Keen K flag 'launches' sound
%patch $E533 $2B
#Keen K flag 'lands' sound
%patch $E4C7 $EB $0A
#Don't play Keen K flag 'launches' sound
%patch $E532 $EB $0A
#Don't play Keen K flag 'lands' sound

Patch: Keen 6
%patch $D720 $2B     
#Keen K flag 'launches' sound
%patch $D71F $2B
#Keen K flag 'lands' sound
%patch $D78B $EB $0A
#Don't play Keen K flag 'launches' sound
%patch $D78A $EB $0A
#Don't play Keen K flag 'lands' sound


Clipping and foreground

Both the flipping and sitting Flags use a foreground variable of 3, putting them in front of all tiles at all times. This can cause issues. (the Flags will appear in front of the Scorebox for example.)

Flags have no clipping, so they may ignore map tiles, especially when flipping. If this is not the case Flags can get 'stuck'.

Patch: Keen 4
#Flag foreground variable
%patch $E307 $0003W
#Flipping
%patch $E369 $0003W
#Sitting
#Flag clipping
%patch $E302 $0000W
#Flipping
%patch $E364 $0000W
#Sitting

Patch: Keen 5
#Sign
%patch $DC4C $0000W
#Clipping
%patch $DC51 $0003W
#Foreground

Sprite-tile interaction

The default Keen 4 flags use the 'sit' interaction, ignoring all tiles, the Keen 5 signs use 'solid'; being blocked by solid tiles.

Patch: Keen 4
#Flipping flag
%patch $304DC $09DC176ERL
#Sit
%patch $304FA $09DC176ERL
#Sit
%patch $30518 $09DC176ERL
#Sit
%patch $30536 $09DC176ERL
#Sit
%patch $30554 $09DC176ERL
#Sit
%patch $30572 $09DC176ERL
#Sit
%patch $30590 $09DC176ERL
#Sit
#Waving flag
%patch $30464 $09DC176ERL
#Sit
%patch $30482 $09DC176ERL
#Sit
%patch $304A0 $09DC176ERL
#Sit
%patch $304BE $09DC176ERL
#Sit

Patch: Keen 5
#Map sign
%patch $317E2 $090B17B5RL
#Solid
%patch $31800 $090B17B5RL
#Solid
%patch $3181E $090B17B5RL
#Solid
%patch $3183C $090B17B5RL
#Solid


Motion parameter

The flipping flags in Keen 4 are an interesting case. The first action uses value 2 for its entire flip, all others using value 3, allowing them to 'fall' into the holder. Sitting flags have value 0.

Patch: Keen 4
#Flipping flag
%patch $304DA $0002W
#Keen flag flips into holder 1 (Upwards flip)
%patch $304F8 $0003W
#Keen flag flips into holder 2
%patch $30516 $0003W
#Keen flag flips into holder 3
%patch $30534 $0003W
#Keen flag flips into holder 4
%patch $30552 $0003W
#Keen flag flips into holder 5
%patch $30570 $0003W
#Keen flag flips into holder 6
%patch $3058E $0003W
#Keen flag flips into holder 7
#Sitting flag
%patch $30462 $0000W
#Keen K flag waving 1 (Sit)
%patch $30480 $0000W
#Keen K flag waving 2
%patch $3049E $0000W
#Keen K flag waving 3
%patch $304BC $0000W
#Keen K flag waving 4

Patch: Keen 5
#Keen K sign
%patch $317CE $0000W %patch $317EC $0000W %patch $3180A $0000W %patch $31828 $0000W


Deprotect and stick to ground

The map flags do not use these variables as they don't move, except the 7th flag flip, where it uses the stick-to-ground variable to settle correctly into the flag holder.

Patch: Keen 4
#Flipping flag
%patch $304DC $0000W $0000W
#Flag flip 1
%patch $304FA $0000W $0000W
#Flag flip 2
%patch $30518 $0000W $0000W
#Flag flip 3
%patch $30536 $0000W $0000W
#Flag flip 4
%patch $30554 $0000W $0000W
#Flag flip 5
%patch $30572 $0000W $0000W
#Flag flip 6
%patch $30590 $0001W $0000W
#Flag flip 7 (Notice value of 1)
#Sitting flag
%patch $30464 $0000W $0000W
#Flag waving 1
%patch $30482 $0000W $0000W
#Flag waving 2
%patch $304A0 $0000W $0000W
#Flag waving 3
%patch $304BE $0000W $0000W
#Flag waving 4

Patch: Keen 5
#Keen's K sign
%patch $317D0 $0000W $0000W
#Stand
%patch $317EE $0000W $0000W
#Stand
%patch $3180C $0000W $0000W
#Stand
%patch $3182A $0000W $0000W
#Stand


Sprite spawn code

Flags do not have a traditional spawning setup, they cannot be placed in levels by default, but they can be spawned on the map using a spawn code. There are two kinds of spawning, for sitting flags and for 'jumping flags'.

In the sitting Flag spawning code the last blue highlighted value is the sprite action the sprite uses as it proceeds to act in-level. $C7 $02 $xxxxW sets the sprite activity, (here set to be active even when offscreen.) $C7 $07 $xxxxW sets the sprite type, $C7 $20 $xxxxW sets the foreground value. (Here set to be 3, in front of all tiles, even foreground ones.) Finally $D3 $E0 $05 $xxxx is how far down (Or more usually up) the sprite is spawned from where it is placed. The flag has two of these values, setting its horizontal and vertical position relative to flag holders.

The flipping flag code is more complex, the first few lines create a similar sprite to the sitting flag. On the third line its spawn location is set, taking Keen's current location and subtracting 16 pixels ($0100W) from it. Line 5 sets the Flag's 'drop' start relative to the target Flag holder. Lines 8 and 9 set the Flag's horizontal speed when it flips into the holder. Line 12 is how far down the Flag flips before settling into the holder. Line 15 starts with the Flag's upwards flip speed while the following line controls how far above the target the Flag starts to fall vertically down.

Patch: Keen 4
#Sitting flag spawn code
%patch $E2ED $55 $8B $EC $33 $C0 $50 $9A $06BD1E11RL $83 $C4 $02 $8B $1E $D8 $A7 $C7 $47 $06 $0000W $C7 $47 $20 $0003W $C7 $07 $0022W $C7 $47 $02 $0001W $8B $46 $06 $B1 $08 $D3 $E0 $05 $0060W $89 $47 $0A $8B $46 $08 $D3 $E0 $05 $FE20W $89 $47 $0C $9A $1D02002ARL $BB $0010W $99 $F7 $FB $8B $1E $D8 $A7 $89 $47 $1A $B8 $15EEW $50 $53 $9A $09DC118CRL $83 $C4 $04 $5D $CB
#Flipping Flag spawn code
%patch $E34B $55 $8B $EC $83 $EC $08 $56 $33 $C0 $50 $9A $06BD1E11RL $83 $C4 $02 $8B $1E $D8 $A7 $C7 $47 $06 $0000W $C7 $47 $20 $0003W $C7 $07 $0022W $C7 $47 $02 $0002W $A1 $7A1AW $2D $0100W $89 $47 $0A $A1 $7A1CW $2D $0100W $89 $47 $0C $8B $46 $06 $B1 $08 $D3 $E0 $05 $0060W $89 $47 $3E $8B $46 $08 $D3 $E0 $05 $FDA0W $89 $47 $40 $8B $47 $3E $99 $2B $47 $0A $83 $DA $00 $89 $56 $FE $89 $46 $FC $8B $47 $40 $99 $2B $47 $0C $83 $DA $00 $89 $56 $FA $89 $46 $F8 $33 $F6 $E9 $00D4W $33 $C0 $BA $0018W $50 $52 $83 $FE $18 $7D $04 $8B $C6 $EB $03 $B8 $0018W $99 $50 $52 $8B $56 $FE $8B $46 $FC $59 $5B $9A $0000308ARL $52 $50 $9A $000030C5RL $8B $1E $D8 $A7 $8B $57 $0A $03 $D0 $8B $DE $D1 $E3 $D1 $E3 $89 $97 $BF $CA $33 $C0 $BA $001EW $50 $52 $8B $C6 $99 $50 $52 $8B $56 $FA $8B $46 $F8 $59 $5B $9A $0000308ARL $52 $50 $9A $000030C5RL $8B $1E $D8 $A7 $8B $57 $0C $03 $D0 $8B $DE $D1 $E3 $D1 $E3 $89 $97 $C1 $CA $83 $FE $0A $7D $13 $8B $C6 $BA %patch $E43B $0030W $F7 $EA $8B $DE $D1 $E3 $D1 $E3 $29 $87 $C1 $CA $EB $4B $83 $FE $0F $7D $15 $8B $C6 $B1 $04 $D3 $E0 $05 $0140W $8B $DE $D1 $E3 $D1 $E3 $29 $87 $C1 $CA $EB $31 $83 $FE $14 $7D $18 $B8 $0014W $2B $C6 $B1 $04 $D3 $E0 $05 $01E0W $8B $DE $D1 $E3 $D1 $E3 $29 $87 $C1 $CA $EB $14 $B8 $001DW $2B $C6 $BA $0030W $F7 $EA $8B $DE $D1 $E3 $D1 $E3 $29 $87 $C1 $CA $46 $83 $FE $1E $7D $03 $E9 $FF24W $B8 $1666W $50 $FF $36 $D8 $A7 $9A $09DC118CRL $83 $C4 $04 $5E $8B $E5 $5D $CB

Patch: Keen 5
#Sitting sign spawn code
%patch $DC37 $55 $8B $EC $33 $C0 $50 $9A $06B91DCDRL $83 $C4 $02 $8B $1E $40 $9E $C7 $47 $06 $0000W $C7 $47 $20 $0003W $C7 $07 $0008W $C7 $47 $02 $0001W $8B $46 $06 $B1 $08 $D3 $E0 $05 $FFB0W $89 $47 $0A $8B $46 $08 $D3 $E0 $05 $FE20W $89 $47 $0C $9A $1DFB0036RL $BB $0010W $99 $F7 $FB $8B $1E $40 $9E $89 $47 $1A $B8 $148AW $50 $53 $9A $090B11C4RL $83 $C4 $04 $5D $CB