Register - Login
Views: 99379910
Main - Memberlist - Active users - Calendar - Wiki - IRC Chat - Online users
Ranks - Rules/FAQ - Stats - Latest Posts - Color Chart - Smilies
04-23-22 11:09:27 PM
Jul - SM64 Hacking (Archive) - How to properly read level scripts? New poll - New thread - New reply
Next newer thread | Next older thread
Doogie1012
Member
Level: 15


Posts: 20/35
EXP: 14542
For next: 1842

Since: 10-21-08


Since last post: 11.6 years
Last activity: 9.2 years

Posted on 12-31-08 07:51:26 AM (last edited by Doogie1012 at 12-31-08 04:52 AM) Link | Quote
In my Mario 64 Editor I am currently working on making my level scanner actually jump when it needs to and scan ram segments etc.

Currently it just scans from start to finish which provides inaccurate commands (false postitives).

(Bom-Omb's Battlefield)
405D44 - 06 08 0000 15 000660

Command = 06, Jump to offset in ram segment
Length Byte = 08
Ram Segment No. = 15
Offset = 000660

To be able to allow my level scanner to jump to this location I need to know where Ram Segment Number 15 is loaded, unfortunately my hex editor can only search for 3 hex values at once (17 0C 00).

Based on results from my level scanner this bank is not loaded at the entry-point of the level.

(Just to be clear, everything here is hex, so the Ram Segment is 15 in hex and 21 in dec)
VL-Tone
Member
Super Mario 64 forum moderator
Level: 53


Posts: 370/621
EXP: 1135504
For next: 21615

Since: 07-27-07

From: Montreal, Canada

Since last post: 4.7 years
Last activity: 1.2 years

Posted on 01-03-09 02:35:21 PM (last edited by VL-Tone at 01-03-09 11:49 AM) Link | Quote
Time: Now - Date: Today - Weather: What can be seen outside. - Mood: How it feels. Answer to the universe: 42
RAM segments might contain different things depending on the level. To know what's in it, you need to read the level script in order from the start and then collect the pointers associated with RAM segments (or banks) by looking for commands 0x17, 0x18, 0x00 and 0x01. The two latter commands (0x00 and 0x01) will both load data in a RAM segment and jump to a specific offset in that bank. I could look out for what's in the 0x15 bank for BBB, but it would be better if you could figure out by yourself, as this value shouldn't be hard-coded in your program.

To correctly load a level you have to read level script data in order, starting with the main menu "hub" script. Take a look at this document for some explanations on how it works. The "official" entry point where you should start is at 108A10.
108A10/0000:  1B 04 00 00

108A14/0004: 03 04 00 02
108A18/0008: 34 04 00 00
108A1C/000C: 13 04 00 00
108A20/0010: 00 10 00 14 00 26 9E A0 00 26 A3 A0 14 00 00 00 --Loads Level Script data from 269EA0-26A3A0 into segment 0x14, jumps to offset 0x000000
108A30/0020: 05 08 00 00 10 00 00 00 --Jumps to segment 0x10? What's in segment 0x10?


TT64 though starts reading at 269EA0 at the beginning of bank 0x14 as defined by the 0x00 command found in the little script found at 108A10. The content of bank 0x10 is unknown, but it doesn't matter since the 0x00 command just before will jump to the level script. Bank 0x10 may well be containing the little 108A14 script, so the thing simply loops when you exit the level script (so you get back to the menu).

The 0x0C commands found in bank 0x15 (later if you follow the script) are a conditional jump which will jump according to the current level number. So when reading commands, ignore all 0x0C commands except the one corresponding to the level you want to read.

You should experiment with the TT64 script dumping commands to see how the levels are loaded. Particularly, the "Level script select" category which shows the level as read starting in the menu hub script.

It's important to read/load starting from the menu hub script because some stuff is loaded from there that will be used by the level ( 0x17 and 0x22 commands amongst other things).

The level-specific scripts go back to bank 0x15 using the 0x06 command to read things like 0x22 and 0x21 commands. The thing is, some of these "sub-banks" containing 0x22 and 0x21 commands are shared by multiple levels, so if you change something there, it might have repercussions on other levels, including a possible crash if you change a 0x22 command to refer to a bank that is not used by all levels that depend on this command. TT64 indicates which commands are "shared" with a little "s" in the command list. Those with an "x" are also part of bank 0x15 (or some other bank external to the current level script) but are exclusive to this particular level ie.: they're not shared.

It all reminds me of when I started to comprehend the level script structure a few years ago. As you understand more and more you'll see that complex level manipulations are not that easy to pull off (and from I saw I think you're not even starting to deal with objects (0x42 and 0x43) which are found inside the MIO0 banks).

Edit: I've changed the title of this thread so that it can be used as a more general topic about reading level scripts, and so that newbies (aka n00b) don't think you can create a new thread just for a very specific question that could be asked in an existing thread.



Just a little note: I'm moving tomorrow to a nice new apartment, and my internet connection won't be available until tuesday night.

____________________
Doogie1012
Member
Level: 15


Posts: 27/35
EXP: 14542
For next: 1842

Since: 10-21-08


Since last post: 11.6 years
Last activity: 9.2 years

Posted on 03-06-09 05:42:48 AM Link | Quote
I've been busy (and lazy), So I haven't been able to develop my program since this discussion much. Before I start to program my 'buffer-stores-ram segment' array, I just wanted to know how to make the program differentiate two commands which use the same number id. (aka switch between reading commands as a Level Script Command or a Geometry Command)
VL-Tone
Member
Super Mario 64 forum moderator
Level: 53


Posts: 409/621
EXP: 1135504
For next: 21615

Since: 07-27-07

From: Montreal, Canada

Since last post: 4.7 years
Last activity: 1.2 years

Posted on 03-15-09 04:26:12 PM Link | Quote
Time: Now - Date: Today - Weather: What can be seen outside. - Mood: How it feels. Answer to the universe: 42
Originally posted by Doogie1012
I've been busy (and lazy), So I haven't been able to develop my program since this discussion much. Before I start to program my 'buffer-stores-ram segment' array, I just wanted to know how to make the program differentiate two commands which use the same number id. (aka switch between reading commands as a Level Script Command or a Geometry Command)


It's simply a matter of switching to geo layout commands when the level script calls for them (with 0x22 or 0x1F commands). When you encounter the geo layout "end" command (I think it's 0x01, check to be sure), just go back to where you were in the level script.

TT64 builds a table of unique geo layout offsets while reading level scripts and encountering 0x22 and 0x1F commands, then reads/load all geo layouts one after the other after having read all level scripts. But reading geo layouts while reading the level scripts could give you the same results.

You should really try to read scripts by following all the jump/goto/gosub commands instead of linearly read the content of banks. You should take a look at this document and start reading your data from there (either at 108A10 or 269EA0), then follow the jump commands. (Don't forget that the 0x0C jump command is conditional on the current level).


____________________
Next newer thread | Next older thread
Jul - SM64 Hacking (Archive) - How to properly read level scripts? New poll - New thread - New reply


Rusted Logic

Acmlmboard - commit 47be4dc [2021-08-23]
©2000-2022 Acmlm, Xkeeper, Kaito Sinclaire, et al.

30 database queries, 2 query cache hits.
Query execution time:  0.236515 seconds
Script execution time:  0.014803 seconds
Total render time:  0.251318 seconds


TidyHTML vomit below
line 1 column 1 - Warning: missing <!DOCTYPE> declaration
line 2 column 300 - Warning: unescaped & or unknown entity "&page"
line 119 column 11 - Warning: <form> isn't allowed in <table> elements
line 118 column 10 - Info: <table> previously mentioned
line 120 column 11 - Warning: missing <tr>
line 120 column 119 - Warning: missing </font> before </td>
line 124 column 16 - Warning: plain text isn't allowed in <tr> elements
line 120 column 11 - Info: <tr> previously mentioned
line 125 column 68 - Warning: missing </nobr> before </td>
line 141 column 68 - Warning: missing </nobr> before <tr>
line 147 column 35 - Warning: missing <tr>
line 147 column 50 - Warning: missing </font> before </td>
line 148 column 37 - Warning: unescaped & or unknown entity "&id"
line 147 column 206 - Warning: missing </font> before </table>
line 149 column 35 - Warning: missing <tr>
line 149 column 50 - Warning: missing </font> before </td>
line 149 column 91 - Warning: missing </font> before </table>
line 156 column 9 - Warning: <div> isn't allowed in <table> elements
line 152 column 17 - Info: <table> previously mentioned
line 158 column 9 - Warning: missing <tr>
line 176 column 13 - Warning: missing <tr>
line 177 column 99 - Warning: unescaped & or unknown entity "&postid"
line 198 column 9 - Warning: <div> isn't allowed in <table> elements
line 152 column 17 - Info: <table> previously mentioned
line 200 column 9 - Warning: missing <tr>
line 218 column 13 - Warning: missing <tr>
line 219 column 99 - Warning: unescaped & or unknown entity "&postid"
line 221 column 73 - Warning: <style> isn't allowed in <td> elements
line 221 column 9 - Info: <td> previously mentioned
line 221 column 1511 - Warning: missing </font> before <pre>
line 230 column 1 - Warning: inserting implicit <font>
line 230 column 1 - Warning: missing </font> before <hr>
line 246 column 1 - Warning: inserting implicit <font>
line 221 column 137 - Warning: missing </div>
line 249 column 9 - Warning: <div> isn't allowed in <table> elements
line 152 column 17 - Info: <table> previously mentioned
line 251 column 9 - Warning: missing <tr>
line 269 column 13 - Warning: missing <tr>
line 270 column 101 - Warning: unescaped & or unknown entity "&postid"
line 275 column 9 - Warning: <div> isn't allowed in <table> elements
line 152 column 17 - Info: <table> previously mentioned
line 277 column 9 - Warning: missing <tr>
line 295 column 13 - Warning: missing <tr>
line 296 column 101 - Warning: unescaped & or unknown entity "&postid"
line 298 column 74 - Warning: <style> isn't allowed in <td> elements
line 298 column 9 - Info: <td> previously mentioned
line 298 column 1512 - Warning: missing </font> before <blockquote>
line 298 column 1591 - Warning: inserting implicit <font>
line 298 column 1591 - Warning: missing </font> before <hr>
line 298 column 1658 - Warning: inserting implicit <font>
line 298 column 1658 - Warning: missing </font> before <hr>
line 299 column 1 - Warning: inserting implicit <font>
line 298 column 138 - Warning: missing </div>
line 308 column 17 - Warning: missing <tr>
line 308 column 17 - Warning: discarding unexpected <table>
line 311 column 35 - Warning: missing <tr>
line 311 column 50 - Warning: missing </font> before </td>
line 311 column 91 - Warning: missing </font> before </table>
line 313 column 35 - Warning: missing <tr>
line 313 column 50 - Warning: missing </font> before </td>
line 314 column 37 - Warning: unescaped & or unknown entity "&id"
line 313 column 206 - Warning: missing </font> before </table>
line 315 column 17 - Warning: discarding unexpected </textarea>
line 315 column 28 - Warning: discarding unexpected </form>
line 315 column 35 - Warning: discarding unexpected </embed>
line 315 column 43 - Warning: discarding unexpected </noembed>
line 315 column 53 - Warning: discarding unexpected </noscript>
line 315 column 64 - Warning: discarding unexpected </noembed>
line 315 column 74 - Warning: discarding unexpected </embed>
line 315 column 82 - Warning: discarding unexpected </table>
line 315 column 90 - Warning: discarding unexpected </table>
line 317 column 9 - Warning: missing </font> before <table>
line 329 column 25 - Warning: discarding unexpected </font>
line 338 column 57 - Warning: discarding unexpected </font>
line 316 column 1 - Warning: missing </center>
line 120 column 63 - Warning: <img> lacks "alt" attribute
line 125 column 19 - Warning: <td> attribute "width" has invalid value "120px"
line 125 column 93 - Warning: <img> lacks "alt" attribute
line 141 column 19 - Warning: <td> attribute "width" has invalid value "120px"
line 141 column 98 - Warning: <img> lacks "alt" attribute
line 148 column 44 - Warning: <img> proprietary attribute value "absmiddle"
line 148 column 142 - Warning: <img> proprietary attribute value "absmiddle"
line 148 column 245 - Warning: <img> proprietary attribute value "absmiddle"
line 161 column 22 - Warning: <img> lacks "alt" attribute
line 161 column 63 - Warning: <img> lacks "alt" attribute
line 161 column 112 - Warning: <img> lacks "alt" attribute
line 161 column 162 - Warning: <img> lacks "alt" attribute
line 172 column 15 - Warning: <img> lacks "alt" attribute
line 203 column 22 - Warning: <img> lacks "alt" attribute
line 203 column 63 - Warning: <img> lacks "alt" attribute
line 203 column 112 - Warning: <img> lacks "alt" attribute
line 203 column 162 - Warning: <img> lacks "alt" attribute
line 214 column 15 - Warning: <img> lacks "alt" attribute
line 221 column 693 - Warning: <img> lacks "alt" attribute
line 246 column 5462 - Warning: <img> lacks "alt" attribute
line 246 column 5621 - Warning: <img> lacks "alt" attribute
line 254 column 22 - Warning: <img> lacks "alt" attribute
line 254 column 63 - Warning: <img> lacks "alt" attribute
line 254 column 112 - Warning: <img> lacks "alt" attribute
line 254 column 162 - Warning: <img> lacks "alt" attribute
line 265 column 15 - Warning: <img> lacks "alt" attribute
line 280 column 22 - Warning: <img> lacks "alt" attribute
line 280 column 63 - Warning: <img> lacks "alt" attribute
line 280 column 112 - Warning: <img> lacks "alt" attribute
line 280 column 162 - Warning: <img> lacks "alt" attribute
line 291 column 15 - Warning: <img> lacks "alt" attribute
line 298 column 694 - Warning: <img> lacks "alt" attribute
line 305 column 3119 - Warning: <img> lacks "alt" attribute
line 305 column 3278 - Warning: <img> lacks "alt" attribute
line 314 column 44 - Warning: <img> proprietary attribute value "absmiddle"
line 314 column 142 - Warning: <img> proprietary attribute value "absmiddle"
line 314 column 245 - Warning: <img> proprietary attribute value "absmiddle"
line 323 column 25 - Warning: <img> lacks "alt" attribute
line 328 column 267 - Warning: <img> lacks "alt" attribute
line 149 column 50 - Warning: trimming empty <font>
line 298 column 1512 - Warning: trimming empty <font>
line 308 column 17 - Warning: trimming empty <tr>
line 311 column 50 - Warning: trimming empty <font>
line 125 column 68 - Warning: <nobr> is not approved by W3C
line 141 column 68 - Warning: <nobr> is not approved by W3C
line 177 column 27 - Warning: <nobr> is not approved by W3C
line 219 column 27 - Warning: <nobr> is not approved by W3C
line 221 column 157 - Warning: <table> proprietary attribute "height"
line 221 column 222 - Warning: <td> proprietary attribute "background"
line 221 column 318 - Warning: <td> proprietary attribute "background"
line 221 column 408 - Warning: <table> proprietary attribute "height"
line 221 column 488 - Warning: <td> proprietary attribute "background"
line 221 column 1443 - Warning: <td> proprietary attribute "background"
line 270 column 27 - Warning: <nobr> is not approved by W3C
line 296 column 27 - Warning: <nobr> is not approved by W3C
line 298 column 158 - Warning: <table> proprietary attribute "height"
line 298 column 223 - Warning: <td> proprietary attribute "background"
line 298 column 319 - Warning: <td> proprietary attribute "background"
line 298 column 409 - Warning: <table> proprietary attribute "height"
line 298 column 489 - Warning: <td> proprietary attribute "background"
line 298 column 1444 - Warning: <td> proprietary attribute "background"
Info: Document content looks like HTML5
Info: No system identifier in emitted doctype
Tidy found 128 warnings and 0 errors!


The alt attribute should be used to give a short description
of an image; longer descriptions should be given with the
longdesc attribute which takes a URL linked to the description.
These measures are needed for people using non-graphical browsers.

For further advice on how to make your pages accessible
see http://www.w3.org/WAI/GL.
You are recommended to use CSS to specify the font and
properties such as its size and color. This will reduce
the size of HTML files and make them easier to maintain
compared with using <FONT> elements.

You are recommended to use CSS to control line wrapping.
Use "white-space: nowrap" to inhibit wrapping in place
of inserting <NOBR>...</NOBR> into the markup.

About HTML Tidy: https://github.com/htacg/tidy-html5
Bug reports and comments: https://github.com/htacg/tidy-html5/issues
Official mailing list: https://lists.w3.org/Archives/Public/public-htacg/
Latest HTML specification: http://dev.w3.org/html5/spec-author-view/
Validate your HTML documents: http://validator.w3.org/nu/
Lobby your company to join the W3C: http://www.w3.org/Consortium

Do you speak a language other than English, or a different variant of
English? Consider helping us to localize HTML Tidy. For details please see
https://github.com/htacg/tidy-html5/blob/master/README/LOCALIZE.md