map: Added up arrow animation
authorLukas Krickl <lukas@krickl.dev>
Sun, 5 Oct 2025 05:54:40 +0000 (07:54 +0200)
committerLukas Krickl <lukas@krickl.dev>
Sun, 5 Oct 2025 05:54:40 +0000 (07:54 +0200)
src/map.s
src/wram.s
tiles/bank8800.inc

index 8a8a2fbe1715bda9dcd1d2c9f4c2f4b5536c6c3b..14be49379970b40f9d64fb3bef7d0e1e890f3c94 100644 (file)
--- 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
index 62dd7769a94ccf22c3542e452335dfcfe11c8f11..55f6414aac61d0d775007ad607747f2459178195 100644 (file)
@@ -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
index 68c1a2eac3bd389d33e802e98698952dec6d7fa4..75c60c6c696a6815ddf1cdc99207184451bd1e86 100644 (file)
 .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