User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
level_commands [2015/12/02 13:05]
queueram Fix formatting of 2E
— (current)
Line 1: Line 1:
-======== Level Commands ======== 
  
-The level commands define the top-level control of the game.  They are used to load levels, textures, collision data, objects, warps, etc. and determine how everything is connected. ​ The first byte of the level command is the command type and the second byte is the length of the command in bytes. 
- 
-===== Level Layout Commands ===== 
-==== 00: Load Raw Data and Jump ==== 
-Loads raw data to RAM segment and jumps to segment offset. ​ Used for loading level scripts and then jumping to an offset in them 
- 
-''​00 10 00 [<color red>​XX</​color>​] [<color green>YY YY YY YY</​color>​] [<color blue>ZZ ZZ ZZ ZZ</​color>​] [<color purple>​AA AA AA AA</​color>​]''​ 
- 
-| <color red>​X</​color>​ | RAM segment number | 
-| <color green>​Y</​color>​ | ROM address start | 
-| <color blue>​Z</​color>​ | ROM address end | 
-| <color purple>​A</​color>​ | Segment offset of jump target | 
- 
----- 
- 
-==== 01: Load Raw Data and Jump ==== 
- 
-Load raw data to RAM segment and jump to segment offset. The only difference between this command and 0x00 is a call to 0x80278498 
- 
-''​01 10 00 [XX] [YY YY YY YY] [ZZ ZZ ZZ ZZ] [AA AA AA AA]''​ 
- 
-| X | RAM segment number | 
-| Y | ROM address start | 
-| Z | ROM address end | 
-| A | Segment offset of jump target | 
- 
----- 
- 
-==== 02: End Level Data ==== 
-End of level layout data.  Typically followed by null padding. 
- 
-''​02 04 00 00''​ 
- 
----- 
- 
-==== 03: Delay Frames ==== 
-Set flag to 0, delay X frames, set flag to 1.  Sets s16 flag (8038BE20) to 0 before delay and 1 after. ​ Does not increment level script pointer until after delay. 
- 
-''​03 04 [XX XX]''​ 
- 
-| X | number of delay frames | 
- 
----- 
- 
-==== 04: Delay Frames 2 ==== 
-Set flag to -1, delay X frames, set flag to 1. 
-Identical to 0x03, except for flag set at start: 
-sets s16 flag (8038BE20) to -1 before delay and 1 after. 
-Does not increment level pointer until after delay. 
- 
-''​04 04 [XX XX]''​ 
- 
-| X | number of delay frames | 
- 
----- 
- 
-==== 05: Jump to Address ==== 
-Jump to level script at segmented address. 
- 
-''​05 08 00 00 [XX XX XX XX]''​ 
- 
-| X | segmented address of jump | 
- 
----- 
- 
-==== 06: Push Stack ==== 
-Push script stack and jump to level script at segmented address. 
-Similar to 05, but also pushes current place on script stack so it can be popped later. 
- 
-''​06 08 00 00 [XX XX XX XX]''​ 
- 
-| X | segmented address of jump | 
- 
----- 
- 
-==== 07: Pop Stack ==== 
-Pop script stack, returns to where previous 06 or 0C pushed from. 
- 
-''​07 04 00 00''​ 
- 
----- 
- 
-==== 08: Push Stack + 16 ==== 
-Push script stack and 16-bit value on stack. 
-This command is never used in any of the level scripts. 
- 
-''​08 04 [XX XX]''​ 
- 
-| X | 16 bit value pushed on script stack after current address | 
- 
----- 
- 
-==== 09: Pop Stack + 16 ==== 
-Pops script stack and param (possibly from previous 08 or 0A). 
-This command is never used in any of the level scripts. 
- 
-''​09 04 00 00''​ 
- 
----- 
- 
-==== 0A: Push Script + 0x00 ==== 
- 
-Pushes next level command on script stack and param 0x00000000. 
-This command is only used once in main level scripts. 
- 
-''​0A 04 00 00''​ 
- 
----- 
- 
-==== 0B: Conditional Pop ==== 
-If result of operation is true, pop stack. 
-This command is only used once in main level scripts. 
- 
-''​0B 08 [XX] 00 [YY YY YY YY]''​ 
- 
-| X | operation, a0 to 8037E1A0 (unsigned 8) | 
-| Y | argument, a1 to 8037E1A0 (signed 32) | 
- 
-^         ​Operations ​        ^^ 
-| 0 | script_accum & argument | 
-| 1 | !(script_accum & argument) | 
-| 2 | script_accum == argument | 
-| 3 | script_accum != argument | 
-| 4 | script_accum < argument | 
-| 5 | script_accum <= argument | 
-| 6 | script_accum > argument | 
-| 7 | script_accum >= argument | 
- 
----- 
- 
-==== 0C: Conditional Jump ==== 
-If result of operation is true, jumps to segmented address. 
- 
-''​0C 0C [XX] 00 [YY YY YY YY] [ZZ ZZ ZZ ZZ]''​ 
- 
-| X | operation, a0 to 8037E1A0 (unsigned 8). See [[#0B: Conditional Pop]] for valid operations | 
-| Y | argument, a1 to 8037E1A0 (signed 32) | 
-| Z | segment address of jump | 
- 
----- 
- 
-==== 0D: Conditional Push ==== 
-If result of operation is true, pushes next command on stack and jumps to segmented address 
- 
-''​0D ?? [XX] 00 [YY YY YY YY]''​ 
- 
-| X | operation, a0 to 8037E1A0 (unsigned 8).  See [[#0B: Conditional Pop]] for valid operations | 
-| Y | argument, a1 to 8037E1A0 (signed 32) | 
- 
----- 
- 
-==== 0E: Conditional Skip ==== 
-If result of operation is false, skips over following 0x0F, 0x10 commands. 
-This command is never used in any of the level scripts. 
- 
-''​0E 08 [XX] 00 [YY YY YY YY]''​ 
- 
-| X | operation, a0 to 8037E1A0 (unsigned 8).  See [[#0B: Conditional Pop]] for valid operations | 
-| Y | argument, a1 to 8037E1A0 (signed 32) | 
- 
- 
----- 
- 
-==== 0F: Skip Next ==== 
-Skips over the following 0x10 commands. 
-This command is never used in any of the level scripts. 
- 
-''​0F 04 00 00''​ 
- 
----- 
- 
-==== 10: No Operation ==== 
-Doesn'​t do anything, nop. 
-This command is never used in any of the level scripts. 
- 
-''​10 04 00 00''​ 
- 
----- 
- 
-==== 11: Set Accumulator From ASM ==== 
-Set level accumulator (8038BE24) from assembly routine. 
- 
-''​11 08 [XX XX] [YY YY YY YY]''​ 
- 
-| X | second argument to function Y | 
-| Y | Assembly routine of format ''​u32 func(u32 a0, u16 A1)''​ | 
- 
-Call assembly routine Y (A0 = word from 0x8038BE24, A1 = halfword X). 
-Store return value at 0x8038BE24. 
-  
-| Game startup | 8016F5B0 | 
-| File select | 801766DC | 
-| File select -> Castle grounds | 8024BD5C | 
-| Other levels | 8024BE14, 8024BCD8 | 
- 
----- 
- 
-==== 12: Actively Set Accumulator ==== 
- 
-''​12 08 [XX XX] [YY YY YY YY]''​ 
- 
- Call assembly routine Y (A0 = word from 0x8038BE24, A1 = halfword X). 
- Store return value at 0x8038BE24. 
- If return value is 0, set upper halfword @ 0x8039BE20 = 0 and do not continue to next command. 
- Else, set upper halfword @ 0x8039BE20 = 1 and continue to the next command. 
- 
-| Demo screen ​ | 8016F5B0 | 
-| File select ​ | 801768A0 | 
-| Other levels | 8024BCD8 | 
- 
----- 
- 
-==== 13: Set Accumulator ==== 
-Set level accumulator (8038BE24) to constant value. 
- 
-''​13 04 [XX XX]''​ 
- 
-| X | Value to set level accumulator | 
- 
----- 
- 
-==== 14: ?? ==== 
-Call 0x802783E8 
- 
-''​14 04 00 00''​ 
- 
----- 
- 
-==== 0x15: ?? ==== 
-Call 0x80278498 
- 
-''​15 04 00 00''​ 
- 
----- 
- 
-==== 16: Load ROM to RAM ==== 
-Load raw data from ROM to absolute RAM address. ​ Call 0x802786F0 (A0 = X, A1 = Y, A2 = Z) 
- 
-''​16 10 00 00 [XX XX XX XX] [YY YY YY YY] [ZZ ZZ ZZ ZZ]''​ 
- 
-| X | RAM address | 
-| Y | ROM address start | 
-| Z | ROM address end | 
- 
----- 
- 
-==== 17: Load ROM to Segment ==== 
-Load raw data from ROM to RAM segment. 
- 
-''​17 0C 00 [XX] [YY YY YY YY] [ZZ ZZ ZZ ZZ]''​ 
- 
-| X | RAM segment number | 
-| Y | ROM address start | 
-| Z | ROM address end | 
- 
----- 
- 
-==== 18: Decompress MIO0 to Segment ==== 
-Load and decompress MIO0 data from ROM to RAM segment. 
- 
-''​18 0C 00 [XX] [YY YY YY YY] [ZZ ZZ ZZ ZZ]''​ 
- 
-| X | RAM segment number | 
-| Y | ROM address start | 
-| Z | ROM address end | 
- 
----- 
- 
-==== 19: Create Mario Demo ==== 
-Create Mario face for the demo screen. 
- 
-''​19 04 00 [XX]''​ 
- 
-| X | Settings: 01 No face, 02 Regular face, 03 Game over face | 
- 
-   Call 0x80278120 (A0 = 0x000E1000, A1 = 0); allocate 0xE1000 bytes for mario face settings 
-   If allocation was successful: 
-   Call 0x8019C450(A0 = 0x000E1000, A1 = pointer to allocated area in ram) 
-   Call 0x8019C418(A0 = 0x80000400, A1 = 0x00025800) 
-   Call 0x8019C418(A0 = 0x8039F800, A1 = 0x00070800) 
-   Call 0x8019C4EC ; data gets loaded into 80000400 and 8039F800 after this call 
-   Call 0x8019C684(A0 = X) 
- 
----- 
- 
-==== 1A: Decompress MIO0 Textures ==== 
-Load and decompress MIO0 data from ROM to RAM segment (level terrain textures) 
- 
-''​1A 0C 00 [XX] [YY YY YY YY] [ZZ ZZ ZZ ZZ]''​ 
- 
-| X | RAM segment number | 
-| Y | ROM address start | 
-| Z | ROM address end | 
- 
----- 
- 
-==== 1B: Start Load Sequence ==== 
-Start load sequence. ​ Used before a chain of load commands. 
- 
-''​1B 04 00 00''​ 
- 
----- 
- 
-==== 1C: ?? ==== 
-Always follows 0x12 command. ​ Used near end of level layout. 
- 
-''​1C 04 00 00''​ 
- 
----- 
- 
-==== 1D: End Load Sequence ==== 
-Used after a chain of load commands. 
- 
-''​1D 04 00 00''​ 
- 
----- 
- 
-==== 1E: ?? ==== 
-Command used near the end of level layout. ​ Maybe builds level collision? 
- 
-''​1E 04 00 00''​ 
- 
----- 
- 
-==== 1F Start Area ==== 
-Start of an area. 
- 
-''​1F 08 [XX] 00 [YY YY YY YY]''​ 
- 
-| XX | Area number | 
-| YY | Segment offset address of geometry layout | 
- 
----- 
- 
-==== 20: End Area ==== 
-End of an area. 
- 
-''​20 04 00 00''​ 
- 
----- 
- 
-==== 21: Load Polygon Without Geo ==== 
-Load polygon data without geometry layout. 
- 
-''​21 08 [X]0 [YY] [ZZ ZZ ZZ ZZ]''​ 
-  
-| X | Drawing layer | 
-| Y | ID of the model to be used with 3D objects | 
-| Z | Segment offset address | 
- 
----- 
- 
-==== 22: Load Polygon With Geo ==== 
-Load polygon data with geometry layout. 
- 
-''​22 08 00 [XX] [YY YY YY YY]''​ 
- 
-| X | ID of the model to be used with 3D objects | 
-| Y | Segment offset address | 
- 
----- 
- 
-==== 23: ?? ==== 
- 
----- 
- 
-==== 24: Place Object ==== 
-Places a 3D object in the level. 
- 
-''​24 18 [AA] [ID] [XX XX] [YY YY] [ZZ ZZ] [RX RX] [RY RY] [RZ RZ] [B1 B1] [B2 B2] [BS] [BO BO BO]''​ 
-  
-| AA | Act mask in which this object will appear in | 
-| ID | ID of the model to use for this object (defined by [[#21: Load Polygon Without Geo]] and [[#22: Load Polygon With Geo]]) | 
-| XX | X position of object (s16) | 
-| YY | Y position of object (s16) | 
-| ZZ | Z position of object (s16) | 
-| RX | Rotation across X axis (s16) | 
-| RY | Rotation across Y axis (s16) | 
-| RZ | Rotation across Z axis (s16) | 
-| B1 | Behavior parameter 1 | 
-| B2 | Behavior parameter 2 | 
-| BS | RAM segment for behavior script | 
-| BO | Offset of the RAM segment | 
- 
----- 
- 
-==== 25: Load Mario ==== 
-Loads the Mario object. 
- 
-''​25 0C 00 [XX] [YY YY YY YY] [ZZ ZZ ZZ ZZ]''​ 
-Always: ''​25 0C 00 01 00 00 00 01 13 00 2E C0''​ 
-  
-| X | ID of the model to use for Mario (defined by [[#21: Load Polygon Without Geo]] and [[#22: Load Polygon With Geo]]) | 
-| Y | Some parameters, not sure what they do. | 
-| Z | RAM segment for behavior script | 
- 
----- 
- 
-==== 26: Connect Warps ==== 
-Connect warps defined by previous [[#24: Place Object]] commands. 
- 
-''​26 08 [AA] [BB] [CC] [DD] 00 00''​ 
-  
-| A | Warp ID to jump from (defined by [[#21: Load Polygon Without Geo]] and [[#22: Load Polygon With Geo]]) | 
-| B | Course ID number to warp to | 
-| C | Course area to jump to | 
-| D | Warp ID number in destination level area | 
- 
----- 
- 
-==== 27: Painting Warp ==== 
-Define level warps for paintings inside the Castle. 
- 
-''​27 08 [AA] [BB] [CC] [DD] 00 00''​ 
-  
-| A | Warp ID to jump from (defined by [[#21: Load Polygon Without Geo]] and [[#22: Load Polygon With Geo]]) | 
-| B | Course ID number to warp to | 
-| C | Course area to jump to | 
-| D | Warp ID number in destination level area | 
- 
----- 
- 
-==== 28: Transport Mario ==== 
-Transport Mario to an area. 
- 
-''​28 0C [??] [AA] [XX XX] [YY YY] [ZZ ZZ] 00 00''​ 
- 
-| ? | Unknown | 
-| A | Course area # to go to | 
-| X | Teleport Mario by this amount on the X axis (s16) | 
-| Y | Teleport Mario by this amount on the Y axis (s16) | 
-| Z | Teleport Mario by this amount on the Z axis (s16) | 
- 
----- 
- 
-==== 29: ?? ==== 
- 
----- 
- 
-==== 2A: ?? ==== 
- 
-''​2A 04 00 00''​ 
----- 
- 
-==== 2B: ?? ==== 
- 
----- 
- 
-==== 2C: ?? ==== 
-''​2C 04 00 00''​ 
- 
----- 
- 
-==== 2D: ?? ==== 
-''​2D 04 00 00''​ 
- 
----- 
- 
-==== 2E: Load Collision ==== 
-Loads terrain collision data for level, and other special models to be placed in the level. 
- 
-''​2E 08 00 00 [XX XX XX XX]''​ 
- 
-| X | Segmented address of [[Collision Data]] | 
- 
----- 
- 
-==== 2F: Render Area?? ==== 
-Decides which area of the level geometry to render. ​ Used in BBH, HMC, and Inside Castle levels. 
-''​2F 08 00 00 [XX XX XX XX]''​ 
- 
-| X | Segment offset pointer to ?? | 
- 
----- 
- 
-==== 30: ?? ==== 
- 
----- 
- 
-==== 31: Set Default Terrain ==== 
-Set default terrain. 
- 
-''​31 04 00 [XX]''​ 
- 
-| X | 00 Normal A, 01 Normal B, 02 Snow, 03 Sand, 04 Haunted house, 05 Water levels, 06 Slippery Slide | 
- 
----- 
- 
-==== 32: No Operation 2 ==== 
-No operation. ​ This command is not used in any of the level scripts. 
-''​32 [XX] ''​ 
- 
----- 
- 
-==== 33: Fade Color ==== 
-Fade/​overlay screen with color. 
- 
-''​33 08 [XX] [YY] [RR] [GG] [BB] 00''​ 
- 
-| X | 01 Enable, 00 Disable | 
-| Y | Controls duration? usually 0x10 | 
-| R,G,B = rgb colors | 
- 
----- 
- 
-==== 34: Blackout Screen ==== 
-Calls [[http://​level42.ca/​projects/​ultra64/​Documentation/​man/​n64man/​os/​osViBlack.html|osViBlack(bool)]] (80323340), passing it  X. 
-''​34 04 [XX] 00''​ 
- 
-| X | 1 = blackout, 0 = cancel blackout | 
- 
----- 
- 
-==== 35: ?? ==== 
-''​35 04 [XX] 00''​ 
-   If X is 0, call 0x803733B0 (A0 = 2) 
-   Else, call 0x803733B0 (A0 = 1) 
- 
----- 
- 
-==== 36: Set Music ==== 
-Set music 
-''​36 08 [??] [??] [??] YY 00 00''​ 
- 
-| ? | Other music parameters? | 
-| Y | Sequence number | 
- 
----- 
- 
-==== 37: Set Music ==== 
-Set music 
- 
-''​37 04 00 [XX]''​ 
- 
-| X | Sequence number | 
- 
----- 
- 
-==== 38: ?? ==== 
-''​38 04 [XX XX]''​ 
- 
-Call 0x8024922C (A0 = X) 
- 
----- 
- 
-==== 39: Place Macro Objects ==== 
-Place macro objects defined in segmented address. 
- 
-''​39 08 00 00 [XX XX XX XX]''​ 
- 
-| X | Segment offset pointer to object placement list | 
- 
-List format: (each entry is 10 bytes) 
- 
-''​[BB BB] [XX XX] [YY YY] [ZZ ZZ] [?? ??​]''​ 
- 
-| B | Object type ID (behavior, model, etc) | 
-| X,Y,Z | Coordinates | 
-| ?? | Always 00 00 ? | 
- 
----- 
- 
-==== 3A: ?? ==== 
- 
----- 
- 
-==== 3B: Jet Stream ==== 
-Define jet streams in JRB or DDD that repulse or suck Mario. 
- 
-''​3B 0C 00 00 [XX XX] [YY YY] [ZZ ZZ] [II II]''​ 
- 
-| X | X position | 
-| Y | Y position | 
-| Z | Z position | 
-| I | Intensity. negative means repulsion, positive means suction | 
- 
----- 
- 
-==== 3C: ?? ==== 
-Get/put remote values? ​ Only used in main or menu level scripts. 
- 
-''​3C 04 [XX] [YY]''​ 
- 
-| X | ?? 01 in main level scripts, 00 in menu | 
-| Y | ?? 00, 02, 03 | 
- 
-===== See Also ===== 
-[[List of Level Scripts]] 
- 
-===== References ===== 
-  * http://​origami64.net/​showthread.php?​tid=160 
-  * http://​qubedstudios.rustedlogic.net/​Mario64_HackingDoc1.5.txt 
-  * http://​s26.photobucket.com/​user/​Starxxon/​media/​M64Diagram.gif.html