diff options
| author | Rangi <35663410+Rangi42@users.noreply.github.com> | 2025-11-25 17:53:29 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-25 16:53:29 -0600 |
| commit | e92d1af478c8381fde30f709c2619abe90104d3a (patch) | |
| tree | 7be135926706fabcf23d2b278378d0fdd7f7eda7 /engine/battle | |
| parent | Use `ld_hli_a_string` macro to make byte-by-byte strings more obvious (#540) (diff) | |
| download | pokeyellow-e92d1af478c8381fde30f709c2619abe90104d3a.tar.gz pokeyellow-e92d1af478c8381fde30f709c2619abe90104d3a.tar.xz pokeyellow-e92d1af478c8381fde30f709c2619abe90104d3a.zip | |
Avoid magic numbers for most `CopyData` calls (#542)
Diffstat (limited to 'engine/battle')
| -rw-r--r-- | engine/battle/animations.asm | 20 | ||||
| -rw-r--r-- | engine/battle/core.asm | 21 | ||||
| -rw-r--r-- | engine/battle/draw_hud_pokeball_gfx.asm | 8 | ||||
| -rw-r--r-- | engine/battle/effects.asm | 2 | ||||
| -rw-r--r-- | engine/battle/ghost_marowak_anim.asm | 2 | ||||
| -rw-r--r-- | engine/battle/move_effects/transform.asm | 9 | ||||
| -rw-r--r-- | engine/battle/trainer_ai.asm | 4 |
7 files changed, 34 insertions, 32 deletions
diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index 711ebda4..f66be640 100644 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -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 diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 672bd416..4c25373a 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -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 diff --git a/engine/battle/draw_hud_pokeball_gfx.asm b/engine/battle/draw_hud_pokeball_gfx.asm index 983e7cdf..011b4b33 100644 --- a/engine/battle/draw_hud_pokeball_gfx.asm +++ b/engine/battle/draw_hud_pokeball_gfx.asm @@ -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 diff --git a/engine/battle/effects.asm b/engine/battle/effects.asm index e107853c..003592aa 100644 --- a/engine/battle/effects.asm +++ b/engine/battle/effects.asm @@ -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" diff --git a/engine/battle/ghost_marowak_anim.asm b/engine/battle/ghost_marowak_anim.asm index 4b1eb452..1040f85f 100644 --- a/engine/battle/ghost_marowak_anim.asm +++ b/engine/battle/ghost_marowak_anim.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 diff --git a/engine/battle/move_effects/transform.asm b/engine/battle/move_effects/transform.asm index 6f2e705c..343fa3ca 100644 --- a/engine/battle/move_effects/transform.asm +++ b/engine/battle/move_effects/transform.asm @@ -82,14 +82,15 @@ TransformEffect_: ld a, [hli] ld [de], a inc de -; Attack, Defense, Speed, and Special stats +; Skip level and max HP inc hl inc hl inc hl inc de inc de inc de - ld bc, $8 +; Attack, Defense, Speed, and Special stats + 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 diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm index 4134047f..546dd60e 100644 --- a/engine/battle/trainer_ai.asm +++ b/engine/battle/trainer_ai.asm @@ -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 |
