pokered/home/names.asm

142 lines
2.2 KiB
NASM
Raw Normal View History

2020-07-04 02:57:43 +00:00
GetMonName::
push hl
ldh a, [hLoadedROMBank]
2020-07-04 02:57:43 +00:00
push af
ld a, BANK(MonsterNames)
ldh [hLoadedROMBank], a
2020-07-04 02:57:43 +00:00
ld [MBC1RomBank], a
ld a, [wd11e]
dec a
ld hl, MonsterNames
ld c, 10
ld b, 0
call AddNTimes
ld de, wcd6d
push de
ld bc, 10
call CopyData
ld hl, wcd6d + 10
ld [hl], "@"
pop de
pop af
ldh [hLoadedROMBank], a
2020-07-04 02:57:43 +00:00
ld [MBC1RomBank], a
pop hl
ret
GetItemName::
; given an item ID at [wd11e], store the name of the item into a string
; starting at wcd6d
push hl
push bc
ld a, [wd11e]
2020-07-06 02:52:27 +00:00
cp HM01 ; is this a TM/HM?
2020-07-04 02:57:43 +00:00
jr nc, .Machine
ld [wd0b5], a
ld a, ITEM_NAME
ld [wNameListType], a
ld a, BANK(ItemNames)
ld [wPredefBank], a
call GetName
jr .Finish
.Machine
call GetMachineName
.Finish
ld de, wcd6d ; pointer to where item name is stored in RAM
pop bc
pop hl
ret
GetMachineName::
; copies the name of the TM/HM in [wd11e] to wcd6d
push hl
push de
push bc
ld a, [wd11e]
push af
2020-07-06 02:52:27 +00:00
cp TM01 ; is this a TM? [not HM]
2020-07-04 02:57:43 +00:00
jr nc, .WriteTM
2020-07-06 02:52:27 +00:00
; if HM, then write "HM" and add NUM_HMS to the item ID, so we can reuse the
2020-07-04 02:57:43 +00:00
; TM printing code
2020-07-06 02:52:27 +00:00
add NUM_HMS
2020-07-04 02:57:43 +00:00
ld [wd11e], a
ld hl, HiddenPrefix ; points to "HM"
ld bc, 2
jr .WriteMachinePrefix
.WriteTM
ld hl, TechnicalPrefix ; points to "TM"
ld bc, 2
.WriteMachinePrefix
ld de, wcd6d
call CopyData
; now get the machine number and convert it to text
ld a, [wd11e]
2020-07-06 02:52:27 +00:00
sub TM01 - 1
2020-07-04 02:57:43 +00:00
ld b, "0"
.FirstDigit
sub 10
jr c, .SecondDigit
inc b
jr .FirstDigit
.SecondDigit
add 10
push af
ld a, b
ld [de], a
inc de
pop af
ld b, "0"
add b
ld [de], a
inc de
ld a, "@"
ld [de], a
pop af
ld [wd11e], a
pop bc
pop de
pop hl
ret
TechnicalPrefix::
db "TM"
HiddenPrefix::
db "HM"
; sets carry if item is HM, clears carry if item is not HM
; Input: a = item ID
IsItemHM::
2020-07-06 02:52:27 +00:00
cp HM01
2020-07-04 02:57:43 +00:00
jr c, .notHM
2020-07-06 02:52:27 +00:00
cp TM01
2020-07-04 02:57:43 +00:00
ret
.notHM
and a
ret
; sets carry if move is an HM, clears carry if move is not an HM
; Input: a = move ID
IsMoveHM::
ld hl, HMMoves
ld de, 1
jp IsInArray
HMMoves::
INCLUDE "data/moves/hm_moves.asm"
GetMoveName::
push hl
ld a, MOVE_NAME
ld [wNameListType], a
ld a, [wd11e]
ld [wd0b5], a
ld a, BANK(MoveNames)
ld [wPredefBank], a
call GetName
ld de, wcd6d ; pointer to where move name is stored in RAM
pop hl
ret