From e078591fc511d009f4e76f8b99b50d3f7fcf772d Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Wed, 1 Jan 2025 10:20:30 +0100 Subject: [PATCH] map: Removed clearing code for exits since they should be zeroed anyway --- src/map.s | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/map.s b/src/map.s index 43f2509..6146595 100644 --- 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 -- 2.30.2