Difference between revisions of "Background/Arena File Format (.BK)"

From WTFwiki
Jump to navigation Jump to search
m (19 revisions)
 
(17 intermediate revisions by 2 users not shown)
Line 4: Line 4:
  
 
{| border='1'
 
{| border='1'
|Unknown || 1 BYTE || 0 for INTRO, 2 for ending cutscenes,4 for main menu/newsroom/VS/Mechlab/melee, 6 for credits,
+
|Unknown || 1 DWORD || 0 for INTRO, 2 for ending cutscenes,4 for main menu/newsroom/VS/Mechlab/melee, 6 for credits,
 
8 for Arena0, 16 for Arena1, 32 for Arena2, 64 for Arena3 and 128 for Arena4
 
8 for Arena0, 16 for Arena1, 32 for Arena2, 64 for Arena3 and 128 for Arena4
 
|-
 
|-
|Unknown || 1 DWORD || ?
+
|Unknown || 1 BYTE || ? 1, 2 or variable
 
|-
 
|-
|Width || 1 WORD || Background width? (always 320?)
+
|Width || 1 WORD || Background width (always 320?)
 
|-
 
|-
| Height || 1 WORD || Background height? (always 200?)
+
| Height || 1 WORD || Background height (always 200?)
 
|}
 
|}
  
 
== Animations ==
 
== Animations ==
Each animation is preceeded by the offset of the next animation stored as a DWORD. Reading the animation and advancing the file pointer should result in the file pointer being the same as this value. When the value is the same as the value for the previous animation, the animation block is at an end.
+
Each animation is preceded by the offset of the next animation stored as a DWORD, along with an animation number. Reading the animation and advancing the file pointer should result in the file pointer being the same as the ''next animation'' offset. An ''animation number'' >= 50 marks the end of the animations section. When this occurs, the ''next animation'' offset is set to the offset of the current animation.
  
 
{| border='1'
 
{| border='1'
|Next Animation || 1 DWORD || position of next animation, in bytes
+
|Next animation || 1 DWORD || Position of next animation relative to start of file, in bytes
 +
|-
 +
|Animation number || 1 BYTE || Unique identifier for animation
 
|}
 
|}
  
Line 24: Line 26:
  
 
{| border='1'
 
{| border='1'
|Animation Number || 1 WORD || Unique identifier for animation
+
| Unknown || 1 BYTE || Nul padding? (not for fire pit wandering orb)
 +
|-
 +
| Unknown A || 1 BYTE || Animation to chain to if collision/hit (eg. fire orb 15 -> fire ball 17)
 +
|-
 +
| Unknown B || 1 BYTE || Animation to chain to on no collision/hit(?) (eg. fire orb 15 -> fire orb fade 16)
 +
|-
 +
| Repeat || 1 BYTE || 255 for repeating animations (eg. spotlights on main menu, torches in fire pit, newscaster's lips/eyes), Desert animation (spawn the planes) 0 has 254 in this field.
 +
|-
 +
| Probability || 1 WORD || How likely this is to happen, lower is higher probability, 0 means never. 1 for torches/'cloud of dust' in fire pit, 200 for 'cloud of dust' in desert, 1000 for spikes in spike pit. For example, setting this to 1 for animation 0 in the desert means that planes will always be strafing you.
 +
|-
 +
| Unknown E || 1 BYTE || Arena hazard damage (eg. spike pit, fire pit fireball, electric walls in powerplant)?
 +
|-
 +
| Something size || 1 WORD ||
 +
|-
 +
| Something || N BYTES || Animation string, size is determined by the previous value
 +
|}
 +
 
 +
There then follows an [[HAR File Format (.AF)#Animation|AF Animation Structure]].
 +
 
 +
== Footer ==
 +
 
 +
After the animations there is a footer structure:
 +
 
 +
{| border='1'
 +
| Background image || W*H BYTES || W and H are the ''width'' and ''height'' in the file header
 +
|-
 +
| Num palettes || 1 BYTE || Specifies the number of palettes which follow
 +
|}
 +
 
 +
=== Palettes ===
 +
 
 +
{| border='1'
 +
| Palette data || 256 * 3 BYTES || A palette
 
|-
 
|-
| Unknown || 1 BYTE || Nul padding?
+
| Palette remapping tables || 19 * 256 BYTES || See below
 +
|}
 +
 
 +
The palette remapping tables are maps from image colour indices into palette indices, for various different colour effects. The tables are for:
 +
 
 +
{| border='1'
 +
! Index !! Purpose
 +
|-
 +
| 0-3 || Fade to black, for shadows
 +
|-
 +
| 4 || Dark blue, for menu backgrounds
 
|-
 
|-
| Unknown || 1 DWORD || This is a magic value that somehow relates to the subsequent animation structure
+
!colspan=2| Most BK files
 
|-
 
|-
| Unknown || 13 BYTES || This value is here unless the previous value is 'weird' (65536000 or 18 or 15?)
+
| 5-8 || Saturating to white, then black-and-white (newsroom transition?)
 +
|-
 +
| 9-13 || Saturating light blue -> white (lightning flashes?)
 +
|-
 +
| 14-18 || Green (?)
 +
|-
 +
!colspan=2| Fire pit [3 palettes: normal, fire, ice]
 +
|-
 +
| ?? || TODO
 +
|-
 +
!colspan=2| Desert [4 palettes]
 +
|-
 +
| 5-18 || Slow fade to white
 
|}
 
|}
 +
 +
=== Rest of footer ===
 +
An [[HAR File Format (.AF)#Footer|AF Footer]] follows.
 +
 +
== Sample Implementations ==
 +
 +
[[PythonAfBkParser|Sample python parser for .af and .bk files]]

Latest revision as of 21:49, 4 January 2013

The BK file format is similar in many ways to the AF file format, however, there are some signifigant differences.

Header

Unknown 1 DWORD 0 for INTRO, 2 for ending cutscenes,4 for main menu/newsroom/VS/Mechlab/melee, 6 for credits,

8 for Arena0, 16 for Arena1, 32 for Arena2, 64 for Arena3 and 128 for Arena4

Unknown 1 BYTE ? 1, 2 or variable
Width 1 WORD Background width (always 320?)
Height 1 WORD Background height (always 200?)

Animations

Each animation is preceded by the offset of the next animation stored as a DWORD, along with an animation number. Reading the animation and advancing the file pointer should result in the file pointer being the same as the next animation offset. An animation number >= 50 marks the end of the animations section. When this occurs, the next animation offset is set to the offset of the current animation.

Next animation 1 DWORD Position of next animation relative to start of file, in bytes
Animation number 1 BYTE Unique identifier for animation

Animation Header

Unknown 1 BYTE Nul padding? (not for fire pit wandering orb)
Unknown A 1 BYTE Animation to chain to if collision/hit (eg. fire orb 15 -> fire ball 17)
Unknown B 1 BYTE Animation to chain to on no collision/hit(?) (eg. fire orb 15 -> fire orb fade 16)
Repeat 1 BYTE 255 for repeating animations (eg. spotlights on main menu, torches in fire pit, newscaster's lips/eyes), Desert animation (spawn the planes) 0 has 254 in this field.
Probability 1 WORD How likely this is to happen, lower is higher probability, 0 means never. 1 for torches/'cloud of dust' in fire pit, 200 for 'cloud of dust' in desert, 1000 for spikes in spike pit. For example, setting this to 1 for animation 0 in the desert means that planes will always be strafing you.
Unknown E 1 BYTE Arena hazard damage (eg. spike pit, fire pit fireball, electric walls in powerplant)?
Something size 1 WORD
Something N BYTES Animation string, size is determined by the previous value

There then follows an AF Animation Structure.

Footer

After the animations there is a footer structure:

Background image W*H BYTES W and H are the width and height in the file header
Num palettes 1 BYTE Specifies the number of palettes which follow

Palettes

Palette data 256 * 3 BYTES A palette
Palette remapping tables 19 * 256 BYTES See below

The palette remapping tables are maps from image colour indices into palette indices, for various different colour effects. The tables are for:

Index Purpose
0-3 Fade to black, for shadows
4 Dark blue, for menu backgrounds
Most BK files
5-8 Saturating to white, then black-and-white (newsroom transition?)
9-13 Saturating light blue -> white (lightning flashes?)
14-18 Green (?)
Fire pit [3 palettes: normal, fire, ice]
?? TODO
Desert [4 palettes]
5-18 Slow fade to white

Rest of footer

An AF Footer follows.

Sample Implementations

Sample python parser for .af and .bk files