stats: reworked stats to save memory
authorLukas Krickl <lukas@krickl.dev>
Fri, 13 Jun 2025 04:03:45 +0000 (06:03 +0200)
committerLukas Krickl <lukas@krickl.dev>
Fri, 13 Jun 2025 04:03:45 +0000 (06:03 +0200)
src/defs.s
src/macros.inc
src/main.s
src/stats.s [new file with mode: 0644]

index 6bc0c0ffacce9e2c768c25c1ecea9994cc16b062..3dfe9657d1a79ed170093f4e5073ed48e27d1781 100644 (file)
 
 
   ; 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
 .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
 
index 2e0ddffc7bc55930cf565bc4e75df7baacbde9b3..9fc0ce0d6454f757f590f86f130dbeb96c8b39cb 100644 (file)
   .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
   ;   $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
index 1b90de8de0e8f7ab0ca27e705baf1b07f47e3dc4..2f86235eb260dee631500ece3949c9990e2ceb5e 100644 (file)
@@ -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 (file)
index 0000000..3ecac69
--- /dev/null
@@ -0,0 +1,8 @@
+
+  ; calculates the real strength stat
+  ; inputs:
+  ;   de: actor
+  ; returns:
+  ;   a: str value
+stat_calc_str:
+  ret