From: Lukas Krickl Date: Sat, 21 Jun 2025 15:58:10 +0000 (+0200) Subject: unit: units are now not displayed on top of the window area anymore X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=abd6e61b0ef1b8564c1340138598da0db58d806b;p=gbrg%2F.git unit: units are now not displayed on top of the window area anymore --- diff --git a/src/hw.inc b/src/hw.inc index 513c405..3496da4 100644 --- a/src/hw.inc +++ b/src/hw.inc @@ -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 diff --git a/src/ui.s b/src/ui.s index f72464e..133da52 100644 --- 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: diff --git a/src/unit.s b/src/unit.s index a283f39..4b2420e 100644 --- a/src/unit.s +++ b/src/unit.s @@ -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 diff --git a/src/video.s b/src/video.s index cf9b6d9..2db9ea0 100644 --- a/src/video.s +++ b/src/video.s @@ -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 diff --git a/tiles/bank8800.inc b/tiles/bank8800.inc index 59cea83..9c7c787 100644 --- a/tiles/bank8800.inc +++ b/tiles/bank8800.inc @@ -593,14 +593,14 @@ .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