Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
balloon.c
Go to the documentation of this file.
1/* The balloons over an actor's head */
2
3#include "field/field_mode.h"
4
5/* Steps a balloon's animation (FIELDSTG_triggerAnims) and returns its frame */
7 task->time -= GFX.funcs.getFrameTime();
8 if (task->time < 0) {
9 task->frame += 2;
10 if (FIELDSTG_triggerAnims[task->key2][task->frame] == 0xFF) {
11 task->frame = 0;
12 }
13 task->time = FIELDSTG_triggerAnims[task->key2][task->frame + 1];
14 }
15 return FIELDSTG_triggerAnims[task->key2][task->frame];
16}
17
18/* Draws a balloon over its actor: its frame, and once open, its animation */
20 SpriteDrawer sprite;
21 Vec2 pos;
22 s32 frame;
23
24 pos.x = task->actor->tile.x;
25 pos.y = task->actor->tile.y - (task->actor->z >> 8);
26 initSpriteDrawer(&sprite);
27 sprite.setLayerId(FIELD_LAYER_MAP, 1);
29 if (task->substate == 2) {
30 frame = FIELDSTG_stepBalloonAnim(task);
31 sprite.draw(FILE_CACHE.getEntry(FIELD_SPRITES_FILE << 16), frame, pos.x, pos.y - 0x1B);
32 }
33 sprite.draw(FILE_CACHE.getEntry(FIELD_SPRITES_FILE << 16), task->pop >> 2, pos.x, pos.y - 0x1B);
34}
35
36/* A balloon's update: it pops open over the player (or another actor), stays
37 while the trigger is on offer and pops shut in TASK_DONE */
39 switch (task->state) {
40 default:
41 case TASK_INIT:
42 if (task->actor == NULL) {
44 if (task->actor == NULL) {
45 break;
46 }
47 }
48 if (task->key1 == 0) {
49 task->popStart = 0xC8;
50 task->popOpen = 0xD4;
51 task->popEnd = 0xDC;
52 } else {
53 task->popStart = 0x104;
54 task->popOpen = 0x10C;
55 task->popEnd = 0x114;
56 }
57 if (task->key2 != 1) {
59 }
60 task->nextState(task);
61 /* fallthrough */
62 case TASK_RUN:
63 if (FIELDSTG_state.menuOpen != 0) {
64 break;
65 }
66 switch (task->substate) {
67 default:
68 case 0:
69 task->pop = task->popStart;
70 task->nextSubstate(task);
71 /* fallthrough */
72 case 1:
73 task->pop += GFX.funcs.getFrameTime();
74 if (task->pop >= task->popOpen) {
75 task->pop = task->popOpen;
76 task->nextSubstate(task);
77 }
78 break;
79 case 2:
80 break;
81 }
83 break;
84 case TASK_DONE:
85 task->pop += GFX.funcs.getFrameTime();
86 if (task->pop >= task->popEnd) {
87 task->pop = task->popEnd;
88 task->setState(task, TASK_KILL);
89 }
91 break;
92 case TASK_KILL:
93 break;
94 }
95}
96
97/* Creates a balloon of a kind (its sprites) with an animation, under a task
98 id */
101 task->key1 = kind;
102 task->key2 = anim;
103 return task;
104}
105
106/* The balloon over the player: script commands 803 to 806
107 (FIELDSTG_scriptCommands) */
111
112/* A balloon's script commands: 0x325 and 0x327 put it over the actor id with
113 animation 0 or 1, 0x326 pops it shut */
114void FIELDSTG_balloonCommand(Balloon *task, s32 command, s32 id) {
115 if (task != NULL) {
116 switch (command) {
117 case 0x325:
118 task->key2 = 0;
119 break;
120 case 0x327:
121 task->key2 = 1;
122 break;
123 case 0x326:
124 task->setState(task, TASK_DONE);
125 break;
126 }
127 if (command == 0x325 || command == 0x327) {
129 }
130 }
131}
void FIELDSTG_updateBalloon(Balloon *task)
A balloon's update: it pops open over the player (or another actor), stays while the trigger is on of...
Definition balloon.c:38
s32 FIELDSTG_stepBalloonAnim(Balloon *task)
Steps a balloon's animation (FIELDSTG_triggerAnims) and returns its frame.
Definition balloon.c:6
void FIELDSTG_createPlayerBalloon(s32 id)
The balloon over the player: script commands 803 to 806 (FIELDSTG_scriptCommands)
Definition balloon.c:108
Balloon * FIELDSTG_createBalloon(s32 kind, s32 anim, s32 id)
Creates a balloon of a kind (its sprites) with an animation, under a task id.
Definition balloon.c:99
void FIELDSTG_balloonCommand(Balloon *task, s32 command, s32 id)
A balloon's script commands: 0x325 and 0x327 put it over the actor id with animation 0 or 1,...
Definition balloon.c:114
void FIELDSTG_drawBalloon(Balloon *task)
Draws a balloon over its actor: its frame, and once open, its animation.
Definition balloon.c:19
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
#define TASK_RUN
Definition task.h:35
#define TASK_KILL
Definition task.h:37
#define TASK_INIT
Tasks: every game object is a task, a heap block that starts with this header and is updated once per...
Definition task.h:34
#define TASK_DONE
Definition task.h:36
#define FIELD_LAYER_MAP
the map, its objects and characters, and the menus
Definition field_map.h:20
#define FIELD_TASK_ACTOR
every character (FIELDSTG_createActor)
Definition field_map.h:26
FIELDSTG.PRO: the field mode, where the player walks around the map.
#define FIELD_SPRITES_X
Where the field keeps its textures in VRAM: the two images of FIELD_SPRITES_FILE (its entries 2 and 3...
Definition field_mode.h:27
#define FIELD_SPRITES_FILE
The field's effect sprites (FIELDSTG_drawSpotEffect): the discs number their files differently.
Definition field_mode.h:591
#define FIELD_SPRITES_Y
Definition field_mode.h:29
#define SOUND_FUKIDASH
a balloon
Definition field_mode.h:44
FieldState FIELDSTG_state
Definition fieldstg.c:2641
u8 FIELDSTG_triggerAnims[][9]
FIELDSTG_stepBalloonAnim's animations: (frame, time) pairs up to 0xFF.
Definition fieldstg.c:1773
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
TaskRegistry TASK_REGISTRY
Definition registry.c:122
SoundState SOUND
rsin and rcos (libgte) read rsin_tbl[a - 0x800] and the like: their addresses before the table fall i...
Definition sound.c:180
void initSpriteDrawer(SpriteDrawer *obj)
Clears a sprite drawer to neutral (no scale, gray tint, follows the scroll), gives it its methods and...
s32 z
how high it is off the ground, in 1/256 pixels (drawn that much higher)
Definition field_map.h:339
Vec2 tile
Definition field_map.h:337
A balloon over an actor's head (FIELDSTG_createBalloon): it pops up, plays its FIELDSTG_triggerAnims ...
Definition field_mode.h:173
s32 popOpen
to here
Definition field_mode.h:177
s32 state
Definition field_mode.h:174
s32 substate
Definition field_mode.h:174
s32 frame
into its FIELDSTG_triggerAnims row
Definition field_mode.h:180
void(* nextSubstate)(struct Balloon *task)
Definition field_mode.h:174
void(* nextState)(struct Balloon *task)
Definition field_mode.h:174
s32 popEnd
and closes to here
Definition field_mode.h:178
void(* setState)(struct Balloon *task, s32 state)
Definition field_mode.h:174
Actor * actor
the player when NULL
Definition field_mode.h:175
s32 popStart
the pop-up's sprites, times 4: it opens from here
Definition field_mode.h:176
s32 pop
the pop-up's sprite, times 4
Definition field_mode.h:179
s32 menuOpen
the field menu (START) or the inn (FIELDSTG_openInn) is open: the pad doesn't move the player
Definition field_map.h:464
void *(* getEntry)(u32 fileAndIndex)
Definition file.h:96
s32(* getFrameTime)(void)
Definition gfx.h:32
GfxFuncs funcs
Definition gfx.h:77
short(* playSound)(s32 id)
returns the voice of a key-on
Definition sound.h:187
Draws sprites from a sprite sheet (such as file 0x277, the menu graphics): a sheet has a table of fra...
Definition gfx.h:223
void(* setLayerId)()
(id, depth)
Definition gfx.h:244
void(* draw)()
(sheet, frame, x, y)
Definition gfx.h:246
void(* setTexture)()
(x, y)
Definition gfx.h:242
void *(* find)(s32 id, s32 key1, s32 key2)
Definition task.h:18
TaskFuncs funcs
Definition task.h:76
Definition gfx.h:352
s32 y
Definition gfx.h:354
s32 x
Definition gfx.h:353
void * createTaskWithId(void(*update)(), s32 size, s32 childrenSize, s32 id)
Allocates a zeroed task of size bytes (header included) with room for childrenSize / 4 child tasks.
Definition task.c:80