diff options
Diffstat (limited to 'home/text.asm')
-rw-r--r-- | home/text.asm | 375 |
1 files changed, 202 insertions, 173 deletions
diff --git a/home/text.asm b/home/text.asm index c76504c53..1445aa5ef 100644 --- a/home/text.asm +++ b/home/text.asm @@ -16,20 +16,20 @@ ClearBox:: ; fb6 ld a, " " -Functionfb8:: -.col +FillBoxWithByte:: +.row push bc push hl -.row +.col ld [hli], a dec c - jr nz, .row + jr nz, .col pop hl ld bc, SCREEN_WIDTH add hl, bc pop bc dec b - jr nz, .col + jr nz, .row ret ; fc8 @@ -61,8 +61,11 @@ ClearScreen:: ; fdb TextBox:: ; fe8 -; Draw a text box width c height b at hl. -; Dimensions do not include the border. +; Draw a text box at hl with room for +; b lines of c characters each. +; Places a border around the textbox, +; then switches the palette to the +; text black-and-white scheme. push bc push hl call TextBoxBorder @@ -221,49 +224,65 @@ else endc jp z, \2 endm - dict $15, Char15 - dict $4f, Line - dict $4e, NextLine - dict $16, Char16 + +dict2: macro +if \1 == 0 + and a +else + cp \1 +endc + jr nz, \@ + ld a, \2 +\@: +endm + +dict3: macro +if \1 == 0 + and a +else + cp \1 +endc + jr z, \2 +endm + + dict "<DAY>", Char15 + dict "<LINE>", LineChar + dict "<NEXT>", NextLineChar + dict TX_FAR, TextFar dict $00, NullChar - dict $4c, Function1337 + dict $4c, Char4C dict $4b, Char4B - dict $51, Paragraph - dict $49, PrintMomsName - dict $52, PrintPlayerName - dict $53, PrintRivalName + dict "<PARA>", Paragraph + dict "<MOM>", PrintMomsName + dict "<PLAYER>", PrintPlayerName + dict "<RIVAL>", PrintRivalName dict $35, Char35 dict $36, Char36 dict $37, Char37 - dict $38, PrintRedsName - dict $39, PrintGreensName - dict $54, Char54 - dict $5b, Char5B - dict $5e, Char5E - dict $5c, Char5C - dict $5d, Char5D - dict $23, Char23 - dict $22, Char22 - dict $55, ContText - dict $56, Char56 - dict $57, DoneText - dict $58, PromptText - dict $4a, Char4A - dict $24, Char24 + dict "<RED>", PrintRedsName + dict "<GREEN>", PrintGreensName + dict "#", PlacePOKe + dict "<PC>", PCChar + dict "<ROCKET>", RocketChar + dict "<TM>", TMChar + dict "<TRNER>", TrainerChar + dict $23, PlaceKougeki + dict "<LNBRK>", Char22 + dict "<CONT>", ContText + dict "<......>", SixDotsChar + dict "<DONE>", DoneText + dict "<PROMPT>", PromptText + dict "<PKMN>", PlacePKMN + dict "<POKE>", PlacePOKE dict $25, NextChar - cp $1f - jr nz, .ok - ld a, $7f -.ok - dict $5f, Char5F - dict $59, Char59 - dict $5a, Char5A - dict $3f, Char3F - dict $14, Char14 - cp $e4 ; handakuten - jr z, .place - cp $e5 ; dakuten - jr z, .place + dict2 $1f, " " + dict "<DEXEND>", PlaceDexEnd + dict "<TARGET>", PlaceMoveTargetsName + dict "<USER>", PlaceMoveUsersName + dict "<ENEMY>", PlaceEnemysName + dict "<PLAY_G>", PlaceGenderedPlayerName + dict3 $e4, .place + dict3 $e5, .place jr .nope ld b, a @@ -319,7 +338,7 @@ Char15:: ; 117b print_name: macro push de ld de, \1 - jp Function126a + jp PlaceCommandCharacter endm PrintMomsName: print_name MomsName ; 1186 @@ -328,49 +347,49 @@ PrintRivalName: print_name RivalName ; 1194 PrintRedsName: print_name RedsName ; 119b PrintGreensName: print_name GreensName ; 11a2 -Char5D: print_name Char5DText ; 11a9 -Char5C: print_name Char5CText ; 11b0 -Char5B: print_name Char5BText ; 11b7 -Char5E: print_name Char5EText ; 11be -Char54: print_name Char54Text ; 11c5 -Char23: print_name Char23Text ; 11cc -Char56: print_name Char56Text ; 11d3 -Char4A: print_name Char4AText ; 11da -Char24: print_name Char24Text ; 11e1 +TrainerChar: print_name TrainerCharText ; 11a9 +TMChar: print_name TMCharText ; 11b0 +PCChar: print_name PCCharText ; 11b7 +RocketChar: print_name RocketCharText ; 11be +PlacePOKe: print_name PlacePOKeText ; 11c5 +PlaceKougeki: print_name KougekiText ; 11cc +SixDotsChar: print_name SixDotsCharText ; 11d3 +PlacePKMN: print_name PlacePKMNText ; 11da +PlacePOKE: print_name PlacePOKEText ; 11e1 Char35: print_name Char35Text ; 11e8 Char36: print_name Char36Text ; 11ef Char37: print_name Char37Text ; 11f6 -Char59:: ; 11fd +PlaceMoveTargetsName:: ; 11fd ld a, [hBattleTurn] xor 1 - jr Char59_5A + jr PlaceMoveTargetsName_5A -Char5A:: ; 1203 +PlaceMoveUsersName:: ; 1203 ld a, [hBattleTurn] -Char59_5A: ; 1205 +PlaceMoveTargetsName_5A: ; 1205 push de and a jr nz, .enemy ld de, BattleMonNick - jr Function126a + jr PlaceCommandCharacter .enemy - ld de, Char5AText ; Enemy + ld de, EnemyText ; Enemy call PlaceString ld h, b ld l, c ld de, EnemyMonNick - jr Function126a + jr PlaceCommandCharacter -Char3F:: ; 121b +PlaceEnemysName:: ; 121b push de - ld a, [InLinkBattle] + ld a, [wLinkMode] and a jr nz, .linkbattle @@ -390,18 +409,18 @@ Char3F:: ; 121b callab Battle_GetTrainerName pop hl ld de, StringBuffer1 - jr Function126a + jr PlaceCommandCharacter .rival ld de, RivalName - jr Function126a + jr PlaceCommandCharacter .linkbattle ld de, OTName - jr Function126a + jr PlaceCommandCharacter -Char14:: ; 1252 +PlaceGenderedPlayerName:: ; 1252 push de ld de, PlayerName call PlaceString @@ -409,13 +428,13 @@ Char14:: ; 1252 ld l, c ld a, [PlayerGender] bit 0, a - ld de, String12a5 - jr z, Function126a - ld de, String12a6 - jr Function126a + ld de, String_kun + jr z, PlaceCommandCharacter + ld de, String_chan + jr PlaceCommandCharacter -Function126a:: ; 126a +PlaceCommandCharacter:: ; 126a call PlaceString ld h, b ld l, c @@ -423,25 +442,25 @@ Function126a:: ; 126a jp NextChar ; 0x1273 -Char5CText:: db "TM@" ; 1273 -Char5DText:: db "TRAINER@" ; 1276 -Char5BText:: db "PC@" ; 127e -Char5EText:: db "ROCKET@" ; 1281 -Char54Text:: db "POKé@" ; 1288 -Char23Text:: db "こうげき@" ; 128d -Char56Text:: db "……@" ; 1292 -Char5AText:: db "Enemy @" ; 1295 -Char4AText:: db $e1, $e2, "@" ; PK MN ; 129c -Char24Text:: db $70, $71, "@" ; PO KE ; 129f +TMCharText:: db "TM@" ; 1273 +TrainerCharText:: db "TRAINER@" ; 1276 +PCCharText:: db "PC@" ; 127e +RocketCharText:: db "ROCKET@" ; 1281 +PlacePOKeText:: db "POKé@" ; 1288 +KougekiText:: db "こうげき@" ; 128d +SixDotsCharText:: db "……@" ; 1292 +EnemyText:: db "Enemy @" ; 1295 +PlacePKMNText:: db "<PK><MN>@" ; PK MN ; 129c +PlacePOKEText:: db "<PO><KE>@" ; PO KE ; 129f String12a2:: db " @" ; 12a2 Char35Text:: Char36Text:: Char37Text:: db "@" ; 12a4 -String12a5:: db "@" ; 12a5 -String12a6:: db "@" ; 12a6 +String_kun:: db "@" ; 12a5 +String_chan:: db "@" ; 12a6 ; 12a7 -NextLine:: ; 12a7 +NextLineChar:: ; 12a7 pop hl ld bc, SCREEN_WIDTH * 2 add hl, bc @@ -457,38 +476,38 @@ Char22:: ; 12b0 jp NextChar ; 12b9 -Char16:: ; 12b9 +TextFar:: ; 12b9 pop hl push de ld bc, -TileMap + $10000 add hl, bc ld de, -SCREEN_WIDTH ld c, 1 -.asm_12c4 +.loop ld a, h and a - jr nz, .asm_12cd + jr nz, .next ld a, l cp SCREEN_WIDTH - jr c, .asm_12d1 + jr c, .done -.asm_12cd +.next add hl, de inc c - jr .asm_12c4 + jr .loop -.asm_12d1 +.done hlcoord 0, 0 ld de, SCREEN_WIDTH ld a, c -.asm_12d8 +.loop2 and a - jr z, .asm_12df + jr z, .done2 add hl, de dec a - jr .asm_12d8 + jr .loop2 -.asm_12df +.done2 pop de inc de ld a, [de] @@ -500,7 +519,7 @@ Char16:: ; 12b9 ; 12ea -Line:: ; 12ea +LineChar:: ; 12ea pop hl hlcoord TEXTBOX_INNERX, TEXTBOX_INNERY + 2 push hl @@ -510,20 +529,20 @@ Line:: ; 12ea Paragraph:: ; 12f2 push de - ld a, [InLinkBattle] - cp $3 - jr z, .asm_1301 - cp $4 - jr z, .asm_1301 - call Function13c7 -.asm_1301 + ld a, [wLinkMode] + cp LINK_COLOSSEUM + jr z, .linkbattle + cp LINK_MOBILE + jr z, .linkbattle + call LoadBlinkingCursor +.linkbattle call Function13b6 call KeepTextOpen hlcoord TEXTBOX_INNERX, TEXTBOX_INNERY lb bc, TEXTBOX_INNERH - 1, TEXTBOX_INNERW call ClearBox - call Function13cd + call UnloadBlinkingCursor ld c, 20 call DelayFrames hlcoord TEXTBOX_INNERX, TEXTBOX_INNERY @@ -533,26 +552,26 @@ Paragraph:: ; 12f2 Char4B:: ; 131f - ld a, [InLinkBattle] + ld a, [wLinkMode] or a - jr nz, .asm_1328 - call Function13c7 -.asm_1328 + jr nz, .communication + call LoadBlinkingCursor +.communication call Function13b6 push de call KeepTextOpen pop de - ld a, [InLinkBattle] + ld a, [wLinkMode] or a - call z, Function13cd + call z, UnloadBlinkingCursor -Function1337:: ; 1337 +Char4C:: ; 1337 push de - call Function138c - call Function138c + call TextScroll + call TextScroll hlcoord TEXTBOX_INNERX, TEXTBOX_INNERY + 2 pop de jp NextChar @@ -574,7 +593,7 @@ ContText:: ; 1345 ; 1356 -Char5F:: ; 1356 +PlaceDexEnd:: ; 1356 ; Legacy: ends a Pokédex entry (Red). ; Dex entries are now regular strings. ld [hl], "." @@ -583,22 +602,22 @@ Char5F:: ; 1356 ; 135a PromptText:: ; 135a - ld a, [InLinkBattle] - cp $3 + ld a, [wLinkMode] + cp LINK_COLOSSEUM jr z, .ok - cp $4 + cp LINK_MOBILE jr z, .ok - call Function13c7 -.ok + call LoadBlinkingCursor +.ok call Function13b6 call KeepTextOpen - ld a, [InLinkBattle] - cp $3 + ld a, [wLinkMode] + cp LINK_COLOSSEUM jr z, DoneText - cp $4 + cp LINK_MOBILE jr z, DoneText - call Function13cd + call UnloadBlinkingCursor DoneText:: ; 137c pop hl @@ -615,19 +634,22 @@ NullChar:: ; 1383 jp NextChar ; 138c -Function138c:: ; 138c +TextScroll:: ; 138c hlcoord TEXTBOX_INNERX, TEXTBOX_INNERY decoord TEXTBOX_INNERX, TEXTBOX_INNERY - 1 ld a, TEXTBOX_INNERH - 1 + .col push af ld c, TEXTBOX_INNERW + .row ld a, [hli] ld [de], a inc de dec c jr nz, .row + rept 2 inc de endr @@ -637,6 +659,7 @@ endr pop af dec a jr nz, .col + hlcoord TEXTBOX_INNERX, TEXTBOX_INNERY + 2 ld a, " " ld bc, TEXTBOX_INNERW @@ -652,7 +675,9 @@ Function13b6:: ; 13b6 push af ld a, 1 ld [hOAMUpdate], a + call WaitBGMap + pop af ld [hOAMUpdate], a pop bc @@ -663,15 +688,15 @@ Diacritic:: ; 13c6 ret ; 13c7 -Function13c7:: ; 13c7 +LoadBlinkingCursor:: ; 13c7 ld a, "▼" - ld [TileMap + 18 + 17 * SCREEN_WIDTH], a + ldcoord_a 18, 17 ret ; 13cd -Function13cd:: ; 13cd - ld a, [TileMap + 17 + 17 * SCREEN_WIDTH] - ld [TileMap + 18 + 17 * SCREEN_WIDTH], a +UnloadBlinkingCursor:: ; 13cd + lda_coord 17, 17 + ldcoord_a 18, 17 ret ; 13d4 @@ -703,19 +728,19 @@ PlaceWholeStringInBoxAtOnce:: ; 13e5 set 1, a ld [TextBoxFrame + 1], a - call Function13f6 + call DoTextUntilTerminator pop af ld [TextBoxFrame + 1], a ret ; 13f6 -Function13f6:: ; 13f6 +DoTextUntilTerminator:: ; 13f6 ld a, [hli] cp "@" ret z call .TextCommand - jr Function13f6 + jr DoTextUntilTerminator .TextCommand: push hl @@ -738,19 +763,19 @@ endr ; 1410 TextCommands:: ; 1410 - dw Text_00 - dw Text_01 - dw Text_02 - dw Text_03 - dw Text_04 - dw Text_05 - dw Text_06 - dw Text_07 - dw Text_08 - dw Text_09 - dw Text_0A + dw Text_TX + dw Text_TX_RAM + dw Text_TX_BCD + dw Text_TX_MOVE + dw Text_TX_BOX + dw Text_TX_LOW + dw Text_WAIT_BUTTON + dw Text_TX_SCROLL + dw Text_START_ASM + dw Text_TX_NUM + dw Text_TX_EXIT dw Text_PlaySound ; $0b - dw Text_0C + dw Text_TX_DOTS dw Text_0D dw Text_PlaySound ; $0e dw Text_PlaySound ; $0f @@ -758,12 +783,12 @@ TextCommands:: ; 1410 dw Text_PlaySound ; $11 dw Text_PlaySound ; $12 dw Text_PlaySound ; $13 - dw Text_14 - dw Text_15 - dw Text_16 + dw Text_TX_STRINGBUFFER + dw Text_TX_DAY + dw Text_TX_FAR ; 143e -Text_00:: ; 143e +Text_TX:: ; 143e ; TX ; write text until "@" ; [$00]["...@"] @@ -779,7 +804,7 @@ Text_00:: ; 143e ret ; 1449 -Text_01:: ; 1449 +Text_TX_RAM:: ; 1449 ; text_from_ram ; write text from a ram address ; little endian @@ -797,7 +822,7 @@ Text_01:: ; 1449 ret ; 1455 -Text_16:: ; 1455 +Text_TX_FAR:: ; 1455 ; text_jump ; write text from a different bank ; little endian @@ -818,7 +843,7 @@ Text_16:: ; 1455 push hl ld h, d ld l, e - call Function13f6 + call DoTextUntilTerminator pop hl pop af @@ -827,7 +852,7 @@ Text_16:: ; 1455 ret ; 1470 -Text_02:: ; 1470 +Text_TX_BCD:: ; 1470 ; TX_BCD ; write bcd from address, typically ram ; [$02][addr][flags] @@ -849,7 +874,7 @@ Text_02:: ; 1470 ret ; 1480 -Text_03:: ; 1480 +Text_TX_MOVE:: ; 1480 ; TX_MOVE ; move to a new tile ; [$03][addr] @@ -863,7 +888,7 @@ Text_03:: ; 1480 ret ; 148b -Text_04:: ; 148b +Text_TX_BOX:: ; 148b ; TX_BOX ; draw a box ; little endian @@ -885,7 +910,7 @@ Text_04:: ; 148b ret ; 149b -Text_05:: ; 149b +Text_TX_LOW:: ; 149b ; TX_LOW ; write text at (1,16) ; [$05] @@ -894,39 +919,41 @@ Text_05:: ; 149b ret ; 149f -Text_06:: ; 149f +Text_WAIT_BUTTON:: ; 149f ; TX_WAITBUTTON ; wait for button press ; show arrow ; [06] - ld a, [InLinkBattle] - cp $3 + ld a, [wLinkMode] + cp LINK_COLOSSEUM jp z, Text_0D - cp $4 + cp LINK_MOBILE jp z, Text_0D push hl - call Function13c7 + call LoadBlinkingCursor push bc call KeepTextOpen pop bc - call Function13cd + call UnloadBlinkingCursor pop hl ret ; 14ba -Text_07:: ; 14ba +Text_TX_SCROLL:: ; 14ba +; pushes text up two lines and sets the BC cursor to the border tile +; below the first character column of the text box. push hl - call Function13cd - call Function138c - call Function138c + call UnloadBlinkingCursor + call TextScroll + call TextScroll pop hl bccoord TEXTBOX_INNERX, TEXTBOX_INNERY + 2 ret ; 14c9 -Text_08:: ; 14c9 +Text_START_ASM:: ; 14c9 ; TX_ASM bit 7, h @@ -939,7 +966,7 @@ Text_08:: ; 14c9 ret ; 14d2 -Text_09:: ; 14d2 +Text_TX_NUM:: ; 14d2 ; TX_NUM ; [$09][addr][hi:bytes lo:digits] ld a, [hli] @@ -956,7 +983,7 @@ Text_09:: ; 14d2 ld a, b and $f0 swap a - set 6, a + set PRINTNUM_RIGHTALIGN_F, a ld b, a call PrintNum ld b, h @@ -965,7 +992,7 @@ Text_09:: ; 14d2 ret ; 14ed -Text_0A:: ; 14ed +Text_TX_EXIT:: ; 14ed push hl push bc call GetJoypad @@ -1040,13 +1067,14 @@ TextSFX:: ; 152d db -1 ; 1543 -Text_0C:: ; 1543 +Text_TX_DOTS:: ; 1543 ; [$0C][num] ld a, [hli] ld d, a push hl ld h, b ld l, c + .loop push de ld a, "…" @@ -1061,6 +1089,7 @@ Text_0C:: ; 1543 pop de dec d jr nz, .loop + ld b, h ld c, l pop hl @@ -1078,7 +1107,7 @@ Text_0D:: ; 1562 ret ; 156a -Text_14:: ; 156a +Text_TX_STRINGBUFFER:: ; 156a ; Print a string from one of the following: ; 0: StringBuffer3 ; 1: StringBuffer4 @@ -1108,7 +1137,7 @@ endr ret ; 1582 -Text_15:: ; 1582 +Text_TX_DAY:: ; 1582 ; TX_DAY call GetWeekday |