Skip to content

Commit 4134b7e

Browse files
QoL #16: improve name handling
1 parent 5330187 commit 4134b7e

File tree

2 files changed

+16
-29
lines changed

2 files changed

+16
-29
lines changed

constants/text_constants.asm

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ NAME_LENGTH_JAPANESE EQU 6
1212
const_def 1
1313
const MON_NAME ; 1
1414
const MOVE_NAME ; 2
15-
const DUMMY_NAME ; 3
16-
const ITEM_NAME ; 4
17-
const PARTY_OT_NAME ; 5
18-
const ENEMY_OT_NAME ; 6
19-
const TRAINER_NAME ; 7
20-
const MOVE_DESC_NAME_BROKEN ; 8
15+
const ITEM_NAME ; 3
16+
const PARTY_OT_NAME ; 4
17+
const ENEMY_OT_NAME ; 5
18+
const TRAINER_NAME ; 6
2119

2220
; see home/text.asm
2321
BORDER_WIDTH EQU 2

home/names.asm

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
NamesPointers::
2-
; entries correspond to GetName constants (see constants/text_constants.asm)
3-
dba PokemonNames ; MON_NAME (not used; jumps to GetPokemonName)
2+
; entries correspond to GetName constants (see constants/text_constants.asm); MON_NAME is not handled by this table
43
dba MoveNames ; MOVE_NAME
5-
dba NULL ; DUMMY_NAME
64
dba ItemNames ; ITEM_NAME
75
dbw 0, wPartyMonOT ; PARTY_OT_NAME
86
dbw 0, wOTPartyMonOT ; ENEMY_OT_NAME
97
dba TrainerClassNames ; TRAINER_NAME
10-
dbw 4, MoveDescriptions ; MOVE_DESC_NAME_BROKEN (wrong bank)
118

129
GetName::
1310
; Return name wCurSpecies from name list wNamedObjectTypeBuffer in wStringBuffer1.
@@ -19,27 +16,24 @@ GetName::
1916
push de
2017

2118
ld a, [wNamedObjectTypeBuffer]
22-
cp MON_NAME
23-
jr nz, .NotPokeName
19+
dec a
20+
jr nz, .not_mon_name
2421

2522
ld a, [wCurSpecies]
2623
ld [wNamedObjectIndexBuffer], a
2724
call GetPokemonName
28-
ld hl, MON_NAME_LENGTH
29-
add hl, de
30-
ld e, l
31-
ld d, h
3225
jr .done
3326

34-
.NotPokeName:
35-
ld a, [wNamedObjectTypeBuffer]
27+
.not_mon_name
3628
dec a
37-
ld e, a
38-
ld d, 0
39-
ld hl, NamesPointers
40-
add hl, de
41-
add hl, de
42-
add hl, de
29+
ld l, a
30+
add a, a
31+
add a, l
32+
add a, LOW(NamesPointers)
33+
ld l, a
34+
ld a, HIGH(NamesPointers)
35+
adc 0
36+
ld h, a
4337
ld a, [hli]
4438
rst Bankswitch
4539
ld a, [hli]
@@ -55,11 +49,6 @@ GetName::
5549
call CopyBytes
5650

5751
.done
58-
ld a, e
59-
ld [wUnusedD102], a
60-
ld a, d
61-
ld [wUnusedD102 + 1], a
62-
6352
pop de
6453
pop bc
6554
pop hl

0 commit comments

Comments
 (0)