2018-06-24 07:09:41 -07:00
|
|
|
NamesPointers::
|
2018-01-18 21:29:05 -08:00
|
|
|
; entries correspond to GetName constants (see constants/text_constants.asm)
|
2018-01-20 09:25:55 -08:00
|
|
|
dba PokemonNames ; MON_NAME (not used; jumps to GetPokemonName)
|
2018-01-18 21:42:31 -08:00
|
|
|
dba MoveNames ; MOVE_NAME
|
2018-07-29 13:00:11 -07:00
|
|
|
dba NULL ; DUMMY_NAME
|
2018-01-18 21:42:31 -08:00
|
|
|
dba ItemNames ; ITEM_NAME
|
2018-07-29 13:00:11 -07:00
|
|
|
dbw 0, wPartyMonOT ; PARTY_OT_NAME
|
|
|
|
dbw 0, wOTPartyMonOT ; ENEMY_OT_NAME
|
2018-01-18 21:42:31 -08:00
|
|
|
dba TrainerClassNames ; TRAINER_NAME
|
|
|
|
dbw 4, MoveDescriptions ; MOVE_DESC_NAME_BROKEN (wrong bank)
|
2017-12-22 19:50:28 -08:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetName::
|
2018-01-23 14:39:09 -08:00
|
|
|
; Return name wCurSpecies from name list wNamedObjectTypeBuffer in wStringBuffer1.
|
2017-12-22 19:50:28 -08:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2017-12-22 19:50:28 -08:00
|
|
|
push af
|
|
|
|
push hl
|
|
|
|
push bc
|
|
|
|
push de
|
|
|
|
|
|
|
|
ld a, [wNamedObjectTypeBuffer]
|
2018-01-20 09:25:55 -08:00
|
|
|
cp MON_NAME
|
2017-12-22 19:50:28 -08:00
|
|
|
jr nz, .NotPokeName
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurSpecies]
|
2018-07-28 16:27:34 -07:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
2017-12-22 19:50:28 -08:00
|
|
|
call GetPokemonName
|
2018-01-20 09:25:55 -08:00
|
|
|
ld hl, MON_NAME_LENGTH
|
2017-12-22 19:50:28 -08:00
|
|
|
add hl, de
|
|
|
|
ld e, l
|
|
|
|
ld d, h
|
|
|
|
jr .done
|
|
|
|
|
|
|
|
.NotPokeName:
|
|
|
|
ld a, [wNamedObjectTypeBuffer]
|
|
|
|
dec a
|
|
|
|
ld e, a
|
|
|
|
ld d, 0
|
|
|
|
ld hl, NamesPointers
|
|
|
|
add hl, de
|
|
|
|
add hl, de
|
|
|
|
add hl, de
|
|
|
|
ld a, [hli]
|
|
|
|
rst Bankswitch
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wCurSpecies]
|
2017-12-22 19:50:28 -08:00
|
|
|
dec a
|
|
|
|
call GetNthString
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wStringBuffer1
|
2017-12-22 19:50:28 -08:00
|
|
|
ld bc, ITEM_NAME_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
.done
|
|
|
|
ld a, e
|
2020-10-28 10:35:39 -07:00
|
|
|
ld [wUnusedNamesPointer], a
|
2017-12-22 19:50:28 -08:00
|
|
|
ld a, d
|
2020-10-28 10:35:39 -07:00
|
|
|
ld [wUnusedNamesPointer + 1], a
|
2017-12-22 19:50:28 -08:00
|
|
|
|
|
|
|
pop de
|
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetNthString::
|
2017-12-22 19:50:28 -08:00
|
|
|
; Return the address of the
|
|
|
|
; ath string starting from hl.
|
|
|
|
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
|
|
|
|
push bc
|
|
|
|
ld b, a
|
|
|
|
ld c, "@"
|
|
|
|
.readChar
|
|
|
|
ld a, [hli]
|
|
|
|
cp c
|
|
|
|
jr nz, .readChar
|
|
|
|
dec b
|
|
|
|
jr nz, .readChar
|
|
|
|
pop bc
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetBasePokemonName::
|
2017-12-22 19:50:28 -08:00
|
|
|
; Discards gender (Nidoran).
|
|
|
|
|
|
|
|
push hl
|
|
|
|
call GetPokemonName
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wStringBuffer1
|
2017-12-22 19:50:28 -08:00
|
|
|
.loop
|
|
|
|
ld a, [hl]
|
|
|
|
cp "@"
|
|
|
|
jr z, .quit
|
|
|
|
cp "♂"
|
|
|
|
jr z, .end
|
|
|
|
cp "♀"
|
|
|
|
jr z, .end
|
|
|
|
inc hl
|
|
|
|
jr .loop
|
|
|
|
.end
|
|
|
|
ld [hl], "@"
|
|
|
|
.quit
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetPokemonName::
|
2018-07-28 16:27:34 -07:00
|
|
|
; Get Pokemon name for wNamedObjectIndexBuffer.
|
2017-12-22 19:50:28 -08:00
|
|
|
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2017-12-22 19:50:28 -08:00
|
|
|
push af
|
|
|
|
push hl
|
|
|
|
ld a, BANK(PokemonNames)
|
|
|
|
rst Bankswitch
|
|
|
|
|
|
|
|
; Each name is ten characters
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wNamedObjectIndexBuffer]
|
2017-12-22 19:50:28 -08:00
|
|
|
dec a
|
|
|
|
ld d, 0
|
|
|
|
ld e, a
|
|
|
|
ld h, 0
|
|
|
|
ld l, a
|
2020-02-19 10:28:50 -08:00
|
|
|
add hl, hl
|
|
|
|
add hl, hl
|
|
|
|
add hl, de
|
|
|
|
add hl, hl
|
2017-12-22 19:50:28 -08:00
|
|
|
ld de, PokemonNames
|
|
|
|
add hl, de
|
|
|
|
|
|
|
|
; Terminator
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wStringBuffer1
|
2017-12-22 19:50:28 -08:00
|
|
|
push de
|
2018-01-20 09:25:55 -08:00
|
|
|
ld bc, MON_NAME_LENGTH - 1
|
2017-12-22 19:50:28 -08:00
|
|
|
call CopyBytes
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wStringBuffer1 + MON_NAME_LENGTH - 1
|
2017-12-22 19:50:28 -08:00
|
|
|
ld [hl], "@"
|
|
|
|
pop de
|
|
|
|
|
|
|
|
pop hl
|
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetItemName::
|
2018-07-28 16:27:34 -07:00
|
|
|
; Get item name for wNamedObjectIndexBuffer.
|
2017-12-22 19:50:28 -08:00
|
|
|
|
|
|
|
push hl
|
|
|
|
push bc
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wNamedObjectIndexBuffer]
|
2017-12-22 19:50:28 -08:00
|
|
|
|
|
|
|
cp TM01
|
|
|
|
jr nc, .TM
|
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurSpecies], a
|
2017-12-22 19:50:28 -08:00
|
|
|
ld a, ITEM_NAME
|
|
|
|
ld [wNamedObjectTypeBuffer], a
|
|
|
|
call GetName
|
|
|
|
jr .Copied
|
|
|
|
.TM:
|
|
|
|
call GetTMHMName
|
|
|
|
.Copied:
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wStringBuffer1
|
2017-12-22 19:50:28 -08:00
|
|
|
pop bc
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetTMHMName::
|
2018-07-28 16:27:34 -07:00
|
|
|
; Get TM/HM name for item wNamedObjectIndexBuffer.
|
2017-12-22 19:50:28 -08:00
|
|
|
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wNamedObjectIndexBuffer]
|
2017-12-22 19:50:28 -08:00
|
|
|
push af
|
|
|
|
|
|
|
|
; TM/HM prefix
|
|
|
|
cp HM01
|
|
|
|
push af
|
|
|
|
jr c, .TM
|
|
|
|
|
|
|
|
ld hl, .HMText
|
|
|
|
ld bc, .HMTextEnd - .HMText
|
2020-02-19 10:28:50 -08:00
|
|
|
jr .copy
|
2017-12-22 19:50:28 -08:00
|
|
|
|
|
|
|
.TM:
|
|
|
|
ld hl, .TMText
|
|
|
|
ld bc, .TMTextEnd - .TMText
|
|
|
|
|
2020-02-19 10:28:50 -08:00
|
|
|
.copy
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wStringBuffer1
|
2017-12-22 19:50:28 -08:00
|
|
|
call CopyBytes
|
|
|
|
|
|
|
|
; TM/HM number
|
|
|
|
push de
|
2018-07-28 16:27:34 -07:00
|
|
|
ld a, [wNamedObjectIndexBuffer]
|
2017-12-22 19:50:28 -08:00
|
|
|
ld c, a
|
2017-12-24 09:47:30 -08:00
|
|
|
callfar GetTMHMNumber
|
2017-12-22 19:50:28 -08:00
|
|
|
pop de
|
|
|
|
|
|
|
|
; HM numbers start from 51, not 1
|
|
|
|
pop af
|
|
|
|
ld a, c
|
2020-02-19 10:28:50 -08:00
|
|
|
jr c, .not_hm
|
2017-12-22 19:50:28 -08:00
|
|
|
sub NUM_TMS
|
2020-02-19 10:28:50 -08:00
|
|
|
.not_hm
|
2017-12-22 19:50:28 -08:00
|
|
|
|
|
|
|
; Divide and mod by 10 to get the top and bottom digits respectively
|
|
|
|
ld b, "0"
|
|
|
|
.mod10
|
|
|
|
sub 10
|
2020-02-19 10:28:50 -08:00
|
|
|
jr c, .done_mod
|
2017-12-22 19:50:28 -08:00
|
|
|
inc b
|
|
|
|
jr .mod10
|
|
|
|
|
2020-02-19 10:28:50 -08:00
|
|
|
.done_mod
|
|
|
|
add 10
|
2017-12-22 19:50:28 -08:00
|
|
|
push af
|
|
|
|
ld a, b
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
pop af
|
|
|
|
|
|
|
|
ld b, "0"
|
|
|
|
add b
|
|
|
|
ld [de], a
|
|
|
|
|
|
|
|
; End the string
|
|
|
|
inc de
|
|
|
|
ld a, "@"
|
|
|
|
ld [de], a
|
|
|
|
|
|
|
|
pop af
|
2018-07-28 16:27:34 -07:00
|
|
|
ld [wNamedObjectIndexBuffer], a
|
2017-12-22 19:50:28 -08:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
|
|
|
.TMText:
|
|
|
|
db "TM"
|
|
|
|
.TMTextEnd:
|
|
|
|
db "@"
|
|
|
|
|
|
|
|
.HMText:
|
|
|
|
db "HM"
|
|
|
|
.HMTextEnd:
|
|
|
|
db "@"
|
|
|
|
|
|
|
|
INCLUDE "home/hm_moves.asm"
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetMoveName::
|
2017-12-22 19:50:28 -08:00
|
|
|
push hl
|
|
|
|
|
|
|
|
ld a, MOVE_NAME
|
|
|
|
ld [wNamedObjectTypeBuffer], a
|
|
|
|
|
|
|
|
ld a, [wNamedObjectIndexBuffer] ; move id
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wCurSpecies], a
|
2017-12-22 19:50:28 -08:00
|
|
|
|
|
|
|
call GetName
|
2018-01-23 14:39:09 -08:00
|
|
|
ld de, wStringBuffer1
|
2017-12-22 19:50:28 -08:00
|
|
|
|
|
|
|
pop hl
|
|
|
|
ret
|