|
|
@ -61,8 +61,22 @@ start: |
|
|
|
ld [PENDING_ROW_PTR], a |
|
|
|
ld [PENDING_ROW_PTR + 1], a |
|
|
|
|
|
|
|
; TODO: remove once scrolling is implemented |
|
|
|
; scroll map with arrow keys |
|
|
|
call scroll_update |
|
|
|
|
|
|
|
; wait for vblank |
|
|
|
halt |
|
|
|
|
|
|
|
call Map_Update |
|
|
|
|
|
|
|
; ~160 cycles |
|
|
|
ld a, HIGH(_OAM) |
|
|
|
call DMA_Start |
|
|
|
|
|
|
|
jp .loop |
|
|
|
|
|
|
|
; TODO: remove once scrolling is implemented |
|
|
|
scroll_update: |
|
|
|
; scroll map with arrow keys |
|
|
|
ld a, [keys] |
|
|
|
and PADF_UP |
|
|
|
jr z, .down |
|
|
@ -76,7 +90,7 @@ start: |
|
|
|
ld hl, CURRENT_CAMERA_Y |
|
|
|
ld a, [hl] |
|
|
|
or a |
|
|
|
jr z, .vbl |
|
|
|
ret z |
|
|
|
|
|
|
|
.update_up: |
|
|
|
ld hl, rSCY |
|
|
@ -93,7 +107,7 @@ start: |
|
|
|
|
|
|
|
.update_up_map: |
|
|
|
call Map_Scroll |
|
|
|
jr .vbl |
|
|
|
ret |
|
|
|
|
|
|
|
.down: |
|
|
|
ld a, [keys] |
|
|
@ -110,7 +124,7 @@ start: |
|
|
|
ld a, [CURRENT_CAMERA_Y] |
|
|
|
add 18 |
|
|
|
cp b |
|
|
|
jr z, .vbl |
|
|
|
ret z |
|
|
|
|
|
|
|
.update_down: |
|
|
|
ld hl, rSCY |
|
|
@ -126,36 +140,73 @@ start: |
|
|
|
|
|
|
|
.update_down_map: |
|
|
|
call Map_Scroll |
|
|
|
jr .vbl |
|
|
|
ret |
|
|
|
|
|
|
|
.right: |
|
|
|
ld a, [keys] |
|
|
|
and PADF_RIGHT |
|
|
|
jr z, .left |
|
|
|
|
|
|
|
; don't scroll right if on last tile |
|
|
|
ld hl, rSCX |
|
|
|
ld a, [hl] |
|
|
|
and %111 |
|
|
|
jr nz, .update_right |
|
|
|
|
|
|
|
ld a, [CURRENT_MAP_WIDTH] |
|
|
|
ld b, a |
|
|
|
ld a, [CURRENT_CAMERA_X] |
|
|
|
inc a |
|
|
|
; add 18 |
|
|
|
cp b |
|
|
|
ret z |
|
|
|
|
|
|
|
.update_right: |
|
|
|
ld hl, rSCX |
|
|
|
inc [hl] |
|
|
|
|
|
|
|
ld a, [hl] |
|
|
|
and %111 |
|
|
|
jr nz, .update_right_map |
|
|
|
|
|
|
|
ld a, [CURRENT_CAMERA_X] |
|
|
|
inc a |
|
|
|
ld [CURRENT_CAMERA_X], a |
|
|
|
|
|
|
|
.update_right_map: |
|
|
|
call Map_Scroll |
|
|
|
ret |
|
|
|
|
|
|
|
.left: |
|
|
|
ld a, [keys] |
|
|
|
and PADF_LEFT |
|
|
|
jr z, .vbl |
|
|
|
ret z |
|
|
|
|
|
|
|
; don't scroll left if on last tile |
|
|
|
ld hl, rSCX |
|
|
|
dec [hl] |
|
|
|
ld a, [hl] |
|
|
|
and %111 |
|
|
|
cp %111 |
|
|
|
jr nz, .update_left |
|
|
|
|
|
|
|
call Map_Scroll |
|
|
|
; call Player_Update |
|
|
|
ld hl, CURRENT_CAMERA_X |
|
|
|
ld a, [hl] |
|
|
|
or a |
|
|
|
ret z |
|
|
|
|
|
|
|
; wait for vblank |
|
|
|
.vbl: |
|
|
|
halt |
|
|
|
.update_left: |
|
|
|
ld hl, rSCX |
|
|
|
dec [hl] |
|
|
|
|
|
|
|
call Map_Update |
|
|
|
ld a, [hl] |
|
|
|
and %111 |
|
|
|
cp %111 |
|
|
|
jr nz, .update_left_map |
|
|
|
|
|
|
|
; ~160 cycles |
|
|
|
ld a, HIGH(_OAM) |
|
|
|
call DMA_Start |
|
|
|
ld a, [CURRENT_CAMERA_X] |
|
|
|
dec a |
|
|
|
ld [CURRENT_CAMERA_X], a |
|
|
|
|
|
|
|
jp .loop |
|
|
|
.update_left_map: |
|
|
|
call Map_Scroll |
|
|
|
ret |