User Tools

Site Tools


super_mario_64:behavior_commands

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 [TT] [AA AA]

T Type of object. Used to determine which linked list placed in.
A Might be a bit-field, but Behavior00 ignores them
List Description
00 Mario
01 Unused
02 Objects that can be used to destroy other objects, like bob-ombs and corkboxes.
03 Unused
04 Most normal 'enemies' or actors are on this list.
05 This is a group of objects which can push each other around as well as their parent objects.
06 General level objects such as heart, star.
07 Unused
08 Default list.
09 Objects that use a collision model.
0A Objects that attract or otherwise “cling” mario similar to a pole action.
0B Spawners
0C Objects that will not load if there are not enough object slots.

Length: 4


01: State Loop

Used by some small effects. if A > current 0x1F4, adds 1 to 0x1F4 of object, otherwise sets to 0. It loops obj→0x1F4 from 0 up to A - 1 and then back to 0.

01 00 [AA AA]

A obj→0x1F4 = (A >= obj→0x1F4) ? obj→0x1F4 + 1 : 0

Length: 4


Jumps into another behavior and changes obj→0x1D0.

02 00 00 00 [AA AA AA AA]

A 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 [AA AA AA AA]

A Segmented address of behavior to jump to

Length: 8


05: Loop N

Loop specified amount of times.

05 00 [AA AA]

A 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: End Behavior script

Marks the end of a behavior that doesn't use a loop.

0A 00 00 00

Length: 4


0B: End Behavior script (Unused)

Marks the end of a behavior that doesn't use a loop. Exactly the same as command 0xA, except this never seems to be used.

0B 00 00 00

Length: 4


0C: Call Function

Calls an ASM function in RAM.

0C 00 00 00 [AA AA AA AA]

A RAM address of ASM function to call

Length: 8


0D: Offset by Float

Used to offset the value of an address by a float.

0D [AA] [BB BB]

A Address = A*4+88
B s16
obj→address += B(float)

Length: 4


0E: Set to Float

Used to set the value of an address to a float.

0E [AA] [BB BB]

A Address = A*4+88
B s16
obj→address = B(float)

Length: 4


0F: Offset by Integer

Used to offset the value of an address by an integer.

0F [AA] [BB BB]

A Address = A*4+88
B u16
obj→address += B

Length: 4


10: Set to Integer

Used to set the value of an address to an integer.

10 [AA] [BB BB]

A Address = A*4+88
B u16
obj→address = B

Length: 4


11: Bit-set

Sets bits designated by mask B at object offset A*4+88.

11 [AA] [BB BB]

A Address = A*4+88
B u16
obj→address |= B

Length: 4


12: Bit-clear

Clears bits designated by mask B at object offset A*4+88. This is not used by any of the behavior scripts.

12 [AA] [BB BB]

A Address = A*4+88
B u16
obj→address &= (B ^ 0xFFFF)

Length: 4


13: Add RNG

Used in dirt and arrow lift. Calls 80383BB0 (some RNG).

13 [AA] [BB BB] [CC CC] 00 00

A Address = A*4+88
B u16
C u16
obj→address = B + (80383BB0() » C)

Length: 8


14: Object Type?

Mostly used for object type and once for Y-speed.

14 [AA] [BB BB] [CC CC] 00 00

A Address = A*4+88
B float
C float
obj→address = (float)B * (float)C

Length: 8


15: Float Multiply

Floating point multiple with float return from 80383CB4(). Used only in bubbles.

15 [AA] [BB BB] [CC CC] 00 00

A Address = A*4+88
B float
C float
obj→address = B + 80383CB4() * C

Length: 8


16: Float Add

Floating point add with float return from 80383CB4(). Used only in water particles.

16 [AA] [BB BB] [CC CC] 00 00

A Address = A*4+88
B float
C float
obj→address = (float)B + 80383CB4() + (float)C

Length: 8


17: Add RNG 2

Right shift C with return from 80383BB0(). Unused.

17 [AA] [BB BB] [CC CC] 00 00

A Address = A*4+88
B u16
C u16
obj→address = (obj→address + B) + (80383BB0() » C)

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 [II II]

I model ID

Length: 4


1C: Load Child Object

Load child object and save child object pointer to 0x6C (automatically follows?).

1C 00 00 00 [II II II II] [AA AA AA AA]

I model ID
A 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 [AA] [BB] [CC]

A AddressA = A*4+88
B AddressB = B*4+88
C AddressC = C*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 [AA] [BB] [CC]

A AddressA = A*4+88
B AddressB = B*4+88
C AddressC = C*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 Render Invisible flag

Sets Render Invisible (0x10) in graph flags.

22 00 00 00

Length: 4


23: Collision cylinder size

Define the collision cylinder size.

23 00 00 00 [RR RR] [HH HH]

R Radius of collision cylinder
H Height of collision cylinder

Length: 8


24: Nothing

Does nothing. Unused.

24 [AA] [BB BB]

A Unused
B 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 [AA] 00 00

A AddressA = A*4+88
if (obj->0x1F4 < obj->AddressA - 1) {
  obj->0x1F4 += 1;
} else {
  obj->0x1F4 = 0;
}

Length: 4


26: Loop?

Similar to behavior command 0x05, except parameter is only 1 byte. Unused.

26 [AA] 00 00

A 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 [AA] 00 00 [BB BB BB BB]

A AddressA = A*4+88
B value to store in AddressA
obj→addressA = B

Length: 8


28: Animates

Animates object by advancing animation pointer (obj→0x120).

28 [AA] 00 00

A animation number (*4)
8037C658(obj, obj→0x120 + A*4)

Length: 4


29: Load Child Object

Load child object. Only used in Koopa flag and poundable.

29 00 [AA AA] [BB BB BB BB] [CC CC CC CC]

A Bparam for child object
B model ID
C Segmented address of behavior

Length: C


2A: Set Collision

Set collision data.

2A 00 00 00 [AA AA AA AA]

A Segmented address of collision pointer

Length: 8


2B: Set Collision Sphere

Set collision data.

2B 00 00 00 [AA AA] [BB BB] [CC CC] 00 00

A X/Z sphere as int
B Y sphere as int
C obj→-Y offset(0x208) = (float)C

Length: C


2C: Spawn Object

Spawns object. Same as 0x1C, but stores child obj pointer to parent→0x6C.

2C 00 00 00 [AA AA AA AA] [BB BB BB BB]

A model ID
B Segmented address of behavior

Length: C


2D: Set Init Position

Declare initial position. Saves positions to 0x164, 0x168, and 0x16C. Used in Dorrie, Fly guys, etc. to determine in which range they can move.

2D 00 00 00

Length: 4


2E: Set Hurtbox

Sets object hurtbox radius and height

2E 00 00 00 [AA AA] [BB BB]

A obj→Hurtbox Radius (0x200) = (float) A
B obj→Hurtbox Height (0x204) = (float) B

Length: 8


2F: Set Interaction

Set interaction (obj→0x130). Same as 27 2A.

2F 00 00 00 [AA AA AA AA]

A Interaction (see table below)
Interaction Description
00000001 Mario can hang from it
00000002 Mario can pick it up
00000004 Door
00000008 Damages Mario (normal)
00000010 Coin
00000020 Cap
00000040 Pole
00000080 Damages Mario (can be punched, bounced on)
00000100 Damages Mario (can be punched)
00000200 Nothing (can be punched)
00000400 Blows Mario away
00000800 Warp door
00001000 Star
00002000 Warp hole
00004000 Cannon
00008000 Damages Mario (can be punched, bounced on)
00010000 Replenishes health
00020000 Bully
00040000 Flame
00080000 Koopa shell
00100000 Damages Mario (can be punched, bounced on)
00200000 Damages Mario
00400000 Damages Mario (can be punched and bounced on)
00800000 Message
01000000 Makes Mario spin
02000000 Makes Mario fall?
04000000 Damages Mario
08000000 Warp (Mario shrinks in)
10000000 Damages Mario
20000000 Electrocutes Mario
40000000 Normal

Length: 8


30: Set Gravity

Set gravity.

30 00 00 00 [AA AA] [BB BB] [CC CC] [DD DD] [EE EE] [FF FF] [GG GG] [HH HH]

A obj→oWallHitboxRadius = (float)A
B obj→oGravity = (float)B/100
C obj→oBounce = (float)C/100
D obj→oDragStrength = (float)D/100
E obj→oFriction = (float)E/100
F obj→oBuoyancy = (float)F/100
G Ignored
H Ignored

Length: 0x14


31: Set Interaction Sub-Type

Sets obj→0x190

31 00 00 00 [AA AA AA AA]

A obj→Interaction SubType (0x190) = A

Length: 8


32: Scale Object

Scale object uniformly, sets X, Y, Z scaling to A as percent.

32 00 [AA AA]

A scale value (percent)
ScaleObject((float)A/100.0f;

Length: 4


33: Child Object Change

Clear flags in address of child object.

33 [AA] 00 00 [BB BB BB BB]

A AddressA = A*4+88
B bit values to clear
obj→child(0x68)→addressA &= ~B

Length: 8


34: Texture Animate Rate

Clear flags in address of child object. Only used for texture animation rate (0x1A).

34 [AA] [BB BB]

A AddressA = A*4+0x88
B divide value at 0x8032d5d4 with this (see code below)
if ((*0x8032d5d4 / B) == 0) {
  addressA = A*4 + 0x88;
  obj->addressA += 1;
}
return 0;

Length: 4


35: Clear Graph Flag

Clears least significant bit of graph (obj→0x02 &= 0xFFFE).

35 00 00 00

Length: 4


36: Set Value

Store value B at address A. Unused.

36 [AA] 00 00 [BB BB] 00 00

A AddressA = A*4+0x88
B value (u16)
obj→addressA = (u32)value

Length: 8


37: Spawn Something

Spawns something. Only used in waves generator and surface waves.

37 00 00 00 [AA AA AA AA]

A Spawn function address

Length: 8

See Also

References

super_mario_64/behavior_commands.txt · Last modified: 2019/11/03 09:17 by jesusyoshi54