actor/player: Added basic cursor tile
authorLukas Krickl <lukas@krickl.dev>
Thu, 27 Feb 2025 19:50:32 +0000 (20:50 +0100)
committerLukas Krickl <lukas@krickl.dev>
Thu, 27 Feb 2025 19:50:32 +0000 (20:50 +0100)
This tile indicate which actor is currently moving.

src/actor.s
src/player.s
tiles/tileset0.inc

index 2a1d4b7f99d6ab3c10719fb539d58eb4919660f0..60262600822a2f5b549c76021927564be514987f 100644 (file)
@@ -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:
index fdf3c421896ad5c4913229e12bafb53f39204d63..a47cd3d6b933ea1a224619fd659277a0435c4171 100644 (file)
@@ -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
index 12d1cf673cbc15d7118d488870dd42e7b67254ab..c4b76c7bbe8e3a82cde738068115f7f9e4c0ce7e 100644 (file)
 .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