# MB_Init

## Syntax

  `#include <nitro/mb.h>`
  `int MB_Init(void *work, const MBUserInfo *user, u32 ggid, u32 tgid, u32 dma);`

## Arguments

work | Pointer to memory allocated for the internal state management of the MB library. It must be at least `MB_SYSTEM_BUF_SIZE` bytes in size. The allocated memory is used internally until the `MB_End` function is called. If you can ensure that the `MB_StartParentFromIdle` function is called after the `MB_Init` function, you can reduce the size by `WM_SYSTEM_BUF_SIZE` bytes.
user | Pointer to the structure in which user data is saved. The content specified by this pointer is referenced only in the `MB_Init` function.
ggid | A 4-byte game group ID.

tgid

A 16-bit value from `0x0000` to `0xFFFF` that indicates the TGID value. When specified as `MB_TGID_AUTO`, the TGID is obtained automatically by calling the `WM_GetNextTgid` function internally. At the initial program launch (IPL), the display information is not updated when the `tgid`, `ggid`, and MAC address are the same (a single parent is assumed). After a parent terminates, the user information displayed in the child IPL may not be updated if the user name was updated and restarted as an MB parent.
If `MB_TGID_AUTO` is not specified, use the `OS_GetVBlankCount` function or the RTC to set a different value for each startup whenever possible.

dma | The DMA channel allocated for MB internal processing. The DMA channel is used internally until the `MB_End` function is called.

## Return Values

Returns `MB_SUCCESS` if the initialization completes successfully.

## Description

Initializes the multiboot (MB) library. The `MB_Init` function must be called once before any MB function is called. However, if you call `MB_Init` more than once, nothing happens.
After calling this function, use the `MB_SetParentCommParam` function to set the maximum number of connected children. Do this before the `MB_StartParent` function is called.

## See Also

`MBUserInfo`
`MB_StartParent`
`MB_StartParentFromIdle`
`MB_SetParentCommParam`
`MB_End`
`OS_GetVBlankCount`

## Revision History

2005/04/11 Expanded the type of the tgid argument to `u32` and added a description for `MB_TGID_AUTO`.
2004/11/24 Renamed `MB_StartParentEx` to `MB_StartParentFromIdle`.
2004/10/18 Added a description for the `MB_StartParentEx` function.
2004/10/05 Corrected an error in the description of internal operations.
2004/09/30 Added an argument.
2004/08/09 Initial version.

CONFIDENTIAL