wip: map actor loading
authorLukas Krickl <lukas@krickl.dev>
Thu, 24 Oct 2024 18:24:09 +0000 (20:24 +0200)
committerLukas Krickl <lukas@krickl.dev>
Thu, 24 Oct 2024 18:24:09 +0000 (20:24 +0200)
src/map.s
src/video.s

index 83845c242518b57ed404b4776eef6f80cf6e2e55..f6682d91738135a575a3172dc52d6491f2433af5 100644 (file)
--- a/src/map.s
+++ b/src/map.s
   ;   curr_room_init_act: ptr to initial actors to be loaded 
 map_load:
   call room_draw
+  call room_load_actors
+  ret
+
+  ; loads actors from 
+  ; [curr_room_init_act] 
+  ; into the active actor table 
+room_load_actors:
+  ; clear actor table 
+  ld d, 0
+  ld bc, ACTORS_MAX * actor_size
+  ld hl, actor_table
+  call memset
+
+  ; hl = ptr to initial actor table 
+  ld hl, curr_room_init_act
+  ld a, [hl+]
+  ld d, a
+  ld a, [hl]
+  ld e, a
+  ; de = length...source table 
+
+  ld b, 0
+  ld a, [de]
+  ld e, a ; be = len
+
+  inc de ; de = source table 
+  ld hl, actor_table ; hl = dst
+  call memcpy
+
+
   ret
 
   ; maps are collections of rooms
index 06108abef972aef3cdb28b72abba5bb5a406984a..9cbdffbde10f5f03fa98c2a3009bc472e56e1d2f 100644 (file)
@@ -93,8 +93,12 @@ video_init:
   ldhi a, base_room_flags 
   ld [curr_room_flags+1], a 
 
-  call room_draw
+  ldlo a, base_room_actors
+  ld [curr_room_init_act], a
+  ldhi a, base_room_actors
+  ld [curr_room_init_act+1], a
 
+  call map_load
   
   ; set up bgp
   ld a, BGP