From: Lukas Krickl Date: Sat, 14 Feb 2026 16:52:16 +0000 (+0100) Subject: mapgen: Added map section drawing macro X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=995f8a5abbd34d8c380f5f12fea414febb8b5f8a;p=gbrg%2F.git mapgen: Added map section drawing macro --- diff --git a/src/defs.s b/src/defs.s index afa9e44..e152935 100644 --- a/src/defs.s +++ b/src/defs.s @@ -39,6 +39,7 @@ #define MAP_H 32 #define MAP_TILES (MAP_W * MAP_H) #define MAP_SECTION_SIZE 8 +#define MAP_SECTION_PER_ROW (MAP_W / MAP_SECTION_SIZE) #define RENDER_BUF_W 20 #define RENDER_BUF_H 14 diff --git a/src/mapgen.s b/src/mapgen.s index 4e0d3dc..343289a 100644 --- a/src/mapgen.s +++ b/src/mapgen.s @@ -69,16 +69,36 @@ map_generate: ld [srand+1], a ret + ; makes a room at a sector offset + ; the room is placed randomly within the sector + ; and then drawn. + ; inputs: + ; $1: sector y + ; $2: sector x +#macro _mapgen_make_room_section +.beginscope + ld hl, mapgen_tiles + MAP_SECTION_SIZE * MAP_SECTION_PER_ROW * MAP_SECTION_SIZE \ + * $1 + MAP_SECTION_SIZE * $2 + ld bc, 0x0808 ; 8x8 fill the entire sector for now + call mapgen_make_room +.endscope +#endmacro + ; 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 + _mapgen_make_room_section 0, 0 + _mapgen_make_room_section 0, 1 + _mapgen_make_room_section 0, 2 + _mapgen_make_room_section 0, 3 + + _mapgen_make_room_section 1, 0 + _mapgen_make_room_section 1, 1 + _mapgen_make_room_section 1, 2 + _mapgen_make_room_section 1, 3 ret ; generates a single rectanglular room