Palette rotation: Difference between revisions

From NeoGeo Development Wiki
Jump to navigation Jump to search
mNo edit summary
(Example code (please test !))
Line 1: Line 1:
Palette rotation is a video effect made by shifting and wrapping a range of color entries inside a [[palettes|palette]].
Palette rotation is a non-NeoGeo-specific video effect made by shifting a range of color entries inside a [[palettes|palette]].


This effect was frequently used in older games for cyclic, scrolling animations (waterfalls...) without having to use multiple tiles, saving up graphics memory and CPU time.
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.


<gallery>
<gallery>
Line 11: Line 11:


<syntaxhighlight>
<syntaxhighlight>
To do.
; Untested ! Doesn't care about transparent index.
; Executes in about 720 cycles
 
  lea    COLOR_LIST,a0  ; Pointer to list of 32 colors
  lea    64(a0),a2      ; End of list (32 words)
  lea    PALETTE,a1      ; Pointer to start of palette in palette RAM
  clr.l  d0
  move.b  ROT_INDEX,d0    ; Offset variable
  move.b  #16,d7          ; Number of entries in palette
  andi.b  #31,d0          ; Warp on 32
  add.w  d0,d0          ; Colors are words
  movea.l 0(a0,d0),a0
-:
  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>
</syntaxhighlight>


[[Category:Video system]]
[[Category:Video system]]
[[Category:Code]]
[[Category:Code]]

Revision as of 14:59, 15 August 2016

Palette rotation is a non-NeoGeo-specific video effect made by shifting a range of color entries inside a 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.

Example code

; Untested ! Doesn't care about transparent index.
; Executes in about 720 cycles

  lea     COLOR_LIST,a0   ; Pointer to list of 32 colors
  lea     64(a0),a2       ; End of list (32 words)
  lea     PALETTE,a1      ; Pointer to start of palette in palette RAM
  clr.l   d0
  move.b  ROT_INDEX,d0    ; Offset variable
  move.b  #16,d7          ; Number of entries in palette
  andi.b  #31,d0          ; Warp on 32
  add.w   d0,d0           ; Colors are words
  movea.l 0(a0,d0),a0
-:
  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