From: Lukas Krickl Date: Thu, 27 Feb 2025 19:50:32 +0000 (+0100) Subject: actor/player: Added basic cursor tile X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=cd9cb2cac7bcc7cbc7c6f9116257e47dc72bafac;p=gbrg%2F.git actor/player: Added basic cursor tile This tile indicate which actor is currently moving. --- diff --git a/src/actor.s b/src/actor.s index 2a1d4b7..6026260 100644 --- a/src/actor.s +++ b/src/actor.s @@ -270,6 +270,7 @@ actor_update_null: ; bat actor actor_update_bat: actor_check_who + call z, draw_cursor jr nz, @skip REL ; call state update @@ -432,6 +433,40 @@ anim_clear: ld [anim_target_x], a ret + ; draws cursor at the active actor's location + ; inputs: + ; bc: actor_ptr +draw_cursor: + push_all + + inc bc + ld a, [bc] + ld d, a ; d = y + inc bc + ld a, [bc] + ld e, a ; e = x + +@draw: + ; draw obj + ld hl, PLAYER_SPRITE1+12 + ld a, d ; a = y + add a, OBJ_OFF_Y + ld [hl+], a + + ld a, e ; a = x + add a, OBJ_OFF_X + ld [hl+], a + + ld a, CURSOR_TILE + ld [hl+], a + + xor a, a + ld [hl], a + + pop_all + + ret + ; advance to the next actor if end_turn != 0 ; effectively ending the current actor's turn who_next: diff --git a/src/player.s b/src/player.s index fdf3c42..a47cd3d 100644 --- a/src/player.s +++ b/src/player.s @@ -1,6 +1,8 @@ ; player gets 3 sprite slots in a row .def int PLAYER_SPRITE1 = shadow_oam + 0 +.def int CURSOR_TILE = 0x04 + .def int PLAYER_TILE_IDLE1 = 0x00 .def int PLAYER_TILE_IDLE2 = 0x12 @@ -51,6 +53,15 @@ player_init: ret +player_draw_cursor: + push hl + push hl + pop bc + dec bc ; bc = fake player actor + call draw_cursor + pop hl + ret + ; update the player ; players do not behave like regular actors ; and are not allocate to the regular @@ -61,6 +72,7 @@ player_update: ; update ld a, [who] cp a, WHO_PLAYER + call z, player_draw_cursor jp nz, @skip_input ; call state update diff --git a/tiles/tileset0.inc b/tiles/tileset0.inc index 12d1cf6..c4b76c7 100644 --- a/tiles/tileset0.inc +++ b/tiles/tileset0.inc @@ -35,12 +35,12 @@ .chr 00003333 .chr 00000000 ; tile 4 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 +.chr 11111100 +.chr 13333300 +.chr 13333300 +.chr 13300000 +.chr 13300000 +.chr 13300000 .chr 00000000 .chr 00000000 ; tile 5