From 7083ad73ed1ab762f9a827b60de5f296397bee8e Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Mon, 25 Aug 2025 14:29:47 +0200 Subject: [PATCH] mapgen: The player now spawns in a random spot --- src/mapgen.s | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/mapgen.s b/src/mapgen.s index 1ea33ab..4d661ab 100644 --- a/src/mapgen.s +++ b/src/mapgen.s @@ -614,16 +614,27 @@ mapgen_select_player_spawn: call map_get_tile cp a, 0x00 ; we want no flags here pop bc - jr z, @try_placement_again REL + jr nz, @try_placement_again REL + + push bc + ; test if a unit is here + call unit_find_at + ld a, h + or a, l + pop bc + jp nz, @try_placement_again REL ; otherwise write position ld hl, player_unit ld de, act_pos_y add hl, de ld a, b - ;ld [hl+], a ; write y + ld [hl+], a ; write y ld a, c - ;ld [hl], a ; write x + ld [hl], a ; write x + + ld de, player_unit + call unit_scroll_center ret -- 2.30.2