Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
card_choice.c
Go to the documentation of this file.
1/* CARDGAME's card choices: a card of a hand, of a pile, a previous card or
2 the target slots, by the player or the computer. */
3
5
6/* Sets up CARDGAME_chooseCard's choice of one of a side's cards: kind 0 among
7 its hand, 1 and 2 among its deck, 3 among its discards */
8void CARDGAME_setupCardChoice(CardBattle *battle, CardScreen *screen, s32 side, s32 kind) {
9 s32 i;
10
11 switch (kind) {
12 case 0:
13 battle->effectStep.vars[4] = side != 0 ? 11 : 5;
14 battle->effectStep.vars[3] = battle->sides[side].pile.handCount;
15 break;
16 case 1:
17 case 2:
18 if (side == 0) {
19 battle->effectStep.vars[4] = 7;
20 battle->sortCards(battle, battle->sides[0].pile.deck, battle->sides[0].pile.deckTop | (40 << 16), 2);
21 } else {
22 battle->effectStep.vars[4] = 13;
23 if (kind != 2) {
24 battle->sortCards(battle, battle->sides[1].pile.deck, battle->sides[1].pile.deckTop | (40 << 16), 3);
25 }
26 }
27 battle->effectStep.vars[3] = battle->sides[side].pile.deckCount;
28 break;
29 case 3:
30 battle->effectStep.vars[4] = side != 0 ? 15 : 9;
31 battle->effectStep.vars[3] = battle->sides[side].pile.discardCount;
32 break;
33 }
34 for (i = 0; i < 40; i++) {
35 if (i < battle->effectStep.vars[3]) {
36 battle->effectStep.marked[i] = 0;
37 if (battle->effectStep.eligible[i] != 0) {
38 battle->anim.dimmed[i] = 0;
39 } else {
40 battle->anim.dimmed[i] = 1;
41 }
42 }
43 }
44 battle->effectStep.nextState = 1;
45 CARDGAME_clearCardInfo(battle, screen);
46 battle->effectStep.cursor = 0;
47 battle->effectStep.choice = -1;
48}
49
50/* CARDGAME_setupCardChoice of side, kind 0 */
51void CARDGAME_setupSideChoice(CardBattle *battle, CardScreen *screen, s32 side) {
52 CARDGAME_setupCardChoice(battle, screen, side, 0);
53}
54
55/* Moves the highlight along the hand by delta, raising the highlighted card */
56void CARDGAME_moveHandHighlight(CardBattle *battle, CardScreen *screen, s32 delta) {
58 screen->startSlide(screen, battle->effectStep.cursor, 5, screen->getHandOffset(battle->effectStep.vars[3], battle->effectStep.cursor) + 0x1800, 0x6100);
59 screen->sprites[battle->effectStep.cursor].highlight &= ~1;
60 screen->sprites[battle->effectStep.cursor].moving = 0;
61 battle->effectStep.cursor += delta;
62 screen->startSlide(screen, battle->effectStep.cursor, 1, screen->getHandOffset(battle->effectStep.vars[3], battle->effectStep.cursor) + 0x1800, 0x5C00);
63 screen->sprites[battle->effectStep.cursor].highlight |= 1;
64 screen->sprites[battle->effectStep.cursor].moving = 1;
65}
66
67/* Moves the highlight along the hand with left and right; cross picks a playable card */
69 screen->sprites[battle->effectStep.cursor].highlight |= 1;
70 screen->sprites[battle->effectStep.cursor].moving = 1;
71 if ((PAD.getRepeated(0) & (1 << PAD.getButtonBit(0, PAD_LEFT))) | (PAD.getPressed(0) & (1 << PAD.getButtonBit(0, PAD_LEFT)))) {
72 if (battle->effectStep.cursor > 0) {
73 CARDGAME_moveHandHighlight(battle, screen, -1);
74 }
75 } else if ((PAD.getRepeated(0) & (1 << PAD.getButtonBit(0, PAD_RIGHT))) | (PAD.getPressed(0) & (1 << PAD.getButtonBit(0, PAD_RIGHT)))) {
76 if (battle->effectStep.cursor < battle->effectStep.vars[3] - 1) {
77 CARDGAME_moveHandHighlight(battle, screen, 1);
78 }
79 } else if (PAD_PRESSED(PAD_CROSS) && battle->effectStep.eligible[battle->effectStep.cursor] != 0) {
80 battle->effectStep.nextState = 3;
81 }
82 battle->effectStep.flags = 0;
83}
84
85/* Shows the card being played (sprite 15) scaling in on the slot row */
86static inline void showPlayedCard(CardBattle *battle, CardScreen *screen) {
87#if PAL_VIDEO
89#else
90 screen->addSprite(screen, 15, 0x1800, 0x9000);
91#endif
92 screen->setSpriteCard(screen, 15, battle->record.plays[battle->record.playCount].card);
93 screen->sprites[15].scaleX = 0;
94 screen->scaleSprite(screen, 15, 8, 0x1000, 0x1000);
95}
96
97/* Takes the picked card (effectStep.choice): one of the player's deck is
98 swapped to its top and the rest shuffled, one of the opponent's draws
99 gives its order */
100static inline void takePickedCard(CardBattle *battle) {
101 s32 card;
102
103 switch (battle->effectStep.vars[4]) {
104 case 7:
105 /* the picked card goes to the top of the hand */
106 card = battle->sides[0].pile.deck[battle->sides[0].pile.deckTop];
107
108 battle->sides[0].pile.deck[battle->sides[0].pile.deckTop] = battle->sides[0].pile.deck[battle->sides[0].pile.deckTop + battle->effectStep.choice];
109 battle->sides[0].pile.deck[battle->sides[0].pile.deckTop + battle->effectStep.choice] = card;
110 battle->effectStep.choice = battle->sides[0].pile.deckTop;
111 battle->shufflePile(battle, battle->sides[0].pile.deckTop + 1, battle->sides[0].pile.deckCount - 1);
112 break;
113 case 13:
114 battle->effectStep.choice = battle->opponentDraws[battle->effectStep.choice + battle->sides[1].pile.deckTop].order;
116 break;
117 }
118}
119
120/* Lets a player pick a card of a row (set up by CARDGAME_setupCardChoice): 2 once one is
121 picked, 1 if the player backed out with triangle (mode 1), else 0 */
123 s32 result = 0;
124
125 if (battle->effectStep.nextState != 0) {
126 switch (battle->effectStep.nextState) {
127 case 1:
128 battle->anim.next = battle->effectStep.vars[4];
129 switch (battle->effectStep.vars[4]) {
130 case 5:
132 break;
133 case 7:
135 break;
136 case 13:
138 break;
139 case 9:
141 break;
142 case 11:
143 case 15:
145 break;
146 }
147 if (mode == 2) {
148 screen->openPanel(screen, 0);
149 }
150 battle->effectStep.vars[1] = 0;
151 battle->effectStep.vars[0] = 0;
152 battle->effectStep.time = 0;
153 battle->effectStep.choice = 0;
154 battle->effectStep.count = 0;
155 break;
156 case 3:
158 /* fallthrough */
159 case 2:
160 battle->effectStep.vars[0] = 0;
161 battle->effectStep.time = 0;
162 break;
163 case 4:
164 if (mode == 1) {
165 screen->scaleSprite(screen, 15, 8, 0, 0x1000);
166 }
167 battle->effectStep.vars[0] = 0;
168 battle->effectStep.time = 0;
169 battle->anim.next = battle->anim.hide;
170 screen->closeWindow(screen, 4);
171 screen->closeWindow(screen, 0);
172 screen->closeWindow(screen, 1);
173 screen->closeWindow(screen, 2);
174 screen->closeWindow(screen, 3);
175 break;
176 }
177 battle->effectStep.state = battle->effectStep.nextState;
178 battle->effectStep.nextState = 0;
179 }
180 switch (battle->effectStep.state) {
181 case 1:
182 battle->effectStep.vars[1] = CARDGAME_openStepWindows(battle, screen, 2, CARDGAME_selectionText, battle->effectStep.time, battle->effectStep.vars[1]);
183 CARDGAME_showCardInfo(battle, screen, 0);
184 if (battle->effectStep.time == 2 && mode == 1) {
185 showPlayedCard(battle, screen);
186 }
187 if (battle->anim.count * 4 + 14 < battle->effectStep.time) {
188 battle->effectStep.nextState = 2;
189 screen->startSlide(screen, 0, 5, 0x1800, 0x5C00);
190 screen->sprites[battle->effectStep.cursor].highlight |= 1;
191 screen->sprites[battle->effectStep.cursor].moving = 1;
192 }
193 battle->effectStep.time++;
194 break;
195 case 2:
196 CARDGAME_browseHand(battle, screen);
197 if (mode == 1 && PAD_PRESSED(PAD_TRIANGLE)) {
199 battle->effectStep.flags = 1;
200 battle->effectStep.nextState = 4;
201 }
202 CARDGAME_showCardInfo(battle, screen, 0);
203 break;
204 case 3:
205 if (CARDGAME_stepPulseCard(battle, screen)) {
206 battle->effectStep.flags = 2;
207 battle->effectStep.nextState = 4;
208 if (mode == 2) {
209 screen->closePanel(screen, 0);
210 }
211 }
212 CARDGAME_showCardInfo(battle, screen, 0);
213 break;
214 case 4:
215 if (battle->effectStep.vars[3] * 4 + 5 < battle->effectStep.time++) {
216 battle->effectStep.choice = battle->effectStep.cursor;
217 takePickedCard(battle);
218 battle->effectStep.marked[battle->effectStep.choice] = 1;
219 result = battle->effectStep.flags;
220 battle->effectStep.nextState = 0;
221 battle->effectStep.next = 0;
222 battle->effectStep.id = 0;
223 battle->effectStep.next = 0;
224 }
225 break;
226 }
227 return result;
228}
229
230/* The computer marks (effectStep.marked) the cards of its hand it plays: up to six that
231 can be played, but not its kind 5 ones, paying their points; 1 */
233 s32 i;
234 s32 card;
235
236 for (i = 0; i < battle->sides[1].pile.handCount; i++) {
237 battle->effectStep.marked[i] = 0;
238 if (battle->effectStep.count < 6 && CARDGAME_canPlayCard(battle, battle->sides[1].pile.points, battle->sides[1].pile.hand[i])) {
239 card = battle->sides[1].pile.hand[i];
240 if (battle->opponentPlans[card - 40].kind != 5) {
241 CARDGAME_addCardPoints(battle, screen, &battle->sides[1].pile, 0, card);
242 battle->effectStep.marked[i] = 1;
243 battle->effectStep.count++;
244 }
245 }
246 }
247 return 1;
248}
249
250/* Sets effectStep.choice to the effectStep.eligible-marked card of the pile effectStep.vars[4] picks with the highest CardImage.rank, the weakest (the strongest when lowest != 0), or -1 */
251void CARDGAME_pickBestPileCard(CardBattle *battle, CardScreen *screen, s32 lowest) {
252 CardDrawer drawer;
253 CardImage *header;
254 CardImage *current;
255 s32 count = 0;
256 s32 card;
257 s32 best;
258 s32 i;
259
260 /* the match depends on cases 11 and 13 having bodies of their own in
261 both switches */
262 switch (battle->effectStep.vars[4]) {
263 case 5:
264 count = battle->sides[0].pile.handCount;
265 break;
266 case 7:
267 count = battle->sides[0].pile.deckCount;
268 break;
269 case 11:
270 count = battle->sides[1].pile.handCount;
271 break;
272 case 13:
273 count = battle->sides[1].pile.handCount;
274 break;
275 case 9:
276 count = battle->sides[0].pile.discardCount;
277 break;
278 case 15:
279 count = battle->sides[1].pile.discardCount;
280 break;
281 }
282 header = NULL;
283 card = 0;
284 initCardDrawer(&drawer);
285 best = -1;
286 for (i = 0; i < count; i++) {
287 if (battle->effectStep.eligible[i] != 0) {
288 switch (battle->effectStep.vars[4]) {
289 case 5:
290 card = battle->sides[0].pile.hand[i];
291 break;
292 case 7:
293 card = battle->sides[0].pile.deck[i];
294 break;
295 case 11:
296 card = battle->sides[1].pile.hand[i];
297 break;
298 case 13:
299 card = battle->sides[1].pile.hand[i];
300 break;
301 case 9:
302 card = battle->sides[0].pile.discards[i];
303 break;
304 case 15:
305 card = battle->sides[1].pile.discards[i];
306 break;
307 }
308 drawer.setCard(battle->cards[card] + 1);
309 current = drawer.card;
310 if (best != -1) {
311 if (lowest == 0) {
312 if (current->rank >= header->rank) {
313 best = i;
314 header = current;
315 }
316 } else if (current->rank < header->rank) {
317 best = i;
318 header = current;
319 }
320 } else {
321 best = i;
322 header = current;
323 }
324 }
325 }
326 battle->effectStep.choice = best;
327}
328
329/* The computer's pick from its deck: the first card flagged (effectStep.eligible) from its
330 top up to drawEnd, or else the last one flagged */
332 s32 i;
333 s32 found = 0;
334
335 for (i = battle->sides[1].pile.deckTop; i < battle->drawEnd; i++) {
336 if (battle->effectStep.eligible[i - battle->sides[1].pile.deckTop] != 0) {
337 battle->effectStep.choice = i;
338 found = 1;
339 break;
340 }
341 }
342 if (!found) {
343 for (i = 39; battle->sides[1].pile.deckTop < i; i--) {
344 if (battle->effectStep.eligible[i - battle->sides[1].pile.deckTop] != 0) {
345 break;
346 }
347 }
348 battle->effectStep.choice = i;
349 }
350 battle->effectStep.marked[battle->effectStep.choice] = 1;
351}
352
353/* Picks the player's card with the lowest CardImage.rank, the strongest */
355 CardDrawer drawer;
356 s32 best = battle->sides[0].pile.deckTop;
357 s32 lowest;
358 s32 i;
359
360 initCardDrawer(&drawer);
361 lowest = 400;
362 for (i = battle->sides[0].pile.deckTop; i < 40; i++) {
363 drawer.setCard(battle->cards[battle->sides[0].pile.deck[i]] + 1);
364 if (drawer.card->rank < lowest) {
365 lowest = drawer.card->rank;
366 best = i;
367 }
368 }
369 battle->effectStep.choice = best;
370}
371
372/* Shows the card being played as sprite 15 and the panels with flags, and
373 starts CARDGAME_stepPileChoice's choice */
374void CARDGAME_startPileChoice(CardBattle *battle, CardScreen *screen, s32 flags) {
375 s32 i;
376
377 screen->resetPanels(screen);
378 screen->setPanelFlags(screen, flags);
379 battle->effectStep.choice = 0;
380 battle->effectStep.state = 1;
381 battle->effectStep.vars[4] = flags;
382 screen->addSprite(screen, 15, 0xE500, 0x6100);
383 screen->setSpriteCard(screen, 15, battle->record.plays[battle->record.playCount].card);
384 screen->sprites[15].scaleX = 0;
385 screen->scaleSprite(screen, 15, 8, 0x1000, 0x1000);
386 screen->openPanels(screen);
387 battle->anim.dimAll = CARD_ANIM_DIM_ALL;
388 battle->anim.dimmed[15] = 0;
389 for (i = 0; i < 15; i++) {
390 battle->effectStep.marked[i] = 0;
391 }
393}
394
395/* The steps of CARDGAME_startPileChoice: confirming is allowed when the pile the panel flags (effectStep.vars[4]) pick has cards; 1 then, 0 on leaving with triangle, -1 until then */
397 s32 result = -1;
398
399 switch (battle->effectStep.state) {
400 case 1:
401 if (screen->panels[0].state == 2 && battle->anim.current == CARD_ANIM_NONE) {
402 battle->effectStep.state = 2;
403 }
404 break;
405 case 2:
406 if (PAD_PRESSED(PAD_CROSS)) {
407 switch (battle->effectStep.vars[4]) {
408 case 0x400:
409 case 0x1400:
410 if (battle->sides[0].pile.discardCount != 0) {
411 result = 1;
412 }
413 break;
414 case 0x1000:
415 if (battle->sides[0].pile.deckCount != 0) {
416 result = 1;
417 }
418 break;
419 case 0x4000:
420 if (battle->sides[0].pile.handCount != 0) {
421 result = 1;
422 }
423 break;
424 case 0x2000:
425 if (battle->sides[1].pile.deckCount != 0) {
426 result = 1;
427 }
428 break;
429 case 0x8000:
430 if (battle->sides[1].pile.handCount != 0) {
431 result = 1;
432 }
433 break;
434 default:
435 result = 1;
436 break;
437 }
438 if (result == 1) {
440 }
441 } else if (PAD_PRESSED(PAD_TRIANGLE)) {
443 screen->closePanels(screen);
444 battle->effectStep.choice = 1;
445 battle->effectStep.state = 3;
446 screen->scaleSprite(screen, 15, 4, 0, 0x1000);
448 }
449 break;
450 case 3:
451 if (screen->panels[0].state == 0 && battle->anim.current == CARD_ANIM_NONE) {
452 screen->removeSprite(screen, 15);
453 screen->clearPanelFlags(screen);
454 result = 0;
455 }
456 break;
457 }
458 return result;
459}
460
461/* Shows the last card played as sprite 15; with mode 0, or mode 1 and a colour 6 card before it, the card before it can be picked too */
463 CardDrawer drawer;
464 s32 i;
465 s32 j;
466 s32 ok;
467 s32 card;
468 s32 sprite;
469
470 screen->resetPanels(screen);
471 battle->effectStep.choice = 0;
472 battle->effectStep.state = 1;
473 battle->effectStep.vars[4] = 0;
474 screen->addSprite(screen, 15, 0xE500, 0x6100);
475 screen->setSpriteCard(screen, 15, battle->record.plays[battle->record.playCount].card);
476 screen->sprites[15].scaleX = 0;
477 screen->scaleSprite(screen, 15, 8, 0x1000, 0x1000);
478 screen->openPanels(screen);
479 for (i = 0; i < 15; i++) {
480 battle->anim.dimmed[i] = 1;
481 }
482 battle->anim.dimmed[15] = 0;
483 for (j = 0; j < 15; j++) {
484 battle->effectStep.marked[j] = 0;
485 }
486 if (battle->record.playCount != 0) {
487 ok = 0;
488 if (mode == 0) {
489 ok = 1;
490 } else if (mode == 1) {
491 card = battle->record.plays[battle->record.playCount - 1].card;
492 initCardDrawer(&drawer);
493 drawer.setCard(battle->cards[card] + 1);
494 if (drawer.card->color == 6) {
495 ok = 1;
496 }
497 }
498 if (ok) {
499 sprite = battle->record.playCount + 11;
500 screen->sprites[sprite].highlight |= 1;
501 battle->anim.dimmed[sprite] = 0;
502 battle->effectStep.vars[4] = 1;
503 }
504 }
506}
507
508/* The steps of CARDGAME_startPreviousCardChoice: confirming takes the card before the last one played, if it can be taken; 1 then, 0 on leaving with triangle, -1 until then */
510 s32 result = -1;
511 s32 sprite;
512
513 switch (battle->effectStep.state) {
514 case 1:
515 if (screen->panels[0].state == 2 && battle->anim.current == CARD_ANIM_NONE) {
516 battle->effectStep.state = 2;
517 if (battle->record.playCount != 0) {
518 screen->sprites[battle->record.playCount + 11].highlight |= 1;
519 }
520 }
521 break;
522 case 2:
523 if (PAD_PRESSED(PAD_CROSS)) {
524 if (battle->effectStep.vars[4] == 1) {
526 sprite = battle->record.playCount + 11;
527 screen->sprites[sprite].highlight &= ~1;
528 battle->effectStep.marked[sprite] = battle->record.playCount + 1;
529 result = 1;
530 battle->record.plays[battle->record.playCount - 1].mark = battle->record.playCount;
531 }
532 } else if (PAD_PRESSED(PAD_TRIANGLE)) {
534 screen->closePanels(screen);
535 battle->effectStep.choice = 1;
536 battle->effectStep.state = 3;
537 screen->scaleSprite(screen, 15, 4, 0, 0x1000);
539 }
540 break;
541 case 3:
542 if (screen->panels[0].state == 0 && battle->anim.current == CARD_ANIM_NONE) {
543 screen->removeSprite(screen, 15);
544 screen->clearPanelFlags(screen);
545 result = 0;
546 }
547 break;
548 }
549 return result;
550}
551
552/* Shows the card being played as sprite 15 and lets the slots out that its target picks (a side of owner's, both, or a card colour) be chosen: effectStep.marked marks them, effectStep.vars[4] is 1 if there are any */
553void CARDGAME_showTargetSlots(CardBattle *battle, CardScreen *screen, s32 owner, s32 target) {
554 s32 i;
555 s32 ok;
556 s32 card;
557 s32 j;
558
559 screen->resetPanels(screen);
560 battle->effectStep.choice = 0;
561 battle->effectStep.state = 1;
562 screen->addSprite(screen, 15, 0xE500, 0x6100);
563 screen->setSpriteCard(screen, 15, battle->record.plays[battle->record.playCount].card);
564 screen->sprites[15].scaleX = 0;
565 screen->scaleSprite(screen, 15, 8, 0x1000, 0x1000);
566 screen->openPanels(screen);
567 battle->effectStep.vars[4] = 0;
568 for (i = 0, ok = 0; i < 12; i++, ok = 0) {
569 battle->effectStep.marked[i] = 0;
570 battle->anim.dimmed[i] = 1;
571 screen->sprites[i].highlight &= ~1;
572 if (i < 6) {
573 if (i >= battle->players[0].slotCount) {
574 continue;
575 }
576 card = battle->players[0].slots[i].card;
577 } else {
578 if (i - 6 >= battle->players[1].slotCount) {
579 continue;
580 }
581 card = battle->players[1].slots[i - 6].card;
582 }
583 switch (target) {
584 case 1:
585 if (owner == 0) {
586 if (i < 6) {
587 ok = 1;
588 }
589 } else if (i >= 6) {
590 ok = 1;
591 }
592 break;
593 case 2:
594 if (owner == 0) {
595 if (i >= 6) {
596 ok = 1;
597 }
598 } else if (i < 6) {
599 ok = 1;
600 }
601 break;
602 case 3:
603 ok = 1;
604 break;
605 case 4:
606 if (screen->getCardColor(screen, card) != 1) {
607 ok = 1;
608 }
609 break;
610 case 5:
611 if (screen->getCardColor(screen, card) != 2) {
612 ok = 1;
613 }
614 break;
615 case 6:
616 if (screen->getCardColor(screen, card) == 3) {
617 ok = 1;
618 }
619 break;
620 case 7:
621 if (screen->getCardColor(screen, card) != 4) {
622 ok = 1;
623 }
624 break;
625 case 8:
626 if (screen->getCardColor(screen, card) == 6) {
627 ok = 1;
628 }
629 break;
630 }
631 if (ok) {
632 battle->effectStep.marked[i] = 1;
633 battle->anim.dimmed[i] = 0;
634 battle->effectStep.vars[4] = 1;
635 }
636 }
637 for (j = 0; j < 3; j++) {
638 battle->anim.dimmed[j + 12] = 1;
639 }
640 battle->anim.dimmed[15] = 0;
642}
643
644/* The steps of CARDGAME_showTargetSlots: highlights the marked slots (effectStep.marked); confirming needs one (effectStep.vars[4]); 1 then, 0 on leaving with triangle, -1 until then */
646 s32 result = -1;
647 s32 i;
648
649 switch (battle->effectStep.state) {
650 case 1:
651 if (screen->panels[0].state == 2 && battle->anim.current == CARD_ANIM_NONE) {
652 battle->effectStep.state = 2;
653 for (i = 0; i < 12; i++) {
654 if (battle->effectStep.marked[i] != 0) {
655 screen->sprites[i].highlight |= 1;
656 }
657 }
658 }
659 break;
660 case 2:
661 if (PAD_PRESSED(PAD_CROSS)) {
662 if (battle->effectStep.vars[4] != 0) {
664 result = 1;
665 for (i = 0; i < 12; i++) {
666 if (battle->effectStep.marked[i] != 0) {
667 screen->sprites[i].highlight &= ~1;
668 }
669 }
670 }
671 } else if (PAD_PRESSED(PAD_TRIANGLE)) {
673 screen->closePanels(screen);
674 battle->effectStep.choice = 1;
675 battle->effectStep.state = 3;
676 screen->scaleSprite(screen, 15, 4, 0, 0x1000);
678 }
679 break;
680 case 3:
681 if (screen->panels[0].state == 0 && battle->anim.current == CARD_ANIM_NONE) {
682 screen->removeSprite(screen, 15);
683 screen->clearPanelFlags(screen);
684 result = 0;
685 for (i = 0; i < 12; i++) {
686 if (battle->effectStep.marked[i] != 0) {
687 screen->sprites[i].highlight &= ~1;
688 }
689 }
690 }
691 break;
692 }
693 return result;
694}
CARDGAME.PRO: the card battle (mode 0x700).
s32 CARDGAME_chooseCard(CardBattle *battle, CardScreen *screen, s32 mode)
Lets a player pick a card of a row (set up by CARDGAME_setupCardChoice): 2 once one is picked,...
static void takePickedCard(CardBattle *battle)
Takes the picked card (effectStep.choice): one of the player's deck is swapped to its top and the res...
void CARDGAME_browseHand(CardBattle *battle, CardScreen *screen)
Moves the highlight along the hand with left and right; cross picks a playable card.
Definition card_choice.c:68
void CARDGAME_startPreviousCardChoice(CardBattle *battle, CardScreen *screen, s32 mode)
Shows the last card played as sprite 15; with mode 0, or mode 1 and a colour 6 card before it,...
s32 CARDGAME_stepTargetSlots(CardBattle *battle, CardScreen *screen)
The steps of CARDGAME_showTargetSlots: highlights the marked slots (effectStep.marked); confirming ne...
void CARDGAME_setupSideChoice(CardBattle *battle, CardScreen *screen, s32 side)
CARDGAME_setupCardChoice of side, kind 0.
Definition card_choice.c:51
void CARDGAME_pickBestPileCard(CardBattle *battle, CardScreen *screen, s32 lowest)
Sets effectStep.choice to the effectStep.eligible-marked card of the pile effectStep....
s32 CARDGAME_pickComputerCards(CardBattle *battle, CardScreen *screen)
The computer marks (effectStep.marked) the cards of its hand it plays: up to six that can be played,...
void CARDGAME_setupCardChoice(CardBattle *battle, CardScreen *screen, s32 side, s32 kind)
Sets up CARDGAME_chooseCard's choice of one of a side's cards: kind 0 among its hand,...
Definition card_choice.c:8
void CARDGAME_moveHandHighlight(CardBattle *battle, CardScreen *screen, s32 delta)
Moves the highlight along the hand by delta, raising the highlighted card.
Definition card_choice.c:56
static void showPlayedCard(CardBattle *battle, CardScreen *screen)
Shows the card being played (sprite 15) scaling in on the slot row.
Definition card_choice.c:86
s32 CARDGAME_stepPreviousCardChoice(CardBattle *battle, CardScreen *screen)
The steps of CARDGAME_startPreviousCardChoice: confirming takes the card before the last one played,...
void CARDGAME_showTargetSlots(CardBattle *battle, CardScreen *screen, s32 owner, s32 target)
Shows the card being played as sprite 15 and lets the slots out that its target picks (a side of owne...
void CARDGAME_startPileChoice(CardBattle *battle, CardScreen *screen, s32 flags)
Shows the card being played as sprite 15 and the panels with flags, and starts CARDGAME_stepPileChoic...
s32 CARDGAME_stepPileChoice(CardBattle *battle, CardScreen *screen)
The steps of CARDGAME_startPileChoice: confirming is allowed when the pile the panel flags (effectSte...
void CARDGAME_pickComputerDeckCard(CardBattle *battle, CardScreen *screen)
The computer's pick from its deck: the first card flagged (effectStep.eligible) from its top up to dr...
void CARDGAME_pickLowestPlayerCard(CardBattle *battle, CardScreen *screen)
Picks the player's card with the lowest CardImage.rank, the strongest.
void initCardDrawer(CardDrawer *obj)
Clears a card drawer, gives it its methods and binds it.
#define CARD_ANIM_DIM_ALL
Definition battle.h:190
@ CARD_ANIM_HIDE_SLOTS
Definition battle.h:169
@ CARD_ANIM_SHOW_SLOTS
Definition battle.h:168
@ CARD_ANIM_NONE
Definition battle.h:167
s32 CARDGAME_selectionText
the message of CARDGAME_chooseCard's selection
Definition cardgame_3.c:181
s32 CARDGAME_slotRowPositions[2][4]
sprite positions, by SHIFT_PAL_SCREEN
Definition cardgame_3.c:14
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
s32 SHIFT_PAL_SCREEN
moves both display areas 0x18 lines down
Definition eu_settings.c:15
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_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_RIGHT
Definition pad.h:23
#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_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_sortOpponentCards(CardBattle *battle)
Sorts the opponent's cards by opponentDraws[].order, then swaps card effectStep.choice to reserveStar...
Definition play_checks.c:7
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
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_MENU_CONFIRM
SYSTEM07.
Definition sound.h:44
#define SOUND_MENU_CANCEL
SYSTEM01.
Definition sound.h:39
#define SOUND_MENU_MOVE
SYSTEM06.
Definition sound.h:43
s32 count
the pile's cards
Definition battle.h:204
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 drawEnd
the first card of the opponent's deck above the round's group
Definition battle.h:260
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
CardPlan opponentPlans[40]
one per card of side 1 (40-79)
Definition battle.h:257
void(* shufflePile)(struct CardBattle *battle, s32 base, s32 n)
Definition battle.h:276
CardAnim anim
Definition battle.h:263
void(* sortCards)(struct CardBattle *battle, s16 *list, s32 range, s32 flags)
Definition battle.h:277
CardStep effectStep
Definition battle.h:262
CardSide sides[2]
Definition battle.h:274
CardDraw opponentDraws[40]
by the opponent's deck card
Definition battle.h:255
u8 order
its place in the deck
Definition battle.h:103
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
A card's image (CardDrawer.card): 64 to a file, a 12-byte header and a 32x32 8-bit TIM.
Definition gfx.h:172
u8 color
from 1
Definition gfx.h:173
s16 rank
by strength, from 1 the strongest (0 on the two blank cards)
Definition gfx.h:182
s16 state
Definition screen.h:137
s16 deckCount
the cards left in the deck
Definition battle.h:113
s16 discardCount
Definition battle.h:112
s16 deck[40]
deckTop on are left
Definition battle.h:118
s16 handCount
Definition battle.h:114
s16 deckTop
the index of the deck's top card
Definition battle.h:111
u8 points[5]
one per card colour
Definition battle.h:115
s16 discards[10]
the cards played and lost from the slots, discardCount in use
Definition battle.h:120
s16 hand[10]
handCount in use
Definition battle.h:119
u8 kind
1-7 (CardDeckCard.kind)
Definition battle.h:64
s16 card
the index in the battle's card list
Definition battle.h:44
s16 mark
Definition battle.h:45
CardSlot slots[8]
Definition battle.h:39
u8 slotCount
Definition battle.h:38
s8 playCount
the plays in use
Definition battle.h:130
CardPlay plays[3]
the cards played this turn, up to three
Definition battle.h:137
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(* closePanel)(struct CardScreen *screen, s32 side)
Definition screen.h:292
void(* scaleSprite)(struct CardScreen *screen, s32 index, s32 duration, s32 scaleX, s32 scaleY)
Definition screen.h:318
s32(* getCardColor)(struct CardScreen *screen, s32 index)
Definition screen.h:325
void(* setPanelFlags)(struct CardScreen *screen, s32 bits)
Definition screen.h:291
void(* clearPanelFlags)(struct CardScreen *screen)
Definition screen.h:290
void(* resetPanels)(struct CardScreen *screen)
Definition screen.h:296
void(* openPanels)(struct CardScreen *screen)
Definition screen.h:295
CardSprite sprites[40]
Definition screen.h:271
s32(* getHandOffset)(s32 count, s32 index)
Definition screen.h:299
s32(* removeSprite)(struct CardScreen *screen, s32 index)
Definition screen.h:315
void(* closePanels)(struct CardScreen *screen)
Definition screen.h:294
void(* closeWindow)(struct CardScreen *screen, s32 index)
Definition screen.h:289
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 card
the index in the battle's card list
Definition battle.h:20
s16 moving
Definition screen.h:177
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
u8 flags
the step's own: the rows to pick from, the deck run out...
Definition battle.h:153
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(* 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
short(* playSound)(s32 id)
returns the voice of a key-on
Definition sound.h:187