ref: 4aedff021786dd5c0b81d3a35f505b7aa42adddc
parent: 1df1e9181e2f3d95f57c98e0ea6e38ce4261fb2a
author: dannye <corrnondacqb@yahoo.com>
date: Mon Aug 10 19:51:20 EDT 2015
Replace hardcoded name lengths with NAME_LENGTH
--- a/constants/misc_constants.asm
+++ b/constants/misc_constants.asm
@@ -14,6 +14,8 @@
HOF_TEAM EQU PARTY_LENGTH * HOF_MON
HOF_TEAM_CAPACITY EQU 50
+NAME_LENGTH EQU 11
+
A_BUTTON EQU %00000001
B_BUTTON EQU %00000010
SELECT EQU %00000100
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -1728,7 +1728,7 @@
ld a, [wPlayerMonNumber]
call SkipFixedLengthTextEntries
ld de, wBattleMonNick
- ld bc, $b
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wBattleMonLevel
ld de, wPlayerMonUnmodifiedLevel ; block of memory used for unmodified stats
@@ -1772,7 +1772,7 @@
ld a, [wWhichPokemon]
call SkipFixedLengthTextEntries
ld de, wEnemyMonNick
- ld bc, $b
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wEnemyMonLevel
ld de, wEnemyMonUnmodifiedLevel ; block of memory used for unmodified stats
@@ -2099,7 +2099,7 @@
; the following happens for the old man tutorial
ld hl, wPlayerName
ld de, W_GRASSRATE
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData ; temporarily save the player name in unused space,
; which is supposed to get overwritten when entering a
; map with wild Pokémon. Due to an oversight, the data
@@ -2107,7 +2107,7 @@
; Missingno. glitch can show up.
ld hl, .oldManName
ld de, wPlayerName
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
; the following simulates the keystrokes by drawing menus on screen
coord hl, 9, 14
@@ -6326,7 +6326,7 @@
call GetMonName
ld hl, wcd6d
ld de, wEnemyMonNick
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld a, [wEnemyMonSpecies2]
ld [wd11e], a
--- a/engine/cable_club.asm
+++ b/engine/cable_club.asm
@@ -176,7 +176,7 @@
jr z, .findStartOfEnemyNameLoop
dec hl
ld de, wLinkEnemyTrainerName
- ld c, 11
+ ld c, NAME_LENGTH
.copyEnemyNameLoop
ld a, [hli]
cp SERIAL_NO_DATA_BYTE
@@ -698,7 +698,7 @@
call GetMonName
ld hl, wcd6d
ld de, wNameOfPlayerMonToBeTraded
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld a, [wTradingWhichEnemyMon]
ld hl, wEnemyPartyMons
@@ -756,7 +756,7 @@
ld hl, wPartyMonOT
call SkipFixedLengthTextEntries
ld de, wTradedPlayerMonOT
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wPartyMon1Species
ld a, [wTradingWhichPlayerMon]
@@ -772,7 +772,7 @@
ld hl, wEnemyMonOT
call SkipFixedLengthTextEntries
ld de, wTradedEnemyMonOT
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wEnemyMons
ld a, [wTradingWhichEnemyMon]
--- a/engine/evos_moves.asm
+++ b/engine/evos_moves.asm
@@ -278,7 +278,7 @@
cp "@"
jr nz, .compareNamesLoop
ld a, [wWhichPokemon]
- ld bc, 11
+ ld bc, NAME_LENGTH
ld hl, wPartyMonNicks
call AddNTimes
push hl
--- a/engine/hall_of_fame.asm
+++ b/engine/hall_of_fame.asm
@@ -276,7 +276,7 @@
ld e, l
ld d, h
ld hl, wcd6d
- ld bc, $b
+ ld bc, NAME_LENGTH
jp CopyData
HoFFadeOutScreenAndMusic: ; 70423 (1c:4423)
--- a/engine/in_game_trades.asm
+++ b/engine/in_game_trades.asm
@@ -17,7 +17,7 @@
ld a,[hli]
push af
ld de,wInGameTradeMonNick
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
pop af
ld l,a
@@ -81,7 +81,7 @@
call GetMonName
ld hl,wcd6d
pop de
- ld bc, 11
+ ld bc, NAME_LENGTH
jp CopyData
INCLUDE "data/trades.asm"
@@ -168,11 +168,11 @@
ld a, [wInGameTradeReceiveMonSpecies]
ld [hl], a ; wTradedEnemyMonSpecies
ld hl, wPartyMonOT
- ld bc, 11
+ ld bc, NAME_LENGTH
ld a, [wWhichPokemon]
call AddNTimes
ld de, wTradedPlayerMonOT
- ld bc, 11
+ ld bc, NAME_LENGTH
call InGameTrade_CopyData
ld hl, InGameTrade_TrainerString
ld de, wTradedEnemyMonOT
@@ -201,16 +201,16 @@
InGameTrade_CopyDataToReceivedMon: ; 71d19 (1c:5d19)
ld hl, wPartyMonNicks
- ld bc, 11
+ ld bc, NAME_LENGTH
call InGameTrade_GetReceivedMonPointer
ld hl, wInGameTradeMonNick
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wPartyMonOT
- ld bc, 11
+ ld bc, NAME_LENGTH
call InGameTrade_GetReceivedMonPointer
ld hl, InGameTrade_TrainerString
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wPartyMon1OTID
ld bc, wPartyMon2 - wPartyMon1
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -142,7 +142,7 @@
.oldManBattle
ld hl,W_GRASSRATE
ld de,wPlayerName
- ld bc,11
+ ld bc,NAME_LENGTH
call CopyData ; save the player's name in the Wild Monster data (part of the Cinnabar Island Missingno glitch)
jp .BallSuccess
.notOldManBattle
@@ -2573,7 +2573,7 @@
jr nz, .asm_e7b1
call GetMonHeader
ld hl, wBoxMonOT
- ld bc, 11
+ ld bc, NAME_LENGTH
ld a, [W_NUMINBOX]
dec a
jr z, .asm_e7ee
@@ -2580,7 +2580,7 @@
dec a
call AddNTimes
push hl
- ld bc, 11
+ ld bc, NAME_LENGTH
add hl, bc
ld d, h
ld e, l
@@ -2591,12 +2591,12 @@
.asm_e7db
push bc
push hl
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
pop hl
ld d, h
ld e, l
- ld bc, -$b
+ ld bc, -NAME_LENGTH
add hl, bc
pop bc
dec b
@@ -2604,17 +2604,17 @@
.asm_e7ee
ld hl, wPlayerName
ld de, wBoxMonOT
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld a, [W_NUMINBOX]
dec a
jr z, .asm_e82a
ld hl, wBoxMonNicks
- ld bc, 11
+ ld bc, NAME_LENGTH
dec a
call AddNTimes
push hl
- ld bc, 11
+ ld bc, NAME_LENGTH
add hl, bc
ld d, h
ld e, l
@@ -2625,12 +2625,12 @@
.asm_e817
push bc
push hl
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
pop hl
ld d, h
ld e, l
- ld bc, -$b
+ ld bc, -NAME_LENGTH
add hl, bc
pop bc
dec b
--- a/engine/learn_move.asm
+++ b/engine/learn_move.asm
@@ -5,7 +5,7 @@
call GetPartyMonName
ld hl, wcd6d
ld de, wd036
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
DontAbandonLearning: ; 6e5b (1:6e5b)
--- a/engine/menu/league_pc.asm
+++ b/engine/menu/league_pc.asm
@@ -90,7 +90,7 @@
ld a, [hli]
ld [wHoFMonLevel], a
ld de, wcd6d
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld b, $0B
ld c, 0
--- a/engine/menu/main_menu.asm
+++ b/engine/menu/main_menu.asm
@@ -689,7 +689,7 @@
ld a, $1
ld [MBC1SRamBankingMode], a
ld [MBC1SRamBank], a
- ld b, $b
+ ld b, NAME_LENGTH
ld hl, sPlayerName
.loop
ld a, [hli]
--- a/engine/menu/naming_screen.asm
+++ b/engine/menu/naming_screen.asm
@@ -46,7 +46,7 @@
ld d, h
ld e, l
ld hl, wcd6d
- ld bc, 11
+ ld bc, NAME_LENGTH
jp CopyData
DoYouWantToNicknameText: ; 0x6557
@@ -67,13 +67,13 @@
cp "@"
jr z, .playerCancelled
ld hl, wPartyMonNicks
- ld bc, 11
+ ld bc, NAME_LENGTH
ld a, [wWhichPokemon]
call AddNTimes
ld e, l
ld d, h
ld hl, wBuffer
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
and a
ret
@@ -158,7 +158,7 @@
.submitNickname
pop de
ld hl, wcf4b
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
call GBPalWhiteOutWithDelay3
call ClearScreen
--- a/engine/menu/start_sub_menus.asm
+++ b/engine/menu/start_sub_menus.asm
@@ -813,7 +813,7 @@
call SkipFixedLengthTextEntries
push hl
ld de, wSwitchPartyMonTempBuffer
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wPartyMonOT
ld a, [wMenuItemToSwap]
@@ -820,11 +820,11 @@
call SkipFixedLengthTextEntries
pop de
push hl
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
pop de
ld hl, wSwitchPartyMonTempBuffer
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wPartyMonNicks
ld a, [wCurrentMenuItem]
@@ -831,7 +831,7 @@
call SkipFixedLengthTextEntries
push hl
ld de, wSwitchPartyMonTempBuffer
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wPartyMonNicks
ld a, [wMenuItemToSwap]
@@ -838,11 +838,11 @@
call SkipFixedLengthTextEntries
pop de
push hl
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
pop de
ld hl, wSwitchPartyMonTempBuffer
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld a, [wMenuItemToSwap]
ld [wSwappedMenuItem], a
--- a/engine/oak_speech.asm
+++ b/engine/oak_speech.asm
@@ -24,11 +24,11 @@
call z, InitOptions
ld hl, NintenText
ld de, wPlayerName
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, SonyText
ld de, W_RIVALNAME
- ld bc, 11
+ ld bc, NAME_LENGTH
jp CopyData
OakSpeech: ; 6115 (1:6115)
--- a/engine/oak_speech2.asm
+++ b/engine/oak_speech2.asm
@@ -73,7 +73,7 @@
call DelayFrames
pop de
ld hl, wcd6d
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
call Delay3
coord hl, 12, 4
--- a/engine/save.asm
+++ b/engine/save.asm
@@ -57,7 +57,7 @@
.checkSumsMatched
ld hl, sPlayerName
ld de, wPlayerName
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, sMainData
ld de, wMainDataStart
@@ -203,7 +203,7 @@
ld [MBC1SRamBank], a
ld hl, wPlayerName
ld de, sPlayerName
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wMainDataStart
ld de, sMainData
--- a/engine/titlescreen.asm
+++ b/engine/titlescreen.asm
@@ -1,6 +1,6 @@
-; copy text of fixed length $b (like player name, rival name, mon names, ...)
+; copy text of fixed length NAME_LENGTH (like player name, rival name, mon names, ...)
CopyFixedLengthText: ; 42b1 (1:42b1)
- ld bc, 11
+ ld bc, NAME_LENGTH
jp CopyData
SetDefaultNamesBeforeTitlescreen: ; 42b7 (1:42b7)
--- a/engine/trade.asm
+++ b/engine/trade.asm
@@ -190,7 +190,7 @@
call GetMonName
ld hl, wcd6d
ld de, wcf4b
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld a, [wTradedEnemyMonSpecies]
ld [wd11e], a
@@ -204,15 +204,15 @@
Trade_SwapNames: ; 41217 (10:5217)
ld hl, wPlayerName
ld de, wBuffer
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wLinkEnemyTrainerName
ld de, wPlayerName
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld hl, wBuffer
ld de, wLinkEnemyTrainerName
- ld bc, 11
+ ld bc, NAME_LENGTH
jp CopyData
Trade_Cleanup: ; 4123b (10:523b)
--- a/home.asm
+++ b/home.asm
@@ -626,10 +626,10 @@
GetPartyMonName:: ; 15ba (0:15ba)
push hl
push bc
- call SkipFixedLengthTextEntries ; add 11 to hl, a times
+ call SkipFixedLengthTextEntries ; add NAME_LENGTH to hl, a times
ld de,wcd6d
push de
- ld bc,11
+ ld bc,NAME_LENGTH
call CopyData
pop de
pop bc
@@ -2238,7 +2238,7 @@
call CopyData ; load city name
pop hl
ld de, wGymLeaderName
- ld bc, $b
+ ld bc, NAME_LENGTH
jp CopyData ; load gym leader name
; reads specific information from trainer header (pointed to at W_TRAINERHEADERPTR)
@@ -3264,7 +3264,7 @@
jr nz,.otherEntries
;1 = MON_NAMES
call GetMonName
- ld hl,11
+ ld hl,NAME_LENGTH
add hl,de
ld e,l
ld d,h
@@ -3825,12 +3825,12 @@
ld [MBC1RomBank], a
ret
-; skips a text entries, each of size 11 (like trainer name, OT name, rival name, ...)
-; hl: base pointer, will be incremented by $b * a
+; skips a text entries, each of size NAME_LENGTH (like trainer name, OT name, rival name, ...)
+; hl: base pointer, will be incremented by NAME_LENGTH * a
SkipFixedLengthTextEntries:: ; 3a7d (0:3a7d)
and a
ret z
- ld bc, 11
+ ld bc, NAME_LENGTH
.skipLoop
add hl, bc
dec a
--- a/main.asm
+++ b/main.asm
@@ -1967,7 +1967,7 @@
.asm_7ba6
ld d, h
ld e, l
- ld bc, 11
+ ld bc, NAME_LENGTH
add hl, bc
ld bc, wPartyMonNicks
ld a, [wRemoveMonFromBox]
@@ -2007,12 +2007,12 @@
jr z, .asm_7bfa
ld hl, wBoxMonNicks
.asm_7bfa
- ld bc, 11
+ ld bc, NAME_LENGTH
ld a, [wWhichPokemon]
call AddNTimes
ld d, h
ld e, l
- ld bc, 11
+ ld bc, NAME_LENGTH
add hl, bc
ld bc, wPokedexOwned
ld a, [wRemoveMonFromBox]
@@ -3587,7 +3587,7 @@
ld d, h
ld e, l
ld hl, wPlayerName
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld a, [wMonDataLocation]
and a
@@ -3858,7 +3858,7 @@
ld hl, wEnemyMonOT
ld a, [wWhichPokemon]
call SkipFixedLengthTextEntries
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData ; write new mon's OT name (from an enemy mon)
ld hl, wPartyMonNicks
ld a, [wPartyCount]
@@ -3869,7 +3869,7 @@
ld hl, wEnemyMonNicks
ld a, [wWhichPokemon]
call SkipFixedLengthTextEntries
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData ; write new mon's nickname (from an enemy mon)
ld a, [wcf91]
ld [wd11e], a
@@ -4000,7 +4000,7 @@
ld a, [wWhichPokemon]
call SkipFixedLengthTextEntries
.asm_f5ec
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
ld a, [wMoveMonType]
cp PARTY_TO_DAYCARE
@@ -4030,7 +4030,7 @@
ld a, [wWhichPokemon]
call SkipFixedLengthTextEntries
.asm_f62a
- ld bc, 11
+ ld bc, NAME_LENGTH
call CopyData
pop hl
ld a, [wMoveMonType]
--- a/scripts/namerater.asm
+++ b/scripts/namerater.asm
@@ -10,11 +10,11 @@
NameRaterScript_1da20: ; 1da20 (7:5a20)
ld hl, wPartyMonOT
- ld bc, 11
+ ld bc, NAME_LENGTH
ld a, [wWhichPokemon]
call AddNTimes
ld de, wPlayerName
- ld c, 11
+ ld c, NAME_LENGTH
call .asm_1da47
jr c, .asm_1da52
ld hl, wPartyMon1OTID
--- a/sram.asm
+++ b/sram.asm
@@ -12,7 +12,7 @@
SECTION "Save Data", SRAM, BANK[1]
ds $598
-sPlayerName:: ds 11 ; a598
+sPlayerName:: ds NAME_LENGTH ; a598
sMainData:: ds wMainDataEnd - wMainDataStart ; a5a3
sSpriteData:: ds wSpriteDataEnd - wSpriteDataStart ; ad2c
sPartyData:: ds wPartyDataEnd - wPartyDataStart ; af2c
--- a/wram.asm
+++ b/wram.asm
@@ -1302,7 +1302,7 @@
ds 17
wGymLeaderName:: ; cf70
- ds 11
+ ds NAME_LENGTH
wItemList:: ; cf7b
ds 16
@@ -1441,7 +1441,7 @@
wBattleMonSpecies2:: ; cfd9
ds 1
-wEnemyMonNick:: ds 11 ; cfda
+wEnemyMonNick:: ds NAME_LENGTH ; cfda
wEnemyMon:: ; cfe5
; The wEnemyMon struct reaches past 0xcfff,
@@ -1479,7 +1479,7 @@
wEnemyMonCatchRate:: ds 1
wEnemyMonBaseExp:: ds 1
-wBattleMonNick:: ds 11 ; d009
+wBattleMonNick:: ds NAME_LENGTH ; d009
wBattleMon:: battle_struct wBattleMon ; d014
@@ -2164,7 +2164,7 @@
ds 1
wPlayerName:: ; d158
- ds 11
+ ds NAME_LENGTH
wPartyDataStart::
@@ -2181,8 +2181,8 @@
wPartyMon5:: party_struct wPartyMon5 ; d21b
wPartyMon6:: party_struct wPartyMon6 ; d247
-wPartyMonOT:: ds 11 * PARTY_LENGTH ; d273
-wPartyMonNicks:: ds 11 * PARTY_LENGTH ; d2b5
+wPartyMonOT:: ds NAME_LENGTH * PARTY_LENGTH ; d273
+wPartyMonNicks:: ds NAME_LENGTH * PARTY_LENGTH ; d2b5
wPartyDataEnd::
@@ -2209,7 +2209,7 @@
ds 3 ; BCD
W_RIVALNAME:: ; d34a
- ds 11
+ ds NAME_LENGTH
W_OPTIONS:: ; d355
; bit 7 = battle animation
@@ -2962,8 +2962,8 @@
wEnemyMon5:: party_struct wEnemyMon5
wEnemyMon6:: party_struct wEnemyMon6
-wEnemyMonOT:: ds 11 * PARTY_LENGTH ; d9ac
-wEnemyMonNicks:: ds 11 * PARTY_LENGTH ; d9ee
+wEnemyMonOT:: ds NAME_LENGTH * PARTY_LENGTH ; d9ac
+wEnemyMonNicks:: ds NAME_LENGTH * PARTY_LENGTH ; d9ee
W_TRAINERHEADERPTR:: ; da30
@@ -3006,8 +3006,8 @@
; 1 if pokemon is in the daycare
ds 1
-W_DAYCAREMONNAME:: ds 11 ; da49
-W_DAYCAREMONOT:: ds 11 ; da54
+W_DAYCAREMONNAME:: ds NAME_LENGTH ; da49
+W_DAYCAREMONOT:: ds NAME_LENGTH ; da54
wDayCareMon:: box_struct wDayCareMon ; da5f
@@ -3023,8 +3023,8 @@
wBoxMon1:: box_struct wBoxMon1 ; da96
wBoxMon2:: ds box_struct_length * (MONS_PER_BOX + -1) ; dab7
-wBoxMonOT:: ds 11 * MONS_PER_BOX ; dd2a
-wBoxMonNicks:: ds 11 * MONS_PER_BOX ; de06
+wBoxMonOT:: ds NAME_LENGTH * MONS_PER_BOX ; dd2a
+wBoxMonNicks:: ds NAME_LENGTH * MONS_PER_BOX ; de06
wBoxMonNicksEnd:: ; dee2
wBoxDataEnd::