mirror of
https://github.com/pret/pokered.git
synced 2026-10-01 13:38:02 -05:00
Avoid magic numbers for most CopyData calls (#542)
Some checks failed
CI / build (push) Has been cancelled
Some checks failed
CI / build (push) Has been cancelled
This commit is contained in:
@@ -7,7 +7,11 @@ DEF SCREEN_BLOCK_HEIGHT EQU 5 ; blocks
|
||||
DEF SURROUNDING_WIDTH EQU SCREEN_BLOCK_WIDTH * BLOCK_WIDTH ; tiles
|
||||
DEF SURROUNDING_HEIGHT EQU SCREEN_BLOCK_HEIGHT * BLOCK_HEIGHT ; tiles
|
||||
|
||||
DEF SPRITEBUFFERSIZE EQU 7 * 7 * TILE_1BPP_SIZE
|
||||
DEF PIC_WIDTH EQU 7 ; tiles
|
||||
DEF PIC_HEIGHT EQU PIC_WIDTH ; tiles
|
||||
DEF PIC_SIZE EQU PIC_WIDTH * PIC_HEIGHT ; tiles
|
||||
|
||||
DEF SPRITEBUFFERSIZE EQU PIC_WIDTH * PIC_HEIGHT * TILE_1BPP_SIZE
|
||||
|
||||
; HP bar
|
||||
DEF HP_BAR_GREEN EQU 0
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
DEF NAME_LENGTH EQU 11
|
||||
DEF ITEM_NAME_LENGTH EQU 13
|
||||
DEF NAME_BUFFER_LENGTH EQU 20
|
||||
DEF GYM_CITY_LENGTH EQU 17
|
||||
|
||||
; PrintNumber, PrintBCDNumber
|
||||
const_def 5
|
||||
|
||||
@@ -1213,12 +1213,12 @@ _AnimationSlideMonUp:
|
||||
push bc
|
||||
|
||||
; In each iteration, slide up all rows but the top one (which is overwritten).
|
||||
ld b, 6
|
||||
ld b, PIC_HEIGHT - 1
|
||||
.slideLoop
|
||||
push bc
|
||||
push de
|
||||
push hl
|
||||
ld bc, 7
|
||||
ld bc, PIC_WIDTH
|
||||
call CopyData
|
||||
; Note that de and hl are popped in the same order they are pushed, swapping
|
||||
; their values. When CopyData is called, hl points to a tile 1 row below
|
||||
@@ -1242,10 +1242,10 @@ _AnimationSlideMonUp:
|
||||
ld a, [wSlideMonUpBottomRowLeftTile]
|
||||
inc a
|
||||
ld [wSlideMonUpBottomRowLeftTile], a
|
||||
ld c, 7
|
||||
ld c, PIC_WIDTH
|
||||
.fillBottomRowLoop
|
||||
ld [hli], a
|
||||
add 7
|
||||
add PIC_WIDTH
|
||||
dec c
|
||||
jr nz, .fillBottomRowLoop
|
||||
|
||||
@@ -1723,10 +1723,10 @@ AnimationMinimizeMon:
|
||||
ld hl, wTempPic
|
||||
push hl
|
||||
xor a
|
||||
ld bc, (7 * 7) tiles
|
||||
ld bc, PIC_SIZE tiles
|
||||
call FillMemory
|
||||
pop hl
|
||||
ld de, (7 * 3 + 4) tiles + TILE_SIZE / 4
|
||||
ld de, (PIC_WIDTH * 3 + 4) tiles + TILE_SIZE / 4
|
||||
add hl, de
|
||||
ld de, MinimizedMonSprite
|
||||
ld c, MinimizedMonSpriteEnd - MinimizedMonSprite
|
||||
@@ -1774,7 +1774,7 @@ AnimationSlideMonDownAndHide:
|
||||
jr nz, .loop
|
||||
call AnimationHideMonPic
|
||||
ld hl, wTempPic
|
||||
ld bc, 7 * 7 tiles
|
||||
ld bc, PIC_SIZE tiles
|
||||
xor a
|
||||
call FillMemory
|
||||
jp CopyTempPicToMonPic
|
||||
@@ -1867,7 +1867,7 @@ CopyTempPicToMonPic:
|
||||
ld hl, vFrontPic ; enemy turn
|
||||
.next
|
||||
ld de, wTempPic
|
||||
ld bc, 7 * 7
|
||||
ld bc, PIC_SIZE
|
||||
jp CopyVideoData
|
||||
|
||||
AnimationWavyScreen:
|
||||
@@ -1935,7 +1935,7 @@ AnimationSubstitute:
|
||||
; Changes the pokemon's sprite to the mini sprite
|
||||
ld hl, wTempPic
|
||||
xor a
|
||||
ld bc, 7 * 7 tiles
|
||||
ld bc, PIC_SIZE tiles
|
||||
call FillMemory
|
||||
ldh a, [hWhoseTurn]
|
||||
and a
|
||||
@@ -2473,7 +2473,7 @@ AnimationShakeEnemyHUD:
|
||||
; Make a copy of the back pic's tile patterns in sprite tile pattern VRAM.
|
||||
ld de, vBackPic
|
||||
ld hl, vSprites
|
||||
ld bc, 7 * 7
|
||||
ld bc, PIC_SIZE
|
||||
call CopyVideoData
|
||||
|
||||
xor a
|
||||
|
||||
@@ -1183,17 +1183,17 @@ SlideDownFaintedMonPic:
|
||||
push af
|
||||
set BIT_NO_TEXT_DELAY, a
|
||||
ld [wStatusFlags5], a
|
||||
ld b, 7 ; number of times to slide
|
||||
ld b, PIC_HEIGHT ; number of times to slide
|
||||
.slideStepLoop ; each iteration, the mon is slid down one row
|
||||
push bc
|
||||
push de
|
||||
push hl
|
||||
ld b, 6 ; number of rows
|
||||
ld b, PIC_HEIGHT - 1 ; number of rows
|
||||
.rowLoop
|
||||
push bc
|
||||
push hl
|
||||
push de
|
||||
ld bc, $7
|
||||
ld bc, PIC_WIDTH
|
||||
call CopyData
|
||||
pop de
|
||||
pop hl
|
||||
@@ -1225,7 +1225,8 @@ SlideDownFaintedMonPic:
|
||||
ret
|
||||
|
||||
SevenSpacesText:
|
||||
db " @"
|
||||
ds PIC_WIDTH, ' '
|
||||
db "@"
|
||||
|
||||
; slides the player or enemy trainer off screen
|
||||
; a is the number of tiles to slide it horizontally (always 9 for the player trainer or 8 for the enemy trainer)
|
||||
@@ -1237,7 +1238,7 @@ SlideTrainerPicOffScreen:
|
||||
.slideStepLoop ; each iteration, the trainer pic is slid one tile left/right
|
||||
push bc
|
||||
push hl
|
||||
ld b, 7 ; number of rows
|
||||
ld b, PIC_HEIGHT ; number of rows
|
||||
.rowLoop
|
||||
push hl
|
||||
ldh a, [hSlideAmount]
|
||||
@@ -1794,7 +1795,7 @@ AnimateRetreatingPlayerMon:
|
||||
lb bc, 7, 7
|
||||
jp ClearScreenArea
|
||||
|
||||
; Copies player's current pokemon's current HP and status into the party
|
||||
; Copies player's current pokemon's current HP, party pos, and status into the party
|
||||
; struct data so it stays after battle or switching
|
||||
ReadPlayerMonCurHPAndStatus:
|
||||
ld a, [wPlayerMonNumber]
|
||||
@@ -1804,7 +1805,7 @@ ReadPlayerMonCurHPAndStatus:
|
||||
ld d, h
|
||||
ld e, l
|
||||
ld hl, wBattleMonHP
|
||||
ld bc, $4 ; 2 bytes HP, 1 byte unknown (unused?), 1 byte status
|
||||
ld bc, MON_STATUS + 1 - MON_HP ; also copies party pos in-between HP and status
|
||||
jp CopyData
|
||||
|
||||
DrawHUDsAndHPBars:
|
||||
@@ -6352,7 +6353,7 @@ LoadPlayerBackPic:
|
||||
ld [hl], d ; OAM Y
|
||||
inc hl
|
||||
ld [hl], e ; OAM X
|
||||
ld a, $8 ; height of tile
|
||||
ld a, TILE_HEIGHT
|
||||
add d ; increase Y by height of tile
|
||||
ld d, a
|
||||
inc hl
|
||||
@@ -6366,7 +6367,7 @@ LoadPlayerBackPic:
|
||||
ldh a, [hOAMTile]
|
||||
add $4 ; increase tile number by 4
|
||||
ldh [hOAMTile], a
|
||||
ld a, $8 ; width of tile
|
||||
ld a, TILE_WIDTH
|
||||
add e ; increase X by width of tile
|
||||
ld e, a
|
||||
dec b
|
||||
@@ -6381,7 +6382,7 @@ LoadPlayerBackPic:
|
||||
ld de, sSpriteBuffer1
|
||||
ldh a, [hLoadedROMBank]
|
||||
ld b, a
|
||||
ld c, 7 * 7
|
||||
ld c, PIC_SIZE
|
||||
call CopyVideoData
|
||||
xor a
|
||||
ld [rRAMG], a
|
||||
|
||||
@@ -119,7 +119,7 @@ WritePokeballOAMData:
|
||||
PlacePlayerHUDTiles:
|
||||
ld hl, PlayerBattleHUDGraphicsTiles
|
||||
ld de, wHUDGraphicsTiles
|
||||
ld bc, $3
|
||||
ld bc, wHUDGraphicsTilesEnd - wHUDGraphicsTiles
|
||||
call CopyData
|
||||
hlcoord 18, 10
|
||||
ld de, -1
|
||||
@@ -134,7 +134,7 @@ PlayerBattleHUDGraphicsTiles:
|
||||
PlaceEnemyHUDTiles:
|
||||
ld hl, EnemyBattleHUDGraphicsTiles
|
||||
ld de, wHUDGraphicsTiles
|
||||
ld bc, $3
|
||||
ld bc, wHUDGraphicsTilesEnd - wHUDGraphicsTiles
|
||||
call CopyData
|
||||
hlcoord 1, 2
|
||||
ld de, $1
|
||||
@@ -150,7 +150,7 @@ PlaceHUDTiles:
|
||||
ld [hl], $73
|
||||
ld bc, SCREEN_WIDTH
|
||||
add hl, bc
|
||||
ld a, [wHUDGraphicsTiles + 1] ; leftmost tile
|
||||
ld a, [wHUDCornerTile] ; leftmost tile
|
||||
ld [hl], a
|
||||
ld a, 8
|
||||
.loop
|
||||
@@ -159,7 +159,7 @@ PlaceHUDTiles:
|
||||
dec a
|
||||
jr nz, .loop
|
||||
add hl, de
|
||||
ld a, [wHUDGraphicsTiles + 2] ; rightmost tile
|
||||
ld a, [wHUDTriangleTile] ; rightmost tile
|
||||
ld [hl], a
|
||||
ret
|
||||
|
||||
|
||||
@@ -754,7 +754,7 @@ PrintStatText:
|
||||
jr .findStatName_inner
|
||||
.foundStatName
|
||||
ld de, wStringBuffer
|
||||
ld bc, $a
|
||||
ld bc, NAME_LENGTH - 1 ; all StatModTextStrings are at most 10 bytes
|
||||
jp CopyData
|
||||
|
||||
INCLUDE "data/battle/stat_mod_names.asm"
|
||||
|
||||
@@ -52,7 +52,7 @@ MarowakAnim:
|
||||
CopyMonPicFromBGToSpriteVRAM:
|
||||
ld de, vFrontPic
|
||||
ld hl, vSprites
|
||||
ld bc, 7 * 7
|
||||
ld bc, PIC_SIZE
|
||||
call CopyVideoData
|
||||
ld a, $10
|
||||
ld [wBaseCoordY], a
|
||||
|
||||
@@ -82,14 +82,15 @@ TransformEffect_:
|
||||
ld a, [hli]
|
||||
ld [de], a
|
||||
inc de
|
||||
; Skip level and max HP
|
||||
inc hl
|
||||
inc hl
|
||||
inc hl
|
||||
inc de
|
||||
inc de
|
||||
inc de
|
||||
; Attack, Defense, Speed, and Special stats
|
||||
inc hl
|
||||
inc hl
|
||||
inc hl
|
||||
inc de
|
||||
inc de
|
||||
inc de
|
||||
ld bc, $8
|
||||
ld bc, (NUM_STATS - 1) * 2
|
||||
call CopyData
|
||||
ld bc, wBattleMonMoves - wBattleMonPP
|
||||
add hl, bc ; ld hl, wBattleMonMoves
|
||||
@@ -99,7 +100,7 @@ TransformEffect_:
|
||||
ld a, [hli]
|
||||
and a
|
||||
jr z, .lessThanFourMoves
|
||||
ld a, $5
|
||||
ld a, 5
|
||||
ld [de], a
|
||||
inc de
|
||||
dec b
|
||||
@@ -136,7 +137,7 @@ TransformEffect_:
|
||||
ld l, e
|
||||
pop de
|
||||
.gotStatsOrModsToCopy
|
||||
ld bc, $8
|
||||
ld bc, (NUM_STATS - 1) * 2
|
||||
jp CopyData
|
||||
|
||||
.failed
|
||||
|
||||
@@ -583,7 +583,7 @@ AISwitchIfEnoughMons:
|
||||
|
||||
SwitchEnemyMon:
|
||||
|
||||
; prepare to withdraw the active monster: copy hp, number, and status to roster
|
||||
; prepare to withdraw the active monster: copy HP, party pos, and status to roster
|
||||
|
||||
ld a, [wEnemyMonPartyPos]
|
||||
ld hl, wEnemyMon1HP
|
||||
@@ -592,7 +592,7 @@ SwitchEnemyMon:
|
||||
ld d, h
|
||||
ld e, l
|
||||
ld hl, wEnemyMonHP
|
||||
ld bc, 4
|
||||
ld bc, MON_STATUS + 1 - MON_HP ; also copies party pos in-between HP and status
|
||||
call CopyData
|
||||
|
||||
ld hl, AIBattleWithdrawText
|
||||
|
||||
@@ -226,7 +226,7 @@ InGameTrade_CopyDataToReceivedMon:
|
||||
ld bc, wPartyMon2 - wPartyMon1
|
||||
call InGameTrade_GetReceivedMonPointer
|
||||
ld hl, wTradedEnemyMonOTID
|
||||
ld bc, $2
|
||||
ld bc, 2
|
||||
jp CopyData
|
||||
|
||||
; the received mon's index is (partyCount - 1),
|
||||
|
||||
@@ -1302,13 +1302,13 @@ ItemUseMedicine:
|
||||
.statNameInnerLoop
|
||||
ld a, [hli]
|
||||
ld b, a
|
||||
ld a, $50
|
||||
ld a, '@'
|
||||
cp b
|
||||
jr nz, .statNameInnerLoop
|
||||
jr .statNameLoop
|
||||
.gotStatName
|
||||
ld de, wStringBuffer
|
||||
ld bc, 10
|
||||
ld bc, NAME_LENGTH - 1 ; all VitaminStats are at most 10 bytes
|
||||
call CopyData ; copy the stat's name to wStringBuffer
|
||||
ld a, SFX_HEAL_AILMENT
|
||||
call PlaySound
|
||||
@@ -2029,7 +2029,7 @@ ItemUsePPRestore:
|
||||
ld bc, wPartyMon2 - wPartyMon1
|
||||
call AddNTimes
|
||||
ld de, wBattleMonPP
|
||||
ld bc, 4
|
||||
ld bc, NUM_MOVES
|
||||
call CopyData ; copy party data to in-battle data
|
||||
.skipUpdatingInBattleData
|
||||
ld a, SFX_HEAL_AILMENT
|
||||
|
||||
@@ -20,7 +20,7 @@ DisplayTownMap:
|
||||
call PlaceString
|
||||
ld hl, wShadowOAMSprite00
|
||||
ld de, wShadowOAMBackupSprite00
|
||||
ld bc, 4 * 4
|
||||
ld bc, OBJ_SIZE * 4
|
||||
call CopyData
|
||||
ld hl, vSprites tile BIRD_BASE_TILE
|
||||
ld de, TownMapCursor
|
||||
@@ -64,7 +64,7 @@ DisplayTownMap:
|
||||
call PlaceString
|
||||
ld hl, wShadowOAMSprite04
|
||||
ld de, wShadowOAMBackupSprite04
|
||||
ld bc, 4 * 4
|
||||
ld bc, OBJ_SIZE * 4
|
||||
call CopyData
|
||||
.inputLoop
|
||||
call TownMapSpriteBlinkingAnimation
|
||||
|
||||
@@ -30,7 +30,7 @@ EvolveMon:
|
||||
call Evolution_LoadPic
|
||||
ld de, vFrontPic
|
||||
ld hl, vBackPic
|
||||
ld bc, 7 * 7
|
||||
ld bc, PIC_SIZE
|
||||
call CopyVideoData
|
||||
ld a, [wEvoOldSpecies]
|
||||
ld [wCurPartySpecies], a
|
||||
|
||||
@@ -188,7 +188,7 @@ HoFLoadPlayerPics:
|
||||
call UncompressSpriteFromDE
|
||||
ld hl, sSpriteBuffer1
|
||||
ld de, sSpriteBuffer0
|
||||
ld bc, $310
|
||||
ld bc, 2 * SPRITEBUFFERSIZE
|
||||
call CopyData
|
||||
ld de, vFrontPic
|
||||
call InterlaceMergeSpriteBuffers
|
||||
|
||||
@@ -133,7 +133,7 @@ AnimateShootingStar:
|
||||
; shift the existing OAM entries down to make room for the next wave
|
||||
ld hl, wShadowOAMSprite04
|
||||
ld de, wShadowOAM
|
||||
ld bc, $50
|
||||
ld bc, OBJ_SIZE * 20
|
||||
call CopyData
|
||||
|
||||
pop af
|
||||
|
||||
@@ -77,13 +77,13 @@ AnimCutGrass_UpdateOAMEntries:
|
||||
AnimCutGrass_SwapOAMEntries:
|
||||
ld hl, wShadowOAMSprite36
|
||||
ld de, wBuffer
|
||||
ld bc, $8
|
||||
ld bc, 2 * OBJ_SIZE
|
||||
call CopyData
|
||||
ld hl, wShadowOAMSprite38
|
||||
ld de, wShadowOAMSprite36
|
||||
ld bc, $8
|
||||
ld bc, 2 * OBJ_SIZE
|
||||
call CopyData
|
||||
ld hl, wBuffer
|
||||
ld de, wShadowOAMSprite38
|
||||
ld bc, $8
|
||||
ld bc, 2 * OBJ_SIZE
|
||||
jp CopyData
|
||||
|
||||
@@ -264,7 +264,7 @@ InitFacingDirectionList:
|
||||
ld [wSavedPlayerScreenY], a
|
||||
ld hl, PlayerSpinningFacingOrder
|
||||
ld de, wFacingDirectionList
|
||||
ld bc, 4
|
||||
ld bc, OBJ_SIZE
|
||||
call CopyData
|
||||
ld a, [wSpritePlayerStateData1ImageIndex] ; (image index is locked to standing images)
|
||||
ld hl, wFacingDirectionList
|
||||
@@ -288,7 +288,7 @@ SpinPlayerSprite:
|
||||
push hl
|
||||
ld hl, wFacingDirectionList
|
||||
ld de, wFacingDirectionList - 1
|
||||
ld bc, 4
|
||||
ld bc, OBJ_SIZE
|
||||
call CopyData
|
||||
ld a, [wFacingDirectionList - 1]
|
||||
ld [wFacingDirectionList + 3], a
|
||||
@@ -393,7 +393,7 @@ FishingAnim:
|
||||
ld hl, FishingRodOAM
|
||||
add hl, bc
|
||||
ld de, wShadowOAMSprite39
|
||||
ld bc, $4
|
||||
ld bc, OBJ_SIZE
|
||||
call CopyData
|
||||
ld c, 100
|
||||
call DelayFrames
|
||||
|
||||
@@ -231,7 +231,7 @@ _AddPartyMon::
|
||||
dec a
|
||||
jr nz, .calcFreshStats
|
||||
ld hl, wEnemyMonMaxHP
|
||||
ld bc, $a
|
||||
ld bc, NUM_STATS * 2
|
||||
call CopyData ; copy stats of cur enemy mon
|
||||
pop hl
|
||||
jr .done
|
||||
|
||||
@@ -447,7 +447,7 @@ SlotMachine_CheckForMatches:
|
||||
ld h, [hl]
|
||||
ld l, a
|
||||
ld de, wStringBuffer
|
||||
ld bc, 4
|
||||
ld bc, 4 ; every SlotReward*Text is at most 4 bytes
|
||||
call CopyData
|
||||
pop hl
|
||||
ld de, .flashScreenLoop
|
||||
|
||||
@@ -31,7 +31,7 @@ ExecuteCurMapScriptInTable::
|
||||
LoadGymLeaderAndCityName::
|
||||
push de
|
||||
ld de, wGymCityName
|
||||
ld bc, $11
|
||||
ld bc, GYM_CITY_LENGTH
|
||||
call CopyData ; load city name
|
||||
pop hl
|
||||
ld de, wGymLeaderName
|
||||
|
||||
@@ -12,8 +12,8 @@ NEXTU
|
||||
; battle/menu
|
||||
vSprites:: ds $80 tiles
|
||||
vFont:: ds $80 tiles
|
||||
vFrontPic:: ds 7 * 7 tiles
|
||||
vBackPic:: ds 7 * 7 tiles
|
||||
vFrontPic:: ds PIC_SIZE tiles
|
||||
vBackPic:: ds PIC_SIZE tiles
|
||||
|
||||
NEXTU
|
||||
; overworld
|
||||
@@ -25,7 +25,7 @@ NEXTU
|
||||
; title
|
||||
ds $80 tiles
|
||||
vTitleLogo:: ds $80 tiles
|
||||
ds 7 * 7 tiles
|
||||
ds PIC_SIZE tiles
|
||||
vTitleLogo2:: ds 30 tiles
|
||||
|
||||
ENDU
|
||||
|
||||
10
ram/wram.asm
10
ram/wram.asm
@@ -191,7 +191,7 @@ wOverworldMap:: ds 1300
|
||||
wOverworldMapEnd::
|
||||
|
||||
NEXTU
|
||||
wTempPic:: ds 7 * 7 tiles
|
||||
wTempPic:: ds PIC_SIZE tiles
|
||||
ENDU
|
||||
|
||||
|
||||
@@ -688,7 +688,11 @@ NEXTU
|
||||
ds 1
|
||||
; difference in X between the next ball and the current one
|
||||
wHUDPokeballGfxOffsetX:: db
|
||||
wHUDGraphicsTiles:: ds 3
|
||||
wHUDGraphicsTiles::
|
||||
wHUDUnusedTopTile:: db
|
||||
wHUDCornerTile:: db
|
||||
wHUDTriangleTile:: db
|
||||
wHUDGraphicsTilesEnd::
|
||||
|
||||
NEXTU
|
||||
; the level of the mon at the time it entered day care
|
||||
@@ -1079,7 +1083,7 @@ wExpAmountGained:: dw
|
||||
wGainBoostedExp:: db
|
||||
ENDU
|
||||
|
||||
wGymCityName:: ds 17
|
||||
wGymCityName:: ds GYM_CITY_LENGTH
|
||||
|
||||
wGymLeaderName:: ds NAME_LENGTH
|
||||
|
||||
|
||||
Reference in New Issue
Block a user