Difference between revisions of "BHAV"

From SimsWiki
Jump to: navigation, search
m (Added categories)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{OldWikiEntry}} ====""SimAntics"" Behavioural Function====
+
{{Resource tgi
 +
|hex code = [[42484156]]
 +
|short = BHAV
 +
|long = Behaviour Function
 +
}}
  
__All BHAVs have a similar basic format:__
+
==Introduction==
64 - Filename (null terminated)
+
This resource is the one where the programming of an object takes place. The BHAV is the code that runs to control an object. The programming language of a BHAV is known as [[SimAntics]]. Each node in a BHAV has an [[OpCode]] and a number of operands. These nodes can be [[Node linkages|linked together]] so that depending on the outcome of an OpCode, a certain path can be taken through the BHAV.
12 - Header
+
''var'' - Instruction 1
+
''var'' - Instruction 2
+
''var'' - Instruction n
+
...
+
  
__Each header also uses a similar format:__
+
==Declaring your stack variables==
2 - signature (0x8000 through 0x8009)
+
[[Image:StackVariableDeclaration.jpg|frame|Fields for declaring stack variables]]If you use any [[Sims 2 Param|parameters]] into your BHAV, you must declare how many of them in the "Arg Count" field. If you want to make these arguments more useful, you can give them labels ([[TPRP]]). If you use any [[Sims 2 Local|local]] variables you must declare how many of them in the "Local Var Count".
2 - count (number of instructions in file)
+
1 - tree type (deprecated)
+
1 - args (number of Parameters passed to the subroutine)
+
1 - locals (number of local variables used in the subroutine)
+
1 - header flag (deprecated)
+
4 - Tree Version # (signed integer)
+
  
 +
<br clear="all"/>
  
The signature also defines the structure of the individual
+
[[Category:Sims 2 Modding]]
instructions, as follows:
+
*  8000, 8001 & 8002 (instruction length: 12 bytes)
+
- 2 - Function/OpCode
+
- 1 - Goto on True
+
- 1 - Goto on False
+
- 8 - Operands
+
*  8003 & 8004 (instruction length: 20 bytes)
+
- 2 - Function/OpCode
+
- 1 - Goto on True
+
- 1 - Goto on False
+
- 16 - Operands
+
*  8005 & 8006 (instruction length: 21 bytes)
+
- 2 - Function/OpCode
+
- 1 - Goto on True
+
- 1 - Goto on False
+
- 1 - Node Version (Flag - 0x00 or 0x01)
+
- 16 - Operands
+
*  8007 & 8008 (instruction length: 23 bytes)
+
- 2 - Function/OpCode
+
- 2 - Goto on True
+
- 2 - Goto on False
+
- 1 - Node Version (Flag - 0x00 or 0x01)
+
- 16 - Operands
+
*  8009 (instruction length: 24 bytes)
+
- 2 - Function/OpCode
+
- 2 - Goto on True
+
- 2 - Goto on False
+
- 1 - Node Version (Flag - 0x00 or 0x01)
+
- 16 - Operands
+
- 1 - Cacheflags
+
 
+
Notes:
+
The 1-byte Goto statements in 8001-8006 appear to be the same as
+
  was used in TS1: 0xFD as Error, 0xFE as True, and 0xFF as False.
+
 
+
The 2-byte Goto statements in 8007 appear to be using
+
  0xFFFC as Error, 0xFFFD as True, and 0xFFFE as False.
+
 
+
The 8007 format can contain more than 256 seperate instructions,
+
  thus the use of 2-byte Goto statements.
+
 
+
Number of each signature type (0x8000 - 0x8007) contained in objects.package:
+
0x8000 - 1
+
0x8001 - 2
+
0x8002 - 25
+
0x8003 - 75
+
0x8004 - 4
+
0x8005 - 285
+
0x8006 - 1,357
+
0x8007 - 15,507
+
 
+
[[Category:Modding]]
+
 
[[Category:InternalFormats]]
 
[[Category:InternalFormats]]
 
[[Category:FormatsByName]]
 
[[Category:FormatsByName]]

Latest revision as of 18:09, 17 September 2012

42484156
Short name: BHAV
Long name: Behaviour Function

[edit] Introduction

This resource is the one where the programming of an object takes place. The BHAV is the code that runs to control an object. The programming language of a BHAV is known as SimAntics. Each node in a BHAV has an OpCode and a number of operands. These nodes can be linked together so that depending on the outcome of an OpCode, a certain path can be taken through the BHAV.

[edit] Declaring your stack variables

Fields for declaring stack variables
If you use any parameters into your BHAV, you must declare how many of them in the "Arg Count" field. If you want to make these arguments more useful, you can give them labels (TPRP). If you use any local variables you must declare how many of them in the "Local Var Count".


Personal tools
Namespaces

Variants
Actions
Navigation
game select
Toolbox