Patch:Tomatooth

From KeenWiki
Jump to navigation Jump to search

Tomatooth, also known as 'Killer Tomatoes' are red, rotund creatures that are found in many levels in Tuberia in Keen Dreams. They will chase Keen bouncing along the ground. This makes them difficult to hit.


Sprite Type

Tomatooth use type 6 which has no impact on any other sprites save for making them transform into Wilted Flowers properly.

Keen Dreams

#Tomatooth sprite type
%patch $826D $06


Sprite Actions

The Tomatooth has a simple set of actions. It is spawned in the first frame of its bouncing cycle and continues bouncing indefinitely.

Actions:
$1B46W #Tomatooth 1
$1B64W #Tomatooth 2

Keen Dreams

#Place Tomatooth in level
%patch $828A [$1B46W]

#Bouncing cycle
%patch $255D2 [$1B64W]
%patch $255F0 [$1B46W]


Sprite Behavior

The Tomatooth has its own behavior that does not seem to be used by any other sprites. It causes the Tomatooth to chase Keen and also fall under gravity.

Keen Dreams

#Tomatooth bouncing
%patch $255C6 $07C5064BRL
%patch $255E4 $07C5064BRL


Seeking Keen

The Tomatooth always seeks Keen when it is bouncing. Reversing the values in the patch below will make it flee Keen.

Keen seeking

#Seek Keen when bouncing
%patch $82B8 $0001W
%patch $82B3 $FFFFW


Complete behavior code

This is the complete behavior code for the Tomatooth bouncing. On the first line the Tomatooth's horizontal speed (Both left and right) is set. On the second line the Tomatooth's direction is set depending on whether it is left or right of the player. On line 3 the Tomatooth's horizontal speed is checked and its direction set to match. (This resets its direction after it has hit a wall.)

At the end of line 4 the Tomatooth's Misc 1 variable is checked and a complicated bit of code performed which relates to the Tomatooth's horizontal movement. On the last line gravity is called to make the Tomatooth fall.

Keen Dreams

#Tomatooth bouncing code
%patch $829B $55 $8B $EC $56 $8B $76 $06 $B8 [$0010W]  $50 $8B $44 $0A $8B $1E
             $34 $70 $3B $47 $0A $76 $05 $B8 [$FFFFW]  $EB $03 $B8 [$0001W]  $50
             $56 $0E $E8 $FA0CW  $83 $C4 $06 $83 $7C {$16} [$00] {$7E} $07 $C7 $44
             $0E [$0001W]  $EB $05 $C7 $44 $0E [$FFFFW]  $83 $7C {$3E} [$00] {$74} $2F
             $8B $44 {$3E} $3B $06 [$BDD4W]  {$73} $10 $8B $44 {$18} $F7 $6C {$3E} $89
             $44 {$14} $C7 $44 {$3E} [$0000W]  $EB $1D $8B $44 {$18} $F7 $2E [$BDD4W]
             $89 $44 {$14} $8B $44 {$3E} $2B $06 [$BDD4W]  $89 $44 {$3E} $EB $07 $56
             $0E $E8 $F943W  $44 $44 $5E $5D $CB


Speed and Jump Height

The Tomatooth does not have any animation motion. Its speed is controlled by its behavior and tile collision. Its horizontal speed is controlled by its behavior and it $10. Its falling speed uses standard game gravity. Jump height is controlled by tile collision in an unknown manner.

Tomatooth speeds

#Tomatooth horizontal speed
%patch $82A3 [$0010W]

Animation motion

#Tomatooth speed
%patch $255C2 [$0000W $0000W]
%patch $255E0 [$0000W $0000W])


Sprite collision

Like nearly all sprites in Keen Dreams the Tomatooth does not have a sprite collision. Instead Keen and his shots react to them and their sprite types.

Keen Dreams

#Tomatooth bounce
%patch $255CA $00000000L
%patch $255E8 $00000000L


Animations

Tomatooth have only two animations.

Keen Dreams

#Cache
%patch $23E7A $0101W #Tomatooth cache start
%patch $23EA6 $0104W #Tomatooth cache end

#Tomatooth
%patch $255B6 $0101W $0103W
%patch $255C0 $0014W        #Animation speed
%patch $255D4 $0102W $0104W
%patch $255DE $0014W        #Animation speed


Sprite positioning

The Tomatooth spawns 8 pixels higher then where it is placed in-level. This does not need to be changed with its sprite height, it may simply be there for cosmetic reasons (So Tomatooth are touching the ground and thus bounce as soon as they are spawned).

Keen Dreams

#Tomatooth spawn height
%patch $827F [$FF80W] #8 pixels upwards


Sounds

The Tomatooth has two sounds, one for hitting floors and one for hitting ceilings. Both can be blocked.

Keen Dreams

#Tomatooth sounds
%patch $8362 $11     #Tomatooth hit floor sound
%patch $839F $11     #Tomatooth hit roof sound

#Don't play sounds
%patch $8361 $EB $09 #Don't play Tomatooth hit floor sound
%patch $839E $EB $09 #Don't play Tomatooth hit roof sound


Sprite-tile interaction

The Cart has its own tile interaction that does not appear to be used by any other sprite. This makes it turn when it hits walls and bounce off floors and ceilings while making a noise.

Keen Dreams

#Tomatooth bouncing
%patch $255CE $07C506C4RL
%patch $255EC $07C506C4RL


Tile interaction code

This appears to be the Tomatooth tile interaction. The two blue values are the Tomatooth bounce sounds.

Keen Dreams

#Tomatooth tile collision
%patch $8314 $55 $8B $EC $56 $8B $76 $06 $83 $7C $38 $00 $75 $06 $83 $7C $3C
             $00 $74 $10 $8B $44 $0E $F7 $D8 $89 $44 $0E $8B $44 $16 $F7 $D8
             $89 $44 $16 $83 $7C $3A $00 $74 $37 $8B $44 $30 $3B $06 $9C $BD
             $72 $26 $8B $44 $2C $3B $06 $30 $70 $77 $1D $8B $44 $2E $3B $06
             $9E $BD $72 $14 $8B $44 $32 $3B $06 $32 $70 $77 $0B $B8 [$0011W] 
             $50 $9A $10BB1282RL     $44 $44 $8B $44 $18 $F7 $D8 $89 $44 $18
             $83 $7C $36 $00 $74 $45 $8B $44 $30 $3B $06 $9C $BD $72 $26 $8B
             $44 $2C $3B $06 $30 $70 $77 $1D $8B $44 $2E $3B $06 $9E $BD $72
             $14 $8B $44 $32 $3B $06 $32 $70 $77 $0B $B8 [$0011W]  $50 $9A
         $10BB1282RL     $44 $44 $9A $16C40026RL     $B1 $04 $D3 $F8 $BA $E2
             $FF $2B $D0 $89 $54 $18 $C7 $44 $3E $0A $00 $33 $C0 $50 $50 $FF
             $74 $20 $FF $74 $0C $FF $74 $0A $8B $C6 $05 $46 $00 $50 $9A
         $0E450DC5RL     $83 $C4 $0C $5E $5D $CB


Action type

As they need to move smoothly through the air, react quickly and animate, Tomatooth actions are type 3.

Sprite action types

#Tomatooth bouncing
%patch $255BA [$0003W]
%patch $255D8 [$0003W]


Deprotect and stick to ground

The Tomatooth has no need for either of these variables and so has a value of 0 for both in both of its actions.

Sprite deprotect, stick

#Tomatooth bouncing
%patch $255BC [$0000W $0000W]
%patch $255DA [$0000W $0000W]


Sprite spawn code

There is only one type of Tomatooth; in its initiation code its cache is set in $C7 $06 $70BEW $0001W

The last blue highlighted value 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 $FF80W is how far up the Tomatooth 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. Why the Tomatooth uses it is unknown.

Keen Dreams

#Tomatooth initiation pointer
%patch $4A2F [$0354W] #Tomatooth (At $4824)

#Tomatooth initiation code
%patch $4824 $FF $36 $7052W  $FF $36 $7050W  {$9A $07C5060ARL}     $83 $C4 $04
             $8B $1E $3E $70 $C7 $47 $02 $0000W  $C7 $06 $70BEW  $0001W  $E9
             $0186W

#Tomatooth spawn code
%patch $825A $55 $8B $EC $33 $C0 $50 $9A $044D01C9RL     $44 $44 $8B $1E $3E
             $70 $C7 $07 [$0006W]  $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B
             $46 $08 $D3 $E0 $05 [$FF80W]  $89 $47 $0C $C7 $47 $0E [$0001W] $B8
             [$1B46W]  $50 $FF $36 $3E $70 $9A $044D1212RL     $83 $C4 $04 $5D
             $CB