Alchemy
Loading...
Searching...
No Matches

actors.c

Go to the documentation of this file.
1/// @file
2/// The party's sprites, placing a scene's actors, and the actor table.
3/// Part of object.c, the field object, compiled only through it.
4
6
7enum {
8 ACTOR_DJINNI_FLAG_COUNT = NUM_ELEMENTS * 20, ///< 20 flags per element
10};
11
12/// Returns the sprite of character, which is the character itself except that
13/// FLAG_CHILDHOOD gives characters 0 and 1 sprites 0x12 and 0x13, and
14/// FLAG_ISAAC_WEARS_TUNIC gives grown Isaac sprite 0x11.
15///
16/// Called by Event_SpawnObjectTable for every placement, and by
17/// PsynergyMenu_InitializeEntryObjects (through
18/// Party_RemapCharacterIdByFlagsFar) for the party's figures.
20 s32 sprite;
21
22 sprite = character;
23 if (sprite <= 8) {
25 if (sprite == 0) {
26 sprite = 0x12;
27 }
28 if (sprite == 1) {
29 sprite = 0x13;
30 }
31 } else if ((GameFlag_TestFar(FLAG_ISAAC_WEARS_TUNIC) != 0) &&
32 (sprite == 0)) {
33 sprite = 0x11;
34 }
35 }
36 return sprite;
37}
38
39/// Returns the sprite of character as Party_RemapCharacterIdByFlags would with
40/// FLAG_CHILDHOOD set to childhood (as recorded in a save file's summary).
41///
42/// Called by SaveMenu_ShowPartySprites through
43/// Party_RemapCharacterIdIfEnabledFar. Save summaries omit the tunic flag,
44/// so this never gives sprite 0x11.
46 s32 sprite;
47
48 sprite = character;
49 if ((sprite <= 8) && (childhood != 0)) {
50 if (sprite == 0) {
51 sprite = 0x12;
52 }
53 if (sprite == 1) {
54 sprite = 0x13;
55 }
56 }
57 return sprite;
58}
59
60#define MAP_CELLS ((struct MapCell *)Ram_MapCellBuffer)
61
62extern const struct ScenePlacement gField_DefaultPlacements[2];
63
64/// Creates the actors of a scene's placement table (ended by sprite -1), and
65/// records the table among the scene's tables. Sprites 0 to 7 are the party's
66/// characters and take their own actor slot; other placements take the actor
67/// slots from slot on, one each, up to slot 65. A placement whose condition
68/// does not hold is skipped, as is a Djinni hidden after a lost battle outside
69/// the world map. An existing actor is moved back to its place unless the
70/// party keeps its position.
71///
72/// Called by ObjectTable_ResetForObject (the leader, then the scene's table),
73/// BattleEffect_ClearAllObjects and Event_CallWithLastActiveObjectId. Records
74/// the table in work->tables and each actor in work->actors.
75void Event_SpawnObjectTable(struct ScenePlacement *entry, s32 slot) {
76 struct FieldWork *work;
77 struct ObjectRuntime *object;
78 struct ObjectRuntime *previous;
79 struct AnimationObject *sprite;
80 s32 tableIndex;
81 s32 actorIndex;
82 s32 spriteId;
83 s32 condition;
84 u8 spriteSlot;
85 u16 placementSprite;
86
87 work = (struct FieldWork *)gEventWork;
88 // Remember the table once, before consuming slots for its placements.
89 for (tableIndex = 0; tableIndex < 4; tableIndex++) {
90 if (work->tables[tableIndex] == entry)
91 break;
92 if (work->tables[tableIndex] == 0) {
93 work->tables[tableIndex] = entry;
94 break;
95 }
96 }
97 for (placementSprite = entry->sprite;
98 (s16)placementSprite != -1 && slot <= 65;
99 entry++, placementSprite = entry->sprite) {
100 // Current placement tables use sprites 0 to 504, so every live row sets
101 // actorIndex. XXX: what the 0x2705 cutoff was for; no table reaches it.
102 if (entry->sprite <= 7)
103 actorIndex = entry->sprite;
104 else if (entry->sprite <= 0x2705)
105 actorIndex = slot++;
106 condition = entry->condition;
107 if (!GameFlag_IsConditionActive(condition))
108 continue;
109 // Djinn_ResolvePendingEvent hides a Djinni after a loss or escape.
110 // Scene_ResetFlagsOnEnter clears these temporary flags on a normal entry.
111 if ((u32)(condition - FLAG_DJINNI_0) <= ACTOR_DJINNI_FLAG_COUNT - 1 &&
112 work->mode != MODE_WORLD_MAP &&
114 continue;
115 spriteId = Party_RemapCharacterIdByFlags(entry->sprite);
116 object = ObjectTable_Get(actorIndex);
117 if (object == 0) {
118 object = Object_CreateFar(spriteId, entry->x, entry->y, entry->z);
119 // Placement flag 1: share the previous actor's sprite resource.
121 previous = ObjectTable_Get(actorIndex - 1);
122 if (previous->animationKind == 1 && object->animationKind == 1) {
123 sprite = previous->animation;
124 sprite->retainCacheEntry = 1;
125 spriteSlot = sprite->slot;
126 sprite = object->animation;
127 sprite->retainCacheEntry = 1;
128 Resource_ResetEntry(sprite->slot);
129 sprite->slot = spriteSlot;
130 }
131 }
132 // Dora's tunic overlays the young sprites with its child part.
134 (u32)(spriteId - 0x12) <= 1)
138 Object_SetPositionAndResetMotionFar(object, entry->x, entry->y, entry->z);
139 }
140
141 if (object) {
143 // Start each idle animation at a random frame.
144 if (object->animationKind == 1 && (sprite = object->animation) != 0)
145 sprite->lastNo = ((u32)(Random16()) % (u32)30);
146 object->angle = entry->facing;
147 object->collisionFlags = 1;
150 ((struct ScriptObjectRuntime *)object)->homeX = object->x / 0x10000;
151 ((struct ScriptObjectRuntime *)object)->homeZ = object->z / 0x10000;
152 // A placement with a height is lifted half a pixel more and takes flags
153 // 4; outside the world map every height is then counted from the
154 // terrain below.
155 if (object->y != 0) {
156 object->flags = 4;
157 object->y += 0x8000;
158 }
159 if (work->mode == MODE_WORLD_MAP) {
160 // World-map placements use single sprites. While the tunic flag is
161 // set, all keep their native scale; otherwise they draw at 3/4 size.
162 object->flags &= 0xfe;
164 // UB: sprite creation can fail while the actor slot stays live.
165 // The native local is then indeterminate or from an earlier row.
166 // Checking the sprite grows tbs-en from 608 to 628 bytes.
167#ifdef UBFIX
168 if (object->animationKind == 1 &&
169 (sprite = object->animation) != NULL)
170#endif
171 sprite->scale = Iwram_MulQ16(sprite->scale, 3 * Q16_ONE / 4);
172 }
173 } else {
174 object->terrainHeight =
175 Map_GetTerrainHeightFar(0, object->x, object->z);
176 object->y += object->terrainHeight;
177 }
178 object->priorityFlags = 1;
179 }
180 work->actors[actorIndex] = (struct FieldActor *)object;
181 }
182}
183
184/// Destroys the actor in slot actorIndex, if there is one, and empties the
185/// slot. No caller names it; its far-call veneer has no exported name.
187 struct FieldWork *work = (struct FieldWork *)gEventWork;
188 void *object = ObjectTable_Get(actorIndex);
189
190 if (object != NULL) {
192#ifdef UBFIX
193 {
194 void *empty = NULL;
195
196 // Get also accepts words past the actor array, within the field work.
197 memcpy((u8 *)work + 0x14 + (u32)actorIndex * sizeof(empty), &empty,
198 sizeof(empty));
199 }
200#else
201 work->actors[actorIndex] = NULL;
202#endif
203 }
204}
205
206/// Creates a scene's actors on entering it: the party leader where the game
207/// state puts it, then the scene's placement table from actor slot 8, and the
208/// camera that follows the leader. A leader entering above ground where its
209/// cell and the cell north of it are climbing spots (collision code 0xfd) is
210/// raised by the ground height of the cell north of it less 32 pixels, and
211/// starts climbing (movement mode 1).
212///
213/// Called by Field_RunScene on entering a scene, and by
214/// Event_RunObjectHookAndWait.
215/// Empties every actor slot and table first; sets work->camera, the map's
216/// origin and gGameState.movementMode.
218 struct FieldWork *work;
219 struct ScenePlacement *entry;
220 struct ObjectRuntime *object;
221 struct ObjectRuntime *camera;
222 struct MapCell *cell;
223 struct MapCell *above;
224 s32 leader;
225 s32 pos;
226 s32 height;
227
228 work = (struct FieldWork *)gEventWork;
229 leader = gGameState.selectedActor;
230 // Build the leader's temporary placement before the scene's placed actors.
231 // The two-row table lives in the event work at 0x200.
232 entry = (struct ScenePlacement *)((u8 *)work + 0x200);
233 entry[0] = gField_DefaultPlacements[0];
234 entry[1] = gField_DefaultPlacements[1];
235 for (pos = 0; pos < 4; pos++)
236 work->tables[pos] = 0;
238 entry->condition = -1;
239 entry->sprite = leader;
241 entry->facing = gGameState.heading;
242 Event_SpawnObjectTable(entry, leader);
244
245 object = (struct ObjectRuntime *)work->actors[leader];
246 object->terrainId = gGameState.turn;
247 pos = (object->x / 0x100000) + (object->z / 0x100000) * 128;
248 cell = &MAP_CELLS[pos];
249 above = &MAP_CELLS[pos - 128];
250 if (gGameState.y != 0 && cell->collisionCode == 0xfd &&
251 above->collisionCode == 0xfd) {
253 height =
254 Map_GetTerrainHeightFar(0, object->x, object->z - 0x100000) - 0x200000;
255 object->y += height;
256 object->terrainHeight = object->y;
257 object->flags = 0;
260 } else {
262 }
263
264 // The camera follows this leader and starts at its resolved ground height;
265 // the map scrolls by the camera's position.
266 camera = Object_CreateFar(0x8000, object->x, object->y, object->z);
267 camera->terrainHeight = object->terrainHeight;
268 ObjectDispatch_StartCameraFar((struct DispatchObject *)camera, (s32)object);
269 if (work->mode == MODE_WORLD_MAP) {
270 struct AnimationEntry *meta =
272 23);
273 meta->param = 15;
274 meta->priority = 9;
275 }
276 ((struct MapScrollWork *)gMapWork[0])->origin = &camera->x;
277 work->camera = camera;
278}
279
280/// Returns the slot after the last placed actor (8 when there is none), or -1
281/// when slot 65 is occupied. Earlier holes are not reused by this append scan.
282///
283/// Called by BattleEffect_ClearAllObjects and Event_CallWithLastActiveObjectId
284/// to choose where Event_SpawnObjectTable starts.
286 struct FieldWork *work = (struct FieldWork *)gEventWork;
287 s32 lastActorIndex = ACTOR_FIRST_PLACED - 1;
288 s32 actorIndex = ACTOR_FIRST_PLACED;
289 struct FieldActor **slot = &work->actors[ACTOR_FIRST_PLACED];
290
291 do {
292 struct FieldActor *object = *slot++;
293
294 if (object != 0) {
295 lastActorIndex = actorIndex;
296 }
297 actorIndex++;
298 } while (actorIndex <= 65);
299 lastActorIndex++;
300 if (lastActorIndex == 66) {
301 lastActorIndex = -1;
302 }
303 return lastActorIndex;
304}
305
306/// Returns the address of actor slot index in the event work.
308 return (u8 *)gEventWork + 0x14 + actorIndex * sizeof(void *);
309}
310
311// Actors and the view: placement conditions from the map's view bounds, and
312// clearing placed actors.
313
314#define FLAG_IN_VIEW 0x164 ///< kept clear, so a placement using it appears
315#define FLAG_OUT_OF_VIEW 0x165 ///< kept set, so a placement using it does not
316
317#define PLACED_MAX 58 ///< actor slots 8 to 65
318
319/// Gives each placement with condition 0 a condition saying whether it lies
320/// within the map's view bounds, so that only those inside appear.
321///
322/// Called by scene overlays through Scene_AssignViewFlagsFar, which they import
323/// under four local names (FieldScene_PrepareActors the most used). Writes the
324/// placements' condition, and clears FLAG_IN_VIEW and sets FLAG_OUT_OF_VIEW.
326 struct MapScrollWork *view = gMapWork[0];
327
330 while (entry->sprite != -1) {
331 /* FAKEMATCH(temporary): the condition read into a u16 local and then an
332 * s16 one, which keeps loop.c to one hoisted bound address; as
333 * entry->condition == 0, 18 of 57 instructions differ in tbs-en. */
334 u16 rawCondition = entry->condition;
335 s16 condition = rawCondition;
336
337 if (condition == 0) {
338 s32 x = entry->x;
339 s32 z = entry->z;
340
341 if (view->minX <= x && x <= view->maxX && view->minY <= z &&
342 z <= view->maxY)
343 entry->condition = FLAG_IN_VIEW;
344 else
346 }
347 entry++;
348 }
349}
350
351/// Destroys the placed actors far from the view's centre: more than 160 pixels
352/// to either side, 200 pixels north or 100 pixels south. Actors at (0, 0) stay.
353///
354/// Called on the world map before an effect plays, by Field_UsePsynergy and
355/// Djinn_JoinParty; empties the slots it frees. BattleEffect_ClearAllObjects
356/// brings the actors back afterwards.
358 struct FieldWork *work = (struct FieldWork *)gEventWork;
359 struct ObjectRuntime *camera;
360 s32 centerX;
361 s32 centerZ;
362 s32 left;
363 s32 right;
364 s32 top;
365 s32 bottom;
366 struct FieldActor **actorSlot;
367 s32 releaseCacheMask;
368 s32 remainingSlots;
369
370 camera = work->camera;
371 centerX = camera->x;
372 left = centerX - 0xa00000;
373 right = centerX + 0xa00000;
374 centerZ = camera->z;
375 top = centerZ - 0xc80000;
376 bottom = centerZ + 0x640000;
377 actorSlot = &work->actors[ACTOR_FIRST_PLACED];
378 releaseCacheMask = ~1;
379
380 for (remainingSlots = PLACED_MAX - 1; remainingSlots >= 0; remainingSlots--) {
381 struct FieldActor *actor = *actorSlot;
382
383 if (actor != NULL) {
384 s32 actorX = actor->x.fixed;
385 s32 actorZ = actor->z.fixed;
386
387 if (actorX != 0 || actorZ != 0) {
388 if (actorX < left || actorX > right || actorZ < top ||
389 actorZ > bottom) {
390 u8 *sprite;
391 u8 *removed = &actor->spriteStorageKind;
392 u32 flags;
393
394 // Release the sprite's retained cache entry when destroying the
395 // actor.
396 *removed = 1;
397 sprite = (u8 *)actor->sprite;
398 flags = sprite[29];
399 sprite[29] = flags & releaseCacheMask;
401 sprite = NULL;
402 *actorSlot = (struct FieldActor *)sprite;
403 }
404 }
405 }
406
407 actorSlot++;
408 }
409}
410
411/// Destroys every placed actor and places the scene's actors again from its
412/// first placement table after the leader's.
413///
414/// Called on the world map after an effect, by Field_UsePsynergy and
415/// Djinn_JoinParty. Clears work->tables 1 to 3 before the table is spawned
416/// again.
418 struct FieldWork *work = (struct FieldWork *)gEventWork;
419 struct ScenePlacement *placements;
420 s32 slotIndex;
421
422 for (slotIndex = 0; slotIndex < PLACED_MAX; slotIndex++) {
423 struct FieldActor *actor = work->actors[ACTOR_FIRST_PLACED + slotIndex];
424
425 if (actor != 0) {
426 actor->spriteStorageKind = 1;
427 actor->sprite->retainCacheEntry = 0;
429 work->actors[ACTOR_FIRST_PLACED + slotIndex] = 0;
430 }
431 }
432 placements = work->tables[1];
433 work->tables[1] = 0;
434 work->tables[2] = 0;
435 work->tables[3] = 0;
436 if (placements != 0)
438}
439
440/// Empties all 66 actor slots, without destroying the actors.
441///
442/// Called by ObjectTable_ResetForObject.
444 struct FieldWork *work;
445 struct FieldActor *emptyActor;
446 s32 actorIndex;
447
448 emptyActor = NULL;
449 actorIndex = 65;
450 work = (struct FieldWork *)gEventWork;
451 do {
452 work->actors[actorIndex] = emptyActor;
453 actorIndex--;
454 } while (actorIndex >= 0);
455}
456
457/// Returns the actor in slot index (0 to 65), or NULL. Indices up to 191 read
458/// past the actor slots into the rest of the event work; larger ones give NULL.
459///
460/// The field's actor lookup: called across the object folder and, through
461/// ObjectTable_GetFar (Engine_ActorLookup), by scene overlays.
462void *ObjectTable_Get(u32 actorIndex) {
463 u8 *workBytes = (u8 *)gEventWork;
464 u32 slotOffset;
465#ifdef UBFIX
466 void *object;
467#endif
468 if (actorIndex > 0xbf)
469 return 0;
470 slotOffset = (actorIndex * 4) + 0x14;
471#ifdef UBFIX
472 // The legacy range includes non-pointer fields. Copy their representation
473 // without reading them through an incompatible pointer lvalue.
474 memcpy(&object, workBytes + slotOffset, sizeof(object));
475 return object;
476#else
477 return *(void **)(workBytes + slotOffset);
478#endif
479}
480
481/// Saves up to 32 actors (only the party's 8 on the world map) into
482/// gObjectSnapshots, with each one's slot, animation, sprite flags and
483/// priority, so that ObjectTable_Restore can put them back.
484///
485/// Called by Field_RunScene before a random battle, by the save menu through
486/// SaveState_CaptureObjectTableFar, and by two scenes (Tolbi's spring and the
487/// Venus Lighthouse aerie).
489 struct FieldWork *work;
490 struct ObjectRuntime *snapshot = gObjectSnapshots.actors;
491 u8 *animations = gObjectSnapshots.animations;
492 u8 *spriteFlags = gObjectSnapshots.spriteFlags;
493 u8 *priorities = gObjectSnapshots.priorities;
494 u8 *indices = gObjectSnapshots.slots;
495 u32 savedCount = 0;
496 s32 actorLimit = sizeof(work->actors) / sizeof(work->actors[0]);
497 struct ObjectRuntime *object;
498 s32 actorIndex;
500 u32 spriteFlagBits;
501 u32 priority;
502
503 work = (struct FieldWork *)gEventWork;
504 if (work->mode == MODE_WORLD_MAP)
505 actorLimit = ACTOR_FIRST_PLACED;
506 // Keep each actor and its three sprite-state bytes at matching save indices.
507 for (actorIndex = 0; actorIndex < actorLimit; actorIndex++) {
508 object = ObjectTable_Get(actorIndex);
509 if (object == NULL)
510 continue;
511 *indices++ = actorIndex;
512 Dma_Set(object, snapshot,
513 (DMA_ENABLE | DMA_32BIT) << 16 | (sizeof(struct ObjectRuntime) / 4),
514 REG_DMA3);
515 if (object->animationKind == 1) {
516 struct AnimationObject *sprite = object->animation;
517 animation = sprite->lastNo;
518 spriteFlagBits = sprite->flags;
519 priority = sprite->image.priority;
520 } else {
521 animation = 0;
522 spriteFlagBits = 0;
523 priority = 0;
524 }
525 *animations++ = animation;
526 *spriteFlags++ = spriteFlagBits;
527 *priorities++ = priority;
528 savedCount++;
529 snapshot++;
530 if (savedCount > OBJECT_SNAPSHOT_CAPACITY - 1)
531 break;
532 }
533 for (actorIndex = savedCount; actorIndex < OBJECT_SNAPSHOT_CAPACITY;
534 actorIndex++)
535 *indices++ = OBJECT_SNAPSHOT_EMPTY;
536}
537
538/// Puts back the actors ObjectTable_Snapshot saved, and moves the camera to the
539/// party leader's height.
540///
541/// Called by Field_RunScene when the party keeps its position
542/// (FLAG_KEEP_PARTY_POSITION), and by the Venus Lighthouse aerie scene through
543/// ObjectTable_RestoreFar. Only actors whose slots are filled again are
544/// restored; the leader is set idle.
546 struct ObjectRuntime *snapshot = gObjectSnapshots.actors;
547 u8 *indices = gObjectSnapshots.slots;
548 u8 *animations = gObjectSnapshots.animations;
549 u8 *spriteFlags = gObjectSnapshots.spriteFlags;
550 u8 *priorities = gObjectSnapshots.priorities;
551 s32 restoredCount;
552 struct ObjectRuntime *object;
553 struct AnimationObject *sprite;
554 struct ObjectRuntime *camera;
555 s32 *cameraPosition;
556 s32 actorIndex;
558 s32 priority;
559 s32 y;
560 s32 *leaderId = &gGameState.selectedActor;
561 struct EventWork **fieldWork = &gEventWork;
562 struct MapScrollWork **mapWork = (struct MapScrollWork **)gMapWork;
563
564 restoredCount = 0;
565 actorIndex = *indices++;
566 while (actorIndex != OBJECT_SNAPSHOT_EMPTY) {
567 object = ObjectTable_Get(actorIndex);
568 if (object != NULL) {
569 sprite = object->animation;
570 Dma_Set(snapshot, object,
571 (DMA_ENABLE | DMA_32BIT) << 16 |
572 (sizeof(struct ObjectRuntime) / 4),
573 REG_DMA3);
574 animation = *animations;
575 if (animation != 0)
576 ObjectDispatch_SelectAnimationFar(object, animation);
578 *spriteFlags);
579 priority = *priorities;
580 sprite->image.priority = priority;
581 sprite->shadow.priority = priority;
582 object->animation = sprite;
583 // Re-anchor the camera only when restoring the selected leader.
584 if (actorIndex == *leaderId) {
585 camera = ((struct FieldWork *)*fieldWork)->camera;
586 cameraPosition = (*mapWork)->origin;
587 y = object->y;
589 camera->y = y;
590 cameraPosition[1] = y;
592 }
593 }
594 snapshot++;
595 animations++;
596 spriteFlags++;
597 priorities++;
598 restoredCount++;
599 if (restoredCount > OBJECT_SNAPSHOT_CAPACITY - 1)
600 break;
601 actorIndex = *indices++;
602 }
603}
604
605#undef MAP_CELLS
606#undef FLAG_IN_VIEW
607#undef FLAG_OUT_OF_VIEW
608#undef PLACED_MAX
void ObjectMotion_SetActionCallback(struct ObjectRuntime *object, s32 action)
Starts an actor's action script: 1 to 4 the fixed action scripts, 5 follow the linked object,...
void * ObjectTable_Get(u32 actorIndex)
Returns the actor in slot index (0 to 65), or NULL.
Definition actors.c:462
#define FLAG_OUT_OF_VIEW
kept set, so a placement using it does not
Definition actors.c:315
@ ACTOR_TUNIC_ANIMATION
Definition actors.c:9
@ ACTOR_DJINNI_FLAG_COUNT
20 flags per element
Definition actors.c:8
#define PLACED_MAX
actor slots 8 to 65
Definition actors.c:317
s32 ObjectTable_FindLastActiveId(void)
Returns the slot after the last placed actor (8 when there is none), or -1 when slot 65 is occupied.
Definition actors.c:285
const struct ScenePlacement gField_DefaultPlacements[2]
void ObjectTable_ResetForObject(struct ScenePlacement *table)
Creates a scene's actors on entering it: the party leader where the game state puts it,...
Definition actors.c:217
void Scene_AssignViewFlags(struct ScenePlacement *entry)
Gives each placement with condition 0 a condition saying whether it lies within the map's view bounds...
Definition actors.c:325
void ObjectTable_Snapshot(void)
Saves up to 32 actors (only the party's 8 on the world map) into gObjectSnapshots,...
Definition actors.c:488
void ObjectTable_ClearAll(void)
Empties all 66 actor slots, without destroying the actors.
Definition actors.c:443
void ObjectTable_DestroyAtIndex(s32 actorIndex)
Destroys the actor in slot actorIndex, if there is one, and empties the slot.
Definition actors.c:186
void ObjectTable_Restore(void)
Puts back the actors ObjectTable_Snapshot saved, and moves the camera to the party leader's height.
Definition actors.c:545
UNUSED void * ObjectTable_GetSlotAddress(u32 actorIndex)
Returns the address of actor slot index in the event work.
Definition actors.c:307
#define FLAG_IN_VIEW
kept clear, so a placement using it appears
Definition actors.c:314
void Event_SpawnObjectTable(struct ScenePlacement *entry, s32 slot)
Creates the actors of a scene's placement table (ended by sprite -1), and records the table among the...
Definition actors.c:75
s32 Party_RemapCharacterIdByFlags(s32 character)
Returns the sprite of character, which is the character itself except that FLAG_CHILDHOOD gives chara...
Definition actors.c:19
void BattleEffect_ClearOutOfBoundsObjects(void)
Destroys the placed actors far from the view's centre: more than 160 pixels to either side,...
Definition actors.c:357
void BattleEffect_ClearAllObjects(void)
Destroys every placed actor and places the scene's actors again from its first placement table after ...
Definition actors.c:417
s32 Party_RemapCharacterIdIfEnabled(s32 character, s32 childhood)
Returns the sprite of character as Party_RemapCharacterIdByFlags would with FLAG_CHILDHOOD set to chi...
Definition actors.c:45
@ NUM_ELEMENTS
Definition battle_unit.h:41
static __inline__ void Dma_Set(const volatile void *source, volatile void *destination, u32 control, volatile u32 *channel)
Starts a DMA transfer: stores the source, destination and control words into channel's registers with...
Definition dma.h:62
void ObjectDispatch_StartCameraFar(struct DispatchObject *obj, s32 arg)
struct ObjectRuntime * Object_CreateFar(s32 id, s32 x, s32 y, s32 z)
Far call to FieldObject_Create.
void ObjectDispatch_ReleaseFar(struct DispatchObject *obj)
s32 Map_GetTerrainHeightFar(s32 layer, s32 x, s32 y)
void Object_SetPositionAndResetMotionFar(struct ObjectRuntime *obj, s32 x, s32 y, s32 z)
void ObjectDispatch_SetSingleChildFlagsFar(struct DispatchObject *obj, u32 flags)
void ObjectDispatch_SelectAnimationFar(void *raw, s32 no)
s32 ResourceMetadata_RegisterFar(struct AnimationObject *state, s32 id)
void ObjectDispatch_RegisterChildMetadataFar(struct DispatchObject *obj, s32 no)
void ObjectDispatch_StartIdleFar(struct DispatchObject *obj)
s32 GameFlag_TestFar(s32 flag)
s32 GameFlag_SetBitFar(s32 flag)
void GameFlag_ClearBitFar(s32 flag)
@ ACTOR_FIRST_PLACED
#define PLACEMENT_SHARE_PREVIOUS_SPRITE
#define Q16_ONE
One in the engine's signed 16.16 fixed-point format.
Definition fixed_math.h:10
#define FLAG_DJINNI_0
the flag of Djinni 0, set once it is caught
Definition flags.h:15
#define FLAG_KEEP_PARTY_POSITION
Definition flags.h:93
#define FLAG_CHILDHOOD
the prologue: Isaac and Garet are children
Definition flags.h:10
#define FLAG_ISAAC_WEARS_TUNIC
The young Isaac wears the tunic Dora made him take on the stormy night: placed child sprites get its ...
Definition flags.h:14
struct GameState gGameState
void * gMapWork[]
#define DMA_32BIT
Definition io_reg.h:210
#define REG_DMA3
Definition io_reg.h:153
#define DMA_ENABLE
Definition io_reg.h:217
#define Iwram_MulQ16(left, right)
Definition iwram_call.h:127
#define SET_POSITION(p, px, py, pz)
Sets the position or the velocity of a particle, a piece of debris or an object in one statement.
Definition macros.h:16
#define MAP_CELLS
Definition map_layers.c:794
u32 Random16(void)
Advances the game's random number generator (the C library's classic linear congruential one),...
Definition math.c:10
s32 GameFlag_IsConditionActive(s32 condition)
Returns whether an event condition holds: -1 always holds; a condition with bit 0x1000 holds while th...
Definition events.c:65
What every part of object.c shares: its includes and the macros and types more than one part uses.
struct ObjectTableSnapshot gObjectSnapshots
@ OBJECT_SNAPSHOT_EMPTY
@ OBJECT_SNAPSHOT_CAPACITY
struct EventWork * gEventWork
#define NULL
Definition bilibin.h:6
One animation layer of a sprite: its animation id, frames, running script and timer.
Definition animspr.h:37
u8 param
SpriteColorMode its pixels are drawn with; 0 when taken.
Definition animspr.h:45
u8 priority
drawing order 0 to 3 among the layers; above 3 not drawn
Definition animspr.h:46
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
Definition animspr.h:108
struct AnimationSpritePart shadow
Definition animspr.h:110
struct AnimationSpritePart image
Definition animspr.h:109
u8 flags
bits: 1 outlined in ObjectSystemWork's edge and fill colours | 0 shadow drawn (set when created)
Definition animspr.h:128
u8 lastNo
The animation number last selected, which selecting again skips.
Definition animspr.h:124
u8 slot
VRAM cache entry holding its tiles.
Definition animspr.h:112
s32 scale
16.16 fixed point, 0x10000 full size
Definition animspr.h:111
u8 retainCacheEntry
Keeps the VRAM cache entry when it is released or off screen.
Definition animspr.h:114
u16 priority
2 when created
Definition animspr.h:100
A field object as the object dispatcher's far calls take it.
The running scene's event work: its placement and event tables, its actors, the triggers and exit it ...
Definition event_work.h:20
A field actor: a person or thing on the field with a position, motion toward a target,...
Definition field_obj.h:30
union FieldCoordinate x
16.16 fixed-point pixels
Definition field_obj.h:35
u8 spriteStorageKind
Zero hides sprites; one draws a single sprite, two draws a group.
Definition field_obj.h:78
union FieldCoordinate z
16.16 fixed-point pixels
Definition field_obj.h:37
u16 work
The side of the player's next footprint (2 after a stop), or scene scratch.
Definition field_obj.h:112
Full event work allocated by Field_RunScene (heap slot 27).
struct ScenePlacement * tables[4]
The placement tables placed so far, recorded by Event_SpawnObjectTable.
struct ObjectRuntime * camera
the object the map view follows
s16 mode
MODE_WORLD_MAP (3) on the world map.
struct FieldActor * actors[66]
The actors by id: 0 to 7 the party's characters, 8 on the placed actors.
s32 z
16.16 fixed-point pixels
Definition game_state.h:52
s32 y
16.16 fixed-point pixels
Definition game_state.h:51
u16 turn
the leader's terrainId, kept with its position
Definition game_state.h:54
u32 heading
1/65536 turns
Definition game_state.h:53
s32 x
16.16 fixed-point pixels
Definition game_state.h:50
u8 movementMode
1 while the leader is climbing, 0 otherwise
Definition game_state.h:57
s32 selectedActor
the leader: its unit and its actor
Definition game_state.h:59
One cell of a map layer: its metatile and flags, its collision code and an attribute indexing the col...
Definition map.h:13
u8 collisionCode
The step code: 1 to 239 scene events, 240 and 241 encounter ground, 250 hazard, 252 to 254 for Field_...
Definition map.h:18
The field map's work: the followed position, screen shake, tile animations, blend script,...
Definition map_scroll.h:27
s32 * origin
The followed point, read as x, height and z in 16.16 fixed-point pixels; Camera_FollowActor points it...
Definition map_scroll.h:30
s32 maxY
16.16 fixed-point pixels
Definition map_scroll.h:41
One of the 64 field objects in the object pool (heap slot 5): its script, position,...
s32 terrainHeight
16.16 fixed-point pixels
s32 z
16.16 fixed-point pixels
void * animation
its sprite, or its list of four, by animationKind
s32 x
16.16 fixed-point pixels
s32 y
16.16 fixed-point pixels
u8 animationKind
Low four bits: 0 no sprite, 1 one sprite, 2 a group of up to four.
u8 animations[OBJECT_SNAPSHOT_CAPACITY]
each sprite's lastNo
struct ObjectRuntime actors[OBJECT_SNAPSHOT_CAPACITY]
copied by DMA
u8 slots[OBJECT_SNAPSHOT_CAPACITY]
actor numbers, or OBJECT_SNAPSHOT_EMPTY
u8 priorities[OBJECT_SNAPSHOT_CAPACITY]
both image and shadow priority
u8 spriteFlags[OBJECT_SNAPSHOT_CAPACITY]
restored through the dispatcher
An actor a scene places: its sprite, the condition for placing it, how it behaves,...
Definition field_scene.h:81
s32 x
16.16 fixed-point pixels
Definition field_scene.h:91
u8 flags
PLACEMENT_SHARE_PREVIOUS_SPRITE.
Definition field_scene.h:96
s16 condition
-1 always, a flag | 0x1000 set, else the flag clear; off the world map, 48 to 127 also need condition...
Definition field_scene.h:87
u16 facing
1/65536 turns (enum Facing)
Definition field_scene.h:94
s32 z
16.16 fixed-point pixels
Definition field_scene.h:93
s32 y
16.16 fixed-point pixels
Definition field_scene.h:92
s16 sprite
The actor's sprite; 0 to 7 are the party's characters, each in its own actor slot,...
Definition field_scene.h:84
s32 behavior
A built-in action (enum ActorBehavior, 1 to 7) or an action script, for ObjectMotion_SetActionCallbac...
Definition field_scene.h:90
A field object as its object script commands see it: the script and its place, position,...
s16 homeX
Its home, in pixels: where it was created or placed.
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
signed short s16
Definition types.h:12
unsigned short u16
Definition types.h:13
#define UNUSED
Definition types.h:22
unsigned char u8
Definition types.h:11
s32 fixed
16.16 fixed-point pixels
#define MODE_WORLD_MAP
the world map
Definition object.h:78
void * memcpy(void *destination, const void *source, unsigned long size)
s32 Resource_ResetEntry(u32 no)
Frees cache entry no: its blocks go back and the entry is marked free (offset 0xffff).
Definition vram_cache.c:106