How to add and remove extra room states
by JAM


O.     Introduction
I.     Understanding room state data
Ia.    Removing one alternate state (starting from last)
Ib.    Removing all alternate states
II.    Adding an extra state
IIa.   Placing extra state outside of room header
IIaa.  Placing extra state outside of room header, without adding a door
IIab.  Placing extra state outside of room header, while adding a door
IIb.   Placing extra state inside of room header
IIba.  Placing extra state inside of room header, without adding a door
IIbb.  Placing extra state inside of room header, while adding a door





O. INTRODUCTION


With this guide you can actually create room in Brinstar (for example) that will change itself when:
1. you got Morphing Ball item
2. you got Missiles
3. after defeating Spore Spawn
4. after defeating Kraid
5. after obtaining Power Bombs.
6. Maridia tube's explosion can also affect your room if you want to (raise water level, for example).
7. after defeating Mother Brain (when Zebes going to explode)

Limitations.
Any room can handle more that 4 alternative states. You are limited only by free space in bank $8F. Every alternative state will take 31 ($1F) bytes.

Warning!
Adding more alternative states will overwrite data after the room you edit! If you need next room, then make new room in bank $8F (See 3.2)

Small note.
When I say "write on paper" or "read from paper" you can use temporary text file in your computer if you want to. When certain bytes will be colored, you can do it by underline these bytes using color pencils or pens.





I. UNDERSTANDING ROOM STATE DATA


Let's start from removing (the easiest part).

For example, we need to remove all states from landing site room to free space for other rooms. In that case, in will raining forever. Or not raining if you change FX data.

1. Let's open room 791F8 in SMILE.

2. Open room 791F8 in SMILE. Choose Edit > Pointers to call pointers window. Write on a paper pointers for Door Out, Level Data and Scroll. If scroll is 0000 or 0001, don't write it. In this case, there is no scrolling data for each screen in mdb. All screens are blue or green. In our case, Door Out pointer is 927B, Scroll pointer is 9283 and Level Data pointer is ?2C2BB.

Also, remember, how many doors in there. Move cursor to any door and press "D" to call Door Editor. In right part will be several doors listed as Door $00, Door $01 etc. Look at the last door. It's the Door $03. Add 1 in mind to count Door $00 and you'll get 4 doors in the room. Write on paper: "4 doors". If there are just a pair of doors, then you can easy count them by yourself.

3. Repeat process for all alternative variants of this room. Click ComboBox with E5E6 in it. It's just right from ComboBox with level mdb in it (791F8). Door Out pointer is always the same but Scroll pointer and Level Data pointer sometimes may be different. In our case, the values are the same.

4. Close pointer window. Choose Edit > Room Properties in SMILE. Write on paper room's size. Quit SMILE

5. Let's open room 791F8 in hex. The underlined 00 on the very top row is where 791F8 begins. Notice that it is 9 ($08 bytes in hex) bytes to the right of the green 791F0 on the very left, hence 791F8 as our offset address.

791F0: ?? ?? ?? ?? ?? ?? ?? ?? 00 00 17 00 09 05 70 A0
79200: 00 7B 92 12 E6 0E 61 92 69 E6 47 92 12 E6 00 2D
79210: 92 E6 E5 BB C2 C2 01 06 05 C0 80 3D 88 93 81 81
79220: 01 83 92 00 00 16 C1 00 80 6A B7 C9 91 BB C2 C2
79230: 00 06 06 C0 80 3D 88 93 81 81 01 83 92 00 00 16
79240: C1 00 80 6A B7 C9 91 BB C2 C2 00 0C 05 D0 80 3D
79250: 88 93 81 81 01 83 92 00 00 16 C1 00 80 6A B7 C9
79260: 91 BB C2 C2 00 00 00 00 80 0D 8C 83 82 81 01 83
79270: 92 00 00 20 C1 26 80 6A B7 BD 91 16 89 22 89 2E
79280: 89 3A 89 00 00 02 02 02 02 02 02 02 00 00 02 02
79290: 02 02 02 02 02 01 00 02 02 02 02 02 02 02 00 00
792A0: 02 02 02 02 02 02 02 01 01 01 01 01 01 01 01 01
792B0: 13 01 80


Next room is 792B3, so the last byte we're interested in is 792B2

6. Let's color it a bit.

See the values on a paper. Door Out pointer is 927B and Scroll pointer is 9283. Door Out pointer is always located at 9 bytes from begining of mdb data. Everything is written backwards in hex. 927B is written as 7B 92.

There is a small door array at 927B. Each door pointer have size of 2 bytes. How many doors are in that room? 4 doors. So door array have size of 2*4 bytes, starts at 7927B and ends at 79282.

791F0: ?? ?? ?? ?? ?? ?? ?? ?? 00 00 17 00 09 05 70 A0
79200: 00 7B 92 12 E6 0E 61 92 69 E6 47 92 12 E6 00 2D
79210: 92 E6 E5 BB C2 C2 01 06 05 C0 80 3D 88 93 81 81
79220: 01 83 92 00 00 16 C1 00 80 6A B7 C9 91 BB C2 C2
79230: 00 06 06 C0 80 3D 88 93 81 81 01 83 92 00 00 16
79240: C1 00 80 6A B7 C9 91 BB C2 C2 00 0C 05 D0 80 3D
79250: 88 93 81 81 01 83 92 00 00 16 C1 00 80 6A B7 C9
79260: 91 BB C2 C2 00 00 00 00 80 0D 8C 83 82 81 01 83
79270: 92 00 00 20 C1 26 80 6A B7 BD 91 16 89 22 89 2E
79280: 89 3A 89 00 00 02 02 02 02 02 02 02 00 00 02 02
79290: 02 02 02 02 02 01 00 02 02 02 02 02 02 02 00 00
792A0: 02 02 02 02 02 02 02 01 01 01 01 01 01 01 01 01
792B0: 13 01 80


Legend.

Green: offset from start of ROM
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Blue: door array pointer.
??: data from other place. Don't touch it.

7. Let's color Scroll data. See at paper, Scroll data starts from 79283 but where it ends? See room dimensions on paper. Each screen in scroll data takes 1 byte. In our case, Width is 9, Height is 5. 9*5=45 screens in total. Convert 45 in hex. You'll get 2D. Add 2D to 79283. You'll get 792B0. Other data will starts there. But next room's mdb starts from 792B3. What's the data is located after Scroll Data? Special scrolling data. Scrolling PLMs are points to this. Let's color these bytes in brown.

If scroll data ends right before next room's mdb, then there is no Special scrolling data for this room.

791F0: ?? ?? ?? ?? ?? ?? ?? ?? 00 00 17 00 09 05 70 A0
79200: 00 7B 92 12 E6 0E 61 92 69 E6 47 92 12 E6 00 2D
79210: 92 E6 E5 BB C2 C2 01 06 05 C0 80 3D 88 93 81 81
79220: 01 83 92 00 00 16 C1 00 80 6A B7 C9 91 BB C2 C2
79230: 00 06 06 C0 80 3D 88 93 81 81 01 83 92 00 00 16
79240: C1 00 80 6A B7 C9 91 BB C2 C2 00 0C 05 D0 80 3D
79250: 88 93 81 81 01 83 92 00 00 16 C1 00 80 6A B7 C9
79260: 91 BB C2 C2 00 00 00 00 80 0D 8C 83 82 81 01 83
79270: 92 00 00 20 C1 26 80 6A B7 BD 91 16 89 22 89 2E
79280: 89 3A 89 00 00 02 02 02 02 02 02 02 00 00 02 02
79290: 02 02 02 02 02 01 00 02 02 02 02 02 02 02 00 00
792A0: 02 02 02 02 02 02 02 01 01 01 01 01 01 01 01 01
792B0: 13 01 80


Legend.

Green: offset from start of ROM
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Orange: scroll array. 1 byte for every screen of room. It starts from upper-left corner of room.
Blue: door array pointer
Brown: special scrolling data. Scrolling PLMs are points to this.
??: data from other place. Don't touch it.

8. Now, let's color Level Data in red. See at paper. C2C2BB. Write it backwards. You'll get BB C2 C2. Search these bytes in your mdb. They are at 79213, 7922D, 79247 and 79261. Write them on paper or remember if you want.

Original state will always be after "E6 E5" bytes. Alternative states will always have a pointer. All bytes after pink ones and before red ones are used for alternative states.

9. Level Data for alternative state is at 7922D, 79247 and 79261. Everything in hex is stored backwards. Only last 4 digits used in pointers. So, search for "2D 92", "47 92" and "61 92" between pink bytes and first red bytes. Color it in yellow.

2 or 3 bytes before yellow-colored are used to determine what event should happen to load alternative state for this room after that.

12 E6 means E612 -- Events. 0E is a number of event. "Zebes is exploding" is stored under number 0E.
69 E6 means E669 -- item related event "Samus got Power Bombs". No third byte here.
12 E6 means E612 -- Events. 00 is a number of event. "Zebes is awake" is stored under number 00.

Let's color them too.

791F0: ?? ?? ?? ?? ?? ?? ?? ?? 00 00 17 00 09 05 70 A0
79200: 00 7B 92 12 E6 0E 61 92 69 E6 47 92 12 E6 00 2D
79210: 92 E6 E5 BB C2 C2 01 06 05 C0 80 3D 88 93 81 81
79220: 01 83 92 00 00 16 C1 00 80 6A B7 C9 91 BB C2 C2
79230: 00 06 06 C0 80 3D 88 93 81 81 01 83 92 00 00 16
79240: C1 00 80 6A B7 C9 91 BB C2 C2 00 0C 05 D0 80 3D
79250: 88 93 81 81 01 83 92 00 00 16 C1 00 80 6A B7 C9
79260: 91 BB C2 C2 00 00 00 00 80 0D 8C 83 82 81 01 83
79270: 92 00 00 20 C1 26 80 6A B7 BD 91 16 89 22 89 2E
79280: 89 3A 89 00 00 02 02 02 02 02 02 02 00 00 02 02
79290: 02 02 02 02 02 01 00 02 02 02 02 02 02 02 00 00
792A0: 02 02 02 02 02 02 02 01 01 01 01 01 01 01 01 01
792B0: 13 01 80


Legend.

Green: offset from start of ROM
Red: pointer for level data
Yellow: pointer for pointer in bank 8F for level data
Aqua: alternative state. It shows what should happen for room to change.
Purple: extra value for alternative state.
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Orange: scroll array. 1 byte for every screen of room. It starts from upper-left corner of room.
Blue: door array pointer.
Brown: special scrolling data. Scrolling PLMs are points to this.
??: data from other place. Don't touch it.

79203: 61 92 is a pointer to pointer to 3rd alternative room ($8F 92 61)
7E208: 47 92 is a pointer to pointer to 2nd alternative room ($8F 92 47)
7E20C: 2D 92 is a pointer to pointer to 1st alternative room ($8F 92 2D)

Same thing, in more explaining form...

79203 => 79261 => C2C2BB (3rd alt. room)
7E208 => 79247 => C2C2BB (2nd alt. room)
7E20C => 7922D => C2C2BB (1st alt. room)

Original state's mdb will always be stored first.





Ia. REMOVING ONE ALTERNATE STATE (STARTING FROM LAST)


A. Open ROM in hex at 791F8.

We'll need to:
B. Remove the pointer to alternative state.
To do so, we'll have to get rid of the data between 7E203 and 7E207, which is now marked with gray text, second row from the top.

Result:
791F0: ?? ?? ?? ?? ?? ?? ?? ?? 00 00 17 00 09 05 70 A0
79200: 00 7B 92 12 E6 0E 61 92 69 E6 47 92 12 E6 00 2D
79210: 92 E6 E5 BB C2 C2 01 06 05 C0 80 3D 88 93 81 81
79220: 01 83 92 00 00 16 C1 00 80 6A B7 C9 91 BB C2 C2
79230: 00 06 06 C0 80 3D 88 93 81 81 01 83 92 00 00 16
79240: C1 00 80 6A B7 C9 91 BB C2 C2 00 0C 05 D0 80 3D
79250: 88 93 81 81 01 83 92 00 00 16 C1 00 80 6A B7 C9
79260: 91 BB C2 C2 00 00 00 00 80 0D 8C 83 82 81 01 83
79270: 92 00 00 20 C1 26 80 6A B7 BD 91 16 89 22 89 2E
79280: 89 3A 89 00 00 02 02 02 02 02 02 02 00 00 02 02
79290: 02 02 02 02 02 01 00 02 02 02 02 02 02 02 00 00
792A0: 02 02 02 02 02 02 02 01 01 01 01 01 01 01 01 01
792B0: 13 01 80


Grey: Data that we no longer need.

C. Shift all data from 7E209 to 7E204 towards the left. Stop right before last red bytes.

D. Fill 5 bytes before red bytes with FF's as we are shifted everything left 5 bytes.

Result:
791F0: ?? ?? ?? ?? ?? ?? ?? ?? 00 00 17 00 09 05 70 A0
79200: 00 7B 92 69 E6 47 92 12 E6 00 2D 92 E6 E5 BB C2
79210: C2 01 06 05 C0 80 3D 88 93 81 81 01 83 92 00 00
79220: 16 C1 00 80 6A B7 C9 91 BB C2 C2 00 06 06 C0 80
79230: 3D 88 93 81 81 01 83 92 00 00 16 C1 00 80 6A B7
79240: C9 91 BB C2 C2 00 0C 05 D0 80 3D 88 93 81 81 01
79250: 83 92 00 00 16 C1 00 80 6A B7 C9 91 FF FF FF FF
79260: FF BB C2 C2 00 00 00 00 80 0D 8C 83 82 81 01 83
79270: 92 00 00 20 C1 26 80 6A B7 BD 91 16 89 22 89 2E
79280: 89 3A 89 00 00 02 02 02 02 02 02 02 00 00 02 02
79290: 02 02 02 02 02 01 00 02 02 02 02 02 02 02 00 00
792A0: 02 02 02 02 02 02 02 01 01 01 01 01 01 01 01 01
792B0: 13 01 80


Legend
Grey: Data there is we no longer need.

E. We don't need all bytes between last grey byte and first blue byte, so color them in grey too.

Result:
791F0: ?? ?? ?? ?? ?? ?? ?? ?? 00 00 17 00 09 05 70 A0
79200: 00 7B 92 69 E6 47 92 12 E6 00 2D 92 E6 E5 BB C2
79210: C2 01 06 05 C0 80 3D 88 93 81 81 01 83 92 00 00
79220: 16 C1 00 80 6A B7 C9 91 BB C2 C2 00 06 06 C0 80
79230: 3D 88 93 81 81 01 83 92 00 00 16 C1 00 80 6A B7
79240: C9 91 BB C2 C2 00 0C 05 D0 80 3D 88 93 81 81 01
79250: 83 92 00 00 16 C1 00 80 6A B7 C9 91 FF FF FF FF
79260: FF BB C2 C2 00 00 00 00 80 0D 8C 83 82 81 01 83
79270: 92 00 00 20 C1 26 80 6A B7 BD 91 16 89 22 89 2E
79280: 89 3A 89 00 00 02 02 02 02 02 02 02 00 00 02 02
79290: 02 02 02 02 02 01 00 02 02 02 02 02 02 02 00 00
792A0: 02 02 02 02 02 02 02 01 01 01 01 01 01 01 01 01
792B0: 13 01 80


F. As long as we shifted alternative states by 5 bytes, pointers to them should also be changed. Substract 5 (as we're shifted all data by 5 bytes) from all yellow bytes.

Result:
791F0: ?? ?? ?? ?? ?? ?? ?? ?? 00 00 17 00 09 05 70 A0
79200: 00 7B 92 69 E6 42 92 12 E6 00 28 92 E6 E5 BB C2
79210: C2 01 06 05 C0 80 3D 88 93 81 81 01 83 92 00 00
79220: 16 C1 00 80 6A B7 C9 91 BB C2 C2 00 06 06 C0 80
79230: 3D 88 93 81 81 01 83 92 00 00 16 C1 00 80 6A B7
79240: C9 91 BB C2 C2 00 0C 05 D0 80 3D 88 93 81 81 01
79250: 83 92 00 00 16 C1 00 80 6A B7 C9 91 FF FF FF FF
79260: FF BB C2 C2 00 00 00 00 80 0D 8C 83 82 81 01 83
79270: 92 00 00 20 C1 26 80 6A B7 BD 91 16 89 22 89 2E
79280: 89 3A 89 00 00 02 02 02 02 02 02 02 00 00 02 02
79290: 02 02 02 02 02 01 00 02 02 02 02 02 02 02 00 00
792A0: 02 02 02 02 02 02 02 01 01 01 01 01 01 01 01 01
792B0: 13 01 80


10. Write on a paper address of first FF. It's 7925C. Close hex editor.

11. Open SMILE. Choose Edit > Pointers.
Write value "925C" in the "Door Out" field.
Click on button "SAVE" below

12. When SMILE ask you "Copy data or leave it?" choose "YES".
When SMILE ask you again "Also move the pointer data?" choose "YES" as we are want to do it too.

13. If your scroll value is 0000 or 0001, then skip this step.

Look at paper. How many doors are there?
4 doors in our case. Every door will take 2 bytes. 4*2=8.

Value in "Scroll" field will be 925C+8=9265

And don't enter everything backwards!!! Remember: backwards in hex, normally in SMILE.

Click on button "SAVE" below

14. Repeat step 13 for every alternative state. "Door Out" pointer is common for all states. It's value is correct now. Don't change it. Close SMILE.

15. Open ROM at offset 791F8 in hex.

791F0: ?? ?? ?? ?? ?? ?? ?? ?? 00 00 17 00 09 05 70 A0
79200: 00 5C 92 69 E6 42 92 12 E6 00 28 92 E6 E5 BB C2
79210: C2 01 06 05 C0 80 3D 88 93 81 81 01 64 92 00 00
79220: 16 C1 00 80 6A B7 C9 91 BB C2 C2 00 06 06 C0 80
79230: 3D 88 93 81 81 01 64 92 00 00 16 C1 00 80 6A B7
79240: C9 91 BB C2 C2 00 0C 05 D0 80 3D 88 93 81 81 01
79250: 64 92 00 00 16 C1 00 80 6A B7 C9 91 16 89 22 89
79260: 2E 89 3A 89 00 00 02 02 02 02 02 02 02 00 00 02
79270: 02 02 02 02 02 02 01 00 02 02 02 02 02 02 02 00
79280: 00 02 02 02 02 02 02 02 01 01 01 01 01 01 01 01
79290: 01 02 02 02 02 01 00 02 02 02 02 02 02 02 00 00
792A0: 02 02 02 02 02 02 02 01 01 01 01 01 01 01 01 01
792B0: 13 01 80


Note that pink bytes are changed. Some other bytes (scroll pointers) are changed too.

Scroll data starts from 79264 but where it ends? See how many screens are in that room? See at paper. 9*5=45 screens. You've already converted it to the hex. See step 7. It's 2D. Add 2D to 79264. You'll get 79291. Data starting from 79291 is a part of old scroll array. We no longer need this data. What we get in final?

791F0: ?? ?? ?? ?? ?? ?? ?? ?? 00 00 17 00 09 05 70 A0
79200: 00 5C 92 69 E6 42 92 12 E6 00 28 92 E6 E5 BB C2
79210: C2 01 06 05 C0 80 3D 88 93 81 81 01 64 92 00 00
79220: 16 C1 00 80 6A B7 C9 91 BB C2 C2 00 06 06 C0 80
79230: 3D 88 93 81 81 01 64 92 00 00 16 C1 00 80 6A B7
79240: C9 91 BB C2 C2 00 0C 05 D0 80 3D 88 93 81 81 01
79250: 64 92 00 00 16 C1 00 80 6A B7 C9 91 16 89 22 89
79260: 2E 89 3A 89 00 00 02 02 02 02 02 02 02 00 00 02
79270: 02 02 02 02 02 02 01 00 02 02 02 02 02 02 02 00
79280: 00 02 02 02 02 02 02 02 01 01 01 01 01 01 01 01
79290: 01 02 02 02 02 01 00 02 02 02 02 02 02 02 00 00
792A0: 02 02 02 02 02 02 02 01 01 01 01 01 01 01 01 01
792B0: 13 01 80


16. Now you can use data between orange bytes and brown bytes to something else. I recommend to write FF's there.

Final result.

791F0: ?? ?? ?? ?? ?? ?? ?? ?? 00 00 17 00 09 05 70 A0
79200: 00 5C 92 69 E6 42 92 12 E6 00 28 92 E6 E5 BB C2
79210: C2 01 06 05 C0 80 3D 88 93 81 81 01 64 92 00 00
79220: 16 C1 00 80 6A B7 C9 91 BB C2 C2 00 06 06 C0 80
79230: 3D 88 93 81 81 01 64 92 00 00 16 C1 00 80 6A B7
79240: C9 91 BB C2 C2 00 0C 05 D0 80 3D 88 93 81 81 01
79250: 64 92 00 00 16 C1 00 80 6A B7 C9 91 16 89 22 89
79260: 2E 89 3A 89 00 00 02 02 02 02 02 02 02 00 00 02
79270: 02 02 02 02 02 02 01 00 02 02 02 02 02 02 02 00
79280: 00 02 02 02 02 02 02 02 01 01 01 01 01 01 01 01
79290: 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
792A0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
792B0: 13 01 80


Store there a few door arrays, scrolling data or PLMs. Just don't overwrite brown bytes. If you'll remove 2 alternative states, there'll even be a place for new room.





Ib. REMOVING ALL ALTERNATE STATES


A. Open ROM in hex at 791F8.

We'll need to:
B. Remove the pointer to alternative state.
To do so, get rid of data between 7E203 and 7E210, marked with the color gray

Result:
791F0: ?? ?? ?? ?? ?? ?? ?? ?? 00 00 17 00 09 05 70 A0
79200: 00 7B 92 12 E6 0E 61 92 69 E6 47 92 12 E6 00 2D
79210: 92 E6 E5 BB C2 C2 01 06 05 C0 80 3D 88 93 81 81
79220: 01 83 92 00 00 16 C1 00 80 6A B7 C9 91 BB C2 C2
79230: 00 06 06 C0 80 3D 88 93 81 81 01 83 92 00 00 16
79240: C1 00 80 6A B7 C9 91 BB C2 C2 00 0C 05 D0 80 3D
79250: 88 93 81 81 01 83 92 00 00 16 C1 00 80 6A B7 C9
79260: 91 BB C2 C2 00 00 00 00 80 0D 8C 83 82 81 01 83
79270: 92 00 00 20 C1 26 80 6A B7 BD 91 16 89 22 89 2E
79280: 89 3A 89 00 00 02 02 02 02 02 02 02 00 00 02 02
79290: 02 02 02 02 02 01 00 02 02 02 02 02 02 02 00 00
792A0: 02 02 02 02 02 02 02 01 01 01 01 01 01 01 01 01
792B0: 13 01 80


Grey: Data there is we no longer need.

C. Shift all data from 7E211 to 7E204. Stop right before next red bytes.

D. Fill 14 (dec) bytes before second red bytes with FF's as we are shifted everything by 14 (dec) bytes.

Result:
791F0: ?? ?? ?? ?? ?? ?? ?? ?? 00 00 17 00 09 05 70 A0
79200: 00 7B 92 E6 E5 BB C2 C2 01 06 05 C0 80 3D 88 93
79210: 81 81 01 83 92 00 00 16 C1 00 80 6A B7 C9 91 FF
79220: FF FF FF FF FF FF FF FF FF FF FF FF FF BB C2 C2
79230: 00 06 06 C0 80 3D 88 93 81 81 01 83 92 00 00 16
79240: C1 00 80 6A B7 C9 91 BB C2 C2 00 0C 05 D0 80 3D
79250: 88 93 81 81 01 83 92 00 00 16 C1 00 80 6A B7 C9
79260: 91 BB C2 C2 00 00 00 00 80 0D 8C 83 82 81 01 83
79270: 92 00 00 20 C1 26 80 6A B7 BD 91 16 89 22 89 2E
79280: 89 3A 89 00 00 02 02 02 02 02 02 02 00 00 02 02
79290: 02 02 02 02 02 01 00 02 02 02 02 02 02 02 00 00
792A0: 02 02 02 02 02 02 02 01 01 01 01 01 01 01 01 01
792B0: 13 01 80


E. We don't need all bytes between last grey byte and first blue byte, so color them in grey too.

Result:
791F0: ?? ?? ?? ?? ?? ?? ?? ?? 00 00 17 00 09 05 70 A0
79200: 00 7B 92 E6 E5 BB C2 C2 01 06 05 C0 80 3D 88 93
79210: 81 81 01 83 92 00 00 16 C1 00 80 6A B7 C9 91 FF
79220: FF FF FF FF FF FF FF FF FF FF FF FF FF BB C2 C2
79230: 00 06 06 C0 80 3D 88 93 81 81 01 83 92 00 00 16
79240: C1 00 80 6A B7 C9 91 BB C2 C2 00 0C 05 D0 80 3D
79250: 88 93 81 81 01 83 92 00 00 16 C1 00 80 6A B7 C9
79260: 91 BB C2 C2 00 00 00 00 80 0D 8C 83 82 81 01 83
79270: 92 00 00 20 C1 26 80 6A B7 BD 91 16 89 22 89 2E
79280: 89 3A 89 00 00 02 02 02 02 02 02 02 00 00 02 02
79290: 02 02 02 02 02 01 00 02 02 02 02 02 02 02 00 00
792A0: 02 02 02 02 02 02 02 01 01 01 01 01 01 01 01 01
792B0: 13 01 80


F. Write on a paper address of first FF. It's 7921F. Close hex editor.

10. Open SMILE. Choose Edit > Pointers.
Write value "921F" in the "Door Out" field. Don't press buttons below yet.
Click on button "SAVE" below

11. When SMILE ask you "Copy data or leave it?" choose "YES".
When SMILE ask you again "Also move the pointer data?" choose "YES" as we are want to do it too.

12. If your scroll value is 0000 or 0001, then skip this step.

Look at paper. How many doors are there?
4 doors in our case. Every door will take 2 bytes. 4*2=8.

Value in "Scroll" field will be 921F+8=9227

And don't enter everything backwards!!! Remember: backwards in hex, normally in SMILE.

Click on button "SAVE" below.

13. Open ROM at offset 791F8 in hex.

Result:
791F0: ?? ?? ?? ?? ?? ?? ?? ?? 00 00 17 00 09 05 70 A0
79200: 00 1F 92 E6 E5 BB C2 C2 01 06 05 C0 80 3D 88 93
79210: 81 81 01 27 92 00 00 16 C1 00 80 6A B7 C9 91 16
79220: 89 22 89 2E 89 3A 89 00 00 02 02 02 02 02 02 02
79230: 00 00 02 02 02 02 02 02 02 01 00 02 02 02 02 02
79240: 02 02 00 00 02 02 02 02 02 02 02 01 01 01 01 01
79250: 01 01 01 01 01 83 92 00 00 16 C1 00 80 6A B7 C9
79260: 91 BB C2 C2 00 00 00 00 80 0D 8C 83 82 81 01 83
79270: 92 00 00 20 C1 26 80 6A B7 BD 91 16 89 22 89 2E
79280: 89 3A 89 00 00 02 02 02 02 02 02 02 00 00 02 02
79290: 02 02 02 02 02 01 00 02 02 02 02 02 02 02 00 00
792A0: 02 02 02 02 02 02 02 01 01 01 01 01 01 01 01 01
792B0: 13 01 80


Note that pink bytes are changed. Some other bytes (scroll pointers) are changed too.

14. We're removed so many data that Door Out array and Scroll array are doubled by now. Actually, we don't need second blue bytes and second orange bytes. Let's color them in grey.

Result:
791F0: ?? ?? ?? ?? ?? ?? ?? ?? 00 00 17 00 09 05 70 A0
79200: 00 1F 92 E6 E5 BB C2 C2 01 06 05 C0 80 3D 88 93
79210: 81 81 01 27 92 00 00 16 C1 00 80 6A B7 C9 91 16
79220: 89 22 89 2E 89 3A 89 00 00 02 02 02 02 02 02 02
79230: 00 00 02 02 02 02 02 02 02 01 00 02 02 02 02 02
79240: 02 02 00 00 02 02 02 02 02 02 02 01 01 01 01 01
79250: 01 01 01 01 01 83 92 00 00 16 C1 00 80 6A B7 C9
79260: 91 BB C2 C2 00 00 00 00 80 0D 8C 83 82 81 01 83
79270: 92 00 00 20 C1 26 80 6A B7 BD 91 16 89 22 89 2E
79280: 89 3A 89 00 00 02 02 02 02 02 02 02 00 00 02 02
79290: 02 02 02 02 02 01 00 02 02 02 02 02 02 02 00 00
792A0: 02 02 02 02 02 02 02 01 01 01 01 01 01 01 01 01
792B0: 13 01 80


15. Now you can use data between orange bytes and brown bytes to something else. I recommend to write FF's there.

Final result.
791F0: ?? ?? ?? ?? ?? ?? ?? ?? 00 00 17 00 09 05 70 A0
79200: 00 1F 92 E6 E5 BB C2 C2 01 06 05 C0 80 3D 88 93
79210: 81 81 01 27 92 00 00 16 C1 00 80 6A B7 C9 91 16
79220: 89 22 89 2E 89 3A 89 00 00 02 02 02 02 02 02 02
79230: 00 00 02 02 02 02 02 02 02 01 00 02 02 02 02 02
79240: 02 02 00 00 02 02 02 02 02 02 02 01 01 01 01 01
79250: 01 01 01 01 FF FF FF FF FF FF FF FF FF FF FF FF
79260: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
79270: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
79280: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
79290: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
792A0: FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
792B0: 13 01 80


Free space of FF's can be used for doors, scrolling data special scrolling data (PLM linking to that) or PLM's. You can even create 2 more rooms using free space at 79254!





II. ADDING AN EXTRA STATE


If you've read and understood part I, then you're ready to add new states.

Please note that adding new states requieres adding bytes to room header and relocating some of the list: Door Array, Scroll array, Special Scrolling data. To add new state you'll need a minimum 4 bytes of space. It means that not every room can handle extra state without moving next room.

Remember this:
If room have 2 doors, standart scroll value and no Scroll PLM, then you can add only item-based states.*

If room have at least 3 doors, or at least 2 doors with non-standart scroll value, or 1 door with at least 1 Scroll PLM then you can add item-based stated and event-based states (E612 and E629) to your room as far as event-based states are using 5 bytes instead of 4.

If your room have only 1 door, with no Scroll PLM, it's it easier to create new room with extra state than add extra state to this room.

* Actually, you can add event-based and boss-based events in this case, but you'll need to overwrite the first byte of next room's header (Room Index in SMILE). If you aren't using any patches using Room Index, you are free to do this.

1. Select a room that needs an extra state. 793FE is a good example to explain.

2. Open room 793FE in SMILE. Choose Edit > Pointers to call pointers window. Write on a paper pointers for Door Out, Level Data and Scroll. If scroll is 0000 or 0001, don't write it. In this case, there is no scrolling data for each screen in mdb. All screens are blue or green. In our case, Door Out pointer is 9425, Scroll pointer is 9431 and Level Data pointer is C2EB45.

Also, remember, how many doors in there. Move cursor to any door and press "D" to call Door Editor. In right part will be several doors listed as Door $00, Door $01 etc. Look at the last door. It's the Door $05. Add 1 in mind to count Door $00 and you'll get 6 doors in the room. Write on paper: "6 doors". If there are just a pair of doors, then you can easy count them by yourself.

3. Close pointer window. Choose Edit > Room Properties in SMILE. Write on paper room's size. Quit SMILE

4. Let's open room 793FE in hex; the byte @ 793FE (05) is underlined like before, located $0E bytes right of 793F0.

793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 25 94 E6 E5 45 EB C2 00 0C
79410: 05 12 81 84 86 61 81 81 01 31 94 00 00 00 00 DC
79420: 81 AE B7 CE 91 CA 89 D6 89 E2 89 EE 89 FA 89 06
79430: 8A 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
79440: 02 02 02 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Next room is 79461, so the last byte we're interested in is 79460

5. Let's color it a bit.

See the values on a paper. Door Out pointer is 9425 and Scroll pointer is 9431. Door Out pointer is always located at 9 bytes from begining of mdb data. Everything is written backwards in hex. 9425 is written as 25 94.

There is a small door array at 9425. Each door pointer have size of 2 bytes. How many doors are in that room? 6 doors. So door array have size of 2*6 bytes, starts at 79425 and ends at 79430.

793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 25 94 E6 E5 45 EB C2 00 0C
79410: 05 12 81 84 86 61 81 81 01 31 94 00 00 00 00 DC
79420: 81 AE B7 CE 91 CA 89 D6 89 E2 89 EE 89 FA 89 06
79430: 8A 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
79440: 02 02 02 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Legend.

Green: offset from start of ROM
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Blue: door array pointer.
??: data from other place. Don't touch it.

6. Let's color Scroll data. See at paper, Scroll data starts from 79431 but where it ends? See room dimensions on paper. Each screen in scroll data takes 1 byte. In our case, Width is 8, Height is 6. 8*6=48 screens in total. Convert 48 in hex. You'll get 30. Add 30 to 79431. You'll get 79461. Exactly where next room's mdb starts. So, this room hasn't special scrolling data.

If there is a gap between place where scroll data ends and next room's mdb, then there is Special Scrolling Data.

793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 25 94 E6 E5 45 EB C2 00 0C
79410: 05 12 81 84 86 61 81 81 01 31 94 00 00 00 00 DC
79420: 81 AE B7 CE 91 CA 89 D6 89 E2 89 EE 89 FA 89 06
79430: 8A 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
79440: 02 02 02 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Legend.

Green: offset from start of ROM
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Orange: scroll array. 1 byte for every screen of room. It starts from upper-left corner of room.
Blue: door array pointer
Brown: special scrolling data. Scrolling PLMs are points to this.
??: data from other place. Don't touch it.

7. Now, let's color Level Data in red. See at paper. C2EB45. Write it backwards. You'll get 45 EB C2. Search these bytes in your mdb. They are at 7940B.

Original state will always be after "E6 E5" bytes. Alternative states will always have a pointer. All bytes after pink ones and before red ones are used for alternative states.

We have no alternate pointer, so E6 E5 bytes will be placed right after Door Out pointer and before Level Data pointer, like this: [Door Out] E6 E5 [Level Data]

793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 25 94 E6 E5 45 EB C2 00 0C
79410: 05 12 81 84 86 61 81 81 01 31 94 00 00 00 00 DC
79420: 81 AE B7 CE 91 CA 89 D6 89 E2 89 EE 89 FA 89 06
79430: 8A 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
79440: 02 02 02 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Legend.

Green: offset from start of ROM
Red: pointer for level data
Yellow: pointer for pointer in bank 8F for level data
Aqua: alternative state. It shows what should happen for room to change.
Purple: extra value for alternative state.
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Orange: scroll array. 1 byte for every screen of room. It starts from upper-left corner of room.
Blue: door array pointer.
Brown: special scrolling data. Scrolling PLMs are points to this.
??: data from other place. Don't touch it.

8. Let's decide what state should there be. I.e., what should happens to change the room.

Room may change itself after killing certain boss. In this case, we should use instruction E629 with extra byte as argument and pointer to new state.

Room may change itself after certain event is happen. Already programmed events are "Zebes are awake", "Maridian tube broken", "Chozo has lowered lava" etc. You can see full list of used events in SMILE. In this case, we should use instruction E612 with extra byte as argument and pointer to new state.

Room may change itself after player obtains a certain item or items. There are already programmed check for some items, such as:
E640 Morphing Ball
E652 Morphing Ball & Missiles (any)
E669 Power Bombs (any)
E676 Speed Booster
In this case, we should use instruction depending of desirable check and pointer to new state.

SMALL NOTE:
I've made 2 patches. One of them (FF events & multiple tubes) can set extra events to use as extra states. There'll be a 256 in total use including 22 already used. Another one (Item-related events v.2) includes checks for all items and beams that player have and also checks for any amount of health (regular or reserve, current or max) and checks for any amount of any type of ammo.

I hope this guide will help to use these patches at full power.

9. Check how many space to insert extra state we have. We can push blue or orange bytes to any place in bank $8F to free up space in header of this room. We have:
2*6 + 6*8 + Brown = 12 + 48 + 0 = 60
60 > 30 [way 1 is fully accepted]
60 > 4 [way 2 is fully accepted] (if = 4, only item-based events can be add without overwriting anything.)

Looks like, we have a lot of space. So, we have 2 ways to creating extra state.

Each way have it's own advantages and lacks.





IIa. PLACING EXTRA STATE OUTSIDE OF ROOM HEADER


In short, we need to insert alternative state instruction, alternative state argument (only for event-related and boss-related states) and alternative state pointer between pink bytes and E6 E5. As far as our data will be shifted, we need to relocate blue bytes or/and orange bytes, sometimes brown bytes.

The advantages are:
Yon need only 4 (5) bytes to add an extra state. That means you can do so in almost any room with 2 doors or more.

And the lacks are:
You can forget location of your new state.
It's not so obvious.
It's more harder.

A. For example, we want to add an extra state depending on Kraid statue. Our instruction will be E612 (events) with extra byte as argument. 2 more bytes are used for pointer, 5 in total. We need to place them between pink and first aqua bytes (E6 E5). To do so we need to shift one data and relocate another.

B. Open your room in hex one more time.

793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 25 94 E6 E5 45 EB C2 00 0C
79410: 05 12 81 84 86 61 81 81 01 31 94 00 00 00 00 DC
79420: 81 AE B7 CE 91 CA 89 D6 89 E2 89 EE 89 FA 89 06
79430: 8A 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
79440: 02 02 02 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Legend.

Green: offset from start of ROM
Red: pointer for level data
Yellow: pointer for pointer in bank 8F for level data
Aqua: alternative state. It shows what should happen for room to change.
Purple: extra value for alternative state.
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Orange: scroll array. 1 byte for every screen of room. It starts from upper-left corner of room.
Blue: door array pointer.
Brown: special scrolling data. Scrolling PLMs are points to this.
??: data from other place. Don't touch it.

We have blue and orange bytes in this room. Both of them can be relocated easily with SMILE, but for now relocating of blue bytes will be enough. Remember the count of blue bytes. 12 in this case.

C. Find a free space in the end of bank $8F. Just scroll down in hex editor until you see a lot of FF's. For clean unheadered ROM they should start at 7E99A. 7E9A0 is ok to start. Write on paper: E9A0 -- new door array, 12 bytes. Close hex editor.

D. Open SMILE. Load your room. Choose Edit > Pointers.
Change value in the Door_Out field from "9425" to "E9A0".
Click on button "SAVE" below.

E. When SMILE ask you "Copy data or leave it?" choose "YES".
When SMILE ask you again "Also move the pointer data?" choose "YES" as we are want to do it too. Close SMILE.

If you want to add or remove door, it is a perfect time to do it now. If you don't want to do this, read section IIaa. If you want to, read section IIab.





IIaa. PLACING EXTRA STATE OUTSIDE OF ROOM HEADER, WITHOUT ADDING A DOOR


F. Open hex editor. Look at paper. Where are new location of our door array? At E9A0. Jump in there in hex:

7E9A0: CA 89 D6 89 E2 89 EE 89 FA 89 06 8A 00 00 FF FF

Where is a location of first byte after 00 00 bytes? It is at 7E9AE.
Write on paper: new state at 7E9AE.

10. Jump to location of your room (793FE).

793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 A0 E9 E6 E5 45 EB C2 00 0C
79410: 05 12 81 84 86 61 81 81 01 31 94 00 00 00 00 DC
79420: 81 AE B7 CE 91 CA 89 D6 89 E2 89 EE 89 FA 89 06
79430: 8A 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
79440: 02 02 02 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Write at paper 26 bytes just after E6 E5, starting from red-colored bytes. Or you just can take a screenshot. Press Print Screen button, open Paint (or any other graphic editor) and press Ctrl+V to paste scrrenshot into image. Save it somewhere, it will need later.

11. Where are new state located? At 7E9AE. Jump there.

Write 26 bytes that you wrote at paper at 7E9AE, just after 00 00 bytes.

Result:
7E9A0: CA 89 D6 89 E2 89 EE 89 FA 89 06 8A 00 00 45 EB
7E9B0: C2 00 0C 05 12 81 84 86 61 81 81 01 31 94 00 00
7E9C0: 00 00 DC 81 AE B7 CE 91


Legend.

Green: offset from start of ROM
Red: pointer for level data
Blue: door array pointer.

12. We have wrote the new state itself. Now we should add bytes to make the game correctly linking to it. Jump to 793FE.

793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 A0 E9 E6 E5 45 EB C2 00 0C
79410: 05 12 81 84 86 61 81 81 01 31 94 00 00 00 00 DC
79420: 81 AE B7 CE 91 CA 89 D6 89 E2 89 EE 89 FA 89 06
79430: 8A 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
79440: 02 02 02 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Legend.

Green: offset from start of ROM
Red: pointer for level data
Yellow: pointer for pointer in bank 8F for level data
Aqua: alternative state. It shows what should happen for room to change.
Purple: extra value for alternative state.
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Orange: scroll array. 1 byte for every screen of room. It starts from upper-left corner of room.
Blue: door array pointer.
Brown: special scrolling data. Scrolling PLMs are points to this.
Gray: Data that we no longer need.
??: data from other place. Don't touch it.

Note that pink bytes are changed and it points to 7E9A0, and because of that bytes at 79425 is no longer blue-colored (if you are reading this carefully, then you may noticed this at step 10). You can freely modify them.

Now we should insert alternative state instruction, alternative state argument (optional) and alternative state pointer to get link to new data.

At step A we decided to make an extra state depending on Kraid statue. Our instruction will be E612 (events) with extra byte as argument. 2 more bytes are used for pointer, 5 in total. We need to place them between pink and first aqua bytes (E6 E5).

Blue bytes are relocated, so we can rewrite old blue bytes, which are colored in grey now. Shift 26 bytes after E6 E5 by 5 bytes to the right. You simply can use screenshot you made earlier (at step 15) or if you wrote state at paper, read this data from paper. Shift E6 E5 to the right too.

Result:
793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 A0 E9 E6 E5 45 EB C2 E6 E5
79410: 45 EB C2 00 0C 05 12 81 84 86 61 81 81 01 31 94
79420: 00 00 00 00 DC 81 AE B7 CE 91 89 EE 89 FA 89 06
79430: 8A 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
79440: 02 02 02 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Legend.

Green: offset from start of ROM
Red: pointer for level data
Yellow: pointer for pointer in bank 8F for level data
Aqua: alternative state. It shows what should happen for room to change.
Purple: extra value for alternative state.
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Orange: scroll array. 1 byte for every screen of room. It starts from upper-left corner of room.
Blue: door array pointer.
Brown: special scrolling data. Scrolling PLMs are points to this.
Gray: Data that we no longer need.
??: data from other place. Don't touch it.

13. Let's add an extra state instruction in our room. Find first byte after pink bytes. It will be 79409. Write alternative state instruction there. In our case, instruction is E612 (event-based). Write these 2 bytes at 79409: 12 E6 (instruction written backwards). If you want to add instruction E629 (boss-based), write 29 E6.

Now it's turn to alternative state argument as far as we're adding instructions E612 or E629. What number should we add to make new state react to Kraid statue? Well, just write 00 as next byte. You can easily change that in SMILE.

And finally, we need to add pointer to new state. Where are a new state? Look at paper. It's at E9AE. Write these bytes then: AE E9.

Result:
793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 A0 E9 12 E6 00 AE E9 E6 E5
79410: 45 EB C2 00 0C 05 12 81 84 86 61 81 81 01 31 94
79420: 00 00 00 00 DC 81 AE B7 CE 91 89 EE 89 FA 89 06
79430: 8A 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
79440: 02 02 02 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Legend.

Green: offset from start of ROM
Red: pointer for level data
Yellow: pointer for pointer in bank 8F for level data
Aqua: alternative state. It shows what should happen for room to change.
Purple: extra value for alternative state.
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Orange: scroll array. 1 byte for every screen of room. It starts from upper-left corner of room.
Blue: door array pointer.
Brown: special scrolling data. Scrolling PLMs are points to this.
Gray: Data that we no longer need.
??: data from other place. Don't touch it.

What we get by now. When you load this room, the game will check instruction E612 (aqua bytes) with argument 00 (purple bytes), is event 00 happened or not.

If yes, jump to address written by yellow bytes and read 26 bytes there.

If no, read next. There are these bytes E6 E5 (instruction E5E6 for standart state). If the game get there, it will read the next 26 bytes after E6 E5.

14. We have a few unused grey bytes left. Let's mark them somehow, to make sure in future that this data is unused. Replace all grey bytes with FF's.

Result:
793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 A0 E9 12 E6 00 AE E9 E6 E5
79410: 45 EB C2 00 0C 05 12 81 84 86 61 81 81 01 31 94
79420: 00 00 00 00 DC 81 AE B7 CE 91 FF FF FF FF FF FF
79430: FF 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
79440: 02 02 02 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Legend.

Green: offset from start of ROM
Red: pointer for level data
Yellow: pointer for pointer in bank 8F for level data
Aqua: alternative state. It shows what should happen for room to change.
Purple: extra value for alternative state.
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Orange: scroll array. 1 byte for every screen of room. It starts from upper-left corner of room.
Blue: door array pointer.
Brown: special scrolling data. Scrolling PLMs are points to this.
Gray: Data that we no longer need.
??: data from other place. Don't touch it.

Close hex editor.

15. Open SMILE. Choose your room. If you done everything right, the second combo box becomes green and you can select and edit alternative state. All we need is to set correct event to trigger changes in our room.

Click the second combo box (to the right from room address) and select "Events 1". Room will reload. When it's done, click Edit > State Properties. Choose "Kraid statue grey" as we decided to do so. Click "OK". Save room.

IMPORTANT NOTE
You may notice that there are a lot of unmarked events (16?), (17?) etc. You can use them as extra states too, if you'll make the game to set it somehow. There are 256 events in total. If you want to use new events, download my patch "FF events and multiple tubes" from Patch section.

16. Last linear step. It's time to decide what should happens after certain event (Kraid statue grey in our case) will happened. It can be a lot of things:

Replace enemies in the room (example: all Mocktroids turns into Metroids);
Add enemies in the room (example: enemy population will grow);
Delete all enemies from the room (example: Metroids will not respawn after killing all of them in this room);

Replace PLMs in the room (example: always closed grey door will replaced by orange door);
Add PLMs in the room (example: add hidden item or weapon expansion);
Delete all PLMs from the room (example: get rid of grey gates blocking path);

Change music in the room (example: after Zebes is awake music will change);

Change layout of the room (example: remove blocks blocking a new path, add/remove spikes etc.);

Add liquid to the room;
Remove liquid from the room (example: removing water allows player to go further without Gravity Suit);
Change liquid levels (example: lowering lava level allows player to speed up and brake speed booster blocks in certain places);
Allow liquid to rise/drop after player enters the room;
Change weather (example: replace rain with fog);

Change brightness level (example: turn on the light);

Change background;

All next steps will depends on what you change right now. And don't forget to clone data you want to change (read: level data, PLMs, enemies etc.).

17'. Let it be simple music change and enemy removing in single room.

Open your room.
Select alternative state (Events 1).
Click "Other" button.

If you want to set elevator music, change value in second ComboBox to 03. Changing value in first ComboBox isn't nessasary then.
If you want to set "Empty Zebes without thunder" effect, change value is first ComboBox to 06 and value in second ComboBox to 07.

Save your room.

18'. Now it's time to get rid of enemies. Don't forget, ComboBox to the right of room must show "Events 1", not "Standart 1", or you will make changes in default state.

By default, there are 07 enemies in this room. If there isn't a grey door in this room that will opens after all enemies is killed, then you can save 3 bytes in bank $A1.

That's how enemies are stored there:
[enemy 1] -- 16 bytes
[enemy 2] -- 16 bytes
...
[enemy 7] -- 16 bytes
[FF FF] -- terminator
[07] -- enemies to clean room

We can simply points to FF FF to get desirable effect.

Open pointers window. Look at Enemy Pop/Allowed field. Value there is 8684.

Each enemy uses 16 ($10 in hex) bytes.

10*7=70

8684+70=86F4

Enter this value to Enemy Pop field and click "SAVE".

19'. When SMILE ask you "Copy data or leave it?" choose "NO". We don't want to affect enemies in default state.

Using this method you can place common enemies in both states and extra enemies in one of states (standart or alternate). It's useful when some enemies in both state have the same paramaters (speed, position etc.)

If you want to left 1 enemy in both states and 6 other enemies in standart state, value in standart state should be 8684 and in alternative state:
10*6=60 (6 enemies removed)
8684+60=86E4

If you want the opposite (6 enemies in alternative state and 1 common enemy), value in alternative state will be 8684, and in standart state: 86E4.

20'. Let's start from Level Data. Open "smile/files" folder. Find a file level_entries.txt. Open it.

We are about to add a new bank to the end of the ROM. Add 2 lines: 300000 and 308000.

Save and exit.

21'. Open SMILE.

Click Tools > Expand ROM.

We have just added a bank to the end of the ROM where we can store data. New bank is $E0. Level Data will be stored there.

21'. Select your room. Choose alternative state. Open pointers window.

Replace value in the Level Data field with E08000. Click "SAVE".

22'. When SMILE ask you "Copy data or leave it?" choose "YES". Level Data from old address (C2EB45) will be copied to the new address (E08000).

Save your room. Now you can freely edit level layout in the alternative state of your room.

When you save your room everytime, you'll see in the header of SMILE something like this: 3567/32768.

23'. When you room will be finished, remember a first number, increase it a bit and set limit to this room. If your room uses 3810 bytes, something like 4000 should be enough. We are leaving a small gap in case if we want to change something in this room later.

Convert 4000 to hex. Windows calculator is good for this. You'll get FA0.

Add FA0 to starting room address. 300000 + FA0 = 300FA0

24'. Open file level_entries.txt in "smile/files" folder. Add your limitation address to the text file between 300000 and 308000.

Save and close text file.

Now when you'll edit an alternative state of your room, you'll see something like this: 3810/4000.

The address you've added will be an address for next room (if you will repoint any room in future).

25'. Time to place enemies.
Select your room. Choose alternative state. Open pointers window.

Replace value in the "Enemy Pop" field with vaule of new enemy pointer (EBD1).

Replace value in the "Enemy Set" field with vaule of allowed list (F4B8).

Click "SAVE". Close pointers window. Save your room.

26'. Correct enemy pointers are set. Now it's time to add enemies.

Open Edit > Special > Enemy/PLM +/- menu. Set any desirable amount of enemies. Click "SAVE".

27'. Select Help > Offscreen Enemies to Screen option.

In upper-left corner a few knights from Zelda should appear. Click on each of them and select desired enemy from the list.

28'. When adding a new type of enemies to the room, double click to each one of them to add all of them to the allowed list.

You are limited to have 4 different types of enemies in single room.

29'. Set correct palette values to the enemy allowed list. Correct values are 0001, 0002, 0003, 0007. Setting different values for certain enemy will cause palette change for this enemy or for something else.

If set 0000, enemy with this palette value will be displayed correctly, but hurt flash in this room (when you are damaging enemy) will use palette of this enemy. Sound cool enough, but this also affects flash color of ammo pickups which is not so cool.

If 2 enemies is the list are using the same palette values, upper one in the list will use palette of lower one in the list.

This trick allows to re-color some enemies to make them look differently in some rooms.

If you want example, open allowed list in the room 7ACB3 of the clean room to see what makes Catacac (Saboten) to have an orange color, and what makes Waver to have a red color.

2A'. Now it's up to you to place enemies in certain location of the room.





IIab. PLACING EXTRA STATE OUTSIDE OF ROOM HEADER, WHILE ADDING A DOOR


F. For example, we want to add 1 more door.

10. Let's find a space for new door. Door_Out is points to door pointer array (bank $8F), in which every word is a pointer to address is bank $83. So, the door data itself is in bank $83.

11. Open hex editor. Go to 18000 and search for a lot of FF's.
For clean unheadered ROM they should start at 1AD66. Gaps between doors isn't nessesary, but let 1AD68 will be a first new door.

Each door uses 12 (C in hex) bytes. Write on paper or remember this: new door at 1AD66
Next new door (if you'll add more than one) will be at 1AD66 + C = 1AD72.
Next one: 1AD72 + C = 1AD7E
Next one: 1AD7E + C = 1AD8A
Next one: 1AD8A + C = 1AD96 etc.)

Don't write anything there, just remember the address (or addresses)

12. Look at paper. Where are new location of our door array? At E9A0. Jump to there in hex:

7E9A0: CA 89 D6 89 E2 89 EE 89 FA 89 06 8A 00 00 FF FF

00 00 is an ending mark of array. Don't touch this yet.

13. Look at paper. Where are will be a new door? At 1AD66. Shift 00 00 to the right and write address of new door there. Use only last 2 byte and write them a vise versa:

7E9A0: CA 89 D6 89 E2 89 EE 89 FA 89 06 8A 66 AD 00 00

Congratulations! New door is successfully added. It's destination and other data you can set in SMILE. There was 6 doors, and now will be 7. Door $06 should appears in the list of the doors when editing your room.

14. Zeroes after door array are shifted.
Where is a location of first byte after 00 00 bytes? It is at 7E9B0.
Write on paper: new state at 7E9B0.

15. Jump to location of your room (793FE).

793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 A0 E9 E6 E5 45 EB C2 00 0C
79410: 05 12 81 84 86 61 81 81 01 31 94 00 00 00 00 DC
79420: 81 AE B7 CE 91 CA 89 D6 89 E2 89 EE 89 FA 89 06
79430: 8A 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
79440: 02 02 02 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Write at paper 26 bytes just after E6 E5, starting from red-colored bytes. Or you just can take a screenshot. Press Print Screen button, open Paint (or any other graphic editor) and press Ctrl+V to paste scrrenshot into image. Save it somewhere, it will need later.

16. Where are new state located? At 7E9B0. Jump there.

Write 26 bytes that you wrote at paper at 7E9B0, just after 00 00 bytes.

Result:
7E9A0: CA 89 D6 89 E2 89 EE 89 FA 89 06 8A 66 AD 00 00
7E9B0: 45 EB C2 00 0C 05 12 81 84 86 61 81 81 01 31 94
7E9C0: 00 00 00 00 DC 81 AE B7 CE 91


Legend.

Green: offset from start of ROM
Red: pointer for level data
Blue: door array pointer.

17. We have wrote the new state itself. Now we should add bytes to make the game correctly linking to it. Jump to 793FE.

793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 A0 E9 E6 E5 45 EB C2 00 0C
79410: 05 12 81 84 86 61 81 81 01 31 94 00 00 00 00 DC
79420: 81 AE B7 CE 91 CA 89 D6 89 E2 89 EE 89 FA 89 06
79430: 8A 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
79440: 02 02 02 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Legend.

Green: offset from start of ROM
Red: pointer for level data
Yellow: pointer for pointer in bank 8F for level data
Aqua: alternative state. It shows what should happen for room to change.
Purple: extra value for alternative state.
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Orange: scroll array. 1 byte for every screen of room. It starts from upper-left corner of room.
Blue: door array pointer.
Brown: special scrolling data. Scrolling PLMs are points to this.
Gray: Data that we no longer need.
??: data from other place. Don't touch it.

Note that pink bytes are changed and it points to 7E9A0, and because of that bytes at 79425 is no longer blue-colored (if you are reading this carefully, then you may noticed it at step 15). You can freely modify them.

Now we should insert alternative state instruction, alternative state argument (optional) and alternative state pointer to get link to new data.

At step A we decided to make an extra state depending on Kraid statue. Our instruction will be E612 (events) with extra byte as argument. 2 more bytes are used for pointer, 5 in total. We need to place them between pink and first aqua bytes (E6 E5).

Blue bytes are relocated, so we can rewrite old blue bytes, which are colored in grey now. Shift 26 bytes after E6 E5 by 5 bytes to the right. You simply can use screenshot you made earlier (at step 15) or if you wrote state at paper, read this data from paper. Shift E6 E5 to the right too.

Result:
793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 A0 E9 E6 E5 45 EB C2 E6 E5
79410: 45 EB C2 00 0C 05 12 81 84 86 61 81 81 01 31 94
79420: 00 00 00 00 DC 81 AE B7 CE 91 89 EE 89 FA 89 06
79430: 8A 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
79440: 02 02 02 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Legend.

Green: offset from start of ROM
Red: pointer for level data
Yellow: pointer for pointer in bank 8F for level data
Aqua: alternative state. It shows what should happen for room to change.
Purple: extra value for alternative state.
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Orange: scroll array. 1 byte for every screen of room. It starts from upper-left corner of room.
Blue: door array pointer.
Brown: special scrolling data. Scrolling PLMs are points to this.
Gray: Data that we no longer need.
??: data from other place. Don't touch it.

18. Let's add an extra state instruction in our room. Find first byte after pink bytes. It will be 79409. Write alternative state instruction there. In our case, instruction is E612 (event-based). Write these 2 bytes at 79409: 12 E6 (instruction written backwards). If you want to add instruction E629 (boss-based), write 29 E6.

Now it's turn to alternative state argument as far as we're adding instructions E612 or E629. What number should we add to make new state react to Kraid statue? Well, just write 00 as next byte. You can easily change that in SMILE.

And finally, we need to add pointer to new state. Where are a new state? Look at paper. It's at E9B0. Write these bytes then: B0 E9.

Result:
793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 A0 E9 12 E6 00 B0 E9 E6 E5
79410: 45 EB C2 00 0C 05 12 81 84 86 61 81 81 01 31 94
79420: 00 00 00 00 DC 81 AE B7 CE 91 89 EE 89 FA 89 06
79430: 8A 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
79440: 02 02 02 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Legend.

Green: offset from start of ROM
Red: pointer for level data
Yellow: pointer for pointer in bank 8F for level data
Aqua: alternative state. It shows what should happen for room to change.
Purple: extra value for alternative state.
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Orange: scroll array. 1 byte for every screen of room. It starts from upper-left corner of room.
Blue: door array pointer.
Brown: special scrolling data. Scrolling PLMs are points to this.
Gray: Data that we no longer need.
??: data from other place. Don't touch it.

What we get by now. When you load this room, the game will check instruction E612 (aqua bytes) with argument 00 (purple bytes), is event 00 happened or not.

If yes, jump to address written by yellow bytes and read 26 bytes there.

If no, read next. There are these bytes E6 E5 (instruction E5E6 for standart state). If the game get there, it will read the next 26 bytes after E6 E5.

19. We have a few unused grey bytes left. Let's mark them somehow, to make sure in future that this data is unused. Replace all grey bytes with FF's.

Result:
793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 A0 E9 12 E6 00 B0 E9 E6 E5
79410: 45 EB C2 00 0C 05 12 81 84 86 61 81 81 01 31 94
79420: 00 00 00 00 DC 81 AE B7 CE 91 FF FF FF FF FF FF
79430: FF 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
79440: 02 02 02 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Legend.

Green: offset from start of ROM
Red: pointer for level data
Yellow: pointer for pointer in bank 8F for level data
Aqua: alternative state. It shows what should happen for room to change.
Purple: extra value for alternative state.
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Orange: scroll array. 1 byte for every screen of room. It starts from upper-left corner of room.
Blue: door array pointer.
Brown: special scrolling data. Scrolling PLMs are points to this.
Gray: Data that we no longer need.
??: data from other place. Don't touch it.

Close hex editor.

1A. Open SMILE. Choose your room. If you done everything right, the second combo box becomes green and you can select and edit alternative state. All we need is to set correct event to trigger changes in our room.

Click the second combo box (to the right from room address) and select "Events 1". Room will reload. When it's done, click Edit > State Properties. Choose "Kraid statue grey" as we decided to do so. Click "OK". Save room.

IMPORTANT NOTE
You may notice that there are a lot of unmarked events (16?), (17?) etc. You can use them as extra states too, if you'll make the game to set it somehow. There are 256 events in total. If you want to use new events, download my patch "FF events and multiple tubes" from Patch section.

1B. Last step. It's time to decide what should happens after certain event (Kraid statue grey in our case) will happened. It can be a lot of things:

Replace enemies in the room (example: All Mocktroids turns into Metroids);
Add enemies in the room (example: enemy population will grow);
Delete all enemies from the room (example: Metroid will not respawn after killing);

Replace PLMs in the room (example: always closed grey door will replaced by orange door);
Add PLMs in the room (example: add hidden item or weapon expansion);
Delete all PLMs from the room (example: get rid of grey gates blocking path);

Change music in the room (example: after Zebes is awake music will change);

Change layout of the room (example: remove blocks blocking a new path, add/remove spikes etc.);

Add liquid to the room;
Remove liquid from the room (example: removing water allows player to go further without Gravity Suit);
Change liquid levels (example: lowering lava level allows player to spped up and brake speed booster blocks);
Allow liquid to rise/drop after player re-enters the room;

Change weather (example: replace rain with fog);

Change brightness level (example: turn on the light);

Change background;

1C'. Let it be enemy replacement and level data changing.
If we don't want to overwrite anything, we'll need to search for a free space for level data (in any bank) and a free space for enemies (bank $A1 only).

Close SMILE.

1D'. Open hex editor. Find a free space in the end of bank $A1. Jump to 108000 where bank $A1 starts. Scroll down until you see a lot of FF's. For default ROM, it'll be at 10EBD1.

Write on paper: new enemy pointer is EBD1.

1E'. As far as there'll be a new enemies, we should also search for a place to "allowed enemies" in your room. A free space must be in bank $B4. Jump to the start of bank $B4 (1A0000). For a clean ROM, free space starts from 1A74B8.

Write on paper: allowed list is at F4B8. Why not 74B8? Pointers must always be >8000. If they are less than 8000, just add 8000 to gain correct pointer.

1F'. Now it's time to search a place for a Level Data. Let's suppose you're doing this at first time*. Close hex editor. Space for Level Data will be in the new bank.

*If you are really know what to do, search a free space in banks $DE and $DF, but carefully.

To prevent overwriting data, when using a free space in bank $DE, add line "2F8000" to level_entries.txt in "smile/files" folder.

To prevent overwriting data, when using a free space in bank $DF if you haven't expand your ROM, add line "300000" to level_entries.txt in "smile/files" folder. Lines with addresses 2FD000, 2FE000 and 2FF000 can be removed.

20'. Let's start from Level Data. Open "smile/files" folder. Find a file level_entries.txt. Open it.

We are about to add a new bank to the end of the ROM. Add 2 lines: 300000 and 308000.

Save and exit.

21'. Open SMILE.

Click Tools > Expand ROM.

We have just added a bank to the end of the ROM where we can store data. New bank is $E0. Level Data will be stored there.

21'. Select your room. Choose alternative state. Open pointers window.

Replace value in the Level Data field with E08000. Click "SAVE".

22'. When SMILE ask you "Copy data or leave it?" choose "YES". Level Data from old address (C2EB45) will be copied to the new address (E08000).

Save your room. Now you can freely edit level layout in the alternative state of your room.

When you save your room everytime, you'll see in the header of SMILE something like this: 3567/32768.





IIb. PLACING EXTRA STATE INSIDE OF ROOM HEADER


In short, we need to insert alternative state instruction, alternative state argument (only for event-related and boss-related states) and alternative state pointer between pink bytes and E6 E5 and place alternative state itself inside of header. We need to relocate blue bytes or/and orange bytes, sometimes brown bytes.

The advantages are:

This is simplier.
It's more obvious.
You won't lose an alternative state pointer.

The lacks are:

Can be done only a few rooms (for rooms with big scroll array or for rooms with a lot of special scrolling data made by Scroll PLMs).

A. For example, we want to add an extra state depending on Power Bombs. Our instruction will be E669 without extra byte as argument. 2 more bytes are used for pointer, 4 in total. State itself will use 26 bytes.

B. Open your room in hex one more time.

793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 25 94 E6 E5 45 EB C2 00 0C
79410: 05 12 81 84 86 61 81 81 01 31 94 00 00 00 00 DC
79420: 81 AE B7 CE 91 CA 89 D6 89 E2 89 EE 89 FA 89 06
79430: 8A 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
79440: 02 02 02 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Legend.

Green: offset from start of ROM
Red: pointer for level data
Yellow: pointer for pointer in bank 8F for level data
Aqua: alternative state. It shows what should happen for room to change.
Purple: extra value for alternative state.
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Orange: scroll array. 1 byte for every screen of room. It starts from upper-left corner of room.
Blue: door array pointer.
Brown: special scrolling data. Scrolling PLMs are points to this.
Gray: Data that we no longer need.
??: data from other place. Don't touch it.

We have blue and orange bytes in this room. We need to free up 30 bytes, so we need to relocate both of them.
Remember the count of blue bytes. 12 in this case.
Remember the count of orange bytes. 48 in this case.

C. Find a free space in the end of bank $8F. Just scroll down in hex editor until you see a lot of FF's. For clean unheadered ROM they should start at 7E99A. 7E9A0 is ok to start. Write on paper: E9A0 -- new door array, 12 bytes. Close hex editor.

D. Open SMILE. Load your room. Choose Edit > Pointers.
Change value in the Door_Out field from "9425" to "E9A0".
Click on button "SAVE" below.

E. When SMILE ask you "Copy data or leave it?" choose "YES".
When SMILE ask you again "Also move the pointer data?" choose "YES" as we are want to do it too.

If you want to add or remove door, it is a perfect time to do it now. If you don't want to do this, read section IIba. If you want to, read section IIbb.





IIba. PLACING EXTRA STATE INSIDE OF ROOM HEADER, WITHOUT ADDING A DOOR


F. We have successfully relocated door array. Now it's time to relocate scroll array. Where should we place it?

There are always ending bytes of the end of each door pointers array. They should be XX YY, where XX -- anything and YY < 80. And in scroll array every byte is 00, 01, 02. So, this condition is fulfilled and we can replace ending bytes of door pointers array. Don't be afraid.

New door pointers array starts at E9A0 and use 12 bytes. So, it'll ends at E9A0 + C = E9AC. That will be the address of new scroll array.

10. Change value in the Scroll field from "9431" to "E9AC". Click on button "SAVE" below.

11. When SMILE ask you "Copy data or leave it?" choose "YES". Close SMILE.

12. Open hex editor. Jump to location of your room (793FE).

793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 A0 E9 E6 E5 45 EB C2 00 0C
79410: 05 12 81 84 86 61 81 81 01 AC E9 00 00 00 00 DC
79420: 81 AE B7 CE 91 CA 89 D6 89 E2 89 EE 89 FA 89 06
79430: 8A 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
79440: 02 02 02 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Green: offset from start of ROM
Red: pointer for level data
Yellow: pointer for pointer in bank 8F for level data
Aqua: alternative state. It shows what should happen for room to change.
Purple: extra value for alternative state.
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Orange: scroll array. 1 byte for every screen of room. It starts from upper-left corner of room.
Blue: door array pointer.
Brown: special scrolling data. Scrolling PLMs are points to this.
Gray: Data that we no longer need.
??: data from other place. Don't touch it.

Note that pink bytes are changed and it points to 7E9A0, and because of that bytes at 79425 is no longer blue-colored. Same for orange-colored bytes. You can find scroll array pointer in this bytes if you want to. Just if you curious. You can freely modify grey-colored bytes.

13. Alternative state instruction and alternative state pointer will take 4 bytes. Because of that, leave a gap of 4 grey bytes and copy default state there. Where will be a first byte after this gap? At 79429. Copy 26 bytes after E6 E5 to 79429.

Result:
793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 A0 E9 E6 E5 45 EB C2 00 0C
79410: 05 12 81 84 86 61 81 81 01 AC E9 00 00 00 00 DC
79420: 81 AE B7 CE 91 CA 89 D6 89 45 EB C2 00 0C 05 12
79430: 81 84 86 61 81 81 01 AC E9 00 00 00 00 DC 81 AE
79440: B7 CE 91 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Legend.

Green: offset from start of ROM
Red: pointer for level data
Yellow: pointer for pointer in bank 8F for level data
Aqua: alternative state. It shows what should happen for room to change.
Purple: extra value for alternative state.
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Orange: scroll array. 1 byte for every screen of room. It starts from upper-left corner of room.
Blue: door array pointer.
Brown: special scrolling data. Scrolling PLMs are points to this.
Gray: Data that we no longer need.
??: data from other place. Don't touch it.

14. We have wrote the new state itself. Now we should add bytes to make the game correctly linking to it. To do this we must shift original state by 4 bytes to the right. Why 4 bytes? 2 bytes go for alternative state instruction and 2 more bytes for it's address. Note again that there no alternative state argument for item-based events.

We have successfully copied original state, so we can just write data from there. Where are second red bytes? At 79429. It's a start of alternative state. Original state is at 7940B. 7940B + 4 = 7940F.
Copy 26 bytes, starting from 79429 to 7940B.
Shift E6 E5 to the right too.

Result:
793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 A0 E9 E6 E5 45 EB E6 E5 45
79410: EB C2 00 0C 05 12 81 84 86 61 81 81 01 0C EA 00
79420: 00 00 00 DC 81 AE B7 CE 91 45 EB C2 00 0C 05 12
79430: 81 84 86 61 81 81 01 AC E9 00 00 00 00 DC 81 AE
79440: B7 CE 91 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Legend.

Green: offset from start of ROM
Red: pointer for level data
Yellow: pointer for pointer in bank 8F for level data
Aqua: alternative state. It shows what should happen for room to change.
Purple: extra value for alternative state.
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Orange: scroll array. 1 byte for every screen of room. It starts from upper-left corner of room.
Blue: door array pointer.
Brown: special scrolling data. Scrolling PLMs are points to this.
Gray: Data that we no longer need.
??: data from other place. Don't touch it.

15. Now we should insert alternative state instruction and alternative state pointer to get link to new data.

At step A we decided to make an extra state depending on Power Bombs. Our instruction will be E669 (Power Bombs) without extra byte as argument. 2 more bytes are used for pointer, 4 in total. We need to place them between pink and first aqua bytes (E6 E5).

Find first byte after pink bytes. It will be 79409. Write alternative state instruction there. In our case, instruction is E669 (Power Bombs). Write these 2 bytes at 79409: 69 E6 (instruction written backwards). If you want to add another instruction, for example: E640 (Morphing Ball), write 40 E6.

We don't need to write alternative state argument as far as we're not adding instructions E612 or E629.

And finally, we need to add pointer to new state. Where are a new state?
Find a location of second red bytes.
It's at 79429. Write these bytes then: 29 94.

Result:
793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 A0 E9 69 E6 29 94 E6 E5 45
79410: EB C2 00 0C 05 12 81 84 86 61 81 81 01 0C EA 00
79420: 00 00 00 DC 81 AE B7 CE 91 45 EB C2 00 0C 05 12
79430: 81 84 86 61 81 81 01 AC E9 00 00 00 00 DC 81 AE
79440: B7 CE 91 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Legend.

Green: offset from start of ROM
Red: pointer for level data
Yellow: pointer for pointer in bank 8F for level data
Aqua: alternative state. It shows what should happen for room to change.
Purple: extra value for alternative state.
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Orange: scroll array. 1 byte for every screen of room. It starts from upper-left corner of room.
Blue: door array pointer.
Brown: special scrolling data. Scrolling PLMs are points to this.
Gray: Data that we no longer need.
??: data from other place. Don't touch it.

What we get by now. When you load this room, the game will check instruction E669 (aqua bytes), if player got Power Bombs or not.

If yes, jump to address written by yellow bytes and read 26 bytes there.

If no, read next. There are these bytes E6 E5 (instruction E5E6 for standart state). If the game get there, it will read the next 26 bytes after E6 E5.

Close hex editor.

16. Open SMILE. Choose your room. If you done everything right, the second combo box becomes green and you can select and edit alternative state.

IMPORTANT NOTE
You may notice that there are just a few item events you can set. If you want to use any item as alternative event, download my patch "Item-based events v2" from Patch section.

17. Last linear step. It's time to decide what should happens after certain event (player got Power Bombs) will happened. It can be a lot of things:

Replace enemies in the room (example: all Mocktroids turns into Metroids);
Add enemies in the room (example: enemy population will grow);
Delete all enemies from the room (example: Metroids will not respawn after killing all of them in this room);

Replace PLMs in the room (example: always closed grey door will replaced by orange door);
Add PLMs in the room (example: add hidden item or weapon expansion);
Delete all PLMs from the room (example: get rid of grey gates blocking path);

Change music in the room (example: after Zebes is awake music will change);

Change layout of the room (example: remove blocks blocking a new path, add/remove spikes etc.);

Add liquid to the room;
Remove liquid from the room (example: removing water allows player to go further without Gravity Suit);
Change liquid levels (example: lowering lava level allows player to speed up and brake speed booster blocks in certain places);
Allow liquid to rise/drop after player enters the room;

Change weather (example: replace rain with fog);

Change brightness level (example: turn on the light);

Change background;

All next steps will depends on what you change right now. And don't forget to clone data you want to change (read: level data, PLMs, enemies etc.).

Let is be PLM replacement.

18'. PLM replacement. There are a grey door blocking access from Crateria to a Gravity Suit room. How about to open it? We'll need to replace PLMs for alternative state.

SMILE can't actually copy all PLM in certain room to the new place. We have to do it manually.

Select alternative state of your room. Open pointers window. Where are PLMs located? At 81DC. Write on paper: Old PLMs at 81DC.

19'. How many PLMs are there? The easiest way to check is click Enemy > Special > Enemy/PLM +/- in SMILE.

Write on paper the second value in the window (PLMs in the room). 05 in our case.

Click on 'X' button to close the window. DON'T click "SAVE"! If room have no enemies, then SMILE will add 1 of them add overwrite data!

Close SMILE.

1A'. Open hex editor. Go to PLM pointer (781DC).

Each PLM is using 6 bytes, so the whole space for PLMs is 6*5+2=30+2=32(dec)=20(hex). Last byte you need is 781DC+20-1=781FB

781D0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 42 C8 5E 36
781E0: 0B 90 72 C8 7E 46 0C 00 DB EE 02 5B 01 00 83 EF
781F0: 1C 03 02 00 DB EE 01 2F 03 00 00 00


Write these bytes on paper or made a screenshot of hex editor window.

1B'. Find a free space for a new PLM array in bank $8F. For a clean ROM, E9A0 is a good place to start. Write on paper: New PLMs at E9A0.

Jump there and write bytes that you wrote on paper (or from screenshot).

Result:
7E9A0: 42 C8 5E 36 0B 90 72 C8 7E 46 0C 00 DB EE 02 5B
7E9B0: 01 00 83 EF 1C 03 02 00 DB EE 01 2F 03 00 00 00


Close hex editor.

1C'. Open SMILE. Select your room. Choose an alternative style. Open pointers window.

Change PLM pointer from 81DC to E9A0. Click "SAVE". Close pointers window. Save your room.

1D'. Alright, now after changing any PLM or PLMs in alternative state, the original state will not be affected.

We want to change grey door blocking access to Gravity Suit room. Click on this PLM with right button and select type. Change High Byte from 10 to 0C. Click OK. Save your room.

1E'. Now that door will flash and ready to open after a few enemies will be destroyed? How to change that "a few"? Click on every enemy with right button and select Species.

IMPORTANT NOTE
Change value near enemies to clear the room from 07 to 00. Note that this action affects this value for original state too, but there are no grey doors that will opens after cleaning the room, so it's OK to do it.

Click OK. Save your room.

Now, after Kraid statue will became grey, in the room 793FE the one and only grey door will always flash in blue.







IIbb. PLACING EXTRA STATE INSIDE OF ROOM HEADER, WHILE ADDING A DOOR


F. For example, we want to add 1 more door.

10. Let's find a space for new door. Door_Out is points to door pointer array (bank $8F), in which every word is a pointer to address is bank $83. So, the door data itself is in bank $83.

11. Open hex editor. Go to 18000 and search for a lot of FF's.
For clean unheadered ROM they should start at 1AD66. Gaps between doors isn't nessesary, but let 1AD68 will be a first new door.

Each door uses 12 (C in hex) bytes. Write on paper or remember this: new door at 1AD66
Next new door (if you'll add more than one) will be at 1AD66 + C = 1AD72.
Next one: 1AD72 + C = 1AD7E
Next one: 1AD7E + C = 1AD8A
Next one: 1AD8A + C = 1AD96 etc.)

Don't write anything there, just remember the address (or addresses)

12. Look at paper. Where are new location of our door array? At E9A0. Jump to there in hex:

7E9A0: CA 89 D6 89 E2 89 EE 89 FA 89 06 8A 00 00 FF FF

00 00 is an ending mark of array. Don't touch this yet.

13. Look at paper. Where are will be a new door? At 1AD66. Shift 00 00 to the right and write address of new door there. Use only last 2 byte and write them a vise versa:

7E9A0: CA 89 D6 89 E2 89 EE 89 FA 89 06 8A 66 AD 00 00

Congratulations! New door is successfully added. It's destination and other data you can set in SMILE. There was 6 doors, and now will be 7. Door $06 should appears in the list of the doors when editing your room.

14. Now it's time to relocate scroll array. Where should we place it? Zeroes after door array are shifted.

There are always ending bytes of the end of each door pointers array. They should be XX YY, where XX -- anything and YY < 80. And in scroll array every byte is 00, 01, 02. So, this condition is fulfilled and we can replace ending bytes of door pointers array. Don't be afraid.

Where is a location of ending bytes of door pointers array? It is at 7E9AE.
Write on paper: scroll array at 7E9AE. Close hex editor.

15. Open SMILE. Choose your room. Onep pointers window. Change value in the Scroll field from "9431" to "E9AE". Click on button "SAVE" below.

16. When SMILE ask you "Copy data or leave it?" choose "YES". Close SMILE.

17. Open hex editor. Jump to location of your room (793FE).

793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 A0 E9 E6 E5 45 EB C2 00 0C
79410: 05 12 81 84 86 61 81 81 01 AE E9 00 00 00 00 DC
79420: 81 AE B7 CE 91 CA 89 D6 89 E2 89 EE 89 FA 89 06
79430: 8A 02 02 02 02 02 02 02 02 02 02 02 02 02 02 02
79440: 02 02 02 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Green: offset from start of ROM
Red: pointer for level data
Yellow: pointer for pointer in bank 8F for level data
Aqua: alternative state. It shows what should happen for room to change.
Purple: extra value for alternative state.
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Orange: scroll array. 1 byte for every screen of room. It starts from upper-left corner of room.
Blue: door array pointer.
Brown: special scrolling data. Scrolling PLMs are points to this.
Gray: Data that we no longer need.
??: data from other place. Don't touch it.

Note that pink bytes are changed and it points to 7E9A0, and because of that bytes at 79425 is no longer blue-colored. Same for orange-colored bytes. You can find scroll array pointer in this bytes if you want to. Just if you curious. You can freely modify grey-colored bytes.

18. Alternative state instruction and alternative state pointer will take 4 bytes. Because of that, leave a gap of 4 grey bytes and copy default state there. Where will be a first byte after this gap? At 79429. Copy 26 bytes after E6 E5 to 79429.

Result:
793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 A0 E9 E6 E5 45 EB C2 00 0C
79410: 05 12 81 84 86 61 81 81 01 AE E9 00 00 00 00 DC
79420: 81 AE B7 CE 91 CA 89 D6 89 45 EB C2 00 0C 05 12
79430: 81 84 86 61 81 81 01 AE E9 00 00 00 00 DC 81 AE
79440: B7 CE 91 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Legend.

Green: offset from start of ROM
Red: pointer for level data
Yellow: pointer for pointer in bank 8F for level data
Aqua: alternative state. It shows what should happen for room to change.
Purple: extra value for alternative state.
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Orange: scroll array. 1 byte for every screen of room. It starts from upper-left corner of room.
Blue: door array pointer.
Brown: special scrolling data. Scrolling PLMs are points to this.
Gray: Data that we no longer need.
??: data from other place. Don't touch it.

19. We have wrote the new state itself. Now we should add bytes to make the game correctly linking to it. To do this we must shift original state by 4 bytes to the right. Why 4 bytes? 2 bytes go for alternative state instruction and 2 more bytes for it's address. Note again that there no alternative state argument for item-based events.

We have successfully copied original state, so we can just write data from there. Where are second red bytes? At 79429. It's a start of alternative state. Original state is at 7940B. 7940B + 4 = 7940F.
Copy 26 bytes, starting from 79429 to 7940B.
Shift E6 E5 to the right too.

Result:
793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 A0 E9 E6 E5 45 EB E6 E5 45
79410: EB C2 00 0C 05 12 81 84 86 61 81 81 01 0C EA 00
79420: 00 00 00 DC 81 AE B7 CE 91 45 EB C2 00 0C 05 12
79430: 81 84 86 61 81 81 01 AC E9 00 00 00 00 DC 81 AE
79440: B7 CE 91 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Legend.

Green: offset from start of ROM
Red: pointer for level data
Yellow: pointer for pointer in bank 8F for level data
Aqua: alternative state. It shows what should happen for room to change.
Purple: extra value for alternative state.
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Orange: scroll array. 1 byte for every screen of room. It starts from upper-left corner of room.
Blue: door array pointer.
Brown: special scrolling data. Scrolling PLMs are points to this.
Gray: Data that we no longer need.
??: data from other place. Don't touch it.

1A. Now we should insert alternative state instruction and alternative state pointer to get link to new data.

At step A we decided to make an extra state depending on Power Bombs. Our instruction will be E669 (Power Bombs) without extra byte as argument. 2 more bytes are used for pointer, 4 in total. We need to place them between pink and first aqua bytes (E6 E5).

Find first byte after pink bytes. It will be 79409. Write alternative state instruction there. In our case, instruction is E669 (Power Bombs). Write these 2 bytes at 79409: 69 E6 (instruction written backwards). If you want to add another instruction, for example: E640 (Morphing Ball), write 40 E6.

We don't need to write alternative state argument as far as we're not adding instructions E612 or E629.

And finally, we need to add pointer to new state. Where are a new state?
Find a location of second red bytes.
It's at 79429. Write these bytes then: 29 94.

Result:
793F0: ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? ?? 05 00
79400: 26 00 08 06 90 A0 00 A0 E9 69 E6 29 94 E6 E5 45
79410: EB C2 00 0C 05 12 81 84 86 61 81 81 01 0C EA 00
79420: 00 00 00 DC 81 AE B7 CE 91 45 EB C2 00 0C 05 12
79430: 81 84 86 61 81 81 01 AC E9 00 00 00 00 DC 81 AE
79440: B7 CE 91 02 00 00 02 00 00 02 02 02 02 02 02 00
79450: 00 02 02 02 02 02 02 02 02 01 01 01 01 01 01 01
79460: 01


Legend.

Green: offset from start of ROM
Red: pointer for level data
Yellow: pointer for pointer in bank 8F for level data
Aqua: alternative state. It shows what should happen for room to change.
Purple: extra value for alternative state.
Pink: Door Out pointer. Colored pink to differs it from pointers for pointers (colored yellow).
Orange: scroll array. 1 byte for every screen of room. It starts from upper-left corner of room.
Blue: door array pointer.
Brown: special scrolling data. Scrolling PLMs are points to this.
Gray: Data that we no longer need.
??: data from other place. Don't touch it.

What we get by now. When you load this room, the game will check instruction E669 (aqua bytes), if player got Power Bombs or not.

If yes, jump to address written by yellow bytes and read 26 bytes there.

If no, read next. There are these bytes E6 E5 (instruction E5E6 for standart state). If the game get there, it will read the next 26 bytes after E6 E5.

Close hex editor.

1B. Open SMILE. Choose your room. If you done everything right, the second combo box becomes green and you can select and edit alternative state.

IMPORTANT NOTE
You may notice that there are just a few item events you can set. If you want to use any item as alternative event, download my patch "Item-based events v2" from Patch section.

1C. Last linear step. It's time to decide what should happens after certain event (player got Power Bombs) will happened. It can be a lot of things:

Replace enemies in the room (example: all Mocktroids turns into Metroids);
Add enemies in the room (example: enemy population will grow);
Delete all enemies from the room (example: Metroids will not respawn after killing all of them in this room);

Replace PLMs in the room (example: always closed grey door will replaced by orange door);
Add PLMs in the room (example: add hidden item or weapon expansion);
Delete all PLMs from the room (example: get rid of grey gates blocking path);

Change music in the room (example: after Zebes is awake music will change);

Change layout of the room (example: remove blocks blocking a new path, add/remove spikes etc.);

Add liquid to the room;
Remove liquid from the room (example: removing water allows player to go further without Gravity Suit);
Change liquid levels (example: lowering lava level allows player to speed up and brake speed booster blocks in certain places);
Allow liquid to rise/drop after player enters the room;

Change weather (example: replace rain with fog);

Change brightness level (example: turn on the light);

Change background;

All next steps will depends on what you change right now. And don't forget to clone data you want to change (read: level data, PLMs, enemies etc.).

Let it be a tileset change and liquid change.

1D'. Tileset change. Select alternative state of your room.
The easiest way is change tileset 1 (upper Crateria) to tileset 2 (hell Crateria). Save your room.

Perhaps, Power Bombs are in Norfair. After obtaining them, the lava level of planet will rise and heat will burn up some rooms in Crateria. To create this illusion you may need to add alternative state to some Norfair rooms where lava level will rise. And when you return in this room after obtaining Power Bombs, tileset in this room will be changed.

SMALL NOTE
With Palette blend patch by DSO you can do even more than this: change palette in any room to any color. You can download it from patch section.

Example: using this patch copy palette of tileset 7 to one of the blends and change all green colors to red ones as if heat from Norfair is burning Brinstar rooms. Of course, you will need to change FX to change palette blend number in alternative state of some rooms.

1E'. Changing FX. This room is heated now. Of course, it should somehow affect water in this room:
It's level may be lowered as if some of the water is turned into steam.
All water can be turned into steam creating the fog.
Heat may be so high that all water will be turned into acid.

Let's start from lowering level of liquid.

Unless we want to overwrite some existing FXes, we should create a new one. Close SMILE for now.

1F'. Creating new FX.

All FX are stored in bank $83. Each one takes 10 (16 dec) bytes. Let's find a free space for new one.

Open hex editor. Go to 18000 where bank $83 starts. Scroll down until you see a bunch of FF's. For clean unheadered ROM they should start at 1AD66, but we have added a door, remember this? When you'll set a destination for a new door, these FF will changed into something else.

Each door is using C (12 bytes). So, the unused space is starts at 1AD72. Write on paper: FX1 at AD72. Close hex editor.

20'. Open SMILE. Choose your room. Select alternative state. Open pointers window.
Where are free space stared in bank $83? At AD72.
Change FX1 value from 8112 to AD72.

21'. When SMILE ask you "Copy data or leave it?" choose "YES".

22'. Open FX1 window in Edit menu. Now you can do whenever you want to the liquid in internative state.

Are you want to change it's level? Change Surfance Start value from 04F0 to 0580 (just example). You may even create "evaporation" effect by very slow lowering. Example:
Surfance Start: 04F0
Surfance End: 0600
Surfance Speed: FFF0 (or even FFFF)
Surfance Delay: 01 (1 frame after entering the room, should be non-zero).



Guide written by JAM, converted to HTML and proof-read by Grime.

Written for and hosted by http://www.metroidconstruction.com.