Post by Jason777 on Mar 28, 2011 14:37:35 GMT -5
[glow=red,2,300]Adding Exits to Custom Maps[/glow]
**By Jason777**
Many people have custom maps inserted into their ROM but they don't really know how to make it part of their game/mod. Well, I have made this tutorial just for that purpose. I must warn you, though- this may be a difficult process to understand if you aren't familiar with the scene header and the collision format. I would recommend making backups of your unmodified scene and map before trying this.
**I will be doing this for the Debug ROM, Obj2Area release2, and UoT 0.90 b4.1**
**REQUIREMENTS**
* A hex editor (to define the exit list and entrance index)
* A map NOT YET imported that can be editted in 3D modelling tool
* Obj2Area (I am still using release2)
* A scientific calculator that can convert between hexidecimal and decimal format (windows provides one)
* Rice's Video Plugin (some maps have trouble loading without it)
* An emulator (I use PJ64 1.6)
* UoT 0.90 b4.1(for actor positioning and collision flag editting)
* Have basic knowledge on how UoT 0.90 b4.1 works (.NET framework 2.0 or higher installed, etc. etc)
* Know how to import maps with Obj2Area (to get the map in the ROM)
* Have basic knowledge on how Obj2Area works (pypng and python 2.5.2 installed)
**DOWNLOADS**
Obj2Area releases
UoT releases
HxD hex editor
Rice's Video Plugin
**FORMATTING THE POLYGONS IN THE MAP**
Alright, before we start we are going to correctly format the polygon(s) in the map to be assigned to a different polygon type...
1st: Open up your map in a 3D modelling tool such as Google Sketchup
2nd: Assign the polygons you wish to edit a different texture than anything else in the map. You can make 2 polygons you wish to edit the same texture if you want to have that exit lead to the same place. However, if you want to have the polygons lead to different places, assign them different textures to avoid confusion in the future when we are editting the collision in UoT. The reason we are doing this is because spinout's converter assigns different polygon types for each different texture in the map. For example, if your entire map was all the same texture, it would all be assigned to the same polygon type and it would be quite frustating trying to find which polygon is the polygon you wish to edit so that way you can assign it a different polygon type via hex editor. That is just a theory of mine, though- I may be wrong. However, by default the converter has each polygon type definition disabled (a bunch of 00s at the offset the collision header points to).
3rd: Before exporting make sure that all the correct faces are reversed. White side of the polygon means that it will be solid in the game; blue side means that it will have no collision on that side. You can reverse faces by selecting the face and then right click-->Reverse Faces
4th: Export the map to OBJ. In Google Sketchup this would be accomplished by File-->Export-->3D Model. From there you would change the export type drop-down list to OBJ and then click the Options button. Once the OBJ Export Options window pops up, have the "Triangulate all Faces", "Export Texture Maps", and the "Swap YZ Coordinates (Y is Up)" boxes filled in and then click OK. Then, back at the Export Model window, click Export to finish the job. Move your OBJ, MTL, and texture folder to the Obj2Area directory.
^^ We are done with the 3D modelling tool- you can close it.
**IMPORTING THE MAP**
Now it is time to import the map into the ROM...
1st: You should have your ROM and OBJ, MTL, & texture folder in the same directory as Obj2Area and all its necessary files to run.
2nd: Run Obj2Area with the correct configuration. Here is how I imported mine:
NOTE: For your import please realize that when it asks you for "Number of start postitions" you should put in the number of exits you want in your map. However, start positions are not exactly exits... I'll explain later in the tutorial.
^^ You're done with Obj2Area...
**EXTRACTING THE MAP AND SCENE TO BE EDITTED**
Now we come to the issue of how we are going to edit the scene and map(s). You could use ZLE2 to dump the map and scene but I'd rather use a hex editor because it's much quicker than having to set up ZLE2.
1st: Open the ROM with the imported map in a hex editor.
2nd: Go to 0x035CE040 in the ROM. That is where free space is found and where spinout's converter places the map and scene.
3rd: The first thing you should see is the map header NOT the scene header. The reason for this is because spinout's converter places the map before the scene in the ROM. To extract the map simply search for the next (foward) occurence of "DF 00 00 00 00 00 00 00" (display list ending command). That would be the ending display list of the map and also the end of the map since spinouts converter places the map's display list at the end of the map. Select the block of data from the end of the DF command to the start of the map (0x035CE040)- that should be your map. Copy that data and save it as seperate file and name it (its start and end offsets).zmap. Repeat this extraction process for any other maps you have if you made a multiple map level. If you haven't done so, take note of their start and end offsets.
4th: Directly after the map(s) should come the scene- it should start off with the scene header. Copy all the data from the start of the scene header all the way down until you reach a bunch of FFs (not 00s). The scene file should be from the very start of the scene header to the very start of all those FFs. NOTE: There should be ALOT (and I mean ALOT) of FFs all back-to-back. Copy that data and save it as (its start and end offsets).zscene. If you haven't done so, take note of its start and end offsets
^^ The extraction process is done...
**DEFINING THE EXIT LIST AND THE ENTRANCE INDEX**
After extracting the correct data we come to the step of defining the exit list (which scenes the map should be linked to when going through an exit) and the entrance index (which start position to use when coming into the map).
NOTE: You can find a detailed page on the format of Maps and Scenes here
1st: Open your extracted scene in the hex editor
2nd: In the scene's header (everything before the first occurence of "14 00 00 00 00 00 00 00"), find the exit list and entrance index command. These are the formats:
^^ Take note of the offsets given
^^ Take note of the offsets given
3rd: Go to the offset given by the exit list command. This is what exits the scene uses when going through an exit. The format of the exit list is:
NOTE: The entire ROM's exit table can be found here
"Each entry is a two-byte exit number, from the game's exit table. The length of the list is undefined, the engine assumes all indexes within the list which it asks for exist."
We would put in the exits we wish the map to link to. For example, if I wanted to use the stalfos middle boss room (selection 120) daytime-child exit to link to, I would put at the start off the scene's exit list,"00 1C". Repeat that process for any other exits you would like to link to. However, be sure to not exceed the length of the scene's exit list. In other words: you cannot write over another list that is pointed to by the scene header UNLESS you relocate the exit list pointer to the end of the scene and do other things.
4th: Go to the offset give by the entrance index command. This tells the game what start position to use in the game when you enter the level. The format of the entrance index is:
For example, if we only have one map, the entrance index would have an mm value of 00 for each and every entry.
^^ We are done editting the scene in the hex editor. You can save and close it.
**USING UOT TO PLACE THE START POSITIONS**
We have to make this map legit so that means we should place the starting points at thoughtful locations such as where you would enter the level...
1st: Open up your extracted zmap (or the certain map you want to edit) in UoT. It should ask for the scene file- use the scene we just recently modified in the hex editor.
2nd: Move around the start positions to the desired locations you wish to start off in the level when you enter. It works the same as actor positioning except you have to select the link actor. Please note that the link actor #1 is the place you will start off if you enter the level through level select.
3rd: Once you are done moving around the start positions, save but DO NOT inject it into the ROM.
^^ You are done modifying the start positions...
**USING UOT TO EDIT THE FLAGS/POLYGON TYPES**
Now that we are done modifying the starting points we have to edit the polygon types of the polygons we wish to edit.
1st: The scene and map should already be opened since we just modified the start positions with UoT.
2nd: Change the Mouse Tool to the Collision Triangle Editor and then click on the polygon you want to edit and on the far right of the UoT window you should click the button to show tabs. From there, click on the Collision tab and make sure that the Variable drop-down list reads a value that no other polygon in the map has. This varible tells which polygon type set to use for this polygon. If you textured that one polygon differently than any other polygon it should be the only one with that variable but make sure. This is so that we don't accidentally give another polygon the collision of an exit.
3rd: While in the Collision tab you will notice the "Flag 1, Flag 2, Flag 3, Flag 4" section. This is the polygon type modifier or what we use to change the collision of the polygon. We want to edit the Polygon type to be an exit. This is the most basic format for how we would set up the flags:
We would want it to link up to the Stalfos Middle Boss Room which was the first entry in the exit list of the scene so we would set E to the value of 1 or the 1st entry. This is what our flags should look like now:
NOTE: There is alot more you can do with the flags but I am just showing you the basic set up to be an exit. If you want to know what else you can do, refer to here
^^ each polygon type entry is basically all the values of the flags put side by side.
4th: Click Apply at the very bottom to change the polygon type and then save the map and scene but DO NOT inject into the ROM.
^^ You are almost done with this tutorial and finished with UoT. You can close it now...
**INSERTING THE MODIFIED SCENE INTO THE ROM**
We are at the final step and don't worry- it's extremely easy.
1st: Open the scene we just finished modifying and the ROM that the original map was imported into. We don't need to open the map because every change we made was only to the scene. If you followed the link I gave you to map and scene formats, you would know that.
2nd: You should have wrote down the start and end offset of the scene a long time ago. Go to the start offset of the scene in the ROM. Once you are there, copy all the data from the modified scene you should have open and PASTE WRITE it at the start offset of the original imported scene in the ROM. We don't need to make any changes to the file table because we didn't increase the size of the scene.
3rd: Save the ROM and test.
-- END OF TUTORIAL--
If there is something that didn't work for you or you have a question about something else, feel free to ask. Some parts may be wrong due to the fact that I had originally done this completely through hex editor before trying it out with UoT. Not to mention, this tutorial took me 3 1/2 hours to write so I'm pretty tired now.
+REP or +KARMA would be appreciated
**FAQ**
Q: Do the polygons you want to edit HAVE to be different textures?
A: No, you could make the things you want to edit into different components because that seems to do the trick also. Another way to do it would be to manually assign that polygon a different polygon type set and make by going to the collision header, looking throught the vertex array to find out which vertecies have the correct XYZ positions that match up with the vertices that form the desired polygon, note their entries in the vertex array, go to the polygon array, find the polygon(s) that use those vertex array entries, assign it a different polygon type set (its the first two bytes of that polygon's entry in the polygon array), go to the polygon type definitions, go to the entry that the polygon you wish to edit uses and then use the polygon type definition format to modify that entry. You have to use the collision header for pretty much everything. So all-in-all, it isn't worth the trouble- just make them different textures or components.
Q: Whenever, I go through the exit of the custom map, it takes me to the correct place but when I try to go back to the custom map I can't.
A: You need to modify that scene's exit to lead back to the custom map. There are many tutorials on how to do so.
Q: Could I use this process to basically add exits to other scenes like Hyrule Field?!
A: I dunno... I bet you could if there was buffer (free space) in the scene for you to add on to the exit list, entrance index, start position, and polygon type definitions. If there wasn't free space then you could always modify the pointers in the header to point to the end of the scene, insert your new data there, copy the modified scene, paste write it at free space in the ROM, and then change it's entry in the file table. Hmm... I wanna try this now
**CREDITS**
Me- doing this completely through hex editor before trying to make a simpler tutorial. I found out that UoT does wonders when you don't inject stuff into the ROM
spinout- directing me to the info on everything that must be studied in order to add exits and for his Wiki of which I am very grateful for
Flotonic- A man who has taught me most tricks when it comes to custom maps. He showed me the correct path to editting collision which led to the realization that the "flags" section for collision editting in UoT are polygon type definers. Also, he gave me a link to his unreleased notes on this very matter (exit addition).
Rivan- being the first one to teach me how to insert custom maps
Naxylldritt- his custom map textures
Zant/Twilght/Twili16- the first one to teach me how to use transition actors and how they are pointed to by the scene header. It started me on the road to making "legit" custom maps.
^^ If I have left any people out who I have to thank for my growing knowledge well... you know who you are
**I will be fixing up this tutorial in the future to better suit those noobie boobies in the community**
**By Jason777**
Many people have custom maps inserted into their ROM but they don't really know how to make it part of their game/mod. Well, I have made this tutorial just for that purpose. I must warn you, though- this may be a difficult process to understand if you aren't familiar with the scene header and the collision format. I would recommend making backups of your unmodified scene and map before trying this.
**I will be doing this for the Debug ROM, Obj2Area release2, and UoT 0.90 b4.1**
**REQUIREMENTS**
* A hex editor (to define the exit list and entrance index)
* A map NOT YET imported that can be editted in 3D modelling tool
* Obj2Area (I am still using release2)
* A scientific calculator that can convert between hexidecimal and decimal format (windows provides one)
* Rice's Video Plugin (some maps have trouble loading without it)
* An emulator (I use PJ64 1.6)
* UoT 0.90 b4.1(for actor positioning and collision flag editting)
* Have basic knowledge on how UoT 0.90 b4.1 works (.NET framework 2.0 or higher installed, etc. etc)
* Know how to import maps with Obj2Area (to get the map in the ROM)
* Have basic knowledge on how Obj2Area works (pypng and python 2.5.2 installed)
**DOWNLOADS**
Obj2Area releases
UoT releases
HxD hex editor
Rice's Video Plugin
**FORMATTING THE POLYGONS IN THE MAP**
Alright, before we start we are going to correctly format the polygon(s) in the map to be assigned to a different polygon type...
1st: Open up your map in a 3D modelling tool such as Google Sketchup
2nd: Assign the polygons you wish to edit a different texture than anything else in the map. You can make 2 polygons you wish to edit the same texture if you want to have that exit lead to the same place. However, if you want to have the polygons lead to different places, assign them different textures to avoid confusion in the future when we are editting the collision in UoT. The reason we are doing this is because spinout's converter assigns different polygon types for each different texture in the map. For example, if your entire map was all the same texture, it would all be assigned to the same polygon type and it would be quite frustating trying to find which polygon is the polygon you wish to edit so that way you can assign it a different polygon type via hex editor. That is just a theory of mine, though- I may be wrong. However, by default the converter has each polygon type definition disabled (a bunch of 00s at the offset the collision header points to).
3rd: Before exporting make sure that all the correct faces are reversed. White side of the polygon means that it will be solid in the game; blue side means that it will have no collision on that side. You can reverse faces by selecting the face and then right click-->Reverse Faces
4th: Export the map to OBJ. In Google Sketchup this would be accomplished by File-->Export-->3D Model. From there you would change the export type drop-down list to OBJ and then click the Options button. Once the OBJ Export Options window pops up, have the "Triangulate all Faces", "Export Texture Maps", and the "Swap YZ Coordinates (Y is Up)" boxes filled in and then click OK. Then, back at the Export Model window, click Export to finish the job. Move your OBJ, MTL, and texture folder to the Obj2Area directory.
^^ We are done with the 3D modelling tool- you can close it.
**IMPORTING THE MAP**
Now it is time to import the map into the ROM...
1st: You should have your ROM and OBJ, MTL, & texture folder in the same directory as Obj2Area and all its necessary files to run.
2nd: Run Obj2Area with the correct configuration. Here is how I imported mine:
Zelda 64 Debug ROM: ZELOOTMA.z64
Wavefront obj file for collision: Exit.obj
Scale: 1
Reverse faces? (y/n): n
Area number (0-109): 109
Music value: 0x00
Number of start positions: 2
Number of tansition actors: 0
Number of water boxes: 0
Use different obj for mesh, or multiple mesh map?(y/n): n
# Actors: 0
# Objects: 0
Indoor? (y/n): n
NOTE: For your import please realize that when it asks you for "Number of start postitions" you should put in the number of exits you want in your map. However, start positions are not exactly exits... I'll explain later in the tutorial.
^^ You're done with Obj2Area...
**EXTRACTING THE MAP AND SCENE TO BE EDITTED**
Now we come to the issue of how we are going to edit the scene and map(s). You could use ZLE2 to dump the map and scene but I'd rather use a hex editor because it's much quicker than having to set up ZLE2.
1st: Open the ROM with the imported map in a hex editor.
2nd: Go to 0x035CE040 in the ROM. That is where free space is found and where spinout's converter places the map and scene.
3rd: The first thing you should see is the map header NOT the scene header. The reason for this is because spinout's converter places the map before the scene in the ROM. To extract the map simply search for the next (foward) occurence of "DF 00 00 00 00 00 00 00" (display list ending command). That would be the ending display list of the map and also the end of the map since spinouts converter places the map's display list at the end of the map. Select the block of data from the end of the DF command to the start of the map (0x035CE040)- that should be your map. Copy that data and save it as seperate file and name it (its start and end offsets).zmap. Repeat this extraction process for any other maps you have if you made a multiple map level. If you haven't done so, take note of their start and end offsets.
4th: Directly after the map(s) should come the scene- it should start off with the scene header. Copy all the data from the start of the scene header all the way down until you reach a bunch of FFs (not 00s). The scene file should be from the very start of the scene header to the very start of all those FFs. NOTE: There should be ALOT (and I mean ALOT) of FFs all back-to-back. Copy that data and save it as (its start and end offsets).zscene. If you haven't done so, take note of its start and end offsets
^^ The extraction process is done...
**DEFINING THE EXIT LIST AND THE ENTRANCE INDEX**
After extracting the correct data we come to the step of defining the exit list (which scenes the map should be linked to when going through an exit) and the entrance index (which start position to use when coming into the map).
NOTE: You can find a detailed page on the format of Maps and Scenes here
1st: Open your extracted scene in the hex editor
2nd: In the scene's header (everything before the first occurence of "14 00 00 00 00 00 00 00"), find the exit list and entrance index command. These are the formats:
*Exit List scene header command*
13 00 00 00 BB YY YY YY
BB- bank (02 for scenes)
YY YY YY- offset of the exit list in the scene file
^^ Take note of the offsets given
*Entrance Index scene header command*
06 00 00 00 BB YY YY YY
BB- bank (02 for scenes)
YY YY YY- offset of the entrance index in the scene file
^^ Take note of the offsets given
3rd: Go to the offset given by the exit list command. This is what exits the scene uses when going through an exit. The format of the exit list is:
NOTE: The entire ROM's exit table can be found here
"Each entry is a two-byte exit number, from the game's exit table. The length of the list is undefined, the engine assumes all indexes within the list which it asks for exist."
We would put in the exits we wish the map to link to. For example, if I wanted to use the stalfos middle boss room (selection 120) daytime-child exit to link to, I would put at the start off the scene's exit list,"00 1C". Repeat that process for any other exits you would like to link to. However, be sure to not exceed the length of the scene's exit list. In other words: you cannot write over another list that is pointed to by the scene header UNLESS you relocate the exit list pointer to the end of the scene and do other things.
4th: Go to the offset give by the entrance index command. This tells the game what start position to use in the game when you enter the level. The format of the entrance index is:
mmee (repeats for each entry)
mm- which map to use for this entrance
ee- which start position to use, defined by the start positions list for this entrance
For example, if we only have one map, the entrance index would have an mm value of 00 for each and every entry.
^^ We are done editting the scene in the hex editor. You can save and close it.
**USING UOT TO PLACE THE START POSITIONS**
We have to make this map legit so that means we should place the starting points at thoughtful locations such as where you would enter the level...
1st: Open up your extracted zmap (or the certain map you want to edit) in UoT. It should ask for the scene file- use the scene we just recently modified in the hex editor.
2nd: Move around the start positions to the desired locations you wish to start off in the level when you enter. It works the same as actor positioning except you have to select the link actor. Please note that the link actor #1 is the place you will start off if you enter the level through level select.
3rd: Once you are done moving around the start positions, save but DO NOT inject it into the ROM.
^^ You are done modifying the start positions...
**USING UOT TO EDIT THE FLAGS/POLYGON TYPES**
Now that we are done modifying the starting points we have to edit the polygon types of the polygons we wish to edit.
1st: The scene and map should already be opened since we just modified the start positions with UoT.
2nd: Change the Mouse Tool to the Collision Triangle Editor and then click on the polygon you want to edit and on the far right of the UoT window you should click the button to show tabs. From there, click on the Collision tab and make sure that the Variable drop-down list reads a value that no other polygon in the map has. This varible tells which polygon type set to use for this polygon. If you textured that one polygon differently than any other polygon it should be the only one with that variable but make sure. This is so that we don't accidentally give another polygon the collision of an exit.
3rd: While in the Collision tab you will notice the "Flag 1, Flag 2, Flag 3, Flag 4" section. This is the polygon type modifier or what we use to change the collision of the polygon. We want to edit the Polygon type to be an exit. This is the most basic format for how we would set up the flags:
Flag 1: 0000
Flag 2: 0E00
Flag 3: 0000
Flag 4: 000
E- exit list entry number in the scene.
We would want it to link up to the Stalfos Middle Boss Room which was the first entry in the exit list of the scene so we would set E to the value of 1 or the 1st entry. This is what our flags should look like now:
Flag 1: 0000
Flag 2: 0100
Flag 3: 0000
Flag 4: 000
NOTE: There is alot more you can do with the flags but I am just showing you the basic set up to be an exit. If you want to know what else you can do, refer to here
^^ each polygon type entry is basically all the values of the flags put side by side.
4th: Click Apply at the very bottom to change the polygon type and then save the map and scene but DO NOT inject into the ROM.
^^ You are almost done with this tutorial and finished with UoT. You can close it now...
**INSERTING THE MODIFIED SCENE INTO THE ROM**
We are at the final step and don't worry- it's extremely easy.
1st: Open the scene we just finished modifying and the ROM that the original map was imported into. We don't need to open the map because every change we made was only to the scene. If you followed the link I gave you to map and scene formats, you would know that.
2nd: You should have wrote down the start and end offset of the scene a long time ago. Go to the start offset of the scene in the ROM. Once you are there, copy all the data from the modified scene you should have open and PASTE WRITE it at the start offset of the original imported scene in the ROM. We don't need to make any changes to the file table because we didn't increase the size of the scene.
3rd: Save the ROM and test.
-- END OF TUTORIAL--
If there is something that didn't work for you or you have a question about something else, feel free to ask. Some parts may be wrong due to the fact that I had originally done this completely through hex editor before trying it out with UoT. Not to mention, this tutorial took me 3 1/2 hours to write so I'm pretty tired now.
+REP or +KARMA would be appreciated
**FAQ**
Q: Do the polygons you want to edit HAVE to be different textures?
A: No, you could make the things you want to edit into different components because that seems to do the trick also. Another way to do it would be to manually assign that polygon a different polygon type set and make by going to the collision header, looking throught the vertex array to find out which vertecies have the correct XYZ positions that match up with the vertices that form the desired polygon, note their entries in the vertex array, go to the polygon array, find the polygon(s) that use those vertex array entries, assign it a different polygon type set (its the first two bytes of that polygon's entry in the polygon array), go to the polygon type definitions, go to the entry that the polygon you wish to edit uses and then use the polygon type definition format to modify that entry. You have to use the collision header for pretty much everything. So all-in-all, it isn't worth the trouble- just make them different textures or components.
Q: Whenever, I go through the exit of the custom map, it takes me to the correct place but when I try to go back to the custom map I can't.
A: You need to modify that scene's exit to lead back to the custom map. There are many tutorials on how to do so.
Q: Could I use this process to basically add exits to other scenes like Hyrule Field?!
A: I dunno... I bet you could if there was buffer (free space) in the scene for you to add on to the exit list, entrance index, start position, and polygon type definitions. If there wasn't free space then you could always modify the pointers in the header to point to the end of the scene, insert your new data there, copy the modified scene, paste write it at free space in the ROM, and then change it's entry in the file table. Hmm... I wanna try this now
**CREDITS**
Me- doing this completely through hex editor before trying to make a simpler tutorial. I found out that UoT does wonders when you don't inject stuff into the ROM
spinout- directing me to the info on everything that must be studied in order to add exits and for his Wiki of which I am very grateful for
Flotonic- A man who has taught me most tricks when it comes to custom maps. He showed me the correct path to editting collision which led to the realization that the "flags" section for collision editting in UoT are polygon type definers. Also, he gave me a link to his unreleased notes on this very matter (exit addition).
Rivan- being the first one to teach me how to insert custom maps
Naxylldritt- his custom map textures
Zant/Twilght/Twili16- the first one to teach me how to use transition actors and how they are pointed to by the scene header. It started me on the road to making "legit" custom maps.
^^ If I have left any people out who I have to thank for my growing knowledge well... you know who you are
**I will be fixing up this tutorial in the future to better suit those noobie boobies in the community**