From: Lukas Krickl Date: Tue, 15 Jul 2025 17:14:34 +0000 (+0200) Subject: video: made menu to level transiton look nicer X-Git-Url: https://git.krickl.dev/?a=commitdiff_plain;h=696c949077ad158e03f098154d50a49771b4d8ed;p=gbrg%2F.git video: made menu to level transiton look nicer Moved BGP handling for fade out to a shadow register fade in now takes a target palette as a parameter. Moved IE to a shadow register so interrupts can be centrally configured even if they are disabled. --- diff --git a/src/mem.s b/src/mem.s index 96d4e09..e48a7e5 100644 --- a/src/mem.s +++ b/src/mem.s @@ -5,6 +5,10 @@ mem_init: ld bc, WRAMLEN call memset + ; set up shadow IE + ld a, IVBLANK | ILCD + ld [shadow_ie], a + ; set up rand call rand_init diff --git a/src/player.s b/src/player.s index f695c6b..be4b0f2 100644 --- a/src/player.s +++ b/src/player.s @@ -160,6 +160,7 @@ unit_check_exit_hit: call scroll_write ; fade back in + ld a, [shadow_bpg] call video_fade_in diff --git a/src/sys.s b/src/sys.s index b881cba..d2cec96 100644 --- a/src/sys.s +++ b/src/sys.s @@ -16,14 +16,19 @@ panic: @loop: jp @loop - + + ; enabels interrupts + ; writes shadow_ie to IE enableinterrupts: ; enable interrupts - ld a, IVBLANK | ILCD + ld a, [shadow_ie] ld [IE], a ei ret + ; disables interrupts + ; writes 0 to IE + ; leaves shadow_ie as is disableinterrutpts: ld a, 0 ld [IE], a diff --git a/src/update.s b/src/update.s index c72a775..4a83536 100644 --- a/src/update.s +++ b/src/update.s @@ -41,6 +41,8 @@ update: ; loads default map new_game_init: call video_fade_out + + call shadow_oam_clear call unit_load_default_player @@ -48,6 +50,9 @@ new_game_init: call map_init call game_init + + ld a, BGP + ld [shadow_bpg], a call video_fade_in ret @@ -67,12 +72,15 @@ game_init: ; gameplay ld a, BGP ld [RBGP], a + ld [shadow_bpg], a ld a, 0b11100100 ld [ROBP0], a + ld [shadow_robp0], a ld a, 0b11011000 ld [ROBP1], a + ld [shadow_robp1], a ldnull bc ret diff --git a/src/video.s b/src/video.s index a9dec0d..5488045 100644 --- a/src/video.s +++ b/src/video.s @@ -151,7 +151,7 @@ video_wait_n_frames: ; inputs: ; $1: BGP #macro video_fade_set_bgp - ld a, BGP + ld a, [RBGP] and a, $1 ld [RBGP], a @@ -164,6 +164,7 @@ video_wait_n_frames: ; interrupts must be enabled ; preserved all registers ; disables window + ; fades away from current RBGP video_fade_out: push_all @@ -189,6 +190,8 @@ video_fade_out: ; interrupts must be enabled ; preserved all registers ; enables window + ; inputs: + ; a: new palette video_fade_in: push_all @@ -198,21 +201,26 @@ video_fade_in: ld a, [RLCD] and a, ~LCDF_WINDOWON & 0xFF ld [RLCD], a - - video_fade_set_bgp 0b11000000 - video_fade_set_bgp 0b11110000 - video_fade_set_bgp 0b11111100 - video_fade_set_bgp 0b11111111 + + ; wait a few frames + call next_vblank_wait + call next_vblank_wait + call next_vblank_wait + call next_vblank_wait + call next_vblank_wait + call next_vblank_wait + call next_vblank_wait ; re-enable window ld a, [RLCD] or a, LCDF_WINDOWON ld [RLCD], a - ld a, BGP - ld [RBGP], a pop_all + ; push all saved new palette value + ; so we can use it here + ld [RBGP], a ret #undefine video_fade_set_bgp diff --git a/src/wram.s b/src/wram.s index bb576f5..606445a 100644 --- a/src/wram.s +++ b/src/wram.s @@ -22,6 +22,14 @@ curr_inputs: .adv 1 prev_inputs: .adv 1 game_mode: .adv st_size + + ; used by video fade out and fade in +shadow_bpg: .adv 1 +shadow_robp0: .adv 1 +shadow_robp1: .adv 1 + +; shadow version of IE +shadow_ie: .adv 1 ; status text buffer status_text: .adv 32