From e26622264f4f29da2f953c7e3ae71a729c134e67 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sun, 20 Jul 2025 17:54:18 +0200 Subject: [PATCH] actors: reworked actor table 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 | 10 ++++++++++ src/defs.s | 44 ++++++++------------------------------------ src/macros.inc | 46 ++-------------------------------------------- src/mapgen.s | 7 ++++++- src/player.s | 3 --- src/unit_demo.s | 15 --------------- src/wram.s | 36 +++++++++++++++++++++++++++++------- 7 files changed, 55 insertions(+), 106 deletions(-) diff --git a/src/actortables.s b/src/actortables.s index c6029d9..8dad2a9 100644 --- a/src/actortables.s +++ b/src/actortables.s @@ -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 + + diff --git a/src/defs.s b/src/defs.s index 95c8f4c..15b72f5 100644 --- a/src/defs.s +++ b/src/defs.s @@ -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 @@ -117,15 +115,6 @@ .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 @@ -140,9 +129,6 @@ ; 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 @@ -171,6 +157,14 @@ ; 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 @@ -184,28 +178,6 @@ .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 diff --git a/src/macros.inc b/src/macros.inc index 32b8cc8..03a62c5 100644 --- a/src/macros.inc +++ b/src/macros.inc @@ -186,6 +186,8 @@ ; 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) @@ -224,50 +226,6 @@ 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 diff --git a/src/mapgen.s b/src/mapgen.s index 42eca12..8feb43f 100644 --- a/src/mapgen.s +++ b/src/mapgen.s @@ -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 diff --git a/src/player.s b/src/player.s index 0ed1569..b27874d 100644 --- a/src/player.s +++ b/src/player.s @@ -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 diff --git a/src/unit_demo.s b/src/unit_demo.s index 1a5d51f..a8fe037 100644 --- a/src/unit_demo.s +++ b/src/unit_demo.s @@ -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 diff --git a/src/wram.s b/src/wram.s index e95af00..0be6abb 100644 --- a/src/wram.s +++ b/src/wram.s @@ -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 -- 2.30.2