Palette rotation

From NeoGeo Development Wiki
Revision as of 14:59, 15 August 2016 by Furrtek (talk | contribs) (Example code (please test !))
Jump to navigation Jump to search

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