From 33e6ad8293998b5b316cd99663ec47ee5169bd3c Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sun, 5 Oct 2025 07:54:40 +0200 Subject: [PATCH] map: Added up arrow animation --- src/map.s | 79 +++++++++++++++++++++++++++++++++++++++++++--- src/wram.s | 7 ++++ tiles/bank8800.inc | 14 ++++---- 3 files changed, 89 insertions(+), 11 deletions(-) diff --git a/src/map.s b/src/map.s index 8a8a2fb..14be493 100644 --- a/src/map.s +++ b/src/map.s @@ -1,4 +1,12 @@ #define SCRN0_END 0x9BF3 + + ; clears the map routine to nop +map_clear_routine: + ld a, map_r_nop LO + ld [map_routine], a + ld a, map_r_nop HI + ld [map_routine+1], a + ret ; loads a map ; including the required tileset @@ -9,10 +17,7 @@ ; 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 map_clear_routine call disableinterrupts call next_vblank_wait @@ -250,7 +255,72 @@ map_r_nop: ; checks if all enemies are defeated ; and re-enables scroll map_r_enable_scroll_all_enemies_defeated: + ld a, [map_anim_timer] + cp a, 0 + jp z, @no_animation ; TODO + call map_arrow_indicator + ret + +@no_animation: + ; set animation + ld a, 120 + ld [map_anim_timer], a + + xor a, a + ld [map_anim_state], a + + ld a, 80 ; x position + ld [map_anim_p0], a + ret + +#define MAP_TILE_ARROW 0x84 + + ; plays an arrow indicator animation + ; flashng it every 32 frames + ; uses timer for duration + ; map anim state for state counter + ; anim p0 for x position +map_arrow_indicator: + ld a, [map_anim_timer] + dec a + ld [map_anim_timer], a + jp z, @end_anim + + ; check state + ld a, [map_anim_state] + inc a + cp a, 32 + jr nz, @no_x_swap REL + ld a, [map_anim_p0] + xor a, 80 + ld [map_anim_p0], a + xor a, a ; clear state +@no_x_swap: + ld [map_anim_state], a + + ld a, 1 + call oamalloc + + ld a, 16 + ; y + ld [hl+], a + + ; x + ld a, [map_anim_p0] + ld [hl+], a + + ; tile + ld a, MAP_TILE_ARROW + ld [hl+], a + + ; flags + xor a, a + ld [hl+], a + + ret +@end_anim: + call map_clear_routine ret l1_map: @@ -276,6 +346,7 @@ l1_objs: modef2 MOT_ACTOR_SPAWNER, 0, 18, ACT_T_GUARD, 0x40 modef MOT_SET_PAT, 0, 0x1E, pat_empty + modef2 MOT_ACTOR_SPAWNER, 0, 0x1F, ACT_T_GUARD, 0x40 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/wram.s b/src/wram.s index 62dd776..55f6414 100644 --- a/src/wram.s +++ b/src/wram.s @@ -114,6 +114,13 @@ map_scrn_ptr: .adv 2 ; can be set by map object map_routine: .adv 2 + ; map animation timer + ; use for e.g. arrow indicating scroll is enabled again +map_anim_timer: .adv 1 + ; state data for map anim +map_anim_state: .adv 1 + ; custom data for map anim +map_anim_p0: .adv 1 ; current debug function dbg_fn: .adv 1 diff --git a/tiles/bank8800.inc b/tiles/bank8800.inc index 68c1a2e..75c60c6 100644 --- a/tiles/bank8800.inc +++ b/tiles/bank8800.inc @@ -33,13 +33,13 @@ .chr 00000000 .chr 00000000 ; tile 2 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 -.chr 00000000 +.chr 00003000 +.chr 00033300 +.chr 00333330 +.chr 03333333 +.chr 00033300 +.chr 03333300 +.chr 03333000 .chr 00000000 .chr 00000000 .chr 00000000 -- 2.30.2