added init player function
authorLukas Krickl <lukas@krickl.dev>
Fri, 4 Oct 2024 14:30:09 +0000 (16:30 +0200)
committerLukas Krickl <lukas@krickl.dev>
Fri, 4 Oct 2024 14:30:09 +0000 (16:30 +0200)
src/main.s
src/player.s
src/wram.s

index 2a059a3c63918348eaa1b83e30d93c182d0df82e..a77c47e29173b8b7527769f354660e3ee728a50c 100644 (file)
@@ -17,7 +17,9 @@ entry:
   call video_init
   call lcd_on
   call vblank_wait
-
+  
+  ld hl, player
+  call player_init
 
   call enableinterrupts
 
index 378bd73f7577a0e624b07635086c271d2afecbd3..322ff0bb6c2243ddc81b31fe50166171e19def3c 100644 (file)
@@ -5,6 +5,38 @@
 .def int PLAYER_TILE_IDLE2 = 0x14
 .def int PLAYER_TILE_IDLE3 = 0x24
 
+  ; init the player 
+  ; inputs:
+  ;   hl: pointer to player memory
+player_init:
+  xor a, a
+  ; y
+  ld [hl+], a
+  ; x
+  ld [hl+], a
+  ; flags
+  ld [hl+], a
+
+  ; default hp max
+  ld a, PLAYER_DEFAULT_HP
+  ld [hl+], a ; hp
+  ld [hl+], a ; hp max
+
+  ; default mp max
+  ld a, PLAYER_DEFAULT_MP
+  ld [hl+], a ; mp
+  ld [hl+], a ; mp max
+
+  ; default def 
+  ld a, PLAYER_DEFAULT_DEF 
+  ld [hl+], a
+
+  ; default atk 
+  ld a, PLAYER_DEFAULT_ATK
+  ld [hl+], a
+
+  ret
+
   ; update the player 
   ; players do not behave like regular actors
   ; and are not allocate to the regular 
index 0cc107af882be6238326e25f9e680f18c6b4ee39..acae72c4274c23a7e668be9d7c6a37bd7b9cf9c2 100644 (file)
@@ -30,11 +30,25 @@ prev_inputs: .adv 1
 
 actor_table: .adv ACTORS_MAX * actor_size
 
+#define PLAYER_DEFAULT_HP 3
+#define PLAYER_DEFAULT_MP 3
+#define PLAYER_DEFAULT_DEF 1
+#define PLAYER_DEFAULT_ATK 1
+
 ; struct player
 .se 0
 .de player_y, 1
 .de player_x, 1
 .de player_flags, 1
+
+  ; player stats
+.de player_hp, 1
+.de player_hp_max, 1
+.de player_mp, 1
+.de player_mp_max, 1
+.de player_def, 1
+.de player_atk, 1
+
 .de player_size, 0
 
 player: .adv player_size