actor: fixed endianess problem when setting actor table
authorLukas Krickl <lukas@krickl.dev>
Tue, 3 Feb 2026 14:58:31 +0000 (15:58 +0100)
committerLukas Krickl <lukas@krickl.dev>
Tue, 3 Feb 2026 14:58:31 +0000 (15:58 +0100)
Fixed bat not having stamina causing hp to overflow

src/actor.s
src/attributes.s
src/macros.inc
src/math.s
src/player.s

index 8a31e56f96463f8a1f3f34b4babcecafe2169799..fe57087e4197e7810c2b52937c5f5663529fc2a0 100644 (file)
@@ -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
index ed325fb31551364adb189f3f61a308d53abaf0f1..63f3c069577516e6b85f53910f048e7997b6f0ae 100644 (file)
@@ -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]
index ba38410e2fad5aa9ef6090bf1f96d07b41aa5e4e..33eb77ef23bd5736e193c9f147e8bed953172a92 100644 (file)
@@ -52,8 +52,8 @@
 #endmacro
 
   ; same as dw but 
-  ; stores in big endian
-#macro dw
+  ; stores in little endian
+#macro dwl
 .db ($1 >> 8) & 0xFF 
 .db $1 & 0xFF
 #endmacro
index d1b0dcc5c500be4a07da4a3f8ac987033e1d49a1..152775a1d46b010d27135279d1c0db577d9d4df1 100644 (file)
@@ -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]
index b61f052544fff80051139ef447aadc2005eda66a..bdd25a8aa858f34f23875f0c600b8511a4f4aceb 100644 (file)
@@ -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