; 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
.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
; 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
.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
#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
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
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
; 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
; 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