diff options
author | mid-kid <esteve.varela@gmail.com> | 2020-09-11 13:51:51 +0200 |
---|---|---|
committer | mid-kid <esteve.varela@gmail.com> | 2020-09-11 13:52:48 +0200 |
commit | e3dcbcde48466cb07522bd5bf98559aec05a9b07 (patch) | |
tree | cdce91a2d07223f07fdef70fb0167d7b7d6837b3 | |
parent | b0f8c8a763cb1626672b2555e92be93a3afc7bad (diff) |
Document text_char_print
-rw-r--r-- | doc/complete_save.txt | 3 | ||||
-rw-r--r-- | include/macros.inc | 2 | ||||
-rw-r--r-- | shim.sym | 7 | ||||
-rw-r--r-- | source/bank_00.asm | 2 | ||||
-rw-r--r-- | source/bank_02.asm | 88 |
5 files changed, 99 insertions, 3 deletions
diff --git a/doc/complete_save.txt b/doc/complete_save.txt new file mode 100644 index 0000000..15fc41c --- /dev/null +++ b/doc/complete_save.txt @@ -0,0 +1,3 @@ +D6E6-D721: Stage clear flags, set all to FF +DB19: Mew appear flag +DB1A: Mew pokedex flag diff --git a/include/macros.inc b/include/macros.inc index 7ab2dc5..d93bfd0 100644 --- a/include/macros.inc +++ b/include/macros.inc @@ -7,5 +7,5 @@ farcall: macro ld a, BANK(\1) ld [w_bank_temp], a pop af - call farcall + call _farcall endm @@ -1,8 +1,11 @@ +05:420f text_scroll_char_print + 00:c31e w_bank_temp ; db 00:c317 w_farcall_target ; dw 00:c315 w_bank_rom ; db 00:c336 w_c336 +00:c342 w_c342 00:c35b w_vwf_char_start_x ; db 00:c35c w_vwf_char_start_y ; db 00:c35d w_vwf_char_end_x ; db @@ -24,5 +27,9 @@ 00:cd6d w_cd6d 00:cd6e w_cd6e +01:d548 w_text_cur_string ; dw +01:d546 w_text_cur_x ; db +01:d547 w_text_cur_y ; db +01:d55e w_textbox_x ; db 01:d560 w_textbox_width ; db 01:d561 w_textbox_height ; db 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 |