summaryrefslogtreecommitdiff
path: root/src/engine/bank01.asm
diff options
context:
space:
mode:
authordannye <33dannye@gmail.com>2021-01-06 22:01:30 -0600
committerdannye <33dannye@gmail.com>2021-01-06 22:01:30 -0600
commit0dc8af64aab2658a882f73d34bd7a5cc6563f7a1 (patch)
treee9b1a552f849a7c4bef055725b018937b3f5c56c /src/engine/bank01.asm
parentfec3f3580a54dbaa3dfb138398c92b37d6c58dee (diff)
parenta99feeb46f165fd7c4419811be4b3f591d8f1dad (diff)
Merge branch 'anims' of https://github.com/ElectroDeoxys/poketcg
Diffstat (limited to 'src/engine/bank01.asm')
-rw-r--r--src/engine/bank01.asm408
1 files changed, 250 insertions, 158 deletions
diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm
index 572109f..2c2a23f 100644
--- a/src/engine/bank01.asm
+++ b/src/engine/bank01.asm
@@ -183,16 +183,18 @@ MainDuelLoop: ; 40ee (1:40ee)
pop af
ldh [hWhoseTurn], a
call Func_3b21
+
+; animate the duel result screen
+; load the correct music and animation depending on result
ld a, [wDuelFinished]
cp TURN_PLAYER_WON
jr z, .active_duelist_won_battle
cp TURN_PLAYER_LOST
jr z, .active_duelist_lost_battle
- ld a, $5f
+ ld a, DUEL_ANIM_DUEL_DRAW
ld c, MUSIC_MATCH_DRAW
ldtx hl, DuelWasADrawText
jr .handle_duel_finished
-
.active_duelist_won_battle
ldh a, [hWhoseTurn]
cp PLAYER_TURN
@@ -200,11 +202,10 @@ MainDuelLoop: ; 40ee (1:40ee)
.player_won_battle
xor a ; DUEL_WIN
ld [wDuelResult], a
- ld a, $5d
+ ld a, DUEL_ANIM_DUEL_WIN
ld c, MUSIC_MATCH_VICTORY
ldtx hl, WonDuelText
jr .handle_duel_finished
-
.active_duelist_lost_battle
ldh a, [hWhoseTurn]
cp PLAYER_TURN
@@ -212,7 +213,7 @@ MainDuelLoop: ; 40ee (1:40ee)
.opponent_won_battle
ld a, DUEL_LOSS
ld [wDuelResult], a
- ld a, $5e
+ ld a, DUEL_ANIM_DUEL_LOSS
ld c, MUSIC_MATCH_LOSS
ldtx hl, LostDuelText
@@ -1491,7 +1492,7 @@ DisplayDrawNCardsScreen: ; 4935 (1:4935)
call DrawWideTextBox_PrintText
call EnableLCD
.anim_drawing_cards_loop
- call Func_49a8
+ call PlayTurnDuelistDrawAnimation
ld hl, wNumCardsBeingDrawn
inc [hl]
call PrintNumberOfHandAndDeckCards
@@ -1512,23 +1513,26 @@ DisplayDrawNCardsScreen: ; 4935 (1:4935)
pop hl
ret
-Func_49a8: ; 49a8 (1:49a8)
+; animates the screen for Turn Duelist drawing a card
+PlayTurnDuelistDrawAnimation: ; 49a8 (1:49a8)
call Func_3b21
- ld e, $56
+ ld e, DUEL_ANIM_PLAYER_DRAW
ldh a, [hWhoseTurn]
cp PLAYER_TURN
- jr z, .asm_49b5
- ld e, $57
-.asm_49b5
+ jr z, .got_duelist
+ ld e, DUEL_ANIM_OPP_DRAW
+.got_duelist
ld a, e
call Func_3b6a
-.asm_49b9
+
+.loop_anim
call DoFrame
call CheckSkipDelayAllowed
- jr c, .asm_49c6
+ jr c, .done_anim
call CheckAnyAnimationPlaying
- jr c, .asm_49b9
-.asm_49c6
+ jr c, .loop_anim
+
+.done_anim
call Func_3b31
ret
@@ -1749,7 +1753,7 @@ Func_4b60: ; 4b60 (1:4b60)
call SwapTurn
call InitializeDuelVariables
call SwapTurn
- call Func_4e84
+ call PlayShuffleAndDrawCardsAnimation_BothDuelists
call ShuffleDeckAndDrawSevenCards
ldh [hTemp_ffa0], a
call SwapTurn
@@ -1771,7 +1775,7 @@ Func_4b60: ; 4b60 (1:4b60)
.ensure_player_basic_pkmn_loop
call DisplayNoBasicPokemonInHandScreenAndText
call InitializeDuelVariables
- call Func_4e6e
+ call PlayShuffleAndDrawCardsAnimation_TurnDuelist
call ShuffleDeckAndDrawSevenCards
jr c, .ensure_player_basic_pkmn_loop
jr .hand_cards_ok
@@ -1781,7 +1785,7 @@ Func_4b60: ; 4b60 (1:4b60)
.ensure_opp_basic_pkmn_loop
call DisplayNoBasicPokemonInHandScreenAndText
call InitializeDuelVariables
- call Func_4e6e
+ call PlayShuffleAndDrawCardsAnimation_TurnDuelist
call ShuffleDeckAndDrawSevenCards
jr c, .ensure_opp_basic_pkmn_loop
call SwapTurn
@@ -2170,31 +2174,37 @@ DisplayPracticeDuelPlayerHandScreen: ; 4e40 (1:4e40)
call EnableLCD
ret
-Func_4e6e: ; 4e6e (1:4e6e)
- ld b, $51
- ld c, $56
+PlayShuffleAndDrawCardsAnimation_TurnDuelist: ; 4e6e (1:4e6e)
+ ld b, DUEL_ANIM_PLAYER_SHUFFLE
+ ld c, DUEL_ANIM_PLAYER_DRAW
ldh a, [hWhoseTurn]
cp PLAYER_TURN
- jr z, .asm_4e7c
- ld b, $52
- ld c, $57
-.asm_4e7c
+ jr z, .play_anim
+ ld b, DUEL_ANIM_OPP_SHUFFLE
+ ld c, DUEL_ANIM_OPP_DRAW
+.play_anim
ldtx hl, ShufflesTheDeckText
ldtx de, Drew7CardsText
- jr Func_4e98
+ jr PlayShuffleAndDrawCardsAnimation
-Func_4e84: ; 4e84 (1:4e84)
- ld b, $53
- ld c, $55
+PlayShuffleAndDrawCardsAnimation_BothDuelists: ; 4e84 (1:4e84)
+ ld b, DUEL_ANIM_BOTH_SHUFFLE
+ ld c, DUEL_ANIM_BOTH_DRAW
ldtx hl, EachPlayerShuffleOpponentsDeckText
ldtx de, EachPlayerDraw7CardsText
ld a, [wDuelType]
cp DUELTYPE_PRACTICE
- jr nz, Func_4e98
+ jr nz, PlayShuffleAndDrawCardsAnimation
ldtx hl, ThisIsJustPracticeDoNotShuffleText
; fallthrough
-Func_4e98: ; 4e98 (1:4e98)
+; animate the shuffle and drawing screen
+; input:
+; b = shuffling animation index
+; c = drawing animation index
+; hl = text to print while shuffling
+; de = text to print while drawing
+PlayShuffleAndDrawCardsAnimation: ; 4e98 (1:4e98)
push bc
push de
push hl
@@ -2211,63 +2221,75 @@ Func_4e98: ; 4e98 (1:4e98)
cp DUELTYPE_PRACTICE
jr nz, .not_practice
call WaitForWideTextBoxInput
- jr .asm_4ee0
+ jr .print_deck_info
+
.not_practice
+; get the shuffling animation from input value of b
call Func_3b21
ld hl, sp+$03
+ ; play animation 3 times
ld a, [hl]
call Func_3b6a
ld a, [hl]
call Func_3b6a
ld a, [hl]
call Func_3b6a
-.asm_4ed0
+
+.loop_shuffle_anim
call DoFrame
call CheckSkipDelayAllowed
- jr c, .asm_4edd
+ jr c, .done_shuffle
call CheckAnyAnimationPlaying
- jr c, .asm_4ed0
-.asm_4edd
+ jr c, .loop_shuffle_anim
+.done_shuffle
call Func_3b31
-.asm_4ee0
+
+.print_deck_info
xor a
ld [wNumCardsBeingDrawn], a
call PrintDeckAndHandIconsAndNumberOfCards
call Func_3b21
pop hl
call DrawWideTextBox_PrintText
-.asm_4eee
+.draw_card
+; get the draw animation from input value of c
ld hl, sp+$00
ld a, [hl]
call Func_3b6a
-.asm_4ef4
+
+.loop_drawing_anim
call DoFrame
call CheckSkipDelayAllowed
- jr c, .asm_4f28
+ jr c, .done
call CheckAnyAnimationPlaying
- jr c, .asm_4ef4
+ jr c, .loop_drawing_anim
+
ld hl, wNumCardsBeingDrawn
inc [hl]
ld hl, sp+$00
ld a, [hl]
- cp $55
- jr nz, .asm_4f11
+ cp DUEL_ANIM_BOTH_DRAW
+ jr nz, .one_duelist_shuffled
+ ; if both duelists shuffled
call PrintDeckAndHandIconsAndNumberOfCards.not_cgb
- jr .asm_4f14
-.asm_4f11
+ jr .check_num_cards
+.one_duelist_shuffled
call PrintNumberOfHandAndDeckCards
-.asm_4f14
+
+.check_num_cards
ld a, [wNumCardsBeingDrawn]
cp 7
- jr c, .asm_4eee
+ jr c, .draw_card
+
ld c, 30
.wait_loop
call DoFrame
call CheckSkipDelayAllowed
- jr c, .asm_4f28
+ jr c, .done
dec c
jr nz, .wait_loop
-.asm_4f28
+
+.done
call Func_3b31
pop bc
ret
@@ -2282,50 +2304,61 @@ Func_4f2d: ; 4f2d (1:4f2d)
.skip_draw_scene
ld a, SHUFFLE_DECK
ld [wDuelDisplayedScreen], a
+
+; if duelist has only one card in deck,
+; skip shuffling animation
ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK
call GetTurnDuelistVariable
ld a, DECK_SIZE
sub [hl]
cp 2
jr c, .one_card_in_deck
+
ldtx hl, ShufflesTheDeckText
call DrawWideTextBox_PrintText
call EnableLCD
call Func_3b21
- ld e, $51
+
+; load correct animation depending on turn duelist
+ ld e, DUEL_ANIM_PLAYER_SHUFFLE
ldh a, [hWhoseTurn]
cp PLAYER_TURN
- jr z, .asm_4f64
- ld e, $52
-.asm_4f64
+ jr z, .load_anim
+ ld e, DUEL_ANIM_OPP_SHUFFLE
+.load_anim
+; play animation 3 times
ld a, e
call Func_3b6a
ld a, e
call Func_3b6a
ld a, e
call Func_3b6a
-.asm_4f70
+
+.loop_anim
call DoFrame
call CheckSkipDelayAllowed
- jr c, .asm_4f7d
+ jr c, .done_anim
call CheckAnyAnimationPlaying
- jr c, .asm_4f70
-.asm_4f7d
+ jr c, .loop_anim
+
+.done_anim
call Func_3b31
ld a, $01
ret
+
.one_card_in_deck
+; no animation, just print text and delay
ld l, a
ld h, $00
call LoadTxRam3
ldtx hl, DeckHasXCardsText
call DrawWideTextBox_PrintText
call EnableLCD
- ld a, $3c
-.asm_4f94
+ ld a, 60
+.loop_wait
call DoFrame
dec a
- jr nz, .asm_4f94
+ jr nz, .loop_wait
ld a, $01
ret
@@ -6749,6 +6782,7 @@ HandleBetweenTurnsEvents: ; 6baf (1:6baf)
call DiscardAttachedDefenders
call SwapTurn
ret
+
.something_to_handle
; either:
; 1. turn holder's arena Pokemon is paralyzed, asleep, poisoned or double poisoned
@@ -6760,6 +6794,7 @@ HandleBetweenTurnsEvents: ; 6baf (1:6baf)
call DrawDuelBoxMessage
ldtx hl, BetweenTurnsText
call DrawWideTextBox_WaitForInput
+
ld a, DUELVARS_ARENA_CARD
call GetTurnDuelistVariable
call GetCardIDFromDeckIndex
@@ -6768,24 +6803,27 @@ HandleBetweenTurnsEvents: ; 6baf (1:6baf)
ld l, DUELVARS_ARENA_CARD_STATUS
ld a, [hl]
or a
- jr z, .asm_6c1a
- call Func_6d3f
- jr c, .asm_6c1a
- call Func_6cfa
+ jr z, .discard_pluspower
+ ; has status condition
+ call HandlePoisonDamage
+ jr c, .discard_pluspower
+ call HandleSleepCheck
ld a, [hl]
and CNF_SLP_PRZ
cp PARALYZED
- jr nz, .asm_6c1a
+ jr nz, .discard_pluspower
+ ; heal paralysis
ld a, DOUBLE_POISONED
and [hl]
ld [hl], a
call Func_6c7e
ldtx hl, IsCuredOfParalysisText
call Func_6ce4
- ld a, $3e
+ ld a, DUEL_ANIM_HEAL
call Func_6cab
call WaitForWideTextBoxInput
-.asm_6c1a
+
+.discard_pluspower
call DiscardAttachedPluspowers
call SwapTurn
ld a, DUELVARS_ARENA_CARD
@@ -6797,13 +6835,13 @@ HandleBetweenTurnsEvents: ; 6baf (1:6baf)
ld a, [hl]
or a
jr z, .asm_6c3a
- call Func_6d3f
+ call HandlePoisonDamage
jr c, .asm_6c3a
- call Func_6cfa
+ call HandleSleepCheck
.asm_6c3a
call DiscardAttachedDefenders
call SwapTurn
- call $6e4c
+ call Func_6e4c
ret
; discard any PLUSPOWER attached to the turn holder's arena and/or bench Pokemon
@@ -6865,6 +6903,7 @@ Func_6c7e: ; 6c7e (1:6c7e)
call DrawDuelMainScene
call SwapTurn
ret
+
.asm_6c98
ld hl, wWhoseTurn
ldh a, [hWhoseTurn]
@@ -6875,33 +6914,39 @@ Func_6c7e: ; 6c7e (1:6c7e)
call SwapTurn
ret
+; input:
+; a = animation ID
Func_6cab: ; 6cab (1:6cab)
push af
ld a, [wDuelType]
or a
- jr nz, .asm_6cc6
+ jr nz, .store_duelist_turn
ld a, [wWhoseTurn]
cp PLAYER_TURN
- jr z, .asm_6cc6
+ jr z, .store_duelist_turn
call SwapTurn
ldh a, [hWhoseTurn]
ld [wd4af], a
call SwapTurn
jr .asm_6ccb
-.asm_6cc6
+
+.store_duelist_turn
ldh a, [hWhoseTurn]
ld [wd4af], a
+
.asm_6ccb
xor a
ld [wd4b0], a
- ld a, $00
- ld [wd4ae], a
+ ld a, DUEL_ANIM_SCREEN_MAIN_SCENE
+ ld [wDuelAnimationScreen], a
pop af
+
+; play animation
call Func_3b6a
-.asm_6cd8
+.loop_anim
call DoFrame
call CheckAnyAnimationPlaying
- jr c, .asm_6cd8
+ jr c, .loop_anim
call Func_6c7e.asm_6c98
ret
@@ -6920,11 +6965,15 @@ Func_6ce4: ; 6ce4 (1:6ce4)
call DrawWideTextBox_PrintText
ret
-Func_6cfa: ; 6cfa (1:6cfa)
+; handles the sleep check for the NonTurn Duelist
+; heals sleep status if coin is heads, else
+; it plays sleeping animation
+HandleSleepCheck: ; 6cfa (1:6cfa)
ld a, [hl]
and CNF_SLP_PRZ
cp ASLEEP
- ret nz
+ ret nz ; quit if not asleep
+
push hl
ld a, [wTempNonTurnDuelistCardID]
ld e, a
@@ -6938,17 +6987,20 @@ Func_6cfa: ; 6cfa (1:6cfa)
ld [hl], a
ldtx de, PokemonsSleepCheckText
call TossCoin
- ld a, $03
+ ld a, DUEL_ANIM_SLEEP
ldtx hl, IsStillAsleepText
- jr nc, .asm_6d2d
+ jr nc, .tails
+
+; coin toss was heads, cure sleep status
pop hl
push hl
ld a, DOUBLE_POISONED
and [hl]
ld [hl], a
- ld a, $3e
+ ld a, DUEL_ANIM_HEAL
ldtx hl, IsCuredOfSleepText
-.asm_6d2d
+
+.tails
push af
push hl
call Func_6c7e
@@ -6960,10 +7012,12 @@ Func_6cfa: ; 6cfa (1:6cfa)
call WaitForWideTextBoxInput
ret
-Func_6d3f: ; 6d3f (1:6d3f)
+HandlePoisonDamage: ; 6d3f (1:6d3f)
or a
bit POISONED_F , [hl]
- ret z
+ ret z ; quit if not poisoned
+
+; load damage and text according to normal/double poison
push hl
bit DOUBLE_POISONED_F, [hl]
ld a, PSN_DAMAGE
@@ -6971,18 +7025,24 @@ Func_6d3f: ; 6d3f (1:6d3f)
jr z, .not_double_poisoned
ld a, DBLPSN_DAMAGE
ldtx hl, Received20DamageDueToPoisonText
+
.not_double_poisoned
push af
ld [wd4b1], a
xor a
ld [wd4b2], a
+
push hl
call Func_6c7e
pop hl
call Func_6ce4
- ld a, $05
+
+; play animation
+ ld a, DUEL_ANIM_POISON
call Func_6cab
pop af
+
+; deal poison damage
ld e, a
ld d, $00
ld a, DUELVARS_ARENA_CARD_HP
@@ -6992,6 +7052,7 @@ Func_6d3f: ; 6d3f (1:6d3f)
ld a, $8c
call Func_6cab
pop hl
+
call PrintKnockedOutIfHLZero
push af
call WaitForWideTextBoxInput
@@ -7128,6 +7189,9 @@ ApplyStatusConditionToArenaPokemon: ; 6e38 (1:6e38)
Func_6e49: ; 6e49 (1:6e49)
call HandleDestinyBondSubstatus
+ ; fallthrough
+
+Func_6e4c: ; 6e4c (1:6e4c)
call ClearDamageReductionSubstatus2OfKnockedOutPokemon
xor a
ld [wcce8], a
@@ -7714,19 +7778,20 @@ Func_7195: ; 7195 (1:7195)
ret
_TossCoin: ; 71ad (1:71ad)
- ld [wcd9c], a
+ ld [wCoinTossTotalNum], a
ld a, [wDuelDisplayedScreen]
cp COIN_TOSS
- jr z, .asm_71c1
+ jr z, .print_text
xor a
- ld [wcd9f], a
+ ld [wCoinTossNumTossed], a
call EmptyScreen
call LoadDuelCoinTossResultTiles
-.asm_71c1
- ld a, [wcd9f]
+.print_text
+; no need to print text if this is not the first coin toss
+ ld a, [wCoinTossNumTossed]
or a
- jr nz, .asm_71ec
+ jr nz, .clear_text_pointer
ld a, COIN_TOSS
ld [wDuelDisplayedScreen], a
lb de, 0, 12
@@ -7743,125 +7808,144 @@ _TossCoin: ; 71ad (1:71ad)
ld l, a
call PrintText
-.asm_71ec
+.clear_text_pointer
ld hl, wCoinTossScreenTextID
xor a
ld [hli], a
ld [hl], a
+
+; store duelist type and reset number of heads
call EnableLCD
ld a, DUELVARS_DUELIST_TYPE
call GetTurnDuelistVariable
- ld [wcd9e], a
+ ld [wCoinTossDuelistType], a
call ExchangeRNG
xor a
ld [wCoinTossNumHeads], a
-.asm_7204
- ld a, [wcd9c]
- cp $2
+.print_coin_tally
+; skip printing text if it's only one coin toss
+ ld a, [wCoinTossTotalNum]
+ cp 2
jr c, .asm_7223
+
+; write "#coin/#total coins"
lb bc, 15, 11
- ld a, [wcd9f]
- inc a
+ ld a, [wCoinTossNumTossed]
+ inc a ; current coin number is wCoinTossNumTossed + 1
call WriteTwoDigitNumberInTxSymbolFormat
ld b, 17
ld a, SYM_SLASH
call WriteByteToBGMap0
inc b
- ld a, [wcd9c]
+ ld a, [wCoinTossTotalNum]
call WriteTwoDigitNumberInTxSymbolFormat
.asm_7223
call Func_3b21
- ld a, $58
+ ld a, DUEL_ANIM_COIN_SPIN
call Func_3b6a
- ld a, [wcd9e]
+
+ ld a, [wCoinTossDuelistType]
or a
jr z, .asm_7236
- call $7324
+ call Func_7324
jr .asm_723c
.asm_7236
call WaitForWideTextBoxInput
- call $72ff
+ call Func_72ff
.asm_723c
call Func_3b21
- ld d, $5a
- ld e, $0
+ ld d, DUEL_ANIM_COIN_TOSS2
+ ld e, $0 ; heads
call UpdateRNGSources
rra
- jr c, .asm_724d
- ld d, $59
- ld e, $1
-
-.asm_724d
+ jr c, .got_result
+ ld d, DUEL_ANIM_COIN_TOSS1
+ ld e, $1 ; tails
+
+.got_result
+; already decided on coin toss result,
+; load the correct tossing animation
+; and wait for it to finish
ld a, d
call Func_3b6a
- ld a, [wcd9e]
+ ld a, [wCoinTossDuelistType]
or a
- jr z, .asm_725e
+ jr z, .wait_anim
ld a, e
- call $7310
+ call Func_7310
ld e, a
- jr .asm_726c
-
-.asm_725e
+ jr .done_toss_anim
+.wait_anim
push de
call DoFrame
call CheckAnyAnimationPlaying
pop de
- jr c, .asm_725e
+ jr c, .wait_anim
ld a, e
- call $72ff
+ call Func_72ff
-.asm_726c
- ld b, $5c
- ld c, $34
+.done_toss_anim
+ ld b, DUEL_ANIM_COIN_HEADS
+ ld c, $34 ; tile for circle
ld a, e
or a
- jr z, .asm_727c
- ld b, $5b
- ld c, $30
+ jr z, .show_result
+ ld b, DUEL_ANIM_COIN_TAILS
+ ld c, $30 ; tile for cross
ld hl, wCoinTossNumHeads
inc [hl]
-.asm_727c
+.show_result
ld a, b
call Func_3b6a
- ld a, [wcd9e]
+
+; load correct sound effect
+; the sound of the coin toss result
+; is dependant on whether it was the Player
+; or the Opponent to get heads/tails
+ ld a, [wCoinTossDuelistType]
or a
- jr z, .asm_728a
+ jr z, .check_sfx
ld a, $1
- xor e
+ xor e ; invert result in case it's not Player
ld e, a
-
-.asm_728a
+.check_sfx
ld d, SFX_54
ld a, e
or a
- jr nz, .asm_7292
+ jr nz, .got_sfx
ld d, SFX_55
-
-.asm_7292
+.got_sfx
ld a, d
call PlaySFX
- ld a, [wcd9c]
+
+; in case it's a multiple coin toss scenario,
+; then the result needs to be registered on screen
+; with a circle (o) or a cross (x)
+ ld a, [wCoinTossTotalNum]
dec a
- jr z, .asm_72b9
+ jr z, .incr_num_coin_tossed ; skip if not more than 1 coin toss
ld a, c
push af
- ld e, $0
- ld a, [wcd9f]
+ ld e, 0
+ ld a, [wCoinTossNumTossed]
+; calculate the offset to draw the circle/cross
.asm_72a3
- cp $a
- jr c, .asm_72ad
+ ; if < 10, then the offset is simply calculated
+ ; from wCoinTossNumTossed * 2...
+ cp 10
+ jr c, .got_offset
+ ; ...else the y-offset is added for each multiple of 10
inc e
inc e
- sub $a
+ sub 10
jr .asm_72a3
-.asm_72ad
+.got_offset
add a
ld d, a
lb bc, 2, 2
@@ -7869,18 +7953,19 @@ _TossCoin: ; 71ad (1:71ad)
pop af
call FillRectangle
-.asm_72b9
- ld hl, wcd9f
+.incr_num_coin_tossed
+ ld hl, wCoinTossNumTossed
inc [hl]
- ld a, [wcd9e]
+
+ ld a, [wCoinTossDuelistType]
or a
jr z, .asm_72dc
ld a, [hl]
- ld hl, wcd9c
+ ld hl, wCoinTossTotalNum
cp [hl]
call z, WaitForWideTextBoxInput
- call $7324
- ld a, [wcd9c]
+ call Func_7324
+ ld a, [wCoinTossTotalNum]
ld hl, wCoinTossNumHeads
or [hl]
jr nz, .asm_72e2
@@ -7889,17 +7974,19 @@ _TossCoin: ; 71ad (1:71ad)
.asm_72dc
call WaitForWideTextBoxInput
- call $72ff
+ call Func_72ff
.asm_72e2
call Func_3b31
- ld a, [wcd9f]
- ld hl, wcd9c
+ ld a, [wCoinTossNumTossed]
+ ld hl, wCoinTossTotalNum
cp [hl]
- jp c, .asm_7204
+ jp c, .print_coin_tally
call ExchangeRNG
call Func_3b31
call Func_3b21
+
+; return carry if at least 1 heads
ld a, [wCoinTossNumHeads]
or a
ret z
@@ -7922,17 +8009,21 @@ Func_7310: ; 7310 (1:7310)
ldh [hff96], a
ld a, [wDuelType]
cp DUELTYPE_LINK
- jr z, .asm_7338
-.asm_7319
+ jr z, Func_7338
+.loop_anim
call DoFrame
call CheckAnyAnimationPlaying
- jr c, .asm_7319
+ jr c, .loop_anim
ldh a, [hff96]
ret
+
+Func_7324: ; 7324 (1:7324)
ldh [hff96], a
ld a, [wDuelType]
cp DUELTYPE_LINK
- jr z, .asm_7338
+ jr z, Func_7338
+
+; delay coin flip for AI opponent
ld a, 30
.asm_732f
call DoFrame
@@ -7940,10 +8031,11 @@ Func_7310: ; 7310 (1:7310)
jr nz, .asm_732f
ldh a, [hff96]
ret
-.asm_7338
+
+Func_7338: ; 7338 (1:7338)
call DoFrame
call SerialRecvByte
- jr c, .asm_7338
+ jr c, Func_7338
call Func_7344
ret
; 0x7344