From: Lukas Krickl Date: Thu, 19 Feb 2026 05:03:22 +0000 (+0100) Subject: mapgen: Fixed map seed X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=d7d8ce3891f00a9dfc303817c3dca7488b033c47;p=gbrg%2F.git mapgen: Fixed map seed Map seeds were not set correctly and restoring was also broken. --- diff --git a/src/mapgen.s b/src/mapgen.s index 3aaab42..6bebab6 100644 --- a/src/mapgen.s +++ b/src/mapgen.s @@ -10,11 +10,12 @@ mapgen_init_seeds: ; numbers into rng ld b, MAPGEN_FLOORS_MAX * 2 @loop: + push hl call rand + pop hl ld [hl+], a dec b - jr z, @loop REL - + jr nz, @loop REL call mbc1_ram_disable ret @@ -38,6 +39,7 @@ map_generate: ld [mapgen_game_seed+1], a ; load the seed + call mbc1_ram_enable call save_file_select ld d, 0 ld a, [mapgen_floor] @@ -46,7 +48,8 @@ map_generate: ld a, [hl+] ld [srand], a ld a, [hl] - ld [srand], a + ld [srand+1], a + call mbc1_ram_disable ; 2) set up map header @@ -82,10 +85,11 @@ map_generate: ; cleanup) finally ; restore game seed from rng - ld [mapgen_game_seed], a + ld a, [mapgen_game_seed] ld [srand], a - ld [mapgen_game_seed+1], a + ld a, [mapgen_game_seed+1] ld [srand+1], a + BREAK ret ; makes a room at a sector offset