summaryrefslogtreecommitdiff
path: root/home/lcd.asm
diff options
context:
space:
mode:
Diffstat (limited to 'home/lcd.asm')
-rw-r--r--home/lcd.asm51
1 files changed, 28 insertions, 23 deletions
diff --git a/home/lcd.asm b/home/lcd.asm
index b488cbec..4ab79019 100644
--- a/home/lcd.asm
+++ b/home/lcd.asm
@@ -1,19 +1,24 @@
-LCD:: ; 41b (0:041b)
+; LCD handling
+
+LCD::
push af
- ld a, [hLCDCPointer]
+ ldh a, [hLCDCPointer]
and a
jr z, .done
+
+; At this point it's assumed we're in WRAM bank 5!
push hl
- ld a, [rLY]
+ ldh a, [rLY]
ld l, a
- ld h, wLYOverrides >> 8
+ ld h, HIGH(wLYOverrides)
ld h, [hl]
- ld a, [hLCDCPointer]
+ ldh a, [hLCDCPointer]
ld l, a
ld a, h
- ld h, rSCY >> 8
+ ld h, HIGH(rSCY)
ld [hl], a
pop hl
+
.done
pop af
reti
@@ -22,37 +27,37 @@ DisableLCD::
; Turn the LCD off
; Don't need to do anything if the LCD is already off
- ld a, [rLCDC]
- bit 7, a
+ ldh a, [rLCDC]
+ bit rLCDC_ENABLE, a
ret z
xor a
- ld [rIF], a
- ld a, [rIE]
+ ldh [rIF], a
+ ldh a, [rIE]
ld b, a
; Disable VBlank
- res 0, a
- ld [rIE], a
+ res VBLANK, a
+ ldh [rIE], a
.wait
; Wait until VBlank would normally happen
- ld a, [rLY]
- cp 145
+ ldh a, [rLY]
+ cp LY_VBLANK + 1
jr nz, .wait
- ld a, [rLCDC]
- and %01111111
- ld [rLCDC], a
+ ldh a, [rLCDC]
+ and $ff ^ (1 << rLCDC_ENABLE)
+ ldh [rLCDC], a
xor a
- ld [rIF], a
+ ldh [rIF], a
ld a, b
- ld [rIE], a
+ ldh [rIE], a
ret
EnableLCD::
- ld a, [rLCDC]
- set 7, a
- ld [rLCDC], a
- ret
+ ldh a, [rLCDC]
+ set rLCDC_ENABLE, a
+ ldh [rLCDC], a
+ ret \ No newline at end of file