30#include "text/msg_ids.h"
76#define SPRING_CENTER_X PIXELS(120)
77#define SPRING_CENTER_Z PIXELS(71)
123 s32 question = MsgTolbiLuckyMedal;
137 s32 question = MsgTolbiYerFirstTime;
239 if (coinChange > 0) {
240 if (coinChange > 19999) {
242 }
else if (coinChange > 4999) {
252 }
else if (coinChange < 0) {
267 if (wonPrizes[0] == -1) {
269 }
else if (wonPrizes[0] != -2) {
272 if (*wonPrizes != -1) {
273 for (prizeIndex = 0; wonPrizes[prizeIndex] != -1; prizeIndex++) {
274 if (prizeIndex == 0) {
360 const u16 *alphaSteps;
366 for (stepIndex = 0; stepIndex < 16; stepIndex++) {
371 for (stepIndex = 0; stepIndex < 8; stepIndex++) {
385 s32 message = MsgTolbiStepRightTry;
404 }
else if (room <= 6) {
466#if LANGUAGE == LANGUAGE_ENGLISH || LANGUAGE == LANGUAGE_JAPANESE
471#if LANGUAGE == LANGUAGE_JAPANESE
475#elif LANGUAGE == LANGUAGE_ENGLISH
502 message = MsgTolbiThrow;
512 text = MsgTolbiCoins;
521 if (choice == cancel) {
572 asm(
"" :
"+r"(message));
574 text = MsgTolbiCoins;
577 asm(
"" :
"+r"(text));
593 if (choice == cancel) {
621 result = MsgTolbiToss;
644 if (result != cancel) {
681 if (prizeIndex < result * 3 + 3) {
683 u8 prizeWeight = ((
u8 *)state)[prizeIndex + 285];
684 totalWeight += (
s8)prizeWeight;
686 }
while (prizeIndex < result * 3 + 3);
689 for (prizeIndex = 0; prizeIndex < 15; prizeIndex++) {
695 if (prizeIndex == 15) {
705 ->prize[prizeIndex]);
717 register s32 slot
asm(
"r1") = prizeIndex + 284;
718 s8 *prizeWeight = (
s8 *)state + 1;
720 if (prizeWeight[slot] > 1) {
721 prizeWeight[slot] /= 2;
727 register s8 *prizeWeight
asm(
"r0");
728 s32 slot = prizeIndex + 284;
731 __asm__(
"" :
"=r"(prizeWeight) :
"0"(state));
733 if (prizeWeight[slot] > 1) {
734 prizeWeight[slot] /= 2;
768 variant = (previousVariant +
780 s32 facing,
s32 colorVariant,
789 actor->
x.
fixed = *coordinate++;
790 actor->
y.
fixed = *coordinate++;
791 actor->
z.
fixed = *coordinate;
795 actor->sprite->flags = zero.
v;
800 sprite = actor->sprite;
801 entryCount = sprite->
count;
802 if (entryCount != 0) {
803 u32 invalidFrame = 255;
805 u32 entriesLeft = entryCount;
810 if (entry->
param != colorVariant) {
811 entry->
param = colorVariant;
816 frame |= invalidFrame;
820 }
while (--entriesLeft != 0);
874 }
while (index != 0);
880 toss->
trail[0].
y = height;
903 distance =
Iwram_Sqrt(deltaX * deltaX + deltaZ * deltaZ);
935 s32 distanceSquared = deltaX * deltaX + deltaZ * deltaZ;
939 if (distanceSquared <= 224) {
941 }
else if (distanceSquared <= 624) {
943 }
else if (distanceSquared <= 1088) {
945 }
else if (distanceSquared <= 1680) {
961 minX =
PIXELS(48) + edgeInset;
965 maxX =
PIXELS(192) - edgeInset;
971 edgeInset = (toss->
trail[0].
z * 42 -
PIXELS(102) * 42) / 18;
972 minX =
PIXELS(48) + edgeInset;
976 maxX =
PIXELS(192) - edgeInset;
983 minZ =
PIXELS(24) + edgeInset;
987 maxZ =
PIXELS(120) - edgeInset;
993 edgeInset = (toss->
trail[0].
x * 18 -
PIXELS(150) * 18) / 42;
994 minZ =
PIXELS(24) + edgeInset;
998 maxZ =
PIXELS(120) - edgeInset;
1005 if (toss->
trail[0].
x < minX) {
1011 if (toss->
trail[0].
x > maxX) {
1017 if (toss->
trail[0].
z < minZ) {
1023 if (toss->
trail[0].
z > maxZ) {
1049 if (speedMode == 1) {
1050 motionStep = motionStep * 2;
1052 if (speedMode == 2) {
1053 motionStep = motionStep * 3;
1089 }
else if (index == 2) {
1092 if (speedMode == 1) {
1093 motionStep = motionStep * 2;
1095 if (speedMode == 2) {
1096 motionStep = motionStep * 3;
1106 cycleFrame = (
u16)obstacle->
heading + motionStep;
1107 obstacle->
heading = cycleFrame;
1114 if (speedMode == 1) {
1115 motionStep = motionStep * 2;
1117 if (speedMode == 2) {
1118 motionStep = motionStep * 3;
1122 }
else if (cycleFrame <= 383) {
1139 s32 distanceSquared;
1143 distanceSquared = deltaX * deltaX + deltaZ * deltaZ;
1144 if (distanceSquared <= 119 && toss->attractionFrames > 30) {
1166 toss->
velocity.
x = -deltaX * speed / distance;
1167 toss->
velocity.
z = -deltaZ * speed / distance;
1171 nextMode = (obstacle->
speedMode + 1) % 3;
1209 }
while (index != 4);
1254 s32 obstacleIndex = 0;
1256 const u16 *headings;
1269 obstacle->
heading = *headings;
1280 }
while (obstacleIndex != 4);
1351 {0,
CONDITION_ALWAYS, 120, 0, 152,
FACING_SOUTH, 0, -1, -1, -1, -1, 0},
1352 {1,
CONDITION_ALWAYS, 120, 0, 168,
FACING_NORTH, 0, -1, -1, -1, -1, 0},
1353 {2,
CONDITION_ALWAYS, 120, 0, 152,
FACING_SOUTH, 0, -1, -1, -1, -1, 0},
1354 {10,
CONDITION_ALWAYS, 128, 0, 176,
FACING_NORTH, 0, 8, 8, 248, 200, 0},
1355 {11,
CONDITION_ALWAYS, 96, 0, 440,
FACING_NORTH, 0, 8, 288, 248, 456, 0},
1356 {12,
CONDITION_ALWAYS, 144, 0, 390,
FACING_NORTH, 0, 8, 288, 248, 456, 0},
1357 {13,
CONDITION_ALWAYS, 120, 0, 152,
FACING_WEST, 0, 8, 8, 248, 200, 0},
1486 0x90a, 0xa08, 0xb06, 0xc04, 0xd03, 0xe02, 0xf01, 0x1000,
1490 23, 124, 81, 152, 37, 108, 171, 142,
1491 48, 160, 133, 97, 183, 186, 189,
1499 250, 251, 252, 256, 257, 258, 262, 263,
1500 264, 183, 182, 181, 189, 186, 188,
Ability numbers, named from the English release.
struct FieldActor * Object_GetById(s32 actor)
Returns an actor, or NULL if it does not exist.
void ObjectTable_Snapshot(void)
Saves up to 32 actors (only the party's 8 on the world map) into gObjectSnapshots,...
Calls through a function pointer, by argument count.
The engine calls the debug menus import, and their palette swatch tiles.
The edition's language, for C to compare (LANGUAGE == LANGUAGE_GERMAN).
static s32 FieldScheduler_AddCallback(SchedulerCallback callback, s32 priority)
Registers a main-image scheduler callback.
void ObjectDispatch_SetAnimationSpeed(struct DispatchObject *rawObject, s32 value)
Sets the animation speed (timer step) of all of an object's sprites.
The scene script layer: the engine services a scene's events call, declared once (Engine_EventBegin,...
static s32 Event_OpenMessage(s32 speaker, s32 flags)
static void Actor_FaceDirection(s32 actor, s32 facing, s32 frames)
void Object_SetMode(struct FieldActor *object, s32 animation)
s32 Engine_EventChooseYesNo(s32 actor, s32 flags)
s32 Engine_PartyGiveItem(s32 item, s32 flags)
s32 Engine_MathSin(s32 angle)
void Engine_ItemShowFound(s32 item, s32 height)
void Engine_ActorFaceDirection(s32 actor, s32 facing, s32 frames)
static void Map_CopyCellsTo(s32 srcX, s32 srcY, s32 destX, s32 destY, s32 width, s32 height)
void Engine_ActorWalkToAndWait(s32 actor, s32 x, s32 z)
void Engine_EventWaitForScreen(void)
void Engine_EventOpenScreen(void)
s32 Engine_EventOpenMessage(s32 speaker, s32 flags)
void Engine_GameFlagSet(s32 flag)
static void Event_ShowMessage(s32 speaker, s32 flags)
static void Event_PlayCue(s32 cue)
void Engine_ActorSetChildValue(s32 actor, s32 value)
s32 Engine_GameFlagIsSet(s32 flag)
s32 Engine_MathCos(s32 angle)
static s32 Random_Next(void)
void Engine_EventWait(s32 frames)
@ TRANSITION_BACKDROP_FADE
@ ACTOR_PRIORITY_UNDERFOOT
The depth sort treats it as 320 pixels higher on the screen.
#define SCENE_TRANSITION(style, variant)
The scene table formats: entrances, exits, placements and events, and the macros that write them.
#define SCENE_EXITS(scene)
#define SCENE_EXIT(exit, scene, entrance)
@ TALK_FACE_PARTY_AND_BACK
#define PSYNERGY_ON_ACTOR(ability)
#define EVENT_SCRIPT(script)
#define SCENE_EXIT_IF(exit, scene, entrance, flag)
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 Event_Wait(s32 frames)
static s32 Event_ChooseYesNo(s32 actor, s32 flags)
static void Event_SetMessage(s32 message)
16.16 fixed-point constants, sine and cosine, and the library division.
#define Q16_ONE
One in the engine's signed 16.16 fixed-point format.
Game flags, named where their meaning is shown.
#define FLAG_COLOSSO_OVER
the Colosso finals have been fought
#define FLAG_BABI_SAVED
The party has saved Babi in Altmiller Cave with his Mystic Draught; Tolbi then holds the Colosso fina...
#define FLAG_SCENE_TEMP_00
#define FLAG_KEEP_PARTY_POSITION
The frame loop's globals: lag counts, the CPU load display and the VBlank flags.
u8 gOamCopyEnabled
The VBlank handler copies the OAM list only while it is set; scenes clear it to keep their own sprite...
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.
The screen blend's globals and the graphics routines.
s32 PartyInventory_CountItem(s32 itemId)
Counts itemId across the party.
s32 PartyInventory_CountFreeSlots(void)
Returns the free inventory slots of the whole party.
s32 PartyInventory_Remove(s32 itemId)
Removes one itemId from whoever carries it first; always returns 0.
gOverflowItem, an item slot the spoils code uses when items are handed out.
The hardware's I/O registers and their bits, as pret names them.
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.
Item numbers, named from the English release.
The IWRAM call layer: the routines the game keeps resident in IWRAM, each at its fixed address,...
static s32 Iwram_Sqrt(s32 value)
The keypad state the VBlank interrupt keeps.
volatile u32 gKeysPressed
Keys that went down this frame.
Maps: their cells, layers, animations and blend scripts, and the map state.
The reel game's title lettering.
void Battle_ResetEffectCounter(void)
Clears the field's busy flag and, while Reveal is active, ends it: Reveal used with ACT_PACKED runs i...
s32 Party_AdjustCoins(s32 amount)
Adds amount to the party's coins, kept between 0 and 999999, and returns the new total.
void Event_SetNextDestination(s32 scene, s32 entrance)
Sets the scene and entrance that the field goes to next (gGameState.nextScene and nextEntrance).
void Event_RequestDestination(u16 scene, u16 entrance)
Makes the event leave for entrance entrance of scene scene: sets gGameState.scene and entrance and ra...
void AudioCommand_WaitForStateByteClear(void)
Waits one frame at a time until the sound driver has finished the last command.
Scene numbers, named after their places.
char SceneId_TolbiSpring1
char SceneId_TolbiSpring2
Song and sound effect ids, indices into gSound_SongTable.
void Engine_ActorSetAnimation()
struct EventWork * gEventWork
void Engine_ActorSetPosition(u32 actor, s32 x, s32 z)
void Engine_EventEnd(void)
void Engine_AudioPlayCue()
void Engine_EventBegin(void)
void Engine_EventSetMessage()
void Engine_EventShowMessage()
#define offsetof(type, member)
One animation layer of a sprite: its animation id, frames, running script and timer.
u8 param
SpriteColorMode its pixels are drawn with; 0 when taken.
u8 frame
frame shown, frameBase plus the facing offset; 255 none
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
struct AnimationEntry * entries[4]
its layers; empty ones null
u8 count
layers in use, up to the last one present
A field object as the object dispatcher's far calls take it.
s32 startTransition
SCENE_TRANSITION(style, variant).
u16 message
the next message, advanced as each window opens
A field actor: a person or thing on the field with a position, motion toward a target,...
u8 motionFlags
ActorMotionFlag bits; zero is free flight in 3D, and 3 is set on creation.
union FieldCoordinate x
16.16 fixed-point pixels
union FieldCoordinate y
16.16 fixed-point pixels
u8 priorityFlags
ActorPriorityFlag bits, read by the scrolling camera.
u8 spriteStorageKind
Zero hides sprites; one draws a single sprite, two draws a group.
union FieldCoordinate z
16.16 fixed-point pixels
s32 scaleX
16.16 fixed point, 0x10000 full size
The game's state: play time, coins, the scene and the leader's position, the active party and the opt...
s8 prizeWeights[0x0f]
The slot machine's prize weights, three prizes to each of 4, 8, 16, 32 and 64 on a new game; not read...
s8 wonPrizes[0x10]
Lucky Wheels: 0 to 7 the prize categories won, ended by -1 (-2 once awarded); 8 on the last variant g...
s32 selectedActor
the leader: its unit and its actor
A halfword holding the zero the gauge's slide and phase are cleared with.
The map work in heap slot 8 (struct MapScrollWork), seen as its tile animation channels,...
A scene entrance: where and facing which way the party arrives, and the camera's bounds there (-1 for...
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,...
A scene's exit region: the box that, while its condition holds, takes the party leader out through it...
One of the four obstacles moving in the spring during a toss.
struct Vector3 position
16.16 fixed-point pixels
The tossed coin or medal: its last four positions for the trail, its velocity and the frames the priz...
struct Vector3 velocity
16.16 fixed-point pixels per frame
struct Vector3 trail[4]
16.16 fixed-point pixels
A window: a framed rectangle of the tilemap with its sprite outputs, its opening or closing animation...
Three coordinates, x, y and z: a position, a velocity or a direction.
The system's routines and globals: interrupts, BIOS sound bias, random numbers and sleep.
void UiText_DrawNumberInWindow(s32 value, s32 width, struct UiWindow *window, s32 x, s32 y)
Draws a number (width as UiText_FormatNumber) into a window's tilemap at pixel (x,...
void UiText_DrawCharacterAtOffset(s32 message, const struct UiWindow *window, u32 offsetX, u32 offsetY)
Decodes a message and draws it as tiles in a window at pixel (offsetX, offsetY) of its interior.
static struct SpringObstacle sObstacles[4]
TolbiSpringActor
The spring's own actors, numbered the same way.
@ TOLBI_SPRING_MEDAL_SEEKER
Asks for a medal. "Do you have a Lucky Medal?".
@ TOLBI_SPRING_SPRING
searched to toss a coin or medal
static void TolbiSpring_SetActorAppearance(s32 actorId, const s32 *coordinate, s32 facing, s32 colorVariant, s32 childValue)
Copies three coordinates and sets the actor's facing, child value and colors.
const struct SceneEvent * TolbiSpring_GetEvents(void)
Selects interactions for the spring or the game attendants.
const u32 * TolbiSpring_GetExits(void)
static void TolbiSpring_SetSpriteStorageKind(s32 actorId, s32 storageKind)
Sets whether the specified actor draws its sprite.
const u16 gTolbiSpring_AlphaSteps[]
BLDALPHA steps.
const u8 gTolbiSpring_ActorPixelZ[]
static s32 TolbiSpring_RunToss(s32 tossKind)
Launches the chosen coin or medal and waits for its final prize ring.
const u16 gTolbiSpring_ActorHeadings[]
TolbiSpringGameRoomActor
The game room's actors, numbered in the order of its placement table from 8.
@ TOLBI_SPRING_SOLDIER
A soldier, gone after Colosso. "poor soldiers like us".
@ TOLBI_SPRING_DICE_ATTENDANT
@ TOLBI_SPRING_WHEELS_PRIZE_SIGN
@ TOLBI_SPRING_WHEELS_RULES_SIGN
@ TOLBI_SPRING_WHEELS_ATTENDANT
static void TolbiSpring_ReadLuckyWheelsPrizes(void)
Reads the Lucky Wheels prize sign.
const struct SceneEvent gTolbiSpringEventsOther[]
const struct ScenePlacement * TolbiSpring_GetPlacements(void)
Selects the actors for the spring or its nearby games.
const struct SceneEntrance gTolbiSpring_Entrances[]
const struct ScenePlacement gTolbiSpringPlacementsOther[]
static void TolbiSpring_AskAboutFirstDiceGame(s32 actorId)
Asks whether this is the party's first Lucky Dice game.
static __inline__ void Io_SetBlendAlpha(s32 value)
const u32 gTolbiSpring_LuckyWheelsPrizeItems[]
static void TolbiSpring_RevealPrize(s32 item)
Animates the spring's prize reveal, gives the item, and closes it.
static void TolbiSpring_TalkToWheelsAttendant(void)
const struct SceneEntrance * TolbiSpring_GetEntrances(void)
const struct SceneRegion * TolbiSpring_GetRegions(void)
const struct SceneEvent gTolbiSpringEvents2[]
const u8 gTolbiSpring_SliderFrames[]
static __inline__ void Io_SetBlendControl(s32 value)
static void TolbiSpring_AskAboutLuckyMedal(s32 actorId)
Asks whether the party has a Lucky Medal.
const u32 gTolbiSpring_Exits[]
static void TolbiSpring_UpdateTossSimulation(void)
Advances the toss, obstacles, collisions and displayed trail each frame.
static struct SpringTossMotion sToss
const u32 gTolbiSpring_PrizeItems[]
static s32 TolbiSpring_SelectLuckyWheelsPrize(s32 category)
Chooses an item variant in the prize category, avoiding its last variant.
static void TolbiSpring_TossCoinOrMedal(void)
Reveals the spring once, then positions the leader to toss into it.
const u8 gTolbiSpring_CircleFrames[]
static void TolbiSpring_ShowPrizeFrame(s32 sourceColumn, s32 sourceRow)
Displays one frame of the spring's opening or closing prize animation.
static void TolbiSpring_RiseAndFadeIn(void)
Raises the spring's displayed layer and blends it into view.
static void TolbiSpring_OfferLuckyWheels(s32 spoken)
Checks tickets and inventory space before sending the party to Lucky Wheels.
s32 TolbiSpring_Initialize(void)
Prepares the spring or settles rewards from the nearby games.
const u8 gTolbiSpring_ActorPixelX[]
const struct ScenePlacement gTolbiSpringPlacements2[]
static s32 TolbiSpring_RunSpringGame(void)
Chooses a coin or medal, runs its toss, and awards the resulting prize.
const u16 gTolbiSpring_CoinPrizes[]
static void TolbiSpring_ReadLuckyWheelsRules(void)
Reads the Lucky Wheels rules sign.
static void TolbiSpring_OfferLuckyDice(void)
Offers Lucky Dice and saves the coin total for the return visit.
static void TolbiSpring_InitializeTossSimulation(void)
Resets four obstacles and schedules the spring simulation.
The integer types, TRUE, UNUSED and the fixed-address macros.
s32 fixed
16.16 fixed-point pixels
u32 Party_GetAverageLevel(void)
Returns the average level of the party members, rounded down (0 with no members).
static const s32 * Vector3_Coordinates(const struct Vector3 *vector)
Returns the vector's three coordinates as an array.
void UiWork_PushValueSlot(u32 value, u32 kind)
Adds a message argument of kind (MSG_ARG_) with value to the first free place of the argument table; ...
void UiWork_FinalizePendingCore(void)
Closes each message channel's window whose text has ended, then waits ten frames.
void UiWork_Finalize(struct UiWindow *window, s32 instant)
Closes a window: clears its contents and remembers its last rectangle.
struct UiWindow * UiWindow_Create(s32 x, s32 y, s32 width, s32 height, s32 attrs)
Opens a window at tile (x, y) of width by height tiles in the first free window slot,...