summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authormid-kid <esteve.varela@gmail.com>2020-09-11 13:51:51 +0200
committermid-kid <esteve.varela@gmail.com>2020-09-11 13:52:48 +0200
commite3dcbcde48466cb07522bd5bf98559aec05a9b07 (patch)
treecdce91a2d07223f07fdef70fb0167d7b7d6837b3 /source
parentb0f8c8a763cb1626672b2555e92be93a3afc7bad (diff)
Document text_char_print
Diffstat (limited to 'source')
-rw-r--r--source/bank_00.asm2
-rw-r--r--source/bank_02.asm88
2 files changed, 88 insertions, 2 deletions
diff --git a/source/bank_00.asm b/source/bank_00.asm
index bfb542a..c2c5c85 100644
--- a/source/bank_00.asm
+++ b/source/bank_00.asm
@@ -603,7 +603,7 @@ vram_copy::
SECTION "farcall", ROM0[$10cd]
; Save current bank and jump to w_farcall_target in w_bank_temp
-farcall::
+_farcall::
push af
push af
push af
diff --git a/source/bank_02.asm b/source/bank_02.asm
index c083325..cf93d5f 100644
--- a/source/bank_02.asm
+++ b/source/bank_02.asm
@@ -1,4 +1,90 @@
-SECTION "text_char_draw", ROMX[$4c80], BANK[$02]
+INCLUDE "charmap.inc"
+INCLUDE "macros.inc"
+
+SECTION "text_char", ROMX[$4bf7], BANK[$02]
+far_text_char_print::
+ farcall text_char_print
+ jp farcall_ret
+
+; Returns:
+; flags - z if reached end of string
+text_char_print::
+ ld a, [w_c342]
+ bit 0, a
+ jp nz, farcall_ret
+
+ ld a, [w_text_cur_string + 0]
+ ld l, a
+ ld a, [w_text_cur_string + 1]
+ ld h, a
+ ld a, [w_text_cur_x]
+ ld b, a
+ ld a, [w_text_cur_y]
+ ld c, a
+ ld a, [hl+]
+ ld e, a
+ ld a, [hl+]
+
+ ; Check if we've reached the end of the string
+ ld d, a
+ and e
+ cp TX_EOM
+ jp z, farcall_ret
+ push hl
+
+ ; Check for line feed
+ ld a, e
+ cp LOW(TX_LF)
+ jr nz, .not_line_feed
+ ld a, d
+ cp HIGH(TX_LF)
+ jr z, .line_feed
+.not_line_feed
+
+ ; Draw ピ one pixel higher
+ ld a, e
+ cp "ピ"
+ jr nz, .not_pi
+ ld a, d
+ and a
+ jr nz, .not_pi
+ dec c
+.not_pi
+
+ ; Draw character
+ farcall text_char_draw
+
+ ; Leave two pixels space between each character
+ ld hl, w_text_cur_x
+ add 2
+ add [hl]
+ ld [hl], a
+ jr .done
+
+.line_feed
+ ; Advance to the next line
+ ld a, [w_textbox_x]
+ ld [w_text_cur_x], a
+ ld a, [w_text_cur_y]
+ add 11
+ ld [w_text_cur_y], a
+
+.done
+ ; Back up string pointer
+ pop hl
+ ld a, l
+ ld [w_text_cur_string + 0], a
+ ld a, h
+ ld [w_text_cur_string + 1], a
+
+ ; Check if the next character is a terminator
+ ld a, [hl+]
+ and [hl]
+ cp TX_EOM
+ jp farcall_ret
+
+; Returns:
+; a - character width
; Parameters:
; de - character to print
; b - x position