attrs: wip attribute management
authorLukas Krickl <lukas@krickl.dev>
Fri, 19 Dec 2025 18:08:25 +0000 (19:08 +0100)
committerLukas Krickl <lukas@krickl.dev>
Fri, 19 Dec 2025 18:08:25 +0000 (19:08 +0100)
src/attributes.s
src/defs.s
src/levels.s
src/macros.inc
src/map.s
src/player.s
src/wram.s

index d7b4d488d9a689766adc341cd44a822da00c10f2..1b25463dab8fc476e08dd82bb16891ef39e31120 100644 (file)
@@ -1,4 +1,12 @@
 
        ; table of actor type -> attribute
 act_attr_table:
+       dw attr_null
+       dw player_attr
+       dw attr_bat
 
+attr_null:
+attrdef 0, 0, 0, 0, 0
+
+attr_bat:
+attrdef 1, 0, 0, 1, 0
index 3f12972839f9c05da4d43e8777e7588db5c9e536..89c17c876e398dce89ea047e5c2e7e1e3f5c3e1b 100644 (file)
 .de act_p0, 1
        ; state parameter
 .de act_state, 1
-.de act_hp, 1
-.de act_mp, 1
+.de act_hp, 2
+.de act_mp, 2
+       ; currently active buff id
+       ; NNNN0000: buff status
+       ;       0000NNNN: buff type
+.de act_buff, 1
+       ; currently active debuff id
+       ; NNNN0000: debuff status
+       ;       0000NNNN: debuff type
+.de act_debuff, 1
 .de act_size, 0
 
  
 .de t_p0, 1
 .de t_size, 0
 
-       ; exit table entry
-.se 0
-       ; pointer to new map header
-.de map_exit_entry, 2
-
-
 
        
        ; alias for directions
        ; attribute struct
 .se 0
 .de attr_str, 1
+.de attr_agi, 1
+.de attr_wis, 1
+.de attr_stam, 1
+       ; resistances are 2 bit values
+       ; see resistance masks
+.de attr_res, 1
 .de attr_size, 0
+
+       ; resistance masks
+.def int ATTR_RES_POISON = 0b11000000
+.def int ATTR_RES_FIRE = 0b00110000
+.def int ATTR_RES_FROST = 0b00001100
+.def int ATTR_RES_LIGHTNING = 0b00000011
index 4618e1bb7201acba22c73a8210d87c83f912b940..87a1d2a695034e2f2b99c310178ad23facce0beb 100644 (file)
@@ -14,8 +14,8 @@ l1:
        
        ; l1 actor table
 l1_acts:
-       actdef ACT_T_BAT, 0, 4, 6, 0, 0
-       actdef ACT_T_BAT, 0, 0, 2, 0, 0
+       actdef ACT_T_BAT, 0, 4, 6, 2, 1
+       actdef ACT_T_BAT, 0, 0, 2, 2, 1
        .db 0 ; terminate
        
 
index 080a9763927e0f3b94acca504b4ff6a4cf80871c..16a57d55ad1945187a9b20076abead86897e6ec4 100644 (file)
@@ -189,30 +189,19 @@ $1:
        .db $1, $2, $3, $4
        ; dir, p0 and state
        .db 0, 0, 0 
-       .db $5, $6
-#endmacro
-
-       ; defines combat stats
-       ; inputs:
-       ;               $1: lvl
-       ;               $2: atk
-       ;               $3: def
-       ;               $4: hp max
-       ;               $5: mp max
-#macro actcbdef
-       ; flags
-       .db 0
-       .db $1, $2, $2
-       ; exp
-       .db 0, 0
-       .db $4, $5
-       ; p0, state
-       .db 0, 0
+       dw $5
+       dw $6
+       ; buff/debuff
+       .db 0, 0 
 #endmacro
        
        ; defines an attribute list
        ; inputs:
-       ;               $1: str
+       ;               $1: strength
+       ;         $2: agility
+       ;               $3: wisdom
+       ;               $4: stamina
+       ;               $5: resistances 
 #macro attrdef
-       .db $1
+       .db $1, $2, $3, $4, $5
 #endmacro
index d38df5a848718a89ef209a3c7969493288695497..6a10cb26a232f1c5f4bdc287b739dbf62ae83454 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -2,13 +2,7 @@
 #define WALL_EMPTY_TILE 0x17
        
        ; inits map globals
-       ; such as map_vram_tl
 map_globals_init:
-       ld hl, SCRN0
-       ld a, h
-       ld [map_vram_tl], a
-       ld a, l
-       ld [map_vram_tl+1], a
        ret
 
        ; loads a map and performs a full redraw
@@ -60,42 +54,6 @@ map_settings_load:
        push de
        call map_tiles_load
        pop de
-
-       ; load exits in the following order:
-       ; up, down, left, right
-       ld bc, map_exit_up
-
-       ; up
-       ld a, [hl+]
-       ld [bc], a
-       inc bc
-       ld a, [hl+]
-       ld [bc], a
-       inc bc
-
-       ; down
-       ld a, [hl+]
-       ld [bc], a
-       inc bc
-       ld a, [hl+]
-       ld [bc], a
-       inc bc
-
-       ; left
-       ld a, [hl+]
-       ld [bc], a
-       inc bc
-       ld a, [hl+]
-       ld [bc], a
-       inc bc
-
-       ; right
-       ld a, [hl+]
-       ld [bc], a
-       inc bc
-       ld a, [hl]
-       ld [bc], a
-
        
        push de
        ; load actors
index 1d2815f1dcc441db64a48bfb63d40df20b625aef..1a365680367085cc89cdab947d489d10fba3150f 100644 (file)
@@ -24,6 +24,31 @@ player_init:
 
        ld a, ACT_T_PLAYER
        ld [player], a ; set type
+
+       ld a, 1
+       ld [player_level], a
+       
+       ; str
+       ld [player_attr], a
+       ; agi
+       ld [player_attr+1], a
+       ; wis
+       ld [player_attr+2], a
+       ; stam
+       ld [player_attr+3], a
+
+       ; resistance
+       xor a, a
+       ld [player_attr+4], a
+       
+       ; set hp and mp
+       ld a, 5
+       ld [player+act_hp+1], a
+       ld [player+act_mp+1], a
+       xor a, a
+       ld [player+act_hp], a
+       ld [player+act_mp], a
+
        
        ret
        
index 5161ecb4dc7ba03605da7168aaa9b17741cdff35..c0e89a725d26862b2fc7a76e859a3370aeb161fb 100644 (file)
@@ -69,13 +69,13 @@ animation_frame: .adv 1
   ; seed must never be 0
 srand: .adv 2
        
-       ; stores the last move direction
-player_direction: .adv 1
-
-       ; how many frames can the player jump?
-player_jump_timer: .adv 1
-       ; flag to indicate player jump has peaked
-player_jump_peak: .adv 1
+       ; player specific actor stats
+       ; ===========================
+       
+       ; player attributes are variable
+player_attr: .adv attr_size
+player_exp: .adv 2
+player_level: .adv 1
 
 actors:
 player: .adv act_size
@@ -86,23 +86,6 @@ tmp_x: .adv 1
        
        ; current map ptr
 map: .adv 2
-       ; ptr to top left corner of SCRN
-       ; where the map should be drawn
-map_vram_tl: .adv 2
-       ; exit table
-       ; an exit table always has 4 entries
-       ; exits usually transition using a scroll
-       ; unless the current map has the full reload flag 
-       ; set in which case the map fades out and full reloads
-       ; the scene
-       ; 0: eixt up
-       ; 1: exit down
-       ;       2: exit left
-       ;       3: exit right
-map_exit_up: .adv 2
-map_exit_down: .adv 2
-map_exit_left: .adv 2
-map_exit_right: .adv 2
        
        ; ptr to current tile to be updated
 tiles: .adv t_size * MAP_TILES