From 09ba471b985fa6bfa065e71b4b441a0575b4878d Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Fri, 4 Oct 2024 16:30:09 +0200 Subject: [PATCH] added init player function --- src/main.s | 4 +++- src/player.s | 32 ++++++++++++++++++++++++++++++++ src/wram.s | 14 ++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/src/main.s b/src/main.s index 2a059a3..a77c47e 100644 --- a/src/main.s +++ b/src/main.s @@ -17,7 +17,9 @@ entry: call video_init call lcd_on call vblank_wait - + + ld hl, player + call player_init call enableinterrupts diff --git a/src/player.s b/src/player.s index 378bd73..322ff0b 100644 --- a/src/player.s +++ b/src/player.s @@ -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 diff --git a/src/wram.s b/src/wram.s index 0cc107a..acae72c 100644 --- a/src/wram.s +++ b/src/wram.s @@ -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 -- 2.30.2