libtonc
tonc_types.h File Reference
#include <stdint.h>
#include <stdbool.h>

Data Structures

struct  BLOCK
 8-word type for fast struct-copies More...
 
struct  TILE
 4bpp tile type, for easy indexing and copying of 4-bit tiles More...
 
struct  TILE8
 8bpp tile type, for easy indexing and 8-bit tiles More...
 
struct  AFF_SRC
 Simple scale-rotation source struct. More...
 
struct  AFF_SRC_EX
 Extended scale-rotate source struct. More...
 
struct  AFF_DST
 Simple scale-rotation destination struct, BG version. More...
 
struct  AFF_DST_EX
 Extended scale-rotate destination struct. More...
 
struct  POINT16
 Regular bg points; range: :0010 - :001F. More...
 
struct  DMA_REC
 DMA struct; range: 0400:00B0 - 0400:00DF. More...
 
struct  TMR_REC
 Timer struct, range: 0400:0100 - 0400:010F. More...
 
struct  OBJ_ATTR
 Object attributes. More...
 
struct  OBJ_AFFINE
 Object affine parameters. More...
 

Macros

#define IWRAM_DATA   __attribute__((section(".iwram")))
 Put variable in IWRAM (default).
 
#define EWRAM_DATA   __attribute__((section(".ewram")))
 Put variable in EWRAM.
 
#define EWRAM_BSS   __attribute__((section(".sbss")))
 Put non-initialized variable in EWRAM.
 
#define IWRAM_CODE   __attribute__((section(".iwram"), long_call))
 Put function in IWRAM.
 
#define EWRAM_CODE   __attribute__((section(".ewram"), long_call))
 Put function in EWRAM.
 
#define ALIGN(n)   __attribute__((aligned(n)))
 Force a variable to an n-byte boundary.
 
#define ALIGN4   __attribute__((aligned(4)))
 Force word alignment.
 
#define PACKED   __attribute__((packed))
 Pack aggregate members.
 
#define DEPRECATED   __attribute__((deprecated))
 Deprecated notice.
 
#define INLINE   static inline
 Inline function declarator.
 
#define NULL   (void*)0
 

Typedefs

Base types

Basic signed and unsigned types for 8, 16, 32 and 64-bit integers.

  • s# : signed #-bit integer.
  • u#/u{type} : unsigned #-bit integer.
  • e{type} : enum'ed #-bit integer.

typedef unsigned int uint
 
typedef unsigned int eint
 
typedef unsigned short ushort
 
typedef unsigned short eshort
 
typedef uint8_t u8
 
typedef uint8_t byte
 
typedef uint8_t uchar
 
typedef uint8_t echar
 
typedef uint16_t u16
 
typedef uint16_t hword
 
typedef uint32_t u32
 
typedef uint32_t word
 
typedef uint64_t u64
 
typedef int8_t s8
 
typedef int16_t s16
 
typedef int32_t s32
 
typedef int64_t s64
 
Volatile types

Volatile types for registers

typedef volatile u8 vu8
 
typedef volatile u16 vu16
 
typedef volatile u32 vu32
 
typedef volatile u64 vu64
 
typedef volatile s8 vs8
 
typedef volatile s16 vs16
 
typedef volatile s32 vs32
 
typedef volatile s64 vs64
 
affine structs
typedef struct AFF_SRC AFF_SRC
 Simple scale-rotation source struct.
 
typedef struct AFF_SRC ObjAffineSource
 Simple scale-rotation source struct.
 
typedef struct AFF_SRC_EX AFF_SRC_EX
 Extended scale-rotate source struct.
 
typedef struct AFF_SRC_EX BgAffineSource
 Simple scale-rotation source struct.
 
typedef struct AFF_DST AFF_DST
 Simple scale-rotation destination struct, BG version.
 
typedef struct AFF_DST ObjAffineDest
 Simple scale-rotation source struct.
 
typedef struct AFF_DST_EX AFF_DST_EX
 Extended scale-rotate destination struct.
 
typedef struct AFF_DST_EX BgAffineDest
 Simple scale-rotation source struct.
 
IO register types
typedef struct POINT16 POINT16
 Regular bg points; range: :0010 - :001F.
 
typedef struct POINT16 BG_POINT
 Regular bg points; range: :0010 - :001F.
 
typedef struct AFF_DST_EX BG_AFFINE
 Affine parameters for backgrounds; range : 0400:0020 - 0400:003F.
 
typedef struct DMA_REC DMA_REC
 DMA struct; range: 0400:00B0 - 0400:00DF.
 
typedef struct TMR_REC TMR_REC
 Timer struct, range: 0400:0100 - 0400:010F.
 
PAL types
typedef COLOR PALBANK[16]
 Palette bank type, for 16-color palette banks.
 
VRAM array types

These types allow VRAM access as arrays or matrices in their most natural types.

typedef SCR_ENTRY SCREENLINE[32]
 
typedef SCR_ENTRY SCREENMAT[32][32]
 
typedef SCR_ENTRY SCREENBLOCK[1024]
 
typedef COLOR M3LINE[240]
 
typedef u8 M4LINE[240]
 
typedef COLOR M5LINE[160]
 
typedef TILE CHARBLOCK[512]
 
typedef TILE8 CHARBLOCK8[256]
 
OAM structs
Note
These OBJ_ATTR and OBJ_AFFINE structs are interlaced in OAM. When using affine objs, struct/DMA/mem copies will give bad results.
typedef struct OBJ_ATTR OBJ_ATTR
 Object attributes.
 
typedef struct OBJ_AFFINE OBJ_AFFINE
 Object affine parameters.
 

Const types

Const types for const function aprameters

#define TRUE   1
 Type for consting a string as well as the pointer than points to it.
 
#define FALSE   0
 Type for consting a string as well as the pointer than points to it.
 
typedef const u8 cu8
 Type for consting a string as well as the pointer than points to it.
 
typedef const u16 cu16
 Type for consting a string as well as the pointer than points to it.
 
typedef const u32 cu32
 Type for consting a string as well as the pointer than points to it.
 
typedef const u64 cu64
 Type for consting a string as well as the pointer than points to it.
 
typedef const s8 cs8
 Type for consting a string as well as the pointer than points to it.
 
typedef const s16 cs16
 Type for consting a string as well as the pointer than points to it.
 
typedef const s32 cs32
 Type for consting a string as well as the pointer than points to it.
 
typedef const s64 cs64
 Type for consting a string as well as the pointer than points to it.
 
typedef const char *const CSTR
 Type for consting a string as well as the pointer than points to it.
 
typedef s32 FIXED
 Fixed point type.
 
typedef u16 COLOR
 Type for colors.
 
typedef u16 SCR_ENTRY
 Type for consting a string as well as the pointer than points to it.
 
typedef u16 SE
 Type for screen entries.
 
typedef u8 SCR_AFF_ENTRY
 Type for consting a string as well as the pointer than points to it.
 
typedef u8 SAE
 Type for affine screen entries.
 
typedef struct TILE TILE4
 Type for consting a string as well as the pointer than points to it.
 
typedef u8 BOOL
 Type for consting a string as well as the pointer than points to it.
 
typedef void(* fnptr) (void)
 void foo() function pointer
 
typedef void(* fn_v_i) (int)
 void foo(int x) function pointer
 
typedef int(* fn_i_i) (int)
 int foo(int x) function pointer
 

Detailed Description

Author
J Vijn
Date
20060508 - 20080111