actor: wip actor drawing
authorLukas Krickl <lukas@krickl.dev>
Fri, 19 Sep 2025 15:45:07 +0000 (17:45 +0200)
committerLukas Krickl <lukas@krickl.dev>
Fri, 19 Sep 2025 15:45:07 +0000 (17:45 +0200)
src/actor.s [new file with mode: 0644]
src/main.s
src/map.s
src/player.s
src/sys.s
src/update.s
src/wram.s

diff --git a/src/actor.s b/src/actor.s
new file mode 100644 (file)
index 0000000..5c1b5a7
--- /dev/null
@@ -0,0 +1,13 @@
+       ; draws a single object
+       ; for an actor accounting for scroll
+       ; inputs:
+       ;               de: actor
+       ;               hl: oam ptr
+       ;                b: tile
+       ;                c: oam flags
+       ;                a: nnnn0000: y offset from actor pos; 
+       ;                         0000nnnn: x offset from actor pos
+       ;       returns:
+       ;               hl: next oam ptr (if reserved!)
+actor_draw:
+       ret
index 37473bc5f94802f3a1e4865e6047fe2db6918077..c1f398f3fe6ddb25421a4fe0d670ae59df9103a1 100644 (file)
@@ -64,6 +64,7 @@ main:
 #include "rowpatterns.s"
 #include "math.s"
 #include "game.s"
+#include "actor.s"
 
 #include "tiles.inc"
 #include "text.s"
index eb40337964da6c70306abc9134fd7cbbb6a3a942..3e19a6786f75d45d7fa186f25146a0385797c209 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -48,6 +48,8 @@ map_load:
        ; to make bottom of scrn0 visible
        ld a, 144
        ld [scroll_y], a
+
+       call player_init
        ret
        
        ; loads all tile banks 
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..aa07701deb2411a9bf172fb2fdb775577fc22b0a 100644 (file)
@@ -0,0 +1,27 @@
+       ; sets up the player actor
+player_init:
+       ; initial position
+       ld a, 232
+       ld [player+act_pos_y], a
+       ld a, 64
+       ld [player+act_pos_x], a
+       ret
+       
+       ; updates the special player actor
+player_update:
+       ret
+
+#define PLAYER_SPRITE_IDLE1 0x8A
+
+       ; draws the special player actor
+player_draw:
+       ld a, 2
+       call oamalloc 
+
+       ld de, player
+       ld b, PLAYER_SPRITE_IDLE1
+       ld c, 0
+       ld a, 0
+       call actor_draw
+
+       ret
index 3c6e58f299ff52e40da96817cef966ccfb9a1158..871ddedd7215ec7227265ca96b2194faf5b3cd30 100644 (file)
--- a/src/sys.s
+++ b/src/sys.s
@@ -55,22 +55,14 @@ call_tbl:
   ; hl = function value 
   jp hl
 
-  ; loads scroll into bc
-  ; returns:
-  ;   b: scroll y
-  ;   c: scroll x
-load_scroll:
-  ld a, [scroll_y]
-  ld b, a ; b = scroll_y
-  ld a, [scroll_x]
-  ld c, a ; c = scroll_x
-  ret
-
   ; loads unit sprite into hl
   ; increments unit sprite
+       ; inputs:
+       ;               a: amount of objects to reserve
   ; returns;
   ;   hl: current unit sprite
-load_oam_obj:
+oamalloc:
+       push af
   ld a, [current_oam_obj]
   
 
@@ -81,13 +73,17 @@ load_oam_obj:
   add hl, de ; hl = next oam 
   
   ; next object 
-  add a, oamsize 
+       ld b, a
+       pop af
+       sla a
+       sla a ; * 4 to get oam size from requsted objs
+       add a, b ; current oam + input * 4
   ld [current_oam_obj], a
 
   ret
 
   ; resets unit obj
-reset_oam_obj:
+oamfree_all:
   xor a, a
   ld [current_oam_obj], a
   ret
index 139fab5a6f0eb10654355085cb836493e3a3026f..e342b237be45233c48bccaefbf1b6d726fd5f75f 100644 (file)
@@ -7,6 +7,9 @@ update_game:
 
   ; clear oam
   call shadow_oam_clear
+
+       call player_draw
+       call player_update
        
   ret
 
@@ -27,7 +30,7 @@ update:
   ld [frame_count], a
 
   ; reset objects
-  call reset_oam_obj
+  call oamfree_all 
 
        ; load current sate routine
        ld a, [game_state]
index 27e86b388b9cf30752f13e4597fc4775b11294af..b1f0a683f771d4ad3fc7b18e7788743beccf3370 100644 (file)
@@ -55,9 +55,7 @@ scroll_x: .adv 1
 srand: .adv 2
 
 
-; units 
-; player_unit (unit 0) is reserved
-player_unit: .adv 0 
+player: .adv act_size
 actors: .adv act_size * ACTS_MAX 
 map_objs: .adv mo_size * MAP_OBJ_MAX