From 9a025bd362c244c2b2b5ea5e2ff78d14d2642202 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Fri, 19 Sep 2025 18:27:17 +0200 Subject: [PATCH] actor: Added generic actor draw function --- src/actor.s | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/player.s | 11 ++++++++--- 2 files changed, 60 insertions(+), 3 deletions(-) diff --git a/src/actor.s b/src/actor.s index 5c1b5a7..8fe56ac 100644 --- a/src/actor.s +++ b/src/actor.s @@ -10,4 +10,56 @@ ; returns: ; hl: next oam ptr (if reserved!) actor_draw: + push hl + ld hl, act_pos_y + add hl, de + push hl + pop de ; de = pos y + pop hl + + ; hl = oam ptr again + + ; deal with y position + push bc + push af + + ; get y offset + and a, 0xF0 + swap a ; a = y offset + ld b, a + ld a, [de] + add a, b ; a = y postion + ld b, a + ld a, [scroll_y] + add a, b + + ; TODO: deal with row offset + + + inc de ; de = x pos + + ld [hl+], a + + pop af + + ; deal with x position + + and a, 0xF ; a = x offset + ld b, a + ld a, [de] + add a, b ; b = x position + + ld [hl+], a + + pop bc + + ; tile + ld a, b + ld [hl+], a + + ; oam flags + ld a, c + ld [hl+], a + + ret diff --git a/src/player.s b/src/player.s index aa07701..f05c71e 100644 --- a/src/player.s +++ b/src/player.s @@ -1,9 +1,9 @@ ; sets up the player actor player_init: ; initial position - ld a, 232 + ld a, 132 ld [player+act_pos_y], a - ld a, 64 + ld a, 24 ld [player+act_pos_x], a ret @@ -11,7 +11,7 @@ player_init: player_update: ret -#define PLAYER_SPRITE_IDLE1 0x8A +#define PLAYER_SPRITE_IDLE1 0x88 ; draws the special player actor player_draw: @@ -24,4 +24,9 @@ player_draw: ld a, 0 call actor_draw + ld de, player + ld b, PLAYER_SPRITE_IDLE1+2 + ld c, 0 + ld a, 8 + call actor_draw ret -- 2.30.2