Alchemy
Loading...
Searching...
No Matches

mercury_lighthouse_lights.h

Go to the documentation of this file.
1#include "battle.h"
2#include "debug.h"
3#include "field.h"
4#include "game.h"
5#include "graphics.h"
6#include "menu.h"
7#include "minigame.h"
8#include "sound.h"
9#include "system.h"
10#include "mem.h"
11#include "dma.h"
12#include "ram_buffer.h"
13#include "field_event.h"
14#include "field_scene.h"
15#include "object_runtime.h"
16#include "animspr.h"
17#include "map.h"
18#include "io_reg.h"
19#include "flags.h"
20
21// Mercury Lighthouse and its entrance: the lights that carry the leader over
22// the pool (mercury_lighthouse_pillar.h).
23
24/// Keeps the lights' state st in work slot 35 for the floor's region, the
25/// pool's collision code. On an ordinary entrance the leader has no lights.
26/// When the party returns to where it was, the column of lights over the leader
27/// and the light under them in the pool are made again.
29 struct MercuryLighthouseLights *st) {
30 struct FieldActor *actor;
31 struct FieldActor *obj;
32 struct AnimationObject *anim;
33 struct MapCell *cell;
34 s32 z;
35 s32 flag;
36
37 *(struct MercuryLighthouseLights **)Runtime_AllocateBlock(35, sizeof(st)) =
38 st;
40 if (flag == 0) {
41 Dma_Fill32(flag, st, sizeof(*st));
42 st->terrainCode = region;
43 return;
44 }
46 z = actor->z.fixed;
47 cell = (struct MapCell *)Ram_MapCellBuffer + ((z / 0x100000) << 7) +
48 actor->x.fixed / 0x100000;
49 if (st->levels != 0 && st->pillar != 0) {
50 obj = Engine_ObjectCreate(26, actor->x.fixed, actor->y.fixed + 0x180000, z);
51 if (obj != 0) {
52 obj->terrainHeight = actor->terrainHeight;
53 anim = obj->sprite;
55 obj->linkedObject = actor;
56 obj->motionFlags = 4;
57 obj->y.fixed += -0x8000;
58 if (anim != 0) {
60 anim->flags = 0;
61 anim->image.priority = 1;
62 }
63 st->pillar = obj;
64 }
65 } else {
66 st->pillar = 0;
67 }
68 if (cell->collisionCode == region && st->stepEffect != 0) {
69 obj =
70 Engine_ObjectCreate(26, actor->x.fixed, actor->y.fixed, actor->z.fixed);
71 if (obj == 0)
72 return;
73 obj->terrainHeight = actor->terrainHeight;
74 anim = obj->sprite;
76 obj->motionFlags = 0;
77 obj->timer = 0;
78 obj->priorityFlags = 2;
79 obj->speed = 0x40000;
80 if (anim != 0) {
82 anim->flags = 0;
83 }
84 st->stepEffect = obj;
85 } else {
86 st->stepEffect = 0;
87 }
88}
s32 AnimationObjects_SelectAnimation(struct AnimationObject *sprite, s32 animation)
Starts animation flags & 0x7f on every layer of a sprite (bit 7 keeps each layer's place and timer),...
Definition animation.c:317
Animated sprites: their layers, frames and colour modes, and the resource slots they draw from.
struct FieldActor * Engine_ObjectCreate(s32, s32, s32, s32)
The engine calls the debug menus import, and their palette swatch tiles.
DMA channel registers, and the DMA and CPU fills.
#define Dma_Fill32(value, destination, size)
Fills size bytes at destination with the word value by DMA3.
Definition dma.h:30
The scene script layer: the engine services a scene's events call, declared once (Engine_EventBegin,...
struct FieldActor * Engine_ActorLookup(s32 actor)
void Engine_ObjectSetScript(struct FieldActor *object, const s32 *script)
s32 Engine_GameFlagIsSet(s32 flag)
The scene table formats: entrances, exits, placements and events, and the macros that write them.
Game flags, named where their meaning is shown.
#define FLAG_KEEP_PARTY_POSITION
Definition flags.h:93
struct GameState gGameState
The screen blend's globals and the graphics routines.
void * Runtime_AllocateBlock(s32 kind, s32 size)
As Runtime_AllocateHeapBlock, but tries EWRAM first, for blocks that need room more than speed: the b...
Definition heap.c:80
The hardware's I/O registers and their bits, as pret names them.
Maps: their cells, layers, animations and blend scripts, and the map state.
The heaps: allocating and freeing blocks.
s32 gMercuryLighthouse_PillarScript[]
s32 gMercuryLighthouse_RampScript[]
The reel game's title lettering.
ObjectRuntime, a field object's runtime state, and the object snapshots.
The work pointers in the gWorkSlot table, by name.
#define Ram_MapCellBuffer
Definition ram_buffer.h:10
void MercuryLighthouse_RestoreLights(s32 region, struct MercuryLighthouseLights *st)
Keeps the lights' state st in work slot 35 for the floor's region, the pool's collision code.
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
Definition animspr.h:108
struct AnimationSpritePart image
Definition animspr.h:109
u8 flags
bits: 1 outlined in ObjectSystemWork's edge and fill colours | 0 shadow drawn (set when created)
Definition animspr.h:128
u16 priority
2 when created
Definition animspr.h:100
A field actor: a person or thing on the field with a position, motion toward a target,...
Definition field_obj.h:30
s16 timer
The parameter its action script reads (a follow distance or an angle to face), the player's frames to...
Definition field_obj.h:109
s32 speed
speed limit, 16.16 fixed-point pixels per frame
Definition field_obj.h:55
struct FieldActor * linkedObject
The object its action script follows or faces.
Definition field_obj.h:114
u8 motionFlags
ActorMotionFlag bits; zero is free flight in 3D, and 3 is set on creation.
Definition field_obj.h:83
union FieldCoordinate x
16.16 fixed-point pixels
Definition field_obj.h:35
union FieldCoordinate y
16.16 fixed-point pixels
Definition field_obj.h:36
u8 priorityFlags
ActorPriorityFlag bits, read by the scrolling camera.
Definition field_obj.h:51
s32 terrainHeight
16.16 fixed-point pixels
Definition field_obj.h:38
union FieldCoordinate z
16.16 fixed-point pixels
Definition field_obj.h:37
s32 selectedActor
the leader: its unit and its actor
Definition game_state.h:59
One cell of a map layer: its metatile and flags, its collision code and an attribute indexing the col...
Definition map.h:13
u8 collisionCode
The step code: 1 to 239 scene events, 240 and 241 encounter ground, 250 hazard, 252 to 254 for Field_...
Definition map.h:18
Published in the scene's light-controller slot while the pillar is active.
s32 terrainCode
the pool's collision code, the floor's region
s32 levels
The leader's lights, 0 to 3: the heart gives three and each hop into the pool spends one.
struct FieldActor * pillar
the column of light over the leader, or null
struct FieldActor * stepEffect
The light holding the leader up where they landed in the pool, or null.
The system's routines and globals: interrupts, BIOS sound bias, random numbers and sleep.
signed int s32
Definition types.h:14
s32 fixed
16.16 fixed-point pixels