Patch:Purple spark
Purple Sparks are purple, harmless sprites found in Keen 3. They are a part of the Mangling Machine. This page lists patches relating to Spark sprites. It is divided into sections relating to the various sprite properties the patches involve. Being fluent with various sprite patch pages will help when working with these patches.
A related sprite is the Heart.
Sprite Type
Sparks use type 13, also used by Hearts. This does not affect any other sprite in any way. There is also the Zap-zot sprites produced when the Mangling Machine is destroyed; these use type 19, a similarly ineffectual property.
Keen 3
#Spark sprite type:
%patch $4071 $0D #Heart
%patch $4F5D $13 #MM destroyed zap-zots
Sprite Behavior
Purple sparks have only one behavior, they sit in place and animate. This never changes.
Behaviors: $4E02W #Spark sit $4E19W #Spark collision
When spawned
#Spark behavior
%patch $4094 {$4E02W}
#Spark collision
%patch $4099 {$4E19W}
Complete Spark behavior
This is the complete code for the Purple Spark's behavior, which is exceedingly simple. It merely site in place and animates. The blue values are the number of animation frames and start animation in that order.
Complete Spark behavior
#Complete Spark behavior
%patch $4E02 $55 $8B $EC $A1 $61 $53 $D1 $E8 $D1 $E8 $D1 $E8 $25 [$0003W] $05
[$0072W] $A3 $38 $99 $5D $C3
Sprite Collision and points given when shot
Sparks have an interesting sprite collision; if a certain number of them are destroyed then an area of the level will be destroyed also. This is used to destroy the Mangling Machine's arms when six are sot. Further patches can be found on the Mangling Machine's page. The Spark is only damaged by Keen's shot and vanishes when shot.
The Sparks give 1000 points each when destroyed and six are required to trigger the level destruction sequence.
Basic patches
These are simple patches for altering what the Spark's collision does.
Keen 3
%patch $4099 {$4E19W} #Spark collision
%patch $4E22 $3F [$0F] #Spark killed by Keen's shot
Points given when destroyed
#Points you get for shooting a spark
%patch $4E44 [$03E8W]
#How many sparks need to be shot to destroy the arms
%patch $4E53 [$0006W] $75
Spark counter reset in Mortimer conversation window
When the Mortimer McMire conversation window plays,t he number of sparks shot is set to 0. This means that this value is only reset at the start of level 16 by default. See Patch:Mangling Machine and Patch:Game stats.
Keen 3
#Spark counter set to this when Mortimer window plays
%patch $507A {$990CW} [$0000W]
Ice tiles reset Purple Spark counter
This patch resets the counter when Keen steps on ice property tiles, place one at the level start and that will fix that problem. (Side effect, you can't use ice tiles throughout the level:
Keen 3
#'Ice' tile top property resets Purple spark counter on contact
%patch $7046 $83 $3E {$5FD6W} [$00] {$75} $15 $C7 $06 {$990CW} [$0000W] $EB $0D
#Make these tiles behave more like normal ground
%patch $6FB9 $04 $7D #What tile properties stops Keen from changing his speed when on them
%patch $708F $04 $7D #What tile properties stop Keen animating while walking left
%patch $70B6 $04 $7D #What tile properties stop Keen animating while walking right
%patch $70E8 $04 $7D #What tile properties stop Keen making the walking sound
Complete collision code
This is the collision code in its entirety. Notably it does not contain the code that causes part of the level to be destroyed when six sparks are shot, that is elsewhere and is triggered by the collision code.
In the first line of the patch the Spark checks to see if it is colliding with Keen's shot, this is the only sprite type that can destroy it. If it is not then is jump over a jump to the end of the code. (A rather odd and complex thing to do.) On the second line Keen's shot's type is set to 0 and the Spark's vertical position is set to 4 (Why is unknown.)
On the third line the behavior is set t0 $8048 and its vertical position is further modified. (Again why is unknown.) 1000 points is then added to the player's score. On the fourth line the number of shot sparks is increased by 1, and if 6 have been shot more code is executed. (See Patch:Game stats.) The function of the extra code is to destroy part of the Mangling Machine, but how it does this is not currently known.
Keen 3
#Purple spark collision
%patch $4E19 $55 $8B $EC $56 $57 $8B $5E $06 $83 $3F [$0F] {$74} $02 $EB $7A $8B
$5E $04 $C7 $07 [$0000W] $E8 $11D6W $8B $F0 $C7 $44 $08 [$0004W]
$C7 $44 $22 {$8048W} $C7 $44 $0A [$0000W] $B8 [$03E8W] $50 $E8 $BF7BW
$59 $FF $06 $990CW $A1 $990CW $3D [$0006W] {$75} $4B $33 $FF
$EB $20 $8B $C7 $BA $24 $00 $F7 $EA $8B $D8 $83 $BF $CE $96 $06
$75 $0F $8B $C7 $BA $24 $00 $F7 $EA $8B $D8 $C7 $87 $CE $96 $00
$00 $47 $3B $3E $06 $99 $7C $DA $E8 $84 $11 $8B $F0 $C7 $44 $08
$0008W $C7 $44 $22 $B6 $4F $C7 $44 $04 $0006W $C7 $44 $06 $0000W
$33 $C0 $89 $44 $0C $89 $44 $0A $5F $5E $5D $C3
Don't destroy Mangling Machine Arms
This patch removes the code that destroys the Mangling Machine arms. This means that any number of sparks can be destroyed in a level without this occurring.
Keen 3
#Purple spark collision - no MM destruction
%patch $4E19 $55 $8B $EC $56 $57 $8B $5E $06 $83 $3F [$0F] {$75} $2F $8B #Check for Keen's shot
$5E $04 $C7 $07 [$0000W] $E8 $11D8W $8B $F0 $C7 $44 $08 [$0004W]
$C7 $44 $22 {$8048W} $C7 $44 $0A [$0000W] $B8 [$03E8W] $50 $E8 $BF7DW
$59 $5F $5E $5D $C3
Animations
These are the animations used by the Spark. it has only one animation cycle of four frames.
When spawned
%patch $409E [$0072W] #Start
In level
%patch $4E12 [$0072W] #Spark
%patch $4E0F $03 #Frames used
Sprite spawning
This is the complete code for the Spark's spawning. As it contains many patches elsewhere on this page, it is incompatible with them.
The Spark has a normal sort of spawn code, despite its simplicity as a sprite. Its sprite type is set to 13, its behavior to running 'Sit', its collision to 'destroy 6 to blast Mangling Machine arms' with a strength of 1. However it lacks any sort of initial speed, it sits perfectly still.
Spark spawn
#Spark initiation pointer
%patch $3BEA [$000CW]
#Initiation - Spark (Code at $3B4B + $516 + 5 = $4066)
%patch $3B4B $56 $57 $E8 $0516W $59 $59 $EB $66
#Spark spawn code
%patch $4066 $55 $8B $EC $56 $E8 $1F50W $8B $F0 $C7 $04 [$000DW] $8B $46 $04 #Sprite type = 13
$99 $B1 $0C $E8 $AB45W $89 $44 $04 $89 $54 $06 $8B $46 $06 $99
$B1 $0C $E8 $AB36W $89 $44 $08 $89 $54 $0A $C7 $44 $32 {$4E02W} #Behavior = $4E02
$C7 $44 $34 {$4E19W} $C7 $44 $28 [$0072W] $5E $5D $C3 #Collision $4E19, sprite = 72