From: Lukas Krickl Date: Sun, 27 Jul 2025 06:33:52 +0000 (+0200) Subject: room patterns: Added room pattern generation for special patterns X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=41f7ddfbdf9ed5c2b55c829159b2472d717b2ceb;p=gbrg%2F.git room patterns: Added room pattern generation for special patterns Mainmenu now ticks rng every frame to ensure randomness when pressing new game. --- diff --git a/src/mainmenu.s b/src/mainmenu.s index eec7f28..14c1e53 100644 --- a/src/mainmenu.s +++ b/src/mainmenu.s @@ -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 diff --git a/src/mapgen.s b/src/mapgen.s index 8ffda5a..6977096 100644 --- a/src/mapgen.s +++ b/src/mapgen.s @@ -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 diff --git a/src/roompatterns.s b/src/roompatterns.s index bb84379..645308f 100644 --- a/src/roompatterns.s +++ b/src/roompatterns.s @@ -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)