aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNarishma-gb <194818981+Narishma-gb@users.noreply.github.com>2025-11-18 21:17:31 +0100
committerGitHub <noreply@github.com>2025-11-18 15:17:31 -0500
commitf3326786259f4e53c06b7565369add7605bea8ba (patch)
tree1e09025ed19a6403fa74c408aa195662178cc0ca
parentAdd `_vc` patch targets to `.PHONY` (diff)
downloadpokeyellow-f3326786259f4e53c06b7565369add7605bea8ba.tar.gz
pokeyellow-f3326786259f4e53c06b7565369add7605bea8ba.tar.xz
pokeyellow-f3326786259f4e53c06b7565369add7605bea8ba.zip
Use more hardware and graphics constants (#532)
- Use `OBJ_SIZE` and `TILE_SIZE` from hardware.inc. - `SPRITESTATEDATA1_LENGTH`, `NUM_SPRITESTATEDATA_STRUCTS` and `TILE_1BPP_SIZE` are used in some places. - Highlight an oversight in `OakSpeech` where several direct MBC bank switches are requested. - Remove redundant comments in home/overworld.asm. - Add unreferenced `FillBgMap` function to avoid a byte of dead code. - Some constants added in wram.asm. - Correctly separate the commented code in `SaveMainData`.
-rw-r--r--engine/battle/animations.asm18
-rw-r--r--engine/battle/battle_transitions.asm6
-rw-r--r--engine/battle/core.asm12
-rw-r--r--engine/battle/draw_hud_pokeball_gfx.asm2
-rw-r--r--engine/battle/effects.asm2
-rw-r--r--engine/events/diploma.asm2
-rw-r--r--engine/gfx/load_pokedex_tiles.asm2
-rw-r--r--engine/gfx/mon_icons.asm10
-rw-r--r--engine/gfx/palettes.asm2
-rw-r--r--engine/gfx/sprite_oam.asm8
-rw-r--r--engine/items/town_map.asm10
-rw-r--r--engine/link/cable_club.asm2
-rw-r--r--engine/menus/display_text_id_init.asm7
-rw-r--r--engine/menus/naming_screen.asm2
-rw-r--r--engine/menus/save.asm4
-rw-r--r--engine/menus/start_sub_menus.asm10
-rw-r--r--engine/movie/credits.asm4
-rw-r--r--engine/movie/intro.asm4
-rw-r--r--engine/movie/oak_speech/oak_speech.asm11
-rw-r--r--engine/movie/splash.asm8
-rw-r--r--engine/movie/title.asm5
-rw-r--r--engine/movie/trade.asm4
-rw-r--r--engine/overworld/cut.asm6
-rw-r--r--engine/overworld/dust_smoke.asm4
-rw-r--r--engine/overworld/ledges.asm2
-rw-r--r--engine/overworld/player_animations.asm6
-rw-r--r--home/clear_sprites.asm8
-rw-r--r--home/load_font.asm6
-rw-r--r--home/overworld.asm38
-rw-r--r--home/pics.asm10
-rw-r--r--home/reset_player_sprite.asm3
-rw-r--r--home/text_script.asm4
-rw-r--r--home/vcopy.asm29
-rw-r--r--ram/wram.asm6
-rw-r--r--scripts/VermilionDock.asm2
35 files changed, 138 insertions, 121 deletions
diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm
index 40b2047b..711ebda4 100644
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -928,7 +928,7 @@ BallMoveDistances2:
DoGrowlSpecialEffects:
ld hl, wShadowOAM
ld de, wShadowOAMSprite04
- ld bc, $10
+ ld bc, OBJ_SIZE * 4
call CopyData ; copy the musical note graphic
ld a, [wSubAnimCounter]
dec a
@@ -1308,7 +1308,7 @@ AdjustOAMBlockXPos:
ld h, d
AdjustOAMBlockXPos2:
- ld de, 4
+ ld de, OBJ_SIZE
.loop
ld a, [wCoordAdjustmentAmount]
ld b, a
@@ -1318,7 +1318,7 @@ AdjustOAMBlockXPos2:
jr c, .skipPuttingEntryOffScreen
; put off-screen if X >= 168
dec hl
- ld a, 160
+ ld a, SCREEN_HEIGHT_PX + OAM_Y_OFS
ld [hli], a
.skipPuttingEntryOffScreen
ld [hl], a
@@ -1332,7 +1332,7 @@ AdjustOAMBlockYPos:
ld h, d
AdjustOAMBlockYPos2:
- ld de, 4
+ ld de, OBJ_SIZE
.loop
ld a, [wCoordAdjustmentAmount]
ld b, a
@@ -1670,7 +1670,7 @@ _AnimationShootBallsUpward:
dec a
ld [wNumShootingBalls], a
.next
- ld de, 4
+ ld de, OBJ_SIZE
add hl, de ; next OAM entry
dec b
jr nz, .innerLoop
@@ -1723,10 +1723,10 @@ AnimationMinimizeMon:
ld hl, wTempPic
push hl
xor a
- ld bc, 7 * 7 * $10
+ ld bc, (7 * 7) tiles
call FillMemory
pop hl
- ld de, 7 * 3 * $10 + 4 * $10 + 4
+ ld de, (7 * 3 + 4) tiles + TILE_SIZE / 4
add hl, de
ld de, MinimizedMonSprite
ld c, MinimizedMonSpriteEnd - MinimizedMonSprite
@@ -1971,7 +1971,7 @@ AnimationSubstitute:
jp AnimationShowMonPic
CopyMonsterSpriteData:
- ld bc, 1 tiles
+ ld bc, TILE_SIZE
ld a, BANK(MonsterSprite)
jp FarCopyData2
@@ -2379,7 +2379,7 @@ FallingObjects_UpdateOAMEntry:
inc a
cp 112
jr c, .next
- ld a, 160 ; if Y >= 112, put it off-screen
+ ld a, SCREEN_HEIGHT_PX + OAM_Y_OFS ; if Y >= 112, put it off-screen
.next
ld [hli], a ; Y
ld a, [wFallingObjectMovementByte]
diff --git a/engine/battle/battle_transitions.asm b/engine/battle/battle_transitions.asm
index fe731c5d..3670cddc 100644
--- a/engine/battle/battle_transitions.asm
+++ b/engine/battle/battle_transitions.asm
@@ -14,7 +14,7 @@ BattleTransition:
ldh a, [hSpriteIndex] ; enemy trainer sprite index (0 if wild battle)
ld c, a
ld b, 0
- ld de, $10
+ ld de, SPRITESTATEDATA1_LENGTH
.loop1
ld a, [hl]
cp $ff
@@ -35,13 +35,13 @@ BattleTransition:
jr z, .skip2 ; skip clearing the block if the enemy trainer is using it
push hl
push bc
- ld bc, $10
+ ld bc, OBJ_SIZE * 4
xor a
call FillMemory
pop bc
pop hl
.skip2
- ld de, $10
+ ld de, OBJ_SIZE * 4
add hl, de
dec c
jr nz, .loop2
diff --git a/engine/battle/core.asm b/engine/battle/core.asm
index 87abf2e8..0916176c 100644
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -106,8 +106,8 @@ SlidePlayerAndEnemySilhouettesOnScreen:
SlidePlayerHeadLeft:
push bc
ld hl, wShadowOAMSprite00XCoord
- ld c, $15 ; number of OAM entries
- ld de, $4 ; size of OAM entry
+ ld c, 7 * 3 ; number of OAM entries
+ ld de, OBJ_SIZE
.loop
dec [hl] ; decrement X
dec [hl] ; decrement X
@@ -6655,11 +6655,11 @@ LoadHudTilePatterns:
.lcdEnabled
ld de, BattleHudTiles1
ld hl, vChars2 tile $6d
- lb bc, BANK(BattleHudTiles1), (BattleHudTiles1End - BattleHudTiles1) / $8
+ lb bc, BANK(BattleHudTiles1), (BattleHudTiles1End - BattleHudTiles1) / TILE_1BPP_SIZE
call CopyVideoDataDouble
ld de, BattleHudTiles2
ld hl, vChars2 tile $73
- lb bc, BANK(BattleHudTiles2), (BattleHudTiles3End - BattleHudTiles2) / $8
+ lb bc, BANK(BattleHudTiles2), (BattleHudTiles3End - BattleHudTiles2) / TILE_1BPP_SIZE
jp CopyVideoDataDouble
PrintEmptyString:
@@ -7040,14 +7040,14 @@ LoadMonBackPic:
ld b, 7
ld c, 8
call ClearScreenArea
- ld hl, wMonHBackSprite - wMonHeader
+ ld hl, wMonHBackSprite - wMonHeader
call UncompressMonSprite
predef ScaleSpriteByTwo
ld de, vBackPic
call InterlaceMergeSpriteBuffers ; combine the two buffers to a single 2bpp sprite
ld hl, vSprites
ld de, vBackPic
- ld c, (2 * SPRITEBUFFERSIZE) / 16 ; count of 16-byte chunks to be copied
+ ld c, (2 * SPRITEBUFFERSIZE) / TILE_SIZE ; count of 16-byte chunks to be copied
ldh a, [hLoadedROMBank]
ld b, a
jp CopyVideoData
diff --git a/engine/battle/draw_hud_pokeball_gfx.asm b/engine/battle/draw_hud_pokeball_gfx.asm
index 34bff58d..983e7cdf 100644
--- a/engine/battle/draw_hud_pokeball_gfx.asm
+++ b/engine/battle/draw_hud_pokeball_gfx.asm
@@ -13,7 +13,7 @@ DrawEnemyPokeballs:
LoadPartyPokeballGfx:
ld de, PokeballTileGraphics
ld hl, vSprites tile $31
- lb bc, BANK(PokeballTileGraphics), (PokeballTileGraphicsEnd - PokeballTileGraphics) / $10
+ lb bc, BANK(PokeballTileGraphics), (PokeballTileGraphicsEnd - PokeballTileGraphics) / TILE_SIZE
jp CopyVideoData
SetupOwnPartyPokeballs:
diff --git a/engine/battle/effects.asm b/engine/battle/effects.asm
index 413c34d9..e107853c 100644
--- a/engine/battle/effects.asm
+++ b/engine/battle/effects.asm
@@ -686,7 +686,7 @@ UpdateLoweredStatDone:
.ApplyBadgeBoostsAndStatusPenalties
ldh a, [hWhoseTurn]
and a
- call nz, ApplyBadgeStatBoosts ; whenever the player uses a stat-down move, badge boosts get reapplied again to every stat,
+ call nz, ApplyBadgeStatBoosts ; whenever the opponent uses a stat-down move, badge boosts get reapplied again to every stat,
; even to those not affected by the stat-down move (will be boosted further)
ld hl, MonsStatsFellText
call PrintText
diff --git a/engine/events/diploma.asm b/engine/events/diploma.asm
index b4ccbb07..3d181210 100644
--- a/engine/events/diploma.asm
+++ b/engine/events/diploma.asm
@@ -11,7 +11,7 @@ DisplayDiploma::
call DisableLCD
ld hl, CircleTile
ld de, vChars2 tile CIRCLE_TILE_ID
- ld bc, $10
+ ld bc, TILE_SIZE
ld a, BANK(CircleTile)
call FarCopyData2
hlcoord 0, 0
diff --git a/engine/gfx/load_pokedex_tiles.asm b/engine/gfx/load_pokedex_tiles.asm
index a3f69171..b0857137 100644
--- a/engine/gfx/load_pokedex_tiles.asm
+++ b/engine/gfx/load_pokedex_tiles.asm
@@ -3,7 +3,7 @@ LoadPokedexTilePatterns:
call LoadHpBarAndStatusTilePatterns
ld de, PokedexTileGraphics
ld hl, vChars2 tile $60
- lb bc, BANK(PokedexTileGraphics), (PokedexTileGraphicsEnd - PokedexTileGraphics) / $10
+ lb bc, BANK(PokedexTileGraphics), (PokedexTileGraphicsEnd - PokedexTileGraphics) / TILE_SIZE
call CopyVideoData
ld de, PokeballTileGraphics
ld hl, vChars2 tile $72
diff --git a/engine/gfx/mon_icons.asm b/engine/gfx/mon_icons.asm
index 49e789a5..63da2345 100644
--- a/engine/gfx/mon_icons.asm
+++ b/engine/gfx/mon_icons.asm
@@ -44,7 +44,7 @@ GetAnimationSpeed:
push bc
ld hl, wMonPartySpritesSavedOAM
ld de, wShadowOAM
- ld bc, $60
+ ld bc, OBJ_SIZE * 4 * PARTY_LENGTH
call CopyData
pop bc
xor a
@@ -52,7 +52,7 @@ GetAnimationSpeed:
.animateSprite
push bc
ld hl, wShadowOAMSprite00TileID
- ld bc, $10
+ ld bc, OBJ_SIZE * 4
ld a, [wCurrentMenuItem]
call AddNTimes
ld c, ICONOFFSET
@@ -68,8 +68,8 @@ GetAnimationSpeed:
ld c, $1 ; amount to increase the y coord by
; otherwise, load a second sprite frame
.editTileIDS
- ld b, $4
- ld de, $4
+ ld b, 4
+ ld de, OBJ_SIZE
.loop
ld a, [hl]
add c
@@ -254,7 +254,7 @@ WriteMonPartySpriteOAM:
.makeCopy
ld hl, wShadowOAM
ld de, wMonPartySpritesSavedOAM
- ld bc, $60
+ ld bc, OBJ_SIZE * 4 * PARTY_LENGTH
jp CopyData
GetPartyMonSpriteID:
diff --git a/engine/gfx/palettes.asm b/engine/gfx/palettes.asm
index 0497f74a..f4ae5c39 100644
--- a/engine/gfx/palettes.asm
+++ b/engine/gfx/palettes.asm
@@ -611,7 +611,7 @@ CopySGBBorderTiles:
ld b, 128
.tileLoop
; Copy bit planes 1 and 2 of the tile data.
- ld c, 16
+ ld c, TILE_SIZE
.copyLoop
ld a, [hli]
ld [de], a
diff --git a/engine/gfx/sprite_oam.asm b/engine/gfx/sprite_oam.asm
index 737443a6..649ab01e 100644
--- a/engine/gfx/sprite_oam.asm
+++ b/engine/gfx/sprite_oam.asm
@@ -148,16 +148,16 @@ PrepareOAMData::
ldh a, [hOAMBufferOffset]
ld l, a
ld h, HIGH(wShadowOAM)
- ld de, $4
- ld b, $a0
+ ld de, OBJ_SIZE
+ ld b, SCREEN_HEIGHT_PX + OAM_Y_OFS
ld a, [wMovementFlags]
bit BIT_LEDGE_OR_FISHING, a
- ld a, $a0
+ ld a, LOW(wShadowOAMEnd)
jr z, .clear
; Don't clear the last 4 entries because they are used for the shadow in the
; jumping down ledge animation and the rod in the fishing animation.
- ld a, $90
+ ld a, LOW(wShadowOAMSprite36)
.clear
cp l
diff --git a/engine/items/town_map.asm b/engine/items/town_map.asm
index 6758adea..573ba581 100644
--- a/engine/items/town_map.asm
+++ b/engine/items/town_map.asm
@@ -24,7 +24,7 @@ DisplayTownMap:
call CopyData
ld hl, vSprites tile BIRD_BASE_TILE
ld de, TownMapCursor
- lb bc, BANK(TownMapCursor), (TownMapCursorEnd - TownMapCursor) / $8
+ lb bc, BANK(TownMapCursor), (TownMapCursorEnd - TownMapCursor) / TILE_1BPP_SIZE
call CopyVideoDataDouble
xor a
ld [wWhichTownMapLocation], a
@@ -149,7 +149,7 @@ LoadTownMap_Fly::
call CopyVideoData
ld de, TownMapUpArrow
ld hl, vChars1 tile $6d
- lb bc, BANK(TownMapUpArrow), (TownMapUpArrowEnd - TownMapUpArrow) / $8
+ lb bc, BANK(TownMapUpArrow), (TownMapUpArrowEnd - TownMapUpArrow) / TILE_1BPP_SIZE
call CopyVideoDataDouble
call BuildFlyLocationsList
ld hl, wUpdateSpritesEnabled
@@ -609,11 +609,11 @@ TownMapSpriteBlinkingAnimation::
xor a
jr .done
.hideSprites
- ld hl, wShadowOAM
+ ld hl, wShadowOAMSprite00YCoord
ld b, OAM_COUNT - 4
- ld de, $4
+ ld de, OBJ_SIZE
.hideSpritesLoop
- ld [hl], $a0
+ ld [hl], SCREEN_HEIGHT_PX + OAM_Y_OFS
add hl, de
dec b
jr nz, .hideSpritesLoop
diff --git a/engine/link/cable_club.asm b/engine/link/cable_club.asm
index c94b2693..ea39b938 100644
--- a/engine/link/cable_club.asm
+++ b/engine/link/cable_club.asm
@@ -977,5 +977,5 @@ CableClub_DrawHorizontalLine:
LoadTrainerInfoTextBoxTiles:
ld de, TrainerInfoTextBoxTileGraphics
ld hl, vChars2 tile $76
- lb bc, BANK(TrainerInfoTextBoxTileGraphics), (TrainerInfoTextBoxTileGraphicsEnd - TrainerInfoTextBoxTileGraphics) / $10
+ lb bc, BANK(TrainerInfoTextBoxTileGraphics), (TrainerInfoTextBoxTileGraphicsEnd - TrainerInfoTextBoxTileGraphics) / TILE_SIZE
jp CopyVideoData
diff --git a/engine/menus/display_text_id_init.asm b/engine/menus/display_text_id_init.asm
index f8bd6512..7ffdf7c3 100644
--- a/engine/menus/display_text_id_init.asm
+++ b/engine/menus/display_text_id_init.asm
@@ -43,8 +43,8 @@ DisplayTextIDInit::
; this is done because when you talk to an NPC, they turn to look your way
; the original direction they were facing must be restored after the dialogue is over
ld hl, wSprite01StateData1FacingDirection
- ld c, $0f
- ld de, $10
+ ld c, NUM_SPRITESTATEDATA_STRUCTS - 1
+ ld de, SPRITESTATEDATA1_LENGTH
.spriteFacingDirectionCopyLoop
ld a, [hl] ; x#SPRITESTATEDATA1_FACINGDIRECTION
inc h
@@ -56,7 +56,8 @@ DisplayTextIDInit::
; loop to force all the sprites in the middle of animation to stand still
; (so that they don't like they're frozen mid-step during the dialogue)
ld hl, wSpritePlayerStateData1ImageIndex
- ld de, $10
+ ld de, SPRITESTATEDATA1_LENGTH
+ ASSERT NUM_SPRITESTATEDATA_STRUCTS == SPRITESTATEDATA1_LENGTH
ld c, e
.spriteStandStillLoop
ld a, [hl]
diff --git a/engine/menus/naming_screen.asm b/engine/menus/naming_screen.asm
index fda482e3..9c0cd0a8 100644
--- a/engine/menus/naming_screen.asm
+++ b/engine/menus/naming_screen.asm
@@ -327,7 +327,7 @@ LoadEDTile:
ld de, ED_Tile
ld hl, vFont tile $70
; BUG: BANK("Home") should be BANK(ED_Tile), although it coincidentally works as-is
- lb bc, BANK("Home"), (ED_TileEnd - ED_Tile) / $8
+ lb bc, BANK("Home"), (ED_TileEnd - ED_Tile) / TILE_1BPP_SIZE
jp CopyVideoDataDouble
ED_Tile:
diff --git a/engine/menus/save.asm b/engine/menus/save.asm
index 9dfdd949..3fab0d01 100644
--- a/engine/menus/save.asm
+++ b/engine/menus/save.asm
@@ -225,15 +225,15 @@ SaveMainData:
ld de, sSpriteData
ld bc, wSpriteDataEnd - wSpriteDataStart
call CopyData
- ld hl, wBoxDataStart
; this part is redundant, SaveCurrentBoxData is always called next
+ ld hl, wBoxDataStart
ld de, sCurBoxData
ld bc, wBoxDataEnd - wBoxDataStart
call CopyData
+
ldh a, [hTileAnimations]
ld [sTileAnimations], a
-
ld hl, sGameData
ld bc, sGameDataEnd - sGameData
call CalcCheckSum
diff --git a/engine/menus/start_sub_menus.asm b/engine/menus/start_sub_menus.asm
index 8ba05b3f..c27e58a9 100644
--- a/engine/menus/start_sub_menus.asm
+++ b/engine/menus/start_sub_menus.asm
@@ -511,7 +511,7 @@ DrawTrainerInfo:
ld de, 13 tiles
add hl, de ; hl = colon tile pattern
ld de, vChars1 tile $56
- ld bc, 1 tiles
+ ld bc, TILE_SIZE
ld a, BANK(TextBoxGraphics)
push bc
call FarCopyData2
@@ -677,13 +677,13 @@ SwitchPartyMon_ClearGfx:
dec c
jr nz, .clearMonBGLoop
pop af
- ld hl, wShadowOAM
- ld bc, $10
+ ld hl, wShadowOAMSprite00YCoord
+ ld bc, OBJ_SIZE * 4
call AddNTimes
- ld de, $4
+ ld de, OBJ_SIZE
ld c, e
.clearMonOAMLoop
- ld [hl], $a0
+ ld [hl], SCREEN_HEIGHT_PX + OAM_Y_OFS
add hl, de
dec c
jr nz, .clearMonOAMLoop
diff --git a/engine/movie/credits.asm b/engine/movie/credits.asm
index 1a68a7b5..b1ca7c91 100644
--- a/engine/movie/credits.asm
+++ b/engine/movie/credits.asm
@@ -11,7 +11,7 @@ HallOfFamePC:
ld bc, ($20 tiles) / 2
call ZeroMemory
ld hl, vChars2 tile $7e
- ld bc, 1 tiles
+ ld bc, TILE_SIZE
ld a, $ff ; solid black
call FillMemory
hlcoord 0, 0
@@ -246,7 +246,7 @@ Credits:
pop de
ld de, TheEndGfx
ld hl, vChars2 tile $60
- lb bc, BANK(TheEndGfx), (TheEndGfxEnd - TheEndGfx) / $10
+ lb bc, BANK(TheEndGfx), (TheEndGfxEnd - TheEndGfx) / TILE_SIZE
call CopyVideoData
hlcoord 4, 8
ld de, TheEndTextString
diff --git a/engine/movie/intro.asm b/engine/movie/intro.asm
index 00316018..2fa442f9 100644
--- a/engine/movie/intro.asm
+++ b/engine/movie/intro.asm
@@ -439,12 +439,12 @@ IntroNidorinoAnimation7:
GameFreakIntro:
INCBIN "gfx/splash/gamefreak_presents.2bpp"
INCBIN "gfx/splash/gamefreak_logo.2bpp"
- ds 16, $00 ; blank tile
+ ds TILE_SIZE, $00 ; blank tile
GameFreakIntroEnd:
FightIntroBackMon:
INCBIN "gfx/intro/gengar.2bpp"
- ds 16, $00 ; blank tile
+ ds TILE_SIZE, $00 ; blank tile
FightIntroBackMonEnd:
IF DEF(_RED)
diff --git a/engine/movie/oak_speech/oak_speech.asm b/engine/movie/oak_speech/oak_speech.asm
index 02826b98..a5f13def 100644
--- a/engine/movie/oak_speech/oak_speech.asm
+++ b/engine/movie/oak_speech/oak_speech.asm
@@ -117,6 +117,9 @@ OakSpeech:
ld a, SFX_SHRINK
call PlaySound
pop af
+; bug: switching ROM Bank should not happen outside of Home Bank
+; This code does nothing, as PlaySound does all necessary Bank switch
+; It looks like a leftover from an early development stage
ldh [hLoadedROMBank], a
ld [rROMB], a
ld c, 4
@@ -145,6 +148,7 @@ OakSpeech:
ld [wNewSoundID], a
call PlaySound
pop af
+; bug: switching ROM Bank should not happen outside of Home Bank
ldh [hLoadedROMBank], a
ld [rROMB], a
ld c, 20
@@ -160,21 +164,26 @@ OakSpeech:
call DelayFrames
call GBFadeOutToWhite
jp ClearScreen
+
OakSpeechText1:
text_far _OakSpeechText1
text_end
+
OakSpeechText2:
text_far _OakSpeechText2A
; BUG: The cry played does not match the sprite displayed.
sound_cry_nidorina
text_far _OakSpeechText2B
text_end
+
IntroducePlayerText:
text_far _IntroducePlayerText
text_end
+
IntroduceRivalText:
text_far _IntroduceRivalText
text_end
+
OakSpeechText3:
text_far _OakSpeechText3
text_end
@@ -226,7 +235,7 @@ IntroDisplayPicCenteredOrUpperRight:
call UncompressSpriteFromDE
ld hl, sSpriteBuffer1
ld de, sSpriteBuffer0
- ld bc, $310
+ ld bc, 2 * SPRITEBUFFERSIZE
call CopyData
ld de, vFrontPic
call InterlaceMergeSpriteBuffers
diff --git a/engine/movie/splash.asm b/engine/movie/splash.asm
index da3fec0d..7f06c68b 100644
--- a/engine/movie/splash.asm
+++ b/engine/movie/splash.asm
@@ -13,7 +13,7 @@ LoadShootingStarGraphics:
call CopyVideoData
ld de, FallingStar
ld hl, vChars1 tile $22
- lb bc, BANK(FallingStar), (FallingStarEnd - FallingStar) / $10
+ lb bc, BANK(FallingStar), (FallingStarEnd - FallingStar) / TILE_SIZE
call CopyVideoData
ld hl, GameFreakLogoOAMData
ld de, wShadowOAMSprite24
@@ -60,11 +60,11 @@ AnimateShootingStar:
jr nz, .bigStarLoop
; Clear big star OAM.
- ld hl, wShadowOAM
+ ld hl, wShadowOAMSprite00YCoord
ld c, 4
- ld de, 4
+ ld de, OBJ_SIZE
.clearOAMLoop
- ld [hl], 160
+ ld [hl], SCREEN_HEIGHT_PX + OAM_Y_OFS
add hl, de
dec c
jr nz, .clearOAMLoop
diff --git a/engine/movie/title.asm b/engine/movie/title.asm
index 698dd5e0..c9ea4b47 100644
--- a/engine/movie/title.asm
+++ b/engine/movie/title.asm
@@ -104,7 +104,7 @@ DisplayTitleScreen:
; place tiles for title screen copyright
hlcoord 2, 17
ld de, .tileScreenCopyrightTiles
- ld b, $10
+ ld b, .tileScreenCopyrightTilesEnd - .tileScreenCopyrightTiles
.tileScreenCopyrightTilesLoop
ld a, [de]
ld [hli], a
@@ -116,6 +116,7 @@ DisplayTitleScreen:
.tileScreenCopyrightTiles
db $41,$42,$43,$42,$44,$42,$45,$46,$47,$48,$49,$4A,$4B,$4C,$4D,$4E ; ©'95.'96.'98 GAME FREAK inc.
+.tileScreenCopyrightTilesEnd
.next
call SaveScreenTilesToBuffer2
@@ -380,7 +381,7 @@ LoadCopyrightAndTextBoxTiles:
LoadCopyrightTiles:
ld de, NintendoCopyrightLogoGraphics
ld hl, vChars2 tile $60
- lb bc, BANK(NintendoCopyrightLogoGraphics), (GameFreakLogoGraphicsEnd - NintendoCopyrightLogoGraphics) / $10
+ lb bc, BANK(NintendoCopyrightLogoGraphics), (GameFreakLogoGraphicsEnd - NintendoCopyrightLogoGraphics) / TILE_SIZE
call CopyVideoData
hlcoord 2, 7
ld de, CopyrightTextString
diff --git a/engine/movie/trade.asm b/engine/movie/trade.asm
index bf77f21e..292f47cd 100644
--- a/engine/movie/trade.asm
+++ b/engine/movie/trade.asm
@@ -316,7 +316,7 @@ Trade_AnimateBallEnteringLinkCable:
ld [wLinkCableAnimBulgeToggle], a
add $7e
ld hl, wShadowOAMSprite00TileID
- ld de, 4
+ ld de, OBJ_SIZE
ld c, e
.cycleLinkCableBulgeTile
ld [hl], a
@@ -602,7 +602,7 @@ Trade_AnimCircledMon:
xor $3c ; make link cable flash
ldh [rBGP], a
ld hl, wShadowOAMSprite00TileID
- ld de, $4
+ ld de, OBJ_SIZE
ld c, $14
.loop
ld a, [hl]
diff --git a/engine/overworld/cut.asm b/engine/overworld/cut.asm
index 93902b51..368941d5 100644
--- a/engine/overworld/cut.asm
+++ b/engine/overworld/cut.asm
@@ -100,13 +100,13 @@ InitCutAnimOAM:
call LoadCutGrassAnimationTilePattern
call WriteCutOrBoulderDustAnimationOAMBlock
ld hl, wShadowOAMSprite36Attributes
- ld de, 4
- ld a, $30
+ ld de, OBJ_SIZE
+ ld a, OAM_XFLIP | OAM_PAL1
ld c, e
.loop
ld [hl], a
add hl, de
- xor $60
+ xor OAM_YFLIP | OAM_XFLIP
dec c
jr nz, .loop
ret
diff --git a/engine/overworld/dust_smoke.asm b/engine/overworld/dust_smoke.asm
index 96dd364a..85b89cdc 100644
--- a/engine/overworld/dust_smoke.asm
+++ b/engine/overworld/dust_smoke.asm
@@ -70,7 +70,7 @@ LoadSmokeTileFourTimes::
push hl
call LoadSmokeTile
pop hl
- ld bc, 1 tiles
+ ld bc, TILE_SIZE
add hl, bc
pop bc
dec c
@@ -79,7 +79,7 @@ LoadSmokeTileFourTimes::
LoadSmokeTile:
ld de, SSAnneSmokePuffTile
- lb bc, BANK(SSAnneSmokePuffTile), (SSAnneSmokePuffTileEnd - SSAnneSmokePuffTile) / $10
+ lb bc, BANK(SSAnneSmokePuffTile), (SSAnneSmokePuffTileEnd - SSAnneSmokePuffTile) / TILE_SIZE
jp CopyVideoData
SSAnneSmokePuffTile:
diff --git a/engine/overworld/ledges.asm b/engine/overworld/ledges.asm
index db8b9e97..69403042 100644
--- a/engine/overworld/ledges.asm
+++ b/engine/overworld/ledges.asm
@@ -59,7 +59,7 @@ INCLUDE "data/tilesets/ledge_tiles.asm"
LoadHoppingShadowOAM:
ld hl, vChars1 tile $7f
ld de, LedgeHoppingShadow
- lb bc, BANK(LedgeHoppingShadow), (LedgeHoppingShadowEnd - LedgeHoppingShadow) / $8
+ lb bc, BANK(LedgeHoppingShadow), (LedgeHoppingShadowEnd - LedgeHoppingShadow) / TILE_1BPP_SIZE
call CopyVideoDataDouble
ld a, $9
lb bc, $54, $48 ; b, c = y, x coordinates of shadow
diff --git a/engine/overworld/player_animations.asm b/engine/overworld/player_animations.asm
index c163b27e..4ed1f49f 100644
--- a/engine/overworld/player_animations.asm
+++ b/engine/overworld/player_animations.asm
@@ -209,13 +209,13 @@ LeaveMapThroughHoleAnim:
ld [wShadowOAMSprite02TileID], a
ld a, [wShadowOAMSprite01TileID]
ld [wShadowOAMSprite03TileID], a
- ld a, $a0
+ ld a, SCREEN_HEIGHT_PX + OAM_Y_OFS
ld [wShadowOAMSprite00YCoord], a
ld [wShadowOAMSprite01YCoord], a
ld c, 2
call DelayFrames
; hide upper half of player's sprite
- ld a, $a0
+ ld a, SCREEN_HEIGHT_PX + OAM_Y_OFS
ld [wShadowOAMSprite02YCoord], a
ld [wShadowOAMSprite03YCoord], a
call GBFadeOutToWhite
@@ -423,7 +423,7 @@ FishingAnim:
ld a, [wSpritePlayerStateData1ImageIndex] ; (image index is locked to standing images)
cp SPRITE_FACING_UP
jr nz, .skipHidingFishingRod
- ld a, $a0
+ ld a, SCREEN_HEIGHT_PX + OAM_Y_OFS
ld [wShadowOAMSprite39YCoord], a
.skipHidingFishingRod
diff --git a/home/clear_sprites.asm b/home/clear_sprites.asm
index 6d1066fa..c18b1ff3 100644
--- a/home/clear_sprites.asm
+++ b/home/clear_sprites.asm
@@ -9,10 +9,10 @@ ClearSprites::
ret
HideSprites::
- ld a, 160
- ld hl, wShadowOAM
- ld de, 4
- ld b, 40
+ ld a, SCREEN_HEIGHT_PX + OAM_Y_OFS
+ ld hl, wShadowOAMSprite00YCoord
+ ld de, OBJ_SIZE
+ ld b, OAM_COUNT
.loop
ld [hl], a
add hl, de
diff --git a/home/load_font.asm b/home/load_font.asm
index e886f76e..47ad60f1 100644
--- a/home/load_font.asm
+++ b/home/load_font.asm
@@ -11,7 +11,7 @@ LoadFontTilePatterns::
.on
ld de, FontGraphics
ld hl, vFont
- lb bc, BANK(FontGraphics), (FontGraphicsEnd - FontGraphics) / $8
+ lb bc, BANK(FontGraphics), (FontGraphicsEnd - FontGraphics) / TILE_1BPP_SIZE
jp CopyVideoDataDouble ; if LCD is on, transfer during V-blank
LoadTextBoxTilePatterns::
@@ -27,7 +27,7 @@ LoadTextBoxTilePatterns::
.on
ld de, TextBoxGraphics
ld hl, vChars2 tile $60
- lb bc, BANK(TextBoxGraphics), (TextBoxGraphicsEnd - TextBoxGraphics) / $10
+ lb bc, BANK(TextBoxGraphics), (TextBoxGraphicsEnd - TextBoxGraphics) / TILE_SIZE
jp CopyVideoData ; if LCD is on, transfer during V-blank
LoadHpBarAndStatusTilePatterns::
@@ -43,5 +43,5 @@ LoadHpBarAndStatusTilePatterns::
.on
ld de, HpBarAndStatusGraphics
ld hl, vChars2 tile $62
- lb bc, BANK(HpBarAndStatusGraphics), (HpBarAndStatusGraphicsEnd - HpBarAndStatusGraphics) / $10
+ lb bc, BANK(HpBarAndStatusGraphics), (HpBarAndStatusGraphicsEnd - HpBarAndStatusGraphics) / TILE_SIZE
jp CopyVideoData ; if LCD is on, transfer during V-blank
diff --git a/home/overworld.asm b/home/overworld.asm
index 5af527c0..f837815b 100644
--- a/home/overworld.asm
+++ b/home/overworld.asm
@@ -119,7 +119,7 @@ OverworldLoopLessDelay::
ld [wDestinationMap], a
call PrepareForSpecialWarp
ld a, [wCurMap]
- call SwitchToMapRomBank ; switch to the ROM bank of the current map
+ call SwitchToMapRomBank
ld hl, wCurMapTileset
set BIT_NO_PREVIOUS_MAP, [hl]
.changeMap
@@ -506,7 +506,7 @@ WarpFound2::
; for maps that can have the 0xFF destination map, which means to return to the outside map
; not all these maps are necessarily indoors, though
.indoorMaps
- ldh a, [hWarpDestinationMap] ; destination map
+ ldh a, [hWarpDestinationMap]
cp LAST_MAP
jr z, .goBackOutside
; if not going back to the previous map
@@ -567,7 +567,7 @@ CheckMapConnections::
srl c
jr z, .savePointer1
.pointerAdjustmentLoop1
- ld a, [wWestConnectedMapWidth] ; width of connected map
+ ld a, [wWestConnectedMapWidth]
add MAP_BORDER * 2
ld e, a
ld d, 0
@@ -584,7 +584,7 @@ CheckMapConnections::
.checkEastMap
ld b, a
- ld a, [wCurrentMapWidth2] ; map width
+ ld a, [wCurrentMapWidth2]
cp b
jr nz, .checkNorthMap
ld a, [wEastConnectedMap]
@@ -1171,7 +1171,7 @@ IsSpriteInFrontOfPlayer2::
ld a, PLAYER_DIR_LEFT
.doneCheckingDirection
ld [wPlayerDirection], a
- ld a, [wNumSprites] ; number of sprites
+ ld a, [wNumSprites]
and a
ret z
; if there are sprites
@@ -1198,7 +1198,7 @@ IsSpriteInFrontOfPlayer2::
.nextSprite
pop hl
ld a, l
- add $10
+ add SPRITESTATEDATA1_LENGTH
ld l, a
inc e
dec d
@@ -1258,8 +1258,8 @@ CollisionCheckOnLand::
; function that checks if the tile in front of the player is passable
; clears carry if it is, sets carry if not
CheckTilePassable::
- predef GetTileAndCoordsInFrontOfPlayer ; get tile in front of player
- ld a, [wTileInFrontOfPlayer] ; tile in front of player
+ predef GetTileAndCoordsInFrontOfPlayer
+ ld a, [wTileInFrontOfPlayer]
ld c, a
ld hl, wTilesetCollisionPtr ; pointer to list of passable tiles
ld a, [hli]
@@ -1282,7 +1282,7 @@ CheckTilePassable::
; sets carry if there is a collision and unsets carry if not
CheckForJumpingAndTilePairCollisions::
push hl
- predef GetTileAndCoordsInFrontOfPlayer ; get the tile in front of the player
+ predef GetTileAndCoordsInFrontOfPlayer
push de
push bc
farcall HandleLedges ; check if the player is trying to jump a ledge
@@ -1315,7 +1315,7 @@ CheckForTilePairCollisions::
inc hl
jr .tilePairCollisionLoop
.tilesetMatches
- ld a, [wTilePlayerStandingOn] ; tile the player is on
+ ld a, [wTilePlayerStandingOn]
ld b, a
ld a, [hl]
cp b
@@ -1350,9 +1350,9 @@ INCLUDE "data/tilesets/pair_collision_tile_ids.asm"
LoadCurrentMapView::
ldh a, [hLoadedROMBank]
push af
- ld a, [wTilesetBank] ; tile data ROM bank
+ ld a, [wTilesetBank]
ldh [hLoadedROMBank], a
- ld [rROMB], a ; switch to ROM bank that contains tile data
+ ld [rROMB], a
ld a, [wCurrentTileBlockMapViewPointer] ; address of upper left corner of current map view
ld e, a
ld a, [wCurrentTileBlockMapViewPointer + 1]
@@ -1434,7 +1434,7 @@ LoadCurrentMapView::
jr nz, .rowLoop2
pop af
ldh [hLoadedROMBank], a
- ld [rROMB], a ; restore previous ROM bank
+ ld [rROMB], a
ret
AdvancePlayerSprite::
@@ -1442,7 +1442,7 @@ AdvancePlayerSprite::
ld b, a
ld a, [wSpritePlayerStateData1XStepVector]
ld c, a
- ld hl, wWalkCounter ; walking animation counter
+ ld hl, wWalkCounter
dec [hl]
jr nz, .afterUpdateMapCoords
; if it's the end of the animation, update the player's map coordinates
@@ -1453,7 +1453,7 @@ AdvancePlayerSprite::
add c
ld [wXCoord], a
.afterUpdateMapCoords
- ld a, [wWalkCounter] ; walking animation counter
+ ld a, [wWalkCounter]
cp $07
jp nz, .scrollBackgroundAndSprites
; if this is the first iteration of the animation
@@ -1612,7 +1612,7 @@ AdvancePlayerSprite::
; shift all the sprites in the direction opposite of the player's motion
; so that the player appears to move relative to them
ld hl, wSprite01StateData1YPixels
- ld a, [wNumSprites] ; number of sprites
+ ld a, [wNumSprites]
and a ; are there any sprites?
jr z, .done
ld e, a
@@ -2151,8 +2151,8 @@ LoadMapHeader::
jr nz, .zeroSpriteDataLoop
; disable SPRITESTATEDATA1_IMAGEINDEX (set to $ff) for sprites 01-15
ld hl, wSprite01StateData1ImageIndex
- ld de, $10
- ld c, $0f
+ ld de, SPRITESTATEDATA1_LENGTH
+ ld c, NUM_SPRITESTATEDATA_STRUCTS - 1
.disableSpriteEntriesLoop
ld [hl], $ff
add hl, de
@@ -2296,7 +2296,7 @@ LoadMapData::
ldh a, [hLoadedROMBank]
push af
call DisableLCD
- ld a, $98
+ ld a, HIGH(vBGMap0)
ld [wMapViewVRAMPointer + 1], a
xor a
ld [wMapViewVRAMPointer], a
diff --git a/home/pics.asm b/home/pics.asm
index ea34e3d5..475e834d 100644
--- a/home/pics.asm
+++ b/home/pics.asm
@@ -127,8 +127,8 @@ AlignSpriteDataCentered::
dec c
jr nz, .columnInnerLoop
pop hl
- ld bc, 7*8 ; 7 tiles
- add hl, bc ; advance one full column
+ ld bc, 7 * TILE_1BPP_SIZE
+ add hl, bc ; advance one full column
pop af
dec a
jr nz, .columnLoop
@@ -156,7 +156,7 @@ InterlaceMergeSpriteBuffers::
ld hl, sSpriteBuffer2 + (SPRITEBUFFERSIZE - 1) ; destination: end of buffer 2
ld de, sSpriteBuffer1 + (SPRITEBUFFERSIZE - 1) ; source 2: end of buffer 1
ld bc, sSpriteBuffer0 + (SPRITEBUFFERSIZE - 1) ; source 1: end of buffer 0
- ld a, SPRITEBUFFERSIZE/2 ; $c4
+ ld a, SPRITEBUFFERSIZE / 2
ldh [hSpriteInterlaceCounter], a
.interlaceLoop
ld a, [de]
@@ -178,7 +178,7 @@ InterlaceMergeSpriteBuffers::
ld a, [wSpriteFlipped]
and a
jr z, .notFlipped
- ld bc, 2*SPRITEBUFFERSIZE
+ ld bc, 2 * SPRITEBUFFERSIZE
ld hl, sSpriteBuffer1
.swapLoop
swap [hl] ; if flipped swap nybbles in all bytes
@@ -190,7 +190,7 @@ InterlaceMergeSpriteBuffers::
.notFlipped
pop hl
ld de, sSpriteBuffer1
- ld c, (2*SPRITEBUFFERSIZE)/16 ; $31, number of 16 byte chunks to be copied
+ ld c, (2 * SPRITEBUFFERSIZE) / TILE_SIZE ; $31, number of 16 byte chunks to be copied
ldh a, [hLoadedROMBank]
ld b, a
jp CopyVideoData
diff --git a/home/reset_player_sprite.asm b/home/reset_player_sprite.asm
index 72df31a1..6ce4a6fa 100644
--- a/home/reset_player_sprite.asm
+++ b/home/reset_player_sprite.asm
@@ -15,6 +15,7 @@ ResetPlayerSpriteData::
; overwrites sprite data with zeroes
ResetPlayerSpriteData_ClearSpriteData::
- ld bc, $10
+ ld bc, SPRITESTATEDATA1_LENGTH
+ ASSERT SPRITESTATEDATA2_LENGTH == SPRITESTATEDATA1_LENGTH
xor a
jp FillMemory
diff --git a/home/text_script.asm b/home/text_script.asm
index 389f2499..36f6338b 100644
--- a/home/text_script.asm
+++ b/home/text_script.asm
@@ -113,8 +113,8 @@ CloseTextDisplay::
ldh [hAutoBGTransferEnabled], a ; disable continuous WRAM to VRAM transfer each V-blank
; loop to make sprites face the directions they originally faced before the dialogue
ld hl, wSprite01StateData2OrigFacingDirection
- ld c, $0f
- ld de, $10
+ ld c, NUM_SPRITESTATEDATA_STRUCTS - 1
+ ld de, SPRITESTATEDATA1_LENGTH
.restoreSpriteFacingDirectionLoop
ld a, [hl] ; x#SPRITESTATEDATA2_ORIGFACINGDIRECTION
dec h
diff --git a/home/vcopy.asm b/home/vcopy.asm
index 8ae9484a..cf4c3e6c 100644
--- a/home/vcopy.asm
+++ b/home/vcopy.asm
@@ -20,9 +20,14 @@ GetRowColAddressBgMap::
; INPUT: h - high byte of background tile map address in VRAM
ClearBgMap::
ld a, ' '
- jr .next
+ jr FillBgMapCommon
+
+; fills a VRAM background map with tile index in register l
+; INPUT: h - high byte of background tile map address in VRAM
+FillBgMap:: ; unreferenced
ld a, l
-.next
+
+FillBgMapCommon:
ld de, TILEMAP_AREA
ld l, e
.loop
@@ -69,8 +74,8 @@ RedrawRowOrColumn::
.noCarry
; the following 4 lines wrap us from bottom to top if necessary
ld a, d
- and $3
- or $98
+ and HIGH(TILEMAP_AREA - 1)
+ or HIGH(vBGMap0)
ld d, a
dec c
jr nz, .loop1
@@ -86,7 +91,7 @@ RedrawRowOrColumn::
push de
call .DrawHalf ; draw upper half
pop de
- ld a, TILEMAP_WIDTH ; width of VRAM background map
+ ld a, TILEMAP_WIDTH
add e
ld e, a
; fall through and draw lower half
@@ -102,10 +107,10 @@ RedrawRowOrColumn::
ld a, e
inc a
; the following 6 lines wrap us from the right edge to the left edge if necessary
- and $1f
+ and %11111
ld b, a
ld a, e
- and $e0
+ and %11100000
or b
ld e, a
dec c
@@ -134,7 +139,7 @@ AutoBgMapTransfer::
dec a
jr z, .transferMiddleThird
.transferBottomThird
- hlcoord 0, 12
+ hlcoord 0, 2 * SCREEN_HEIGHT / 3
ld sp, hl
ldh a, [hAutoBGTransferDest + 1]
ld h, a
@@ -154,7 +159,7 @@ AutoBgMapTransfer::
ld a, TRANSFERMIDDLE
jr .doTransfer
.transferMiddleThird
- hlcoord 0, 6
+ hlcoord 0, SCREEN_HEIGHT / 3
ld sp, hl
ldh a, [hAutoBGTransferDest + 1]
ld h, a
@@ -165,7 +170,7 @@ AutoBgMapTransfer::
ld a, TRANSFERBOTTOM
.doTransfer
ldh [hAutoBGTransferPortion], a ; store next portion
- ld b, 6
+ ld b, SCREEN_HEIGHT / 3
TransferBgRows::
; unrolled loop and using pop for speed
@@ -390,7 +395,7 @@ UpdateMovingBgTiles::
; water
ld hl, vTileset tile $14
- ld c, $10
+ ld c, TILE_SIZE
ld a, [wMovingBGTilesCounter2]
inc a
@@ -435,7 +440,7 @@ UpdateMovingBgTiles::
ld hl, FlowerTile3
.copy
ld de, vTileset tile $03
- ld c, $10
+ ld c, TILE_SIZE
.loop
ld a, [hli]
ld [de], a
diff --git a/ram/wram.asm b/ram/wram.asm
index 0121b065..ff7d10ae 100644
--- a/ram/wram.asm
+++ b/ram/wram.asm
@@ -363,7 +363,7 @@ wFilteredBagItems:: ds 4
NEXTU
; Saved copy of OAM for the first frame of the animation to make it easy to
; flip back from the second frame.
-wMonPartySpritesSavedOAM:: ds $60
+wMonPartySpritesSavedOAM:: ds OBJ_SIZE * 4 * PARTY_LENGTH
NEXTU
wTrainerCardBlkPacket:: ds $40
@@ -401,7 +401,7 @@ wAnimPalette:: db
NEXTU
ds 60
; temporary buffer when swapping party mon data
-wSwitchPartyMonTempBuffer:: ds 44 ; party_struct size
+wSwitchPartyMonTempBuffer:: ds PARTYMON_STRUCT_LENGTH
NEXTU
ds 120
@@ -1806,7 +1806,7 @@ wWestConnectionHeader:: map_connection_struct wWest
wEastConnectionHeader:: map_connection_struct wEast
; sprite set for the current map (11 sprite picture ID's)
-wSpriteSet:: ds 11
+wSpriteSet:: ds SPRITE_SET_LENGTH
; sprite set ID for the current map
wSpriteSetID:: db
diff --git a/scripts/VermilionDock.asm b/scripts/VermilionDock.asm
index 237b4175..beb53112 100644
--- a/scripts/VermilionDock.asm
+++ b/scripts/VermilionDock.asm
@@ -128,7 +128,7 @@ VermilionDock_AnimSmokePuffDriftRight:
ld a, [wSSAnneSmokeDriftAmount]
swap a
ld c, a
- ld de, 4
+ ld de, OBJ_SIZE
.drift_loop
inc [hl]
inc [hl]