shithub: pokecrystal

Download patch

ref: 7d6befa1816110c5518292d4c7cb8841a355dc79
parent: 80ece33e3e847563188782b76107256fba53088d
author: mid-kid <esteve.varela@gmail.com>
date: Sat Feb 16 14:08:34 EST 2019

Fix issues in review

--- a/constants/battle_anim_constants.asm
+++ b/constants/battle_anim_constants.asm
@@ -25,7 +25,7 @@
 	const BATTLEANIMSTRUCT_16
 	const BATTLEANIMSTRUCT_17
 BATTLEANIMSTRUCT_LENGTH EQU const_value
-NUM_ANIM_OBJECTS EQUS "(wActiveAnimObjectsEnd - wActiveAnimObjects) / BATTLEANIMSTRUCT_LENGTH"
+NUM_ANIM_OBJECTS EQU 10 ; see wActiveAnimObjects
 
 ; Start tile for battle animation graphics
 BATTLEANIM_BASE_TILE EQU 7 * 7  ; Maximum size of a pokemon picture
@@ -818,7 +818,7 @@
 	const BG_EFFECT_STRUCT_BATTLE_TURN
 	const BG_EFFECT_STRUCT_03
 BG_EFFECT_STRUCT_LENGTH EQU const_value
-NUM_BG_EFFECTS EQUS "(wActiveBGEffectsEnd - wActiveBGEffects) / BG_EFFECT_STRUCT_LENGTH"
+NUM_BG_EFFECTS EQU 5 ; see wActiveBGEffects
 
 ; battle palettes
 	const_def
--- a/engine/battle_anims/core.asm
+++ b/engine/battle_anims/core.asm
@@ -89,7 +89,7 @@
 	ld hl, wBattleAnimTempOAMFlags
 	ld a, [wBattleAnimTempFrameOAMFlags]
 	xor [hl]
-	and $e0 ; Keep priority, x flip and y flip flags.
+	and PRIORITY | Y_FLIP | X_FLIP
 	ld [hl], a
 	pop af
 
@@ -171,7 +171,7 @@
 	or b
 	ld b, a
 	ld a, [wBattleAnimTempPalette]
-	and $f
+	and (PRIORITY | Y_FLIP | X_FLIP | OBP_NUM) ^ $ff
 	or b
 	ld [de], a
 
@@ -203,7 +203,7 @@
 	add hl, bc
 	ld a, [hl]
 
-	and %10000000
+	and PRIORITY
 	ld [wBattleAnimTempOAMFlags], a
 	xor a
 	ld [wBattleAnimTempFrameOAMFlags], a
--- a/engine/battle_anims/helpers.asm
+++ b/engine/battle_anims/helpers.asm
@@ -37,7 +37,7 @@
 	push af
 	ld a, [hl]
 	push hl
-	and %00111111
+	and (Y_FLIP << 1 | X_FLIP << 1) ^ $ff
 	ld hl, BATTLEANIMSTRUCT_DURATION
 	add hl, bc
 	ld [hl], a
@@ -55,6 +55,7 @@
 	ld hl, BATTLEANIMSTRUCT_DURATION
 	add hl, bc
 	ld [hl], a
+
 	ld hl, BATTLEANIMSTRUCT_FRAME
 	add hl, bc
 	dec [hl]
--- a/engine/gfx/sprites.asm
+++ b/engine/gfx/sprites.asm
@@ -315,8 +315,8 @@
 AddOrSubtractY:
 	push hl
 	ld a, [hl]
-	ld hl, wCurSpriteAddSubFlags
-	bit 6, [hl]
+	ld hl, wCurSpriteOAMFlags
+	bit OAM_Y_FLIP, [hl]
 	jr z, .ok
 	; 8 - a
 	add $8
@@ -330,8 +330,8 @@
 AddOrSubtractX:
 	push hl
 	ld a, [hl]
-	ld hl, wCurSpriteAddSubFlags
-	bit 5, [hl] ; x flip
+	ld hl, wCurSpriteOAMFlags
+	bit OAM_X_FLIP, [hl]
 	jr z, .ok
 	; 8 - a
 	add $8
@@ -343,20 +343,20 @@
 	ret
 
 GetSpriteOAMAttr:
-	ld a, [wCurSpriteAddSubFlags]
+	ld a, [wCurSpriteOAMFlags]
 	ld b, a
 	ld a, [hl]
 	xor b
-	and $e0
+	and PRIORITY | Y_FLIP | X_FLIP
 	ld b, a
 	ld a, [hl]
-	and $1f
+	and (PRIORITY | Y_FLIP | X_FLIP) ^ $ff
 	or b
 	ret
 
 InitSpriteAnimBuffer:
 	xor a
-	ld [wCurSpriteAddSubFlags], a
+	ld [wCurSpriteOAMFlags], a
 	ld hl, SPRITEANIMSTRUCT_TILE_ID
 	add hl, bc
 	ld a, [hli]
@@ -436,7 +436,7 @@
 	push af
 	ld a, [hl]
 	push hl
-	and $3f
+	and (Y_FLIP << 1 | X_FLIP << 1) ^ $ff
 	ld hl, SPRITEANIMSTRUCT_DURATIONOFFSET
 	add hl, bc
 	add [hl]
@@ -446,9 +446,9 @@
 	pop hl
 .okay
 	ld a, [hl]
-	and $c0
+	and Y_FLIP << 1 | X_FLIP << 1 ; The << 1 is compensated in the "frame" macro
 	srl a
-	ld [wCurSpriteAddSubFlags], a
+	ld [wCurSpriteOAMFlags], a
 	pop af
 	ret
 
--- a/macros/legacy.asm
+++ b/macros/legacy.asm
@@ -174,3 +174,6 @@
 link_wait_button       EQUS "text_linkwaitbutton"
 current_day            EQUS "text_today"
 text_jump              EQUS "text_far"
+
+; macros/scripts/battle_anims.asm
+anim_clearsprites EQUS "anim_keepsprites"
--- a/wram.asm
+++ b/wram.asm
@@ -263,7 +263,7 @@
 wCurIconTile:: db
 wSpriteAnimAddrBackup::
 wSpriteAnimIDBuffer::
-wCurSpriteAddSubFlags::
+wCurSpriteOAMFlags::
 	dw
 wCurAnimVTile:: db
 wCurAnimXCoord:: db