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
behavior_commands [2015/12/07 13:04]
queueram Add commands 0x29-0x2C
— (current)
Line 1: Line 1:
-======== Behavior Commands ======== 
  
-The behavior layout commands define how the objects and Mario are initialized and interact. ​ Like the [[Geometry Layout Commands]], the behavior commands start with a type byte and have no length byte. 
- 
-===== Behavior Commands ===== 
- 
-==== 00: Start ==== 
-Marks start of behavior. If haunted chair (4FD4) or mad piano (5024), it calls BehCommonInit (802A4120). If it is message panel (32E0), it sets 0x194 to 0x43160000 (150.0). 
- 
-''​00 [<color darkgrey>​TT</​color>​] [<color purple>​AA AA</​color>​]''​ 
- 
-| <color darkgrey>​T</​color>​ | Type of object. ​ Used to determine which linked list placed in. | 
-| <color purple>​A</​color>​ | Might be a bit-field, but Behavior00 ignores them | 
- 
-Length: 4 
- 
----- 
- 
-==== 01: State Loop ==== 
-Used by some small effects. ​ if <color purple>​A</​color>​ > current 0x1F4, adds 1 to 0x1F4 of object, otherwise sets to 0.  It loops obj->​0x1F4 from 0 up to <color purple>​A</​color>​ - 1 and then back to 0. 
- 
-''​01 00 [<color purple>​AA AA</​color>​]''​ 
- 
-| <color purple>​A</​color>​ | obj->​0x1F4 = (<color purple>​A</​color>​ >= obj->​0x1F4) ? obj->​0x1F4 + 1 : 0 | 
- 
-Length: 4 
- 
----- 
- 
-==== 02: Jump and Link? ==== 
-Jumps into another behavior and changes obj->​0x1D0. 
- 
-''​02 00 00 00 [<color purple>​AA AA AA AA</​color>​]''​ 
- 
-| <color purple>​A</​color>​ | Segmented address of behavior to jump to | 
- 
-Length: 8 
- 
----- 
- 
-==== 03: Return? ==== 
-Writes something to 0x1D0. jumps into behavior at object->​0x1d4. 
- 
-''​03 00 00 00''​ 
- 
-Length: 4 
- 
----- 
- 
-==== 04: Jump ==== 
-Jumps into another behavior. 
- 
-''​04 00 00 00 [<color purple>​AA AA AA AA</​color>​]''​ 
- 
-| <color purple>​A</​color>​ | Segmented address of behavior to jump to | 
- 
-Length: 8 
- 
----- 
- 
-==== 05: Loop N ==== 
-Loop specified amount of times. 
- 
-''​05 00 [<color purple>​AA AA</​color>​]''​ 
- 
-| <color purple>​A</​color>​ | Number of times to loop | 
- 
-Length: 4 
- 
----- 
- 
-==== 06: End Loop N ==== 
-End 0x05 loop. 
- 
-''​06 00 00 00''​ 
- 
-Length: 4 
- 
----- 
- 
-==== 07: Infinite Loop ==== 
-Jumps back 4 bytes (usually results in infinite loop). 
- 
-''​07 00 00 00''​ 
- 
-Length: 4 
- 
----- 
- 
-==== 08: Loop Start ==== 
-Loop start. 
- 
-''​08 00 00 00''​ 
- 
-Length: 4 
- 
----- 
- 
-==== 09: Loop End ==== 
-End of 08 loop. Behavior script normally ends with this, looping around ASM function (0x0C command). 
- 
-''​09 00 00 00''​ 
- 
-Length: 4 
- 
----- 
- 
-==== 0A: No Op ==== 
-No operation. 
- 
-''​0A 00 00 00''​ 
- 
-Length: 4 
- 
----- 
- 
-==== 0B: Unused ==== 
-No operation. ​ Unused. 
- 
----- 
- 
-==== 0C: Call Function ==== 
-Calls ASM function. ​ Usually used to call object init routine or looping routine between 0x08/0x09 commands. 
- 
-''​0C 00 00 00 [<color purple>​AA AA AA AA</​color>​]''​ 
- 
-| <color purple>​A</​color>​ | ASM routine to call | 
- 
-Length: 8 
- 
----- 
- 
-==== 0D: Update Object ==== 
-Used to offset X, Y, or Z position a bit.  It's useless except for Dorrie. 
- 
-''​0D [<color purple>​AA</​color>​] [<color brown>BB BB</​color>​]''​ 
- 
-| <color purple>​A</​color>​ | Address = <color purple>​A</​color>​*4+88 | 
-| <color brown>​B</​color>​ | float | 
-| obj->​address += (float)B (special cases are 06, 07 and 08. 06 is X, 07 is Y, and 08 is Z-position) || 
- 
-Length: 4 
- 
----- 
- 
-==== 0E: Sight Distance ==== 
-Mostly used for sight distance, does nearly the same as 0x0D. 
- 
-''​0E [<color purple>​AA</​color>​] [<color brown>BB BB</​color>​]''​ 
- 
-| <color purple>​A</​color>​ | Address = <color purple>​A</​color>​*4+88 | 
-| <color brown>​B</​color>​ | float | 
-| obj->​address = (float)B (special case is 45 for sight distance) || 
- 
-Length: 4 
- 
----- 
- 
-==== 0F: Texture Animate ==== 
-Mostly used as texture animation rate. Same as 0x0D, but without float. 
- 
-''​0F [<color purple>​AA</​color>​] [<color brown>BB BB</​color>​]''​ 
- 
-| <color purple>​A</​color>​ | Address = <color purple>​A</​color>​*4+88 | 
-| <color brown>​B</​color>​ | u16 | 
-| obj->​address = B (special case is 1A for texture animation rate) || 
- 
-Length: 4 
- 
----- 
- 
-==== 10: Special Parameter ==== 
-Special Parameter. 
- 
-''​10 [<color purple>​AA</​color>​] [<color brown>BB BB</​color>​]''​ 
- 
-| <color purple>​A</​color>​ | Address = <color purple>​A</​color>​*4+88 | 
-| <color brown>​B</​color>​ | u16 | 
-| obj->​address += B (special case is 2A for interaction or 2F for Bparam2 rate) || 
- 
-Length: 4 
- 
----- 
- 
-==== 11: Bit-set ==== 
-Sets bits designated by mask <color brown>​B</​color>​ at object offset <color purple>​A</​color>​*4+88. 
- 
-''​11 [<color purple>​AA</​color>​] [<color brown>BB BB</​color>​]''​ 
- 
-| <color purple>​A</​color>​ | Address = <color purple>​A</​color>​*4+88 | 
-| <color brown>​B</​color>​ | u16 | 
-| ''​obj->​address |= B''​ || 
- 
-Length: 4 
- 
----- 
- 
- 
-==== 12: Bit-clear ==== 
-Clears bits designated by mask <color brown>​B</​color>​ at object offset <color purple>​A</​color>​*4+88. This is not used by any of the behavior scripts. 
- 
-''​12 [<color purple>​AA</​color>​] [<color brown>BB BB</​color>​]''​ 
- 
-| <color purple>​A</​color>​ | Address = <color purple>​A</​color>​*4+88 | 
-| <color brown>​B</​color>​ | u16 | 
-| ''​obj->​address &= (B ^ 0xFFFF)''​ || 
- 
-Length: 4 
- 
----- 
- 
-==== 13: Add RNG ==== 
-Used in dirt and arrow lift.  Calls 80383BB0 (some RNG). 
- 
-''​13 [<color purple>​AA</​color>​] [<color brown>BB BB</​color>​] [<color darkgrey>​CC CC</​color>​] 00 00''​ 
- 
-| <color purple>​A</​color>​ | Address = <color purple>​A</​color>​*4+88 | 
-| <color brown>​B</​color>​ | u16 | 
-| <color darkgrey>​C</​color>​ | u16 | 
-| obj->​address = <color brown>​B</​color>​ + (80383BB0() >> <color darkgrey>​C</​color>​) || 
- 
-Length: 8 
- 
----- 
- 
-==== 14: Object Type? ==== 
-Mostly used for object type and once for Y-speed. 
- 
-''​14 [<color purple>​AA</​color>​] [<color brown>BB BB</​color>​] [<color darkgrey>​CC CC</​color>​] 00 00''​ 
- 
-| <color purple>​A</​color>​ | Address = <color purple>​A</​color>​*4+88 | 
-| <color brown>​B</​color>​ | float | 
-| <color darkgrey>​C</​color>​ | float | 
-| obj->​address = (float)<​color brown>​B</​color>​ * (float)<​color darkgrey>​C</​color>​ || 
- 
-Length: 8 
- 
----- 
- 
-==== 15: Float Multiply ==== 
-Floating point multiple with float return from 80383CB4(). Used only in bubbles. 
- 
-''​15 [<color purple>​AA</​color>​] [<color brown>BB BB</​color>​] [<color darkgrey>​CC CC</​color>​] 00 00''​ 
- 
-| <color purple>​A</​color>​ | Address = <color purple>​A</​color>​*4+88 | 
-| <color brown>​B</​color>​ | float | 
-| <color darkgrey>​C</​color>​ | float | 
-| obj->​address = <color brown>​B</​color>​ + 80383CB4() * <color darkgrey>​C</​color>​ || 
- 
-Length: 8 
- 
----- 
- 
-==== 16: Float Add ==== 
-Floating point add with float return from 80383CB4(). Used only in water particles. 
- 
-''​16 [<color purple>​AA</​color>​] [<color brown>BB BB</​color>​] [<color darkgrey>​CC CC</​color>​] 00 00''​ 
- 
-| <color purple>​A</​color>​ | Address = <color purple>​A</​color>​*4+88 | 
-| <color brown>​B</​color>​ | float | 
-| <color darkgrey>​C</​color>​ | float | 
-| obj->​address = (float)<​color brown>​B</​color>​ + 80383CB4() + (float)<​color darkgrey>​C</​color>​ || 
- 
-Length: 8 
- 
----- 
- 
-==== 17: Right Shift ==== 
-Right shift C with return from 80383BB0(). Unused. 
- 
-''​17 [<color purple>​AA</​color>​] [<color brown>BB BB</​color>​] [<color darkgrey>​CC CC</​color>​] 00 00''​ 
- 
-| <color purple>​A</​color>​ | Address = <color purple>​A</​color>​*4+88 | 
-| <color brown>​B</​color>​ | u16 | 
-| <color darkgrey>​C</​color>​ | u16 | 
-| obj->​address = <color brown>​B</​color>​ + 80383BB0() >> <color darkgrey>​C</​color>​ || 
- 
-Length: 8 
- 
----- 
- 
-==== 18: No Operation ==== 
-Does nothing. Unused. 
- 
-''​18 ?? ?? ??''​ 
- 
-Length: 4 
- 
----- 
- 
-==== 19: No Operation ==== 
-Does nothing. Unused. 
- 
-''​19 ?? ?? ??''​ 
- 
-Length: 4 
- 
----- 
- 
-==== 1A: No Operation ==== 
-Does nothing. Unused. 
- 
-''​1A ?? ?? ??''​ 
- 
-Length: 4 
- 
----- 
- 
- 
-==== 1B: Change model ID ==== 
-Changes the model ID of current behavior. ​ Used by Mr. I, Bowser flame spawn, and floating wood bridge. 
- 
-''​1B 00 [<color darkgray>​II II</​color>​]''​ 
- 
-| <color darkgray>​I</​color>​ | model ID | 
- 
-Length: 4 
- 
----- 
- 
-==== 1C: Load Child Object ==== 
-Load child object and save child object pointer to 0x6C (automatically follows?). 
- 
-''​1C 00 00 00 [<color darkgray>​II II II II</​color>​] [<color purple>​AA AA AA AA</​color>​]''​ 
- 
-| <color darkgray>​I</​color>​ | model ID | 
-| <color purple>​A</​color>​ | segmented address of child object behavior | 
- 
-Length: C 
- 
----- 
- 
-==== 1D: Deactivate ==== 
-Deactivates object. obj->​active (0x74) = 0 
- 
-''​1D 00 00 00''​ 
- 
-Length: 4 
- 
----- 
- 
-==== 1E: Drop to Ground? ==== 
-Calls 80381794(). ​ Drop to ground? and object->​0xEC |= 0x2; 
- 
-''​1E 00 00 00''​ 
- 
-Length: 4 
- 
----- 
- 
- 
-==== 1F: Used for Waves ==== 
-Sums two floats at offsets B and C and stores in offset A.  Used for waves and bubbles. 
- 
-''​1F [<color darkred>​AA</​color>​] [<color darkgreen>​BB</​color>​] [<color darkblue>​CC</​color>​]''​ 
- 
-| <color darkred>​A</​color>​ | AddressA = <color darkred>​A</​color>​*4+88 | 
-| <color darkgreen>​B</​color>​ | AddressB = <color darkgreen>​B</​color>​*4+88 | 
-| <color darkblue>​C</​color>​ | AddressC = <color darkblue>​C</​color>​*4+88 | 
-| obj->​addressA = obj->​addressB + obj->​addressC || 
- 
-Length: 4 
- 
----- 
- 
-==== 20: Unused ==== 
-Sums two values at offsets B C and stores in offset A? 
- 
-''​20 [<color darkred>​AA</​color>​] [<color darkgreen>​BB</​color>​] [<color darkblue>​CC</​color>​]''​ 
- 
-| <color darkred>​A</​color>​ | AddressA = <color darkred>​A</​color>​*4+88 | 
-| <color darkgreen>​B</​color>​ | AddressB = <color darkgreen>​B</​color>​*4+88 | 
-| <color darkblue>​C</​color>​ | AddressC = <color darkblue>​C</​color>​*4+88 | 
-| obj->​addressA = obj->​addressB + obj->​addressC || 
- 
-Length: 4 
- 
----- 
- 
-==== 21: Set Billboarding ==== 
-Sets billboarding flag (0x04) in graph flags. 
- 
-''​21 00 00 00''​ 
- 
-Length: 4 
- 
----- 
- 
-==== 22: Set 0x10 flag ==== 
-Sets 0x10 in graph flags. 
- 
-''​22 00 00 00''​ 
- 
-Length: 4 
- 
----- 
- 
-==== 23: Collision sphere size ==== 
-Define the collision sphere size. 
- 
-''​23 00 00 00 [<color darkred>​XZ XZ</​color>​] [<color darkgreen>​YY YY</​color>​]''​ 
- 
-| <color darkred>​XZ</​color>​ | X and Z sphere| 
-| <color darkgreen>​Y</​color>​ | Y sphere | 
- 
-Length: 8 
- 
----- 
- 
-==== 24: Nothing ==== 
-Does nothing. Unused. 
- 
-''​24 [<color darkred>​AA</​color>​] [<color darkgreen>​BB BB</​color>​]''​ 
- 
-| <color darkred>​A</​color>​ | Unused | 
-| <color darkgreen>​B</​color>​ | Unused | 
- 
-Length: 4 
- 
----- 
- 
-==== 25: State Cycle ==== 
-Increment obj->​0x1F4 or cycle back to 0 when it reaches obj->​AddressA. Only used in Bubble (Mario) behavior. 
- 
-''​25 [<color darkred>​AA</​color>​] 00 00''​ 
- 
-| <color darkred>​A</​color>​ | AddressA = <color darkred>​A</​color>​*4+88 | 
-| <code c>if (obj->​0x1F4 < obj->​AddressA - 1) { 
-  obj->​0x1F4 += 1; 
-} else { 
-  obj->​0x1F4 = 0; 
-}</​code>​|| 
- 
-Length: 4 
- 
----- 
- 
-==== 26: Loop? ==== 
-Similar to behavior command 0x05, except parameter is only 1 byte. Unused. 
- 
-''​26 [<color darkred>​AA</​color>​] 00 00''​ 
- 
-| <color darkred>​A</​color>​ | Loops? | 
- 
-Length: 4 
- 
----- 
- 
-==== 27: Set Word ==== 
-Store word B at address A of object. Always used with A = 0x26 (addressA = 0x120) to set initial animation with segmented address. 
- 
-''​27 [<color darkred>​AA</​color>​] 00 00 [<color darkred>​BB BB BB BB</​color>​]''​ 
- 
-| <color darkred>​A</​color>​ | AddressA = <color darkred>​A</​color>​*4+88 | 
-| <color darkgreen>​B</​color>​ | value to store in AddressA | 
-| obj->​addressA = <color darkgreen>​B</​color>​ || 
- 
-Length: 8 
- 
----- 
- 
-==== 28: Animates ==== 
-Animates object by advancing animation pointer (obj->​0x120). 
- 
-''​28 [<color darkred>​AA</​color>​] 00 00''​ 
- 
-| <color darkred>​A</​color>​ | animation number (*4) | 
-| ''​8037C658(obj,​ obj->​0x120 + <color darkred>​A</​color>​*4)''​ || 
- 
-Length: 4 
- 
----- 
- 
-==== 29: Load Child Object ==== 
-Load child object. Only used in Koopa flag and poundable. 
- 
-''​29 00 [<color darkred>​AA AA</​color>​] [<color darkgreen>​BB BB BB BB</​color>​] [<color darkblue>​CC CC CC CC</​color>​]''​ 
- 
-| <color darkred>​A</​color>​ | Bparam for child object | 
-| <color darkgreen>​B</​color>​ | model ID | 
-| <color darkblue>​C</​color>​ | Segmented address of behavior | 
- 
-Length: C 
- 
----- 
- 
-==== 2A: Set collision ==== 
-Set collision data. 
- 
-''​2A 00 00 00 [<color darkred>​AA AA AA AA</​color>​]''​ 
- 
-| <color darkred>​A</​color>​ | Segmented address of collision pointer | 
- 
-Length: 8 
- 
----- 
- 
-==== 2B: Set collision sphere ==== 
-Set collision data. 
- 
-''​2B 00 00 00 [<color darkred>​AA AA</​color>​] [<color darkgreen>​BB BB</​color>​] [<color darkblue>​CC CC</​color>​]''​ 
- 
-| <color darkred>​A</​color>​ | X/Z sphere as int | 
-| <color darkgreen>​B</​color>​ | Y sphere as int | 
-| <color darkblue>​C</​color>​ | obj->​0x208 = (float)<​color darkblue>​C</​color>​ | 
- 
-Length: C 
- 
----- 
- 
-==== 2C: Spawn Object ==== 
-Spawns object. Same as 0x1C, but stores child obj pointer to parent->​0x6C. 
- 
-''​2C 00 00 00 [<color darkred>​AA AA AA AA</​color>​] [<color darkgreen>​BB BB BB BB</​color>​] [<color darkblue>​CC CC</​color>​]''​ 
- 
-| <color darkred>​A</​color>​ | model ID | 
-| <color darkgreen>​B</​color>​ | Segmented address of behavior | 
- 
-Length: C 
- 
-===== See Also ===== 
-[[List of Behaviors]] 
- 
-===== References ===== 
-  * http://​www.smwcentral.net/?​p=viewthread&​t=67851 (RIP) 
-  * https://​sites.google.com/​site/​kazemario64/​home/​all-behavior-commands