#define BG_PRIORITE_0                        0x0000
#define BG_PRIORITE_1                        0x0001
#define BG_PRIORITE_2                        0x0002
#define BG_PRIORITE_3                        0x0003
#define BG_CHARBLOCK_0                        0x0000
#define BG_CHARBLOCK_1                        0x0004
#define BG_CHARBLOCK_2                        0x0008
#define BG_CHARBLOCK_3                        0x000C
#define BG_EFFET_MOSAIQUE                0x0040
#define BG_1_PALETTE                        0x0080
#define BG_16_PALETTES                        0x0000
#define BG_WRAP                                        0x2000
#define BG_TEXTE_256x256                0x0000
#define BG_TEXTE_512x256                0x4000
#define BG_TEXTE_256x512                0x8000
#define BG_TEXTE_512x512                0xC000
#define BG_ROTATION_128x128                0x0000
#define BG_ROTATION_256x256                0x4000
#define BG_ROTATION_512x512                0x8000
#define BG_ROTATION_1024x1024        0xC000
#define EWRAM                                        ((volatile u8 *) 0x02000000)
#define CharBaseBlock(n)                (((n) * 0x4000) + 0x6000000)

//#define CharBaseBlock(n) ((volatile unsigned short *)(((n)*0x4000)+0x6000000))
#define ScreenBaseBlock(n)        (((n) * 0x0800) + 0x6000000)
#define VIDEO_BG0_ENABLED        0x100
#define VIDEO_BG1_ENABLED        0x200
#define VIDEO_BG2_ENABLED        0x400
#define VIDEO_BG3_ENABLED        0x800
#define VIDEO_MODE0                        0x0
#define VIDEO_MODE1                        0x1
#define VIDEO_MODE2                        0x2
#define VIDEO_MODE3                        0x3
#define VIDEO_MODE4                        0x4
#define VIDEO_MODE5                        0x5
#define BG_CHARBLOCK_0                0x0000
#define BG_CHARBLOCK_1                0x0004
#define BG_CHARBLOCK_2                0x0008
#define BG_CHARBLOCK_3                0x000C

#define REG_DMA3SAD                        * (volatile unsigned int *) 0x40000D4
#define REG_DMA3DAD                        * (volatile unsigned int *) 0x40000D8
#define REG_DMA3CNT                        * (volatile unsigned int *) 0x40000DC
#define REG_DMA2SAD                        * (volatile unsigned int *) 0x40000C8
#define REG_DMA2DAD                        * (volatile unsigned int *) 0x40000CC
#define REG_DMA2CNT                        * (volatile unsigned int *) 0x40000D0
#define REG_DMA1SAD                        * (volatile unsigned int *) 0x40000BC
#define REG_DMA1DAD                        * (volatile unsigned int *) 0x40000C0
#define REG_DMA1CNT                        * (volatile unsigned int *) 0x40000C4
#define REG_DMA0SAD                        * (volatile unsigned int *) 0x40000B0
#define REG_DMA0DAD                        * (volatile unsigned int *) 0x40000B4
#define REG_DMA0CNT                        * (volatile unsigned int *) 0x40000B8

#define DMA_ENABLED                        0x80000000
#define DMA_TIMING_IMMEDIAT 0x00000000
#define DMA_16                                0x00000000
#define DMA_32                                0x04000000

#define DMA_16im                        (DMA_ENABLED | DMA_TIMING_IMMEDIAT | DMA_16)
#define DMA_32im                        (DMA_ENABLED | DMA_TIMING_IMMEDIAT | DMA_32)
#define REG_KEYS                        * (volatile unsigned long *) 0x4000130
#define tilesObj                        (volatile unsigned short *) 0x06010000

#define REG_TOUCHES                        (~(REG_KEYS) & 0x3FF)
#define TOUCHE_A                        0x0001
#define TOUCHE_B                        0x0002
#define TOUCHE_SELECT                0x0004
#define TOUCHE_START                0x0008
#define KEY_RIGHT                0x0010
#define KEY_LEFT                0x0020
#define KEY_UP                        0x0040
#define KEY_DOWN                        0x0080
#define TOUCHE_R                        0x0100
#define TOUCHE_L                        0x0200

#define OBJ_ENABLED                        0x1000

typedef struct
{
        unsigned short attribut0;
        unsigned short attribut1;
        unsigned short attribut2;
        unsigned short attribut3;
} TypeSprite;

#define MODE_NORMAL                        0x0
#define MODE_TRANSPARENT        0x400

/*#define ROMMEM __attribute__ ((section (".ewram")))
#define IWRAM_CODE __attribute__ ((section (".iwram"), long_call))
#define CODE_IN_ROM __attribute__ ((section (".text"), long_call))
#define IWRAM_CODE __attribute__ ((section (".iwram")))
#define EWRAM_DATA __attribute__ ((section (".ewram")))*/

//#define IWRAM_CODE __attribute__ ((section (".iwram"), long_call))
//#define CODE_IN_EWRAM __attribute__ ((section (".ewram"), long_call))
#define INIT_BRANCH void(*ptr2Function) ();
#define BRANCH(a, b...) \
        ( \
{ \
        ptr2Function = a; ptr2Function(b); \
} \
        )

//typedef unsigned int u32;
#define IWRAM_CODE        __attribute__((section(".iwram")))
#define EWRAM_DATA        __attribute__((section(".ewram")))

//extern u32 __FarFunction (u32 (*ptr)(), ...); // Reference to routine in crt0.S
//extern void __FarProcedure (void (*ptr)(), ...); // Reference to routine in crt0.S

/*#define REG_BLDMOD *(unsigned short*)0x4000050
#define REG_COLEV *(unsigned short*)0x4000052*/
#define REG_WAITRAM * (volatile unsigned long *) 0x4000800

typedef struct tagRotData
{
        u16 filler1[3];
        u16 pa;
        u16 filler2[3];
        u16 pb;
        u16 filler3[3];
        u16 pc;
        u16 filler4[3];
        u16 pd;
}
RotData, *pRotData;

#define REG_INTERRUPT			* (u32 *) 0x3007FFC //Interrupt Register
#define REG_STOPCNT                * (volatile unsigned char *) 0x4000301
