; inputs:
; hl: actor table
act_table_load:
+ push hl
+ ; clear old table data
+ ld hl, map_actors
+ ld bc, act_size * ACT_MAX
+ ld d, 0
+ call memset
+
+ pop de ; de = source
+ ld a, d
+ or a, e
+ ret z ; no table? -> bail
+
+
+ ld hl, map_actors ; hl = dst
+
+ ; load all tables until type is 0
+@load_loop:
+ ; check type for NULL
+ ld a, [de]
+ cp a, 0
+ jp z, @load_done
+
+ ld bc, act_size
+ call memcpy
+ ; hl = next destination
+ ; de = next source
+ jp @load_loop
+@load_done:
+
+ ; run actor init code for each actor type
+ ld hl, map_actors
+@init_loop:
+ ; check for type NULL
+ ld a, [hl]
+ cp a, 0
+ jp z, @init_done
+
+ push hl
+ pop de
+ push de
+ call act_init
+ pop hl
+
+ ld bc, act_size
+ add hl, bc ; next act
+ jp @init_loop
+@init_done:
+ ret
+
+ ; nop actor routine
+act_r_nop:
ret
+
; updates the entire current actor table
act_all_update:
ret
+
+ ; updates a bat
+ ; inputs:
+ ; de: actor ptr
+act_r_bat:
+ ret
+
+act_update_table:
+ ; NULL
+ dw act_r_nop
+ ; player
+ dw act_r_nop
+ ; bat
+ dw act_r_bat
; updates and draws an actor
; calls different routines fro combat and map state
; inputs:
- ; hl: actor ptr
+ ; de: actor ptr
act_update:
; TODO: read type, get ptr from table
; and call
+ ld a, [de] ; type
+ add a, a ; * 2 for offset
+ ld hl, act_update_table
+ ld b, 0
+ ld c, a
+ add hl, bc
+
+ ; load routine ptr
+ ld a, [hl+]
+ ld h, [hl]
+ ld l, a
+ jp hl
+
+ ; generic set tact init call
+ ; inputs:
+ ; de: actor ptr
+act_init_set_tact:
+ call act_set_tact
ret
+
+act_init_table:
+ ; NULL
+ dw act_r_nop
+ ; player
+ dw act_init_set_tact
+ ; bat
+ dw act_init_set_tact
+
+ ; inits an actor based on its type
+ ; inputs:
+ ; de: actor ptr
+act_init:
+ ld a, [de] ; type
+ add a, a ; * 2 for table offset
+ ld hl, act_init_table
+ ld b, 0
+ ld c, a
+ add hl, bc
+
+ ; load routine ptr
+ ld a, [hl+]
+ ld h, [hl]
+ ld l, a
+ jp hl
+
+ ; draws a bat actor
+ ; inputs:
+ ; de: act ptr
+act_draw_nearby_bat:
+ ret
+
+act_draw_nearby_table:
+ ; NULL
+ dw act_r_nop
+ ; player
+ dw act_r_nop
+ ; bat
+ dw act_draw_nearby_bat
; draws an actor if they are near
; usuall act_nearby or prop_nearby
; to the camera
; inputs:
- ; hl: actor ptr
+ ; de: actor ptr
act_draw_nearby:
- ret
+ ld a, [de] ; type
+ add a, a ; * 2 for offset
+ ld hl, act_draw_nearby_table
+ ld b, 0
+ ld c, a
+ add hl, bc
+
+ ; load routine ptr
+ ld a, [hl+]
+ ld h, [hl]
+ ld l, a
+ jp hl
; clears tact at the current actors position
; inputs:
; where each tile has values and its current state. The map can be drawn from this.
l1:
- mapdef MAP_F_DO_FULL_REDRAW, map_r_nop, 0, tile_banks_default
+ mapdef MAP_F_DO_FULL_REDRAW, map_r_nop, l1_acts, tile_banks_default
#include "l1.inc"
; l1 actor table
l1_acts:
actdef ACT_T_BAT, 0, 10, 10, 0, 0
+ actdef ACT_T_BAT, 0, 0, 2, 0, 0
.db 0 ; terminate