Alchemy
Loading...
Searching...
No Matches

djinn_figures.c

Go to the documentation of this file.
1/// @file
2/// FourObjectMotion: the row of four figures the Status and Djinn menus show,
3/// placed by a scheduler callback and eased in and out.
4/// Part of menu.c, the menu object, compiled only through it.
5
6#include "../menu_internal.h"
7
8/// Replaces the four displayed objects and starts their projected-position
9/// task.
10void FourObjectMotion_InitializeTopRow(void *unused0, s32 unused1) {
11 struct FourObjectMotionState *state = gMenuWork;
12 s32 index;
13
14 for (index = 0; index < 4; index++) {
15 struct AnimationObject *object = state->objects[index];
16
17 if (object != NULL) {
19 state->objects[index] = NULL;
20 }
21 }
22
23 for (index = 0; index < 4; index++) {
24 struct AnimationObject *object =
26
27 if (object != NULL) {
29 }
30 state->objects[index] = object;
31 state->positionsX[index] = 0x10;
32 state->positionsY[index] = 0x20;
33 }
35}
36
37/// Releases the four objects and removes their scheduler callback.
38#define FOUR_OBJECT_MOTION_DEFINE_RELEASE(name, update) \
39 void name(void) { \
40 struct FourObjectMotionState *state = gMenuWork; \
41 s32 index = 0; \
42 \
43 do { \
44 struct AnimationObject *object = state->objects[index]; \
45 \
46 if (object != NULL) { \
47 ResourceObject_ReleaseFar(object); \
48 state->objects[index] = NULL; \
49 } \
50 index++; \
51 } while (index < 4); \
52 Scheduler_RemoveCallback(update); \
53 }
54
57
58/// Full size, 1.0 in 16.16, and the height the figures are placed from: 482
59/// pixels, in 16.16.
60#define FOUR_OBJECT_MOTION_FULL_SCALE 0x10000u
61#define FOUR_OBJECT_MOTION_ORIGIN_Y 0x01e20000u
62
63/// Projects the four objects at full scale from their saved row positions.
65 struct FourObjectMotionState *state = gMenuWork;
66 s32 index;
67 struct SpriteScale scale;
68 struct SpritePlacement placement;
69
70 index = 0;
71 while (1) {
72 struct AnimationObject *object = state->objects[index];
73
74 if (object != 0) {
76 ((s32)state->verticalOrigins[index] << 16);
77 object->image.priority = 0;
80 placement.x = (s32)state->positionsX[index] << 16;
81 placement.height = vertical;
82 placement.y = ((s32)state->positionsY[index] << 16) + vertical;
83 placement.groundHeight = 0;
84 Object_ApplyProjectedPlacementFar(object, &placement, &scale, 0x4000);
85 }
86 index += 1;
87 if (index > 3)
88 break;
89 }
90}
91
92/// Projects the bottom row using its saved scale or easing toward full size.
94 struct FourObjectMotionState *menu = gMenuWork;
95 s32 objectIndex;
96 struct SpriteScale scale;
97 struct SpritePlacement placement;
98
100 objectIndex = 0;
101 do {
102 struct AnimationObject *object = menu->objects[objectIndex];
103
104 if (object != 0) {
105 u32 projectedY =
106 (241u << 17) - ((u32)(s32)menu->verticalOrigins[objectIndex] << 16);
107 s32 phase;
108 s32 limit;
109 /* FAKEMATCH(pin): rowY fixed in r2, where the row's second read goes;
110 * as a plain s32, which takes r3 and costs limit its register, 39 of
111 * 120 instructions differ in tbs-en. */
112 register s32 rowY asm("r2");
113
114 object->image.priority = 0;
115 phase = menu->phases[objectIndex];
116 if (phase < 0) {
117 scale.x = -phase;
118 scale.y = -phase;
119 } else {
120 scale.x = phase + (s32)(0x10000 - phase) / 3;
121 scale.y = scale.x;
122 menu->phases[objectIndex] = scale.x;
123 }
124 placement.x = (u32)(s32)menu->positionsX[objectIndex] << 16;
125 placement.height = projectedY;
126 placement.y =
127 ((u32)(s32)menu->positionsY[objectIndex] << 16) + projectedY;
128 placement.groundHeight = 0;
129 rowY = menu->positionsY[objectIndex];
130 limit = 0x8000;
131 if (rowY >= 0)
132 limit = 0x4000;
133 Object_ApplyProjectedPlacementFar(object, &placement, &scale, limit);
134 }
135 objectIndex++;
136 } while (objectIndex <= 3);
137}
138
139/// Replaces the bottom row's four objects and starts its easing task.
141 struct FourObjectMotionState *state = gMenuWork;
142 s32 index;
143
144 for (index = 0; index < 4; index++) {
145 struct AnimationObject *object = state->objects[index];
146
147 if (object != NULL) {
149 state->objects[index] = NULL;
150 }
151 }
152 for (index = 0; index < 4; index++) {
153 struct AnimationObject *object =
155
156 if (object != NULL)
158 state->objects[index] = object;
159 state->phases[index] = 0x10000;
160 state->positionsX[index] = 0x10;
161 state->positionsY[index] = 0xc8;
162 }
164}
165
166/// Updates one object's saved position and its signed y marker.
168 struct FourObjectMotionState *state = gMenuWork;
169
170 if (state->objects[index] != NULL) {
171 state->positionsX[index] = x;
172 state->positionsY[index] = negative != 0 ? y | (s32)0xffff8000 : y;
173 return 0x23c + index * 2;
174 }
175 return index;
176}
177
179 ((struct FourObjectMotionState *)gMenuWork)->phases[index] = phase;
180#ifdef UBFIX
181 return 0;
182#endif
183}
184
185/// Replaces one displayed object and selects its animation.
186s32 FourObjectMotion_ReplaceSlot(s32 index, s32 resourceKind, s32 value) {
187 struct FourObjectMotionState *state = gMenuWork;
188
189 if (state->objects[index] != NULL) {
190 ResourceObject_ReleaseFar(state->objects[index]);
191 state->objects[index] = NULL;
192 }
193 {
194 struct AnimationObject *object =
196
197 if (object != NULL)
199 state->objects[index] = object;
200 }
201 return 1;
202}
203
206
207/// Starts the walking animation (1) of each party figure. Nothing calls it.
209 struct InventoryMenuState *state = gMenuWork;
210 s32 index;
211
212 for (index = 0; index < state->partyCount; ++index) {
214 }
215}
216
217#undef FOUR_OBJECT_MOTION_DEFINE_RELEASE
218#undef FOUR_OBJECT_MOTION_FULL_SCALE
219#undef FOUR_OBJECT_MOTION_ORIGIN_Y
void FourObjectMotion_UpdateAllPositions(void)
Projects the four objects at full scale from their saved row positions.
void FourObjectMotion_ClearSlotsAndScheduleAlt(void)
s32 FourObjectMotion_ReplaceSlot(s32 index, s32 resourceKind, s32 value)
Replaces one displayed object and selects its animation.
#define FOUR_OBJECT_MOTION_DEFINE_RELEASE(name, update)
Releases the four objects and removes their scheduler callback.
void FourObjectMotion_InitializeBottomRow(s32 unused0, s32 unused1)
Replaces the bottom row's four objects and starts its easing task.
void FourObjectMotion_ClearSlotsAndSchedule(void)
void FourObjectMotion_InitializeTopRow(void *unused0, s32 unused1)
Replaces the four displayed objects and starts their projected-position task.
#define FOUR_OBJECT_MOTION_ORIGIN_Y
s32 FourObjectMotion_SetSlotPosition(s32 index, s32 x, s32 y, s32 negative)
Updates one object's saved position and its signed y marker.
s32 FourObjectMotion_SetSlotPhase(s32 index, s32 phase)
UNUSED void Menu_StartPartyFiguresWalking(void)
Starts the walking animation (1) of each party figure. Nothing calls it.
void FourObjectMotion_UpdateBottomRow(void)
Projects the bottom row using its saved scale or easing toward full size.
#define FOUR_OBJECT_MOTION_FULL_SCALE
Full size, 1.0 in 16.16, and the height the figures are placed from: 482 pixels, in 16....
s32 AnimationObjects_SelectAnimationFar(struct AnimationObject *state, s32 flags)
struct AnimationObject * ResourceObject_CreateFar(s32 id)
void Object_ApplyProjectedPlacementFar(struct AnimationObject *sprite, const struct SpritePlacement *position, const struct SpriteScale *scale, s32 facing)
Far call to Render_ApplyProjectedPlacement.
void ResourceObject_ReleaseFar(struct AnimationObject *sprite)
void Link_DrawShiftedTilePairFar(s32 offset)
void * gMenuWork
What every part of the menu object shares: its includes, and the macros and types more than one part ...
s32 gFourObjectMotion_ResourceIds[4]
The resource ids of the four sprites FourObjectMotion shows.
Definition menudata.c:55
s32 Scheduler_AddOrUpdateCallback(SchedulerCallback callback, s32 order)
Schedules callback with order, or gives a task already running it the new order, and re-sorts the tab...
Definition scheduler.c:102
#define NULL
Definition bilibin.h:6
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
Definition animspr.h:108
s32 scale
16.16 fixed point, 0x10000 full size
Definition animspr.h:111
The menu work as the row of four figures reads it: each figure's object, screen position and motion p...
struct AnimationObject * objects[4]
s16 positionsX[4]
screen pixels
s16 verticalOrigins[4]
screen pixels
s16 positionsY[4]
screen pixels
The item menu's work, in the HEAP_SLOT_MENU work slot: its windows, the party figures,...
struct AnimationObject * ownerObjects[8]
the party members' figures
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.
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
#define UNUSED
Definition types.h:22
#define UI_PAGE_ARROW_VRAM
Definition window.h:64