Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
banner.c
Go to the documentation of this file.
1/* The area name banner, with the names of the area and the place. Its
2 rodata, at 0x800825CC (USA), starts FIELDSTG.PRO's fourth object (see
3 data/fieldstg.c). */
4
5#include "field/field_mode.h"
6
7/* Opens the banner's windows with the names of the mode's area and place
8 (FIELDSTG_areaNames) */
10 s16 mode = GAME.funcs.getMode();
11 s32 i;
12
13 for (i = 0; FIELDSTG_areaNames[i].mode != 0; i++) {
14 if (FIELDSTG_areaNames[i].mode == mode) {
15 windows->area = createTextWindow(FIELD_LAYER_BANNER, 1, 0x80, 0x1A);
17 windows->area->setTypeDelay(windows->area, 5);
18 windows->place = createTextWindow(FIELD_LAYER_BANNER, 1, 0x28, 0x44);
20 windows->place->setTypeDelay(windows->place, 5);
21 break;
22 }
23 }
24}
25
26/* Stretches a box toward from-to along one axis. The match depends on each
27 case having its own variables. */
29 switch (box->stretch) {
30 case 1: {
31 s32 start = box->pos.vx;
32 s32 end = start + box->size.vx;
33 s32 from = box->from;
34 s32 to = box->to;
35 s32 speed = box->speed;
36
37 if (start < from) {
38 start += speed;
39 if (start > from) {
40 start = from;
41 }
42 } else if (start > from) {
43 start -= speed;
44 if (start < from) {
45 start = from;
46 }
47 }
48 if (end < to) {
49 end += speed;
50 if (end > to) {
51 end = to;
52 }
53 } else if (end > to) {
54 end -= speed;
55 if (end < to) {
56 end = to;
57 }
58 }
59 box->pos.vx = start;
60 box->size.vx = end - start;
61 if (start == from && end == to) {
62 box->stretch = 0;
63 }
64 break;
65 }
66 case 2: {
67 s32 start = box->pos.vy;
68 s32 end = start + box->size.vy;
69 s32 from = box->from;
70 s32 to = box->to;
71 s32 speed = box->speed;
72
73 if (start < from) {
74 start += speed;
75 if (start > from) {
76 start = from;
77 }
78 } else if (start > from) {
79 start -= speed;
80 if (start < from) {
81 start = from;
82 }
83 }
84 if (end < to) {
85 end += speed;
86 if (end > to) {
87 end = to;
88 }
89 } else if (end > to) {
90 end -= speed;
91 if (end < to) {
92 end = to;
93 }
94 }
95 box->pos.vy = start;
96 box->size.vy = end - start;
97 if (start == from && end == to) {
98 box->stretch = 0;
99 }
100 break;
101 }
102 }
103}
104
105/* Draws one of the banner's boxes, a flat quad of a color */
106void FIELDSTG_drawBannerBox(AreaBanner *task, u_long *ot, DVECTOR pos, DVECTOR size, s32 color) {
107 POLY_F4 *poly = GFX.funcs.getPrim();
108
109 setlen(poly, 5);
110 *(s32 *)&poly->r0 = color; /* r0, g0 and b0 in one store; code follows */
111 poly->code = 0x28;
112 poly->x0 = pos.vx;
113 poly->x1 = pos.vx + size.vx;
114 poly->x2 = pos.vx;
115 poly->x3 = pos.vx + size.vx;
116 poly->y0 = pos.vy;
117 poly->y1 = pos.vy;
118 poly->y2 = pos.vy + size.vy;
119 poly->y3 = pos.vy + size.vy;
120 addPrim(ot, poly);
121 GFX.funcs.setPrim(poly + 1);
122}
123
124/*
125 * The area name banner: in TASK_INIT it copies its ten boxes from
126 * FIELDSTG_bannerBoxes and opens the area and place windows
127 * (FIELDSTG_showAreaName); in TASK_RUN the boxes appear and stretch in turn
128 * until both windows have finished; in TASK_DONE it closes the layer's clip
129 * from the top and the bottom.
130 */
132 Layer *layer;
133 u_long *ot;
134 s32 i;
135
136 switch (task->state) {
137 default:
138 case TASK_INIT:
139 if (task->key1 != 0) {
140 s32 j;
141
142 for (j = 0; j < 10; j++) {
143 task->boxes[j] = FIELDSTG_bannerBoxes[j];
144 }
145 FIELDSTG_showAreaName(task, windows);
146 task->nextState(task);
147 } else {
148 task->setState(task, TASK_DONE);
149 }
150 break;
151 case TASK_RUN:
152 switch (task->substate) {
153 default:
154 case 0:
155 task->boxes[0].visible = 1;
156 task->boxes[5].visible = 1;
157 if (task->boxes[5].stretch != 0) {
158 break;
159 }
160 task->nextSubstate(task);
161 /* fallthrough */
162 case 1:
163 task->boxes[8].visible = 1;
164 task->boxes[9].visible = 1;
165 task->boxes[6].visible = 1;
166 task->boxes[1].visible = 1;
167 task->boxes[2].visible = 1;
168 task->boxes[7].visible = 1;
169 task->boxes[3].visible = 1;
170 if (task->boxes[9].stretch != 0) {
171 break;
172 }
173 task->nextSubstate(task);
174 /* fallthrough */
175 case 2:
176 task->nextSubstate(task);
177 /* fallthrough */
178 case 3:
179 task->boxes[4].visible = 1;
180 if (task->boxes[4].stretch == 0) {
181 task->nextSubstate(task);
182 }
183 break;
184 case 4:
185 if (windows->area->isFinished(windows->area) && windows->place->isFinished(windows->place)) {
186 task->setState(task, TASK_DONE);
187 }
188 break;
189 }
190 break;
191 case TASK_DONE:
193 /* the match depends on the empty case 0 */
194 switch (task->substate) {
195 case 0:
196 break;
197 case 1:
198 task->step += GFX.funcs.getFrameTime();
199 if (task->step < 60) {
200 break;
201 }
202 task->nextSubstate(task);
203 /* fallthrough */
204 case 2:
205 task->clip.w = 320;
206 task->clip.x = 0;
207 task->clip.y = 0;
208 task->clip.h = 240;
209 task->nextSubstate(task);
210 /* fallthrough */
211 case 3:
212 task->clip.y += 8;
213 task->clip.h -= 16;
214 layer->setClipPos(layer, task->clip.x, task->clip.y);
215 layer->setClipSize(layer, task->clip.w, task->clip.h);
216 if (task->clip.h == 0) {
217 task->setState(task, TASK_KILL);
218 }
219 break;
220 }
221 break;
222 case TASK_KILL:
224 break;
225 }
226 if (task->state >= 1 && task->state <= 2 && task->key1 != 0) {
228
229 ot = top->getOtEntry(top, 1);
230 for (i = 0; i < 10; i++) {
231 if (task->boxes[i].visible) {
232 FIELDSTG_stretchBannerBox(task, &task->boxes[i]);
233 FIELDSTG_drawBannerBox(task, ot, task->boxes[i].pos, task->boxes[i].size, task->boxes[i].color);
234 }
235 }
236 }
237}
238
239/* Creates the area name banner, which closes at once unless show; the
240 player is frozen until it ends */
243
244 task->key1 = show;
246 return task;
247}
void FIELDSTG_stretchBannerBox(AreaBanner *task, BannerBox *box)
Stretches a box toward from-to along one axis.
Definition banner.c:28
Task * FIELDSTG_createBanner(s32 show)
Creates the area name banner, which closes at once unless show; the player is frozen until it ends.
Definition banner.c:241
void FIELDSTG_showAreaName(AreaBanner *task, AreaNameWindows *windows)
Opens the banner's windows with the names of the mode's area and place (FIELDSTG_areaNames)
Definition banner.c:9
void FIELDSTG_drawBannerBox(AreaBanner *task, u_long *ot, DVECTOR pos, DVECTOR size, s32 color)
Draws one of the banner's boxes, a flat quad of a color.
Definition banner.c:106
void FIELDSTG_updateBanner(AreaBanner *task, AreaNameWindows *windows)
The area name banner: in TASK_INIT it copies its ten boxes from FIELDSTG_bannerBoxes and opens the ar...
Definition banner.c:131
signed int s32
Definition common.h:11
signed short s16
Definition common.h:9
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
GameState GAME
The save data, the game mode and the methods.
Definition state.c:64
#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_TASK_BANNER
the area name banner
Definition field_map.h:28
#define FIELD_LAYER_BANNER
the area name banner
Definition field_map.h:21
FIELDSTG.PRO: the field mode, where the player walks around the map.
BannerBox FIELDSTG_bannerBoxes[10]
FIELDSTG_updateBanner's boxes.
Definition fieldstg.c:1761
AreaName FIELDSTG_areaNames[]
Definition fieldstg.c:1519
FieldState FIELDSTG_state
Definition fieldstg.c:2641
#define TEXT_AREA_NAMES
STAREA.
Definition file.h:224
#define TEXT_FILE(file)
Definition file.h:190
#define TEXT_STAGE_NAMES
STNAME.
Definition file.h:226
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
Task * start(void)
The mode's entry point (MODE_ENTRY_POINTS): starts its root task (update_scene.inc....
Definition start.inc.c:3
The area name banner (FIELD_TASK_BANNER, FIELDSTG_createBanner)
Definition field_mode.h:636
void(* setState)(struct AreaBanner *task, s32 state)
Definition field_mode.h:637
void(* nextState)(struct AreaBanner *task)
Definition field_mode.h:637
BannerBox boxes[10]
Definition field_mode.h:638
void(* nextSubstate)(struct AreaBanner *task)
Definition field_mode.h:637
RECT clip
the layer's, closing in TASK_DONE
Definition field_mode.h:639
The windows of FIELDSTG_showAreaName.
Definition field_mode.h:617
TextWindow * area
Definition field_mode.h:618
TextWindow * place
Definition field_mode.h:619
A rectangle of an AreaBanner, which can stretch to a new range.
Definition field_mode.h:623
DVECTOR pos
Definition field_mode.h:625
s32 stretch
1: horizontally, 2: vertically
Definition field_mode.h:628
DVECTOR size
Definition field_mode.h:626
s32 frozen
no control, triggers or encounters for the player: while the area name banner shows (FIELDSTG_createB...
Definition field_map.h:466
void *(* load)(u32 file)
Definition file.h:92
s32(* getMode)(void)
Definition game_state.h:19
GameFuncs funcs
Definition game_state.h:582
void *(* getPrim)(void)
Definition gfx.h:19
s32(* getFrameTime)(void)
Definition gfx.h:32
struct Layer *(* getLayer)(s32 id)
Definition gfx.h:28
void(* setPrim)(void *next)
Definition gfx.h:20
GfxFuncs funcs
Definition gfx.h:77
A drawing layer (GFX.funcs.createLayer): a DRAWENV with a pair of ordering tables,...
Definition gfx.h:128
u_long *(* getOtEntry)(struct Layer *, s32 depth)
Definition gfx.h:155
void(* setClipSize)()
no prototype: callers would truncate s16 args
Definition gfx.h:146
void(* setClipPos)()
no prototype: callers would truncate s16 args
Definition gfx.h:145
Any task, seen through its header.
Definition task.h:62
s32 key1
Definition task.h:63
s32(* isFinished)()
s32: callers don't truncate the result to a byte
Definition text.h:186
void(* setTypeDelay)()
Definition text.h:172
void(* setString)()
Definition text.h:165
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
TextWindow * createTextWindow(s16 layerId, s16 style, s16 x, s16 y)
A text window on a layer, in a font style, at (x, y)