ui: moved bg update to video.s
authorLukas Krickl <lukas@krickl.dev>
Wed, 9 Jul 2025 03:43:55 +0000 (05:43 +0200)
committerLukas Krickl <lukas@krickl.dev>
Wed, 9 Jul 2025 03:43:55 +0000 (05:43 +0200)
src/defs.s
src/ui.s
src/update.s
src/video.s

index bcb70d178f438f94093d1cbf963d342bc57e021e..b062c463ca6b924c369f39b01b41a7fb9955e4f3 100644 (file)
 
   ; draw flags
 .se 1
-.de DRAWF_UPDATE_UI, 1
   ; if set to 1, return 
   ; an invalid object from soam 
   ; when units want to draw
-.de DRAWF_SKIP_UNIT_OBJS, 2
+.de DRAWF_SKIP_UNIT_OBJS, 1
 
   ; gameplay flags
 .se 1
index 38a187d06c720fbf9c7d46edef9d4050150a4dc1..d4582e63158103ce86ff4ee98a016436d81cd64c 100644 (file)
--- a/src/ui.s
+++ b/src/ui.s
@@ -8,46 +8,10 @@
 
   ; inits UI
 ui_init:
+  call ui_redraw_hp
   ret
 
-  ; schedules a unit draw
-  ; sets draw flag for UI 
-  ; and sets current unit as ui_draw_actor
-  ; inputs:
-  ;   de: unit
-ui_unit_need_draw:
-  ld a, [draw_flags]
-  or a, DRAWF_UPDATE_UI
-  ld [draw_flags], a
-  
-  ; store actor 
-  ld hl, ui_draw_actor
-  ld a, e
-  ld [hl+], a
-  ld a, d
-  ld [hl], a
-
-  ret
-
-  ; displays the current unit
-ui_display_current_unit:
-  ld a, [ui_draw_actor]
-  ld e, a
-  ld a, [ui_draw_actor+1]
-  ld d, a
-  
-  ld b, CURSOR_TILE
-  ld c, 0
-  call unit_generic_draw
-
-  ret
-
-  ; update the UI 
-  ; this should only be called 
-  ; during blanking 
-ui_draw:
-  ld a, [draw_flags]
-  xor a, DRAWF_UPDATE_UI
-  ld [draw_flags], a
   
+  ; updates HP UI
+ui_redraw_hp:
   ret
index 08290a1501a8f2d49ce5e2582d608ff57aef4500..e69854c6424ac1d882bcd8665e4497651bfb5c21 100644 (file)
@@ -35,107 +35,4 @@ update:
   ld de, game_mode
   jp st_update
 
-  
-
-  ; bg update queue 
-  ; this is called once during blank
-  ; it processess all tile updates 
-  ; until the bg_update_index is 0 
-bg_update_queue_process:
-  ; read index
-  ld a, [bg_update_index]
-  ld e, a
-  ld a, [bg_update_index+1]
-  ld d, a
-  
-
-  ; skip if index is already 0
-  ld a, d
-  xor a, e
-  jp z, @done 
-
-  ld a, BG_UPDATE_MAX
-@loop:
-    push af
-    ; index--
-    ; sub length of an entry
-    dec de
-    dec de 
-    dec de
-
-    ; write to vram
-    ld hl, bg_update_queue 
-    add hl, de ; hl = next index to process
-
-    ld a, [hl+]
-    ld c, a
-    ld a, [hl+]
-    ld b, a
-    ; bc = vram address
-    
-    ld a, [hl]
-    ld [bc], a
-
-
-    ; a--
-    pop af 
-    dec a
-    
-    ld b, a ; save a for after 
-    cp a, 0
-    jr z, @done REL
-
-    ld a, d
-    xor a, e
-    jr z, @done REL
-
-    ld a, b ; restore a
-    jr @loop REL 
-  
 
-@done:
-  ; write index
-  ld a, e
-  ld [bg_update_index], a
-  ld a, d
-  ld [bg_update_index+1], a
-
-  ret
-
-
-
-  ; pushes a new bg update to the queue
-  ; inputs:
-  ;   hl: ptr to tile 
-  ;    a: tile data
-bg_update_queue_push:
-  push hl
-  pop bc ; move hl to bc
-  push af
-  ld hl, bg_update_queue
-  ld a, [bg_update_index]
-  ld e, a
-  ld a, [bg_update_index+1]
-  ld d, a
-  add hl, de ; hl = update queue + current offset 
-
-  inc de ; offset += bgu_size 
-  inc de 
-  inc de
-
-  ld a, e
-  ld [bg_update_index], a
-  ld a, d
-  ld [bg_update_index+1], a
-  
-  ; store ptr
-  ld a, c
-  ld [hl+], a
-  ld a, b
-  ld [hl+], a
-  
-  ; store new tile 
-  pop af
-  ld [hl], a
-
-  ret
index 7b5fa9d6b2fbc565807861acd2d53328a2d40750..4b2cc10c4a4de4d8ccb754e10a49f8ff506062de 100644 (file)
@@ -13,11 +13,6 @@ vblank:
   call scroll_write
   call bg_update_queue_process
 
-  ; update some tiles asap!
-  ld a, [draw_flags]
-  and a, DRAWF_UPDATE_UI
-  call nz, ui_draw
-
   ; cycle bg tiles for animations
   ld a, [frame_count]
   and a, BG_CYCLE_FRAMES
@@ -216,3 +211,109 @@ tiles_load_bank9000:
   ld hl, VRAM9000 
   ld bc, bank9000_end - bank9000 
   jp memcpy
+
+  
+
+  ; bg update queue 
+  ; this is called once during blank
+  ; it processess all tile updates 
+  ; until the bg_update_index is 0 
+bg_update_queue_process:
+  ; read index
+  ld a, [bg_update_index]
+  ld e, a
+  ld a, [bg_update_index+1]
+  ld d, a
+  
+
+  ; skip if index is already 0
+  ld a, d
+  xor a, e
+  jp z, @done 
+
+  ld a, BG_UPDATE_MAX
+@loop:
+    push af
+    ; index--
+    ; sub length of an entry
+    dec de
+    dec de 
+    dec de
+
+    ; write to vram
+    ld hl, bg_update_queue 
+    add hl, de ; hl = next index to process
+
+    ld a, [hl+]
+    ld c, a
+    ld a, [hl+]
+    ld b, a
+    ; bc = vram address
+    
+    ld a, [hl]
+    ld [bc], a
+
+
+    ; a--
+    pop af 
+    dec a
+    
+    ld b, a ; save a for after 
+    cp a, 0
+    jr z, @done REL
+
+    ld a, d
+    xor a, e
+    jr z, @done REL
+
+    ld a, b ; restore a
+    jr @loop REL 
+  
+
+@done:
+  ; write index
+  ld a, e
+  ld [bg_update_index], a
+  ld a, d
+  ld [bg_update_index+1], a
+
+  ret
+
+
+
+
+  ; pushes a new bg update to the queue
+  ; inputs:
+  ;   hl: ptr to tile 
+  ;    a: tile data
+bg_update_queue_push:
+  push hl
+  pop bc ; move hl to bc
+  push af
+  ld hl, bg_update_queue
+  ld a, [bg_update_index]
+  ld e, a
+  ld a, [bg_update_index+1]
+  ld d, a
+  add hl, de ; hl = update queue + current offset 
+
+  inc de ; offset += bgu_size 
+  inc de 
+  inc de
+
+  ld a, e
+  ld [bg_update_index], a
+  ld a, d
+  ld [bg_update_index+1], a
+  
+  ; store ptr
+  ld a, c
+  ld [hl+], a
+  ld a, b
+  ld [hl+], a
+  
+  ; store new tile 
+  pop af
+  ld [hl], a
+
+  ret