From 5647ca687b92954dcf37a6ea6bfbc9a341c32de4 Mon Sep 17 00:00:00 2001 From: dannye <33dannye@gmail.com> Date: Wed, 4 Nov 2020 00:06:44 -0600 Subject: Sync with pokered --- engine/gfx/screen_effects.asm | 73 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 engine/gfx/screen_effects.asm (limited to 'engine/gfx/screen_effects.asm') diff --git a/engine/gfx/screen_effects.asm b/engine/gfx/screen_effects.asm new file mode 100644 index 00000000..973a951a --- /dev/null +++ b/engine/gfx/screen_effects.asm @@ -0,0 +1,73 @@ +; inverts the BGP for 4 (6 on CGB due to lag) frames +ChangeBGPalColor0_4Frames: + call GetPredefRegisters ; leftover of red/blue, has no use here + ldh a, [rBGP] + xor $ff + ldh [rBGP], a + call UpdateGBCPal_BGP + ld c, 4 + call DelayFrames + ldh a, [rBGP] + xor $ff + ldh [rBGP], a + call UpdateGBCPal_BGP + ret + +PredefShakeScreenVertically: +; Moves the window down and then back in a sequence of progressively smaller +; numbers of pixels, starting at b. + call GetPredefRegisters + ld a, 1 + ld [wDisableVBlankWYUpdate], a + xor a +.loop + ldh [hMutateWY], a + call .MutateWY + call .MutateWY + dec b + ld a, b + jr nz, .loop + xor a + ld [wDisableVBlankWYUpdate], a + ret + +.MutateWY + ldh a, [hMutateWY] + xor b + ldh [hMutateWY], a + ldh [rWY], a + ld c, 3 + jp DelayFrames + +PredefShakeScreenHorizontally: +; Moves the window right and then back in a sequence of progressively smaller +; numbers of pixels, starting at b. + call GetPredefRegisters + xor a +.loop + ldh [hMutateWX], a + call .MutateWX + ld c, 1 + call DelayFrames + call .MutateWX + dec b + ld a, b + jr nz, .loop + +; restore normal WX + ld a, 7 + ldh [rWX], a + ret + +.MutateWX + ldh a, [hMutateWX] + xor b + ldh [hMutateWX], a + bit 7, a + jr z, .skipZeroing + xor a ; zero a if it's negative +.skipZeroing + add 7 + ldh [rWX], a + ld c, 4 + jp DelayFrames -- cgit v1.3.1-sl0p