# GX_TrySetBankForBGEx

## Syntax

  `#include <nitro/gx/gx_vramcnt.h>`
  `BOOL GX_TrySetBankForBGEx(GXVRamBG bg1, GXVRamBG bg2);`

## Arguments

bg1 | Specifies the VRAM banks allocated to the BG-VRAM addresses 0x6000000-0x6017FFF in the main 2D engine. Only combinations of VRAM-E, F, and G can be set.
bg2 | Specifies the VRAM banks allocated to the BG-VRAM addresses 0x6020000-0x607FFFF in the main 2D engine. Only combinations of VRAM-A, B, C, and D can be set, and the maximum size is 512 KB.

## Return Values

Returns TRUE if the VRAM bank is allocated normally. Returns FALSE if the VRAM bank to be allocated is locked by another library.

## Description

Attempts to allocate a designated VRAM bank to the BG of the main 2D engine. Allocates that VRAM bank to the BG of the main 2D engine if the designated VRAM bank is disabled or if it is allocated to LCDC. The allocation will fail if the designated VRAM bank is exclusively locked by another library.
With this function, it is possible to configure combinations of banks that cannot be mapped to continuous addresses in the BG-VRAM. VRAM-E, VRAM-F, and VRAM-G will be mapped from the BG-VRAM top 0x6000000 continuous address, while VRAM-A, VRAM-B, VRAM-C, and VRAM-D will be mapped from the BG-VRAM 0x6020000 continuous address.

Parameters that can be specified for the first argument:
`GX_VRAM_BG_16_F` | 16 KB are reserved in BG. VRAM-F is allocated.
`GX_VRAM_BG_16_G` | 16 KB are reserved in BG. VRAM-G is allocated.
`GX_VRAM_BG_32_FG` | 32 KB are reserved in BG. VRAM-F and -G are allocated.
`GX_VRAM_BG_64_E` | 64 KB are reserved in BG. VRAM-E is allocated.
`GX_VRAM_BG_80_EF` | 80 KB are reserved in BG. VRAM-E and -F are allocated.
`GX_VRAM_BG_96_EFG` | 96 KB are reserved in BG. VRAM-E, -F, and -G are allocated.
`GX_VRAM_BG_80_EG` | 80 KB are reserved in BG. VRAM-E and -G are allocated.
Parameters that can be specified for the second argument:
`GX_VRAM_BG_128_A` | 128 KB are reserved in BG. VRAM-A is allocated.
`GX_VRAM_BG_128_B` | 128 KB are reserved in BG. VRAM-B is allocated.
`GX_VRAM_BG_128_C` | 128 KB are reserved in BG. VRAM-C is allocated.
`GX_VRAM_BG_128_D` | 128 KB are reserved in BG. VRAM-D is allocated.
`GX_VRAM_BG_256_AB` | 256 KB are reserved in BG. VRAM-A and -B are allocated.
`GX_VRAM_BG_256_BC` | 256 KB are reserved in BG. VRAM-B and -C are allocated.
`GX_VRAM_BG_256_CD` | 256 KB are reserved in BG. VRAM-C and -D are allocated.
`GX_VRAM_BG_384_ABC` | 384 KB are reserved in BG. VRAM-A, -B, and -C are allocated.
`GX_VRAM_BG_384_BCD` | 384 KB are reserved in BG. VRAM-B, -C, and -D are allocated.
`GX_VRAM_BG_256_AC` | 256 KB are reserved in BG. VRAM-A and -C are allocated.
`GX_VRAM_BG_256_AD` | 256 KB are reserved in BG. VRAM-A and -D are allocated.
`GX_VRAM_BG_256_BD` | 256 KB are reserved in BG. VRAM-B and -D are allocated.
`GX_VRAM_BG_384_ABD` | 384 KB are reserved in BG. VRAM-A, -B, and -D are allocated.
`GX_VRAM_BG_384_ACD` | 384 KB are reserved in BG. VRAM-A, -C, and -D are allocated.

The following is the type definition for `GXVRamBG` types:

    typedef enum
    {
        GX_VRAM_BG_NONE     = 0x0000,
        GX_VRAM_BG_16_F     = GX_VRAM_F,                                     // ARM9: HW_BG_VRAM   -->   HW_BG_VRAM + HW_VRAM_F_SIZE
        GX_VRAM_BG_16_G     = GX_VRAM_G,                                     // ARM9: HW_BG_VRAM   -->   HW_BG_VRAM + HW_VRAM_G_SIZE
        GX_VRAM_BG_32_FG    = GX_VRAM_F | GX_VRAM_G,                         // ARM9: HW_BG_VRAM   -->   HW_BG_VRAM + HW_VRAM_F_SIZE + HW_VRAM_G_SIZE
        GX_VRAM_BG_64_E     = GX_VRAM_E,                                     // ARM9: HW_BG_VRAM   -->   HW_BG_VRAM + HW_VRAM_E_SIZE
        GX_VRAM_BG_80_EF    = GX_VRAM_E | GX_VRAM_F,                         // ARM9: HW_BG_VRAM   -->   HW_BG_VRAM + HW_VRAM_E_SIZE + HW_VRAM_F_SIZE
        GX_VRAM_BG_96_EFG   = GX_VRAM_E | GX_VRAM_F | GX_VRAM_G,             // ARM9: HW_BG_VRAM   -->   HW_BG_VRAM + HW_VRAM_E_SIZE + HW_VRAM_F_SIZE + HW_VRAM_G_SIZE
        GX_VRAM_BG_128_A    = GX_VRAM_A,                                     // ARM9: HW_BG_VRAM   -->   HW_BG_VRAM + HW_VRAM_A_SIZE
        GX_VRAM_BG_128_B    = GX_VRAM_B,                                     // ARM9: HW_BG_VRAM   -->   HW_BG_VRAM + HW_VRAM_B_SIZE
        GX_VRAM_BG_128_C    = GX_VRAM_C,                                     // ARM9: HW_BG_VRAM   -->   HW_BG_VRAM + HW_VRAM_C_SIZE
        GX_VRAM_BG_128_D    = GX_VRAM_D,                                     // ARM9: HW_BG_VRAM   -->   HW_BG_VRAM + HW_VRAM_D_SIZE
        GX_VRAM_BG_256_AB   = GX_VRAM_A | GX_VRAM_B,                         // ARM9: HW_BG_VRAM   -->   HW_BG_VRAM + HW_VRAM_A_SIZE + HW_VRAM_B_SIZE
        GX_VRAM_BG_256_BC   = GX_VRAM_B | GX_VRAM_C,                         // ARM9: HW_BG_VRAM   -->   HW_BG_VRAM + HW_VRAM_B_SIZE + HW_VRAM_C_SIZE
        GX_VRAM_BG_256_CD   = GX_VRAM_C | GX_VRAM_D,                         // ARM9: HW_BG_VRAM   -->   HW_BG_VRAM + HW_VRAM_C_SIZE + HW_VRAM_D_SIZE
        GX_VRAM_BG_384_ABC  = GX_VRAM_A | GX_VRAM_B | GX_VRAM_C,             // ARM9: HW_BG_VRAM   -->   HW_BG_VRAM + HW_VRAM_A_SIZE + HW_VRAM_B_SIZE + HW_VRAM_C_SIZE
        GX_VRAM_BG_384_BCD  = GX_VRAM_B | GX_VRAM_C | GX_VRAM_D,             // ARM9: HW_BG_VRAM   -->   HW_BG_VRAM + HW_VRAM_B_SIZE + HW_VRAM_C_SIZE + HW_VRAM_D_SIZE
        GX_VRAM_BG_512_ABCD = GX_VRAM_A | GX_VRAM_B | GX_VRAM_C | GX_VRAM_D, // ARM9: HW_BG_VRAM   -->   HW_BG_VRAM + HW_VRAM_A_SIZE + HW_VRAM_B_SIZE + HW_VRAM_C_SIZE + HW_VRAM_D_SIZE

        // discontinuous in LCDC memory
        GX_VRAM_BG_80_EG    = GX_VRAM_E | GX_VRAM_G,                         // ARM9: HW_BG_VRAM   -->   HW_BG_VRAM + HW_VRAM_E_SIZE + HW_VRAM_G_SIZE
        GX_VRAM_BG_256_AC   = GX_VRAM_A | GX_VRAM_C,                         // ARM9: HW_BG_VRAM   -->   HW_BG_VRAM + HW_VRAM_A_SIZE + HW_VRAM_C_SIZE
        GX_VRAM_BG_256_AD   = GX_VRAM_A | GX_VRAM_D,                         // ARM9: HW_BG_VRAM   -->   HW_BG_VRAM + HW_VRAM_A_SIZE + HW_VRAM_D_SIZE
        GX_VRAM_BG_256_BD   = GX_VRAM_B | GX_VRAM_D,                         // ARM9: HW_BG_VRAM   -->   HW_BG_VRAM + HW_VRAM_B_SIZE + HW_VRAM_D_SIZE
        GX_VRAM_BG_384_ABD  = GX_VRAM_A | GX_VRAM_B | GX_VRAM_D,             // ARM9: HW_BG_VRAM   -->   HW_BG_VRAM + HW_VRAM_A_SIZE + HW_VRAM_B_SIZE + HW_VRAM_D_SIZE
        GX_VRAM_BG_384_ACD  = GX_VRAM_A | GX_VRAM_C | GX_VRAM_D              // ARM9: HW_BG_VRAM   -->   HW_BG_VRAM + HW_VRAM_A_SIZE + HW_VRAM_C_SIZE + HW_VRAM_D_SIZE
    }
    GXVRamBG;

## See Also

`GX_SetBankForBGEx, GX_GetBankForBG, GX_ResetBankForBG, GX_DisableBankForBG, GX_GetSizeOfBG,GX_SetBankForBG`

## Revision History

2005/05/12 Deleted `GX_VRAM_BG_512_ABCD` from the list of enumerated values that can be specified. Fixed excerpt of `GXVRamBG`.
2005/02/15 Initial version.

CONFIDENTIAL