Patch:Goplat (Keen 5)

From KeenWiki
Jump to navigation Jump to search

Platforms in Keen 5 are sprites that Keen can stand on and sometimes be carried places on. This page lists patches relating to a specific Platform sprite, the Goplat or path following Platform. The page 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.

The Goplats are 'path following' platforms; they move in loops and paths. Platforms that move back and forth are Horizontal-Vertical Platforms.

Patches relating to other Keen 5 platforms can be found at Patch:Platform (Keen 5). Patches relating to the Dropping Platform in other Keen games can be found at Patch:Platform (Keen 4) and Patch:Goplat (Keen 6).


Bad Spot error

This error occurs when the Goplats follow an arrow path onto a square with no arrow. Having no direction to move in the game crashes.

Goplat errors

#Red Goplat error
%patch $10845 [$1C8AW] #Text called from
%patch $31FCA "Goplat moved to a bad spot: " $00

#Purple Goplat error
%patch $10A62 [$1EF0W] #Text called from
%patch $32230 "Goplat moved to a bad spot!" $00


Ignore error, Goplats freeze

These patches circumvent the Goplat error. Instead of crashing the game the Goplats merely freeze in place. This can be useful for creating things such as a Platform that rises up out of the ground to a specific height before stopping. This is impossible to do with regular Goplats. This approach also allows easier troubleshooting of the problem as the exact platform and location responsible can be found.

Goplats freeze on error

#Red Goplats freeze when they run out of arrows
%patch $10844 $EB $0A

#Purple Goplats freeze when they run out of arrows
%patch $10A61 $EB $0A


Sprite Type

Dropping Goplats use type 6, one of the types that lets Keen stand on a sprite. Changing this may make it impossible for Keen to stand on the platforms. The Goplat uses the same value as all other platforms.

Keen 5

#Goplat sprite type
%patch $1067b $06


Sprite Actions

There are two types of Goplat; red and purple. The first kind has one single action while the second loops between two actions. Both are spawned in the first of their actions and do nothing else, making their actions quite simple.

Actions:
$1C30W #Red Goplat
$1C4EW #Purple Goplat
$1C6CW #Purple Goplat

Keen 5

#Spawn Goplats:
%patch $106B5 {$1C4EW} #Purple
%patch $106C4 {$1C30W} #Red

#Red Goplat
%patch $31F8C {$0000W}

#Purple Goplat
%patch $31FAA {$1C6CW}
%patch $31FC8 {$1C4EW}


Sprite Behavior

Each Goplat type has its own unique behavior. This is because one must animate while the other has no need to.

Behaviors:
$0F921005RL #Purple Goplat
$0F921524RL #Red Goplat

Keen 5 Goplat behaviors

#Red Goplat
%patch $31F80 $0F920DE5RL

#Purple Goplat
%patch $31F9E $0F921005RL
%patch $31FBE $0F921005RL


Behavior code

This is the complete behavior code for the Goplats. For the red Goplats the first two lines check that two variables are zero before proceeding with the rest of the code. $000CW is the Goplat's speed. The rest of the code is currently of unknown function.

Red Goplat behavior code

#Red Goplat behavior
%patch $10705 $55 $8B $EC $83 $EC $48 $56 $57 $8B $76 $06 $83 $3E {$BF85W}  [$00]
              {$74} $03 $E9 $0205W  $83 $3E {$BF83W}  [$00] {$74} $03 $E9 $01FBW  $A1
              $9BB4W  $BA [$000CW]  $F7 $EA $89 $46 $FE $8B $44 $40 $3B $46 $FE
              $76 $73 $2B $46 $FE $89 $44 $40 $8B $5C $3E $D1 $E3 $8B $BF $26
              $19 $83 {$FF} [$01] {$75} $0B $A1 $BF85W  $03 $46 $FE $A3 $BF85W  $EB
              $14 $83 {$FFFFW}  [$75] $0F $8B $46 $FE $F7 $D8 $8B $16 $BF85W  $03
              $D0 $89 $16 $BF85W  $8B $5C $3E $D1 $E3 $8B $BF $36 $19 $83 {$FF}
              [$0]1 {$75} $0F $A1 $BF83W  $03 $46 $FE $A3 $BF83W  $5F $5E $8B $E5
              $5D $CB
                      $83 {$FFFFW}  [$74] $03 $E9 $0190W  $8B $46 $FE $F7 $D8 $8B
              $16 $BF83W  $03 $D0 $89 $16 $BF83W  $5F $5E $8B $E5 $5D $CB $5F
              $5E $8B $E5 $5D $CB
                                  $8B $5C $3E $D1 $E3 $8B $BF $26 $19 $83 {$FF}
              [$01] {$75} $09 $8B $44 $40 $01 $06 $BF85W  $EB $0E $83 {$FFFFW}  [$75]
              $09 $8B $44 $40 $F7 $D8 $01 $06 $BF85W  $8B $5C $3E $D1 $E3 $8B
              $BF $36 $19 $83 {$FF} [$01] {$75} $09 $8B $44 $40 $01 $06 $BF83W  $EB
              $0E $83 {$FFFFW}  [$75] $09 $8B $44 $40 $F7 $D8 $01 $06 $BF83W  $8B
              $44 $0A $03 $06 $BF85W  $B1 $08 $D3 $E8 $89 $46 $FC $8B $44 $0C
              $03 $06 $BF83W  $D3 $E8 $89 $46 $FA $8B $5E $FA $D1 $E3 $8B $9F
              $87 $BF $D1 $EB $D1 $E3 $8E $06 $53 $9E $8B $46 $FC $D1 $E0 $03
              $D8 $26 $8B $07 $2D [$005BW]  $89 $44 $3E $83 $7C $3E [$00] {$7C} $09
              $83 $7C $3E [$08] {$7F} $03 $E9 $0080W  $16 $8D $46 $B8 [$1E50W]  $B8
              [$1C8AW]  $50 $B9 [$003CW]  $9A $000032E5RL     $16 $8D $46 $F4 $50
              $1E $B8 [$1CC6W]  $50 $B9 [$0005W]  $9A $000032E5RL     $B8 [$0010W]
              $50 $8D $46 $F4 $50 {$FF} [$74] $0A $9A $00001C6FRL     $83 $C4 $06
              $50 $8D $46 $B8 $50 $9A $00002281RL     $83 $C4 $04 $B8 [$1EEEW]
              $50 $8D $46 $B8 $50 $9A $00002281RL     $83 $C4 $04 $B8 [$0010W]
              $50 $8D $46 $F4 $50 {$FF} [$74] $0C $9A $00001C6FRL     $83 $C4 $06
              $50 $8D $46 $B8 $50 $9A $00002281RL     $83 $C4 $04 $8D $46 $B8
              $50 $9A $037D022FRL     $83 $C4 $02 $8B $44 $40 $29 $46 $FE $B8
              [$0100W]  $2B $46 $FE $89 $44 $40 $8B $5C $3E $D1 $E3 $8B $BF $26
              $19 $83 {$FF} [$01] {$75} $0B $A1 $BF85W  $03 $46 $FE $A3 $BF85W  $EB
              $0E $83 [$FFFFW]  {$75} $09 $A1 $BF85W  $2B $46 $FE $A3 $BF85W  $8B
              $5C $3E $D1 $E3 $8B $BF $36 $19 $83 {$FF} [$01] {$75} $0F $A1 $BF83W
              $03 $46 $FE $A3 $BF83W  $5F $5E $8B $E5 $5D $CB
                                                              $83 [$FFFFW]  {$75}
              $09 $A1 $BF83W  $2B $46 $FE $A3 $BF83W  $5F $5E $8B $E5 $5D $CB


Speed

The Goplat's speeds are controlled by their behavior code and cannot yet be patched. Their animation motion is not used.

Animation motion

#Info path red plat
%patch $31F7C [$0000W $0000W]

#Info path purple plat
%patch $31F9A [$0000W $0000W]
%patch $31FB8 [$0000W $0000W]


Sprite Collision

Goplats have no sprite collision. They do not interact with any sprites.


Collision values

Goplats have no collision at all. They do not interact with any sprites. (Keen being able to stand on them is part of his collision, not the Goplat's.) Giving the Goplat a collision can make them more interesting. (Destructible for instance.)

Keen 5 collision values

#Info path Red Goplat
%patch $31F84 $00000000L  #Nothing

#Info path Purple plat
%patch $31FA2 $00000000L  #Nothing
%patch $31FC0 $00000000L  #Nothing


Animations

The Goplats use one or two animations by default; a different one for each action. 'Their' caches are not however used only by them; instead it is used by all red\purple platforms. This means that changing them will affect the other red\purple platforms and cause either memory issues or an uncached sprite error. This makes editing the Goplat's animations difficult.

Keen 5 Cache

#Caches
%patch $31A44 {$01A6W} #Purple plat cache start
%patch $31A98 {$01A7W} #Cache end

%patch $31A4A {$01BEW} #Red plat cache start
%patch $31A9E {$01BEW} #Cache end

Keen 5

#Red Goplat
%patch $31F70 $01BEW $01BEW #Red plat
%patch $31F7A $0000W        #Wait

#Purple Goplat
%patch $31F8E $01A6W $01A6W #Purple plat
%patch $31F98 $0000W        #Wait
%patch $31FAC $01A7W $01A7W #Purple plat
%patch $31FB6 $0000W        #Wait


Clipping and foreground

The Goplats have a foreground variable of 0, meaning they appears behind all sprites and foreground tiles. The clipping cannot be patched by default; having no clipping allowing them to move through solid tiles.

Keen 5

#Goplat foreground variable
%patch $10685 $0000W

Keen 5

#Goplat clipping variable
%patch $106A4 $0000W


Sprite-tile interaction

The Goplat does not interact with tiles at all, it can pass right through them. Its tile interaction is simply to ensure it stays visible.

Keen 5

#Red Goplat
%patch $31F88 $090B17B5RL

#Purple Goplat
%patch $31FA6 $090B17B5RL
%patch $31FC4 $090B17B5RL


Action type

Both platforms need to be instantly responsive. The Red Goplat does not need to animate and thus uses type 2 for its action. The Purple Goplats do however and must use type 3.

Keen 5

#Red Goplat
%patch $31F74 $0002W #Stunned

#Purple Goplat
%patch $31F92 $0003W #Can fall
%patch $31FB0 $0003W #Can fall


Deprotect and stick to ground

The Goplats needs neither of these variables and so both are set to 0 in all of their actions.

Keen 5

#Red Goplat
%patch $31F76 [$0000W $0000W]

#Purple Goplat
%patch $31F94 [$0000W $0000W]
%patch $31FB2 [$0000W $0000W]


Sprite spawn code

Both Red and Purple Goplats have four types of initiation pointer. In each case all four pointers use the same initiation code. (Each set of four however uses a different initiation code from each other.) Notice that there are two different caches; one for each platform type. The cache is set in $C7 $06 $C2xxW $0001W. The Platform guide sprites have no initiation code, they are merely special cases of 'do nothing' sprites.

The initiation codes are where the platforms' directions are set. Notice that both Red and Purple platform initiation codes use the same spawning code. They do however send a different value to it (0 and 1 respectively) that let's the game change their initial action.

The spawning code is more complex. In the spawning code the third- and fourth-to-last blue highlighted value is the sprite action the Platform uses as it proceeds to act in-level. Notice that there are two actions in the code; as noted above Red and Purple platforms send a different value to the spawning code letting it 'pick' this one difference between the two platforms. Otherwise their spawning is the same.

$C7 $06 $xxxxW sets the clipping, $C7 $07 $xxxxW sets the sprite type, $C7 $20 $xxxxW sets the foreground value. 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.

$C7 $02 $xxxxW sets the sprite activity, $C7 $47 $10 $xxxxW is the vertical direction the sprite starts moving in, either $0001W (Facing down), $FFFFW (Facing up) or $0000W (Neither.) $C7 $47 $0E $xxxxW is the horizontal direction. All Goplats start the level moving downwards, but this is modified somehow.

Depending on their initial spawn value the Red or Purple Goplats will leave a certain sprite behind where they were initially spawned so there is no 'gap' in the guide loop they occupy. The start of this sprite placement is sprite $005B (Upwards guide arrow.)

The spawn code contains and is thus incompatible with a number of patches elsewhere on this page.

Keen 5 sprite spawning

%patch $F50C [$0387W] #Up Red Goplat (At $F0D7)
%patch $F50E [$0387W] #Right Red Goplat (At $F0D7)
%patch $F510 [$0387W] #Down Red Goplat  (At $F0D7)
%patch $F512 [$0387W] #Left Red Goplat  (At $F0D7)

%patch $F564 [$057DW] #Up Purple Goplat (At $F2CD)
%patch $F566 [$057DW] #Right Purple Goplat (At $F2CD)
%patch $F568 [$057DW] #Down Purple Goplat (At $F2CD)
%patch $F56A [$057DW] #Left Purple Goplat (At $F2CD)

%patch $F57A [$0657W] #Up Platform guide (At $F3A7)
%patch $F57C [$0657W] #Right Platform guide  (At $F3A7)
%patch $F57E [$0657W] #Down Platform guide  (At $F3A7)
%patch $F580 [$0657W] #Left Platform guide  (At $F3A7)
%patch $F582 [$0657W] #Up-right Platform guide  (At $F3A7)
%patch $F584 [$0657W] #Down-right Platform guide  (At $F3A7)
%patch $F586 [$0657W] #Down-left  Platform guide (At $F3A7)
%patch $F588 [$0657W] #Up-left Platform guide  (At $F3A7)

#Red Goplat
%patch $F0D7 $33 $C0 $50 $8B $46 $FA $05 $FFDCW  $50 $57 $56 $9A {$0F920D3FRL}
             $83 $C4 $08 $C7 $06 $C29DW  $0001W  $E9 $02B3W

#Purple Goplat
%patch $F2CD $B8 [$0001W]  $50 $8B $46 $FA $05 $B0 $FF $50 $57 $56 $9A {$0F920D3FRL}
                     $83 $C4 $08 $C7 $06 $C297W  $0001W  $E9 $00BCW

#Goplat spawning code
%patch $1065F $55 $8B $EC $56 $57 $8B $76 $06 $8B $7E $08 $33 $C0 $50 $9A
           $06B91DCDRL    $83 $C4 $02 $8B $1E $40 $9E $C7 $07 [$0006W]  $C7 $47
              $02 [$0002W]  $C7 $47 $20 [$0000W]  $8B $C6 $B1 $08 $D3 $E0 $89 $47
              $0A $8B $C7 $D3 $E0 $89 $47 $0C $C7 $47 $0E [$0000W]  $C7 $47 $10
              [$0001W]  $C7 $47 $06 [$0000W]  $83 $7E $0C $00 $74 $17 $83 $47 $0A
              $40 $83 $47 $0C $40 $B8 [$1C4EW]  $50 $53 $9A $090B11C4RL    $83
              $C4 $04 $EB $10 $B8 [$1C30W]  $50 $FF $36 $40 $9E $9A $090B11C4RL
                  $83 $C4 $04 $8B $46 $0A $05 [$005BW]  $8B $DF $D1 $E3 $8B $9F
              $87 $BF $D1 $EB $D1 $E3 $8E $06 $53 $9E $8B $D6 $D1 $E2 $03 $DA
              $26 $89 $07 $8B $1E $40 $9E $8B $46 $0A $89 $47 $3E $C7 $47 $40
              [$0100W]  $5F $5E $5D $CB