Difference between revisions of "Opening.bnr"

From WiiBrew
Jump to navigation Jump to search
(Initial Opening.bnr information)
 
(→‎IMET: Updated)
 
(43 intermediate revisions by 20 users not shown)
Line 1: Line 1:
=opening.bnr=
+
'''Opening.bnr''', also known as 00000000.app, is a file related to Wii homebrew development. The file is one of the first read by the Wii when a new DVD is inserted (as is 00000000.app for channels), and it is used to display the banner (the channel animation). Even though Opening.bnr shares the name with the file on the GameCube, the content of the file has no resemblance to the GC Opening.bnr file.
  
==Description==
+
== Description ==
Opening.bnr is the banner file located on wii discs which contains the channel icon, banner, animation and sound. A Similar opening.bnr exists on Gamecube discs. However, the format has been expanded for the wii to include more content.
+
Opening.bnr consists of two parts, an IMET header which is (almost) identical to the latter of part A (starting from Zeroes_1) in [[Content.bin]] (see [[Content.bin file structure]]). However, the last 16 bytes contain some random-looking bytes which are, in fact, an MD5 sum of 0x40 to 0x640 in the header.
  
==Opening.bnr Struct==
+
Opening.bnr is also stored in the console specific encrypted area of content.bin (a copy of icon.bin is in the SD encrypted area). For some of the channels a generic opening.bnr (which doesn't resemble the actual banner) is stored in the NAND under the \META tree as TITLE.MET. Their purpose is unknown.
{| border="1"
+
The proper ones can be found in the unencrypted NAND as one of the .app files, content index 0 (you can get this from the TMD). Also some of those the offset to the IMET header is at 0x80 instead of 0x40.
 +
 
 +
After the header follows an [[U8 archive]]. This is an archive consisting of the following contents:
 +
 
 +
 
 +
{| class="wikitable"
 +
|-
 +
! Full Path
 +
! Description
 +
|-
 +
| /meta/
 +
| Directory
 +
|-
 +
| [[#banner.bin and icon.bin|/meta/banner.bin]]
 +
| Contains the images and animation displayed when the channel is selected.
 +
|-
 +
| [[#banner.bin and icon.bin|/meta/icon.bin]]
 +
| Contains the images and animation displayed when the channel is in the menu.
 +
|-
 +
| [[#sound.bin|/meta/sound.bin]]
 +
| Contains the audio that is played when the channel is selected.
 +
|}
 +
 
 +
== banner.bin and icon.bin ==
 +
The banner.bin and icon.bin files are (usually, though not required to be) LZ77 compressed [[U8 archive]]s themselves, each with an IMD5 header, containing the MD5 of the file (described below).
 +
 
 +
More information on LZ77 compression can be found on [http://en.wikipedia.org/wiki/LZ77_and_LZ78 Wikipedia]. Example C# source is available in the [[#Tools and Example Source|Tools and Example Source]] section.
 +
 
 +
The banner.bin and icon.bin U8 archives have a file format like this:
 +
{| class="wikitable"
 +
|-
 +
! Full Path
 +
! Description
 +
|-
 +
| /arc/
 +
| Directory
 +
|-
 +
| /arc/anim/
 +
| Contains the images and animation displayed when the channel is selected.
 +
|-
 +
| /arc/anim/*.brlan
 +
| Contains the animation.
 
|-
 
|-
! Location
+
| /arc/blyt/
! Number of Bytes
+
| Contains the images and animation displayed when the channel is selected.
! Description
 
 
|-
 
|-
| 0-64
+
| /arc/blyt/*.brlyt
| 64
+
| Contains the layout used in the animation.
| Padding (0x00)
 
 
|-
 
|-
| 64-92
+
| /arc/timg/
| 28
+
| Contains the images used.
| ??
 
 
|-
 
|-
| 92-176
+
| /arc/timg/*.tpl
| 84
+
| The images, in standard GC TPL format.
| Title (Null separated characters)
+
|}
 +
 
 +
=== TPL Files ===
 +
The TPL files are textures. They can be read by the tplx program from the gcube library, and created using gentpl from [[benzin]].
 +
 
 +
The format is also described in [[YAGCD]] at http://pabut.homeip.net:8000/yagcd/chap14.html#sec14.4. It can contain many different independent texture formats, with varying sizes and supports, and can contain multiple textures in one file.
 +
 
 +
=== brlan Files ===
 +
brlan files are described in the [[Wii Animations#Animations .28.2A.brlan.29|Wii Animations]] section, and can be created and parsed with [[benzin]].
 +
 
 +
=== brlyt Files (Layout) ===
 +
brlyt files are described in the [[Wii Animations#Textures and Material lists .28.2A.brlyt.29|Wii Animations]] section, and can be created and parsed with [[benzin]].
 +
 
 +
== sound.bin ==
 +
sound.bin also has an IMD5 header. Currently, three sound.bin formats have been discovered.
 +
 
 +
{| class="wikitable"
 
|-
 
|-
| 176-504
+
! Format
| 84 x 6
+
! Hex Identifier
| Title above repeated 6 times. (Possible that these are descriptions or something...)
+
! Description
 
|-
 
|-
| 504-1332
+
| BNS
| 828
+
| 0x42 0x4E 0x53 0x20 (BNS )
| Padding (0x00)
+
| Similar to the brstm format, always in the NGC-DSP ADPCM format, supports having an intro sound and a loop point.
 
|-
 
|-
| 1332-1440
+
| WAV
| 108
+
| 0x52 0x49 0x46 0x46 (RIFF)
| ?? (cksum or prefix to file data of some sort)
+
| Standard wav/(16 bit) PCM format, supports having an intro sound and a loop point using the tool Wavosaur (PC). Can be LZ77 compressed.
 
|-
 
|-
| 1440-EOF
+
| AIFF
| ??
+
| 0x46 0x4F 0x52 0x4D (FORM)
| ?? (File Data (/banner.bin, /icon.bin, /sound.bin)
+
| Standard AIFF/PCM format, only plays once. Can be LZ77 compressed.
 
|}
 
|}
  
==banner.bin==
+
== Header Formats ==
 +
=== IMD5 ===
 +
<source lang="c">
 +
typedef struct {
 +
u32 imd5; // 'IMD5'
 +
u32 filesize; //size of rest of file
 +
u8 zeroes[8]; //padding
 +
u8 crypto[16]; //MD5 of rest of file
 +
} IMD5;
 +
</source>
 +
=== IMET ===
 +
<source lang="c">
 +
typedef struct {
 +
    u8 zeroes[64]; // padding
 +
    u32 imet; // "IMET"
 +
    u32 hashsize; // Hash length
 +
    u32 unk;  // 3 fixed, unknown purpose. Possibly file count?
 +
    u32 sizes[3]; // icon.bin, banner.bin, sound.bin
 +
    u32 flag1; // unknown
 +
    u8 names[10][84]; // Japanese, English, German, French, Spanish, Italian, Dutch, unknown, unknown, Korean
 +
    u8 zeroes_2[588]; // padding
 +
    u8 crypto[16]; // MD5 of 0 to 'hashsize' in header. crypto should be all 0's when calculating final MD5
 +
} IMET;
 +
</source>
 +
 
 +
=== BNS ===
 +
<source lang="c">
 +
// Header
 +
typedef struct {
 +
u32 bns; // 'BNS '
 +
u32 version; // 0xFEFF0100 endianness and format version check
 +
u32 filesize; // size of entire BNS
 +
u16 headersize; // size of BNS header (including chunkinfo)
 +
u16 chunkcount; // number of chunks
 +
struct {
 +
u32 offset; // offset from start of BNS of chunk header
 +
u32 size; // size of chunk including header
 +
} chunkinfo[chunkcount]; // info for each chunk
 +
} BNS;
 +
 
 +
// Chunk header
 +
typedef struct {
 +
u32 type; // 'INFO' or 'DATA'
 +
u32 size; // size including header
 +
} BNS_chunk;
 +
 
 +
// INFO chunk
 +
typedef struct {
 +
u8 unk; // 0, possibly format control
 +
u8 loop; // loop flag, 0 = no loop, 1 = loop
 +
u8 channels; // channel count
 +
u8 unk2; // 0, padding?
 +
u16 samplerate; // sample rate (Hz)
 +
u16 pad; // 0
 +
u32 loopstart; // loop start sample
 +
u32 samples; // total sample count
 +
u32 offset; // offset (in INFO) to channel info offset list
 +
u32 unk4; // 0, padding?
 +
} INFO_chunk;
 +
 
 +
// channel info offset list
 +
typdef struct {
 +
u32 offset[channels]; // offset (in INFO) to channel info for each channel
 +
} channel_info_offset_list
 +
 
 +
// channel info (for DSP ADPCM)
 +
typedef struct {
 +
u32 data_offset; // offset (in DATA) of audio data for channel
 +
u32 info_offset; // offset (in INFO) of DSP info (0x30 byte block)
 +
u32 unk; // 0
 +
} channel_info;
 +
</source>
 +
 
 +
== Tools and Example Source ==
  
==icon.bin==
+
{| class="wikitable"
 +
|-
 +
! Name
 +
! Language
 +
! Author
 +
! Description
 +
|-
 +
| [[User:Magicus/Magicus's Tools/Parse-opening.c|parse-opening.c]]
 +
| C
 +
| [[User:magicus|magicus]]
 +
| Extracts the contents of the opening.bnr file to a file structure.
 +
|-
 +
| [[LZ77]]
 +
| Python
 +
| [[User:Marcan|Marcan]]
 +
| Decompresses LZ77 files.
 +
|-
 +
| [http://pastebin.com/f30596571 LZ77Stream.cs]
 +
| C#
 +
| [[User:Atacama|Atacama]]
 +
| C# Stream object for decompressing LZ77 Files.
 +
|-
 +
| [http://pastebin.com/f332ae5e4 BNRSound.cs]
 +
| C#
 +
| [[User:Atacama|Atacama]]
 +
| C# Class which processes sound.bin so it can be read as PCM data.
 +
|-
 +
| [http://tinyurl.com/62w7kt tplx]
 +
| C
 +
| monk
 +
| Command line tool included with gcube that extracts the textures in tpl files to seperate tga files.
 +
|-
 +
| [http://pastie.caboo.se/168489 bnrstruct.c]
 +
| C
 +
| [[User:dasda|dasda]]
 +
| [[User:dasda|dasda's]] structures for the brlan and brlyt files
 +
|-
 +
| [http://codepad.org/PrARwNoM bannersigner.c]
 +
| C
 +
| icefire
 +
| Adds IMET/IMD5 headers to U8 files. IMET is partially broken.
 +
|}
  
==sound.bin==
+
[[Category:File formats]]

Latest revision as of 13:14, 26 November 2010

Opening.bnr, also known as 00000000.app, is a file related to Wii homebrew development. The file is one of the first read by the Wii when a new DVD is inserted (as is 00000000.app for channels), and it is used to display the banner (the channel animation). Even though Opening.bnr shares the name with the file on the GameCube, the content of the file has no resemblance to the GC Opening.bnr file.

Description

Opening.bnr consists of two parts, an IMET header which is (almost) identical to the latter of part A (starting from Zeroes_1) in Content.bin (see Content.bin file structure). However, the last 16 bytes contain some random-looking bytes which are, in fact, an MD5 sum of 0x40 to 0x640 in the header.

Opening.bnr is also stored in the console specific encrypted area of content.bin (a copy of icon.bin is in the SD encrypted area). For some of the channels a generic opening.bnr (which doesn't resemble the actual banner) is stored in the NAND under the \META tree as TITLE.MET. Their purpose is unknown. The proper ones can be found in the unencrypted NAND as one of the .app files, content index 0 (you can get this from the TMD). Also some of those the offset to the IMET header is at 0x80 instead of 0x40.

After the header follows an U8 archive. This is an archive consisting of the following contents:


Full Path Description
/meta/ Directory
/meta/banner.bin Contains the images and animation displayed when the channel is selected.
/meta/icon.bin Contains the images and animation displayed when the channel is in the menu.
/meta/sound.bin Contains the audio that is played when the channel is selected.

banner.bin and icon.bin

The banner.bin and icon.bin files are (usually, though not required to be) LZ77 compressed U8 archives themselves, each with an IMD5 header, containing the MD5 of the file (described below).

More information on LZ77 compression can be found on Wikipedia. Example C# source is available in the Tools and Example Source section.

The banner.bin and icon.bin U8 archives have a file format like this:

Full Path Description
/arc/ Directory
/arc/anim/ Contains the images and animation displayed when the channel is selected.
/arc/anim/*.brlan Contains the animation.
/arc/blyt/ Contains the images and animation displayed when the channel is selected.
/arc/blyt/*.brlyt Contains the layout used in the animation.
/arc/timg/ Contains the images used.
/arc/timg/*.tpl The images, in standard GC TPL format.

TPL Files

The TPL files are textures. They can be read by the tplx program from the gcube library, and created using gentpl from benzin.

The format is also described in YAGCD at http://pabut.homeip.net:8000/yagcd/chap14.html#sec14.4. It can contain many different independent texture formats, with varying sizes and supports, and can contain multiple textures in one file.

brlan Files

brlan files are described in the Wii Animations section, and can be created and parsed with benzin.

brlyt Files (Layout)

brlyt files are described in the Wii Animations section, and can be created and parsed with benzin.

sound.bin

sound.bin also has an IMD5 header. Currently, three sound.bin formats have been discovered.

Format Hex Identifier Description
BNS 0x42 0x4E 0x53 0x20 (BNS ) Similar to the brstm format, always in the NGC-DSP ADPCM format, supports having an intro sound and a loop point.
WAV 0x52 0x49 0x46 0x46 (RIFF) Standard wav/(16 bit) PCM format, supports having an intro sound and a loop point using the tool Wavosaur (PC). Can be LZ77 compressed.
AIFF 0x46 0x4F 0x52 0x4D (FORM) Standard AIFF/PCM format, only plays once. Can be LZ77 compressed.

Header Formats

IMD5

typedef struct {
	u32 imd5; // 'IMD5'
	u32 filesize; //size of rest of file
	u8 zeroes[8]; //padding
	u8 crypto[16]; //MD5 of rest of file
} IMD5;

IMET

typedef struct {
    u8 zeroes[64]; // padding
    u32 imet; // "IMET"
    u32 hashsize; // Hash length
    u32 unk;  // 3 fixed, unknown purpose. Possibly file count?
    u32 sizes[3]; // icon.bin, banner.bin, sound.bin
    u32 flag1; // unknown
    u8 names[10][84]; // Japanese, English, German, French, Spanish, Italian, Dutch, unknown, unknown, Korean
    u8 zeroes_2[588]; // padding
    u8 crypto[16]; // MD5 of 0 to 'hashsize' in header. crypto should be all 0's when calculating final MD5
} IMET;

BNS

// Header
typedef struct {
	u32 bns; // 'BNS '
	u32 version; // 0xFEFF0100 endianness and format version check
	u32 filesize; // size of entire BNS
	u16 headersize; // size of BNS header (including chunkinfo)
	u16 chunkcount; // number of chunks
	struct {
		u32 offset; // offset from start of BNS of chunk header
		u32 size; // size of chunk including header
	} chunkinfo[chunkcount]; // info for each chunk
} BNS;

// Chunk header
typedef struct {
	u32 type; // 'INFO' or 'DATA'
	u32 size; // size including header
} BNS_chunk;

// INFO chunk
typedef struct {
	u8 unk; // 0, possibly format control
	u8 loop; // loop flag, 0 = no loop, 1 = loop
	u8 channels; // channel count
	u8 unk2; // 0, padding?
	u16 samplerate; // sample rate (Hz)
	u16 pad; // 0
	u32 loopstart; // loop start sample
	u32 samples; // total sample count
	u32 offset; // offset (in INFO) to channel info offset list
	u32 unk4; // 0, padding?
} INFO_chunk;

// channel info offset list
typdef struct {
	u32 offset[channels]; // offset (in INFO) to channel info for each channel
} channel_info_offset_list

// channel info (for DSP ADPCM)
typedef struct {
	u32 data_offset; // offset (in DATA) of audio data for channel
	u32 info_offset; // offset (in INFO) of DSP info (0x30 byte block)
	u32 unk; // 0
} channel_info;

Tools and Example Source

Name Language Author Description
parse-opening.c C magicus Extracts the contents of the opening.bnr file to a file structure.
LZ77 Python Marcan Decompresses LZ77 files.
LZ77Stream.cs C# Atacama C# Stream object for decompressing LZ77 Files.
BNRSound.cs C# Atacama C# Class which processes sound.bin so it can be read as PCM data.
tplx C monk Command line tool included with gcube that extracts the textures in tpl files to seperate tga files.
bnrstruct.c C dasda dasda's structures for the brlan and brlyt files
bannersigner.c C icefire Adds IMET/IMD5 headers to U8 files. IMET is partially broken.