Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
questions.c
Go to the documentation of this file.
1/* CARDGAME's step windows, the yes/no question and the card info. */
2
4
5/* A position of CARDGAME_stepWindowPositions */
7#if PAL_VIDEO
9#else
10 return CARDGAME_stepWindowPositions[0][a][b][c];
11#endif
12}
13
14/* Opens the windows of the step CARDGAME_windowSteps[step] once its time is past; the next step */
15s32 CARDGAME_openStepWindows(CardBattle *battle, CardScreen *screen, s32 layout, s32 text, s32 time, s32 step) {
16 if (CARDGAME_windowSteps[step].time < time) {
17 switch (CARDGAME_windowSteps[step].kind) {
18 case 0:
19 screen->openWindow(screen, 2, 1, 0, CARDGAME_getStepWindowPos(layout, 0, 0), CARDGAME_getStepWindowPos(layout, 0, 1));
20 screen->openWindow(screen, 4, 2, 0, CARDGAME_getStepWindowPos(layout, 1, 0), CARDGAME_getStepWindowPos(layout, 1, 1));
21 if (text != 0) {
22 screen->openWindow(screen, 0, 0, text, 0, 0x42);
23 }
24 if (battle->effectStep.id == 0x9A) {
25 screen->openWindow(screen, 5, 4, 0x24, 0, 0x14);
26 }
27 break;
28 case 1:
29 screen->openWindow(screen, 3, 1, 0, CARDGAME_getStepWindowPos(layout, 2, 0), CARDGAME_getStepWindowPos(layout, 2, 1));
30 break;
31 case 2:
32 screen->openWindow(screen, 1, 3, 0, CARDGAME_getStepWindowPos(layout, 3, 0), CARDGAME_getStepWindowPos(layout, 3, 1));
33 break;
34 }
35 if (step < 3) {
36 step++;
37 }
38 }
39 return step;
40}
41
42/* Opens the panels and asks message value; the European and Japanese versions
43 start on the second choice when none of the player's hand can be played */
44void CARDGAME_startQuestion(CardBattle *battle, CardScreen *screen, s32 value) {
45#if VERSION_EU || VERSION_JP
46 s32 i;
47 s32 found;
48#endif
49
50 battle->effectStep.choice = 0;
51 battle->effectStep.state = 0;
52 if (screen->panels[0].state == 0) {
55 screen->openPanels(screen);
56 }
57 battle->effectStep.time = 0;
58 screen->message.message = value;
59#if VERSION_US
60 screen->message.choice = 0;
61 screen->message.place = 0;
62#elif VERSION_EU || VERSION_JP
63 screen->message.place = 0;
64 found = 0;
65 for (i = 0; i < battle->sides[0].pile.handCount; i++) {
66 if (CARDGAME_canPlayCard(battle, battle->sides[0].pile.points, battle->sides[0].pile.hand[i])) {
67 found = 1;
68 break;
69 }
70 }
71 if (found) {
72 screen->message.choice = 0;
73 battle->effectStep.choice = 0;
74 battle->effectStep.vars[4] = 2;
75 } else {
76 screen->message.choice = 1;
77 battle->effectStep.choice = 1;
78 battle->effectStep.vars[4] = 3;
79 }
80#endif
81}
82
83/* The yes/no window's buttons: cross answers, triangle answers the second
84 choice, up and down change the choice, L1 or R1 moves the window and
85 circle opens the battle menu */
86static inline void readYesNoInput(CardBattle *battle, CardScreen *screen) {
88 screen->confirmMessage(screen);
89 battle->effectStep.state = 7;
90 } else if (PAD_PRESSED(PAD_TRIANGLE)) {
91 battle->effectStep.choice = 1;
92 screen->setMessageChoice(screen, 1);
93 screen->confirmMessage(screen);
94 battle->effectStep.state = 7;
95#if VERSION_US
96 } else if (PAD_PRESSED(PAD_UP) || PAD_PRESSED(PAD_DOWN)) {
97#elif VERSION_EU || VERSION_JP
98 } else if ((PAD_PRESSED(PAD_UP) || PAD_PRESSED(PAD_DOWN)) && battle->effectStep.vars[4] == 2) {
99#endif
101 battle->effectStep.choice ^= 1;
102 screen->setMessageChoice(screen, battle->effectStep.choice);
103 } else if ((!PAD_HELD(PAD_R1) && PAD_PRESSED(PAD_L1)) || (!PAD_HELD(PAD_L1) && PAD_PRESSED(PAD_R1))) {
104 screen->closeMessage(screen);
105 battle->effectStep.state = 6;
106 } else if (PAD_PRESSED(PAD_CIRCLE)) {
107 screen->closeMessage(screen);
108 battle->effectStep.time = 0;
109 battle->effectStep.state = 3;
110 }
111}
112
113/* Closes the panels and opens the battle menu once they are closed */
114static inline void hideForMenu(CardBattle *battle, CardScreen *screen) {
115 switch (battle->effectStep.time) {
116 case 0:
117 if (screen->message.state == 0) {
119 screen->closePanels(screen);
120 battle->effectStep.time = 1;
121 }
122 break;
123 case 1:
124 if (screen->panels[0].state == 0 && battle->anim.current == CARD_ANIM_NONE) {
125 battle->run = CARD_RUN_MENU;
126 battle->record.menuState = 0;
127 battle->effectStep.state = 4;
128 }
129 break;
130 }
131}
132
133/* Back from the battle menu: reopens the yes/no window once the panels are open again */
134static inline void showAfterMenu(CardBattle *battle, CardScreen *screen) {
135 switch (battle->effectStep.time) {
136 case 0:
137 if (battle->anim.current == CARD_ANIM_NONE && screen->panels[0].state == 2) {
138#if VERSION_US
139 screen->openMessage(screen, screen->message.message, 1, screen->message.choice, screen->message.place);
140#elif VERSION_EU || VERSION_JP
141 screen->openMessage(screen, screen->message.message, battle->effectStep.vars[4], screen->message.choice, screen->message.place);
142#endif
143 battle->effectStep.time = 1;
144 }
145 break;
146 case 1:
147 if (screen->message.state == 2) {
148 battle->effectStep.state = 2;
149 }
150 break;
151 }
152}
153
154/* Runs the yes/no window that CARDGAME_startQuestion sets up: 1 for the first choice, 2 for the second, 0 until then */
156 s32 result = 0;
157
158 switch (battle->effectStep.state) {
159 case 0:
160 battle->effectStep.time += GFX.funcs.getFrameTime();
161 if (battle->effectStep.time >= 36 && battle->anim.current == CARD_ANIM_NONE) {
162#if VERSION_US
163 battle->effectStep.state = 1;
164 battle->effectStep.time = 0;
165 screen->openMessage(screen, screen->message.message, 1, screen->message.choice, screen->message.place);
166#elif VERSION_EU || VERSION_JP
167 battle->effectStep.time = 0;
168 if (battle->record.playCount != 0 && battle->effectStep.vars[4] == 3) {
169 battle->effectStep.state = 8;
170 } else {
171 battle->effectStep.state = 1;
172 screen->openMessage(screen, screen->message.message, battle->effectStep.vars[4], screen->message.choice, screen->message.place);
173 }
174#endif
175 }
176 break;
177 case 2:
178 readYesNoInput(battle, screen);
179 break;
180 case 6:
181 if (screen->message.state == 0) {
182 screen->message.place ^= 2;
183#if VERSION_US
184 screen->openMessage(screen, screen->message.message, 1, screen->message.choice, screen->message.place);
185#elif VERSION_EU || VERSION_JP
186 screen->openMessage(screen, screen->message.message, battle->effectStep.vars[4], screen->message.choice, screen->message.place);
187#endif
188 battle->effectStep.state = 1;
189 }
190 break;
191 case 7:
192 if (screen->message.state == 0) {
193 if (battle->effectStep.choice == 0) {
194 battle->effectStep.state = 9;
196 screen->closePanels(screen);
197 } else {
198 battle->effectStep.state = 8;
199 }
200 }
201 break;
202 case 3:
203 hideForMenu(battle, screen);
204 break;
205 case 4:
208 screen->openPanels(screen);
209 battle->effectStep.state = 5;
210 battle->effectStep.time = 0;
211 break;
212 case 5:
213 showAfterMenu(battle, screen);
214 break;
215 case 1:
216 if (screen->message.state == 2) {
217 battle->effectStep.state = 2;
218 }
219 break;
220 case 9:
221 if (screen->panels[0].state != 0 || battle->anim.current != CARD_ANIM_NONE) {
222 break;
223 }
224 /* fallthrough */
225 case 8:
226 result = 2;
227 if (battle->effectStep.choice == 0) {
228 result = 1;
229 }
230 break;
231 }
232 return result;
233}
234
235/* Empties the card information windows 1-4 */
237 screen->windows[1].showCount = 0;
238 screen->windows[1].value = 0;
239 screen->windows[2].value = 0;
240 screen->windows[3].value = 0;
241 screen->windows[4].value = 0;
242}
243
244/* Fills the information windows with the card of sprite offset + effectStep.cursor (the
245 highlighted one): its colour, name, picture or values, and kind */
246void CARDGAME_showCardInfo(CardBattle *battle, CardScreen *screen, s32 offset) {
247 CardDrawer drawer;
248 s32 i;
249 s32 found;
250 s32 card;
251 s32 id;
252
253 CARDGAME_clearCardInfo(battle, screen);
254 if (screen->sprites[offset + battle->effectStep.cursor].isKind16 != 0) {
255 screen->windows[1].value |= screen->sprites[offset + battle->effectStep.cursor].points;
256 screen->windows[1].value |= screen->sprites[offset + battle->effectStep.cursor].color << 4;
257 screen->windows[1].showCount = 1;
258 }
259 found = 0;
260 if (screen->sprites[offset + battle->effectStep.cursor].visible != 3) {
261 card = battle->cards[screen->sprites[offset + battle->effectStep.cursor].index] + 1;
262 screen->windows[2].value = card;
263 for (i = 0; i < 5; i++) {
264 if (CARDGAME_countingCards[i] == battle->cards[screen->sprites[offset + battle->effectStep.cursor].index]) {
265 found = 1;
266 }
267 }
268 if (screen->sprites[offset + battle->effectStep.cursor].isKind16 != 0 && found == 0) {
269 screen->windows[4].value = 500;
270 screen->windows[4].numbers[2] = 1;
271 screen->windows[4].numbers[0] = screen->sprites[offset + battle->effectStep.cursor].ap;
272 screen->windows[4].numbers[1] = screen->sprites[offset + battle->effectStep.cursor].hp;
273 } else {
274 screen->windows[4].numbers[2] = 0;
275 screen->windows[4].value = card;
276 }
277 id = battle->cards[screen->sprites[offset + battle->effectStep.cursor].index];
278 initCardDrawer(&drawer);
279 drawer.setCard(id + 1);
280 switch (drawer.card->level) {
281 case 0:
282 screen->windows[3].value = 0;
283 break;
284 case 1:
285 screen->windows[3].value = 0x25;
286 break;
287 case 2:
288 screen->windows[3].value = 0x26;
289 break;
290 case 3:
291 screen->windows[3].value = 0x27;
292 break;
293 case 4:
294 screen->windows[3].value = 0x28;
295 break;
296 case 5:
297 screen->windows[3].value = 0x29;
298 break;
299 }
300 } else {
301 screen->windows[4].numbers[2] = 0;
302 screen->windows[4].value = 500;
303 }
304}
305
306/* CARDGAME_showCardInfo for the highlighted card of a row (kind 0, 1 or 2, as
307 CARDGAME_moveTableHighlight) */
309 s32 offset = 0;
310
311 switch (kind) {
312 case 1:
313 offset = 6;
314 break;
315 case 2:
316 offset = 12;
317 break;
318 }
319 CARDGAME_showCardInfo(battle, screen, offset);
320}
CARDGAME.PRO: the card battle (mode 0x700).
void initCardDrawer(CardDrawer *obj)
Clears a card drawer, gives it its methods and binds it.
@ CARD_RUN_MENU
Definition battle.h:74
#define CARD_ANIM_UNDIM_ALL
CardAnim.dimAll.
Definition battle.h:189
@ CARD_ANIM_HIDE_SLOTS
Definition battle.h:169
@ CARD_ANIM_SHOW_SLOTS
Definition battle.h:168
@ CARD_ANIM_NONE
Definition battle.h:167
s16 CARDGAME_stepWindowPositions[2][3][4][2]
three sets of four positions, then the same moved for SHIFT_PAL_SCREEN
Definition cardgame_2.c:6
CardBattleStep CARDGAME_windowSteps[]
Definition cardgame_2.c:21
s16 CARDGAME_countingCards[]
five card ids, minus one
Definition cardgame_3.c:134
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
s32 SHIFT_PAL_SCREEN
moves both display areas 0x18 lines down
Definition eu_settings.c:15
#define PAD_CROSS
Definition pad.h:31
#define PAD_CIRCLE
Definition pad.h:30
#define PAD_DOWN
Definition pad.h:24
#define PAD_TRIANGLE
Definition pad.h:32
#define PAD_PRESSED(button)
One button of pad 1: newly pressed, auto-repeated while held, or held.
Definition pad.h:140
#define PAD_UP
Definition pad.h:22
#define PAD_L1
Definition pad.h:28
#define PAD_HELD(button)
Definition pad.h:142
#define PAD_R1
Definition pad.h:29
s32 CARDGAME_canPlayCard(CardBattle *battle, u8 *points, s32 card)
Whether a card can be played: in CARD_PHASE_PUT_OUT a kind 0x10 card needs as many points of its colo...
Definition play_checks.c:57
static void readYesNoInput(CardBattle *battle, CardScreen *screen)
The yes/no window's buttons: cross answers, triangle answers the second choice, up and down change th...
Definition questions.c:86
static void hideForMenu(CardBattle *battle, CardScreen *screen)
Closes the panels and opens the battle menu once they are closed.
Definition questions.c:114
void CARDGAME_startQuestion(CardBattle *battle, CardScreen *screen, s32 value)
Opens the panels and asks message value; the European and Japanese versions start on the second choic...
Definition questions.c:44
s16 CARDGAME_getStepWindowPos(s32 a, s32 b, s32 c)
A position of CARDGAME_stepWindowPositions.
Definition questions.c:6
void CARDGAME_showCardInfo(CardBattle *battle, CardScreen *screen, s32 offset)
Fills the information windows with the card of sprite offset + effectStep.cursor (the highlighted one...
Definition questions.c:246
void CARDGAME_clearCardInfo(CardBattle *battle, CardScreen *screen)
Empties the card information windows 1-4.
Definition questions.c:236
s32 CARDGAME_stepYesNo(CardBattle *battle, CardScreen *screen)
Runs the yes/no window that CARDGAME_startQuestion sets up: 1 for the first choice,...
Definition questions.c:155
static void showAfterMenu(CardBattle *battle, CardScreen *screen)
Back from the battle menu: reopens the yes/no window once the panels are open again.
Definition questions.c:134
s32 CARDGAME_openStepWindows(CardBattle *battle, CardScreen *screen, s32 layout, s32 text, s32 time, s32 step)
Opens the windows of the step CARDGAME_windowSteps[step] once its time is past; the next step.
Definition questions.c:15
void CARDGAME_showTableCardInfo(CardBattle *battle, CardScreen *screen, s32 kind)
CARDGAME_showCardInfo for the highlighted card of a row (kind 0, 1 or 2, as CARDGAME_moveTableHighlig...
Definition questions.c:308
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
#define SOUND_CURSOR
SYSTEM02: a cursor moves.
Definition sound.h:40
u8 next
the one to start
Definition battle.h:195
u8 current
a CardAnimId
Definition battle.h:194
u8 dimAll
sets dimmed of the first 15 sprites once
Definition battle.h:199
The card battle (CARDGAME_createBattle).
Definition battle.h:226
u8 run
what runs this frame (CARD_RUN_*)
Definition battle.h:238
CardRecord record
Definition battle.h:273
s16 cards[250]
card ids, minus one (CARDGAME_loadCardImages)
Definition battle.h:228
CardAnim anim
Definition battle.h:263
CardStep effectStep
Definition battle.h:262
CardSide sides[2]
Definition battle.h:274
Draws the cards' images (CardImage), from files 0x7E7-0x7EB.
Definition gfx.h:193
void(* setCard)()
(id)
Definition gfx.h:205
CardImage * card
Definition gfx.h:194
u8 level
a Digimon's, 2-5 (CARDGAME shows its name); 0 on the other cards
Definition gfx.h:180
s16 choice
the cursor's row
Definition screen.h:254
u8 state
1 opening, 2 open, 4 confirmed, 5 closing
Definition screen.h:256
s32 place
in CARDGAME_messageWindowPositions
Definition screen.h:249
s16 state
Definition screen.h:137
s16 handCount
Definition battle.h:114
u8 points[5]
one per card colour
Definition battle.h:115
s16 hand[10]
handCount in use
Definition battle.h:119
u8 menuState
CARDGAME_runBattleMenu's state.
Definition battle.h:126
s8 playCount
the plays in use
Definition battle.h:130
The battle screen (created by CARDGAME_createScreen): the two panels, the cards on the table and the ...
Definition screen.h:263
CardMessageWindow message
Definition screen.h:274
void(* openWindow)(struct CardScreen *screen, s32 index, s16 layout, s32 value, s32 x, s32 y)
Definition screen.h:288
void(* openPanels)(struct CardScreen *screen)
Definition screen.h:295
void(* setMessageChoice)(struct CardScreen *screen, s32 choice)
Definition screen.h:305
CardSprite sprites[40]
Definition screen.h:271
void(* openMessage)(struct CardScreen *screen, s32 message, s32 prompt, s16 choice, s32 place)
Definition screen.h:302
void(* confirmMessage)(struct CardScreen *screen)
Definition screen.h:304
void(* closePanels)(struct CardScreen *screen)
Definition screen.h:294
CardWindow windows[6]
Definition screen.h:281
void(* closeMessage)(struct CardScreen *screen)
Definition screen.h:303
CardPanel panels[2]
Definition screen.h:270
CardPile pile
Definition battle.h:160
s16 index
in the battle's card list
Definition screen.h:183
u8 ap
the values shown, which count towards the slot's
Definition screen.h:188
s16 color
the card's colour, from 0
Definition screen.h:182
u8 points
the card's
Definition screen.h:186
u8 visible
Definition screen.h:190
s16 isKind16
Definition screen.h:184
u8 id
the step running
Definition battle.h:144
s32 cursor
the card or slot highlighted
Definition battle.h:150
s32 time
a frame count, or the step's own sub-state
Definition battle.h:148
u8 state
the step's own state
Definition battle.h:146
s32 vars[5]
values each step uses its own way
Definition battle.h:149
s32 choice
the card, slot or answer chosen; -1 for none
Definition battle.h:151
u8 numbers[3]
two numbers, and whether they are shown
Definition screen.h:242
s16 showCount
Definition screen.h:240
s32 value
by its layout: a string, a card, or points | colour << 4
Definition screen.h:241
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