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
40
41
42
43
44
45
46
|
; vblank interrupt handler
VBlankHandler:
push af
push bc
push de
push hl
ldh a, [hBankROM]
push af
ld hl, wReentrancyFlag
bit IN_VBLANK, [hl]
jr nz, .done
set IN_VBLANK, [hl]
ld a, [wVBlankOAMCopyToggle]
or a
jr z, .no_oam_copy
call hDMAFunction ; DMA-copy $ca00-$ca9f to OAM memory
xor a
ld [wVBlankOAMCopyToggle], a
.no_oam_copy
; flush scaling/windowing parameters
ldh a, [hSCX]
ldh [rSCX], a
ldh a, [hSCY]
ldh [rSCY], a
ldh a, [hWX]
ldh [rWX], a
ldh a, [hWY]
ldh [rWY], a
; flush LCDC
ld a, [wLCDC]
ldh [rLCDC], a
ei
call wVBlankFunctionTrampoline
call FlushPalettesIfRequested
ld hl, wVBlankCounter
inc [hl]
ld hl, wReentrancyFlag
res IN_VBLANK, [hl]
.done
pop af
call BankswitchROM
pop hl
pop de
pop bc
pop af
reti
|