Alchemy
Loading...
Searching...
No Matches

object_depth.h

Go to the documentation of this file.
1#include "types.h"
2#include "field_obj.h"
3
4// Tunnel Ruins and Venus Lighthouse: blocks the leader can stand beside, behind
5// or on.
6
7// An update hook: draw the block under the actors (ACTOR_PRIORITY_UNDERFOOT)
8// unless the leader is north of it and no higher than its height plus their
9// distance and 4 pixels, that is, behind it rather than on it.
10//
11// UB: update hooks return void. In tbs-en venus_lighthouse, plain
12// void differs in 7 bytes (extent 70 to 68 bytes). Keep the
13// unused native result in matching builds.
14#ifdef UBFIX
15static void
17#else
18static s32
20#endif
21 struct FieldActor *actor = (struct FieldActor *)fieldObject;
22 struct FieldActor *ref;
23 u8 *fp;
24 u8 flag;
26 fp = &actor->priorityFlags;
27 flag = *fp | ACTOR_PRIORITY_UNDERFOOT;
28 *fp = flag;
29 if (ref->z.fixed < actor->z.fixed) {
30 s32 lim = actor->z.fixed - ref->z.fixed;
31 s32 ay;
32 lim += PIXELS(4);
33 ay = actor->y.fixed;
34 ay += lim;
35 if (ref->y.fixed <= ay) {
37 *fp = flag;
38 }
39 }
40#ifdef UBFIX
41 return;
42#else
43 return 0;
44#endif
45}
46
47/// Unless actor first is south of actor second, swaps their positions and waits
48/// a frame.
49static void SceneActor_SwapPositionsByDepth(s32 first, s32 second) {
50 struct FieldActor *a = Object_GetById(first);
51 struct FieldActor *b = Object_GetById(second);
52
53 if (a->z.fixed <= b->z.fixed) {
54 s32 t;
55
56 t = a->x.fixed;
57 a->x.fixed = b->x.fixed;
58 b->x.fixed = t;
59 t = a->y.fixed;
60 a->y.fixed = b->y.fixed;
61 b->y.fixed = t;
62 t = a->z.fixed;
63 a->z.fixed = b->z.fixed;
64 b->z.fixed = t;
66 }
67}
struct FieldActor * Object_GetById(s32 actor)
Returns an actor, or NULL if it does not exist.
Field objects and actors, and the scene transition styles.
@ ACTOR_PRIORITY_UNDERFOOT
The depth sort treats it as 320 pixels higher on the screen.
Definition field_obj.h:155
@ ACTOR_PARTY_LEADER
#define PIXELS(value)
static s32 SceneActor_SetFlagBitByRelativeDepth(union FieldObject *fieldObject)
static void SceneActor_SwapPositionsByDepth(s32 first, s32 second)
Unless actor first is south of actor second, swaps their positions and waits a frame.
void Engine_TaskWait()
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
u8 priorityFlags
ActorPriorityFlag bits, read by the scrolling camera.
Definition field_obj.h:51
union FieldCoordinate z
16.16 fixed-point pixels
Definition field_obj.h:37
The integer types, TRUE, UNUSED and the fixed-address macros.
signed int s32
Definition types.h:14
unsigned char u8
Definition types.h:11
s32 fixed
16.16 fixed-point pixels
An object on the field, read as an actor or as an effect.