From: Lukas Krickl Date: Fri, 10 Oct 2025 15:13:37 +0000 (+0200) Subject: map: Added new rectangle clear object. X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=1d0d28157d3868615eeff8c1e114ea6e4c5458a5;p=gbrg%2F.git map: Added new rectangle clear object. This object allows the targeted removal of all collision objects. This is way more straight forward than automatically clearing large rectangles. --- diff --git a/src/defs.s b/src/defs.s index ad55b85..3ca6774 100644 --- a/src/defs.s +++ b/src/defs.s @@ -131,6 +131,7 @@ .de MOT_RECT, 1 .de MOT_ACTOR_SPAWNER, 1 .de MOT_SET_MAP_ROUTINE, 1 +.de MOT_RECT_CLEAR, 1 ; map object struct .se 0 diff --git a/src/map.s b/src/map.s index ef1fb5d..35089cb 100644 --- a/src/map.s +++ b/src/map.s @@ -376,6 +376,7 @@ l1_objs: modef2 MOT_ACTOR_SPAWNER, 0, 11, ACT_T_GUARD, 0x80 modef MOT_SET_PAT, 0, 18, pat_center_empty_wall + modef MOT_RECT_CLEAR, 0, 18, 0 modef2 MOT_RECT, 0, 18, 0x0F, 0x08 modef2 MOT_ACTOR_SPAWNER, 0, 18, ACT_T_GUARD, 0x40 @@ -384,6 +385,7 @@ l1_objs: modef MOT_DISABLE_SCROLL, 0, 0x20, 0 modef MOT_SET_MAP_ROUTINE, 0, 0x20, map_r_enable_scroll_all_enemies_defeated + modef MOT_RECT_CLEAR, 0, 0x21, 0 modef MOT_SET_PAT, 0, 0x21, pat_center_empty_wall modef MOT_SET_PAT, 0, 0x2E, pat_empty modef MOT_DISABLE_SCROLL, 0, 0x30, 0 diff --git a/src/mapobj.s b/src/mapobj.s index 99fa9a8..8bdea40 100644 --- a/src/mapobj.s +++ b/src/mapobj.s @@ -13,6 +13,7 @@ mo_routines: dw mo_rect dw mo_actor_spawner dw mo_set_map_routine + dw mo_rect_clear mo_nop: ret @@ -229,3 +230,20 @@ mo_set_map_routine: ld a, [hl+] ld [map_routine+1], a ret + + ; clears all map rectangles + ; use this to despawn current collision + ; shapes +mo_rect_clear: + ld hl, rectangles + ld de, r_size + ld b, RECT_MAX + xor a, a +@loop: + ld [hl], a + add hl, de + dec b + jr nz, @loop REL + + + ret diff --git a/src/video.s b/src/video.s index d584386..f226a18 100644 --- a/src/video.s +++ b/src/video.s @@ -145,16 +145,8 @@ scroll_up_adjust: ld [hl+], a ; hl = r_pos_x - ; check if off-screen - cp a, -16 & 0xFF ; do not despawn if -16 - jr nc, @no_rect_despawn REL - - pop de - push de - ; despawn if *bottom* corner is far off-screen - cp a, 0xA0 - call nc, rect_despawn - + ; rectangles never despawn + ; unless cleared with mo_rect_clear @no_rect_despawn: pop hl