49 if ((sprite <= 8) && (childhood != 0)) {
60#define MAP_CELLS ((struct MapCell *)Ram_MapCellBuffer)
89 for (tableIndex = 0; tableIndex < 4; tableIndex++) {
90 if (work->
tables[tableIndex] == entry)
92 if (work->
tables[tableIndex] == 0) {
93 work->
tables[tableIndex] = entry;
97 for (placementSprite = entry->
sprite;
98 (
s16)placementSprite != -1 && slot <= 65;
99 entry++, placementSprite = entry->
sprite) {
103 actorIndex = entry->
sprite;
104 else if (entry->
sprite <= 0x2705)
125 spriteSlot = sprite->
slot;
126 sprite =
object->animation;
129 sprite->
slot = spriteSlot;
134 (
u32)(spriteId - 0x12) <= 1)
146 object->angle = entry->
facing;
147 object->collisionFlags = 1;
155 if (object->
y != 0) {
162 object->flags &= 0xfe;
174 object->terrainHeight =
176 object->y +=
object->terrainHeight;
178 object->priorityFlags = 1;
190 if (
object !=
NULL) {
197 memcpy((
u8 *)work + 0x14 + (
u32)actorIndex *
sizeof(empty), &empty,
235 for (pos = 0; pos < 4; pos++)
247 pos = (
object->x / 0x100000) + (object->
z / 0x100000) * 128;
256 object->terrainHeight =
object->y;
295 lastActorIndex = actorIndex;
298 }
while (actorIndex <= 65);
300 if (lastActorIndex == 66) {
303 return lastActorIndex;
308 return (
u8 *)
gEventWork + 0x14 + actorIndex *
sizeof(
void *);
314#define FLAG_IN_VIEW 0x164
315#define FLAG_OUT_OF_VIEW 0x165
330 while (entry->
sprite != -1) {
335 s16 condition = rawCondition;
337 if (condition == 0) {
341 if (view->
minX <= x && x <= view->
maxX && view->
minY <= z &&
367 s32 releaseCacheMask;
370 camera =
work->camera;
372 left = centerX - 0xa00000;
373 right = centerX + 0xa00000;
375 top = centerZ - 0xc80000;
376 bottom = centerZ + 0x640000;
378 releaseCacheMask = ~1;
380 for (remainingSlots =
PLACED_MAX - 1; remainingSlots >= 0; remainingSlots--) {
387 if (actorX != 0 || actorZ != 0) {
388 if (actorX < left || actorX > right || actorZ < top ||
397 sprite = (
u8 *)actor->sprite;
399 sprite[29] = flags & releaseCacheMask;
422 for (slotIndex = 0; slotIndex <
PLACED_MAX; slotIndex++) {
427 actor->sprite->retainCacheEntry = 0;
432 placements =
work->tables[1];
452 work->
actors[actorIndex] = emptyActor;
454 }
while (actorIndex >= 0);
468 if (actorIndex > 0xbf)
470 slotOffset = (actorIndex * 4) + 0x14;
474 memcpy(&
object, workBytes + slotOffset,
sizeof(
object));
477 return *(
void **)(workBytes + slotOffset);
507 for (actorIndex = 0; actorIndex < actorLimit; actorIndex++) {
511 *indices++ = actorIndex;
517 animation = sprite->
lastNo;
518 spriteFlagBits = sprite->
flags;
525 *animations++ = animation;
526 *spriteFlags++ = spriteFlagBits;
527 *priorities++ = priority;
565 actorIndex = *indices++;
568 if (
object !=
NULL) {
569 sprite =
object->animation;
574 animation = *animations;
579 priority = *priorities;
582 object->animation = sprite;
584 if (actorIndex == *leaderId) {
586 cameraPosition = (*mapWork)->origin;
590 cameraPosition[1] = y;
601 actorIndex = *indices++;
607#undef FLAG_OUT_OF_VIEW
void ObjectMotion_SetActionCallback(struct ObjectRuntime *object, s32 action)
Starts an actor's action script: 1 to 4 the fixed action scripts, 5 follow the linked object,...
void * ObjectTable_Get(u32 actorIndex)
Returns the actor in slot index (0 to 65), or NULL.
#define FLAG_OUT_OF_VIEW
kept set, so a placement using it does not
@ ACTOR_DJINNI_FLAG_COUNT
20 flags per element
#define PLACED_MAX
actor slots 8 to 65
s32 ObjectTable_FindLastActiveId(void)
Returns the slot after the last placed actor (8 when there is none), or -1 when slot 65 is occupied.
const struct ScenePlacement gField_DefaultPlacements[2]
void ObjectTable_ResetForObject(struct ScenePlacement *table)
Creates a scene's actors on entering it: the party leader where the game state puts it,...
void Scene_AssignViewFlags(struct ScenePlacement *entry)
Gives each placement with condition 0 a condition saying whether it lies within the map's view bounds...
void ObjectTable_Snapshot(void)
Saves up to 32 actors (only the party's 8 on the world map) into gObjectSnapshots,...
void ObjectTable_ClearAll(void)
Empties all 66 actor slots, without destroying the actors.
void ObjectTable_DestroyAtIndex(s32 actorIndex)
Destroys the actor in slot actorIndex, if there is one, and empties the slot.
void ObjectTable_Restore(void)
Puts back the actors ObjectTable_Snapshot saved, and moves the camera to the party leader's height.
UNUSED void * ObjectTable_GetSlotAddress(u32 actorIndex)
Returns the address of actor slot index in the event work.
#define FLAG_IN_VIEW
kept clear, so a placement using it appears
void Event_SpawnObjectTable(struct ScenePlacement *entry, s32 slot)
Creates the actors of a scene's placement table (ended by sprite -1), and records the table among the...
s32 Party_RemapCharacterIdByFlags(s32 character)
Returns the sprite of character, which is the character itself except that FLAG_CHILDHOOD gives chara...
void BattleEffect_ClearOutOfBoundsObjects(void)
Destroys the placed actors far from the view's centre: more than 160 pixels to either side,...
void BattleEffect_ClearAllObjects(void)
Destroys every placed actor and places the scene's actors again from its first placement table after ...
s32 Party_RemapCharacterIdIfEnabled(s32 character, s32 childhood)
Returns the sprite of character as Party_RemapCharacterIdByFlags would with FLAG_CHILDHOOD set to chi...
static __inline__ void Dma_Set(const volatile void *source, volatile void *destination, u32 control, volatile u32 *channel)
Starts a DMA transfer: stores the source, destination and control words into channel's registers with...
void ObjectDispatch_StartCameraFar(struct DispatchObject *obj, s32 arg)
struct ObjectRuntime * Object_CreateFar(s32 id, s32 x, s32 y, s32 z)
Far call to FieldObject_Create.
void ObjectDispatch_ReleaseFar(struct DispatchObject *obj)
s32 Map_GetTerrainHeightFar(s32 layer, s32 x, s32 y)
void Object_SetPositionAndResetMotionFar(struct ObjectRuntime *obj, s32 x, s32 y, s32 z)
void ObjectDispatch_SetSingleChildFlagsFar(struct DispatchObject *obj, u32 flags)
void ObjectDispatch_SelectAnimationFar(void *raw, s32 no)
s32 ResourceMetadata_RegisterFar(struct AnimationObject *state, s32 id)
void ObjectDispatch_RegisterChildMetadataFar(struct DispatchObject *obj, s32 no)
void ObjectDispatch_StartIdleFar(struct DispatchObject *obj)
s32 GameFlag_TestFar(s32 flag)
s32 GameFlag_SetBitFar(s32 flag)
void GameFlag_ClearBitFar(s32 flag)
#define PLACEMENT_SHARE_PREVIOUS_SPRITE
#define Q16_ONE
One in the engine's signed 16.16 fixed-point format.
#define FLAG_DJINNI_0
the flag of Djinni 0, set once it is caught
#define FLAG_KEEP_PARTY_POSITION
#define FLAG_CHILDHOOD
the prologue: Isaac and Garet are children
#define FLAG_ISAAC_WEARS_TUNIC
The young Isaac wears the tunic Dora made him take on the stormy night: placed child sprites get its ...
struct GameState gGameState
#define Iwram_MulQ16(left, right)
#define SET_POSITION(p, px, py, pz)
Sets the position or the velocity of a particle, a piece of debris or an object in one statement.
u32 Random16(void)
Advances the game's random number generator (the C library's classic linear congruential one),...
s32 GameFlag_IsConditionActive(s32 condition)
Returns whether an event condition holds: -1 always holds; a condition with bit 0x1000 holds while th...
What every part of object.c shares: its includes and the macros and types more than one part uses.
struct ObjectTableSnapshot gObjectSnapshots
@ OBJECT_SNAPSHOT_CAPACITY
struct EventWork * gEventWork
One animation layer of a sprite: its animation id, frames, running script and timer.
u8 param
SpriteColorMode its pixels are drawn with; 0 when taken.
u8 priority
drawing order 0 to 3 among the layers; above 3 not drawn
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
struct AnimationSpritePart shadow
struct AnimationSpritePart image
u8 flags
bits: 1 outlined in ObjectSystemWork's edge and fill colours | 0 shadow drawn (set when created)
u8 lastNo
The animation number last selected, which selecting again skips.
u8 slot
VRAM cache entry holding its tiles.
s32 scale
16.16 fixed point, 0x10000 full size
u8 retainCacheEntry
Keeps the VRAM cache entry when it is released or off screen.
u16 priority
2 when created
A field object as the object dispatcher's far calls take it.
The running scene's event work: its placement and event tables, its actors, the triggers and exit it ...
A field actor: a person or thing on the field with a position, motion toward a target,...
union FieldCoordinate x
16.16 fixed-point pixels
u8 spriteStorageKind
Zero hides sprites; one draws a single sprite, two draws a group.
union FieldCoordinate z
16.16 fixed-point pixels
u16 work
The side of the player's next footprint (2 after a stop), or scene scratch.
Full event work allocated by Field_RunScene (heap slot 27).
struct ScenePlacement * tables[4]
The placement tables placed so far, recorded by Event_SpawnObjectTable.
struct ObjectRuntime * camera
the object the map view follows
s16 mode
MODE_WORLD_MAP (3) on the world map.
struct FieldActor * actors[66]
The actors by id: 0 to 7 the party's characters, 8 on the placed actors.
s32 z
16.16 fixed-point pixels
s32 y
16.16 fixed-point pixels
u16 turn
the leader's terrainId, kept with its position
s32 x
16.16 fixed-point pixels
u8 movementMode
1 while the leader is climbing, 0 otherwise
s32 selectedActor
the leader: its unit and its actor
One cell of a map layer: its metatile and flags, its collision code and an attribute indexing the col...
u8 collisionCode
The step code: 1 to 239 scene events, 240 and 241 encounter ground, 250 hazard, 252 to 254 for Field_...
One of the 64 field objects in the object pool (heap slot 5): its script, position,...
s32 terrainHeight
16.16 fixed-point pixels
s32 z
16.16 fixed-point pixels
void * animation
its sprite, or its list of four, by animationKind
s32 x
16.16 fixed-point pixels
s32 y
16.16 fixed-point pixels
u8 animationKind
Low four bits: 0 no sprite, 1 one sprite, 2 a group of up to four.
u8 animations[OBJECT_SNAPSHOT_CAPACITY]
each sprite's lastNo
struct ObjectRuntime actors[OBJECT_SNAPSHOT_CAPACITY]
copied by DMA
u8 slots[OBJECT_SNAPSHOT_CAPACITY]
actor numbers, or OBJECT_SNAPSHOT_EMPTY
u8 priorities[OBJECT_SNAPSHOT_CAPACITY]
both image and shadow priority
u8 spriteFlags[OBJECT_SNAPSHOT_CAPACITY]
restored through the dispatcher
An actor a scene places: its sprite, the condition for placing it, how it behaves,...
s32 x
16.16 fixed-point pixels
u8 flags
PLACEMENT_SHARE_PREVIOUS_SPRITE.
s16 condition
-1 always, a flag | 0x1000 set, else the flag clear; off the world map, 48 to 127 also need condition...
u16 facing
1/65536 turns (enum Facing)
s32 z
16.16 fixed-point pixels
s32 y
16.16 fixed-point pixels
s16 sprite
The actor's sprite; 0 to 7 are the party's characters, each in its own actor slot,...
s32 behavior
A built-in action (enum ActorBehavior, 1 to 7) or an action script, for ObjectMotion_SetActionCallbac...
A field object as its object script commands see it: the script and its place, position,...
s16 homeX
Its home, in pixels: where it was created or placed.
s32 fixed
16.16 fixed-point pixels
#define MODE_WORLD_MAP
the world map
void * memcpy(void *destination, const void *source, unsigned long size)
s32 Resource_ResetEntry(u32 no)
Frees cache entry no: its blocks go back and the entry is marked free (offset 0xffff).