1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
; does nothing since no stats are ever selected (barring glitches)
DoubleSelectedStats:
ld a, [H_WHOSETURN]
and a
ld a, [wPlayerStatsToDouble]
ld hl, wBattleMonAttack + 1
jr z, .notEnemyTurn
ld a, [wEnemyStatsToDouble]
ld hl, wEnemyMonAttack + 1
.notEnemyTurn
ld c, 4
ld b, a
.loop
srl b
call c, .doubleStat
inc hl
inc hl
dec c
ret z
jr .loop
.doubleStat
ld a, [hl]
add a
ld [hld], a
ld a, [hl]
rl a
ld [hli], a
ret
; does nothing since no stats are ever selected (barring glitches)
HalveSelectedStats:
ld a, [H_WHOSETURN]
and a
ld a, [wPlayerStatsToHalve]
ld hl, wBattleMonAttack
jr z, .notEnemyTurn
ld a, [wEnemyStatsToHalve]
ld hl, wEnemyMonAttack
.notEnemyTurn
ld c, 4
ld b, a
.loop
srl b
call c, .halveStat
inc hl
inc hl
dec c
ret z
jr .loop
.halveStat
ld a, [hl]
srl a
ld [hli], a
rr [hl]
or [hl]
jr nz, .nonzeroStat
ld [hl], 1
.nonzeroStat
dec hl
ret
|