actors: reworked actor table
authorLukas Krickl <lukas@krickl.dev>
Sun, 20 Jul 2025 15:54:18 +0000 (17:54 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sun, 20 Jul 2025 15:54:18 +0000 (17:54 +0200)
This change was made to make general actors more slim.
Actors do not need equipment and inventory slots.
Instead general actors now have a runtime spot for loot table
information.
Only the player has a special memory space for inventory/equipment data
now.

src/actortables.s
src/defs.s
src/macros.inc
src/mapgen.s
src/player.s
src/unit_demo.s
src/wram.s

index c6029d9479e474e381b0e146d8d29e76d0237cdc..8dad2a929395bd6c168cd6a2a7509090685b7bf9 100644 (file)
@@ -1,5 +1,13 @@
 #include "unit_demo.s"
 
+; actor table:
+;   an actor table is a list of actors
+;   that can either be loaded into the active table directly
+;   or it can be used as a template for placing new actors
+;   that are valid for this map.
+;   to use as a template use the actors but move the position
+;   as needed and setting act_loot_table_dat.
+
 map_c_actor_table:
 .db 10 ; size
 dw unit_demo_2
@@ -20,3 +28,5 @@ dw unit_demo_warrior
 dw unit_demo_warrior
 dw unit_demo_warrior
 dw unit_demo_warrior
+
+
index 95c8f4cefbe83a3f1b62a2d29bec3bdc5e707aa3..15b72f5621b2b737c3a337e6cc86a6088c86958d 100644 (file)
@@ -54,8 +54,6 @@
 #define REDRAW_TILES_PER_FRAME 4
 
 
-  ; each unit can have up to 4 status effects
-#define EFFECTS_MAX 4
 
   ; draw flags
 .se 1
 .de effect_dat, 1
 .de effect_size, 0
 
-  ; status effect types
-.se 0
-.de EFFECT_NONE, 1
-
-  ; damage over time effect
-  ; dat NNNN0000: timer
-  ; dat 0000NNNN: damage value per tick
-.de EFFECT_DOT, 1
-
 
   ; actor type enum
 .se 0
   ; act_def
   ; act_stat_def1
   ; act_stat_def2
-  ; act_inventory_def or act_inventory_empty
-  ; act_equipment_def or act_equipment_empty
-  ; act_effects_def or act_effects_empty
   ; act_st_def
   ; act_def_meta
 .se 0
   ; 00c00000: c: sub tile enabled
 .de act_rt_sub_tile, 1
 
+  ; inventory/equipment
+  ; if type player use the file-specific inventory/equipment
+  ; for players.
+  ; for any other actor this contains information about the loot table
+  ; that can be generated by the map generator
+  ; loot tables are based on the current floor.
+.de act_rt_loot_table_dat, 2
+
   ; stats1
 .de act_level, 1
 .de act_hp, stat_size
 .de act_dex, stat_size
 .de act_vit, stat_size
 
-
-
-  ; inventory
-  ; stores items, for all actors but player
-  ; there are 4 inventory slots.
-  ; if the actor is type player a special inventory 
-  ; used instead
-  ; call unit_get_inventory to get a ptr and length
-
-  ; equipment 
-  ; stores all items equiped
-  ; for all actors there are 6 eqipment slots
-.de act_eq_head, 2
-.de act_eq_body, 2
-.de act_eq_hand1, 2
-.de act_eq_hand2, 2
-.de act_eq_ring, 2
-.de act_eq_amulet, 2
-
-  ; status effects
-.de act_effect, EFFECTS_MAX * effect_size 
-
   ; actor states 
   ; used for state switching
   ; set to 0000 to disable the state
index 32b8cc8738de89e65da65242681bad833e490b6b..03a62c547ed176f7eff83f8a47879e00ca91472a 100644 (file)
   ; act_rt_collided_with
   dw 0 
   .db 0  ; act_rt_sub_tile 
+  ; act_rt_loot_table_dat
+  dw 0
 #endmacro
   
   ; defines an actor's stats (1/2)
   dw $4
 #endmacro
 
-
-  ; defines an actors inventory content
-#macro act_inventory_def
-#endmacro
-  
-  ; defines an empty inventory
-#macro act_inventory_empty
-  act_inventory_def
-#endmacro
-
-  ; defines an actor's equipment
-  ; inputs:
-  ;   $1: head
-  ;   $2: body
-  ;   $3: hand1
-  ;   $4: hand2
-  ;   $5: ring
-  ;   $6: amulet 
-#macro act_equipment_def
-  dw $1
-  dw $2
-  dw $3
-  dw $4
-  dw $5
-  dw $6
-#endmacro
-
-  ; defines an empty equipment set
-#macro act_equipment_empty
-  act_equipment_def NULL, NULL, NULL, NULL, NULL, NULL
-#endmacro
-
-  ; defines an actors current stats effects
-#macro act_effects_def
-#endmacro
-
-  ; defines an empty status effect table
-#macro act_effects_empty
-  .db 0, 0
-  .db 0, 0
-  .db 0, 0
-  .db 0, 0
-#endmacro
-
   ; defines an exit table entry
   ; inputs:
   ;   $1: flags
index 42eca122aafc4db0e902e6cd6b5852dd704e5242..8feb43f045f62cac1020bab6d4484d05a20a12b4 100644 (file)
@@ -6,10 +6,15 @@
   ; 3) places doors
   ; 4) places between 1-3 actors from a valid actor list
   ;    actor placement may fail if the actor table is full
+  ; If the tile id is not 0 this rotuine will consider the tile invalid
+  ; and will never write to it
   ; inputs:
-  ;   a map must be loaded
+  ;   hl: writable decompressed tile array (e.g [map]) 
+  ;       of size MAP_H * MAP_W
   ; returns:
   ;   a == 0: room was unable to be placed
   ;   a == 1: room was placed
 mapgen_make_room:
+  ; roll a room size
+
   ret
index 0ed15696264039fea4c5a346e3a227695bc4434d..b27874dbae6969baf40ffd011cb4816f3fe8ccbc 100644 (file)
@@ -199,9 +199,6 @@ unit_player:
   act_def ACT_T_DEMO_1, 0, 2, 2, 0
   act_stat_def1 1, 1, 1, 1
   act_stat_def2 1, 1, 90, 1 
-  act_inventory_empty
-  act_equipment_empty
-  act_effects_empty
   act_st_def NULL, NULL, st_unit_player_update, st_unit_idle
   act_def_meta unit_draw, 0x8C, 0, NULL
 
index 1a5d51f7d8231c295761171fd05e43d66eac2ea7..a8fe037fad484491962e215eb5dbcf30c1a67760 100644 (file)
@@ -44,9 +44,6 @@ unit_demo_2:
   act_def ACT_T_DEMO_1, 0, 3, 3, 0 
   act_stat_def1 1, 1, 1, 1
   act_stat_def2 1, 1, 32, 1
-  act_inventory_empty
-  act_equipment_empty
-  act_effects_empty
   act_st_def NULL, NULL, st_unit_demo_1_cpu_update_idle, st_unit_idle
   act_def_meta unit_draw, 0x88, 0, NULL
 
@@ -55,9 +52,6 @@ unit_demo_warrior:
   act_def ACT_T_DEMO_1, 0, 4, 4, 0 
   act_stat_def1 1, 1, 1, 1 
   act_stat_def2 1, 1, 32, 1
-  act_inventory_empty
-  act_equipment_empty
-  act_effects_empty
   act_st_def NULL, NULL, st_unit_demo_1_cpu_update, st_unit_idle
   act_def_meta unit_draw, 0x88, 0, NULL
 
@@ -66,9 +60,6 @@ unit_demo_mage:
   act_def ACT_T_DEMO_1, 0, 4, 4, 0 
   act_stat_def1 1, 1, 1, 1 
   act_stat_def2 1, 1, 32, 1
-  act_inventory_empty
-  act_equipment_empty
-  act_effects_empty
   act_st_def NULL, NULL, st_unit_demo_1_cpu_update, st_unit_idle
   act_def_meta unit_draw, 0x8C, 0, NULL
 
@@ -77,9 +68,6 @@ unit_demo_thief:
   act_def ACT_T_DEMO_1, 0, 4, 4, 0 
   act_stat_def1 1, 1, 1, 1 
   act_stat_def2 1, 1, 32, 1
-  act_inventory_empty
-  act_equipment_empty
-  act_effects_empty
   act_st_def NULL, NULL, st_unit_demo_1_cpu_update, st_unit_idle
   act_def_meta unit_draw, 0x90, 0, NULL
 
@@ -89,9 +77,6 @@ unit_demo_priest:
   act_def ACT_T_DEMO_1, 0, 4, 4, 0 
   act_stat_def1 1, 1, 1, 1 
   act_stat_def2 1, 1, 32, 1
-  act_inventory_empty
-  act_equipment_empty
-  act_effects_empty
   act_st_def NULL, NULL, st_unit_demo_1_cpu_update, st_unit_idle
   act_def_meta unit_draw, 0x94, 0, NULL
 
index e95af0037030a66fa5b6bac92682d5879b8d55a8..0be6abbe8c24c3518705688b8e7a100e38a38ab0 100644 (file)
@@ -83,6 +83,15 @@ st_custom: .adv st_size
   ; to change its timer
 st_unit_delay_to_active: .adv st_size
 
+  ; scroll location
+scroll_y: .adv 1
+scroll_x: .adv 1
+
+  ; +/-1 for each time the cursor moves
+  ; allows us to move scroll when needed 
+scroll_move_y: .adv 1
+scroll_move_x: .adv 1
+
   ; game state
   ; this region holds the entire game state
   ; everything thats needed for a savme game should be
@@ -101,17 +110,30 @@ game_speed: .adv 1
   ; last d16 result
 d16: .adv 1
 
-  ; +/-1 for each time the cursor moves
-  ; allows us to move scroll when needed 
-scroll_move_y: .adv 1
-scroll_move_x: .adv 1
 
   ; the current floor
 floor: .adv 1
 
-  ; scroll location
-scroll_y: .adv 1
-scroll_x: .adv 1
+
+
+  ; player speciifc data
+
+  ; player inventory data
+player_inventory: 
+  ; TODO: add data here
+
+  ; player equipment
+  ; pointers to items
+  ; stores all items equiped
+  ; for player actors there are 6 eqipment slots
+  ; for all other actors there is no equipment
+player_equipment:
+player_eq_head: .adv 2
+player_eq_body: .adv 2
+player_eq_hand1: .adv 2
+player_eq_hand2: .adv 2
+player_eq_ring: .adv 2
+player_eq_amulet: .adv 2
 
 ; units 
 ; player_unit (unit 0) is reserved