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
call StageBallTilesData
; ldpixel wPlaceBallsX, 12, 12
ld a, 12 * 8
ld a, 12 * TILE_WIDTH
ld hl, wPlaceBallsX
ld [hli], a
ld [hl], a
ld a, 8
ld a, TILE_WIDTH
ld [wPlaceBallsDirection], a
ld hl, wShadowOAMSprite00
jp LoadTrainerHudOAM
@ -36,10 +36,10 @@ ShowOTTrainerMonsRemaining:
call StageBallTilesData
; ldpixel wPlaceBallsX, 9, 4
ld hl, wPlaceBallsX
ld a, 9 * 8
ld a, 9 * TILE_WIDTH
ld [hli], a
ld [hl], 4 * 8
ld a, -8
ld [hl], 4 * TILE_WIDTH
ld a, -TILE_WIDTH
ld [wPlaceBallsDirection], a
ld hl, wShadowOAMSprite00 + PARTY_LENGTH * SPRITEOAMSTRUCT_LENGTH
jp LoadTrainerHudOAM
@ -182,10 +182,10 @@ LinkBattle_TrainerHuds:
ld de, wPartyCount
call StageBallTilesData
ld hl, wPlaceBallsX
ld a, 10 * 8
ld a, 10 * TILE_WIDTH
ld [hli], a
ld [hl], 8 * 8
ld a, 8
ld [hl], 8 * TILE_WIDTH
ld a, TILE_WIDTH
ld [wPlaceBallsDirection], a
ld hl, wShadowOAMSprite00
call LoadTrainerHudOAM
@ -194,9 +194,9 @@ LinkBattle_TrainerHuds:
ld de, wOTPartyCount
call StageBallTilesData
ld hl, wPlaceBallsX
ld a, 10 * 8
ld a, 10 * TILE_WIDTH
ld [hli], a
ld [hl], 13 * 8
ld [hl], 13 * TILE_WIDTH
ld hl, wShadowOAMSprite00 + PARTY_LENGTH * SPRITEOAMSTRUCT_LENGTH
jp LoadTrainerHudOAM

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -779,9 +779,9 @@ EggHatch_CrackShell:
ret nc
swap a
srl a
add 9 * 8 + 4
add 9 * TILE_WIDTH + 4
ld d, a
ld e, 11 * 8
ld e, 11 * TILE_WIDTH
ld a, SPRITE_ANIM_INDEX_EGG_CRACK
call InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_TILE_ID
@ -838,7 +838,7 @@ Hatch_InitShellFragments:
MACRO shell_fragment
; 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
.SpriteData:

View File

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

View File

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

View File

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

View File

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

View File

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