LIB: pm_cspr

CStyle Lib: Sprites Manipulations

pmrom_cspr.s

Type: Source File

Dependency: pm_init.s and pm_cstyle.s

Including Rules: Must be after ROM (PM_HEADER) declaration

Functions

Clear sprites list

c_spr_clear

No return

Remove all sprites in the list, does not affect sprites in the hardware

Update sprites list into hardware

c_spr_update

No return

It's recommended to call this function shortly after PRC_COPY.

Add sprite to list

c_spr_add pos, tile

[CVar] pos: Sprite position

Low byte -> OAM X

High byte -> OAM Y

[CVar] tile: Sprite tile and control

Low byte -> OAM Tile

High byte -> OAM Ctrl

Returns:

0 = Sprites list full

-1 / $FFFF = Sprite offscreen

1 = Sprite added

If pos argument is zero, the sprite won't be added.

The following defines can be logic OR with tile argument:

Definition Value Description
CSPR_HFLIP $0100 Flip sprite horizontally
CSPR_VFLIP $0200 Flip sprite vertically
CSPR_INVERT $0400 Invert pixels

Inserted sprite will have SPR_ENABLE attribute automaticaly set.

This function can be chained with c_map8_sprpos / c_map16_sprpos (with 1st argument being REG_BA).