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.
 
 
 
 

103 lines
1.3 KiB

INCLUDE "hardware.inc"
INCLUDE "input.inc"
SECTION "Header", ROM0[$100]
_entry:
di
jp start
rept $150 - _entry
db 0
endr
SECTION "Frame", WRAM0
frame:: db
SECTION "VBlank", ROM0[$40]
handle_vblank:
reti
SECTION "Code", ROM0
start:
ld hl, rLCDC
res 7, [hl]
res 2, [hl]
ld hl, rIE
ld [hl], IEF_VBLANK
call OAM_Init
; call Keys_Init
; call Player_Init
ld hl, intro_Data
call Map_Load
; set palette
ld a, %11100100
ld hl, rOBP0
ld [hl], a
ld hl, rBGP
ld [hl], a
; enable lcd, sprites and interrupts
ld hl, rLCDC
set 7, [hl]
set 1, [hl]
ei
.loop:
ld hl, frame
inc [hl]
call Keys_Update
; TODO: remove once scrolling is implemented
; scroll map with arrow keys
ld a, [keys]
and BTN_UP
jr z, .down
ld hl, rSCY
dec [hl]
.down:
ld a, [keys]
and BTN_DOWN
jr z, .right
ld hl, rSCY
inc [hl]
.right:
ld a, [keys]
and BTN_RIGHT
jr z, .left
ld hl, rSCX
inc [hl]
.left:
ld a, [keys]
and BTN_LEFT
jr z, .vbl
ld hl, rSCX
dec [hl]
call Map_Scroll
; call Player_Update
; wait for vblank
.vbl:
halt
; ~160 cycles
ld a, HIGH(_OAM)
call DMA_Start
jp .loop