sprite.h

nds sprite functionality. [詳細]

#include "nds/ndstypes.h"
#include "nds/arm9/video.h"
#include "nds/memory.h"
#include "nds/system.h"

ソースコードを見る。

構成

union  SpriteEntry
 A bitfield of sprite attribute goodness...ugly to look at but not so bad to use. [詳細]
struct  SpriteRotation
 A sprite rotation entry. [詳細]
union  OAMTable
struct  AllocHeader
struct  OamState

マクロ定義

#define ATTR0_NORMAL   (0<<8)
#define ATTR0_ROTSCALE   (1<<8)
#define ATTR0_DISABLED   (2<<8)
#define ATTR0_ROTSCALE_DOUBLE   (3<<8)
#define ATTR0_TYPE_NORMAL   (0<<10)
#define ATTR0_TYPE_BLENDED   (1<<10)
#define ATTR0_TYPE_WINDOWED   (2<<10)
#define ATTR0_BMP   (3<<10)
#define ATTR0_MOSAIC   (1<<12)
#define ATTR0_COLOR_16   (0<<13)
#define ATTR0_COLOR_256   (1<<13)
#define ATTR0_SQUARE   (0<<14)
#define ATTR0_WIDE   (1<<14)
#define ATTR0_TALL   (2<<14)
#define OBJ_Y(m)   ((m)&0x00ff)
#define ATTR1_ROTDATA(n)   ((n)<<9)
#define ATTR1_FLIP_X   (1<<12)
#define ATTR1_FLIP_Y   (1<<13)
#define ATTR1_SIZE_8   (0<<14)
#define ATTR1_SIZE_16   (1<<14)
#define ATTR1_SIZE_32   (2<<14)
#define ATTR1_SIZE_64   (3<<14)
#define OBJ_X(m)   ((m)&0x01ff)
#define ATTR2_PRIORITY(n)   ((n)<<10)
#define ATTR2_PALETTE(n)   ((n)<<12)
#define ATTR2_ALPHA(n)   ((n)<<12)
#define SPRITE_COUNT   128
#define MATRIX_COUNT   32
#define SPRITE_SIZE_SHAPE(size)   (((size) >> 12) & 0x3)
#define SPRITE_SIZE_SIZE(size)   (((size) >> 14) & 0x3)
#define SPRITE_SIZE_PIXELS(size)   (((size) & 0xFFF) << 5)

型定義

typedef union SpriteEntry SpriteEntry
typedef union SpriteEntrypSpriteEntry
typedef struct SpriteRotation SpriteRotation
typedef struct SpriteRotationpSpriteRotation
typedef union OAMTable OAMTable
typedef struct AllocHeader AllocHeader
typedef struct OamState OamState

列挙型

enum  ObjBlendMode {
  OBJMODE_NORMAL,
  OBJMODE_BLENDED,
  OBJMODE_WINDOWED,
  OBJMODE_BITMAP
}
 

The blending mode of the sprite.

[詳細]
enum  ObjShape {
  OBJSHAPE_SQUARE,
  OBJSHAPE_WIDE,
  OBJSHAPE_TALL,
  OBJSHAPE_FORBIDDEN
}
 

The shape of the sprite.

[詳細]
enum  ObjSize {
  OBJSIZE_8,
  OBJSIZE_16,
  OBJSIZE_32,
  OBJSIZE_64
}
 

The size of the sprite.

[詳細]
enum  ObjColMode {
  OBJCOLOR_16,
  OBJCOLOR_256
}
 

The color mode of the sprite.

[詳細]
enum  ObjPriority {
  OBJPRIORITY_0,
  OBJPRIORITY_1,
  OBJPRIORITY_2,
  OBJPRIORITY_3
}
 

The priority of the sprite.

[詳細]
enum  SpriteSize {
  SpriteSize_8x8 = (OBJSIZE_8 << 14) | (OBJSHAPE_SQUARE << 12) | (8*8>>5),
  SpriteSize_16x16 = (OBJSIZE_16 << 14) | (OBJSHAPE_SQUARE << 12) | (16*16>>5),
  SpriteSize_32x32 = (OBJSIZE_32 << 14) | (OBJSHAPE_SQUARE << 12) | (32*32>>5),
  SpriteSize_64x64 = (OBJSIZE_64 << 14) | (OBJSHAPE_SQUARE << 12) | (64*64>>5),
  SpriteSize_16x8 = (OBJSIZE_8 << 14) | (OBJSHAPE_WIDE << 12) | (16*8>>5),
  SpriteSize_32x8 = (OBJSIZE_16 << 14) | (OBJSHAPE_WIDE << 12) | (32*8>>5),
  SpriteSize_32x16 = (OBJSIZE_32 << 14) | (OBJSHAPE_WIDE << 12) | (32*16>>5),
  SpriteSize_64x32 = (OBJSIZE_64 << 14) | (OBJSHAPE_WIDE << 12) | (64*32>>5),
  SpriteSize_8x16 = (OBJSIZE_8 << 14) | (OBJSHAPE_TALL << 12) | (8*16>>5),
  SpriteSize_8x32 = (OBJSIZE_16 << 14) | (OBJSHAPE_TALL << 12) | (8*32>>5),
  SpriteSize_16x32 = (OBJSIZE_32 << 14) | (OBJSHAPE_TALL << 12) | (16*32>>5),
  SpriteSize_32x64 = (OBJSIZE_64 << 14) | (OBJSHAPE_TALL << 12) | (32*64>>5)
}
enum  SpriteMapping {
  SpriteMapping_1D_32 = DISPLAY_SPR_1D | DISPLAY_SPR_1D_SIZE_32 | (0 << 28) | 0,
  SpriteMapping_1D_64 = DISPLAY_SPR_1D | DISPLAY_SPR_1D_SIZE_64 | (1 << 28) | 1,
  SpriteMapping_1D_128 = DISPLAY_SPR_1D | DISPLAY_SPR_1D_SIZE_128 | (2 << 28) | 2,
  SpriteMapping_1D_256 = DISPLAY_SPR_1D | DISPLAY_SPR_1D_SIZE_256 | (3 << 28) | 3,
  SpriteMapping_2D = DISPLAY_SPR_2D | (4 << 28),
  SpriteMapping_Bmp_1D_128 = DISPLAY_SPR_1D | DISPLAY_SPR_1D_SIZE_128 | DISPLAY_SPR_1D_BMP |DISPLAY_SPR_1D_BMP_SIZE_128 | (5 << 28) | 2,
  SpriteMapping_Bmp_1D_256 = DISPLAY_SPR_1D | DISPLAY_SPR_1D_SIZE_256 | DISPLAY_SPR_1D_BMP |DISPLAY_SPR_1D_BMP_SIZE_256 | (6 << 28) | 3,
  SpriteMapping_Bmp_2D_128 = DISPLAY_SPR_2D | DISPLAY_SPR_2D_BMP_128 | (7 << 28) | 2,
  SpriteMapping_Bmp_2D_256 = DISPLAY_SPR_2D | DISPLAY_SPR_2D_BMP_256 | (8 << 28) | 3
}
enum  SpriteColorFormat {
  SpriteColorFormat_16Color = OBJCOLOR_16,
  SpriteColorFormat_256Color = OBJCOLOR_256,
  SpriteColorFormat_Bmp = OBJMODE_BITMAP
}

関数

void oamInit (OamState *oam, SpriteMapping mapping, bool extPalette)
 Initializes the 2D sprite engine In order to mix tiled and bitmap sprites use SpriteMapping_Bmp_1D_128 or SpriteMapping_Bmp_1D_256. This will set mapping for both to 1D and give same sized boundaries so the sprite gfx allocation will function. VBlank IRQ must be enabled for this function to work.
void oamDisable (OamState *oam)
 Disables sprite rendering.
void oamEnable (OamState *oam)
 Enables sprite rendering.
u16 * oamGetGfxPtr (OamState *oam, int gfxOffsetIndex)
 translates an oam offset into a video ram address
u16 * oamAllocateGfx (OamState *oam, SpriteSize size, SpriteColorFormat colorFormat)
 Allocates graphics memory for the supplied sprite attributes.
void oamFreeGfx (OamState *oam, const void *gfxOffset)
 translates an oam offset into a video ram address
void oamSetMosaic (unsigned int dx, unsigned int dy)
 sets engine A global sprite mosaic
void oamSetMosaicSub (unsigned int dx, unsigned int dy)
 sets engine B global sprite mosaic
void oamSet (OamState *oam, int id, int x, int y, int priority, int palette_alpha, SpriteSize size, SpriteColorFormat format, const void *gfxOffset, int affineIndex, bool sizeDouble, bool hide, bool hflip, bool vflip, bool mosaic)
 sets an oam entry to the supplied values
void oamClear (OamState *oam, int start, int count)
 Hides the sprites in the supplied range: if count is zero all 128 sprites will be hidden.
void oamUpdate (OamState *oam)
 causes oam memory to be updated...must be called during vblank if using oam api
void oamRotateScale (OamState *oam, int rotId, int angle, int sx, int sy)
 sets the specified rotation scale entry
int oamCountFragments (OamState *oam)
 determines the number of fragments in the allocation engine
void oamAllocReset (OamState *oam)
unsigned int oamGfxPtrToOffset (OamState *oam, const void *offset)

変数

OamState oamMain
 oamMain an object representing the main 2D engine
OamState oamSub
 oamSub an object representing the sub 2D engine

説明

nds sprite functionality.


列挙型

The blending mode of the sprite.

列挙型の値:
OBJMODE_NORMAL 

No special mode is on - Normal sprite state.

OBJMODE_BLENDED 

Color blending is on - Sprite can use HW blending features.

OBJMODE_WINDOWED 

Sprite can be seen only inside the sprite window.

OBJMODE_BITMAP 

Sprite is not using tiles - per pixel image data.

enum ObjColMode

The color mode of the sprite.

列挙型の値:
OBJCOLOR_16 

sprite has 16 colors.

OBJCOLOR_256 

sprite has 256 colors.

The priority of the sprite.

列挙型の値:
OBJPRIORITY_0 

sprite priority level 0 - highest.

OBJPRIORITY_1 

sprite priority level 1.

OBJPRIORITY_2 

sprite priority level 2.

OBJPRIORITY_3 

sprite priority level 3 - lowest.

enum ObjShape

The shape of the sprite.

列挙型の値:
OBJSHAPE_SQUARE 

Sprite shape is NxN (Height == Width).

OBJSHAPE_WIDE 

Sprite shape is NxM with N > M (Height < Width).

OBJSHAPE_TALL 

Sprite shape is NxM with N < M (Height > Width).

OBJSHAPE_FORBIDDEN 

Sprite shape is undefined.

enum ObjSize

The size of the sprite.

列挙型の値:
OBJSIZE_8 

Major sprite size is 8px.

OBJSIZE_16 

Major sprite size is 16px.

OBJSIZE_32 

Major sprite size is 32px.

OBJSIZE_64 

Major sprite size is 64px.

Color formats for sprite graphics

列挙型の値:
SpriteColorFormat_16Color 

16 colors per sprite

SpriteColorFormat_256Color 

256 colors per sprite

SpriteColorFormat_Bmp 

16-bit sprites

Graphics memory layout options

列挙型の値:
SpriteMapping_1D_32 

1D tile mapping 32 byte boundary between offset

SpriteMapping_1D_64 

1D tile mapping 64 byte boundary between offset

SpriteMapping_1D_128 

1D tile mapping 128 byte boundary between offset

SpriteMapping_1D_256 

1D tile mapping 256 byte boundary between offset

SpriteMapping_2D 

2D tile mapping 32 byte boundary between offset

SpriteMapping_Bmp_1D_128 

1D bitmap mapping 128 byte boundary between offset

SpriteMapping_Bmp_1D_256 

1D bitmap mapping 256 byte boundary between offset

SpriteMapping_Bmp_2D_128 

2D bitmap mapping 128 pixels wide bitmap

SpriteMapping_Bmp_2D_256 

2D bitmap mapping 256 pixels wide bitmap

enum SpriteSize

Enumerates all sizes supported by the 2D engine

列挙型の値:
SpriteSize_8x8 

8x8

SpriteSize_16x16 

16x16

SpriteSize_32x32 

32x32

SpriteSize_64x64 

64x64

SpriteSize_16x8 

16x8

SpriteSize_32x8 

32x8

SpriteSize_32x16 

32x16

SpriteSize_64x32 

64x32

SpriteSize_8x16 

8x16

SpriteSize_8x32 

8x32

SpriteSize_16x32 

16x32

SpriteSize_32x64 

32x64


関数

u16 * oamAllocateGfx ( OamState oam,
SpriteSize  size,
SpriteColorFormat  colorFormat 
)

Allocates graphics memory for the supplied sprite attributes.

引数:
oam must be: &oamMain or &oamSub
size the size of the sprite to allocate
colorFormat the color format of the sprite
戻り値:
the address in vram of the allocated sprite
例:
Graphics/Sprites/allocation_test/source/main.c, Graphics/Sprites/animate_simple/source/template.c, Graphics/Sprites/bitmap_sprites/source/main.cpp, と Graphics/Sprites/simple/source/template.c.
void oamClear ( OamState oam,
int  start,
int  count 
)

Hides the sprites in the supplied range: if count is zero all 128 sprites will be hidden.

引数:
oam must be: &oamMain or &oamSub
start The first index to clear
count The number of sprites to clear
void oamCountFragments ( OamState oam  ) 

determines the number of fragments in the allocation engine

引数:
oam must be: &oamMain or &oamSub
void oamDisable ( OamState oam  ) 

Disables sprite rendering.

引数:
oam must be: &oamMain or &oamSub
void oamEnable ( OamState oam  ) 

Enables sprite rendering.

引数:
oam must be: &oamMain or &oamSub
void oamFreeGfx ( OamState oam,
const void *  gfxOffset 
)

translates an oam offset into a video ram address

引数:
oam must be: &oamMain or &oamSub
gfxOffset a vram offset obtained from oamAllocateGfx
例:
Graphics/Sprites/allocation_test/source/main.c.
u16 * oamGetGfxPtr ( OamState oam,
int  gfxOffsetIndex 
)

translates an oam offset into a video ram address

引数:
oam must be: &oamMain or &oamSub
gfxOffsetIndex the index to compute
戻り値:
the address in vram corresponding to the supplied offset
void oamInit ( OamState oam,
SpriteMapping  mapping,
bool  extPalette 
)

Initializes the 2D sprite engine In order to mix tiled and bitmap sprites use SpriteMapping_Bmp_1D_128 or SpriteMapping_Bmp_1D_256. This will set mapping for both to 1D and give same sized boundaries so the sprite gfx allocation will function. VBlank IRQ must be enabled for this function to work.

引数:
oam must be: &oamMain or &oamSub
mapping the mapping mode
extPalette if true the engine sets up extended palettes for 8bpp sprites
例:
Graphics/3D/3D_Both_Screens/source/template.c, Graphics/Sprites/allocation_test/source/main.c, Graphics/Sprites/animate_simple/source/template.c, Graphics/Sprites/bitmap_sprites/source/main.cpp, と Graphics/Sprites/simple/source/template.c.
void oamRotateScale ( OamState oam,
int  rotId,
int  angle,
int  sx,
int  sy 
)

sets the specified rotation scale entry

引数:
oam must be: &oamMain or &oamSub
rotId the rotation entry to set
angle the ccw angle to rotate [-32768 - 32767]
sx the inverse scale factor in the x direction
sy the inverse scale factor in the y direction
例:
Graphics/Sprites/bitmap_sprites/source/main.cpp.
void oamSet ( OamState oam,
int  id,
int  x,
int  y,
int  priority,
int  palette_alpha,
SpriteSize  size,
SpriteColorFormat  format,
const void *  gfxOffset,
int  affineIndex,
bool  sizeDouble,
bool  hide,
bool  hflip,
bool  vflip,
bool  mosaic 
)

sets an oam entry to the supplied values

引数:
oam must be: &oamMain or &oamSub
id the oam number to be set [0 - 127]
x the x location of the sprite in pixels
y the y location of the sprite in pixels
priority The sprite priority (0 to 3)
palette_alpha the palette number for 4bpp and 8bpp (extended palette mode), or the alpha value for bitmap sprites (bitmap sprites must specify a value > 0 to display) [0-15]
size the size of the sprite
format the color format of the sprite
gfxOffset the video memory address of the sprite graphics (not an offset)
affineIndex affine index to use (if < 0 or > 31 the sprite will be unrotated)
sizeDouble if affineIndex >= 0 this will be used to double the sprite size for rotation
hide if non zero (true) the sprite will be hidden
vflip flip the sprite vertically
hflip flip the sprite horizontally
mosaic if true mosaic will be applied to the sprite
例:
Graphics/3D/3D_Both_Screens/source/template.c, Graphics/Sprites/allocation_test/source/main.c, Graphics/Sprites/animate_simple/source/template.c, Graphics/Sprites/bitmap_sprites/source/main.cpp, と Graphics/Sprites/simple/source/template.c.
static void oamSetMosaic ( unsigned int  dx,
unsigned int  dy 
) [inline]

sets engine A global sprite mosaic

引数:
dx (0-15) horizontal mosaic value
dy (0-15) horizontal mosaic value
static void oamSetMosaicSub ( unsigned int  dx,
unsigned int  dy 
) [inline]

sets engine B global sprite mosaic

引数:
dx (0-15) horizontal mosaic value
dy (0-15) horizontal mosaic value
void oamUpdate ( OamState oam  ) 
 全て クラス ファイル 関数 変数 型定義 列挙型 列挙型の値 マクロ定義
libndsに対してMon Apr 26 23:39:50 2010に生成されました。  doxygen 1.6.3