ref: 849b53623b2ace56ef40b7bbdefe29a86e10162e
parent: a957bb154046427966d6e00de526adab13388938
author: YamaArashi <shadow962@live.com>
date: Sun Jul 12 12:24:03 EDT 2015
shake screen functions
--- a/engine/battle/animations.asm
+++ b/engine/battle/animations.asm
@@ -835,9 +835,9 @@
; if the subaninmation counter is between 8 and 11, shake the screen horizontally and vertically
.shakeScreen
ld b,1
- predef Func_48125 ; shake horizontally
+ predef PredefShakeScreenHorizontally ; shake horizontally
ld b,1
- predef_jump Func_480ff ; shake vertically
+ predef_jump PredefShakeScreenVertically ; shake vertically
FlashScreenEveryEightFrameBlocks: ; 78ff7 (1e:4ff7)
ld a,[W_SUBANIMCOUNTER]
@@ -1225,7 +1225,7 @@
ld b, $5
AnimationShakeScreenVertically: ; 79209 (1e:5209)
- predef_jump Func_480ff
+ predef_jump PredefShakeScreenVertically
AnimationShakeScreen: ; 7920e (1e:520e)
; Shakes the screen for a while. Used in Earthquake/Fissure/etc. animations.
@@ -1232,7 +1232,7 @@
ld b, $8
AnimationShakeScreenHorizontallyFast: ; 79210 (1e:5210)
- predef_jump Func_48125
+ predef_jump PredefShakeScreenHorizontally
AnimationWaterDropletsEverywhere: ; 79215 (1e:5215)
; Draws water droplets all over the screen and makes them
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -3958,7 +3958,7 @@
ld hl, KeptGoingAndCrashedText
call PrintText
ld b, $4
- predef Func_48125
+ predef PredefShakeScreenHorizontally
ld a, [H_WHOSETURN]
and a
jr nz, .enemyTurn
--- a/engine/predefs.asm
+++ b/engine/predefs.asm
@@ -85,10 +85,10 @@
dbw $03,GiveItem
add_predef ChangeBGPalColor0_4Frames
add_predef FindPathToPlayer
- add_predef Func_480ff
+ add_predef PredefShakeScreenVertically
add_predef CalcPositionOfPlayerRelativeToNPC
add_predef ConvertNPCMovementDirectionsToJoypadMasks
- add_predef Func_48125
+ add_predef PredefShakeScreenHorizontally
add_predef UpdateHPBar
add_predef HPBarLength
add_predef Diploma_TextBoxBorder
--- a/engine/predefs12.asm
+++ b/engine/predefs12.asm
@@ -4,7 +4,7 @@
ld a, [rBGP]
or b
ld [rBGP], a
- ld c, 4
+ ld c, $4
call DelayFrames
ld a, [rBGP]
and %11111100
@@ -11,55 +11,61 @@
ld [rBGP], a
ret
-Func_480ff: ; 480ff (12:40ff)
+PredefShakeScreenVertically: ; 480ff (12:40ff)
+; 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 [wd0a0], a
+ ld a, 1
+ ld [wDisableVBlankWYUpdate], a
xor a
-.asm_48108
- ld [H_NUMTOPRINT], a ; (aliases: H_MULTIPLICAND)
- call Func_48119
- call Func_48119
+.loop
+ ld [$ff96], a
+ call .MutateWY
+ call .MutateWY
dec b
ld a, b
- jr nz, .asm_48108
+ jr nz, .loop
xor a
- ld [wd0a0], a
+ ld [wDisableVBlankWYUpdate], a
ret
-Func_48119: ; 48119 (12:4119)
- ld a, [H_NUMTOPRINT] ; (aliases: H_MULTIPLICAND)
+.MutateWY ; 48119 (12:4119)
+ ld a, [$ff96]
xor b
- ld [H_NUMTOPRINT], a ; (aliases: H_MULTIPLICAND)
+ ld [$ff96], a
ld [rWY], a
ld c, 3
jp DelayFrames
-Func_48125: ; 48125 (12:4125)
+PredefShakeScreenHorizontally: ; 48125 (12:4125)
+; Moves the window right and then back in a sequence of progressively smaller
+; numbers of pixels, starting at b.
call GetPredefRegisters
xor a
-.asm_48129
+.loop
ld [$ff97], a
- call Func_4813f
+ call .MutateWX
ld c, 1
call DelayFrames
- call Func_4813f
+ call .MutateWX
dec b
ld a, b
- jr nz, .asm_48129
- ld a, $7
+ jr nz, .loop
+
+; restore normal WX
+ ld a, 7
ld [rWX], a
ret
-Func_4813f: ; 4813f (12:413f)
+.MutateWX ; 4813f (12:413f)
ld a, [$ff97]
xor b
ld [$ff97], a
bit 7, a
- jr z, .asm_48149
- xor a
-.asm_48149
- add $7
+ jr z, .skipZeroing
+ xor a ; zero a if it's negative
+.skipZeroing
+ add 7
ld [rWX], a
ld c, 4
jp DelayFrames
--- a/home/vblank.asm
+++ b/home/vblank.asm
@@ -13,7 +13,7 @@
ld a, [hSCY]
ld [rSCY], a
- ld a, [wd0a0]
+ ld a, [wDisableVBlankWYUpdate]
and a
jr nz, .ok
ld a, [hWY]
--- a/wram.asm
+++ b/wram.asm
@@ -1223,7 +1223,7 @@
wNewTileBlockID:: ; d09f
wd09f:: ds 1 ; used with predef ReplaceTileBlock
-wd0a0:: ds 1 ; used in VBlank and ChangeBGPalColor0_4Frames
+wDisableVBlankWYUpdate:: ds 1 ; if non-zero, don't update WY during V-blank
W_SPRITECURPOSX:: ; d0a1
ds 1