From 7efc3881cfdaa8683e4dd9642a3903d7069e9399 Mon Sep 17 00:00:00 2001 From: Forest Belton <65484+forestbelton@users.noreply.github.com> Date: Sun, 11 Jul 2021 22:26:16 -0400 Subject: [PATCH] Write pending column data --- src/main.s | 5 +++-- src/map.s | 28 ++++++++++++++++++++++++++-- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/main.s b/src/main.s index 8273a5d..198ec9b 100644 --- a/src/main.s +++ b/src/main.s @@ -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 diff --git a/src/map.s b/src/map.s index a340e63..8a675e3 100644 --- a/src/map.s +++ b/src/map.s @@ -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