mapgen: Added setup for room patterns
authorLukas Krickl <lukas@krickl.dev>
Thu, 24 Jul 2025 16:15:35 +0000 (18:15 +0200)
committerLukas Krickl <lukas@krickl.dev>
Thu, 24 Jul 2025 16:15:35 +0000 (18:15 +0200)
RULES.md
src/map.s
src/mapgen.s

index 1f85f192e558292d1edc0640b88c3a6ec5814e07..e1924588095365a6be35e47e0ac31e960089c448 100644 (file)
--- a/RULES.md
+++ b/RULES.md
@@ -1,20 +1,2 @@
 # Gameplay rules
 
-This is the rulebook for all the rpg elements
-
-## Dice
-
-The game rolls 16-sided (d16) dice to decide what happens.
-The outcome of all mechanics is decided by one or more dice rolls. 
-
-## Turns
-
-Each unit can move until all of its moves are used up.
-When all moves are used control is handed over to the next unit.
-
-## Initiative 
-
-When a unit ends its turn the unit with the next highest initiative is picked.
-A unit may fail to take initiative if a d16 roll fails (initiative < d16). In such a case another unit may be chosen.
-
-If all units fail to take initiative or have used all their moves all moves are reset and the process is restarted.
index 22c28c69f9951a3a131278d003c915eb43865eb1..0da455aaf19613f3af1daca55b3aab72e9c82cae 100644 (file)
--- a/src/map.s
+++ b/src/map.s
@@ -515,6 +515,9 @@ map_null_state:
   ldnull bc
   ret
 
+; template maps
+; maps can be loaded directly
+
 #include "map_c.s"
 #include "map_ce.s"
 #include "map_cw.s"
@@ -526,3 +529,21 @@ map_null_state:
 #include "map_be.s"
 #include "map_bc.s"
 #include "map_bw.s"
+
+; template rooms
+; rooms are template patterns that can be placed
+; on maps
+; the room pattern tiles used depend on the current floor
+; each pattern entry has a specific flag set that is placed in the map
+; room patterns are 6 by 6 areas with the following properties:
+.se 0
+.de ROOM_PAT_UP_LEFT_CORNER, 1
+.de ROOM_PAT_UP_WALL, 1
+.de ROOM_PAT_UP_RIGHT_CORNER, 1
+.de ROOM_PAT_LEFT_WALL, 1
+.de ROOM_PAT_BOTTOM_LEFT_CORNER, 1
+.de ROOM_PAT_BOTTOM_WALL, 1
+.de ROOM_PAT_BOTTOM_RIGHT_CORNER, 1
+.de ROOM_PAT_RIGHT_WALL, 1
+.de ROOM_PAT_FLOOR, 1
+.de ROOM_PAT_DOOR, 1
index 1223e52012f9feda19d34b20fbfd171e1058a6f3..a89bb7d856bf9b33080c69c52e6797cfcded9a2d 100644 (file)
   ;       de: seed after generation has finished
   ; preserves:
   ;   srand
-mapgen_make_room:
+mapgen:
   ; roll a room size
 
+  ; load seed
+  ; and back it up
+  ld a, [srand]
+  ld b, a
+  ld a, [srand+1]
+  ld c, a
+  push bc
+  
+  ; load seed param
+  ld a, e
+  ld [srand+1], a
+  ld a, d
+  ld [srand], a
+  
+  ; generate first room
+  push hl 
+  call mapgen_up_left_room
+  pop hl
+
+
+  ; restore seed
+  pop bc
+  ld a, c
+  ld [srand+1], a
+  ld b, a
+  ld [srand], a
+
+  ret
+
+  ; inputs:
+  ;   hl: [map]
+mapgen_up_left_room:
   ret