Patch:Pea Pod
Pea Pods are green, banana-like creatures (or rather creature) that is found in only one level, Apple Acres in Keen Dreams. They move back and forth ignoring Keen, but if he is close they may eject a Pea Brain to chase after him.
Pea Brain are closely related to the Pea Pod and patches relating to them are also on this page. They are also targets for the dropping enemy bug which can crash the game if it is abused. This will occur is a Pea Brain is fired off a cliff.
Sprite Type
Pea Pods and Pea Brains use types 15\16 which have no impact on any other sprites save for making them transform into Wilted Flowers properly.
Keen Dreams
#Pea sprite types
%patch $91FA [$15] #Pea Pod
%patch $917C [$16] #Pea Brain
%patch $9245 [$16] #Pea Brain spat from Pod
Sprite Actions
The Pea Brain has a simple set of actions; it is spawned walking and continues walking indefinitely.
Pea Pods are spawned in the first frame of their walking cycle. They remain in this four frame cycle until they randomly go to spitting. Spitting is a two frame sequence that ends with the Pea Pod returning to walking.
When spitting the Pea Pod produces a falling Pea Brain. The falling Pea Brain does nothing by itself, instead waiting to hit the ground. When it does it produces a walking Pea Brain that acts like any other Pea Brain.
Actions: $228AW #Pea Brain fall $22A8W #Pea Brain walk 1 $22C6W #Pea Brain walk 2 $22E4W #Pea Brain walk 3 $2302W #Pea Brain walk 4 $2320W #Pea Pod walk 1 $233EW #Pea Pod walk 2 $235CW #Pea Pod walk 3 $237AW #Pea Pod walk 4 $2398W #Pea Pod spit 1 $23B6W #Pea Pod spit 2
Pea Brain
#Place Pea Brain in level
%patch $9191 [$22A8W]
#Walking cycle
%patch $25D34 [$22C6W]
%patch $25D52 [$22E4W]
%patch $25D70 [$2302W]
%patch $25D8E [$22A8W]
Pea Pod
#Place Pea Pod in level
%patch $921C [$2320W]
#Walking cycle
%patch $25DAC [$233EW]
%patch $25DCA [$235CW]
%patch $25DE8 [$237AW]
%patch $25E06 [$2320W]
#Pod randomly go to spitting
%patch $9300 [$2398W]
#Spitting sequence
%patch $25E24 [$23B6W]
%patch $25E42 [$2320W]
#What spitting Pod produces
%patch $9299 [$228AW]
#What falling Pea Brain does
%patch $25D16 [$0000W]
#When falling Pea Brain hits ground
%patch $91BD [$22A8W]
Sprite Behavior
Behaviors: $07C501A4RL #Move through the air $08680B22RL #Pea Brain walk $08680BADRL #Pea Pod make Pea $08680C2BRL #Pea Pod walk, spit
The Pea Brain and Pea Pod have three unique behaviors. The Pea has its own walking behavior when walking as does the Pea Pod. (The Pea Pod's makes it spit randomly.) The first frame of the Pea Pod spitting uses a behavior that makes it produce a Pea Brain while the second frame has no behavior. Finally the falling Pea Brain uses a general 'move through the air' behavior.
Replacing the Pea Pod's walking behavior will stop it producing Pea Brains.
Keen Dreams
#Pea fall
%patch $25D0A $07C501A4RL
#Pea walk
%patch $25D28 $08680B22RL
%patch $25D46 $08680B22RL
%patch $25D64 $08680B22RL
%patch $25D82 $08680B22RL
#Peapod walk
%patch $25DA0 $08680C2BRL
%patch $25DBE $08680C2BRL
%patch $25DDC $08680C2BRL
%patch $25DFA $08680C2BRL
#Peapod spit
%patch $25E18 $08680BADRL
%patch $25E36 $00000000L
Spitting range
The Pea Pod will only spit Pea Brains if in front of Keen and less than 3 tiles ($0300W) above or below Keen.
Keen Dreams
#Pea Pod spitting range
%patch $92C2 [$0300W] #Vertical
Number of Peas produced per pod
Each Pea Pod will produce only a certain number of Pea brains. By default this is four. The maximum number producible is $7F, which is enough to make the game crash.
Keen Dreams
#Number of Peas per Pod
%patch $92F7 [$04]
Speed
Both the Pea Brain and Pea Pod have animation motion; this governs how fast they walk back and forth.
Animation motion
#Pea fall
%patch $25D06 [$0000W $0000W]
#Pea walk
%patch $25D24 [$0080W $0000W]
%patch $25D42 [$0080W $0000W]
%patch $25D60 [$0080W $0000W]
%patch $25D7E [$0080W $0000W]
#Peapod walk
%patch $25D9C [$0080W $0000W]
%patch $25DBA [$0080W $0000W]
%patch $25DD8 [$0080W $0000W]
%patch $25DF6 [$0080W $0000W]
#Peapod spit
%patch $25E14 [$0000W $0000W]
%patch $25E32 [$0000W $0000W]
Sprite collision
Like nearly all sprites in Keen Dreams the Pea Pod and Pea Brain do not have a sprite collision. Instead Keen and his shots react to them and their sprite types.
Keen Dreams
#Pea fall
%patch $25D0E $00000000L
#Pea walk
%patch $25D2C $00000000L
%patch $25D4A $00000000L
%patch $25D68 $00000000L
%patch $25D86 $00000000L
#Peapod walk
%patch $25DA4 $00000000L
%patch $25DC2 $00000000L
%patch $25DE0 $00000000L
%patch $25DFE $00000000L
#Peapod spit
%patch $25E1C $00000000L
%patch $25E3A $00000000L
Animations
Pea Pods have two animation cycles, one to walk and one to spit. Pea brains are similar, one walking cycle and one being spat cycle (Flying through the air.) Both the Pea brain and Pea Pod use the same cache.
Keen Dreams
#Cache
%patch $23E8E $0155W #Cache start
%patch $23EBA $0166W #Cache end
#Pea brain being spat out
%patch $25CFA $0163W $015FW
%patch $25D04 $0000W #Animation speed
#Pea brain walk
%patch $25D18 $0163W $015FW
%patch $25D22 $000AW #Animation speed
%patch $25D36 $0164W $0160W
%patch $25D40 $000AW #Animation speed
%patch $25D54 $0165W $0161W
%patch $25D5E $000AW #Animation speed
%patch $25D72 $0166W $0162W
%patch $25D7C $000AW #Animation speed
#Pea pod walk
%patch $25D90 $015AW $0155W
%patch $25D9A $000AW #Animation speed
%patch $25DAE $015BW $0156W
%patch $25DB8 $000AW #Animation speed
%patch $25DCC $015CW $0157W
%patch $25DD6 $000AW #Animation speed
%patch $25DEA $015DW $0158W
%patch $25DF4 $000AW #Animation speed
#Pea pod spit
%patch $25E08 $015EW $0159W
%patch $25E12 $001EW #Animation speed
%patch $25E26 $015EW $0159W
%patch $25E30 $001EW #Animation speed
Sprite-tile interaction
Both the walking Pea Brain and walking Pea Pod use a generic 'turn at walls and edges' tile collision that lets them walk back and forth. The spitting Pea Pod uses a 'sit' tile interaction while the falling Pea brain uses its own, special, tile interaction that produces a walking Pea Brain when it hits floors.
Keen Dreams
#Pea fall
%patch $25D12 $08680B2FRL
#Pea walk
%patch $25D30 $07C50299RL
%patch $25D4E $07C50299RL
%patch $25D6C $07C50299RL
%patch $25D8A $07C50299RL
#Peapod walk
%patch $25DA8 $07C50299RL
%patch $25DC6 $07C50299RL
%patch $25DE4 $07C50299RL
%patch $25E02 $07C50299RL
#Peapod spit
%patch $25E20 $07C501DDRL
%patch $25E3E $07C501DDRL
Spitting probability
When the Pea Pod stops to spit there is a certain probability of it producing a Pea brain. By default this is quite low, $0008W or 3% of the time. The Pod can spit multiple consecutive peas, so if this is increased the Pod will start producing 'clusters' of peas.
The number of Peas produced per pod is covered under the behavior section.
Keen Dreams
#Pea Pod production probability
%patch $92F0 [$0008W]
Sprite positioning
The Pea Pod spawns 16 pixels higher then where it is placed in-level. This needs to be changed with its sprite height as it is vital to make it walk on the ground.
Spat our Pea brains appear 8 pixels down from the Pea Pod's top. If the Pea Pod is facing right it will also be move 8 pixels right.
Keen Dreams
#Pea Pod spawn height
%patch $920C [$FF00W] #8 pixels upwards
#Spat out Peas
%patch $9251 [$0080W] #8 pixels right
%patch $9263 [$0080W] #8 pixels down
Action type
Needing to fall smoothly the falling Pea Brain uses a type 2 action. All other actions are more simple and thus type 0.
Sprite action types
#Pea fall
%patch $25CFE [$0002W]
#Pea walk
%patch $25D1C [$0000W]
%patch $25D3A [$0000W]
%patch $25D58 [$0000W]
%patch $25D76 [$0000W]
#Peapod walk
%patch $25D94 [$0000W]
%patch $25DB2 [$0000W]
%patch $25DD0 [$0000W]
%patch $25DEE [$0000W]
#Peapod spit
%patch $25E0C [$0000W]
%patch $25E2A [$0000W]
Deprotect and stick to ground
Both the Peapod and Pea brain need to stick to the ground while walking and thus uses a value of 1 for this variable in their walking actions. Only the falling Pea Brain uses a value of 0.
Sprite deprotect, stick
#Pea fall
%patch $25D00 [$0000W $0000W]
#Pea walk
%patch $25D1E [$0000W $0001W]
%patch $25D3C [$0000W $0001W]
%patch $25D5A [$0000W $0001W]
%patch $25D78 [$0000W $0001W]
#Peapod walk
%patch $25D96 [$0000W $0001W]
%patch $25DB4 [$0000W $0001W]
%patch $25DD2 [$0000W $0001W]
%patch $25DF0 [$0000W $0001W]
#Peapod spit
%patch $25E0E [$0000W $0001W]
%patch $25E2C [$0000W $0001W]
Sprite spawn code
Both the Pea Brain and Pea Pod have their own initiation and spawning codes. however the pea brain is never used in the game. There is only one type of Brain and Pod; they both use the same cache. In their initiation codes their cache is set in $C7 $06 $70D2W $0001W.
The last blue highlighted value in each spawn code is the sprite action the sprite uses as it proceeds to act in-level. $C7 $07 $xxxxW sets the sprite type and $C7 $47 $0E $xxxxW is the horizontal direction the sprite starts moving in, either $0001W (Facing right), $FFFFW (Facing left) or $0000W (Neither, never used.) $C7 $47 $10 $xxxxW is the vertical direction and works similarly.
$D3 $E0 $05 $FF00W is how far up the Pea Pod is spawned from where it is placed. This is necessary for sprites that walk on the ground as they can only be placed in the level at multiples of 16 pixels high while their actual height can be anything.
Keen Dreams
#Pea initiation pointers
%patch $4A51 [$04A4W] #Pea Pod (At $4974)
%patch $4A53 [$04C5W] #Pea Brain (At $4995)
#Pea Pod initiation code
%patch $4974 $FF $36 $7052W $FF $36 $7050W $9A $08680B67RL $83 $C4 $04
$8B $1E $3E $70 $C7 $47 $02 $0000W $C7 $06 $70D2W $0001W $EB
$37
#Pea Brain initiation code
%patch $4995 $FF $36 $7052W $FF $36 $7050W $9A $08680AE9RL $83 $C4 $04
$8B $1E $3E $70 $C7 $47 $02 $0000W $C7 $06 $70D2W $0001W $EB
$16
#Pea Pod spawn code
%patch $91E7 $55 $8B $EC $33 $C0 $50 $9A $044D01C9RL $44 $44 $8B $1E $3E
$70 $C7 $07 [$0015W] $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B
$46 $08 $D3 $E0 $05 [$FF00W] $89 $47 $0C $C7 $47 $0E [$0001W] $C7
$47 $10 [$0001W] $B8 [$2320W] $50 $FF $36 $3E $70 $9A $044D1212RL
$83 $C4 $04 $5D $CB
#Pea Brain spawn code
%patch $9169 $55 $8B $EC $33 $C0 $50 $9A $044D01C9RL $44 $44 $8B $1E $3E
$70 $C7 $07 [$0016W] $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B
$46 $08 $D3 $E0 $89 $47 $0C $B8 [$22A8W] $50 $FF $36 $3E $70 $9A
$044D1212RL $83 $C4 $04 $5D $CB