14 for (i = 0; i < 40; i++) {
17 if (i < pile->handCount) {
30 if (pile->
side == 0) {
47 for (i = 0; i < 40; i++) {
288 if (pile->
side == 0) {
315 screen->
openWindow(screen, 2, 1, 0, 0x82, 0xA5);
316 screen->
openWindow(screen, 4, 2, 0, 0x86, 0x31);
317 screen->
openWindow(screen, 3, 1, 0, 0x82, 0x90);
318 screen->
openWindow(screen, 1, 3, 0, 0xFD, 0x90);
320 screen->
openWindow(screen, 5, 4, 0x24, 0, 0x14);
322 if (pile->
side == 0) {
338 if (pile->
side != 0) {
370 if (pile->
side == 0) {
465 screen->
openWindow(screen, 4, 2, 0, 0x86, 0x31);
466 screen->
openWindow(screen, 5, 4, 0x24, 0, 0x14);
530 if (pile->
side == 0) {
579 screen->
startSlide(screen, 0, 5, 0x1800, 0x5C00);
589 screen->
startSlide(screen, 0, 5, 0x1800, 0x5C00);
780 }
else if (counting) {
812 screen->
openWindow(screen, 5, 5, entry[0], 0, 0x42);
866 screen->
addSprite(screen, 0, 0x7400, 0x6100);
867 screen->
addSprite(screen, 1, 0xA400, 0x6100);
898 screen->
scaleSprite(screen, 0, 10, 0x1000, 0x1000);
901 screen->
scaleSprite(screen, 1, 10, 0x1000, 0x1000);
907 screen->
startSlide(screen, 0, 5, 0x7400, 0x5C00);
940#if VERSION_EU || VERSION_JP
949#elif VERSION_EU || VERSION_JP
956#elif VERSION_EU || VERSION_JP
964#if VERSION_EU || VERSION_JP
CARDGAME.PRO: the card battle (mode 0x700).
void initCardDrawer(CardDrawer *obj)
Clears a card drawer, gives it its methods and binds it.
#define CARD_ANIM_UNDIM_ALL
CardAnim.dimAll.
@ CARD_ANIM_SHOW_HAND
the player's piles...
@ CARD_ANIM_HIDE_OPPONENT_HAND
@ CARD_ANIM_SHOW_OPPONENT_HAND
...and the opponent's
s32 CARDGAME_coinCardPositions[][2]
the two cards' x, y (CARDGAME_startFirstPick)
u8 CARDGAME_stepMessages[][2]
CARDGAME_startStepMessage's text for window 5 and what screen->openMessage shows, by message.
s32 CARDGAME_promptText
the text of window 0
GfxState GFX
GFX: the graphics state and its methods.
void CARDGAME_movePileSelection(CardBattle *battle, CardScreen *screen, CardPile *pile, s32 step)
Moves the selection by STEP among the cards of PILE's hand: the selected card is raised.
s32 CARDGAME_drawFirstPlayer(CardBattle *battle, CardScreen *screen)
The draw for who goes first: the two face-down cards open, the player picks one with left/right and c...
s32 CARDGAME_stepPulseCard(CardBattle *battle, CardScreen *screen)
Scales the highlighted sprite up to 1.25 and back, 5 frames each; 1 once done.
void CARDGAME_readPickInput(CardBattle *battle, CardScreen *screen, CardPile *pile)
Reads the pad while cards of PILE's hand are being picked: Left/Right move, Cross picks or puts back,...
static void readConfirmInput(CardBattle *battle, CardScreen *screen)
The answer to the confirm message: yes (effectStep.choice 0) ends the choice (state 8),...
void CARDGAME_flagPlayableCards(CardBattle *battle, CardScreen *screen, CardPile *pile)
Flags (effectStep.eligible) the cards of pile's hand that can be played and aren't picked (effectStep...
s32 CARDGAME_stepMessage(CardBattle *battle, CardScreen *screen)
Waits for window 5 to open, then for Cross or Triangle to close it; 1 once it has closed.
void CARDGAME_readChooseInput(CardBattle *battle, CardScreen *screen, CardPile *pile)
Reads the pad while a card of PILE's hand is being chosen: Left/Right move, Cross picks,...
void CARDGAME_moveSelection(CardBattle *battle, CardScreen *screen, s32 count, s32 step)
Moves the selection by STEP among COUNT cards: the selected card is raised.
void CARDGAME_startStepMessage(CardBattle *battle, CardScreen *screen, s32 index)
Shows CARDGAME_stepMessages[index]: its message and window 5.
static void backToChoosing(CardBattle *battle, CardScreen *screen, CardPile *pile)
After a no to the confirm message: reopens the choice's windows, then lifts the highlighted card agai...
static void hideHandForMenu(CardBattle *battle, CardScreen *screen, CardPile *pile)
Hides the hand and the choice's windows for the battle menu.
static void showChosenCards(CardBattle *battle, CardScreen *screen, CardPile *pile)
The chosen cards pulse with a sound, then the hand and its windows close.
void CARDGAME_startFirstPick(CardBattle *battle, CardScreen *screen)
Who goes first: cards 0x57 and 0x58 face down, in a random order.
static void askToConfirm(CardBattle *battle, CardScreen *screen, CardPile *pile)
Puts the highlighted card back in the hand and opens the confirm message.
s32 CARDGAME_stepTally(CardBattle *battle, CardScreen *screen)
Turns the opponent's slot cards over, then counts the panels' ap and hp up to each side's pile apTota...
void CARDGAME_switchCoinCard(CardBattle *battle, CardScreen *screen)
Moves the selection to the other one of the two cards that CARDGAME_startFirstPick lays out.
s32 CARDGAME_isHandPickDone(CardBattle *battle, CardScreen *screen, CardPile *pile)
Whether the pick is over: six cards picked (effectStep.count), or none left that can be played.
s32 CARDGAME_stepChooseCards(CardBattle *battle, CardScreen *screen, CardPile *pile)
Choosing cards of PILE's hand to play: effectStep.nextState queues the next step (startChooseState).
static void resumeChoosing(CardBattle *battle, CardScreen *screen, CardPile *pile)
Back from the battle menu: once the hand is shown again, choosing goes on with the picked cards highl...
void CARDGAME_startPick(CardBattle *battle, CardScreen *screen, s32 all, s32 mode)
Starts a pick of the cards (all when all > 0) in mode (anim.next)
void CARDGAME_startPanelsStep(CardBattle *battle, CardScreen *screen)
Opens the panels for a step.
void CARDGAME_startHandPick(CardBattle *battle, CardScreen *screen, CardPile *pile)
Starts a pick from pile's hand: flags (effectStep.eligible) the cards that can be played,...
static void showHandAfterMenu(CardBattle *battle, CardScreen *screen, CardPile *pile)
Back from the battle menu: shows the hand again, the cards that can't be played dimmed,...
s32 CARDGAME_togglePick(CardBattle *battle, CardScreen *screen, CardPile *pile)
Picks or puts back the selected card of PILE's hand: 1 picked, 2 put back, 0 neither.
void CARDGAME_readCountInput(CardBattle *battle, CardScreen *screen, s32 count)
Reads the pad while one of COUNT cards is being chosen: Left/Right move, Triangle cancels.
static void startChooseState(CardBattle *battle, CardScreen *screen, CardPile *pile)
Starts the state of the card choice effectStep.nextState asks for: its prompt, windows and dimmed car...
void CARDGAME_addCardPoints(CardBattle *battle, CardScreen *screen, CardPile *pile, s32 add, s32 card)
Adds a card's points to pile's points of its colour (takes them when add is 0), on the panel.
PadState PAD
Controller input: cleared by initPad, then the methods.
#define PAD_PRESSED(button)
One button of pad 1: newly pressed, auto-repeated while held, or held.
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...
void CARDGAME_showCardInfo(CardBattle *battle, CardScreen *screen, s32 offset)
Fills the information windows with the card of sprite offset + effectStep.cursor (the highlighted one...
void CARDGAME_clearCardInfo(CardBattle *battle, CardScreen *screen)
Empties the card information windows 1-4.
s32 CARDGAME_openStepWindows(CardBattle *battle, CardScreen *screen, s32 layout, s32 text, s32 time, s32 step)
Opens the windows of the step CARDGAME_windowSteps[step] once its time is past; the next step.
SoundState SOUND
rsin and rcos (libgte) read rsin_tbl[a - 0x800] and the like: their addresses before the table fall i...
#define SOUND_COUNT
SYSTEM10: a number counts up or down.
#define SOUND_MENU_CONFIRM
SYSTEM07.
#define SOUND_MENU_OPEN
SYSTEM03.
#define SOUND_MENU_CANCEL
SYSTEM01.
#define SOUND_MENU_MOVE
SYSTEM06.
#define SOUND_CURSOR
SYSTEM02: a cursor moves.
s32 count
the pile's cards
u8 faceDown
the next pile or slots are laid out face down
u8 dimAll
sets dimmed of the first 15 sprites once
u8 hide
the one that hides what the last one showed
The card battle (CARDGAME_createBattle).
u8 run
what runs this frame (CARD_RUN_*)
s16 cards[250]
card ids, minus one (CARDGAME_loadCardImages)
Draws the cards' images (CardImage), from files 0x7E7-0x7EB.
u8 points
what it adds to its colour
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
u8 points[5]
one per card colour
s16 apTotal
the sum of its slot cards' ap, which comes off the other side's hpTotal
s16 hand[10]
handCount in use
u8 menuState
CARDGAME_runBattleMenu's state.
The battle screen (created by CARDGAME_createScreen): the two panels, the cards on the table and the ...
void(* setSpriteCard)(struct CardScreen *screen, s32 sprite, s32 index)
void(* openWindow)(struct CardScreen *screen, s32 index, s16 layout, s32 value, s32 x, s32 y)
void(* closePanel)(struct CardScreen *screen, s32 side)
void(* setPanelValue)(struct CardScreen *screen, s32 side, u32 which, s32 value)
void(* scaleSprite)(struct CardScreen *screen, s32 index, s32 duration, s32 scaleX, s32 scaleY)
void(* startMove)(struct CardScreen *screen, s32 index, s32 duration, s32 x, s32 y)
void(* resetPanels)(struct CardScreen *screen)
void(* openPanels)(struct CardScreen *screen)
void(* setMessageChoice)(struct CardScreen *screen, s32 choice)
void(* openMessage)(struct CardScreen *screen, s32 message, s32 prompt, s16 choice, s32 place)
s32(* getHandOffset)(s32 count, s32 index)
void(* confirmMessage)(struct CardScreen *screen)
void(* closePanels)(struct CardScreen *screen)
void(* closeMessage)(struct CardScreen *screen)
void(* closeWindow)(struct CardScreen *screen, s32 index)
s32(* startBlink)(struct CardScreen *screen, s32 index)
s32(* startFlip)(struct CardScreen *screen, s32 index)
s32(* addSprite)(struct CardScreen *screen, s32 index, s32 x, s32 y)
void(* startSlide)(struct CardScreen *screen, s32 index, s32 duration, s32 x, s32 y)
void(* openPanel)(struct CardScreen *screen, s32 side)
u8 highlight
bit 0 the cursor, bit 1 picked, bit 2 glowing
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
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
s32 value
by its layout: a string, a card, or points | colour << 4
s32(* getFrameTime)(void)
s32(* getRepeated)(s32 pad)
s32(* getButtonBit)(s32 pad, s32 button)
s32(* getPressed)(s32 pad)
s32(* next)(void)
0 to RANDOM_COUNT - 1
short(* playSound)(s32 id)
returns the voice of a key-on