summaryrefslogtreecommitdiff
path: root/home/lcd.asm
blob: b488cbec9881c521f9054c7845c221facbfb4c33 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
LCD:: ; 41b (0:041b)
	push af
	ld a, [hLCDCPointer]
	and a
	jr z, .done
	push hl
	ld a, [rLY]
	ld l, a
	ld h, wLYOverrides >> 8
	ld h, [hl]
	ld a, [hLCDCPointer]
	ld l, a
	ld a, h
	ld h, rSCY >> 8
	ld [hl], a
	pop hl
.done
	pop af
	reti

DisableLCD::
; Turn the LCD off

; Don't need to do anything if the LCD is already off
	ld a, [rLCDC]
	bit 7, a
	ret z

	xor a
	ld [rIF], a
	ld a, [rIE]
	ld b, a

; Disable VBlank
	res 0, a
	ld [rIE], a

.wait
; Wait until VBlank would normally happen
	ld a, [rLY]
	cp 145
	jr nz, .wait

	ld a, [rLCDC]
	and %01111111
	ld [rLCDC], a

	xor a
	ld [rIF], a
	ld a, b
	ld [rIE], a
	ret

EnableLCD::
	ld a, [rLCDC]
	set 7, a
	ld [rLCDC], a
	ret