1#ifndef ALCHEMY_FIELD_EVENT_H
2#define ALCHEMY_FIELD_EVENT_H
27#define STORE_CONST(place) (*(__typeof__(((void)0, (place))) *)&(place))
29#define STORE_CONST(place) (place)
49#define EMOTE_IN_FRONT 0x100
54#define SPEAKER_PORTRAIT_LEFT 0x1000
55#define SPEAKER_PORTRAIT_RIGHT 0x2000
56#define SPEAKER_WINDOW_ABOVE 0x4000
57#define SPEAKER_WINDOW_BELOW 0x8000
59#define MAP_CELL_STEP(srcX, srcY, width, height, frames) \
60 (srcX), (srcY), (width), (height), (frames)
61#define MAP_CELL_STEPS_END 0xffff
143 s32 fixed_y,
s32 fixed_z);
192 s32 extra,
s32 other_speaker,
194 s32 other_extra,
s32 flags);
203#ifdef FIELD_STAGED_ACTOR_IMPORTS
204void Audio_PlayCue(
s32 cue);
210 *message = *message + count;
241#ifndef FIELD_STAGED_ACTOR_IMPORTS
297#define GameFlag_Set FieldEvent_GameFlagSet
298#define GameFlag_IsSet FieldEvent_GameFlagIsSet
299#define GameFlag_Clear FieldEvent_GameFlagClear
312#ifndef FIELD_STAGED_ACTOR_IMPORTS
319 return dividend / divisor;
323 s32 fixed_y,
s32 fixed_z) {
359#define ACTION_TABLE_STOP ((const u8 *)1)
389 s32 otherSpeaker,
s32 otherX,
391 s32 otherExtra,
s32 flags) {
393 otherX, otherY, otherArg, otherExtra,
void Object_SetActionCallbackAndRefreshById(u32 objectId, s32 action)
Starts a built-in action or supplied script, then waits up to 300 frames for its script to end.
struct FieldActor * Object_GetById(s32 actor)
Returns an actor, or NULL if it does not exist.
void Engine_ObjectSetPosition(struct FieldActor *object, s32 fixed_x, s32 fixed_y, s32 fixed_z)
static void FieldEvent_GameFlagSet(s32 flag)
u32 Math_RemainderUnsigned(u32 dividend, u32 divisor)
static s32 Event_OpenMessage(s32 speaker, s32 flags)
void Engine_ActorFaceActor(s32 actor, s32 target, s32 frames)
s32 Engine_LeaderCheckAhead(void)
static void Actor_SetDestination(s32 actor, s32 x, s32 z)
static void Actor_FaceDirection(s32 actor, s32 facing, s32 frames)
void Engine_MapCopyCellAttributes(s32 srcX, s32 srcY, s32 width, s32 height, s32 destX, s32 destY)
void Engine_ActorSetAnimationAndWait(s32 actor, s32 animation)
void Engine_WorkSetValuesIfNonNegative(s32 first, s32 second, s32 third)
void Engine_SanctumOpen(s32 priest)
void Object_SetMode(struct FieldActor *object, s32 animation)
static void Map_AnimateCells(const u16 *steps, s32 destX, s32 destY)
void Engine_ActorWalkByAndWait(s32 actor, s32 dx, s32 dz)
void Engine_ActorsRefresh(void)
void Engine_ActorSetSpritePriority(s32 actor, s32 priority)
void Engine_PsynergyBegin(s32 ability, s32 flags)
u8 * Engine_ResourceGetTableEntry(s32 resource)
struct FieldActor * Engine_ActorLookup(s32 actor)
static void Event_ShowMessageAndWait(s32 speaker, s32 flags, s32 frames)
void Engine_ActorEnableActionCallback(s32 actor, s32 action)
void Engine_ActorWalkBy(s32 actor, s32 dx, s32 dz)
static void Actor_SetBuiltinAction(s32 actor, s32 action)
void Engine_PartyAddMembers(s32 first, s32 second)
s32 Engine_EventChooseYesNo(s32 actor, s32 flags)
void Engine_MessageShowCentered(s32 message, s32 flags)
void Engine_ObjectSetPartPalettes(struct FieldActor *object, s32 palette)
s32 Engine_PartyGiveItem(s32 item, s32 flags)
void Engine_EventShowMessageAndWait(s32 speaker, s32 flags, s32 frames)
void Engine_CameraSetSpeed(s32 speed, s32 acceleration)
static void Actor_WalkToAndWait(s32 actor, s32 x, s32 z)
static void Camera_SetSpeed(s32 speed, s32 acceleration)
void Engine_CameraMoveTo(s32 fixed_x, s32 fixed_y, s32 fixed_z, s32 pan)
void Engine_PsynergyRaiseHands(void)
s32 Engine_TaskRemoveCallback(void(*callback)(void))
void Engine_PsynergyLowerHands(void)
void Engine_CameraMoveToActor(s32 actor, s32 pan)
void Engine_ActorMoveToAndWait(s32 actor, s32 x, s32 z)
void Engine_ActorJump(s32 actor, s32 height, s32 frames)
void Engine_ItemLoadIcon(s32 item)
@ OBJECT_BLEND_TRANSLUCENT
static void Actor_MoveToAndWait(s32 actor, s32 x, s32 z)
s32 Engine_MathSin(s32 angle)
void Engine_ItemShowFound(s32 item, s32 height)
static void Actor_SetDestinationOffset(s32 actor, s32 dx, s32 dz)
void Engine_ActorSetSpeed(s32 actor, s32 speed, s32 acceleration)
void Engine_ActorFaceDirection(s32 actor, s32 facing, s32 frames)
void Engine_InnOpen(s32 inn, s32 keeper)
void Engine_EventCloseScreen(void)
void Engine_ObjectDispatchRelease(struct FieldActor *object)
void Engine_ActorSetDestination(s32 actor, s32 x, s32 z)
static void Actor_RunActionScriptAndWait(s32 actor, const s32 *script)
Runs a script, waiting at most 300 frames for its final command.
static void Map_CopyCellsTo(s32 srcX, s32 srcY, s32 destX, s32 destY, s32 width, s32 height)
void Engine_ActorWalkToAndWait(s32 actor, s32 x, s32 z)
static void Event_SkipMessages(s32 count)
static void Actor_FaceActor(s32 actor, s32 target, s32 frames)
void Engine_HeapRelease(s32 slot)
static void ColorBuffer_ApplyTarget(s32 value, s32 mode)
s32 Engine_VramLoad(s32 block, s32 size, const void *data)
static void Actor_WalkTo(s32 actor, s32 x, s32 z)
void Engine_PsynergyCancel(void)
void Engine_EventWaitForScreen(void)
void Engine_ActorDestroy(s32 actor)
static void Actor_ShowEmote(s32 actor, s32 emote, s32 frames)
static void Actor_WalkByAndWait(s32 actor, s32 dx, s32 dz)
void Engine_MapCopyCells(s32 srcX, s32 srcY, s32 width, s32 height, s32 destX, s32 destY)
s32 Engine_EventAskYesNo(s32 speaker, s32 flags)
void Engine_MapCopyCellsLayered(s32 srcX, s32 srcY, s32 destX, s32 destY, s32 width, s32 height)
void Engine_ObjectSetScript(struct FieldActor *object, const s32 *script)
static s32 Math_Divide(s32 dividend, s32 divisor)
void Engine_ObjectSetBlendMode(struct FieldActor *object, s32 mode)
static s32 FieldEvent_GameFlagIsSet(s32 flag)
static void Event_ShowTwoMessagesAndWait(s32 speaker, s32 x, s32 y, s32 arg, s32 extra, s32 otherSpeaker, s32 otherX, s32 otherY, s32 otherArg, s32 otherExtra, s32 flags)
void Engine_EventOpenScreen(void)
void Engine_BlendSetDarkenTarget16(s32 target)
void Engine_ActorSetActionCallback(struct FieldActor *actor, s32 value)
s32 Engine_EventOpenMessage(s32 speaker, s32 flags)
void Engine_MapWaitWorkValuesBelow256(void)
void Engine_GameFlagSet(s32 flag)
void Engine_MapRenderWaitForValues(void)
void Engine_MapCopyCellsTo(s32 srcX, s32 srcY, s32 destX, s32 destY, s32 width, s32 height)
void Engine_GameFlagClear(s32 flag)
void Engine_CameraWaitForMove(void)
static void Actor_SetActionScript(s32 actor, const s32 *script)
The engine encodes either a built-in action or an action-script address.
void Engine_ActorWaitForMove(s32 actor)
void Engine_CameraFollowActor(s32 actor, s32 keep_position)
void * Engine_HeapAllocate(s32 slot, s32 size)
static void Map_CopyCellAttributes(s32 srcX, s32 srcY, s32 width, s32 height, s32 destX, s32 destY)
void Engine_ActorStop(s32 actor)
void Engine_ActorRunRepeatedMotion(s32 actor, s32 repeats)
void Engine_EventShowTwoMessagesAndWait(s32 speaker, s32 x, s32 y, s32 arg, s32 extra, s32 other_speaker, s32 otherX, s32 other_y, s32 other_arg, s32 other_extra, s32 flags)
void Engine_ActorWalkTo(s32 actor, s32 x, s32 z)
static void Event_ShowMessage(s32 speaker, s32 flags)
void Engine_ActorSetAttachedEffect(s32 actor, s32 effect)
static void Event_PlayCue(s32 cue)
static void Map_CopyCells(s32 srcX, s32 srcY, s32 width, s32 height, s32 destX, s32 destY)
void Engine_ActorSetChildValue(s32 actor, s32 value)
static void Map_SetShake(s32 horizontal, s32 vertical, s32 decay)
Sets shake amplitudes in fixed-point pixels and the per-frame decay factor.
void Engine_MapObjectSetPosition(s32 object, s32 fixed_x, s32 fixed_z)
static void Actor_SetChildValue(s32 actor, s32 value)
s32 Engine_GameFlagIsSet(s32 flag)
void Engine_MapAnimateCells(const u16 *steps, s32 destX, s32 destY)
void Engine_PsynergyPlayEffect(s32 effect)
void Engine_ActorStartRepeatedMotion(s32 actor, s32 repeats)
void Engine_RunRisingObjectSequence(struct FieldActor *object, s32 mode)
static struct FieldActor * Object_Create(s32 type, s32 fixed_x, s32 fixed_y, s32 fixed_z)
struct FieldActor * Engine_EventGetViewCenter(void)
s32 Engine_MathCos(s32 angle)
static s32 Event_AskYesNo(s32 speaker, s32 flags)
static void Actor_WalkBy(s32 actor, s32 dx, s32 dz)
static void Actor_CenterAndWalk(s32 actor, s32 priority, s32 dz)
static void MapObject_SetPosition(s32 object, s32 fixed_x, s32 fixed_z)
static void Actor_SetSpeed(s32 actor, s32 speed, s32 acceleration)
void Engine_ObjectMotionSetPositionAndCommit(s32 actor, s32 x, s32 z)
void Engine_MapRedraw(void)
void Engine_ShopOpen(s32 shop, s32 keeper)
static s32 Random_Next(void)
void Engine_ColorBufferInterpolate(s32 frames)
static void Camera_MoveTo(s32 fixed_x, s32 fixed_y, s32 fixed_z, s32 pan)
static void Actor_SetPosition(s32 actor, s32 fixed_x, s32 fixed_z)
static void Map_CopyCellsLayered(s32 srcX, s32 srcY, s32 destX, s32 destY, s32 width, s32 height)
void Engine_ActorSetDestinationOffset(s32 actor, s32 dx, s32 dz)
void Engine_ActorFaceEachOther(s32 actor, s32 other, s32 frames)
void Engine_EventWait(s32 frames)
void Engine_ActorCenterAndWalk(s32 actor, s32 priority, s32 dz)
static void FieldEvent_GameFlagClear(s32 flag)
static void Actor_SetAttachedEffect(s32 actor, s32 effect)
void Engine_PsynergySetTarget(s32 caster, s32 target)
void Engine_ColorBufferApplyTarget(s32 value, s32 mode)
void Engine_ColorBufferApplySource(s32 value, s32 mode)
static void Object_SetScript(struct FieldActor *object, const s32 *script)
static struct FieldActor * Actor_Get(s32 actor)
static void ColorBuffer_ApplySource(s32 value, s32 mode)
Field objects and actors, and the scene transition styles.
The frame loop's globals: lag counts, the CPU load display and the VBlank flags.
GameState, the game's state: play time, coins, the scene and the leader's position,...
Declares nothing of its own: it only includes edition.h and types.h.
void Engine_ActorSetAnimation()
struct EventWork * gEventWork
void Engine_EventRequestExit()
void Engine_ActorSetPosition(u32 actor, s32 x, s32 z)
void Engine_EventEnd(void)
void Engine_AudioPlayCue()
void Engine_EventBegin(void)
void Engine_ActorShowEmote()
void Engine_EventSetMessage()
void Engine_EventShowMessage()
STATIC_ASSERT, a compile-time check that emits nothing.
u16 message
the next message, advanced as each window opens
A field actor: a person or thing on the field with a position, motion toward a target,...
s32 speed
speed limit, 16.16 fixed-point pixels per frame
union FieldCoordinate x
16.16 fixed-point pixels
union FieldCoordinate y
16.16 fixed-point pixels
union FieldCoordinate z
16.16 fixed-point pixels
s32 acceleration
Added toward the target each frame, or taken off the speed when there is none, in 16....
Cell replacement: procedure and destination cells.
u16 y
destination cell row
const u16 * steps
MAP_CELL_STEP records, ended by MAP_CELL_STEPS_END, for Map_PlayMetatileCopySequence.
u16 x
destination cell column