actor: Added actor die table
authorLukas Krickl <lukas@krickl.dev>
Mon, 22 Dec 2025 05:32:03 +0000 (06:32 +0100)
committerLukas Krickl <lukas@krickl.dev>
Mon, 22 Dec 2025 05:32:03 +0000 (06:32 +0100)
src/actor.s
src/player.s
src/wram.s

index 5fedb33e2b9f7258382de784ee571ee40d7825a6..8bf49f97125a38953b75de56925e44e51f3696e9 100644 (file)
@@ -195,6 +195,42 @@ act_init:
        ld l, a
        jp hl
 
+act_die_table:
+       ; NULL
+       dw act_r_nop
+       ; player
+       dw act_r_nop
+       ; bat
+       dw act_die_bat
+       
+       ; actor die table
+       ; inputs:
+       ;               de: actor ptr
+act_die:
+       ld a, [de] ; type
+       add a, a ; * 2 for table offset
+       ld hl, act_die_table
+       ld b, 0
+       ld c, a
+       add hl, bc
+       
+       ; load routine ptr
+       ld a, [hl+]
+       ld h, [hl]
+       ld l, a
+       jp hl
+       
+       ; bat dealloc
+       ; inputs:
+       ;               de: bat
+act_die_bat:
+       xor a, a
+       ld [de], a ; set type == 0
+
+       call act_clear_tact
+
+       ret
+
        
        ; generic actor table call
        ; inputs:
index fffee984c3e082f042c188e0d0a044eb009dd080..2db9143f24a5a27af79713d6ecf53ce16d53bfdb 100644 (file)
@@ -76,7 +76,10 @@ player_update:
        ; player attack call
 player_attack:
        ld de, player
-       call act_attr_get_attack_damage
+       ld a, player HI
+       ld [combat_src_act], a
+       ld a, player LO
+       ld [combat_src_act+1], a
        
        ; TODO: implement correctly
        ; for now just remove an actor if
@@ -90,16 +93,19 @@ player_attack:
        add hl, de
 
        ld a, [hl+]
-       ld e, [hl]
+       ld [combat_dst_act], a
+       ld a, [hl]
+       ld [combat_dst_act+1], a
+       
+       ; for now just die if actor != NULL
+       ld a, [combat_dst_act]
        ld d, a
-       or a, e 
+       ld a, [combat_dst_act+1]
+       ld e, a
+       or a, d
        ret z
-       
-       xor a, a
-       dec hl
-       ld [de], a ; set type to 0
-       ld [hl+], a ; clear ptr
-       ld [hl], a
+
+       call act_die
 
        ret
        
index c0e89a725d26862b2fc7a76e859a3370aeb161fb..5f457765630bea74fdb565e88f5ec34b7b32f68c 100644 (file)
@@ -124,4 +124,8 @@ tmp_act_x: .adv 1
 tile_near: .adv 2
 tile_far: .adv 2
 tile_furthest: .adv 2
-
+       
+       ; ptrs to source and dst actor
+       ; if dst is NULL the attack fails
+combat_src_act: .adv 2
+combat_dst_act: .adv 2