shithub: pokecrystal

Download patch

ref: 2746288030ff3bd4febc43c1c9fe8a203272b927
parent: 32833adef3694b3e599b41f8493a380e353939b0
author: mid-kid <esteve.varela@gmail.com>
date: Wed Nov 21 18:44:31 EST 2018

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...

--- a/constants/battle_anim_constants.asm
+++ b/constants/battle_anim_constants.asm
@@ -26,6 +26,9 @@
 	const BATTLEANIMSTRUCT_17
 BATTLEANIMSTRUCT_LENGTH EQU const_value
 
+; Start tile for battle animation graphics
+BATTLEANIM_BASE_TILE EQU 7 * 7  ; Maximum size of a pokemon picture
+
 ; BattleAnimObjects indexes (see data/battle_anims/objects.asm)
 	const_def
 	const ANIM_OBJ_00
@@ -804,6 +807,8 @@
 	const ANIM_GFX_ANGELS
 	const ANIM_GFX_WAVE
 	const ANIM_GFX_AEROBLAST
+	const ANIM_GFX_PLAYER
+	const ANIM_GFX_ENEMY
 
 ; battle_bg_effect struct members (see macros/wram.asm)
 	const_def
--- a/data/battle_anims/objects.asm
+++ b/data/battle_anims/objects.asm
@@ -202,7 +202,7 @@
 	battleanimobj RELATIVE_X | X_FLIP, $ff, BATTLEANIMFRAMESET_19, BATTLEANIMFUNC_4E, PAL_BATTLE_OB_BROWN, ANIM_GFX_ROCKS ; ANIM_OBJ_ROCK_SMASH
 	battleanimobj RELATIVE_X, $90, BATTLEANIMFRAMESET_73, BATTLEANIMFUNC_08, PAL_BATTLE_OB_RED, ANIM_GFX_FLOWER ; ANIM_OBJ_FLOWER
 	battleanimobj RELATIVE_X, $ff, BATTLEANIMFRAMESET_89, BATTLEANIMFUNC_4F, PAL_BATTLE_OB_RED, ANIM_GFX_MISC ; ANIM_OBJ_COTTON
-	battleanimobj ABSOLUTE_X, $00, BATTLEANIMFRAMESET_B5, BATTLEANIMFUNC_00, PAL_BATTLE_OB_ENEMY, $28 ; ANIM_OBJ_PLAYERFEETFOLLOW
-	battleanimobj ABSOLUTE_X, $00, BATTLEANIMFRAMESET_B6, BATTLEANIMFUNC_00, PAL_BATTLE_OB_PLAYER, $29 ; ANIM_OBJ_ENEMYFEETFOLLOW
-	battleanimobj ABSOLUTE_X, $00, BATTLEANIMFRAMESET_B7, BATTLEANIMFUNC_00, PAL_BATTLE_OB_ENEMY, $28 ; ANIM_OBJ_PLAYERHEADFOLLOW
-	battleanimobj ABSOLUTE_X, $00, BATTLEANIMFRAMESET_B8, BATTLEANIMFUNC_00, PAL_BATTLE_OB_PLAYER, $29 ; ANIM_OBJ_ENEMYHEADFOLLOW
+	battleanimobj ABSOLUTE_X, $00, BATTLEANIMFRAMESET_B5, BATTLEANIMFUNC_00, PAL_BATTLE_OB_ENEMY, ANIM_GFX_PLAYER ; ANIM_OBJ_PLAYERFEETFOLLOW
+	battleanimobj ABSOLUTE_X, $00, BATTLEANIMFRAMESET_B6, BATTLEANIMFUNC_00, PAL_BATTLE_OB_PLAYER, ANIM_GFX_ENEMY ; ANIM_OBJ_ENEMYFEETFOLLOW
+	battleanimobj ABSOLUTE_X, $00, BATTLEANIMFRAMESET_B7, BATTLEANIMFUNC_00, PAL_BATTLE_OB_ENEMY, ANIM_GFX_PLAYER ; ANIM_OBJ_PLAYERHEADFOLLOW
+	battleanimobj ABSOLUTE_X, $00, BATTLEANIMFRAMESET_B8, BATTLEANIMFUNC_00, PAL_BATTLE_OB_PLAYER, ANIM_GFX_ENEMY ; ANIM_OBJ_ENEMYHEADFOLLOW
--- a/engine/battle_anims/anim_commands.asm
+++ b/engine/battle_anims/anim_commands.asm
@@ -665,7 +665,7 @@
 	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 @@
 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 @@
 	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 @@
 	add hl, bc
 	pop af
 	dec a
-	jr nz, .LoadFootprint
+	jr nz, .LoadFeet
 	ret
 
 BattleAnimCmd_PlayerHeadObj:
@@ -832,25 +832,25 @@
 	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 @@
 	push af
 	push hl
 	push de
-	lb bc, BANK(BattleAnimCmd_EnemyFeetObj), 2
+	lb bc, BANK(@), 2
 	call Request2bpp
 	pop de
 	ld a, [wBattleAnimTemp0]
@@ -927,7 +927,7 @@
 
 	ld hl, vTiles2 tile $00
 	ld b, 0
-	ld c, $31
+	ld c, 7 * 7
 	call Request2bpp
 	ret
 
@@ -934,7 +934,7 @@
 .player
 	ld hl, vTiles2 tile $31
 	ld b, 0
-	ld c, $24
+	ld c, 6 * 6
 	call Request2bpp
 	ret
 
@@ -1028,7 +1028,7 @@
 
 GetMinimizePic:
 	ld hl, sScratch
-	ld bc, $31 tiles
+	ld bc, (7 * 7) tiles
 .loop
 	xor a
 	ld [hli], a
--- a/engine/battle_anims/core.asm
+++ b/engine/battle_anims/core.asm
@@ -147,7 +147,7 @@
 	inc hl
 	inc de
 	ld a, [wBattleAnimTempTileID]
-	add $31
+	add BATTLEANIM_BASE_TILE
 	add [hl]
 	ld [de], a
 	inc hl