Palette rotation: Difference between revisions

From NeoGeo Development Wiki
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 made by shifting a range of color entries inside a [[palettes|palette]].
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]].


This effect was frequently used along [[auto animation]] for cyclic, scrolling animations (waterfalls...) without having to use multiple tiles, saving up graphics memory and VDC time.
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)
  lea    PALETTE,a1      ; Pointer to start of palette in palette RAM
   clr.l  d0
   clr.l  d0
   move.b  ROT_INDEX,d0    ; Offset variable
   move.b  ROT_INDEX,d0    ; Offset variable
  move.b  #16,d7          ; Number of entries in palette
   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
   movea.l 0(a0,d0),a0
   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.

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