Metroid Construction
Powered by LOVE


-> Documents -> How to add more doors to a room

Before you dive into this, I reccomend having at least a basic understanding of how to use SMILE so I don't have to explain every single little detail along the way. No sense adding new doors to the game if you don't know how to edit a room yet. You should already know how to move doors around ("door cloning"), and that the BTS ## you place on a door tile will determine which number the door is in a room. If you don't, read "Section C: Moving doors" in this guide.

Repointing "Door Out" in SMILE's Pointers window to free space in bank $8F lets you to add more doors to a room. Door Out actually points to a set of other pointers, so there's an extra step or two involved in making this work. Nothing you can't handle. The data for each individual door is located in bank $83, which is pointed to from bank $8F. Each door for a room takes exactly 12 bytes.

Go to free space anywhere in bank $83. For this example I'll start at offset 1ADA0 ($8FADA0). Nothing but FF bytes here for a long ways down. Unlike repointing other things, you'll need to manually enter new data for each door so SMILE can recognize them. It's not as hard as it sounds. Copy these 12 bytes to your clipboard (12 byes = 1 door):

19 DC 00 04 01 06 00 00 00 80 00 00

Make sure you copy only those bytes and nothing else. It actually doesn't matter which bytes you use exactly, as long as it's 12 bytes of working door data. When you edit the doors later on in SMILE, some of the values in the 12-byte string will be changed anyway, but will never become less or more than 12 bytes.

You have two options on how your door data should be arranged in the hex editor: 1 door per line (this is more organized), or have the doors directly next to each other, which is less organized, but also uses less free space. You'd be saving 4 bytes of free space per door, in fact. With all of this in mind, pick a room that you want more doors added to. I'll go with room 79879, which only has 2 doors. The free space I chose is 1ADA0, but my Door Out pointer will NOT be ADA0 like it normally would for other pointers. This is where the extra steps come in.

Those 12 bytes you copied? You're gonna be pasting these into the ROM with a hex editor, starting at the offset you chose to use for free space in bank $83 (in my case, 1ADA0). Make sure that these bytes are WRITTEN into the ROM, and not added! In other words, the 12 door bytes you copied will need to replace 12 "FF" bytes. In HxD, this is called "paste write" which can also be done by pressing Ctrl+B.

Decide how many doors you want the room to have, and paste-write those 12 bytes once for each door. I'm gonna give the room 4 doors instead of the 2 it has normally, so I'll be pasting the bytes 4 times (48 bytes total). To elaborate on what I said earlier about choosing how to arrange door data in the hex editor, this is what 1 door per line will look like, compared to placing them all in a row to conserve free space:

1 door per line (4 doors, 4 lines)
19 = byte #1 of 12-byte door data that you copied
00 = byte #12 of 12-byte door data that you copied
0001ADA0 | 19 DC 00 04 01 06 00 00 00 80 00 00 FF FF FF FF
0001ADB0 | 19 DC 00 04 01 06 00 00 00 80 00 00 FF FF FF FF
0001ADC0 | 19 DC 00 04 01 06 00 00 00 80 00 00 FF FF FF FF
0001ADD0 | 19 DC 00 04 01 06 00 00 00 80 00 00 FF FF FF FF

Doors directly next to each other (4 doors, 3 lines)
19 = byte #1 of 12-byte door data that you copied
00 = byte #12 of 12-byte door data that you copied
0001ADA0 | 19 DC 00 04 01 06 00 00 00 80 00 00 19 DC 00 04
0001ADB0 | 01 06 00 00 00 80 00 00 19 DC 00 04 01 06 00 00
0001ADC0 | 00 80 00 00 19 DC 00 04 01 06 00 00 00 80 00 00

See? 4 lines used if you have 1 door per line. 3 lines used by placing them next to each other. That's enough free space saved for a whole new door. Wowza.

For either scenario, what you want to pay attention to are the 4 offsets that each "19" is at. Since 19 is the very first byte of the door data, all 4 offsets will need to be noted. I'd suggest writing them down.

In the "1 door per line" example, the 4 19s are all directly on top of each other, making their offsets 1ADA0, 1ADB0, 1ADC0 and 1ADD0.

In the "doors directly next to each other" example, the 19s are obviously not stacked the same way. Click on each of the 4 19s. HxD tells you the offset on the bottom-left corner of the window; other hex editors probably do the same thing. If yours doesn't, just look for any way to see the offsets (PC addresses) of where you've clicked. The 4 offsets are 1ADA0, 1ADAC, 1ADB8 and 1ADC4.

Okay! So you've pasted the 12 bytes of door data 4 times, and have the offsets for the very first byte (19) for each door written down. Excellent. That's all you need to do in bank $83. Now it's time to hop on over to bank $8F. Go to some free space in bank $8F, as usual. I'll go with offset 7EA30 ($8FEA30), meaning my Door Out pointer will be EA30 when comes time to repoint. We're almost there.

Remember what I said about Door Out being a pointer to other pointers? Yup, you've gotta make these other pointers yourself, but it's simple. Those 4 door offsets I told you to write down? This is where you will point to them so SMILE can recognize them as new doors. Something to know about pointers, is that the bytes are usually reversed. By reversed, I mean that "01 02 03" would become "03 02 01" if you were using those 3 bytes as a pointer.

Apply this logic to your 4 offsets. For instance, 1ADA0. The first digit is assumed because the game already knows to load door data from bank $83, so the 1 will be ignored. This leaves you with ADA0. Break it apart, and you have 2 bytes: AD A0. Reverse these 2 bytes, and it becomes A0 AD. Thus, it becomes a pointer for 1 door in bank $83.

Do this with all 4 of the offsets (if you added more than 4 doors, say 9, you'd do this with all 9 offsets). If you have 1 door per line, 1ADA0, 1ADB0, 1ADC0 and 1ADD0 would become A0 AD, B0 AD, C0 AD and D0 AD. If your doors are all next to each other, 1ADA0, 1ADAC, 1ADB8 and 1ADC4 becomes A0 AD, AC AD, B8 AD and A0 AD.

In your hex editor, enter these reversed 2-byte offset values as a continuous string, like so:

## ## = 4 pointers for 4 doors
01 01 = I'll explain the meaning of these below
0007EA30 | A0 AD B0 AD C0 AD D0 AD 01 01 FF FF FF FF FF FF

Easy, right? Now, about the 01 01 that I placed at the end of the 4 door pointers. These tell SMILE to stop reading the door pointers. Without the 01 01, SMILE would continue reading past the 4th door pointer, and you would end up with like 50 doors in your room. Always place 01 01 at the end of your door pointers.

Save the ROM in your hex editor, then change the Door Out pointer in SMILE to EA30. Click no when it asks you to copy data or leave it. Done. You'll notice that the door editor now shows doors $00-$03 instead of just the $00-$01 it had normally.

This will cause all of the doors in your room to point to the same room (somewhere in Tourian) because you pasted the same door data X number of times. This is fine. Just use door cloning to connect all of your doors to neighboring rooms like usual. If you feel like it, take a look at the doors you pasted in bank $83 again after you've edited them with SMILE. You'll notice that all of the doors don't have the same exact data anymore.

Sweeeeeeet. You can now add doors to any room you want.

This is just some extra info about the actual door data itself that you copied and pasted earlier. Open up SMILE's door editor window. It doesn't matter which door you're looking at:

There are 12 bytes here, 92 FD 00 05 4E 06 04 00 80 00 00 00. Look familiar? SMILE edits most of these values for you automatically when you move and/or clone doors, but it still doesn't hurt to know what each of these attributes does:

Room ID
SMILE edits this automatically. The "7" at the beginning of all room IDs is omitted because the game already knows to load this from bank $8F. This is the ID of the room that the door will be leading into, NOT the room ID that the door itself is in. Same goes for everything else in the door editor.

SMILE does NOT edit this automatically. This is set to 00 most of the time because BitFlags are only used in certain instances. These include entering a new area (such as going from Brinstar to Maridia), and elevators. For entering a new area, the BitFlag will usually be 40. For elevators, well... I haven't edited elevators yet, so I can't really say much else. Using BitFlag 40 for an area transition prevents the map from messing up. You'll need to change the BitFlag from 00 to 40 yourself if the door is leading into another area.

SMILE edits this automatically. You can probably guess... this simply determines which direction the door is going. 04 = right, 05 = left, 06 = down, 07 = up.

SMILE edits this automatically. Xi is the number of screens, starting from the very left that Samus will appear after going through the door.

SMILE edits this automatically. Same as Xi, except it's the number of screens starting from the top of the room instead. Think of Xi and Yi as a sort of Latitude/Longitude for determining where to place Samus.

SMILE edits this automatically. It works the same way as Xi, but on a smaller scale. It's the number of tiles within the screen determined by Xi/Yi, starting from the left.

SMILE edits this automatically. Same as X. Smaller scale, starts from the top instead of from the left, yadda yadda.

Distance from door
SMILE does NOT edit this automatically. I don't know a whole lot about the specifics of this, except that left/right/down doors use 8000. If a door is leading up, it has a distance-from-door value of 01C0. This prevents the door from closing around Samus' feet. You'll need to change it from 8000 to 01C0 yourself if you've got a ceiling door.

Scroll pointer
SMILE does NOT edit this automatically. Scroll pointer rocks. It's usually set to 0000, but you can point it to free space in bank $8F like any other pointer, and if you know any assembly, write your own code to run when Samus passes through the door. The most common use is changing the color of scroll blocks, but you can do so many other things, like adjust Samus' energy and missile counts, make the door turn her around and deny entry to a room, and God knows what else.

I'll be detailing how to use door scroll pointer ASM in another write-up, hopefully sometime in the near future. Hopefully.
Site design by begrimed