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
|
|
|
|
|
inc a ; ─
|
|
|
|
|
call NPlaceChar
|
|
|
|
|
inc a ; ┐
|
|
|
|
|
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, " "
|
|
|
|
|
call NPlaceChar
|
|
|
|
|
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, "─"
|
|
|
|
|
call NPlaceChar
|
|
|
|
|
ld [hl], "┘"
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
|
|
NPlaceChar::
|
|
|
|
|
; 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
|
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 "@"
|
2016-06-12 07:51:59 +00:00
|
|
|
|
jr nz, Char4ETest
|
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
|
|
|
|
|
|
2016-06-12 07:51:59 +00:00
|
|
|
|
Char4ETest::
|
|
|
|
|
cp $4E ; next
|
|
|
|
|
jr nz, .char4FTest
|
|
|
|
|
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
|
2015-07-14 07:16:19 +00:00
|
|
|
|
jp PlaceNextChar_inc
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
2016-06-12 07:51:59 +00:00
|
|
|
|
.char4FTest
|
|
|
|
|
cp $4F ; line
|
2017-12-30 00:54:27 +00:00
|
|
|
|
jr nz, .next3
|
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
|
2015-07-14 07:16:19 +00:00
|
|
|
|
jp PlaceNextChar_inc
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
|
|
|
|
.next3 ; Check against a dictionary
|
2016-06-12 07:51:59 +00:00
|
|
|
|
dict: macro
|
|
|
|
|
if \1 == 0
|
2014-05-31 02:52:24 +00:00
|
|
|
|
and a
|
2016-06-12 07:51:59 +00:00
|
|
|
|
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
|
|
|
|
|
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld [hli], a
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call PrintLetterDelay
|
2016-06-12 00:24:04 +00:00
|
|
|
|
PlaceNextChar_inc::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
inc de
|
|
|
|
|
jp PlaceNextChar
|
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
|
Char00::
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld b, h
|
|
|
|
|
ld c, l
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld de, Char00Text
|
2014-05-31 02:52:24 +00:00
|
|
|
|
dec de
|
|
|
|
|
ret
|
|
|
|
|
|
2016-06-12 07:19:19 +00:00
|
|
|
|
Char00Text:: ; “%d ERROR.”
|
2014-05-31 02:52:24 +00:00
|
|
|
|
TX_FAR _Char00Text
|
|
|
|
|
db "@"
|
|
|
|
|
|
2016-06-12 07:19:19 +00:00
|
|
|
|
Char52:: ; player’s name
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push de
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld de, wPlayerName
|
2014-05-31 02:52:24 +00:00
|
|
|
|
jr FinishDTE
|
|
|
|
|
|
2016-06-12 06:42:19 +00:00
|
|
|
|
Char53:: ; rival’s name
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push de
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld de, wRivalName
|
2014-05-31 02:52:24 +00:00
|
|
|
|
jr FinishDTE
|
|
|
|
|
|
2016-06-12 06:42:19 +00:00
|
|
|
|
Char5D:: ; TRAINER
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push de
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld de, Char5DText
|
2014-05-31 02:52:24 +00:00
|
|
|
|
jr FinishDTE
|
|
|
|
|
|
2016-06-12 06:42:19 +00:00
|
|
|
|
Char5C:: ; TM
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push de
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld de, Char5CText
|
2014-05-31 02:52:24 +00:00
|
|
|
|
jr FinishDTE
|
|
|
|
|
|
2016-06-12 06:42:19 +00:00
|
|
|
|
Char5B:: ; PC
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push de
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld de, Char5BText
|
2014-05-31 02:52:24 +00:00
|
|
|
|
jr FinishDTE
|
|
|
|
|
|
2016-06-12 06:42:19 +00:00
|
|
|
|
Char5E:: ; ROCKET
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push de
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld de, Char5EText
|
2014-05-31 02:52:24 +00:00
|
|
|
|
jr FinishDTE
|
|
|
|
|
|
2016-06-12 06:42:19 +00:00
|
|
|
|
Char54:: ; POKé
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push de
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld de, Char54Text
|
2014-05-31 02:52:24 +00:00
|
|
|
|
jr FinishDTE
|
|
|
|
|
|
2016-06-12 06:42:19 +00:00
|
|
|
|
Char56:: ; ……
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push de
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld de, Char56Text
|
2014-05-31 02:52:24 +00:00
|
|
|
|
jr FinishDTE
|
|
|
|
|
|
2016-06-12 06:42:19 +00:00
|
|
|
|
Char4A:: ; PKMN
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push de
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld de, Char4AText
|
2014-05-31 02:52:24 +00:00
|
|
|
|
jr FinishDTE
|
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
|
Char59::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
; depending on whose turn it is, print
|
|
|
|
|
; enemy active monster’s name, prefixed with “Enemy ”
|
|
|
|
|
; or
|
|
|
|
|
; player active monster’s name
|
|
|
|
|
; (like Char5A but flipped)
|
2020-07-03 23:59:41 +00:00
|
|
|
|
ld a, [hWhoseTurn]
|
2014-05-31 02:52:24 +00:00
|
|
|
|
xor 1
|
|
|
|
|
jr MonsterNameCharsCommon
|
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
|
Char5A::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
; depending on whose turn it is, print
|
|
|
|
|
; player active monster’s name
|
|
|
|
|
; or
|
|
|
|
|
; enemy active monster’s name, prefixed with “Enemy ”
|
2020-07-03 23:59:41 +00:00
|
|
|
|
ld a, [hWhoseTurn]
|
2016-06-12 00:24:04 +00:00
|
|
|
|
MonsterNameCharsCommon::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push de
|
|
|
|
|
and a
|
2017-12-30 00:54:27 +00:00
|
|
|
|
jr nz, .Enemy
|
|
|
|
|
ld de, wBattleMonNick ; player active monster name
|
2014-05-31 02:52:24 +00:00
|
|
|
|
jr FinishDTE
|
|
|
|
|
|
2015-07-14 05:21:03 +00:00
|
|
|
|
.Enemy
|
2014-05-31 02:52:24 +00:00
|
|
|
|
; print “Enemy ”
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld de, Char5AText
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call PlaceString
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld h, b
|
|
|
|
|
ld l, c
|
|
|
|
|
ld de, wEnemyMonNick ; enemy active monster name
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
|
FinishDTE::
|
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
|
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
|
Char5CText::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
db "TM@"
|
2016-06-12 00:24:04 +00:00
|
|
|
|
Char5DText::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
db "TRAINER@"
|
2016-06-12 00:24:04 +00:00
|
|
|
|
Char5BText::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
db "PC@"
|
2016-06-12 00:24:04 +00:00
|
|
|
|
Char5EText::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
db "ROCKET@"
|
2016-06-12 00:24:04 +00:00
|
|
|
|
Char54Text::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
db "POKé@"
|
2016-06-12 00:24:04 +00:00
|
|
|
|
Char56Text::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
db "……@"
|
2016-06-12 00:24:04 +00:00
|
|
|
|
Char5AText::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
db "Enemy @"
|
2016-06-12 00:24:04 +00:00
|
|
|
|
Char4AText::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
db $E1,$E2,"@" ; PKMN
|
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
|
Char55::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push de
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld b, h
|
|
|
|
|
ld c, l
|
|
|
|
|
ld hl, Char55Text
|
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
|
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
|
Char55Text::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
; equivalent to Char4B
|
|
|
|
|
TX_FAR _Char55Text
|
|
|
|
|
db "@"
|
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
|
Char5F::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
; ends a Pokédex entry
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld [hl], "."
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
|
|
|
|
ret
|
|
|
|
|
|
2016-06-12 07:51:59 +00:00
|
|
|
|
Char58:: ; prompt
|
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
|
2016-06-12 07:51:59 +00:00
|
|
|
|
Char57:: ; done
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
2016-06-12 07:51:59 +00:00
|
|
|
|
ld de, Char58Text
|
2014-05-31 02:52:24 +00:00
|
|
|
|
dec de
|
|
|
|
|
ret
|
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
|
Char58Text::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
db "@"
|
|
|
|
|
|
2016-06-12 07:51:59 +00:00
|
|
|
|
Char51:: ; para
|
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
|
2015-07-14 07:16:19 +00:00
|
|
|
|
jp PlaceNextChar_inc
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
|
Char49::
|
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
|
2015-07-14 07:16:19 +00:00
|
|
|
|
jp PlaceNextChar_inc
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
|
Char4B::
|
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
|
2014-05-31 02:52:24 +00:00
|
|
|
|
;fall through
|
2016-06-12 00:24:04 +00:00
|
|
|
|
Char4C::
|
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
|
2015-07-14 07:16:19 +00:00
|
|
|
|
jp PlaceNextChar_inc
|
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
|
|
|
|
|
|
|
|
|
; wait five frames
|
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]
|
|
|
|
|
cp "@" ; terminator
|
|
|
|
|
jr nz, .doTextCommand
|
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
|
|
|
|
|
.doTextCommand
|
|
|
|
|
push hl
|
2017-12-30 00:54:27 +00:00
|
|
|
|
cp $17
|
2016-06-12 07:51:59 +00:00
|
|
|
|
jp z, TextCommand17
|
2017-12-30 00:54:27 +00:00
|
|
|
|
cp $0e
|
|
|
|
|
jp nc, TextCommand0B ; if a != 0x17 and a >= 0xE, go to command 0xB
|
2014-05-31 02:52:24 +00:00
|
|
|
|
; if a < 0xE, use a jump table
|
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
|
|
|
|
|
|
|
|
|
; draw box
|
|
|
|
|
; 04AAAABBCC
|
|
|
|
|
; AAAA = address of upper left corner
|
|
|
|
|
; BB = height
|
|
|
|
|
; CC = width
|
2016-06-12 00:24:04 +00:00
|
|
|
|
TextCommand04::
|
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
|
|
|
|
|
|
|
|
|
|
; place string inline
|
|
|
|
|
; 00{string}
|
2016-06-12 00:24:04 +00:00
|
|
|
|
TextCommand00::
|
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
|
|
|
|
|
|
|
|
|
|
; place string from RAM
|
|
|
|
|
; 01AAAA
|
|
|
|
|
; AAAA = address of string
|
2016-06-12 00:24:04 +00:00
|
|
|
|
TextCommand01::
|
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
|
|
|
|
|
|
|
|
|
|
; print BCD number
|
|
|
|
|
; 02AAAABB
|
|
|
|
|
; AAAA = address of BCD number
|
|
|
|
|
; BB
|
|
|
|
|
; bits 0-4 = length in bytes
|
|
|
|
|
; bits 5-7 = unknown flags
|
2016-06-12 00:24:04 +00:00
|
|
|
|
TextCommand02::
|
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
|
|
|
|
|
|
|
|
|
|
; repoint destination address
|
|
|
|
|
; 03AAAA
|
|
|
|
|
; AAAA = new destination address
|
2016-06-12 00:24:04 +00:00
|
|
|
|
TextCommand03::
|
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
|
|
|
|
|
|
|
|
|
|
; repoint destination to second line of dialogue text box
|
|
|
|
|
; 05
|
|
|
|
|
; (no arguments)
|
2016-06-12 00:24:04 +00:00
|
|
|
|
TextCommand05::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
2015-07-18 20:52:03 +00:00
|
|
|
|
coord bc, 1, 16 ; address of second line of dialogue text box
|
2014-05-31 02:52:24 +00:00
|
|
|
|
jp NextTextCommand
|
|
|
|
|
|
|
|
|
|
; blink arrow and wait for A or B to be pressed
|
|
|
|
|
; 06
|
|
|
|
|
; (no arguments)
|
2016-06-12 00:24:04 +00:00
|
|
|
|
TextCommand06::
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld a, [wLinkState]
|
|
|
|
|
cp LINK_STATE_BATTLING
|
|
|
|
|
jp z, TextCommand0D
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
; scroll text up one line
|
|
|
|
|
; 07
|
|
|
|
|
; (no arguments)
|
2016-06-12 00:24:04 +00:00
|
|
|
|
TextCommand07::
|
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
|
2015-07-18 20:52:03 +00:00
|
|
|
|
coord bc, 1, 16 ; address of second line of dialogue text box
|
2014-05-31 02:52:24 +00:00
|
|
|
|
jp NextTextCommand
|
|
|
|
|
|
|
|
|
|
; execute asm inline
|
|
|
|
|
; 08{code}
|
2016-06-12 00:24:04 +00:00
|
|
|
|
TextCommand08::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
2017-12-30 00:54:27 +00:00
|
|
|
|
ld de, NextTextCommand
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push de ; return address
|
2016-06-12 07:51:59 +00:00
|
|
|
|
jp hl
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
|
|
|
|
; print decimal number (converted from binary number)
|
|
|
|
|
; 09AAAABB
|
|
|
|
|
; AAAA = address of number
|
|
|
|
|
; BB
|
|
|
|
|
; bits 0-3 = how many digits to display
|
|
|
|
|
; bits 4-7 = how long the number is in bytes
|
2016-06-12 00:24:04 +00:00
|
|
|
|
TextCommand09::
|
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
|
2015-07-28 01:48:44 +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
|
|
|
|
|
|
|
|
|
|
; wait half a second if the user doesn't hold A or B
|
|
|
|
|
; 0A
|
|
|
|
|
; (no arguments)
|
2016-06-12 00:24:04 +00:00
|
|
|
|
TextCommand0A::
|
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
|
|
|
|
|
jr nz, .skipDelay
|
|
|
|
|
ld c, 30
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call DelayFrames
|
|
|
|
|
.skipDelay
|
|
|
|
|
pop bc
|
|
|
|
|
pop hl
|
|
|
|
|
jp NextTextCommand
|
|
|
|
|
|
|
|
|
|
; plays sounds
|
|
|
|
|
; this actually handles various command ID's, not just 0B
|
|
|
|
|
; (no arguments)
|
2016-06-12 00:24:04 +00:00
|
|
|
|
TextCommand0B::
|
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]
|
|
|
|
|
ld b, a ; b = 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
|
2017-12-30 00:54:27 +00:00
|
|
|
|
jr z, .matchFound
|
2014-05-31 02:52:24 +00:00
|
|
|
|
inc hl
|
|
|
|
|
jr .loop
|
|
|
|
|
.matchFound
|
2017-12-30 00:54:27 +00:00
|
|
|
|
cp $14
|
|
|
|
|
jr z, .pokemonCry
|
|
|
|
|
cp $15
|
|
|
|
|
jr z, .pokemonCry
|
|
|
|
|
cp $16
|
|
|
|
|
jr z, .pokemonCry
|
|
|
|
|
ld a, [hl]
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call PlaySound
|
|
|
|
|
call WaitForSoundToFinish
|
|
|
|
|
pop hl
|
|
|
|
|
pop bc
|
|
|
|
|
jp NextTextCommand
|
|
|
|
|
.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
|
|
|
|
|
|
|
|
|
|
; format: text command ID, sound ID or cry ID
|
2016-06-12 00:24:04 +00:00
|
|
|
|
TextCommandSounds::
|
2016-07-18 06:32:24 +00:00
|
|
|
|
db $0B, SFX_GET_ITEM_1 ; actually plays SFX_LEVEL_UP when the battle music engine is loaded
|
2016-06-12 07:51:59 +00:00
|
|
|
|
db $12, SFX_CAUGHT_MON
|
2016-07-18 06:32:24 +00:00
|
|
|
|
db $0E, SFX_POKEDEX_RATING ; unused?
|
|
|
|
|
db $0F, SFX_GET_ITEM_1 ; unused?
|
2016-06-12 07:51:59 +00:00
|
|
|
|
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?
|
2014-05-31 02:52:24 +00:00
|
|
|
|
|
|
|
|
|
; draw ellipses
|
|
|
|
|
; 0CAA
|
|
|
|
|
; AA = number of ellipses to draw
|
2016-06-12 00:24:04 +00:00
|
|
|
|
TextCommand0C::
|
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
|
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
|
|
|
|
|
jr nz, .skipDelay ; if so, skip the delay
|
|
|
|
|
ld c, 10
|
2014-05-31 02:52:24 +00:00
|
|
|
|
call DelayFrames
|
|
|
|
|
.skipDelay
|
|
|
|
|
dec d
|
2017-12-30 00:54:27 +00:00
|
|
|
|
jr nz, .loop
|
|
|
|
|
ld b, h
|
|
|
|
|
ld c, l
|
2014-05-31 02:52:24 +00:00
|
|
|
|
pop hl
|
|
|
|
|
jp NextTextCommand
|
|
|
|
|
|
|
|
|
|
; wait for A or B to be pressed
|
|
|
|
|
; 0D
|
|
|
|
|
; (no arguments)
|
2016-06-12 00:24:04 +00:00
|
|
|
|
TextCommand0D::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
push bc
|
|
|
|
|
call ManualTextScroll ; wait for A or B to be pressed
|
|
|
|
|
pop bc
|
|
|
|
|
pop hl
|
|
|
|
|
jp NextTextCommand
|
|
|
|
|
|
|
|
|
|
; process text commands in another ROM bank
|
|
|
|
|
; 17AAAABB
|
|
|
|
|
; AAAA = address of text commands
|
|
|
|
|
; BB = bank
|
2016-06-12 00:24:04 +00:00
|
|
|
|
TextCommand17::
|
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
|
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-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
|
|
|
|
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
|
|
|
|
|
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::
|
2014-05-31 02:52:24 +00:00
|
|
|
|
dw TextCommand00
|
|
|
|
|
dw TextCommand01
|
|
|
|
|
dw TextCommand02
|
|
|
|
|
dw TextCommand03
|
|
|
|
|
dw TextCommand04
|
|
|
|
|
dw TextCommand05
|
|
|
|
|
dw TextCommand06
|
|
|
|
|
dw TextCommand07
|
|
|
|
|
dw TextCommand08
|
|
|
|
|
dw TextCommand09
|
|
|
|
|
dw TextCommand0A
|
|
|
|
|
dw TextCommand0B
|
|
|
|
|
dw TextCommand0C
|
|
|
|
|
dw TextCommand0D
|