Create a rainbow gradient in Photoshop

Index the colors... I'm not a palette master, but I believe you have to use your character's color depth

Open the Color Table and save the pal

Screw with this to adjust the frequency
[State -2, Rainbow]
type = RemapPal
trigger1 = GameTime%4 = 0
source = 1,1
dest = 2,(GameTime%32)/4
ignorehitpause = 1