diff options
Diffstat (limited to 'home/text.asm')
-rw-r--r-- | home/text.asm | 373 |
1 files changed, 183 insertions, 190 deletions
diff --git a/home/text.asm b/home/text.asm index 276b652e..b983f609 100644 --- a/home/text.asm +++ b/home/text.asm @@ -1,5 +1,5 @@ TextBoxBorder:: -; Draw a cxb text box at hl. +; Draw a c×b text box at hl. ; top row push hl @@ -11,7 +11,7 @@ TextBoxBorder:: ld [hl], a pop hl - ld de, 20 + ld de, SCREEN_WIDTH add hl, de ; middle rows @@ -24,7 +24,7 @@ TextBoxBorder:: ld [hl], "│" pop hl - ld de, 20 + ld de, SCREEN_WIDTH add hl, de dec b jr nz, .next @@ -46,88 +46,78 @@ NPlaceChar:: jr nz, .loop ret -PlaceString:: ; 1955 (0:1955) +PlaceString:: push hl -PlaceNextChar:: ; 1956 (0:1956) +PlaceNextChar:: ld a,[de] cp "@" - jr nz,.PlaceText + jr nz, Char4ETest ld b,h ld c,l pop hl ret -.PlaceText - cp $4E - jr nz,.next - ld bc,$0028 +Char4ETest:: + cp $4E ; next + jr nz, .char4FTest + ld bc, 2 * SCREEN_WIDTH ld a,[hFlags_0xFFF6] bit 2,a - jr z,.next2 - ld bc,$14 -.next2 + jr z,.ok + ld bc,SCREEN_WIDTH +.ok pop hl add hl,bc push hl - jp Next19E8 + jp PlaceNextChar_inc -.next - cp $4F +.char4FTest + cp $4F ; line jr nz,.next3 pop hl - hlCoord 1, 16 + coord hl, 1, 16 push hl - jp Next19E8 + 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 -Next19E8:: ; 19e8 (0:19e8) +PlaceNextChar_inc:: inc de jp PlaceNextChar -Char00:: ; 19ec (0:19ec) +Char00:: ld b,h ld c,l pop hl @@ -135,56 +125,56 @@ Char00:: ; 19ec (0:19ec) dec de ret -Char00Text:: ; 0x19f4 “%d ERROR.” +Char00Text:: ; “%d ERROR.” TX_FAR _Char00Text db "@" -Char52:: ; 0x19f9 player’s name +Char52:: ; player’s name push de ld de,wPlayerName jr FinishDTE -Char53:: ; 19ff (0:19ff) ; rival’s name +Char53:: ; rival’s name push de - ld de,W_RIVALNAME + ld de,wRivalName jr FinishDTE -Char5D:: ; 1a05 (0:1a05) ; TRAINER +Char5D:: ; TRAINER push de ld de,Char5DText jr FinishDTE -Char5C:: ; 1a0b (0:1a0b) ; TM +Char5C:: ; TM push de ld de,Char5CText jr FinishDTE -Char5B:: ; 1a11 (0:1a11) ; PC +Char5B:: ; PC push de ld de,Char5BText jr FinishDTE -Char5E:: ; 1a17 (0:1a17) ; ROCKET +Char5E:: ; ROCKET push de ld de,Char5EText jr FinishDTE -Char54:: ; 1a1d (0:1a1d) ; POKé +Char54:: ; POKé push de ld de,Char54Text jr FinishDTE -Char56:: ; 1a23 (0:1a23) ; …… +Char56:: ; …… push de ld de,Char56Text jr FinishDTE -Char4A:: ; 1a29 (0:1a29) ; PKMN +Char4A:: ; PKMN push de ld de,Char4AText jr FinishDTE -Char59:: ; 1a2f (0:1a2f) +Char59:: ; depending on whose turn it is, print ; enemy active monster’s name, prefixed with “Enemy ” ; or @@ -194,29 +184,28 @@ Char59:: ; 1a2f (0:1a2f) xor 1 jr MonsterNameCharsCommon -Char5A:: ; 1a35 (0:1a35) +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 ld de,wBattleMonNick ; player active monster name jr FinishDTE -.Enemy ; 1A40 +.Enemy ; print “Enemy ” ld de,Char5AText call PlaceString - ld h,b ld l,c ld de,wEnemyMonNick ; enemy active monster name -FinishDTE:: ; 1a4b (0:1a4b) +FinishDTE:: call PlaceString ld h,b ld l,c @@ -224,24 +213,24 @@ FinishDTE:: ; 1a4b (0:1a4b) inc de jp PlaceNextChar -Char5CText:: ; 1a55 (0:1a55) +Char5CText:: db "TM@" -Char5DText:: ; 1a58 (0:1a58) +Char5DText:: db "TRAINER@" -Char5BText:: ; 1a60 (0:1a60) +Char5BText:: db "PC@" -Char5EText:: ; 1a63 (0:1a63) +Char5EText:: db "ROCKET@" -Char54Text:: ; 1a6a (0:1a6a) +Char54Text:: db "POKé@" -Char56Text:: ; 1a6f (0:1a6f) +Char56Text:: db "……@" -Char5AText:: ; 1a72 (0:1a72) +Char5AText:: db "Enemy @" -Char4AText:: ; 1a79 (0:1a79) +Char4AText:: db $E1,$E2,"@" ; PKMN -Char55:: ; 1a7c (0:1a7c) +Char55:: push de ld b,h ld c,l @@ -253,104 +242,108 @@ Char55:: ; 1a7c (0:1a7c) inc de jp PlaceNextChar -Char55Text:: ; 1a8c (0:1a8c) +Char55Text:: ; equivalent to Char4B TX_FAR _Char55Text db "@" -Char5F:: ; 1a91 (0:1a91) +Char5F:: ; ends a Pokédex entry ld [hl],"." pop hl ret -Char58:: ; 1a95 (0:1a95) +Char58:: ; prompt ld a,[wLinkState] cp LINK_STATE_BATTLING - jp z,Next1AA2 - ld a,$EE + jp z, .ok + ld a, "▼" Coorda 18, 16 -Next1AA2:: ; 1aa2 (0:1aa2) +.ok call ProtectedDelay3 call ManualTextScroll - ld a,$7F + ld a, " " Coorda 18, 16 -Char57:: ; 1aad (0:1aad) +Char57:: ; done pop hl - ld de,Char58Text + ld de, Char58Text dec de ret -Char58Text:: ; 1ab3 (0:1ab3) +Char58Text:: db "@" -Char51:: ; 1ab4 (0:1ab4) +Char51:: ; para push de - ld a,$EE + ld a, "▼" Coorda 18, 16 call ProtectedDelay3 call ManualTextScroll - hlCoord 1, 13 - ld bc,$0412 + coord hl, 1, 13 + lb bc, 4, 18 call ClearScreenArea - ld c,$14 + ld c, 20 call DelayFrames pop de - hlCoord 1, 14 - jp Next19E8 + coord hl, 1, 14 + jp PlaceNextChar_inc -Char49:: ; 1ad5 (0:1ad5) +Char49:: push de - ld a,$EE + ld a,"▼" Coorda 18, 16 call ProtectedDelay3 call ManualTextScroll - hlCoord 1, 10 - ld bc,$0712 + coord hl, 1, 10 + lb bc, 7, 18 call ClearScreenArea - ld c,$14 + ld c,20 call DelayFrames pop de pop hl - hlCoord 1, 11 + coord hl, 1, 11 push hl - jp Next19E8 + jp PlaceNextChar_inc -Char4B:: ; 1af8 (0:1af8) - ld a,$EE +Char4B:: + ld a,"▼" Coorda 18, 16 call ProtectedDelay3 push de call ManualTextScroll pop de - ld a,$7F + ld a, " " Coorda 18, 16 ;fall through -Char4C:: ; 1b0a (0:1b0a) +Char4C:: push de - call Next1B18 - call Next1B18 - hlCoord 1, 16 + call ScrollTextUpOneLine + call ScrollTextUpOneLine + coord hl, 1, 16 pop de - jp Next19E8 - -Next1B18:: ; 1b18 (0:1b18) - hlCoord 0, 14 - deCoord 0, 13 - ld b,$3C -.next + jp PlaceNextChar_inc + +; move both rows of text in the normal text box up one row +; always called twice in a row +; first time, copy the two rows of text to the "in between" rows that are usually emtpy +; second time, copy the bottom row of text into the top row of text +ScrollTextUpOneLine:: + coord hl, 0, 14 ; top row of text + coord de, 0, 13 ; empty line above text + ld b, SCREEN_WIDTH * 3 +.copyText ld a,[hli] ld [de],a inc de dec b - jr nz,.next - hlCoord 1, 16 - ld a,$7F - ld b,$12 -.next2 + jr nz,.copyText + coord hl, 1, 16 + ld a, " " + ld b,SCREEN_WIDTH - 2 +.clearText ld [hli],a dec b - jr nz,.next2 + jr nz,.clearText ; wait five frames ld b,5 @@ -361,57 +354,57 @@ Next1B18:: ; 1b18 (0:1b18) ret -ProtectedDelay3:: ; 1b3a (0:1b3a) +ProtectedDelay3:: push bc call Delay3 pop bc ret -TextCommandProcessor:: ; 1b40 (0:1b40) - ld a,[wd358] +TextCommandProcessor:: + ld a,[wLetterPrintingDelayFlags] push af set 1,a ld e,a - ld a,[$fff4] + ld a, [$fff4] xor e - ld [wd358],a + ld [wLetterPrintingDelayFlags],a ld a,c - ld [wcc3a],a + ld [wTextDest],a ld a,b - ld [wcc3b],a + ld [wTextDest + 1],a -NextTextCommand:: ; 1b55 (0:1b55) +NextTextCommand:: ld a,[hli] cp a, "@" ; terminator jr nz,.doTextCommand pop af - ld [wd358],a + ld [wLetterPrintingDelayFlags],a ret .doTextCommand push hl - cp a,$17 - jp z,TextCommand17 - cp a,$0e + cp a, $17 + jp z, TextCommand17 + cp a, $0e jp nc,TextCommand0B ; if a != 0x17 and a >= 0xE, go to command 0xB ; if a < 0xE, use a jump table ld hl,TextCommandJumpTable push bc add a - ld b,$00 - ld c,a - add hl,bc + ld b, 0 + ld c, a + add hl, bc pop bc - ld a,[hli] - ld h,[hl] - ld l,a - jp [hl] + ld a, [hli] + ld h, [hl] + ld l, a + jp hl ; draw box ; 04AAAABBCC ; AAAA = address of upper left corner ; BB = height ; CC = width -TextCommand04:: ; 1b78 (0:1b78) +TextCommand04:: pop hl ld a,[hli] ld e,a @@ -430,7 +423,7 @@ TextCommand04:: ; 1b78 (0:1b78) ; place string inline ; 00{string} -TextCommand00:: ; 1b8a (0:1b8a) +TextCommand00:: pop hl ld d,h ld e,l @@ -445,7 +438,7 @@ TextCommand00:: ; 1b8a (0:1b8a) ; place string from RAM ; 01AAAA ; AAAA = address of string -TextCommand01:: ; 1b97 (0:1b97) +TextCommand01:: pop hl ld a,[hli] ld e,a @@ -464,7 +457,7 @@ TextCommand01:: ; 1b97 (0:1b97) ; BB ; bits 0-4 = length in bytes ; bits 5-7 = unknown flags -TextCommand02:: ; 1ba5 (0:1ba5) +TextCommand02:: pop hl ld a,[hli] ld e,a @@ -484,32 +477,32 @@ TextCommand02:: ; 1ba5 (0:1ba5) ; repoint destination address ; 03AAAA ; AAAA = new destination address -TextCommand03:: ; 1bb7 (0:1bb7) +TextCommand03:: pop hl ld a,[hli] - ld [wcc3a],a + ld [wTextDest],a ld c,a ld a,[hli] - ld [wcc3b],a + ld [wTextDest + 1],a ld b,a jp NextTextCommand ; repoint destination to second line of dialogue text box ; 05 ; (no arguments) -TextCommand05:: ; 1bc5 (0:1bc5) +TextCommand05:: pop hl - bcCoord 1, 16 ; address of second line of dialogue text box + coord bc, 1, 16 ; address of second line of dialogue text box jp NextTextCommand ; blink arrow and wait for A or B to be pressed ; 06 ; (no arguments) -TextCommand06:: ; 1bcc (0:1bcc) +TextCommand06:: ld a,[wLinkState] cp a,LINK_STATE_BATTLING jp z,TextCommand0D - ld a,$ee ; down arrow + ld a,"▼" Coorda 18, 16 ; place down arrow in lower right corner of dialogue text box push bc call ManualTextScroll ; blink arrow and wait for A or B to be pressed @@ -522,22 +515,22 @@ TextCommand06:: ; 1bcc (0:1bcc) ; scroll text up one line ; 07 ; (no arguments) -TextCommand07:: ; 1be7 (0:1be7) - ld a," " +TextCommand07:: + ld a, " " Coorda 18, 16 ; place blank space in lower right corner of dialogue text box - call Next1B18 ; scroll up text - call Next1B18 + call ScrollTextUpOneLine + call ScrollTextUpOneLine pop hl - bcCoord 1, 16 ; address of second line of dialogue text box + coord bc, 1, 16 ; address of second line of dialogue text box jp NextTextCommand ; execute asm inline ; 08{code} -TextCommand08:: ; 1bf9 (0:1bf9) +TextCommand08:: pop hl ld de,NextTextCommand push de ; return address - jp [hl] + jp hl ; print decimal number (converted from binary number) ; 09AAAABB @@ -545,7 +538,7 @@ TextCommand08:: ; 1bf9 (0:1bf9) ; BB ; bits 0-3 = how many digits to display ; bits 4-7 = how long the number is in bytes -TextCommand09:: ; 1bff (0:1bff) +TextCommand09:: pop hl ld a,[hli] ld e,a @@ -561,7 +554,7 @@ TextCommand09:: ; 1bff (0:1bff) ld a,b and a,$f0 swap a - set 6,a + set BIT_LEFT_ALIGN,a ld b,a call PrintNumber ld b,h @@ -572,11 +565,11 @@ TextCommand09:: ; 1bff (0:1bff) ; wait half a second if the user doesn't hold A or B ; 0A ; (no arguments) -TextCommand0A:: ; 1c1d (0:1c1d) +TextCommand0A:: push bc call Joypad ld a,[hJoyHeld] - and a,%00000011 ; A and B buttons + and a,A_BUTTON | B_BUTTON jr nz,.skipDelay ld c,30 call DelayFrames @@ -588,7 +581,7 @@ TextCommand0A:: ; 1c1d (0:1c1d) ; plays sounds ; this actually handles various command ID's, not just 0B ; (no arguments) -TextCommand0B:: ; 1c31 (0:1c31) +TextCommand0B:: pop hl push bc dec hl @@ -625,22 +618,22 @@ TextCommand0B:: ; 1c31 (0:1c31) jp NextTextCommand ; format: text command ID, sound ID or cry ID -TextCommandSounds:: ; 1c64 (0:1c64) - db $0B,(SFX_02_3a - SFX_Headers_02) / 3 - db $12,(SFX_08_46 - SFX_Headers_08) / 3 - db $0E,(SFX_02_41 - SFX_Headers_02) / 3 - db $0F,(SFX_02_3a - SFX_Headers_02) / 3 - db $10,(SFX_02_3b - SFX_Headers_02) / 3 - db $11,(SFX_02_42 - SFX_Headers_02) / 3 - db $13,(SFX_08_45 - SFX_Headers_08) / 3 - db $14,NIDORINA ; used in OakSpeech - db $15,PIDGEOT ; used in SaffronCityText12 - db $16,DEWGONG ; unused? +TextCommandSounds:: + db $0B, SFX_GET_ITEM_1 ; actually plays SFX_LEVEL_UP when the battle music engine is loaded + db $12, SFX_CAUGHT_MON + db $0E, SFX_POKEDEX_RATING ; unused? + db $0F, SFX_GET_ITEM_1 ; unused? + db $10, SFX_GET_ITEM_2 + db $11, SFX_GET_KEY_ITEM + db $13, SFX_DEX_PAGE_ADDED + db $14, NIDORINA ; used in OakSpeech + db $15, PIDGEOT ; used in SaffronCityText12 + db $16, DEWGONG ; unused? ; draw ellipses ; 0CAA ; AA = number of ellipses to draw -TextCommand0C:: ; 1c78 (0:1c78) +TextCommand0C:: pop hl ld a,[hli] ld d,a @@ -648,13 +641,13 @@ TextCommand0C:: ; 1c78 (0:1c78) ld h,b ld l,c .loop - ld a,$75 ; ellipsis + ld a,"…" ld [hli],a push de call Joypad pop de ld a,[hJoyHeld] ; joypad state - and a,%00000011 ; is A or B button pressed? + and a,A_BUTTON | B_BUTTON jr nz,.skipDelay ; if so, skip the delay ld c,10 call DelayFrames @@ -669,7 +662,7 @@ TextCommand0C:: ; 1c78 (0:1c78) ; wait for A or B to be pressed ; 0D ; (no arguments) -TextCommand0D:: ; 1c9a (0:1c9a) +TextCommand0D:: push bc call ManualTextScroll ; wait for A or B to be pressed pop bc @@ -680,7 +673,7 @@ TextCommand0D:: ; 1c9a (0:1c9a) ; 17AAAABB ; AAAA = address of text commands ; BB = bank -TextCommand17:: ; 1ca3 (0:1ca3) +TextCommand17:: pop hl ld a,[H_LOADEDROMBANK] push af @@ -690,7 +683,7 @@ TextCommand17:: ; 1ca3 (0:1ca3) ld d,a ld a,[hli] ld [H_LOADEDROMBANK],a - ld [$2000],a + ld [MBC1RomBank],a push hl ld l,e ld h,d @@ -698,10 +691,10 @@ TextCommand17:: ; 1ca3 (0:1ca3) pop hl pop af ld [H_LOADEDROMBANK],a - ld [$2000],a + ld [MBC1RomBank],a jp NextTextCommand -TextCommandJumpTable:: ; 1cc1 (0:1cc1) +TextCommandJumpTable:: dw TextCommand00 dw TextCommand01 dw TextCommand02 |