From f64bbf700df42e7fec2d9d4d1f65d5f7911c2f31 Mon Sep 17 00:00:00 2001 From: xCrystal Date: Fri, 4 Aug 2023 23:54:53 +0200 Subject: [PATCH] Consolidate behavior of fading to/from white in overworld (#2), Fix naming screen tiles (#3) (bug fix to 6e3c5fd00874e9af40624aedf192ecb511099dec) --- data/events/special_pointers.asm | 9 ++- data/maps/setup_script_pointers.asm | 4 +- data/maps/setup_scripts.asm | 16 ++--- engine/events/field_moves.asm | 4 +- engine/events/halloffame.asm | 4 +- engine/events/sacred_ash.asm | 12 ++-- engine/events/whiteout.asm | 2 +- engine/menus/intro_menu.asm | 9 --- engine/menus/naming_screen.asm | 8 +-- engine/tilesets/timeofday_pals.asm | 100 +++++++++++++++++++++------- home/map.asm | 4 +- ram/wram.asm | 7 +- 12 files changed, 112 insertions(+), 67 deletions(-) diff --git a/data/events/special_pointers.asm b/data/events/special_pointers.asm index 55543a08d..bbcfbff90 100644 --- a/data/events/special_pointers.asm +++ b/data/events/special_pointers.asm @@ -53,11 +53,10 @@ SpecialsPointers:: add_special CardFlip add_special UnusedMemoryGame ; unused add_special ClearBGPalettesBufferScreen ; unused - add_special FadeOutPalettes - add_special BattleTowerFade - add_special FadeBlackQuickly - add_special FadeInPalettes - add_special FadeInQuickly + add_special FadeOutPalettesToWhite + add_special FadeOutPalettesToBlack + add_special FadeInPalettesFromWhite + add_special FadeInPalettesFromBlack add_special ReloadSpritesNoPalettes ; bank 0 add_special ClearBGPalettes ; bank 0 add_special UpdateTimePals ; bank 0 diff --git a/data/maps/setup_script_pointers.asm b/data/maps/setup_script_pointers.asm index 2d7e49abc..9b913b3fc 100644 --- a/data/maps/setup_script_pointers.asm +++ b/data/maps/setup_script_pointers.asm @@ -33,8 +33,8 @@ MapSetupCommands: add_mapsetup LoadMapAttributes ; 1a add_mapsetup LoadMapAttributes_SkipObjects ; 1b add_mapsetup ClearBGPalettes ; 1c - add_mapsetup FadeOutPalettes ; 1d - add_mapsetup FadeInPalettes ; 1e + add_mapsetup FadeOutPalettesToWhite ; 1d + add_mapsetup FadeInPalettesFromWhite ; 1e add_mapsetup GetMapScreenCoords ; 1f add_mapsetup GetWarpDestCoords ; 20 add_mapsetup SpawnInFacingDown ; 21 diff --git a/data/maps/setup_scripts.asm b/data/maps/setup_scripts.asm index bcb1057d1..03824a09f 100644 --- a/data/maps/setup_scripts.asm +++ b/data/maps/setup_scripts.asm @@ -23,7 +23,7 @@ ENDM MapSetupScript_Teleport: mapsetup ResetPlayerObjectAction MapSetupScript_Fly: - mapsetup FadeOutPalettes + mapsetup FadeOutPalettesToWhite mapsetup JumpRoamMons MapSetupScript_Warp: mapsetup DisableLCD @@ -45,7 +45,7 @@ MapSetupScript_Warp: mapsetup RefreshMapSprites mapsetup PlayMapMusicBike mapsetup FadeInToMusic - mapsetup FadeInPalettes + mapsetup FadeInPalettesFromWhite mapsetup ActivateMapAnims mapsetup LoadWildMonData db -1 ; end @@ -69,7 +69,7 @@ MapSetupScript_BadWarp: mapsetup SpawnInFacingDown mapsetup RefreshMapSprites mapsetup FadeToMapMusic - mapsetup FadeInPalettes + mapsetup FadeInPalettesFromWhite mapsetup ActivateMapAnims mapsetup LoadWildMonData db -1 ; end @@ -95,7 +95,7 @@ MapSetupScript_Connection: MapSetupScript_Fall: mapsetup ResetPlayerObjectAction MapSetupScript_Door: - mapsetup FadeOutPalettes + mapsetup FadeOutPalettesToWhite MapSetupScript_Train: mapsetup EnterMapWarp mapsetup LoadMapAttributes @@ -113,7 +113,7 @@ MapSetupScript_Train: mapsetup LoadMapPalettes mapsetup RefreshMapSprites mapsetup FadeToMapMusic - mapsetup FadeInPalettes + mapsetup FadeInPalettesFromWhite mapsetup ActivateMapAnims mapsetup LoadWildMonData mapsetup UpdateRoamMons @@ -132,7 +132,7 @@ MapSetupScript_ReloadMap: mapsetup LoadMapPalettes mapsetup RefreshMapSprites mapsetup ForceMapMusic - mapsetup FadeInPalettes + mapsetup FadeInPalettesFromWhite mapsetup ActivateMapAnims mapsetup LoadWildMonData db -1 ; end @@ -150,7 +150,7 @@ MapSetupScript_LinkReturn: mapsetup LoadMapPalettes mapsetup RefreshMapSprites mapsetup PlayMapMusicBike - mapsetup FadeInPalettes + mapsetup FadeInPalettesFromWhite mapsetup ActivateMapAnims mapsetup LoadWildMonData mapsetup EnableTextAcceleration @@ -171,7 +171,7 @@ MapSetupScript_Continue: mapsetup LoadMapPalettes mapsetup RefreshMapSprites mapsetup PlayMapMusicBike - mapsetup FadeInPalettes + mapsetup FadeInPalettesFromWhite mapsetup ActivateMapAnims mapsetup LoadWildMonData db -1 ; end diff --git a/engine/events/field_moves.asm b/engine/events/field_moves.asm index 1e4f0a777..4feaad827 100644 --- a/engine/events/field_moves.asm +++ b/engine/events/field_moves.asm @@ -10,14 +10,14 @@ PlayWhirlpoolSound: ret BlindingFlash: - farcall FadeOutPalettes + farcall FadeOutPalettesToWhite ld hl, wStatusFlags set STATUSFLAGS_FLASH_F, [hl] farcall ReplaceTimeOfDayPals farcall UpdateTimeOfDayPal ld b, CGB_MAPPALS call GetCGBLayout - farcall FadeInPalettes + farcall FadeInPalettesFromWhite ret ShakeHeadbuttTree: diff --git a/engine/events/halloffame.asm b/engine/events/halloffame.asm index 16c10db8b..02dd5a11a 100644 --- a/engine/events/halloffame.asm +++ b/engine/events/halloffame.asm @@ -41,7 +41,7 @@ RedCredits:: ld [wMusicFadeID + 1], a ld a, 10 ld [wMusicFade], a - farcall FadeOutPalettes + farcall FadeOutPalettesToWhite xor a ld [wVramState], a ldh [hMapAnims], a @@ -63,7 +63,7 @@ HallOfFame_FadeOutMusic: ld [wMusicFadeID + 1], a ld a, 10 ld [wMusicFade], a - farcall FadeOutPalettes + farcall FadeOutPalettesToWhite xor a ld [wVramState], a ldh [hMapAnims], a diff --git a/engine/events/sacred_ash.asm b/engine/events/sacred_ash.asm index d105b2fb7..26df78cc8 100644 --- a/engine/events/sacred_ash.asm +++ b/engine/events/sacred_ash.asm @@ -49,12 +49,12 @@ SacredAshScript: special HealParty reloadmappart playsound SFX_WARP_TO - special FadeOutPalettes - special FadeInPalettes - special FadeOutPalettes - special FadeInPalettes - special FadeOutPalettes - special FadeInPalettes + special FadeOutPalettesToWhite + special FadeInPalettesFromWhite + special FadeOutPalettesToWhite + special FadeInPalettesFromWhite + special FadeOutPalettesToWhite + special FadeInPalettesFromWhite waitsfx writetext .UseSacredAshText playsound SFX_CAUGHT_MON diff --git a/engine/events/whiteout.asm b/engine/events/whiteout.asm index 241b537f3..9a20f97a5 100644 --- a/engine/events/whiteout.asm +++ b/engine/events/whiteout.asm @@ -9,7 +9,7 @@ OverworldWhiteoutScript:: Script_Whiteout: writetext .WhitedOutText waitbutton - special FadeOutPalettes + special FadeOutPalettesToWhite pause 40 special HealParty checkflag ENGINE_BUG_CONTEST_TIMER diff --git a/engine/menus/intro_menu.asm b/engine/menus/intro_menu.asm index 144c6e418..0501375d4 100644 --- a/engine/menus/intro_menu.asm +++ b/engine/menus/intro_menu.asm @@ -670,15 +670,6 @@ NamePlayer: .Kris: db "KRIS@@@@@@@" -GSShowPlayerNamingChoices: ; unreferenced - call LoadMenuHeader - call VerticalMenu - ld a, [wMenuCursorY] - dec a - call CopyNameFromMenu - call CloseWindow - ret - StorePlayerName: ld a, "@" ld bc, NAME_LENGTH diff --git a/engine/menus/naming_screen.asm b/engine/menus/naming_screen.asm index 122581205..d4ee0d098 100644 --- a/engine/menus/naming_screen.asm +++ b/engine/menus/naming_screen.asm @@ -1,8 +1,8 @@ DEF NAMINGSCREEN_CURSOR EQU $7e -DEF NAMINGSCREEN_BORDER EQU "■" ; $60 -DEF NAMINGSCREEN_MIDDLELINE EQU "→" ; $eb -DEF NAMINGSCREEN_UNDERLINE EQU "." ; $e8 +DEF NAMINGSCREEN_BORDER EQU "■" ; $ba +DEF NAMINGSCREEN_MIDDLELINE EQU "▲" ; $bb +DEF NAMINGSCREEN_UNDERLINE EQU "☎" ; $bc _NamingScreen: call DisableSpriteUpdates @@ -832,7 +832,7 @@ LoadNamingScreenGFX: lb bc, BANK(NamingScreenGFX_UnderLine), 1 call Get1bpp - ld de, vTiles2 tile NAMINGSCREEN_BORDER + ld de, vTiles0 tile NAMINGSCREEN_BORDER ld hl, NamingScreenGFX_Border ld bc, 1 tiles ld a, BANK(NamingScreenGFX_Border) diff --git a/engine/tilesets/timeofday_pals.asm b/engine/tilesets/timeofday_pals.asm index 154a04e7d..816f9b219 100644 --- a/engine/tilesets/timeofday_pals.asm +++ b/engine/tilesets/timeofday_pals.asm @@ -111,45 +111,44 @@ _UpdateTimePals:: call DmgToCgbTimePals ret -FadeInPalettes:: +FadeInPalettesFromWhite:: +; fades from white to normal palettes in four steps +; all palettes use white color of Pal0 before step 3 + call BackupWhiteColorFromBGPals1 + call FillWhiteBGColor ld c, $12 call GetTimePalFade - ld b, $4 + ld b, $2 + call ConvertTimePalsDecHL + call RestoreWhiteColorToBGPals1 + ld c, $c + call GetTimePalFade + ld b, $2 call ConvertTimePalsDecHL ret -FadeOutPalettes:: - call FillWhiteBGColor +FadeOutPalettesToWhite:: +; fades from normal palettes to white in four steps +; all palettes use white color of Pal0 after step 2 ld c, $9 call GetTimePalFade - ld b, $4 + ld b, $2 + call ConvertTimePalsIncHL + call FillWhiteBGColor + ld c, $f + call GetTimePalFade + ld b, $2 call ConvertTimePalsIncHL ret -BattleTowerFade: - call FillWhiteBGColor - ld c, $9 - call GetTimePalFade - ld b, $4 -.loop - call DmgToCgbTimePals - inc hl - inc hl - inc hl - ld c, $7 - call DelayFrames - dec b - jr nz, .loop - ret - -FadeInQuickly: +FadeInPalettesFromBlack: ld c, $0 call GetTimePalFade ld b, $4 call ConvertTimePalsIncHL ret -FadeBlackQuickly: +FadeOutPalettesToBlack: ld c, $9 call GetTimePalFade ld b, $4 @@ -157,6 +156,7 @@ FadeBlackQuickly: ret FillWhiteBGColor: +; copy white palette of wBGPals1 Pal0 into white palette of wBGPals1 Pal1-Pal6 ldh a, [rSVBK] push af ld a, BANK(wBGPals1) @@ -184,6 +184,60 @@ endr ldh [rSVBK], a ret +BackupWhiteColorFromBGPals1: + ldh a, [rSVBK] + push af + ld a, BANK(wBGPals1) + ldh [rSVBK], a + + ld hl, wBGPals1 + ld de, wBGPalsRegularWhiteColors + ld c, 8 +.loop + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + inc de +rept PALETTE_SIZE - 1 * PAL_COLOR_SIZE + inc hl +endr + dec c + jr nz, .loop + + pop af + ldh [rSVBK], a + ret + +RestoreWhiteColorToBGPals1: + ldh a, [rSVBK] + push af + ld a, BANK(wBGPals1) + ldh [rSVBK], a + + ld hl, wBGPalsRegularWhiteColors + ld de, wBGPals1 + ld c, 8 +.loop + ld a, [hli] + ld [de], a + inc de + ld a, [hli] + ld [de], a + inc de +rept PALETTE_SIZE - 1 * PAL_COLOR_SIZE + inc de +endr + dec c + jr nz, .loop + + pop af + ldh [rSVBK], a + ret + + + ReplaceTimeOfDayPals: ld a, [wMapTimeOfDay] bit IN_DARKNESS_F, a diff --git a/home/map.asm b/home/map.asm index 4933d4777..2913652b9 100644 --- a/home/map.asm +++ b/home/map.asm @@ -1890,7 +1890,7 @@ FadeToMenu:: xor a ldh [hBGMapMode], a call LoadStandardMenuHeader - farcall FadeOutPalettes + farcall FadeOutPalettesToWhite call ClearSprites call DisableSpriteUpdates ret @@ -1913,7 +1913,7 @@ FinishExitMenu:: ld b, CGB_MAPPALS call GetCGBLayout call WaitBGMap2 - farcall FadeInPalettes + farcall FadeInPalettesFromWhite call EnableSpriteUpdates ret diff --git a/ram/wram.asm b/ram/wram.asm index 39ea789d6..f1535bfd2 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -2621,8 +2621,6 @@ wOBPals2:: ds 8 palettes wLYOverrides:: ds SCREEN_HEIGHT_PX wLYOverridesEnd:: - ds 1 - wMagnetTrain:: ; used only for BANK(wMagnetTrain) wMagnetTrainDirection:: db wMagnetTrainInitPosition:: db @@ -2630,7 +2628,10 @@ wMagnetTrainHoldPosition:: db wMagnetTrainFinalPosition:: db wMagnetTrainPlayerSpriteInitX:: db - ds 106 + ; Used by FadeInPalettesFromWhite +wBGPalsRegularWhiteColors:: ds 8 * PAL_COLOR_SIZE + + ds 91 align 8 wLYOverridesBackup:: ds SCREEN_HEIGHT_PX