summaryrefslogtreecommitdiff
path: root/home/random.asm
blob: 3c2972af63ce45d95af11cca7cdb368db60229ac (plain)
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
Random:: ; 30a2 (0:30a2)
	push bc
	ld a, [rDIV]
	ld b, a
	ld a, [hRandom]
	adc b
	ld [hRandom], a
	ld a, [rDIV]
	ld b, a
	ld a, [hRandomSub]
	sbc b
	ld [hRandomSub], a
	pop bc
	ret

BattleRandom::
	ld a, [hROMBank]
	push af
	ld a, BANK(BattleRandom_)
	rst Bankswitch
	call BattleRandom_
	ld [wPredefTemp + 1], a
	pop af
	rst Bankswitch
	ld a, [wPredefTemp + 1]
	ret

RandomRange::
	push bc
	ld c, a
	xor a
	sub c
.asm_30cb
	sub c
	jr nc, .asm_30cb
	add c
	ld b, a
	push bc
.asm_30d1
	call Random
	ld a, [hRandom]
	ld c, a
	add b
	jr c, .asm_30d1
	ld a, c
	pop bc
	call SimpleDivide
	pop bc
	ret