From c210f052a8097b1cef277d7cd008408ff6c21323 Mon Sep 17 00:00:00 2001 From: mid-kid Date: Wed, 21 Nov 2018 14:14:34 +0100 Subject: Move BattleSideCopy to transform.asm --- engine/battle/effect_commands.asm | 15 --------------- engine/battle/move_effects/transform.asm | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 16 deletions(-) (limited to 'engine') diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm index 2dafc04ba..f257b025c 100644 --- a/engine/battle/effect_commands.asm +++ b/engine/battle/effect_commands.asm @@ -6220,21 +6220,6 @@ BattleCommand_Heal: INCLUDE "engine/battle/move_effects/transform.asm" -BattleSideCopy: -; Copy bc bytes from hl to de if it's the player's turn. -; Copy bc bytes from de to hl if it's the enemy's turn. - ldh a, [hBattleTurn] - and a - jr z, .copy - -; Swap hl and de - push hl - ld h, d - ld l, e - pop de -.copy - jp CopyBytes - BattleEffect_ButItFailed: call AnimateFailedMove jp PrintButItFailed diff --git a/engine/battle/move_effects/transform.asm b/engine/battle/move_effects/transform.asm index ab94da79c..509a8d03f 100644 --- a/engine/battle/move_effects/transform.asm +++ b/engine/battle/move_effects/transform.asm @@ -1,4 +1,3 @@ - BattleCommand_Transform: ; transform @@ -137,3 +136,18 @@ BattleCommand_Transform: call nz, LoadAnim ld hl, TransformedText jp StdBattleTextBox + +BattleSideCopy: +; Copy bc bytes from hl to de if it's the player's turn. +; Copy bc bytes from de to hl if it's the enemy's turn. + ldh a, [hBattleTurn] + and a + jr z, .copy + +; Swap hl and de + push hl + ld h, d + ld l, e + pop de +.copy + jp CopyBytes -- cgit v1.2.3 From 2746288030ff3bd4febc43c1c9fe8a203272b927 Mon Sep 17 00:00:00 2001 From: mid-kid Date: Wed, 21 Nov 2018 23:44:31 +0100 Subject: Define ANIM_GFX for PLAYER and ENEMY These are used where the head or the feet of the player/enemy have to be moved in an animation, and shouldn't overlap. These aren't actual GFX and should be loaded with the proper commands, and they're always loaded at the end of the VRAM area. Furthermore, I've defined BATTLEANIM_BASE_TILE, which is the tile from which battle animation graphics may start to load. This value was picked to make sure at least an entire pokemon pic fits in the area before it, even though it doesn't seem very used... --- engine/battle_anims/anim_commands.asm | 66 +++++++++++++++++------------------ engine/battle_anims/core.asm | 2 +- 2 files changed, 34 insertions(+), 34 deletions(-) (limited to 'engine') diff --git a/engine/battle_anims/anim_commands.asm b/engine/battle_anims/anim_commands.asm index 4191fdf81..fcf61c43f 100644 --- a/engine/battle_anims/anim_commands.asm +++ b/engine/battle_anims/anim_commands.asm @@ -665,7 +665,7 @@ BattleAnimCmd_5GFX: ld [wBattleAnimTemp0], a .loop ld a, [wBattleAnimTemp0] - cp (vTiles1 - vTiles0) / $10 - $31 + cp (vTiles1 - vTiles0) / LEN_2BPP_TILE - BATTLEANIM_BASE_TILE ret nc call GetBattleAnimByte ld [hli], a @@ -678,7 +678,7 @@ BattleAnimCmd_5GFX: rept 4 add hl, hl endr - ld de, vTiles0 tile $31 + ld de, vTiles0 tile BATTLEANIM_BASE_TILE add hl, de ld a, [wBattleAnimByte] call LoadBattleAnimObj @@ -778,33 +778,33 @@ BattleAnimCmd_EnemyFeetObj: jr .loop .okay - ld a, $28 + ld a, ANIM_GFX_PLAYER ld [hli], a - ld a, $42 + ld a, ($80 - 6 - 7) - BATTLEANIM_BASE_TILE ld [hli], a - ld a, $29 + ld a, ANIM_GFX_ENEMY ld [hli], a - ld a, $49 + ld a, ($80 - 6) - BATTLEANIM_BASE_TILE ld [hl], a - ld hl, vTiles0 tile $73 - ld de, vTiles2 tile $06 - ld a, $70 + ld hl, vTiles0 tile ($80 - 6 - 7) + ld de, vTiles2 tile $06 ; Enemy feet start tile + ld a, 7 tiles ; Enemy pic height ld [wBattleAnimTemp0], a - ld a, $7 - call .LoadFootprint - ld de, vTiles2 tile $31 - ld a, $60 + ld a, 7 ; Copy 7x1 tiles + call .LoadFeet + ld de, vTiles2 tile $31 ; Player head start tile + ld a, 6 tiles ; Player pic height ld [wBattleAnimTemp0], a - ld a, $6 - call .LoadFootprint + ld a, 6 ; Copy 6x1 tiles + call .LoadFeet ret -.LoadFootprint: +.LoadFeet: push af push hl push de - lb bc, BANK(BattleAnimCmd_EnemyFeetObj), 1 + lb bc, BANK(@), 1 call Request2bpp pop de ld a, [wBattleAnimTemp0] @@ -818,7 +818,7 @@ BattleAnimCmd_EnemyFeetObj: add hl, bc pop af dec a - jr nz, .LoadFootprint + jr nz, .LoadFeet ret BattleAnimCmd_PlayerHeadObj: @@ -832,25 +832,25 @@ BattleAnimCmd_PlayerHeadObj: jr .loop .okay - ld a, $28 + ld a, ANIM_GFX_PLAYER ld [hli], a - ld a, $35 + ld a, ($80 - 6 * 2 - 7 * 2) - BATTLEANIM_BASE_TILE ld [hli], a - ld a, $29 + ld a, ANIM_GFX_ENEMY ld [hli], a - ld a, $43 + ld a, ($80 - 6 * 2) - BATTLEANIM_BASE_TILE ld [hl], a - ld hl, vTiles0 tile $66 - ld de, vTiles2 tile $05 - ld a, $70 + ld hl, vTiles0 tile ($80 - 6 * 2 - 7 * 2) + ld de, vTiles2 tile $05 ; Enemy feet start tile + ld a, 7 tiles ; Enemy pic height ld [wBattleAnimTemp0], a - ld a, $7 + ld a, 7 ; Copy 7x2 tiles call .LoadHead - ld de, vTiles2 tile $31 - ld a, $60 + ld de, vTiles2 tile $31 ; Player head start tile + ld a, 6 tiles ; Player pic height ld [wBattleAnimTemp0], a - ld a, $6 + ld a, 6 ; Copy 6x2 tiles call .LoadHead ret @@ -858,7 +858,7 @@ BattleAnimCmd_PlayerHeadObj: push af push hl push de - lb bc, BANK(BattleAnimCmd_EnemyFeetObj), 2 + lb bc, BANK(@), 2 call Request2bpp pop de ld a, [wBattleAnimTemp0] @@ -927,14 +927,14 @@ BattleAnimCmd_UpdateActorPic: ld hl, vTiles2 tile $00 ld b, 0 - ld c, $31 + ld c, 7 * 7 call Request2bpp ret .player ld hl, vTiles2 tile $31 ld b, 0 - ld c, $24 + ld c, 6 * 6 call Request2bpp ret @@ -1028,7 +1028,7 @@ BattleAnimCmd_MinimizeOpp: GetMinimizePic: ld hl, sScratch - ld bc, $31 tiles + ld bc, (7 * 7) tiles .loop xor a ld [hli], a diff --git a/engine/battle_anims/core.asm b/engine/battle_anims/core.asm index 541de6fc7..b213a9f82 100644 --- a/engine/battle_anims/core.asm +++ b/engine/battle_anims/core.asm @@ -147,7 +147,7 @@ BattleAnimOAMUpdate: inc hl inc de ld a, [wBattleAnimTempTileID] - add $31 + add BATTLEANIM_BASE_TILE add [hl] ld [de], a inc hl -- cgit v1.2.3 From 41f39211ca3448ee79a6c65757bd703f247442fd Mon Sep 17 00:00:00 2001 From: mid-kid Date: Thu, 22 Nov 2018 12:32:24 +0100 Subject: Identified another user of wBattleAnimTemp QueueBattleAnimation loads an object using these wram addresses. Usually populated by the anim_obj command, but in a couple of cases also manually. --- engine/battle_anims/anim_commands.asm | 8 ++++---- engine/battle_anims/bg_effects.asm | 32 ++++++++++++++++---------------- engine/battle_anims/core.asm | 8 ++++---- 3 files changed, 24 insertions(+), 24 deletions(-) (limited to 'engine') diff --git a/engine/battle_anims/anim_commands.asm b/engine/battle_anims/anim_commands.asm index fcf61c43f..0d1c29da5 100644 --- a/engine/battle_anims/anim_commands.asm +++ b/engine/battle_anims/anim_commands.asm @@ -595,13 +595,13 @@ BattleAnimCmd_IfParamAnd: BattleAnimCmd_Obj: ; index, x, y, param call GetBattleAnimByte - ld [wBattleAnimTemp0], a + ld [wBattleObjectTempID], a call GetBattleAnimByte - ld [wBattleAnimTemp1], a + ld [wBattleObjectTempXCoord], a call GetBattleAnimByte - ld [wBattleAnimTemp2], a + ld [wBattleObjectTempYCoord], a call GetBattleAnimByte - ld [wBattleAnimTemp3], a + ld [wBattleObjectTemp0b], a call QueueBattleAnimation ret diff --git a/engine/battle_anims/bg_effects.asm b/engine/battle_anims/bg_effects.asm index 6aaa85189..28fe1bc6f 100644 --- a/engine/battle_anims/bg_effects.asm +++ b/engine/battle_anims/bg_effects.asm @@ -427,20 +427,20 @@ BattleBGEffect_FeetFollow: call BGEffect_CheckBattleTurn jr nz, .player_turn ld a, ANIM_OBJ_PLAYERFEETFOLLOW - ld [wBattleAnimTemp0], a - ld a, 16 * 8 + 4 + ld [wBattleObjectTempID], a + ld a, 16 * TILE_WIDTH + 4 jr .okay .player_turn ld a, ANIM_OBJ_ENEMYFEETFOLLOW - ld [wBattleAnimTemp0], a - ld a, 6 * 8 + ld [wBattleObjectTempID], a + ld a, 6 * TILE_WIDTH .okay - ld [wBattleAnimTemp1], a - ld a, 8 * 8 - ld [wBattleAnimTemp2], a + ld [wBattleObjectTempXCoord], a + ld a, 8 * TILE_WIDTH + ld [wBattleObjectTempYCoord], a xor a - ld [wBattleAnimTemp3], a + ld [wBattleObjectTemp0b], a call _QueueBattleAnimation pop bc ret @@ -494,20 +494,20 @@ BattleBGEffect_HeadFollow: call BGEffect_CheckBattleTurn jr nz, .player_turn ld a, ANIM_OBJ_PLAYERHEADFOLLOW - ld [wBattleAnimTemp0], a - ld a, 16 * 8 + 4 + ld [wBattleObjectTempID], a + ld a, 16 * TILE_WIDTH + 4 jr .okay .player_turn ld a, ANIM_OBJ_ENEMYHEADFOLLOW - ld [wBattleAnimTemp0], a - ld a, 6 * 8 + ld [wBattleObjectTempID], a + ld a, 6 * TILE_WIDTH .okay - ld [wBattleAnimTemp1], a - ld a, 8 * 8 - ld [wBattleAnimTemp2], a + ld [wBattleObjectTempXCoord], a + ld a, 8 * TILE_WIDTH + ld [wBattleObjectTempYCoord], a xor a - ld [wBattleAnimTemp3], a + ld [wBattleObjectTemp0b], a call _QueueBattleAnimation pop bc ret diff --git a/engine/battle_anims/core.asm b/engine/battle_anims/core.asm index b213a9f82..b71303afc 100644 --- a/engine/battle_anims/core.asm +++ b/engine/battle_anims/core.asm @@ -27,7 +27,7 @@ DeinitBattleAnimation: ret InitBattleAnimation: - ld a, [wBattleAnimTemp0] + ld a, [wBattleObjectTempID] ld e, a ld d, 0 ld hl, BattleAnimObjects @@ -58,14 +58,14 @@ endr ld a, [de] call GetBattleAnimTileOffset ld [hli], a ; Tile ID - ld a, [wBattleAnimTemp1] + ld a, [wBattleObjectTempXCoord] ld [hli], a ; X Coord - ld a, [wBattleAnimTemp2] + ld a, [wBattleObjectTempYCoord] ld [hli], a ; Y Coord xor a ld [hli], a ; X Offset ld [hli], a ; Y Offset - ld a, [wBattleAnimTemp3] + ld a, [wBattleObjectTemp0b] ld [hli], a ; 0b xor a ld [hli], a ; 0c -- cgit v1.2.3 From 5dfe652ff60008dd5f1ca6dd49322b2826d5fd52 Mon Sep 17 00:00:00 2001 From: mid-kid Date: Fri, 23 Nov 2018 23:03:27 +0100 Subject: CalcStats -> CalcBattleStats Confusingly ambiguous name --- engine/battle/effect_commands.asm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engine') diff --git a/engine/battle/effect_commands.asm b/engine/battle/effect_commands.asm index f257b025c..8125115e8 100644 --- a/engine/battle/effect_commands.asm +++ b/engine/battle/effect_commands.asm @@ -4853,7 +4853,7 @@ CalcPlayerStats: ld bc, wBattleMonAttack ld a, 5 - call CalcStats + call CalcBattleStats ld hl, BadgeStatBoosts call CallBattleCore @@ -4874,7 +4874,7 @@ CalcEnemyStats: ld bc, wEnemyMonAttack ld a, 5 - call CalcStats + call CalcBattleStats call BattleCommand_SwitchTurn @@ -4886,7 +4886,7 @@ CalcEnemyStats: jp BattleCommand_SwitchTurn -CalcStats: +CalcBattleStats: .loop push af ld a, [hli] -- cgit v1.2.3 From c4979d9770bb9b7b01da9aef151dfb83224647a4 Mon Sep 17 00:00:00 2001 From: mid-kid Date: Sun, 25 Nov 2018 23:57:38 +0100 Subject: Rename "feet and head follow" commands The lot of these were rather misnamed, since they're used to replace part of the player or enemy with objects for several background effects. https://github.com/pret/pokecrystal/pull/578#issuecomment-440996244 --- engine/battle_anims/anim_commands.asm | 18 +++++++++--------- engine/battle_anims/bg_effects.asm | 32 ++++++++++++++++---------------- engine/battle_anims/helpers.asm | 2 +- 3 files changed, 26 insertions(+), 26 deletions(-) (limited to 'engine') diff --git a/engine/battle_anims/anim_commands.asm b/engine/battle_anims/anim_commands.asm index 0d1c29da5..6cc2d6620 100644 --- a/engine/battle_anims/anim_commands.asm +++ b/engine/battle_anims/anim_commands.asm @@ -334,8 +334,8 @@ BattleAnimCommands:: dw BattleAnimCmd_IncObj dw BattleAnimCmd_SetObj dw BattleAnimCmd_IncBGEffect - dw BattleAnimCmd_EnemyFeetObj - dw BattleAnimCmd_PlayerHeadObj + dw BattleAnimCmd_BattlerGFX_1Row + dw BattleAnimCmd_BattlerGFX_2Row dw BattleAnimCmd_CheckPokeball dw BattleAnimCmd_Transform dw BattleAnimCmd_RaiseSub @@ -681,7 +681,7 @@ endr ld de, vTiles0 tile BATTLEANIM_BASE_TILE add hl, de ld a, [wBattleAnimByte] - call LoadBattleAnimObj + call LoadBattleAnimGFX ld a, [wBattleAnimTemp0] add c ld [wBattleAnimTemp0], a @@ -767,7 +767,7 @@ BattleAnimCmd_SetObj: ld [hl], a ret -BattleAnimCmd_EnemyFeetObj: +BattleAnimCmd_BattlerGFX_1Row: ld hl, wBattleAnimTileDict .loop ld a, [hl] @@ -778,11 +778,11 @@ BattleAnimCmd_EnemyFeetObj: jr .loop .okay - ld a, ANIM_GFX_PLAYER + ld a, ANIM_GFX_PLAYERHEAD ld [hli], a ld a, ($80 - 6 - 7) - BATTLEANIM_BASE_TILE ld [hli], a - ld a, ANIM_GFX_ENEMY + ld a, ANIM_GFX_ENEMYFEET ld [hli], a ld a, ($80 - 6) - BATTLEANIM_BASE_TILE ld [hl], a @@ -821,7 +821,7 @@ BattleAnimCmd_EnemyFeetObj: jr nz, .LoadFeet ret -BattleAnimCmd_PlayerHeadObj: +BattleAnimCmd_BattlerGFX_2Row: ld hl, wBattleAnimTileDict .loop ld a, [hl] @@ -832,11 +832,11 @@ BattleAnimCmd_PlayerHeadObj: jr .loop .okay - ld a, ANIM_GFX_PLAYER + ld a, ANIM_GFX_PLAYERHEAD ld [hli], a ld a, ($80 - 6 * 2 - 7 * 2) - BATTLEANIM_BASE_TILE ld [hli], a - ld a, ANIM_GFX_ENEMY + ld a, ANIM_GFX_ENEMYFEET ld [hli], a ld a, ($80 - 6 * 2) - BATTLEANIM_BASE_TILE ld [hl], a diff --git a/engine/battle_anims/bg_effects.asm b/engine/battle_anims/bg_effects.asm index 28fe1bc6f..05d086f7c 100644 --- a/engine/battle_anims/bg_effects.asm +++ b/engine/battle_anims/bg_effects.asm @@ -96,8 +96,8 @@ BattleBGEffects: dw BattleBGEffect_Whirlpool dw BattleBGEffect_Teleport dw BattleBGEffect_NightShade - dw BattleBGEffect_FeetFollow - dw BattleBGEffect_HeadFollow + dw BattleBGEffect_BattlerObj_1Row + dw BattleBGEffect_BattlerObj_2Row dw BattleBGEffect_DoubleTeam dw BattleBGEffect_AcidArmor dw BattleBGEffect_RapidFlash @@ -403,7 +403,7 @@ BattleBGEffect_ShowMon: db 3, $00, 3 db -1 -BattleBGEffect_FeetFollow: +BattleBGEffect_BattlerObj_1Row: call BattleBGEffects_AnonJumptable .anon_dw dw .zero @@ -425,14 +425,14 @@ BattleBGEffect_FeetFollow: call BattleBGEffects_IncrementJumptable push bc call BGEffect_CheckBattleTurn - jr nz, .player_turn - ld a, ANIM_OBJ_PLAYERFEETFOLLOW + jr nz, .player_side + ld a, ANIM_OBJ_ENEMYFEET_1ROW ld [wBattleObjectTempID], a ld a, 16 * TILE_WIDTH + 4 jr .okay -.player_turn - ld a, ANIM_OBJ_ENEMYFEETFOLLOW +.player_side + ld a, ANIM_OBJ_PLAYERHEAD_1ROW ld [wBattleObjectTempID], a ld a, 6 * TILE_WIDTH .okay @@ -449,12 +449,12 @@ BattleBGEffect_FeetFollow: call BattleBGEffects_IncrementJumptable push bc call BGEffect_CheckBattleTurn - jr nz, .player_turn_2 + jr nz, .player_side_2 hlcoord 12, 6 lb bc, 1, 7 jr .okay2 -.player_turn_2 +.player_side_2 hlcoord 2, 6 lb bc, 1, 6 .okay2 @@ -470,7 +470,7 @@ BattleBGEffect_FeetFollow: call EndBattleBGEffect ret -BattleBGEffect_HeadFollow: +BattleBGEffect_BattlerObj_2Row: call BattleBGEffects_AnonJumptable .anon_dw dw .zero @@ -492,14 +492,14 @@ BattleBGEffect_HeadFollow: call BattleBGEffects_IncrementJumptable push bc call BGEffect_CheckBattleTurn - jr nz, .player_turn - ld a, ANIM_OBJ_PLAYERHEADFOLLOW + jr nz, .player_side + ld a, ANIM_OBJ_ENEMYFEET_2ROW ld [wBattleObjectTempID], a ld a, 16 * TILE_WIDTH + 4 jr .okay -.player_turn - ld a, ANIM_OBJ_ENEMYHEADFOLLOW +.player_side + ld a, ANIM_OBJ_PLAYERHEAD_2ROW ld [wBattleObjectTempID], a ld a, 6 * TILE_WIDTH .okay @@ -516,12 +516,12 @@ BattleBGEffect_HeadFollow: call BattleBGEffects_IncrementJumptable push bc call BGEffect_CheckBattleTurn - jr nz, .player_turn_2 + jr nz, .player_side_2 hlcoord 12, 5 lb bc, 2, 7 jr .okay2 -.player_turn_2 +.player_side_2 hlcoord 2, 6 lb bc, 2, 6 .okay2 diff --git a/engine/battle_anims/helpers.asm b/engine/battle_anims/helpers.asm index 63177b1b1..4a7f2950c 100644 --- a/engine/battle_anims/helpers.asm +++ b/engine/battle_anims/helpers.asm @@ -100,7 +100,7 @@ GetBattleAnimOAMPointer: add hl, de ret -LoadBattleAnimObj: +LoadBattleAnimGFX: push hl ld l, a ld h, 0 -- cgit v1.2.3