From: Lukas Krickl Date: Thu, 24 Apr 2025 16:10:04 +0000 (+0200) Subject: bg: fixed issue where the bg update queue would incorrectly process X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=51aba2b743069c00a680dd654a8e316aadc11057;p=gbrg%2F.git bg: fixed issue where the bg update queue would incorrectly process every byte as a single update call This caused out of bounds writes to seemingly random addresses. --- diff --git a/src/cells.s b/src/cells.s index 0af0c3a..98676ed 100644 --- a/src/cells.s +++ b/src/cells.s @@ -74,9 +74,6 @@ cell_road_init: push bc pop hl ; hl = ptr to tile ld a, BUILDING_ROAD_NORTH_SOUTH - - assert nc, h, 0x80 - assert c, h, 0xA0 call bg_update_queue_push diff --git a/src/defs.s b/src/defs.s index 4011df4..3003e60 100644 --- a/src/defs.s +++ b/src/defs.s @@ -129,7 +129,7 @@ .de BT_FARM, 1 .de BT_LUMBER, 1 -#define BGE_MAX 32 +#define BGE_MAX 64 ; max bg updates per frame #define BG_UPDATE_MAX 8 diff --git a/src/update.s b/src/update.s index 422383a..5919b31 100644 --- a/src/update.s +++ b/src/update.s @@ -35,8 +35,6 @@ update: ; it processess all tile updates ; until the bg_update_index is 0 bg_update_queue_process: - ld hl, bg_update_index - ; read index ld a, [bg_update_index] ld e, a @@ -53,6 +51,9 @@ bg_update_queue_process: @loop: push af ; index-- + ; sub length of an entry + dec de + dec de dec de ; write to vram