Palette rotation: Difference between revisions
Jump to navigation
Jump to search
(Example code (please test !)) |
mNo edit summary |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
Palette rotation is a non-NeoGeo-specific video effect | 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> | <gallery> | ||
Line 9: | Line 9: | ||
==Example code== | ==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> | <syntaxhighlight> | ||
Line 15: | Line 16: | ||
lea COLOR_LIST,a0 ; Pointer to list of 32 colors | 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) | lea 64(a0),a2 ; End of list (32 words) | ||
clr.l d0 | clr.l d0 | ||
move.b ROT_INDEX,d0 ; Offset variable | move.b ROT_INDEX,d0 ; Offset variable | ||
andi.b #31,d0 ; Warp on 32 | andi.b #31,d0 ; Warp on 32 | ||
add.w d0,d0 ; Colors are words | 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 | move.w (a0)+,(a1)+ ; Copy |
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