From: Lukas Krickl Date: Sun, 5 Oct 2025 04:08:33 +0000 (+0200) Subject: map: Added map routine and map object that can set map routines X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=02ab9027bd1ea76a113c1e56a7907374e79f1d5b;p=gbrg%2F.git map: Added map routine and map object that can set map routines --- diff --git a/src/defs.s b/src/defs.s index 28965ba..ad55b85 100644 --- a/src/defs.s +++ b/src/defs.s @@ -14,7 +14,7 @@ #define NULL 0 #define ACTS_PLAYER_PROJECTILES 6 -#define ACTS_ENEMY 6 +#define ACTS_ENEMY 4 #define ACTS_ENEMY_PROJECTILES 6 #define ACTS_MAX (ACTS_PLAYER_PROJECTILES + ACTS_ENEMY + ACTS_ENEMY_PROJECTILES) @@ -130,6 +130,7 @@ .de MOT_ENABLE_SCROLL, 1 .de MOT_RECT, 1 .de MOT_ACTOR_SPAWNER, 1 +.de MOT_SET_MAP_ROUTINE, 1 ; map object struct .se 0 diff --git a/src/map.s b/src/map.s index 0c5f256..8a8a2fb 100644 --- a/src/map.s +++ b/src/map.s @@ -8,6 +8,12 @@ ; inputs: ; de: map ptr map_load: + ; clear map routine + ld a, map_r_nop LO + ld [map_routine], a + ld a, map_r_nop HI + ld [map_routine+1], a + call disableinterrupts call next_vblank_wait call lcd_off @@ -236,6 +242,16 @@ map_page_full_draw: call next_vblank_wait call map_advance_row ret + + ; nop map rotuine +map_r_nop: + ret + + ; checks if all enemies are defeated + ; and re-enables scroll +map_r_enable_scroll_all_enemies_defeated: + ; TODO + ret l1_map: mapdef 0, pat_empty, l1_objs, bank8000, bank8800, bank8C00, bank9000 @@ -261,4 +277,7 @@ l1_objs: modef MOT_SET_PAT, 0, 0x1E, pat_empty modef MOT_DISABLE_SCROLL, 0, 0x20, 0 + modef MOT_SET_MAP_ROUTINE, 0, 0x20, map_r_enable_scroll_all_enemies_defeated modef MOT_NOP, 0, 0xFF, 0 + + diff --git a/src/mapobj.s b/src/mapobj.s index 8c0bd40..99fa9a8 100644 --- a/src/mapobj.s +++ b/src/mapobj.s @@ -12,6 +12,7 @@ mo_routines: dw mo_enable_scroll dw mo_rect dw mo_actor_spawner + dw mo_set_map_routine mo_nop: ret @@ -215,3 +216,16 @@ mo_actor_spawner: call actor_init ret + + ; sets the current map routine + ; dat1/2: map routine ptw + ; inputs: + ; de: map object ptr +mo_set_map_routine: + ld hl, mo_dat + add hl, de + ld a, [hl+] + ld [map_routine], a + ld a, [hl+] + ld [map_routine+1], a + ret diff --git a/src/update.s b/src/update.s index d44be69..4248076 100644 --- a/src/update.s +++ b/src/update.s @@ -11,11 +11,17 @@ update_game: call player_update call actor_update_all - ; clear oam call shadow_oam_clear_rest + ; update map + ld a, [map_routine] + ld l, a + ld a, [map_routine+1] + ld h, a + call_hl + ret new_game: diff --git a/src/wram.s b/src/wram.s index aa53b34..62dd776 100644 --- a/src/wram.s +++ b/src/wram.s @@ -109,6 +109,11 @@ map_curr_obj: .adv 2 ; current bg pointer to write to map_scrn_ptr: .adv 2 + + ; map update routine + ; can be set by map object +map_routine: .adv 2 + ; current debug function dbg_fn: .adv 1