Palette rotation: Difference between revisions
Jump to navigation
Jump to search
(Created page with "thumb|[[League Bowling's title screen uses palette rotation for its background.]] Palette rotation is a video effect made by shifting and wrapping co...") |
mNo edit summary |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
[[ | Palette rotation is a non-NeoGeo-specific video effect produced by rotating (shifting in a loop) a range of color entries inside a [[palettes|palette]]. | ||
Like the [[auto animation]] feature, this effect was frequently used for cyclic animations (waterfalls, neon signs...) without having to use multiple tiles, saving up graphics memory and [[VRAM]] access time. | |||
<gallery> | |||
Lbowlpalrot.gif|[[League Bowling]]'s title screen uses palette rotation as a mean to provoke eye cancer. | |||
Ff2palrot.gif|[[Fatal Fury 2]] uses palette rotations to animate water efficiently. | |||
</gallery> | |||
==Example code== | |||
The easiest way is to simply cycle through a table of pre-baked palettes. It can also be done procedurally, for example: | |||
<syntaxhighlight> | |||
; Untested ! Doesn't care about transparent index. | |||
; Executes in about 720 cycles | |||
lea COLOR_LIST,a0 ; Pointer to list of 32 colors | |||
lea PALETTE,a1 ; Pointer to destination palette in palette RAM | |||
lea 64(a0),a2 ; End of list (32 words) | |||
clr.l d0 | |||
move.b ROT_INDEX,d0 ; Offset variable | |||
andi.b #31,d0 ; Warp on 32 | |||
add.w d0,d0 ; Colors are words | |||
adda.l d0,a0 | |||
move.b #16,d7 ; Number of entries in a palette | |||
-: | |||
move.w (a0)+,(a1)+ ; Copy | |||
subq.b #1,d7 | |||
beq + ; Are we done ? | |||
cmp.l a0,a2 | |||
bne - ; Warp ? | |||
lea COLOR_LIST,a0 ; Warp ! | |||
bra - | |||
+: | |||
addq.b #1,ROT_INDEX ; Animate | |||
</syntaxhighlight> | |||
[[Category:Video system]] | [[Category:Video system]] | ||
[[Category:Code]] |
Latest revision as of 00:55, 8 March 2019
Palette rotation is a non-NeoGeo-specific video effect produced by rotating (shifting in a loop) a range of color entries inside a palette.
Like the auto animation feature, this effect was frequently used for cyclic animations (waterfalls, neon signs...) without having to use multiple tiles, saving up graphics memory and VRAM access time.
-
League Bowling's title screen uses palette rotation as a mean to provoke eye cancer.
-
Fatal Fury 2 uses palette rotations to animate water efficiently.
Example code
The easiest way is to simply cycle through a table of pre-baked palettes. It can also be done procedurally, for example:
; Untested ! Doesn't care about transparent index.
; Executes in about 720 cycles
lea COLOR_LIST,a0 ; Pointer to list of 32 colors
lea PALETTE,a1 ; Pointer to destination palette in palette RAM
lea 64(a0),a2 ; End of list (32 words)
clr.l d0
move.b ROT_INDEX,d0 ; Offset variable
andi.b #31,d0 ; Warp on 32
add.w d0,d0 ; Colors are words
adda.l d0,a0
move.b #16,d7 ; Number of entries in a palette
-:
move.w (a0)+,(a1)+ ; Copy
subq.b #1,d7
beq + ; Are we done ?
cmp.l a0,a2
bne - ; Warp ?
lea COLOR_LIST,a0 ; Warp !
bra -
+:
addq.b #1,ROT_INDEX ; Animate