room patterns: Added room pattern generation for special patterns
authorLukas Krickl <lukas@krickl.dev>
Sun, 27 Jul 2025 06:33:52 +0000 (08:33 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sun, 27 Jul 2025 06:33:52 +0000 (08:33 +0200)
Mainmenu now ticks rng every frame to ensure randomness when pressing
new game.

src/mainmenu.s
src/mapgen.s
src/roompatterns.s

index eec7f28ee30729e95ddfe7e11768367021ba565f..14c1e5329d73f261d18e3ba18b09a57ec9dd0386 100644 (file)
@@ -17,6 +17,8 @@ main_menu_cursor_locations_y:
   ; handles cursor sprite drawing
   ; handles file/new game selection
 main_menu_update:
+  call rand
+
   ; clear oam
   call shadow_oam_clear
 
index 8ffda5adf4b5ce86e33b2c63ef63afda033a0f8a..6977096a0282559e8680c9130dba89be051429cf 100644 (file)
@@ -58,6 +58,8 @@ mapgen:
   call mapgen_up_right_room
   call mapgen_bottom_right_room
 
+  call mapgen_place_special_room
+
 
   ; restore seed
   pop bc
@@ -179,6 +181,37 @@ mapgen_bottom_right_room:
   call mapgen_draw_room_pattern
   pop hl
   ret
+  
+  ; rolls rng
+  ; if value > 128 a random special room is placed
+  ; special rooms overwrite other rooms and are larger room
+  ; patterns
+  ; special rooms are placed starting in the top left corner 
+  ; inputs:
+  ;   hl: [map]
+mapgen_place_special_room:
+  push hl
+  call rand
+  and a, 0x80
+  pop hl
+  ret z ; bail if no speical room is requested
+
+  ; move to correct location on map
+  ld bc, MAP_W*c_size
+  add hl, bc
+  inc hl
+  inc hl 
+  ; pick a room from the special pattern list
+
+  push hl
+  ld a, ROOM_PATTERN_SPECIAL_SIZE
+  ld hl, room_pattern_special
+  call mapgen_select_pattern
+  pop hl
+  
+  call mapgen_draw_room_pattern
+
+  ret
 
 
   ; draws a room pattern to the map
index bb8437935572f3daa93a1e07e7f8dd2871f4b831..645308f7ec9e19f6c2a485097d9c521bd6c45803 100644 (file)
@@ -88,6 +88,17 @@ room_pattern3:
   rprow RPFL, RPFL, RPDB, RPBW, RPBR, RPFL
   rprow RPFL, RPFL, RPFL, RPFL, RPFL, RPFL
 
+room_pattern_special1:
+  rpheaderdef 0x6E
+  .db RPUL, RPUW, RPUW, RPDU, RPUW, RPUW, RPUW, RPUW, RPUW, RPUW, RPUW, RPUW, RPUW, RPUR
+  .db RPLW, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPRW
+  .db RPLW, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPRW
+  .db RPLW, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPRW
+  .db RPLW, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPFL, RPRW
+  .db RPBL, RPBW, RPBW, RPBW, RPBW, RPDB, RPBW, RPBW, RPBW, RPBW, RPBW, RPBW, RPBW, RPBR
+
+  
+
   ; translation tables for tiles
 room_pattern_tile_translation:
   ; walls
@@ -110,11 +121,20 @@ room_pattern_flags_translation:
 
   ; table of 6 by 6 room patterns
 room_pattern_6x6:
-  dw room_pattern_empty
-  dw room_pattern1
+  dw room_pattern_empty
+  dw room_pattern1
   dw room_pattern1
   dw room_pattern2
   dw room_pattern3
 room_pattern_6x6_end:
 
 #define ROOM_PATTERN_6X6_SIZE ((room_pattern_6x6_end - room_pattern_6x6) / 2)
+  
+
+  ; table of special room patterns
+room_pattern_special:
+  dw room_pattern_special1
+  dw room_pattern_special1
+room_pattern_special_end:
+
+#define ROOM_PATTERN_SPECIAL_SIZE ((room_pattern_special_end - room_pattern_special) / 2)