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.
 
 
 
 

69 lines
1.0 KiB

INCLUDE "hardware.inc"
INCLUDE "util.inc"
INCLUDE "png/map/intro.inc"
SECTION "BG Data", WRAM0
BG_COLLISION_DATA:: dw
BG_MAP_WIDTH:: db
BG_MAP_HEIGHT:: db
BG_SCROLLING:: db
SECTION "BG Code", ROM0
MACRO update_map_info
ld hl, BG_COLLISION_DATA
ld a, HIGH(\1)
ld [hl+], a
ld a, LOW(\1)
ld [hl+], a
ld a, \2
ld [hl+], a
ld a, \3
ld [hl+], a
ENDM
BG_Init::
SET8 BG_SCROLLING, 0
; copy map
ld e, intro_HEIGHT
ld bc, _SCRN0
ld hl, intro_MAP
.copy_map_row:
ld d, intro_WIDTH
call memcpy
dec e
jr z, .done
; nothing to skip if map is max width
ld a, 32 - intro_WIDTH
or a
jr z, .copy_map_row
ld d, a
.skip:
; skip over trailing part in vram
inc c
jr nz, .nocarry
inc b
.nocarry:
dec d
jr nz, .skip
jr .copy_map_row
.done:
; copy tiles
ld hl, intro_TILES
ld bc, _VRAM
ld d, intro_NUM_TILES
call memcpy
update_map_info intro_COLLISION, intro_WIDTH, intro_HEIGHT
ret
BG_Update::
ret