|
|
@ -30,8 +30,6 @@ SECTION "Map Code", ROM0 |
|
|
|
DEF INIT_SCX EQUS "((SCRN_VX - SCRN_X) / 2)" |
|
|
|
DEF INIT_SCY EQUS "((SCRN_VY - SCRN_Y) / 2)" |
|
|
|
|
|
|
|
DEF PAGE_SIZE EQU 2 |
|
|
|
|
|
|
|
DEF STACK_OFFSET_ROW EQU 3 |
|
|
|
DEF STACK_OFFSET_MAP EQU 1 |
|
|
|
DEF STACK_OFFSET_LEFT EQU 0 |
|
|
@ -180,21 +178,34 @@ Map_Scroll:: |
|
|
|
jr .done |
|
|
|
|
|
|
|
.scroll_down_check: |
|
|
|
; Check SCY + SCRN_Y = PAGEY |
|
|
|
; Check SCY + (SCRN_Y + 16) = PAGEY |
|
|
|
ld a, [PAGEY] |
|
|
|
sub SCRN_Y |
|
|
|
sub SCRN_Y + 16 |
|
|
|
ld hl, rSCY |
|
|
|
cp [hl] |
|
|
|
jr nz, .done |
|
|
|
|
|
|
|
ld a, [PAGEY] |
|
|
|
srl a |
|
|
|
srl a |
|
|
|
srl a |
|
|
|
dec a |
|
|
|
ld e, a |
|
|
|
call compute_vram_ptr |
|
|
|
|
|
|
|
; B = CAMERA_X - SCX/8 |
|
|
|
ld a, [rSCX] |
|
|
|
ld b, a |
|
|
|
ld a, [CURRENT_CAMERA_X] |
|
|
|
srl b |
|
|
|
srl b |
|
|
|
srl b |
|
|
|
sub b |
|
|
|
ld b, a |
|
|
|
|
|
|
|
ld a, [CURRENT_CAMERA_Y] |
|
|
|
add SCRN_X_B + 1 |
|
|
|
add SCRN_Y_B + 1 |
|
|
|
ld c, a |
|
|
|
|
|
|
|
call compute_vram_ptr |
|
|
|
call enqueue_row_write |
|
|
|
|
|
|
|
ld a, [PAGEY] |
|
|
@ -353,7 +364,7 @@ enqueue_row_write: |
|
|
|
xor a |
|
|
|
ld c, SCRN_VX_B |
|
|
|
.zero_row_loop: |
|
|
|
ld a, [hl+] |
|
|
|
ld [hl+], a |
|
|
|
dec c |
|
|
|
jr nz, .zero_row_loop |
|
|
|
ret |
|
|
@ -384,7 +395,7 @@ write_map_row: |
|
|
|
ld d, SCRN_VX_B |
|
|
|
xor a |
|
|
|
.zero_row_loop: |
|
|
|
ld a, [hl+] |
|
|
|
ld [hl+], a |
|
|
|
dec d |
|
|
|
jr nz, .zero_row_loop |
|
|
|
.zero_row_done: |
|
|
@ -403,7 +414,7 @@ write_map_row: |
|
|
|
ld hl, sp + STACK_OFFSET_LEFT |
|
|
|
ld [hl], SCRN_VX_B |
|
|
|
|
|
|
|
; HL = CURRENT_MAP_PTR + Y * CURRENT_MAP_HEIGHT |
|
|
|
; HL = CURRENT_MAP_PTR + Y * CURRENT_MAP_WIDTH |
|
|
|
ld a, [CURRENT_MAP_PTR] |
|
|
|
ld l, a |
|
|
|
ld a, [CURRENT_MAP_PTR + 1] |
|
|
@ -414,7 +425,7 @@ write_map_row: |
|
|
|
or a |
|
|
|
jr z, .compute_map_row_done |
|
|
|
|
|
|
|
ld a, [CURRENT_MAP_HEIGHT] |
|
|
|
ld a, [CURRENT_MAP_WIDTH] |
|
|
|
ADD16 HL |
|
|
|
dec c |
|
|
|
jr .compute_map_row |
|
|
|