aboutsummaryrefslogtreecommitdiff
path: root/Src/Plugins/Visualization/vis_nsfs/makepal.cpp
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/Plugins/Visualization/vis_nsfs/makepal.cpp
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/Plugins/Visualization/vis_nsfs/makepal.cpp')
-rw-r--r--Src/Plugins/Visualization/vis_nsfs/makepal.cpp96
1 files changed, 96 insertions, 0 deletions
diff --git a/Src/Plugins/Visualization/vis_nsfs/makepal.cpp b/Src/Plugins/Visualization/vis_nsfs/makepal.cpp
new file mode 100644
index 00000000..65c28a07
--- /dev/null
+++ b/Src/Plugins/Visualization/vis_nsfs/makepal.cpp
@@ -0,0 +1,96 @@
+#include <windows.h>
+#include <math.h>
+
+extern int (*warand)(void);
+static double rsc[3], rv[3];
+
+static double drand(void)
+{
+ return (warand()%4096)/(double)4096;
+}
+
+static void startgen(void)
+{
+ for (int x = 0; x < 3; x ++)
+ {
+ rsc[x]=drand()*256.0+256.0;
+ rv[x]=drand()*0.25+0.25;
+ }
+
+ if ((warand()&0xf)==5) rv[0]+=drand()*4.0;
+ if ((warand()&0xf)==2) rv[1]+=drand()*4.0;
+ if ((warand()&0xf)==3) rv[2]+=drand()*4.0;
+}
+
+static int getv(int i, int w)
+{
+ double d=sin((double)i*3.14159/256.0*rv[w])*rsc[w];
+ int v;
+ __asm
+ {
+ fld d
+ fistp v
+ }
+ if (v<0)v=0;
+ if (v>0xff)v=0xff;
+ return v;
+}
+
+static int lreversed;
+
+unsigned char *getnewpalette()
+{
+ static unsigned char thispal[256][3];
+ int x;
+ startgen();
+
+ for (x = 0; x < 768; x ++)
+ {
+ thispal[x/3][x%3]=getv(x/3,x%3);
+ }
+
+ int lr=warand()%21;
+
+ if (lreversed)
+ {
+ if (warand()&1) lreversed=0;
+ lr=4;
+ }
+ else if (lr == 4)
+ {
+ lreversed=1;
+ }
+
+ switch (lr)
+ {
+ case 3:
+ for (x = 0; x < 128; x ++)
+ {
+ thispal[x][0]=thispal[x*2][0];
+ thispal[x][1]=thispal[x*2][1];
+ thispal[x][2]=thispal[x*2][2];
+ }
+ for (; x < 256; x ++)
+ {
+ thispal[x][0]=thispal[255-x][0];
+ thispal[x][1]=thispal[255-x][1];
+ thispal[x][2]=thispal[255-x][2];
+ }
+ break;
+ case 4:
+ for (x = 0; x < 128; x ++)
+ {
+ int q;
+ for (q = 0; q < 3; q ++)
+ {
+ unsigned char t;
+ t=thispal[x][q];
+ thispal[x][q]=thispal[255-x][q];
+ thispal[255-x][q]=t;
+ }
+ }
+ break;
+ }
+
+ return &thispal[0][0];
+} \ No newline at end of file