forked from pret/pokered
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnames.asm
141 lines (131 loc) · 2.17 KB
/
names.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
GetMonName::
push hl
ldh a, [hLoadedROMBank]
push af
ld a, BANK(MonsterNames)
ldh [hLoadedROMBank], a
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
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]
cp HM01 ; is this a TM/HM?
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
cp TM01 ; is this a TM? [not HM]
jr nc, .WriteTM
; if HM, then write "HM" and add NUM_HMS to the item ID, so we can reuse the
; TM printing code
add NUM_HMS
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]
sub TM01 - 1
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::
cp HM01
jr c, .notHM
cp TM01
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