map: Removed clearing code for exits since they should be zeroed anyway
authorLukas Krickl <lukas@krickl.dev>
Wed, 1 Jan 2025 09:20:30 +0000 (10:20 +0100)
committerLukas Krickl <lukas@krickl.dev>
Wed, 1 Jan 2025 09:20:30 +0000 (10:20 +0100)
src/map.s

index 43f250915cd56a8de775e571d452a5fee5033725..6146595ec4dfd96181538542ccbf2a87c7990d22 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -489,13 +489,20 @@ map_generate:
 
   ld d, ROOMS_TOTAL ; d = loop counter
   ld hl, map0 ; hl = current room
+  ld de, map0 ; de = previous room 
 
   ; move to map_gen_next from here 
   
   ; generate the next room 
   ; inputs:
   ;   hl: current room
+  ;   de: previous room
+  ;    a: 0 == stop recursion
+  ;    a: 1 == continue recurions
 map_gen_next:
+  push hl ; save current room
+  push de ; save previous room
+
   ; depth ++
   ld a, [mapgen_depth]
   inc a
@@ -571,8 +578,24 @@ map_gen_next:
   ld a, [mapgen_depth]
   dec a
   ld [mapgen_depth], a
+
+  ; pop saved registers 
+  pop de
+  pop hl
+
   ret
 
+  ; link two rooms together
+  ; by setting up the exit pointers 
+  ; for a given direction
+  ; inputs:
+  ;   a: direction
+  ;  hl: source room header
+  ;  de: target room header
+map_gen_link_rooms:
+  ret
+
+
   ; copies a base room
   ; sets all exits to 0000 (null ptr)
   ; inputs:
@@ -722,9 +745,11 @@ map_gen_copy_base_room:
   ld [hl], a
 
   pop hl ; hl = exit table location 
-  ; set exits to NULL  
+  ; skip exit bytes to get hl in position for next operation
+  ; all values should be 0 at this point because
+  ; we memset the entire map
   xor a, a
-.rep ci, 2 * ROOM_EXITS_MAX, 1, ld a, [hl+]
+.rep ci, 2 * ROOM_EXITS_MAX, 1, inc hl 
 
   ret