unit: units are now not displayed on top of the window area anymore
authorLukas Krickl <lukas@krickl.dev>
Sat, 21 Jun 2025 15:58:10 +0000 (17:58 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sat, 21 Jun 2025 15:58:10 +0000 (17:58 +0200)
src/hw.inc
src/ui.s
src/unit.s
src/video.s
tiles/bank8800.inc

index 513c4057a94e030ffad30ae19c96672528cb6cb8..3496da4ad9db40901fdcc8353155c0f85019cc15 100644 (file)
@@ -84,6 +84,7 @@
 .def int OBJSIZE = 4
 .def int OAMRAM_SIZE = OBJSMAX * OBJSIZE
 
+#define OAM_FPRIO 0b10000000
 #define OAM_FYFLIP 0b01000000
 #define OAM_FXFLIP 0b00100000
 #define OAM_DMG_PAL 0b00010000
index f72464ef2ca7c6ca3cf78126bc108ebd299b4de8..133da528b769d5676fd45102de11348ed0c7e9a0 100644 (file)
--- a/src/ui.s
+++ b/src/ui.s
@@ -2,6 +2,7 @@
 ; in top row for each move remaining
 #define UI_TILE_MOVE 0xC0  
 #define UI_TILE_MOVE_USED 0xC1  
+#define UI_WINDOW_BACKGROUND 0xC2  
 
   ; inits UI
 ui_init:
index a283f3990abe4b8380a6e6cd322757fc61bac5c4..4b2420e24e7a674de7ff715c1e41b5ca325bbc1d 100644 (file)
@@ -86,6 +86,10 @@ unit_draw:
   ;   b: tile
   ;   c: flags
 unit_generic_draw:
+#define TMP_OAMFLAG_PRIO scratch
+  xor a, a
+  ld [TMP_OAMFLAG_PRIO], a
+
   push bc
 
   ld hl, act_pos_y
@@ -103,7 +107,14 @@ unit_generic_draw:
   add a, OBJ_OFF_Y
   sub a, b
   ld [hl+], a
-  
+
+  ; if the position is inside the window set PRIO bit
+  cp a, 136 ; window start position in pixels
+  jr c, @not_on_window REL
+    ld a, OAM_FPRIO
+    ld [TMP_OAMFLAG_PRIO], a
+
+@not_on_window:
   ; set x pos
   inc de
   ld a, [de]
@@ -120,11 +131,13 @@ unit_generic_draw:
 
 
   ; set flags
-  ld a, c
+  ld a, [TMP_OAMFLAG_PRIO]
+  or a, c
   ld [hl+], a
 
   ldnull bc
   ret
+#undefine TMP_OAMFLAG_PRIO
 
   ; generic unit input handler
   ; inputs:
@@ -466,7 +479,6 @@ unit_sleep:
   ; inputs:
   ;   de: unit
 unit_delay_to_active:
-  call unit_resume_objs
   ldnull bc
   ret
 
index cf9b6d9ef2034442227bbea45f7ef683a93d92d3..2db9ea083ce944406d3ba789b21f3f488b02485d 100644 (file)
@@ -90,7 +90,7 @@ video_init:
 
   ld hl, SCRN1
   ld bc, 1024
-  ld d, EMPTY_TILE
+  ld d, UI_WINDOW_BACKGROUND
   call memset
   
   ; set up bgp
index 59cea83b522ad1fa68c0cf21ef14e6481e68b840..9c7c7871c519dcebbb6f8510db8364d819dffdc2 100644 (file)
 .chr 00300030
 .chr 00033300
 ; tile 66
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
-.chr 00000000
+.chr 22222222
+.chr 22222222
+.chr 22222222
+.chr 22222222
+.chr 22222222
+.chr 22222222
+.chr 22222222
+.chr 22222222
 ; tile 67
 .chr 00000000
 .chr 00000000