projects
/
gbrg
/
.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
9518d4e
)
player: Added code to calculate cursor building offset when pressing a
author
Lukas Krickl
<lukas@krickl.dev>
Thu, 10 Apr 2025 12:04:29 +0000
(14:04 +0200)
committer
Lukas Krickl
<lukas@krickl.dev>
Thu, 10 Apr 2025 12:04:29 +0000
(14:04 +0200)
src/macros.inc
patch
|
blob
|
history
src/player.s
patch
|
blob
|
history
diff --git
a/src/macros.inc
b/src/macros.inc
index 8c80e8188215a7423651a4be56e54e73d0aa240f..4f82d8a2c1ea07cd40ea90455311a5ae364d516e 100644
(file)
--- a/
src/macros.inc
+++ b/
src/macros.inc
@@
-60,14
+60,13
@@
- ; divides a regiser by
16
+ ; divides a regiser by
8
; inputs:
; $1: the register
-#macro div
16
+#macro div
8
srl $1 ; / 2
srl $1 ; / 4
srl $1 ; / 8
- srl $1 ; / 16
#endmacro
; multiplies a regiser with 8
diff --git
a/src/player.s
b/src/player.s
index 3330c899a84583235613522ec27d318fdbda2577..39b875830e7bcfe8135983b1db2027c3a9fa33d9 100644
(file)
--- a/
src/player.s
+++ b/
src/player.s
@@
-218,5
+218,33
@@
try_abort_move_at:
; at cursor_y/x
; aborts if the tiel will not fit
cursor_place_tile:
+ ; find the cell the cursor has selected
+ ld hl, state_cells
+
+ ; move y rows down
+ ld de, MAP_W * c_size
+ ld a, [cursor_y]
+ div8 a
+ cp a, 0
+ jr z, @not_y_loop REL
+@y_loop:
+ add hl, de
+ dec a
+ cp a, 0
+ jr nz, @y_loop REL
+@not_y_loop:
+
+ ; move x cells
+ ld de, c_size
+ ld a, [cursor_x]
+ div8 a
+ cp a, 0
+ jr z, @not_x_loop REL
+@x_loop:
+ add hl, de
+ dec a
+ cp a, 0
+ jr nz, @x_loop REL
+@not_x_loop:
ret