Palette fade: Difference between revisions

1,763 bytes added ,  12 days ago
no edit summary
No edit summary
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 15:
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. See [[#Timing Data|timing data]] for details.
 
== Additional data format ==
 
The format for the additional data in the level is:
 
{| class="wikitable"
|-
! Offset !! Length !! [[Data types|Type]] !! Description
|-
| 0x00 || 4 || pointer32 || Pointer to target background palette
|-
| 0x04 || 4 || pointer32 || Pointer to target sprite palette
|}
 
== RAM map ==
 
=== Entity arguments ===
 
{| class="wikitable"
|-
! Address !! Length !! [[Data types|Type]] !! Description
|-
| $00 || 4 || pointer32 || Pointer to [[#Additional data format|additional data]]
|}
 
=== Entity memory ===
 
{| class="wikitable"
|-
! Address !! Length !! [[Data types|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.
 
== Timing Data ==
 
{| class="wikitable"
Line 86 ⟶ 133:
|}
 
Highlighted rows in the table below are palette combinations that occur in the original game.
== Additional data format ==
 
The format for the additional data in the level is:
 
{| class="wikitable"
|-
! Tileset !! Palette 1 !! Palette 2 !! Largest component<br/>difference !! Duration (seconds)
! Offset !! Length !! Type !! Description
|-
| rowspan="6"|Grass || Autumn || Night || 24 || 36.87261642
| 0x00 || 4 || pointer32 || Pointer to target background palette
|-
| 0x04Autumn || 4Normal || pointer3218 || Pointer to target sprite palette36.07393159
|}
 
== RAM map ==
 
=== Entity arguments ===
 
{| class="wikitable"
|-
| Autumn || Winter || 28 || 37.40507298
! Address !! Length !! Type !! Description
|- class="highlightrow"
| Night || Normal || 30 || 37.67130126
|-
| Night || Winter || 30 || 37.67130126
| $00 || 4 || pointer32 || Pointer to [[#Additional data format|additional data]]
|}
 
=== Entity memory ===
 
{| class="wikitable"
|-
| Normal || Winter || 23 || 36.73950229
! Address !! Length !! Type !! Description
|-
| rowspan="6"|Castle || Bright || Dark || 24 || 36.87261642
| $0A || 2 || boolean || Any palette has been updated in current 8-palette cycle
|- class="highlightrow"
| Bright || Night || 24 || 36.87261642
|-
| $0CBright || 2Normal || uint1624 || Index of current palette (in bytes)36.87261642
|-
| $0EDark || 2Night || uint1617 || Current delay between iterations35.94081745
|-
| $10Dark || 4Normal || pointer3214 || Pointer to target background palette35.54147504
|- class="highlightrow"
| Night || Normal || 21 || 36.47327401
|-
| $14Mall+Factory || 4Factory || pointer32Mall || Pointer27 to target sprite|| palette37.27195884
|-
| rowspan="10"|Office+Cave || Dark Fire Cave || Dark || 31 || 37.8044154
|-
| Dark Fire Cave || Fire Cave || 31 || 37.8044154
|-
| Dark Fire Cave || Light || 31 || 37.8044154
|-
| Dark Fire Cave || Normal || 31 || 37.8044154
|-
| Dark || Fire Cave || 31 || 37.8044154
|- class="highlightrow"
| Dark || Light || 24 || 36.87261642
|-
| Dark || Normal || 31 || 37.8044154
|-
| Fire Cave || Light || 31 || 37.8044154
|-
| Fire Cave || Normal || 18 || 36.07393159
|- class="highlightrow"
| Light || Normal || 31 || 37.8044154
|-
| rowspan="6"|Sand || Beach || Dark Beach || 23 || 36.73950229
|-
| Beach || Mines || 22 || 36.60638815
|-
| Beach || Pyramid || 22 || 36.60638815
|-
| Dark Beach || Mines || 18 || 36.07393159
|-
| Dark Beach || Pyramid || 23 || 36.73950229
|-
| Mines || Pyramid || 22 || 36.60638815
|}
 
=== 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]]
[[Category:Monster]]
[[Category:Entity]]