Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
battle.c File Reference

CARDGAME's card battle (CARDGAME_createBattle): the opponent, the deck choice, the rounds, the plays and their results. More...

Include dependency graph for battle.c:

Go to the source code of this file.

Functions

void CARDGAME_loadOpponent (CardBattle *battle, CardBattleItems *items)
 Loads the opponent's data (FILE_CARDGAME_OPPONENTS, entry arg - 1): its deck and its card order.
 
void CARDGAME_sortOpponentHand (CardBattle *battle)
 Sorts the opponent's hand by its cards' opponentPlans kind, then value.
 
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 of its deck before the cards of kind 7
 
void CARDGAME_returnOpponentHand (CardBattle *battle, CardBattleItems *items)
 Puts side 1's hand back on its pile and renumbers the pile's cards.
 
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 deckTop) as sprites in a row.
 
s32 CARDGAME_stepHidePanels (CardBattle *battle, CardBattleItems *items)
 Closes the panels once; 1 once they are closed.
 
void CARDGAME_startPileCount (CardBattle *battle, CardBattleItems *items, s32 side, s32 which)
 Starts the count of side's hand, discards or deck (which 0-2)
 
static void markPlayTargets (CardBattle *battle, CardScreen *screen, s32 play)
 Marks in each slot sprite's marks[play] whether play of record.plays applies to it, by the play's targetKind.
 
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.plays (12 on), marking in marks[play] the slot sprites it applies to (markPlayTargets)
 
void CARDGAME_startStepFade (CardBattle *battle, CardBattleItems *items)
 Starts the fade that fade asks for (CARDGAME_fadeColors)
 
void CARDGAME_resetSpriteFlags (CardBattle *battle)
 Sets the 15 sprites' anim.dimmed to whether anim.dimAll is 2, once it is set.
 
static void showSlots (CardBattle *battle, CardBattleItems *items, CardAnim *anim)
 Scales the slots in, a pair every 4 frames, then shows the plays.
 
static void showPlays (CardBattle *battle, CardBattleItems *items, CardAnim *anim)
 Scales the plays in, one every 4 frames, opening each one's gauge after it.
 
static void hideSlots (CardBattle *battle, CardBattleItems *items, CardAnim *anim)
 Scales the slots out, a pair every 4 frames, then hides the plays.
 
static void hidePlays (CardBattle *battle, CardBattleItems *items, CardAnim *anim)
 Scales the plays out with their gauges, one every 4 frames.
 
static void showPile (CardAnim *anim, CardScreen *screen)
 Scales a pile's cards in, one every 4 frames (at least one)
 
static void hidePile (CardAnim *anim, CardScreen *screen)
 Scales a pile's cards out, one every 4 frames (at least one)
 
void CARDGAME_updateCardAnims (CardBattle *battle, CardBattleItems *items)
 Starts (anim.next) and runs (anim.current) the screen's card animations: the hands', the record's and a pile's sprites scaling in or out.
 
void CARDGAME_showPanelValues (CardBattle *battle, CardBattleItems *items)
 Shows both sides' values on their panels: the points of each colour, the deck, hand and discards, AP and HP.
 
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 bit 0) and effectStep.eligible (bit 1) with them.
 
void CARDGAME_shufflePile (CardBattle *battle, s32 base, s32 n)
 Shuffles the player's pile's deck[base..base + n) with 40 random swaps.
 
static void waitPhaseStep (CardBattle *battle, s32 frames)
 Goes to the next phaseStep after frames frames.
 
static void openDeckWindow (CardBattle *battle, CardBattleItems *items, s32 index)
 Opens deck window index with its sound.
 
static void closeDeckWindow (CardBattle *battle, CardBattleItems *items, s32 index)
 Closes deck window index with its sound.
 
static void moveDeckMarker (CardBattle *battle, CardBattleItems *items)
 Up and Down move the marker between the three decks; Cross picks the marked one, which blinks.
 
static void loadChosenDeck (CardBattle *battle, CardBattleItems *items)
 Loads the chosen deck (or the default one when it is empty) and the opponent's, fills both piles and shuffles the player's.
 
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, then loads both decks' cards; 1 once done.
 
s32 CARDGAME_runFirstPick (CardBattle *battle, CardBattleItems *items)
 Runs step 0xA7 (CARDGAME_startFirstPick) and then keeps who goes first (firstStarter); 1 once done.
 
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 short, 3 the opponent's.
 
s32 CARDGAME_takeFlaggedCard (CardBattle *battle, CardBattleItems *items)
 Takes the first flagged card out of the hand of side record.turnSide into the play record.plays[playCount]; returns its condition id.
 
void CARDGAME_flagTargetSlots (CardBattle *battle, CardScreen *screen)
 Flags (effectStep.marked) the slots that the current play's target kind (record.plays[playCount].targetKind) picks.
 
static void startRounds (CardBattle *battle, CardBattleItems *items)
 Starts the rounds: clears the record, shows the slots and opens the panels.
 
static void startPlay (CardBattle *battle, CardBattleItems *items)
 Picks the side that plays next, by the starter and the plays so far, or once three cards are played resolves them.
 
static void playComputerTurn (CardBattle *battle, CardBattleItems *items)
 The computer plays a card (CARDGAME_pickComputerCard); without one it passes when it would play first, else the plays resolve.
 
static void playPlayerTurn (CardBattle *battle, CardBattleItems *items)
 The player picks a card to play (effect step 0x98); without one they pass when they would play first, else the plays resolve.
 
static void takePickedCard (CardBattle *battle, CardBattleItems *items)
 Takes the picked card into the play and runs its condition's step: when it holds the card is played, else it goes back to the hand.
 
static void startNextTurn (CardBattle *battle)
 Starts the next turn, the other side starting; after two passes the rounds end (state 15)
 
s32 CARDGAME_playRounds (CardBattle *battle, CardBattleItems *items)
 Runs the rounds of plays (state record.turnState): each side in turn plays a card, the computer through CARDGAME_pickComputerCard; 1 once over.
 
void CARDGAME_prepareTurn (CardBattle *battle, CardBattleItems *items)
 Clears record.turnState, shows the panel values and sorts the player's hand.
 
void CARDGAME_removeMarkedHandCards (CardBattle *battle, CardPile *pile)
 Takes the marked cards (effectStep.marked) out of pile's hand.
 
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.
 
void CARDGAME_addCard (CardBattle *battle, s32 side, s32 card)
 CardBattle.addCard: puts card in 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.
 
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 counts (0 to 99)
 
s32 CARDGAME_setAllCountingValues (CardBattle *battle)
 Sets the values of the counting cards out, pass by pass (CARDGAME_setCountingCardValues); whether any card is out.
 
void CARDGAME_sumSlotValues (CardBattle *battle, s32 side)
 Side's apTotal and hpTotal become the sums of its slot cards' ap and hp.
 
s32 CARDGAME_runPutOut (CardBattle *battle, CardBattleItems *items)
 A battle step: each side puts out its flagged cards (putOutCards) between messages 0x9A, 0x9D and 0x9E; 1 once done.
 
s32 CARDGAME_findCardSet (CardBattle *battle, s32 side, s32 start)
 Finds three or more of one card (with a CardImage.comboCard) among a side's slots, by id from start: flags them in effectStep.eligible; the index after them or -1.
 
void CARDGAME_openPanelsPhase (CardBattle *battle, CardBattleItems *items)
 Opens the panels for a phase.
 
static void runPlayerCardSets (CardBattle *battle)
 Runs effect step 0x19 for each set of three or more of one card among the player's slots (CARDGAME_findCardSet), then goes on to the opponent's.
 
static void runOpponentCardSets (CardBattle *battle)
 Runs effect step 0x1A for each set of three or more of one card among the opponent's slots (CARDGAME_findCardSet)
 
static void runKeptCardSteps (CardBattle *battle)
 Runs effect step 0x1B for the kept card (keptCard) until keptCount runs out.
 
static void checkEmptyRows (CardBattle *battle, CardScreen *screen)
 When a side has no slots left, the round ends at once, the higher total winning; else the round's result window opens.
 
static void pickRoundWinner (CardBattle *battle)
 Gives the round to the side with the higher total (pile.hpTotal) and runs its win's effect step (0x18 the player's, 0x17 the opponent's)
 
static void countRoundWin (CardBattle *battle, CardBattleItems *items, CardScreen *screen)
 Blinks the round winner's wins on its panel with a flash, then counts the win and shows the round's result.
 
static void waitRoundResultShown (CardBattle *battle, CardScreen *screen)
 Waits for the round's result: its window, or the draw message when the totals are equal.
 
static void closeRoundResult (CardBattle *battle, CardScreen *screen)
 Cross or Triangle closes the round's result window or message.
 
static void waitRoundResultClosed (CardBattle *battle, CardScreen *screen)
 Once the round's result is closed, opens message 19.
 
static void checkBattleWinner (CardBattle *battle, CardScreen *screen)
 Once a side has two wins, shows who won the battle; else goes on to the next round.
 
static void runRoundEndStep (CardBattle *battle)
 Runs the round's closing effect step: 0x1C after the player's win, 0x1D after the opponent's.
 
static void closeBattleResult (CardBattle *battle, CardScreen *screen)
 Cross or Triangle closes the battle's result: the player's win goes on to the prize, a loss ends it.
 
s32 CARDGAME_endRound (CardBattle *battle, CardBattleItems *items)
 The end of a round: shows both sides' cards, gives the round to the higher total (pile.hpTotal) and the battle to the first side with two rounds; 1 for the next round, 2 once the battle is over.
 
void CARDGAME_returnHandToDeck (CardPile *pile)
 Puts pile's hand back on top of its deck.
 
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 the next round (round)
 
void CARDGAME_startBattleMessage (CardBattle *battle, CardBattleItems *items)
 Starts the step of battle message prevPhase (CARDGAME_battleMessages)
 
void CARDGAME_initBattle (CardBattle *battle, CardBattleItems *items)
 Sets up a card battle: the sides' panels, no result, CARD_PHASE_FADE_IN.
 
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 the battle is over.
 
s32 CARDGAME_stepShowPanels (CardBattle *battle, CardBattleItems *items)
 Opens the panels once; 1 once they are open.
 
s32 CARDGAME_showPlayedCard (CardBattle *battle, CardBattleItems *items)
 Shows the last card played (record.plays) in window 2 for 35 frames (Cross cuts it short), then scales its sprite away; 1 once done.
 
static void checkPlayedCard (CardBattle *battle, CardBattleItems *items)
 When the played card's play condition holds, shows its message instead of its effects; else starts its effects.
 
static void runCardEffects (CardBattle *battle, CardBattleItems *items)
 Runs the played card's effect steps one after another, then clears its marks.
 
static void discardPlayedCard (CardBattle *battle)
 Puts the played card in its side's discards (unless it is card 13) and takes it (and the one before when that was discarded) off the record.
 
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's discards (pile.discards); 1 once done.
 
static void moveMenuCursor (CardBattle *battle, CardBattleItems *items)
 Up and Down move the menu's cursor (wrapping round its five rows), Cross picks the row, Triangle closes the menu.
 
static void openMenuChoice (CardBattle *battle, CardBattleItems *items)
 Once the menu is closed, goes to the picked row's help, back, or the quit question.
 
static void answerQuitQuestion (CardBattle *battle, CardBattleItems *items)
 The quit question: Up and Down choose yes or no, Cross answers, Triangle answers no.
 
s32 CARDGAME_runBattleMenu (CardBattle *battle, CardBattleItems *items)
 The battle menu (record.menuState its state): three help messages, back, and quitting after a yes/no question; 1 when closed, 2 to quit.
 
s32 CARDGAME_runBattle (CardBattle *battle, CardBattleItems *items)
 A frame of the card battle: the sprites' flags, the card animations, the fades, then the phase, the effect step, the card's resolution or the battle menu; 1 once it is over.
 
void CARDGAME_updateBattle (CardBattle *battle, CardBattleItems *items)
 The card battle task: sets up the battle and fades in, runs it (CARDGAME_runBattle), then fades out and gives the player the prize item for a win; result 2 once over.
 
CardBattle * CARDGAME_createBattle (s32 arg)
 Creates the card battle against opponent arg (CARDGAME_loadOpponent), with its functions, and loads its sound bank.
 

Detailed Description

CARDGAME's card battle (CARDGAME_createBattle): the opponent, the deck choice, the rounds, the plays and their results.

Definition in file battle.c.

Function Documentation

◆ CARDGAME_loadOpponent()

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 at line 7 of file battle.c.

Referenced by CARDGAME_updateBattle().

Here is the caller graph for this function:

◆ CARDGAME_sortOpponentHand()

void CARDGAME_sortOpponentHand ( CardBattle *  battle)

Sorts the opponent's hand by its cards' opponentPlans kind, then value.

Definition at line 71 of file battle.c.

Referenced by CARDGAME_runPutOut(), and playComputerTurn().

Here is the caller graph for this function:

◆ CARDGAME_findOpponentDeckLimits()

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 of its deck before the cards of kind 7

Definition at line 102 of file battle.c.

Referenced by CARDGAME_startNextRound(), and loadChosenDeck().

Here is the caller graph for this function:

◆ CARDGAME_returnOpponentHand()

void CARDGAME_returnOpponentHand ( CardBattle *  battle,
CardBattleItems *  items 
)

Puts side 1's hand back on its pile and renumbers the pile's cards.

Definition at line 120 of file battle.c.

Referenced by CARDGAME_startNextRound().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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 deckTop) as sprites in a row.

Definition at line 156 of file battle.c.

Referenced by CARDGAME_updateCardAnims().

Here is the caller graph for this function:

◆ CARDGAME_stepHidePanels()

s32 CARDGAME_stepHidePanels ( CardBattle *  battle,
CardBattleItems *  items 
)

Closes the panels once; 1 once they are closed.

Definition at line 213 of file battle.c.

Referenced by CARDGAME_endRound(), and CARDGAME_playRounds().

Here is the caller graph for this function:

◆ CARDGAME_startPileCount()

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 at line 228 of file battle.c.

Referenced by CARDGAME_updateCardAnims().

Here is the caller graph for this function:

◆ markPlayTargets()

static void markPlayTargets ( CardBattle *  battle,
CardScreen *  screen,
s32  play 
)
inlinestatic

Marks in each slot sprite's marks[play] whether play of record.plays applies to it, by the play's targetKind.

Definition at line 250 of file battle.c.

Referenced by CARDGAME_layOutSlots().

Here is the caller graph for this function:

◆ CARDGAME_layOutSlots()

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.plays (12 on), marking in marks[play] the slot sprites it applies to (markPlayTargets)

Definition at line 351 of file battle.c.

Referenced by CARDGAME_updateCardAnims().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARDGAME_startStepFade()

void CARDGAME_startStepFade ( CardBattle *  battle,
CardBattleItems *  items 
)

Starts the fade that fade asks for (CARDGAME_fadeColors)

Definition at line 404 of file battle.c.

Referenced by CARDGAME_runBattle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARDGAME_resetSpriteFlags()

void CARDGAME_resetSpriteFlags ( CardBattle *  battle)

Sets the 15 sprites' anim.dimmed to whether anim.dimAll is 2, once it is set.

Definition at line 425 of file battle.c.

Referenced by CARDGAME_runBattle().

Here is the caller graph for this function:

◆ showSlots()

static void showSlots ( CardBattle *  battle,
CardBattleItems *  items,
CardAnim *  anim 
)
inlinestatic

Scales the slots in, a pair every 4 frames, then shows the plays.

Definition at line 439 of file battle.c.

Referenced by CARDGAME_updateCardAnims().

Here is the caller graph for this function:

◆ showPlays()

static void showPlays ( CardBattle *  battle,
CardBattleItems *  items,
CardAnim *  anim 
)
inlinestatic

Scales the plays in, one every 4 frames, opening each one's gauge after it.

Definition at line 458 of file battle.c.

Referenced by CARDGAME_updateCardAnims().

Here is the caller graph for this function:

◆ hideSlots()

static void hideSlots ( CardBattle *  battle,
CardBattleItems *  items,
CardAnim *  anim 
)
inlinestatic

Scales the slots out, a pair every 4 frames, then hides the plays.

Definition at line 477 of file battle.c.

Referenced by CARDGAME_updateCardAnims().

Here is the caller graph for this function:

◆ hidePlays()

static void hidePlays ( CardBattle *  battle,
CardBattleItems *  items,
CardAnim *  anim 
)
inlinestatic

Scales the plays out with their gauges, one every 4 frames.

Definition at line 496 of file battle.c.

Referenced by CARDGAME_updateCardAnims().

Here is the caller graph for this function:

◆ showPile()

static void showPile ( CardAnim *  anim,
CardScreen *  screen 
)
inlinestatic

Scales a pile's cards in, one every 4 frames (at least one)

Definition at line 513 of file battle.c.

Referenced by CARDGAME_updateCardAnims().

Here is the caller graph for this function:

◆ hidePile()

static void hidePile ( CardAnim *  anim,
CardScreen *  screen 
)
inlinestatic

Scales a pile's cards out, one every 4 frames (at least one)

Definition at line 533 of file battle.c.

Referenced by CARDGAME_updateCardAnims().

Here is the caller graph for this function:

◆ CARDGAME_updateCardAnims()

void CARDGAME_updateCardAnims ( CardBattle *  battle,
CardBattleItems *  items 
)

Starts (anim.next) and runs (anim.current) the screen's card animations: the hands', the record's and a pile's sprites scaling in or out.

Definition at line 553 of file battle.c.

Referenced by CARDGAME_runBattle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARDGAME_showPanelValues()

void CARDGAME_showPanelValues ( CardBattle *  battle,
CardBattleItems *  items 
)

Shows both sides' values on their panels: the points of each colour, the deck, hand and discards, AP and HP.

Definition at line 675 of file battle.c.

Referenced by CARDGAME_prepareTurn(), CARDGAME_resolveCard(), CARDGAME_startNextRound(), and loadChosenDeck().

Here is the caller graph for this function:

◆ CARDGAME_sortCards()

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 bit 0) and effectStep.eligible (bit 1) with them.

Definition at line 693 of file battle.c.

Referenced by CARDGAME_createBattle().

Here is the caller graph for this function:

◆ CARDGAME_shufflePile()

void CARDGAME_shufflePile ( CardBattle *  battle,
s32  base,
s32  n 
)

Shuffles the player's pile's deck[base..base + n) with 40 random swaps.

Definition at line 730 of file battle.c.

Referenced by CARDGAME_createBattle().

Here is the caller graph for this function:

◆ waitPhaseStep()

static void waitPhaseStep ( CardBattle *  battle,
s32  frames 
)
inlinestatic

Goes to the next phaseStep after frames frames.

Definition at line 749 of file battle.c.

Referenced by CARDGAME_chooseDeck().

Here is the caller graph for this function:

◆ openDeckWindow()

static void openDeckWindow ( CardBattle *  battle,
CardBattleItems *  items,
s32  index 
)
inlinestatic

Opens deck window index with its sound.

< SYSTEM03

Definition at line 758 of file battle.c.

Referenced by CARDGAME_chooseDeck().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ closeDeckWindow()

static void closeDeckWindow ( CardBattle *  battle,
CardBattleItems *  items,
s32  index 
)
inlinestatic

Closes deck window index with its sound.

< SYSTEM04

Definition at line 766 of file battle.c.

Referenced by CARDGAME_chooseDeck().

Here is the caller graph for this function:

◆ moveDeckMarker()

static void moveDeckMarker ( CardBattle *  battle,
CardBattleItems *  items 
)
inlinestatic

Up and Down move the marker between the three decks; Cross picks the marked one, which blinks.

< SYSTEM06

< SYSTEM06

< SYSTEM07

Definition at line 775 of file battle.c.

Referenced by CARDGAME_chooseDeck().

Here is the caller graph for this function:

◆ loadChosenDeck()

static void loadChosenDeck ( CardBattle *  battle,
CardBattleItems *  items 
)
inlinestatic

Loads the chosen deck (or the default one when it is empty) and the opponent's, fills both piles and shuffles the player's.

Definition at line 800 of file battle.c.

Referenced by CARDGAME_chooseDeck().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARDGAME_chooseDeck()

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, then loads both decks' cards; 1 once done.

< SYSTEM03

Definition at line 830 of file battle.c.

Referenced by CARDGAME_runPhase().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARDGAME_runFirstPick()

s32 CARDGAME_runFirstPick ( CardBattle *  battle,
CardBattleItems *  items 
)

Runs step 0xA7 (CARDGAME_startFirstPick) and then keeps who goes first (firstStarter); 1 once done.

Definition at line 927 of file battle.c.

Referenced by CARDGAME_runPhase().

Here is the caller graph for this function:

◆ CARDGAME_runStartStep()

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 short, 3 the opponent's.

Definition at line 947 of file battle.c.

Referenced by CARDGAME_runPhase().

Here is the caller graph for this function:

◆ CARDGAME_takeFlaggedCard()

s32 CARDGAME_takeFlaggedCard ( CardBattle *  battle,
CardBattleItems *  items 
)

Takes the first flagged card out of the hand of side record.turnSide into the play record.plays[playCount]; returns its condition id.

Definition at line 971 of file battle.c.

Referenced by playComputerTurn(), and takePickedCard().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARDGAME_flagTargetSlots()

void CARDGAME_flagTargetSlots ( CardBattle *  battle,
CardScreen *  screen 
)

Flags (effectStep.marked) the slots that the current play's target kind (record.plays[playCount].targetKind) picks.

Definition at line 997 of file battle.c.

Referenced by playComputerTurn().

Here is the caller graph for this function:

◆ startRounds()

static void startRounds ( CardBattle *  battle,
CardBattleItems *  items 
)
inlinestatic

Starts the rounds: clears the record, shows the slots and opens the panels.

Definition at line 1091 of file battle.c.

Referenced by CARDGAME_playRounds().

Here is the caller graph for this function:

◆ startPlay()

static void startPlay ( CardBattle *  battle,
CardBattleItems *  items 
)
inlinestatic

Picks the side that plays next, by the starter and the plays so far, or once three cards are played resolves them.

Definition at line 1106 of file battle.c.

Referenced by CARDGAME_playRounds().

Here is the caller graph for this function:

◆ playComputerTurn()

static void playComputerTurn ( CardBattle *  battle,
CardBattleItems *  items 
)
inlinestatic

The computer plays a card (CARDGAME_pickComputerCard); without one it passes when it would play first, else the plays resolve.

< SYSTEM03

< SYSTEM03

Definition at line 1137 of file battle.c.

Referenced by CARDGAME_playRounds().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ playPlayerTurn()

static void playPlayerTurn ( CardBattle *  battle,
CardBattleItems *  items 
)
inlinestatic

The player picks a card to play (effect step 0x98); without one they pass when they would play first, else the plays resolve.

< SYSTEM03

Definition at line 1170 of file battle.c.

Referenced by CARDGAME_playRounds().

Here is the caller graph for this function:

◆ takePickedCard()

static void takePickedCard ( CardBattle *  battle,
CardBattleItems *  items 
)
inlinestatic

Takes the picked card into the play and runs its condition's step: when it holds the card is played, else it goes back to the hand.

Definition at line 1194 of file battle.c.

Referenced by CARDGAME_playRounds().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ startNextTurn()

static void startNextTurn ( CardBattle *  battle)
inlinestatic

Starts the next turn, the other side starting; after two passes the rounds end (state 15)

Definition at line 1214 of file battle.c.

Referenced by CARDGAME_playRounds().

Here is the caller graph for this function:

◆ CARDGAME_playRounds()

s32 CARDGAME_playRounds ( CardBattle *  battle,
CardBattleItems *  items 
)

Runs the rounds of plays (state record.turnState): each side in turn plays a card, the computer through CARDGAME_pickComputerCard; 1 once over.

Definition at line 1230 of file battle.c.

Referenced by CARDGAME_runPhase().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARDGAME_prepareTurn()

void CARDGAME_prepareTurn ( CardBattle *  battle,
CardBattleItems *  items 
)

Clears record.turnState, shows the panel values and sorts the player's hand.

Definition at line 1336 of file battle.c.

Referenced by CARDGAME_runPhase().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARDGAME_removeMarkedHandCards()

void CARDGAME_removeMarkedHandCards ( CardBattle *  battle,
CardPile *  pile 
)

Takes the marked cards (effectStep.marked) out of pile's hand.

Definition at line 1343 of file battle.c.

Referenced by CARDGAME_putOutCards().

Here is the caller graph for this function:

◆ CARDGAME_setSlot()

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 at line 1359 of file battle.c.

Referenced by CARDGAME_addCard().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARDGAME_addCard()

void CARDGAME_addCard ( CardBattle *  battle,
s32  side,
s32  card 
)

CardBattle.addCard: puts card in side's next slot.

Definition at line 1376 of file battle.c.

Referenced by CARDGAME_createBattle(), and CARDGAME_putOutCards().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARDGAME_putOutCards()

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 at line 1383 of file battle.c.

Referenced by CARDGAME_createBattle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARDGAME_setCountingCardValues()

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 counts (0 to 99)

Definition at line 1398 of file battle.c.

Referenced by CARDGAME_setAllCountingValues(), and CARDGAME_takeHandCard().

Here is the caller graph for this function:

◆ CARDGAME_setAllCountingValues()

s32 CARDGAME_setAllCountingValues ( CardBattle *  battle)

Sets the values of the counting cards out, pass by pass (CARDGAME_setCountingCardValues); whether any card is out.

Definition at line 1443 of file battle.c.

Referenced by CARDGAME_resolveCard(), and CARDGAME_runPutOut().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARDGAME_sumSlotValues()

void CARDGAME_sumSlotValues ( CardBattle *  battle,
s32  side 
)

Side's apTotal and hpTotal become the sums of its slot cards' ap and hp.

Definition at line 1463 of file battle.c.

Referenced by CARDGAME_runPutOut().

Here is the caller graph for this function:

◆ CARDGAME_runPutOut()

s32 CARDGAME_runPutOut ( CardBattle *  battle,
CardBattleItems *  items 
)

A battle step: each side puts out its flagged cards (putOutCards) between messages 0x9A, 0x9D and 0x9E; 1 once done.

Definition at line 1475 of file battle.c.

Referenced by CARDGAME_runPhase().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARDGAME_findCardSet()

s32 CARDGAME_findCardSet ( CardBattle *  battle,
s32  side,
s32  start 
)

Finds three or more of one card (with a CardImage.comboCard) among a side's slots, by id from start: flags them in effectStep.eligible; the index after them or -1.

Definition at line 1516 of file battle.c.

Referenced by runOpponentCardSets(), and runPlayerCardSets().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARDGAME_openPanelsPhase()

void CARDGAME_openPanelsPhase ( CardBattle *  battle,
CardBattleItems *  items 
)

Opens the panels for a phase.

Definition at line 1570 of file battle.c.

Referenced by CARDGAME_runPhase().

Here is the caller graph for this function:

◆ runPlayerCardSets()

static void runPlayerCardSets ( CardBattle *  battle)
inlinestatic

Runs effect step 0x19 for each set of three or more of one card among the player's slots (CARDGAME_findCardSet), then goes on to the opponent's.

Definition at line 1579 of file battle.c.

Referenced by CARDGAME_endRound().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ runOpponentCardSets()

static void runOpponentCardSets ( CardBattle *  battle)
inlinestatic

Runs effect step 0x1A for each set of three or more of one card among the opponent's slots (CARDGAME_findCardSet)

Definition at line 1592 of file battle.c.

Referenced by CARDGAME_endRound().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ runKeptCardSteps()

static void runKeptCardSteps ( CardBattle *  battle)
inlinestatic

Runs effect step 0x1B for the kept card (keptCard) until keptCount runs out.

Definition at line 1604 of file battle.c.

Referenced by CARDGAME_endRound().

Here is the caller graph for this function:

◆ checkEmptyRows()

static void checkEmptyRows ( CardBattle *  battle,
CardScreen *  screen 
)
inlinestatic

When a side has no slots left, the round ends at once, the higher total winning; else the round's result window opens.

Definition at line 1619 of file battle.c.

Referenced by CARDGAME_endRound().

Here is the caller graph for this function:

◆ pickRoundWinner()

static void pickRoundWinner ( CardBattle *  battle)
inlinestatic

Gives the round to the side with the higher total (pile.hpTotal) and runs its win's effect step (0x18 the player's, 0x17 the opponent's)

Definition at line 1639 of file battle.c.

Referenced by CARDGAME_endRound().

Here is the caller graph for this function:

◆ countRoundWin()

static void countRoundWin ( CardBattle *  battle,
CardBattleItems *  items,
CardScreen *  screen 
)
inlinestatic

Blinks the round winner's wins on its panel with a flash, then counts the win and shows the round's result.

Definition at line 1654 of file battle.c.

Referenced by CARDGAME_endRound().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ waitRoundResultShown()

static void waitRoundResultShown ( CardBattle *  battle,
CardScreen *  screen 
)
inlinestatic

Waits for the round's result: its window, or the draw message when the totals are equal.

Definition at line 1688 of file battle.c.

Referenced by CARDGAME_endRound().

Here is the caller graph for this function:

◆ closeRoundResult()

static void closeRoundResult ( CardBattle *  battle,
CardScreen *  screen 
)
inlinestatic

Cross or Triangle closes the round's result window or message.

Definition at line 1702 of file battle.c.

Referenced by CARDGAME_endRound().

Here is the caller graph for this function:

◆ waitRoundResultClosed()

static void waitRoundResultClosed ( CardBattle *  battle,
CardScreen *  screen 
)
inlinestatic

Once the round's result is closed, opens message 19.

Definition at line 1714 of file battle.c.

Referenced by CARDGAME_endRound().

Here is the caller graph for this function:

◆ checkBattleWinner()

static void checkBattleWinner ( CardBattle *  battle,
CardScreen *  screen 
)
inlinestatic

Once a side has two wins, shows who won the battle; else goes on to the next round.

< W_JINGLE: a battle won

Definition at line 1730 of file battle.c.

Referenced by CARDGAME_endRound().

Here is the caller graph for this function:

◆ runRoundEndStep()

static void runRoundEndStep ( CardBattle *  battle)
inlinestatic

Runs the round's closing effect step: 0x1C after the player's win, 0x1D after the opponent's.

Definition at line 1749 of file battle.c.

Referenced by CARDGAME_endRound().

Here is the caller graph for this function:

◆ closeBattleResult()

static void closeBattleResult ( CardBattle *  battle,
CardScreen *  screen 
)
inlinestatic

Cross or Triangle closes the battle's result: the player's win goes on to the prize, a loss ends it.

Definition at line 1761 of file battle.c.

Referenced by CARDGAME_endRound().

Here is the caller graph for this function:

◆ CARDGAME_endRound()

s32 CARDGAME_endRound ( CardBattle *  battle,
CardBattleItems *  items 
)

The end of a round: shows both sides' cards, gives the round to the higher total (pile.hpTotal) and the battle to the first side with two rounds; 1 for the next round, 2 once the battle is over.

Definition at line 1774 of file battle.c.

Referenced by CARDGAME_runPhase().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARDGAME_returnHandToDeck()

void CARDGAME_returnHandToDeck ( CardPile *  pile)

Puts pile's hand back on top of its deck.

Definition at line 1891 of file battle.c.

Referenced by CARDGAME_startNextRound().

Here is the caller graph for this function:

◆ CARDGAME_startNextRound()

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 the next round (round)

Definition at line 1900 of file battle.c.

Referenced by CARDGAME_runPhase().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARDGAME_startBattleMessage()

void CARDGAME_startBattleMessage ( CardBattle *  battle,
CardBattleItems *  items 
)

Starts the step of battle message prevPhase (CARDGAME_battleMessages)

Definition at line 1923 of file battle.c.

Referenced by CARDGAME_runPhase().

Here is the caller graph for this function:

◆ CARDGAME_initBattle()

void CARDGAME_initBattle ( CardBattle *  battle,
CardBattleItems *  items 
)

Sets up a card battle: the sides' panels, no result, CARD_PHASE_FADE_IN.

Definition at line 1932 of file battle.c.

Referenced by CARDGAME_updateBattle().

Here is the caller graph for this function:

◆ CARDGAME_runPhase()

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 the battle is over.

Definition at line 1941 of file battle.c.

Referenced by CARDGAME_runBattle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARDGAME_stepShowPanels()

s32 CARDGAME_stepShowPanels ( CardBattle *  battle,
CardBattleItems *  items 
)

Opens the panels once; 1 once they are open.

Definition at line 2043 of file battle.c.

Referenced by CARDGAME_resolveCard().

Here is the caller graph for this function:

◆ CARDGAME_showPlayedCard()

s32 CARDGAME_showPlayedCard ( CardBattle *  battle,
CardBattleItems *  items 
)

Shows the last card played (record.plays) in window 2 for 35 frames (Cross cuts it short), then scales its sprite away; 1 once done.

Definition at line 2059 of file battle.c.

Referenced by CARDGAME_resolveCard().

Here is the caller graph for this function:

◆ checkPlayedCard()

static void checkPlayedCard ( CardBattle *  battle,
CardBattleItems *  items 
)
inlinestatic

When the played card's play condition holds, shows its message instead of its effects; else starts its effects.

Definition at line 2123 of file battle.c.

Referenced by CARDGAME_resolveCard().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ runCardEffects()

static void runCardEffects ( CardBattle *  battle,
CardBattleItems *  items 
)
inlinestatic

Runs the played card's effect steps one after another, then clears its marks.

Definition at line 2138 of file battle.c.

Referenced by CARDGAME_resolveCard().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ discardPlayedCard()

static void discardPlayedCard ( CardBattle *  battle)
inlinestatic

Puts the played card in its side's discards (unless it is card 13) and takes it (and the one before when that was discarded) off the record.

Definition at line 2160 of file battle.c.

Referenced by CARDGAME_resolveCard().

Here is the caller graph for this function:

◆ CARDGAME_resolveCard()

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's discards (pile.discards); 1 once done.

Definition at line 2182 of file battle.c.

Referenced by CARDGAME_runBattle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ moveMenuCursor()

static void moveMenuCursor ( CardBattle *  battle,
CardBattleItems *  items 
)
inlinestatic

Up and Down move the menu's cursor (wrapping round its five rows), Cross picks the row, Triangle closes the menu.

< SYSTEM02: a cursor moves

< SYSTEM02: a cursor moves

< SYSTEM01

Definition at line 2291 of file battle.c.

Referenced by CARDGAME_runBattleMenu().

Here is the caller graph for this function:

◆ openMenuChoice()

static void openMenuChoice ( CardBattle *  battle,
CardBattleItems *  items 
)
inlinestatic

Once the menu is closed, goes to the picked row's help, back, or the quit question.

Definition at line 2321 of file battle.c.

Referenced by CARDGAME_runBattleMenu().

Here is the caller graph for this function:

◆ answerQuitQuestion()

static void answerQuitQuestion ( CardBattle *  battle,
CardBattleItems *  items 
)
inlinestatic

The quit question: Up and Down choose yes or no, Cross answers, Triangle answers no.

< SYSTEM02: a cursor moves

< SYSTEM02: a cursor moves

< SYSTEM01

Definition at line 2346 of file battle.c.

Referenced by CARDGAME_runBattleMenu().

Here is the caller graph for this function:

◆ CARDGAME_runBattleMenu()

s32 CARDGAME_runBattleMenu ( CardBattle *  battle,
CardBattleItems *  items 
)

The battle menu (record.menuState its state): three help messages, back, and quitting after a yes/no question; 1 when closed, 2 to quit.

Definition at line 2372 of file battle.c.

Referenced by CARDGAME_runBattle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARDGAME_runBattle()

s32 CARDGAME_runBattle ( CardBattle *  battle,
CardBattleItems *  items 
)

A frame of the card battle: the sprites' flags, the card animations, the fades, then the phase, the effect step, the card's resolution or the battle menu; 1 once it is over.

Definition at line 2448 of file battle.c.

Referenced by CARDGAME_updateBattle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARDGAME_updateBattle()

void CARDGAME_updateBattle ( CardBattle *  battle,
CardBattleItems *  items 
)

The card battle task: sets up the battle and fades in, runs it (CARDGAME_runBattle), then fades out and gives the player the prize item for a win; result 2 once over.

< CBTLMAIN: the card battles

< W_JINGLE: a battle won

< CBTLMAIN: the card battles

Definition at line 2484 of file battle.c.

Referenced by CARDGAME_createBattle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CARDGAME_createBattle()

CardBattle * CARDGAME_createBattle ( s32  arg)

Creates the card battle against opponent arg (CARDGAME_loadOpponent), with its functions, and loads its sound bank.

Definition at line 2554 of file battle.c.

Referenced by CARDGAME_updateScene().

Here is the call graph for this function:
Here is the caller graph for this function: