Door versitility

Completed patches for Keen1.
Post Reply
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Door versitility

Post by levellass »

Oooh! My very own topic! I feel apprehensive!

Right; somebody recently asked for a door trick, something I don't have the skill to pull off. (Indded, it turned out I was looking at the whole wrong area of code.) The code involved here is that which chooses the tiles displayed as the door is opened, it is found at location $27F8 - $290D (With some other subroutines linked to it)

Basically, when Keen goes to open a door, the game looks at the level he's in and 'takes' three tiles from the level; the door top tile, and the tiles 3 and 4 rows below this. From the door top tile, it then picks the tile next along in the tileset. The four tiles the game now has are displayed as follows; the two door tiles start at the door top, and fall downwards for 2 tiles, then dissapear. To make it look like the tiles are sinking into the ground, the remaining two tiles are displayed over the level, just under the door, to hide the bottom of the two door tiles. After (Actually during) the door tiles' sinking, the level's door tiles are replaced by two other (blank) tiles so Keen can get past where the door used to be.

After a long phone conversation with Adis (Disguised as a deep heart-to-heart chat.) I have managed to cut n' paste together this somewhat clunky and complicated patch. I apologize for it's lack of use and complexity, but a crazy patcher I am not.

Code: Select all

#The door opening involves 3 tiles; one 3 below the door top, one 2 below the door top,
#and the door top (And the tile that follows it in the tileset) There are also 2 tiles that
#replace the door when it is opened. For the opening door, it is possible to change where
#in the level these tiles are taken from; normally the tile displayed is the same as that
#already there, but this can be changed... (PATCH MAY HAVE SIDE EFFECTS!)

#Ultimate door versitility patch; set default door code:
%patch $28A1 $C7 $05 $02 $00 $F7 $2E $08 $6C $03 $46 $04 $D1 $E0 $C4 $1E $48 #1
%patch $28B1 $6C $03 $D8 $26 $8B $07 $89 $44 $0E $8B $C7 $05 $00 $00 $F7 $2E #3-4
%patch $28C1 $08 $6C $03 $46 $04 $D1 $E0 $C4 $1E $48 $6C $03 $D8 $26 $8B $07
%patch $28D1 $89 $44 $10 $8B $5E $FE $D1 $E3 $C7 $87 $9A $AA $00 $00 $8B $C7
%patch $28E1 $05 $00 $00 $F7 $2E $08 $6C $03 $46 $04 $D1 $E0 $C4 $1E $48 $6C #3-7
%patch $28F1 $03 $D8 $26 $C7 $07 $8F $00 $8B $C7 $05 $01 $00 $F7 $2E $08 $6C #2-9
%patch $2901 $03 $46 $04 $D1 $E0 $C4 $1E $48 $6C $03 $D8 $26 $C7 $07 $8F $00
%patch $2911 $5F $5E $8B $E5 $5D $C3 $90 $90

#Adjustable stuff:
%patch $2889 $03 $00 #Tile for 4 below doortop is picked from... [Vert location]
%patch $28A3 $02 $00 #Tile for 3 below doortop is picked from...
%patch $28BD $00 $00 #Doortop is picked from...
%patch $28E2 $00 $00 #First replacement tile vert location
%patch $28FB $01 $00 #Second replacement tile vert location
%patch $28F6 $8F $00 #First replacement tile
%patch $290F $8F $00 #Second replacement tile

#Probbably poinmtless stuff:
#%patch $289F $12 #Make 4 below tile always tile 0
#%patch $28B9 $12 #Make 3 below tile always tile 0
#%patch $28D3 $12 #Make descending door tiles always tile 0
The last three patches will probbably not be needed by anyone, but you never know... Along with this, I came across several other patches that may be of interest:

Code: Select all

#Door opening sound
%patch $2801 $21 $00

#Only blue door takes key
%patch $28D7 $A0

#Doors don't take keys
%patch $28D7 $00

#Doors don't open, Keen can just walk right through them
#If he has the right key- over and over. (Doesn't take Keen's key.)
%patch $27F8 $C3
I hope these are of some use to someone, and I may have time to further research the doors after christmas.
EricMushroomWilson
Posts: 78
Joined: Mon Dec 18, 2006 9:52 pm
Location: Limbo

Post by EricMushroomWilson »

Are the tile locations relative or absolute? Also, for the tiles that the door is replaced with, are they locations in the level or tile numbers?
Stealthy71088
Posts: 583
Joined: Thu Mar 17, 2005 11:54 pm
Location: NY

locations of the doors? Nope, nothin that fancy.

Post by Stealthy71088 »

EricMushroomWilson wrote:Also, for the tiles that the door is replaced with, are they locations in the level or tile numbers?
It's all tile numbers, it has nothing to do with locations, unlike the teleporters and bridges. It depends on what you're doing. If you aren't using any special patches, and are working in Keen1 or Keen2, the doors are replaced with the first blank grey tile in the tileset. Anything bellow a certain number, I don't know the number off the top of my head, becomes the lower right corner of the pogo sign. I don't know what the magic tile is in Keen2- you'll have to experiment.

If you're working with keen3, or the keen3 tileset patch (not offical name), the game reads the tileset a little differently. It replaces every door with the tile in the same row all the way on the left. This means that if you use this patch and make your door on the left end of the tileset, that door will keep respawning itself whenever you try to open it. The plus side of this setup is that you can have lots of different tiles that are spawned, a different tile for every door if you like.

Or you can just take the easy approach, and use LevelLass's patch to pick out the tiles you want by number, and not have to worry about possibly having to reorganize your tileset if you're pretty far in.

This all works the same with points, the pogo, and the raygun.

Did I get that all right, guys?
levellass
Posts: 3001
Joined: Wed Oct 11, 2006 12:03 pm
Location: Ngaruawahia New Zealand

Post by levellass »

Are the tile locations relative or absolute? Also, for the tiles that the door is replaced with, are they locations in the level or tile numbers?
As you would expect, the locations are all relative to the top of the door being opened; otherwise no door would work. The last two lines are the tiles the door is replaced with. (As it says.)

Just fiddle with it and see how it goes!


As far as I can see; doors in Keen 1 and 2 behave the same; they both use specific hard coded replacement tiles; in Keen 3 the code used for items, etc; the usual leftmost tile. The second background tile is found in Keen 1 too and is a result of a big value of $xx being used instead of infinity. What am I on about? If you look at the background patch Andy made you'll see that you can make every second line, third line, etc the special tile. In Keen 1 and 2 this is (I think.) the 12th line.

You'll notice that the last part of Andy's background patches does nothing more than alter the door behaviour; it's not vital. Thus, if you are going to have this patch. (From this topic) and the background patch; remove:

Code: Select all

#Make doors open like in Keen 3
%patch $28EC                  $26 $8B $07 $B6 
%patch $28F0  $0D $F6 $FE $F6 $EE $26 $89 $07 
%patch $28F8  $03 $1E $08 $6C $03 $1E $08 $6C 
%patch $2900  $26 $89 $07 $90 $90 $90 $90 $90 
Last edited by levellass on Tue Dec 19, 2006 10:09 am, edited 1 time in total.
User avatar
Freeyorp101
Posts: 159
Joined: Thu Nov 24, 2005 2:12 am
Location: New Zealand

Post by Freeyorp101 »

In Keen 1 and 2 this is (I think.) the 14th line.
It's the first tile on the 12th; tile 143 ($8F), which is also used for a number of different things like the bridge and exit.
Post Reply