Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
battle.h
Go to the documentation of this file.
1#ifndef CARDGAME_BATTLE_H
2#define CARDGAME_BATTLE_H
3
4/* CARDGAME's card battle: the slots, piles, plays, effects and steps, the
5 opponent and the rounds (effect_script.c, battle.c, battle_steps.c, round.c,
6 play_checks.c, pile_effects.c, slot_effects.c and computer.c). */
7
10
11/* The opponents of the card battles (CardOpponent) */
12#if VERSION_US || VERSION_JP
13#define FILE_CARDGAME_OPPONENTS 0x795
14#elif VERSION_EU
15#define FILE_CARDGAME_OPPONENTS 0x7A4
16#endif
17
18/* A card a player has out (CARDGAME_setSlot) */
19typedef struct CardSlot {
20 /* 0x0 */ s16 card; /* the index in the battle's card list */
21 /* 0x2 */ s16 apBonus; /* what the effects added to its ap */
22 /* 0x4 */ s16 hpBonus; /* and to its hp */
23 /* 0x6 */ s16 ap; /* its attack points, 0 to 99 */
24 /* 0x8 */ s16 hp; /* its hit points, 0 to 99: at 0 it is lost */
25 /* 0xA */ u8 side;
26 /* 0xB */ u8 owner;
27 /* 0xC */ u8 order; /* CardBattle.slotCount when it was added */
28} CardSlot;
29
30/* A slot's card, sorted by id (CARDGAME_findCardSet) */
31typedef struct CardSortEntry {
32 /* 0x0 */ s16 slot;
33 /* 0x2 */ s16 card; /* its id, minus one */
35
36/* One of the two players of a card battle */
37typedef struct CardPlayer {
38 /* 0x00 */ u8 slotCount;
39 /* 0x02 */ CardSlot slots[8];
41
42/* A card played in a round (CardRecord.plays), whose effect then runs */
43typedef struct CardPlay {
44 /* 0x0 */ s16 card; /* the index in the battle's card list */
45 /* 0x2 */ s16 mark;
46 /* 0x4 */ u8 side; /* who played it */
47 /* 0x5 */ u8 targetKind; /* its effect's (CardEffect.target) */
48 /* 0x6 */ u8 target; /* the slot's order, or the card, it was played on */
49} CardPlay;
50
51/* A card's effect (CARDGAME_cardEffects), read through
52 CARDGAME_getEffectField */
53typedef struct CardEffect {
54 /* 0x0 */ u8 condition; /* for the computer (CARDGAME_checkComputerCondition) */
55 /* 0x1 */ u8 playCondition; /* CARDGAME_checkPlayCondition's */
56 /* 0x2 */ u8 message; /* what it shows when the play condition holds */
57 /* 0x3 */ u8 target; /* the kind of target of its play (CardPlay.targetKind) */
58 /* 0x4 */ u8 script[40]; /* the effect steps it runs one by one, up to a 0 */
60
61/* How the computer plays a card of its deck (CardBattle.opponentPlans):
62 kind first, then priority (CARDGAME_sortOpponentHand) */
63typedef struct CardPlan {
64 /* 0x0 */ u8 kind; /* 1-7 (CardDeckCard.kind) */
65 /* 0x1 */ u8 flagged; /* bit 15 of the card in the opponent's deck */
66 /* 0x2 */ s16 priority; /* by kind, then by place in the deck */
67} CardPlan;
68
69/* What CARDGAME_runBattle runs this frame (CardBattle.run) */
70enum CardRun {
71 CARD_RUN_PHASE, /* the battle's phase (CARDGAME_runPhase) */
72 CARD_RUN_STEP, /* an effect step (CARDGAME_runEffectStep) */
73 CARD_RUN_RESOLVE, /* the card just played (CARDGAME_resolveCard) */
74 CARD_RUN_MENU /* the battle menu (CARDGAME_runBattleMenu) */
75};
76
77/* The phases of a card battle (CardBattle.phase, CARDGAME_runPhase) */
79 CARD_PHASE_NONE, /* for nextPhase: no switch */
82 CARD_PHASE_FIRST_PICK, /* who starts */
83 CARD_PHASE_DEAL, /* six cards to each side */
84 CARD_PHASE_PLAYS_BEFORE, /* plays before the cards are put out: kind 2 cards only */
86 CARD_PHASE_PLAYS_AFTER, /* plays after: any kind but 0 */
89 CARD_PHASE_MESSAGE /* the message of the phase that ended (CARDGAME_battleMessages) */
90};
91
92/* What a phase does once it is over (CARDGAME_battleMessages): the step
93 that shows its message, and the phase after it */
94typedef struct CardBattleMessage {
95 /* 0x0 */ u16 step; /* for CardStep.next */
96 /* 0x2 */ u16 phase; /* for CardBattle.nextPhase */
98
99/* Where a card of the opponent's deck is drawn (CardBattle.opponentDraws):
100 the computer draws the cards of group round * 2 + 2 (CardBattle.round),
101 and holds the cards of group 7 back */
102typedef struct CardDraw {
103 /* 0x0 */ u8 order; /* its place in the deck */
104 /* 0x1 */ u8 group;
105} CardDraw;
106
107/* A player's cards in a card battle (CardSide.pile) */
108typedef struct CardPile {
109 /* 0x00 */ s16 apTotal; /* the sum of its slot cards' ap, which comes off the other side's hpTotal */
110 /* 0x02 */ s16 hpTotal; /* the sum of its slot cards' hp: the higher one wins the round */
111 /* 0x04 */ s16 deckTop; /* the index of the deck's top card */
112 /* 0x06 */ s16 discardCount;
113 /* 0x08 */ s16 deckCount; /* the cards left in the deck */
114 /* 0x0A */ s16 handCount;
115 /* 0x0C */ u8 points[5]; /* one per card colour */
116 /* 0x11 */ u8 side; /* its panel */
117 /* 0x12 */ u8 wins; /* rounds won: two win the battle */
118 /* 0x14 */ s16 deck[40]; /* deckTop on are left */
119 /* 0x64 */ s16 hand[10]; /* handCount in use */
120 /* 0x78 */ s16 discards[10]; /* the cards played and lost from the slots, discardCount in use */
121} CardPile;
122
123/* The turns of a round, in which the sides play cards one after the other
124 (CARDGAME_playRounds), and the battle menu (CardBattle.record) */
125typedef struct CardRecord {
126 /* 0x00 */ u8 menuState; /* CARDGAME_runBattleMenu's state */
127 /* 0x01 */ u8 menuCursor; /* CARDGAME_runBattleMenu's cursor, 0-4 */
128 /* 0x02 */ u8 pad2[0xA]; /* never read or written */
129 /* 0x0C */ u8 turnState; /* CARDGAME_playRounds' state */
130 /* 0x0D */ s8 playCount; /* the plays in use */
131 /* 0x0E */ u8 turns; /* the turns of plays this round */
132 /* 0x0F */ u8 passes; /* the turns with no card played: two end the plays */
133 /* 0x10 */ u8 starter; /* the side that starts the round */
134 /* 0x11 */ u8 turnSide; /* the side whose turn it is */
135 /* 0x12 */ s8 answer; /* a step's result: -1 while waiting, then 0 or 1 */
136 /* 0x14 */ s32 waitTime;
137 /* 0x18 */ CardPlay plays[3]; /* the cards played this turn, up to three */
138 /* 0x30 */ u8 pad30[4]; /* never read or written: CardBattle.sides follows 0x34 bytes after the record */
139} CardRecord;
140
141/* The effect step that runs (CARDGAME_runEffectStep) and its values, which
142 CARDGAME_runBattleMenu keeps a copy of while the menu is open */
143typedef struct CardStep {
144 /* 0x00 */ u8 id; /* the step running */
145 /* 0x01 */ u8 next; /* the step to start: CARDGAME_runEffectStep sets it up first */
146 /* 0x02 */ u8 state; /* the step's own state */
147 /* 0x03 */ u8 nextState; /* the state to set up first, if not 0 */
148 /* 0x04 */ s32 time; /* a frame count, or the step's own sub-state */
149 /* 0x08 */ s32 vars[5]; /* values each step uses its own way */
150 /* 0x1C */ s32 cursor; /* the card or slot highlighted */
151 /* 0x20 */ s32 choice; /* the card, slot or answer chosen; -1 for none */
152 /* 0x24 */ u8 count; /* the cards picked, or to draw */
153 /* 0x25 */ u8 flags; /* the step's own: the rows to pick from, the deck run out... */
154 /* 0x26 */ s8 eligible[0x29]; /* the cards or slots that can be picked */
155 /* 0x4F */ s8 marked[40]; /* the cards or slots picked */
156} CardStep;
157
158/* Each player's side of a card battle (CardBattle.sides) */
159typedef struct CardSide {
160 /* 0x00 */ CardPile pile;
161 /* 0x8C */ u8 pad[0x3C]; /* never read or written: CardBattle.sides[2] spans 0x190 bytes */
162} CardSide;
163
164/* The animations of the cards on the table (CardBattle.anim): the slots,
165 the plays or a pile laid out as sprites that scale in, then out */
187
188/* CardAnim.dimAll */
189#define CARD_ANIM_UNDIM_ALL 1
190#define CARD_ANIM_DIM_ALL 2
191
192/* The running animation of the cards on the table (CARDGAME_updateCardAnims) */
193typedef struct CardAnim {
194 /* 0x00 */ u8 current; /* a CardAnimId */
195 /* 0x01 */ u8 next; /* the one to start */
196 /* 0x02 */ u8 pad; /* never read or written */
197 /* 0x03 */ u8 hide; /* the one that hides what the last one showed */
198 /* 0x04 */ u8 faceDown; /* the next pile or slots are laid out face down */
199 /* 0x05 */ u8 dimAll; /* sets dimmed of the first 15 sprites once */
200 /* 0x06 */ u8 dimmed[40]; /* by sprite */
201 /* 0x30 */ s32 time;
202 /* 0x34 */ s32 shown; /* the sprites scaled so far */
203 /* 0x38 */ s32 stagger; /* one more sprite scales every 4 frames */
204 /* 0x3C */ s32 count; /* the pile's cards */
205 /* 0x40 */ s32 duration;
206} CardAnim;
207
208/* A card of an opponent's deck (CardOpponent.cards) */
209typedef struct CardDeckCard {
210 /* 0x0 */ s16 card; /* the id plus one in the low 12 bits; bit 15 a flag */
211 /* 0x2 */ u8 group; /* when the computer draws it (CardDraw.group) */
212 /* 0x3 */ u8 kind; /* how it plays it (CardPlan.kind) */
214
215/* An opponent of the card battle: an entry of file FILE_CARDGAME_OPPONENTS, picked by
216 CardBattle.arg (CARDGAME_loadOpponent) */
217typedef struct CardOpponent {
218 /* 0x00 */ CardDeckCard cards[40];
219 /* 0xA0 */ s16 counterCards[20]; /* from 1, up to a 0: CardBattle.counterCards before the usual ones */
220 /* 0xC8 */ u8 level; /* shown after "LV" (card text 0x3E), 4-92 */
221 /* 0xCC */ s32 prize; /* its index in CARDGAME_prizeItems */
223
224/* The card battle (CARDGAME_createBattle). Its seven task items: the battle
225 screen is the last one (CardBattleItems). */
228 /* 0x050 */ s16 cards[250]; /* card ids, minus one (CARDGAME_loadCardImages) */
229 /* 0x244 */ u8 cardCount; /* in cards */
230 /* 0x245 */ u8 pad245[3]; /* never read or written */
231 /* 0x248 */ s16 opponentDeck[40]; /* the opponent's deck */
232 /* 0x298 */ s16 playerDeck[40]; /* the player's deck */
233 /* 0x2E8 */ u8 arg; /* the mode argument: the opponent, from 1 */
234 /* 0x2E9 */ u8 opponentLevel; /* CardOpponent.level */
235 /* 0x2EA */ s16 deckChoice; /* the player's deck (GAME.decks) */
236 /* 0x2EC */ s32 prize; /* the item the player wins (GAME.items) */
237 /* 0x2F0 */ CardOpponent *opponents; /* file FILE_CARDGAME_OPPONENTS */
238 /* 0x2F4 */ u8 run; /* what runs this frame (CARD_RUN_*) */
239 /* 0x2F5 */ u8 firstStarter; /* the side that starts the first round */
240 /* 0x2F6 */ u8 prevPhase;
241 /* 0x2F7 */ u8 nextPhase; /* the phase to switch to, if not 0 */
242 /* 0x2F8 */ u8 phase; /* a CARD_PHASE_* */
243 /* 0x2F9 */ u8 phaseStep; /* the phase's own state */
244 /* 0x2FC */ s32 phaseTime; /* a frame count, or the phase's own counter */
245 /* 0x300 */ u8 round; /* from 0 */
246 /* 0x301 */ u8 roundWinner; /* the side that won the round */
247 /* 0x302 */ u8 playerLost; /* 0 once the player has won the battle */
248 /* 0x303 */ u8 result; /* 2 once the battle is over */
249 /* 0x304 */ u8 keptCard; /* the card CARDGAME_keepLastCard kept, plus one */
250 /* 0x305 */ u8 keptCount; /* and how many times */
251 /* 0x306 */ u8 fade; /* the fade to start (CARDGAME_fadeColors), plus one */
252 /* 0x307 */ u8 pad307; /* never read or written */
253 /* 0x308 */ u8 slotCount; /* the slots added so far */
254 /* 0x309 */ u8 pad309; /* never read or written */
255 /* 0x30A */ CardDraw opponentDraws[40]; /* by the opponent's deck card */
256 /* 0x35A */ u8 pad35A[2]; /* never read or written */
257 /* 0x35C */ CardPlan opponentPlans[40]; /* one per card of side 1 (40-79) */
258 /* 0x3FC */ u8 pad3FC[4]; /* never read or written */
259 /* 0x400 */ u8 counterCards[0x1B]; /* the cards the computer answers with a kind 4 card, up to an 0xFF */
260 /* 0x41B */ u8 drawEnd; /* the first card of the opponent's deck above the round's group */
261 /* 0x41C */ u8 reserveStart; /* the first card of the opponent's deck held back (group 7) */
262 /* 0x420 */ CardStep effectStep;
263 /* 0x498 */ CardAnim anim;
264 /* 0x4DC */ u8 resolveState; /* CARDGAME_resolveCard's */
265 /* 0x4DD */ u8 prevDiscarded; /* the card before the last one played went off too */
266 /* 0x4DE */ u8 playsToResolve; /* record.playCount, as CARDGAME_resolveCard starts; nothing reads it */
267 /* 0x4E0 */ s16 effectPos; /* the step of the card's effect script to run next */
268 /* 0x4E2 */ s16 loopCount; /* the effect script's loop: the runs left */
269 /* 0x4E4 */ s16 loopStart; /* and where it starts again */
270 /* 0x4E8 */ s32 subState; /* the state of a phase's helpers (CARDGAME_showPlayedCard...) */
271 /* 0x4EC */ s32 subTime; /* and their frame count */
272 /* 0x4F0 */ CardStep savedStep; /* the step, while the battle menu is open */
273 /* 0x568 */ CardRecord record;
274 /* 0x59C */ CardSide sides[2];
275 /* 0x72C */ CardPlayer players[2];
276 /* 0x810 */ void (*shufflePile)(struct CardBattle *battle, s32 base, s32 n);
277 /* 0x814 */ void (*sortCards)(struct CardBattle *battle, s16 *list, s32 range, s32 flags);
278 /* 0x818 */ void (*putOutCards)(struct CardBattle *battle, s32 side);
279 /* 0x81C */ void (*addCard)(struct CardBattle *battle, s32 side, s32 card);
280 /* 0x820 */ s32 (*scoreHand)(struct CardBattle *battle, s32 side, s32 mask);
281};
282
283/* The card battle's task items */
284typedef struct CardBattleItems {
285 /* 0x00 */ CardPreloader *preloader; /* the card game's files' (CARDGAME_startPreloader) */
286 /* 0x04 */ CardFader *fader;
287 /* 0x08 */ CardMarker *marker; /* the deck choice's */
289 /* 0x18 */ CardScreen *screen;
291
292/* The steps CARDGAME_stepPlayCard has before its card goes off: the European and
293 Japanese versions show the card's information first, and wait for a button */
294#if VERSION_US
295#define CARD_INFO_STEPS 0
296#elif VERSION_EU || VERSION_JP
297#define CARD_INFO_STEPS 2
298#endif
299
300/* The functions and data the overlay's files share */
301extern CardEffect CARDGAME_cardEffects[]; /* the effects of the first 60 cards, by card id minus one: conditions, target and messages */
304extern s16 CARDGAME_animPiles[7][2]; /* the side and pile CARDGAME_updateCardAnims passes to CARDGAME_layOutPile */
305/* the deck used when the chosen one is empty: its first 40 cards, as card
306 ids - 1 (CardBattle.playerDeck); nothing reads the 40 after them */
308extern CardOffset CARDGAME_deckWindowPos[3]; /* the three deck windows */
309extern u8 CARDGAME_turnStates[]; /* the next record.turnState state, by step and side */
310extern CardBattleMessage CARDGAME_battleMessages[]; /* the step and nextPhase of CARDGAME_startBattleMessage, by prevPhase */
311#if PAL_VIDEO
312extern s32 CARDGAME_slotRowPositions[2][4]; /* sprite positions, by SHIFT_PAL_SCREEN */
313extern CardOffset CARDGAME_panelIconPositions[2][2][2]; /* CARDGAME_drawPanelIcon's icon and label positions, by SHIFT_PAL_SCREEN and side (EU) */
314#endif
315void CARDGAME_startColorChange(CardBattle *battle, CardScreen *screen, s32 amount, s32 interval);
316extern s16 CARDGAME_cardWindowPositions[2][2][2]; /* two positions, then the same moved for SHIFT_PAL_SCREEN */
317extern s16 CARDGAME_colorFlags[]; /* a flag bit per card colour */
318extern s32 CARDGAME_discardPositions[][2]; /* x, y per side */
319extern u8 CARDGAME_slotMoves[2][6][2]; /* per side, the slot moves (from, to) of CARDGAME_removeMarkedSlots */
320extern u8 CARDGAME_slotMoveCounts[]; /* per side, the entries of CARDGAME_slotMoves */
321extern u8 CARDGAME_markedCounts[2]; /* per side, the marked slots */
323s32 CARDGAME_canPlayCard(CardBattle *battle, u8 *points, s32 card);
324s32 CARDGAME_stepColorValue(CardBattle *battle, CardScreen *screen, s32 side, s32 color);
325s32 CARDGAME_stepShakeAway(CardBattle *battle, CardScreen *screen, s32 index);
326void CARDGAME_discardSlotCard(CardBattle *battle, CardScreen *screen, s32 side, s32 index);
327s32 CARDGAME_stepDiscardSlotCard(CardBattle *battle, CardScreen *screen, s32 side, s32 index);
328s32 CARDGAME_stepSendOff(CardBattle *battle, CardScreen *screen, s32 index);
329void CARDGAME_returnSlotCard(CardBattle *battle, CardScreen *screen, s32 side, s32 index);
330void CARDGAME_sortCards(CardBattle *battle, s16 *list, s32 range, s32 flags);
331void CARDGAME_shufflePile(CardBattle *battle, s32 base, s32 n);
332void CARDGAME_setCountingCardValues(CardBattle *battle, CardSlot *slot, s32 side, s32 pass);
333extern CardFadeColor CARDGAME_fadeColors[]; /* CARDGAME_startStepFade's fade colours and blends, by fade - 1 */
334extern s32 CARDGAME_recordCardPositions[][2]; /* where card 15 goes, by CardRecord.playCount */
335extern s16 CARDGAME_countingCards[]; /* five card ids, minus one */
336extern CardOffset CARDGAME_playedCardPos[2][2]; /* then the same moved for SHIFT_PAL_SCREEN */
338void CARDGAME_setSlot(CardBattle *battle, s32 side, s32 card, s32 index);
339void CARDGAME_addCard(CardBattle *battle, s32 side, s32 card);
340void CARDGAME_putOutCards(CardBattle *battle, s32 side);
342void CARDGAME_runEffectStep(CardBattle *battle, CardScreen *screen);
347s32 CARDGAME_scoreHand(CardBattle *battle, s32 side, s32 mask);
348s32 CARDGAME_unflagSlotsOver(CardBattle *battle, s32 side, s32 value, s32 keep);
350s32 CARDGAME_getEffectField(s32 index, u32 field, s32 offset);
351void CARDGAME_jumpIfLastSide(CardBattle *battle, CardScreen *screen, s32 value, s32 offset);
352void CARDGAME_jumpIfFewInHand(CardBattle *battle, s32 side, s32 value, s32 offset);
353void CARDGAME_jumpIfManyInHand(CardBattle *battle, s32 side, s32 value, s32 offset);
354void CARDGAME_jumpIfDeckLeft(CardBattle *battle, s32 side, s32 offset);
355void CARDGAME_jumpIfSlotFree(CardBattle *battle, s32 side, s32 offset);
357void CARDGAME_chooseNextDraw(CardBattle *battle, CardScreen *screen, s32 which);
358void CARDGAME_markSlotsOfOrder(CardBattle *battle, CardScreen *screen);
363s32 CARDGAME_addColorCount(CardBattle *battle, CardScreen *screen, s32 side, s32 card);
364s32 CARDGAME_stepReturnSlotCard(CardBattle *battle, CardScreen *screen, s32 side, s32 index);
365s32 CARDGAME_waitFor(CardBattle *battle, CardScreen *screen, s32 duration);
366void CARDGAME_beginStep(CardBattle *battle, CardScreen *screen);
367void CARDGAME_startHandCount(CardBattle *battle, CardScreen *screen, s32 side);
368void CARDGAME_startColorDrain(CardBattle *battle, CardScreen *screen);
369void CARDGAME_startCloseGauge(CardBattle *battle, CardScreen *screen);
371void CARDGAME_showPileCard(CardBattle *battle, CardScreen *screen, s32 side, s32 which);
372s32 CARDGAME_drawFromDeck(CardBattle *battle, CardScreen *screen, s32 side, s32 which);
373void CARDGAME_startDiscardCount(CardBattle *battle, CardScreen *screen, s32 side);
375void CARDGAME_startDraw(CardBattle *battle, CardScreen *screen, s32 count);
376s32 CARDGAME_markDrawnCards(CardBattle *battle, CardScreen *screen, s32 side);
377void CARDGAME_drawMarkedCards(CardBattle *battle, CardScreen *screen, s32 side);
378s32 CARDGAME_drawNewCards(CardBattle *battle, CardScreen *screen, s32 side);
379void CARDGAME_startSlotSweep(CardBattle *battle, CardScreen *screen);
380s32 CARDGAME_stepSlotSweep(CardBattle *battle, CardScreen *screen, s32 which);
381void CARDGAME_markRecordHits(CardBattle *battle, CardScreen *screen, s32 side, s32 index);
382void CARDGAME_putSlotCard(CardBattle *battle, CardScreen *screen, s32 side, s32 card);
383void CARDGAME_takeHandCard(CardBattle *battle, CardScreen *screen, s32 side);
384s32 CARDGAME_moveSlotCard(CardBattle *battle, CardScreen *screen, s32 side);
385void CARDGAME_copySlotCard(CardBattle *battle, CardScreen *screen, s32 side);
386s32 CARDGAME_flipSlotCard(CardBattle *battle, CardScreen *screen, s32 side);
387void CARDGAME_startPlayCard(CardBattle *battle, CardScreen *screen, s32 side);
389void CARDGAME_clearHands(CardBattle *battle, CardScreen *screen);
390void CARDGAME_dealHands(CardBattle *battle, CardScreen *screen);
392void CARDGAME_startAttack(CardBattle *battle, CardScreen *screen, s32 side);
393s32 CARDGAME_stepAttack(CardBattle *battle, CardScreen *screen, s32 side);
394void CARDGAME_startDiscardAllSlots(CardBattle *battle, CardScreen *screen, s32 side);
396s32 CARDGAME_interpolate(s32 to, s32 from, s32 duration, s32 time);
397void CARDGAME_startSwap(CardBattle *battle, CardScreen *screen);
398void CARDGAME_startTotals(CardBattle *battle, CardScreen *screen);
399void CARDGAME_startRoundEnd(CardBattle *battle, CardScreen *screen);
400void CARDGAME_startMessage(CardBattle *battle, CardScreen *screen, s32 text);
401void CARDGAME_startClosePanels(CardBattle *battle, CardScreen *screen, s32 force);
403void CARDGAME_startOpenPanels(CardBattle *battle, CardScreen *screen, s32 force);
406
407/* The steps CARDGAME_runEffectStep starts (CardBattle.effectStep.next) and runs (effectStep.id) */
408void CARDGAME_startSlotEffects(CardBattle *battle, CardScreen *screen, s32 which);
409void CARDGAME_moveMarkedSlots(CardBattle *battle, CardScreen *screen, s32 arg2, s32 arg3);
411void CARDGAME_markTargetSlots(CardBattle *battle, CardScreen *screen);
413s32 CARDGAME_markPileCardsByColor(CardBattle *battle, CardScreen *screen, s32 side, s32 kind, s32 flags);
414s32 CARDGAME_markSlotsByColor(CardBattle *battle, CardScreen *screen, s32 side, s32 flags);
415s32 CARDGAME_discardHand(CardBattle *battle, CardScreen *screen, s32 side);
418s32 CARDGAME_discardPickedCard(CardBattle *battle, CardScreen *screen, s32 side, s32 arg3);
419void CARDGAME_takeCardToHand(CardBattle *battle, CardScreen *screen, s32 side, s32 arg3);
421void CARDGAME_showSlotTotal(CardBattle *battle, CardScreen *screen, s32 side);
422s32 CARDGAME_stepSlotTotal(CardBattle *battle, CardScreen *screen, s32 side);
424s32 CARDGAME_stepRoundEnd(CardBattle *battle, CardScreen *screen, s32 side);
428extern s16 CARDGAME_prizeItems[]; /* the item an opponent gives for a win (CardBattle.prize), by its CardOpponent.prize */
432void CARDGAME_startPileCount(CardBattle *battle, CardBattleItems *items, s32 side, s32 which);
433void CARDGAME_layOutPile(CardBattle *battle, CardBattleItems *items, s32 side, s32 which);
446void CARDGAME_sumSlotValues(CardBattle *battle, s32 side);
447s32 CARDGAME_findCardSet(CardBattle *battle, s32 side, s32 index);
456void CARDGAME_keepLowestSlot(CardBattle *battle, s32 side);
460s32 CARDGAME_isSlotWithin(CardBattle *battle, s32 side, s32 index, s32 value);
466s32 CARDGAME_compareCards(CardBattle *battle, s32 id1, s32 id2, s32 flip);
469void CARDGAME_flagTargetSlots(CardBattle *battle, CardScreen *screen);
470
471#endif /* CARDGAME_BATTLE_H */
s32 CARDGAME_removeMarkedSlots(CardBattle *battle, CardScreen *screen)
Removes the slots marked in effectStep.marked: slides the cards after them left on screen,...
s32 CARDGAME_addColorCount(CardBattle *battle, CardScreen *screen, s32 side, s32 card)
Counts a card of the colour it has on a side's panel (at most 99); 1 if it has one.
Definition slot_effects.c:7
s32 CARDGAME_runPutOut(CardBattle *battle, CardBattleItems *items)
A battle step: each side puts out its flagged cards (putOutCards) between messages 0x9A,...
Definition battle.c:1475
s32 CARDGAME_waitMessage(CardBattle *battle, CardScreen *screen)
Waits for the message window to open, for cross or triangle, then for the window to close; 1 once it ...
void CARDGAME_startAttack(CardBattle *battle, CardScreen *screen, s32 side)
Starts CARDGAME_stepAttack: side's apTotal comes off the other side's hpTotal (down to 0),...
Definition round.c:781
s32 CARDGAME_getCardLimit(CardBattle *battle, s32 id)
The limit card id sets for CARDGAME_compareCards (0 for most)
Definition computer.c:413
s32 CARDGAME_isSlotWithin(CardBattle *battle, s32 side, s32 index, s32 value)
Whether side's slot index is flagged and its hp is at most value.
Definition computer.c:337
s16 CARDGAME_animPiles[7][2]
the side and pile CARDGAME_updateCardAnims passes to CARDGAME_layOutPile
Definition cardgame_3.c:160
void CARDGAME_layOutPile(CardBattle *battle, CardBattleItems *items, s32 side, s32 which)
Lays out the cards of one of a side's piles (which: 0 the hand; 1 the discards; 2 the deck from deckT...
Definition battle.c:156
CardOffset CARDGAME_panelIconPositions[2][2][2]
CARDGAME_drawPanelIcon's icon and label positions, by SHIFT_PAL_SCREEN and side (EU)
Definition cardgame_3.c:60
void CARDGAME_markSlotsOfOrder(CardBattle *battle, CardScreen *screen)
Marks (effectStep.marked) the slots whose order is the last card played's target.
void CARDGAME_layOutSlots(CardBattle *battle, CardBattleItems *items)
Lays out the slots as sprites (0-5 player 0's, 6-11 player 1's) and each play of record....
Definition battle.c:351
u8 CARDGAME_slotMoveCounts[]
per side, the entries of CARDGAME_slotMoves
Definition cardgame_3.c:192
void CARDGAME_sumSlotValues(CardBattle *battle, s32 side)
Side's apTotal and hpTotal become the sums of its slot cards' ap and hp.
Definition battle.c:1463
s32 CARDGAME_stepDiscardSlotCard(CardBattle *battle, CardScreen *screen, s32 side, s32 index)
Shakes side's slot index away, then CARDGAME_discardSlotCard; 1 once done.
void CARDGAME_returnOpponentHand(CardBattle *battle, CardBattleItems *items)
Puts side 1's hand back on its pile and renumbers the pile's cards.
Definition battle.c:120
void CARDGAME_jumpIfSlotFree(CardBattle *battle, s32 side, s32 offset)
The effect script jumps offset steps (effectPos) when side has fewer than six cards out.
u8 CARDGAME_slotMoves[2][6][2]
per side, the slot moves (from, to) of CARDGAME_removeMarkedSlots
Definition cardgame_3.c:182
u8 CARDGAME_markedCounts[2]
per side, the marked slots
void CARDGAME_takeHandCard(CardBattle *battle, CardScreen *screen, s32 side)
Takes the card the last record names out of the side's hand into its next slot and shows it.
Definition round.c:151
s32 CARDGAME_stepSwap(CardBattle *battle, CardScreen *screen)
Swaps the two sides' pile apTotal and hpTotal, counting the panels' ap and hp over to each other,...
Definition round.c:928
s32 CARDGAME_stepSendOff(CardBattle *battle, CardScreen *screen, s32 index)
Moves sprite index off the left of the screen; 1 once it is there.
void CARDGAME_startTotals(CardBattle *battle, CardScreen *screen)
Starts CARDGAME_stepTotals.
Definition round.c:1163
void CARDGAME_startDiscardCount(CardBattle *battle, CardScreen *screen, s32 side)
Starts a count of side's discards and deck (effectStep.vars[0] and effectStep.vars[1])
void CARDGAME_markTargetSlots(CardBattle *battle, CardScreen *screen)
Marks in effectStep.marked the slots out that the last card played applies to, by its target (record....
void CARDGAME_setCountingCardValues(CardBattle *battle, CardSlot *slot, s32 side, s32 pass)
Sets the values of a slot that holds the pass-th card of CARDGAME_countingCards from the battle's cou...
Definition battle.c:1398
void CARDGAME_putSlotCard(CardBattle *battle, CardScreen *screen, s32 side, s32 card)
Puts a card in the side's next slot (owned by side 2) and shows it.
Definition round.c:120
s32 CARDGAME_markSlotsByColor(CardBattle *battle, CardScreen *screen, s32 side, s32 flags)
Marks in effectStep.eligible the slots of the sides flags picks (0x100 side's own,...
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
s32 CARDGAME_drainColorValues(CardBattle *battle, CardScreen *screen)
Counts both sides' colour values (pile.points) down by one each effectStep.vars[2] frames,...
s32 CARDGAME_stepEffectColorValue(CardBattle *battle, CardScreen *screen)
Effect steps 30-40: CARDGAME_stepColorValue on a colour of the last card's side (30-35) or of the oth...
void CARDGAME_takeCardToHand(CardBattle *battle, CardScreen *screen, s32 side, s32 arg3)
Adds card effectStep.choice of a side's discards (which 4) or deck to its hand.
s32 CARDGAME_drawFromDeck(CardBattle *battle, CardScreen *screen, s32 side, s32 which)
Moves the card just put in the hand into place, then takes card effectStep.choice out of the deck (ta...
s32 CARDGAME_stepSlotSweep(CardBattle *battle, CardScreen *screen, s32 which)
Goes over the marked slots one by one, discarding their cards (which 0) or returning them to the hand...
Definition round.c:16
void CARDGAME_initBattle(CardBattle *battle, CardBattleItems *items)
Sets up a card battle: the sides' panels, no result, CARD_PHASE_FADE_IN.
Definition battle.c:1932
void CARDGAME_prepareTurn(CardBattle *battle, CardBattleItems *items)
Clears record.turnState, shows the panel values and sorts the player's hand.
Definition battle.c:1336
s32 CARDGAME_keepLastCard(CardBattle *battle, CardScreen *screen)
Keeps the last card played in keptCard (as card + 1) and counts it (keptCount); 1.
s32 CARDGAME_pickComputerTarget(CardBattle *battle, CardScreen *screen, s32 id)
The computer's target for card id: a slot picked by the card's rule; 1 once there is one.
Definition computer.c:461
s32 CARDGAME_runStartStep(CardBattle *battle, CardBattleItems *items)
Runs step 20 (CARDGAME_stepStart) and then returns its choice + 1: 1 dealt, 2 the player's deck was s...
Definition battle.c:947
void CARDGAME_markRecordHits(CardBattle *battle, CardScreen *screen, s32 side, s32 index)
Marks (marks) the plays whose effect reaches sprite index, by their target (targetKind): a side,...
Definition round.c:60
void CARDGAME_resetSpriteFlags(CardBattle *battle)
Sets the 15 sprites' anim.dimmed to whether anim.dimAll is 2, once it is set.
Definition battle.c:425
void CARDGAME_updateCardAnims(CardBattle *battle, CardBattleItems *items)
Starts (anim.next) and runs (anim.current) the screen's card animations: the hands',...
Definition battle.c:553
s32 CARDGAME_interpolate(s32 to, s32 from, s32 duration, s32 time)
The value going from FROM to TO in DURATION, at TIME, never past TO.
Definition round.c:899
s32 CARDGAME_stepSlotTotal(CardBattle *battle, CardScreen *screen, s32 side)
Takes the marked slots' sprites away, shows card effectStep.vars[4] in window 2 for 90 frames (or unt...
Definition round.c:1062
s32 CARDGAME_checkPlayCondition(CardBattle *battle, CardScreen *screen, s32 kind)
Whether the condition kind (1-11) of the card being played holds for its side: 1 if it does.
void CARDGAME_startStepFade(CardBattle *battle, CardBattleItems *items)
Starts the fade that fade asks for (CARDGAME_fadeColors)
Definition battle.c:404
s32 CARDGAME_runBattle(CardBattle *battle, CardBattleItems *items)
A frame of the card battle: the sprites' flags, the card animations, the fades, then the phase,...
Definition battle.c:2448
void CARDGAME_discardSlotCard(CardBattle *battle, CardScreen *screen, s32 side, s32 index)
Puts the card of side's slot index on its owner's discards, on the panel.
s32 CARDGAME_recordCardPositions[][2]
where card 15 goes, by CardRecord.playCount
Definition cardgame_2.c:32
u8 CARDGAME_resolveCard(CardBattle *battle, CardBattleItems *items)
Plays out the last card played (record.plays): its effect and its messages, then puts it in its side'...
Definition battle.c:2182
void CARDGAME_sortCards(CardBattle *battle, s16 *list, s32 range, s32 flags)
Sorts the cards list[from..to) (range: to << 16 | from) by their values, moving opponentDraws (flags ...
Definition battle.c:693
s16 CARDGAME_colorFlags[]
a flag bit per card colour
Definition cardgame_2.c:28
s32 CARDGAME_targetFlaggedSlot(CardBattle *battle, s32 side)
The next play targets (target) side's first flagged slot; whether there is one.
Definition computer.c:272
void CARDGAME_chooseNextDraw(CardBattle *battle, CardScreen *screen, s32 which)
effectStep.choice becomes the card side which draws next: the player's deck top, or the opponent's fi...
s32 CARDGAME_stepAttack(CardBattle *battle, CardScreen *screen, s32 side)
The side's slot cards go over one by one (every 27 frames) while the panels count its attack (CARD_PA...
Definition round.c:804
void CARDGAME_clearHands(CardBattle *battle, CardScreen *screen)
Empties both hands, on the panels with the decks.
Definition round.c:524
s32 CARDGAME_stepHidePanels(CardBattle *battle, CardBattleItems *items)
Closes the panels once; 1 once they are closed.
Definition battle.c:213
void CARDGAME_copySlotCard(CardBattle *battle, CardScreen *screen, s32 side)
Copies the first marked slot card (effectStep.marked) into the side's next slot.
Definition round.c:245
void CARDGAME_putOutCards(CardBattle *battle, s32 side)
Puts side's flagged cards of its pile into its slots, up to effectStep.count of them.
Definition battle.c:1383
CardFadeColor CARDGAME_fadeColors[]
CARDGAME_startStepFade's fade colours and blends, by fade - 1.
Definition cardgame_3.c:156
void CARDGAME_showSlotTotal(CardBattle *battle, CardScreen *screen, s32 side)
Adds up the marked slots' ap and hp (at most 99, 20 more for four or more slots) and shows them on sp...
Definition round.c:998
s32 CARDGAME_stepShowPanels(CardBattle *battle, CardBattleItems *items)
Opens the panels once; 1 once they are open.
Definition battle.c:2043
s32 CARDGAME_takeFlaggedCard(CardBattle *battle, CardBattleItems *items)
Takes the first flagged card out of the hand of side record.turnSide into the play record....
Definition battle.c:971
s32 CARDGAME_stepTotals(CardBattle *battle, CardScreen *screen)
Adds up both players' slots' ap and hp and counts the panels' ap and hp over to the totals,...
Definition round.c:1173
s32 CARDGAME_scoreHand(CardBattle *battle, s32 side, s32 mask)
Scores the cards in a side's slots, counting runs of the same card.
Definition computer.c:143
s32 CARDGAME_stepShakeAway(CardBattle *battle, CardScreen *screen, s32 index)
Shakes sprite index, then shrinks it to nothing; 1 once done.
s32 CARDGAME_setAllCountingValues(CardBattle *battle)
Sets the values of the counting cards out, pass by pass (CARDGAME_setCountingCardValues); whether any...
Definition battle.c:1443
s32 CARDGAME_returnUsedCards(CardBattle *battle, CardScreen *screen, s32 side)
Counts the panel's discards down into its deck, then puts the side's discards back into its deck; 1 o...
s32 CARDGAME_findOpponentHandKind(CardBattle *battle, s32 kind)
The index of the first card of the opponent's hand of opponentPlans kind (its count when none)
Definition computer.c:603
void CARDGAME_removeMarkedHandCards(CardBattle *battle, CardPile *pile)
Takes the marked cards (effectStep.marked) out of pile's hand.
Definition battle.c:1343
void CARDGAME_startDraw(CardBattle *battle, CardScreen *screen, s32 count)
Starts drawing count cards (effectStep.count)
s32 CARDGAME_slotRowPositions[2][4]
sprite positions, by SHIFT_PAL_SCREEN
Definition cardgame_3.c:14
CardPhase
The phases of a card battle (CardBattle.phase, CARDGAME_runPhase)
Definition battle.h:78
@ CARD_PHASE_FIRST_PICK
who starts
Definition battle.h:82
@ CARD_PHASE_PUT_OUT
Definition battle.h:85
@ CARD_PHASE_DEAL
six cards to each side
Definition battle.h:83
@ CARD_PHASE_NEXT_ROUND
Definition battle.h:88
@ CARD_PHASE_PLAYS_AFTER
plays after: any kind but 0
Definition battle.h:86
@ CARD_PHASE_PLAYS_BEFORE
plays before the cards are put out: kind 2 cards only
Definition battle.h:84
@ CARD_PHASE_END_ROUND
Definition battle.h:87
@ CARD_PHASE_FADE_IN
Definition battle.h:80
@ CARD_PHASE_NONE
for nextPhase: no switch
Definition battle.h:79
@ CARD_PHASE_CHOOSE_DECK
Definition battle.h:81
@ CARD_PHASE_MESSAGE
Definition battle.h:89
u8 CARDGAME_turnStates[]
the next record.turnState state, by step and side
Definition cardgame_3.c:162
void CARDGAME_startClosePanels(CardBattle *battle, CardScreen *screen, s32 force)
When the last card was the player's (or force): takes its play off for a while and closes the panels.
void CARDGAME_jumpIfLastSide(CardBattle *battle, CardScreen *screen, s32 value, s32 offset)
The effect script jumps offset steps (effectPos) when the last card played was side value's.
s32 CARDGAME_markDrawnCards(CardBattle *battle, CardScreen *screen, s32 side)
Marks (effectStep.marked) the cards side draws from its deck: from its top for the player,...
s32 CARDGAME_stepStart(CardBattle *battle, CardScreen *screen)
The start of a card battle: deals six cards to each side (dealNextCards), turns them over and counts ...
Definition round.c:670
s32 CARDGAME_runPhase(CardBattle *battle, CardBattleItems *items)
Runs the battle's current phase (phase), after switching to the one asked for in nextPhase; 1 once th...
Definition battle.c:1941
void CARDGAME_beginStep(CardBattle *battle, CardScreen *screen)
Starts a step's first state.
s32 CARDGAME_stepColorValue(CardBattle *battle, CardScreen *screen, s32 side, s32 color)
Moves a side's colour value (pile.points[color]) one step each effectStep.vars[2] frames towards usin...
s32 CARDGAME_canPlayCardKind(CardBattle *battle, s32 index)
Whether card index can be played in this phase by its kind: any kind but 0 in CARD_PHASE_PLAYS_AFTER,...
Definition play_checks.c:39
CardRun
What CARDGAME_runBattle runs this frame (CardBattle.run)
Definition battle.h:70
@ CARD_RUN_MENU
Definition battle.h:74
@ CARD_RUN_RESOLVE
the card just played (CARDGAME_resolveCard)
Definition battle.h:73
@ CARD_RUN_STEP
an effect step (CARDGAME_runEffectStep)
Definition battle.h:72
@ CARD_RUN_PHASE
the battle's phase (CARDGAME_runPhase)
Definition battle.h:71
s32 CARDGAME_stepDiscardAllSlots(CardBattle *battle, CardScreen *screen, s32 side)
Discards side's slot cards from the last to the first; 1 once done.
Definition round.c:878
void CARDGAME_sortOpponentHand(CardBattle *battle)
Sorts the opponent's hand by its cards' opponentPlans kind, then value.
Definition battle.c:71
void CARDGAME_startColorDrain(CardBattle *battle, CardScreen *screen)
Starts CARDGAME_drainColorValues.
void CARDGAME_runEffectStep(CardBattle *battle, CardScreen *screen)
Starts the effect step battle->effectStep.next asks for (startEffectStep), then runs the current one ...
s32 CARDGAME_countDown(CardBattle *battle, CardScreen *screen)
Counts effectStep.time down by the frame time; whether it ran out.
s32 CARDGAME_pickLowestOpponentCard(CardBattle *battle)
Picks the opponent's flagged card with the lowest CardImage.rank, the strongest; 1 if there is one.
Definition computer.c:386
void CARDGAME_dealHands(CardBattle *battle, CardScreen *screen)
Deals six cards from each side's deck into its hand and puts them on the table, face down.
Definition round.c:537
void CARDGAME_startPlayCard(CardBattle *battle, CardScreen *screen, s32 side)
Shows the card being played as sprite 15 (opening the panels for side 0) and starts moving it to its ...
Definition round.c:358
s32 CARDGAME_discardPickedCard(CardBattle *battle, CardScreen *screen, s32 side, s32 arg3)
Moves sprite 17 to the side's spot, then puts card effectStep.vars[4] on the side's discards and take...
s32 CARDGAME_flipSlotCard(CardBattle *battle, CardScreen *screen, s32 side)
Waits effectStep.time frames, then flips the side's next slot card over and moves it into place; 1 on...
Definition round.c:293
s32 CARDGAME_discardPositions[][2]
x, y per side
Definition cardgame_2.c:31
s32 CARDGAME_discardHand(CardBattle *battle, CardScreen *screen, s32 side)
Counts a side's hand cards over to its discards on its panel, one every 7 frames, then moves them; 1 ...
CardEffect CARDGAME_cardEffects[]
The functions and data the overlay's files share.
void CARDGAME_startCloseGauge(CardBattle *battle, CardScreen *screen)
Closes the gauge of the card before the last one.
void CARDGAME_startDiscardAllSlots(CardBattle *battle, CardScreen *screen, s32 side)
Starts CARDGAME_stepDiscardAllSlots from side's last slot.
Definition round.c:871
u16 CARDGAME_defaultDeck[]
the deck used when the chosen one is empty: its first 40 cards, as card ids - 1 (CardBattle....
Definition cardgame_3.c:144
void CARDGAME_showPanelValues(CardBattle *battle, CardBattleItems *items)
Shows both sides' values on their panels: the points of each colour, the deck, hand and discards,...
Definition battle.c:675
void CARDGAME_startSlotEffects(CardBattle *battle, CardScreen *screen, s32 which)
The steps CARDGAME_runEffectStep starts (CardBattle.effectStep.next) and runs (effectStep....
s32 CARDGAME_moveSlotCard(CardBattle *battle, CardScreen *screen, s32 side)
Moves the side's next slot card into place; 1 once it is there.
Definition round.c:188
s16 CARDGAME_cardWindowPositions[2][2][2]
two positions, then the same moved for SHIFT_PAL_SCREEN
Definition cardgame_2.c:33
s32 CARDGAME_findCardSet(CardBattle *battle, s32 side, s32 index)
Finds three or more of one card (with a CardImage.comboCard) among a side's slots,...
Definition battle.c:1516
s32 CARDGAME_stepClosePanels(CardBattle *battle, CardScreen *screen)
Waits for the panels to close and puts the play back; 1 once done.
void CARDGAME_markBestOpponentSlot(CardBattle *battle)
Marks the opponent's slot that scoreHand rates highest, and keeps it in effectStep....
s32 CARDGAME_stepRoundEnd(CardBattle *battle, CardScreen *screen, s32 side)
Takes the side's slots away one by one, then moves both sides' hands back into their decks one at a t...
Definition round.c:1237
void CARDGAME_jumpIfManyInHand(CardBattle *battle, s32 side, s32 value, s32 offset)
The effect script jumps offset steps (effectPos) when side holds more than value cards.
void CARDGAME_startSlotSweep(CardBattle *battle, CardScreen *screen)
Starts CARDGAME_stepSlotSweep.
Definition round.c:9
void CARDGAME_startColorChange(CardBattle *battle, CardScreen *screen, s32 amount, s32 interval)
Starts CARDGAME_stepColorValue: amount (effectStep.vars[3], below 0 to take) one at a time,...
void CARDGAME_returnHandToDeck(CardPile *pile)
Puts pile's hand back on top of its deck.
Definition battle.c:1891
CardOffset CARDGAME_deckWindowPos[3]
the three deck windows
Definition cardgame_3.c:161
void CARDGAME_setSlot(CardBattle *battle, s32 side, s32 card, s32 index)
Puts the battle's card card in side's slot index, with its AP and HP and the order it came out in.
Definition battle.c:1359
CardBattleMessage CARDGAME_battleMessages[]
the step and nextPhase of CARDGAME_startBattleMessage, by prevPhase
Definition cardgame_3.c:165
void CARDGAME_shufflePile(CardBattle *battle, s32 base, s32 n)
Shuffles the player's pile's deck[base..base + n) with 40 random swaps.
Definition battle.c:730
s32 CARDGAME_runFirstPick(CardBattle *battle, CardBattleItems *items)
Runs step 0xA7 (CARDGAME_startFirstPick) and then keeps who goes first (firstStarter); 1 once done.
Definition battle.c:927
void CARDGAME_findOpponentDeckLimits(CardBattle *battle, CardBattleItems *items)
drawEnd: the first card of the opponent's deck above the round's level (round); reserveStart: the end...
Definition battle.c:102
void CARDGAME_startMessage(CardBattle *battle, CardScreen *screen, s32 text)
Opens message text for a step.
Definition battle_steps.c:8
void CARDGAME_startBattleMessage(CardBattle *battle, CardBattleItems *items)
Starts the step of battle message prevPhase (CARDGAME_battleMessages)
Definition battle.c:1923
s32 CARDGAME_compareCards(CardBattle *battle, s32 id1, s32 id2, s32 flip)
Compares two cards by the rule of the current play; returns 1 if the second one wins.
Definition computer.c:517
s32 CARDGAME_pickComputerCard(CardBattle *battle, CardScreen *screen)
Picks the computer's next card, flagging it in effectStep.marked; returns 1 if one was found.
Definition computer.c:615
s32 CARDGAME_stepReturnSlotCard(CardBattle *battle, CardScreen *screen, s32 side, s32 index)
Sends side's slot index off, then CARDGAME_returnSlotCard; 1 once done.
void CARDGAME_openPanelsPhase(CardBattle *battle, CardBattleItems *items)
Opens the panels for a phase.
Definition battle.c:1570
void CARDGAME_updateBattle(CardBattle *battle, CardBattleItems *items)
The card battle task: sets up the battle and fades in, runs it (CARDGAME_runBattle),...
Definition battle.c:2484
s32 CARDGAME_playRounds(CardBattle *battle, CardBattleItems *items)
Runs the rounds of plays (state record.turnState): each side in turn plays a card,...
Definition battle.c:1230
s32 CARDGAME_targetColor3Slot(CardBattle *battle, s32 side)
CARDGAME_targetFlaggedSlot among side's flagged slots of colour 3.
Definition computer.c:293
s32 CARDGAME_chooseDeck(CardBattle *battle, CardBattleItems *items)
Chooses the player's deck: opens the three deck windows and a marker, Up/Down/Cross pick one,...
Definition battle.c:830
s32 CARDGAME_checkComputerCondition(CardBattle *battle, CardScreen *screen, s32 id)
Checks the condition id (0x70 to 0x96) of a card for the computer; returns 1 if it holds.
Definition computer.c:17
void CARDGAME_flagTargetSlots(CardBattle *battle, CardScreen *screen)
Flags (effectStep.marked) the slots that the current play's target kind (record.plays[playCount]....
Definition battle.c:997
CardMessageWindow CARDGAME_savedScreenState
Definition cardgame_3.c:193
void CARDGAME_startPileCount(CardBattle *battle, CardBattleItems *items, s32 side, s32 which)
Starts the count of side's hand, discards or deck (which 0-2)
Definition battle.c:228
CardOffset CARDGAME_playedCardPos[2][2]
then the same moved for SHIFT_PAL_SCREEN
Definition cardgame_3.c:177
void CARDGAME_loadOpponent(CardBattle *battle, CardBattleItems *items)
Loads the opponent's data (FILE_CARDGAME_OPPONENTS, entry arg - 1): its deck and its card order.
Definition battle.c:7
s32 CARDGAME_discardPrevCard(CardBattle *battle, CardScreen *screen)
Puts the card played before the last one (record.plays[playCount - 2]) on its side's discards once it...
s32 CARDGAME_waitFor(CardBattle *battle, CardScreen *screen, s32 duration)
Counts effectStep.time up by the frame time; whether it passed duration.
void CARDGAME_keepLowestSlot(CardBattle *battle, s32 side)
Keeps the flag (effectStep.eligible) only on side's flagged slot that CARDGAME_scoreHand rates lowest...
Definition computer.c:243
void CARDGAME_drawMarkedCards(CardBattle *battle, CardScreen *screen, s32 side)
Moves side's marked deck cards to its hand and opens its panel.
void CARDGAME_jumpIfDeckLeft(CardBattle *battle, s32 side, s32 offset)
The effect script jumps offset steps (effectPos) when side's deck has cards left.
s16 CARDGAME_prizeItems[]
the item an opponent gives for a win (CardBattle.prize), by its CardOpponent.prize
Definition cardgame_3.c:137
CardBattle * CARDGAME_createBattle(s32 arg)
Creates the card battle against opponent arg (CARDGAME_loadOpponent), with its functions,...
Definition battle.c:2554
void CARDGAME_moveMarkedSlots(CardBattle *battle, CardScreen *screen, s32 arg2, s32 arg3)
Starts moving the marked slots (effectStep.marked) by an offset packed as x << 16 | y.
s32 CARDGAME_stepSlotStats(CardBattle *battle, CardScreen *screen)
Counts the marked slots' ap and hp up or down by one a frame (sign of effectStep.vars[0]/effectStep....
s32 CARDGAME_drawNewCards(CardBattle *battle, CardScreen *screen, s32 side)
Moves the cards drawn into the hand (from effectStep.vars[4] on) into place one at a time (goToNextCa...
s32 CARDGAME_stepOpenPanels(CardBattle *battle, CardScreen *screen)
Waits for the panels to open and puts the play back; 1 once done.
s32 CARDGAME_getCardBonus(CardBattle *battle, s32 id)
The bonus card id gives in CARDGAME_compareCards (0 for most)
Definition computer.c:435
void CARDGAME_startOpenPanels(CardBattle *battle, CardScreen *screen, s32 force)
When the last card was the player's (or force): takes its play off for a while and opens the panels.
void CARDGAME_startHandCount(CardBattle *battle, CardScreen *screen, s32 side)
Starts a count of side's hand and discards (effectStep.vars[0] and effectStep.vars[1])
Definition pile_effects.c:7
s32 CARDGAME_getEffectField(s32 index, u32 field, s32 offset)
One field of card effect index (CardEffect): 0 its condition, 1 its play condition,...
s32 CARDGAME_targetColor4Slot(CardBattle *battle, s32 side)
CARDGAME_targetFlaggedSlot among side's flagged slots of colour 4.
Definition computer.c:315
s32 CARDGAME_runBattleMenu(CardBattle *battle, CardBattleItems *items)
The battle menu (record.menuState its state): three help messages, back, and quitting after a yes/no ...
Definition battle.c:2372
s32 CARDGAME_countSlotValues(CardBattle *battle, CardScreen *screen)
Steps each slot's shown values (its sprite's ap and hp) one unit toward the slot's ap and hp,...
void CARDGAME_startRoundEnd(CardBattle *battle, CardScreen *screen)
Starts CARDGAME_stepRoundEnd.
Definition round.c:1226
void CARDGAME_startSwap(CardBattle *battle, CardScreen *screen)
Shows the kept card (keptCard) as sprite 17 for CARDGAME_stepSwap.
Definition round.c:919
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_returnSlotCard(CardBattle *battle, CardScreen *screen, s32 side, s32 index)
Puts the card of side's slot index back in its owner's hand, on the panel.
void CARDGAME_jumpIfFewInHand(CardBattle *battle, s32 side, s32 value, s32 offset)
The effect script jumps offset steps (effectPos) when side holds at most value cards.
s16 CARDGAME_countingCards[]
five card ids, minus one
Definition cardgame_3.c:134
s32 CARDGAME_unflagSlotsOver(CardBattle *battle, s32 side, s32 value, s32 keep)
Unflags side's slots whose hp is over value; when none is left, 1 (and the last one flagged again,...
Definition computer.c:348
s32 CARDGAME_stepPlayCard(CardBattle *battle, CardScreen *screen)
Card 15 goes off and the marked slot cards turn over; it then lands in sprite 12 + CardRecord....
Definition round.c:408
CardAnimId
The animations of the cards on the table (CardBattle.anim): the slots, the plays or a pile laid out a...
Definition battle.h:166
@ CARD_ANIM_HIDE_DECK
Definition battle.h:175
@ CARD_ANIM_HIDE_HAND
Definition battle.h:173
@ CARD_ANIM_LAY_OUT_HAND
the hand laid out at once
Definition battle.h:184
@ CARD_ANIM_HIDE_SLOTS
Definition battle.h:169
@ CARD_ANIM_SHOW_OPPONENT_DISCARDS
Definition battle.h:182
@ CARD_ANIM_SHOW_HAND
the player's piles...
Definition battle.h:172
@ CARD_ANIM_SHOW_DISCARDS
Definition battle.h:176
@ CARD_ANIM_SHOW_OPPONENT_DECK
Definition battle.h:180
@ CARD_ANIM_SHOW_PLAYS
Definition battle.h:170
@ CARD_ANIM_HIDE_OPPONENT_DISCARDS
Definition battle.h:183
@ CARD_ANIM_HIDE_OPPONENT_DECK
Definition battle.h:181
@ CARD_ANIM_SHOW_SLOTS
Definition battle.h:168
@ CARD_ANIM_SHOW_DECK
Definition battle.h:174
@ CARD_ANIM_LAY_OUT_OPPONENT_HAND
Definition battle.h:185
@ CARD_ANIM_HIDE_PLAYS
Definition battle.h:171
@ CARD_ANIM_HIDE_OPPONENT_HAND
Definition battle.h:179
@ CARD_ANIM_SHOW_OPPONENT_HAND
...and the opponent's
Definition battle.h:178
@ CARD_ANIM_NONE
Definition battle.h:167
@ CARD_ANIM_HIDE_DISCARDS
Definition battle.h:177
void CARDGAME_addCard(CardBattle *battle, s32 side, s32 card)
CardBattle.addCard: puts card in side's next slot.
Definition battle.c:1376
void CARDGAME_showPileCard(CardBattle *battle, CardScreen *screen, s32 side, s32 which)
Shows side's card at effectStep.choice as sprite 17: of its hand (which 0) or its deck (1)
s32 CARDGAME_endRound(CardBattle *battle, CardBattleItems *items)
The end of a round: shows both sides' cards, gives the round to the higher total (pile....
Definition battle.c:1774
s32 CARDGAME_showPlayedCard(CardBattle *battle, CardBattleItems *items)
Shows the last card played (record.plays) in window 2 for 35 frames (Cross cuts it short),...
Definition battle.c:2059
void CARDGAME_startNextRound(CardBattle *battle, CardBattleItems *items)
Puts both hands back in the decks, shuffles the player's, clears the round's values and moves on to t...
Definition battle.c:1900
s32 CARDGAME_markPileCardsByColor(CardBattle *battle, CardScreen *screen, s32 side, s32 kind, s32 flags)
Marks in effectStep.eligible the cards of a side's hand (kind 2), deck (3) or discards (4) whose colo...
CARDGAME's shared declarations: the headers it builds on and the types the other headers point to bef...
signed int s32
Definition common.h:11
unsigned int u32
Definition common.h:12
signed char s8
Definition common.h:7
signed short s16
Definition common.h:9
unsigned short u16
Definition common.h:10
unsigned char u8
Definition common.h:8
#define TASK_HEADER(Type)
Definition task.h:39
CARDGAME's battle screen: its task, panels, card sprites, blinkers, gauges, numbers and windows,...
The running animation of the cards on the table (CARDGAME_updateCardAnims)
Definition battle.h:193
s32 duration
Definition battle.h:205
s32 count
the pile's cards
Definition battle.h:204
u8 faceDown
the next pile or slots are laid out face down
Definition battle.h:198
u8 next
the one to start
Definition battle.h:195
s32 time
Definition battle.h:201
u8 pad
never read or written
Definition battle.h:196
s32 shown
the sprites scaled so far
Definition battle.h:202
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
s32 stagger
one more sprite scales every 4 frames
Definition battle.h:203
u8 dimmed[40]
by sprite
Definition battle.h:200
The card battle's task items.
Definition battle.h:284
CardPreloader * preloader
the card game's files' (CARDGAME_startPreloader)
Definition battle.h:285
CardFader * fader
Definition battle.h:286
CardDeckWindow * deckWindows[3]
Definition battle.h:288
CardScreen * screen
Definition battle.h:289
CardMarker * marker
the deck choice's
Definition battle.h:287
What a phase does once it is over (CARDGAME_battleMessages): the step that shows its message,...
Definition battle.h:94
u16 phase
for CardBattle.nextPhase
Definition battle.h:96
u16 step
for CardStep.next
Definition battle.h:95
The card battle (CARDGAME_createBattle).
Definition battle.h:226
u8 fade
the fade to start (CARDGAME_fadeColors), plus one
Definition battle.h:251
s32 prize
the item the player wins (GAME.items)
Definition battle.h:236
u8 run
what runs this frame (CARD_RUN_*)
Definition battle.h:238
u8 phaseStep
the phase's own state
Definition battle.h:243
u8 drawEnd
the first card of the opponent's deck above the round's group
Definition battle.h:260
void(* putOutCards)(struct CardBattle *battle, s32 side)
Definition battle.h:278
u8 pad35A[2]
never read or written
Definition battle.h:256
u8 playsToResolve
record.playCount, as CARDGAME_resolveCard starts; nothing reads it
Definition battle.h:266
CardPlayer players[2]
Definition battle.h:275
s16 deckChoice
the player's deck (GAME.decks)
Definition battle.h:235
u8 arg
the mode argument: the opponent, from 1
Definition battle.h:233
CardRecord record
Definition battle.h:273
u8 firstStarter
the side that starts the first round
Definition battle.h:239
u8 pad309
never read or written
Definition battle.h:254
u8 resolveState
CARDGAME_resolveCard's.
Definition battle.h:264
u8 pad307
never read or written
Definition battle.h:252
u8 opponentLevel
CardOpponent.level.
Definition battle.h:234
s16 playerDeck[40]
the player's deck
Definition battle.h:232
s16 cards[250]
card ids, minus one (CARDGAME_loadCardImages)
Definition battle.h:228
u8 result
2 once the battle is over
Definition battle.h:248
u8 playerLost
0 once the player has won the battle
Definition battle.h:247
u8 prevDiscarded
the card before the last one played went off too
Definition battle.h:265
u8 keptCount
and how many times
Definition battle.h:250
s16 loopCount
the effect script's loop: the runs left
Definition battle.h:268
s32(* scoreHand)(struct CardBattle *battle, s32 side, s32 mask)
Definition battle.h:280
CardPlan opponentPlans[40]
one per card of side 1 (40-79)
Definition battle.h:257
s32 phaseTime
a frame count, or the phase's own counter
Definition battle.h:244
s16 effectPos
the step of the card's effect script to run next
Definition battle.h:267
u8 roundWinner
the side that won the round
Definition battle.h:246
u8 phase
a CARD_PHASE_*
Definition battle.h:242
u8 pad245[3]
never read or written
Definition battle.h:230
void(* shufflePile)(struct CardBattle *battle, s32 base, s32 n)
Definition battle.h:276
u8 reserveStart
the first card of the opponent's deck held back (group 7)
Definition battle.h:261
CardOpponent * opponents
file FILE_CARDGAME_OPPONENTS
Definition battle.h:237
s32 subState
the state of a phase's helpers (CARDGAME_showPlayedCard...)
Definition battle.h:270
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
u8 nextPhase
the phase to switch to, if not 0
Definition battle.h:241
CardStep savedStep
the step, while the battle menu is open
Definition battle.h:272
void(* addCard)(struct CardBattle *battle, s32 side, s32 card)
Definition battle.h:279
u8 cardCount
in cards
Definition battle.h:229
u8 round
from 0
Definition battle.h:245
s16 opponentDeck[40]
the opponent's deck
Definition battle.h:231
u8 prevPhase
Definition battle.h:240
s32 subTime
and their frame count
Definition battle.h:271
u8 counterCards[0x1B]
the cards the computer answers with a kind 4 card, up to an 0xFF
Definition battle.h:259
u8 keptCard
the card CARDGAME_keepLastCard kept, plus one
Definition battle.h:249
u8 slotCount
the slots added so far
Definition battle.h:253
s16 loopStart
and where it starts again
Definition battle.h:269
u8 pad3FC[4]
never read or written
Definition battle.h:258
CardSide sides[2]
Definition battle.h:274
CardDraw opponentDraws[40]
by the opponent's deck card
Definition battle.h:255
A card of an opponent's deck (CardOpponent.cards)
Definition battle.h:209
s16 card
the id plus one in the low 12 bits; bit 15 a flag
Definition battle.h:210
u8 group
when the computer draws it (CardDraw.group)
Definition battle.h:211
u8 kind
how it plays it (CardPlan.kind)
Definition battle.h:212
A deck's window (CARDGAME_createDeckWindow): its name and how many cards of each of the six colours i...
Definition choice.h:39
Where a card of the opponent's deck is drawn (CardBattle.opponentDraws): the computer draws the cards...
Definition battle.h:102
u8 order
its place in the deck
Definition battle.h:103
u8 group
Definition battle.h:104
A card's effect (CARDGAME_cardEffects), read through CARDGAME_getEffectField.
Definition battle.h:53
u8 playCondition
CARDGAME_checkPlayCondition's.
Definition battle.h:55
u8 script[40]
the effect steps it runs one by one, up to a 0
Definition battle.h:58
u8 condition
for the computer (CARDGAME_checkComputerCondition)
Definition battle.h:54
u8 message
what it shows when the play condition holds
Definition battle.h:56
u8 target
the kind of target of its play (CardPlay.targetKind)
Definition battle.h:57
A fade colour and blend mode (CardBattle.fade - 1 picks one)
Definition screen.h:51
Fades the screen to a colour: a POLY_F4 over it, blended (blend is the semi-transparency rate)
Definition screen.h:34
A blinking marker that opens and closes by scaling (CARDGAME_createMarker): frame 0x47 of the TIM arc...
Definition choice.h:20
The battle screen's message window (CardScreen.message), which CARDGAME_runBattleMenu keeps a copy of...
Definition screen.h:248
An offset from a window's corner.
Definition screen.h:59
An opponent of the card battle: an entry of file FILE_CARDGAME_OPPONENTS, picked by CardBattle....
Definition battle.h:217
u8 level
shown after "LV" (card text 0x3E), 4-92
Definition battle.h:220
CardDeckCard cards[40]
Definition battle.h:218
s32 prize
its index in CARDGAME_prizeItems
Definition battle.h:221
s16 counterCards[20]
from 1, up to a 0: CardBattle.counterCards before the usual ones
Definition battle.h:219
A player's cards in a card battle (CardSide.pile)
Definition battle.h:108
s16 hpTotal
the sum of its slot cards' hp: the higher one wins the round
Definition battle.h:110
s16 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
u8 side
its panel
Definition battle.h:116
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 apTotal
the sum of its slot cards' ap, which comes off the other side's hpTotal
Definition battle.h:109
u8 wins
rounds won: two win the battle
Definition battle.h:117
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
How the computer plays a card of its deck (CardBattle.opponentPlans): kind first, then priority (CARD...
Definition battle.h:63
u8 kind
1-7 (CardDeckCard.kind)
Definition battle.h:64
u8 flagged
bit 15 of the card in the opponent's deck
Definition battle.h:65
s16 priority
by kind, then by place in the deck
Definition battle.h:66
A card played in a round (CardRecord.plays), whose effect then runs.
Definition battle.h:43
s16 card
the index in the battle's card list
Definition battle.h:44
u8 targetKind
its effect's (CardEffect.target)
Definition battle.h:47
u8 side
who played it
Definition battle.h:46
u8 target
the slot's order, or the card, it was played on
Definition battle.h:48
s16 mark
Definition battle.h:45
One of the two players of a card battle.
Definition battle.h:37
CardSlot slots[8]
Definition battle.h:39
u8 slotCount
Definition battle.h:38
Reads CARDGAME's files into the file cache, one at a time.
Definition screen.h:25
The turns of a round, in which the sides play cards one after the other (CARDGAME_playRounds),...
Definition battle.h:125
u8 menuState
CARDGAME_runBattleMenu's state.
Definition battle.h:126
s32 waitTime
Definition battle.h:136
u8 pad2[0xA]
never read or written
Definition battle.h:128
u8 pad30[4]
never read or written: CardBattle.sides follows 0x34 bytes after the record
Definition battle.h:138
u8 turns
the turns of plays this round
Definition battle.h:131
u8 turnState
CARDGAME_playRounds' state.
Definition battle.h:129
u8 menuCursor
CARDGAME_runBattleMenu's cursor, 0-4.
Definition battle.h:127
s8 answer
a step's result: -1 while waiting, then 0 or 1
Definition battle.h:135
s8 playCount
the plays in use
Definition battle.h:130
u8 turnSide
the side whose turn it is
Definition battle.h:134
u8 passes
the turns with no card played: two end the plays
Definition battle.h:132
u8 starter
the side that starts the round
Definition battle.h:133
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
Each player's side of a card battle (CardBattle.sides)
Definition battle.h:159
u8 pad[0x3C]
never read or written: CardBattle.sides[2] spans 0x190 bytes
Definition battle.h:161
CardPile pile
Definition battle.h:160
A card a player has out (CARDGAME_setSlot)
Definition battle.h:19
u8 owner
Definition battle.h:26
s16 hp
its hit points, 0 to 99: at 0 it is lost
Definition battle.h:24
s16 hpBonus
and to its hp
Definition battle.h:22
u8 side
Definition battle.h:25
s16 apBonus
what the effects added to its ap
Definition battle.h:21
s16 ap
its attack points, 0 to 99
Definition battle.h:23
s16 card
the index in the battle's card list
Definition battle.h:20
u8 order
CardBattle.slotCount when it was added.
Definition battle.h:27
A slot's card, sorted by id (CARDGAME_findCardSet)
Definition battle.h:31
s16 card
its id, minus one
Definition battle.h:33
The effect step that runs (CARDGAME_runEffectStep) and its values, which CARDGAME_runBattleMenu keeps...
Definition battle.h:143
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