Alchemy
Loading...
Searching...
No Matches

motobj.h

Go to the documentation of this file.
1#ifndef ALCHEMY_MOTION_OBJECT_H
2#define ALCHEMY_MOTION_OBJECT_H
3
4/// @file
5/// MotionObject, an effect object that moves and draws one sprite.
6
7#include "types.h"
8#include "static_assert.h"
9#include "battle_session.h"
10#include "edition.h"
11#include "farcall.h"
12
13union FieldObject;
14
15/// An effect object that moves and draws one sprite: its position, scale,
16/// velocity and target, and its per-frame update.
17/// It is one of the object slots Object_CreateFar hands out, the same object
18/// FieldActor and ScriptMotionObject describe; the notes name their fields at
19/// the same offsets.
21 u8 unk00[0x06]; ///< ScriptMotionObject's script and scriptCursor
22 u16 angle; ///< 1/65536 turns
23 s32 x; ///< 16.16 fixed-point pixels
24 s32 y; ///< 16.16 fixed-point pixels
25 s32 z; ///< 16.16 fixed-point pixels
26 u8 unk14[0x04]; ///< FieldActor's terrainHeight, the ground's y
27 s32 scaleX; ///< 16.16 fixed point, 0x10000 full size
28 s32 scaleY; ///< 16.16 fixed point, 0x10000 full size
29 u16 height; ///< half the sprite's box height; FieldActor's radius
30 u8 unk22[0x02]; ///< FieldActor's terrainId and priorityFlags
31 s32 velocityX; ///< 16.16 fixed-point pixels per frame
32 s32 velocityY; ///< 16.16 fixed-point pixels per frame
33 s32 velocityZ; ///< 16.16 fixed-point pixels per frame
34 s32 speedLimit; ///< 16.16 fixed-point pixels per frame
35 /// Horizontal speed gained each frame towards the target, or lost braking
36 /// without one, in 16.16 fixed-point pixels per frame.
38 s32 targetX; ///< 16.16 fixed-point pixels; 0x80000000 for no target
39 s32 targetY; ///< 16.16 fixed-point pixels
40 s32 targetZ; ///< 16.16 fixed-point pixels
41 /// With motionFlags bit 1, the 16.16 share of velocityY kept on a bounce;
42 /// with bit 2, the float's phase, stepped each frame (ScriptMotionObject's
43 /// vertical).
45 /// Gravity: taken from velocityY each frame above the ground with
46 /// motionFlags bit 1, in 16.16 fixed-point pixels per frame; with bit 2, it
47 /// also scales the float.
49 u8 unk4c[0x04]; ///< FieldActor's riseBaseY
50 void *records; ///< one sprite, or a table of up to four (recordStorageKind)
51 /// bits: 3..0 RECORDS_NONE, RECORDS_SINGLE or RECORDS_TABLE
53 /// bits: 4 no terrain slowdown | 3 bigger float | 2 floats | 1 falls |
54 /// 0 follows terrain
56 u8 unk56[0x02]; ///< ScriptMotionObject's arrivalAxis and unk57
57 u8 snapToTarget; ///< nonzero: lands exactly on the target, else brakes in
58 u8 unk59; ///< FieldActor's collisionFlags; battle units set 3
59 u8 autoFaceMotion; ///< bit 0 turns the object to face where it moves
60 /// FieldActor's paused, timer, linkedObject and the bytes between; not
61 /// named by TBS code through this view.
62 u8 unk5b[0x11];
63 void (*update)(union FieldObject *object); ///< run first each frame
64};
65
66/// A sprite of an animation record, as battle objects set its palette and
67/// drawing priority.
72};
73
74STATIC_ASSERT(sizeof(struct MotionObject) == 0x70);
75STATIC_ASSERT(offsetof(struct MotionObject, scaleX) == 0x18);
77STATIC_ASSERT(offsetof(struct MotionObject, velocityX) == 0x24);
78STATIC_ASSERT(offsetof(struct MotionObject, targetX) == 0x38);
79STATIC_ASSERT(offsetof(struct MotionObject, motionFlags) == 0x55);
80STATIC_ASSERT(offsetof(struct MotionObject, records) == 0x50);
81STATIC_ASSERT(offsetof(struct MotionObject, recordStorageKind) == 0x54);
82STATIC_ASSERT(offsetof(struct MotionObject, update) == 0x6c);
83STATIC_ASSERT(sizeof(struct SpriteEntry) == 0x08);
84STATIC_ASSERT(offsetof(struct SpriteEntry, palette) == 0x05);
85STATIC_ASSERT(offsetof(struct SpriteEntry, priority) == 0x06);
86
87#endif
A battle's objects and sprites, each unit's command and action record, and the spoils.
The edition's language, for C to compare (LANGUAGE == LANGUAGE_GERMAN).
Public interfaces to the engine's code banks.
STATIC_ASSERT, a compile-time check that emits nothing.
#define STATIC_ASSERT(condition)
C89 permits repeated extern declarations of the same array.
#define offsetof(type, member)
Definition stddef.h:19
An effect object that moves and draws one sprite: its position, scale, velocity and target,...
Definition motobj.h:20
u8 unk00[0x06]
ScriptMotionObject's script and scriptCursor.
Definition motobj.h:21
s32 verticalMotionPhase
With motionFlags bit 1, the 16.16 share of velocityY kept on a bounce; with bit 2,...
Definition motobj.h:44
s32 velocityZ
16.16 fixed-point pixels per frame
Definition motobj.h:33
s32 scaleX
16.16 fixed point, 0x10000 full size
Definition motobj.h:27
u8 unk4c[0x04]
FieldActor's riseBaseY.
Definition motobj.h:49
s32 speedLimit
16.16 fixed-point pixels per frame
Definition motobj.h:34
s32 velocityX
16.16 fixed-point pixels per frame
Definition motobj.h:31
s32 z
16.16 fixed-point pixels
Definition motobj.h:25
u8 snapToTarget
nonzero: lands exactly on the target, else brakes in
Definition motobj.h:57
u8 unk14[0x04]
FieldActor's terrainHeight, the ground's y.
Definition motobj.h:26
u8 unk56[0x02]
ScriptMotionObject's arrivalAxis and unk57.
Definition motobj.h:56
u8 unk22[0x02]
FieldActor's terrainId and priorityFlags.
Definition motobj.h:30
void(*) update(union FieldObject *object)
run first each frame
Definition motobj.h:63
s32 targetY
16.16 fixed-point pixels
Definition motobj.h:39
s32 y
16.16 fixed-point pixels
Definition motobj.h:24
u16 height
half the sprite's box height; FieldActor's radius
Definition motobj.h:29
u8 unk59
FieldActor's collisionFlags; battle units set 3.
Definition motobj.h:58
s32 velocityY
16.16 fixed-point pixels per frame
Definition motobj.h:32
u8 unk5b[0x11]
FieldActor's paused, timer, linkedObject and the bytes between; not named by TBS code through this vi...
Definition motobj.h:62
u16 angle
1/65536 turns
Definition motobj.h:22
void * records
one sprite, or a table of up to four (recordStorageKind)
Definition motobj.h:50
s32 targetZ
16.16 fixed-point pixels
Definition motobj.h:40
u8 motionFlags
bits: 4 no terrain slowdown | 3 bigger float | 2 floats | 1 falls | 0 follows terrain
Definition motobj.h:55
u8 recordStorageKind
bits: 3..0 RECORDS_NONE, RECORDS_SINGLE or RECORDS_TABLE
Definition motobj.h:52
s32 acceleration
Horizontal speed gained each frame towards the target, or lost braking without one,...
Definition motobj.h:37
s32 scaleY
16.16 fixed point, 0x10000 full size
Definition motobj.h:28
s32 x
16.16 fixed-point pixels
Definition motobj.h:23
s32 targetX
16.16 fixed-point pixels; 0x80000000 for no target
Definition motobj.h:38
s32 verticalMotionStrength
Gravity: taken from velocityY each frame above the ground with motionFlags bit 1, in 16....
Definition motobj.h:48
u8 autoFaceMotion
bit 0 turns the object to face where it moves
Definition motobj.h:59
A sprite of an animation record, as battle objects set its palette and drawing priority.
Definition motobj.h:68
u8 unk00[5]
Definition motobj.h:69
u8 priority
Definition motobj.h:71
u8 palette
Definition motobj.h:70
The integer types, TRUE, UNUSED and the fixed-address macros.
signed int s32
Definition types.h:14
unsigned short u16
Definition types.h:13
unsigned char u8
Definition types.h:11
An object on the field, read as an actor or as an effect.