Drawing sprites: composing their layers and placing them on screen. More...
Go to the source code of this file.
Typedefs | |
| typedef void(*) | SpriteDrawFn(const void *src, void *dst, s32 param) |
| Draws one layer's frame into a sprite's pixel buffer (Render_DecodeFrame, run from RAM). | |
| typedef void(*) | SpriteUploadFn(const void *src, u32 w, u32 h, void *vram) |
| Uploads a finished sprite buffer to sprite VRAM (Tile_CopyStrided). | |
Functions | |
| s32 | Sprite_ComposeAnimationFrame (struct AnimationObject *obj, u16 dir) |
| Advances a sprite's animation layers by one frame, picks each layer's frame for the facing dir, and when any frame changed redraws the sprite: the layers composed by priority into one pixel buffer, an optional outline, and the result uploaded to the sprite's VRAM tiles. | |
| void | Render_PlaceSpritePartPair (struct AnimationObject *sprite, s32 screenX, s32 height, s32 screenY, s32 groundHeight, s32 *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. | |
| void | Render_ApplyProjectedPlacement (struct AnimationObject *sprite, const struct SpritePlacement *position, const struct SpriteScale *scale, s32 facing) |
| Places a sprite for the scrolling camera and queues it for drawing. | |
| void | Render_PlaceProjectedSprite (struct AnimationObject *sprite, s32 *point, s32 *scale, s32 facing, s32 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. | |
| void | ObjectGroup_SetChildValueUnlessFifteen (void *rawSprite, u32 value) |
| Sets the draw parameter of each of a sprite's layers to value, except layers whose parameter is 15, and marks the sprite for redrawing. | |
Drawing sprites: composing their layers and placing them on screen.
Part of field.c, the field object, compiled only through it.
Definition in file sprite_draw.c.
| typedef void(*) SpriteDrawFn(const void *src, void *dst, s32 param) |
Draws one layer's frame into a sprite's pixel buffer (Render_DecodeFrame, run from RAM).
Definition at line 9 of file sprite_draw.c.
Uploads a finished sprite buffer to sprite VRAM (Tile_CopyStrided).
Definition at line 11 of file sprite_draw.c.
| s32 Sprite_ComposeAnimationFrame | ( | struct AnimationObject * | obj, |
| u16 | dir ) |
Advances a sprite's animation layers by one frame, picks each layer's frame for the facing dir, and when any frame changed redraws the sprite: the layers composed by priority into one pixel buffer, an optional outline, and the result uploaded to the sprite's VRAM tiles.
Returns 1 when layer 0's frame for this facing is drawn mirrored.
Called for each sprite drawn, every frame, by Render_ApplyProjectedPlacement and Render_PlaceProjectedSprite. Writes the layers' script position, timer and frame, the sprite's dirty flag and tile, its tiles in OBJ VRAM, and the ObjectSystemWork's count of bytes composed; takes heap slot HEAP_SLOT_FRAME_SCRATCH for the decoder when no caller holds it, and frees it again.
Definition at line 25 of file sprite_draw.c.
Referenced by Render_ApplyProjectedPlacement(), Render_PlaceProjectedSprite(), and Sprite_ComposeAnimationFrame().
| void Render_PlaceSpritePartPair | ( | struct AnimationObject * | sprite, |
| s32 | screenX, | ||
| s32 | height, | ||
| s32 | screenY, | ||
| s32 | groundHeight, | ||
| s32 * | 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. It has a bare veneer in the field far-call table, and no caller names it.
Definition at line 337 of file sprite_draw.c.
Referenced by Render_PlaceSpritePartPair().
| void Render_ApplyProjectedPlacement | ( | struct AnimationObject * | sprite, |
| const struct SpritePlacement * | position, | ||
| const struct SpriteScale * | scale, | ||
| s32 | facing ) |
Places a sprite for the scrolling camera and queues it for drawing.
Position holds screen x, height, screen y and ground height in 16.16 pixels; scale holds its x/y factors and facing its angle. Builds an affine matrix when the sprite is mirrored, scaled or rotated, queues the shadow (when the sprite has one) and then the image in a draw slot by depth; an object 100 pixels or more below the ground takes slot 1 instead, its shadow slot 0.
Called by ObjectSystem_UpdateCamera for each one-sprite object on a layered map, by the sprite viewer, and as Object_ApplyProjectedPlacementFar by the battle effects, the Psynergy effects and the menus.
Definition at line 384 of file sprite_draw.c.
Referenced by Battle_PlaceActorsByFormationKind(), ObjectSystem_UpdateCamera(), and Render_ApplyProjectedPlacement().
| void Render_PlaceProjectedSprite | ( | struct AnimationObject * | sprite, |
| s32 * | point, | ||
| s32 * | scale, | ||
| s32 | facing, | ||
| s32 | 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. A sprite off screen gives up its VRAM cache entry unless retainCacheEntry holds it.
Called by ObjectSystem_UpdateCameraFixed for each object on the world map and in the battle; while a menu suspends projection (ObjectSystemWork.suspended) every sprite is treated as off screen.
Definition at line 481 of file sprite_draw.c.
Referenced by ObjectSystem_UpdateCameraFixed(), and Render_PlaceProjectedSprite().
| void ObjectGroup_SetChildValueUnlessFifteen | ( | void * | rawSprite, |
| u32 | value ) |
Sets the draw parameter of each of a sprite's layers to value, except layers whose parameter is 15, and marks the sprite for redrawing.
Called by Animation_ApplyChildValues and, as ObjectGroup_SetChildValueUnlessFifteenFar, by the Psynergy effects, the Sanctum and the Altmiller Cave scene.
Definition at line 599 of file sprite_draw.c.
Referenced by AltmillerCave_ReleaseWallBurst(), Animation_ApplyChildValues(), and ObjectGroup_SetChildValueUnlessFifteen().