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
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:
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