From 7d6befa1816110c5518292d4c7cb8841a355dc79 Mon Sep 17 00:00:00 2001 From: mid-kid Date: Sat, 16 Feb 2019 19:08:34 +0100 Subject: [PATCH] Fix issues in review --- constants/battle_anim_constants.asm | 4 ++-- engine/battle_anims/core.asm | 6 +++--- engine/battle_anims/helpers.asm | 3 ++- engine/gfx/sprites.asm | 22 +++++++++++----------- macros/legacy.asm | 3 +++ wram.asm | 2 +- 6 files changed, 22 insertions(+), 18 deletions(-) diff --git a/constants/battle_anim_constants.asm b/constants/battle_anim_constants.asm index 167bfd7e5..fcd512b97 100644 --- 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 @@ BATTLEANIM_BASE_TILE EQU 7 * 7 ; Maximum size of a pokemon picture 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 diff --git a/engine/battle_anims/core.asm b/engine/battle_anims/core.asm index 1a63b98e1..171816f38 100644 --- a/engine/battle_anims/core.asm +++ b/engine/battle_anims/core.asm @@ -89,7 +89,7 @@ BattleAnimOAMUpdate: 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 @@ BattleAnimOAMUpdate: 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 @@ InitBattleAnimBuffer: add hl, bc ld a, [hl] - and %10000000 + and PRIORITY ld [wBattleAnimTempOAMFlags], a xor a ld [wBattleAnimTempFrameOAMFlags], a diff --git a/engine/battle_anims/helpers.asm b/engine/battle_anims/helpers.asm index 127fe5412..64d43f032 100644 --- a/engine/battle_anims/helpers.asm +++ b/engine/battle_anims/helpers.asm @@ -37,7 +37,7 @@ GetBattleAnimFrame: 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 @@ GetBattleAnimFrame: ld hl, BATTLEANIMSTRUCT_DURATION add hl, bc ld [hl], a + ld hl, BATTLEANIMSTRUCT_FRAME add hl, bc dec [hl] diff --git a/engine/gfx/sprites.asm b/engine/gfx/sprites.asm index 76519eb62..79cd71671 100644 --- a/engine/gfx/sprites.asm +++ b/engine/gfx/sprites.asm @@ -315,8 +315,8 @@ UpdateAnimFrame: 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 @@ AddOrSubtractY: 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 @@ AddOrSubtractX: 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 @@ GetSpriteAnimFrame: 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 @@ GetSpriteAnimFrame: 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 diff --git a/macros/legacy.asm b/macros/legacy.asm index 8be6b3798..0aa4d5e4d 100644 --- a/macros/legacy.asm +++ b/macros/legacy.asm @@ -174,3 +174,6 @@ limited_interpret_data EQUS "text_dots" 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" diff --git a/wram.asm b/wram.asm index 4f37aa32f..7fa8363d7 100644 --- a/wram.asm +++ b/wram.asm @@ -263,7 +263,7 @@ wCurIcon:: db ; c3b6 wCurIconTile:: db wSpriteAnimAddrBackup:: wSpriteAnimIDBuffer:: -wCurSpriteAddSubFlags:: +wCurSpriteOAMFlags:: dw wCurAnimVTile:: db wCurAnimXCoord:: db