From: Lukas Krickl Date: Tue, 3 Feb 2026 14:58:31 +0000 (+0100) Subject: actor: fixed endianess problem when setting actor table X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=e45910125c96ce2253d4e8a82716a8b2614cc46a;p=gbrg%2F.git actor: fixed endianess problem when setting actor table Fixed bat not having stamina causing hp to overflow --- diff --git a/src/actor.s b/src/actor.s index 8a31e56..fe57087 100644 --- a/src/actor.s +++ b/src/actor.s @@ -413,9 +413,8 @@ act_load_attr_table: add hl, de ; hl = attr table ptr ld a, [hl+] - ld c, [hl] - ld b, a - + ld b, [hl] + ld c, a ; bc = attribute table ret diff --git a/src/attributes.s b/src/attributes.s index ed325fb..63f3c06 100644 --- a/src/attributes.s +++ b/src/attributes.s @@ -11,7 +11,7 @@ attr_null: attrdef 0, 0, 0, 0, 0 attr_bat: -attrdef 1, 0, 0, 0, 0 +attrdef 1, 1, 1, 1, 0 ; gets the max hp for an actor ; hp formula: @@ -138,7 +138,6 @@ act_attr_write_hp: ; bc: damage value act_attr_take_weapon_damage: push de - ; TODO: apply resistances to bc m16_write_bc m16_b @@ -153,7 +152,6 @@ act_attr_take_weapon_damage: pop de call act_attr_write_hp - BREAK ; if m16_flags carry is set ; -> die ld a, [m16_flags] diff --git a/src/macros.inc b/src/macros.inc index ba38410..33eb77e 100644 --- a/src/macros.inc +++ b/src/macros.inc @@ -52,8 +52,8 @@ #endmacro ; same as dw but - ; stores in big endian -#macro dwb + ; stores in little endian +#macro dwl .db ($1 >> 8) & 0xFF .db $1 & 0xFF #endmacro diff --git a/src/math.s b/src/math.s index d1b0dcc..152775a 100644 --- a/src/math.s +++ b/src/math.s @@ -125,7 +125,7 @@ m16_add: m16_sub: xor a, a ldh [m16_flags], a - + ldh a, [m16_b] ld b, a ldh a, [m16_a] diff --git a/src/player.s b/src/player.s index b61f052..bdd25a8 100644 --- a/src/player.s +++ b/src/player.s @@ -47,9 +47,9 @@ player_init: ld [player+act_mp], a ; set player attribute table - ld a, player_attr HI - ld [player+act_attr], a ld a, player_attr LO + ld [player+act_attr], a + ld a, player_attr HI ld [player+act_attr+1], a ; set default stats