2014-05-31 02:52:24 +00:00
|
|
|
|
TextBoxBorder::
|
2016-09-11 09:01:37 +00:00
|
|
|
|
; Draw a c×b text box at hl.
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
|
|
|
|
; top row
|
|
|
|
|
push hl
|
|
|
|
|
ld a, "┌"
|
|
|
|
|
ld [hli], a
|
2020-07-04 21:09:35 +00:00
|
|
|
|
inc a ; "─"
|
|
|
|
|
call .PlaceChars
|
|
|
|
|
inc a ; "┐"
|
2014-05-31 02:52:24 +00:00
|
|
|
|
ld [hl], a
|
|
|
|
|
pop hl
|
|
|
|
|
|
2016-07-18 06:17:03 +00:00
|
|
|
|
ld de, SCREEN_WIDTH
|
2014-05-31 02:52:24 +00:00
|
|
|
|
add hl, de
|
|
|
|
|
|
|
|
|
|
; middle rows
|
|
|
|
|
.next
|
|
|
|
|
push hl
|
|
|
|
|
ld a, "│"
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld [hli], a
|
2014-05-31 02:52:24 +00:00
|
|
|
|
ld a, " "
|
2020-07-04 21:09:35 +00:00
|
|
|
|
call .PlaceChars
|
2014-05-31 02:52:24 +00:00
|
|
|
|
ld [hl], "│"
|
|
|
|
|
pop hl
|
|
|
|
|
|
2016-07-18 06:17:03 +00:00
|
|
|
|
ld de, SCREEN_WIDTH
|
2014-05-31 02:52:24 +00:00
|
|
|
|
add hl, de
|
|
|
|
|
dec b
|
|
|
|
|
jr nz, .next
|
|
|
|
|
|
|
|
|
|
; bottom row
|
|
|
|
|
ld a, "└"
|
|
|
|
|
ld [hli], a
|
|
|
|
|
ld a, "─"
|
2020-07-04 21:09:35 +00:00
|
|
|
|
call .PlaceChars
|
2014-05-31 02:52:24 +00:00
|
|
|
|
ld [hl], "┘"
|
|
|
|
|
ret
|
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
.PlaceChars::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
; Place char a c times.
|
|
|
|
|
ld d, c
|
|
|
|
|
.loop
|
|
|
|
|
ld [hli], a
|
|
|
|
|
dec d
|
|
|
|
|
jr nz, .loop
|
|
|
|
|
ret
|
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
|
PlaceString::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push hl
|
2020-07-04 21:09:35 +00:00
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
|
PlaceNextChar::
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, [de]
|
2014-05-31 02:52:24 +00:00
|
|
|
|
cp "@"
|
2020-07-04 21:09:35 +00:00
|
|
|
|
jr nz, .NotTerminator
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld b, h
|
|
|
|
|
ld c, l
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
|
|
|
|
ret
|
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
.NotTerminator
|
|
|
|
|
cp "<NEXT>"
|
|
|
|
|
jr nz, .NotNext
|
2016-06-12 07:51:59 +00:00
|
|
|
|
ld bc, 2 * SCREEN_WIDTH
|
2020-07-03 23:59:41 +00:00
|
|
|
|
ld a, [hFlagsFFF6]
|
2017-12-30 00:54:27 +00:00
|
|
|
|
bit 2, a
|
|
|
|
|
jr z, .ok
|
|
|
|
|
ld bc, SCREEN_WIDTH
|
2016-06-12 07:51:59 +00:00
|
|
|
|
.ok
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
2017-12-30 00:54:27 +00:00
|
|
|
|
add hl, bc
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push hl
|
2020-07-04 21:09:35 +00:00
|
|
|
|
jp NextChar
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
.NotNext
|
|
|
|
|
cp "<LINE>"
|
|
|
|
|
jr nz, .NotLine
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
2015-07-18 20:52:03 +00:00
|
|
|
|
coord hl, 1, 16
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push hl
|
2020-07-04 21:09:35 +00:00
|
|
|
|
jp NextChar
|
|
|
|
|
|
|
|
|
|
.NotLine
|
|
|
|
|
|
|
|
|
|
; Check against a dictionary
|
|
|
|
|
dict "<NULL>", NullChar
|
|
|
|
|
dict "<SCROLL>", _ContTextNoPause
|
|
|
|
|
dict "<_CONT>", _ContText
|
|
|
|
|
dict "<PARA>", Paragraph
|
|
|
|
|
dict "<PAGE>", PageChar
|
|
|
|
|
dict "<PLAYER>", PrintPlayerName
|
|
|
|
|
dict "<RIVAL>", PrintRivalName
|
|
|
|
|
dict "#", PlacePOKe
|
|
|
|
|
dict "<PC>", PCChar
|
|
|
|
|
dict "<ROCKET>", RocketChar
|
|
|
|
|
dict "<TM>", TMChar
|
|
|
|
|
dict "<TRAINER>", TrainerChar
|
|
|
|
|
dict "<CONT>", ContText
|
|
|
|
|
dict "<……>", SixDotsChar
|
|
|
|
|
dict "<DONE>", DoneText
|
|
|
|
|
dict "<PROMPT>", PromptText
|
|
|
|
|
dict "<PKMN>", PlacePKMN
|
|
|
|
|
dict "<DEXEND>", PlaceDexEnd
|
|
|
|
|
dict "<TARGET>", PlaceMoveTargetsName
|
|
|
|
|
dict "<USER>", PlaceMoveUsersName
|
2016-06-12 07:51:59 +00:00
|
|
|
|
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld [hli], a
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call PrintLetterDelay
|
2020-07-04 21:09:35 +00:00
|
|
|
|
|
|
|
|
|
NextChar::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
inc de
|
|
|
|
|
jp PlaceNextChar
|
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
NullChar::
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld b, h
|
|
|
|
|
ld c, l
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
2020-07-04 21:09:35 +00:00
|
|
|
|
ld de, TextIDErrorText
|
2014-05-31 02:52:24 +00:00
|
|
|
|
dec de
|
|
|
|
|
ret
|
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
TextIDErrorText:: ; "[hSpriteIndexOrTextID] ERROR."
|
|
|
|
|
text_far _TextIDErrorText
|
|
|
|
|
text_end
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
print_name: MACRO
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push de
|
2020-07-04 21:09:35 +00:00
|
|
|
|
ld de, \1
|
|
|
|
|
jr PlaceCommandCharacter
|
|
|
|
|
ENDM
|
|
|
|
|
|
|
|
|
|
PrintPlayerName:: print_name wPlayerName
|
|
|
|
|
PrintRivalName:: print_name wRivalName
|
|
|
|
|
|
|
|
|
|
TrainerChar:: print_name TrainerCharText
|
|
|
|
|
TMChar:: print_name TMCharText
|
|
|
|
|
PCChar:: print_name PCCharText
|
|
|
|
|
RocketChar:: print_name RocketCharText
|
|
|
|
|
PlacePOKe:: print_name PlacePOKeText
|
|
|
|
|
SixDotsChar:: print_name SixDotsCharText
|
|
|
|
|
PlacePKMN:: print_name PlacePKMNText
|
|
|
|
|
|
|
|
|
|
PlaceMoveTargetsName::
|
2020-07-03 23:59:41 +00:00
|
|
|
|
ld a, [hWhoseTurn]
|
2014-05-31 02:52:24 +00:00
|
|
|
|
xor 1
|
2020-07-04 21:09:35 +00:00
|
|
|
|
jr PlaceMoveUsersName.place
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
PlaceMoveUsersName::
|
2020-07-03 23:59:41 +00:00
|
|
|
|
ld a, [hWhoseTurn]
|
2020-07-04 21:09:35 +00:00
|
|
|
|
|
|
|
|
|
.place:
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push de
|
|
|
|
|
and a
|
2020-07-04 21:09:35 +00:00
|
|
|
|
jr nz, .enemy
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
ld de, wBattleMonNick
|
|
|
|
|
jr PlaceCommandCharacter
|
|
|
|
|
|
|
|
|
|
.enemy
|
|
|
|
|
ld de, EnemyText
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call PlaceString
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld h, b
|
|
|
|
|
ld l, c
|
2020-07-04 21:09:35 +00:00
|
|
|
|
ld de, wEnemyMonNick
|
|
|
|
|
; fallthrough
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
PlaceCommandCharacter::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call PlaceString
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld h, b
|
|
|
|
|
ld l, c
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop de
|
|
|
|
|
inc de
|
|
|
|
|
jp PlaceNextChar
|
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
TMCharText:: db "TM@"
|
|
|
|
|
TrainerCharText:: db "TRAINER@"
|
|
|
|
|
PCCharText:: db "PC@"
|
|
|
|
|
RocketCharText:: db "ROCKET@"
|
|
|
|
|
PlacePOKeText:: db "POKé@"
|
|
|
|
|
SixDotsCharText:: db "……@"
|
|
|
|
|
EnemyText:: db "Enemy @"
|
|
|
|
|
PlacePKMNText:: db "<PK><MN>@"
|
|
|
|
|
|
|
|
|
|
ContText::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push de
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld b, h
|
|
|
|
|
ld c, l
|
2020-07-04 21:09:35 +00:00
|
|
|
|
ld hl, ContCharText
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call TextCommandProcessor
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld h, b
|
|
|
|
|
ld l, c
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop de
|
|
|
|
|
inc de
|
|
|
|
|
jp PlaceNextChar
|
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
ContCharText::
|
|
|
|
|
text_far _ContCharText
|
|
|
|
|
text_end
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
PlaceDexEnd::
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld [hl], "."
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
|
|
|
|
ret
|
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
PromptText::
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, [wLinkState]
|
2015-02-07 10:43:08 +00:00
|
|
|
|
cp LINK_STATE_BATTLING
|
2016-06-12 07:51:59 +00:00
|
|
|
|
jp z, .ok
|
2016-07-18 06:32:24 +00:00
|
|
|
|
ld a, "▼"
|
2014-06-25 20:58:27 +00:00
|
|
|
|
Coorda 18, 16
|
2016-06-12 07:51:59 +00:00
|
|
|
|
.ok
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call ProtectedDelay3
|
|
|
|
|
call ManualTextScroll
|
2015-07-14 07:16:19 +00:00
|
|
|
|
ld a, " "
|
2014-06-25 20:58:27 +00:00
|
|
|
|
Coorda 18, 16
|
2020-07-04 21:09:35 +00:00
|
|
|
|
|
|
|
|
|
DoneText::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
2020-07-04 21:09:35 +00:00
|
|
|
|
ld de, .stop
|
2014-05-31 02:52:24 +00:00
|
|
|
|
dec de
|
|
|
|
|
ret
|
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
.stop:
|
|
|
|
|
text_end
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
Paragraph::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push de
|
2016-07-18 06:32:24 +00:00
|
|
|
|
ld a, "▼"
|
2014-06-25 20:58:27 +00:00
|
|
|
|
Coorda 18, 16
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call ProtectedDelay3
|
|
|
|
|
call ManualTextScroll
|
2015-07-18 20:52:03 +00:00
|
|
|
|
coord hl, 1, 13
|
2015-08-05 21:20:29 +00:00
|
|
|
|
lb bc, 4, 18
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call ClearScreenArea
|
2016-06-12 07:51:59 +00:00
|
|
|
|
ld c, 20
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call DelayFrames
|
|
|
|
|
pop de
|
2015-07-18 20:52:03 +00:00
|
|
|
|
coord hl, 1, 14
|
2020-07-04 21:09:35 +00:00
|
|
|
|
jp NextChar
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
PageChar::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push de
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, "▼"
|
2014-06-25 20:58:27 +00:00
|
|
|
|
Coorda 18, 16
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call ProtectedDelay3
|
|
|
|
|
call ManualTextScroll
|
2015-07-18 20:52:03 +00:00
|
|
|
|
coord hl, 1, 10
|
2015-08-05 21:20:29 +00:00
|
|
|
|
lb bc, 7, 18
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call ClearScreenArea
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld c, 20
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call DelayFrames
|
|
|
|
|
pop de
|
|
|
|
|
pop hl
|
2015-07-18 20:52:03 +00:00
|
|
|
|
coord hl, 1, 11
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push hl
|
2020-07-04 21:09:35 +00:00
|
|
|
|
jp NextChar
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
_ContText::
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, "▼"
|
2014-06-25 20:58:27 +00:00
|
|
|
|
Coorda 18, 16
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call ProtectedDelay3
|
|
|
|
|
push de
|
|
|
|
|
call ManualTextScroll
|
|
|
|
|
pop de
|
2015-07-14 07:16:19 +00:00
|
|
|
|
ld a, " "
|
2014-06-25 20:58:27 +00:00
|
|
|
|
Coorda 18, 16
|
2020-07-04 21:09:35 +00:00
|
|
|
|
_ContTextNoPause::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push de
|
2016-06-12 07:51:59 +00:00
|
|
|
|
call ScrollTextUpOneLine
|
|
|
|
|
call ScrollTextUpOneLine
|
2015-07-18 20:52:03 +00:00
|
|
|
|
coord hl, 1, 16
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop de
|
2020-07-04 21:09:35 +00:00
|
|
|
|
jp NextChar
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
2016-07-18 06:17:03 +00:00
|
|
|
|
; 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
|
2016-06-12 07:51:59 +00:00
|
|
|
|
ScrollTextUpOneLine::
|
2016-07-18 06:17:03 +00:00
|
|
|
|
coord hl, 0, 14 ; top row of text
|
|
|
|
|
coord de, 0, 13 ; empty line above text
|
|
|
|
|
ld b, SCREEN_WIDTH * 3
|
|
|
|
|
.copyText
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld [de], a
|
2014-05-31 02:52:24 +00:00
|
|
|
|
inc de
|
|
|
|
|
dec b
|
2017-12-30 00:54:27 +00:00
|
|
|
|
jr nz, .copyText
|
2015-07-18 20:52:03 +00:00
|
|
|
|
coord hl, 1, 16
|
2015-07-14 07:16:19 +00:00
|
|
|
|
ld a, " "
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld b, SCREEN_WIDTH - 2
|
2016-07-18 06:17:03 +00:00
|
|
|
|
.clearText
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld [hli], a
|
2014-05-31 02:52:24 +00:00
|
|
|
|
dec b
|
2017-12-30 00:54:27 +00:00
|
|
|
|
jr nz, .clearText
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld b, 5
|
2014-05-31 02:52:24 +00:00
|
|
|
|
.WaitFrame
|
|
|
|
|
call DelayFrame
|
|
|
|
|
dec b
|
2017-12-30 00:54:27 +00:00
|
|
|
|
jr nz, .WaitFrame
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
|
ProtectedDelay3::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push bc
|
|
|
|
|
call Delay3
|
|
|
|
|
pop bc
|
|
|
|
|
ret
|
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
|
TextCommandProcessor::
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, [wLetterPrintingDelayFlags]
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push af
|
2017-12-30 00:54:27 +00:00
|
|
|
|
set 1, a
|
|
|
|
|
ld e, a
|
2020-07-04 02:11:35 +00:00
|
|
|
|
ld a, [hClearLetterPrintingDelayFlags]
|
2014-05-31 02:52:24 +00:00
|
|
|
|
xor e
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld [wLetterPrintingDelayFlags], a
|
|
|
|
|
ld a, c
|
|
|
|
|
ld [wTextDest], a
|
|
|
|
|
ld a, b
|
|
|
|
|
ld [wTextDest + 1], a
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
|
NextTextCommand::
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, [hli]
|
2020-07-04 21:09:35 +00:00
|
|
|
|
cp TX_END
|
|
|
|
|
jr nz, .TextCommand
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop af
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld [wLetterPrintingDelayFlags], a
|
2014-05-31 02:52:24 +00:00
|
|
|
|
ret
|
2020-07-04 21:09:35 +00:00
|
|
|
|
|
|
|
|
|
.TextCommand:
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push hl
|
2020-07-04 21:09:35 +00:00
|
|
|
|
cp TX_FAR
|
|
|
|
|
jp z, TextCommand_FAR
|
|
|
|
|
cp TX_SOUND_POKEDEX_RATING
|
|
|
|
|
jp nc, TextCommand_SOUND
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld hl, TextCommandJumpTable
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push bc
|
|
|
|
|
add a
|
2016-06-12 07:51:59 +00:00
|
|
|
|
ld b, 0
|
|
|
|
|
ld c, a
|
|
|
|
|
add hl, bc
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop bc
|
2016-06-12 07:51:59 +00:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld h, [hl]
|
|
|
|
|
ld l, a
|
|
|
|
|
jp hl
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
TextCommand_BOX::
|
|
|
|
|
; draw a box (height, width)
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld e, a
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld d, a
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld b, a
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld c, a
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push hl
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld h, d
|
|
|
|
|
ld l, e
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call TextBoxBorder
|
|
|
|
|
pop hl
|
|
|
|
|
jr NextTextCommand
|
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
TextCommand_START::
|
|
|
|
|
; write text until "@"
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld d, h
|
|
|
|
|
ld e, l
|
|
|
|
|
ld h, b
|
|
|
|
|
ld l, c
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call PlaceString
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld h, d
|
|
|
|
|
ld l, e
|
2014-05-31 02:52:24 +00:00
|
|
|
|
inc hl
|
|
|
|
|
jr NextTextCommand
|
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
TextCommand_RAM::
|
|
|
|
|
; write text from a ram address (little endian)
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld e, a
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld d, a
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push hl
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld h, b
|
|
|
|
|
ld l, c
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call PlaceString
|
|
|
|
|
pop hl
|
|
|
|
|
jr NextTextCommand
|
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
TextCommand_BCD::
|
|
|
|
|
; write bcd from address, typically ram
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld e, a
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld d, a
|
|
|
|
|
ld a, [hli]
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push hl
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld h, b
|
|
|
|
|
ld l, c
|
|
|
|
|
ld c, a
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call PrintBCDNumber
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld b, h
|
|
|
|
|
ld c, l
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
|
|
|
|
jr NextTextCommand
|
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
TextCommand_MOVE::
|
|
|
|
|
; move to a new tile
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld [wTextDest], a
|
|
|
|
|
ld c, a
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld [wTextDest + 1], a
|
|
|
|
|
ld b, a
|
2014-05-31 02:52:24 +00:00
|
|
|
|
jp NextTextCommand
|
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
TextCommand_LOW::
|
|
|
|
|
; write text at (1,16)
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
2020-07-04 21:09:35 +00:00
|
|
|
|
coord bc, 1, 16 ; second line of dialogue text box
|
2014-05-31 02:52:24 +00:00
|
|
|
|
jp NextTextCommand
|
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
TextCommand_PROMPT_BUTTON::
|
|
|
|
|
; wait for button press; show arrow
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, [wLinkState]
|
|
|
|
|
cp LINK_STATE_BATTLING
|
2020-07-04 21:09:35 +00:00
|
|
|
|
jp z, TextCommand_LINK_PROMPT_BUTTON
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, "▼"
|
2014-06-25 20:58:27 +00:00
|
|
|
|
Coorda 18, 16 ; place down arrow in lower right corner of dialogue text box
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push bc
|
|
|
|
|
call ManualTextScroll ; blink arrow and wait for A or B to be pressed
|
|
|
|
|
pop bc
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, " "
|
2014-06-25 20:58:27 +00:00
|
|
|
|
Coorda 18, 16 ; overwrite down arrow with blank space
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
|
|
|
|
jp NextTextCommand
|
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
TextCommand_SCROLL::
|
|
|
|
|
; pushes text up two lines and sets the BC cursor to the border tile
|
|
|
|
|
; below the first character column of the text box.
|
2016-06-12 07:51:59 +00:00
|
|
|
|
ld a, " "
|
2014-06-25 20:58:27 +00:00
|
|
|
|
Coorda 18, 16 ; place blank space in lower right corner of dialogue text box
|
2016-06-12 07:51:59 +00:00
|
|
|
|
call ScrollTextUpOneLine
|
|
|
|
|
call ScrollTextUpOneLine
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
2020-07-04 21:09:35 +00:00
|
|
|
|
coord bc, 1, 16 ; second line of dialogue text box
|
2014-05-31 02:52:24 +00:00
|
|
|
|
jp NextTextCommand
|
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
TextCommand_START_ASM::
|
|
|
|
|
; run assembly code
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld de, NextTextCommand
|
2020-07-04 21:09:35 +00:00
|
|
|
|
push de
|
2016-06-12 07:51:59 +00:00
|
|
|
|
jp hl
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
TextCommand_NUM::
|
|
|
|
|
; print a number
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld e, a
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld d, a
|
|
|
|
|
ld a, [hli]
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push hl
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld h, b
|
|
|
|
|
ld l, c
|
|
|
|
|
ld b, a
|
|
|
|
|
and $0f
|
|
|
|
|
ld c, a
|
|
|
|
|
ld a, b
|
|
|
|
|
and $f0
|
2014-05-31 02:52:24 +00:00
|
|
|
|
swap a
|
2020-07-04 21:09:35 +00:00
|
|
|
|
set BIT_LEFT_ALIGN, a
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld b, a
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call PrintNumber
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld b, h
|
|
|
|
|
ld c, l
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
|
|
|
|
jp NextTextCommand
|
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
TextCommand_PAUSE::
|
|
|
|
|
; wait for button press or 30 frames
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push bc
|
|
|
|
|
call Joypad
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, [hJoyHeld]
|
|
|
|
|
and A_BUTTON | B_BUTTON
|
2020-07-04 21:09:35 +00:00
|
|
|
|
jr nz, .done
|
|
|
|
|
ld c, 30 ; half a second
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call DelayFrames
|
2020-07-04 21:09:35 +00:00
|
|
|
|
.done
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop bc
|
|
|
|
|
pop hl
|
|
|
|
|
jp NextTextCommand
|
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
TextCommand_SOUND::
|
|
|
|
|
; play a sound effect from TextCommandSounds
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
|
|
|
|
push bc
|
|
|
|
|
dec hl
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, [hli]
|
2020-07-04 21:09:35 +00:00
|
|
|
|
ld b, a ; b = text command number that got us here
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push hl
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld hl, TextCommandSounds
|
2014-05-31 02:52:24 +00:00
|
|
|
|
.loop
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, [hli]
|
2014-05-31 02:52:24 +00:00
|
|
|
|
cp b
|
2020-07-04 21:09:35 +00:00
|
|
|
|
jr z, .play
|
2014-05-31 02:52:24 +00:00
|
|
|
|
inc hl
|
|
|
|
|
jr .loop
|
2020-07-04 21:09:35 +00:00
|
|
|
|
|
|
|
|
|
.play
|
|
|
|
|
cp TX_SOUND_CRY_NIDORINA
|
2017-12-30 00:54:27 +00:00
|
|
|
|
jr z, .pokemonCry
|
2020-07-04 21:09:35 +00:00
|
|
|
|
cp TX_SOUND_CRY_PIDGEOT
|
2017-12-30 00:54:27 +00:00
|
|
|
|
jr z, .pokemonCry
|
2020-07-04 21:09:35 +00:00
|
|
|
|
cp TX_SOUND_CRY_DEWGONG
|
2017-12-30 00:54:27 +00:00
|
|
|
|
jr z, .pokemonCry
|
|
|
|
|
ld a, [hl]
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call PlaySound
|
|
|
|
|
call WaitForSoundToFinish
|
|
|
|
|
pop hl
|
|
|
|
|
pop bc
|
|
|
|
|
jp NextTextCommand
|
2020-07-04 21:09:35 +00:00
|
|
|
|
|
2014-05-31 02:52:24 +00:00
|
|
|
|
.pokemonCry
|
|
|
|
|
push de
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, [hl]
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call PlayCry
|
|
|
|
|
pop de
|
|
|
|
|
pop hl
|
|
|
|
|
pop bc
|
|
|
|
|
jp NextTextCommand
|
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
|
TextCommandSounds::
|
2020-07-04 21:09:35 +00:00
|
|
|
|
db TX_SOUND_GET_ITEM_1, SFX_GET_ITEM_1 ; actually plays SFX_LEVEL_UP when the battle music engine is loaded
|
|
|
|
|
db TX_SOUND_CAUGHT_MON, SFX_CAUGHT_MON
|
|
|
|
|
db TX_SOUND_POKEDEX_RATING, SFX_POKEDEX_RATING ; unused
|
|
|
|
|
db TX_SOUND_GET_ITEM_1_DUPLICATE, SFX_GET_ITEM_1 ; unused
|
|
|
|
|
db TX_SOUND_GET_ITEM_2, SFX_GET_ITEM_2
|
|
|
|
|
db TX_SOUND_GET_KEY_ITEM, SFX_GET_KEY_ITEM
|
|
|
|
|
db TX_SOUND_DEX_PAGE_ADDED, SFX_DEX_PAGE_ADDED
|
|
|
|
|
db TX_SOUND_CRY_NIDORINA, NIDORINA ; used in OakSpeech
|
|
|
|
|
db TX_SOUND_CRY_PIDGEOT, PIDGEOT ; used in SaffronCityText12
|
|
|
|
|
db TX_SOUND_CRY_DEWGONG, DEWGONG ; unused
|
|
|
|
|
|
|
|
|
|
TextCommand_DOTS::
|
|
|
|
|
; wait for button press or 30 frames while printing "…"s
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld d, a
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push hl
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld h, b
|
|
|
|
|
ld l, c
|
2020-07-04 21:09:35 +00:00
|
|
|
|
|
2014-05-31 02:52:24 +00:00
|
|
|
|
.loop
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, "…"
|
|
|
|
|
ld [hli], a
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push de
|
|
|
|
|
call Joypad
|
|
|
|
|
pop de
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, [hJoyHeld] ; joypad state
|
|
|
|
|
and A_BUTTON | B_BUTTON
|
2020-07-04 21:09:35 +00:00
|
|
|
|
jr nz, .next ; if so, skip the delay
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld c, 10
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call DelayFrames
|
2020-07-04 21:09:35 +00:00
|
|
|
|
.next
|
2014-05-31 02:52:24 +00:00
|
|
|
|
dec d
|
2017-12-30 00:54:27 +00:00
|
|
|
|
jr nz, .loop
|
2020-07-04 21:09:35 +00:00
|
|
|
|
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld b, h
|
|
|
|
|
ld c, l
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
|
|
|
|
jp NextTextCommand
|
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
TextCommand_LINK_PROMPT_BUTTON::
|
|
|
|
|
; wait for button press; display arrow
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push bc
|
2020-07-04 21:09:35 +00:00
|
|
|
|
call ManualTextScroll
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop bc
|
|
|
|
|
pop hl
|
|
|
|
|
jp NextTextCommand
|
|
|
|
|
|
2020-07-04 21:09:35 +00:00
|
|
|
|
TextCommand_FAR::
|
|
|
|
|
; write text from a different bank (little endian)
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
2020-07-03 23:59:41 +00:00
|
|
|
|
ld a, [hLoadedROMBank]
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push af
|
2020-07-04 21:09:35 +00:00
|
|
|
|
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld e, a
|
|
|
|
|
ld a, [hli]
|
|
|
|
|
ld d, a
|
|
|
|
|
ld a, [hli]
|
2020-07-04 21:09:35 +00:00
|
|
|
|
|
2020-07-03 23:59:41 +00:00
|
|
|
|
ld [hLoadedROMBank], a
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld [MBC1RomBank], a
|
2020-07-04 21:09:35 +00:00
|
|
|
|
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push hl
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld l, e
|
|
|
|
|
ld h, d
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call TextCommandProcessor
|
|
|
|
|
pop hl
|
2020-07-04 21:09:35 +00:00
|
|
|
|
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop af
|
2020-07-03 23:59:41 +00:00
|
|
|
|
ld [hLoadedROMBank], a
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld [MBC1RomBank], a
|
2014-05-31 02:52:24 +00:00
|
|
|
|
jp NextTextCommand
|
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
|
TextCommandJumpTable::
|
2020-07-04 21:09:35 +00:00
|
|
|
|
; entries correspond to TX_* constants (see macros/scripts/text.asm)
|
|
|
|
|
dw TextCommand_START ; TX_START
|
|
|
|
|
dw TextCommand_RAM ; TX_RAM
|
|
|
|
|
dw TextCommand_BCD ; TX_BCD
|
|
|
|
|
dw TextCommand_MOVE ; TX_MOVE
|
|
|
|
|
dw TextCommand_BOX ; TX_BOX
|
|
|
|
|
dw TextCommand_LOW ; TX_LOW
|
|
|
|
|
dw TextCommand_PROMPT_BUTTON ; TX_PROMPT_BUTTON
|
|
|
|
|
dw TextCommand_SCROLL ; TX_SCROLL
|
|
|
|
|
dw TextCommand_START_ASM ; TX_START_ASM
|
|
|
|
|
dw TextCommand_NUM ; TX_NUM
|
|
|
|
|
dw TextCommand_PAUSE ; TX_PAUSE
|
|
|
|
|
dw TextCommand_SOUND ; TX_SOUND_GET_ITEM_1 (also handles other TX_SOUND_* commands)
|
|
|
|
|
dw TextCommand_DOTS ; TX_DOTS
|
|
|
|
|
dw TextCommand_LINK_PROMPT_BUTTON ; TX_LINK_PROMPT_BUTTON
|
|
|
|
|
; greater TX_* constants are handled directly by NextTextCommand
|