summaryrefslogtreecommitdiff
path: root/home/print_text.asm
diff options
context:
space:
mode:
authorRangi <35663410+Rangi42@users.noreply.github.com>2020-07-07 19:48:22 -0400
committerGitHub <noreply@github.com>2020-07-07 19:48:22 -0400
commit9571c550b6a0dcb3a4f54513c881661a87271024 (patch)
treed73507228a57e4f3cece2fb93fe7df3a9439553f /home/print_text.asm
parentc480632d5494d04f7f5f0298a31877a2293b564e (diff)
parentbbf2f51a02b2544f1bef32a5868503b474ae2fef (diff)
Merge pull request #263 from Rangi42/master
Syncing style with pokecrystal
Diffstat (limited to 'home/print_text.asm')
-rw-r--r--home/print_text.asm45
1 files changed, 45 insertions, 0 deletions
diff --git a/home/print_text.asm b/home/print_text.asm
new file mode 100644
index 00000000..049ddfb4
--- /dev/null
+++ b/home/print_text.asm
@@ -0,0 +1,45 @@
+; This function is used to wait a short period after printing a letter to the
+; screen unless the player presses the A/B button or the delay is turned off
+; through the [wd730] or [wLetterPrintingDelayFlags] flags.
+PrintLetterDelay::
+ ld a, [wd730]
+ bit 6, a
+ ret nz
+ ld a, [wLetterPrintingDelayFlags]
+ bit 1, a
+ ret z
+ push hl
+ push de
+ push bc
+ ld a, [wLetterPrintingDelayFlags]
+ bit 0, a
+ jr z, .waitOneFrame
+ ld a, [wOptions]
+ and $f
+ ldh [hFrameCounter], a
+ jr .checkButtons
+.waitOneFrame
+ ld a, 1
+ ldh [hFrameCounter], a
+.checkButtons
+ call Joypad
+ ldh a, [hJoyHeld]
+.checkAButton
+ bit 0, a ; is the A button pressed?
+ jr z, .checkBButton
+ jr .endWait
+.checkBButton
+ bit 1, a ; is the B button pressed?
+ jr z, .buttonsNotPressed
+.endWait
+ call DelayFrame
+ jr .done
+.buttonsNotPressed ; if neither A nor B is pressed
+ ldh a, [hFrameCounter]
+ and a
+ jr nz, .checkButtons
+.done
+ pop bc
+ pop de
+ pop hl
+ ret