Palette rotation: Difference between revisions

From NeoGeo Development Wiki
Jump to navigation Jump to search
(Example code (please test !))
mNo edit summary
Line 9: Line 9:


==Example code==
==Example code==
(You really should just load a pre baked palette entry instead of computing it)


<syntaxhighlight>
<syntaxhighlight>

Revision as of 13:30, 24 September 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

(You really should just load a pre baked palette entry instead of computing it)

; 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