1#ifndef CARDGAME_BATTLE_H
2#define CARDGAME_BATTLE_H
12#if VERSION_US || VERSION_JP
13#define FILE_CARDGAME_OPPONENTS 0x795
15#define FILE_CARDGAME_OPPONENTS 0x7A4
189#define CARD_ANIM_UNDIM_ALL 1
190#define CARD_ANIM_DIM_ALL 2
295#define CARD_INFO_STEPS 0
296#elif VERSION_EU || VERSION_JP
297#define CARD_INFO_STEPS 2
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.
s32 CARDGAME_runPutOut(CardBattle *battle, CardBattleItems *items)
A battle step: each side puts out its flagged cards (putOutCards) between messages 0x9A,...
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),...
s32 CARDGAME_getCardLimit(CardBattle *battle, s32 id)
The limit card id sets for CARDGAME_compareCards (0 for most)
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.
s16 CARDGAME_animPiles[7][2]
the side and pile CARDGAME_updateCardAnims passes to CARDGAME_layOutPile
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...
CardOffset CARDGAME_panelIconPositions[2][2][2]
CARDGAME_drawPanelIcon's icon and label positions, by SHIFT_PAL_SCREEN and side (EU)
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....
u8 CARDGAME_slotMoveCounts[]
per side, the entries of CARDGAME_slotMoves
void CARDGAME_sumSlotValues(CardBattle *battle, s32 side)
Side's apTotal and hpTotal become the sums of its slot cards' ap and hp.
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.
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
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.
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,...
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.
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...
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.
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...
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...
void CARDGAME_initBattle(CardBattle *battle, CardBattleItems *items)
Sets up a card battle: the sides' panels, no result, CARD_PHASE_FADE_IN.
void CARDGAME_prepareTurn(CardBattle *battle, CardBattleItems *items)
Clears record.turnState, shows the panel values and sorts the player's hand.
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.
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...
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,...
void CARDGAME_resetSpriteFlags(CardBattle *battle)
Sets the 15 sprites' anim.dimmed to whether anim.dimAll is 2, once it is set.
void CARDGAME_updateCardAnims(CardBattle *battle, CardBattleItems *items)
Starts (anim.next) and runs (anim.current) the screen's card animations: the hands',...
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.
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...
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)
s32 CARDGAME_runBattle(CardBattle *battle, CardBattleItems *items)
A frame of the card battle: the sprites' flags, the card animations, the fades, then the phase,...
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
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'...
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 ...
s16 CARDGAME_colorFlags[]
a flag bit per card colour
s32 CARDGAME_targetFlaggedSlot(CardBattle *battle, s32 side)
The next play targets (target) side's first flagged slot; whether there is one.
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...
void CARDGAME_clearHands(CardBattle *battle, CardScreen *screen)
Empties both hands, on the panels with the decks.
s32 CARDGAME_stepHidePanels(CardBattle *battle, CardBattleItems *items)
Closes the panels once; 1 once they are closed.
void CARDGAME_copySlotCard(CardBattle *battle, CardScreen *screen, s32 side)
Copies the first marked slot card (effectStep.marked) into the side's next slot.
void CARDGAME_putOutCards(CardBattle *battle, s32 side)
Puts side's flagged cards of its pile into its slots, up to effectStep.count of them.
CardFadeColor CARDGAME_fadeColors[]
CARDGAME_startStepFade's fade colours and blends, by fade - 1.
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...
s32 CARDGAME_stepShowPanels(CardBattle *battle, CardBattleItems *items)
Opens the panels once; 1 once they are open.
s32 CARDGAME_takeFlaggedCard(CardBattle *battle, CardBattleItems *items)
Takes the first flagged card out of the hand of side record.turnSide into the play record....
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,...
s32 CARDGAME_scoreHand(CardBattle *battle, s32 side, s32 mask)
Scores the cards in a side's slots, counting runs of the same card.
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...
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)
void CARDGAME_removeMarkedHandCards(CardBattle *battle, CardPile *pile)
Takes the marked cards (effectStep.marked) out of pile's hand.
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
CardPhase
The phases of a card battle (CardBattle.phase, CARDGAME_runPhase)
@ CARD_PHASE_FIRST_PICK
who starts
@ CARD_PHASE_DEAL
six cards to each side
@ CARD_PHASE_PLAYS_AFTER
plays after: any kind but 0
@ CARD_PHASE_PLAYS_BEFORE
plays before the cards are put out: kind 2 cards only
@ CARD_PHASE_NONE
for nextPhase: no switch
u8 CARDGAME_turnStates[]
the next record.turnState state, by step and side
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 ...
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...
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,...
CardRun
What CARDGAME_runBattle runs this frame (CardBattle.run)
@ CARD_RUN_RESOLVE
the card just played (CARDGAME_resolveCard)
@ CARD_RUN_STEP
an effect step (CARDGAME_runEffectStep)
@ CARD_RUN_PHASE
the battle's phase (CARDGAME_runPhase)
s32 CARDGAME_stepDiscardAllSlots(CardBattle *battle, CardScreen *screen, s32 side)
Discards side's slot cards from the last to the first; 1 once done.
void CARDGAME_sortOpponentHand(CardBattle *battle)
Sorts the opponent's hand by its cards' opponentPlans kind, then value.
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.
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.
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 ...
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...
s32 CARDGAME_discardPositions[][2]
x, y per side
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.
u16 CARDGAME_defaultDeck[]
the deck used when the chosen one is empty: its first 40 cards, as card ids - 1 (CardBattle....
void CARDGAME_showPanelValues(CardBattle *battle, CardBattleItems *items)
Shows both sides' values on their panels: the points of each colour, the deck, hand and discards,...
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.
s16 CARDGAME_cardWindowPositions[2][2][2]
two positions, then the same moved for SHIFT_PAL_SCREEN
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,...
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...
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.
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.
CardOffset CARDGAME_deckWindowPos[3]
the three deck windows
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.
CardBattleMessage CARDGAME_battleMessages[]
the step and nextPhase of CARDGAME_startBattleMessage, by prevPhase
void CARDGAME_shufflePile(CardBattle *battle, s32 base, s32 n)
Shuffles the player's pile's deck[base..base + n) with 40 random swaps.
s32 CARDGAME_runFirstPick(CardBattle *battle, CardBattleItems *items)
Runs step 0xA7 (CARDGAME_startFirstPick) and then keeps who goes first (firstStarter); 1 once done.
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...
void CARDGAME_startMessage(CardBattle *battle, CardScreen *screen, s32 text)
Opens message text for a step.
void CARDGAME_startBattleMessage(CardBattle *battle, CardBattleItems *items)
Starts the step of battle message prevPhase (CARDGAME_battleMessages)
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.
s32 CARDGAME_pickComputerCard(CardBattle *battle, CardScreen *screen)
Picks the computer's next card, flagging it in effectStep.marked; returns 1 if one was found.
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.
void CARDGAME_updateBattle(CardBattle *battle, CardBattleItems *items)
The card battle task: sets up the battle and fades in, runs it (CARDGAME_runBattle),...
s32 CARDGAME_playRounds(CardBattle *battle, CardBattleItems *items)
Runs the rounds of plays (state record.turnState): each side in turn plays a card,...
s32 CARDGAME_targetColor3Slot(CardBattle *battle, s32 side)
CARDGAME_targetFlaggedSlot among side's flagged slots of colour 3.
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,...
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.
void CARDGAME_flagTargetSlots(CardBattle *battle, CardScreen *screen)
Flags (effectStep.marked) the slots that the current play's target kind (record.plays[playCount]....
CardMessageWindow CARDGAME_savedScreenState
void CARDGAME_startPileCount(CardBattle *battle, CardBattleItems *items, s32 side, s32 which)
Starts the count of side's hand, discards or deck (which 0-2)
CardOffset CARDGAME_playedCardPos[2][2]
then the same moved for SHIFT_PAL_SCREEN
void CARDGAME_loadOpponent(CardBattle *battle, CardBattleItems *items)
Loads the opponent's data (FILE_CARDGAME_OPPONENTS, entry arg - 1): its deck and its card order.
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...
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
CardBattle * CARDGAME_createBattle(s32 arg)
Creates the card battle against opponent arg (CARDGAME_loadOpponent), with its functions,...
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)
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])
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.
s32 CARDGAME_runBattleMenu(CardBattle *battle, CardBattleItems *items)
The battle menu (record.menuState its state): three help messages, back, and quitting after a yes/no ...
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.
void CARDGAME_startSwap(CardBattle *battle, CardScreen *screen)
Shows the kept card (keptCard) as sprite 17 for CARDGAME_stepSwap.
void CARDGAME_sortOpponentCards(CardBattle *battle)
Sorts the opponent's cards by opponentDraws[].order, then swaps card effectStep.choice to reserveStar...
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
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,...
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....
CardAnimId
The animations of the cards on the table (CardBattle.anim): the slots, the plays or a pile laid out a...
@ CARD_ANIM_LAY_OUT_HAND
the hand laid out at once
@ CARD_ANIM_SHOW_OPPONENT_DISCARDS
@ CARD_ANIM_SHOW_HAND
the player's piles...
@ CARD_ANIM_SHOW_DISCARDS
@ CARD_ANIM_SHOW_OPPONENT_DECK
@ CARD_ANIM_HIDE_OPPONENT_DISCARDS
@ CARD_ANIM_HIDE_OPPONENT_DECK
@ CARD_ANIM_LAY_OUT_OPPONENT_HAND
@ CARD_ANIM_HIDE_OPPONENT_HAND
@ CARD_ANIM_SHOW_OPPONENT_HAND
...and the opponent's
@ CARD_ANIM_HIDE_DISCARDS
void CARDGAME_addCard(CardBattle *battle, s32 side, s32 card)
CardBattle.addCard: puts card in side's next slot.
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....
s32 CARDGAME_showPlayedCard(CardBattle *battle, CardBattleItems *items)
Shows the last card played (record.plays) in window 2 for 35 frames (Cross cuts it short),...
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...
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...
#define TASK_HEADER(Type)
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)
s32 count
the pile's cards
u8 faceDown
the next pile or slots are laid out face down
u8 pad
never read or written
s32 shown
the sprites scaled so far
u8 dimAll
sets dimmed of the first 15 sprites once
u8 hide
the one that hides what the last one showed
s32 stagger
one more sprite scales every 4 frames
The card battle's task items.
CardPreloader * preloader
the card game's files' (CARDGAME_startPreloader)
CardDeckWindow * deckWindows[3]
CardMarker * marker
the deck choice's
What a phase does once it is over (CARDGAME_battleMessages): the step that shows its message,...
u16 phase
for CardBattle.nextPhase
u16 step
for CardStep.next
The card battle (CARDGAME_createBattle).
u8 fade
the fade to start (CARDGAME_fadeColors), plus one
s32 prize
the item the player wins (GAME.items)
u8 run
what runs this frame (CARD_RUN_*)
u8 phaseStep
the phase's own state
u8 drawEnd
the first card of the opponent's deck above the round's group
void(* putOutCards)(struct CardBattle *battle, s32 side)
u8 pad35A[2]
never read or written
u8 playsToResolve
record.playCount, as CARDGAME_resolveCard starts; nothing reads it
s16 deckChoice
the player's deck (GAME.decks)
u8 arg
the mode argument: the opponent, from 1
u8 firstStarter
the side that starts the first round
u8 pad309
never read or written
u8 resolveState
CARDGAME_resolveCard's.
u8 pad307
never read or written
u8 opponentLevel
CardOpponent.level.
s16 playerDeck[40]
the player's deck
s16 cards[250]
card ids, minus one (CARDGAME_loadCardImages)
u8 result
2 once the battle is over
u8 playerLost
0 once the player has won the battle
u8 prevDiscarded
the card before the last one played went off too
u8 keptCount
and how many times
s16 loopCount
the effect script's loop: the runs left
s32(* scoreHand)(struct CardBattle *battle, s32 side, s32 mask)
CardPlan opponentPlans[40]
one per card of side 1 (40-79)
s32 phaseTime
a frame count, or the phase's own counter
s16 effectPos
the step of the card's effect script to run next
u8 roundWinner
the side that won the round
u8 pad245[3]
never read or written
void(* shufflePile)(struct CardBattle *battle, s32 base, s32 n)
u8 reserveStart
the first card of the opponent's deck held back (group 7)
CardOpponent * opponents
file FILE_CARDGAME_OPPONENTS
s32 subState
the state of a phase's helpers (CARDGAME_showPlayedCard...)
void(* sortCards)(struct CardBattle *battle, s16 *list, s32 range, s32 flags)
u8 nextPhase
the phase to switch to, if not 0
CardStep savedStep
the step, while the battle menu is open
void(* addCard)(struct CardBattle *battle, s32 side, s32 card)
s16 opponentDeck[40]
the opponent's deck
s32 subTime
and their frame count
u8 counterCards[0x1B]
the cards the computer answers with a kind 4 card, up to an 0xFF
u8 keptCard
the card CARDGAME_keepLastCard kept, plus one
u8 slotCount
the slots added so far
s16 loopStart
and where it starts again
u8 pad3FC[4]
never read or written
CardDraw opponentDraws[40]
by the opponent's deck card
A card of an opponent's deck (CardOpponent.cards)
s16 card
the id plus one in the low 12 bits; bit 15 a flag
u8 group
when the computer draws it (CardDraw.group)
u8 kind
how it plays it (CardPlan.kind)
A deck's window (CARDGAME_createDeckWindow): its name and how many cards of each of the six colours i...
Where a card of the opponent's deck is drawn (CardBattle.opponentDraws): the computer draws the cards...
u8 order
its place in the deck
A card's effect (CARDGAME_cardEffects), read through CARDGAME_getEffectField.
u8 playCondition
CARDGAME_checkPlayCondition's.
u8 script[40]
the effect steps it runs one by one, up to a 0
u8 condition
for the computer (CARDGAME_checkComputerCondition)
u8 message
what it shows when the play condition holds
u8 target
the kind of target of its play (CardPlay.targetKind)
A fade colour and blend mode (CardBattle.fade - 1 picks one)
Fades the screen to a colour: a POLY_F4 over it, blended (blend is the semi-transparency rate)
A blinking marker that opens and closes by scaling (CARDGAME_createMarker): frame 0x47 of the TIM arc...
The battle screen's message window (CardScreen.message), which CARDGAME_runBattleMenu keeps a copy of...
An offset from a window's corner.
An opponent of the card battle: an entry of file FILE_CARDGAME_OPPONENTS, picked by CardBattle....
u8 level
shown after "LV" (card text 0x3E), 4-92
s32 prize
its index in CARDGAME_prizeItems
s16 counterCards[20]
from 1, up to a 0: CardBattle.counterCards before the usual ones
A player's cards in a card battle (CardSide.pile)
s16 hpTotal
the sum of its slot cards' hp: the higher one wins the round
s16 deckCount
the cards left in the deck
s16 deck[40]
deckTop on are left
s16 deckTop
the index of the deck's top card
u8 points[5]
one per card colour
s16 apTotal
the sum of its slot cards' ap, which comes off the other side's hpTotal
u8 wins
rounds won: two win the battle
s16 discards[10]
the cards played and lost from the slots, discardCount in use
s16 hand[10]
handCount in use
How the computer plays a card of its deck (CardBattle.opponentPlans): kind first, then priority (CARD...
u8 kind
1-7 (CardDeckCard.kind)
u8 flagged
bit 15 of the card in the opponent's deck
s16 priority
by kind, then by place in the deck
A card played in a round (CardRecord.plays), whose effect then runs.
s16 card
the index in the battle's card list
u8 targetKind
its effect's (CardEffect.target)
u8 target
the slot's order, or the card, it was played on
One of the two players of a card battle.
Reads CARDGAME's files into the file cache, one at a time.
The turns of a round, in which the sides play cards one after the other (CARDGAME_playRounds),...
u8 menuState
CARDGAME_runBattleMenu's state.
u8 pad2[0xA]
never read or written
u8 pad30[4]
never read or written: CardBattle.sides follows 0x34 bytes after the record
u8 turns
the turns of plays this round
u8 turnState
CARDGAME_playRounds' state.
u8 menuCursor
CARDGAME_runBattleMenu's cursor, 0-4.
s8 answer
a step's result: -1 while waiting, then 0 or 1
s8 playCount
the plays in use
u8 turnSide
the side whose turn it is
u8 passes
the turns with no card played: two end the plays
u8 starter
the side that starts the round
CardPlay plays[3]
the cards played this turn, up to three
The battle screen (created by CARDGAME_createScreen): the two panels, the cards on the table and the ...
Each player's side of a card battle (CardBattle.sides)
u8 pad[0x3C]
never read or written: CardBattle.sides[2] spans 0x190 bytes
A card a player has out (CARDGAME_setSlot)
s16 hp
its hit points, 0 to 99: at 0 it is lost
s16 apBonus
what the effects added to its ap
s16 ap
its attack points, 0 to 99
s16 card
the index in the battle's card list
u8 order
CardBattle.slotCount when it was added.
A slot's card, sorted by id (CARDGAME_findCardSet)
s16 card
its id, minus one
The effect step that runs (CARDGAME_runEffectStep) and its values, which CARDGAME_runBattleMenu keeps...
s32 cursor
the card or slot highlighted
s32 time
a frame count, or the step's own sub-state
s8 eligible[0x29]
the cards or slots that can be picked
u8 count
the cards picked, or to draw
u8 state
the step's own state
s32 vars[5]
values each step uses its own way
u8 nextState
the state to set up first, if not 0
u8 flags
the step's own: the rows to pick from, the deck run out...
s8 marked[40]
the cards or slots picked
s32 choice
the card, slot or answer chosen; -1 for none
u8 next
the step to start: CARDGAME_runEffectStep sets it up first