shithub: pokered

Download patch

ref: 8a6d46f3d9ba4fb6939eb9ea9949f47aa8608d4a
parent: f8a9c37a0019eb085c22c6e3ae53b16ff0cd4f6a
author: dannye <corrnondacqb@yahoo.com>
date: Sun Aug 9 19:56:20 EDT 2015

Replace some hardcoded data sizes

--- a/data/evos_moves.asm
+++ b/data/evos_moves.asm
@@ -1262,6 +1262,7 @@
 	db EV_ITEM,THUNDER_STONE ,1,JOLTEON
 	db EV_ITEM,WATER_STONE ,1,VAPOREON
 	db 0
+Mon133_EvosEnd:
 ;Learnset
 	db 27,QUICK_ATTACK
 	db 31,TAIL_WHIP
--- a/data/moves.asm
+++ b/data/moves.asm
@@ -11,6 +11,7 @@
 endm
 
 	move POUND,        NO_ADDITIONAL_EFFECT,        40, NORMAL,   100, 35
+MoveEnd:
 	move KARATE_CHOP,  NO_ADDITIONAL_EFFECT,        50, NORMAL,   100, 25
 	move DOUBLESLAP,   TWO_TO_FIVE_ATTACKS_EFFECT,  15, NORMAL,    85, 10
 	move COMET_PUNCH,  TWO_TO_FIVE_ATTACKS_EFFECT,  18, NORMAL,    85, 15
--- a/engine/HoF_room_pc.asm
+++ b/engine/HoF_room_pc.asm
@@ -246,7 +246,7 @@
 	pop de
 	ld de, TheEndGfx
 	ld hl, vChars2 + $600
-	lb bc, BANK(TheEndGfx), $0a
+	lb bc, BANK(TheEndGfx), (TheEndGfxEnd - TheEndGfx) / $10
 	call CopyVideoData
 	coord hl, 4, 8
 	ld de, TheEndTextString
@@ -267,3 +267,4 @@
 
 TheEndGfx: ; 7473e (1d:473e) (7473f on blue)
 	INCBIN "gfx/theend.interleave.2bpp"
+TheEndGfxEnd:
--- a/engine/battle/battle_transitions.asm
+++ b/engine/battle/battle_transitions.asm
@@ -184,11 +184,12 @@
 LoadBattleTransitionTile: ; 70a4d (1c:4a4d)
 	ld hl, vChars1 + $7f0
 	ld de, BattleTransitionTile
-	lb bc, BANK(BattleTransitionTile), $01
+	lb bc, BANK(BattleTransitionTile), (BattleTransitionTileEnd - BattleTransitionTile) / $10
 	jp CopyVideoData
 
 BattleTransitionTile: ; 70a59 (1c:4a59)
 	INCBIN "gfx/battle_transition.2bpp"
+BattleTransitionTileEnd:
 
 BattleTransition_BlackScreen: ; 70a69 (1c:4a69)
 	ld a, $ff
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -2394,7 +2394,7 @@
 	jp DisplayBattleMenu
 .partyMonDeselected
 	coord hl, 11, 11
-	ld bc, $81
+	ld bc, 6 * SCREEN_WIDTH + 9
 	ld a, " "
 	call FillMemory
 	xor a ; NORMAL_PARTY_MENU
@@ -5194,7 +5194,7 @@
 	ld [wd11e],a
 	dec a
 	ld hl,Moves
-	ld bc,$0006
+	ld bc,MoveEnd - Moves
 	call AddNTimes
 	ld a,BANK(Moves)
 	call FarCopyData ; copy the move's stats
@@ -6170,7 +6170,7 @@
 	ld [wd0b5], a
 	dec a
 	ld hl, Moves
-	ld bc, $6
+	ld bc, MoveEnd - Moves
 	call AddNTimes
 	ld a, BANK(Moves)
 	call FarCopyData
@@ -6707,22 +6707,22 @@
 .lcdDisabled
 	ld hl, BattleHudTiles1
 	ld de, vChars2 + $6d0
-	ld bc, $18
+	ld bc, BattleHudTiles1End - BattleHudTiles1
 	ld a, BANK(BattleHudTiles1)
 	call FarCopyDataDouble
 	ld hl, BattleHudTiles2
 	ld de, vChars2 + $730
-	ld bc, $30
+	ld bc, BattleHudTiles3End - BattleHudTiles2
 	ld a, BANK(BattleHudTiles2)
 	jp FarCopyDataDouble
 .lcdEnabled
 	ld de, BattleHudTiles1
 	ld hl, vChars2 + $6d0
-	lb bc, BANK(BattleHudTiles1), $03
+	lb bc, BANK(BattleHudTiles1), (BattleHudTiles1End - BattleHudTiles1) / $8
 	call CopyVideoDataDouble
 	ld de, BattleHudTiles2
 	ld hl, vChars2 + $730
-	lb bc, BANK(BattleHudTiles2), $06
+	lb bc, BANK(BattleHudTiles2), (BattleHudTiles3End - BattleHudTiles2) / $8
 	jp CopyVideoDataDouble
 
 PrintEmptyString: ; 3ee94 (f:6e94)
--- a/engine/battle/draw_hud_pokeball_gfx.asm
+++ b/engine/battle/draw_hud_pokeball_gfx.asm
@@ -13,7 +13,7 @@
 LoadPartyPokeballGfx: ; 3a85d (e:685d)
 	ld de, PokeballTileGraphics
 	ld hl, vSprites + $310
-	lb bc, BANK(PokeballTileGraphics), $04
+	lb bc, BANK(PokeballTileGraphics), (PokeballTileGraphicsEnd - PokeballTileGraphics) / $10
 	jp CopyVideoData
 
 SetupOwnPartyPokeballs: ; 3a869 (e:6869)
@@ -189,3 +189,4 @@
 ; four tiles: pokeball, black pokeball (status ailment), crossed out pokeball (faited) and pokeball slot (no mon)
 PokeballTileGraphics:: ; 3a97e (e:697e)
 	INCBIN "gfx/pokeball.2bpp"
+PokeballTileGraphicsEnd:
--- a/engine/battle/trainer_ai.asm
+++ b/engine/battle/trainer_ai.asm
@@ -264,7 +264,7 @@
 	push bc
 	dec a
 	ld hl,Moves
-	ld bc,6
+	ld bc,MoveEnd - Moves
 	call AddNTimes
 	ld de,W_ENEMYMOVENUM
 	call CopyData
--- a/engine/cable_club.asm
+++ b/engine/cable_club.asm
@@ -598,7 +598,7 @@
 TradeCenter_DrawCancelBox:
 	coord hl, 11, 15
 	ld a, $7e
-	ld bc, 2 * 20 + 9
+	ld bc, 2 * SCREEN_WIDTH + 9
 	call FillMemory
 	coord hl, 0, 15
 	ld b, 1
@@ -614,7 +614,7 @@
 TradeCenter_PlaceSelectedEnemyMonMenuCursor:
 	ld a, [wSerialSyncAndExchangeNybbleReceiveData]
 	coord hl, 1, 9
-	ld bc, 20
+	ld bc, SCREEN_WIDTH
 	call AddNTimes
 	ld [hl], $ec ; cursor
 	ret
--- a/engine/evos_moves.asm
+++ b/engine/evos_moves.asm
@@ -479,7 +479,7 @@
 	push hl
 	dec a
 	ld hl, Moves
-	ld bc, 6
+	ld bc, MoveEnd - Moves
 	call AddNTimes
 	ld de, wBuffer
 	ld a, BANK(Moves)
--- a/engine/gamefreak.asm
+++ b/engine/gamefreak.asm
@@ -13,15 +13,15 @@
 	call CopyVideoData
 	ld de, FallingStar
 	ld hl, vChars1 + $220
-	lb bc, BANK(FallingStar), $01
+	lb bc, BANK(FallingStar), (FallingStarEnd - FallingStar) / $10
 	call CopyVideoData
 	ld hl, GameFreakLogoOAMData
 	ld de, wOAMBuffer + $60
-	ld bc, $40
+	ld bc, GameFreakLogoOAMDataEnd - GameFreakLogoOAMData
 	call CopyData
 	ld hl, GameFreakShootingStarOAMData
 	ld de, wOAMBuffer
-	ld bc, $10
+	ld bc, GameFreakShootingStarOAMDataEnd - GameFreakShootingStarOAMData
 	jp CopyData
 
 AnimateShootingStar: ; 70044 (1c:4044)
@@ -88,7 +88,7 @@
 .initSmallStarsOAMLoop
 	push af
 	ld hl, SmallStarsOAM
-	ld bc, 4
+	ld bc, SmallStarsOAMEnd - SmallStarsOAM
 	call CopyData
 	pop af
 	dec a
@@ -147,6 +147,7 @@
 
 SmallStarsOAM: ; 700ee (1c:40ee)
 	db $00,$00,$A2,$90
+SmallStarsOAMEnd:
 
 SmallStarsWaveCoordsPointerTable: ; 700f2 (1c:40f2)
 	dw SmallStarsWave1Coords
@@ -229,6 +230,7 @@
 	db $60,$68,$83,$00
 	db $60,$70,$81,$00
 	db $60,$78,$86,$00
+GameFreakLogoOAMDataEnd:
 
 GameFreakShootingStarOAMData: ; 70180 (1c:4180)
 	db $00,$A0,$A0,$10
@@ -235,6 +237,8 @@
 	db $00,$A8,$A0,$30
 	db $08,$A0,$A1,$10
 	db $08,$A8,$A1,$30
+GameFreakShootingStarOAMDataEnd:
 
 FallingStar: ; 70190 (1c:4190)
 	INCBIN "gfx/falling_star.2bpp"
+FallingStarEnd:
--- a/engine/intro.asm
+++ b/engine/intro.asm
@@ -278,22 +278,22 @@
 LoadIntroGraphics: ; 41852 (10:5852)
 	ld hl, FightIntroBackMon
 	ld de, vChars2
-	ld bc, $600
+	ld bc, FightIntroBackMonEnd - FightIntroBackMon
 	ld a, BANK(FightIntroBackMon)
 	call FarCopyData2
 	ld hl, GameFreakIntro
 	ld de, vChars2 + $600
-	ld bc, $140
+	ld bc, GameFreakIntroEnd - GameFreakIntro
 	ld a, BANK(GameFreakIntro)
 	call FarCopyData2
 	ld hl, GameFreakIntro
 	ld de, vChars1
-	ld bc, $140
+	ld bc, GameFreakIntroEnd - GameFreakIntro
 	ld a, BANK(GameFreakIntro)
 	call FarCopyData2
 	ld hl, FightIntroFrontMon
 	ld de, vChars0
-	ld bc, $6c0
+	ld bc, FightIntroFrontMonEnd - FightIntroFrontMon
 	ld a, BANK(FightIntroFrontMon)
 	jp FarCopyData2
 
@@ -430,9 +430,11 @@
 	INCBIN "gfx/gamefreak_intro.2bpp"
 	INCBIN "gfx/gamefreak_logo.2bpp"
 	ds $10 ; blank tile
+GameFreakIntroEnd:
 
 FightIntroBackMon: ; 41a99 (10:5a99)
 	INCBIN "gfx/intro_fight.2bpp"
+FightIntroBackMonEnd:
 
 FightIntroFrontMon: ; 42099 (10:6099)
 
@@ -440,11 +442,13 @@
 	INCBIN "gfx/red/intro_nido_1.6x6.2bpp"
 	INCBIN "gfx/red/intro_nido_2.6x6.2bpp"
 	INCBIN "gfx/red/intro_nido_3.6x6.2bpp"
-	ds $10 ; blank tile
 ENDC
 IF DEF(_BLUE)
 	INCBIN "gfx/blue/intro_purin_1.6x6.2bpp"
 	INCBIN "gfx/blue/intro_purin_2.6x6.2bpp"
 	INCBIN "gfx/blue/intro_purin_3.6x6.2bpp"
-	ds $10 ; blank tile
 ENDC
+
+FightIntroFrontMonEnd:
+
+	ds $10 ; blank tile
--- a/engine/items/items.asm
+++ b/engine/items/items.asm
@@ -912,7 +912,7 @@
 	ld [wHPBarNewHP+1],a
 	coord hl, 4, 1
 	ld a,[wWhichPokemon]
-	ld bc,2 * 20
+	ld bc,2 * SCREEN_WIDTH
 	call AddNTimes ; calculate coordinates of HP bar of pokemon that used Softboiled
 	ld a,SFX_HEAL_HP
 	call PlaySoundWaitForCurrent
@@ -1937,7 +1937,7 @@
 	cp b ; is the pokemon whose PP was restored active in battle?
 	jr nz,.skipUpdatingInBattleData
 	ld hl,wPartyMon1PP
-	ld bc,44
+	ld bc,wPartyMon2 - wPartyMon1
 	call AddNTimes
 	ld de,wBattleMonPP
 	ld bc,4
@@ -2289,7 +2289,7 @@
 ; [wCurrentMenuItem] = index of move (when using a PP Up)
 RestoreBonusPP: ; e606 (3:6606)
 	ld hl,wPartyMon1Moves
-	ld bc,44
+	ld bc,wPartyMon2 - wPartyMon1
 	ld a,[wWhichPokemon]
 	call AddNTimes
 	push hl
@@ -2407,7 +2407,7 @@
 	dec a
 	push hl
 	ld hl,Moves
-	ld bc,6
+	ld bc,MoveEnd - Moves
 	call AddNTimes
 	ld de,wcd6d
 	ld a,BANK(Moves)
--- a/engine/learn_move.asm
+++ b/engine/learn_move.asm
@@ -44,7 +44,7 @@
 	push de
 	dec a
 	ld hl, Moves
-	ld bc, $6
+	ld bc, MoveEnd - Moves
 	call AddNTimes
 	ld de, wBuffer
 	ld a, BANK(Moves)
--- a/engine/load_pokedex_tiles.asm
+++ b/engine/load_pokedex_tiles.asm
@@ -3,7 +3,7 @@
 	call LoadHpBarAndStatusTilePatterns
 	ld de,PokedexTileGraphics
 	ld hl,vChars2 + $600
-	lb bc, BANK(PokedexTileGraphics), $12
+	lb bc, BANK(PokedexTileGraphics), (PokedexTileGraphicsEnd - PokedexTileGraphics) / $10
 	call CopyVideoData
 	ld de,PokeballTileGraphics
 	ld hl,vChars2 + $720
--- a/engine/menu/naming_screen.asm
+++ b/engine/menu/naming_screen.asm
@@ -326,11 +326,14 @@
 LoadEDTile: ; 675b (1:675b)
 	ld de, ED_Tile
 	ld hl, vFont + $700
-	ld bc, $1
+	ld bc, (ED_TileEnd - ED_Tile) / $8
+	; to fix the graphical bug on poor emulators
+	;lb bc, BANK(ED_Tile), (ED_TileEnd - ED_Tile) / $8
 	jp CopyVideoDataDouble
 
 ED_Tile: ; 6767 (1:6767)
 	INCBIN "gfx/ED_tile.1bpp"
+ED_TileEnd:
 
 PrintAlphabet: ; 676f (1:676f)
 	xor a
--- a/engine/menu/party_menu.asm
+++ b/engine/menu/party_menu.asm
@@ -150,7 +150,7 @@
 	ld l,a
 	ld de,wcd6d
 	ld a,BANK(EvosMovesPointerTable)
-	ld bc,13
+	ld bc,Mon133_EvosEnd - Mon133_EvosMoves
 	call FarCopyData
 	ld hl,wcd6d
 	ld de,.notAbleToEvolveText
--- a/engine/menu/start_sub_menus.asm
+++ b/engine/menu/start_sub_menus.asm
@@ -611,7 +611,7 @@
 	jp PrintNumber
 
 TrainerInfo_FarCopyData: ; 1357f (4:757f)
-	ld a,$0b
+	ld a,BANK(TrainerInfoTextBoxTileGraphics)
 	jp FarCopyData2
 
 TrainerInfo_NameMoneyTimeText: ; 13584 (4:7584)
--- a/engine/menu/status_screen.asm
+++ b/engine/menu/status_screen.asm
@@ -99,7 +99,7 @@
 	call CopyVideoDataDouble ; ─┘
 	ld de, PTile
 	ld hl, vChars2 + $720
-	lb bc, BANK(PTile), $01
+	lb bc, BANK(PTile), (PTileEnd - PTile) / $8
 	call CopyVideoDataDouble ; P (for PP), inline
 	ld a, [hTilesetType]
 	push af
@@ -242,6 +242,7 @@
 
 PTile: ; 12adc (4:6adc) ; This is a single 1bpp "P" tile
 	INCBIN "gfx/p_tile.1bpp"
+PTileEnd:
 
 PrintStatsBox: ; 12ae4 (4:6ae4)
 	ld a, d
--- a/engine/overworld/emotion_bubbles.asm
+++ b/engine/overworld/emotion_bubbles.asm
@@ -9,7 +9,7 @@
 	inc hl
 	ld d, [hl]
 	ld hl, vChars1 + $780
-	lb bc, BANK(EmotionBubblesPointerTable), $04
+	lb bc, BANK(EmotionBubbles), $04
 	call CopyVideoData
 	ld a, [wUpdateSpritesEnabled]
 	push af
--- a/engine/overworld/healing_machine.asm
+++ b/engine/overworld/healing_machine.asm
@@ -1,7 +1,7 @@
 AnimateHealingMachine: ; 70433 (1c:4433)
 	ld de, PokeCenterFlashingMonitorAndHealBall
 	ld hl, vChars0 + $7c0
-	lb bc, BANK(PokeCenterFlashingMonitorAndHealBall), $03
+	lb bc, BANK(PokeCenterFlashingMonitorAndHealBall), $03 ; loads one too many tiles
 	call CopyVideoData
 	ld hl, wUpdateSpritesEnabled
 	ld a, [hl]
--- a/engine/overworld/ledges.asm
+++ b/engine/overworld/ledges.asm
@@ -69,7 +69,7 @@
 LoadHoppingShadowOAM: ; 1a6f0 (6:66f0)
 	ld hl, vChars1 + $7f0
 	ld de, LedgeHoppingShadow
-	lb bc, BANK(LedgeHoppingShadow), $01
+	lb bc, BANK(LedgeHoppingShadow), (LedgeHoppingShadowEnd - LedgeHoppingShadow) / $8
 	call CopyVideoDataDouble
 	ld a, $9
 	lb bc, $54, $48 ; b, c = y, x coordinates of shadow
@@ -79,6 +79,7 @@
 
 LedgeHoppingShadow: ; 1a708 (6:6708)
 	INCBIN "gfx/ledge_hopping_shadow.1bpp"
+LedgeHoppingShadowEnd:
 
 LedgeHoppingShadowOAM: ; 1a710 (6:6710)
 	db $FF,$10,$FF,$20
--- a/engine/overworld/ssanne.asm
+++ b/engine/overworld/ssanne.asm
@@ -85,8 +85,9 @@
 
 LoadSmokeTile: ; 79fd4 (1e:5fd4)
 	ld de, SSAnneSmokePuffTile
-	lb bc, BANK(SSAnneSmokePuffTile), $01
+	lb bc, BANK(SSAnneSmokePuffTile), (SSAnneSmokePuffTileEnd - SSAnneSmokePuffTile) / $10
 	jp CopyVideoData
 
 SSAnneSmokePuffTile: ; 79fdd (1e:5fdd)
 	INCBIN "gfx/ss_anne_smoke_puff.2bpp"
+SSAnneSmokePuffTileEnd:
--- a/engine/titlescreen.asm
+++ b/engine/titlescreen.asm
@@ -56,15 +56,8 @@
 	ld a, BANK(PokemonLogoGraphics)
 	call FarCopyData2          ; second chunk
 	ld hl, Version_GFX
-IF DEF(_RED)
-	ld de,vChars2 + $600
-	ld bc,$50
-ENDC
-IF DEF(_BLUE)
-	ld de,vChars2 + $600 + $10
-	ld bc,$50 - $10
-ENDC
-
+	ld de,vChars2 + $600 - (Version_GFXEnd - Version_GFX - $50)
+	ld bc, Version_GFXEnd - Version_GFX
 	ld a, BANK(Version_GFX)
 	call FarCopyDataDouble
 	call ClearBothBGMaps
@@ -317,7 +310,7 @@
 DrawPlayerCharacter: ; 44dd (1:44dd)
 	ld hl, PlayerCharacterTitleGraphics
 	ld de, vSprites
-	ld bc, $230
+	ld bc, PlayerCharacterTitleGraphicsEnd - PlayerCharacterTitleGraphics
 	ld a, BANK(PlayerCharacterTitleGraphics)
 	call FarCopyData2
 	call ClearSprites
@@ -377,7 +370,7 @@
 LoadCopyrightTiles: ; 4541 (1:4541)
 	ld de, NintendoCopyrightLogoGraphics
 	ld hl, vChars2 + $600
-	lb bc, BANK(NintendoCopyrightLogoGraphics), $1c
+	lb bc, BANK(NintendoCopyrightLogoGraphics), (GamefreakLogoGraphicsEnd - NintendoCopyrightLogoGraphics) / $10
 	call CopyVideoData
 	coord hl, 2, 7
 	ld de, CopyrightTextString
--- a/engine/town_map.asm
+++ b/engine/town_map.asm
@@ -20,7 +20,7 @@
 	call CopyData
 	ld hl, vSprites + $40
 	ld de, TownMapCursor
-	lb bc, BANK(TownMapCursor), $04
+	lb bc, BANK(TownMapCursor), (TownMapCursorEnd - TownMapCursor) / $8
 	call CopyVideoDataDouble
 	xor a
 	ld [wWhichTownMapLocation], a
@@ -107,6 +107,7 @@
 
 TownMapCursor: ; 70f40 (1c:4f40)
 	INCBIN "gfx/town_map_cursor.1bpp"
+TownMapCursorEnd:
 
 LoadTownMap_Nest: ; 70f60 (1c:4f60)
 	call LoadTownMap
@@ -144,7 +145,7 @@
 	call CopyVideoData
 	ld de, TownMapUpArrow
 	ld hl, vChars1 + $6d0
-	lb bc, BANK(TownMapUpArrow), $01
+	lb bc, BANK(TownMapUpArrow), (TownMapUpArrowEnd - TownMapUpArrow) / $8
 	call CopyVideoDataDouble
 	call BuildFlyLocationsList
 	ld hl, wUpdateSpritesEnabled
@@ -271,6 +272,7 @@
 
 TownMapUpArrow: ; 71093 (1c:5093)
 	INCBIN "gfx/up_arrow.1bpp"
+TownMapUpArrowEnd:
 
 LoadTownMap: ; 7109b (1c:509b)
 	call GBPalWhiteOutWithDelay3
@@ -283,12 +285,12 @@
 	call DisableLCD
 	ld hl, WorldMapTileGraphics
 	ld de, vChars2 + $600
-	ld bc, $100
+	ld bc, WorldMapTileGraphicsEnd - WorldMapTileGraphics
 	ld a, BANK(WorldMapTileGraphics)
 	call FarCopyData2
 	ld hl, MonNestIcon
 	ld de, vSprites + $40
-	ld bc, $8
+	ld bc, MonNestIconEnd - MonNestIcon
 	ld a, BANK(MonNestIcon)
 	call FarCopyDataDouble
 	coord hl, 0, 0
@@ -582,6 +584,7 @@
 
 MonNestIcon: ; 716be (1c:56be)
 	INCBIN "gfx/mon_nest_icon.1bpp"
+MonNestIconEnd:
 
 TownMapSpriteBlinkingAnimation: ; 716c6 (1c:56c6)
 	ld a, [wAnimCounter]
--- a/engine/trade.asm
+++ b/engine/trade.asm
@@ -149,7 +149,7 @@
 
 Trade_ClearTileMap: ; 41196 (10:5196)
 	coord hl, 0, 0
-	ld bc, 20 * 18
+	ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
 	ld a, " "
 	jp FillMemory
 
@@ -158,12 +158,12 @@
 	call DisableLCD
 	ld hl, TradingAnimationGraphics
 	ld de, vChars2 + $310
-	ld bc, $310
+	ld bc, TradingAnimationGraphicsEnd - TradingAnimationGraphics
 	ld a, BANK(TradingAnimationGraphics)
 	call FarCopyData2
 	ld hl, TradingAnimationGraphics2
 	ld de, vSprites + $7c0
-	ld bc, $40
+	ld bc, TradingAnimationGraphics2End - TradingAnimationGraphics2
 	ld a, BANK(TradingAnimationGraphics2)
 	call FarCopyData2
 	ld hl, vBGMap0
@@ -190,7 +190,7 @@
 	call GetMonName
 	ld hl, wcd6d
 	ld de, wcf4b
-	ld bc, $b
+	ld bc, 11
 	call CopyData
 	ld a, [wTradedEnemyMonSpecies]
 	ld [wd11e], a
--- a/home.asm
+++ b/home.asm
@@ -3092,13 +3092,13 @@
 .off
 	ld hl, FontGraphics
 	ld de, vFont
-	ld bc, $400
+	ld bc, FontGraphicsEnd - FontGraphics
 	ld a, BANK(FontGraphics)
 	jp FarCopyDataDouble ; if LCD is off, transfer all at once
 .on
 	ld de, FontGraphics
 	ld hl, vFont
-	lb bc, BANK(FontGraphics), $80
+	lb bc, BANK(FontGraphics), (FontGraphicsEnd - FontGraphics) / $8
 	jp CopyVideoDataDouble ; if LCD is on, transfer during V-blank
 
 LoadTextBoxTilePatterns::
@@ -3108,13 +3108,13 @@
 .off
 	ld hl, TextBoxGraphics
 	ld de, vChars2 + $600
-	ld bc, $200
+	ld bc, TextBoxGraphicsEnd - TextBoxGraphics
 	ld a, BANK(TextBoxGraphics)
 	jp FarCopyData2 ; if LCD is off, transfer all at once
 .on
 	ld de, TextBoxGraphics
 	ld hl, vChars2 + $600
-	lb bc, BANK(TextBoxGraphics), $20
+	lb bc, BANK(TextBoxGraphics), (TextBoxGraphicsEnd - TextBoxGraphics) / $10
 	jp CopyVideoData ; if LCD is on, transfer during V-blank
 
 LoadHpBarAndStatusTilePatterns::
@@ -3124,13 +3124,13 @@
 .off
 	ld hl, HpBarAndStatusGraphics
 	ld de, vChars2 + $620
-	ld bc, $1e0
+	ld bc, HpBarAndStatusGraphicsEnd - HpBarAndStatusGraphics
 	ld a, BANK(HpBarAndStatusGraphics)
 	jp FarCopyData2 ; if LCD is off, transfer all at once
 .on
 	ld de, HpBarAndStatusGraphics
 	ld hl, vChars2 + $620
-	lb bc, BANK(HpBarAndStatusGraphics), $1e
+	lb bc, BANK(HpBarAndStatusGraphics), (HpBarAndStatusGraphicsEnd - HpBarAndStatusGraphics) / $10
 	jp CopyVideoData ; if LCD is on, transfer during V-blank
 
 
--- a/main.asm
+++ b/main.asm
@@ -590,7 +590,7 @@
 LoadTrainerInfoTextBoxTiles: ; 5ae6 (1:5ae6)
 	ld de, TrainerInfoTextBoxTileGraphics
 	ld hl, vChars2 + $760
-	lb bc, BANK(TrainerInfoTextBoxTileGraphics), $09
+	lb bc, BANK(TrainerInfoTextBoxTileGraphics), (TrainerInfoTextBoxTileGraphicsEnd - TrainerInfoTextBoxTileGraphics) / $10
 	jp CopyVideoData
 
 INCLUDE "engine/menu/main_menu.asm"
@@ -2068,7 +2068,7 @@
 	ld [hli], a
 	ld [hl], a
 	ld hl, wWhichTrade
-	ld bc, $1e
+	ld bc, wStandingOnWarpPadOrHole - wWhichTrade
 	call FillMemory
 	ret
 
@@ -3296,7 +3296,7 @@
 
 InitializeMissableObjectsFlags: ; f175 (3:7175)
 	ld hl, W_MISSABLEOBJECTFLAGS
-	ld bc, $20
+	ld bc, wMissableObjectFlagsEnd - W_MISSABLEOBJECTFLAGS
 	xor a
 	call FillMemory ; clear missable objects flags
 	ld hl, MapHS00
@@ -3808,7 +3808,7 @@
 	push de
 	push bc
 	ld hl, Moves
-	ld bc, $6
+	ld bc, MoveEnd - Moves
 	call AddNTimes
 	ld de, wcd6d
 	ld a, BANK(Moves)
@@ -4173,7 +4173,7 @@
 	push bc
 
 	ld hl, Moves
-	ld bc, 6
+	ld bc, MoveEnd - Moves
 	call AddNTimes
 	ld de, wcd6d
 	ld a, BANK(Moves)
@@ -4495,7 +4495,7 @@
 	ld [hl], a
 
 	ld hl, W_GAMEPROGRESSFLAGS
-	ld bc, $c8
+	ld bc, wGameProgressFlagsEnd - W_GAMEPROGRESSFLAGS
 	call FillMemory ; clear all game progress flags
 
 	jp InitializeMissableObjectsFlags
@@ -4767,17 +4767,26 @@
 
 PokemonLogoGraphics:            INCBIN "gfx/pokemon_logo.2bpp"
 FontGraphics:                   INCBIN "gfx/font.1bpp"
+FontGraphicsEnd:
 ABTiles:                        INCBIN "gfx/AB.2bpp"
 HpBarAndStatusGraphics:         INCBIN "gfx/hp_bar_and_status.2bpp"
+HpBarAndStatusGraphicsEnd:
 BattleHudTiles1:                INCBIN "gfx/battle_hud1.1bpp"
+BattleHudTiles1End:
 BattleHudTiles2:                INCBIN "gfx/battle_hud2.1bpp"
 BattleHudTiles3:                INCBIN "gfx/battle_hud3.1bpp"
+BattleHudTiles3End:
 NintendoCopyrightLogoGraphics:  INCBIN "gfx/copyright.2bpp"
 GamefreakLogoGraphics:          INCBIN "gfx/gamefreak.2bpp"
+GamefreakLogoGraphicsEnd:
 TextBoxGraphics:                INCBIN "gfx/text_box.2bpp"
+TextBoxGraphicsEnd:
 PokedexTileGraphics:            INCBIN "gfx/pokedex.2bpp"
+PokedexTileGraphicsEnd:
 WorldMapTileGraphics:           INCBIN "gfx/town_map.2bpp"
+WorldMapTileGraphicsEnd:
 PlayerCharacterTitleGraphics:   INCBIN "gfx/player_title.2bpp"
+PlayerCharacterTitleGraphicsEnd:
 
 
 SECTION "Battle (bank 4)", ROMX, BANK[$4]
@@ -5337,6 +5346,7 @@
 INCLUDE "engine/battle/display_effectiveness.asm"
 
 TrainerInfoTextBoxTileGraphics:  INCBIN "gfx/trainer_info.2bpp"
+TrainerInfoTextBoxTileGraphicsEnd:
 BlankLeaderNames:                INCBIN "gfx/blank_leader_names.2bpp"
 CircleTile:                      INCBIN "gfx/circle_tile.2bpp"
 BadgeNumbersTileGraphics:        INCBIN "gfx/badge_numbers.2bpp"
@@ -5498,10 +5508,12 @@
 TradingAnimationGraphics:
 	INCBIN "gfx/game_boy.norepeat.2bpp"
 	INCBIN "gfx/link_cable.2bpp"
+TradingAnimationGraphicsEnd:
 
 TradingAnimationGraphics2:
 ; Pokeball traveling through the link cable.
 	INCBIN "gfx/trade2.2bpp"
+TradingAnimationGraphics2End:
 
 INCLUDE "engine/evos_moves.asm"
 INCLUDE "engine/battle/moveEffects/heal_effect.asm"
@@ -6487,6 +6499,7 @@
 IF DEF(_BLUE)
 	INCBIN "gfx/blue/blueversion.1bpp" ; 8 tiles
 ENDC
+Version_GFXEnd:
 
 Dojo_GFX:
 Gym_GFX:           INCBIN "gfx/tilesets/gym.2bpp"
--- a/scripts/celadonmartelevator.asm
+++ b/scripts/celadonmartelevator.asm
@@ -36,7 +36,7 @@
 	call LoadItemList
 	ld hl, CeldaonMartElevatorWarpMaps
 	ld de, wcc5b
-	ld bc, $000a
+	ld bc, CeldaonMartElevatorWarpMapsEnd - CeldaonMartElevatorWarpMaps
 	jp CopyData
 
 CeladonMartElavatorFloors: ; 48643 (12:4643)
@@ -53,6 +53,7 @@
 	db $02, CELADON_MART_3
 	db $02, CELADON_MART_4
 	db $02, CELADON_MART_5
+CeldaonMartElevatorWarpMapsEnd:
 
 CeladonMartElevatorScript_48654: ; 48654 (12:4654)
 	jpba ShakeElevator
--- a/scripts/namerater.asm
+++ b/scripts/namerater.asm
@@ -10,15 +10,15 @@
 
 NameRaterScript_1da20: ; 1da20 (7:5a20)
 	ld hl, wPartyMonOT
-	ld bc, $000b
+	ld bc, 11
 	ld a, [wWhichPokemon]
 	call AddNTimes
 	ld de, wPlayerName
-	ld c, $b
+	ld c, 11
 	call .asm_1da47
 	jr c, .asm_1da52
 	ld hl, wPartyMon1OTID
-	ld bc, $002c
+	ld bc, wPartyMon2 - wPartyMon1
 	ld a, [wWhichPokemon]
 	call AddNTimes
 	ld de, wPlayerID
--- a/scripts/pewterpokecenter.asm
+++ b/scripts/pewterpokecenter.asm
@@ -27,7 +27,7 @@
 	call DelayFrames
 	ld hl, JigglypuffFacingDirections
 	ld de, wJigglypuffFacingDirections
-	ld bc, 4
+	ld bc, JigglypuffFacingDirectionsEnd - JigglypuffFacingDirections
 	call CopyData
 
 	ld a, [wSpriteStateData1 + 3 * $10 + $2]
@@ -50,7 +50,7 @@
 	push hl
 	ld hl, wJigglypuffFacingDirections
 	ld de, wJigglypuffFacingDirections - 1
-	ld bc, 4
+	ld bc, JigglypuffFacingDirectionsEnd - JigglypuffFacingDirections
 	call CopyData
 	ld a, [wJigglypuffFacingDirections - 1]
 	ld [wJigglypuffFacingDirections + 3], a
@@ -79,6 +79,7 @@
 	db $30 | SPRITE_FACING_LEFT
 	db $30 | SPRITE_FACING_UP
 	db $30 | SPRITE_FACING_RIGHT
+JigglypuffFacingDirectionsEnd:
 
 PewterPokecenterText4: ; 5c60c (17:460c)
 	db $f6
--- a/scripts/rockethideoutelevator.asm
+++ b/scripts/rockethideoutelevator.asm
@@ -36,7 +36,7 @@
 	call LoadItemList
 	ld hl, RocketHideoutElevatorWarpMaps
 	ld de, wcc5b
-	ld bc, $0006
+	ld bc, RocketHideoutElevatorWarpMapsEnd - RocketHideoutElevatorWarpMaps
 	call CopyData
 	ret
 
@@ -52,6 +52,7 @@
 	db $04, ROCKET_HIDEOUT_1
 	db $04, ROCKET_HIDEOUT_2
 	db $02, ROCKET_HIDEOUT_4
+RocketHideoutElevatorWarpMapsEnd:
 
 RocketHideoutElevatorScript_4575f: ; 4575f (11:575f)
 	call Delay3
--- a/scripts/silphcoelevator.asm
+++ b/scripts/silphcoelevator.asm
@@ -36,7 +36,7 @@
 	call LoadItemList
 	ld hl, SilphCoElevatorWarpMaps
 	ld de, wcc5b
-	ld bc, $16
+	ld bc, SilphCoElevatorWarpMapsEnd - SilphCoElevatorWarpMaps
 	call CopyData
 	ret
 
@@ -60,6 +60,7 @@
 	db $02, SILPH_CO_9F
 	db $02, SILPH_CO_10F
 	db $01, SILPH_CO_11F
+SilphCoElevatorWarpMapsEnd:
 
 SilphCoElevatorScript_45827: ; 45827 (11:5827)
 	call Delay3
--- a/scripts/vermiliondock.asm
+++ b/scripts/vermiliondock.asm
@@ -53,8 +53,8 @@
 	ld b, $9c
 	call CopyScreenTileBufferToVRAM
 	coord hl, 0, 10
-	ld bc, $0078
-	ld a, $14
+	ld bc, SCREEN_WIDTH * 6
+	ld a, $14 ; water tile
 	call FillMemory
 	ld a, 1
 	ld [H_AUTOBGTRANSFERENABLED], a
@@ -180,7 +180,7 @@
 
 VermilionDock_1dc94: ; 1dc94 (7:5c94)
 	ld hl, wcc5b
-	ld bc, $00b4
+	ld bc, SCREEN_WIDTH * 9
 	ld a, $14
 	call FillMemory
 	ld hl, vBGMap0 + 10 * 32
--- a/wram.asm
+++ b/wram.asm
@@ -2397,8 +2397,11 @@
 
 W_MISSABLEOBJECTFLAGS:: ; d5a6
 ; bit array of missable objects. set = removed
-	ds 39
+	ds 32
+wMissableObjectFlagsEnd::
 
+	ds 7
+
 wd5cd:: ds 1 ; temp copy of c1x2 (sprite facing/anim)
 
 W_MISSABLEOBJECTLIST:: ; d5ce
@@ -2622,7 +2625,10 @@
 W_ROUTE18GATECURSCRIPT:: ; d669
 	ds 1
 
-	ds 134
+	ds 78
+wGameProgressFlagsEnd::
+
+	ds 56
 
 wObtainedHiddenItemsFlags::
 	ds 14