dec b
jr nz, @loop REL
ret
+
+
+ ; draws the entire current actor table
+act_draw_all:
+ ld hl, map_actors
+ ld b, ACT_MAX
+@loop:
+ push hl
+ pop de ; de = act for update call
+ push hl
+ push bc
+ call act_draw
+ pop bc
+ pop hl
+ ld de, act_size
+ add hl, de
+
+ dec b
+ jr nz, @loop REL
+ ret
; updates a bat
; inputs:
dw act_r_bat
; updates and draws an actor
- ; calls different routines fro combat and map state
; inputs:
; 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 h, [hl]
ld l, a
jp hl
+
+ ; draws the bat actor
+ ; inputs:
+ ; de: actor ptr
+act_d_bat:
+ ld hl, act_pos_y
+ add hl, de
+ push hl
+ pop de ; de = act_pos_y in tiles
+
+ ld a, 1
+ call oamalloc
+
+ ; y pos
+ ld a, [de]
+ ld b, a
+ ld a, [map_offset_y]
+ add a, b
+
+ mul8 a
+ add a, OBJ_OFF_Y
+ ld [hl+], a
+
+ ; x pos
+ inc de ; de = act pos x in tiles
+
+ ld a, [de]
+ ld b, a
+ ld a, [map_offset_x]
+ add a, b
+
+ mul8 a
+ add a, OBJ_OFF_X
+ ld [hl+], a
+
+ ; tile
+ ld a, 0xA3
+ ld [hl+], a
+
+ ; flags
+ xor a, a
+ ld [hl], a
+
+ ret
+
+act_draw_table:
+ ; NULL
+ dw act_r_nop
+ ; player
+ dw act_r_nop
+ ; bat
+ dw act_d_bat
+
+ ; draws all actors
+ ; inputs:
+ ; de: actor ptr
+act_draw:
+ ld a, [de] ; type
+ add a, a ; * 2 for offset
+ ld hl, act_draw_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:
call map_set_visible_range
; set map offset
- ld a, b
- mul8 a
- sub a, OBJ_OFF_Y
+ ; offset to screen corner from player position
+ ; in tiles
+ ld a, [player+act_pos_y]
+ sub a, 10
+ cpl
ld [map_offset_y], a
- ld a, c
- mul8 a
- sub a, OBJ_OFF_X
+ ld a, [player+act_pos_x]
+ sub a, 11
+ cpl
ld [map_offset_x], a
; render destination