diff options
Diffstat (limited to 'home/text.asm')
-rw-r--r-- | home/text.asm | 236 |
1 files changed, 113 insertions, 123 deletions
diff --git a/home/text.asm b/home/text.asm index eadaf0b3..b3f96315 100644 --- a/home/text.asm +++ b/home/text.asm @@ -1,4 +1,4 @@ -TextBoxBorder:: ; 16f0 (0:16f0) +TextBoxBorder:: ; Draw a cxb text box at hl. ; top row @@ -37,7 +37,7 @@ TextBoxBorder:: ; 16f0 (0:16f0) ld [hl], "┘" ret -NPlaceChar:: ; 171d (0:171d) +NPlaceChar:: ; Place char a c times. ld d, c .loop @@ -46,9 +46,9 @@ NPlaceChar:: ; 171d (0:171d) jr nz, .loop ret -PlaceString:: ; 1723 (0:1723) +PlaceString:: push hl -PlaceNextChar:: ; 1724 (0:1724) +PlaceNextChar:: ld a, [de] cp "@" @@ -58,22 +58,22 @@ PlaceNextChar:: ; 1724 (0:1724) pop hl ret -Char4ETest:: ; 172d (0:172d) - cp $4E - jr nz, .next - ld bc, $0028 +Char4ETest:: + cp $4E ; next + jr nz, .char4FTest + ld bc, 2 * SCREEN_WIDTH ld a, [hFlags_0xFFFA] bit 2, a - jr z, .next2 + jr z, .ok ld bc, SCREEN_WIDTH -.next2 +.ok pop hl add hl, bc push hl - jp PlaceNextChar_inc ; 17b6 + jp PlaceNextChar_inc -.next - cp $4F +.char4FTest + cp $4F ; line jr nz, .next3 pop hl coord hl, 1, 16 @@ -81,53 +81,43 @@ Char4ETest:: ; 172d (0:172d) jp PlaceNextChar_inc .next3 ; Check against a dictionary +dict: macro +if \1 == 0 and a - jp z, Char00 - cp $4C - jp z, Char4C - cp $4B - jp z, Char4B - cp $51 - jp z, Char51 - cp $49 - jp z, Char49 - cp $52 - jp z, Char52 - cp $53 - jp z, Char53 - cp $54 - jp z, Char54 - cp $5B - jp z, Char5B - cp $5E - jp z, Char5E - cp $5C - jp z, Char5C - cp $5D - jp z, Char5D - cp $55 - jp z, Char55 - cp $56 - jp z, Char56 - cp $57 - jp z, Char57 - cp $58 - jp z, Char58 - cp $4A - jp z, Char4A - cp $5F - jp z, Char5F - cp $59 - jp z, Char59 - cp $5A - jp z, Char5A +else + cp \1 +endc + jp z, \2 +endm + + dict $00, Char00 ; error + dict $4C, Char4C ; autocont + dict $4B, Char4B ; cont_ + dict $51, Char51 ; para + dict $49, Char49 ; page + dict $52, Char52 ; player + dict $53, Char53 ; rival + dict $54, Char54 ; POKé + dict $5B, Char5B ; PC + dict $5E, Char5E ; ROCKET + dict $5C, Char5C ; TM + dict $5D, Char5D ; TRAINER + dict $55, Char55 ; cont + dict $56, Char56 ; 6 dots + dict $57, Char57 ; done + dict $58, Char58 ; prompt + dict $4A, Char4A ; PKMN + dict $5F, Char5F ; dex + dict $59, Char59 ; TARGET + dict $5A, Char5A ; USER + ld [hli], a call PrintLetterDelay -PlaceNextChar_inc:: ; 17b6 (0:17b6) +PlaceNextChar_inc:: inc de jp PlaceNextChar -Char00:: ; 17ba (0:17ba) +Char00:: ld b, h ld c, l pop hl @@ -135,56 +125,56 @@ Char00:: ; 17ba (0:17ba) dec de ret -Char00Text:: ; 17c2 (0:17c2) ; “%d ERROR.” - TX_FAR _Char00Text ; a0c66 (28:4c66) +Char00Text:: ; “%d ERROR.” + TX_FAR _Char00Text db "@" -Char52:: ; 17c7 (0:17c7) ; player’s name +Char52:: ; player’s name push de ld de, wPlayerName jr FinishDTE -Char53:: ; 17cd (0:17cd) ; rival’s name +Char53:: ; rival’s name push de ld de, wRivalName jr FinishDTE -Char5D:: ; 17d3 (0:17d3) ; TRAINER +Char5D:: ; TRAINER push de ld de, Char5DText jr FinishDTE -Char5C:: ; 17d9 (0:17d9) ; TM +Char5C:: ; TM push de ld de, Char5CText jr FinishDTE -Char5B:: ; 17df (0:17df) ; PC +Char5B:: ; PC push de ld de, Char5BText jr FinishDTE -Char5E:: ; 17e5 (0:17e5) ; ROCKET +Char5E:: ; ROCKET push de ld de, Char5EText jr FinishDTE -Char54:: ; 17eb (0:17eb) ; POKé +Char54:: ; POKé push de ld de, Char54Text jr FinishDTE -Char56:: ; 17f1 (0:17f1) ; …… +Char56:: ; …… push de ld de, Char56Text jr FinishDTE -Char4A:: ; 17f7 (0:17f7) ; PKMN +Char4A:: ; PKMN push de ld de, Char4AText jr FinishDTE -Char59:: ; 17fb (0:17fb) +Char59:: ; depending on whose turn it is, print ; enemy active monster’s name, prefixed with “Enemy ” ; or @@ -194,13 +184,13 @@ Char59:: ; 17fb (0:17fb) xor 1 jr MonsterNameCharsCommon -Char5A:: ; 1803 (0:1803) +Char5A:: ; depending on whose turn it is, print ; player active monster’s name ; or ; enemy active monster’s name, prefixed with “Enemy ” ld a, [H_WHOSETURN] -MonsterNameCharsCommon:: ; 1a37 (0:1a37) +MonsterNameCharsCommon:: push de and a jr nz, .Enemy @@ -215,7 +205,7 @@ MonsterNameCharsCommon:: ; 1a37 (0:1a37) ld l, c ld de, wEnemyMonNick ; enemy active monster name -FinishDTE:: ; 1819 (0:1819) +FinishDTE:: call PlaceString ld h, b ld l, c @@ -223,67 +213,67 @@ FinishDTE:: ; 1819 (0:1819) inc de jp PlaceNextChar -Char5CText:: ; 1823 (0:1823) +Char5CText:: db "TM@" -Char5DText:: ; 1826 (0:1826) +Char5DText:: db "TRAINER@" -Char5BText:: ; 182e (0:182e) +Char5BText:: db "PC@" -Char5EText:: ; 1831 (0:1830) +Char5EText:: db "ROCKET@" -Char54Text:: ; 1838 (0:1838) +Char54Text:: db "POKé@" -Char56Text:: ; 183d (0:183d) +Char56Text:: db "……@" -Char5AText:: ; 1840 (0:1840) +Char5AText:: db "Enemy @" -Char4AText:: ; 1847 (0:1847) +Char4AText:: db $E1, $E2, "@" ; PKMN -Char55:: ; 184a (0:184a) +Char55:: push de ld b, h ld c, l ld hl, Char55Text - call TextCommandProcessor ; 1919 + call TextCommandProcessor ld h, b ld l, c pop de inc de jp PlaceNextChar -Char55Text:: ; 185a (0:185a) +Char55Text:: ; equivalent to Char4B - TX_FAR _Char55Text ; a0c73 (28:4c73) + TX_FAR _Char55Text db "@" -Char5F:: ; 185f (0:185f) +Char5F:: ; ends a Pokédex entry ld [hl], "." pop hl ret -Char58:: ; 1863 (0:1863) +Char58:: ; prompt ld a, [wLinkState] cp LINK_STATE_BATTLING - jp z, Next1870 + jp z, .ok ld a, $EE Coorda 18, 16 -Next1870:: ; 1870 (0:1870) - call ProtectedDelay3 ; 1913 - call ManualTextScroll ; 388e - ld a, " " ; space +.ok + call ProtectedDelay3 + call ManualTextScroll + ld a, " " Coorda 18, 16 -Char57:: ; 1aad (0:1aad) +Char57:: ; done pop hl ld de, Char58Text dec de ret -Char58Text:: ; 1881 (0:1881) +Char58Text:: db "@" -Char51:: ; 1882 (0:1882) +Char51:: ; para push de ld a, $EE Coorda 18, 16 @@ -298,7 +288,7 @@ Char51:: ; 1882 (0:1882) coord hl, 1, 14 jp PlaceNextChar_inc -Char49:: ; 18a3 (0:18a3) +Char49:: ld a, [hFlags_0xFFFA] bit 3, a jr z, .Char49 @@ -322,7 +312,7 @@ Char49:: ; 18a3 (0:18a3) push hl jp PlaceNextChar_inc -Char4B:: ; 18d1 (0:18d1) +Char4B:: ld a, $EE Coorda 18, 16 call ProtectedDelay3 @@ -332,15 +322,15 @@ Char4B:: ; 18d1 (0:18d1) ld a, " " Coorda 18, 16 ;fall through -Char4C:: ; 18e3 (0:18e3) +Char4C:: push de - call Next18F1 ; 18f1 - call Next18F1 + call ScrollTextUpOneLine + call ScrollTextUpOneLine coord hl, 1, 16 pop de jp PlaceNextChar_inc -Next18F1:: ; 18f1 (0:18f1) +ScrollTextUpOneLine:: coord hl, 0, 14 coord de, 0, 13 ld b, 60 @@ -367,13 +357,13 @@ Next18F1:: ; 18f1 (0:18f1) ret -ProtectedDelay3:: ; 1913 (0:1913) +ProtectedDelay3:: push bc call Delay3 pop bc ret -TextCommandProcessor:: ; 1919 (0:1919) +TextCommandProcessor:: ld a, [wLetterPrintingDelayFlags] push af set 1, a @@ -386,7 +376,7 @@ TextCommandProcessor:: ; 1919 (0:1919) ld a, b ld [wTextDestinationTileAddrBuffer + 1], a -NextTextCommand:: ; 192e (0:192e) +NextTextCommand:: ld a, [hli] cp a, "@" ; terminator jr nz, .doTextCommand @@ -403,21 +393,21 @@ NextTextCommand:: ; 192e (0:192e) ld hl, TextCommandJumpTable push bc add a - ld b, $00 + ld b, 0 ld c, a add hl, bc pop bc ld a, [hli] ld h, [hl] ld l, a - jp [hl] + jp hl ; draw box ; 04AAAABBCC ; AAAA = address of upper left corner ; BB = height ; CC = width -TextCommand04:: ; 1951 (0:1951) +TextCommand04:: pop hl ld a, [hli] ld e, a @@ -436,7 +426,7 @@ TextCommand04:: ; 1951 (0:1951) ; place string inline ; 00{string} -TextCommand00:: ; 1963 (0:1963) +TextCommand00:: pop hl ld d, h ld e, l @@ -451,7 +441,7 @@ TextCommand00:: ; 1963 (0:1963) ; place string from RAM ; 01AAAA ; AAAA = address of string -TextCommand01:: ; 1970 (0:1970) +TextCommand01:: pop hl ld a, [hli] ld e, a @@ -470,7 +460,7 @@ TextCommand01:: ; 1970 (0:1970) ; BB ; bits 0-4 = length in bytes ; bits 5-7 = unknown flags -TextCommand02:: ; 197e (0:197e) +TextCommand02:: pop hl ld a, [hli] ld e, a @@ -490,7 +480,7 @@ TextCommand02:: ; 197e (0:197e) ; repoint destination address ; 03AAAA ; AAAA = new destination address -TextCommand03:: ; 1990 (0:1990) +TextCommand03:: pop hl ld a, [hli] ld [wTextDestinationTileAddrBuffer], a @@ -503,7 +493,7 @@ TextCommand03:: ; 1990 (0:1990) ; repoint destination to second line of dialogue text box ; 05 ; (no arguments) -TextCommand05:: ; 199e (0:199e) +TextCommand05:: pop hl coord bc, 1, 16 ; address of second line of dialogue text box jp NextTextCommand @@ -511,7 +501,7 @@ TextCommand05:: ; 199e (0:199e) ; blink arrow and wait for A or B to be pressed ; 06 ; (no arguments) -TextCommand06:: ; 19a5 (0:19a5) +TextCommand06:: ld a, [wLinkState] cp a, LINK_STATE_BATTLING jp z, TextCommand0D @@ -528,22 +518,22 @@ TextCommand06:: ; 19a5 (0:19a5) ; scroll text up one line ; 07 ; (no arguments) -TextCommand07:: ; 19c0 (0:19c0) +TextCommand07:: ld a, " " Coorda 18, 16 ; place blank space in lower right corner of dialogue text box - call Next18F1 ; scroll up text - call Next18F1 + call ScrollTextUpOneLine + call ScrollTextUpOneLine pop hl coord bc, 1, 16 ; address of second line of dialogue text box jp NextTextCommand ; execute asm inline ; 08{code} -TextCommand08:: ; 19d2 (0:19d2) +TextCommand08:: pop hl ld de, NextTextCommand push de ; return address - jp [hl] + jp hl ; print decimal number (converted from binary number) ; 09AAAABB @@ -551,7 +541,7 @@ TextCommand08:: ; 19d2 (0:19d2) ; BB ; bits 0-3 = how many digits to display ; bits 4-7 = how long the number is in bytes -TextCommand09:: ; 19d8 (0:19d8) +TextCommand09:: pop hl ld a, [hli] ld e, a @@ -578,7 +568,7 @@ TextCommand09:: ; 19d8 (0:19d8) ; wait half a second if the user doesn't hold A or B ; 0A ; (no arguments) -TextCommand0A:: ; 19f6 (0:19f6) +TextCommand0A:: push bc call Joypad ld a, [hJoyHeld] @@ -594,7 +584,7 @@ TextCommand0A:: ; 19f6 (0:19f6) ; plays sounds ; this actually handles various command ID's, not just 0B ; (no arguments) -TextCommand0B:: ; 1a0a (0:1a0a) +TextCommand0B:: pop hl push bc dec hl @@ -631,7 +621,7 @@ TextCommand0B:: ; 1a0a (0:1a0a) jp NextTextCommand ; format: text command ID, sound ID or cry ID -TextCommandSounds:: ; 1a3d (0:1a3d) +TextCommandSounds:: db $0B, SFX_GET_ITEM_1 db $12, SFX_TURN_OFF_PC db $0E, SFX_POKEDEX_RATING @@ -639,14 +629,14 @@ TextCommandSounds:: ; 1a3d (0:1a3d) db $10, SFX_GET_ITEM_2 db $11, SFX_GET_KEY_ITEM db $13, SFX_TRADE_MACHINE - db $14, PIKACHU ; used in OakSpeech + db $14, PIKACHU ; used in OakSpeech db $15, PIDGEOT ; used in SaffronCityText12 db $16, DEWGONG ; unused? ; draw ellipses ; 0CAA ; AA = number of ellipses to draw -TextCommand0C:: ; 1a51 (0:1a51) +TextCommand0C:: pop hl ld a, [hli] ld d, a @@ -675,7 +665,7 @@ TextCommand0C:: ; 1a51 (0:1a51) ; wait for A or B to be pressed ; 0D ; (no arguments) -TextCommand0D:: ; 1a73 (0:1a73) +TextCommand0D:: push bc call ManualTextScroll ; wait for A or B to be pressed pop bc @@ -686,7 +676,7 @@ TextCommand0D:: ; 1a73 (0:1a73) ; 17AAAABB ; AAAA = address of text commands ; BB = bank -TextCommand17:: ; 1a7c (0:1a7c) +TextCommand17:: pop hl ld a, [H_LOADEDROMBANK] push af @@ -707,7 +697,7 @@ TextCommand17:: ; 1a7c (0:1a7c) ld [MBC1RomBank], a jp NextTextCommand -TextCommandJumpTable:: ; 1a9a (0:1a9a) +TextCommandJumpTable:: dw TextCommand00 dw TextCommand01 dw TextCommand02 |