Jump to content

Palette fade: Difference between revisions

4,060 bytes added ,  5 months ago
no edit summary
No edit summary
No edit summary
Line 1:
{{Infobox Monster|img=Palette fade.png|hp=N/A|points=N/A}}
{{Infobox Entity|entity_pointer=$82:AB95}}
Palette fade is a [[boss monster]]. Though implemented in the same way as other boss monsters, this is not a monster in the literal sense.
 
== Overview ==
 
A palette fade will cause the background and sprite palettes to transition from their starting values to the specified palettes over time at the start of a level. This is generally used to make the level appear to go from day to night.
 
Once the palette fade is completed, two additional effects are activated. [[Werewolf|Werewolves]] will be allowed to spawn, and [[tourists]] will transform into werewolves. If either of these effects is desired without having a visible palette fade, then the post-fade palettes can be set to the same values as the starting palettes. This will cause the fade to complete quickly, essentially activating werewolves at the beginning of the level.
 
== Details ==
 
The process used to fade between the palettes is as follows. The palette fade starts at palette 0, and on each iteration will update all 16 colors in the background and sprite palettes at the current index. After each iteration, the current palette index is incremented. When all 8 palettes have been updated, the palette fade will complete if there were no colors updated during the last 8 iterations. If there were updated colors, then current palette is reset to 0 and the process repeats.
 
Before each iteration, there is a delay. The delay starts at 64 frames, and this value is decremented between each iteration. The delay will never go below 1 frame.
 
To update a color, compare each of the red, green, and blue components of the current color and the target color. If the current value is less than the target value, increment it, if it is greater, decrement it, and if the values are the same, do not alter it. This process means that the number of iterations required to complete the fade depends on the largest difference between starting and target color components.
 
{| class="wikitable"
|-
! Largest component<br/>difference !! Duration (frames) !! Duration (seconds)
|-
| 0 || 484 || 8.053405392
|-
| 1 || 904 || 15.04189768
|-
| 2 || 1260 || 20.96547685
|-
| 3 || 1552 || 25.82414291
|-
| 4 || 1780 || 29.61789586
|-
| 5 || 1944 || 32.34673571
|-
| 6 || 2044 || 34.01066244
|-
| 7 || 2080 || 34.60967607
|-
| 8 || 2088 || 34.74279021
|-
| 9 || 2096 || 34.87590434
|-
| 10 || 2104 || 35.00901848
|-
| 11 || 2112 || 35.14213262
|-
| 12 || 2120 || 35.27524676
|-
| 13 || 2128 || 35.4083609
|-
| 14 || 2136 || 35.54147504
|-
| 15 || 2144 || 35.67458918
|-
| 16 || 2152 || 35.80770332
|-
| 17 || 2160 || 35.94081745
|-
| 18 || 2168 || 36.07393159
|-
| 19 || 2176 || 36.20704573
|-
| 20 || 2184 || 36.34015987
|-
| 21 || 2192 || 36.47327401
|-
| 22 || 2200 || 36.60638815
|-
| 23 || 2208 || 36.73950229
|-
| 24 || 2216 || 36.87261642
|-
| 25 || 2224 || 37.00573056
|-
| 26 || 2232 || 37.1388447
|-
| 27 || 2240 || 37.27195884
|-
| 28 || 2248 || 37.40507298
|-
| 29 || 2256 || 37.53818712
|-
| 30 || 2264 || 37.67130126
|-
| 31 || 2272 || 37.8044154
|}
 
== Additional data format ==
Line 11 ⟶ 94:
! Offset !! Length !! Type !! Description
|-
| 0x00 || 4 || pointer24pointer32 || Pointer to newtarget background palette
|-
| 0x04 || 4 || pointer24pointer32 || Pointer to newtarget sprite palette
|}
 
== RAM map ==
 
=== Entity arguments ===
 
{| class="wikitable"
|-
! Address !! Length !! Type !! Description
|-
| $00 || 4 || pointer32 || Pointer to [[#Additional data format|additional data]]
|}
 
=== Entity memory ===
 
{| class="wikitable"
|-
! Address !! Length !! Type !! Description
|-
| $0A || 2 || boolean || Any palette has been updated in current 8-palette cycle
|-
| $0C || 2 || uint16 || Index of current palette (in bytes)
|-
| $0E || 2 || uint16 || Current delay between iterations
|-
| $10 || 4 || pointer32 || Pointer to target background palette
|-
| $14 || 4 || pointer32 || Pointer to target sprite palette
|}
 
=== Bugs ===
 
If the high bit is set on any of the colors in the target palettes, then the palette fade will never be considered complete. This happens because the color update logic checks if the color values are exactly equal when determining if the fade is complete, but will never set this bit on the updated colors. Since the high bit is unused in SNES colors, this can be completely avoided by simply leaving the bit unset on all colors.
 
[[Category:Boss monster]]
Cookies help us deliver our services. By using our services, you agree to our use of cookies.