From: Lukas Krickl Date: Sat, 9 Aug 2025 03:44:38 +0000 (+0200) Subject: unit: moved tile to screen to a macro X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=00db562d7ff2a858d3230688a1ea6def7f8ee06b;p=gbrg%2F.git unit: moved tile to screen to a macro --- diff --git a/src/objanim.s b/src/objanim.s index ae697f3..076666b 100644 --- a/src/objanim.s +++ b/src/objanim.s @@ -68,15 +68,11 @@ objanim_door_open_fn: inc de ; skip flags ld a, [de] ; a = y position inc de ; de = x postion - mul16 a - add a, OBJ_OFF_Y - sub a, b + tile_to_scrn OBJ_OFF_Y, b ld [hl+], a ld a, [de] ; a = x position - mul16 a - add a, OBJ_OFF_X - sub a, c + tile_to_scrn OBJ_OFF_X, b ld [hl+], a ld a, 0x80 diff --git a/src/unit.s b/src/unit.s index 3836ed7..9a5933c 100644 --- a/src/unit.s +++ b/src/unit.s @@ -185,6 +185,17 @@ unit_generic_draw_adjust_subtile: @done: ret + + ; translates tile to screen + ; inputs: + ; $1: Y/X offset + ; $2: register containing scroll + ; a: tile position +#macro tile_to_scrn + mul16 a + add a, $1 + sub a, $2 +#endmacro ; draws any unit ; inputs: @@ -215,17 +226,13 @@ unit_generic_draw: ; set y pos ld a, [de] - mul16 a - add a, OBJ_OFF_Y - sub a, b + tile_to_scrn OBJ_OFF_Y, b ld [hl+], a ; set x pos inc de ld a, [de] - mul16 a - add a, OBJ_OFF_X - sub a, c + tile_to_scrn OBJ_OFF_X, c ld c, a ld a, [TMP_X_OFFSET] add a, c