Replace magic numbers with TILE_WIDTH (#1056)

* Replace magic numbers with TILE_WIDTH

* Address more instances
This commit is contained in:
Idain 2023-07-26 20:50:16 -04:00 committed by GitHub
parent 1d64befdb7
commit 94df3c5aa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 62 additions and 62 deletions

View File

@ -20,11 +20,11 @@ ShowPlayerMonsRemaining:
ld de, wPartyCount ld de, wPartyCount
call StageBallTilesData call StageBallTilesData
; ldpixel wPlaceBallsX, 12, 12 ; ldpixel wPlaceBallsX, 12, 12
ld a, 12 * 8 ld a, 12 * TILE_WIDTH
ld hl, wPlaceBallsX ld hl, wPlaceBallsX
ld [hli], a ld [hli], a
ld [hl], a ld [hl], a
ld a, 8 ld a, TILE_WIDTH
ld [wPlaceBallsDirection], a ld [wPlaceBallsDirection], a
ld hl, wShadowOAMSprite00 ld hl, wShadowOAMSprite00
jp LoadTrainerHudOAM jp LoadTrainerHudOAM
@ -36,10 +36,10 @@ ShowOTTrainerMonsRemaining:
call StageBallTilesData call StageBallTilesData
; ldpixel wPlaceBallsX, 9, 4 ; ldpixel wPlaceBallsX, 9, 4
ld hl, wPlaceBallsX ld hl, wPlaceBallsX
ld a, 9 * 8 ld a, 9 * TILE_WIDTH
ld [hli], a ld [hli], a
ld [hl], 4 * 8 ld [hl], 4 * TILE_WIDTH
ld a, -8 ld a, -TILE_WIDTH
ld [wPlaceBallsDirection], a ld [wPlaceBallsDirection], a
ld hl, wShadowOAMSprite00 + PARTY_LENGTH * SPRITEOAMSTRUCT_LENGTH ld hl, wShadowOAMSprite00 + PARTY_LENGTH * SPRITEOAMSTRUCT_LENGTH
jp LoadTrainerHudOAM jp LoadTrainerHudOAM
@ -182,10 +182,10 @@ LinkBattle_TrainerHuds:
ld de, wPartyCount ld de, wPartyCount
call StageBallTilesData call StageBallTilesData
ld hl, wPlaceBallsX ld hl, wPlaceBallsX
ld a, 10 * 8 ld a, 10 * TILE_WIDTH
ld [hli], a ld [hli], a
ld [hl], 8 * 8 ld [hl], 8 * TILE_WIDTH
ld a, 8 ld a, TILE_WIDTH
ld [wPlaceBallsDirection], a ld [wPlaceBallsDirection], a
ld hl, wShadowOAMSprite00 ld hl, wShadowOAMSprite00
call LoadTrainerHudOAM call LoadTrainerHudOAM
@ -194,9 +194,9 @@ LinkBattle_TrainerHuds:
ld de, wOTPartyCount ld de, wOTPartyCount
call StageBallTilesData call StageBallTilesData
ld hl, wPlaceBallsX ld hl, wPlaceBallsX
ld a, 10 * 8 ld a, 10 * TILE_WIDTH
ld [hli], a ld [hli], a
ld [hl], 13 * 8 ld [hl], 13 * TILE_WIDTH
ld hl, wShadowOAMSprite00 + PARTY_LENGTH * SPRITEOAMSTRUCT_LENGTH ld hl, wShadowOAMSprite00 + PARTY_LENGTH * SPRITEOAMSTRUCT_LENGTH
jp LoadTrainerHudOAM jp LoadTrainerHudOAM

View File

@ -243,7 +243,7 @@ InitBattleAnimBuffer:
add hl, bc add hl, bc
ld a, [hli] ld a, [hli]
ld d, a ld d, a
ld a, (-10 * 8) + 4 ld a, (-10 * TILE_WIDTH) + 4
sub d sub d
ld [wBattleAnimTempXCoord], a ld [wBattleAnimTempXCoord], a
ld a, [hli] ld a, [hli]
@ -251,7 +251,7 @@ InitBattleAnimBuffer:
ld a, [wBattleAnimTempFixY] ld a, [wBattleAnimTempFixY]
cp $ff cp $ff
jr nz, .check_kinesis_softboiled_milkdrink jr nz, .check_kinesis_softboiled_milkdrink
ld a, 5 * 8 ld a, 5 * TILE_WIDTH
add d add d
jr .done jr .done
@ -270,7 +270,7 @@ InitBattleAnimBuffer:
jr nz, .no_sub jr nz, .no_sub
.do_sub .do_sub
pop af pop af
sub 1 * 8 sub 1 * TILE_WIDTH
jr .done jr .done
.no_sub .no_sub

View File

@ -348,7 +348,7 @@ FlyToAnim:
ld [hl], SPRITE_ANIM_SEQ_FLY_TO ld [hl], SPRITE_ANIM_SEQ_FLY_TO
ld hl, SPRITEANIMSTRUCT_VAR4 ld hl, SPRITEANIMSTRUCT_VAR4
add hl, bc add hl, bc
ld [hl], 11 * 8 ld [hl], 11 * TILE_WIDTH
ld a, 64 ld a, 64
ld [wFrameCounter], a ld [wFrameCounter], a
.loop .loop

View File

@ -681,7 +681,7 @@ Slots_InitReelTiles:
ld [hl], d ld [hl], d
ld hl, REEL_X_COORD ld hl, REEL_X_COORD
add hl, bc add hl, bc
ld [hl], 6 * 8 ld [hl], 6 * TILE_WIDTH
call .OAM call .OAM
ld bc, wReel2 ld bc, wReel2
@ -699,7 +699,7 @@ Slots_InitReelTiles:
ld [hl], d ld [hl], d
ld hl, REEL_X_COORD ld hl, REEL_X_COORD
add hl, bc add hl, bc
ld [hl], 10 * 8 ld [hl], 10 * TILE_WIDTH
call .OAM call .OAM
ld bc, wReel3 ld bc, wReel3
@ -717,7 +717,7 @@ Slots_InitReelTiles:
ld [hl], d ld [hl], d
ld hl, REEL_X_COORD ld hl, REEL_X_COORD
add hl, bc add hl, bc
ld [hl], 14 * 8 ld [hl], 14 * TILE_WIDTH
call .OAM call .OAM
ret ret
@ -785,7 +785,7 @@ Slots_UpdateReelPositionAndOAM:
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
ld [wCurReelXCoord], a ld [wCurReelXCoord], a
ld a, 10 * 8 ld a, 10 * TILE_WIDTH
ld [wCurReelYCoord], a ld [wCurReelYCoord], a
ld hl, REEL_POSITION ld hl, REEL_POSITION
add hl, bc add hl, bc
@ -2019,7 +2019,7 @@ Slots_AnimateGolem:
jr c, .play_sound jr c, .play_sound
dec [hl] dec [hl]
ld e, a ld e, a
ld d, 14 * 8 ld d, 14 * TILE_WIDTH
farcall BattleAnim_Sine_e farcall BattleAnim_Sine_e
ld a, e ld a, e
ld hl, SPRITEANIMSTRUCT_YOFFSET ld hl, SPRITEANIMSTRUCT_YOFFSET
@ -2046,7 +2046,7 @@ Slots_AnimateGolem:
ld a, [hl] ld a, [hl]
inc [hl] inc [hl]
inc [hl] inc [hl]
cp 9 * 8 cp 9 * TILE_WIDTH
jr nc, .restart jr nc, .restart
and $3 and $3
ret nz ret nz
@ -2090,7 +2090,7 @@ Slots_AnimateChansey:
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
inc [hl] inc [hl]
cp 13 * 8 cp 13 * TILE_WIDTH
jr z, .limit jr z, .limit
and $f and $f
ret nz ret nz

View File

@ -882,7 +882,7 @@ InitCGBPals::
ldh [rVBK], a ldh [rVBK], a
ld a, 1 << rBGPI_AUTO_INCREMENT ld a, 1 << rBGPI_AUTO_INCREMENT
ldh [rBGPI], a ldh [rBGPI], a
ld c, 4 * 8 ld c, 4 * TILE_WIDTH
.bgpals_loop .bgpals_loop
ld a, LOW(PALRGB_WHITE) ld a, LOW(PALRGB_WHITE)
ldh [rBGPD], a ldh [rBGPD], a
@ -892,7 +892,7 @@ InitCGBPals::
jr nz, .bgpals_loop jr nz, .bgpals_loop
ld a, 1 << rOBPI_AUTO_INCREMENT ld a, 1 << rOBPI_AUTO_INCREMENT
ldh [rOBPI], a ldh [rOBPI], a
ld c, 4 * 8 ld c, 4 * TILE_WIDTH
.obpals_loop .obpals_loop
ld a, LOW(PALRGB_WHITE) ld a, LOW(PALRGB_WHITE)
ldh [rOBPD], a ldh [rOBPD], a

View File

@ -88,11 +88,11 @@ Mobile_InitAnimatedMonIcon:
ld [hl], a ld [hl], a
ld hl, SPRITEANIMSTRUCT_XCOORD ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc add hl, bc
ld a, 9 * 8 ld a, 9 * TILE_WIDTH
ld [hl], a ld [hl], a
ld hl, SPRITEANIMSTRUCT_YCOORD ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc add hl, bc
ld a, 9 * 8 ld a, 9 * TILE_WIDTH
ld [hl], a ld [hl], a
ret ret
@ -105,11 +105,11 @@ Mobile_InitPartyMenuBGPal71:
ld [hl], a ld [hl], a
ld hl, SPRITEANIMSTRUCT_XCOORD ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc add hl, bc
ld a, 3 * 8 ld a, 3 * TILE_WIDTH
ld [hl], a ld [hl], a
ld hl, SPRITEANIMSTRUCT_YCOORD ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc add hl, bc
ld a, 12 * 8 ld a, 12 * TILE_WIDTH
ld [hl], a ld [hl], a
ld a, c ld a, c
ld [wc608], a ld [wc608], a
@ -234,8 +234,8 @@ MoveList_InitAnimatedMonIcon:
ld [wCurIcon], a ld [wCurIcon], a
xor a xor a
call GetIconGFX call GetIconGFX
ld d, 3 * 8 + 2 ; depixel 3, 4, 2, 4 ld d, 3 * TILE_WIDTH + 2 ; depixel 3, 4, 2, 4
ld e, 4 * 8 + 4 ld e, 4 * TILE_WIDTH + 4
ld a, SPRITE_ANIM_INDEX_PARTY_MON ld a, SPRITE_ANIM_INDEX_PARTY_MON
call _InitSpriteAnimStruct call _InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID ld hl, SPRITEANIMSTRUCT_ANIM_SEQ_ID

View File

@ -380,7 +380,7 @@ AnimSeq_SlotsChanseyEgg:
ld hl, SPRITEANIMSTRUCT_XCOORD ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
cp 15 * 8 cp 15 * TILE_WIDTH
jr c, .move_right jr c, .move_right
call DeinitializeSprite call DeinitializeSprite
ld a, $4 ld a, $4
@ -682,7 +682,7 @@ AnimSeq_FlyLeaf:
ld hl, SPRITEANIMSTRUCT_XCOORD ld hl, SPRITEANIMSTRUCT_XCOORD
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
cp -9 * 8 cp -9 * TILE_WIDTH
jr nc, .delete_leaf jr nc, .delete_leaf
inc [hl] inc [hl]
inc [hl] inc [hl]
@ -711,7 +711,7 @@ AnimSeq_FlyTo:
ld hl, SPRITEANIMSTRUCT_YCOORD ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
cp 10 * 8 + 4 cp 10 * TILE_WIDTH + 4
ret z ret z
ld hl, SPRITEANIMSTRUCT_YCOORD ld hl, SPRITEANIMSTRUCT_YCOORD

View File

@ -955,10 +955,10 @@ Intro_PlacePlayerSprite:
.sprites .sprites
db 4 db 4
; y pxl, x pxl, tile offset ; y pxl, x pxl, tile offset
db 9 * 8 + 4, 9 * 8, 0 db 9 * TILE_WIDTH + 4, 9 * TILE_WIDTH, 0
db 9 * 8 + 4, 10 * 8, 1 db 9 * TILE_WIDTH + 4, 10 * TILE_WIDTH, 1
db 10 * 8 + 4, 9 * 8, 2 db 10 * TILE_WIDTH + 4, 9 * TILE_WIDTH, 2
db 10 * 8 + 4, 10 * 8, 3 db 10 * TILE_WIDTH + 4, 10 * TILE_WIDTH, 3
const_def const_def

View File

@ -375,7 +375,7 @@ NamingScreenJoypadLoop:
depixel 10, 3 depixel 10, 3
call NamingScreen_IsTargetBox call NamingScreen_IsTargetBox
jr nz, .got_cursor_position jr nz, .got_cursor_position
ld d, 8 * 8 ld d, 8 * TILE_WIDTH
.got_cursor_position .got_cursor_position
ld a, SPRITE_ANIM_INDEX_NAMING_SCREEN_CURSOR ld a, SPRITE_ANIM_INDEX_NAMING_SCREEN_CURSOR
call InitSpriteAnimStruct call InitSpriteAnimStruct

View File

@ -880,12 +880,12 @@ MovementFunction_Shadow:
add hl, de add hl, de
ld a, [hl] ld a, [hl]
maskbits NUM_DIRECTIONS maskbits NUM_DIRECTIONS
ld d, 1 * 8 + 6 ld d, 1 * TILE_WIDTH + 6
cp DOWN cp DOWN
jr z, .ok jr z, .ok
cp UP cp UP
jr z, .ok jr z, .ok
ld d, 1 * 8 + 4 ld d, 1 * TILE_WIDTH + 4
.ok .ok
ld hl, OBJECT_SPRITE_Y_OFFSET ld hl, OBJECT_SPRITE_Y_OFFSET
add hl, bc add hl, bc
@ -909,7 +909,7 @@ MovementFunction_Emote:
ld [hl], 0 ld [hl], 0
ld hl, OBJECT_SPRITE_Y_OFFSET ld hl, OBJECT_SPRITE_Y_OFFSET
add hl, bc add hl, bc
ld [hl], -2 * 8 ld [hl], -2 * TILE_WIDTH
ld hl, OBJECT_SPRITE_X_OFFSET ld hl, OBJECT_SPRITE_X_OFFSET
add hl, bc add hl, bc
ld [hl], 0 ld [hl], 0

View File

@ -2555,10 +2555,10 @@ Pokedex_GetArea:
.PlayerOAM: .PlayerOAM:
; y pxl, x pxl, tile offset ; y pxl, x pxl, tile offset
db -1 * 8, -1 * 8, 0 ; top left db -1 * TILE_WIDTH, -1 * TILE_WIDTH, 0 ; top left
db -1 * 8, 0 * 8, 1 ; top right db -1 * TILE_WIDTH, 0 * TILE_WIDTH, 1 ; top right
db 0 * 8, -1 * 8, 2 ; bottom left db 0 * TILE_WIDTH, -1 * TILE_WIDTH, 2 ; bottom left
db 0 * 8, 0 * 8, 3 ; bottom right db 0 * TILE_WIDTH, 0 * TILE_WIDTH, 3 ; bottom right
db $80 ; terminator db $80 ; terminator
.CheckPlayerLocation: .CheckPlayerLocation:

View File

@ -779,9 +779,9 @@ EggHatch_CrackShell:
ret nc ret nc
swap a swap a
srl a srl a
add 9 * 8 + 4 add 9 * TILE_WIDTH + 4
ld d, a ld d, a
ld e, 11 * 8 ld e, 11 * TILE_WIDTH
ld a, SPRITE_ANIM_INDEX_EGG_CRACK ld a, SPRITE_ANIM_INDEX_EGG_CRACK
call InitSpriteAnimStruct call InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_TILE_ID ld hl, SPRITEANIMSTRUCT_TILE_ID
@ -838,7 +838,7 @@ Hatch_InitShellFragments:
MACRO shell_fragment MACRO shell_fragment
; y tile, y pxl, x tile, x pxl, frameset offset, ??? ; y tile, y pxl, x tile, x pxl, frameset offset, ???
db (\1 * 8) % $100 + \2, (\3 * 8) % $100 + \4, \5 - SPRITE_ANIM_FRAMESET_EGG_HATCH_1, \6 db (\1 * TILE_WIDTH) % $100 + \2, (\3 * TILE_WIDTH) % $100 + \4, \5 - SPRITE_ANIM_FRAMESET_EGG_HATCH_1, \6
ENDM ENDM
.SpriteData: .SpriteData:

View File

@ -53,7 +53,7 @@ HealPartyMon:
ret ret
ComputeHPBarPixels: ComputeHPBarPixels:
; e = bc * (6 * 8) / de ; e = bc * HP_BAR_LENGTH_PX / de
ld a, b ld a, b
or c or c
jr z, .zero jr z, .zero
@ -64,7 +64,7 @@ ComputeHPBarPixels:
ldh [hMultiplicand + 1], a ldh [hMultiplicand + 1], a
ld a, c ld a, c
ldh [hMultiplicand + 2], a ldh [hMultiplicand + 2], a
ld a, 6 * 8 ld a, HP_BAR_LENGTH_PX
ldh [hMultiplier], a ldh [hMultiplier], a
call Multiply call Multiply
; We need de to be under 256 because hDivisor is only 1 byte. ; We need de to be under 256 because hDivisor is only 1 byte.

View File

@ -18,8 +18,8 @@ MACRO anim_obj
else else
; LEGACY: Support the tile+offset format ; LEGACY: Support the tile+offset format
db \1 ; object db \1 ; object
db (\2) * 8 + (\3) ; x_tile, x db (\2) * TILE_WIDTH + (\3) ; x_tile, x
db (\4) * 8 + (\5) ; y_tile, y db (\4) * TILE_WIDTH + (\5) ; y_tile, y
db \6 ; param db \6 ; param
endc endc
ENDM ENDM

View File

@ -2623,12 +2623,12 @@ AnimateEZChatCursor:
ret ret
.nine .nine
ld d, -13 * 8 ld d, -13 * TILE_WIDTH
ld a, SPRITE_ANIM_FRAMESET_EZCHAT_CURSOR_7 ld a, SPRITE_ANIM_FRAMESET_EZCHAT_CURSOR_7
jr .eight_nine_load jr .eight_nine_load
.eight .eight
ld d, 2 * 8 ld d, 2 * TILE_WIDTH
ld a, SPRITE_ANIM_FRAMESET_EZCHAT_CURSOR_6 ld a, SPRITE_ANIM_FRAMESET_EZCHAT_CURSOR_6
.eight_nine_load .eight_nine_load
push de push de
@ -2640,7 +2640,7 @@ AnimateEZChatCursor:
ld e, a ld e, a
sla a sla a
add e add e
add 8 * 8 add 8 * TILE_WIDTH
ld hl, SPRITEANIMSTRUCT_YCOORD ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc add hl, bc
ld [hld], a ld [hld], a

View File

@ -1516,9 +1516,9 @@ MobileTradeAnim_AnimateSentPulse:
ld hl, SPRITEANIMSTRUCT_YCOORD ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
cp -1 * 8 - 6 cp -1 * TILE_WIDTH - 6
jr z, .delete jr z, .delete
sub 1 * 8 sub 1 * TILE_WIDTH
ld [hl], a ld [hl], a
ret ret
@ -1530,9 +1530,9 @@ MobileTradeAnim_AnimateOTPulse:
ld hl, SPRITEANIMSTRUCT_YCOORD ld hl, SPRITEANIMSTRUCT_YCOORD
add hl, bc add hl, bc
ld a, [hl] ld a, [hl]
cp 9 * 8 + 2 cp 9 * TILE_WIDTH + 2
ret z ret z
add 1 * 8 add 1 * TILE_WIDTH
ld [hl], a ld [hl], a
ret ret

View File

@ -6758,10 +6758,10 @@ Function11b3d9:
jr .loop1 jr .loop1
.skip .skip
ld b, 14 * 8 ld b, 14 * TILE_WIDTH
.load_sprites .load_sprites
ld a, 2 * 8 + 5 ld a, 2 * TILE_WIDTH + 5
add b add b
pop hl pop hl
ld [hli], a ld [hli], a
@ -6778,7 +6778,7 @@ Function11b3d9:
jr z, .version2 jr z, .version2
.version1 .version1
ld a, 19 * 8 + 3 ld a, 19 * TILE_WIDTH + 3
ld [hli], a ld [hli], a
ld a, [wcd4c] ld a, [wcd4c]
add $3c add $3c
@ -6789,7 +6789,7 @@ Function11b3d9:
ret ret
.version2 .version2
ld a, 19 * 8 + 3 ld a, 19 * TILE_WIDTH + 3
ld [hli], a ld [hli], a
ld a, $39 ld a, $39
ld [hli], a ld [hli], a