src/field/field_sprite_draw.c
Drawing sprites: composing their animations and placing them on screen. More…
Included by field.c.
Macros
| Name | Description | |
|---|---|---|
#define | ANIMCMD_UNUSED_LAST 250 | Animation commands this game steps over: those from ANIMCMD_WAIT + 1 to ANIMCMD_UNUSED_LAST, and ANIMCMD_SOUND, with which The Lost Age plays a sound. |
#define | ANIMCMD_SOUND 252 | |
#define | ANIM_FACING_PICTURE_MASK 7 | A facing table entry's picture offset from the base picture; its FACING_MIRRORED_BIT mirrors the picture. |
#define | FACING_SECTOR (direction, sectors) | The sector a facing angle lies in, a turn cut into sectors. |
#define | FACING_TABLE_ENTRY (table, direction) | Facing table table's entry for facing angle direction, the turn cut into as many sectors as the table has entries. |
#define | FACING_NEAREST_EIGHTH_SECTOR (direction) | The eighth of a turn a facing angle lies nearest: its top three bits once it is turned half an eighth on, worked in the upper halfword so the sum wraps. |
#define | SHADOW_HALF_WIDTH 8 | A sprite's shadow, 16 by 8 pixels: its half width and half height, both doubled when the sprite is drawn double-size. |
#define | SHADOW_HALF_HEIGHT 4 | |
#define | SPRITE_PART_MIRRORED 8 | A plain part's matrix field holds OAM's horizontal flip bit instead. |
#define | DEPTH_SLOT_BACK_SHADOWS 0 | The two rearmost depth slots: shadows drawn under everything, and the sprites drawn behind every other sprite, just in front of those shadows. |
#define | DEPTH_SLOT_BACK 1 | |
#define | PLACEMENT_IMAGE_SLOT 10 | fdRenderApplyProjectedPlacement's draw slots: a sprite one slot further in front for every two screen rows lower, on from PLACEMENT_IMAGE_SLOT, and its shadow in PLACEMENT_SHADOW_SLOT, behind them. |
#define | PLACEMENT_SHADOW_SLOT 2 | |
#define | PROJECTED_MARGIN 32 | How far past the screen's left, right and top edges a projected sprite's point may lie and still be drawn, and past its bottom edge. |
#define | PROJECTED_MARGIN_BELOW 48 | |
#define | PROJECTED_MIDDLE_DEPTH 512 | A projected sprite at depth PROJECTED_MIDDLE_DEPTH draws in the middle of the 256 depth slots, PROJECTED_MIDDLE_SLOT, and one slot further in front for every two units nearer. |
#define | PROJECTED_MIDDLE_SLOT 128 |
Typedefs
| Name | Description | |
|---|---|---|
typedef void (* | SPR_DRAW_FN )(const void *src, void *dest, Sint32 param); | Draws one sprite animation's picture into a sprite's pixel buffer (fdRenderDecodePicture, run from RAM). |
typedef void (* | SPR_UPLOAD_FN )(const void *src, Uint32 w, Uint32 h, void *vram); | Uploads a finished sprite buffer to sprite VRAM (fdTileCopyStrided). |
Enumerations
| Name | Description | |
|---|---|---|
enum | SPR_PART_AFFINE { SPRITE_PART_PLAIN, SPRITE_PART_AFFINE, SPRITE_PART_AFFINE_DO … } | How a sprite part is drawn (its OAM affine bits): as it is, through an affine matrix, or through one in a box twice its size, so that a part scaled up past full size is not cut off. |
Functions
| Name | Description | |
|---|---|---|
Sint32 | fdSpriteComposePicture (SPR *sprite, Uint16 direction) | Advances a sprite's animations by one tick, picks each sprite animation's picture for the facing direction, and when any picture changed redraws the sprite: the sprite animations composed by priority into one pixel buffer, an optional outline, and the result uploaded to the sprite's VRAM tiles. |
void | fdRenderPlaceSpritePartPair (SPR *sprite, FIXED screenX, Sint32 height, Sint32 screenY, Sint32 groundHeight, FIXED *scale) | Positions a sprite's image (part 0) and shadow (part 1) on the screen: the image centred on screenX and raised height above screenY, the shadow at groundHeight. scale is the sprite's (x, y) scale (16.16); above 1.0 both parts use the double-size affine mode. |
void | fdRenderApplyProjectedPlacement (SPR *sprite, const SPR_PLACEMENT *pos, const SPR_SCALE *scale, Sint32 facing) | Places a sprite for the scrolling camera and queues it for drawing. |
void | fdRenderPlaceProjectedSprite ( SPR *sprite, Sint32 *point, Sint32 *scale, Sint32 facing, Sint32 depth) | Places a sprite at 3D point for the fixed camera and queues it for drawing: projected to the screen and scaled by its distance (unless useOwnScale keeps its own scale), with an affine matrix as needed and its shadow on the ground below. depth 0 sorts it by distance; any other value is its draw slot. |
void | fdSpriteSetAnimationColorModes (void *rawSprite, Uint32 colorMode) | Sets the colour mode (SPR_COL_MODE) of each of a sprite's animations to colorMode, except sprite animations drawn hidden (SPRITE_COLOR_HIDDEN), and marks the sprite for redrawing. |
Description
Drawing sprites: composing their animations and placing them on screen. Part
of field.c.
Macros in detail
ANIMCMD_UNUSED_LAST
#define ANIMCMD_UNUSED_LAST 250
Animation commands this game steps over: those from ANIMCMD_WAIT + 1 to
ANIMCMD_UNUSED_LAST, and ANIMCMD_SOUND, with which The Lost Age plays a
sound. 251 is not among them: it shows as a picture.
Referenced by fdSpriteComposePicture().
Definition at line 15 of file field_sprite_draw.c.
ANIMCMD_SOUND
#define ANIMCMD_SOUND 252
Referenced by fdSpriteComposePicture().
Definition at line 16 of file field_sprite_draw.c.
ANIM_FACING_PICTURE_MASK
#define ANIM_FACING_PICTURE_MASK 7
A facing table entry's picture offset from the base picture; its
FACING_MIRRORED_BIT mirrors the picture.
Referenced by fdSpriteComposePicture().
Definition at line 20 of file field_sprite_draw.c.
FACING_SECTOR
#define FACING_SECTOR(direction, sectors)
The sector a facing angle lies in, a turn cut into sectors.
Referenced by fdSpriteComposePicture().
Definition at line 22 of file field_sprite_draw.c.
FACING_TABLE_ENTRY
#define FACING_TABLE_ENTRY(table, direction)
Facing table table's entry for facing angle direction, the turn cut into
as many sectors as the table has entries.
Referenced by fdSpriteComposePicture().
Definition at line 26 of file field_sprite_draw.c.
FACING_NEAREST_EIGHTH_SECTOR
#define FACING_NEAREST_EIGHTH_SECTOR(direction)
The eighth of a turn a facing angle lies nearest: its top three bits once it is turned half an eighth on, worked in the upper halfword so the sum wraps.
Referenced by fdSpriteComposePicture().
Definition at line 30 of file field_sprite_draw.c.
SHADOW_HALF_WIDTH
#define SHADOW_HALF_WIDTH 8
A sprite's shadow, 16 by 8 pixels: its half width and half height, both doubled when the sprite is drawn double-size.
Referenced by fdRenderApplyProjectedPlacement(), fdRenderPlaceProjectedSprite() and fdRenderPlaceSpritePartPair().
Definition at line 35 of file field_sprite_draw.c.
SHADOW_HALF_HEIGHT
#define SHADOW_HALF_HEIGHT 4
Referenced by fdRenderApplyProjectedPlacement() and fdRenderPlaceSpritePartPair().
Definition at line 36 of file field_sprite_draw.c.
SPRITE_PART_MIRRORED
#define SPRITE_PART_MIRRORED 8
A plain part's matrix field holds OAM's horizontal flip bit instead.
Referenced by fdRenderPlaceProjectedSprite().
Definition at line 49 of file field_sprite_draw.c.
DEPTH_SLOT_BACK_SHADOWS
#define DEPTH_SLOT_BACK_SHADOWS 0
The two rearmost depth slots: shadows drawn under everything, and the sprites drawn behind every other sprite, just in front of those shadows.
Referenced by fdRenderApplyProjectedPlacement() and fdRenderPlaceProjectedSprite().
Definition at line 425 of file field_sprite_draw.c.
DEPTH_SLOT_BACK
#define DEPTH_SLOT_BACK 1
Referenced by fdRenderApplyProjectedPlacement() and fdRenderPlaceProjectedSprite().
Definition at line 426 of file field_sprite_draw.c.
PLACEMENT_IMAGE_SLOT
#define PLACEMENT_IMAGE_SLOT 10
fdRenderApplyProjectedPlacement's draw slots: a sprite one slot further in
front for every two screen rows lower, on from PLACEMENT_IMAGE_SLOT, and its
shadow in PLACEMENT_SHADOW_SLOT, behind them.
Referenced by fdRenderApplyProjectedPlacement().
Definition at line 431 of file field_sprite_draw.c.
PLACEMENT_SHADOW_SLOT
#define PLACEMENT_SHADOW_SLOT 2
Referenced by fdRenderApplyProjectedPlacement().
Definition at line 432 of file field_sprite_draw.c.
PROJECTED_MARGIN
#define PROJECTED_MARGIN 32
How far past the screen's left, right and top edges a projected sprite's point may lie and still be drawn, and past its bottom edge.
Referenced by fdRenderPlaceProjectedSprite().
Definition at line 538 of file field_sprite_draw.c.
PROJECTED_MARGIN_BELOW
#define PROJECTED_MARGIN_BELOW 48
Referenced by fdRenderPlaceProjectedSprite().
Definition at line 539 of file field_sprite_draw.c.
PROJECTED_MIDDLE_DEPTH
#define PROJECTED_MIDDLE_DEPTH 512
A projected sprite at depth PROJECTED_MIDDLE_DEPTH draws in the middle of the
256 depth slots, PROJECTED_MIDDLE_SLOT, and one slot further in front for
every two units nearer.
Referenced by fdRenderPlaceProjectedSprite().
Definition at line 543 of file field_sprite_draw.c.
PROJECTED_MIDDLE_SLOT
#define PROJECTED_MIDDLE_SLOT 128
Referenced by fdRenderPlaceProjectedSprite().
Definition at line 544 of file field_sprite_draw.c.
Typedefs in detail
SPR_DRAW_FN
typedef void (*SPR_DRAW_FN)(const void *src, void *dest, Sint32 param);
Draws one sprite animation's picture into a sprite's pixel buffer
(fdRenderDecodePicture, run from RAM).
Referenced by fdSpriteComposePicture().
Definition at line 8 of file field_sprite_draw.c.
SPR_UPLOAD_FN
typedef void (*SPR_UPLOAD_FN)(const void *src, Uint32 w, Uint32 h, void *vram);
Uploads a finished sprite buffer to sprite VRAM (fdTileCopyStrided).
Referenced by fdSpriteComposePicture().
Definition at line 10 of file field_sprite_draw.c.
Enumerations in detail
SPR_PART_AFFINE
enum SPR_PART_AFFINE
How a sprite part is drawn (its OAM affine bits): as it is, through an affine matrix, or through one in a box twice its size, so that a part scaled up past full size is not cut off.
| Enumerator | Value | Description |
|---|---|---|
SPRITE_PART_PLAIN | 0 | |
SPRITE_PART_AFFINE | 1 | |
SPRITE_PART_AFFINE_DOUBLE | 3 |
Definition at line 41 of file field_sprite_draw.c.
Functions in detail
fdSpriteComposePicture
Sint32 fdSpriteComposePicture(SPR *sprite, Uint16 direction)
Advances a sprite's animations by one tick, picks each sprite animation's
picture for the facing direction, and when any picture changed redraws the
sprite: the sprite animations composed by priority into one pixel buffer, an
optional outline, and the result uploaded to the sprite's VRAM tiles. Returns
1 when the first sprite animation's picture is to be mirrored.
References AnimationFacingEightPictures, AnimationFacingEightPicturesMirrored, AnimationFacingFivePictures, AnimationFacingFourPictures, AnimationFacingFrontBack, AnimationFacingFrontBackSwapped, AnimationFacingOnePicture, AnimationFacingSixPictures, AnimationFacingThreePictures, fdDecompressLZ(), fdRenderDecodePicture, fdRenderDecodePictureEnd, fdSpriteAnimationStart(), HeapSlots, pixels, RenderDecodePictureCodeSize, Sint32, syDecompressSpritePicture(), syDecompressTaggedLZ(), syDMAXCopy(), syHeapAllocate(), syHeapRelease(), syHeapSlotAllocate(), syHeapSlotRelease(), syVRAMCacheLoad(), syWordsClear() and width.
Referenced by fdRenderApplyProjectedPlacement() and fdRenderPlaceProjectedSprite().
Definition at line 56 of file field_sprite_draw.c.
fdRenderPlaceSpritePartPair
void fdRenderPlaceSpritePartPair(SPR *sprite, FIXED screenX, Sint32 height, Sint32 screenY, Sint32 groundHeight, FIXED *scale)
Positions a sprite's image (part 0) and shadow (part 1) on the screen: the image centred on screenX and raised height above screenY, the shadow at groundHeight. scale is the sprite's (x, y) scale (16.16); above 1.0 both parts use the double-size affine mode.
References Sint32.
Definition at line 377 of file field_sprite_draw.c.
fdRenderApplyProjectedPlacement
void fdRenderApplyProjectedPlacement(SPR *sprite, const SPR_PLACEMENT *pos, const SPR_SCALE *scale, Sint32 facing)
Places a sprite for the scrolling camera and queues it for drawing.
References fdSpriteComposePicture(), Sint32, syOAMAddSpriteAtDepth(), syOAMMatrixAllocateFromTransform() and sySpritePlacementReadValues().
Referenced by fdActorSystemPlaceSprites() and fdSpriteViewerPlaceRing().
Definition at line 435 of file field_sprite_draw.c.
fdRenderPlaceProjectedSprite
void fdRenderPlaceProjectedSprite( SPR *sprite, Sint32 *point, Sint32 *scale, Sint32 facing, Sint32 depth)
Places a sprite at 3D point for the fixed camera and queues it for drawing: projected to the screen and scaled by its distance (unless useOwnScale keeps its own scale), with an affine matrix as needed and its shadow on the ground below. depth 0 sorts it by distance; any other value is its draw slot.
References fdSpriteComposePicture(), Sint32, syConvert3Dto2D(), syMulFX(), syOAMAddSpriteAtDepth(), syOAMMatrixAllocateFromTransform() and syVRAMCacheReleaseVRAM().
Referenced by fdActorSystemProjectSprites().
Definition at line 550 of file field_sprite_draw.c.
fdSpriteSetAnimationColorModes
void fdSpriteSetAnimationColorModes(void *rawSprite, Uint32 colorMode)
Sets the colour mode (SPR_COL_MODE) of each of a sprite's animations to
colorMode, except sprite animations drawn hidden (SPRITE_COLOR_HIDDEN), and
marks the sprite for redrawing.
Referenced by fdActorSetSpriteColorMode() and scAltmillerCaveReleaseWallBurst().
Definition at line 694 of file field_sprite_draw.c.