Alchemy
Loading...
Searching...
No Matches

tret_tree_interiors.c

Go to the documentation of this file.
1/// @file
2/// Inside Tret, the great tree: cracked floors that give way under the leader
3/// on the second step, and Tret's face, which attacks the party.
4
6#include "version.h"
7#include "game_state.h"
8#include "scene_ids.h"
11#include "unit/object/object.h"
13#include "unit/game/game.h"
15
16#include "field_obj.h"
17#include "types.h"
18#include "field_event.h"
19#include "field_scene.h"
22#include "battle.h"
23#include "debug.h"
24#include "field.h"
25#include "game.h"
26#include "graphics.h"
27#include "menu.h"
28#include "minigame.h"
29#include "sound.h"
30#include "system.h"
31#include "resource.h"
32#include "global_cells.h"
33#include "iwram_call.h"
34#include "dma.h"
35#include "field_service.h"
36#include "io_reg.h"
37#include "text/msg_ids.h"
38#include "heap_state.h"
39#include "field_effect.h"
40#include "flags.h"
41#include "character_ids.h"
42#include "map_scroll.h"
43#include "songs.h"
44#include "event.h"
45
46/// Tret's face, the first actor placed after the party, and a second Tret
47/// actor placed at the same spot. Both speak Tret's lines: the face as he
48/// attacks, the second after the battle.
49enum {
53};
54
55/// The speaker of a message; every speaker in this scene has
56/// SPEAKER_WINDOW_BELOW.
57#define SPEAKER(actor) (SPEAKER_WINDOW_BELOW | (actor))
58
59// The scene's temporary flags: FLAG_SCENE_TEMP_00 to _14 are set the first
60// time each cracked floor tile is stepped on; the next step makes it give
61// way (gTretTreeInteriors_MapPatches lists them).
62
63#define FLOOR_FALL_SPIN_FRAMES 30
64#define SWIRL_SPARK_LAST_FRAME 79
65#define SWIRL_SPARK_SHRINK_LAST_FRAME 39
66#define TRET_TINT_COLOR_COUNT 63
67#define TRET_TINT_CHANNEL_MAX 31
68#define TRET_TINT_END 99
69
70static void TretPalette_SaveSceneColors(void);
71static void TretPalette_UpdateSceneTint(void);
72static void TretTreeInteriors_PlayGesture(s32 gesture);
76
80
82
83#include "common/effect_spawn.h"
84#include "ability_ids.h"
85#include "item_ids.h"
86#include "objcmd.h"
87
88/// Returns the interior entrance and landing positions.
89const struct SceneEntrance *Scene_GetEntrances(void) {
91}
92
93/// Returns the upper exit regions for the tree interior.
94const struct SceneRegion *Scene_GetRegions(void) {
96}
97
99
100/// Returns the staged party and Tret actors.
103}
104
105/// Stepping on a cracked floor tile: the first step cracks it further and sets
106/// its temporary flag; the next step breaks it, and the leader spins and falls
107/// through, to land at the given entrance.
109 s32 sourceColumn,
110 s32 sourceRow, s32 entrance) {
111 s32 destinationColumn;
112 s32 destinationRow;
113 s32 selectedActorId;
114 struct FieldActor *actor;
115 s32 spinFrame;
116
117 destinationColumn = (gGameState.x >> 20) + 64;
118 destinationRow = gGameState.z >> 20;
119 selectedActorId = gGameState.selectedActor;
120 actor = Object_GetById(selectedActorId);
121 if (entrance == *sLastFloorEntrance)
122 return;
123 *sLastFloorEntrance = entrance;
124 if (FLAG_CHECK(floorFlag) == 0) {
125 Map_CopyCells(sourceColumn, sourceRow, 1, 1, destinationColumn,
126 destinationRow);
127 FLAG_SET(floorFlag);
128 return;
129 }
130 // On the next touch, replace the tile and spin the actor into the fall.
131 *sLastFloorEntrance = -1;
132 Map_CopyCells(sourceColumn, sourceRow + 1, 1, 1, destinationColumn,
133 destinationRow);
134 SE(SE_206);
135 EV_BEGIN();
137 OBJ_MODE(selectedActorId, 27);
138 Engine_ActorSetSpriteFlags(Object_GetById(selectedActorId), 0);
139 Actor_SetAttachedEffect(selectedActorId, 0x101);
140 WAIT(30);
141 Camera_MoveTo(-1, -1, -1, 0);
142 actor->motionFlags = ACTOR_FALLS;
143 actor->terrainHeight = -PIXELS(160);
144 actor->gravity = 0x8000;
145 SE(SE_204);
146 WAIT(3);
147 actor->terrainId = 2;
148 Engine_ActorSetSpritePriority(selectedActorId, 3);
149 for (spinFrame = FLOOR_FALL_SPIN_FRAMES - 1; spinFrame >= 0; spinFrame--) {
150
151 actor->facing += 2 * FACING_STEP;
153 }
154 if (entrance != 50)
155 FLAG_SET(0x122);
156}
157
160}
161
164}
165
168}
169
172}
173
176}
177
180}
181
184}
185
188}
189
192}
193
196}
197
200}
201
204}
205
208}
209
212}
213
216}
217
220}
221
224}
225
226/// A second cracked floor over the same lower middle west landing.
229}
230
233}
234
237}
238
241}
242
243/// Walking off a cracked floor tile lets the next step on it count again.
245 if (Engine_LeaderCheckAhead() == 0)
246 *sLastFloorEntrance = -1;
247}
248
249/// Returns the floor, story, Reveal and search event bindings.
250const struct SceneEvent *Scene_GetEvents(void) {
252}
253
254/// Walking up to Tret (touch trigger 40, until FLAG_TRET_DEFEATED): he roars,
255/// the party gathers in front of him, and he scorns them before the battle with
256/// him starts. "Hm... HROOOM!!!" and "You hoped to find my kindly self?" The
257/// battle returns to entrance 19.
258static void Event_FightTret(void) {
259 s32 hasMia;
260 struct FieldActor *leader;
261
262 hasMia = FLAG_CHECK(FLAG_IN_PARTY(MIA));
263 EV_BEGIN();
264 SE(MUS_017);
265 MESSAGE_SET(MsgTretHmHrooom);
267 SE(MUS_029);
268 OBJ_SPEED(ACTOR_PARTY_LEADER, 0x10000, 0x8000);
269 OBJ_SPEED(GARET, 0x10000, 0x8000);
270 OBJ_SPEED(IVAN, 0x10000, 0x8000);
271 OBJ_SPEED(MIA, 0x10000, 0x8000);
278 if (leader != NULL) {
279 Engine_ActorSetPosition(GARET, leader->x.fixed, leader->z.fixed);
280 }
282 if (leader != NULL) {
283 Engine_ActorSetPosition(IVAN, leader->x.fixed, leader->z.fixed);
284 }
285 if (hasMia != 0) {
287 if (leader != NULL) {
288 Engine_ActorSetPosition(MIA, leader->x.fixed, leader->z.fixed);
289 }
291 }
295 WAIT(10);
300 OBJ_MODE(ACTOR_TRET, 11);
301 WAIT(10);
303 WAIT(20);
325 WAIT(40);
333 EV_END();
334}
335
336/// After the battle: a passage opens beside Tret, who comes to, thanks the
337/// party and says good-bye. "Oh... Mmmmm..." Garet and Ivan stop him and he
338/// asks whether they need something; answering no earns the leader a
339/// scolding. Tret learns he turned the people of Kolima into trees, tries to
340/// free them in a swirl of sparks but cannot, and the party resolve to heal
341/// him. Sets FLAG_TRET_DEFEATED.
343 s32 hasMia;
344 struct FieldActor *partyActor;
345 s32 openingColumn;
346 SchedulerCallback sparkTask;
347 const s32 *actions;
348
349 // Restore the party positions before opening the post-battle conversation.
350 hasMia = FLAG_CHECK(FLAG_IN_PARTY(MIA));
357 SE(MUS_017);
358 EV_BEGIN();
359 OBJ_SPEED(ACTOR_PARTY_LEADER, 0xcccc, 0x6666);
360 OBJ_SPEED(GARET, 0xcccc, 0x6666);
361 OBJ_SPEED(IVAN, 0xcccc, 0x6666);
362 OBJ_SPEED(MIA, 0xcccc, 0x6666);
364 partyActor = Actor_Get(ACTOR_PARTY_LEADER);
365 partyActor->facing = FACING_NORTH;
366 OBJ_POS_SET(GARET, 148, 90);
367 partyActor = Actor_Get(GARET);
368 partyActor->facing = FACING_NORTH;
369 OBJ_POS_SET(IVAN, 182, 90);
370 partyActor = Object_GetById(IVAN);
371 partyActor->facing = FACING_NORTH;
372 if (hasMia != 0) {
373 OBJ_POS_SET(MIA, 166, 104);
374 partyActor = Object_GetById(MIA);
375 partyActor->facing = FACING_NORTH;
376 }
378 Engine_TaskWait(10);
383 WAIT(20);
384 Camera_SetSpeed(0x13333, 0x2666);
385 Camera_MoveTo(PIXELS(168), -1, PIXELS(152), 1);
387 WAIT(10);
388 // Open the passage beside Tret before continuing the conversation.
389 openingColumn = 10;
391 Map_CopyCellAttributes(26, 3, 1, 2, openingColumn, 8);
392 Map_CopyCells(26, 38, 1, 1, openingColumn, 43);
394 Map_CopyCells(26, 37, 1, 2, openingColumn, 42);
396 Map_CopyCells(26, 36, 1, 3, openingColumn, 41);
398 Map_CopyCells(26, 35, 1, 4, openingColumn, 40);
399 Engine_TaskWait(80);
400 // Tret comes to: "Oh... Mmmmm... What has happened to me?"
401 MESSAGE_SET(MsgTretMmmmm);
407 WAIT(20);
408 Camera_MoveTo(PIXELS(168), -1, PIXELS(90), 1);
410 WAIT(40);
412 WAIT(60);
413 SE(MUS_021);
419 OBJ_EMOTE(IVAN, EMOTE_IN_FRONT | 1, 80);
421 WAIT(40);
427 WAIT(20);
430 WAIT(40);
436 WAIT(60);
437 // Garet and Ivan will not let Tret die while they still need his help.
447 WAIT(40);
457 // "Do you need something?" Answering no: "What are you doing, Isaac! Now's
458 // not the time to fool around!"
462 if (Engine_EventChooseYesNo(0, 0) != 0) {
465 MESSAGE_SET(MsgTretDoingNowsNot);
467 OBJ_EMOTE(IVAN, EMOTE_IN_FRONT | 3, 10);
470 }
471 WAIT(20);
473 MESSAGE_SET(MsgTretTurnedPeopleKolima);
477 WAIT(20);
478 // Tret tries to release the people of Kolima: the colours shift and sparks
479 // swirl out from his face, then fade.
480 ColorBuffer_ApplySource(0x10000, 0);
481 ColorBuffer_ApplyTarget(0x406218, 1);
483 Engine_TaskWait(40);
490 WAIT(20);
491 sSparkFrame = 0;
492 {
493 struct FieldPosition *origin = &sSparkOrigin;
494 origin->x = PIXELS(168);
495 origin->y = PIXELS(32);
497 origin->z = PIXELS(52);
498 }
500 WAIT(220);
501 Engine_TaskRemoveCallback(sparkTask);
502 ColorBuffer_ApplyTarget(0x10000, 1);
504 Engine_TaskWait(40);
506 WAIT(20);
507 // "I can't do it... My power no longer reaches Kolima..." His face sinks
508 // away on "People of Kolima... Forgive me...", and the party resolve to
509 // heal him.
514 WAIT(40);
517 OBJ_EMOTE(IVAN, EMOTE_IN_FRONT | 2, 10);
526 if (hasMia != 0) {
529 }
536 if (hasMia != 0) {
537 Actor_SetActionScript(MIA, actions);
538 }
540 WAIT(20);
544 EV_END();
545}
546
547/// Restores the post-battle map and optionally plays its conversation.
548static void TretTreeInteriors_ApplyPostBattleState(s32 playRecoveryScene) {
549 if (playRecoveryScene != 0 && FLAG_CHECK(FLAG_KEEP_PARTY_POSITION) == 0)
551
553 if (FLAG_CHECK(FLAG_TRET_DEFEATED) != 0) {
554 s32 openingColumn = 10;
555 Map_CopyCells(121, 34, 3, 1, 93, openingColumn);
556 {
557 s32 passageColumn = 30;
558 Map_CopyCells(46, 38, 1, 1, passageColumn, 43);
559 Map_CopyCellAttributes(0, 0, 1, 2, passageColumn, 9);
560 }
561 Map_CopyCellAttributes(26, 3, 1, 2, openingColumn, 8);
562 Map_CopyCells(26, 35, 1, 4, openingColumn, 40);
563 } else {
564 s32 openingColumn = 10;
565 s32 passageColumn = 8;
566 Map_CopyCellAttributes(11, 8, 1, 2, openingColumn, passageColumn);
567 }
568}
569
570/// Restores the room, tint and entry fall before continuing its story event.
572 struct FieldActor *tret;
573 struct FieldActor *actor;
574 struct MapScrollWork *mapWork;
575 struct MapLayerScroll *layer;
576 struct FieldWork *fieldWork;
577 s32 entrance;
578 s32 selectedActorId;
579
581 // Restore scene-local floor state and the saved palette first.
584 tret->motionFlags = 0;
585 tret->y.fixed = -PIXELS(10);
586 {
587 struct FieldActor *tretSpeaker = Object_GetById(ACTOR_TRET_SPEAKER);
588
589 tretSpeaker->motionFlags = 0;
590 tretSpeaker->y.fixed = -PIXELS(10);
591 }
594 if (gGameState.entrance != 19)
600 }
603 mapWork = WORK_SLOT(8);
604 // Match the first layer's parallax offset and scale to the room bounds.
605 layer = &mapWork->layers[0];
606 layer->offsetX += Iwram_MulQ16(mapWork->minX + PIXELS(160), 0x1999);
607 layer->offsetY += Iwram_MulQ16(mapWork->minY + PIXELS(136), 0x1999);
608 layer->scaleX = 0xe666;
609 layer->scaleY = 0xe666;
610 // Four floors start out cracked through: the first step on them gives way.
617 fieldWork = WORK_SLOT(HEAP_SLOT_EVENT);
619 entrance = gGameState.entrance;
620 selectedActorId = gGameState.selectedActor;
621 actor = Object_GetById(selectedActorId);
622 // Entrances 20, 30, 40 and 50: the leader falls on through the floor, to
623 // the entrance numbered ten lower. Entrance 10: the leader lands in a cloud
624 // of dust.
625 // Entrance 19: back from the battle with Tret.
626 if (entrance == 50 || entrance == 40 || entrance == 30 || entrance == 20) {
628 OBJ_MODE(selectedActorId, 27);
629 Engine_ActorSetSpriteFlags(Object_GetById(selectedActorId), 0);
630 Actor_SetAttachedEffect(selectedActorId, 0x101);
631 Camera_MoveTo(-1, -1, -1, 0);
632 actor->motionFlags = ACTOR_FALLS;
633 actor->y.fixed = PIXELS(100);
634 actor->terrainHeight = -PIXELS(160);
635 actor->gravity = 0x8000;
636 SE(SE_204);
638 WAIT(20);
639 actor->terrainId = 2;
640 Engine_ActorSetSpritePriority(selectedActorId, 3);
641 WAIT(2);
642 Engine_ActorSetAttachedEffect(selectedActorId, 0x100);
643 WAIT(8);
644 } else if (entrance == 10) {
647 } else if (entrance == 19) {
649 }
650 return 0;
651}
652
653/// Saves background palettes 0 to 13 as the base for Tret's scene tint.
656 (DMA_ENABLE | DMA_32BIT) << 16 | 112, REG_DMA3);
657}
658
659/// Tints background colours 16 to 78 every thirty-two frames, leaving
660/// palette 4's last colour alone. Each later palette receives a weaker tint.
662 u16 *sourceColors;
663 u16 *destinationColors;
664 u32 colorIndex;
665 s32 redStep;
666 s32 greenStep;
667 s32 blueStep;
668 s32 red;
669 s32 green;
670 s32 blue;
671 u32 color;
672 struct FieldWork *fieldWork;
673 struct BattleEffectBuffers *paletteWork;
674
675 fieldWork = WORK_SLOT(HEAP_SLOT_EVENT);
676 paletteWork = WORK_SLOT(32);
677 sourceColors = paletteWork->palette;
678 if (fieldWork->command != 0)
679 return;
680 if ((gFrameCount & 31) != 0)
681 return;
682 sourceColors += 16;
683 destinationColors = (u16 *)0x05000020;
684 colorIndex = 0;
685 for (; colorIndex < TRET_TINT_COLOR_COUNT; colorIndex++, sourceColors++) {
689 if (colorIndex > 47) {
690 redStep -= redStep / 2 + redStep / 3;
691 greenStep -= greenStep / 2 + greenStep / 3;
692 blueStep -= blueStep / 2 + blueStep / 3;
693 } else if (colorIndex > 31) {
694 redStep -= redStep / 3 + redStep / 4;
695 greenStep -= greenStep / 3 + greenStep / 4;
696 blueStep -= blueStep / 3 + blueStep / 4;
697 } else if (colorIndex > 15) {
698 redStep -= redStep / 4 + redStep / 5;
699 greenStep -= greenStep / 4 + greenStep / 5;
700 blueStep -= blueStep / 4 + blueStep / 5;
701 }
702 color = *sourceColors;
703 red = color & 31;
704 green = (color >> 5) & 31;
705 blue = (color >> 10) & 31;
706 red += redStep;
707 green += greenStep;
708 blue += blueStep;
709 if (red > TRET_TINT_CHANNEL_MAX)
711 if (green > TRET_TINT_CHANNEL_MAX)
712 green = TRET_TINT_CHANNEL_MAX;
713 if (blue > TRET_TINT_CHANNEL_MAX)
715 if (red < 0)
716 red = 0;
717 if (green < 0)
718 green = 0;
719 if (blue < 0)
720 blue = 0;
721 *destinationColors++ = (blue << 10) | (green << 5) | red;
722 }
727}
728
729/// Plays a Tret animation sequence with its original pauses.
730static void TretTreeInteriors_PlayGesture(s32 gesture) {
731 switch (gesture) {
732 case 0:
736 break;
737 case 1:
739 break;
740 case 2:
744 break;
745 case 3:
749 break;
750 case 4:
760 break;
761 case 5:
765 break;
766 case 7:
770 break;
771 case 8:
773 break;
774 case 9:
778 break;
779 case 10:
782 OBJ_MODE(ACTOR_TRET, 10);
783 break;
784 case 11:
794 break;
795 case 12:
797 break;
798 }
799 Engine_TaskWait(12);
800}
801
802/// Moves a fading spark outward from its saved origin, then releases it.
803static void TretTreeInteriors_UpdateSwirlSpark(union FieldObject *fieldObject) {
804 struct FieldActor *spark = (struct FieldActor *)fieldObject;
805 struct FieldPosition position;
806 s32 frame;
807
808 frame = spark->timer;
809 if (frame <= SWIRL_SPARK_LAST_FRAME) {
810 position.x = spark->targetX;
811 position.y = spark->targetY;
812 position.z = spark->targetZ;
813 {
814 s32 initialAngle = (s16)spark->work;
815
816 Vector_AddPolarOffset(frame << 16, ((frame * 3) << 8) + initialAngle,
817 &position);
818 }
819 spark->x.fixed = position.x;
820 spark->y.fixed = position.y;
821 spark->z.fixed = position.z;
822 if (spark->timer <= SWIRL_SPARK_SHRINK_LAST_FRAME) {
823 spark->scaleX += -0x51e;
824 spark->scaleY += -0x51e;
825 }
826 spark->timer++;
827 } else {
828 Resource_ResetEntry(spark->sprite->slot);
830 }
831}
832
833/// Emits five shrinking waves of fading sparks from the saved origin.
835 struct FieldActor *spark;
836 u32 frame;
837 void *previousResourceEntry;
838 s32 wave;
839 u32 sparkIndex;
840 s32 *counter;
841
842 counter = &sSparkFrame;
843 frame = *counter;
844 previousResourceEntry = 0;
845 /* FAKEMATCH: the explicit libgcc call keeps the final count's reload in r3;
846 * as (s32)frame / 10, 6 instructions differ in tbs-en. */
847 wave = __divsi3(frame, 10);
848 switch (frame) {
849 case 0:
850 case 10:
851 case 20:
852 case 30:
853 case 40:
854 SE(SE_220);
855 // Waves contain 6, 5, 4, 3 and 2 sparks. Divide degrees before
856 // converting them to turns, preserving the original rounding.
857 for (sparkIndex = 0; sparkIndex < 6 - wave; sparkIndex++) {
860 if (spark != 0) {
861 previousResourceEntry =
862 Sprite_ShareVramCache(spark->sprite, previousResourceEntry);
863 spark->motionFlags = 0;
864 spark->sprite->image.priority = 0;
866 Object_SetMode(spark, 1);
867 spark->timer = 0;
868 spark->work = ((360 / (u32)(6 - wave) * sparkIndex) << 16) / 360;
869 spark->targetX = sSparkOrigin.x;
870 spark->targetY = sSparkOrigin.y;
871 spark->targetZ = sSparkOrigin.z;
872 spark->speed = 0x19999;
874 }
875 }
876 // Each wave also plays the closing sound.
877 // fall through
878 case 44:
879 SE(SE_289);
880 /* FAKEMATCH: the counter pointer is taken again here so it is dead across
881 * the spark loop, which frees its register for the loop index; without
882 * it, 36 instructions differ in tbs-en. */
883 counter = &sSparkFrame;
884 break;
885 }
886 if (++*counter > 120) {
887 *counter = 0;
888 }
889}
890
891/// Restores each enabled single-cell patch whose puzzle flag is set.
893 s32 patchOffset;
894
895 for (patchOffset = 0; gTretTreeInteriors_MapPatches[patchOffset] != -1;
896 patchOffset += 6) {
897 if (FLAG_CHECK(gTretTreeInteriors_MapPatches[patchOffset]) &&
898 gTretTreeInteriors_MapPatches[patchOffset + 1] != 0)
900 gTretTreeInteriors_MapPatches[patchOffset + 3],
901 gTretTreeInteriors_MapPatches[patchOffset + 4],
902 gTretTreeInteriors_MapPatches[patchOffset + 5], 1, 1);
903 }
904}
905
906/// Stops the scene tint while Reveal is active.
907static void Event_CastReveal(void) {
909}
910
912
913/// Drops the leader into the room with a ring of landing particles.
915 struct EffectOptions options;
916 struct FieldPosition velocity;
917 struct EffectOptions *particleOptions;
918 struct FieldPosition *particleVelocity;
919 struct FieldActor *leader;
920 u32 particleIndex;
923
924 EV_BEGIN();
925 Camera_MoveTo(-1, -1, -1, 0);
934 SE(SE_204);
937 WAIT(24);
939 // Spread particles around the leader while the landing effect finishes.
940 particleOptions = &options;
941 particleOptions->palette = 7;
942 particleOptions->update = Effect_AdvanceMotion;
943 particleOptions->startScaleX = 0xcccc;
944 particleOptions->startScaleY = 0xcccc;
945 for (particleIndex = 0; particleIndex <= 16; particleIndex++) {
946 particleVelocity = &velocity;
947 particleVelocity->x = Engine_MathCos(particleIndex << 12);
948 particleVelocity->y = 0;
949 velocityZ = Engine_MathSin(particleIndex << 12);
950 velocityX = particleVelocity->x;
951 particleVelocity->z = velocityZ;
952 velocityX += velocityX / 2;
953 particleVelocity->x = velocityX;
954 Effect_Spawn(leader->x.fixed, leader->y.fixed, leader->z.fixed, velocityX,
955 particleVelocity->y, velocityZ,
958 particleOptions);
959 }
960 SE(SE_188);
963 Map_SetShake(0x50000, 0x50000, 0x10000);
964 Map_SetShake(-1, -1, 0xe666);
969 EV_END();
970}
971
973 SC_WAIT(1), SC_LOOP(22, SC_TOP), SC_WAIT(1),
974 SC_POS(0, 0, 0), SC_WAIT(1), SC_FREE,
975};
976
978 SC_WAIT(1), SC_LOOP(44, SC_TOP), SC_WAIT(1),
979 SC_POS(0, 0, 0), SC_WAIT(1), SC_FREE,
980};
981
983 SC_WAIT(1), SC_LOOP(126, SC_TOP), SC_WAIT(1),
984 SC_POS(0, 0, 0), SC_WAIT(1), SC_FREE,
985};
986
987/// The cracked floors redrawn when the room is restored: floor flag, whether
988/// it is redrawn (not the four that start cracked), source cell x/y,
989/// destination cell x/y.
990// clang-format off
992 FLAG_SCENE_TEMP_00, 1, 64, 35, 113, 6,
993 FLAG_SCENE_TEMP_01, 0, 65, 35, 115, 6,
994 FLAG_SCENE_TEMP_02, 1, 66, 35, 110, 8,
995 FLAG_SCENE_TEMP_03, 1, 67, 35, 110, 10,
996 FLAG_SCENE_TEMP_04, 1, 68, 35, 111, 12,
997 FLAG_SCENE_TEMP_05, 1, 69, 35, 113, 12,
998 FLAG_SCENE_TEMP_06, 1, 70, 35, 112, 14,
999 FLAG_SCENE_TEMP_07, 1, 71, 35, 114, 14,
1000 FLAG_SCENE_TEMP_08, 1, 72, 35, 116, 14,
1001 FLAG_SCENE_TEMP_09, 1, 73, 35, 71, 23,
1002 FLAG_SCENE_TEMP_0A, 1, 74, 35, 77, 24,
1003 FLAG_SCENE_TEMP_0C, 1, 75, 35, 112, 24,
1004 FLAG_SCENE_TEMP_0D, 0, 76, 35, 114, 24,
1005 FLAG_SCENE_TEMP_0E, 1, 77, 35, 116, 24,
1006 FLAG_SCENE_TEMP_0F, 0, 78, 35, 112, 26,
1007 FLAG_SCENE_TEMP_0B, 1, 79, 35, 114, 26,
1008 FLAG_SCENE_TEMP_10, 1, 80, 35, 116, 26,
1009 FLAG_SCENE_TEMP_11, 1, 81, 35, 112, 28,
1010 FLAG_SCENE_TEMP_12, 1, 82, 35, 114, 28,
1011 FLAG_SCENE_TEMP_13, 0, 83, 35, 116, 28,
1012 FLAG_SCENE_TEMP_14, 1, 84, 35, 118, 28,
1013 -1, 0,
1014};
1015
1020};
1021
1023 SC_ARG(2),
1024 SC_MOVE(PIXELS(166), 0, PIXELS(80)),
1025 SC_SYNC,
1026 SC_ARG(1),
1027 SC_END,
1028};
1029
1031 SC_ARG(2),
1032 SC_MOVE(PIXELS(148), 0, PIXELS(90)),
1033 SC_SYNC,
1034 SC_ARG(1),
1035 SC_END,
1036};
1037
1039 SC_ARG(2),
1040 SC_MOVE(PIXELS(182), 0, PIXELS(90)),
1041 SC_SYNC,
1042 SC_ARG(1),
1043 SC_END,
1044};
1045
1047 SC_ARG(2),
1048 SC_MOVE(PIXELS(166), 0, PIXELS(104)),
1049 SC_SYNC,
1050 SC_ARG(1),
1051 SC_END,
1052};
1053
1055 SC_SET(SW_MOTION, 0),
1056 SC_ADD(SW_Y, PIXELS(80)),
1057 SC_WAIT(4),
1058 SC_ADD(SW_Y, -PIXELS(78)),
1059 SC_ADD(SW_SCALE_X, -0x1000),
1060 SC_ADD(SW_SCALE_Y, -0x1000),
1061 SC_WAIT(4),
1062 SC_LOOP(8, SC_TOP),
1063 SC_POS(0, 0, 0),
1064 SC_WAIT(1),
1065 SC_END,
1066};
1067
1069 SC_ARG(2),
1070 SC_MOVE(PIXELS(166), 0, PIXELS(80)),
1071 SC_SYNC,
1072 SC_POS(0, 0, 0),
1073 SC_WAIT(1),
1074 SC_END,
1075};
1076
1078 0, 0, 0, 0, 0, 0, 0, 0,
1079 0, 0, 0, 0, 0, 0, 0, 0,
1080 0, 0, 0, 0, 0, 0, 0, 0,
1081 1, 0, 0, 1, 0, 0, 1, 0,
1082 0, 1, 0, 0, 1, 0, 0, 1,
1083 0, 0, 1, 0, 0, 1, 1, 0,
1084 1, 1, 0, 1, 1, 0, 1, 1,
1085 0, 1, 1, 0, 1, 1, 0, 1,
1086 1, 1, 1, 1, 1, 1, 1, 1,
1087 1, 1, 1, 1, 1, 1, 2, 1,
1088 1, 2, 1, 1, 2, 1, 1, 2,
1089 1, 1, 2, 2, 1, 2, 2, 1,
1090 2, 2, 2, 3, 2, 2, 3, 2,
1091 2, 3, 3, 2, 3, 3, 2, 3,
1092 3, 2, 3, 3, 2, 3, 3, 3,
1093 3, 3, 3, 3, 3, 3, 3, 3,
1094 3, 3, 3, 3, 4, 3, 3, 4,
1095 3, 3, 4, 3, 3, 4, 3, 3,
1096 4, 3, 3, 4, 3, 3, 4, 4,
1097 3, 4, 4, 3, 4, 4, 3, 4,
1098 4, 3, 4, 4, 3, 4, 4, 3,
1099 4, 4, 3, 4, 4, 3, 4, 4,
1100 3, 4, 4, 3, 4, 4, 4, 4,
1101 4, 4, 4, 4, 4, 4, 4, 4,
1102 4, 4, 4, 4, 4, 4, 4, 4,
1103 4, 4, 4, 4, 4, 4, 4, 4,
1104 4, 4, 4, 4, 4, 4, 4, 4,
1105 4, 4, 3, 4, 4, 3, 4, 4,
1106 3, 4, 4, 3, 4, 4, 3, 4,
1107 4, 3, 4, 4, 3, 4, 4, 3,
1108 4, 4, 3, 4, 4, 3, 4, 3,
1109 3, 4, 3, 3, 4, 3, 3, 4,
1110 3, 3, 4, 3, 3, 4, 3, 3,
1111 3, 3, 3, 3, 3, 3, 3, 3,
1112 3, 3, 3, 3, 3, 3, 3, 3,
1113 3, 2, 3, 3, 2, 3, 3, 2,
1114 3, 3, 2, 3, 2, 2, 3, 2,
1115 2, 2, 2, 2, 2, 2, 1, 2,
1116 2, 1, 2, 1, 1, 2, 1, 1,
1117 2, 1, 1, 2, 1, 1, 1, 1,
1118 1, 1, 1, 1, 1, 1, 1, 1,
1119 1, 1, 1, 1, 1, 1, 1, 0,
1120 1, 1, 0, 1, 1, 0, 1, 1,
1121 0, 1, 1, 0, 1, 1, 0, 1,
1122 0, 0, 1, 0, 0, 1, 0, 0,
1123 1, 0, 0, 1, 0, 0, 1, 0,
1124 0, 1, 0, 0, 99, 99, 99, 99,
1125 99, 99, 99, 99, 99, 99, 99, 99,
1126 99, 99, 99, 99, 99, 99, 99, 99,
1127 99, 99, 99, 99, 99, 99, 99, 99,
1128 99, 99, 99, 99, 99, 99, 99, 99,
1129 99, 99, 99, 99, 99, 99, 99, 99,
1130 99, 99, 99, 99, 99, 99, 99, 99,
1131 99, 99, 99, 99, 99, 99, 99, 99,
1132 99, 99, 99,
1133};
1134
1136 { 0, CONDITION_ALWAYS, 136, 0, 136, FACING_SOUTH, 0, -1, -1, -1, -1, 0 },
1137 { 1, CONDITION_ALWAYS, 488, 0, 248, FACING_NORTH, 0, 352, 0, 640, 272, 0 },
1138 { 2, CONDITION_ALWAYS, 712, 0, 152, FACING_EAST, 0, 672, 0, 944, 272, 0 },
1139 { 3, CONDITION_ALWAYS, 920, 0, 152, FACING_WEST, 0, 672, 0, 944, 272, 0 },
1140 { 4, CONDITION_ALWAYS, 168, 0, 520, FACING_NORTH, 0, 32, 272, 304, 544, 0 },
1141 { 5, CONDITION_ALWAYS, 296, 0, 424, FACING_WEST, 0, 32, 272, 304, 544, 0 },
1142 { 6, CONDITION_ALWAYS, 376, 0, 424, FACING_EAST, 0, 352, 272, 640, 544, 0 },
1143 { 7, CONDITION_ALWAYS, 488, 0, 520, FACING_NORTH, 0, 352, 272, 640, 544, 0 },
1144 { 8, CONDITION_ALWAYS, 712, 0, 424, FACING_EAST, 0, 672, 272, 960, 544, 0 },
1145 { 9, CONDITION_ALWAYS, 920, 0, 424, FACING_WEST, 0, 672, 272, 960, 544, 0 },
1146 { 10, CONDITION_ALWAYS, 168, 0, 152, FACING_SOUTH, 0, 32, 0, 304, 272, 0 },
1147 { 11, CONDITION_ALWAYS, 424, 24, 72, FACING_SOUTH, 0, 352, 0, 640, 272, 0 },
1148 { 12, CONDITION_ALWAYS, 744, 0, 88, FACING_SOUTH, 0, 672, 0, 944, 272, 0 },
1149 { 13, CONDITION_ALWAYS, 232, 24, 344, FACING_SOUTH, 0, 32, 272, 304, 544, 0 },
1150 { 14, CONDITION_ALWAYS, 552, 0, 360, FACING_SOUTH, 0, 352, 272, 640, 544, 0 },
1151 { 15, CONDITION_ALWAYS, 168, 24, 152, FACING_SOUTH, 0, 32, 0, 304, 272, 0 },
1152 { 16, CONDITION_ALWAYS, 488, 0, 168, FACING_SOUTH, 0, 352, 0, 640, 272, 0 },
1153 { 21, CONDITION_ALWAYS, 472, 0, 104, FACING_SOUTH, 0, 352, 0, 640, 272, 0 },
1154 { 22, CONDITION_ALWAYS, 504, 0, 104, FACING_SOUTH, 0, 352, 0, 640, 272, 0 },
1155 { 23, CONDITION_ALWAYS, 424, 0, 136, FACING_SOUTH, 0, 352, 0, 640, 272, 0 },
1156 { 24, CONDITION_ALWAYS, 424, 0, 168, FACING_SOUTH, 0, 352, 0, 640, 272, 0 },
1157 { 25, CONDITION_ALWAYS, 440, 0, 200, FACING_SOUTH, 0, 352, 0, 640, 272, 0 },
1158 { 26, CONDITION_ALWAYS, 488, 0, 200, FACING_SOUTH, 0, 352, 0, 640, 272, 0 },
1159 { 27, CONDITION_ALWAYS, 456, 0, 232, FACING_SOUTH, 0, 352, 0, 640, 272, 0 },
1160 { 28, CONDITION_ALWAYS, 488, 0, 232, FACING_SOUTH, 0, 352, 0, 640, 272, 0 },
1161 { 29, CONDITION_ALWAYS, 520, 0, 232, FACING_SOUTH, 0, 352, 0, 640, 272, 0 },
1162 { 31, CONDITION_ALWAYS, 760, 0, 104, FACING_SOUTH, 0, 672, 0, 944, 272, 0 },
1163 { 32, CONDITION_ALWAYS, 856, 0, 120, FACING_SOUTH, 0, 672, 0, 944, 272, 0 },
1164 { 51, CONDITION_ALWAYS, 456, 0, 392, FACING_SOUTH, 0, 352, 272, 640, 544, 0 },
1165 { 52, CONDITION_ALWAYS, 488, 0, 392, FACING_SOUTH, 0, 352, 272, 640, 544, 0 },
1166 { 53, CONDITION_ALWAYS, 520, 0, 392, FACING_SOUTH, 0, 352, 272, 640, 544, 0 },
1167 { 54, CONDITION_ALWAYS, 456, 0, 424, FACING_SOUTH, 0, 352, 272, 640, 544, 0 },
1168 { 55, CONDITION_ALWAYS, 520, 0, 424, FACING_SOUTH, 0, 352, 272, 640, 544, 0 },
1169 { 56, CONDITION_ALWAYS, 456, 0, 424, FACING_SOUTH, 0, 352, 272, 640, 544, 0 },
1170 { 57, CONDITION_ALWAYS, 488, 0, 456, FACING_SOUTH, 0, 352, 272, 640, 544, 0 },
1171 { 58, CONDITION_ALWAYS, 520, 0, 456, FACING_SOUTH, 0, 352, 272, 640, 544, 0 },
1172 { 59, CONDITION_ALWAYS, 552, 0, 456, FACING_SOUTH, 0, 352, 272, 640, 544, 0 },
1173 { 50, CONDITION_ALWAYS, 488, 0, 424, FACING_SOUTH, 0, 352, 272, 640, 544, 0 },
1174 { 40, CONDITION_ALWAYS, 168, 0, 424, FACING_SOUTH, 0, 32, 272, 304, 544, 0 },
1175 { 30, CONDITION_ALWAYS, 808, 0, 152, FACING_SOUTH, 0, 672, 0, 944, 272, 0 },
1176 { 20, CONDITION_ALWAYS, 488, 0, 152, FACING_SOUTH, 0, 352, 0, 640, 272, 0 },
1177 { 19, CONDITION_ALWAYS, 168, 0, 72, FACING_SOUTH, 0, 32, 0, 304, 272, 0 },
1178 { SCENE_TABLE_END },
1179};
1180
1182 { 420, 28, 68, 428, 36, 76, -1, 10 },
1183 { 228, 28, 338, 236, 36, 346, -1, 12 },
1184#if !TBS_PATCH_3
1185 { 163, 28, 148, 171, 36, 156, -1, 14 },
1186#else
1187 { 159, 24, 144, 175, 40, 160, -1, 14 },
1188#endif
1189 { -1, 0, 0, 0, 0, 0, 0, 0 },
1190};
1191
1193 SCENE_EXITS(45),
1194 SCENE_EXIT(1, 44, 2),
1195 SCENE_EXIT(2, 46, 1),
1196 SCENE_EXIT(3, 46, 2),
1197 SCENE_EXIT(4, 46, 3),
1198 SCENE_EXIT(5, 46, 4),
1199 SCENE_EXIT(6, 46, 6),
1200 SCENE_EXIT(7, 46, 5),
1201 SCENE_EXIT(8, 46, 7),
1202 SCENE_EXIT(9, 46, 8),
1203 SCENE_EXIT(10, 45, 12),
1204 SCENE_EXIT(11, 45, 11),
1205 SCENE_EXIT(12, 45, 14),
1206 SCENE_EXIT(13, 45, 13),
1207 SCENE_EXIT(14, 45, 16),
1208 SCENE_EXIT(15, 45, 15),
1210};
1211
1214 0, 0, 0, FACING_EAST, TALK_KEEP_FACING, 0 },
1216 0, 0, 0, FACING_EAST, TALK_KEEP_FACING, 0 },
1218 0, 0, 0, FACING_EAST, TALK_KEEP_FACING, 0 },
1219 { 0x37, CONDITION_ALWAYS, 7,
1220 PIXELS(168), 0, PIXELS(48), FACING_SOUTH, TALK_KEEP_FACING, 0 },
1221 { 0x47, CONDITION_ALWAYS, 7,
1222 PIXELS(168), 0, PIXELS(48), FACING_SOUTH, TALK_KEEP_FACING, 0 },
1223 { SCENE_TABLE_END },
1224};
1225// clang-format on
1226
1228 {0x4401, 1, CONDITION_ALWAYS, 1},
1229 {0x8401, 2, CONDITION_ALWAYS, 2},
1230 {0x401, 3, CONDITION_ALWAYS, 3},
1231 {0x4401, 4, CONDITION_ALWAYS, 4},
1232 {0x401, 5, CONDITION_ALWAYS, 5},
1233 {0x8401, 6, CONDITION_ALWAYS, 6},
1234 {0x4401, 7, CONDITION_ALWAYS, 7},
1235 {0x8401, 8, CONDITION_ALWAYS, 8},
1236 {0x401, 9, CONDITION_ALWAYS, 9},
1237 {EVENT_EXIT, 11, CONDITION_ALWAYS, 11},
1238 {EVENT_EXIT, 13, CONDITION_ALWAYS, 13},
1239 {EVENT_EXIT, 15, CONDITION_ALWAYS, 15},
1328 {SEARCH(SEARCH_CHEST), 101, 0xf5c, FIND_ITEM(ITEM_NUT)},
1331};
1332
Ability numbers, named from the English release.
@ ABILITY_REVEAL
Definition ability_ids.h:19
struct FieldActor * Object_GetById(s32 actor)
Returns an actor, or NULL if it does not exist.
const struct ScenePlacement * Scene_GetPlacements(void)
const struct SceneEntrance * Scene_GetEntrances(void)
const struct SceneEvent * Scene_GetEvents(void)
const u32 * Scene_GetExits(void)
Both scenes share one exit table.
const struct SceneRegion * Scene_GetRegions(void)
s32 gEffectScript0[]
const s32 * gEffectScripts[]
s32 gEffectScript1[]
s32 gEffectScript2[]
The battle animation state, render objects and effect entries, and the palette buffer work.
struct BattleEffectBuffers * gPaletteBufferWork
void(*) SchedulerCallback(void)
Character numbers, with each character's Japanese name.
#define GARET
Jerald.
#define MIA
Mary.
#define IVAN
Ivan.
s32 __divsi3(s32, s32)
The sprite and effect views and the options a scene's configured effect spawner uses.
The engine calls a scene uses to create an overlay object and set its sprite flags.
void Engine_ActorSetSpriteFlags(struct FieldActor *, s32)
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.
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
static s32 FieldScheduler_AddCallback(SchedulerCallback callback, s32 priority)
Registers a main-image scheduler callback.
Definition engine_call.h:36
Scene commands: the all-caps macros the scene scripts are written in.
#define EV_BEGIN()
Definition event.h:30
#define OBJ_DIR(no, d, t)
Definition event.h:16
#define OBJ_POS_SET(no, x, z)
Definition event.h:13
#define EV_END()
Definition event.h:31
#define WAIT(n)
Definition event.h:7
#define OBJ_MODE(no, m)
Definition event.h:18
#define MESSAGE_PUT(no, f)
Definition event.h:10
#define MESSAGE_SET(m)
Definition event.h:9
#define SE(n)
Definition event.h:28
#define FLAG_SET(f)
Definition event.h:26
#define FLAG_CHECK(f)
Definition event.h:25
#define OBJ_EMOTE(no, e, t)
Definition event.h:19
#define OBJ_SPEED(no, s, a)
Definition event.h:15
Field effects, their scripts and the flags that spawn them.
@ EFFECT_USE_PALETTE
options.palette, as its group child value
@ EFFECT_USE_UPDATE
options.update
@ EFFECT_USE_START_SCALE
options.startScaleX and startScaleY
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 s32 Event_OpenMessage(s32 speaker, s32 flags)
s32 Engine_LeaderCheckAhead(void)
void Engine_ActorSetAnimationAndWait(s32 actor, s32 animation)
void Object_SetMode(struct FieldActor *object, s32 animation)
void Engine_ActorSetSpritePriority(s32 actor, s32 priority)
static void Event_ShowMessageAndWait(s32 speaker, s32 flags, s32 frames)
s32 Engine_EventChooseYesNo(s32 actor, s32 flags)
void Engine_EventShowMessageAndWait(s32 speaker, s32 flags, s32 frames)
static void Camera_SetSpeed(s32 speed, s32 acceleration)
s32 Engine_TaskRemoveCallback(void(*callback)(void))
#define EMOTE_IN_FRONT
Definition field_event.h:49
s32 Engine_MathSin(s32 angle)
void Engine_ObjectDispatchRelease(struct FieldActor *object)
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)
static void ColorBuffer_ApplyTarget(s32 value, s32 mode)
void Engine_EventWaitForScreen(void)
void Engine_EventOpenScreen(void)
void Engine_MapWaitWorkValuesBelow256(void)
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.
static void Map_CopyCellAttributes(s32 srcX, s32 srcY, s32 width, s32 height, s32 destX, s32 destY)
void Engine_ActorRunRepeatedMotion(s32 actor, s32 repeats)
static void Event_ShowMessage(s32 speaker, s32 flags)
void Engine_ActorSetAttachedEffect(s32 actor, s32 effect)
s32 Engine_RandomNext()
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.
u8 gSceneState[]
void Engine_ActorStartRepeatedMotion(s32 actor, s32 repeats)
s32 Engine_MathCos(s32 angle)
@ TASK_PRIORITY_SCENE
Definition field_event.h:40
void Engine_MapRedraw(void)
void Engine_ColorBufferInterpolate(s32 frames)
static void Camera_MoveTo(s32 fixed_x, s32 fixed_y, s32 fixed_z, s32 pan)
static void Actor_SetAttachedEffect(s32 actor, s32 effect)
static struct FieldActor * Actor_Get(s32 actor)
static void ColorBuffer_ApplySource(s32 value, s32 mode)
Field objects and actors, and the scene transition styles.
@ TRANSITION_WINDOW
Definition field_obj.h:17
@ TRANSITION_BACKDROP_FADE
Definition field_obj.h:16
@ ACTOR_PRIORITY_AUTOMATIC
The sprite takes its priority from the map cell under it.
Definition field_obj.h:153
@ ACTOR_FOLLOWS_TERRAIN
moves with the ground height under it
Definition field_obj.h:160
@ ACTOR_FALLS
falls by its gravity and bounces
Definition field_obj.h:161
#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
#define FIND_ITEM(item)
@ EVENT_TOUCH
@ EVENT_EXIT
@ FACING_STEP
Definition field_scene.h:36
#define SCENE_EXITS(scene)
Definition field_scene.h:72
#define PSYNERGY_IN_AREA(ability, phase)
#define FIND_PSYNERGY_STONE
#define SCENE_EXIT(exit, scene, entrance)
Definition field_scene.h:73
@ ACTOR_FIRST_PLACED
@ ACTOR_PARTY_LEADER
@ SCENE_TABLE_END
Definition field_scene.h:43
@ CONDITION_ALWAYS
Definition field_scene.h:44
@ TALK_KEEP_FACING
#define EVENT_SCRIPT(script)
#define EVENT_TOUCH_WALKING
@ ACTOR_STAND
#define SEARCH(target)
#define SCENE_EXITS_END
Definition field_scene.h:77
@ FACING_NORTHEAST
Definition field_scene.h:33
@ FACING_EAST
Definition field_scene.h:26
@ FACING_SOUTHEAST
Definition field_scene.h:27
@ FACING_NORTH
Definition field_scene.h:32
@ FACING_SOUTHWEST
Definition field_scene.h:29
@ FACING_NORTHWEST
Definition field_scene.h:31
@ FACING_SOUTH
Definition field_scene.h:28
@ FACING_WEST
Definition field_scene.h:30
#define PIXELS(value)
@ SEARCH_UNNAMED
@ SEARCH_CHEST
The scene service layer: one typed inline for each engine service a scene calls by its own name,...
static s32 Task_AddCallback(void(*callback)(void), s32 priority)
Calls the main-image scheduler through engine_call.h.
Game flags, named where their meaning is shown.
#define FLAG_SCENE_TEMP_05
Definition flags.h:718
#define FLAG_SCENE_TEMP_0D
Definition flags.h:726
#define FLAG_SCENE_TEMP_0F
Definition flags.h:728
#define FLAG_SCENE_TEMP_12
Definition flags.h:731
#define FLAG_SCENE_TEMP_03
Definition flags.h:716
#define FLAG_SCENE_TEMP_13
Definition flags.h:732
#define FLAG_SCENE_TEMP_09
Definition flags.h:722
#define FLAG_SCENE_TEMP_0E
Definition flags.h:727
#define FLAG_IN_PARTY(character)
Flags 0 to 7: the character with that id (character_ids.h) is in the party (Party_AddActiveOwner).
Definition flags.h:9
#define FLAG_SCENE_TEMP_0A
Definition flags.h:723
#define FLAG_SCENE_TEMP_00
Definition flags.h:713
#define FLAG_SCENE_TEMP_08
Definition flags.h:721
#define FLAG_SCENE_TEMP_0B
Definition flags.h:724
#define FLAG_SCENE_TEMP_06
Definition flags.h:719
#define FLAG_SCENE_TEMP_0C
Definition flags.h:725
#define FLAG_SCENE_TEMP_02
Definition flags.h:715
#define FLAG_SCENE_TEMP_11
Definition flags.h:730
#define FLAG_KEEP_PARTY_POSITION
Definition flags.h:93
#define FLAG_SCENE_TEMP_10
Definition flags.h:729
#define FLAG_SCENE_TEMP_01
Definition flags.h:714
#define FLAG_SCENE_TEMP_04
Definition flags.h:717
#define FLAG_TRET_DEFEATED
Definition flags.h:102
#define FLAG_SCENE_TEMP_07
Definition flags.h:720
#define FLAG_SCENE_TEMP_14
Definition flags.h:733
volatile u32 gFrameCount
Frames WaitFrames has finished.
GameState, the game's state: play time, coins, the scene and the leader's position,...
#define Battle_SetStart(mode)
Sets the battle start type.
Definition game_state.h:164
struct GameState gGameState
The work slots of gWorkSlot, read through their own names.
The screen blend's globals and the graphics routines.
The heap's work slots and HeapState.
@ HEAP_SLOT_EVENT
Definition heap_state.h:40
#define WORK_SLOT(n)
Reads slots through their own addresses; adjacent slots are reached by offsets.
Definition heap_state.h:14
s32 PartyInventory_FindOwner(s32 itemId)
Returns who carries itemId, asking the selected character first, or -1.
Definition inventory.c:229
The hardware's I/O registers and their bits, as pret names them.
#define DMA_32BIT
Definition io_reg.h:210
#define REG_DMA3
Definition io_reg.h:153
#define BG_PLTT
Definition io_reg.h:157
#define DMA_ENABLE
Definition io_reg.h:217
Item numbers, named from the English release.
@ ITEM_HERMES_WATER
Definition item_ids.h:44
@ ITEM_HEALING_RING
Definition item_ids.h:84
@ ITEM_NUT
Definition item_ids.h:41
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
@ ACTOR_TRET
The map layers' scroll work and the background scroll values.
void Vector_AddPolarOffset(s32 radius, s32 angle, void *position)
Moves the point position by radius in direction angle on the ground plane: x by the cosine,...
Definition math.c:23
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_LOOP(n, to)
Repeat up to n times.
Definition objcmd.h:28
#define SC_POS(x, y, z)
Set position.
Definition objcmd.h:18
#define SC_FREE
Release.
Definition objcmd.h:43
#define SC_SYNC
Wait for arrival.
Definition objcmd.h:17
#define SC_ADD(w, v)
Definition objcmd.h:38
#define SC_ARG(v)
Definition objcmd.h:44
#define SC_MOVE(x, y, z)
Move toward the target.
Definition objcmd.h:19
#define SC_WAIT(n)
Wait n frames.
Definition objcmd.h:16
#define SC_TOP
Script start.
Definition objcmd.h:13
#define SC_END
Return to the main script.
Definition objcmd.h:32
@ SW_SCALE_Y
Definition objcmd.h:63
@ SW_MOTION
Definition objcmd.h:75
@ SW_Y
Definition objcmd.h:59
@ SW_SCALE_X
Definition objcmd.h:62
struct AnimationObject * Sprite_ShareVramCache(struct AnimationObject *sourceSprite, struct AnimationObject *sharedSprite)
Makes sourceSprite share sharedSprite's VRAM block, releasing its own; with no sharedSprite it keeps ...
Definition dispatch.c:346
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
void Field_RequestBattleFromEncounterTable(s32 zoneNo, s32 slotNo)
Sets up a battle with enemy group slot of encounter table zone.
Definition requests.c:14
void Event_SetNextDestination(s32 scene, s32 entrance)
Sets the scene and entrance that the field goes to next (gGameState.nextScene and nextEntrance).
Definition requests.c:61
Scene numbers, named after their places.
char SceneId_TretTreeInteriors
Song and sound effect ids, indices into gSound_SongTable.
#define SE_220
Definition songs.h:215
#define MUS_029
Definition songs.h:39
#define SE_204
Definition songs.h:199
#define SE_MAP_EXIT
Definition songs.h:116
#define SE_206
Definition songs.h:201
#define MUS_017
Definition songs.h:27
#define MUS_021
Definition songs.h:31
#define SE_188
Definition songs.h:183
#define SE_289
Definition songs.h:282
struct EventWork * gEventWork
void Engine_ActorSetPosition(u32 actor, s32 x, s32 z)
void Engine_TaskWait()
#define NULL
Definition bilibin.h:6
The colour buffer (heap block 32) that fades the BG and OBJ palettes: the source palette,...
Definition palbuf.h:40
u16 palette[0x1c0]
The source palette, RGB555: 224 BG colours, then 224 OBJ colours; palette[0] is the backdrop.
Definition palbuf.h:43
The options of a spawned field effect, each used when its EFFECT_USE_ flag (or EFFECT_SCALE_TO_TARGET...
s32 palette
passed to ObjectGroup_SetChildValue
s32 startScaleY
16.16 fixed point, 0x10000 full size
s32 startScaleX
16.16 fixed point, 0x10000 full size
void(*) update(union FieldObject *object)
replaces the update hook
s32 startTransition
SCENE_TRANSITION(style, variant).
Definition event_work.h:43
s32 transitionFrames
frames
Definition event_work.h:45
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
s32 targetX
16.16 fixed-point pixels; ACTOR_NO_TARGET when unset
Definition field_obj.h:59
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
s32 targetZ
16.16 fixed-point pixels; ACTOR_NO_TARGET when unset
Definition field_obj.h:61
s32 velocityX
16.16 fixed-point pixels per frame
Definition field_obj.h:52
s32 bounce
The share of its falling speed kept as it bounces on landing, 16.16 fixed point (0x4000 when created)...
Definition field_obj.h:64
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
s32 gravity
Taken off the vertical velocity each frame while it is above the ground, in 16.16 fixed-point pixels ...
Definition field_obj.h:68
union FieldCoordinate z
16.16 fixed-point pixels
Definition field_obj.h:37
u16 facing
1/65536 turns
Definition field_obj.h:34
s32 targetY
16.16 fixed-point pixels; ACTOR_NO_TARGET when unset
Definition field_obj.h:60
s32 scaleX
16.16 fixed point, 0x10000 full size
Definition field_obj.h:39
s32 scaleY
16.16 fixed point, 0x10000 full size
Definition field_obj.h:40
void(*) update(union FieldObject *object)
Called each frame before the object's script, while the object is live.
Definition field_obj.h:116
u16 work
The side of the player's next footprint (2 after a stop), or scene scratch.
Definition field_obj.h:112
s32 velocityZ
16.16 fixed-point pixels per frame
Definition field_obj.h:54
u8 terrainId
The map layer (0 to 3) its ground height is read from, which the scrolling camera updates from the ce...
Definition field_obj.h:47
A position on the field.
s32 z
16.16 fixed-point pixels
Full event work allocated by Field_RunScene (heap slot 27).
s16 command
a field Psynergy to use, as owner << 10 | Psynergy
s32 transition
SCENE_TRANSITION(style, variant); 0x100 on entry.
s32 z
16.16 fixed-point pixels
Definition game_state.h:52
s16 entrance
Definition game_state.h:37
s32 x
16.16 fixed-point pixels
Definition game_state.h:50
s32 selectedActor
the leader: its unit and its actor
Definition game_state.h:59
One background layer of the field map: its scroll position, origin, parallax against the view,...
Definition map_scroll.h:14
s32 scaleY
16.16 fixed point, 0x10000 moves with the view
Definition map_scroll.h:17
s32 offsetY
16.16 fixed-point pixels
Definition map_scroll.h:16
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
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 system's routines and globals: interrupts, BIOS sound bias, random numbers and sleep.
#define SPEAKER(actor, window)
A speaker: the actor, and in the top four bits where the message window opens beside them (4,...
static void Event_CastReveal(void)
Casting Reveal on the branch (its phase 2): the window transition and BG1's blend over the rest of th...
static void Event_FloorGivesWayToUpperRightNorthwest(void)
static void Event_FloorGivesWayToLowerMiddleSouthwest(void)
static void TretTreeInteriors_RunLandingDustScene(void)
Drops the leader into the room with a ring of landing particles.
s32 gTretTreeInteriors_TableActions3[]
static void Event_FloorGivesWayToLowerMiddleNortheast(void)
static void TretPalette_UpdateSceneTint(void)
Tints background colours 16 to 78 every thirty-two frames, leaving palette 4's last colour alone.
static void Event_FloorGivesWayToLowerMiddleSoutheast(void)
struct SceneEvent gTretTreeInteriorsEvents[]
#define TRET_TINT_END
static void Event_FloorGivesWayToUpperMiddleSouthwestUpper(void)
static void TretTreeInteriors_PlayGesture(s32 gesture)
Plays a Tret animation sequence with its original pauses.
struct SceneEntrance gTretTreeInteriorsEntrances[]
static void TretTreeInteriors_ApplyPostBattleState(s32 playRecoveryScene)
Restores the post-battle map and optionally plays its conversation.
static void Event_FloorGivesWayToUpperMiddleSouthLower(void)
s16 gTretTreeInteriors_MapPatches[]
The cracked floors redrawn when the room is restored: floor flag, whether it is redrawn (not the four...
static void TretTreeInteriors_UpdateSwirlSpark(union FieldObject *fieldObject)
Moves a fading spark outward from its saved origin, then releases it.
static void Event_FloorGivesWayToUpperRightNortheast(void)
#define TRET_TINT_COLOR_COUNT
s32 gTretTreeInteriors_TableActions1[]
u32 gTretTreeInteriorsExits[]
@ SPRITE_TRET_FACE
@ ACTOR_TRET_SPEAKER
static void TretTreeInteriors_StepOnCrackedFloor(s32 floorFlag, s32 sourceColumn, s32 sourceRow, s32 entrance)
Stepping on a cracked floor tile: the first step cracks it further and sets its temporary flag; the n...
static s32 sSparkFrame
static void Event_FloorGivesWayToLowerMiddleWestB(void)
A second cracked floor over the same lower middle west landing.
#define FLOOR_FALL_SPIN_FRAMES
static void Event_FloorGivesWayToUpperMiddleSouthwestLower(void)
static s16 * sLastFloorEntrance
static void Event_FloorGivesWayToUpperMiddleWestUpper(void)
static void Event_FloorGivesWayToLowerMiddleNorth(void)
static void Event_FloorGivesWayToUpperMiddleSouthUpper(void)
static void Event_FloorGivesWayToUpperMiddleNorthwest(void)
static void Event_FloorGivesWayToLowerMiddleSouth(void)
#define SWIRL_SPARK_SHRINK_LAST_FRAME
static void TretTreeInteriors_SpawnSwirlSparks(void)
Emits five shrinking waves of fading sparks from the saved origin.
s32 gTretTreeInteriors_TintIndex
static void Event_FightTret(void)
Walking up to Tret (touch trigger 40, until FLAG_TRET_DEFEATED): he roars, the party gathers in front...
static void Event_FloorGivesWayToLowerMiddleCenter(void)
static void Event_FloorGivesWayToLowerMiddleEast(void)
static void Event_FloorGivesWayToUpperMiddleWestLower(void)
static void Event_FloorGivesWayToUpperMiddleNortheast(void)
#define TRET_TINT_CHANNEL_MAX
s32 gTretTreeInteriors_TableActions2[]
u32 gTretTreeInteriors_TintSteps[]
s32 gTretTreeInteriors_TableActions0[]
s32 gTretTreeInteriors_ActionTable2[]
static void Event_FloorGivesWayToLowerMiddleWestA(void)
struct SceneRegion gTretTreeInteriorsRegions[]
static void TretPalette_SaveSceneColors(void)
Saves background palettes 0 to 13 as the base for Tret's scene tint.
static void Event_ResetFloorLatchWhenClear(void)
Walking off a cracked floor tile lets the next step on it count again.
struct ScenePlacement gTretTreeInteriorsPlacements[]
#define SWIRL_SPARK_LAST_FRAME
static void TretTreeInteriors_PlayPostBattleConversation(void)
After the battle: a passage opens beside Tret, who comes to, thanks the party and says good-bye.
static struct FieldPosition sSparkOrigin
s32 gTretTreeInteriors_ActionTable1[]
static void Event_FloorGivesWayToUpperMiddleSoutheastLower(void)
s32 TretTreeInteriors_EnterRoom(void)
Restores the room, tint and entry fall before continuing its story event.
static void Event_FloorGivesWayToLowerMiddleNorthwest(void)
static void TretTreeInteriors_ApplyFlaggedMapPatches(void)
Restores each enabled single-cell patch whose puzzle flag is set.
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
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.
s32 Resource_ResetEntry(u32 no)
Frees cache entry no: its blocks go back and the entry is marked free (offset 0xffff).
Definition vram_cache.c:106