bg: fixed issue where the bg update queue would incorrectly process
authorLukas Krickl <lukas@krickl.dev>
Thu, 24 Apr 2025 16:10:04 +0000 (18:10 +0200)
committerLukas Krickl <lukas@krickl.dev>
Thu, 24 Apr 2025 16:10:04 +0000 (18:10 +0200)
every byte as a single update call

This caused out of bounds writes to seemingly random addresses.

src/cells.s
src/defs.s
src/update.s

index 0af0c3a2c932df96c3b56368e36e62422e3ae439..98676edf447b6ce60492d2303eadbf8fd0fcdda5 100644 (file)
@@ -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
   
index 4011df40caf60701bb66cc8a958ae6e0534e8f4a..3003e601f4b9f9c099d8a751ab26b2822911b38a 100644 (file)
 .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 
index 422383af2b7f80812fc44156bae7c0e4d68dac53..5919b310df7070389ae173a9035a6a9ca6d68c57 100644 (file)
@@ -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