Alchemy
Loading...
Searching...
No Matches

object_orbit.h

Go to the documentation of this file.
1#include "orbit.h"
2#include "flags.h"
3
4// Crossbone Isle, Kalay, Kolima's forest clearing, Lunpa, McCoy's palace
5// garden, Mogall Forest and Vale: a Nut floating where it lies, until it is
6// taken.
7
8/// The Nut's callback, each frame: it sways up to two pixels either side of its
9/// spot and dips up to two pixels below it, at a random pace.
11 s16 *q = (s16 *)p[20];
12 s32 a, b;
13 s32 d = Engine_MathSin(p[12]) * 2;
14 if (d > 0)
15 d = -d;
16 p[2] = p[14] + Engine_MathCos(p[12]) * 2;
17 p[3] = p[15] + d;
18 q[15] = Engine_MathCos(p[12] + 0x8000) / 8;
21 p[12] = p[12] + ((((u32)a << 9) >> 16) + (((u32)b << 9) >> 16)) + 0x400;
22 return 0;
23}
24
25/// Draws actor id as the Nut's icon and starts it floating, 32 pixels up unless
26/// the party returns to where it was.
30 u8 *transfer;
31 s32 zero;
32
34 sprite = actor->sprite;
35 sprite->flags09Mode = 1;
36 sprite->flags05Bit5 = 0;
37 sprite->flags09High = 0;
38
39 zero = 0;
40 sprite->state = zero;
41 Engine_ActorSetSpriteFlags((struct FieldActor *)actor, zero);
42 actor->active = zero;
43 actor->mode = zero;
44
46 actor->y += 0x200000;
47
48 actor->flags23 &= 0xfe;
49 actor->visible = 1;
50
51 transfer = Engine_HeapAllocate(17, 0x608);
53 transfer += 0x400;
54 Engine_VramLoad(sprite->palette, 128, transfer);
56
57 actor->orbitCenterX = actor->x;
58 actor->orbitAngle = zero;
59 actor->orbitCenterY = actor->y;
60 actor->active = 1;
62 actor->state = zero;
63}
struct FieldActor * Object_GetById(s32 actor)
Returns an actor, or NULL if it does not exist.
void Engine_ActorSetSpriteFlags(struct FieldActor *, s32)
void Engine_ItemLoadIcon(s32 item)
s32 Engine_MathSin(s32 angle)
void Engine_HeapRelease(s32 slot)
s32 Engine_VramLoad(s32 block, s32 size, const void *data)
void * Engine_HeapAllocate(s32 slot, s32 size)
s32 Engine_RandomNext()
s32 Engine_GameFlagIsSet(s32 flag)
s32 Engine_MathCos(s32 angle)
Game flags, named where their meaning is shown.
#define FLAG_KEEP_PARTY_POSITION
Definition flags.h:93
@ ITEM_NUT
Definition item_ids.h:41
The views of an orbiting scene object's sprite.
void Scene_FloatNut(s32 id)
Draws actor id as the Nut's icon and starts it floating, 32 pixels up unless the party returns to whe...
static s32 SceneEffect_UpdateOrbitPosition(s32 *p)
The Nut's callback, each frame: it sways up to two pixels either side of its spot and dips up to two ...
A field actor: a person or thing on the field with a position, motion toward a target,...
Definition field_obj.h:30
A floating Nut's sprite, seen as the attribute bits, palette and state its scenes set.
Definition orbit.h:11
u8 state
AnimationObject's count of layers; the Nut's scenes zero it.
Definition orbit.h:34
u8 palette
AnimationObject's slot: the VRAM cache entry the Nut's icon is loaded into.
Definition orbit.h:32
u8 flags09Mode
priority; the Nut's scenes set 1
Definition orbit.h:26
u8 flags05Bit5
full colour; the Nut's scenes clear it
Definition orbit.h:18
u8 flags09High
palette; the Nut's scenes set 0
Definition orbit.h:27
A floating Nut's actor: its position, the spot it sways around and how far through the sway it is,...
Definition orbit.h:39
s32 orbitCenterY
16.16 fixed-point pixels
Definition orbit.h:53
s32 y
16.16 fixed-point pixels
Definition orbit.h:42
OrbitingSceneObjectSprite * sprite
Definition orbit.h:56
u8 flags23
FieldActor's priorityFlags; the Nut's scenes clear bit 0, ACTOR_PRIORITY_AUTOMATIC.
Definition orbit.h:47
u32 callback
FieldActor's update hook; Scene_FloatNut sets SceneEffect_UpdateOrbitPosition.
Definition orbit.h:71
u8 visible
FieldActor's frozen, which skips steering, terrain, gravity and floating; the Nut's scenes set it.
Definition orbit.h:67
u8 mode
FieldActor's motionFlags; the Nut's scenes zero it.
Definition orbit.h:58
s32 x
16.16 fixed-point pixels
Definition orbit.h:41
s32 orbitAngle
1/65536 turns; advanced by 0x400 plus two random steps each frame.
Definition orbit.h:50
u8 active
FieldActor.retainSpriteCache: the Nut's scenes keep its sprite's VRAM cache entry.
Definition orbit.h:63
u8 state
FieldActor's first unk56 byte; Scene_FloatNut zeroes it.
Definition orbit.h:59
s32 orbitCenterX
16.16 fixed-point pixels
Definition orbit.h:52
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
signed short s16
Definition types.h:12
unsigned char u8
Definition types.h:11