From acc54c7f2fc3747f0f88b3e7f614bd3d10c43ba2 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Fri, 13 Feb 2026 08:01:25 +0100 Subject: [PATCH] mapgen: added docs for generating rooms --- src/defs.s | 1 + src/mapgen.s | 19 ++++++++++++++----- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/defs.s b/src/defs.s index 07e1f17..afa9e44 100644 --- a/src/defs.s +++ b/src/defs.s @@ -38,6 +38,7 @@ #define MAP_W 32 #define MAP_H 32 #define MAP_TILES (MAP_W * MAP_H) +#define MAP_SECTION_SIZE 8 #define RENDER_BUF_W 20 #define RENDER_BUF_H 14 diff --git a/src/mapgen.s b/src/mapgen.s index 71d9dbf..4e0d3dc 100644 --- a/src/mapgen.s +++ b/src/mapgen.s @@ -52,10 +52,7 @@ map_generate: ; 3) make rooms - ; TODO: this is a test room - ld hl, mapgen_tiles+1+MAP_W - ld bc, 0x0505 ; 5x5 - call mapgen_mak_room + call mapgen_make_rooms ; cleanup) finally @@ -71,6 +68,18 @@ map_generate: ld [mapgen_game_seed+1], a ld [srand+1], a ret + + ; generates all rooms + ; for each section of the map + ; the map is split into MAP_SECTION_SIZExMAP_SECTION_SIZE + ; sections (e.g. 4x4 sections of 8x8 tiles) + ; rooms are placed in each section and then linked up using hallways +mapgen_make_rooms: + ; TODO: this is a test room + ld hl, mapgen_tiles+1+MAP_W + ld bc, 0x0505 ; 5x5 + call mapgen_make_room + ret ; generates a single rectanglular room ; the caller must ensutre hl has enough tiles in @@ -79,7 +88,7 @@ map_generate: ; inputs: ; hl: start position in tile map ; b/c: height/width of room -mapgen_mak_room: +mapgen_make_room: ld de, MAP_W @draw_row: ; save original hl -- 2.30.2