Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
hand_pick.c
Go to the documentation of this file.
1/* CARDGAME's picks of cards from a hand or a pile, by the player or the
2 computer's flags, then the tally, the step messages and the coin toss
3 that picks the first player (one module: cut between them, the tally's
4 jump table would lose its alignment). */
5
7
8/* Starts a pick from pile's hand: flags (effectStep.eligible) the cards that can be
9 played, and opens the player's panel */
11 s32 i;
12
13 if (pile->handCount != 0) {
14 for (i = 0; i < 40; i++) {
15 battle->effectStep.eligible[i] = 0;
16 battle->effectStep.marked[i] = 0;
17 if (i < pile->handCount) {
18 if (CARDGAME_canPlayCard(battle, pile->points, pile->hand[i])) {
19 battle->effectStep.eligible[i] = 1;
20 battle->anim.dimmed[i] = 0;
21 } else {
22 battle->anim.dimmed[i] = 1;
23 }
24 }
25 }
26 } else {
27 battle->anim.dimmed[0] = 0;
28 }
29 screen->resetPanels(screen);
30 if (pile->side == 0) {
32 screen->openPanel(screen, pile->side);
33 } else {
35 }
36 battle->effectStep.nextState = 1;
37 CARDGAME_clearCardInfo(battle, screen);
38 battle->effectStep.cursor = 0;
39 battle->effectStep.choice = -1;
40}
41
42/* Starts a pick of the cards (all when all > 0) in mode (anim.next) */
43void CARDGAME_startPick(CardBattle *battle, CardScreen *screen, s32 all, s32 mode) {
44 s32 i;
45
46 if (all > 0) {
47 for (i = 0; i < 40; i++) {
48 battle->anim.dimmed[i] = 0;
49 }
50 } else {
51 battle->anim.dimmed[0] = 0;
52 }
53 CARDGAME_clearCardInfo(battle, screen);
54 battle->effectStep.nextState = 1;
55 battle->anim.next = mode;
56 battle->effectStep.cursor = 0;
57 battle->effectStep.choice = -1;
58}
59
60/* Moves the selection by STEP among COUNT cards: the selected card is raised */
61void CARDGAME_moveSelection(CardBattle *battle, CardScreen *screen, s32 count, s32 step) {
63 screen->startSlide(screen, battle->effectStep.cursor, 5, screen->getHandOffset(count, battle->effectStep.cursor) + 0x1800, 0x6100);
64 screen->sprites[battle->effectStep.cursor].highlight &= ~1;
65 screen->sprites[battle->effectStep.cursor].moving = 0;
66 battle->effectStep.cursor += step;
67 screen->startSlide(screen, battle->effectStep.cursor, 1, screen->getHandOffset(count, battle->effectStep.cursor) + 0x1800, 0x5C00);
68 screen->sprites[battle->effectStep.cursor].highlight |= 1;
69 screen->sprites[battle->effectStep.cursor].moving = 1;
70}
71
72/* Moves the selection by STEP among the cards of PILE's hand: the selected card is raised */
73void CARDGAME_movePileSelection(CardBattle *battle, CardScreen *screen, CardPile *pile, s32 step) {
75 screen->startSlide(screen, battle->effectStep.cursor, 5, screen->getHandOffset(pile->handCount, battle->effectStep.cursor) + 0x1800, 0x6100);
76 screen->sprites[battle->effectStep.cursor].highlight &= ~1;
77 screen->sprites[battle->effectStep.cursor].moving = 0;
78 battle->effectStep.cursor += step;
79 screen->startSlide(screen, battle->effectStep.cursor, 1, screen->getHandOffset(pile->handCount, battle->effectStep.cursor) + 0x1800, 0x5C00);
80 screen->sprites[battle->effectStep.cursor].highlight |= 1;
81 screen->sprites[battle->effectStep.cursor].moving = 1;
82}
83
84/* Flags (effectStep.eligible) the cards of pile's hand that can be played and aren't
85 picked (effectStep.marked), and dims the others */
87 s32 i;
88
89 for (i = 0; i < pile->handCount; i++) {
90 if (CARDGAME_canPlayCard(battle, pile->points, pile->hand[i]) && battle->effectStep.marked[i] == 0) {
91 battle->effectStep.eligible[i] = 1;
92 screen->sprites[i].dimmed = 0;
93 } else {
94 battle->effectStep.eligible[i] = 0;
95 if (battle->effectStep.marked[i] == 0) {
96 screen->sprites[i].dimmed = 1;
97 } else {
98 screen->sprites[i].dimmed = 0;
99 }
100 }
101 }
102}
103
104/* Whether the pick is over: six cards picked (effectStep.count), or none left that can
105 be played */
107 s32 ok = 1;
108 s32 i;
109
110 if (battle->effectStep.count < 6) {
111 for (i = 0; i < pile->handCount; i++) {
112 if (battle->effectStep.eligible[i] != 0) {
113 ok = 0;
114 break;
115 }
116 }
117 }
118 return ok;
119}
120
121/* Adds a card's points to pile's points of its colour (takes them when add is
122 0), on the panel */
123void CARDGAME_addCardPoints(CardBattle *battle, CardScreen *screen, CardPile *pile, s32 add, s32 card) {
124 CardDrawer drawer;
125
126 initCardDrawer(&drawer);
127 drawer.setCard(battle->cards[card] + 1);
128 if (drawer.card->color < 6) {
129 if (add) {
130 pile->points[drawer.card->color - 1] += drawer.card->points;
131 } else {
132 pile->points[drawer.card->color - 1] -= drawer.card->points;
133 }
134 screen->setPanelValue(screen, pile->side, drawer.card->color - 1, pile->points[drawer.card->color - 1]);
135 }
136}
137
138/* Picks or puts back the selected card of PILE's hand: 1 picked, 2 put back, 0 neither */
140 s32 result = 0;
141
142 if (battle->effectStep.eligible[battle->effectStep.cursor] != 0) {
143 if (battle->effectStep.count < 6) {
144 CARDGAME_addCardPoints(battle, screen, pile, 0, pile->hand[battle->effectStep.cursor]);
145 battle->effectStep.marked[battle->effectStep.cursor] = 1;
146 screen->startBlink(screen, battle->effectStep.cursor);
147 screen->sprites[battle->effectStep.cursor].highlight |= 2;
148 result = 1;
149 battle->effectStep.count++;
150 }
151 } else if (battle->effectStep.marked[battle->effectStep.cursor] != 0) {
152 CARDGAME_addCardPoints(battle, screen, pile, 1, pile->hand[battle->effectStep.cursor]);
153 battle->effectStep.marked[battle->effectStep.cursor] = 0;
154 screen->sprites[battle->effectStep.cursor].highlight &= ~2;
155 result = 2;
156 battle->effectStep.count--;
157 }
158 return result;
159}
160
161/* Reads the pad while a card of PILE's hand is being chosen: Left/Right move, Cross picks, Triangle cancels */
163 screen->sprites[battle->effectStep.cursor].highlight |= 1;
164 screen->sprites[battle->effectStep.cursor].moving = 1;
167 battle->effectStep.choice = -1;
168 battle->effectStep.nextState = 14;
169 }
170 if (PAD_PRESSED(PAD_CIRCLE)) {
171 battle->effectStep.nextState = 11;
172 }
173 if (pile->handCount != 0) {
174 if ((PAD.getRepeated(0) & (1 << PAD.getButtonBit(0, PAD_LEFT))) |
175 (PAD.getPressed(0) & (1 << PAD.getButtonBit(0, PAD_LEFT)))) {
176 if (battle->effectStep.cursor > 0) {
177 CARDGAME_movePileSelection(battle, screen, pile, -1);
178 }
179 } else if ((PAD.getRepeated(0) & (1 << PAD.getButtonBit(0, PAD_RIGHT))) |
180 (PAD.getPressed(0) & (1 << PAD.getButtonBit(0, PAD_RIGHT)))) {
181 if (battle->effectStep.cursor < pile->handCount - 1) {
182 CARDGAME_movePileSelection(battle, screen, pile, 1);
183 }
184 } else if (PAD_PRESSED(PAD_CROSS) && battle->effectStep.eligible[battle->effectStep.cursor] != 0) {
185 battle->effectStep.nextState = 5;
186 battle->effectStep.choice = battle->effectStep.cursor;
187 battle->effectStep.marked[battle->effectStep.choice] = 1;
188 }
189 }
190}
191
192/* Reads the pad while cards of PILE's hand are being picked: Left/Right move, Cross picks or puts back, Square and Circle end */
194 screen->sprites[battle->effectStep.cursor].highlight |= 1;
195 screen->sprites[battle->effectStep.cursor].moving = 1;
196 if (PAD_PRESSED(PAD_SQUARE)) {
197 battle->effectStep.nextState = 6;
198 }
199 if (PAD_PRESSED(PAD_CIRCLE)) {
200 battle->effectStep.nextState = 11;
201 }
202 if (pile->handCount != 0) {
203 if ((PAD.getRepeated(0) & (1 << PAD.getButtonBit(0, PAD_LEFT))) |
204 (PAD.getPressed(0) & (1 << PAD.getButtonBit(0, PAD_LEFT)))) {
205 if (battle->effectStep.cursor > 0) {
206 CARDGAME_movePileSelection(battle, screen, pile, -1);
207 }
208 } else if ((PAD.getRepeated(0) & (1 << PAD.getButtonBit(0, PAD_RIGHT))) |
209 (PAD.getPressed(0) & (1 << PAD.getButtonBit(0, PAD_RIGHT)))) {
210 if (battle->effectStep.cursor < pile->handCount - 1) {
211 CARDGAME_movePileSelection(battle, screen, pile, 1);
212 }
213 } else if (PAD_PRESSED(PAD_CROSS) && CARDGAME_togglePick(battle, screen, pile)) {
214 battle->effectStep.nextState = 4;
215 }
216 }
217}
218
219/* Reads the pad while one of COUNT cards is being chosen: Left/Right move, Triangle cancels */
220void CARDGAME_readCountInput(CardBattle *battle, CardScreen *screen, s32 count) {
221 screen->sprites[battle->effectStep.cursor].highlight |= 1;
222 screen->sprites[battle->effectStep.cursor].moving = 1;
225 battle->effectStep.choice = -1;
226 battle->effectStep.nextState = 10;
227 }
228 if (count != 0) {
229 if (((PAD.getRepeated(0) & (1 << PAD.getButtonBit(0, PAD_LEFT))) |
230 (PAD.getPressed(0) & (1 << PAD.getButtonBit(0, PAD_LEFT)))) &&
231 battle->effectStep.cursor > 0) {
232 CARDGAME_moveSelection(battle, screen, count, -1);
233 }
234 if (((PAD.getRepeated(0) & (1 << PAD.getButtonBit(0, PAD_RIGHT))) |
235 (PAD.getPressed(0) & (1 << PAD.getButtonBit(0, PAD_RIGHT)))) &&
236 battle->effectStep.cursor < count - 1) {
237 CARDGAME_moveSelection(battle, screen, count, 1);
238 }
239 }
240}
241
242/* Scales the highlighted sprite up to 1.25 and back, 5 frames each; 1 once
243 done */
245 s32 done = 0;
246
247 switch (battle->effectStep.time) {
248 case 0:
249 default:
250 screen->scaleSprite(screen, battle->effectStep.cursor, 5, 0x1400, 0x1400);
251 battle->effectStep.vars[0] = 0;
252 battle->effectStep.time++;
253 break;
254 case 1:
255 battle->effectStep.vars[0] += GFX.funcs.getFrameTime();
256 if (battle->effectStep.vars[0] >= 5) {
257 battle->effectStep.time++;
258 }
259 break;
260 case 2:
261 screen->scaleSprite(screen, battle->effectStep.cursor, 5, 0x1000, 0x1000);
262 battle->effectStep.vars[0] = 0;
263 battle->effectStep.time++;
264 break;
265 case 3:
266 battle->effectStep.vars[0] += GFX.funcs.getFrameTime();
267 if (battle->effectStep.vars[0] >= 5) {
268 done = 1;
269 }
270 break;
271 }
272 return done;
273}
274
275/* Hides the hand and the choice's windows for the battle menu */
276static inline void hideHandForMenu(CardBattle *battle, CardScreen *screen, CardPile *pile) {
277 battle->anim.next = battle->anim.hide;
278 CARDGAME_promptText = screen->windows[0].value;
279 battle->effectStep.time = battle->anim.hide;
280 screen->closeWindow(screen, 4);
281 screen->closeWindow(screen, 0);
282 screen->closeWindow(screen, 1);
283 screen->closeWindow(screen, 2);
284 screen->closeWindow(screen, 3);
285 if (battle->effectStep.id == 0x9A) {
286 screen->closeWindow(screen, 5);
287 }
288 if (pile->side == 0) {
289 screen->closePanel(screen, 0);
290 }
291}
292
293/* Back from the battle menu: shows the hand again, the cards that can't be
294 played dimmed, and reopens the choice's windows */
295static inline void showHandAfterMenu(CardBattle *battle, CardScreen *screen, CardPile *pile) {
296 s32 j;
297
298 CARDGAME_promptText = 0x19;
299 battle->effectStep.vars[0] = 0;
300 battle->anim.next = battle->effectStep.time - 1;
301 switch (battle->effectStep.id) {
302 case 0x99:
303 case 0x9A:
304 case 0x9D:
305 for (j = 0; j < pile->handCount; j++) {
306 if (CARDGAME_canPlayCard(battle, pile->points, pile->hand[j])) {
307 battle->anim.dimmed[j] = 0;
308 } else {
309 battle->anim.dimmed[j] = 1;
310 }
311 }
312 break;
313 }
314 screen->openWindow(screen, 0, 0, CARDGAME_promptText, 0, 0x42);
315 screen->openWindow(screen, 2, 1, 0, 0x82, 0xA5);
316 screen->openWindow(screen, 4, 2, 0, 0x86, 0x31);
317 screen->openWindow(screen, 3, 1, 0, 0x82, 0x90);
318 screen->openWindow(screen, 1, 3, 0, 0xFD, 0x90);
319 if (battle->effectStep.id == 0x9A) {
320 screen->openWindow(screen, 5, 4, 0x24, 0, 0x14);
321 }
322 if (pile->side == 0) {
323 screen->openPanel(screen, 0);
324 }
325}
326
327/* Starts the state of the card choice effectStep.nextState asks for: its
328 prompt, windows and dimmed cards */
329static inline void startChooseState(CardBattle *battle, CardScreen *screen, CardPile *pile) {
330 s32 i;
331 s32 j;
332
333 switch (battle->effectStep.nextState) {
334 case 1:
335 case 2:
336 switch (battle->effectStep.id) {
337 case 0x99:
338 if (pile->side != 0) {
339 CARDGAME_promptText = 0x1C;
340 } else {
341 CARDGAME_promptText = 0x19;
342 }
343 break;
344 case 0x9D:
345 CARDGAME_promptText = 0x1C;
346 break;
347 case 0x9C:
348 CARDGAME_promptText = 0x1B;
349 break;
350 case 0x9A:
351 case 0x9B:
352 CARDGAME_promptText = 0x19;
353 break;
354 }
355 battle->effectStep.vars[1] = 0;
356 battle->effectStep.vars[0] = 0;
357 battle->effectStep.time = 0;
358 battle->effectStep.choice = 0;
359 battle->effectStep.count = 0;
360 break;
361 case 5:
363 battle->effectStep.vars[0] = 0;
364 battle->effectStep.time = 0;
365 break;
366 case 4:
368 break;
369 case 14:
370 if (pile->side == 0) {
371 battle->anim.next = CARD_ANIM_HIDE_HAND;
372 screen->closePanel(screen, 0);
373 } else {
375 }
376 battle->effectStep.vars[0] = 0;
377 battle->effectStep.time = 0;
378 screen->closeWindow(screen, 4);
379 screen->closeWindow(screen, 0);
380 screen->closeWindow(screen, 1);
381 screen->closeWindow(screen, 2);
382 screen->closeWindow(screen, 3);
383 break;
384 case 10:
385 battle->effectStep.vars[0] = 0;
386 battle->effectStep.time = 0;
387 battle->anim.next = battle->anim.hide;
388 screen->closeWindow(screen, 4);
389 screen->closeWindow(screen, 0);
390 screen->closeWindow(screen, 1);
391 screen->closeWindow(screen, 2);
392 screen->closeWindow(screen, 3);
393 break;
394 case 6:
395 battle->effectStep.vars[0] = 0;
396 battle->effectStep.time = 0;
397 CARDGAME_promptText = screen->windows[0].value;
398 for (i = 0; i < pile->handCount; i++) {
399 if (battle->effectStep.marked[i] != 0) {
400 screen->sprites[i].dimmed = 0;
401 screen->sprites[i].highlight |= 4;
402 } else {
403 screen->sprites[i].dimmed = 1;
404 }
405 }
406 break;
407 case 7:
408 battle->effectStep.choice = 0;
409 battle->effectStep.time = 0;
410 break;
411 case 3:
412 case 8:
413 battle->effectStep.vars[0] = 0;
414 battle->effectStep.time = 0;
415 break;
416 case 11:
417 hideHandForMenu(battle, screen, pile);
418 break;
419 case 13:
420 showHandAfterMenu(battle, screen, pile);
421 break;
422 case 9:
423 battle->effectStep.vars[0] = 0;
424 battle->effectStep.time = 0;
425 for (j = 0; j < pile->handCount; j++) {
426 if (CARDGAME_canPlayCard(battle, pile->points, pile->hand[j])) {
427 screen->sprites[j].dimmed = 0;
428 } else {
429 screen->sprites[j].dimmed = 1;
430 }
431 if (battle->effectStep.marked[j] != 0) {
432 screen->sprites[j].dimmed = 0;
433 screen->sprites[j].highlight &= ~4;
434 }
435 }
436 break;
437 }
438}
439
440/* Puts the highlighted card back in the hand and opens the confirm message */
441static inline void askToConfirm(CardBattle *battle, CardScreen *screen, CardPile *pile) {
442 switch (battle->effectStep.time) {
443 case 0:
444 screen->closeWindow(screen, 4);
445 screen->closeWindow(screen, 0);
446 screen->closeWindow(screen, 5);
447 screen->startMove(screen, battle->effectStep.cursor, 5, screen->getHandOffset(pile->handCount, battle->effectStep.cursor) + 0x1800, 0x6100);
448 screen->sprites[battle->effectStep.cursor].highlight &= ~1;
449 screen->sprites[battle->effectStep.cursor].moving = 0;
450 break;
451 case 6:
452 screen->openMessage(screen, 15, 1, 0, 2);
453 break;
454 }
455}
456
457/* After a no to the confirm message: reopens the choice's windows, then
458 lifts the highlighted card again and choosing goes on (state 3) */
459static inline void backToChoosing(CardBattle *battle, CardScreen *screen, CardPile *pile) {
460 switch (battle->effectStep.time) {
461 case 6:
462 break;
463 case 18:
464 screen->openWindow(screen, 0, 0, CARDGAME_promptText, 0, 0x42);
465 screen->openWindow(screen, 4, 2, 0, 0x86, 0x31);
466 screen->openWindow(screen, 5, 4, 0x24, 0, 0x14);
467 CARDGAME_showCardInfo(battle, screen, 0);
468 break;
469 }
470 if (++battle->effectStep.time > 30) {
471 battle->effectStep.nextState = 3;
472 screen->startMove(screen, battle->effectStep.cursor, 5, screen->getHandOffset(pile->handCount, battle->effectStep.cursor) + 0x1800, 0x5C00);
473 screen->sprites[battle->effectStep.cursor].highlight |= 1;
474 screen->sprites[battle->effectStep.cursor].moving = 1;
475 }
476}
477
478/* The answer to the confirm message: yes (effectStep.choice 0) ends the choice
479 (state 8), no or triangle goes back to choosing (state 9) */
480static inline void readConfirmInput(CardBattle *battle, CardScreen *screen) {
481 if (PAD_PRESSED(PAD_CROSS)) {
482 screen->confirmMessage(screen);
483 if (battle->effectStep.choice == 0) {
484 battle->effectStep.nextState = 8;
485 } else {
486 battle->effectStep.nextState = 9;
487 }
488 } else if (PAD_PRESSED(PAD_UP) || PAD_PRESSED(PAD_DOWN)) {
489 battle->effectStep.choice ^= 1;
491 screen->setMessageChoice(screen, battle->effectStep.choice);
492 } else if (PAD_PRESSED(PAD_TRIANGLE)) {
494 battle->effectStep.choice = 1;
495 screen->setMessageChoice(screen, 1);
496 screen->confirmMessage(screen);
497 battle->effectStep.nextState = 9;
498 }
499}
500
501/* The chosen cards pulse with a sound, then the hand and its windows close */
502static inline void showChosenCards(CardBattle *battle, CardScreen *screen, CardPile *pile) {
503 /* the match depends on a loop variable of its own for most loops:
504 sharing them gives GCC 2.8.1 other registers */
505 s32 k;
506 s32 m;
507 s32 count;
508
509 switch (battle->effectStep.time) {
510 case 20:
511 count = 0;
512 for (k = 0; k < pile->handCount; k++) {
513 if (battle->effectStep.marked[k] != 0) {
514 screen->scaleSprite(screen, k, 6, 0x1400, 0x1400);
515 count++;
516 }
517 }
518 if (count != 0) {
520 }
521 break;
522 case 25:
523 for (m = 0; m < pile->handCount; m++) {
524 if (battle->effectStep.marked[m] != 0) {
525 screen->scaleSprite(screen, m, 6, 0x1000, 0x1000);
526 }
527 }
528 break;
529 case 35:
530 if (pile->side == 0) {
531 battle->anim.next = CARD_ANIM_HIDE_HAND;
532 screen->closePanel(screen, 0);
533 } else {
535 }
536 screen->closeWindow(screen, 1);
537 screen->closeWindow(screen, 2);
538 screen->closeWindow(screen, 3);
539 break;
540 }
541}
542
543/* Back from the battle menu: once the hand is shown again, choosing goes on
544 with the picked cards highlighted */
545static inline void resumeChoosing(CardBattle *battle, CardScreen *screen, CardPile *pile) {
546 s32 n;
547
548 if (((pile->side == 0 && screen->panels[0].state == 2) || (pile->side != 0 && ++battle->effectStep.vars[0] > 10)) &&
549 battle->anim.current == CARD_ANIM_NONE) {
550 battle->effectStep.nextState = 3;
551 screen->startSlide(screen, battle->effectStep.cursor, 5, screen->getHandOffset(pile->handCount, battle->effectStep.cursor) + 0x1800, 0x5C00);
552 screen->sprites[battle->effectStep.cursor].highlight |= 1;
553 screen->sprites[battle->effectStep.cursor].moving = 1;
554 for (n = 0; n < pile->handCount; n++) {
555 if (battle->effectStep.marked[n] == 1) {
556 screen->sprites[n].dimmed = 0;
557 screen->sprites[n].highlight |= 2;
558 }
559 }
560 }
561}
562
563/* Choosing cards of PILE's hand to play: effectStep.nextState queues the next step (startChooseState). -1 while it runs, then 0 or 1 */
565 s32 result = -1;
566
567 if (battle->effectStep.nextState != 0) {
568 startChooseState(battle, screen, pile);
569 battle->effectStep.state = battle->effectStep.nextState;
570 battle->effectStep.nextState = 0;
571 }
572
573 switch (battle->effectStep.state) {
574 case 1:
575 battle->effectStep.vars[1] = CARDGAME_openStepWindows(battle, screen, 2, CARDGAME_promptText, battle->effectStep.time, battle->effectStep.vars[1]);
576 CARDGAME_showCardInfo(battle, screen, 0);
577 if (battle->anim.count * 4 + 14 < battle->effectStep.time) {
578 battle->effectStep.nextState = 3;
579 screen->startSlide(screen, 0, 5, 0x1800, 0x5C00);
580 screen->sprites[battle->effectStep.cursor].highlight |= 1;
581 screen->sprites[battle->effectStep.cursor].moving = 1;
582 }
583 battle->effectStep.time += GFX.funcs.getFrameTime();
584 break;
585 case 2:
586 screen->scaleSprite(screen, 0, 5, 0x1000, 0x1000);
587 if (battle->effectStep.time > 10) {
588 battle->effectStep.nextState = 3;
589 screen->startSlide(screen, 0, 5, 0x1800, 0x5C00);
590 screen->sprites[battle->effectStep.cursor].highlight |= 1;
591 screen->sprites[battle->effectStep.cursor].moving = 1;
592 }
593 battle->effectStep.time += GFX.funcs.getFrameTime();
594 break;
595 case 3:
596 switch (battle->effectStep.id) {
597 case 0x99:
598 CARDGAME_readChooseInput(battle, screen, pile);
599 break;
600 case 0x9A:
601 case 0x9D:
602 CARDGAME_readPickInput(battle, screen, pile);
603 break;
604 case 0x9B:
605 case 0x9C:
606 CARDGAME_readCountInput(battle, screen, battle->anim.count);
607 break;
608 }
609 CARDGAME_showCardInfo(battle, screen, 0);
610 break;
611 case 4:
612 if (screen->sprites[battle->effectStep.cursor].state == 1) {
613 CARDGAME_flagPlayableCards(battle, screen, pile);
614 if (CARDGAME_isHandPickDone(battle, screen, pile)) {
615 battle->effectStep.nextState = 6;
616 } else {
617 battle->effectStep.nextState = 3;
618 }
619 }
620 CARDGAME_showCardInfo(battle, screen, 0);
621 break;
622 case 5:
623 if (CARDGAME_stepPulseCard(battle, screen)) {
624 battle->effectStep.nextState = 14;
625 }
626 CARDGAME_showCardInfo(battle, screen, 0);
627 break;
628 case 14:
629 if (pile->handCount * 4 + 5 < battle->effectStep.time) {
630 battle->effectStep.nextState = 0;
631 battle->effectStep.next = 0;
632 battle->effectStep.id = 0;
633 battle->effectStep.next = 0;
634 result = battle->effectStep.choice != -1;
635 }
636 battle->effectStep.time += GFX.funcs.getFrameTime();
637 break;
638 case 10:
639 if (battle->anim.count * 4 + 14 < battle->effectStep.time) {
640 result = 0;
641 battle->effectStep.nextState = 0;
642 battle->effectStep.next = 0;
643 battle->effectStep.id = 0;
644 battle->effectStep.next = 0;
645 }
646 battle->effectStep.time += GFX.funcs.getFrameTime();
647 break;
648 case 6:
649 askToConfirm(battle, screen, pile);
650 if (++battle->effectStep.time > 18) {
651 battle->effectStep.nextState = 7;
652 }
653 break;
654 case 7:
655 readConfirmInput(battle, screen);
656 break;
657 case 8:
658 showChosenCards(battle, screen, pile);
659 if (++battle->effectStep.time > 45 && battle->anim.current == CARD_ANIM_NONE) {
660 result = 1;
661 }
662 break;
663 case 9:
664 backToChoosing(battle, screen, pile);
665 break;
666 case 11:
667 if (screen->panels[0].state == 0 && battle->anim.current == CARD_ANIM_NONE) {
668 battle->effectStep.nextState = 12;
669 battle->record.menuState = 0;
670 battle->run = CARD_RUN_MENU;
671 }
672 break;
673 case 12:
674 battle->effectStep.nextState = 13;
675 break;
676 case 13:
677 resumeChoosing(battle, screen, pile);
678 CARDGAME_showCardInfo(battle, screen, 0);
679 break;
680 }
681 return result;
682}
683
684/* Opens the panels for a step */
686 screen->resetPanels(screen);
687 battle->effectStep.choice = 0;
688 battle->effectStep.state = 1;
689 screen->openPanels(screen);
691 battle->anim.faceDown = 1;
693}
694
695/* Turns the opponent's slot cards over, then counts the panels' ap and hp up to each side's pile apTotal and hpTotal; 1 when done */
697 s32 done = 0;
698 s32 counting = 0;
699 s32 step;
700
701 switch (battle->effectStep.state) {
702 case 1:
703 if (screen->panels[0].state == 2 && battle->anim.current == CARD_ANIM_NONE) {
704 if (battle->players[0].slotCount + battle->players[1].slotCount == 0) {
705 battle->effectStep.state = 3;
706 battle->effectStep.time = 0;
707 battle->effectStep.vars[0] = 0;
708 battle->effectStep.vars[1] = 0;
709 battle->effectStep.vars[2] = 0;
710 battle->effectStep.vars[3] = 0;
711 } else {
712 battle->effectStep.state = 2;
713 battle->effectStep.time = 0;
714 battle->effectStep.vars[0] = 0;
715 battle->effectStep.vars[3] = 0;
716 if (battle->players[0].slotCount > battle->players[1].slotCount) {
717 battle->effectStep.vars[1] = battle->players[0].slotCount;
718 } else {
719 battle->effectStep.vars[1] = battle->players[1].slotCount;
720 }
721 battle->effectStep.vars[1] = battle->effectStep.vars[1] * 6 + 18;
722 }
723 }
724 break;
725 case 2:
726 if (battle->effectStep.vars[3] >= 6) {
727 if (battle->effectStep.vars[0] < battle->players[1].slotCount) {
728 screen->startFlip(screen, battle->effectStep.vars[0] + 6);
729 }
730 battle->effectStep.vars[0]++;
731 battle->effectStep.vars[3] -= 6;
732 }
733 if (battle->effectStep.time > battle->effectStep.vars[1]) {
734 battle->effectStep.state = 3;
735 battle->effectStep.time = 0;
736 battle->effectStep.vars[0] = 0;
737 battle->effectStep.vars[1] = 0;
738 battle->effectStep.vars[2] = 0;
739 battle->effectStep.vars[3] = 0;
740 }
741 battle->effectStep.time += GFX.funcs.getFrameTime();
742 battle->effectStep.vars[3] += GFX.funcs.getFrameTime();
743 break;
744 case 3:
745 step = battle->sides[0].pile.apTotal / 60;
746 battle->effectStep.vars[0] += step != 0 ? step : 1;
747 if (battle->effectStep.vars[0] > battle->sides[0].pile.apTotal) {
748 battle->effectStep.vars[0] = battle->sides[0].pile.apTotal;
749 } else {
750 counting = 1;
751 }
752 step = battle->sides[0].pile.hpTotal / 60;
753 battle->effectStep.vars[1] += step != 0 ? step : 1;
754 if (battle->effectStep.vars[1] > battle->sides[0].pile.hpTotal) {
755 battle->effectStep.vars[1] = battle->sides[0].pile.hpTotal;
756 } else {
757 counting = 1;
758 }
759 step = battle->sides[1].pile.apTotal / 60;
760 battle->effectStep.vars[2] += step != 0 ? step : 1;
761 if (battle->effectStep.vars[2] > battle->sides[1].pile.apTotal) {
762 battle->effectStep.vars[2] = battle->sides[1].pile.apTotal;
763 } else {
764 counting = 1;
765 }
766 step = battle->sides[1].pile.hpTotal / 60;
767 battle->effectStep.vars[3] += step != 0 ? step : 1;
768 if (battle->effectStep.vars[3] > battle->sides[1].pile.hpTotal) {
769 battle->effectStep.vars[3] = battle->sides[1].pile.hpTotal;
770 } else {
771 counting = 1;
772 }
773 if (battle->effectStep.time++ > 60) {
774 battle->effectStep.state = 4;
775 battle->effectStep.time = 0;
776 battle->effectStep.vars[0] = battle->sides[0].pile.apTotal;
777 battle->effectStep.vars[1] = battle->sides[0].pile.hpTotal;
778 battle->effectStep.vars[2] = battle->sides[1].pile.apTotal;
779 battle->effectStep.vars[3] = battle->sides[1].pile.hpTotal;
780 } else if (counting) {
782 }
783 screen->setPanelValue(screen, 0, CARD_PANEL_AP, battle->effectStep.vars[0]);
784 screen->setPanelValue(screen, 0, CARD_PANEL_HP, battle->effectStep.vars[1]);
785 screen->setPanelValue(screen, 1, CARD_PANEL_AP, battle->effectStep.vars[2]);
786 screen->setPanelValue(screen, 1, CARD_PANEL_HP, battle->effectStep.vars[3]);
787 break;
788 case 4:
790 battle->effectStep.time = 90;
791 }
792 if (++battle->effectStep.time > 90) {
793 screen->closePanels(screen);
794 battle->effectStep.state = 5;
796 }
797 break;
798 case 5:
799 if (screen->panels[0].state == 0 && battle->anim.current == CARD_ANIM_NONE) {
800 done = 1;
801 }
802 break;
803 }
804 return done;
805}
806
807/* Shows CARDGAME_stepMessages[index]: its message and window 5 */
808void CARDGAME_startStepMessage(CardBattle *battle, CardScreen *screen, s32 index) {
809 u8 *entry = CARDGAME_stepMessages[index];
810
811 screen->openMessage(screen, entry[1], 0, 0, 1);
812 screen->openWindow(screen, 5, 5, entry[0], 0, 0x42);
813 battle->effectStep.state = 1;
814}
815
816/* Waits for window 5 to open, then for Cross or Triangle to close it; 1 once it has closed */
818 s32 done = 0;
819
820 switch (battle->effectStep.state) {
821 case 1:
822 if (screen->windows[5].state == 2) {
823 battle->effectStep.state = 2;
824 }
825 break;
826 case 2:
828 battle->effectStep.state = 3;
829 screen->closeWindow(screen, 5);
830 screen->closeMessage(screen);
831 }
832 break;
833 case 3:
834 if (screen->windows[5].state == 0) {
835 battle->effectStep.state = 4;
836 }
837 break;
838 case 4:
839 done = 1;
840 break;
841 }
842 return done;
843}
844
845/* Moves the selection to the other one of the two cards that CARDGAME_startFirstPick lays out */
849 screen->sprites[battle->effectStep.cursor].highlight &= ~1;
850 screen->sprites[battle->effectStep.cursor].moving = 0;
851 battle->effectStep.cursor ^= 1;
852 screen->startSlide(screen, battle->effectStep.cursor, 1, CARDGAME_coinCardPositions[battle->effectStep.cursor][0], CARDGAME_coinCardPositions[battle->effectStep.cursor][1] - 0x500);
853 screen->sprites[battle->effectStep.cursor].highlight |= 1;
854 screen->sprites[battle->effectStep.cursor].moving = 1;
855}
856
857/* Who goes first: cards 0x57 and 0x58 face down, in a random order */
859 s32 first = RANDOM.next() & 1;
860
861 battle->effectStep.vars[3] = first;
862 battle->effectStep.vars[2] = 0;
863 battle->effectStep.vars[1] = 0;
864 battle->effectStep.vars[0] = 0;
865 battle->effectStep.time = 0;
866 screen->addSprite(screen, 0, 0x7400, 0x6100);
867 screen->addSprite(screen, 1, 0xA400, 0x6100);
868 if (first != 0) {
869 screen->setSpriteCard(screen, 0, 0x57);
870 screen->setSpriteCard(screen, 1, 0x58);
871 } else {
872 screen->setSpriteCard(screen, 1, 0x57);
873 screen->setSpriteCard(screen, 0, 0x58);
874 }
875 screen->sprites[0].visible = 2;
876 screen->sprites[1].visible = 2;
877 screen->sprites[0].scaleX = 0;
878 screen->sprites[0].dimmed = 0;
879 screen->sprites[0].highlight = 0;
880 screen->sprites[1].scaleX = 0;
881 screen->sprites[1].dimmed = 0;
882 screen->sprites[1].highlight = 0;
883 battle->effectStep.cursor = 0;
884 battle->effectStep.choice = 0;
885 battle->effectStep.state = 1;
886}
887
888/* The draw for who goes first: the two face-down cards open, the player picks
889 one with left/right and cross and both turn over; 1 once it is over, with
890 effectStep.choice 1 if the player won the draw */
892 s32 done = 0;
893
894 switch (battle->effectStep.state) {
895 case 1:
896 switch (battle->effectStep.time) {
897 case 0:
898 screen->scaleSprite(screen, 0, 10, 0x1000, 0x1000);
899 break;
900 case 4:
901 screen->scaleSprite(screen, 1, 10, 0x1000, 0x1000);
902 break;
903 }
904 battle->effectStep.time++;
905 if (battle->effectStep.time >= 15) {
906 battle->effectStep.state = 2;
907 screen->startSlide(screen, 0, 5, 0x7400, 0x5C00);
908 screen->sprites[0].moving = 1;
909 screen->sprites[0].highlight |= 1;
910 }
911 break;
912 case 2:
913 screen->sprites[battle->effectStep.cursor].highlight |= 1;
914 screen->sprites[battle->effectStep.cursor].moving = 1;
915 if ((PAD.getRepeated(0) & (1 << PAD.getButtonBit(0, PAD_LEFT))) | (PAD.getPressed(0) & (1 << PAD.getButtonBit(0, PAD_LEFT))) ||
916 (PAD.getRepeated(0) & (1 << PAD.getButtonBit(0, PAD_RIGHT))) | (PAD.getPressed(0) & (1 << PAD.getButtonBit(0, PAD_RIGHT)))) {
917 CARDGAME_switchCoinCard(battle, screen);
918 } else if (PAD_PRESSED(PAD_CROSS)) {
919 battle->effectStep.state = 3;
920 battle->effectStep.choice = battle->effectStep.cursor;
921 battle->effectStep.marked[battle->effectStep.choice] = 1;
922 battle->effectStep.vars[1] = 0;
923 battle->effectStep.vars[0] = 0;
924 battle->effectStep.time = 0;
926 }
927 break;
928 case 3:
929 if (CARDGAME_stepPulseCard(battle, screen)) {
930 battle->effectStep.state = 4;
931 battle->effectStep.vars[1] = 0;
932 battle->effectStep.vars[0] = 0;
933 battle->effectStep.time = 0;
934 screen->startFlip(screen, battle->effectStep.cursor);
935 }
936 break;
937 case 4:
938 if (battle->effectStep.time == 20) {
939 screen->startFlip(screen, battle->effectStep.cursor ^ 1);
940#if VERSION_EU || VERSION_JP
941 screen->openWindow(screen, 5, 5, battle->effectStep.vars[3] == battle->effectStep.choice ? 0x44 : 0x43, 0, 0x42);
943#endif
944 }
945 /* the result stays up for a while; cross or triangle skips it */
946 if (battle->effectStep.time >= 31 && (PAD_PRESSED(PAD_CROSS) || PAD_PRESSED(PAD_TRIANGLE))) {
947#if VERSION_US
948 battle->effectStep.time = 60;
949#elif VERSION_EU || VERSION_JP
950 battle->effectStep.time = 90;
951#endif
952 }
953#if VERSION_US
954 battle->effectStep.time++;
955 if (battle->effectStep.time >= 61) {
956#elif VERSION_EU || VERSION_JP
957 battle->effectStep.time += GFX.funcs.getFrameTime();
958 if (battle->effectStep.time >= 91) {
959#endif
960 battle->effectStep.state = 5;
961 battle->effectStep.vars[1] = 0;
962 battle->effectStep.vars[0] = 0;
963 battle->effectStep.time = 0;
964#if VERSION_EU || VERSION_JP
965 screen->closeWindow(screen, 5);
966#endif
967 }
968 break;
969 case 5:
970 switch (battle->effectStep.time) {
971 case 0:
972 screen->scaleSprite(screen, 0, 5, 0, 0x1000);
973 break;
974 case 4:
975 screen->scaleSprite(screen, 1, 5, 0, 0x1000);
976 break;
977 }
978 battle->effectStep.time++;
979 if (battle->effectStep.time >= 15) {
980 battle->effectStep.state = 6;
981 }
982 break;
983 case 6:
984 if (battle->effectStep.vars[3] == battle->effectStep.choice) {
985 battle->effectStep.choice = 1;
986 } else {
987 battle->effectStep.choice = 0;
988 }
989 done = 1;
990 break;
991 }
992 return done;
993}
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_HAND
Definition battle.h:173
@ CARD_ANIM_HIDE_SLOTS
Definition battle.h:169
@ CARD_ANIM_SHOW_HAND
the player's piles...
Definition battle.h:172
@ CARD_ANIM_SHOW_SLOTS
Definition battle.h:168
@ CARD_ANIM_HIDE_OPPONENT_HAND
Definition battle.h:179
@ CARD_ANIM_SHOW_OPPONENT_HAND
...and the opponent's
Definition battle.h:178
@ CARD_ANIM_NONE
Definition battle.h:167
s32 CARDGAME_coinCardPositions[][2]
the two cards' x, y (CARDGAME_startFirstPick)
Definition cardgame_2.c:26
u8 CARDGAME_stepMessages[][2]
CARDGAME_startStepMessage's text for window 5 and what screen->openMessage shows, by message.
Definition cardgame_2.c:22
s32 CARDGAME_promptText
the text of window 0
Definition cardgame_3.c:179
signed int s32
Definition common.h:11
unsigned char u8
Definition common.h:8
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
void CARDGAME_movePileSelection(CardBattle *battle, CardScreen *screen, CardPile *pile, s32 step)
Moves the selection by STEP among the cards of PILE's hand: the selected card is raised.
Definition hand_pick.c:73
s32 CARDGAME_drawFirstPlayer(CardBattle *battle, CardScreen *screen)
The draw for who goes first: the two face-down cards open, the player picks one with left/right and c...
Definition hand_pick.c:891
s32 CARDGAME_stepPulseCard(CardBattle *battle, CardScreen *screen)
Scales the highlighted sprite up to 1.25 and back, 5 frames each; 1 once done.
Definition hand_pick.c:244
void CARDGAME_readPickInput(CardBattle *battle, CardScreen *screen, CardPile *pile)
Reads the pad while cards of PILE's hand are being picked: Left/Right move, Cross picks or puts back,...
Definition hand_pick.c:193
static void readConfirmInput(CardBattle *battle, CardScreen *screen)
The answer to the confirm message: yes (effectStep.choice 0) ends the choice (state 8),...
Definition hand_pick.c:480
void CARDGAME_flagPlayableCards(CardBattle *battle, CardScreen *screen, CardPile *pile)
Flags (effectStep.eligible) the cards of pile's hand that can be played and aren't picked (effectStep...
Definition hand_pick.c:86
s32 CARDGAME_stepMessage(CardBattle *battle, CardScreen *screen)
Waits for window 5 to open, then for Cross or Triangle to close it; 1 once it has closed.
Definition hand_pick.c:817
void CARDGAME_readChooseInput(CardBattle *battle, CardScreen *screen, CardPile *pile)
Reads the pad while a card of PILE's hand is being chosen: Left/Right move, Cross picks,...
Definition hand_pick.c:162
void CARDGAME_moveSelection(CardBattle *battle, CardScreen *screen, s32 count, s32 step)
Moves the selection by STEP among COUNT cards: the selected card is raised.
Definition hand_pick.c:61
void CARDGAME_startStepMessage(CardBattle *battle, CardScreen *screen, s32 index)
Shows CARDGAME_stepMessages[index]: its message and window 5.
Definition hand_pick.c:808
static void backToChoosing(CardBattle *battle, CardScreen *screen, CardPile *pile)
After a no to the confirm message: reopens the choice's windows, then lifts the highlighted card agai...
Definition hand_pick.c:459
static void hideHandForMenu(CardBattle *battle, CardScreen *screen, CardPile *pile)
Hides the hand and the choice's windows for the battle menu.
Definition hand_pick.c:276
static void showChosenCards(CardBattle *battle, CardScreen *screen, CardPile *pile)
The chosen cards pulse with a sound, then the hand and its windows close.
Definition hand_pick.c:502
void CARDGAME_startFirstPick(CardBattle *battle, CardScreen *screen)
Who goes first: cards 0x57 and 0x58 face down, in a random order.
Definition hand_pick.c:858
static void askToConfirm(CardBattle *battle, CardScreen *screen, CardPile *pile)
Puts the highlighted card back in the hand and opens the confirm message.
Definition hand_pick.c:441
s32 CARDGAME_stepTally(CardBattle *battle, CardScreen *screen)
Turns the opponent's slot cards over, then counts the panels' ap and hp up to each side's pile apTota...
Definition hand_pick.c:696
void CARDGAME_switchCoinCard(CardBattle *battle, CardScreen *screen)
Moves the selection to the other one of the two cards that CARDGAME_startFirstPick lays out.
Definition hand_pick.c:846
s32 CARDGAME_isHandPickDone(CardBattle *battle, CardScreen *screen, CardPile *pile)
Whether the pick is over: six cards picked (effectStep.count), or none left that can be played.
Definition hand_pick.c:106
s32 CARDGAME_stepChooseCards(CardBattle *battle, CardScreen *screen, CardPile *pile)
Choosing cards of PILE's hand to play: effectStep.nextState queues the next step (startChooseState).
Definition hand_pick.c:564
static void resumeChoosing(CardBattle *battle, CardScreen *screen, CardPile *pile)
Back from the battle menu: once the hand is shown again, choosing goes on with the picked cards highl...
Definition hand_pick.c:545
void CARDGAME_startPick(CardBattle *battle, CardScreen *screen, s32 all, s32 mode)
Starts a pick of the cards (all when all > 0) in mode (anim.next)
Definition hand_pick.c:43
void CARDGAME_startPanelsStep(CardBattle *battle, CardScreen *screen)
Opens the panels for a step.
Definition hand_pick.c:685
void CARDGAME_startHandPick(CardBattle *battle, CardScreen *screen, CardPile *pile)
Starts a pick from pile's hand: flags (effectStep.eligible) the cards that can be played,...
Definition hand_pick.c:10
static void showHandAfterMenu(CardBattle *battle, CardScreen *screen, CardPile *pile)
Back from the battle menu: shows the hand again, the cards that can't be played dimmed,...
Definition hand_pick.c:295
s32 CARDGAME_togglePick(CardBattle *battle, CardScreen *screen, CardPile *pile)
Picks or puts back the selected card of PILE's hand: 1 picked, 2 put back, 0 neither.
Definition hand_pick.c:139
void CARDGAME_readCountInput(CardBattle *battle, CardScreen *screen, s32 count)
Reads the pad while one of COUNT cards is being chosen: Left/Right move, Triangle cancels.
Definition hand_pick.c:220
static void startChooseState(CardBattle *battle, CardScreen *screen, CardPile *pile)
Starts the state of the card choice effectStep.nextState asks for: its prompt, windows and dimmed car...
Definition hand_pick.c:329
void CARDGAME_addCardPoints(CardBattle *battle, CardScreen *screen, CardPile *pile, s32 add, s32 card)
Adds a card's points to pile's points of its colour (takes them when add is 0), on the panel.
Definition hand_pick.c:123
PadState PAD
Controller input: cleared by initPad, then the methods.
Definition pad.c:168
#define PAD_CROSS
Definition pad.h:31
#define PAD_CIRCLE
Definition pad.h:30
#define PAD_DOWN
Definition pad.h:24
#define PAD_RIGHT
Definition pad.h:23
#define PAD_SQUARE
Definition pad.h:33
#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_LEFT
Definition pad.h:25
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
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_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
Random RANDOM
Definition random.c:533
@ CARD_PANEL_HP
Definition screen.h:203
@ CARD_PANEL_AP
Definition screen.h:202
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_COUNT
SYSTEM10: a number counts up or down.
Definition sound.h:45
#define SOUND_MENU_CONFIRM
SYSTEM07.
Definition sound.h:44
#define SOUND_MENU_OPEN
SYSTEM03.
Definition sound.h:41
#define SOUND_MENU_CANCEL
SYSTEM01.
Definition sound.h:39
#define SOUND_MENU_MOVE
SYSTEM06.
Definition sound.h:43
#define SOUND_CURSOR
SYSTEM02: a cursor moves.
Definition sound.h:40
s32 count
the pile's cards
Definition battle.h:204
u8 faceDown
the next pile or slots are laid out face down
Definition battle.h:198
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
u8 hide
the one that hides what the last one showed
Definition battle.h:197
u8 dimmed[40]
by sprite
Definition battle.h:200
The card battle (CARDGAME_createBattle).
Definition battle.h:226
u8 run
what runs this frame (CARD_RUN_*)
Definition battle.h:238
CardPlayer players[2]
Definition battle.h:275
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 color
from 1
Definition gfx.h:173
u8 points
what it adds to its colour
Definition gfx.h:179
s16 state
Definition screen.h:137
A player's cards in a card battle (CardSide.pile)
Definition battle.h:108
s16 hpTotal
the sum of its slot cards' hp: the higher one wins the round
Definition battle.h:110
s16 handCount
Definition battle.h:114
u8 side
its panel
Definition battle.h:116
u8 points[5]
one per card colour
Definition battle.h:115
s16 apTotal
the sum of its slot cards' ap, which comes off the other side's hpTotal
Definition battle.h:109
s16 hand[10]
handCount in use
Definition battle.h:119
u8 slotCount
Definition battle.h:38
u8 menuState
CARDGAME_runBattleMenu's state.
Definition battle.h:126
The battle screen (created by CARDGAME_createScreen): the two panels, the cards on the table and the ...
Definition screen.h:263
void(* setSpriteCard)(struct CardScreen *screen, s32 sprite, s32 index)
Definition screen.h:324
void(* openWindow)(struct CardScreen *screen, s32 index, s16 layout, s32 value, s32 x, s32 y)
Definition screen.h:288
void(* closePanel)(struct CardScreen *screen, s32 side)
Definition screen.h:292
void(* setPanelValue)(struct CardScreen *screen, s32 side, u32 which, s32 value)
Definition screen.h:285
void(* scaleSprite)(struct CardScreen *screen, s32 index, s32 duration, s32 scaleX, s32 scaleY)
Definition screen.h:318
void(* startMove)(struct CardScreen *screen, s32 index, s32 duration, s32 x, s32 y)
Definition screen.h:311
void(* resetPanels)(struct CardScreen *screen)
Definition screen.h:296
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
s32(* getHandOffset)(s32 count, s32 index)
Definition screen.h:299
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
void(* closeWindow)(struct CardScreen *screen, s32 index)
Definition screen.h:289
s32(* startBlink)(struct CardScreen *screen, s32 index)
Definition screen.h:316
s32(* startFlip)(struct CardScreen *screen, s32 index)
Definition screen.h:319
s32(* addSprite)(struct CardScreen *screen, s32 index, s32 x, s32 y)
Definition screen.h:314
void(* startSlide)(struct CardScreen *screen, s32 index, s32 duration, s32 x, s32 y)
Definition screen.h:312
void(* openPanel)(struct CardScreen *screen, s32 side)
Definition screen.h:293
CardPanel panels[2]
Definition screen.h:270
CardPile pile
Definition battle.h:160
s16 moving
Definition screen.h:177
u8 dimmed
Definition screen.h:194
u8 visible
Definition screen.h:190
u8 highlight
bit 0 the cursor, bit 1 picked, bit 2 glowing
Definition screen.h:193
s16 scaleX
Definition screen.h:170
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
s8 eligible[0x29]
the cards or slots that can be picked
Definition battle.h:154
u8 count
the cards picked, or to draw
Definition battle.h:152
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
u8 nextState
the state to set up first, if not 0
Definition battle.h:147
s8 marked[40]
the cards or slots picked
Definition battle.h:155
s32 choice
the card, slot or answer chosen; -1 for none
Definition battle.h:151
u8 next
the step to start: CARDGAME_runEffectStep sets it up first
Definition battle.h:145
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
s32(* getRepeated)(s32 pad)
Definition pad.h:127
s32(* getButtonBit)(s32 pad, s32 button)
Definition pad.h:130
s32(* getPressed)(s32 pad)
Definition pad.h:125
s32(* next)(void)
0 to RANDOM_COUNT - 1
Definition random.h:15
short(* playSound)(s32 id)
returns the voice of a key-on
Definition sound.h:187