Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/home/names.asm
1270 views
1
GetMonName::
2
push hl
3
ldh a, [hLoadedROMBank]
4
push af
5
ld a, BANK(MonsterNames)
6
ldh [hLoadedROMBank], a
7
ld [rROMB], a
8
ld a, [wNamedObjectIndex]
9
dec a
10
ld hl, MonsterNames
11
ld c, NAME_LENGTH - 1
12
ld b, 0
13
call AddNTimes
14
ld de, wNameBuffer
15
push de
16
ld bc, NAME_LENGTH - 1
17
call CopyData
18
ld hl, wNameBuffer + NAME_LENGTH - 1
19
ld [hl], "@"
20
pop de
21
pop af
22
ldh [hLoadedROMBank], a
23
ld [rROMB], a
24
pop hl
25
ret
26
27
GetItemName::
28
; given an item ID at [wNamedObjectIndex], store the name of the item in wNameBuffer
29
push hl
30
push bc
31
ld a, [wNamedObjectIndex]
32
cp HM01 ; is this a TM/HM?
33
jr nc, .Machine
34
35
ld [wNameListIndex], a
36
ld a, ITEM_NAME
37
ld [wNameListType], a
38
ld a, BANK(ItemNames)
39
ld [wPredefBank], a
40
call GetName
41
jr .Finish
42
43
.Machine
44
call GetMachineName
45
.Finish
46
ld de, wNameBuffer
47
pop bc
48
pop hl
49
ret
50
51
GetMachineName::
52
; copies the name of the TM/HM in [wNamedObjectIndex] to wNameBuffer
53
push hl
54
push de
55
push bc
56
ld a, [wNamedObjectIndex]
57
push af
58
cp TM01 ; is this a TM? [not HM]
59
jr nc, .WriteTM
60
; if HM, then write "HM" and add NUM_HMS to the item ID, so we can reuse the
61
; TM printing code
62
add NUM_HMS
63
ld [wNamedObjectIndex], a
64
ld hl, HiddenPrefix ; points to "HM"
65
ld bc, 2
66
jr .WriteMachinePrefix
67
.WriteTM
68
ld hl, TechnicalPrefix ; points to "TM"
69
ld bc, 2
70
.WriteMachinePrefix
71
ld de, wNameBuffer
72
call CopyData
73
74
; now get the machine number and convert it to text
75
ld a, [wNamedObjectIndex]
76
sub TM01 - 1
77
ld b, "0"
78
.FirstDigit
79
sub 10
80
jr c, .SecondDigit
81
inc b
82
jr .FirstDigit
83
.SecondDigit
84
add 10
85
push af
86
ld a, b
87
ld [de], a
88
inc de
89
pop af
90
ld b, "0"
91
add b
92
ld [de], a
93
inc de
94
ld a, "@"
95
ld [de], a
96
pop af
97
ld [wNamedObjectIndex], a
98
pop bc
99
pop de
100
pop hl
101
ret
102
103
TechnicalPrefix::
104
db "TM"
105
HiddenPrefix::
106
db "HM"
107
108
; sets carry if item is HM, clears carry if item is not HM
109
; Input: a = item ID
110
IsItemHM::
111
cp HM01
112
jr c, .notHM
113
cp TM01
114
ret
115
.notHM
116
and a
117
ret
118
119
; sets carry if move is an HM, clears carry if move is not an HM
120
; Input: a = move ID
121
IsMoveHM::
122
ld hl, HMMoves
123
ld de, 1
124
jp IsInArray
125
126
HMMoves::
127
INCLUDE "data/moves/hm_moves.asm"
128
129
GetMoveName::
130
push hl
131
ld a, MOVE_NAME
132
ld [wNameListType], a
133
ld a, [wNamedObjectIndex]
134
ld [wNameListIndex], a
135
ld a, BANK(MoveNames)
136
ld [wPredefBank], a
137
call GetName
138
ld de, wNameBuffer
139
pop hl
140
ret
141
142