Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
deck_cards.c
Go to the documentation of this file.
1/* The editor's grid of the deck's cards, shown one by one as their images load */
2
4
5/* Draws the deck's cards shown so far on the grid, 9 a row: each one's frame in
6 its color and its image */
8 SpriteDrawer sprite;
9 CardDrawer card;
10 s32 i;
11 s32 col;
12 s32 row;
13 s32 x;
14 s32 y;
15 void *sheet;
16
17 initSpriteDrawer(&sprite);
18 sprite.setTexture(0x280, 0);
19 sprite.setLayerId(task->layer, task->depth);
20 initCardDrawer(&card);
21 card.setImagePos(0x140, 0x100);
22 card.setClutPos(0x300, 0x100);
23 card.setLayer(task->layer, task->depth);
24 for (i = 0; i < task->count; i++) {
25 card.setCard(GAME.decks[task->editor->deck].cards[i]);
26 col = i % 9;
27 row = i / 9;
29 x = col * 32 + 0x10;
30 y = row * 32 + 0x3A;
31 sprite.draw(sheet, card.card->color + 0x52, x, y);
32 card.setCell(col, row);
33 card.draw(x, y);
34 }
35}
36
37/* Shows one more of the deck's cards, loading its image into its cell of VRAM;
38 TASK_DONE once all 40 are shown */
40 CardDrawer card;
41 s32 i;
42
43 if (++task->count > 40) {
44 task->state = TASK_DONE;
45 task->count = 40;
46 return;
47 }
48 initCardDrawer(&card);
49 card.setCard(GAME.decks[task->editor->deck].cards[task->count - 1]);
50 card.setImagePos(0x140, 0x100);
51 card.setClutPos(0x300, 0x100);
52 i = task->count - 1;
53 card.setCell(i % 9, i / 9);
54 card.loadImage();
55}
56
57/* The deck cards' task: shows one more card each frame, then keeps drawing all
58 40 until the editor kills it */
60 switch (task->state) {
61 case TASK_INIT:
62 default:
63 task->nextState(task);
64 task->count = 0;
65 break;
66 case TASK_RUN:
68 /* fallthrough */
69 case TASK_DONE:
71 break;
72 case TASK_KILL:
73 break;
74 }
75}
76
77/* Creates the deck's cards (task) on the editor's grid */
80
81 task->layer = SCREEN_LAYER;
82 task->depth = 5;
83 task->editor = editor;
84 return task;
85}
void initCardDrawer(CardDrawer *obj)
Clears a card drawer, gives it its methods and binds it.
signed int s32
Definition common.h:11
DeckCards * STCRDDEK_createDeckCards(DeckEditor *editor)
Creates the deck's cards (task) on the editor's grid.
Definition deck_cards.c:78
void STCRDDEK_updateDeckCards(DeckCards *task)
The deck cards' task: shows one more card each frame, then keeps drawing all 40 until the editor kill...
Definition deck_cards.c:59
void STCRDDEK_drawDeckCards(DeckCards *task)
Draws the deck's cards shown so far on the grid, 9 a row: each one's frame in its color and its image...
Definition deck_cards.c:7
void STCRDDEK_loadNextCard(DeckCards *task)
Shows one more of the deck's cards, loading its image into its cell of VRAM; TASK_DONE once all 40 ar...
Definition deck_cards.c:39
STCRDDEK: the deck editor, where the player builds the three decks from the cards they own and rename...
#define STCRDDEK_SPRITES
sprite bank
Definition deck_editor.h:34
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
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
void initSpriteDrawer(SpriteDrawer *obj)
Clears a sprite drawer to neutral (no scale, gray tint, follows the scroll), gives it its methods and...
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
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 color
from 1
Definition gfx.h:173
Draws the deck's cards, appearing one per frame.
void(* nextState)(struct DeckCards *task)
s32 count
cards shown so far
DeckEditor * editor
The deck being edited.
Definition deck_editor.h:49
s32 deck
GAME.decks[].
Definition deck_editor.h:54
s16 cards[40]
Definition game_state.h:275
void *(* getEntry)(u32 fileAndIndex)
Definition file.h:96
Deck decks[3]
Definition game_state.h:516
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(* setLayerId)()
(id, depth)
Definition gfx.h:244
void(* draw)()
(sheet, frame, x, y)
Definition gfx.h:246
void(* setTexture)()
(x, y)
Definition gfx.h:242
void * createTask(void(*update)(), s32 size, s32 childrenSize)
createTaskWithId for a task nothing needs to find
Definition task.c:105