From: Lukas Krickl Date: Thu, 24 Jul 2025 16:15:35 +0000 (+0200) Subject: mapgen: Added setup for room patterns X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=bf646b5645739f873b21d889f3e694569545ac42;p=gbrg%2F.git mapgen: Added setup for room patterns --- diff --git a/RULES.md b/RULES.md index 1f85f19..e192458 100644 --- 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. diff --git a/src/map.s b/src/map.s index 22c28c6..0da455a 100644 --- 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 diff --git a/src/mapgen.s b/src/mapgen.s index 1223e52..a89bb7d 100644 --- a/src/mapgen.s +++ b/src/mapgen.s @@ -19,7 +19,39 @@ ; 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