+ ; same as actor_try_add
+ ; without inputs
+actor_try_add_player_projectile:
+ ld hl, actors_player_projectiles
+ ld b, ACTS_PLAYER_PROJECTILES
+ jp actor_try_add
+
+ ; same as actor_try_add
+ ; without inputs
+actor_try_add_enemy:
+ ld hl, actors_enemy
+ ld b, ACTS_ENEMY
+ jp actor_try_add
+
; attempts to spawna a new actor
; by searching for a free slot of type 0
+ ; inputs:
+ ; hl: actor table
+ ; b: max
; returns:
; hl: free actor ptr
; hl: NULL if no slot is available
; note: memory is not cleared
; the caller will have to initialize the actor
actor_try_add:
- ld b, ACTS_MAX
- ld hl, actors
ld de, act_size
@loop:
ld a, [hl] ; check type
; tests movement against all collision rectangles
; inputs:
+ ; hl: actor table start
+ ; c: actor table length
; a: collision mask
; b: direction
; de: current actor (this actor is skipped)
; a == 1: collision
; hl: if collided with an actor points to the actor hit, otherwise NULL
actor_test_movement:
+ ; save actor table info
+ push hl
+ push bc
+
+ ; save current actor
push de
ld [tmp_rect_mask], a
jp nz, @rect_test_loop
pop de
- ld b, ACTS_MAX + 1 ; +1 to include player
- ; start at player actor
- ld hl, player
+ pop bc
+ ld b, c ; b = actor table lenth
+
+ pop hl ; hl = actor table
@actor_test_loop:
ld a, [hl]
xor a, a ; no collision
ret
@rect_collision:
+ ; need to pop 3 values that were pushed
+ ; before rect loop
pop de
+ pop hl
+ pop bc
ld hl, NULL
ld a, 1
ret
#define NULL 0
-#define ACTS_MAX 16
+#define ACTS_PLAYER_PROJECTILES 3
+#define ACTS_ENEMY 6
+#define ACTS_ENEMY_PROJECTILES 6
+#define ACTS_MAX (ACTS_PLAYER_PROJECTILES + ACTS_ENEMY + ACTS_ENEMY_PROJECTILES)
+
+
#define MAP_OBJ_MAX 32
-#define RECT_MAX 12
+#define RECT_MAX 6
#define MAP_ROW_H 16 ; pixels per row
player: .adv act_size
; actor table should follow player!
-actors: .adv act_size * ACTS_MAX
+actors:
+actors_enemy: .adv act_size * ACTS_ENEMY
+actors_enemy_projectiles: .adv act_size * ACTS_ENEMY_PROJECTILES
+actors_player_projectiles: .adv act_size * ACTS_PLAYER_PROJECTILES
map_objs: .adv mo_size * MAP_OBJ_MAX