Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
album.c
Go to the documentation of this file.
1#include "cardgame/album.h"
2
3/* The cursor's CLUT row on each frame of its blink */
4s32 STCRDABM_cursorBlink[6] = {0, 1, 2, 3, 2, 1};
5
10
14#define FADER_DEPTH 0
16
17/* Loads the images of the grid's page of cards, from grid->first, into VRAM's 6x2 grid
18 of card images */
20 CardDrawer icon;
21 s32 card;
22 s32 col;
23 s32 row;
24
25 initCardDrawer(&icon);
26 icon.setImagePos(0x140, 0x100);
27 icon.setClutPos(0x300, 0x100);
28 card = grid->first;
29 for (row = 0; row < 2; row++) {
30 for (col = 0; col < 6 && card < CARD_COUNT; col++) {
31 icon.setCard(card++);
32 icon.setCell(col, row);
33 icon.loadImage();
34 }
35 }
36}
37
38/* Turns the grid to the page whose first card is `first` (grid->setPage) */
40 grid->prevFirst = grid->first;
41 grid->first = first;
42 grid->turned = 0;
43 grid->frame = 0;
44 grid->setState(grid, TASK_DONE);
45}
46
48
49/* Draws the page's cards, or the page being turned when previous != 0: a seen card's
50 image, the sprite of its color and its AP and HP (sprite 0x1D instead for the other
51 kinds), else an empty slot */
52void STCRDABM_drawCards(CardAlbumGrid *grid, s32 previous) {
53 SpriteDrawer sprite;
54 CardDrawer icon;
55 s32 digits[5];
56 s32 i;
57 s32 j;
58 s32 card;
59 s32 col;
60 s32 row;
61 s32 x;
62 s32 y;
63 s32 value;
64 s32 dx;
65
66 initSpriteDrawer(&sprite);
67 sprite.setLayerId(grid->layer, grid->depth);
68 sprite.setTexture(0x280, 0);
69 initCardDrawer(&icon);
70 icon.setImagePos(0x140, 0x100);
71 icon.setClutPos(0x300, 0x100);
72 icon.setLayer(grid->layer, grid->depth);
73 for (i = 0; i < grid->shown; i++) {
74 if (previous != 0) {
75 card = grid->prevFirst + i;
76 } else {
77 card = grid->first + i;
78 }
79 if (card >= CARD_COUNT) {
80 break;
81 }
82 col = i % 6;
83 row = i / 6;
84 x = col * 42;
85 y = row * 54;
86 if (GAME.cardsSeen[card] != 0) {
87 icon.setCard(card);
88 icon.setCell(col, row);
89 icon.draw(x + 0x27, y + 0x34);
90 if (icon.getKind() != 0) {
91 sprite.draw(FILE_CACHE.getEntry(STCRDABM_SPRITES), 0x1D, x + 0x27, y + 0x53);
92 } else {
93 value = icon.card->ap;
94 j = value / 10;
95 if (j != 0) {
96 digits[0] = j + 0x1E;
97 } else {
98 digits[0] = 0;
99 }
100 j = value % 10;
101 digits[1] = j + 0x1E;
102 digits[2] = 0x1C;
103 for (j = 0, dx = 0x27; j < 3; j++, dx += 7) {
104 if (digits[j] != 0) {
105 sprite.draw(FILE_CACHE.getEntry(STCRDABM_SPRITES), digits[j], x + dx, y + 0x53);
106 }
107 }
108 value = icon.card->hp;
109 j = value / 10;
110 if (j != 0) {
111 digits[0] = j + 0x1E;
112 } else {
113 digits[0] = 0;
114 }
115 j = value % 10;
116 digits[1] = j + 0x1E;
117 for (j = 0, dx = 0x3A; j < 2; j++, dx += 7) {
118 if (digits[j] != 0) {
119 sprite.draw(FILE_CACHE.getEntry(STCRDABM_SPRITES), digits[j], x + dx, y + 0x53);
120 }
121 }
122 }
123 sprite.draw(FILE_CACHE.getEntry(STCRDABM_SPRITES), icon.card->color - 1, x + 0x23, y + 0x32);
124 } else {
125 sprite.draw(FILE_CACHE.getEntry(STCRDABM_SPRITES), 6, x + 0x23, y + 0x32);
126 }
127 }
128}
129
130/* Draws the slots turned so far over the cards, flashing the ones with a seen card */
132 SpriteDrawer sprite;
133 s32 i;
134 s32 card;
135 s32 col;
136 s32 row;
137
138 initSpriteDrawer(&sprite);
139 sprite.setLayerId(grid->layer, grid->depth - 1);
140 sprite.setTexture(0x280, 0);
141 for (i = 0; i < grid->turned; i++) {
142 card = grid->first + i;
143 col = i % 6;
144 row = i / 6;
145 if (GAME.cardsSeen[card] != 0 || card >= CARD_COUNT) {
146 sprite.setClutRow(grid->frame);
147 } else {
148 sprite.setClutRow(0);
149 }
150 sprite.draw(FILE_CACHE.getEntry(STCRDABM_SPRITES), 6, col * 42 + 0x23, row * 54 + 0x32);
151 }
152}
153
154/* 1 when the grid's page holds a seen card (or runs past the last card) */
156 s32 card;
157 s32 i;
158
159 for (i = 0; i < ALBUM_PAGE_CARDS; i++) {
160 card = grid->first + i;
161 if (GAME.cardsSeen[card] != 0 || card >= CARD_COUNT) {
162 return 1;
163 }
164 }
165 return 0;
166}
167
169
170/* The card grid's task: draws the page's cards; on a page turn, turns its 12 slots one
171 every 2 frames over the old cards, then loads and shows the new ones, with a sound
172 when the page has cards */
174 switch (grid->state) {
175 case TASK_INIT:
176 default:
177 grid->nextState(grid);
178 grid->first = 1;
179 STCRDABM_setPage(grid, 1);
180 break;
181 case TASK_RUN:
183 STCRDABM_drawCards(grid, 0);
184 break;
185 case TASK_DONE:
186 switch (grid->substate) {
187 case 0:
188 default:
189 if (++grid->turned < ALBUM_PAGE_CARDS) {
190 grid->nextSubstate(grid);
191 grid->counter = GFX.funcs.getTime();
192 } else {
193 grid->turned = ALBUM_PAGE_CARDS;
194 grid->substate = 2;
195 }
196 break;
197 case 1:
198 if (GFX.funcs.getTime() - grid->counter >= 2) {
199 grid->substate = grid->step;
200 }
201 break;
202 case 2:
203 STCRDABM_loadIcons(grid);
204 grid->shown = ALBUM_PAGE_CARDS;
205 grid->time = GFX.funcs.getTime();
206 grid->nextSubstate(grid);
207 if (STCRDABM_pageHasCards(grid) != 0) {
209 }
210 break;
211 case 3:
212 if (GFX.funcs.getTime() - grid->time >= 2) {
213 grid->time = GFX.funcs.getTime();
214 if (++grid->frame >= 11) {
215 grid->state = 1;
216 }
217 }
218 break;
219 }
221 if (grid->substate < 3) {
222 STCRDABM_drawCards(grid, 1);
223 } else {
224 STCRDABM_drawCards(grid, 0);
225 }
226 break;
227 case TASK_KILL:
228 break;
229 }
230}
231
232/* Creates the album's card grid (task), on the top layer */
235
237 grid->hide = STCRDABM_hideCards;
238 grid->layer = SCREEN_LAYER;
239 grid->depth = 6;
240 grid->album = album;
241 return grid;
242}
243
244#define SCENE_TASK Task
245#define SCENE_CHILD CardAlbum
246#define SCENE_CREATE OVL_NAME(createAlbum)
247#define SCENE_PRIM_BUFFERS 0xF000
248#define SCENE_OT_SHIFT 3
250#include "shared/start.inc.c"
251
252/* Creates the album's text windows (the page's and the selected card's), in front of
253 the album */
255 TextWindow **items;
256 s32 i;
257
258 win->title = createTextWindow(album->layer, 1, 0x10, 0x19);
259 win->help = createTextWindow(album->layer, 1, 0xD0, 0x19);
260 win->page = createTextWindow(album->layer, 1, 0x34, 0x9E);
261 win->pageSlash = createTextWindow(album->layer, 1, 0x35, 0x9E);
262 win->pageCount = createTextWindow(album->layer, 1, 0x4A, 0x9E);
263 win->prev = createTextWindow(album->layer, 1, 0x12, 0x6C);
264 win->next = createTextWindow(album->layer, 1, 0x121, 0x6C);
265 win->name = createTextWindow(album->layer, 1, 0x88, 0xA1);
266 win->levelLabel = createTextWindow(album->layer, 1, 0x115, 0xA1);
267 win->level = createTextWindow(album->layer, 1, 0x126, 0xA1);
268 win->countLabel = createTextWindow(album->layer, 1, 0x115, 0xC7);
269 win->count = createTextWindow(album->layer, 1, 0x12C, 0xC7);
270 win->text = createTextWindow(album->layer, 1, 0x50, 0xB8);
271 win->stat1Label = createTextWindow(album->layer, 1, 0xCE, 0xB8);
272 win->stat1 = createTextWindow(album->layer, 1, 0xF0, 0xB8);
273 win->stat2Label = createTextWindow(album->layer, 1, 0xCE, 0xC5);
274 win->stat2 = createTextWindow(album->layer, 1, 0xF0, 0xC5);
275 for (i = 0, items = album->children; i < album->childCount - 2; i++, items++) {
276 (*items)->setDepth(*items, album->depth - 3);
277 }
278}
279
280/* Shows the title, help and page number and, while the album takes input, the previous
281 and next page hints where there is such a page; hides them all when show is 0 */
283 if (show != 0) {
286 win->page->setNumber(win->page, 0, album->page + 1);
287 win->page->setRightAlign(win->page, 1);
289 win->pageCount->setNumber(win->pageCount, 0, album->pageCount);
290 win->pageCount->setRightAlign(win->pageCount, 1);
291 if (album->active != 0) {
292 if (album->page > 0) {
294 } else {
295 win->prev->setVisible(win->prev, 0);
296 }
297 if (album->page < album->pageCount - 1) {
299 } else {
300 win->next->setVisible(win->next, 0);
301 }
302 }
303 } else {
304 win->title->setVisible(win->title, 0);
305 win->help->setVisible(win->help, 0);
306 win->page->setVisible(win->page, 0);
307 win->pageSlash->setVisible(win->pageSlash, 0);
308 win->pageCount->setVisible(win->pageCount, 0);
309 win->prev->setVisible(win->prev, 0);
310 win->next->setVisible(win->next, 0);
311 }
312}
313
314/*
315 * Shows the card under the cursor (album->card = page * 12 + slot + 1) once
316 * the player has seen it: its name, the copies owned and, for a card of kind
317 * 0, its level and its two stats, or its text for cards 0x45, 0x70, 0x9B,
318 * 0xC6 and 0xF1; the other kinds show their text. Hides it all otherwise.
319 */
321 CardDrawer icon;
322
323 album->card = album->page * 12 + album->slot + 1;
324 if (GAME.cardsSeen[album->card] != 0 && show != 0) {
325 initCardDrawer(&icon);
326 icon.setCard(album->card);
329 win->count->setNumber(win->count, 0, GAME.cards[album->card]);
330 win->count->setRightAlign(win->count, 1);
331 if (icon.getKind() != 0) {
332 win->levelLabel->setVisible(win->levelLabel, 0);
333 win->level->setVisible(win->level, 0);
335 win->stat1Label->setVisible(win->stat1Label, 0);
336 win->stat1->setVisible(win->stat1, 0);
337 win->stat2Label->setVisible(win->stat2Label, 0);
338 win->stat2->setVisible(win->stat2, 0);
339 } else {
341 win->level->setNumber(win->level, 0, icon.card->points);
342 win->level->setRightAlign(win->level, 1);
343 if (album->card == 0x45 || album->card == 0x70 || album->card == 0x9B ||
344 album->card == 0xC6 || album->card == 0xF1) {
346 win->stat1Label->setVisible(win->stat1Label, 0);
347 win->stat1->setVisible(win->stat1, 0);
348 win->stat2Label->setVisible(win->stat2Label, 0);
349 win->stat2->setVisible(win->stat2, 0);
350 } else {
351 win->text->setVisible(win->text, 0);
353 win->stat1->setNumber(win->stat1, 0, icon.card->ap);
354 win->stat1->setRightAlign(win->stat1, 1);
356 win->stat2->setNumber(win->stat2, 0, icon.card->hp);
357 win->stat2->setRightAlign(win->stat2, 1);
358 }
359 }
360 } else {
361 win->name->setVisible(win->name, 0);
362 win->countLabel->setVisible(win->countLabel, 0);
363 win->count->setVisible(win->count, 0);
364 win->levelLabel->setVisible(win->levelLabel, 0);
365 win->level->setVisible(win->level, 0);
366 win->text->setVisible(win->text, 0);
367 win->stat1Label->setVisible(win->stat1Label, 0);
368 win->stat1->setVisible(win->stat1, 0);
369 win->stat2Label->setVisible(win->stat2Label, 0);
370 win->stat2->setVisible(win->stat2, 0);
371 }
372}
373
374/* Draws the album: the scrolling background, its panels as they open, the blinking
375 previous and next page sprites and the cursor while it takes input, and the panels of
376 the card's details */
378 SpriteDrawer sprite;
379 CardDrawer icon;
380 s32 kind;
381 s32 frame;
382
383 initSpriteDrawer(&sprite);
384 sprite.setTexture(0x280, 0);
385 sprite.setLayerId(album->layer, album->depth);
386 if (album->frameToggle != 0) {
387 album->frame = ++album->frame < 0x60 ? album->frame : 0;
388 album->frameToggle = 0;
389 } else {
390 album->frameToggle = 1;
391 }
392 sprite.draw(FILE_CACHE.getEntry(STCRDABM_SPRITES), 8, album->frame, album->frame);
393 sprite.setLayerId(album->layer, album->depth - 2);
394 if (album->fade.level != 0) {
395 if (album->fade.level != ONE) {
396 sprite.setScale(album->fade.level, ONE, ONE);
397 sprite.setPivot(0, 0x20);
398 }
399 sprite.draw(FILE_CACHE.getEntry(STCRDABM_SPRITES), 9, 0, 0x15);
400 if (album->fade.level != ONE) {
401 sprite.setPivot(0x140, 0x20);
402 }
403 sprite.draw(FILE_CACHE.getEntry(STCRDABM_SPRITES), 0xF, 0xC8, 0x15);
404 if (album->fade.level != ONE) {
405 sprite.setScale(album->fade.level, album->fade.level, ONE);
406 sprite.setPivot(0x3A, 0xA5);
407 }
408 sprite.draw(FILE_CACHE.getEntry(STCRDABM_SPRITES), 0xE, 0x22, 0x9A);
409 }
410 if (album->active != 0) {
411 if (album->pageCount >= 2) {
412 if (GFX.funcs.getTime() - album->blinkTime > 0x10) {
413 album->blinkTime = GFX.funcs.getTime();
414 album->blink = 1 - album->blink;
415 }
416 if (album->blink != 0) {
417 if (album->page > 0) {
418 sprite.draw(FILE_CACHE.getEntry(STCRDABM_SPRITES), 0x1A, 0xE, 0x5A);
419 }
420 if (album->page < album->pageCount - 1) {
421 sprite.draw(FILE_CACHE.getEntry(STCRDABM_SPRITES), 0x1B, 0x121, 0x5A);
422 }
423 }
424 }
425 if (album->pageHasCards != 0) {
426 if (GFX.funcs.getTime() - album->cursorTime > 0x10) {
427 album->cursorTime = GFX.funcs.getTime();
428 if (++album->cursorFrame >= 6) {
429 album->cursorFrame = 0;
430 }
431 }
433 sprite.draw(FILE_CACHE.getEntry(STCRDABM_SPRITES), 7, album->slot % 6 * 42 + 0x24, album->slot / 6 * 54 + 0x32);
434 sprite.setClutRow(0);
435 }
436 }
437 if (album->infoFade.level != 0) {
438 initCardDrawer(&icon);
439 icon.setCard(album->card);
440 if (album->infoFade.level != ONE) {
441 sprite.setScale(album->infoFade.level, ONE, ONE);
442 sprite.setPivot(0x140, 0xA8);
443 }
444 kind = icon.getKind();
445 if (kind == 1) {
446 frame = 0x12;
447 } else if (kind == 2) {
448 frame = 0x13;
449 } else {
450 frame = icon.card->color + 0x13;
451 }
452 sprite.draw(FILE_CACHE.getEntry(STCRDABM_SPRITES), frame, 0x103, 0x9F);
453 sprite.draw(FILE_CACHE.getEntry(STCRDABM_SPRITES), 0xD, 0xFC, 0x9D);
454 if (album->infoFade.level != ONE) {
455 sprite.setPivot(0x140, 0xA8);
456 }
457 sprite.draw(FILE_CACHE.getEntry(STCRDABM_SPRITES), 0xA, 0x82, 0x9D);
458 if (album->infoFade.level != ONE) {
459 sprite.setPivot(0x140, 0xD0);
460 }
461 sprite.draw(FILE_CACHE.getEntry(STCRDABM_SPRITES), 0x10, 0x103, 0xC5);
462 sprite.draw(FILE_CACHE.getEntry(STCRDABM_SPRITES), 0xD, 0xFC, 0xC3);
463 if (album->infoFade.level != ONE) {
464 sprite.setPivot(0x140, 0xC6);
465 }
466 if (kind != 0) {
467 sprite.draw(FILE_CACHE.getEntry(STCRDABM_SPRITES), 0xB, 0x4A, 0xB3);
468 } else if (album->card == 0x45 || album->card == 0x70 || album->card == 0x9B || album->card == 0xC6 ||
469 album->card == 0xF1) {
470 sprite.draw(FILE_CACHE.getEntry(STCRDABM_SPRITES), 0xB, 0x4A, 0xB3);
471 } else {
472 sprite.draw(FILE_CACHE.getEntry(STCRDABM_SPRITES), 0xC, 0xC7, 0xB3);
473 }
474 }
475}
476
477/* Notes which slots of the current page hold a seen card, and whether any does */
479 s32 i;
480 s32 card;
481
482 album->pageHasCards = 0;
483 card = album->page * ALBUM_PAGE_CARDS;
484 for (i = 0; i < ALBUM_PAGE_CARDS; i++) {
485 card++;
486 if (card < CARD_COUNT && GAME.cardsSeen[card] != 0) {
487 album->slotHasCard[i] = 1;
488 album->pageHasCards = 1;
489 } else {
490 album->slotHasCard[i] = 0;
491 }
492 }
493}
494
495/* The page turned: shows the new page's cards, fading the card's details in
496 or out when the page gains or loses cards seen */
497static inline void STCRDABM_turnAlbumPage(CardAlbum *album, CardAlbumWindows *win) {
499 album->active = 0;
500 album->slot = 0;
502 STCRDABM_showPageInfo(album, win, 1);
503 if (album->infoFade.level == 0) {
504 if (album->pageHasCards != 0) {
505 album->substate = 10;
506 album->step = 1;
507 win->grid->setPage(win->grid, album->page * ALBUM_PAGE_CARDS | 1);
508 } else {
509 album->substate = 15;
510 }
511 } else {
512 win->grid->setPage(win->grid, album->page * ALBUM_PAGE_CARDS | 1);
513 if (album->pageHasCards == 0) {
514 album->substate = 10;
515 album->step = 0;
516 } else {
517 album->substate = 15;
518 }
519 }
520}
521
522/* The pad moves the cursor between the page's slots (two rows of six) to the
523 next card seen that way, and shows its details; it stays put when there is none */
524static inline void STCRDABM_moveAlbumCursor(CardAlbum *album, CardAlbumWindows *win) {
525 s32 slot;
526 s32 i;
527
528 slot = album->slot;
529 if (PAD_PRESSED(PAD_UP)) {
530 if (album->slot >= 6) {
531 album->slot -= 6;
532 }
533 } else if (PAD_PRESSED(PAD_DOWN)) {
534 if (album->slot < 6) {
535 album->slot += 6;
536 }
537 }
539 if (--album->slot < 0) {
540 album->slot = 0;
541 }
543 if (++album->slot >= ALBUM_PAGE_CARDS) {
544 album->slot = ALBUM_PAGE_CARDS - 1;
545 }
546 }
547 if (album->page * ALBUM_PAGE_CARDS + album->slot >= CARD_COUNT - 1) {
548 album->slot = CARD_COUNT - 2 - album->page * ALBUM_PAGE_CARDS;
549 }
550 if (slot != album->slot) {
551 i = album->slot;
552 album->slot = -1;
553 if (i < slot) {
554 for (; i >= 0; i--) {
555 if (album->slotHasCard[i] != 0) {
556 album->slot = i;
557 break;
558 }
559 }
560 } else if (slot < i) {
561 for (; i < ALBUM_PAGE_CARDS; i++) {
562 if (album->slotHasCard[i] != 0) {
563 album->slot = i;
564 break;
565 }
566 }
567 }
568 if (album->slot == -1) {
569 album->slot = slot;
570 } else {
571 STCRDABM_showCardInfo(album, win, 1);
573 }
574 }
575}
576
577/* The album open: L1/R1 turn the page, the pad moves the cursor between the
578 page's cards seen; triangle fades the screen out to leave */
579static inline void STCRDABM_browseAlbum(CardAlbum *album, CardAlbumWindows *win) {
580 s32 prev;
581
582 prev = album->page;
584 if (--album->page < 0) {
585 album->page = 0;
586 }
587 } else if ((!PAD_HELD(PAD_L1) && PAD_PRESSED(PAD_R1)) || (!PAD_HELD(PAD_L1) && PAD_REPEATED(PAD_R1))) {
588 if (++album->page > album->pageCount - 1) {
589 album->page = album->pageCount - 1;
590 }
591 }
592 if (prev != album->page) {
593 STCRDABM_turnAlbumPage(album, win);
594 } else {
595 STCRDABM_moveAlbumCursor(album, win);
596 }
599 album->active = 0;
600 album->substate = 50;
602 win->fader->start(win->fader, 0, 10);
603 }
604}
605
606/* The album's steps: opens it, then turns pages with L1 and R1, moves the cursor
607 between the seen cards and shows the selected one's details; Triangle fades the
608 screen out to leave */
610 switch (album->substate) {
611 case 0:
612 default:
613 STCRDABM_funcs.startFade(&album->fade, 1);
615 win->grid = STCRDABM_createGrid(album);
616 album->substate++;
617 break;
618 case 1:
619 if (STCRDABM_funcs.updateFade(&album->fade) != 0) {
620 STCRDABM_showPageInfo(album, win, 1);
621 if (album->pageHasCards != 0) {
623 }
624 album->substate = 11;
625 }
626 break;
627 case 3:
628 album->active = 1;
629 album->substate++;
630 break;
631 case 4:
632 STCRDABM_browseAlbum(album, win);
633 break;
634 case 10:
635 if (album->step == 0) {
636 STCRDABM_showCardInfo(album, win, 0);
637 }
638 STCRDABM_funcs.startFade(&album->infoFade, album->step);
639 album->nextSubstate(album);
640 break;
641 case 11:
642 if (STCRDABM_funcs.updateFade(&album->infoFade) != 0) {
643 album->substate = 15;
644 }
645 break;
646 case 15:
647 if (win->grid->state == TASK_RUN) {
648 album->active = win->grid->state;
649 STCRDABM_showPageInfo(album, win, 1);
650 if (album->infoFade.level != 0) {
651 while (1) {
652 if (album->slotHasCard[album->slot] != 0) {
653 break;
654 }
655 album->slot++;
656 }
657 STCRDABM_showCardInfo(album, win, 1);
658 }
659 album->substate = 3;
660 }
661 break;
662 case 50:
663 if (win->fader->state == TASK_DONE) {
664 album->state = TASK_KILL;
665 }
666 break;
667 case 51:
668 if (STCRDABM_funcs.updateFade(&album->infoFade) != 0) {
669 STCRDABM_showPageInfo(album, win, 0);
670 STCRDABM_funcs.startFade(&album->fade, 0);
671 album->substate++;
672 }
673 break;
674 case 52:
675 if (STCRDABM_funcs.updateFade(&album->fade) != 0) {
676 album->substate++;
677 }
678 break;
679 case 53:
680 if (win->grid == NULL) {
681 album->setState(album, TASK_KILL);
682 }
683 break;
684 }
685}
686
687/* The album's task: loads the files and creates its windows, then runs and draws it;
688 once the screen has faded out, goes back to the previous mode */
690 switch (album->state) {
691 case TASK_INIT:
692 default:
693 switch (album->substate) {
694 case 0:
695 default:
697 album->substate++;
698 break;
699 case 1:
700 if (STCRDABM_funcs.filesLoading() == 0) {
701 STCRDABM_createWindows(album, win);
702 album->fade.duration = 8;
703 album->infoFade.duration = 8;
704 album->pageCount = 27;
705 album->card = 1;
706 album->nextState(album);
707 }
708 break;
709 }
710 break;
711 case TASK_RUN:
712 STCRDABM_runAlbum(album, win);
713 STCRDABM_drawAlbum(album);
714 break;
715 case TASK_DONE:
716 break;
717 case TASK_KILL:
719 break;
720 }
721}
722
723/* Creates the album (task), on the top layer */
726
727 album->layer = SCREEN_LAYER;
728 album->depth = 7;
729 return album;
730}
731
732/* Loads the album's images and requests the card data and the card names, effects and
733 album strings */
749
750/* Whether the card data or the strings are still loading */
753 return 1;
754 }
756 return 1;
757 }
759 return 1;
760 }
762 return 1;
763 }
765 return 1;
766 }
768 return 1;
769 }
771 return 1;
772 }
774}
775
s32 STCRDABM_pageHasCards(CardAlbumGrid *grid)
1 when the grid's page holds a seen card (or runs past the last card)
Definition album.c:155
static void STCRDABM_browseAlbum(CardAlbum *album, CardAlbumWindows *win)
The album open: L1/R1 turn the page, the pad moves the cursor between the page's cards seen; triangle...
Definition album.c:579
s32 STCRDABM_cursorBlink[6]
The cursor's CLUT row on each frame of its blink.
Definition album.c:4
void STCRDABM_setPage(CardAlbumGrid *grid, s32 first)
Turns the grid to the page whose first card is first (grid->setPage)
Definition album.c:39
void STCRDABM_updateGrid(CardAlbumGrid *grid)
The card grid's task: draws the page's cards; on a page turn, turns its 12 slots one every 2 frames o...
Definition album.c:173
s32 STCRDABM_filesLoading(void)
Whether the card data or the strings are still loading.
Definition album.c:751
void STCRDABM_drawAlbum(CardAlbum *album)
Draws the album: the scrolling background, its panels as they open, the blinking previous and next pa...
Definition album.c:377
void STCRDABM_drawTurningSlots(CardAlbumGrid *grid)
Draws the slots turned so far over the cards, flashing the ones with a seen card.
Definition album.c:131
void STCRDABM_findPageCards(CardAlbum *album)
Notes which slots of the current page hold a seen card, and whether any does.
Definition album.c:478
void STCRDABM_showPageInfo(CardAlbum *album, CardAlbumWindows *win, s32 show)
Shows the title, help and page number and, while the album takes input, the previous and next page hi...
Definition album.c:282
CardAlbum * STCRDABM_createAlbum(void)
Creates the album (task), on the top layer.
Definition album.c:724
void STCRDABM_createWindows(CardAlbum *album, CardAlbumWindows *win)
Creates the album's text windows (the page's and the selected card's), in front of the album.
Definition album.c:254
CardAlbumFuncs STCRDABM_funcs
Definition album.c:6
void STCRDABM_loadFiles(void)
Loads the album's images and requests the card data and the card names, effects and album strings.
Definition album.c:734
static void STCRDABM_moveAlbumCursor(CardAlbum *album, CardAlbumWindows *win)
The pad moves the cursor between the page's slots (two rows of six) to the next card seen that way,...
Definition album.c:524
void STCRDABM_drawCards(CardAlbumGrid *grid, s32 previous)
Draws the page's cards, or the page being turned when previous != 0: a seen card's image,...
Definition album.c:52
void STCRDABM_updateAlbum(CardAlbum *album, CardAlbumWindows *win)
The album's task: loads the files and creates its windows, then runs and draws it; once the screen ha...
Definition album.c:689
CardAlbumGrid * STCRDABM_createGrid(CardAlbum *album)
Creates the album's card grid (task), on the top layer.
Definition album.c:233
void STCRDABM_runAlbum(CardAlbum *album, CardAlbumWindows *win)
The album's steps: opens it, then turns pages with L1 and R1, moves the cursor between the seen cards...
Definition album.c:609
static void STCRDABM_turnAlbumPage(CardAlbum *album, CardAlbumWindows *win)
The page turned: shows the new page's cards, fading the card's details in or out when the page gains ...
Definition album.c:497
void STCRDABM_showCardInfo(CardAlbum *album, CardAlbumWindows *win, s32 show)
Shows the card under the cursor (album->card = page * 12 + slot + 1) once the player has seen it: its...
Definition album.c:320
void STCRDABM_loadIcons(CardAlbumGrid *grid)
Loads the images of the grid's page of cards, from grid->first, into VRAM's 6x2 grid of card images.
Definition album.c:19
STCRDABM.PRO: the card album (scene 0x1200).
s32 STCRDABM_updateLerp(MenuLerp *lerp)
void STCRDABM_hideCards(CardAlbumGrid *grid)
#define CARD_COUNT
Definition album.h:15
s32 STCRDABM_updateFade(PanelAnim *fade)
void STCRDABM_updateHiding(CardAlbumGrid *grid)
#define STCRDABM_IMAGES
TIM archive.
Definition album.h:29
void STCRDABM_startFade(PanelAnim *fade, s32 fadeIn)
#define ALBUM_PAGE_CARDS
Definition album.h:16
#define STCRDABM_FILE_DATA
Definition album.h:26
void STCRDABM_startLerp(MenuLerp *lerp, s32 from, s32 to, s32 frames)
ScreenFade * STCRDABM_createFader(void)
#define STCRDABM_SPRITES
sprite bank
Definition album.h:28
void initCardDrawer(CardDrawer *obj)
Clears a card drawer, gives it its methods and binds it.
#define NULL
Definition common.h:17
signed int s32
Definition common.h:11
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
GameState GAME
The save data, the game mode and the methods.
Definition state.c:64
#define TASK_RUN
Definition task.h:35
#define TASK_KILL
Definition task.h:37
#define TASK_INIT
Tasks: every game object is a task, a heap block that starts with this header and is updated once per...
Definition task.h:34
#define TASK_DONE
Definition task.h:36
#define TEXT_CARD_NAMES
CARDNM.
Definition file.h:203
#define TEXT_CARD_EFFECTS
CARDST.
Definition file.h:204
#define TEXT_FILE(file)
Definition file.h:190
#define TEXT_CARD_ALBUM
CRDABM: STCRDABM's.
Definition file.h:205
FileCache FILE_CACHE
The file cache.
Definition file_cache.c:7
#define SCREEN_LAYER
The layer over the whole screen that most modes create first and draw their menus on (FIELDSTG and ST...
Definition gfx.h:45
#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_L1
Definition pad.h:28
#define PAD_LEFT
Definition pad.h:25
#define PAD_HELD(button)
Definition pad.h:142
#define PAD_R1
Definition pad.h:29
#define PAD_REPEATED(button)
Definition pad.h:141
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
void initSpriteDrawer(SpriteDrawer *obj)
Clears a sprite drawer to neutral (no scale, gray tint, follows the scroll), gives it its methods and...
s32(* updateFade)(PanelAnim *fade)
Definition album.h:95
void(* startFade)(PanelAnim *fade, s32 fadeIn)
Definition album.h:94
s32(* filesLoading)(void)
Definition album.h:93
void(* loadFiles)(void)
Definition album.h:92
Draws the cards of a page and animates the page turns.
Definition album.h:32
s32 counter
Definition album.h:33
void(* setPage)(struct CardAlbumGrid *grid, s32 first)
Definition album.h:44
void(* nextSubstate)(struct CardAlbumGrid *task)
Definition album.h:33
void(* nextState)(struct CardAlbumGrid *task)
Definition album.h:33
s32 prevFirst
the page being turned
Definition album.h:38
s32 substate
Definition album.h:33
s32 first
first card of the page
Definition album.h:37
s32 frame
Definition album.h:42
s32 state
Definition album.h:33
void(* setState)(struct CardAlbumGrid *task, s32 state)
Definition album.h:33
s32 layer
Definition album.h:35
struct CardAlbum * album
Definition album.h:34
s32 depth
Definition album.h:36
s32 turned
slots turned so far
Definition album.h:40
s32 shown
cards drawn
Definition album.h:39
void(* hide)(struct CardAlbumGrid *grid)
Definition album.h:45
TextWindow * stat2
card data [2]
Definition album.h:86
TextWindow * stat1
card data [1]
Definition album.h:84
TextWindow * text
Definition album.h:82
TextWindow * count
copies the player has
Definition album.h:81
TextWindow * help
Definition album.h:71
TextWindow * title
Definition album.h:70
TextWindow * pageCount
Definition album.h:74
TextWindow * level
card data [5]
Definition album.h:79
TextWindow * stat2Label
Definition album.h:85
TextWindow * countLabel
Definition album.h:80
TextWindow * stat1Label
Definition album.h:83
CardAlbumGrid * grid
Definition album.h:87
TextWindow * next
Definition album.h:76
TextWindow * prev
Definition album.h:75
ScreenFade * fader
Definition album.h:88
TextWindow * pageSlash
Definition album.h:73
TextWindow * name
Definition album.h:77
TextWindow * levelLabel
Definition album.h:78
TextWindow * page
Definition album.h:72
void(* setState)(struct CardAlbum *task, s32 state)
Definition album.h:49
s32 step
Definition album.h:49
s32 page
Definition album.h:54
s32 frame
Definition album.h:52
s32 state
Definition album.h:49
s32 blinkTime
Definition album.h:58
s32 active
Definition album.h:56
s32 card
Definition album.h:60
PanelAnim infoFade
the card's details
Definition album.h:66
s32 slotHasCard[12]
Definition album.h:62
PanelAnim fade
the album
Definition album.h:65
void * children
Definition album.h:49
s32 pageHasCards
Definition album.h:61
void(* nextState)(struct CardAlbum *task)
Definition album.h:49
s32 childCount
Definition album.h:49
s32 slot
Definition album.h:59
void(* nextSubstate)(struct CardAlbum *task)
Definition album.h:49
s32 cursorFrame
Definition album.h:63
s32 frameToggle
Definition album.h:53
s32 cursorTime
Definition album.h:64
s32 pageCount
Definition album.h:55
s32 blink
Definition album.h:57
s32 depth
Definition album.h:51
s32 substate
Definition album.h:49
s32 layer
Definition album.h:50
Draws the cards' images (CardImage), from files 0x7E7-0x7EB.
Definition gfx.h:193
void(* setCard)()
(id)
Definition gfx.h:205
void(* setClutPos)()
(x, y)
Definition gfx.h:210
void(* setCell)()
(x, y)
Definition gfx.h:211
void(* draw)()
(x, y)
Definition gfx.h:207
s32(* getKind)(void)
Definition gfx.h:214
void(* setImagePos)()
(x, y)
Definition gfx.h:209
void(* loadImage)()
Definition gfx.h:206
void(* setLayer)()
(id, depth)
Definition gfx.h:208
CardImage * card
Definition gfx.h:194
u8 hp
Definition gfx.h:175
u8 color
from 1
Definition gfx.h:173
u8 ap
Definition gfx.h:174
u8 points
what it adds to its colour
Definition gfx.h:179
void *(* load)(u32 file)
Definition file.h:92
s32(* isLoading)(s32 file)
Definition file.h:88
void(* request)(s32 file)
Definition file.h:90
void *(* getEntry)(u32 fileAndIndex)
Definition file.h:96
void(* requestMode)(s32 mode, s32 arg)
Definition game_state.h:21
s32(* getPrevMode)()
Definition game_state.h:23
s8 cards[0x13D]
counts, up to CARD_COPIES_MAX
Definition game_state.h:514
u8 cardsSeen[0x149]
Definition game_state.h:515
GameFuncs funcs
Definition game_state.h:582
s32(* getTime)(void)
Definition gfx.h:31
GfxFuncs funcs
Definition gfx.h:77
s32 level
Definition menu.h:21
s32 duration
Definition menu.h:19
void(* start)(struct ScreenFade *fade, s32 fadeIn, s32 frames)
TASK_DONE when done.
Definition gfx.h:368
s32 state
Definition gfx.h:362
short(* playSound)(s32 id)
returns the voice of a key-on
Definition sound.h:187
Draws sprites from a sprite sheet (such as file 0x277, the menu graphics): a sheet has a table of fra...
Definition gfx.h:223
void(* setPivot)()
(x, y)
Definition gfx.h:250
void(* setScale)()
(x, y, z), ONE = 1.0
Definition gfx.h:248
void(* setLayerId)()
(id, depth)
Definition gfx.h:244
void(* setClutRow)()
(row)
Definition gfx.h:247
void(* draw)()
(sheet, frame, x, y)
Definition gfx.h:246
void(* setTexture)()
(x, y)
Definition gfx.h:242
A text window (createTextWindow): up to six text buffers (0 is shown, 1-5 are "work" buffers that con...
Definition text.h:131
void(* setRightAlign)()
no prototype: callers would truncate u8 args
Definition text.h:178
void(* setNumber)()
Definition text.h:166
void(* setString)()
Definition text.h:165
void(* setVisible)(struct TextWindow *obj, u8 arg)
Definition text.h:177
Uploads TIM images to VRAM (initTimLoader); acts on TIM_LOADER.
Definition gfx.h:325
void(* setImagePos)()
(x, y)
Definition gfx.h:336
void(* loadArchive)()
(archive): each image 64 halfwords to the right
Definition gfx.h:338
void * createTask(void(*update)(), s32 size, s32 childrenSize)
createTaskWithId for a task nothing needs to find
Definition task.c:105
TextWindow * createTextWindow(s16 layerId, s16 style, s16 x, s16 y)
A text window on a layer, in a font style, at (x, y)
void initTimLoader(TimLoader *obj)
Clears a TIM loader, gives it its methods and binds it.
Definition tim_loader.c:119