Patch:Meep

From KeenWiki
Jump to navigation Jump to search

Meeps are dangerous, green enemies found in Keen 3. This page lists patches relating to Meep 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.


Sprite Type

Meeps use sprite type 5 which means they push Keen around. They do not otherwise interact with other sprites. The Meep's shot has its own sprite type which kills Keen but otherwise does not interact with anything.

Keen 3

#Meep sprite type:
%patch $3D51 $05

#Meep's shot type:
%patch $4880 $11


Sprite Behavior

There are two behaviors associated with the Meep, the first is to walk back and forth and maybe fall, the second to shoot. The Meep's shot has its own behavior. The Meep will shoot randomly, or when falling. This makes it undesirable to place a Meep where it might fall. After shooting it returns to walking. The Meep's shot has no collision, nothing stops it.

Behaviors:
$4746W #Meep walk
$47D3W #Meep shoot
$48D2W #Meep's shot
$4898W #Meep collision

When spawned

%patch $3D7A {$4746W}

In level

%patch $4791 {$47D3W} #Shoot randomly when walking
%patch $47B6 {$47D3W} #Shoot when falling
%patch $4893 {$4746W} #After shooting, return to walking

%patch $4877 {$48D2W} #Meep's shot behavior

%patch $3D7F {$4898W} #Meep collision


Complete Meep walking code

This is the complete Meep walking code. On the first and second lines the sprite's animations, animation speed and animation frames are set, in that order (Marked in blue.) On the fifth line is the randomly activated action (Shooting in this case.) followed by calls to the gravity and tile collision functions, $E8 $xxxxW. Replacing the first with $90 $90 $90 will make the Meep never fall and the second will make it pass through tiles like a ghost. (All three marked in brown.)

After this the Meep checks to see if it's moved onto empty air; if so it shoots, again marked in brown. After that it checks to see if it has hit a right or left wall, changing its speed to turn around if it has done so. (Both speeds marked in blue.)

Meep walking code

#Meep walking code
%patch $4746 $55 $8B $EC $56 $83 $3E $30 $99 $00 $7E $08 $C7 $06 $38 $99 [$0076W]
                 $EB $06 $C7 $06 $38 $99 [$0078W]  $A1 $61 $53 $B1 [$04] $D3 $E8
             $25 [$0001W]  $8B $16 $38 $99 $03 $D0 $89 $16 $38 $99 $E8 $83CEW
             $3B $06 $40 $5D $73 $17 $A1 $30 $99 $A3 $3E $99 $33 $C0 $A3 $30
             $99 $A3 $3C $99 $A3 $3A $99 $C7 $06 $42 $99 {$47D3W}  {$E8 $1B1EW}
             {$E8 $1B5EW}  $8B $F0 $F7 $C6 $02 $00 $75 $17 $A1 $30 $99 $A3 $3E
             $99 $33 $C0 $A3 $30 $99 $A3 $3C $99 $A3 $3A $99 $C7 $06 $42 $99
             {$47D3W}  $F7 $C6 $04 $00 $74 $06 $C7 $06 $30 $99 [$FFBFW]  $F7 $C6
             $01 $00 $74 $06 $C7 $06 $30 $99 [$0041W]  $5E $5D $C3


Meep walks off edges, doesn't shoot while doing so

By default the Meep will enter an odd shooting-falling situation when it walks off an edge, shooting repeatedly while sitting in the air. This patch fixes this, making the Meep fall normally without shooting. (Though it may air-shoot if the fall is a long one.) The two blue values are its fall left\right speeds. To make the Meep fall straight down, simply set both of these to $0000W.

Meep walks off edges, doesn't shoot

#Meep just walks off platform edges
%patch $47A1 $83 $3E $30 $99 $00 $7E $08 $C7 $06 $30 $99 [$0041W] $EB $06 $C7
             $06 $30 $99 [$FFBFW]  $90 $90


Meep moves back and forth in air

This patch makes the Meep act like a moving platform, turning only at walls it will move back and forth in the air, shooting randomly. This works the same as the above patch, but disables the sprite gravity check.

Meep walks off edges, doesn't shoot

#Make the Meep a moving platform
%patch $47A1 $83 $3E $30 $99 $00 $7E $08 $C7 $06 $30 $99 [$0041W] $EB $06 $C7
             $06 $30 $99 [$FFBFW]  $90 $90
%patch $4793 $90 $90 $90


Complete Meep shooting code

The Meep's shooting code also contains bullet spawning code, making it quite complex. In the first and second line, marked in blue, are the animations used for the Meep facing left and right when shooting. (It does not animate while shooting.)

On line 4 the shooting sound is played and the bullet created. after this there are two types of shot to create, left or right, depending on what direction the Meep is facing. The three brown bytes at the end of line 5 check the Meep's direction.

On line 6 the animation of the left bullet is set, and on line 7 its speed. (Both marked in blue.) The code then jumps past the right bullet code.

On line 8 the right moving bullet's horizontal position is set (It spawns 16 pixels in front of the Meep, see section below.) and on line 9 its speed and animation. Everything after line 9 applies to both bullets, left and right moving.

On line 10 the vertical position of bullets is set (4 pixels down from the Meep's head.) and on line 11 their collision and behavior (48D2W, or Meep's shot behavior, with a collision of 'do nothing') as well as their sprite type (Type $11, deadly to Keen.) Finally line 13 returns the Meep to walking after it has shot.

Meep shooting code

#Meep shooting code
%patch $47D3 $55 $8B $EC $56 $83 $3E $3E $99 $00 $7D $08 $C7 $06 $38 $99 [$007BW]
                 $EB $06 $C7 $06 $38 $99 [$007AW]  $A1 $3A $99 $03 $06 $40 $5D
             $A3 $3A $99 $83 $3E $3A $99 $3C $7D $03 $E9 $0095W  $83 $3E $3C
             $99 $00 $75 $7B $C7 $06 $3C $99 $0001W  $B8 $002BW  $50 $E8 $8155W
                 $59 $E8 $17A5W  $8B $F0 $83 $3E $3E $99 {$00 $7D $1D} $A1 $16
             $99 $8B $16 $14 $99 $89 $54 $04 $89 $44 $06 $B8 [$0080W]  $89 $44
             $2A $89 $44 $28 $C7 $44 $20 [$FF38W]  $EB $22 $A1 $16 $99 $8B $16
             $14 $99 $81 $C2 $00 [$10] $15 [$0000W]  $89 $54 $04 $89 $44 $06 $C7
             $44 $20 [$00C8W]  $B8 [$007EW]  $89 $44 $2A $89 $44 $28 $A1 $1A $99
             $8B $16 $18 $99 $81 $C2 $00 [$04] $15 [$0000W]  $89 $54 $08 $89 $44
             $0A $C7 $44 $32 {$48D2W}  $C7 $44 $34 {$6A00W}  $C7 $04 [$0011W]  $83
             $3E $3A $99 $50 $7E $0C $A1 $3E $99 $A3 $30 $99 $C7 $06 $42 $99
             {$4746W}  $5E $5D $C3


Speed and Jump Height

The default speed of Meeps is +-65 when walking. Their shots move at +-200 Meeps head towards Keen when spawned.

Starting speeds

%patch $3DA4 [$0041W]     #Initial right speed (If left of Keen)
%patch $3D9D [$FFBFW]     #Initial left speed (If right of Keen)

In level

%patch $47CE [$0041W]     #When hits left walls (Move right)
%patch $47C2 [$FFBFW]     #When hits right walls (Move left)

%patch $4855 [$00C8W]     #Bullet right speed
%patch $483A [$FF38W]     #Bullet left speed


Sprite Collision

Meeps interact with Keen's shots. This produces a shot Meep. (See behavior section.) The shot Meep also resets its collision and behavior, the new collision, used for most dead sprites ignores all other sprites, the new behavior likewise is just 'fall an animate' The Meep takes one shot to kill by default, but this can be changed.

The Meep's shot has a collision also; 'nothing', meaning it cannot be destroyed by any sprites.


Basic patches

These are the basic things involved in the Meep's collision. Their function is simple to discern.

Keen 3

%patch $3D7F {$4898W}   #Meep collision
%patch $48A3 $3F [$0F]  #Meep killed by Keen's shot
%patch $3D84 [$0001W]   #Meep strength

%patch $48CD ($7EC0W) #Dead Meep behavior
%patch $48C8 ($6A00W) #Dead Meep collision

%patch $487C ($6A00W) #Meep's shot's collision


Complete collision code

This is the complete Meep collision code. It contains the above collision patches and is thus incompatible with them. On the first line the Meep checks for keen's shot, and if it finds one, if proceeds with the rest of the collision. There is an unknown check in line 2, as well as the Meeps' death sound.

On the third line the Meep's aniamtion counter is set to 0 (For the death behavior.) and its number of death frames and death start animation are set. Finally on the last line its behavior and collision are set so that it dies.

Complete Meep collision code

#Complete Meep collision code
%patch $4898 $55 $8B $EC $56 $8B $76 $04 $8B $5E $06 $83 $3F [$0F] {$75} $28 $FF
             $4C $24 $74 $02 $EB $21 $B8 [$0027W]  $50 $E8 $B4 $80 $59 $C7 $44
             $2A [$0000W]  $C7 $44 $2C [$0002W]  $C7 $44 $28 [$007CW]  $C7 $44 $34
             {$6A00W}  $C7 $44 $32 {$7EC0W}  $5E $5D $C3


Kill Meep, win level

This patch will cause the level to be completed when the Meep is shot.

Keen 3

%patch $48C9 $90 #Keen wins the level


Kill Meep, lose level

This patch will cause Keen to return to the map when a Meep is shot, he will have to start the level over.

Keen 3

%patch $48D1 $EB #Keen is kicked out of the level


Animations

The number of frames used by the bullet cannot yet be patched. It is two.

When spawned

%patch $3DA9 [$0078W] #Start

In level

%patch $4755 [$0076W] #Walking right
%patch $475D [$0078W] #Walking left
%patch $4767 $01    #And next frame

%patch $47EA [$007AW] #Shooting left
%patch $47E2 [$007BW] #Shooting right

%patch $48C3 [$007CW] #Shot
%patch $48BE $02    #Frames used

%patch $482F [$0080W] #Left bullet
%patch $4858 [$007EW] #Right bullet
%patch $48DF $01    #Frames used by both -1


Meep's spawn height and shooting height

Meeps spawn 8 pixels lower than where he is placed, because they are not quite two tiles tall. If the Meep's sprite height is changed this should also be changed by the same amount. The shooting height is similar and may also need to be changed if the Meep's height changes. In this case the top of the shot appears four pixels lower than the top of the Meep.

Keen 3

#Meep's spawn height
%patch $3D6C [$0800W] #Eight pixels down

#Meep's shooting height
%patch $4869 [$0400W] #Four pixels down


Sounds

There are two sounds produced by the Meep; one for shooting and one for when it itself is shot. After the sound aptches are two patches, each of which will disable a single sound. These patches are independent.

Keen 3

#Meep sounds
%patch $480E $2B     #Meep shooting
%patch $48AF $27     #Meep shot sound

#Disable Meep sounds
%patch $480D $EB $06 #Meep shooting sound disabled
%patch $48AE $EB $06 #Meep shot sound disabled


Shooting

These patches don't fit into the above categories. Some of them may have unintended side effects. They all relate tot he Meep shooting and its shots.


Shot spawn position

This controls the position at which the Meep's shots are spawned. It is divided into two values, the first in a 'fine-tuner', the number of pixels down from the Meep sprite's top the bullet appears. The second value is much rougher and is worth 256 pixels when +-1 It is really only useful when making the shot appear a negative number of pixels below (That is above) the sprite, when it will be changed to $FFFFW. There are two sections, the horizontal and vertical components. Values used here are the default. (In this case 16 pixels in front of the Meep and 4 pixels down.)

Note that only the right bullet has its horizontal position set; the left moving bullet looks fine spawning at 0,4 (the left side of the Meep) but the right moving bullet needs to appear on the Meep's right side.

Meep shot position

%patch $4848    [$10] #Horizontal (Right bullets only!)
%patch $484A [$0000W]
%patch $486A    [$04] #Vertical
%patch $486C [$0000W]


Meep produces four shots at once

This patch makes the Meep shoot not one, but four blasts at once each time it shoots.

Keen 3

#Meep produces four shots at once
%patch $480B $00


Stop Meep producing shots when shooting

These patches stop the Meep producing shots while still allowing it to pause and make a shooting noise. (It is possible to disable shooting entirely by setting the 'walk' behavior in place of the 'shoot' behavior See above.) The advantage of using these patches is the Meep still uses the shooting animations, etc. Each of these patches is independent and the first two are equivalent to the third.

Keen 3

#Meep doesn't shoot left
%patch $4821 $EB $36

#Meep doesn't shoot right
%patch $483E $EB $20

#Meep doesn't shoot either direction
%patch $481F $EB $38


Do things when Meep shoots

These patches do various things when the Meep shoots. They may be slightly unstable and have unforeseen side effects. each line is a separate and independent patch.

Keen 3

#When Meep shoots...
%patch $4878 $90 #Keen wins the level
%patch $487D $90 #Keen wins the level... 5 seconds later
%patch $4878 $0A #Keen is kicked out of the level
%patch $4878 $02 #Keen is kicked out AND loses a life


Misc shooting patches

These patches are unstable and may have unforeseen consequences.

Keen 3

#Meep shoots all the time
%patch $477A $75

#Meep turns right every time it shoots left.
%patch $4889 $90

#Meep right bullet appears from left side of screen, no matter where Meep is.
%patch $484E $00