summaryrefslogtreecommitdiff
path: root/src/engine/gfx/sprite_vblank.asm
blob: 5f099a1376fa45838d156e42bef26063fee976a6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
; empties screen and replaces
; wVBlankFunctionTrampoline with HandleAllSpriteAnimations
SetSpriteAnimationsAsVBlankFunction:
	call EmptyScreen
	call Set_OBJ_8x8
	call Func_3ca4
	lb de, $38, $7f
	call SetupText
	ld hl, wVBlankFunctionTrampoline + 1
	ld de, wVBlankFunctionTrampolineBackup
	call BackupVBlankFunctionTrampoline
	di
	ld [hl], LOW(HandleAllSpriteAnimations)
	inc hl
	ld [hl], HIGH(HandleAllSpriteAnimations)
	ei
	ret

; sets backup VBlank function as wVBlankFunctionTrampoline
RestoreVBlankFunction:
	ld hl, wVBlankFunctionTrampolineBackup
	ld de, wVBlankFunctionTrampoline + 1
	call BackupVBlankFunctionTrampoline
	call Func_3ca4
	bank1call ZeroObjectPositionsAndToggleOAMCopy
	ret

; copies 2 bytes from hl to de while interrupts are disabled
; used to load or store wVBlankFunctionTrampoline
; to wVBlankFunctionTrampolineBackup
BackupVBlankFunctionTrampoline:
	di
	ld a, [hli]
	ld [de], a
	inc de
	ld a, [hld]
	ld [de], a
	ei
	ret