Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
table_view.c
Go to the documentation of this file.
1/* CARDGAME's table views: browsing the played cards and picking one. */
2
4
5/* Starts CARDGAME_viewTable */
7 battle->effectStep.nextState = 1;
8}
9
10/* The table's height: 8 per card of the longer row of slots (at least 3), and
11 14 */
13 s32 n;
14
15 if (battle->players[0].slotCount > battle->players[1].slotCount) {
16 n = battle->players[0].slotCount;
17 } else {
18 n = battle->players[1].slotCount;
19 }
20 if (n < 3) {
21 n = 3;
22 }
23 return n * 8 + 14;
24}
25
26/* Moves the highlight of a row of cards (kind 0, 1 or 2) by delta */
27void CARDGAME_moveTableHighlight(CardBattle *battle, CardScreen *screen, s32 kind, s32 delta) {
28 s32 offset = 0;
29
31 switch (kind) {
32 case 1:
33 offset = 6;
34 break;
35 case 2:
36 offset = 12;
37 break;
38 }
39 screen->sprites[offset + battle->effectStep.cursor].highlight &= ~1;
40 screen->sprites[offset + battle->effectStep.cursor].moving = 0;
41 battle->effectStep.cursor += delta;
42 screen->sprites[offset + battle->effectStep.cursor].highlight |= 1;
43 screen->sprites[offset + battle->effectStep.cursor].moving = 1;
44}
45
46/* Closes the card info's four windows */
47static inline void closeTableWindows(CardScreen *screen) {
48 screen->closeWindow(screen, 4);
49 screen->closeWindow(screen, 1);
50 screen->closeWindow(screen, 2);
51 screen->closeWindow(screen, 3);
52}
53
54/* Starts showing a row of cards (0, 1 or 2) and its windows */
55static inline void startTableRow(CardBattle *battle, CardScreen *screen, s32 row) {
56 CARDGAME_clearCardInfo(battle, screen);
57 battle->effectStep.vars[0] = 0;
58 battle->effectStep.time = 0;
59 battle->effectStep.vars[3] = row;
60}
61
62/* Leaves a row of cards (its first sprite at offset): unhighlights its card
63 and closes the windows */
64static inline void leaveTableRow(CardBattle *battle, CardScreen *screen, s32 offset) {
65 screen->sprites[battle->effectStep.cursor + offset].highlight &= ~1;
66 screen->sprites[battle->effectStep.cursor + offset].moving = 0;
67 closeTableWindows(screen);
68 battle->effectStep.vars[0] = 0;
69 battle->effectStep.time = 0;
70}
71
72/* Sets up the table view's next state (effectStep.nextState): opening the
73 panels, a row, leaving a row, closing, or the no-cards message */
74static inline void setUpViewState(CardBattle *battle, CardScreen *screen) {
75 switch (battle->effectStep.nextState) {
76 case 1:
79 screen->panels[0].scale.state = 0;
80 screen->panels[1].scale.state = 0;
83 battle->effectStep.vars[1] = CARDGAME_getTableHeight(battle, screen);
84 battle->effectStep.cursor = 0;
85 screen->resetPanels(screen);
86 screen->openPanels(screen);
87 CARDGAME_clearCardInfo(battle, screen);
88 break;
89 case 2:
90 startTableRow(battle, screen, 0);
91 break;
92 case 4:
93 startTableRow(battle, screen, 1);
94 break;
95 case 3:
96 startTableRow(battle, screen, 2);
97 break;
98 case 8:
99 leaveTableRow(battle, screen, 0);
100 break;
101 case 9:
102 leaveTableRow(battle, screen, 12);
103 break;
104 case 10:
105 leaveTableRow(battle, screen, 6);
106 break;
107 case 11:
108 screen->closePanels(screen);
109 closeTableWindows(screen);
111 break;
112 case 12:
113 screen->openMessage(screen, 0x17, 0, 0, 1);
114 break;
115 case 14:
116 screen->closeMessage(screen);
117 screen->closePanels(screen);
118 break;
119 case 15:
120 /* nothing to set up: it ends */
121 break;
122 }
123}
124
125/* Once the panels are open, shows the first row with cards in it, or the
126 no-cards message */
127static inline void chooseFirstRow(CardBattle *battle, CardScreen *screen) {
128 if (screen->panels[0].state == 2 && battle->anim.current == CARD_ANIM_NONE) {
129 if (battle->players[0].slotCount != 0) {
130 battle->effectStep.nextState = 2;
131 battle->effectStep.vars[3] = 0;
132 } else if (battle->players[1].slotCount != 0) {
133 battle->effectStep.nextState = 4;
134 battle->effectStep.vars[3] = 1;
135 } else if (battle->record.playCount > 0) {
136 battle->effectStep.nextState = 3;
137 battle->effectStep.vars[3] = 2;
138 } else {
139 battle->effectStep.nextState = 12;
140 battle->effectStep.vars[3] = 3;
141 }
142 }
143}
144
145/* The player's own row: up goes to the played or the opponent's row, left
146 and right move along it, triangle leaves */
147static inline void browseOwnRow(CardBattle *battle, CardScreen *screen) {
148 if (PAD_PRESSED(PAD_UP) && (battle->record.playCount > 0 || battle->players[1].slotCount != 0)) {
149 battle->effectStep.nextState = 8;
150 }
151 if ((PAD.getPressed(0) & (1 << PAD.getButtonBit(0, PAD_RIGHT))) | (PAD.getRepeated(0) & (1 << PAD.getButtonBit(0, PAD_RIGHT)))) {
152 if (battle->effectStep.cursor < battle->players[0].slotCount - 1) {
153 CARDGAME_moveTableHighlight(battle, screen, 0, 1);
154 }
155 }
156 if ((PAD.getPressed(0) & (1 << PAD.getButtonBit(0, PAD_LEFT))) | (PAD.getRepeated(0) & (1 << PAD.getButtonBit(0, PAD_LEFT)))) {
157 if (battle->effectStep.cursor > 0) {
158 CARDGAME_moveTableHighlight(battle, screen, 0, -1);
159 }
160 }
161 CARDGAME_showTableCardInfo(battle, screen, 0);
164 battle->effectStep.nextState = 11;
165 }
166}
167
168/* The opponent's row: down goes to the played or the player's own row, left
169 and right move along it, triangle leaves */
170static inline void browseOpponentRow(CardBattle *battle, CardScreen *screen) {
171 if (PAD_PRESSED(PAD_DOWN) && (battle->record.playCount > 0 || battle->players[0].slotCount != 0)) {
172 battle->effectStep.nextState = 10;
173 }
174 if ((PAD.getPressed(0) & (1 << PAD.getButtonBit(0, PAD_RIGHT))) | (PAD.getRepeated(0) & (1 << PAD.getButtonBit(0, PAD_RIGHT)))) {
175 if (battle->effectStep.cursor < battle->players[1].slotCount - 1) {
176 CARDGAME_moveTableHighlight(battle, screen, 1, 1);
177 }
178 }
179 if ((PAD.getPressed(0) & (1 << PAD.getButtonBit(0, PAD_LEFT))) | (PAD.getRepeated(0) & (1 << PAD.getButtonBit(0, PAD_LEFT)))) {
180 if (battle->effectStep.cursor > 0) {
181 CARDGAME_moveTableHighlight(battle, screen, 1, -1);
182 }
183 }
184 CARDGAME_showTableCardInfo(battle, screen, 1);
187 battle->effectStep.nextState = 11;
188 }
189}
190
191/* The row of the cards played: up and down go to the opponent's or the
192 player's own row, left and right move along it, triangle leaves */
193static inline void browsePlayedRow(CardBattle *battle, CardScreen *screen) {
194 if (PAD_PRESSED(PAD_UP)) {
195 if (battle->players[1].slotCount != 0) {
196 battle->effectStep.vars[1] = 1;
197 battle->effectStep.nextState = 9;
198 }
199 } else if (PAD_PRESSED(PAD_DOWN) && battle->players[0].slotCount != 0) {
200 battle->effectStep.vars[1] = 0;
201 battle->effectStep.nextState = 9;
202 }
203 if ((PAD.getPressed(0) & (1 << PAD.getButtonBit(0, PAD_RIGHT))) | (PAD.getRepeated(0) & (1 << PAD.getButtonBit(0, PAD_RIGHT)))) {
204 if (battle->effectStep.cursor < battle->record.playCount - 1) {
205 CARDGAME_moveTableHighlight(battle, screen, 2, 1);
206 }
207 }
208 if ((PAD.getPressed(0) & (1 << PAD.getButtonBit(0, PAD_LEFT))) | (PAD.getRepeated(0) & (1 << PAD.getButtonBit(0, PAD_LEFT)))) {
209 if (battle->effectStep.cursor > 0) {
210 CARDGAME_moveTableHighlight(battle, screen, 2, -1);
211 }
212 }
215 battle->effectStep.nextState = 11;
216 }
217 CARDGAME_showTableCardInfo(battle, screen, 2);
218}
219
220/* 11 frames after leaving the player's own row, goes up to the played row
221 (the cursor halved) or the opponent's row */
222static inline void leaveOwnRow(CardBattle *battle, CardScreen *screen) {
223 battle->effectStep.time++;
224 if (battle->effectStep.time >= 11) {
225 if (battle->record.playCount > 0) {
226 battle->effectStep.nextState = 3;
227 battle->effectStep.cursor /= 2;
228 if (battle->effectStep.cursor > battle->record.playCount - 1) {
229 battle->effectStep.cursor = battle->record.playCount - 1;
230 }
231 } else if (battle->players[1].slotCount != 0) {
232 battle->effectStep.nextState = 4;
233 if (battle->effectStep.cursor > battle->players[1].slotCount - 1) {
234 battle->effectStep.cursor = battle->players[1].slotCount - 1;
235 }
236 }
237 }
238}
239
240/* 11 frames after leaving the played row, goes to the opponent's
241 (effectStep.vars[1]) or the player's own row, the cursor doubled */
242static inline void leavePlayedRow(CardBattle *battle, CardScreen *screen) {
243 battle->effectStep.time++;
244 if (battle->effectStep.time >= 11) {
245 battle->effectStep.cursor = battle->effectStep.cursor * 2 + 1;
246 if (battle->effectStep.vars[1] != 0) {
247 battle->effectStep.nextState = 4;
248 if (battle->effectStep.cursor > battle->players[1].slotCount - 1) {
249 battle->effectStep.cursor = battle->players[1].slotCount - 1;
250 }
251 } else {
252 battle->effectStep.nextState = 2;
253 if (battle->effectStep.cursor > battle->players[0].slotCount - 1) {
254 battle->effectStep.cursor = battle->players[0].slotCount - 1;
255 }
256 }
257 }
258}
259
260/* 11 frames after leaving the opponent's row, goes down to the played row
261 (the cursor halved) or the player's own row */
262static inline void leaveOpponentRow(CardBattle *battle, CardScreen *screen) {
263 battle->effectStep.time++;
264 if (battle->effectStep.time >= 11) {
265 if (battle->record.playCount > 0) {
266 battle->effectStep.nextState = 3;
267 battle->effectStep.cursor /= 2;
268 if (battle->effectStep.cursor > battle->record.playCount - 1) {
269 battle->effectStep.cursor = battle->record.playCount - 1;
270 }
271 } else if (battle->players[0].slotCount != 0) {
272 battle->effectStep.nextState = 2;
273 if (battle->effectStep.cursor > battle->players[0].slotCount - 1) {
274 battle->effectStep.cursor = battle->players[0].slotCount - 1;
275 }
276 }
277 }
278}
279
280/* Lets the player look over the cards out on the table: the two players' rows
281 and the row of the cards played (up and down change rows, left and right
282 move along one, triangle leaves), each state set up by setUpViewState; 1
283 once it is over */
285 s32 done = 0;
286
287 if (battle->effectStep.nextState != 0) {
288 setUpViewState(battle, screen);
289 battle->effectStep.state = battle->effectStep.nextState;
290 battle->effectStep.nextState = 0;
291 }
292 switch (battle->effectStep.state) {
293 case 1:
294 chooseFirstRow(battle, screen);
295 break;
296 case 2:
297 case 3:
298 case 4:
299 battle->effectStep.vars[0] = CARDGAME_openStepWindows(battle, screen, battle->effectStep.vars[3], 0, battle->effectStep.time, battle->effectStep.vars[0]);
301 battle->effectStep.time++;
302 if (battle->effectStep.time >= 11) {
303 CARDGAME_moveTableHighlight(battle, screen, battle->effectStep.vars[3], 0);
305 }
306 break;
307 case 5:
308 browseOwnRow(battle, screen);
309 break;
310 case 6:
311 browseOpponentRow(battle, screen);
312 break;
313 case 7:
314 browsePlayedRow(battle, screen);
315 break;
316 case 8:
317 leaveOwnRow(battle, screen);
318 break;
319 case 9:
320 leavePlayedRow(battle, screen);
321 break;
322 case 10:
323 leaveOpponentRow(battle, screen);
324 break;
325 case 11:
326 if (screen->panels[0].state == 0 && battle->anim.current == CARD_ANIM_NONE) {
327 battle->effectStep.nextState = 15;
328 }
329 break;
330 case 12:
331 if (screen->message.state == 2) {
332 battle->effectStep.nextState = 13;
333 }
334 break;
335 case 13:
337 battle->effectStep.nextState = 14;
338 }
339 break;
340 case 14:
341 if (screen->message.state == 0) {
342 battle->effectStep.nextState = 15;
343 }
344 break;
345 case 15:
348 done = 1;
349 break;
350 }
351 return done;
352}
353
354/* Starts CARDGAME_pickTableCard, which triangle backs out of when cancelable
355 (effectStep.vars[4]) */
356void CARDGAME_startPickTableCard(CardBattle *battle, CardScreen *screen, s32 cancelable) {
357 battle->effectStep.vars[4] = cancelable;
358 battle->effectStep.nextState = 1;
359}
360
361/* CARDGAME_getTableHeight, for CARDGAME_pickTableCard */
363 return CARDGAME_getTableHeight(battle, screen);
364}
365
366/* CARDGAME_moveTableHighlight, for CARDGAME_pickTableCard */
367void CARDGAME_movePickHighlight(CardBattle *battle, CardScreen *screen, s32 kind, s32 delta) {
368 CARDGAME_moveTableHighlight(battle, screen, kind, delta);
369}
370
371/* Sets up the table pick's next state (effectStep.nextState): dimming the
372 cards that can't be picked, a row, leaving a row, the pick, or closing */
373static inline void setUpPickState(CardBattle *battle, CardScreen *screen) {
374 s32 i;
375 /* the match depends on a second loop variable: GCC 2.8.1 gives the first
376 two loops other registers than it gives i */
377 s32 j;
378
379 switch (battle->effectStep.nextState) {
380 case 1:
381 if (battle->effectStep.vars[4] != 0) {
382 for (j = 0; j < 3; j++) {
383 battle->anim.dimmed[j + 12] = 1;
384 }
385 for (j = 0; j < 12; j++) {
386 if (battle->effectStep.eligible[j] != 0) {
387 battle->anim.dimmed[j] = 0;
388 } else {
389 battle->anim.dimmed[j] = 1;
390 }
391 }
393 battle->effectStep.cursor = 0;
394 screen->resetPanels(screen);
395 screen->openPanels(screen);
396 screen->addSprite(screen, 15, 0xE500, 0x6100);
397 screen->setSpriteCard(screen, 15, battle->record.plays[battle->record.playCount].card);
398 screen->sprites[15].scaleX = 0;
399 screen->scaleSprite(screen, 15, 8, 0x1000, 0x1000);
400 } else {
401 for (i = 0; i < 3; i++) {
402 screen->sprites[i + 12].dimmed = 1;
403 }
404 for (i = 0; i < 12; i++) {
405 if (battle->effectStep.eligible[i] != 0) {
406 screen->sprites[i].dimmed = 0;
407 } else {
408 screen->sprites[i].dimmed = 1;
409 }
410 }
411 }
412 battle->effectStep.vars[1] = CARDGAME_getPickTableHeight(battle, screen);
413 CARDGAME_clearCardInfo(battle, screen);
414 break;
415 case 2:
416 startTableRow(battle, screen, 0);
417 break;
418 case 3:
419 startTableRow(battle, screen, 1);
420 break;
421 case 7:
422 leaveTableRow(battle, screen, 0);
423 break;
424 case 8:
425 leaveTableRow(battle, screen, 6);
426 break;
427 case 6:
428 closeTableWindows(screen);
429 screen->startBlink(screen, battle->effectStep.choice);
431 break;
432 case 9:
433 screen->closePanels(screen);
434 closeTableWindows(screen);
436 screen->scaleSprite(screen, 15, 8, 0, 0x1000);
437 break;
438 case 10:
439 screen->closePanels(screen);
441 screen->scaleSprite(screen, 15, 8, 0, 0x1000);
442 break;
443 case 14:
444 /* nothing to set up */
445 break;
446 }
447}
448
449/* Once the panels are open (or right away without them), shows the first
450 row the pick allows that has cards in it, or the no-cards message */
451static inline void chooseFirstPickRow(CardBattle *battle, CardScreen *screen) {
452 if (battle->effectStep.vars[4] == 0 || (screen->panels[0].state == 2 && battle->anim.current == CARD_ANIM_NONE)) {
453 if (battle->effectStep.flags & 1) {
454 if (battle->players[0].slotCount != 0) {
455 battle->effectStep.nextState = 2;
456 battle->effectStep.vars[3] = 0;
457 } else {
458 battle->effectStep.flags &= ~1;
459 }
460 }
461 if (battle->effectStep.flags & 2) {
462 if (battle->players[1].slotCount != 0) {
463 battle->effectStep.nextState = 3;
464 battle->effectStep.vars[3] = 1;
465 } else {
466 battle->effectStep.flags &= ~2;
467 }
468 }
469 if (battle->effectStep.flags == 0) {
470 battle->effectStep.nextState = 12;
471 battle->effectStep.vars[3] = 3;
472 }
473 }
474}
475
476/* The player's own row: up goes to the opponent's row when allowed, left and
477 right move along it, triangle backs out (with effectStep.vars[4]), cross
478 picks an eligible card */
479static inline void pickInOwnRow(CardBattle *battle, CardScreen *screen) {
480 if ((battle->effectStep.flags & 2) && PAD_PRESSED(PAD_UP) && battle->players[1].slotCount != 0) {
481 battle->effectStep.nextState = 7;
482 }
483 if ((PAD.getPressed(0) & (1 << PAD.getButtonBit(0, PAD_RIGHT))) | (PAD.getRepeated(0) & (1 << PAD.getButtonBit(0, PAD_RIGHT)))) {
484 if (battle->effectStep.cursor < battle->players[0].slotCount - 1) {
485 CARDGAME_moveTableHighlight(battle, screen, 0, 1);
486 }
487 }
488 if ((PAD.getPressed(0) & (1 << PAD.getButtonBit(0, PAD_LEFT))) | (PAD.getRepeated(0) & (1 << PAD.getButtonBit(0, PAD_LEFT)))) {
489 if (battle->effectStep.cursor > 0) {
490 CARDGAME_moveTableHighlight(battle, screen, 0, -1);
491 }
492 }
493 CARDGAME_showTableCardInfo(battle, screen, 0);
494 if (battle->effectStep.vars[4] != 0 && PAD_PRESSED(PAD_TRIANGLE)) {
496 battle->effectStep.nextState = 9;
497 }
498 if (PAD_PRESSED(PAD_CROSS) && battle->effectStep.eligible[battle->effectStep.cursor] != 0) {
499 battle->effectStep.nextState = 6;
500 battle->effectStep.choice = battle->effectStep.cursor;
501 }
502}
503
504/* The opponent's row: down goes to the player's own row when allowed, left
505 and right move along it, triangle backs out (with effectStep.vars[4]),
506 else cross picks an eligible card */
507static inline void pickInOpponentRow(CardBattle *battle, CardScreen *screen) {
508 if ((battle->effectStep.flags & 1) && PAD_PRESSED(PAD_DOWN) && battle->players[0].slotCount != 0) {
509 battle->effectStep.nextState = 8;
510 }
511 if ((PAD.getPressed(0) & (1 << PAD.getButtonBit(0, PAD_RIGHT))) | (PAD.getRepeated(0) & (1 << PAD.getButtonBit(0, PAD_RIGHT)))) {
512 if (battle->effectStep.cursor < battle->players[1].slotCount - 1) {
513 CARDGAME_moveTableHighlight(battle, screen, 1, 1);
514 }
515 }
516 if ((PAD.getPressed(0) & (1 << PAD.getButtonBit(0, PAD_LEFT))) | (PAD.getRepeated(0) & (1 << PAD.getButtonBit(0, PAD_LEFT)))) {
517 if (battle->effectStep.cursor > 0) {
518 CARDGAME_moveTableHighlight(battle, screen, 1, -1);
519 }
520 }
521 CARDGAME_showTableCardInfo(battle, screen, 1);
522 if (battle->effectStep.vars[4] != 0 && PAD_PRESSED(PAD_TRIANGLE)) {
524 battle->effectStep.nextState = 9;
525 } else if (PAD_PRESSED(PAD_CROSS) && battle->effectStep.eligible[battle->effectStep.cursor + 6] != 0) {
526 battle->effectStep.nextState = 6;
527 battle->effectStep.choice = battle->effectStep.cursor + 6;
528 }
529}
530
531/* Lets the player pick a card out on the table (effectStep.flags bit 0: in their own
532 row, bit 1: in the opponent's): 2 once one is picked (its sprite in
533 effectStep.choice), 1 if there was none or the player backed out; each
534 state is set up by setUpPickState */
536 s32 result = 0;
537 s32 i;
538
539 if (battle->effectStep.nextState != 0) {
540 setUpPickState(battle, screen);
541 battle->effectStep.state = battle->effectStep.nextState;
542 battle->effectStep.nextState = 0;
543 }
544 switch (battle->effectStep.state) {
545 case 1:
546 chooseFirstPickRow(battle, screen);
547 break;
548 case 2:
549 case 3:
550 battle->effectStep.vars[0] = CARDGAME_openStepWindows(battle, screen, battle->effectStep.vars[3], 0, battle->effectStep.time, battle->effectStep.vars[0]);
552 battle->effectStep.time++;
553 if (battle->effectStep.time >= 11) {
554 switch (battle->effectStep.vars[3]) {
555 case 0:
556 CARDGAME_movePickHighlight(battle, screen, 0, 0);
557 battle->effectStep.nextState = 4;
558 break;
559 case 1:
560 CARDGAME_movePickHighlight(battle, screen, 1, 0);
561 battle->effectStep.nextState = 5;
562 break;
563 }
564 }
565 break;
566 case 4:
567 pickInOwnRow(battle, screen);
568 break;
569 case 5:
570 pickInOpponentRow(battle, screen);
571 break;
572 case 6:
573 if (screen->sprites[battle->effectStep.choice].state == 1) {
574 if (battle->effectStep.vars[4] == 0) {
575 for (i = 0; i < 3; i++) {
576 screen->sprites[i + 12].dimmed = 0;
577 }
578 for (i = 0; i < 12; i++) {
579 screen->sprites[i].dimmed = 0;
580 }
581 }
582 battle->effectStep.nextState = 14;
583 }
584 break;
585 case 7:
586 battle->effectStep.time++;
587 if (battle->effectStep.time >= 11) {
588 battle->effectStep.nextState = 3;
589 if (battle->effectStep.cursor > battle->players[1].slotCount - 1) {
590 battle->effectStep.cursor = battle->players[1].slotCount - 1;
591 }
592 }
593 break;
594 case 8:
595 battle->effectStep.time++;
596 if (battle->effectStep.time >= 11) {
597 battle->effectStep.nextState = 2;
598 if (battle->effectStep.cursor > battle->players[0].slotCount - 1) {
599 battle->effectStep.cursor = battle->players[0].slotCount - 1;
600 }
601 }
602 break;
603 case 11:
604 battle->effectStep.nextState = 14;
605 break;
606 case 9:
607 case 10:
608 if (screen->panels[0].state == 0 && battle->anim.current == CARD_ANIM_NONE) {
609 battle->effectStep.nextState = 13;
610 }
611 break;
612 case 12:
615 battle->effectStep.nextState = 10;
616 }
617 break;
618 case 13:
619 result = 1;
620 break;
621 case 14:
622 for (i = 0; i < 15; i++) {
623 battle->effectStep.marked[i] = 0;
624 }
625 result = 2;
626 battle->effectStep.marked[battle->effectStep.choice] = 1;
627 break;
628 }
629 return result;
630}
CARDGAME.PRO: the card battle (mode 0x700).
#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
s32 CARDGAME_rowSteps[]
the step of each row of CARDGAME_viewTable
Definition cardgame_2.c:27
s32 CARDGAME_rowSpriteOffsets[]
the sprite offset of each row of CARDGAME_viewTable
Definition cardgame_2.c:18
s16 CARDGAME_savedPanelScales[2]
the panels' scale states, kept by CARDGAME_viewTable
Definition cardgame_3.c:180
signed int s32
Definition common.h:11
PadState PAD
Controller input: cleared by initPad, then the methods.
Definition pad.c:168
#define PAD_CROSS
Definition pad.h:31
#define PAD_DOWN
Definition pad.h:24
#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_UP
Definition pad.h:22
#define PAD_LEFT
Definition pad.h:25
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
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_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
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 dimmed[40]
by sprite
Definition battle.h:200
The card battle (CARDGAME_createBattle).
Definition battle.h:226
CardPlayer players[2]
Definition battle.h:275
CardRecord record
Definition battle.h:273
CardAnim anim
Definition battle.h:263
CardStep effectStep
Definition battle.h:262
u8 state
1 opening, 2 open, 4 confirmed, 5 closing
Definition screen.h:256
CardPanelScale scale
Definition screen.h:159
s16 state
Definition screen.h:137
s16 card
the index in the battle's card list
Definition battle.h:44
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
CardMessageWindow message
Definition screen.h:274
void(* setSpriteCard)(struct CardScreen *screen, s32 sprite, s32 index)
Definition screen.h:324
void(* scaleSprite)(struct CardScreen *screen, s32 index, s32 duration, s32 scaleX, s32 scaleY)
Definition screen.h:318
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
void(* openMessage)(struct CardScreen *screen, s32 message, s32 prompt, s16 choice, s32 place)
Definition screen.h:302
void(* closePanels)(struct CardScreen *screen)
Definition screen.h:294
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(* addSprite)(struct CardScreen *screen, s32 index, s32 x, s32 y)
Definition screen.h:314
CardPanel panels[2]
Definition screen.h:270
s16 moving
Definition screen.h:177
u8 dimmed
Definition screen.h:194
u8 highlight
bit 0 the cursor, bit 1 picked, bit 2 glowing
Definition screen.h:193
s16 scaleX
Definition screen.h:170
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 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
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
static void chooseFirstPickRow(CardBattle *battle, CardScreen *screen)
Once the panels are open (or right away without them), shows the first row the pick allows that has c...
Definition table_view.c:451
s32 CARDGAME_viewTable(CardBattle *battle, CardScreen *screen)
Lets the player look over the cards out on the table: the two players' rows and the row of the cards ...
Definition table_view.c:284
static void pickInOwnRow(CardBattle *battle, CardScreen *screen)
The player's own row: up goes to the opponent's row when allowed, left and right move along it,...
Definition table_view.c:479
void CARDGAME_moveTableHighlight(CardBattle *battle, CardScreen *screen, s32 kind, s32 delta)
Moves the highlight of a row of cards (kind 0, 1 or 2) by delta.
Definition table_view.c:27
void CARDGAME_movePickHighlight(CardBattle *battle, CardScreen *screen, s32 kind, s32 delta)
CARDGAME_moveTableHighlight, for CARDGAME_pickTableCard.
Definition table_view.c:367
static void pickInOpponentRow(CardBattle *battle, CardScreen *screen)
The opponent's row: down goes to the player's own row when allowed, left and right move along it,...
Definition table_view.c:507
s32 CARDGAME_getTableHeight(CardBattle *battle, CardScreen *screen)
The table's height: 8 per card of the longer row of slots (at least 3), and 14.
Definition table_view.c:12
s32 CARDGAME_pickTableCard(CardBattle *battle, CardScreen *screen)
Lets the player pick a card out on the table (effectStep.flags bit 0: in their own row,...
Definition table_view.c:535
static void browsePlayedRow(CardBattle *battle, CardScreen *screen)
The row of the cards played: up and down go to the opponent's or the player's own row,...
Definition table_view.c:193
static void browseOwnRow(CardBattle *battle, CardScreen *screen)
The player's own row: up goes to the played or the opponent's row, left and right move along it,...
Definition table_view.c:147
static void setUpViewState(CardBattle *battle, CardScreen *screen)
Sets up the table view's next state (effectStep.nextState): opening the panels, a row,...
Definition table_view.c:74
static void setUpPickState(CardBattle *battle, CardScreen *screen)
Sets up the table pick's next state (effectStep.nextState): dimming the cards that can't be picked,...
Definition table_view.c:373
void CARDGAME_startViewTable(CardBattle *battle, CardScreen *screen)
Starts CARDGAME_viewTable.
Definition table_view.c:6
static void leavePlayedRow(CardBattle *battle, CardScreen *screen)
11 frames after leaving the played row, goes to the opponent's (effectStep.vars[1]) or the player's o...
Definition table_view.c:242
static void leaveOpponentRow(CardBattle *battle, CardScreen *screen)
11 frames after leaving the opponent's row, goes down to the played row (the cursor halved) or the pl...
Definition table_view.c:262
static void chooseFirstRow(CardBattle *battle, CardScreen *screen)
Once the panels are open, shows the first row with cards in it, or the no-cards message.
Definition table_view.c:127
static void leaveTableRow(CardBattle *battle, CardScreen *screen, s32 offset)
Leaves a row of cards (its first sprite at offset): unhighlights its card and closes the windows.
Definition table_view.c:64
static void leaveOwnRow(CardBattle *battle, CardScreen *screen)
11 frames after leaving the player's own row, goes up to the played row (the cursor halved) or the op...
Definition table_view.c:222
s32 CARDGAME_getPickTableHeight(CardBattle *battle, CardScreen *screen)
CARDGAME_getTableHeight, for CARDGAME_pickTableCard.
Definition table_view.c:362
static void browseOpponentRow(CardBattle *battle, CardScreen *screen)
The opponent's row: down goes to the played or the player's own row, left and right move along it,...
Definition table_view.c:170
static void closeTableWindows(CardScreen *screen)
Closes the card info's four windows.
Definition table_view.c:47
static void startTableRow(CardBattle *battle, CardScreen *screen, s32 row)
Starts showing a row of cards (0, 1 or 2) and its windows.
Definition table_view.c:55
void CARDGAME_startPickTableCard(CardBattle *battle, CardScreen *screen, s32 cancelable)
Starts CARDGAME_pickTableCard, which triangle backs out of when cancelable (effectStep....
Definition table_view.c:356