Alchemy
Loading...
Searching...
No Matches

render_placement.h

Go to the documentation of this file.
1#ifndef ALCHEMY_RENDER_PLACEMENT_H
2#define ALCHEMY_RENDER_PLACEMENT_H
3
4/// @file
5/// A sprite's screen position and scale.
6
7#include "types.h"
8#include "static_assert.h"
9
10/// A sprite's screen position and its two vertical offsets, in 16.16 pixels.
12#ifdef UBFIX
13 union {
14 struct {
15 s32 x; ///< screen x of the sprite's centre
16 s32 height; ///< how far the image is raised above y
17 s32 y; ///< screen y at the ground; sets the depth slot
18 s32 groundHeight; ///< how far the shadow is raised above y
19 };
20 s32 values[4];
21 };
22#else
23 s32 x; ///< screen x of the sprite's centre
24 s32 height; ///< how far the image is raised above y
25 s32 y; ///< screen y at the ground; sets the depth slot
26 s32 groundHeight; ///< how far the shadow is raised above y
27#endif
28};
29
30/// Returns the placement's values as an array.
31// UB: the legacy renderer walks across the scalar members as an array. UBFIX
32// supplies a real array; an always-on union changes producer scheduling.
33static inline const s32 *
35#ifdef UBFIX
36 return placement->values;
37#else
38 return &placement->x;
39#endif
40}
41
42/// Returns the placement's values as a writable array.
43static inline s32 *SpritePlacement_Values(struct SpritePlacement *placement) {
44#ifdef UBFIX
45 return placement->values;
46#else
47 return &placement->x;
48#endif
49}
50
51/// Horizontal and vertical sprite scale; 0x10000 is the original size.
53 union {
54 struct {
55 s32 x; ///< 16.16
56 s32 y; ///< 16.16
57 };
58 s32 values[2];
59 };
60};
61
62STATIC_ASSERT(sizeof(struct SpritePlacement) == 0x10);
63STATIC_ASSERT(offsetof(struct SpritePlacement, height) == 0x04);
65STATIC_ASSERT(offsetof(struct SpritePlacement, groundHeight) == 0x0c);
66STATIC_ASSERT(sizeof(struct SpriteScale) == 0x08);
68
69#endif
static s32 * SpritePlacement_Values(struct SpritePlacement *placement)
Returns the placement's values as a writable array.
static const s32 * SpritePlacement_ReadValues(const struct SpritePlacement *placement)
Returns the placement's values as an array.
STATIC_ASSERT, a compile-time check that emits nothing.
#define STATIC_ASSERT(condition)
C89 permits repeated extern declarations of the same array.
#define offsetof(type, member)
Definition stddef.h:19
A sprite's screen position and its two vertical offsets, in 16.16 pixels.
s32 x
screen x of the sprite's centre
s32 y
screen y at the ground; sets the depth slot
s32 groundHeight
how far the shadow is raised above y
s32 height
how far the image is raised above y
Horizontal and vertical sprite scale; 0x10000 is the original size.
The integer types, TRUE, UNUSED and the fixed-address macros.
signed int s32
Definition types.h:14