mapgen: wip mapgen
authorLukas Krickl <lukas@krickl.dev>
Thu, 21 Aug 2025 13:58:27 +0000 (15:58 +0200)
committerLukas Krickl <lukas@krickl.dev>
Thu, 21 Aug 2025 13:58:27 +0000 (15:58 +0200)
src/mapgen.s

index a03a085b2e4d760373123327e7cfc7cb87c117ce..04df7209900a3f9fb73218e584ce6ebeedae44dd 100644 (file)
@@ -146,8 +146,8 @@ mapgen:
        ; avoids placing doors at the edge.
        ; stops after plaving at least N  doors
 mapgen_make_doors:
-       ld b, 3
-       ld c, 3 ; bc = y/x position
+       ld b, 
+       ld c, 1 ; bc = y/x position
        ; start current ptr at 1/1 as well
        ld hl, map_doors_location + 1  * FLOOR_W 
 
@@ -159,8 +159,8 @@ mapgen_make_doors:
        push bc
        push hl
        call rand
-       add a, FLOOR_MAP_COUNT * 2 ; at least N doors
-       and a, (FLOOR_MAP_COUNT - 1) * 4
+       add a, 12 ; at least N doors
+       and a, (FLOOR_MAP_COUNT - 1) 
 
        pop hl
        pop bc
@@ -186,6 +186,7 @@ mapgen_make_doors:
                pop af
                dec a
                jr nz, @loop REL
+       BREAK
        ret
        
        ; creates the counterpart to 
@@ -299,9 +300,9 @@ make_door:
        ld [hl], a
 
        dec b ; y--
-
-       ld de, -FLOOR_W & 0xFFFF
-       add hl, de ; hl one row up
+       
+       ; move hl up one row
+.rep i, FLOOR_W, 1, dec hl
 
        pop af
        ret
@@ -317,8 +318,8 @@ make_door:
 
        inc bc ; y++
 
-       ld de, FLOOR_W
-       add hl, de ; hl one row downa
+       ; move hl one row down  
+.rep i, FLOOR_W, 1, inc hl
 
        pop af
        ret