Patch:Items

From KeenWiki
(Redirected from Patch:Item tiles)
Jump to: navigation, search

This page contains patches relating to the items in Keen games. These are patches that relate to items as a general class of sprites and\or tiles. Many specific items have their own pages, listed in the first section of this page. Patches that involve Keen getting items are Patch:B A T Cheat, Patch:C T Space Cheat, Patch:Cheat codes, Patch:F10 I Cheat, Patch:Game start, Patch:Score and Patch:Scorebox.

In all Keen games points are a tile based system; when Keen touches the item tile he is given something. In the Keen Galaxy (And Dreams) games, items are also sprite and based objects the player can touch to get points added to their score. Point and other items mostly work on a 'list' system; there are certain properties that all sprites share while others are read off a list. As an example the red gem is the first item in the Keen Galaxy games, therefore it uses the first animation in the animation list, the first points value in the points list and so on.

This page is divided into four sections. The first section lists items that have their own pages for various reasons. The second lists 'list properties', properties such as the amount of points given that differ for each item and are controlled by a list. The third section, for Keen Galaxy and Dreams only, lists properties common to all item sprites, such as their behavior. The final section lists miscellaneous patches and currently does not exist.


Items with their own pages

The following pages exist for individual items that are (mostly) not covered here. While some patches on this page may affect these items (Such as the patch for how many points the neural stunner gives when obtained.) in general patches pertaining to them are located elsewhere.


Changing what items give ammo, lives and gems

The complete code for what items give is held on two different types of pages. Patch:Tiles holds item code that deals with item tiles being obtained, while the sprite collision sections of Patch:Keen (Keen 4), Patch:Keen (Keen 5), Patch:Keen (Keen 6), and Patch:Keen (Keen Dreams) contain code relating to item sprites being obtained.

Such code contains most of the patches on this page as well as additional patches affecting which items give ammo, lives and gems. They are kept on their own pages due to their close relationship with tiles and sprites.


Item replacement tile

When tile-based items are obtained their tile is replaced with a tile taken from a reference in the data segment. By default this is tile 0, making the item appear to vanish. This does not have to be the case however and any other tile can be used. (If it is not already present in the level and thus cached however it will leave behind gibberish.)

The tile is used in several distinct situations, notably when item and '100 to get 1UP' tiles are contacted.

Patch: Keen 4
#Item tile calls
%patch $CF8C $1424W
#Items got
%patch $D054 $1424W
#Raindrops got
%patch $11D87 $1424W
#Items got by Smirky
#Items and lifewater replacement tile
%patch $30294 $0000W

Patch: Keen 6
#Item tile calls
%patch $C086 $129CW
#Items got
%patch $C14E $129CW
#Viva got
#Items and Viva replacement tile
%patch $31FCC $0000W


List properties

This section lists patches that alter things that are unique for any individual item, such as the number of points it gives or the animation it uses. For Keen Vorticons this is almost entirely limited to the number of points given to Keen when an item is obtained. Keen galaxy and dreams however have more extensive list properties.

Notice that list properties in Keen Galaxy affect 'non-point' items, such as keygems which can therefore be made to give points as well. The lists are always the same length, defined in the player's sprite or tile collision, but the list locations vary making it possible to have a wider variety of items.

There are three situations when lists are called. The first is when obtaining item tiles, the second while obtaining tile sprites. The third also deals with obtaining sprites but only when Keen is swimming. (In Keen 4 only.)


Points Items give

These patches change the values of the point items, that is, how many points Keen gets when he grabs them. The lists following use the default values and for simplicity are presented as a single patch. Each line affects a different point value. For Keen 1–3, there are five different point types, for Keen 3.5 and 4–6, all collectibles can be given a point value.

What point items increase involves Patch:Game stats, while the 'point item list' patch is a text style patch. Related patches can be found on the Patch:Extra Keen At page.

Patch: Keen 1 Item scores
#Change point item scores
%patch $15076 $01F4W
#500
$0064W
#100
$00C8W
#200
$03E8W
#1000
$1388W
#5000
#What point items add to:
%patch $0D5B $AACAW
#Score high
%patch $0D5F $AACCW
#Score low

Patch: Keen 2 Item scores
#Change point item scores
%patch $19FC2 $01F4W
#500
$0064W
#100
$00C8W
#200
$03E8W
#1000
$1388W
#5000

Patch: Keen 3 Item scores
#Point list read from:
%patch $5A15 $2852W
#Change point item scores
%patch $1C083 $01F4W
#500
$0064W
#100
$00C8W
#200
$03E8W
#1000
$1388W
#5000

Patch: Keen Dreams Item scores
#Location of point list
%patch $76CC $16AAW
#Change point item scores
%patch $2511A $0064W
#100
$00C8W
#200
$01F4W
#500
$03E8W
#1000
$07D0W
#2000
$1388W
#5000

Patch: Keen 4 Item scores
#Location of point list
%patch $CD34 $13F4W
#Item sprites
%patch $CFAD $13F4W
#Item tiles
%patch $F9AD $13F4W
#Item sprites (Swimming)
#Change point item scores
%patch $30264 $0000W
#Red gem
$0000W
#Yellow gem
$0000W
#Blue gem
$0000W
#Green gem
$0064W
#100
$00C8W
#200
$01F4W
#500
$03E8W
#1000
$07D0W
#2000
$1388W
#5000
$0000W
#100 #1UP
$0000W
#Raygun

Patch: Keen 5 Item scores
#Change point item scores
%patch $31614 $0000W
#Red gem
$0000W
#Yellow gem
$0000W
#Blue gem
$0000W
#Green gem
$0064W
#100
$00C8W
#200
$01F4W
#500
$03E8W
#1000
$07D0W
#2000
$1388W
#5000
$0000W
#100 #1UP
$0000W
#Raygun
$0000W
#100 1UP
$0000W
#V card

Patch: Keen 6 Item scores
#Points calls
%patch $BECF $126CW
#Item sprites
%patch $C0A7 $126CW
#Item tiles
#Change point item scores
%patch $31F9C $0000W
#Red gem
$0000W
#Yellow gem
$0000W
#Blue gem
$0000W
#Green gem
$0064W
#100
$00C8W
#200
$01F4W
#500
$03E8W
#1000
$07D0W
#2000
$1388W
#5000
$0000W
#100 #1UP
$0000W
#Raygun


Item animations

In Keen galaxy and Dreams each sprite has a unique animation as well as a unique 'item got' animation. In Dreams however the 'item got' animation is not a list property and is defined elsewhere.

Note that in Keen Dreams more is involved, 'item got' animations are set individually in Keen's collision and some items can have differing numbers of animations. See the relevant section for details.

Patch: Keen Dreams
#Location of item animation list
%patch $813F $19A8W
#Sprites used for each item:
%patch $25418 $00ACW
#100
$00AEW
#200
$00B0W
#500
$00B2W
#1000
$00B4W
#2000
$00B6W
#5000
$00B8W
#1UP
$00BAW
#Eye
$00A2W
#Flower Power
$00BEW
#Flower Pot
$00C0W
#Boobus Bomb
$00C5W
#Key

Patch: Keen 4
#Location of 'item got' animation list
%patch $CD28 $140CW
#Item sprites
%patch $D019 $140CW
#Item tiles
%patch $F9A1 $140CW
#Item sprites (Swimming)
#Sprites used for each item:
%patch $3027C $00FAW
#Red gem got
$00FAW
#Yellow gem got
$00FAW
#Blue gem got
$00FAW
#Green gem got
$00DBW
#100 got
$00DCW
#200 got
$00DDW
#500 got
$00DEW
#1000 got
$00DFW
#2000 got
$00E0W
#5000 got
$00E1W
#1UP got
$00E2W
#Raygun got
%patch $30E10 $00F2W
#Red gem
$00F4W
#Yellow gem
$00F6W
#Blue gem
$00F8W
#Green gem
$00E3W
#100
$00E5W
#200
$00E7W
#500
$00E9W
#1000
$00EBW
#2000
$00EDW
#5000
$00EFW
#1UP
$00FBW
#Raygun

Patch: Keen 5
#Items list
%patch $FDE3 $1A54W
#Item sprites
#Location of 'item got' animation list
%patch $C0D3 $12EEW
#Item sprites
%patch $C32C $12EEW
#Item tiles
#Sprites used for each item:
%patch $3162E $00E8W
#Red gem got
$00E8W
#Yellow gem got
$00E8W
#Blue gem got
$00E8W
#Green gem got
$0C03W
#100 got
$00C4W
#200 got
$00C5W
#500 got
$00C6W
#1000 got
$00C7W
#2000 got
$00C8W
#5000 got
$00C9W
#1UP got
$00CAW
#Raygun got
$00D1W
#V card got
%patch $31D94 $00E0W
#Red gem
$00E2W
#Yellow gem
$00E4W
#Blue gem
$00E6W
#Green gem
$00D2W
#100
$00D4W
#200
$00D6W
#500
$00D8W
#1000
$00DAW
#2000
$00DCW
#5000
$00DEW
#1UP
$00E9W
#Ammo
$00CFW
#V card

Patch: Keen 6
#Location of item animation list
%patch $F424 $1A78W
#Items
%patch $10C7E $1A78W
#Blooglet spawned items
#Location of items got animation list
%patch $BEC3 $1286W
#Item sprites
%patch $C113 $1286W
#Item tiles
#Sprites used for each item:
%patch $31FB4 $00ACW
#Red gem got
%patch $31FB6 $00ACW
#Yellow gem got
%patch $31FB8 $00ACW
#Blue gem got
%patch $31FBA $00ACW
#Green gem got
%patch $31FBC $008AW
#Soda got
%patch $31FBE $008BW
#Iceblock got
%patch $31FC0 $008CW
#Sundae got
%patch $31FC2 $008DW
#Cola got
%patch $31FC4 $008EW
#Split got
%patch $31FC6 $008FW
#Pizza got
%patch $31FC8 $0090W
#Viva Queen got
%patch $31FCA $0091W
#Raygun got
%patch $327A8 $00A4W
#Red gem
%patch $327AA $00A6W
#Yellow gem
%patch $327AC $00A8W
#Blue gem
%patch $327AE $00AAW
#Green gem
%patch $327B0 $0096W
#Soda
%patch $327B2 $0098W
#Iceblock
%patch $327B4 $009AW
#Sundae
%patch $327B6 $009CW
#Cola
%patch $327B8 $009EW
#Split
%patch $327BA $00A0W
#Pizza
%patch $327BC $00A2W
#Viva Queen
%patch $327BE $00ADW
#Raygun


Sounds items make when got

Items also make different sounds when acquired. In Keen Vorticons the sounds are pretty limited and tile-based. In Keen Galaxy and Dreams by contrast the sounds are a list property. In Keen Dreams a mixed approach is taken; most items use sprite-based coded sounds. They are included here for completeness.


Patch: Keen Dreams
#Sounds items make when got:
%patch $76B2 $07
#Get points sound
%patch $76E6 $12
#1Up got sound
%patch $770A $12
#Eye got sound
%patch $773F $06
#Flower Power got sound
%patch $7763 $06
#Flower Pot got sound
%patch $7788 $08
#Boobus Bombs got sound
%patch $77B0 $17
#Key got sound

Patch: Keen 4
#Location of sound list
%patch $CD0E $13DCW
#Item sprites
%patch $CF9D $13DCW
#Item tiles
%patch $F987 $13DCW
#Item sprites (Swimming)
#Sounds items make when got:
%patch $3024C $0013W
#Red gem
%patch $3024E $0013W
#Yellow gem
%patch $30250 $0013W
#Blue gem
%patch $30252 $0013W
#Green gem
%patch $30254 $0008W
#100 item
%patch $30256 $0008W
#200 item
%patch $30258 $0008W
#500 item
%patch $3025A $0008W
#1000 item
%patch $3025C $0008W
#2000 item
%patch $3025E $0008W
#5000 item
%patch $30260 $0011W
#1UP bottle
%patch $30262 $0009W
#Raygun

Patch: Keen 5
#Sounds items make when got:
%patch $315FA $0013W
#Red gem
%patch $315FC $0013W
#Yellow gem
%patch $315FE $0013W
#Blue gem
%patch $31600 $0013W
#Green gem
%patch $31602 $0008W
#100
%patch $31604 $0008W
#200
%patch $31606 $0008W
#500
%patch $31608 $0008W
#1000
%patch $3160A $0008W
#2000
%patch $3160C $0008W
#5000
%patch $3160E $0011W
#100 1UP
%patch $31610 $0009W
#Raygun
%patch $31612 $0037W
#V card

Patch: Keen 6
#Sounds items make when got:
%patch $31F84 $0013W
#Red gem
%patch $31F86 $0013W
#Yellow gem
%patch $31F88 $0013W
#Blue gem
%patch $31F8A $0013W
#Green gem
%patch $31F8C $0008W
#100
%patch $31F8E $0008W
#200
%patch $31F90 $0008W
#500
%patch $31F92 $0008W
#1000
%patch $31F94 $0008W
#2000
%patch $31F96 $0008W
#5000
%patch $31F98 $0011W
#100 1UP
%patch $31F9A $0009W
#Raygun


Don't play item sounds

These patches stop all item sprites or tiles (or both) sound being played. This means that all items of all types will be silent when obtained. As a list property there is no way to block individual item sounds. (Except giving them a very quiet sound.)

In Keen Dreams however individual sounds can be blocked without affecting others.

Patch: Keen Dreams
%patch $76B1 $EB $09 
#Don't play Get points sound
%patch $76E5 $EB $09
#Don't play 1Up got sound
%patch $7709 $EB $09
#Don't play Eye got sound
%patch $773E $EB $09
#Don't play Flower Power got sound
%patch $7762 $EB $09
#Don't play Flower Pot got sound
%patch $7787 $EB $09
#Don't play Boobus Bombs got sound
%patch $77AF $EB $09
#Don't play Key got sound

Patch: Keen 5
#Don't play item sounds
%patch $C0BB $EB $03
#Don't play item sprites got sounds
%patch $C2B2 $EB $03
#Don't play item tiles got sounds

Patch: Keen 6
#Don't play item sounds
%patch $BEAB $EB $03
#Don't play item sprites got sounds
%patch $C099 $EB $03
#Don't play item tiles got sounds


Amount of shots given by Neural Stunners

This changes the amount of shots a raygun gives Keen on easy, medium and hard. This is controlled by a list which is called several times potentially allowing the creation of several kinds of ammunition. See also Patch:Neural stunner.

Patch: Keen 4
#Call ammo list
%patch $CD69 $13D4W
#Ammo sprites got
%patch $CFDE $13D4W
#Ammo tiles got
%patch $F9E2 $13D4W
#Keen swimming related?
#Ammo stunners give Keen
%patch $30246 $0008W
#Easy
$0005W
#Medium
$0005W
#Hard

Patch: Keen 5
#Ammo stunners give Keen
%patch $315F4 $0008W
#Easy
$0005W
#Medium
$0005W
#Hard

Patch: Keen 6
#Ammo stunners give Keen
%patch $31F7E $0008W
#Easy
$0005W
#Medium
$0005W
#Hard


Sprite Properties

In the Keen Galaxy and Dreams games all item sprites are controlled by a single sprite structure. This involves something that sits still and uses two animation frames. Item sprites tend to be used rarely in levels, when a tile-based item cannot be placed. (They use up far more memory than tile based items.)

By altering their properties it is possible to change many aspects of their behavior. However any changes will affect all sprites in the game.


Sprite Type

Items use sprite type 4 or 5 (depending on game) which is used only by items. This is listed as the 'gem' property, but in fact is responsible for all items being collectable (Their specific sprite value determines what is given to Keen.) This severely limits what these patches can do.

As well as items themselves there are a few 'associate sprites' related to items, items got, collectables got and so on. These have property 1, designed for sprites that do not last long.

Patch: Item sprite types
#Keen 4
%patch $FC45 $04
#Items
%patch $CD1A $01
#Item sprites got
%patch $CFF6 $01
#Item tiles got
%patch $D0A9 $01
#100 drop 1UP
%patch $FCAB $01 $
#Raindrop got
#Keen 5
%patch $FDC1 $05
#Items
#Keen 6
%patch $F402 $05
#Items
%patch $10C59 $05
#Keen 6 Blooglet gems)
%patch $F468 $01
#Viva got
%patch $C0F0 $01
#Items got (Includes 100-viva 1UP)
#Keen Dreams
%patch $810F $04
#Items


Sprite Actions

There are two central item actions, both do the same thing, they leave an item sitting, waiting to be collected. There is also an action for the 'item got' sprite, the little image that tells the player what they have got when they grab an item (100, 5000, etc.) Finally there are a few actions relating to that game's '100-collectable', such as the raindrops in Keen 4 (These collectables are not themselves items, but their got sprite is.)


Keen 4

Keen 4 Actions:
$1EECW #Items 1
$1F0AW #Items 2
$1F28W #Items got
$1F46W #Raindrop splash 1
$1F64W #Raindrop splash 2
$1F82W #Raindrop splash 3

Patch: Keen 4
#Extra sprite shown when player gets 100 drops 1UP
%patch $D0D0 $1F28W
#When item sprites are got
%patch $CD70 $1F46W
#Unknown item got
%patch $D026 $1F46W
#When item tiles are got
%patch $F9E9 $1F46W


Keen 5

Keen 5 Actions:
$1946W #Items 1
$1964W #Items 2
$1982W #Cards 1?
$19A0W #Cards 2?
$19BEW #Items got
$19DCW #Vitalin got 1
$19FAW #Vitalin got 2
$1A18W #Vitalin got 3
$1A36W #Vitalin got 4


Keen 6

Keen 6 Actions:
$196AW  #Items 1
$1988W  #Items 2
$19A6W  #Blooglet Items 2?
$19C4W  #Blooglet Items 2?
$19E2W  #Items got
$1A00W  #Viva got 1
$1A1EW  #Viva got 2
$1A3CW  #Viva got 3


Keen Dreams

Keen Dreams uses a prototype system of items and as such has only one item action as well as an item got action. All items of all kinds are sprites and spawned using the same code. However items interact with Keen in many different ways instead of a single generic manner. As such the item got actions occur in many different manners dictated by Keen's sprite collision.

Boobus Bombs that are thrown by the player and don't hit anything will return to an item-like state so they can be picked up and reused. This is the only other case of item spawning in the game.

Keen Dreams Actions:
$196CW #Items
$198AW #Items got

Patch: Keen Dreams
#Dropped Boobus Bombs turn into items
%patch $6955 $196CW
#Spawn items
%patch $8169 $196CW
#Get items
%patch $76D6 $198AW
#Point items
%patch $76FA $198AW
#1UP
%patch $772F $198AW
#Eye
%patch $7753 $198AW
#Flower Power
%patch $7778 $198AW
#Flower Pot
%patch $77A0 $198AW
#Boobus Bomb
%patch $77C4 $198AW
#Key


Sprite Behavior

The item's behavior switches the item's animation between its two frames and nothing else. It is used only by items and not the various 'got actions'. In Keen Dreams there is only one item action using this behavior which operates slightly differently.

Patch: Keen 4
#Items
%patch $30D6C $0FA8024ERL
#Item
%patch $30D8A $0FA8024ERL
#Item
#Items got
%patch $30DA8 $00000000L
#Sit
#Raindrops got
%patch $30DC6 $00000000L
#Sit
%patch $30DE4 $00000000L
#Sit
%patch $30E02 $00000000L
#Sit

Patch: Keen 5
#Items
%patch $31C96 $0F92052ARL
#Item
%patch $31CB4 $0F92052ARL
#Item
#Cards
%patch $31CD2 $0F920545RL
#Card
%patch $31CF0 $0F920545RL
#Card
#Items got
%patch $31D0E $00000000L
#Sit
#Vitalin got
%patch $31D2C $00000000L
#Sit
%patch $31D4A $00000000L
#Sit
%patch $31D68 $00000000L
#Sit
%patch $31D86 $00000000L
#Sit

Patch: Keen Dreams
#Items
%patch $24634 $05E8021BRL
#Item


Speed and Jump Height

Items do not move by default either in their code or animation motion. When got items produce a sprite that rises and this rising speed is controlled by its animation motion.

Patch: Keen 4
#Items
%patch $30D68 $0000W $0000W %patch $30D86 $0000W $0000W
#Items got
%patch $30DA4 $0000W $0008W
#Drop splash
%patch $30DC2 $0000W $0000W %patch $30DE0 $0000W $0000W %patch $30DFE $0000W $0000W

Patch: Keen 5
#Items
%patch $31C92 $0000W $0000W %patch $31CB0 $0000W $0000W
#Cards
%patch $31CCE $0000W $0000W %patch $31CEC $0000W $0000W
#Items got
%patch $31D0A $0000W $0008W
#Vitalin got
%patch $31D28 $0000W $0000W %patch $31D46 $0000W $0000W %patch $31D64 $0000W $0000W %patch $31D82 $0000W $0000W

Patch: Keen 6
#Items
%patch $326A6 $0000W $0000W %patch $326C4 $0000W $0000W
#Blooglet items
%patch $326E2 $0000W $0000W %patch $32700 $0000W $0000W
#Items got
%patch $3271E $0000W $0008W
#Viva got
%patch $3273C $0000W $0000W %patch $3275A $0000W $0000W %patch $32778 $0000W $0000W %patch $32796 $0000W $0000W

Patch: Keen Dreams
#Items
%patch $24630 $0000W $0000W


Animations

By default sprite actions have no animations as these would interfere with the list of animations used to make sprites appear different. These are listed in the 'list properties' section above. If an actual value is given, then all item sprites will look exactly the same. In Galaxy the animation speed controls the animation speed of all items, or in the case of item got sprites, how long the sprite remains before vanishing.

In Keen Dreams things are slightly different. While item animations are given by a list the 'item got' animations are set individually when an item is obtained, except for the point items which do use a list. By default there is also a single item (the 'eye' item) that has four frames of animation instead of two. It is item type 7, but other, even all of the, items may be given this many animation frames also.

Patch: Keen 4
#Item animations
%patch $30D5C $0000W $0000W %patch $30D66 $0014W
#Animation speed
%patch $30D7A $0000W $0000W %patch $30D84 $0014W
#Animation speed
#Items got animations
%patch $30D98 $0000W $0000W %patch $30DA2 $0028W
#Time before vanishing

Patch: Keen 5
#Item animations
%patch $31C86 $0000W $0000W %patch $31C90 $0014W
#Animation speed
%patch $31CA4 $0000W $0000W %patch $31CAE $0014W
#Animation speed
#Cards
%patch $31CC2 $0000W $0000W %patch $31CCC $0014W
#Animation speed
%patch $31CE0 $0000W $0000W %patch $31CEA $0014W
#Animation speed
#Items got animations
%patch $31CFE $0000W $0000W %patch $31D08 $0028W
#Time before vanishing
#Vitalin got
%patch $31D1C $00CBW $00CBW
#Vitalin got 1
%patch $31D26 $0008W
#Animation speed
%patch $31D3A $00CCW $00CCW
#Vitalin got 2
%patch $31D44 $0008W
#Animation speed
%patch $31D58 $00CDW $00CDW
#Vitalin got 3
%patch $31D62 $0008W
#Animation speed
%patch $31D76 $00CEW $00CEW
#Vitalin got 4
%patch $31D80 $0008W
#Animation speed

Patch: Keen 6
#Item animations
%patch $326D6 $0000W $0000W %patch $326E0 $0014W
#Animation speed
%patch $326F4 $0000W $0000W %patch $326FE $0014W
#Animation speed
#Item got animation
%patch $32712 $0000W $0000W %patch $3271C $0028W
#Time before vanishing

Patch: Keen Dreams
#Items - no animation
%patch $24624 $0000W $0000W
#Got item animations
%patch $76F3 $00CDW
#1UP
%patch $7717 $00CEW
#Eye
%patch $774C $00CFW
#Flower Power
%patch $7770 $00D0W
#Flower Pot
%patch $7795 $00D1W
#Boobus Bomb
%patch $77BD $00D2W
#Key
#Item(s) that are special
%patch $814D $07 $74
#Number of animation frames special items have
%patch $815F $0004W
#No special items
%patch $814B $EB $03


Sounds items make when got

These are a list property, see the first section of this page.


Clipping and foreground

Not only do items have their own values for clipping and foreground, but these are changed when the items are acquired. (Or in the case of item tiles, when a sprite is made when the tile is acquired.)

Patch: Keen 4 foreground variables
#Item foreground variables
%patch $CD1F $0003W
#Item sprite got


Sprite-tile interaction

In Galaxy items of all kinds do not need to interact with tiles and so use a basic tile collision that simply ensures they stay visible. In Dreams items have their own special tile interaction.

Patch: Keen 4
#Items
%patch $30D74 $09DC176ERL %patch $30D92 $09DC176ERL
#Items got
%patch $30DB0 $09DC176ERL
#Raindrop splash
%patch $30DCE $09DC176ERL %patch $30DEC $09DC176ERL %patch $30E0A $09DC176ERL

Patch: Keen 5
#Items
%patch $31C9E $090B17B5RL %patch $31CBC $090B17B5RL
#Cards
%patch $31CDA $090B17B5RL %patch $31CF8 $090B17B5RL
#Items got
%patch $31D16 $090B17B5RL
#Vitalin got
%patch $31D34 $090B17B5RL %patch $31D52 $090B17B5RL %patch $31D70 $090B17B5RL %patch $31D8E $090B17B5RL

Patch: Keen Dreams
#Items
%patch $2463C $05E804ACRL


Sprite spawn code

The item spawn code is perhaps the most complex attribute of an item. As such this section is divided up by game as well as providing a section on how item spawning works in general.


General principles

Only in Keen Galaxy and Dreams are items sprites and therefore only in those games do they have a spawning code. All sprites in a game use the same spawning code and usually the same initiation code (with some small exceptions discussed below.) The initiation codes in turn all start with a 'first item value' that gives each item its 'number'

The value is in fact a negative number (highlighted in brown in this section.) equal to the infoplane value of the first item. Thus if right facing Keen (Infoplane value 1) were the first item this value would be -1 or $FFFF. The Item's number is its infoplane value minus the first item value. Thus the first item will have a number of 0. Any items not spawned when the level is started must have their number explicitly set or they too will be number 0. (So a sprite that shoots items for example will produce red gems, item 0, by default.)

The first item value can be different for different initialization codes. This is seen for example in Keen 5 where the V Card has a FIV one less than the other items. (This means the V Card is a type 14 item, since the V card's infoplane value is 13 higher than the first Item.) This means that it is possible to have several sprites spawn as the same type of item under different circumstances. (For example easy, medium or hard items.)

The Item's 'cache' that is set in the initialization code is not a proper cache as such and is used when the item's more specific number-based cache is set later on. each item has its own cache, usually of two animations.

All Items use the same spawning code which insures that they do not appear in front of tiles, have no clipping and use the generic item action.


Keen 4

There are a large number of item initiation pointers. These point to two different initiation codes. The 'normal' item initiation defines the item type by taking the pointer value, subtracting $FFFFW and adding $FFC7W. (The net result here is to subtract $38 or 56 from the pointer value. This basically just sets the first item type in the infoplane tileset.) The alternative 'IF ammo' initiation checks to see if Keen has less than five shots and, if so, spawns a type $0B (12) item. (The raygun.) Both initiation codes set the cache in $C7 $06 $CB3BW $0001W. This caches all items and their got points.

The spawning code is more complex. In the spawning code the last blue highlighted value is the sprite action the Item uses as it proceeds to act in-level. $C7 $07 $xxxxW sets the sprite type and $C7 $20 $xxxxW sets the foreground value.

$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.) $C7 $47 $0E $xxxxW is the horizontal direction. The Items always start the level moving up, the direction that is passed on to their got actions. If this is changed the got items will either sit still or sink instead of rising.

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

Patch: Keen 4
#Location of initiation codes
%patch $EEC7 $03B2W
#IF Ammo (At $ECA2)
%patch $EEF5 $04A4W
#Red Gem (At $ED94)
%patch $EEF7 $04A4W
#Yellow Gem (At $ED94)
%patch $EEF9 $04A4W
#Blue Gem (At $ED94)
%patch $EEFB $04A4W
#Green Gem (At $ED94)
%patch $EEFD $04A4W
#100 Pts (At $ED94)
%patch $EEFF $04A4W
#200 pts (At $ED94)
%patch $EF01 $04A4W
#500 Pts (At $ED94)
%patch $EF03 $04A4W
#1000 Pts (At $ED94)
%patch $EF05 $04A4W
#2000 Pts (At $ED94)
%patch $EF07 $04A4W
#5000 Pts (At $ED94)
%patch $EF09 $04A4W
#1UP (At $ED94)
%patch $EF0B $04A4W
#Raygun (At $ED94)
#IF Ammo initiation code
%patch $ECA2 $83 $3E $7A58W $05 $7C $03 $E9 $0151W $B8 $000BW $50 $FF $76
#Here check Keen's ammo < 5, ammo is 12th item kind
$FC $57 $9A $0FA801A3RL $83 $C4 $06 $8B $1E $D2 $19 $D1 $E3 $C7 $87 $CB3BW $0001W $E9 $0132W $E9 $012FW
#Items initiation code
%patch $ED94 $8B $46 $F8 $05 $FFC7W $50 $FF $76 $FC $57 $9A $0FA801A3RL $83 $C4 $06 $8B $5E $F8 $D1 $E3 $8B $9F $4A $19 $D1 $E3 $C7 $87 $CB3BW $0001W $EB $43
#Items spawn code
%patch $FC23 $55 $8B $EC $56 $8B $76 $0A $33 $C0 $50 $9A $06BD1E11RL $83 $C4 $02 $8B $1E $D8 $A7 $C7 $47 $06 $0000W $C7 $47 $20 $0002W $C7 $07 $0004W $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B $46 $08 $D3 $E0 $89 $47 $0C $C7 $47 $10 $FFFFW $89 $77 $3E $8B $DE $D1 $E3 $8B $87 $1FA0W $8B $1E $D8 $A7 $89 $47 $1E $89 $47 $40 $8B $47 $40 $05 $0002W $89 $47 $42 $B8 $1EECW $50 $53 $9A $09DC118CRL $83 $C4 $04 $5E $5D $CB


Keen 5

In the initiation code notice the cache is set in $C7 $06 $C25FW $0001W. This cache is in fact the item cache also cached by all items before a more specific cache is set.

The spawning code is more complex. In the spawning code the last blue highlighted value is the sprite action the Item uses as it proceeds to act in-level. $C7 $02 $xxxxW sets the sprite activity, $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 $47 $10 $xxxxW is the vertical direction the sprite starts moving in, either $0001W (Facing down), $FFFFW (Facing up) or $0000W (Neither, never used.) $C7 $47 $0E $xxxxW is the horizontal direction. The Items always start the level moving down, possibly this relates to how the item got sprites move upwards.

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

Patch: Keen 5
#Location of initiation code
%patch $F550 $04E3W
#V card (At $F233)
#V card Initiation code
%patch $F233 $8B $46 $FA $05 $FFC6W $50 $57 $56 $9A $0F92047FRL $83 $C4 $06 $8B $5E $FA $D1 $E3 $8B $9F $C8 $17 $D1 $E3 $C7 $87 $C25FW $0001W $E9 $014FW
#V Card spawning code
%patch $FD9F $55 $8B $EC $56 $8B $76 $0A $33 $C0 $50 $9A $06B91DCDRL $83 $C4 $02 $8B $1E $40 $9E $C7 $47 $06 $0000W $C7 $47 $20 $0002W $C7 $07 $0005W $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B $46 $08 $D3 $E0 $89 $47 $0C $C7 $47 $10 $FFFFW $89 $77 $3E $8B $DE $D1 $E3 $8B $87 $54 $1A $8B $1E $40 $9E $89 $47 $1E $89 $47 $40 $8B $47 $40 $05 $0002W $89 $47 $42 $B8 $1946W $50 $53 $9A $090B11C4RL $83 $C4 $04 $5E $5D $CB


Keen Dreams

There are twelve types of item, each giving the player something different. Notice that the Boobus Bomb uses a slightly different segment of initiation code; this does nothing more than set a variable so that Keen is warned there are bombs when entering a level, it then proceeds to use the item initiation code. In the initiation codes no cache is set; items share Keen's cache which is always loaded. Finally note the blue value, this sets the item's 'type' (100, 200, life, etc.) as the item's infoplane value minus $15.

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, $C7 $47 $06 $xxxxW sets the |clipping, and $C7 $47 $0E $xxxxW is the horizontal direction the sprite starts moving in, either $0001W (Facing right), $FFFFW (Facing left) or $0000W (Neither, seldom used.) $C7 $47 $10 $xxxxW is the vertical direction and works similarly.

Clipping is set to 'none' on the second line, this allows items and their got sprites to pass through solid tiles unimpeded. The item's type is set on the same line. On line 4 type 9 items are checked for (That is the Flower Pot.) and their vertical location is adjusted.

On line 5 the item's animation is read from the item animation list. On the next line type 7 items (That is the eye.) is checked for, instead of two animation frames it has four.

Patch: Keen Dreams
#Item initiation pointers
%patch $4A05 $02F3W
#100 Pts (At $47C3)
%patch $4A07 $02F3W
#200 Pts (At $47C3)
%patch $4A09 $02F3W
#500 Pts (At $47C3)
%patch $4A0B $02F3W
#1000 Pts (At $47C3)
%patch $4A0D $02F3W
#2000 Pts (At $47C3)
%patch $4A0F $02F3W
#5000 Pts (At $47C3)
%patch $4A11 $02F3W
#1UP (At $47C3)
%patch $4A13 $02F3W
#Eye (At $47C3)
%patch $4A15 $02F3W
#Flower Power (At $47C3)
%patch $4A17 $02F3W
#Flower Pot (At $47C3)
%patch $4A19 $02EDW
#Boobus Bomb (At $47BD)
%patch $4A1B $02F3W
#Key (At $47C3)
#Boobus Bomb (Uses following item initiation code)
%patch $47BD $C7 $06 $704CW $0001W
#Items initiation code
%patch $47C3 $A1 $70ACW $2D $0015W $50 $FF $36 $7052W $FF $36 $7050W $9A $07C504A3RL $83 $C4 $06 $8B $1E $3E $70 $C7 $47 $02 $0000W $E9 $01E6W
#Item spawn code
%patch $80F3 $55 $8B $EC $56 $8B $76 $0A $33 $C0 $50 $9A $044D01C9RL $44 $44 $8B $1E $3E $70 $C7 $47 $06 $0000W $C7 $07 $0004W $8B $46 $06 $B1 $08 $D3 $E0 $89 $47 $0A $8B $46 $08 $D3 $E0 $89 $47 $0C $83 $FE $09 $75 $05 $81 $0C6FW $0080W $8B $1E $3E $70 $C7 $47 $10 $FFFFW $89 $77 $3E $8B $DE $D1 $E3 $8B $87 $19A8W $8B $1E $3E $70 $89 $47 $20 $89 $47 $40 $83 $FE $07 $74 $07 $8B $47 $40 $40 $40 $EB $0A $8B $1E $3E $70 $8B $47 $40 $05 $0004W $8B $1E $3E $70 $89 $47 $42 $B8 $196CW $50 $FF $36 $3E $70 $9A $044D1212RL $83 $C4 $04 $5E $5D $CB