From: Lukas Krickl Date: Thu, 2 Jan 2025 21:50:21 +0000 (+0100) Subject: map: Maps can now swap room tables based on the current floor X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=8a5200eacdf4cb016b57d3c167075829a46265c2;p=gbrg%2F.git map: Maps can now swap room tables based on the current floor --- diff --git a/src/map.s b/src/map.s index 5f18769..d25d477 100644 --- a/src/map.s +++ b/src/map.s @@ -533,10 +533,27 @@ map_gen_next: ; load base room ptr + ; select table based on level first + ld hl, room_tables + ld a, [floor] + add a, a ; * 2 for offset in ptr table + ld b, 0 + ld c, a + add hl, bc ; hl = room table ptr based on floor + + ld a, [hl+] + ld b, a + ld a, [hl] + ld h, a + ld l, b ; hl = room table max length + ld a, [hl+] ; hl = first room entry + ld b, a ; b = max length of room table + ; select a room randomly from the table + push hl call rand - ld hl, base_room_table - and a, BASE_ROOM_TABLE_LEN + pop hl + and a, b ld b, 0 ld c, a add hl, bc ; base + random offset @@ -1003,13 +1020,20 @@ map_gen_copy_base_room: #include "base_room.s" #include "base_room2.s" + + ; the first byte of the table is the length of the table ; a table of all base room ptrs ; length must be divisible by 2 base_room_table: + .db BASE_ROOM_TABLE_LEN dw base_room_header dw base_room2_header base_room_table_end: + ; a table of all room tables + ; to allow for room sets per level +room_tables: + dw base_room_table ; exit table for empty exits room_empty_exits: