From 87e88f9348c6004fefaf6f35dcc058d7c408c20b Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Fri, 13 Jun 2025 06:03:45 +0200 Subject: [PATCH] stats: reworked stats to save memory --- src/defs.s | 32 ++++++++++++++++++++++---------- src/macros.inc | 18 +++++++++--------- src/main.s | 1 + src/stats.s | 8 ++++++++ 4 files changed, 40 insertions(+), 19 deletions(-) create mode 100644 src/stats.s diff --git a/src/defs.s b/src/defs.s index 6bc0c0f..3dfe965 100644 --- a/src/defs.s +++ b/src/defs.s @@ -81,10 +81,22 @@ ; stats struct + ; with current and max + ; used for hp, mp, fatigue, moves + ; all other stats only have a max value + ; and their real value is calculated before use + ; e.g. stat_calc_str with actor as input + ; used for stats that can change and reset + ; regularly .se 0 .de stat_cur, 1 .de stat_max, 1 .de stat_size, 0 + + ; lite stat with max value only + ; used for stats that are not intended to + ; decrease regularly +#define stat_lite_size 1 ; status effect .se 0 @@ -139,19 +151,19 @@ .de act_hp, stat_size .de act_mp, stat_size .de act_fatigue, stat_size -.de act_ac, stat_size +.de act_ac, stat_lite_size .de act_moves, stat_size ; moves for each turn -.de act_init, 1 ; initiative value +.de act_init, stat_lite_size ; initiative value ; stats2 -.de act_str, stat_size -.de act_int, stat_size -.de act_dex, stat_size -.de act_luck, stat_size -.de act_will, stat_size -.de act_charisma, stat_size -.de act_endurance, stat_size -.de act_speed, stat_size +.de act_str, stat_lite_size +.de act_int, stat_lite_size +.de act_dex, stat_lite_size +.de act_luck, stat_lite_size +.de act_will, stat_lite_size +.de act_charisma, stat_lite_size +.de act_endurance, stat_lite_size +.de act_speed, stat_lite_size ; attributes diff --git a/src/macros.inc b/src/macros.inc index 2e0ddff..9fc0ce0 100644 --- a/src/macros.inc +++ b/src/macros.inc @@ -175,7 +175,7 @@ .db $2, $2 ; hp hp max .db $3, $3 ; mp mp max .db $4, $4 ; fatigue fatigue max - .db $5, $5 ; ac ac max + .db $5 ; ac .db $6, $6 ; moves moves max .db $7 ; initiative #endmacro @@ -189,14 +189,14 @@ ; $7 endurance ; $8 speed #macro act_stat_def2 - .db $1, $1 ; str str max - .db $2, $2 ; int int max - .db $3, $3 ; dex dex max - .db $4, $4 ; luck luck max - .db $5, $5 ; will will max - .db $6, $6 ; char char max - .db $7, $7 ; endurance endurance max - .db $8, $8 ; speed speed max + .db $1 ; str str max + .db $2 ; int int max + .db $3 ; dex dex max + .db $4 ; luck luck max + .db $5 ; will will max + .db $6 ; char char max + .db $7 ; endurance endurance max + .db $8 ; speed speed max #endmacro ; defines actor state callbacks diff --git a/src/main.s b/src/main.s index 1b90de8..2f86235 100644 --- a/src/main.s +++ b/src/main.s @@ -68,6 +68,7 @@ main: #include "unit.s" #include "effect.s" #include "text.s" +#include "stats.s" ; fill bank .fill 0, 0x7FFF - $ diff --git a/src/stats.s b/src/stats.s new file mode 100644 index 0000000..3ecac69 --- /dev/null +++ b/src/stats.s @@ -0,0 +1,8 @@ + + ; calculates the real strength stat + ; inputs: + ; de: actor + ; returns: + ; a: str value +stat_calc_str: + ret -- 2.30.2