From: Lukas Krickl Date: Thu, 31 Jul 2025 19:49:43 +0000 (+0200) Subject: mapgen: Added stub for placing random actors on a new map X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=a2b87f4a510a5915412fe1f7b7c1957ecc52d1b2;p=gbrg%2F.git mapgen: Added stub for placing random actors on a new map --- diff --git a/src/map.s b/src/map.s index cf9de48..ebd1d7b 100644 --- a/src/map.s +++ b/src/map.s @@ -11,6 +11,12 @@ map_init: ; TODO: do not touch lcd or interrupts if ; they were not enabled! map_load: + ; backup the map header + ld a, l + ld [map_header], a + ld a, h + ld [map_header+1], a + ; disable interruts ; wait for next blank ; disable lcd diff --git a/src/mapgen.s b/src/mapgen.s index 3e138fd..dfb7560 100644 --- a/src/mapgen.s +++ b/src/mapgen.s @@ -29,6 +29,7 @@ mapgen_seed: ; hl: writable decompressed tile array (e.g [map]) ; of size MAP_H * MAP_W ; de: the seed used + ; map_header: the current map header ; returns: ; a == 0: room was unable to be placed ; a == 1: room was placed @@ -60,6 +61,8 @@ mapgen: call mapgen_place_special_room + call mapgen_place_actors + ; restore seed pop bc @@ -389,3 +392,18 @@ mapgen_fix_door_adjacent_to_collider: mapgen_fix_door_fixup c_size, RPRW ret + + ; places actors from a valid actor table + ; in the current map's header. This will overwrite the + ; header loaded by map_load. Preserves player entry. + ; inputs: + ; a loaded map + ; [map_header] ptr +mapgen_place_actors: + ; load map ptr + ld a, [map_header] + ld l, a + ld a, [map_header+1] + ld h, a + + ret diff --git a/src/wram.s b/src/wram.s index 795d53f..b0a88b0 100644 --- a/src/wram.s +++ b/src/wram.s @@ -159,5 +159,7 @@ map_end: map_st: .adv st_size ; current exit table ptr map_exit_table: .adv 2 + ; ptr to the last map header used +map_header: .adv 2 state_end: