This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
|
behavior_commands [2015/12/03 15:41] 127.0.0.1 external edit |
— (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 ==== | ||
| - | Used for waves and bubbles. Sums two floats at offsets B C and stores in offset A. | ||
| - | |||
| - | ''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 | ||
| - | |||
| - | ---- | ||
| - | |||
| - | ===== 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 | ||