You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
97 lines
1.5 KiB
97 lines
1.5 KiB
include "video.inc"
|
|
include "hardware.inc"
|
|
|
|
section "home/video.asm@vram", vram[$9800]
|
|
v_bgmap1:: ds $400
|
|
v_bgmap2:: ds $400
|
|
|
|
section "home/video.asm", rom0
|
|
|
|
lcd_vblank_wait::
|
|
ldh a, [r_ly]
|
|
cp r_ly_vblank
|
|
jr nz, lcd_vblank_wait
|
|
ret
|
|
|
|
lcd_blank_wait::
|
|
push af
|
|
.loop
|
|
ldh a, [r_stat]
|
|
and r_stat_mode
|
|
cp r_stat_mode_vblank + 1
|
|
jr nc, .loop
|
|
pop af
|
|
ret
|
|
|
|
lcd_disable::
|
|
call lcd_vblank_wait
|
|
|
|
ld hl, r_lcdc
|
|
res r_lcdc_on_f, [hl]
|
|
|
|
ld hl, r_ie
|
|
res r_int_vblank_f, [hl]
|
|
ret
|
|
|
|
lcd_enable::
|
|
ld hl, r_lcdc
|
|
set r_lcdc_on_f, [hl]
|
|
|
|
ld hl, r_if
|
|
res r_int_vblank_f, [hl]
|
|
|
|
ld hl, r_ie
|
|
set r_int_vblank_f, [hl]
|
|
ret
|
|
|
|
vram_clear::
|
|
xor a
|
|
ld hl, mmap_vram
|
|
ld bc, mmap_vram_end - mmap_vram
|
|
call memset
|
|
ld hl, mmap_oam
|
|
ld bc, mmap_oam_end - mmap_oam
|
|
jp memset
|
|
|
|
vram_clear_bgmap::
|
|
xor a
|
|
ld hl, v_bgmap1
|
|
ld bc, bgmap_width * bgmap_height
|
|
jp memset
|
|
|
|
; Set black/white palettes
|
|
pals_set_bw::
|
|
if def(ENABLE_CGB)
|
|
ldh a, [h_console]
|
|
cp console_cgb
|
|
jr c, .dmg
|
|
|
|
ld a, r_bcps_inc | 0 << r_bcps_pal_f | 0 << r_bcps_offs_f
|
|
ld c, LOW(r_bcps)
|
|
ldh [c], a
|
|
inc c
|
|
ld hl, .pal_bw
|
|
ld b, 8
|
|
.loop_pal_1
|
|
ld a, [hl+]
|
|
ldh [c], a
|
|
dec b
|
|
jr nz, .loop_pal_1
|
|
ret
|
|
endc
|
|
|
|
.dmg
|
|
ld a, $e4
|
|
ld hl, r_bgp
|
|
ld [hl+], a ; r_bgp
|
|
ld [hl+], a ; r_obp0
|
|
ld [hl+], a ; r_obp1
|
|
ret
|
|
|
|
if def(ENABLE_CGB)
|
|
.pal_bw
|
|
dw $7fff
|
|
dw $5294
|
|
dw $294a
|
|
dw $0000
|
|
endc
|
|
|