Alchemy
Loading...
Searching...
No Matches

lemurian_ship.c

Go to the documentation of this file.
1/// @file
2/// The Lemurian ship's hidden harbor at Lalivero, and the end of the game.
3///
4/// The leader steps up with the Black Orb: it glows, spray rises and the
5/// ancient ship comes up out of the water. The party boards, talks over the
6/// journey so far and sails; curtains close and the game goes to the clear
7/// screen.
8
9#include "script.h"
10#include "version.h"
11#include "game_state.h"
12#include "vram_tab.h"
15#include "unit/object/object.h"
17#include "unit/game/game.h"
18#include "unit/shop/shop.h"
19#include "unit/sound/sound.h"
21#include "battle.h"
22#include "debug.h"
23#include "field.h"
24#include "game.h"
25#include "graphics.h"
26#include "menu.h"
27#include "minigame.h"
28#include "sound.h"
29#include "system.h"
30#include "global_cells.h"
31#include "types.h"
32#include "field_event.h"
33#include "dma.h"
34#include "io_reg.h"
35#include "iwram_call.h"
37#include "tbs_edition.h"
38#include "scene_ids.h"
39#include "field_obj.h"
40#include "iowrite.h"
41#include "map_scroll.h"
42#include "field_service.h"
43#include "text/msg_ids.h"
44#include "callback_scheduler.h"
45#include "mem.h"
46#include "scroll.h"
47#include "resource.h"
48#include "vram_block.h"
49#include "ability_ids.h"
50#include "field_scene.h"
51#include "objcmd.h"
52#include "item_ids.h"
53#include "songs.h"
54#include "flags.h"
55
56#if TBS_PATCH_3
57#define LEMURIAN_SHIP_DEPARTURE_DELAY_FRAMES 30
58#else
59#define LEMURIAN_SHIP_DEPARTURE_DELAY_FRAMES 80
60#endif
61
62static void Ripple_Stop(void);
63static void Curtain_Start(void);
64
65enum {
66 SHIP_NORTH = 8, ///< the ship, in two pieces of sprite 0x1f6
68};
69
70/// An entrance the table does not list; arriving by it hands the leader the
71/// Black Orb.
72enum { ENTRANCE_99 = 99 };
73
74/// The sprite of a ship piece or a party actor.
75// ACTOR_SPRITE reads actor->sprite through an s32, so each store reloads it as
76// the native does; read as the field, the two stores share one load.
77#define ACTOR_SPRITE(actor) \
78 ((struct AnimationObject *)*(s32 *)((u8 *)(actor) + 0x50))
79/// Sets one of the sprite's two priority bits of a ship piece or a party
80/// actor: 9 sets the first, any other the second.
81#define SET_PRIORITY(actor, n) \
82 ((n) == 9 ? (void)(ACTOR_SPRITE(actor)->image.priority = 1) \
83 : (void)(ACTOR_SPRITE(actor)->shadow.priority = 1))
84
86
89}
90
91const struct SceneRegion *LemurianShip_GetRegions(void) { return NULL; }
92
94
95/// The ship's two pieces; the party's own actors fill the first three rows.
98}
99
100/// The way out, back into Lalivero's interiors: leaves and clears the
101/// backdrop colour.
102/// Reached by stepping on cell code 1 (gLemurianShipEvents); takes exit 1.
103static void LeaveTheShip(void) {
106}
107
108/// Stops the water's ripple while Reveal shows the scene.
109/// Reached by Reveal's phase 5 anywhere in the scene; Ripple_Start, at
110/// phase 4, starts the ripple again.
111static void Ripple_StopForReveal(void) { Ripple_Stop(); }
112
113/// Starts the two-axis ripple with its original frequencies and amplitudes.
114/// Called by LemurianShip_SetupScene, and reached by Reveal's phase 4 as the
115/// spell ends.
116static void Ripple_Start(void) {
117 DisplayScroll_InitializeHBlankDma(0, 0x40000, 0x10000, 0x2000, 0x10000,
118 0x8000, 0x4000);
119}
120
121/// The exit, Reveal and the Black Orb at the water's edge (cell code 10).
123 return gLemurianShipEvents;
124}
125
126/// Slides a window of six colours along gShipGlowPalettes into palette 7's
127/// colours 4 to 9, one step every 6 frames, so the ship's glow ripples.
128/// Run each frame once RaiseTheShip has brought the ship up.
129static void ShipGlow_CyclePalette(void) {
130 u16 *frame;
131 s32 paletteIndex;
132
133 frame = (u16 *)gShipGlowStep;
134 paletteIndex = Math_DivideUnsigned(*frame, 6);
135 Dma_Set((const void *)(((u32)(paletteIndex << 16) >> 15) +
137 (void *)0x050000e8, (DMA_ENABLE << 16) | 6, REG_DMA3);
138 (*frame)++;
139 if (*frame > 35)
140 *frame = 0;
141}
142
143/// A drop of spray rises and wobbles for its timer, then falls back by
144/// gSprayFallScript, which frees it.
145/// The update hook Ship_UpdateSwell gives each drop it creates.
146static void Spray_Update(union FieldObject *fieldObject) {
147 u8 *obj = (u8 *)fieldObject;
148 u16 *wait = &((struct FieldActor *)obj)->timer;
149 s32 left = *wait;
150
151 if (*(s16 *)wait != 0) {
152 s32 drift;
153
154 *wait = left - 1;
155 drift = Engine_RandomNext();
156 drift -= Engine_RandomNext();
157 ((struct FieldActor *)obj)->x.fixed += drift;
158 ((struct FieldActor *)obj)->y.fixed += 0xcccc;
159 } else if (*(s16 *)&((struct FieldActor *)obj)->work != 0) {
160 *(s16 *)&((struct FieldActor *)obj)->work = 0;
161 Object_SetMode((struct FieldActor *)obj, 1);
162 {
163 u16 *p = (u16 *)(obj + 94);
164 s32 delay = 20;
165
166 *p = delay;
167 }
169 }
170}
171
172/// Every 40 frames, the Black Orb's glow fades a step, down to 4.
173/// Run each frame while the ship rises; RaiseTheShip adds and removes it.
174static void OrbGlow_Fade(void) {
175 s32 frame = gOrbGlowFadeFrames + 1;
176
177 gOrbGlowFadeFrames = frame;
178 if (frame == 40) {
179 if (gOrbGlowStrength > 4) {
180 gOrbGlowStrength -= 1;
182 }
183 }
184}
185
186/// The map's scrolling layers, as the swell moves them.
189 s32 y; ///< 16.16 pixels; layers 6 and 7 are the ship's hull and deck
190 /// Layer 4's unk10[0] and [1], whole pixels in 16.16, are the corner of the
191 /// screen-sized box (240 by 160) the spray rises in.
193};
194
195/// The map work, seen for the scrolling layers the swell moves.
196struct WaveMap {
199};
200
201/// The Black Orb's glow pulses in the blend, the ship (layers 6 and 7) and
202/// everyone on deck bob with the swell, and spray rises from the water.
203/// Run each frame from RaiseTheShip to the end of the game; each part runs
204/// while its flag (gOrbGlowActive, gSwellActive, gSprayActive) is set.
205static void Ship_UpdateSwell(void) {
206 /* FAKEMATCH: volatile restores the form the bytes prove: blend lives at sp+18
207 * and is loaded again with ldrh for the register write (a 20-byte frame for
208 * 16). Without it differ 24, 223 instructions for 225. */
209 volatile u16 blend;
210 struct FixedPointPosition place;
211 struct FixedPointPosition *pos;
212 struct WaveMap *map;
213 struct FieldActor *actor;
214 s32 swell;
215 s32 x, z;
216
217 map = gMapWork[0];
218 if (gOrbGlowActive != 0) {
219 swell = Iwram_MulQ16(Engine_MathSin(gOrbGlowPhase << 9), 3);
220 blend = gOrbGlowStrength + ((swell + 8) << 8);
221 Io_Write16(blend, &REG_BLDALPHA);
223 }
224 if (gSwellActive != 0) {
225 swell = Iwram_MulQ16(Engine_MathSin(gSwellPhase << 9), 2) << 16;
226 map->layers[6].y = gShipHullY + swell;
227 map->layers[7].y = gShipDeckY + swell;
228 if (gLeaderDeckY != -0x10000) {
229 actor = Object_GetById(0);
230 actor->y.fixed = gLeaderDeckY + swell;
231 actor->terrainHeight = gLeaderDeckY + swell;
232 actor->motionFlags = 0;
233 }
234 if (gGaretDeckY != -0x10000) {
235 actor = Object_GetById(1);
236 actor->y.fixed = gGaretDeckY + swell;
237 actor->terrainHeight = gLeaderDeckY + swell;
238 actor->motionFlags = 0;
239 }
240 if (gMiaDeckY != -0x10000) {
241 actor = Object_GetById(3);
242 actor->y.fixed = gMiaDeckY + swell;
243 actor->terrainHeight = gLeaderDeckY + swell;
244 actor->motionFlags = 0;
245 }
246 if (gIvanDeckY != -0x10000) {
247 actor = Object_GetById(2);
248 actor->y.fixed = gIvanDeckY + swell;
249 actor->terrainHeight = gLeaderDeckY + swell;
250 actor->motionFlags = 0;
251 }
252 gSwellPhase++;
253 }
254 if (gSprayActive != 0 && (gFrameCount & 1) != 0) {
255 x = map->layers[4].unk10[0] & -0x10000;
256 z = map->layers[4].unk10[1] & -0x10000;
257 x += Random_Next() * 240;
258 pos = &place;
259 pos->x = x;
260 pos->y = 0;
261 z += Random_Next() * 160;
262 z += 0x1e0000;
263 pos->z = z;
264 actor = Object_Create(0x1f7, pos->x, pos->y, pos->z);
265 if (actor != 0) {
266 actor->update = Spray_Update;
267 actor->timer = 60;
268 actor->work = 1;
269 actor->motionFlags = 0;
270 actor->priorityFlags = 2;
271 actor->sprite->image.priority = 2;
273 Object_SetMode(actor, 0);
274 }
275 }
276}
277
278/// Remembers the leader's height on deck, so that from then on he bobs with
279/// the ship.
280/// Called by gLeaderBoardsShip as he steps on deck; the other members'
281/// boarding scripts call their own copies below.
282static s32 Leader_StepOnDeck(struct ScriptInterpreter *interpreter) {
283 s32 *deckY;
284 struct FieldActor *actor;
285
286 deckY = &gLeaderDeckY;
288 *deckY = actor->y.fixed;
289 return 0;
290}
291
292/// Remembers Garet's boarding height for the swell callback.
293static s32 Garet_StepOnDeck(struct ScriptInterpreter *interpreter) {
294 s32 *deckY;
295 struct FieldActor *actor;
296
297 deckY = &gGaretDeckY;
298 actor = Object_GetById(GARET);
299 *deckY = actor->y.fixed;
300 return 0;
301}
302
303/// Remembers Mia's boarding height for the swell callback.
304static s32 Mia_StepOnDeck(struct ScriptInterpreter *interpreter) {
305 s32 *deckY;
306 struct FieldActor *actor;
307
308 deckY = &gMiaDeckY;
309 actor = Object_GetById(MIA);
310 *deckY = actor->y.fixed;
311 return 0;
312}
313
314/// Remembers Ivan's boarding height for the swell callback.
315static s32 Ivan_StepOnDeck(struct ScriptInterpreter *interpreter) {
316 s32 *deckY;
317 struct FieldActor *actor;
318
319 deckY = &gIvanDeckY;
320 actor = Object_GetById(IVAN);
321 *deckY = actor->y.fixed;
322 return 0;
323}
324
325/// The others step out and talk over the journey while three questions
326/// shape their replies, everyone boards, and the ship sails east as the
327/// curtains close and the game goes to the clear screen.
328/// Called by RaiseTheShip once the ship has risen. Sets FLAG_KEEP_MUSIC and
329/// sends the party to the clear screen (SceneId_Title, entrance 9).
330static void SetSail(void) {
331 struct MapScrollWork *scroll;
332 struct FieldActor *ship;
333 struct EventWork *event;
334
336 Camera_MoveTo(-1, -1, -1, 0);
337 Map_CopyCellAttributes(18, 0, 3, 1, 18, 12);
338 // Garet, Mia and Ivan step out around the leader. Garet: "It looks like
339 // it's finally time to leave Gondowan." Ivan and Mia say how much has
340 // happened.
341 Engine_EventSetMessage(MsgFieldLooksLikeFinally);
367 // The first question, Garet's: will the journey be over once they find
368 // Sheba? The answer picks which of his two replies he says.
379 } else {
384 }
386 // Ivan reminds Garet of their promise to Babi, and Lemuria comes up.
412 // The second question, Mia's: must they find Sheba before going to
413 // Lemuria? Garet answers either way.
423 } else {
431 }
433 // Ivan: their first time on the ocean; Garet: the ocean Kraden wanted
434 // him to see.
450 // The third question, Mia's: the seas are rough; will they be all right?
462 } else {
468 }
470 // Garet: "Well... Shall we, then?" Ivan: "To sea..." Mia: Sheba is waiting
471 // for them. The departure theme starts.
494 // Everyone boards by their own scripts, hopping up onto the deck (SE_153
495 // each); the camera follows up to the ship.
496 Actor_SetSpeed(ACTOR_PARTY_LEADER, 0x13333, 0x9999);
497 Actor_SetSpeed(GARET, 0x13333, 0x9999);
498 Actor_SetSpeed(IVAN, 0x13333, 0x9999);
499 Actor_SetSpeed(MIA, 0x13333, 0x9999);
502 Camera_MoveTo(PIXELS(264), -1, PIXELS(200), 1);
510 // Mia, last, looks back at the shore before she boards.
521 // On deck, all four turn west together and nod.
522 Camera_MoveTo(PIXELS(216), -1, PIXELS(168), 1);
535 // The ship sails east and the curtains close: the sea's layer scrolls
536 // faster while the ship's north piece moves off, and the camera follows.
541 scroll = gMapWork[0];
543 ship->acceleration = 131;
544 ship->speed = 0x20000;
545 scroll->layers[0].speedX = -0x3000;
547 scroll->layers[0].speedX = -0x6000;
550 Engine_EventWait(100);
551 Engine_CameraSetSpeed(0x23333, 0x28f);
552 Engine_CameraMoveTo(PIXELS(808), -1, PIXELS(168), 1);
553 Engine_EventWait(300);
554 // Fade out to the clear screen, the title's entrance 9.
555 event = gMapWork[19];
556 event->startTransition = SCENE_TRANSITION(TRANSITION_BACKDROP_FADE, 0);
558 event->transitionFrames = 96;
564}
565
566/// The water's ripple, this scene's view of the HBlank scroll work
567/// (gHBlankScrollWork, struct DisplayScrollWork): two pages of per-line
568/// scroll offsets, swapped each frame, built from a sine table. Here a line
569/// is one word, BG3's x and y, where DisplayScrollWork has three.
571 u16 pages[2][0x3c0]; ///< per page: 160 lines of BG3 x, y; the rest unused
572 u8 page; ///< the page the HBlank DMA shows; the other is built
574 u16 phase; ///< frames built so far, added to BG3's y
576 s32 frequency[2]; ///< x, y: 16.16 sine entries per frame and per row
577 s32 step[2]; ///< x, y: 16.16 sine entries a line
578 s32 amplitude[2]; ///< x, y: 16.16 scale on the sine, then divided by 256
579};
580
581/// One line's ripple offset.
582static __inline__ s32 Wave_Offset(s32 angle, s32 amplitude, u16 base) {
583 return (u16)(Iwram_MulQ16(gRippleSine[(angle >> 16) & 0xff], amplitude) /
584 256) +
585 base;
586}
587
588/// The Black Orb glows, the water lights up, spray rises and the ship comes
589/// up out of the sea 90 pixels; then the party sets sail.
590/// Reached by using the Black Orb at the water's edge (cell code 10). Adds
591/// the swell and glow callbacks, which run to the end of the game, and calls
592/// SetSail.
593static void RaiseTheShip(void) {
594 struct WaveMap *map;
595 s32 i;
596 s32 flash;
597 s32 white;
598 s32 dark;
599 s32 sunk;
600 /* FAKEMATCH: volatile restores the form the bytes prove: cnt lives at sp+6
601 * and each BGxCNT value is stored there with strh on its way to the register
602 * (an 8-byte frame for 4). Without it differ 26, 225 instructions for 231. */
603 volatile u16 cnt;
604
605 map = gMapWork[0];
606
607 Event_Begin();
609 // The leader steps to the water's edge; the backdrop brightens 16 steps.
612 Event_Wait(40);
614 for (i = 0; i <= 15; i++) {
615 Io_Write16((i << 11) | (i << 5), &PLTT_BACKDROP);
616 Event_Wait(10);
617 }
618 {
619 u16 color = 0x7e00;
620
621 PLTT_BACKDROP = color;
622 }
623 {
624 u16 bright = 0x1010;
625
626 for (flash = 0; flash < 3; flash++) {
628 REG_BLDALPHA = bright;
629 Event_Wait(3);
630 Io_Write16(0x810, &REG_BLDALPHA);
631 Event_Wait(65);
632 }
633 }
634 // The orb's glow and the spray begin, and the water lightens in three
635 // steps.
636 gOrbGlowActive = 1;
637 gOrbGlowPhase = 0;
639 gSprayActive = 1;
640 Event_Wait(20);
642 Map_SetShake(0x10000, 0x10000, 0x10000);
643 Event_Wait(60);
644 gSprayActive = 1;
645 Map_SetShake(0x20000, 0x20000, 0x10000);
646 Event_Wait(60);
647 Map_SetShake(0x30000, 0x30000, 0x10000);
650 // The ship rises 90 pixels, 0.2 pixels a frame.
651 sunk = 0;
652 do {
653 map->layers[6].y += 0x3333;
654 map->layers[7].y += 0x3333;
655 sunk += 0x3333;
656 Task_Wait(1);
657 } while (sunk <= 0x59ffff);
659 gSprayActive = 0;
660 REG_BG3CNT = cnt = (REG_BG3CNT & 0xfffc) | 3;
661 REG_BG2CNT = cnt = (REG_BG2CNT & 0xfffc) | 3;
662 REG_BG1CNT = cnt = (REG_BG1CNT & 0xfffc) | 2;
663 gOrbGlowActive = 0;
665 Task_Wait(1);
666 // A flash of white; the swell starts as it clears.
668 Io_Write16(191, &REG_BLDCNT);
669 for (white = 0; white <= 16; white++) {
670 REG_BLDY = white;
671 Event_Wait(1);
672 }
673 Event_Wait(40);
674 Map_SetShake(-1, -1, 0xe666);
675 gShipHullY = map->layers[6].y;
676 gShipDeckY = map->layers[7].y;
677 gSwellActive = 1;
678 for (dark = 16; dark >= 0; dark--) {
679 REG_BLDY = dark;
680 Event_Wait(8);
681 }
685 Event_Wait(20);
686 Event_End();
687 SetSail();
688}
689
690/// Sets the harbor up: the ship sunk 90 pixels, its pieces and the party
691/// drawn behind the water layers, and the ripple running.
692/// The scene's initialization; arriving by entrance 99, which the entrance
693/// table does not list, first gives the leader the Black Orb.
695 struct WaveMap *map;
696 /* FAKEMATCH: volatile restores the form the bytes prove: cnt lives at sp+2
697 * and each step is stored there with strh; without it, 23 of 165
698 * instructions differ in tbs-en. */
699 volatile u16 cnt;
700
701 map = gMapWork[0];
704 }
705 ((struct EventWork *)gMapWork[19])->startTransition =
711 {
712 struct FieldActor *actor = Object_GetById(SHIP_NORTH);
713
714 SET_PRIORITY(actor, 9);
715 }
716 {
717 struct FieldActor *actor = Object_GetById(SHIP_SOUTH);
718
719 SET_PRIORITY(actor, 9);
720 }
721 {
723
724 SET_PRIORITY(actor, 9);
725 SET_PRIORITY(actor, 21);
726 }
727 {
728 struct FieldActor *actor = Object_GetById(GARET);
729
730 SET_PRIORITY(actor, 9);
731 SET_PRIORITY(actor, 21);
732 }
733 {
734 struct FieldActor *actor = Object_GetById(IVAN);
735
736 SET_PRIORITY(actor, 9);
737 SET_PRIORITY(actor, 21);
738 }
739 {
740 struct FieldActor *actor = Object_GetById(MIA);
741
742 SET_PRIORITY(actor, 9);
743 SET_PRIORITY(actor, 21);
744 }
745 REG_BG3CNT = cnt = (REG_BG3CNT & 0xfffc) | 2;
746 REG_BG2CNT = cnt = (REG_BG2CNT & 0xfffc) | 3;
747 REG_BG1CNT = cnt = (REG_BG1CNT & 0xfffc) | 3;
748 Io_Write16(0x2648, &REG_BLDCNT);
749 Io_Write16(0x810, &REG_BLDALPHA);
750 {
751 struct WaveMapLayer *layer = map->layers + 6;
752
753 layer->y += -0x5a0000;
754 layer = map->layers + 7;
755 layer->y += -0x5a0000;
756 }
758 Ripple_Start();
759 return 0;
760}
761
762/// Arms DMA 0 to copy the shown ripple page, a line each HBlank, into
763/// background 3's scroll registers, writing the first line itself.
764/// Run each frame; DisplayScroll_InitializeHBlankDma adds it and Ripple_Stop
765/// removes it.
767 struct RippleScrollWork *work;
768 u32 *source;
769 volatile u16 *dma0;
770 volatile u32 *destination;
771
772 work = (struct RippleScrollWork *)gHBlankScrollWork;
773 source = (u32 *)work->pages[work->page];
774
775 dma0 = REG_DMA0;
776 destination = (volatile u32 *)&REG_BG3HOFS;
778 dma0[5] &= ~DMA_ENABLE;
779 dma0[5];
780
781 *destination = *source++;
782 Dma_Set(source, (void *)destination, DMA_HBLANK_WORD_PER_LINE,
783 (volatile u32 *)dma0);
784}
785
786/// Builds the other ripple page and swaps it in.
787/// Run each frame; DisplayScroll_InitializeHBlankDma adds it and Ripple_Stop
788/// removes it.
790 struct RippleScrollWork *work;
791 u16 *line;
792 s32 angle;
793 u16 base;
795 s32 step;
796 u16 y;
797 s32 i;
798
799 work = (struct RippleScrollWork *)gHBlankScrollWork;
800 y = gBgScroll[3].y;
801 line = work->pages[work->page ^ 1];
802 step = work->step[0];
803 angle = (work->phase + y) * work->frequency[0];
804 amplitude = work->amplitude[0];
805 base = gBgScroll[3].x;
806 for (i = 0; i != 160; i++) {
807 *line = Wave_Offset(angle, amplitude, base);
808 angle += step;
809 line += 2;
810 }
811 line = work->pages[work->page ^ 1] + 1;
812 step = work->step[1];
813 angle = (work->phase + y) * work->frequency[1];
814 amplitude = work->amplitude[1];
815 for (i = 0; i != 160; i++) {
816 *line = Wave_Offset(angle, amplitude, y);
817 angle += step;
818 line += 2;
819 }
820 work->phase++;
821 work->page ^= 1;
822}
823
825
826/// Takes the ripple's callbacks off and stops DMA 0.
827/// Called by Ripple_StopForReveal.
828static void Ripple_Stop(void) {
829 volatile u16 *reg;
830
833 reg = REG_DMA0;
834 reg[5] = ~DMA_START_TIMING_DRQ_REPEAT & reg[5];
835 reg[5] = ~DMA_ENABLE & reg[5];
836 reg[5];
837}
838
839/// The curtains: three columns of eight 32 by 8 sprites that close in from
840/// the sides as the ship sails.
845};
846
850
851/// Moves the curtains a step closer and queues their 24 sprites.
852/// Run each frame from Curtain_Start to the end of the game.
853static void Curtain_Close(void) {
854 u32 *entry;
855 u32 tile;
856 s32 step;
857 s32 x;
858 u32 i;
859
861 entry = (u32 *)sCurtainSprites;
862 if (sCurtainGap != 0)
863 sCurtainGap--;
864 for (i = 0; i < 8; i++) {
865 s32 left;
866
867 step = sCurtainGap;
868 left = -step / 2;
869 *entry++ = 0;
870 *entry++ = (left & 0xff) | (i << 21) | 0x80004000;
871 *entry++ = tile;
872 }
873 x = (step / 2 + 136) & 0xff;
874 for (i = 0; i < 8; i++) {
875 *entry++ = 0;
876 *entry++ = (i << 21) | x | 0x80004000;
877 *entry++ = tile;
878 }
879 i = 0;
880 x = (sCurtainGap / 2 + 152) & 0xff;
881 for (; i < 8; i++) {
882 *entry++ = 0;
883 *entry++ = (i << 21) | x | 0x80004000;
884 *entry++ = tile;
885 }
886 for (i = 0; i < 24; i++)
888}
889
890/// Fills a 256-byte tile with colour 1 and starts the curtains 48 pixels
891/// open.
892/// Called by SetSail as the ship leaves; adds Curtain_Close.
893static void Curtain_Start(void) {
894 u8 *tiles;
895
898 Dma_Fill32(0x11111111, tiles, 0x100);
899 Engine_VramLoad(sCurtainVramSlot, 0x100, tiles);
900
901 sCurtainGap = 0x30;
903}
904
905/// The ship's glow: ShipGlow_CyclePalette shows six of these colours at a
906/// time, from a start that moves one colour every 6 frames.
908 0x5860, 0x69c0, 0x7f20, 0x69c0, 0x5860, 0x4800,
909 0x5860, 0x69c0, 0x7f20, 0x69c0, 0x5860, 0x0000,
910};
911
912/// A drop of spray, at the end of its rise: freed.
914 SC_FREE,
915};
916
917// clang-format off
919 0, 100, 200, 301, 401, 501, 601, 700,
920 799, 897, 995, 1092, 1189, 1284, 1379, 1474,
921 1567, 1659, 1751, 1841, 1930, 2018, 2105, 2191,
922 2275, 2358, 2439, 2519, 2598, 2675, 2750, 2824,
923 2896, 2966, 3034, 3101, 3166, 3229, 3289, 3348,
924 3405, 3460, 3513, 3563, 3612, 3658, 3702, 3744,
925 3784, 3821, 3856, 3889, 3919, 3947, 3973, 3996,
926 4017, 4035, 4051, 4065, 4076, 4084, 4091, 4094,
927 4096, 4094, 4091, 4084, 4076, 4065, 4051, 4035,
928 4017, 3996, 3973, 3947, 3919, 3889, 3856, 3821,
929 3784, 3744, 3702, 3658, 3612, 3563, 3513, 3460,
930 3405, 3348, 3289, 3229, 3166, 3101, 3034, 2966,
931 2896, 2824, 2750, 2675, 2598, 2519, 2439, 2358,
932 2275, 2191, 2105, 2018, 1930, 1841, 1751, 1659,
933 1567, 1474, 1379, 1284, 1189, 1092, 995, 897,
934 799, 700, 601, 501, 401, 301, 200, 100,
935 0, -100, -200, -301, -401, -501, -601, -700,
936 -799, -897, -995, -1092, -1189, -1284, -1379, -1474,
937 -1567, -1659, -1751, -1841, -1930, -2018, -2105, -2191,
938 -2275, -2358, -2439, -2519, -2598, -2675, -2750, -2824,
939 -2896, -2966, -3034, -3101, -3166, -3229, -3289, -3348,
940 -3405, -3460, -3513, -3563, -3612, -3658, -3702, -3744,
941 -3784, -3821, -3856, -3889, -3919, -3947, -3973, -3996,
942 -4017, -4035, -4051, -4065, -4076, -4084, -4091, -4094,
943 -4096, -4094, -4091, -4084, -4076, -4065, -4051, -4035,
944 -4017, -3996, -3973, -3947, -3919, -3889, -3856, -3821,
945 -3784, -3744, -3702, -3658, -3612, -3563, -3513, -3460,
946 -3405, -3348, -3289, -3229, -3166, -3101, -3034, -2966,
947 -2896, -2824, -2750, -2675, -2598, -2519, -2439, -2358,
948 -2275, -2191, -2105, -2018, -1930, -1841, -1751, -1659,
949 -1567, -1474, -1379, -1284, -1189, -1092, -995, -897,
950 -799, -700, -601, -501, -401, -301, -200, -100,
951};
952// clang-format on
953
955 {0, CONDITION_ALWAYS, 408, 0, 200, FACING_NORTH, 0, -1, -1, -1, -1, 0},
956 {1, CONDITION_ALWAYS, 312, 0, 296, FACING_NORTH, 0, -1, -1, -1, 328, 0},
958};
959
961 SCENE_EXITS(188),
962 SCENE_EXIT(1, 180, 31),
964};
965
968 TALK_FACE_PARTY, 0},
970 0},
972 0},
973 {0x1f6, CONDITION_ALWAYS, ACTOR_STAND, PIXELS(312), 0, PIXELS(248),
975 {0x1f6, CONDITION_ALWAYS, ACTOR_STAND, PIXELS(312), 0, PIXELS(312),
978};
979
989};
990
992
994
996
998
1000
1002
1004
1006
1008
1010
1011s32 gGaretDeckY = -0x10000;
1012
1013s32 gMiaDeckY = -0x10000;
1014
1015s32 gIvanDeckY = -0x10000;
1016
1018 0,
1019};
1020
1022 SC_ARG(2),
1023 SC_MOVE_BY(PIXELS(-8), 0, 0),
1024 SC_SYNC,
1025 SC_MOVE_BY(0, 0, PIXELS(-16)),
1026 SC_SYNC,
1027 SC_SET(SW_VELOCITY_Y, 0x80000),
1028 SC_SE(153),
1029 SC_MOVE_BY(0, 0, PIXELS(-24)),
1030 SC_SYNC,
1031 SC_ARG(1),
1032 SC_WAIT(20),
1033 SC_ARG(2),
1034 SC_MOVE_BY(PIXELS(-8), 0, 0),
1035 SC_SYNC,
1036 SC_MOVE_BY(0, 0, PIXELS(-56)),
1037 SC_SYNC,
1038 SC_ARG(1),
1040 SC_WAIT(1),
1042 SC_END,
1043};
1044
1046 SC_ARG(2),
1047 SC_MOVE_BY(0, 0, PIXELS(-32)),
1048 SC_SYNC,
1049 SC_SET(SW_VELOCITY_Y, 0x80000),
1050 SC_SE(153),
1051 SC_MOVE_BY(0, 0, PIXELS(-24)),
1052 SC_SYNC,
1053 SC_ARG(1),
1054 SC_WAIT(20),
1055 SC_ARG(2),
1056 SC_MOVE_BY(PIXELS(-8), 0, 0),
1057 SC_SYNC,
1058 SC_MOVE_BY(0, 0, PIXELS(-40)),
1059 SC_SYNC,
1060 SC_ARG(1),
1062 SC_WAIT(1),
1064 SC_END,
1065};
1066
1068 SC_ARG(2),
1069 SC_MOVE_BY(PIXELS(-20), 0, 0),
1070 SC_SYNC,
1071 SC_MOVE_BY(0, 0, PIXELS(-32)),
1072 SC_SYNC,
1073 SC_SET(SW_VELOCITY_Y, 0x80000),
1074 SC_SE(153),
1075 SC_MOVE_BY(0, 0, PIXELS(-24)),
1076 SC_SYNC,
1077 SC_ARG(1),
1078 SC_WAIT(20),
1079 SC_ARG(2),
1080 SC_MOVE_BY(PIXELS(-8), 0, 0),
1081 SC_SYNC,
1082 SC_MOVE_BY(0, 0, PIXELS(-24)),
1083 SC_SYNC,
1084 SC_ARG(1),
1086 SC_WAIT(1),
1088 SC_END,
1089};
1090
1092 SC_ARG(2),
1093 SC_MOVE_BY(PIXELS(-8), 0, 0),
1094 SC_SYNC,
1095 SC_MOVE_BY(0, 0, PIXELS(-8)),
1096 SC_SYNC,
1097 SC_SET(SW_VELOCITY_Y, 0x80000),
1098 SC_SE(153),
1099 SC_MOVE_BY(0, 0, PIXELS(-24)),
1100 SC_SYNC,
1101 SC_ARG(1),
1102 SC_WAIT(20),
1103 SC_ARG(2),
1104 SC_MOVE_BY(PIXELS(-8), 0, 0),
1105 SC_SYNC,
1106 SC_MOVE_BY(0, 0, PIXELS(-8)),
1107 SC_SYNC,
1108 SC_ARG(1),
1110 SC_END,
1111};
Ability numbers, named from the English release.
@ ABILITY_REVEAL
Definition ability_ids.h:19
void Object_RefreshSelectorById(u32 objectId)
Waits, at most 300 frames, for an actor's script to reach its end (command 0x10).
void ObjectMotion_CommitPositionAndActivate(u32 objectId, s32 xOffset, s32 zOffset)
Walks the actor (xOffset, zOffset) pixels, waits for it to arrive and stands it still.
void Motion_LaunchFromFocusedObject(u32 objectId, s32 xOffset, s32 zOffset, s32 action)
Places an actor on the leader and sends it walking (xOffset, zOffset) pixels away at speed 0....
struct FieldActor * Object_GetById(s32 actor)
Returns an actor, or NULL if it does not exist.
s32 Math_DivideUnsigned(s32 value, s32 divisor)
Divides the nonnegative random value for wall-fragment scaling.
The task scheduler: tasks, their order and the scheduler's state.
#define GARET
Jerald.
#define MIA
Mary.
#define IVAN
Ivan.
void Engine_ActorSetSpriteFlags(struct FieldActor *, s32)
The engine calls the debug menus import, and their palette swatch tiles.
DMA channel registers, and the DMA and CPU fills.
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...
Definition dma.h:62
#define Dma_Fill32(value, destination, size)
Fills size bytes at destination with the word value by DMA3.
Definition dma.h:30
static s32 FieldScheduler_AddCallback(SchedulerCallback callback, s32 priority)
Registers a main-image scheduler callback.
Definition engine_call.h:36
The scene script layer: the engine services a scene's events call, declared once (Engine_EventBegin,...
@ ANIM_NOD
Definition field_event.h:45
@ ANIM_SHAKE_HEAD
Definition field_event.h:46
static void Actor_FaceDirection(s32 actor, s32 facing, s32 frames)
void Engine_ActorSetAnimationAndWait(s32 actor, s32 animation)
void Object_SetMode(struct FieldActor *object, s32 animation)
s32 Engine_EventChooseYesNo(s32 actor, s32 flags)
void Engine_CameraSetSpeed(s32 speed, s32 acceleration)
static void Actor_WalkToAndWait(s32 actor, s32 x, s32 z)
void Engine_CameraMoveTo(s32 fixed_x, s32 fixed_y, s32 fixed_z, s32 pan)
s32 Engine_TaskRemoveCallback(void(*callback)(void))
#define EMOTE_IN_FRONT
Definition field_event.h:49
@ OBJECT_BLEND_NORMAL
s32 Engine_MathSin(s32 angle)
void Engine_ActorFaceDirection(s32 actor, s32 facing, s32 frames)
void Engine_EventCloseScreen(void)
s32 Engine_VramLoad(s32 block, s32 size, const void *data)
void Engine_EventWaitForScreen(void)
static void Actor_ShowEmote(s32 actor, s32 emote, s32 frames)
void Engine_ObjectSetScript(struct FieldActor *object, const s32 *script)
void Engine_GameFlagSet(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)
static void Map_CopyCellAttributes(s32 srcX, s32 srcY, s32 width, s32 height, s32 destX, s32 destY)
void Engine_ActorRunRepeatedMotion(s32 actor, s32 repeats)
s32 Engine_RandomNext()
static void Event_PlayCue(s32 cue)
static void Map_SetShake(s32 horizontal, s32 vertical, s32 decay)
Sets shake amplitudes in fixed-point pixels and the per-frame decay factor.
static struct FieldActor * Object_Create(s32 type, s32 fixed_x, s32 fixed_y, s32 fixed_z)
static void Actor_SetSpeed(s32 actor, s32 speed, s32 acceleration)
@ TASK_PRIORITY_SCENE
Definition field_event.h:40
void Engine_MapRedraw(void)
static s32 Random_Next(void)
static void Camera_MoveTo(s32 fixed_x, s32 fixed_y, s32 fixed_z, s32 pan)
void Engine_EventWait(s32 frames)
Field objects and actors, and the scene transition styles.
@ TRANSITION_BACKDROP_FADE
Definition field_obj.h:16
#define SCENE_TRANSITION(style, variant)
Definition field_obj.h:20
The scene table formats: entrances, exits, placements and events, and the macros that write them.
#define SCENE_EVENTS_END
@ EVENT_TOUCH
#define SCENE_EXITS(scene)
Definition field_scene.h:72
#define PSYNERGY_IN_AREA(ability, phase)
#define USE_ITEM(item)
#define SCENE_EXIT(exit, scene, entrance)
Definition field_scene.h:73
@ ACTOR_PARTY_LEADER
@ SCENE_TABLE_END
Definition field_scene.h:43
@ CONDITION_ALWAYS
Definition field_scene.h:44
@ TALK_KEEP_FACING
@ TALK_FACE_PARTY
#define EVENT_SCRIPT(script)
@ ACTOR_STAND
#define SCENE_EXITS_END
Definition field_scene.h:77
@ FACING_NORTHEAST
Definition field_scene.h:33
@ FACING_EAST
Definition field_scene.h:26
@ FACING_NORTH
Definition field_scene.h:32
@ FACING_NORTHWEST
Definition field_scene.h:31
@ FACING_SOUTH
Definition field_scene.h:28
@ FACING_WEST
Definition field_scene.h:30
#define PIXELS(value)
The scene service layer: one typed inline for each engine service a scene calls by its own name,...
static void Event_End(void)
static void Task_Wait(s32 frames)
static void Event_Begin(void)
static void FieldObjectMotion_CommitPositionAndActivate(s32 a0, s32 a1, s32 a2)
static void FieldMotion_LaunchFromFocusedObject(s32 actor, s32 dx, s32 dz, s32 facing)
static void Event_Wait(s32 frames)
FixedPointPosition, a position in 16.16 fixed point.
Game flags, named where their meaning is shown.
#define FLAG_KEEP_MUSIC
The next scene keeps the music that is playing; scene.c clears FLAG_KEEP_MUSIC as it does,...
Definition flags.h:35
volatile u32 gFrameCount
Frames WaitFrames has finished.
GameState, the game's state: play time, coins, the scene and the leader's position,...
struct GameState gGameState
The work slots of gWorkSlot, read through their own names.
void * gMapWork[]
The screen blend's globals and the graphics routines.
void * Runtime_BumpAllocateAlternatePool(s32 size)
As MemAlloc, but tries EWRAM first.
Definition heap.c:140
s32 Inventory_AddItem(s32 owner, s32 itemId)
Gives a unit one item, joining its first matching stack (up to 30) or taking the first free slot.
Definition inventory.c:144
The hardware's I/O registers and their bits, as pret names them.
#define DMA_HBLANK_WORD_PER_LINE
Definition io_reg.h:230
#define REG_BG3CNT
Definition io_reg.h:22
#define REG_DMA0
Definition io_reg.h:151
#define DMA_START_TIMING_DRQ_REPEAT
A DMA control's start timing (bits 12 and 13), cartridge request (bit 11) and repeat (bit 9): the bit...
Definition io_reg.h:220
#define REG_BLDY
Definition io_reg.h:146
#define PLTT_BACKDROP
Definition io_reg.h:155
#define REG_BG3HOFS
Definition io_reg.h:53
#define REG_DMA3
Definition io_reg.h:153
#define REG_BG2CNT
Definition io_reg.h:21
#define REG_BLDALPHA
Definition io_reg.h:142
#define REG_BLDCNT
Definition io_reg.h:119
#define REG_BG1CNT
Definition io_reg.h:20
#define DMA_ENABLE
Definition io_reg.h:217
Io_Write16, a 16-bit write to a register or memory.
#define Io_Write16(v, reg)
Writes a value to a 16-bit register or memory location.
Definition iowrite.h:14
Item numbers, named from the English release.
@ ITEM_BLACK_ORB
Definition item_ids.h:80
The IWRAM call layer: the routines the game keeps resident in IWRAM, each at its fixed address,...
#define Iwram_MulQ16(left, right)
Definition iwram_call.h:127
s32 gShipDeckY
s32 gIvanDeckY
s32 gLeaderDeckY
static void OrbGlow_Fade(void)
Every 40 frames, the Black Orb's glow fades a step, down to 4.
@ ENTRANCE_99
s32 gMiaBoardsShip[]
static void ShipGlow_CyclePalette(void)
Slides a window of six colours along gShipGlowPalettes into palette 7's colours 4 to 9,...
static __inline__ s32 Wave_Offset(s32 angle, s32 amplitude, u16 base)
One line's ripple offset.
const struct SceneEntrance * LemurianShip_GetEntrances(void)
const u32 * LemurianShip_GetExits(void)
s32 gGaretDeckY
static void Ripple_Stop(void)
Takes the ripple's callbacks off and stops DMA 0.
s32 gOrbGlowPhase
@ SHIP_NORTH
the ship, in two pieces of sprite 0x1f6
@ SHIP_SOUTH
u32 gLemurianShipExits[]
static void Curtain_Close(void)
Moves the curtains a step closer and queues their 24 sprites.
s32 gSprayActive
s32 gSwellActive
u32 gShipGlowStep[]
const struct ScenePlacement * LemurianShip_GetPlacements(void)
The ship's two pieces; the party's own actors fill the first three rows.
s32 gSprayFallScript[]
A drop of spray, at the end of its rise: freed.
static void Ship_UpdateSwell(void)
The Black Orb's glow pulses in the blend, the ship (layers 6 and 7) and everyone on deck bob with the...
static struct CurtainSprite sCurtainSprites[24]
const struct SceneRegion * LemurianShip_GetRegions(void)
s32 gIvanBoardsShip[]
u16 gShipGlowPalettes[]
The ship's glow: ShipGlow_CyclePalette shows six of these colours at a time, from a start that moves ...
struct SceneEvent gLemurianShipEvents[]
s32 LemurianShip_SetupScene(void)
Sets the harbor up: the ship sunk 90 pixels, its pieces and the party drawn behind the water layers,...
static s16 sCurtainGap
struct SceneEntrance gLemurianShipEntrances[]
s32 gOrbGlowFadeFrames
static void RaiseTheShip(void)
The Black Orb glows, the water lights up, spray rises and the ship comes up out of the sea 90 pixels;...
struct ScenePlacement gLemurianShipPlacements[]
#define SET_PRIORITY(actor, n)
Sets one of the sprite's two priority bits of a ship piece or a party actor: 9 sets the first,...
s32 gMiaDeckY
s16 gRippleSine[256]
s32 gOrbGlowStrength
#define LEMURIAN_SHIP_DEPARTURE_DELAY_FRAMES
static void SetSail(void)
The others step out and talk over the journey while three questions shape their replies,...
static s32 Ivan_StepOnDeck(struct ScriptInterpreter *interpreter)
Remembers Ivan's boarding height for the swell callback.
s32 gShipHullY
static void Curtain_Start(void)
Fills a 256-byte tile with colour 1 and starts the curtains 48 pixels open.
static s32 Leader_StepOnDeck(struct ScriptInterpreter *interpreter)
Remembers the leader's height on deck, so that from then on he bobs with the ship.
static s16 sCurtainVramSlot
s32 gGaretBoardsShip[]
static void LeaveTheShip(void)
The way out, back into Lalivero's interiors: leaves and clears the backdrop colour.
static void Spray_Update(union FieldObject *fieldObject)
A drop of spray rises and wobbles for its timer, then falls back by gSprayFallScript,...
s32 gOrbGlowActive
s32 gSwellPhase
const struct SceneEvent * LemurianShip_GetEvents(void)
The exit, Reveal and the Black Orb at the water's edge (cell code 10).
static s32 Garet_StepOnDeck(struct ScriptInterpreter *interpreter)
Remembers Garet's boarding height for the swell callback.
static void Ripple_Start(void)
Starts the two-axis ripple with its original frequencies and amplitudes.
s32 gLeaderBoardsShip[]
static s32 Mia_StepOnDeck(struct ScriptInterpreter *interpreter)
Remembers Mia's boarding height for the swell callback.
static void Ripple_StopForReveal(void)
Stops the water's ripple while Reveal shows the scene.
The map layers' scroll work and the background scroll values.
struct BgScroll gBgScroll[]
The heaps: allocating and freeing blocks.
static __inline__ void * Runtime_CallAlternatePool(void *(*allocate)(s32), s32 size)
Definition mem.h:15
The reel game's title lettering.
Field object scripts: one s32 command word, then its operands, as gScriptObject_CommandTable runs the...
#define SC_SET(w, v)
Write a work value.
Definition objcmd.h:37
#define SC_FREE
Release.
Definition objcmd.h:43
#define SC_SYNC
Wait for arrival.
Definition objcmd.h:17
#define SC_ARG(v)
Definition objcmd.h:44
#define SC_SE(n)
Sound effect.
Definition objcmd.h:46
#define SC_WAIT(n)
Wait n frames.
Definition objcmd.h:16
#define SC_END
Return to the main script.
Definition objcmd.h:32
#define SC_MOVE_BY(x, y, z)
Move by a relative offset.
Definition objcmd.h:20
@ SW_FACING
Definition objcmd.h:57
@ SW_VELOCITY_Y
Definition objcmd.h:65
#define SC_CALL(fn)
Definition objcmd.h:50
void Battle_ResetEffectCounter(void)
Clears the field's busy flag and, while Reveal is active, ends it: Reveal used with ACT_PACKED runs i...
Definition targets.c:261
void Event_SetDestination(s32 scene, s32 entrance)
Makes the event leave for the given entrance of the given scene: raises the exit request 999 and writ...
Definition events.c:517
struct UiWindow * UiText_OpenMessageAtObject(s32 actor, s32 unused)
The event command "open message": opens the event's current message in a speech window next to the sp...
Definition messages.c:24
void Runtime_PushSlotEntry(void *slotEntry, s32 slot)
Links a sprite entry into depth slot slot (clamped to 0..255) for this frame.
Definition render.c:79
void AudioCommand_WaitForStateByteClear(void)
Waits one frame at a time until the sound driver has finished the last command.
Definition run.c:198
Scene numbers, named after their places.
char SceneId_Title
The field object script interpreter and the operands its commands read.
The display scroll work, the HBlank scroll work and its wave.
struct DisplayScrollWork * gHBlankScrollWork
Song and sound effect ids, indices into gSound_SongTable.
#define SE_163
Definition songs.h:158
#define MUS_PUZZLE_SOLVED
Definition songs.h:79
#define SE_288
Definition songs.h:281
#define MUS_017
Definition songs.h:27
#define SE_212
Definition songs.h:207
#define MUS_067
Definition songs.h:70
#define SE_140
Definition songs.h:133
#define SE_145
Definition songs.h:138
void MusicCommand_SetPitchAndUpdateFrequency(u16 tempoScale)
Sets the BGM tempo scale directly; 0x100 preserves its native tempo.
Definition sound.c:228
void Engine_ActorSetAnimation()
struct EventWork * gEventWork
void Engine_EventRequestExit()
void Engine_AudioPlayCue()
void Engine_EventBegin(void)
void Engine_ActorShowEmote()
void Engine_EventSetMessage()
void Engine_EventShowMessage()
#define NULL
Definition bilibin.h:6
void DisplayScroll_InitializeHBlankDma(s32 mode, s32 freqX, s32 stepX, s32 ampX, s32 freqY, s32 stepY, s32 ampY)
Starts the ripple: its work (heap block 34) holds the mode and, for x and y, the wave's frequency,...
u16 y
pixels
Definition map_scroll.h:65
The curtains: three columns of eight 32 by 8 sprites that close in from the sides as the ship sails.
The running scene's event work: its placement and event tables, its actors, the triggers and exit it ...
Definition event_work.h:20
s32 startTransition
SCENE_TRANSITION(style, variant).
Definition event_work.h:43
s16 touchedTrigger
the step event a touch or exit event answers
Definition event_work.h:26
u16 message
the next message, advanced as each window opens
Definition event_work.h:47
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
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 acceleration
Added toward the target each frame, or taken off the speed when there is none, in 16....
Definition field_obj.h:58
void(*) update(union FieldObject *object)
Called each frame before the object's script, while the object is live.
Definition field_obj.h:116
u16 wait
the object script's wait, in frames (ScriptMotionObject)
Definition field_obj.h:98
u16 work
The side of the player's next footprint (2 after a stop), or scene scratch.
Definition field_obj.h:112
u8 collisionFlags
bits: 7 refuses to move into a solid object | 4 nearer for Psynergy targets | 3 never a talk or Psyne...
Definition field_obj.h:91
A position in three coordinates, each in 16.16 fixed point.
s32 z
16.16 fixed point
s32 x
16.16 fixed point
s32 y
16.16 fixed point
s16 entrance
Definition game_state.h:37
The field map's work: the followed position, screen shake, tile animations, blend script,...
Definition map_scroll.h:27
struct MapLayerScroll layers[3]
BG3, BG2 and BG1, in that order.
Definition map_scroll.h:49
The water's ripple, this scene's view of the HBlank scroll work (gHBlankScrollWork,...
s32 frequency[2]
x, y: 16.16 sine entries per frame and per row
u16 pages[2][0x3c0]
per page: 160 lines of BG3 x, y; the rest unused
u8 page
the page the HBlank DMA shows; the other is built
s32 step[2]
x, y: 16.16 sine entries a line
s32 amplitude[2]
x, y: 16.16 scale on the sine, then divided by 256
u16 phase
frames built so far, added to BG3's y
A scene entrance: where and facing which way the party arrives, and the camera's bounds there (-1 for...
Definition field_scene.h:54
A scene event: its kind and detail, the trigger it answers, its condition and its value (a message or...
An actor a scene places: its sprite, the condition for placing it, how it behaves,...
Definition field_scene.h:81
A scene's exit region: the box that, while its condition holds, takes the party leader out through it...
The prefix that command handlers read from a field object's 0x70-byte slot.
Definition script.h:16
u16 offset
bytes from the start of OBJ VRAM
Definition vram_tab.h:25
The map's scrolling layers, as the swell moves them.
s32 y
16.16 pixels; layers 6 and 7 are the ship's hull and deck
s32 unk10[8]
Layer 4's unk10[0] and [1], whole pixels in 16.16, are the corner of the screen-sized box (240 by 160...
The map work, seen for the scrolling layers the swell moves.
u8 unk00[20]
struct WaveMapLayer layers[8]
The system's routines and globals: interrupts, BIOS sound bias, random numbers and sleep.
Values that differ by patch level or language, chosen once for their code.
The integer types, TRUE, UNUSED and the fixed-address macros.
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
signed short s16
Definition types.h:12
unsigned short u16
Definition types.h:13
unsigned char u8
Definition types.h:11
s32 fixed
16.16 fixed-point pixels
An object on the field, read as an actor or as an effect.
The patch levels: our groups of the measured changes from the Japanese release.
Declares nothing of its own: it only includes the window, battle command, resource and VRAM table hea...
s32 Resource_FindFreeEntry(void)
Returns the number of the first free cache entry, or VRAM_CACHE_ENTRY_COUNT when all are taken.
Definition vram_cache.c:211
The sprite VRAM block cache and its owners.
struct VramBlockCacheEntry gVramBlockCache[]
void DisplayScroll_ArmHBlankDma(void)
Scheduler callback for the wavy background: restarts DMA 0 each frame to copy the current page's BG1 ...
Definition wave_scroll.c:11
void DisplayScroll_BuildAndSwapHBlankPage(void)
Scheduler callback for the wavy background: fills the hidden page with each scanline's BG3,...
Definition wave_scroll.c:44