From: Lukas Krickl Date: Wed, 23 Oct 2024 16:00:44 +0000 (+0200) Subject: wip: actor system X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=da09ae811886b24a8415c8a005ce773ff73f1af7;p=gbrg%2F.git wip: actor system --- diff --git a/src/actor.s b/src/actor.s new file mode 100644 index 0000000..7640f16 --- /dev/null +++ b/src/actor.s @@ -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 diff --git a/src/main.s b/src/main.s index 43363f7..b6308cd 100644 --- a/src/main.s +++ b/src/main.s @@ -54,6 +54,7 @@ main: #include "map.s" #include "ui.s" #include "collision.s" +#include "actor.s" #include "tiles.inc" diff --git a/src/update.s b/src/update.s index de56efb..0c314fc 100644 --- a/src/update.s +++ b/src/update.s @@ -7,6 +7,8 @@ update_game: ; update player ld hl, player call player_update + + call actors_update ret diff --git a/src/wram.s b/src/wram.s index 755b57f..673710c 100644 --- a/src/wram.s +++ b/src/wram.s @@ -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