From: Lukas Krickl Date: Tue, 1 Jul 2025 14:33:04 +0000 (+0200) Subject: actor: unit_generic_draw now draws 2 objects per actor X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=6981a013f9c1cbf019aad430c5a480e5d7852515;p=gbrg%2F.git actor: unit_generic_draw now draws 2 objects per actor --- diff --git a/src/defs.s b/src/defs.s index 807ac3a..af6561e 100644 --- a/src/defs.s +++ b/src/defs.s @@ -204,6 +204,16 @@ ; returns: ; bc: null .de act_draw, 2 + + ; act_oam_tile + flags + ; if using generic draw: + ; 2 tiles are used + ; tile 1 is the tile specified here + ; tile 2 is the tile following tile 1 + ; flags are used for both tiles + ; optional: + ; tile + flags may be a pointer to a + ; tile table. This can be implemented as needed .de act_oam_tile, 1 .de act_oam_flags, 1 diff --git a/src/unit.s b/src/unit.s index bb11525..21f1f0b 100644 --- a/src/unit.s +++ b/src/unit.s @@ -75,8 +75,19 @@ unit_draw: ld b, a ; tile ld a, [hl] ld c, a ; flags + ld a, 0 ; no x-offset + push bc call unit_generic_draw + + ; draw same tile again + pop bc pop de + push de + inc b ; b++ + ld a, 8 ; 8 x-offset + call unit_generic_draw + pop de + ldnull bc ret @@ -145,10 +156,14 @@ unit_generic_draw_adjust_subtile: ; draws any unit ; inputs: ; de: actor - ; b: tile + ; a: x-offset for tiles + ; b: tile1 ; c: flags unit_generic_draw: #define TMP_OAMFLAG_PRIO scratch +#define TMP_X_OFFSET scratch+1 + ld [TMP_X_OFFSET], a ; save for later + push de ; save actor xor a, a @@ -185,6 +200,9 @@ unit_generic_draw: mul16 a add a, OBJ_OFF_X sub a, c + ld c, a + ld a, [TMP_X_OFFSET] + add a, c ld [hl+], a pop bc ; bc = inputs again @@ -208,6 +226,7 @@ unit_generic_draw: ldnull bc ret #undefine TMP_OAMFLAG_PRIO +#undefine TMP_X_OFFSET ; generic unit input handler ; inputs: