# CTRDG_Init

## Syntax

      #include <nitro/ctrdg.h>

      void CTRDG_Init( void );

## Arguments

None.

## Return Values

None.

## Description

Initializes the Game Pak library.

This function only needs to be called once before calls to Game Pak functions. This function is called internally by the `OS_Init` function, so it does not need to be called by the application.

The `CTRDG_Init` function is a weak function, so if the application will not be using a Game Pak, you can redefine the function in the application. The purpose of redefining the function is to reduce the amount of memory occupied by the Game Pak library. When you redefine the function, make sure you only define a call to the `CTRDG_DummyInit` function. For more information, see the `CTRDG_DummyInit` function. Note that the function is a weak function only for NITRO and NITRO/TWL hybrid builds. The function is an inline function in TWL limited builds, and this method cannot be used there,

This function exists in TWL limited builds, but because the TWL hardware does not have a Game Pak slot, it is initialized in only a minimal form.

## Note

The following explanation pertains to NITRO-only and NITRO/TWL hybrid ROMs.

During the initialization process of this function, the library first determines if there is a Game Pak and gets information associated with it. These values will be used later for validation purposes in the `CTRDG_GetAgbMakerCode` and `CTRDG_GetAgbGameCode` functions. When using the Game Pak, before calling this function, be sure to put the Game Pak into a valid state.

A "valid state" means that the Game Pak power is turned on for IS-NITRO-DEBUGGER or other development tools.

The `OS_InitThread` function must be called in advance because a thread will be created for running asynchronous AGB backup access functions when this function is called.

## See Also

`CTRDG_SetPulledOutCallback`
`CTRDG_TerminateForPulledOut`
`CTRDG_DummyInit`

## Revision History

2009/05/19 Explained that this function is called from inside `OS_Init`.
2008/01/28 Added the `CTRDG_DummyInit` function to See Also.
2006/04/05 Added mention that the `OS_InitThread` function must be called beforehand.
2005/04/12 Revised the description of the relationship between the first information obtained and the `CTRDG_GetAgbMakerCode` and `CTRDG_GetAgbGameCode` functions.
2005/03/03 Added note that determining whether there is a Game Card is done only at time of initialization.
2004/09/15 Initial version.

CONFIDENTIAL