wip: actor system
authorLukas Krickl <lukas@krickl.dev>
Wed, 23 Oct 2024 16:00:44 +0000 (18:00 +0200)
committerLukas Krickl <lukas@krickl.dev>
Wed, 23 Oct 2024 16:00:44 +0000 (18:00 +0200)
src/actor.s [new file with mode: 0644]
src/main.s
src/update.s
src/wram.s

diff --git a/src/actor.s b/src/actor.s
new file mode 100644 (file)
index 0000000..7640f16
--- /dev/null
@@ -0,0 +1,38 @@
+; function ptrs for each actor type 
+; inputs:
+;   de: actor ptr
+actor_update_table:
+  dw actor_update_null
+  dw actor_update_dust
+
+actor_update_null:
+  ret
+
+actor_update_dust:
+  ret
+
+  ; updates all active actors from 
+  ; the current actor table
+actors_update:
+  ld b, ACTORS_MAX ; loop counter
+  ld de, actor_table 
+@loop: 
+
+  push de
+  push bc
+
+  ld hl, actor_update_table
+  ld a, [de] 
+  call call_tbl
+
+  pop bc
+  pop de
+@skip:
+  ; inc de sizeof(actor) times 
+.rep i, actor_size, 1, inc hl
+  dec b
+  ld a, b
+  cp a, 0
+  jr nz, @loop REL
+
+  ret
index 43363f7a05daaef3bbddad4518d71786d2e02ed6..b6308cd5b88b320d02d54d4d09428e236e04b866 100644 (file)
@@ -54,6 +54,7 @@ main:
 #include "map.s"
 #include "ui.s"
 #include "collision.s"
+#include "actor.s"
 
 #include "tiles.inc"
 
index de56efb4028e9b5ef8f6804ff8aa1564b5fea405..0c314fc0fa0b6ad1d8e287521875ba6578251ac3 100644 (file)
@@ -7,6 +7,8 @@ update_game:
   ; update player
   ld hl, player
   call player_update
+  
+  call actors_update
 
   ret
 
index 755b57f0e5402e3b046fb79e065180a02c7909d4..673710c97be5c3f3d486c85f1afd31a876343aea 100644 (file)
@@ -17,8 +17,10 @@ curr_inputs: .adv 1
 prev_inputs: .adv 1
 
 ; actor type enum
-.se 1
-.de ACTOR_TYPE_PLAYER, 1
+.se 0
+  ; null actor type = nop
+.de ACTOR_TYPE_NULL, 1
+.de ACTOR_TYPE_DUST, 1
 
 ; struct actor 
 .se 0