Difference between revisions of "DTB"

From Milo Modding Wiki
Jump to navigation Jump to search
m (Document structure of DataNodes within the file)
m (credit ipg for maintaining dtxcs)
 
(2 intermediate revisions by the same user not shown)
Line 30: Line 30:
|2 bytes
|2 bytes
|The number of root nodes.
|The number of root nodes.
|-
|Line number
|Short (LE)
|2 bytes
|The source line of the array.
|-
|-
|Unknown
|Unknown
|Integer (LE)
|Short (LE)
|4 bytes
|2 bytes
|???
|Labeled as "mDeprecated" in the RB2 Wii prototype DWARF info.
|}
|}


Line 115: Line 120:
|-
|-
|0x03
|0x03
|Func
|4 bytes + string length
|The name of a function, in standard length+string format.
|-
|0x04
|Object
|4 bytes + string length
|The name of an Object, in standard length+string format.
|-
|0x05
|Symbol
|Symbol
|4 bytes + string length
|4 bytes + string length
Line 120: Line 135:
|-
|-
|0x06
|0x06
|Empty
|Empty ("unhandled")
|4 bytes
|4 bytes
|Four null bytes.
|Four null bytes.
Line 147: Line 162:
|Command
|Command
|Varies
|Varies
|TODO
|See [[#Nested DataArrays]]
|-
|-
|0x12
|0x12
Line 155: Line 170:
|-
|-
|0x13
|0x13
|Macro
|Property
|Varies
|Varies
|TODO
|See [[#Nested DataArrays]]
|-
|-
|0x20
|0x20
Line 170: Line 185:
|-
|-
|0x22
|0x22
|Include
|Merge
|4 bytes + string length
|4 bytes + string length
|A 32-bit signed integer followed by a UTF8 string.
|A 32-bit signed integer followed by a UTF8 string.
Line 196: Line 211:
=====.dtb=====
=====.dtb=====


{| class="wikitable"
The same as [[#Header]], but without the version byte.
!Name
!Type
!Size
!Function
|-
|Child Nodes
|Short (LE)
|2 bytes
|The number of DataNodes within this DataArray.
|-
|Unknown
|Integer (LE)
|4 bytes
|Some kind of ID?
|}


=====.*_dta_*=====
=====.*_dta_*=====
Line 243: Line 243:
Encrypted files begin with a 4-byte little endian integer which acts as a key for the encryption cipher, followed by an encrypted form of a regular DTB file.
Encrypted files begin with a 4-byte little endian integer which acts as a key for the encryption cipher, followed by an encrypted form of a regular DTB file.


TODO: document the encryption cipher. In the meantime, refer to [https://github.com/InvoxiPlayGames/DtxCS/blob/master/Library/CryptStream.cs CryptStream.cs from DtxCS].
[https://github.com/DarkRTA/rb3/blob/master/src/system/utl/BinStream.cpp#L101 This function] is responsible for the decryption step, and gets its magic numbers from [https://github.com/DarkRTA/rb3/blob/master/src/system/math/Rand2.cpp#L13 this function], whose seed value is set to the encryption key.


==Implementations==
==Implementations==


* [[dtab]] by Onyxite (source code: [https://github.com/mtolly/dtab GitHub])
* [[dtab]] by Onyxite (source code: [https://github.com/mtolly/dtab GitHub])
* [[DtxCS]] by maxton (source code: [https://github.com/maxton/DtxCS GitHub])
* [[DtxCS]] by maxton, maintained by InvoxiPlayGames (source code: [https://github.com/InvoxiPlayGames/DtxCS GitHub])

Latest revision as of 18:45, 3 October 2024

DTB (DaTa Binary?) is the binary serialised counterpart to the plaintext DTA file format. It is capable of storing all DataNodes that the DTA counterpart can store, with the exception of comments.

It is typically stored with .dtb (Guitar Hero 1 through Rock Band 4) and .*_dta_* (Rock Band 4 and Rock Band VR) file extensions.

Structure

There are several variations on the DTB file format, and this dictates the structure of DataArrays in the file (and possibly more), as well as the header.

TODO: further document the actual structure. For now, read the reference implementations for more information

Header

The header is at the start of the file, and serves as information for the DataArray that the file is representing. (TODO: are these correct?)

.dtb

Name Type Size Function
Identifier Byte 1 byte Always 0x01.
Root Nodes Short (LE) 2 bytes The number of root nodes.
Line number Short (LE) 2 bytes The source line of the array.
Unknown Short (LE) 2 bytes Labeled as "mDeprecated" in the RB2 Wii prototype DWARF info.

.*_dta_*

Name Type Size Function
Identifier Byte 1 byte Always 0x01.
Unknown Integer (LE) 4 bytes ???
Root Nodes Short (LE) 2 bytes The number of root nodes.
Unknown Short (LE) 2 bytes ???

Body

The body consists of a DataArray representation, of a count of the root DataNodes specified in the header.

Name Type Size Function
Type Integer (LE) 4 bytes The type of the DataNode
Value Varies Varies The value of the DataNode

Supported DataNode Types

All values are little endian unless specified otherwise. For more information on what these do, see DataNode.

TODO: complete missing values

ID Name Size Value
0x00 Integer 4 bytes A 32-bit signed integer.
0x01 Float 4 bytes A 32-bit single-precision floating point.
0x02 Variable 4 bytes + string length A 32-bit signed integer followed by a UTF8 string.
0x03 Func 4 bytes + string length The name of a function, in standard length+string format.
0x04 Object 4 bytes + string length The name of an Object, in standard length+string format.
0x05 Symbol 4 bytes + string length A 32-bit signed integer followed by a UTF8 string.
0x06 Empty ("unhandled") 4 bytes Four null bytes.
0x07 IfDef 4 bytes + string length A 32-bit signed integer followed by a UTF8 string.
0x08 Else 4 bytes Four null bytes.
0x09 EndIf 4 bytes Four null bytes.
0x10 DataArray Varies See #Nested DataArrays
0x11 Command Varies See #Nested DataArrays
0x12 String 4 bytes + string length A 32-bit signed integer followed by a UTF8 string.
0x13 Property Varies See #Nested DataArrays
0x20 Define 4 bytes + string length A 32-bit signed integer followed by a UTF8 string.
0x21 Include 4 bytes + string length A 32-bit signed integer followed by a UTF8 string.
0x22 Merge 4 bytes + string length A 32-bit signed integer followed by a UTF8 string.
0x23 IfNDef 4 bytes + string length A 32-bit signed integer followed by a UTF8 string.
0x24 Autorun 4 bytes + string length A 32-bit signed integer followed by a UTF8 string.
0x25 Undef 4 bytes + string length A 32-bit signed integer followed by a UTF8 string.

Nested DataArrays

DataArrays in DTB files are prefixed with a header, followed by the regular DTB representation of all values in the nested array.

.dtb

The same as #Header, but without the version byte.

.*_dta_*
Name Type Size Function
Unknown Integer (LE) 4 bytes ????
Child Nodes Short (LE) 2 bytes The number of DataNodes within this DataArray.
Unknown Short (LE) 2 bytes ????

Encryption

DTA files are encrypted when included on-disc. The encryption format was changed in Guitar Hero 2's Xbox 360 release and has been the same since.

Encrypted files begin with a 4-byte little endian integer which acts as a key for the encryption cipher, followed by an encrypted form of a regular DTB file.

This function is responsible for the decryption step, and gets its magic numbers from this function, whose seed value is set to the encryption key.

Implementations

  • dtab by Onyxite (source code: GitHub)
  • DtxCS by maxton, maintained by InvoxiPlayGames (source code: GitHub)