Browse Source

Write pending column data

master
Forest Belton 2 years ago
parent
commit
7efc3881cf
2 changed files with 29 additions and 4 deletions
  1. +3
    -2
      src/main.s
  2. +26
    -2
      src/map.s

+ 3
- 2
src/main.s View File

@ -56,10 +56,12 @@ start:
call Keys_Update
; Clear pending row state
; Clear pending map state
xor a
ld [PENDING_ROW_PTR], a
ld [PENDING_ROW_PTR + 1], a
ld [PENDING_COL_PTR], a
ld [PENDING_COL_PTR + 1], a
call scroll_update
@ -186,7 +188,6 @@ scroll_update:
ld hl, rSCX
ld a, [hl]
and %111
cp %111
jr nz, .update_left
ld hl, CURRENT_CAMERA_X

+ 26
- 2
src/map.s View File

@ -12,6 +12,9 @@ LAST_SCY:: DB ; Value of SCY last frame
PENDING_ROW_PTR:: DW ; Where to write pending row data (0 = no write)
PENDING_ROW_DATA:: DS SCRN_VX_B ; Row to be written
PENDING_COL_PTR:: DW ; Where to write pending column data (0 = no write)
PENDING_COL_DATA: DS SCRN_VY_B ; Column to be written
CURRENT_DATA_START::
CURRENT_TILE_PTR:: DW ; Location of tile data
CURRENT_TILE_SIZE:: DB ; Length of tile data (num_tiles * 8)
@ -204,18 +207,39 @@ Map_Scroll::
ret
Map_Update::
; Skip update if PENDING_ROW_PTR is 0
; Skip row update if PENDING_ROW_PTR is 0
ld a, [PENDING_ROW_PTR]
ld c, a
ld a, [PENDING_ROW_PTR + 1]
ld b, a
or c
ret z
jr z, .update_col
ld hl, PENDING_ROW_DATA
ld d, SCRN_VX_B
MEMCPY bc, hl, d
.update_col:
; Skip update if PENDING_COL_PTR is 0
ld a, [PENDING_COL_PTR]
ld c, a
ld a, [PENDING_COL_PTR + 1]
ld b, a
or c
ret z
ld d, SCRN_VX_B
ld hl, PENDING_COL_DATA
.update_col_loop:
ld a, [hl+]
ld [bc], a
ld a, SCRN_VX_B
ADD16 bc
dec d
jr nz, .update_col_loop
ret
; Computes the offset into map RAM

Loading…
Cancel
Save