Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/battle/end_of_battle.asm
1271 views
1
EndOfBattle:
2
ld a, [wLinkState]
3
cp LINK_STATE_BATTLING
4
jr nz, .notLinkBattle
5
; link battle
6
ld a, [wEnemyMonPartyPos]
7
ld hl, wEnemyMon1Status
8
ld bc, wEnemyMon2 - wEnemyMon1
9
call AddNTimes
10
ld a, [wEnemyMonStatus]
11
ld [hl], a
12
call ClearScreen
13
callfar DisplayLinkBattleVersusTextBox
14
ld a, [wBattleResult]
15
cp $1
16
ld de, YouWinText
17
jr c, .placeWinOrLoseString
18
ld de, YouLoseText
19
jr z, .placeWinOrLoseString
20
ld de, DrawText
21
.placeWinOrLoseString
22
hlcoord 6, 8
23
call PlaceString
24
ld c, 200
25
call DelayFrames
26
jr .evolution
27
.notLinkBattle
28
ld a, [wBattleResult]
29
and a
30
jr nz, .resetVariables
31
ld hl, wTotalPayDayMoney
32
ld a, [hli]
33
or [hl]
34
inc hl
35
or [hl]
36
jr z, .evolution ; if pay day money is 0, jump
37
ld de, wPlayerMoney + 2
38
ld c, $3
39
predef AddBCDPredef
40
ld hl, PickUpPayDayMoneyText
41
call PrintText
42
.evolution
43
xor a
44
ld [wForceEvolution], a
45
predef EvolutionAfterBattle
46
.resetVariables
47
xor a
48
ld [wLowHealthAlarm], a ;disable low health alarm
49
ld [wChannelSoundIDs + CHAN5], a
50
ld [wIsInBattle], a
51
ld [wBattleType], a
52
ld [wMoveMissed], a
53
ld [wCurOpponent], a
54
ld [wForcePlayerToChooseMon], a
55
ld [wNumRunAttempts], a
56
ld [wEscapedFromBattle], a
57
ld hl, wPartyAndBillsPCSavedMenuItem
58
ld [hli], a
59
ld [hli], a
60
ld [hli], a
61
ld [hl], a
62
ld [wListScrollOffset], a
63
ld hl, wPlayerStatsToDouble
64
ld b, $18
65
.loop
66
ld [hli], a
67
dec b
68
jr nz, .loop
69
ld hl, wStatusFlags2
70
set BIT_WILD_ENCOUNTER_COOLDOWN, [hl]
71
call WaitForSoundToFinish
72
call GBPalWhiteOut
73
ld a, $ff
74
ld [wDestinationWarpID], a
75
ret
76
77
YouWinText:
78
db "YOU WIN@"
79
80
YouLoseText:
81
db "YOU LOSE@"
82
83
DrawText:
84
db " DRAW@"
85
86
PickUpPayDayMoneyText:
87
text_far _PickUpPayDayMoneyText
88
text_end
89
90