summaryrefslogtreecommitdiff
path: root/src/home/coin_toss.asm
diff options
context:
space:
mode:
authorElectroDeoxys <ElectroDeoxys@gmail.com>2021-09-09 08:51:12 +0100
committerElectroDeoxys <ElectroDeoxys@gmail.com>2021-09-09 08:51:12 +0100
commit32b02147925566bac93bf71b002860335583574c (patch)
treed9cf016338d08022f0c0db358b356ddfb18b0e16 /src/home/coin_toss.asm
parente4bce9b7ee5e89f8edfd921de2379f0fa06af206 (diff)
Split home bank
Diffstat (limited to 'src/home/coin_toss.asm')
-rw-r--r--src/home/coin_toss.asm39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/home/coin_toss.asm b/src/home/coin_toss.asm
new file mode 100644
index 0000000..d0f06f0
--- /dev/null
+++ b/src/home/coin_toss.asm
@@ -0,0 +1,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: ; 3071 (0:3071)
+ 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: ; 307d (0:307d)
+ 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: ; 3090 (0:3090)
+ ld a, d
+ cp b
+ ret nz
+ ld a, e
+ cp c
+ ret