summaryrefslogtreecommitdiff
path: root/src/home/coin_toss.asm
blob: 726fde0ce746c933fb7d2ea1f25dacee51407482 (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
; function that executes one or more consecutive coin tosses during a duel (a = number of coin tosses),
; displaying each result ([O] or [X]) starting from the top left corner of the screen.
; text at de is printed in a text box during the coin toss.
; returns: the number of heads in a and in wCoinTossNumHeads, and carry if at least one heads
TossCoinATimes:
	push hl
	ld hl, wCoinTossScreenTextID
	ld [hl], e
	inc hl
	ld [hl], d
	bank1call _TossCoin
	pop hl
	ret

; function that executes a single coin toss during a duel.
; text at de is printed in a text box during the coin toss.
; returns: - carry, and 1 in a and in wCoinTossNumHeads if heads
;          - nc, and 0 in a and in wCoinTossNumHeads if tails
TossCoin:
	push hl
	ld hl, wCoinTossScreenTextID
	ld [hl], e
	inc hl
	ld [hl], d
	ld a, 1
	bank1call _TossCoin
	ld hl, wDuelDisplayedScreen
	ld [hl], 0
	pop hl
	ret

; cp de, bc
CompareDEtoBC:
	ld a, d
	cp b
	ret nz
	ld a, e
	cp c
	ret