mirror of
https://github.com/thornAvery/kep-hack.git
synced 2025-12-03 01:54:28 +13:00
Use assertions to catch the GetName bug, and use a NAME_BUFFER_LENGTH constant
This commit is contained in:
parent
506a14084e
commit
4b64b146e4
|
|
@ -1,5 +1,6 @@
|
||||||
NAME_LENGTH EQU 11
|
NAME_LENGTH EQU 11
|
||||||
ITEM_NAME_LENGTH EQU 13
|
ITEM_NAME_LENGTH EQU 13
|
||||||
|
NAME_BUFFER_LENGTH EQU 20
|
||||||
|
|
||||||
; PrintNumber
|
; PrintNumber
|
||||||
const_def 5
|
const_def 5
|
||||||
|
|
|
||||||
|
|
@ -210,7 +210,7 @@ GetDefaultName:
|
||||||
ld h, d
|
ld h, d
|
||||||
ld l, e
|
ld l, e
|
||||||
ld de, wcd6d
|
ld de, wcd6d
|
||||||
ld bc, $14
|
ld bc, NAME_BUFFER_LENGTH
|
||||||
jp CopyData
|
jp CopyData
|
||||||
|
|
||||||
INCLUDE "data/player_names_list.asm"
|
INCLUDE "data/player_names_list.asm"
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,12 @@ GetName::
|
||||||
|
|
||||||
; TM names are separate from item names.
|
; TM names are separate from item names.
|
||||||
; BUG: This applies to all names instead of just items.
|
; BUG: This applies to all names instead of just items.
|
||||||
|
assert NUM_POKEMON_INDEXES < HM01, \
|
||||||
|
"A bug in GetName will get TM/HM names for Pokémon above ${x:HM01}."
|
||||||
|
assert NUM_ATTACKS < HM01, \
|
||||||
|
"A bug in GetName will get TM/HM names for moves above ${x:HM01}."
|
||||||
|
assert NUM_TRAINERS < HM01, \
|
||||||
|
"A bug in GetName will get TM/HM names for trainers above ${x:HM01}."
|
||||||
cp HM01
|
cp HM01
|
||||||
jp nc, GetMachineName
|
jp nc, GetMachineName
|
||||||
|
|
||||||
|
|
@ -28,10 +34,10 @@ GetName::
|
||||||
push hl
|
push hl
|
||||||
push bc
|
push bc
|
||||||
push de
|
push de
|
||||||
ld a, [wNameListType] ;List3759_entrySelector
|
ld a, [wNameListType]
|
||||||
dec a
|
dec a
|
||||||
jr nz, .otherEntries
|
jr nz, .otherEntries
|
||||||
;1 = MON_NAMES
|
; 1 = MONSTER_NAME
|
||||||
call GetMonName
|
call GetMonName
|
||||||
ld hl, NAME_LENGTH
|
ld hl, NAME_LENGTH
|
||||||
add hl, de
|
add hl, de
|
||||||
|
|
@ -39,11 +45,11 @@ GetName::
|
||||||
ld d, h
|
ld d, h
|
||||||
jr .gotPtr
|
jr .gotPtr
|
||||||
.otherEntries
|
.otherEntries
|
||||||
;2-7 = OTHER ENTRIES
|
; 2-7 = other names
|
||||||
ld a, [wPredefBank]
|
ld a, [wPredefBank]
|
||||||
ldh [hLoadedROMBank], a
|
ldh [hLoadedROMBank], a
|
||||||
ld [MBC1RomBank], a
|
ld [MBC1RomBank], a
|
||||||
ld a, [wNameListType] ;VariousNames' entryID
|
ld a, [wNameListType]
|
||||||
dec a
|
dec a
|
||||||
add a
|
add a
|
||||||
ld d, 0
|
ld d, 0
|
||||||
|
|
@ -62,8 +68,8 @@ GetName::
|
||||||
ldh a, [hSwapTemp + 1]
|
ldh a, [hSwapTemp + 1]
|
||||||
ld l, a
|
ld l, a
|
||||||
ld a, [wd0b5]
|
ld a, [wd0b5]
|
||||||
ld b, a
|
ld b, a ; wanted entry
|
||||||
ld c, 0
|
ld c, 0 ; entry counter
|
||||||
.nextName
|
.nextName
|
||||||
ld d, h
|
ld d, h
|
||||||
ld e, l
|
ld e, l
|
||||||
|
|
@ -71,14 +77,14 @@ GetName::
|
||||||
ld a, [hli]
|
ld a, [hli]
|
||||||
cp "@"
|
cp "@"
|
||||||
jr nz, .nextChar
|
jr nz, .nextChar
|
||||||
inc c ;entry counter
|
inc c
|
||||||
ld a, b ;wanted entry
|
ld a, b
|
||||||
cp c
|
cp c
|
||||||
jr nz, .nextName
|
jr nz, .nextName
|
||||||
ld h, d
|
ld h, d
|
||||||
ld l, e
|
ld l, e
|
||||||
ld de, wcd6d
|
ld de, wcd6d
|
||||||
ld bc, $14
|
ld bc, NAME_BUFFER_LENGTH
|
||||||
call CopyData
|
call CopyData
|
||||||
.gotPtr
|
.gotPtr
|
||||||
ld a, e
|
ld a, e
|
||||||
|
|
|
||||||
6
wram.asm
6
wram.asm
|
|
@ -1173,7 +1173,11 @@ wNumMovesMinusOne::
|
||||||
|
|
||||||
UNION
|
UNION
|
||||||
|
|
||||||
wcd6d:: ds 4 ; buffer for various data
|
wcd6d:: ds NAME_BUFFER_LENGTH ; buffer for various data
|
||||||
|
|
||||||
|
NEXTU
|
||||||
|
|
||||||
|
ds 4
|
||||||
|
|
||||||
wStatusScreenCurrentPP::
|
wStatusScreenCurrentPP::
|
||||||
; temp variable used to print a move's current PP on the status screen
|
; temp variable used to print a move's current PP on the status screen
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue