Patch:Garg

Gargs are dangerous, green enemies found in Keen 1. This page lists patches relating to Garg 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

Gargs use sprite type 3 which means they kill Keen on contact.

 Patch: Keen 1 #Garg sprite type: %patch $184E$03

Sprite Behavior

There are three behaviors associated with the Garg, the walking behavior (Walk back and forth, also charge and jump.) and the searching behavior (Look for Keen, if he's on the Garg's level, charge in Keen's direction.) the third behavior is the Garg collision. Gargs are spawned looking for Keen. The difference between walking and charging is simply speed, which is set during searching.

Behaviors:
$1B51W #Garg look for Keen, charge$1AA8W #Garg walk
$1BCEW #Garg collision  Patch: When spawned %patch$1871 $1B51W  Patch: In level %patch$1AD0 $1B51W #Look for Keen after charging into walls, randomly during walking %patch$1BCA $1AA8W #Walk or charge after looking for Keen. %patch$1876 $1BCEW #Garg collision Walking\charging behavior code This is the complete code for the Garg's walking\charging behavior. On the first line the game checks the Garg's vertical speed; if this is not zero (If the Garg is falling) the next two lines are skipped. Next it checks the Garg's horizontal speed; if it finds the Garg is charging left or right (two different checks, one for each direction.) at or faster than its charging speed then it also skips the next two lines. These lines, 2 and 3, thus are only run if the Garg is walking on a flat surface. They call the random number generator to see if the Garg should stop walking and search for Keen. This sets its behavior to 'search' ($1B51W]) and its vertical direction to 0.

Following this on lines 4 and 5 the game checks the Garg's horizontal speed to decide which animation the Garg should show, walking right or walking left. Line 6 calls gravity and tile collision with $E8$1126W and $E8$1166W respectively. Replacing the first with $90$90 $90 will cause Gargs to float while walking; replacing the second will cause them to 'ghost' through tiles (and fall out of the level). The remaining lines deal with interacting with various tile obstacles. Line 7 checks for right walls, making the Garg walk left if detected. Line 8 deals with left walls, making the Garg walk right if detected. The end of line 8 also checks for floors; if on is found the Garg's vertical direction is set to 0 and the rest of the code skipped. If a floor is not found, that is the Garg is standing on nothing, the game checks the Garg's horizontal speed to see whether it is charging. If so it proceeds to check its vertical direction to see if it is already jumping or falling. Only if it is standing on nothing, while charging and not already falling does the game proceed to set the Garg's vertical direction to 1 and give it a jump height. The cumulative result of all of this is to make the charging Garg jump at platform edges.  Patch: Garg Walking code %patch$1AA8 $55$8B $EC$56 $83$3E $8242W$00 $75$25 $81$3E $8240W$FF24W $7E$1D $81$3E $8240W$00DCW $7D$15 $E8$A608W $3B$06 $5B14W$73 $0C$C7 $06$8252W $1B51W$C7 $06$824AW $0000W$83 $3E$8240W $00$7E $08$C7 $06$8248W $0040W$EB $06$C7 $06$8248W $0042W$A1 $5135W$B1 $04$D3 $E8$25 $0001W$8B $16$8248W $03$D0 $89$16 $8248W$E8 $1126W$E8 $1166W$8B $F0$A9 $0004W$74 $06$C7 $06$8240W $FFC4W$F7 $C6$0001W $74$06 $C7$06 $8240W$003CW $F7$C6 $0002W$74 $08$C7 $06$824AW $0000W$EB $20$A1 $8240W$99 $33$C2 $2B$C2 $3D$00DCW $75$13 $83$3E $824AW$00 $75$0C $C7$06 $824AW$0001W $C7$06 $8242W$FF38W $5E$5D $C3 Searching behavior code This is the complete code for the Garg's searching behavior. First the Garg's speed is set to 0. On the first two lines the Garg's animations are set; start animation$3C, plus $03 other frames at an animation speed of$05. The third line calls gravity and tile collision with $E8$10B3W and $E8$10F3W respectively. Replacing the first with $90$90 $90 will cause Gargs to float while searching; replacing the second will cause them to 'ghost' through tiles. The third line also contains the Garg's search time,$50 ticks. Until this time is up all the remaining code is skipped. On line 4 the Garg takes its height and subtracts Keen's height. If a difference of $0800W (Which is equivalent to 8 pixels.) is found then the Garg will charge. If Keen is shorter than the Garg then the$C2 on the line must be changed to $EA Two checks are made on line 5. If both are passed the Garg's speed is set to$DC (Right or left.), if not, it is set to $3C (Again, right or left.) This makes the Garg either chase or walk after Keen. (Also note this means Gargs will walk in Keen's direction even if he is not right in front of them.) Two unknown checks are made in the last two lines and the Garg's behavior set to 'walk\charge'.  Patch: Garg searching code #Garg searching code %patch$1B51 $55$8B $EC$C7 $06$40 $82$0000W $A1$5135W $B1$05 $D3$E8 $25$0003W $05$003CW $A3$8248W $A1$824AW $03$06 $14$5B $A3$824AW $E8$10B3W $E8$10F3W $83$3E $824AW$50 $7C$4B $A1$822AW $8B$16 $8228W$81 $C2$0800W $15$0000W $3B$06 $E4$6E $75$0E $3B$16 $E2$6E $75$08 $C7$06 $8240W$00DCW $EB$06 $C7$06 $8240W$003CW $A1$8226W $8B$16 $8224W$3B $06$E0 $6E$7C $10$7F $06$3B $16$DE $6E$76 $08$A1 $8240W$F7 $D8$A3 $8240W$C7 $06$8252W $1AA8W$5D $C3 Searching and charging behavior These patches relate to the Gargs searching and charging behavior, whether they search and what they do after searching. Gargs still charge when Keen\Garg height changes The Garg\Keen height check is how the Gargs determine if Keen is level with them and thus able to be charged at. If either the Garg or Keen's height changes, they will be unable to charge normally. These patches is used to address the imbalance. There are two patches, only ONE is needed. Here$xx is the difference in height between Keen's sprite and the Garg's sprite in pixels.

 Patch: Make sure that the Garg still charges when Keen/Garg height changes #If Keen is shorter or the Garg is taller: %patch $1B8B$xx #If the Garg is shorter or Keen is taller: %patch $1B8B$xx %patch $1B89$EA

Stand still until Keen is seen

With these two patches, the Gargs will not move at all until Keen is level with them, after which they will charge, either towards or away from him depending on patch. This is useful for making a 'sleeping' enemy that wakes when Keen is near. The two patches are obviously not compatible.

 Patch: Keen 1 #Gargs don't move until they see Keen, then they charge %patch $1BA6$00

 Patch: Keen 1 #Gargs stand still until they see Keen, then they run away %patch $1BA3$90 $90$90 $90$90 $90$90 $90$90 $90$90 $90$90 $90$90 $90$90 $90$90 $90$90 $90$90 $90$90 $90$90 $90$90 $90$90 $90$90 $90$90

Always search

With this patch Gargs spend all their time searching and thus will tend to attack Keen as soon as they see him.

 Patch: Keen 1 #Gargs always look around %patch $1AC9$5C

Searching Gargs keep moving

With this patch the Garg's speed is not set to 0 when searching, this means they slip and slide when searching This is useful since patching the searching speed only one direction is possible by default.

Speed and Jump Height

The default speed of Gargs is +-60 when walking and +-220 when charging. When spawned Gargs will stand still (looking for Keen) by default. They will charge towards Keen after searching for him and finding him otherwise they will walk in a random direction. There is only one speed set for walking\charging that can be in two directions. Likewise there are two jumps heights; one when the Garg is shot and one when it jumps at the edge of a platform while charging. They do not have to match.

When Gargs hit walls at any speed they will change direction and move at walking speed.

Gargs check their speed several times The first two check to see whether the Garg is charging left or right, if it is then the Garg won't search for Keen. (Since it already knows where he is.) The third check is whether the Garg is charging left or right when at the edge of a platform; only if it is will the Garg jump.

Misc

These patches don't fit into the above sections easily.

Garg flies like a Skypest

This is the complete patch code for making the Garg fly like a Skypest. On the first line the Garg's Misc Variable A is checked, if it is not zero two lines are skipped. Else Misc Variable B is checked; if this is not zero as well a line is skipped to a big jump over a large part of the code. If both variables are zero something odd happens to them and the game jumps back to before both checks. This serves in sum to send the game to either line 3 or line 11 in an organized fashion.

Line 3 checks Misc Variable A, again checking if it is zero and incrementing if it is not, returning to the start of the code. This is followed by a check of Misc Variable B's high byte (An odd thing to do.), if this is zero the game skips to line 11.

After this a number of variables are checked. These relate to Keen's position in the level and act to make the Garg 'chase' Keen by changing direction. In sequence this involves checking the variable $6EE4, if it is less than the Garg's then code alters Misc Variable D's high byte to -1 then skips two lines. If it is greater then the variable's high byte is set to 0 then a jump. This means that if it is exactly the same$6EE2W is checked, if it's less than the Garg, MVD's high byte is set to -1, else it's set to 0. On line 8 $6EE0W is checked in an identical fashion, changing MVD's low byte instead of the high. Both of these serve to set MVD as two 0\-1 bytes. On line 11 Misc Variable B is decremented and MVA checked. If it is not zero two lines are skipped. These lines check the Garg's Y and X speed, if either is zero MVD's high or low byte is altered. On line 13 MVD itself is checked and used to set the Garg's horizontal speed (Either$FFBAW or $0046W). On line 14 the same is done with MVD's high byte to set the vertical speeds. The remaining code sets the animation, based on$003CW. It is a two frame ($0001W + 1) animation that has 4 or 2 added to it depending on whether the Garg is chasing Keen or which direction it is moving. This produces an array of 4 possible animations. The very last line calls the 'collide with tiles' code.  Patch: Garg can fly like Skypest #Garg can fly like Skypest %patch$1871 $1AA8W %patch$1AA8 $55$89 $E5$56 $80$3E $8246W$00 $75$1A $80$3E $824CW$00 #Misc checks 1 $75$10 $F6$16 $8246W$C6 $06$824CW $46$C6 $06$824DW $00$EB $E2$E9 $007AW$80 $3E$824CW $00$75 $0B$F6 $16$8246W #Misc checks 2 $C6$06 $824CW$6E $EB$CD $80$3E $824DW$00 $75$5D $C6$06 $824DW$04 $A1$6EE4W $39$44 $0A$7D $07$C6 $06$8251W $FF #Check$6EE4W $EB$1D $74$07 $C6$06 $8251W$00 $EB$14 $A1$6EE2W $39$44 $08$73 $07$C6 $06$8251W $FF$EB $05$C6 $06$8251W $00$A1 $6EE0W$39 $44$06 $7D$07 $C6$06 $8250W$FF $EB$1D $74$07 #Check $6EE0W$C6 $06$8250W $00$EB $14$A1 $6EDEW$39 $44$04 $73$07 $C6$06 $8250W$FF $EB$05 $C6$06 $8250W$00 $FE$0E $824DW$FE $0E$824CW $80$3E $8246W$00 $75$18 $81$3E $8242W$0000W #Check Y\X speed $75$04 $F6$16 $8251W$81 $3E$8240W $0000W$75 $04$F6 $16$8250W $80$3E $8251W$00 $75$08 $C7$06 $8242W$FFBAW $EB #Set h speeds$06 $C7$06 $8242W$0046W $80$3E $8250W$00 $75$08 $C7$06 $8240W$FF6AW $EB$06 $C7$06 $8240W$0096W $BB$003CW $80 #Set v speeds$3E $8250W$00 $74$03 $80$C3 $02$80 $3E$8246W $00$74 $03$80 $C3$04 $A1$5135W $B1$04 $D3$E8 $25$0001W $01$D8 $A3$8248W $E8$10B0W $5E$5D $C3 Shot Garg stuns like a Yorp This patch makes it so that shot Gargs recover after being stunned; like the Yorps when they are stomped, after a time they will recover, search for Keen and act as if nothing had happened. While stunned using this patch they animate their shot sprites. Stunned Gargs are still deadly. The first part of this patch changes what the Garg becomes when it is shot, using its new stunned behavior. The section part is optional, if included then stunned Gargs can be shot again, 'restunning' and resetting their 'stun timer'. If it is removed Gargs will not respond to further shots; though they will still block Keen's shots. The third part of the patch is more complex. The first line contains three variables, the first is the animation speed, the second the number of animation frames minus 1 (That is, 2 by default.) and the third is the start animation frame for the stunned Garg. (Here the first shot frame.) The second line has a blue variable that is the Garg's stunned time, when this much time has passed, the Garg will return to normal. The two brown variables on the third line are the recovered Garg's collision and behavior, making the Garg shootable when it recovers and also changing it's behavior to look for Keen (instead of staying stunned.) The two brown$E8 $xxxxWs on the fourth line are gravity and tile check, replacing the first with$90 $90$90 makes the stunned Garg not fall and hit the ground, replacing the second makes it ghost through tiles.

The third part of the patch makes sure that neither Yorps nor Gargs pause when offscreen when stunned. Each line in it checks for the stunned behavior, and if it is found, changes the sprite to either searching Yorp or searching Garg. (Gargs also have their collision reset so they can be shot again.)

This patch may be incompatible with patches that use the $0AA2 offset, though it is designed to work with the Keen ammo limit patch. (With unique sound and without.) Check your patchfile if conflicts occur.  Patch: Keen 1 #Stunned Garg is deadly static stunned-Yorp-like sprite %patch$1BF5 $0B10W #Shot Garg becomes stunned Garg #Include this to make stunned Gargs 'restunnable' %patch$1BF7 $EB$03 #Stun behavior %patch $0B10$55 $8B$EC $A1$35 $51$B1 $04$D3 $E8$25 $0001W$05 $0044W #Garg animation$A3 $48$82 $A1$4A $82$03 $06$14 $5B$A3 $4A$82 $3D$0320W #Garg stun time $7C$0C $C7$06 $54$82 $1BCEW$C7 $06$52 $82$1B51W $C7$06 #Return to Garg search behavior and collision $40$82 $0000W$E8 $20E3W$E8 $2123W$5D $C3 #Stunned Gargs don't freeze when offscreen %patch$4D98 $E9$BDB1W %patch $0B4C$81 $3E$52 $82$1A2CW $75$08 $C7$06 $52$82 $19D3W$EB $14 #Stunned Yorps$81 $3E$52 $82$0B10W $75$12 $C7$06 $54$82 $1BCEW$C7 $06 #Stunned Gargs$52 $82$1B51W $C7$06 $4A$82 $0000W$E9 \$4233W