Alchemy
Loading...
Searching...
No Matches

object_findslot.h

Go to the documentation of this file.
1#include "types.h"
2#include "field_obj.h"
3#include "field_runtime.h"
4
5// Colosso Log, River and Wall, and Venus Lighthouse.
6
7/// Returns the placed actor (8 to 65) whose cell, and 16-pixel step of height,
8/// is that of the 16.16 position, or 0. self is not read.
9static void *SceneData_FindSlotAtPosition(const struct FieldPosition *position,
10 void *self) {
11 const struct FieldPosition *pos = position;
12 // Field_RunScene owns all 66 slots. EventWork's actors view holds only the
13 // first eight; the placed actors follow in its separate placedActors array.
14 struct FieldWork *work = (struct FieldWork *)gEventWork;
15 struct FieldActor **slots = work->actors;
16 u32 i;
17
18 for (i = ACTOR_FIRST_PLACED;
19 i < sizeof(work->actors) / sizeof(work->actors[0]); i++) {
20 struct FieldActor *p = slots[i];
21
22 // UB: ObjectTable_ClearAll leaves unused slots null. Skipping them grows
23 // this helper from 0x48 to 0x4c bytes in the native English trial.
24#ifdef UBFIX
25 if (p == NULL)
26 continue;
27#endif
28 if ((pos->x >> 20) == (p->x.fixed >> 20) &&
29 (pos->y >> 20) == (p->y.fixed >> 20) &&
30 (pos->z >> 20) == (p->z.fixed >> 20)) {
31 return p;
32 }
33 }
34 return 0;
35}
Field objects and actors, and the scene transition styles.
The field's runtime work: map cells, scene records and regions, map markers and FieldWork.
@ ACTOR_FIRST_PLACED
static void * SceneData_FindSlotAtPosition(const struct FieldPosition *position, void *self)
Returns the placed actor (8 to 65) whose cell, and 16-pixel step of height, is that of the 16....
struct EventWork * gEventWork
#define NULL
Definition bilibin.h:6
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
union FieldCoordinate y
16.16 fixed-point pixels
Definition field_obj.h:36
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
A position on the field.
s32 z
16.16 fixed-point pixels
Full event work allocated by Field_RunScene (heap slot 27).
The integer types, TRUE, UNUSED and the fixed-address macros.
unsigned int u32
Definition types.h:15
s32 fixed
16.16 fixed-point pixels