Alchemy
Loading...
Searching...
No Matches

engine_call.h

Go to the documentation of this file.
1#ifndef ALCHEMY_ENGINE_CALL_H
2#define ALCHEMY_ENGINE_CALL_H
3
4/// @file
5/// The engine call layer: one typed inline for each of the thirteen main-image
6/// routines below that the scene, menu and debug overlays import; every overlay
7/// call of them goes through it.
8///
9/// It is a habit of the whole game written once: a layer, not a
10/// compiler-steering device (AGENTS.md S2). An overlay writes
11/// `FieldScheduler_AddCallback(callback, TASK_PRIORITY_SCENE)` and the inline
12/// calls Scheduler_AddOrUpdateCallback, which resolves to the overlay's import
13/// stub. Main-image code calls the routines as ordinary functions; only the
14/// shared scene/common/scroll_initialize_hblank_dma.h, which
15/// object/psynergy_effects.c includes as lemurian_ship.c does, reaches the
16/// layer there. field_service.h includes this layer; rooms without the scene
17/// command layer use it directly.
18
19// Passing arguments through inline parameters rematerializes constants at each
20// call.
21
22#include "types.h"
25#include "unit/window/window.h"
26#include "unit/game/game.h"
27#include "unit/import.h"
28
29struct FieldActor;
30struct FieldPosition;
31struct MenuSprite;
32
33/// Registers a main-image scheduler callback. The scene layer's
34/// Task_AddCallback and FieldScheduler_AddOrUpdateCallback also use this
35/// wrapper, so overlays import this routine under one name.
37 s32 priority) {
38 return Scheduler_AddOrUpdateCallback(callback, priority);
39}
40
41static inline void FieldUiTextResource_Initialize(struct MenuSprite *cursor,
42 s32 *slot) {
43 UiTextResource_Initialize(cursor, slot);
44}
45
46static inline void FieldUiTextResource_SetPosition(struct MenuSprite *cursor,
47 s32 x, s32 y) {
48 UiTextResource_SetPosition(cursor, x, y);
49}
50
51static inline void FieldUi_AdjustValueWithoutLimit(s32 message, u16 *buffer) {
52 Ui_AdjustValueWithoutLimit(message, buffer);
53}
54
55static inline void FieldMap_SetViewBounds(s32 minX, s32 minY, s32 maxX,
56 s32 maxY) {
57 Map_SetViewBounds(minX, minY, maxX, maxY);
58}
59
60static inline void FieldBattleFx_RunRisingObjectSequence(s32 actor, s32 mode,
61 s32 action) {
62 Actor_JumpDownLedge(actor, mode, action);
63}
64
65static inline s32
67 struct FieldPosition *position) {
68 return Object_CheckMovementCollision((struct ObjectRuntime *)actor, position);
69}
70
71static inline s32 FieldGameFlag_GetByte(s32 flag) {
72 return GameFlag_GetByte(flag);
73}
74
75static inline void FieldGameFlag_SetByte(s32 flag, s32 value) {
76 GameFlag_SetByte(flag, value);
77}
78
79static inline s32 FieldParty_ListActiveOwners(s16 *owners) {
80 return Party_ListActiveOwners(owners);
81}
82
83static inline s32 FieldUnit_AddHp(s32 owner, s32 delta) {
84 return Unit_AddHp(owner, delta);
85}
86
87/// Decodes type-01 compressed data. Scenes and the title and clear menus use
88/// this wrapper. The same decode in main-image field/lucky_dice.c uses call.h's
89/// tagged Value2 instead.
90static inline s32 FieldResource_DecodeType01(const void *source,
91 void *destination) {
92 return Resource_DecodeType01(source, destination);
93}
94
95static inline void DisplayScroll_StartHBlankDma(s32 mode, s32 freqX, s32 stepX,
96 s32 ampX, s32 freqY, s32 stepY,
97 s32 ampY) {
98 Engine_DisplayScrollStartHBlankDma(mode, freqX, stepX, ampX, freqY, stepY,
99 ampY);
100}
101
102#endif
void Actor_JumpDownLedge(s32 actor, s32 pose, s32 param)
Makes an actor jump down off a ledge in front of it (the field runs it for the leader when the player...
void(*) SchedulerCallback(void)
static s32 FieldScheduler_AddCallback(SchedulerCallback callback, s32 priority)
Registers a main-image scheduler callback.
Definition engine_call.h:36
static s32 FieldParty_ListActiveOwners(s16 *owners)
Definition engine_call.h:79
static s32 FieldResource_DecodeType01(const void *source, void *destination)
Decodes type-01 compressed data.
Definition engine_call.h:90
static void FieldUiTextResource_Initialize(struct MenuSprite *cursor, s32 *slot)
Definition engine_call.h:41
static s32 FieldObject_CheckMovementCollision(struct FieldActor *actor, struct FieldPosition *position)
Definition engine_call.h:66
static s32 FieldGameFlag_GetByte(s32 flag)
Definition engine_call.h:71
static void FieldBattleFx_RunRisingObjectSequence(s32 actor, s32 mode, s32 action)
Definition engine_call.h:60
static void FieldMap_SetViewBounds(s32 minX, s32 minY, s32 maxX, s32 maxY)
Definition engine_call.h:55
static s32 FieldUnit_AddHp(s32 owner, s32 delta)
Definition engine_call.h:83
static void DisplayScroll_StartHBlankDma(s32 mode, s32 freqX, s32 stepX, s32 ampX, s32 freqY, s32 stepY, s32 ampY)
Definition engine_call.h:95
static void FieldUi_AdjustValueWithoutLimit(s32 message, u16 *buffer)
Definition engine_call.h:51
static void FieldUiTextResource_SetPosition(struct MenuSprite *cursor, s32 x, s32 y)
Definition engine_call.h:46
static void FieldGameFlag_SetByte(s32 flag, s32 value)
Definition engine_call.h:75
void GameFlag_SetByte(s32 flag, s32 value)
Sets the whole byte flag is in.
Definition flags.c:78
s32 GameFlag_GetByte(s32 flag)
Returns the whole byte flag is in, a counter kept among the flags.
Definition flags.c:68
The main-image routines scene overlays import.
void Engine_DisplayScrollStartHBlankDma(s32 mode, s32 freqX, s32 stepX, s32 ampX, s32 freqY, s32 stepY, s32 ampY)
s32 Object_CheckMovementCollision(struct ObjectRuntime *object, struct FieldPosition *position)
void Map_SetViewBounds(s32 minX, s32 minY, s32 maxX, s32 maxY)
The event command "set view bounds": the camera keeps the screen inside these map coordinates (Camera...
Definition view.c:13
s32 Party_ListActiveOwners(s16 *owners)
Writes the party members to owners, ending with 0xff, and returns how many there are.
Definition party.c:173
s32 Resource_DecodeType01(const void *source, void *destination)
Decodes a type-01 resource and returns its unpacked byte count.
Definition decompress.c:31
s32 Scheduler_AddOrUpdateCallback(SchedulerCallback callback, s32 order)
Schedules callback with order, or gives a task already running it the new order, and re-sorts the tab...
Definition scheduler.c:102
void UiTextResource_Initialize(struct MenuSprite *sprite, s32 *slot)
Sets up a sprite as the right-pointing arrow, in a free tile slot (returned in *slot).
Definition selection.c:1237
void UiTextResource_SetPosition(struct MenuSprite *sprite, s32 x, s32 y)
Places an arrow sprite at (x, y) and queues it for drawing.
Definition selection.c:1254
A field actor: a person or thing on the field with a position, motion toward a target,...
Definition field_obj.h:30
A position on the field.
A menu sprite: a list link and its OAM attributes, as two words or as fields.
Definition menu_list.h:24
One of the 64 field objects in the object pool (heap slot 5): its script, position,...
The integer types, TRUE, UNUSED and the fixed-address macros.
signed int s32
Definition types.h:14
signed short s16
Definition types.h:12
unsigned short u16
Definition types.h:13
s32 Unit_AddHp(s32 owner, s32 delta)
Adds delta to the HP of unit owner, clamped to 0..maxHp, recomputes its gauges and returns the new HP...
Definition units.c:770
void Ui_AdjustValueWithoutLimit(s32 message, u16 *text)
Decodes message into text (a u16 string) with no length limit.
Definition messages.c:8