Patch:Keen (Keen Dreams)
This page contains patches relating to Keen as a sprite in Keen Dreams. That is, such things as the sprites used, the speeds and sounds. It does not cover patches relating to gameplay such as those that make levels scroll or change keys. Those can be found at Patch:Gameplay (Keen Dreams). It is divided into sections relating to the various sprite properties the patches involved. Being fluent with various sprite patch pages will help when working with these patches.
As little is known about Keen, there is less information here than for most sprites.
Keen behaviors with their own pages
The following pages have been created for specific Keen actions that have a significant number of patches, necessitating them being kept separate for clarity:
- Patch:Keen bored
- Patch:Keen dying (Dreams)
- Patch:Keen on map (Dreams)
- Patch:Keen shooting (Dreams)
- Patch:Keen's shot (Dreams)
- Patch:Keen walking (Dreams)
Sprite Type
Keen's type is 1. This has no effect on any sprites at all; things in Keen Dreams happen when Keen reacts to stuff.
Keen Dreams
#Keen's sprite type
%patch $6B88 [$01]
Sprite Actions
Keen's actions are complex and only poorly understood at this time.
Actions: $0ED8W #Keen stand
Keen Dreams
#When spawned
%patch $6BB5 [$0ED8W]
Sprite collision
Keen's sprite collision, along with that of the Flower Power, is responsible for the bulk of sprite interactions. Nearly all enemy sprites have no sprite collision and instead it is the player's response to them which matters. As such the player's sprite collision is exceedingly complex. This collision is used by Keen in nearly all of his actions.
Collision code
The first segment of the sprite collision is the 'hub'; this is what decides what is done next. First a value of 3 is subtracted from the sprite's infoplane value; this skips over both normal Keens and the map Keen. (The infoplane value is the value of the sprite's 'tile' in the level. For example $0001W is Keen right and $0003W is the Horseradish Hill map entrance.) On the start of line 2 all sprites with an remaining value of 15 or less are excluded, they do not interact with Keen because they are level entrances.
In the middle of line 3 is another limit, $0B. Any sprite with an infoplane value higher than $15 + $0B (By default $20 or past the Items.) will have its sprite collision determined by its sprite type instead of its infoplane value. The two lists used for this are highlighted in brown. Of spacial note is that items have their sprite type set to $19 on first collision. This means they will only use the item collision once which is important since otherwise they would interact multiple times. (So a key could give a key 10 times in a row before vanishing say.)
What code the player runs is determined by a list whose location is marked in brown in the hub patch. (Its absolute location is this value plus the segment value of $5E80.) The sprite list is placed after all of the other code but is included with the hub here for simplicity.
The points collision code has four variables. The first is the sound played when points are got, $07. The second is the start of the points got animations $C7 or 199. The third is the start of the points given list at $23A70 + $16AA by default. Finally there is the 'got points' action $198AW which is what points become.
The 1UP code is similar to the points code except there is no need for the points got list location, only the sound, sprite and action values. The code also adds 1 to $7126W or the life variable.
The Eye code is more complex. It too plays sound $12 and sets the new sprite animation on its first line. On the second line it adds 3 to the life counter and 8 to the Flower Power counter as well as 20'000 points. On the third line it sets the eye got action.
The Flower Power got code is similar to the 1Up code. It plays sound $06 and sets the new animation on the first line, adds 1 to the Flower Power counter and sets the new sprite action on the second line. The Flower Pot code is nearly identical except that it adds 5 to the Flower Power counter.
The Boobus Bomb code is again very similar, playing sound 8 but adding to two counters, the Flower Power and temporary Boobus Bomb variables. (This is so that should Keen die in the level he will loose all of the bombs he obtained. Only after winning the level do the bombs become 'permanent'.) Likewise the key code which plays sound $17 and adds 1 to the key variable.
The door code is rather complex. On the first line the game checks to see if Keen has any keys, if not it skips the next three lines. If Keen does have keys then the game checks to see if the Door is already opening (Action $1750.), if so the entire code is skipped to avoid 'double opening' a door. The second line is the door opening code, sound $13 is played and the key counter decreased by 1. The door's action is changed to opening on line 3. Lines 4-5 are the 'door blocking' code; sound $0E is played and Keen's movement blocked.
The Tater Trooper code checks to see if the Trooper's single deadly action is in use. If so then Keen will be killed, otherwise the code is skipped.
The Carrot code pushes Keen. First it checks Keen's clipping, if he has none (such as when he is on a pole.) the code is skipped. Else sound $19 is played, Keen's clipping is set to 1, Keen's action set to his third jumping frame ($1568W), and his draw variable is set to 1. Some other game variable is set to 0.
The Cart's code is quite simple; it calls the push code with value 1. The result of this is it will push Keen unless Keen is against a wall in which case he'll die. This is separate from and different to the Carrot\Squasher push codes.
The Broccolash code checks to see if either of the Broccolash's two deadly actions are in use. If so the code jumps to the 'deadly' sprite code, otherwise it skips everything and nothing happens.
The Squasher code checks to see if the Squasher's single deadly action is in use. If so then it jumps to the deadly code. Otherwise it runs 'push Keen' code. This is nearly identical to the Carrot Courier's pushing code discussed above.
The Grape's code checks to see if its single deadly action is i use. If so then it jumps to the deadly code, otherwise it skips everything and nothing happens.
The deadly sprite code simply runs the 'kill Keen' code. It is jumped to by a few other sprites as well as being used directly.
Keen Dreams
#Keen's sprite collision hub
%patch $767C $55 $8B $EC $56 $57 $8B $7E $06 $8B $76 $08 $8B $1C $83 $EB [$03]
$83 $FB [$15] {$76} $03 $E9 $025EW $D1 $E3 $2E $FF $A7 {$1A8EW} $C7
$04 [$0019W] $8B $5C $3E $83 $FB [$0B] $76 $03 $E9 $0248W $D1 $E3
$2E $FF $A7 {$1A76W}
#Point sprites code
%patch $76B1 $B8 [$0007W] $50 $9A $10BB1282RL $44 $44 $8B $44 $3E $05 [$00C7W]
$89 $44 $20 $8B $5C $3E $D1 $E3 $FF $B7 {$16AAW} $9A $044D090ERL
$44 $44 $B8 [$198AW] $50 $56 $9A $07C50255RL $83 $C4
$04 $E9 $020DW
#1UP code
%patch $76E5 $B8 [$0012W] $50 $9A $10BB1282RL $44 $44 $C7 $44 $20 [$00CDW]
$FF $06 {$7126W} $B8 [$198AW] $50 $56 $9A $07C50255RL $83 $C4
$04 $E9 $01E9W
#Eye code
%patch $7709 $B8 [$0012W] $50 $9A $10BB1282RL $44 $44 $C7 $44 $20 [$00CEW]
$83 $06 {$7126W} [$03] $83 $06 {$711CW} [$08] $B8 [$2710W] $50 $9A
$044D090ERL $44 $44 $B8 [$198AW] $50 $56 $9A $07C50255RL $83
$C4 $04 $E9 $01B4W
#Flower Power code
%patch $773E $B8 [$0006W] $50 $9A $10BB1282RL $44 $44 $C7 $44 $20 [$00CFW]
$FF $06 {$711CW} $B8 [$198AW] $50 $56 $9A $07C50255RL $83 $C4
$04 $E9 $0190W
#Flower Pot code
%patch $7762 $B8 [$0006W] $50 $9A $10BB1282RL $44 $44 $C7 $44 $20 [$00D0W]
$83 $06 {$711CW} [$05] $B8 [$198AW] $50 $56 $9A $07C50255RL $83
$C4 $04 $E9 $016BW
#Boobus Bombs code
%patch $7787 $B8 [$0008W] $50 $9A $10BB1282RL $44 $44 $C7 $44 $20 [$00D1W]
$FF $06 {$711CW} $FF $06 {$7120W} $B8 [$198AW] $50 $56 $9A $07C50255RL
$83 $C4 $04 $E9 $0143W
#Key code
%patch $77AF $B8 [$0017W] $50 $9A $10BB1282RL $44 $44 $C7 $44 $20 [$00D2W]
$FF $06 {$7122W} $B8 [$198AW] $50 $56 $9A $07C50255RL $83 $C4
$04 $E9 $011FW
#Door code
%patch $77D3 $83 $3E {$7122W} [$00] {$74} $29 $81 $7C $1E [$1750W] {$75} $03 $E9 $010EW
$B8 [$0013W] $50 $9A $10BB1282RL $44 $44 $FF $0E {$7122W}
$B8 [$1750W] $50 $56 $9A $07C50255RL $83 $C4 $04 $E9 $00EFW
$B8 [$000EW] $50 $9A $10BB1282RL $44 $44 $56 $57 $9A
$044D0DFERL $83 $C4 $04 $E9 $00D7W
#Tater Trooper
%patch $781B $81 $7C {$1E} [$1D9EW] {$74} $03 $E9 $00CDW $0E $E8 $FE27W $E9 $00C6W
#Carrot code
%patch $782C $56 $57 $9A $044D0DFERL $83 $C4 $04 $83 $7D {$06} [$00] {$74} $03
$E9 $00B3W $B8 [$0019W] $50 $9A $10BB1282RL $44 $44 $C7 $45
$06 [$0001W] $33 $C0 $89 $45 $18 $89 $45 $16 $B8 [$1568W] $50 $57
$9A $07C50255RL $83 $C4 $04 $C7 $45 $40 [$0001W] $C7 $06 {$8EE4W}
[$0000W] $E9 $0080W
#Cantaloupe cart code
%patch $7872 $B8 $0001W $50 $56 $57 $9A $044D0E91RL $83 $C4 $06 $EB $70
#Broccolash code
%patch $7882 $81 $7C $1E [$1A74W] {$74} $07 $81 $7C $1E [$1A92W] {$75} $62 $0E $E8
$FDBCW $EB $5C
#Squasher code
%patch $7896 $81 $7C $1E [$2122W] {$75} $02 $EB $4F $56 $57 $9A $044D0DFERL
$83 $C4 $04 $83 $7D {$06} [$00] {$75} $43 $B8 [$0019W] $50 $9A $10BB1282RL
$44 $44 $C7 $45 $06 [$0001W] $33 $C0 $89 $45 $18 $89 $45
$16 $B8 [$1568W] $50 $57 $9A $07C50255RL $83 $C4 $04 $C7 $45
$40 [$0001W] $C7 $06 {$8EE4W} [$0000W] $EB $11
#Grape code
%patch $78E1 $81 $7C $1E [$1CAEW] {$75} $0A $0E $E8 $FD64W $EB $04
#Deadly sprites code
%patch $78EE $0E $E8 $FD5EW $5F $5E $5D $CB
#Keen's item collision list
%patch $78F6 [$1831W] #100 pts (At $76B1)
%patch $78F8 [$1831W] #200 pts (At $76B1)
%patch $78FA [$1831W] #500 pts (At $76B1)
%patch $78FC [$1831W] #1000 pts (At $76B1)
%patch $78FE [$1831W] #2000 pts (At $76B1)
%patch $7900 [$1831W] #5000 pts (At $76B1)
%patch $7902 [$1865W] #1UP (At $76E5)
%patch $7904 [$1889W] #Eye (At $7709)
%patch $7906 [$18BEW] #Flower Power (At $773E)
%patch $7908 [$18E2W] #Flower Pot (At $7762)
%patch $790A [$1907W] #Boobus Bomb (At $7787)
%patch $790C [$192FW] #Key (At $77AF)
#Keen's sprite collision list
%patch $790E [$1953W] #Door (At $77D3)
%patch $7910 [$181BW] #Item type (At $769B)
%patch $7912 [$1A02W] #Broccolash (At $7882)
%patch $7914 [$1A6EW] #Tomatooth (Deadly -At $78EE)
%patch $7916 [$19ACW] #Carrot (At $782C)
%patch $7918 [$1A6EW] #Unused (Deadly -At $78EE)
%patch $791A [$1A6EW] #Asparagusto (Deadly -At $78EE)
%patch $791C [$1A61W] #Grape (At $78E1)
%patch $791E [$199BW] #Tater Trooper (At $781B)
%patch $7920 [$19F2W] #Mine Cart (At $7872)
%patch $7922 [$1A72W] #Frenchy (Nothing -At $78F2)
%patch $7924 [$1A72W] #Melon (Nothing -At $78F2)
%patch $7926 [$1A6EW] #Unused (Deadly -At $78EE)
%patch $7928 [$1A6EW] #Unused (Deadly -At $78EE)
%patch $792A [$1A6EW] #Unused (Deadly -At $78EE)
%patch $792C [$1A6EW] #Unused (Deadly -At $78EE)
%patch $792E [$1A16W] #Squasher (At $7896)
%patch $7930 [$1A6EW] #Apel (At $78EE)
%patch $7932 [$1A72W] #Pea Pod (At $78F2)
%patch $7934 [$1A6EW] #Pea Brain (At $78EE)
%patch $7936 [$1A6EW] #Boobus Tuber (Deadly -At $78EE)
%patch $7938 [$1A6EW] #Enemy shots (Deadly -At $78EE)
Animations
Keen has two caches, one for his map sprites and one for his in-level sprites. These caches cover not only the player, but also things like collectable items, the door and Patch:Wilted Flowers that Keen will (nearly) always encounter in any level. There are a large number of animation cycles for the player and only the player-related cycles are shown here.
Map Keen
#Map cache
%patch $23E76 $00D5W #Map Keen cache start
%patch $23EA2 $00F0W #Map Keen cache end
#Map Keen wait to wave, etc
%patch $247AA $0000W $0000W
%patch $247B4 $0168W #Animation speed
#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
%patch $248B8 $0000W $0000W
%patch $248C2 $0004W #Animation speed
Level Keen
#Level cache
%patch $23E74 $0048W #Keen cache start
%patch $23EA0 $00D4W #Keen cache end
#Keen's ZZZZZ
%patch $248EE $0078W $0078W
%patch $248F8 $001EW #Animation speed
%patch $2490C $0079W $0079W
%patch $24916 $001EW #Animation speed
%patch $2492A $007AW $007AW
%patch $24934 $001EW #Animation speed
#Keen stand
%patch $24948 $0050W $0048W
%patch $24952 $0004W #Animation speed
#Keen look up bored
%patch $24966 $005FW $0058W
%patch $24970 $003CW #Animation speed
#Keen yawn
%patch $24984 $0066W $0066W
%patch $2498E $0028W #Animation speed
%patch $249A2 $0067W $0067W
%patch $249AC $0028W #Animation speed
%patch $249C0 $0068W $0068W
%patch $249CA $0028W #Animation speed
%patch $249DE $0069W $0069W
%patch $249E8 $0028W #Animation speed
#Keen stand-blink-shrug
%patch $249FC $0061W $005AW
%patch $24A06 $005AW #Animation speed
%patch $24A1A $0060W $0059W
%patch $24A24 $000AW #Animation speed
%patch $24A38 $0061W $005AW
%patch $24A42 $005AW #Animation speed
%patch $24A56 $0060W $0059W
%patch $24A60 $000AW #Animation speed
%patch $24A74 $0061W $005AW
%patch $24A7E $005AW #Animation speed
%patch $24A92 $0062W $005BW
%patch $24A9C $0046W #Animation speed
#Keen go to nap
%patch $24AB0 $0071W $0071W
%patch $24ABA $0014W #Animation speed
%patch $24ACE $0072W $0072W
%patch $24AD8 $0014W #Animation speed
%patch $24AEC $0073W $0073W
%patch $24AF6 $0078W #Animation speed
%patch $24B0A $0074W $0074W
%patch $24B14 $0078W #Animation speed
#Keen wake up
%patch $24B28 $00A1W $009CW
%patch $24B32 $000FW #Animation speed
#Keen die
%patch $24B46 $0087W $0087W
%patch $24B50 $0014W #Animation speed
%patch $24B64 $0088W $0088W
%patch $24B6E $0014W #Animation speed
%patch $24B82 $0089W $0089W
%patch $24B8C $0078W #Animation speed
#Keen look up
%patch $24BA0 $005FW $0058W
%patch $24BAA $0000W #Animation speed
#Keen crouch
%patch $24BBE $006BW $006AW
%patch $24BC8 $0000W #Animation speed
%patch $24BDC $006BW $006AW
%patch $24BE6 $0000W #Animation speed
#Keen on pole
%patch $24BFA $0091W $008AW
%patch $24C04 $0000W #Animation speed
#Keen climb up pole
%patch $24C18 $0091W $008AW
%patch $24C22 $0008W #Animation speed
%patch $24C36 $0092W $008BW
%patch $24C40 $0008W #Animation speed
%patch $24C54 $0093W $008CW
%patch $24C5E $0008W #Animation speed
%patch $24C72 $008DW $008DW
%patch $24C7C $0008W #Animation speed
#Keen climb down pole
%patch $24C90 $008EW $008EW
%patch $24C9A $0008W #Animation speed
%patch $24CAE $008FW $008FW
%patch $24CB8 $0008W #Animation speed
%patch $24CCC $0090W $0090W
%patch $24CD6 $0008W #Animation speed
#Keen polethrow left\right
%patch $24CEA $0094W $0096W
%patch $24CF4 $0008W #Animation speed
%patch $24D08 $0095W $0097W
%patch $24D12 $0001W #Animation speed
%patch $24D26 $0095W $0097W
%patch $24D30 $000AW #Animation speed
#Keen polethrow up
%patch $24D44 $0098W $009DW
%patch $24D4E $0008W #Animation speed
%patch $24D62 $0099W $009EW
%patch $24D6C $0001W #Animation speed
%patch $24D80 $0099W $009EW
%patch $24D8A $000AW #Animation speed
#Keen polethrow down
%patch $24D9E $009FW $009AW
%patch $24DA8 $0008W #Animation speed
%patch $24DBC $00A0W $009BW
%patch $24DC6 $0001W #Animation speed
%patch $24DDA $00A0W $009BW
%patch $24DE4 $000AW #Animation speed
#Keen walk
%patch $24DF8 $0051W $0049W
%patch $24E02 $0006W #Animation speed
%patch $24E16 $0052W $004AW
%patch $24E20 $0006W #Animation speed
%patch $24E34 $0053W $004BW
%patch $24E3E $0006W #Animation speed
%patch $24E52 $0054W $004CW
%patch $24E5C $0006W #Animation speed
#Keen throw left\right
%patch $24E70 $006CW $0075W
%patch $24E7A $0004W #Animation speed
%patch $24E8E $006DW $0076W
%patch $24E98 $0004W #Animation speed
%patch $24EAC $006EW $0077W
%patch $24EB6 $0001W #Animation speed
%patch $24ECA $006EW $0077W
%patch $24ED4 $000AW #Animation speed
#Keen throw up
%patch $24EE8 $006FW $006FW
%patch $24EF2 $0008W #Animation speed
%patch $24F06 $0070W $0070W
%patch $24F10 $0001W #Animation speed
%patch $24F24 $0070W $0070W
%patch $24F2E $000AW #Animation speed
#Keen fall
%patch $24F42 $0064W $005DW
%patch $24F4C $0000W #Animation speed
%patch $24F60 $0065W $005EW
%patch $24F6A $0000W #Animation speed
%patch $24F7E $0064W $005DW
%patch $24F88 $0000W #Animation speed
#Keen jump
%patch $24F9C $0055W $004DW
%patch $24FA6 $0000W #Animation speed
%patch $24FBA $0056W $004EW
%patch $24FC4 $0000W #Animation speed
%patch $24FD8 $0057W $004FW
%patch $24FE2 $0000W #Animation speed
#Keen jumpthrow left\right
%patch $24FF6 $007BW $0081W
%patch $25000 $0008W #Animation speed
%patch $25014 $007CW $0082W
%patch $2501E $0001W #Animation speed
%patch $25032 $007CW $0082W
%patch $2503C $000AW #Animation speed
#Keen jumpthrow up
%patch $25050 $007DW $0083W
%patch $2505A $0008W #Animation speed
%patch $2506E $007EW $0084W
%patch $25078 $0001W #Animation speed
%patch $2508C $007EW $0084W
%patch $25096 $000AW #Animation speed
#Keen jumpthrow down
%patch $250AA $007FW $0085W
%patch $250B4 $0008W #Animation speed
%patch $250C8 $0080W $0086W
%patch $250D2 $0001W #Animation speed
%patch $250E6 $0080W $0086W
%patch $250F0 $000AW #Animation speed
Sprite spawn code
There are two initiation codes, one for Keen facing left and one for Keen facing right. Both are nearly identical except for Keen's starting direction. Both use the same spawning code. There is no cache, Keen's sprites are automatically cached in every level.
In the 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 clipping, $C7 $07 $xxxxW sets the sprite type. Finally $D3 $E0 $05 $xxxx is how far down (Or more usually up) the sprite 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's horizontal direction depends on his initiation code. (It is the first blue variable.) He always starts the level 'facing down' however, though this is of little importance. $C7 $47 $10 $xxxxW is the vertical direction the sprite starts moving in, either $0001W (Facing down), $FFFFW (Facing up) or $0000W (Neither, never used.) Keen's sprite type is important, if it is not $0002W then he will be invulnerable to enemy sprites since this sprite type is used to identify 'killable players'
Keen Dreams
#Location of initiation codes
%patch $49DD [$02A6W] #Keen right (At $4776)
%patch $49DF [$02BDW] #Keen left (At $478D)
#Right Keen initiation code
%patch $4776 $B8 [$0001W] $50 $FF $36 $7052W $FF $36 $7050W $9A $05E80CFFRL #Direction +1
$83 $C4 $06 $E9 $023FW
#Left Keen initiation code
%patch $478D $B8 [$FFFFW] $50 $FF $36 $7052W $FF $36 $7050W $9A $05E80CFFRL #Direction -1
$83 $C4 $06 $E9 $0228W
#Normal Keen spawning code
%patch $6B7F $55 $8B $EC $8B $1E $34 $70 $C7 $07 [$0001W] $C7 $47 $02 [$0001W]
$C7 $47 $06 [$0001W] $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B
$46 $08 $D3 $E0 $05 [$FF00W] $89 $47 $0C $8B $46 $0A $89 $47 $0E
$C7 $47 $10 [$0001W] $B8 [$0ED8W] $50 $FF $36 $34 $70 $9A $044D1212RL
$83 $C4 $04 $5D $CB
Keen's spawn height and changing Keen's height
This simple patch alters how high Keen spawns above where he is placed in a level. By default this is 17 pixels up,suitable for a Keen sprite 33 pixels high. If Keen's height is changed, this should be changed to reflect that. It is part of the above spawning code patch and shouldn't be used in conjunction with it.
Keen Dreams
#Keen's spawn height
%patch $6BA4 [$FF00W] #17 pixels up