From: Lukas Krickl Date: Fri, 19 Dec 2025 18:08:25 +0000 (+0100) Subject: attrs: wip attribute management X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=f6e017db206de75f3ce4de0cafe9ca7287075c56;p=gbrg%2F.git attrs: wip attribute management --- diff --git a/src/attributes.s b/src/attributes.s index d7b4d48..1b25463 100644 --- a/src/attributes.s +++ b/src/attributes.s @@ -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 diff --git a/src/defs.s b/src/defs.s index 3f12972..89c17c8 100644 --- a/src/defs.s +++ b/src/defs.s @@ -60,8 +60,16 @@ .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 @@ -116,12 +124,6 @@ .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 @@ -159,4 +161,16 @@ ; 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 diff --git a/src/levels.s b/src/levels.s index 4618e1b..87a1d2a 100644 --- a/src/levels.s +++ b/src/levels.s @@ -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 diff --git a/src/macros.inc b/src/macros.inc index 080a976..16a57d5 100644 --- a/src/macros.inc +++ b/src/macros.inc @@ -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 diff --git a/src/map.s b/src/map.s index d38df5a..6a10cb2 100644 --- 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 diff --git a/src/player.s b/src/player.s index 1d2815f..1a36568 100644 --- a/src/player.s +++ b/src/player.s @@ -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 diff --git a/src/wram.s b/src/wram.s index 5161ecb..c0e89a7 100644 --- a/src/wram.s +++ b/src/wram.s @@ -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