map: wip get tile sub routine
authorLukas Krickl <lukas@krickl.dev>
Tue, 27 May 2025 17:57:06 +0000 (19:57 +0200)
committerLukas Krickl <lukas@krickl.dev>
Tue, 27 May 2025 17:57:06 +0000 (19:57 +0200)
src/map.s

index 58bce1e46ea0411ef4855a5d78e274894a11de50..ea237a018dd19555bc8daeade64ed60c7df829bb 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -12,8 +12,8 @@ map_init:
   ; inputs:
   ;   b/c: y/x tile position
   ; returns:
-  ;   a: tile
-  ;   b: flags
+  ;   a: flags 
+  ;   b: tile index 
 map_get_tile:
   ; current map
   ld hl, state_cells
@@ -30,10 +30,14 @@ map_get_tile:
   ld e, c
   ; add x offset c_size times
 .rep i, c_size, 1, add hl, de
-  
-  ; load values 
+  ; hl should now be the correct tile
 
 
+  ; load values 
+  ld a, [hl+] ; tile index
+  ld b, a
+  ld a, [hl] ; tile flags
+
   ret
 
  ; loads a map