actor: Added generic actor draw function
authorLukas Krickl <lukas@krickl.dev>
Fri, 19 Sep 2025 16:27:17 +0000 (18:27 +0200)
committerLukas Krickl <lukas@krickl.dev>
Fri, 19 Sep 2025 16:27:17 +0000 (18:27 +0200)
src/actor.s
src/player.s

index 5c1b5a790db4dcf47a401ea2a640e54acac60a35..8fe56ac4caf26c7f7d010f440c419c8cb9da34e9 100644 (file)
        ;       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
index aa07701deb2411a9bf172fb2fdb775577fc22b0a..f05c71e312099b2090d6c9ec1dd70b5bac57b6d2 100644 (file)
@@ -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