summaryrefslogtreecommitdiff
path: root/home/lcd.asm
blob: dcf6bfa1845d50c4f076eaa022e8fa63457f2897 (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
SECTION "LCD functions", ROM0[$3AE]

LCD:: ; 03ae
    push af
    ldh a, [hLCDCPointer]
    and a
    jr z, .done
    push hl
    rla
    jr c, .try_hide_sprites
    ld a, [rLY]
    ld l, a
    ld h, HIGH(wLYOverrides)
    ld h, [hl]
    ldh a, [hLCDCPointer]
    ld l, a
    ld a, h
    ld h, $FF
    ld [hl], a
    pop hl
    pop af
    reti

.try_hide_sprites
    ld a, [rLY]
    cp $80
    jr nz, .dont_hide
    ld hl, rLCDC
    res 1, [hl]
.dont_hide
    pop hl
    pop af
    reti

    ; Seems unused?
    ldh a, [hSCX]
    ld [rSCX], a
    ldh a, [hSCY]
    ld [rSCY], a
    pop hl
.done
    pop af
    reti


; 0:3e1
    sine_table 16


DisableLCD:: ; 0401
    ld a, [rLY]
    bit 7, a
    ret z
    xor a
    ld [rIF], a
    ld a, [rIE]
    ld b, a
    res 0, a
    ld [rIE], a
.wait
    ld a, [rLY]
    cp LY_VBLANK
    jr nz, .wait
    ld a, [rLCDC]
    and $7F ; Shut LCD down
    ld [rLCDC], a
    xor a
    ld [rIF], a
    ld a, b
    ld [rIE], a
    ret

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