From 0e8e19c5ea2f465364f977529712effe7a084184 Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Wed, 11 Feb 2026 05:46:12 +0100 Subject: [PATCH] mapgen: Added simple room drawing test --- src/mapgen.s | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/mapgen.s b/src/mapgen.s index 614c056..71d9dbf 100644 --- a/src/mapgen.s +++ b/src/mapgen.s @@ -51,6 +51,11 @@ map_generate: ld [hl+], a ; 3) make rooms + + ; TODO: this is a test room + ld hl, mapgen_tiles+1+MAP_W + ld bc, 0x0505 ; 5x5 + call mapgen_mak_room ; cleanup) finally @@ -66,3 +71,41 @@ map_generate: ld [mapgen_game_seed+1], a ld [srand+1], a ret + + ; generates a single rectanglular room + ; the caller must ensutre hl has enough tiles in + ; the y and x direction to allow the room to fit. + ; places actors in the room + ; inputs: + ; hl: start position in tile map + ; b/c: height/width of room +mapgen_mak_room: + ld de, MAP_W +@draw_row: + ; save original hl + push hl + + ; save original w + push bc + +@draw_col: + ld a, TI_FLOOR + ld [hl+], a + + dec c ; width-- + jr nz, @draw_col REL + + ; restore w + ld a, b ; need to save height + pop bc + ld b, a + + pop hl + ; go to next row + add hl, de + dec b ; height-- + jr nz, @draw_row REL + + ; TODO: place actors + ret + -- 2.30.2