diff options
author | ElectroDeoxys <ElectroDeoxys@gmail.com> | 2021-02-02 16:01:10 +0000 |
---|---|---|
committer | ElectroDeoxys <ElectroDeoxys@gmail.com> | 2021-02-02 16:01:10 +0000 |
commit | e8b079962bdee30fc5a36994ef928cdf47609898 (patch) | |
tree | 6e38acfcbf70da44a6fe330dbfded7ec9f065290 /src | |
parent | 3dd204220082d85ce5f1c92250f7240e3dc92944 (diff) |
Document screen animations
Diffstat (limited to 'src')
-rw-r--r-- | src/constants/animation_constants.asm | 7 | ||||
-rw-r--r-- | src/data/attack_animations.asm | 32 | ||||
-rw-r--r-- | src/engine/bank04.asm | 2 | ||||
-rw-r--r-- | src/engine/bank06.asm | 12 | ||||
-rw-r--r-- | src/engine/bank07.asm | 257 | ||||
-rw-r--r-- | src/wram.asm | 11 |
6 files changed, 191 insertions, 130 deletions
diff --git a/src/constants/animation_constants.asm b/src/constants/animation_constants.asm index 78988ca..75c82d8 100644 --- a/src/constants/animation_constants.asm +++ b/src/constants/animation_constants.asm @@ -113,6 +113,13 @@ const DUEL_ANIM_DUEL_DRAW ; $5f const DUEL_ANIM_96 ; $60 + const DUEL_ANIM_SMALL_SHAKE_X ; $61 + const DUEL_ANIM_BIG_SHAKE_X ; $62 + const DUEL_ANIM_SMALL_SHAKE_Y ; $63 + const DUEL_ANIM_BIG_SHAKE_Y ; $64 + const DUEL_ANIM_FLASH ; $65 + const DUEL_ANIM_DISTORT ; $66 + ; Special animations const_def $fa const DUEL_ANIM_SHAKE1 ; $fa diff --git a/src/data/attack_animations.asm b/src/data/attack_animations.asm index b8a3e77..8d11f68 100644 --- a/src/data/attack_animations.asm +++ b/src/data/attack_animations.asm @@ -200,7 +200,7 @@ AttackAnimation_Thunderbolt: AttackAnimation_BigLightning:
anim_player DUEL_ANIM_GLOW
- anim_normal $65
+ anim_normal DUEL_ANIM_FLASH
anim_normal DUEL_ANIM_BIG_LIGHTNING
anim_opponent DUEL_ANIM_HIT
anim_normal DUEL_ANIM_SHAKE1
@@ -461,7 +461,7 @@ AttackAnimation_544e: AttackAnimation_Goo:
anim_player DUEL_ANIM_GLOW
anim_opponent DUEL_ANIM_GOO
- anim_normal $66
+ anim_normal DUEL_ANIM_DISTORT
anim_opponent DUEL_ANIM_HIT
anim_normal DUEL_ANIM_SHAKE1
anim_opponent DUEL_ANIM_SHOW_DAMAGE
@@ -470,7 +470,7 @@ AttackAnimation_Goo: AttackAnimation_SpitPoisonFail:
anim_player DUEL_ANIM_GLOW
anim_opponent DUEL_ANIM_GOO
- anim_normal $66
+ anim_normal DUEL_ANIM_DISTORT
anim_end
AttackAnimation_Bubbles:
@@ -500,12 +500,12 @@ AttackAnimation_Boyfriends: AttackAnimation_Lure:
anim_player DUEL_ANIM_GLOW
anim_player DUEL_ANIM_LURE
- anim_normal $66
+ anim_normal DUEL_ANIM_DISTORT
anim_end
AttackAnimation_Toxic:
anim_player DUEL_ANIM_GLOW
- anim_normal $66
+ anim_normal DUEL_ANIM_DISTORT
anim_opponent DUEL_ANIM_TOXIC
anim_opponent DUEL_ANIM_HIT
anim_normal DUEL_ANIM_SHAKE1
@@ -514,7 +514,7 @@ AttackAnimation_Toxic: AttackAnimation_ConfuseRay:
anim_player DUEL_ANIM_GLOW
- anim_normal $65
+ anim_normal DUEL_ANIM_FLASH
anim_opponent DUEL_ANIM_CONFUSE_RAY
anim_opponent DUEL_ANIM_HIT
anim_normal DUEL_ANIM_SHAKE1
@@ -597,7 +597,7 @@ AttackAnimation_Selfdestruct: AttackAnimation_BigSelfdestruct:
anim_player DUEL_ANIM_GLOW
anim_player DUEL_ANIM_BIG_SELFDESTRUCT_1
- anim_normal $65
+ anim_normal DUEL_ANIM_FLASH
anim_player DUEL_ANIM_BIG_SELFDESTRUCT_2
anim_opponent DUEL_ANIM_HIT
anim_normal DUEL_ANIM_SHAKE1
@@ -627,18 +627,18 @@ AttackAnimation_DarkGas: AttackAnimation_GlowEffect:
anim_player DUEL_ANIM_GLOW
- anim_normal $65
+ anim_normal DUEL_ANIM_FLASH
anim_end
AttackAnimation_MirrorMove:
anim_player DUEL_ANIM_GLOW
- anim_normal $65
+ anim_normal DUEL_ANIM_FLASH
anim_opponent DUEL_ANIM_GLOW
anim_end
AttackAnimation_DevolutionBeam:
anim_player DUEL_ANIM_GLOW
- anim_normal $65
+ anim_normal DUEL_ANIM_FLASH
anim_unknown $04
anim_unknown2 DUEL_ANIM_70
anim_end
@@ -646,13 +646,13 @@ AttackAnimation_DevolutionBeam: AttackAnimation_5543:
anim_unknown $04
anim_unknown2 DUEL_ANIM_70
- anim_normal $65
+ anim_normal DUEL_ANIM_FLASH
anim_end
AttackAnimation_Firegiver:
anim_unknown $04
anim_unknown2 DUEL_ANIM_70
- anim_normal $65
+ anim_normal DUEL_ANIM_FLASH
anim_unknown2 DUEL_ANIM_71
anim_unknown2 DUEL_ANIM_71
anim_end
@@ -692,7 +692,7 @@ AttackAnimation_BigThunder: AttackAnimation_SolarPower:
anim_player DUEL_ANIM_GLOW
- anim_normal $65
+ anim_normal DUEL_ANIM_FLASH
anim_end
AttackAnimation_PoisonFang:
@@ -757,7 +757,7 @@ AttackAnimation_Hypnosis: AttackAnimation_EnergyConversion:
anim_player DUEL_ANIM_GLOW
- anim_normal $65
+ anim_normal DUEL_ANIM_FLASH
anim_end
AttackAnimation_Leer:
@@ -866,7 +866,7 @@ AttackAnimation_Gale: anim_opponent DUEL_ANIM_HIT
anim_normal DUEL_ANIM_SHAKE1
anim_opponent DUEL_ANIM_SHOW_DAMAGE
- anim_normal $65
+ anim_normal DUEL_ANIM_FLASH
anim_end
AttackAnimation_Expand:
@@ -895,7 +895,7 @@ AttackAnimation_5659: AttackAnimation_SpitPoisonSuccess:
anim_player DUEL_ANIM_GLOW
anim_opponent DUEL_ANIM_GOO
- anim_normal $66
+ anim_normal DUEL_ANIM_DISTORT
anim_end
AttackAnimation_GustOfWind:
diff --git a/src/engine/bank04.asm b/src/engine/bank04.asm index 13666ec..9178336 100644 --- a/src/engine/bank04.asm +++ b/src/engine/bank04.asm @@ -1415,7 +1415,7 @@ Func_129fa: ; 129fa (4:69fa) ret ; 0x12a13 -Func_12a13: ; 12a13 (4:6a13) +GetSpriteAnimCounter: ; 12a13 (4:6a13) ld a, [wWhichSprite] push hl push bc diff --git a/src/engine/bank06.asm b/src/engine/bank06.asm index 1eb85be..8fc7f28 100644 --- a/src/engine/bank06.asm +++ b/src/engine/bank06.asm @@ -1170,18 +1170,18 @@ Func_19014: ; 19014 (6:5014) jp Func_18f9c.asm_4fd4 .shake_1 - ld c, $61 - ld b, $63 + ld c, DUEL_ANIM_SMALL_SHAKE_X + ld b, DUEL_ANIM_SMALL_SHAKE_Y jr .asm_5067 .shake_2 - ld c, $62 - ld b, $64 + ld c, DUEL_ANIM_BIG_SHAKE_X + ld b, DUEL_ANIM_BIG_SHAKE_Y jr .asm_5067 .shake_3 - ld c, $63 - ld b, $61 + ld c, DUEL_ANIM_SMALL_SHAKE_Y + ld b, DUEL_ANIM_SMALL_SHAKE_X .asm_5067 ldh a, [hWhoseTurn] diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index d664eb8..0d562c0 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -576,7 +576,7 @@ Func_1c8bc: ; 1c8bc (7:48bc) ld [wDuelAnimBufferCurPos], a ld [wDuelAnimBufferSize], a ld [wd4b3], a - call Func_1ccbc + call DefaultScreenAnimationUpdate call Func_3ca0 pop bc pop hl @@ -946,36 +946,38 @@ Func_1cac5: ; 1cac5 (7:4ac5) cp $80 jr z, .asm_1cb11 ld hl, wAnimationQueue - ld c, $07 -.asm_1cadb + ld c, ANIMATION_QUEUE_LENGTH +.loop_queue push af push bc ld a, [hl] cp $ff - jr z, .asm_1caf4 + jr z, .next ld [wWhichSprite], a - farcall Func_12a13 + farcall GetSpriteAnimCounter cp $ff - jr nz, .asm_1caf4 + jr nz, .next farcall Func_129fa ld a, $ff ld [hl], a -.asm_1caf4 + +.next pop bc pop af and [hl] inc hl dec c - jr nz, .asm_1cadb + jr nz, .loop_queue + .asm_1cafb cp $ff - jr nz, .asm_1cb02 + jr nz, .skip_play_anims call PlayBufferedDuelAnimations -.asm_1cb02 +.skip_play_anims ret .asm_1cb03 - ld hl, wd4b9 + ld hl, wScreenAnimUpdatePtr ld a, [hli] ld h, [hl] ld l, a @@ -1003,7 +1005,7 @@ Func_1cb18: ; 1cb18 (7:4b18) ld [wd4c0], a ld a, [wd42a] cp $ff - call nz, $4cd4 + call nz, Func_1ccd4 ld hl, wAnimationQueue ld c, $07 .asm_1cb3b @@ -1037,7 +1039,7 @@ Func_1cb5e: ; 1cb5e (7:4b5e) cp $96 jp nc, Func_1ce03 cp $8c - jp nz, Func_1cc76 + jp nz, InitScreenAnimation jr .asm_1cb6a ; redundant .asm_1cb6a ld a, [wDuelAnimDamage + 1] @@ -1218,10 +1220,13 @@ Func_1cc66: ; 1cc66 (7:4c66) ret ; 0x1cc76 -Func_1cc76: ; 1cc76 (7:4c76) +; initializes a screen animation from wTempAnimation +; loads a function pointer for updating a frame +; and initializes the duration of the animation. +InitScreenAnimation: ; 1cc76 (7:4c76) ld a, [wAnimationsDisabled] or a - jr nz, .asm_1cc9e + jr nz, .skip ld a, [wTempAnimation] ld [wd42a], a sub $61 @@ -1232,39 +1237,50 @@ Func_1cc76: ; 1cc76 (7:4c76) ld hl, Data_1cc9f add hl, bc ld a, [hli] - ld [wd4b9], a + ld [wScreenAnimUpdatePtr], a ld c, a ld a, [hli] - ld [wd4b9 + 1], a + ld [wScreenAnimUpdatePtr + 1], a ld b, a ld a, [hl] - ld [wd4bb], a + ld [wScreenAnimDuration], a call CallBC -.asm_1cc9e +.skip ret ; 0x1cc9f -macro_1cc9f: MACRO - dw \1 - db \2 - db \3 +; for the following animations, these functions +; are run with the corresponding duration. +; this duration decides different effects, +; depending on which function runs +; and is decreased by one each time. +; when it is down to 0, the animation is done. + +screen_effect: MACRO + dw \1 ; function pointer + db \2 ; duration + db $00 ; padding ENDM Data_1cc9f: ; 1cc9f (7:4c9f) - macro_1cc9f Func_1cce4, $18, $00 - macro_1cc9f Func_1cce9, $20, $00 - macro_1cc9f Func_1cd10, $18, $00 - macro_1cc9f Func_1cd15, $20, $00 - macro_1cc9f Func_1cd76, $08, $00 - macro_1cc9f Func_1cdc3, $3f, $00 - -Func_1ccb7: ; 1ccb7 (7:4cb7) - ld a, [wd4bb] +; function pointer, duration + screen_effect ShakeScreenX_Small, 24 ; DUEL_ANIM_SMALL_SHAKE_X + screen_effect ShakeScreenX_Big, 32 ; DUEL_ANIM_BIG_SHAKE_X + screen_effect ShakeScreenY_Small, 24 ; DUEL_ANIM_SMALL_SHAKE_Y + screen_effect ShakeScreenY_Big, 32 ; DUEL_ANIM_BIG_SHAKE_Y + screen_effect WhiteFlashScreen, 8 ; DUEL_ANIM_FLASH + screen_effect DistortScreen, 63 ; DUEL_ANIM_DISTORT + +; checks if screen animation duration is over +; and if so, loads the default update function +LoadDefaultScreenAnimationUpdateWhenFinished: ; 1ccb7 (7:4cb7) + ld a, [wScreenAnimDuration] or a ret nz ; fallthrough -Func_1ccbc: ; 1ccbc (7:4cbc) +; function called for the screen animation update when it is over +DefaultScreenAnimationUpdate: ; 1ccbc (7:4cbc) ld a, $ff ld [wd42a], a call DisableInt_LYCoincidence @@ -1272,80 +1288,92 @@ Func_1ccbc: ; 1ccbc (7:4cbc) ldh [hSCX], a ldh [rSCX], a ldh [hSCY], a - ld hl, wd4b9 - ld [hl], LOW(Func_1ccbc) + ld hl, wScreenAnimUpdatePtr + ld [hl], LOW(DefaultScreenAnimationUpdate) inc hl - ld [hl], HIGH(Func_1ccbc) + ld [hl], HIGH(DefaultScreenAnimationUpdate) ret ; 0x1ccd4 - INCROM $1ccd4, $1cce4 +Func_1ccd4: ; 1ccd4 (7:4cd4) + ld a, 1 + ld [wScreenAnimDuration], a + ld hl, wScreenAnimUpdatePtr + ld a, [hli] + ld h, [hl] + ld l, a + call CallHL2 + jr DefaultScreenAnimationUpdate +; 0x1cce4 -Func_1cce4: ; 1cce4 (7:4ce4) - ld hl, Data_1cd55 - jr Func_1ccee +ShakeScreenX_Small: ; 1cce4 (7:4ce4) + ld hl, SmallShakeOffsets + jr ShakeScreenX -Func_1cce9: ; 1cce9 (7:4ce9) - ld hl, Data_1cd61 - jr Func_1ccee +ShakeScreenX_Big: ; 1cce9 (7:4ce9) + ld hl, BigShakeOffsets + jr ShakeScreenX -Func_1ccee: ; 1ccee (7:4cee) +ShakeScreenX: ; 1ccee (7:4cee) ld a, l ld [wd4bc], a ld a, h ld [wd4bc + 1], a - ld hl, wd4b9 - ld [hl], LOW(.asm_1ccff) + ld hl, wScreenAnimUpdatePtr + ld [hl], LOW(.update) inc hl - ld [hl], HIGH(.asm_1ccff) + ld [hl], HIGH(.update) ret -.asm_1ccff - call Func_1cd71 - call Func_1cd3c - jp nc, Func_1ccb7 +.update + call DecrementScreenAnimDuration + call UpdateShakeOffset + jp nc, LoadDefaultScreenAnimationUpdateWhenFinished ldh a, [hSCX] add [hl] ldh [hSCX], a - jp Func_1ccb7 + jp LoadDefaultScreenAnimationUpdateWhenFinished ; 0x1cd10 -Func_1cd10: ; 1cd10 (7:4d10) - ld hl, Data_1cd55 - jr Func_1cd1a +ShakeScreenY_Small: ; 1cd10 (7:4d10) + ld hl, SmallShakeOffsets + jr ShakeScreenY -Func_1cd15: ; 1cd15 (7:4d15) - ld hl, Data_1cd61 - jr Func_1cd1a +ShakeScreenY_Big: ; 1cd15 (7:4d15) + ld hl, BigShakeOffsets + jr ShakeScreenY -Func_1cd1a: ; 1cd1a (7:4d1a) +ShakeScreenY: ; 1cd1a (7:4d1a) ld a, l ld [wd4bc], a ld a, h ld [wd4bc + 1], a - ld hl, wd4b9 - ld [hl], LOW(.asm_1cd2b) + ld hl, wScreenAnimUpdatePtr + ld [hl], LOW(.update) inc hl - ld [hl], HIGH(.asm_1cd2b) + ld [hl], HIGH(.update) ret -.asm_1cd2b - call Func_1cd71 - call Func_1cd3c - jp nc, Func_1ccb7 +.update + call DecrementScreenAnimDuration + call UpdateShakeOffset + jp nc, LoadDefaultScreenAnimationUpdateWhenFinished ldh a, [hSCY] add [hl] ldh [hSCY], a - jp Func_1ccb7 + jp LoadDefaultScreenAnimationUpdateWhenFinished ; 0x1cd3c -Func_1cd3c: ; 1cd3c (7:4d3c) +; get the displacement of the current frame +; depending on the value of wScreenAnimDuration +; returns carry if displacement was updated +UpdateShakeOffset: ; 1cd3c (7:4d3c) ld hl, wd4bc ld a, [hli] ld h, [hl] ld l, a - ld a, [wd4bb] + ld a, [wScreenAnimDuration] cp [hl] ret nc inc hl @@ -1360,80 +1388,101 @@ Func_1cd3c: ; 1cd3c (7:4d3c) ret ; 0x1cd55 -Data_1cd55: ; 1cd55 (7:4d55) - db $15, $02, $11, $fe, $0d, $02, $09, $fe, $05, $01, $01, $ff - -Data_1cd61: ; 1cd61 (7:4d61) - db $1d, $04, $19, $fc, $15, $04, $11, $fc, $0d, $03, $09, $fd, $05, $02, $01, $fe - -Func_1cd71: ; 1cd71 (7:4d71) - ld hl, wd4bb +SmallShakeOffsets: ; 1cd55 (7:4d55) + db 21, 2 + db 17, -2 + db 13, 2 + db 9, -2 + db 5, 1 + db 1, -1 + +BigShakeOffsets: ; 1cd61 (7:4d61) + db 29, 4 + db 25, -4 + db 21, 4 + db 17, -4 + db 13, 3 + db 9, -3 + db 5, 2 + db 1, -2 + +DecrementScreenAnimDuration: ; 1cd71 (7:4d71) + ld hl, wScreenAnimDuration dec [hl] ret ; 0x1cd76 -Func_1cd76: ; 1cd76 (7:4d76) - ld hl, wd4b9 - ld [hl], $a3 +WhiteFlashScreen: ; 1cd76 (7:4d76) + ld hl, wScreenAnimUpdatePtr + ld [hl], LOW(.update) inc hl - ld [hl], $4d + ld [hl], HIGH(.update) ld a, [wBGP] ld [wd4bc], a + ; backup the current background pals ld hl, wBackgroundPalettesCGB - ld de, wd297 + ld de, wTempBackgroundPalettesCGB ld bc, 8 palettes call CopyDataHLtoDE_SaveRegisters - ld de, $7fff + ld de, $7fff ; rgb 31, 31, 31 ld hl, wBackgroundPalettesCGB - ld bc, $20 + ld bc, (8 palettes) / 2 call FillMemoryWithDE xor a call SetBGP call FlushAllPalettes - call Func_1cd71 - ld a, [wd4bb] + +.update + call DecrementScreenAnimDuration + ld a, [wScreenAnimDuration] or a ret nz - ld hl, wd297 + ; retreive the previous background pals + ld hl, wTempBackgroundPalettesCGB ld de, wBackgroundPalettesCGB ld bc, 8 palettes call CopyDataHLtoDE_SaveRegisters ld a, [wd4bc] call SetBGP call FlushAllPalettes - jp Func_1ccbc + jp DefaultScreenAnimationUpdate ; 0x1cdc3 -Func_1cdc3: ; 1cdc3 (7:4dc3) - ld hl, wd4b9 - ld [hl], $df +DistortScreen: ; 1cdc3 (7:4dc3) + ld hl, wScreenAnimUpdatePtr + ld [hl], LOW(.update) inc hl - ld [hl], $4d + ld [hl], HIGH(.update) xor a ld [wApplyBGScroll], a - ld hl, $cace - ld [hl], $a6 + ld hl, wLCDCFunctionTrampoline + 1 + ld [hl], LOW(ApplyBackgroundScroll) inc hl - ld [hl], $3e - ld a, $01 + ld [hl], HIGH(ApplyBackgroundScroll) + ld a, 1 ld [wBGScrollMod], a call EnableInt_LYCoincidence - ld a, [$d4bb] + +.update + ld a, [wScreenAnimDuration] srl a srl a srl a - and $07 + and %00000111 ld c, a ld b, $00 - ld hl, $4dfb + ld hl, .BGScrollModData add hl, bc ld a, [hl] ld [wBGScrollMod], a - call Func_1cd71 - jp Func_1ccb7 -; 0x1cdfb - - INCROM $1cdfb, $1ce03 + call DecrementScreenAnimDuration + jp LoadDefaultScreenAnimationUpdateWhenFinished + +; each value is applied for 8 "ticks" of wScreenAnimDuration +; starting from the last and running backwards +.BGScrollModData + db 4, 3, 2, 1, 1, 1, 1, 2 +; 0x1ce03 Func_1ce03: ; 1ce03 (7:4e03) cp $9e diff --git a/src/wram.asm b/src/wram.asm index 4fbe652..aa6d106 100644 --- a/src/wram.asm +++ b/src/wram.asm @@ -2147,7 +2147,9 @@ wd292:: ; d292 ds $4 -wd297:: ; d297 +; temporarily holds the palettes from +; wBackgroundPalettesCGB +wTempBackgroundPalettesCGB:: ; d297 ds 8 palettes ds $4c @@ -2426,10 +2428,13 @@ wd4b7:: ; d4b7 wd4b8:: ; d4b8 ds $1 -wd4b9:: ; d4b9 +; pointer to a function to update +; the current screen animation +wScreenAnimUpdatePtr:: ; d4b9 ds $2 -wd4bb:: ; d4bb +; duration of the current screen animation +wScreenAnimDuration:: ; d4bb ds $1 wd4bc:: ; d4bc |