summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxCrystal <rgr.crystal@gmail.com>2018-07-11 20:38:37 +0200
committerxCrystal <rgr.crystal@gmail.com>2018-07-11 20:38:37 +0200
commit04eb7f89a4ccce5c578f9e960749de4ba6a62366 (patch)
tree11553cde44298f57c628aac41af9339cf6c224a7
parent3921b82124e51a1d1054bf5339b15c00ed8298cf (diff)
More text engine documentation
-rw-r--r--src/engine/bank01.asm34
-rw-r--r--src/engine/bank02.asm10
-rw-r--r--src/engine/bank04.asm2
-rw-r--r--src/engine/bank06.asm2
-rw-r--r--src/engine/home.asm287
-rw-r--r--src/wram.asm11
6 files changed, 193 insertions, 153 deletions
diff --git a/src/engine/bank01.asm b/src/engine/bank01.asm
index a67d672..7687865 100644
--- a/src/engine/bank01.asm
+++ b/src/engine/bank01.asm
@@ -1563,23 +1563,23 @@ Func_4a97: ; 4a97 (1:4a97)
push de
call CopyPlayerName
lb de, 0, 11
- call Func_22ae
+ call InitTextPrinting
pop hl
- call Func_21c5
+ call ProcessText
ld bc, $5
call Func_3e10
ld de, wDefaultText
push de
call CopyOpponentName
pop hl
- call Func_23c1
+ call GetTextSizeInHalfTiles
push hl
add SCREEN_WIDTH
ld d, a
ld e, 0
- call Func_22ae
+ call InitTextPrinting
pop hl
- call Func_21c5
+ call ProcessText
ld a, [wOpponentPortrait]
ld bc, $d01
call Func_3e2a
@@ -1662,7 +1662,7 @@ Func_4b38: ; 4b38 (1:4b38)
call PrintCardListItems
ldtx hl, TheCardYouReceivedText
lb de, 1, 1
- call Func_22ae
+ call InitTextPrinting
call PrintTextNoDelay
ldtx hl, YouReceivedTheseCardsText
call DrawWideTextBox_WaitForInput
@@ -1914,7 +1914,7 @@ Func_4e40: ; 4e40 (1:4e40)
call PrintCardListItems
ldtx hl, DuelistHandText
lb de, 1, 1
- call Func_22ae
+ call InitTextPrinting
call PrintTextNoDelay
call EnableLCD
ret
@@ -2149,13 +2149,13 @@ DrawDuelHUD: ; 5093 (1:5093)
or a
jr nz, .print_color_icon
ld hl, wDefaultText
- call Func_23c1
+ call GetTextSizeInHalfTiles
add SCREEN_WIDTH
ld d, a
.print_color_icon
- call Func_22ae
+ call InitTextPrinting
ld hl, wDefaultText
- call Func_21c5
+ call ProcessText
push de
pop bc
call GetArenaCardColor
@@ -2633,7 +2633,7 @@ Func_5690: ; 5690 (1:5690)
Func_56a0: ; 56a0 (1:56a0)
lb de, 1, 14
call AdjustCoordinatesForBGScroll
- call Func_22ae
+ call InitTextPrinting
ld hl, wCardListInfoBoxText
ld a, [hli]
ld h, [hl]
@@ -2644,7 +2644,7 @@ Func_56a0: ; 56a0 (1:56a0)
ld h, [hl]
ld l, a
lb de, 1, 1
- call Func_22ae
+ call InitTextPrinting
call PrintTextNoDelay
ret
; 0x56c2
@@ -3689,7 +3689,7 @@ Func_6510: ; 6510 (1:6510)
call LoadDuelCheckPokemonScreenTiles
call Func_622a
lb de, 1, 4
- call Func_22ae
+ call InitTextPrinting
ld hl, wLoadedCard1Move1Name
call Func_2c20
lb de, 1, 6
@@ -3709,7 +3709,7 @@ Func_653e: ; 653e (1:653e)
dec e
.asm_654c
ld a, 19
- call Func_22a6
+ call InitTextPrintingInTextbox
call Func_2c29
call Func_5f50
ret
@@ -3833,12 +3833,12 @@ Func_6673: ; 6673 (1:6673)
call EmptyScreen
call Func_5f4a
lb de, 1, 1
- call Func_22ae
+ call InitTextPrinting
ld hl, wLoadedCard1Name
call Func_2c23
ld a, 19
lb de, 1, 3
- call Func_22a6
+ call InitTextPrintingInTextbox
ld hl, wLoadedCard1NonPokemonDescription
call Func_2c23
call Func_5f50
@@ -4443,7 +4443,7 @@ _TossCoin: ; 71ad (1:71ad)
call EnableLCD
lb de, 1, 14
ld a, 19
- call Func_22a6
+ call InitTextPrintingInTextbox
ld hl, wCoinTossScreenTextID
ld a, [hli]
ld h, [hl]
diff --git a/src/engine/bank02.asm b/src/engine/bank02.asm
index ffcc1d8..1ebde42 100644
--- a/src/engine/bank02.asm
+++ b/src/engine/bank02.asm
@@ -670,7 +670,7 @@ Func_9253: ; 9253 (2:5253)
ld de, wDefaultText
call Func_92ad
ld hl, wDefaultText
- call Func_23c1
+ call GetTextSizeInHalfTiles
ld b, $0
ld hl, wDefaultText
add hl, bc
@@ -689,7 +689,7 @@ Func_926e: ; 926e (2:526e)
ld de, wDefaultText
call Func_92b4
ld hl, wDefaultText
- call Func_23c1
+ call GetTextSizeInHalfTiles
ld b, $0
ld hl, wDefaultText
add hl, bc
@@ -699,12 +699,12 @@ Func_926e: ; 926e (2:526e)
call Func_92ad
pop de
ld hl, wDefaultText
- call Func_22ae
- call Func_21c5
+ call InitTextPrinting
+ call ProcessText
or a
ret
.asm_929c
- call Func_22ae
+ call InitTextPrinting
ldtx hl, NewDeckText
call Func_2c29
scf
diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm
index 256a2f6..28108fb 100644
--- a/src/engine/bank04.asm
+++ b/src/engine/bank04.asm
@@ -435,7 +435,7 @@ Func_10f2e: ; 10f2e (4:4f2e)
push hl
push de
lb de, 1, 1
- call Func_22ae
+ call InitTextPrinting
call Func_10f4a
rlca
ld e, a
diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm
index f952585..8e6f07d 100644
--- a/src/engine/bank06.asm
+++ b/src/engine/bank06.asm
@@ -38,7 +38,7 @@ _CopyCardNameAndLevel: ; 18000 (6:4000)
pop hl
push de
ld e, c
- call Func_23c1
+ call GetTextSizeInHalfTiles
add e
ld c, a
pop hl
diff --git a/src/engine/home.asm b/src/engine/home.asm
index d68951b..f4c7441 100644
--- a/src/engine/home.asm
+++ b/src/engine/home.asm
@@ -5162,8 +5162,9 @@ SubstractHPFromCard: ; 1c35 (0:1c35)
; check if a flag of wLoadedMove is set
; input:
- ; a = %fffffbbb, where f = flag address counting from wLoadedMoveFlag1
- ; b = flag bit
+ ; a = %fffffbbb, where
+ ; fffff = flag address counting from wLoadedMoveFlag1
+ ; bbb = flag bit
; return carry if the flag is set
CheckLoadedMoveFlag: ; 1c50 (0:1c50)
push hl
@@ -5565,7 +5566,7 @@ DrawLabeledTextBox: ; 1e00 (0:1e00)
pop hl
call CopyText
ld hl, wc000 + 3
- call Func_23c1
+ call GetTextSizeInHalfTiles
ld l, e
ld h, d
; white tile after the text
@@ -5598,9 +5599,9 @@ DrawLabeledTextBox: ; 1e00 (0:1e00)
pop de
push de
push bc
- call Func_22ae
+ call InitTextPrinting
ld hl, wc000
- call Func_21c5
+ call ProcessText
pop bc
pop de
ld a, [wConsole]
@@ -6010,44 +6011,50 @@ DrawDuelBoxMessage: ; 2167 (0:2167)
INCROM $2189, $21c5
-Func_21c5: ; 21c5 (0:21c5)
+; reads the characters from the text at hl processes them. loops until TX_END
+; is found. ignores TX_RAM1, TX_RAM2, and TX_RAM3 characters.
+ProcessText: ; 21c5 (0:21c5)
push de
push bc
- call Func_2298
- jr .asm_21e8
-.asm_21cc
+ call InitTextFormat
+ jr .next_char
+.char_loop
cp TX_CTRL_BEGIN
- jr c, .asm_21d9
+ jr c, .character_pair
cp TX_CTRL_END
- jr nc, .asm_21d9
- call Func_21f2
- jr .asm_21e8
-.asm_21d9
- ld e, a
- ld d, [hl]
- call ProcessFullWidthFontCharacterPair
- jr nc, .asm_21e1
+ jr nc, .character_pair
+ call ProcessSpecialTextCharacter
+ jr .next_char
+.character_pair
+ ld e, a ; first char
+ ld d, [hl] ; second char
+ call ClassifyTextCharacterPair
+ jr nc, .not_tx_fullwidth
inc hl
-.asm_21e1
+.not_tx_fullwidth
call Func_22ca
xor a
- call Func_21f2
-.asm_21e8
+ call ProcessSpecialTextCharacter
+.next_char
ld a, [hli]
or a
- jr nz, .asm_21cc
- call Func_230f
+ jr nz, .char_loop
+ ; TX_END
+ call TerminateHalfWidthText
pop bc
pop de
ret
-Func_21f2: ; 21f2 (0:21f2)
+; processes the text character provided in a checking for specific control characters.
+; hl points to the text character coming right after the one loaded into a.
+; returns carry if the character was not processed by this function.
+ProcessSpecialTextCharacter: ; 21f2 (0:21f2)
or a ; TX_END
jr z, .tx_end
cp TX_HIRAGANA
- jr z, .asm_2221
+ jr z, .set_syllabary
cp TX_KATAKANA
- jr z, .asm_2221
+ jr z, .set_syllabary
cp "\n"
jr z, .end_of_line
cp TX_SYMBOL
@@ -6063,13 +6070,13 @@ Func_21f2: ; 21f2 (0:21f2)
ld [wFontWidth], a
ret
.tx_half2full
- call Func_230f
+ call TerminateHalfWidthText
xor a ; FULL_WIDTH
ld [wFontWidth], a
ld a, TX_KATAKANA
ldh [hJapaneseSyllabary], a
ret
-.asm_2221
+.set_syllabary
ldh [hJapaneseSyllabary], a
xor a
ret
@@ -6078,17 +6085,17 @@ Func_21f2: ; 21f2 (0:21f2)
push af
ld a, HALF_WIDTH
ld [wFontWidth], a
- call Func_230f
+ call TerminateHalfWidthText
pop af
ld [wFontWidth], a
ldh a, [hffb0]
or a
- jr nz, .asm_2240
+ jr nz, .skip_placing_tile
ld a, [hl]
push hl
call PlaceNextTextTile
pop hl
-.asm_2240
+.skip_placing_tile
inc hl
.tx_end
ldh a, [hTextLineLength]
@@ -6101,7 +6108,7 @@ Func_21f2: ; 21f2 (0:21f2)
xor a
ret
.end_of_line
- call Func_230f
+ call TerminateHalfWidthText
ld a, [wLineSeparation]
or a
call z, .next_line
@@ -6132,7 +6139,7 @@ Func_2275: ; 2275 (0:2275)
ld [wcd04], a
ld a, e
ldh [hffa8], a
- call Func_2298
+ call InitTextFormat
xor a
ldh [hffb0], a
ldh [hffa9], a
@@ -6150,22 +6157,22 @@ Func_2275: ; 2275 (0:2275)
; wFontWidth <- FULL_WIDTH
; hTextLineCurPos <- 0
-; wcd0b <- 0
+; wHalfWidthPrintState <- 0
; hJapaneseSyllabary <- TX_KATAKANA
-Func_2298: ; 2298 (0:2298)
+InitTextFormat: ; 2298 (0:2298)
xor a ; FULL_WIDTH
ld [wFontWidth], a
ldh [hTextLineCurPos], a
- ld [wcd0b], a
+ ld [wHalfWidthPrintState], a
ld a, TX_KATAKANA
ldh [hJapaneseSyllabary], a
ret
-; Func_22ae
+; call InitTextPrinting
; hTextLineLength <- a
-Func_22a6: ; 22a6 (0:22a6)
+InitTextPrintingInTextbox: ; 22a6 (0:22a6)
push af
- call Func_22ae
+ call InitTextPrinting
pop af
ldh [hTextLineLength], a
ret
@@ -6173,11 +6180,9 @@ Func_22a6: ; 22a6 (0:22a6)
; hTextHorizontalAlign <- d
; hTextLineLength <- 0
; wCurTextLine <- 0
-; hTextBGMap0Address <- BGMap0(e)
-; hTextBGMap0Address + 1 <- BGMap0(d)
-; Func_2298
-;; writes BGMap0-translated DE to hTextBGMap0Address
-Func_22ae: ; 22ae (0:22ae)
+; write BGMap0-translated DE to hTextBGMap0Address
+; call InitTextFormat
+InitTextPrinting: ; 22ae (0:22ae)
push hl
ld a, d
ldh [hTextHorizontalAlign], a
@@ -6189,9 +6194,9 @@ Func_22ae: ; 22ae (0:22ae)
ldh [hTextBGMap0Address], a
ld a, h
ldh [hTextBGMap0Address + 1], a
- call Func_2298
+ call InitTextFormat
xor a
- ld [wcd0b], a
+ ld [wHalfWidthPrintState], a
pop hl
ret
@@ -6244,13 +6249,16 @@ PlaceNextTextTile: ; 22f2 (0:22f2)
inc [hl]
ret
-Func_230f: ; 230f (0:230f)
+; when terminating half-width text with "\n" or TX_END, or switching to full-width
+; with TX_HALF2FULL or to symbols with TX_SYMBOL, check if it's necessary to append
+; a half-width space to finish an incomplete character pair.
+TerminateHalfWidthText: ; 230f (0:230f)
ld a, [wFontWidth]
or a ; FULL_WIDTH
ret z
- ld a, [wcd0b]
+ ld a, [wHalfWidthPrintState]
or a
- ret z
+ ret z ; return if the last printed character was the second of a pair
push hl
push de
push bc
@@ -6310,22 +6318,25 @@ Func_2325: ; 2325 (0:2325)
; the result to head of list and return it. carry flag denotes success.
Func_235e: ; 235e (0:235e)
ld a, [wFontWidth]
- or a ;
- jr z, .asm_2376 ; if [wFontWidth] == HALF_WIDTH:
- ; uppercase e if wUppercaseHalfWidthLetters != 0
+ or a
+ jr z, .print
call CaseHalfWidthLetter
- ld a, [wcd0b]
- ld d, a ; d ← [wcd0b]
+ ; if [wHalfWidthPrintState] != 0, load it to d and print the pair of chars
+ ; zero wHalfWidthPrintState for next iteration
+ ld a, [wHalfWidthPrintState]
+ ld d, a
or a
- jr nz, .asm_2376 ; if [wcd0b] is zero:
- ld a, e ;
- ld [wcd0b], a ; [wcd0b] ← e
- ld a, $1 ;
- or a ; return a = 1
- ret
-.asm_2376
+ jr nz, .print
+ ; if [wHalfWidthPrintState] == 0, don't print text in this iteration
+ ; load the next value of register d into wHalfWidthPrintState
+ ld a, e
+ ld [wHalfWidthPrintState], a
+ ld a, $1
+ or a
+ ret ; nz
+.print
xor a
- ld [wcd0b], a ; [wcd0b] ← 0
+ ld [wHalfWidthPrintState], a
ldh a, [hffa9]
ld l, a ; l ← [hffa9]; index to to linked-list head
.asm_237d
@@ -6385,47 +6396,64 @@ CaseHalfWidthLetter: ; 23b1 (0:23b1)
ld e, a
ret
-Func_23c1: ; 23c1 (0:23c1)
+; iterates over text at hl until TX_END is found, and sets wFontWidth to
+; FULL_WIDTH if the first character is TX_HALFWIDTH
+; returns:
+; b = size of text in half-tiles
+; c = size of text in bytes
+; a = -b
+GetTextSizeInHalfTiles: ; 23c1 (0:23c1)
ld a, [hl]
cp TX_HALFWIDTH
- jr nz, .asm_23cf
- call .asm_23d3
+ jr nz, .full_width
+ call GetTextSizeInTiles
+ ; return a = - ceil(b/2)
inc b
srl b
xor a
sub b
ret
-.asm_23cf
+.full_width
xor a ; FULL_WIDTH
ld [wFontWidth], a
-.asm_23d3
+; fallthrough
+
+GetTextSizeInTiles: ; 23d3 (0:23d3)
+; iterates over text at hl until TX_END is found
+; returns:
+; b = size of text in tiles
+; c = size of text in bytes
+; a = -b
push hl
push de
- ld bc, $0000
-.asm_23d8
+ lb bc, $00, $00
+.char_loop
ld a, [hli]
- or a
- jr z, .asm_23f8
- inc c
+ or a ; TX_END
+ jr z, .tx_end
+ inc c ; any char except TX_END: c ++
+ ; TX_FULLWIDTH, TX_SYMBOL, or > TX_CTRL_END : b ++
cp TX_CTRL_BEGIN
- jr c, .asm_23ec
+ jr c, .character_pair
cp TX_CTRL_END
- jr nc, .asm_23ec
+ jr nc, .character_pair
cp TX_SYMBOL
- jr nz, .asm_23d8
+ jr nz, .char_loop
inc b
- jr .asm_23f4
-.asm_23ec
- ld e, a
- ld d, [hl]
+ jr .next
+.character_pair
+ ld e, a ; first char
+ ld d, [hl] ; second char
inc b
- call ProcessFullWidthFontCharacterPair
- jr nc, .asm_23d8
-.asm_23f4
- inc c
+ call ClassifyTextCharacterPair
+ jr nc, .char_loop
+ ; TX_FULLWIDTH
+.next
+ inc c ; TX_FULLWIDTH or TX_SYMBOL: c ++
inc hl
- jr .asm_23d8
-.asm_23f8
+ jr .char_loop
+.tx_end
+ ; return a = -b
xor a
sub b
pop de
@@ -6628,10 +6656,10 @@ CreateFullWidthFontTile: ; 252e (0:252e)
call BankpopHome
ret
-; given two text characters at de, use the char at d to determine
-; which type of full width text this pair of characters belongs to.
+; given two text characters at de, use the char at e (first one)
+; to determine which type of text this pair of characters belongs to.
; return carry if TX_FULLWIDTH1 to TX_FULLWIDTH4.
-ProcessFullWidthFontCharacterPair: ; 2546 (0:2546)
+ClassifyTextCharacterPair: ; 2546 (0:2546)
ld a, [wFontWidth]
or a ; FULL_WIDTH
jr nz, .half_width
@@ -6647,6 +6675,7 @@ ProcessFullWidthFontCharacterPair: ; 2546 (0:2546)
or a
ret
.half_width
+; in half width mode, the first character goes in e, so leave them like that
or a
ret
.continue_check
@@ -6659,6 +6688,7 @@ ProcessFullWidthFontCharacterPair: ; 2546 (0:2546)
ret
.ath_font
; TX_FULLWIDTH1 to TX_FULLWIDTH4
+; swap d and e to put the TX_FULLWIDTH* character first
ld e, d
ld d, a
scf
@@ -7062,11 +7092,11 @@ PrintCardListItems: ; 2799 (0:2799)
push de
call LoadCardDataToBuffer1_FromDeckIndex
call DrawCardSymbol
- call Func_22ae
+ call InitTextPrinting
ld a, [wListItemNameMaxLength]
call CopyCardNameAndLevel
ld hl, wDefaultText
- call Func_21c5
+ call ProcessText
pop de
pop bc
pop hl
@@ -7462,13 +7492,13 @@ DrawNarrowTextBox_PrintTextNoDelay: ; 2a3e (0:2a3e)
Func_2a44: ; 2a44 (0:2a44)
lb de, 1, 14
call AdjustCoordinatesForBGScroll
- call Func_22a6
+ call InitTextPrintingInTextbox
pop hl
ld a, l
or h
jp nz, PrintTextNoDelay
ld hl, wDefaultText
- jp Func_21c5
+ jp ProcessText
; draw a 20x6 text box aligned to the bottom of the screen
; and print the text at hl with letter delay
@@ -7478,7 +7508,7 @@ DrawWideTextBox_PrintText: ; 2a59 (0:2a59)
ld a, 19
lb de, 1, 14
call AdjustCoordinatesForBGScroll
- call Func_22a6
+ call InitTextPrintingInTextbox
call EnableLCD
pop hl
jp PrintText
@@ -7769,7 +7799,7 @@ PlaceTextItems: ; 2c08 (0:2c08)
ret nz ; return if no more items of text
ld e, [hl] ; y coord
inc hl ; hl = text id
- call Func_22ae
+ call InitTextPrinting
push hl
call Func_2c23
pop hl
@@ -7778,11 +7808,11 @@ PlaceTextItems: ; 2c08 (0:2c08)
jr PlaceTextItems ; do next item
Func_2c1b: ; 2c1b (0:2c1b)
- call Func_22ae
+ call InitTextPrinting
jr Func_2c29
Func_2c20: ; 2c20 (0:2c20)
- call Func_22ae
+ call InitTextPrinting
Func_2c23: ; 2c23 (0:2c23)
ld a, [hli]
or [hl]
@@ -7794,7 +7824,7 @@ Func_2c29: ; 2c29 (0:2c29)
ldh a, [hBankROM]
push af
call GetTextOffsetFromTextID
- call Func_21c5
+ call ProcessText
pop af
call BankswitchHome
ret
@@ -7892,7 +7922,7 @@ PrintScrollableText: ; 2c84 (0:2c84)
dec c
jr nz, .nonzero_text_speed
.skip_delay
- call Func_2d43
+ call ProcessTextStruct
jr c, .asm_2cc3
ld a, [wCurTextLine]
cp 3
@@ -7982,51 +8012,54 @@ Func_2d15: ; 2d15 (0:2d15)
jr nz, .labeled
call DrawRegularTextBox
call EnableLCD
- jr .asm_2d36
+ jr .init_text
.labeled
ld hl, wTextBoxLabel
ld a, [hli]
ld h, [hl]
ld l, a
call DrawLabeledTextBox
-.asm_2d36
+.init_text
lb de, 1, 14
call AdjustCoordinatesForBGScroll
ld a, 19
- call Func_22a6
+ call InitTextPrintingInTextbox
pop hl
ret
-Func_2d43: ; 2d43 (0:2d43)
+; reads the incoming character from the current wTextStruct and processes it
+; then updates the current wTextStruct to point to the next character.
+; a TX_RAM command causes a switch to a wTextStruct in the level below, and a TX_END
+; command terminates the text unless there is a pending wTextStruct in the above level.
+ProcessTextStruct: ; 2d43 (0:2d43)
call ReadTextStruct
ld a, [hli]
or a ; TX_END
jr z, .tx_end
cp TX_CTRL_BEGIN
- jr c, .full_width_font
+ jr c, .character_pair
cp TX_CTRL_END
- jr nc, .full_width_font
- ; special character
- call Func_21f2
- jr nc, .asm_2d74
+ jr nc, .character_pair
+ call ProcessSpecialTextCharacter
+ jr nc, .processed_char
cp TX_RAM1
jr z, .tx_ram1
cp TX_RAM2
jr z, .tx_ram2
cp TX_RAM3
jr z, .tx_ram3
- jr .asm_2d74
-.full_width_font
+ jr .processed_char
+.character_pair
ld e, a ; first char
ld d, [hl] ; second char
- call ProcessFullWidthFontCharacterPair
- jr nc, .asm_2d6d
+ call ClassifyTextCharacterPair
+ jr nc, .not_tx_fullwidth
inc hl
-.asm_2d6d
+.not_tx_fullwidth
call Func_22ca
xor a
- call Func_21f2
-.asm_2d74
+ call ProcessSpecialTextCharacter
+.processed_char
call WriteToTextStruct
or a
ret
@@ -8037,9 +8070,9 @@ Func_2d43: ; 2d43 (0:2d43)
; handle text struct in the above level
dec a
ld [wWhichTextStruct], a
- jr Func_2d43
+ jr ProcessTextStruct
.no_more_text
- call Func_230f
+ call TerminateHalfWidthText
scf
ret
.tx_ram2
@@ -8053,14 +8086,14 @@ Func_2d43: ; 2d43 (0:2d43)
call HandleTxRam2Or3
ld a, l
or h
- jr z, .asm_2dab
+ jr z, .empty
call GetTextOffsetFromTextID
call WriteToTextStruct
- jr Func_2d43
-.asm_2dab
+ jr ProcessTextStruct
+.empty
ld hl, wDefaultText
call WriteToTextStruct
- jr Func_2d43
+ jr ProcessTextStruct
.tx_ram3
call WriteToTextStruct_MoveToNext
ld de, wTxRam3
@@ -8068,18 +8101,18 @@ Func_2d43: ; 2d43 (0:2d43)
call HandleTxRam2Or3
call TwoByteNumberToText_CountLeadingZeros
call WriteToTextStruct
- jp Func_2d43
+ jp ProcessTextStruct
.tx_ram1
call WriteToTextStruct_MoveToNext
call CopyPlayerNameOrTurnDuelistName
ld a, [wTextBuf]
cp TX_HALFWIDTH
- jr z, .asm_2dda
+ jr z, .tx_halfwidth
ld a, TX_HALF2FULL
- call Func_21f2
-.asm_2dda
+ call ProcessSpecialTextCharacter
+.tx_halfwidth
call WriteToTextStruct
- jp Func_2d43
+ jp ProcessTextStruct
; input:
; de: wTxRam2 or wTxRam3
@@ -8205,7 +8238,7 @@ PrintText: ; 2e41 (0:2e41)
dec a
jr nz, .text_delay_loop
.skip_delay
- call Func_2d43
+ call ProcessTextStruct
jr nc, .next_tile_loop
ret
@@ -8217,7 +8250,7 @@ PrintTextNoDelay: ; 2e76 (0:2e76)
call GetTextOffsetFromTextID
call InitRegistersForPrintingText
.next_tile_loop
- call Func_2d43
+ call ProcessTextStruct
jr nc, .next_tile_loop
pop af
call BankswitchHome
diff --git a/src/wram.asm b/src/wram.asm
index 51ff973..17736b8 100644
--- a/src/wram.asm
+++ b/src/wram.asm
@@ -948,8 +948,15 @@ wCurTextLine:: ; cd09
wFontWidth:: ; cd0a
ds $1
-wcd0b:: ; cd0b
- ds $2
+; when printing half-width text, this variable alternates between 0 and the value
+; of the first character. 0 signals that no text should be printed in the current
+; iteration of Func_235e, while non-0 means to print the character pair
+; made of [wHalfWidthPrintState] (first char) and register e (second char).
+wHalfWidthPrintState:: ; cd0b
+ ds $1
+
+wcd0c:: ; cd0c
+ ds $1
; half-width font letters become uppercase if non-0, lowercase if 0
wUppercaseHalfWidthLetters:: ; cd0d