1 // Just a test with a run of the mill plasma
10 static int init(void);
11 static void destroy(void);
12 static void start(long trans_time);
13 static void draw(void);
15 static struct screen scr = {
24 static unsigned long startingTime;
26 #define PSIN_SIZE 4096
29 static unsigned char *psin1, *psin2, *psin3;
30 static unsigned short *plasmaPal;
32 static unsigned short myBuffer[320 * 240];
35 struct screen *plasma_screen(void)
46 psin1 = (unsigned char*)malloc(sizeof(unsigned char) * PSIN_SIZE);
47 psin2 = (unsigned char*)malloc(sizeof(unsigned char) * PSIN_SIZE);
48 psin3 = (unsigned char*)malloc(sizeof(unsigned char) * PSIN_SIZE);
50 for (i = 0; i < PSIN_SIZE; i++)
52 psin1[i] = (unsigned char)(sin((double)i / 45.0) * 63.0 + 63.0);
53 psin2[i] = (unsigned char)(sin((double)i / 75.0) * 42.0 + 42.0);
54 psin3[i] = (unsigned char)(sin((double)i / 32.0) * 88.0 + 88.0);
57 plasmaPal = (unsigned short*)malloc(sizeof(unsigned short) * PPAL_SIZE);
58 for (i=0; i<PPAL_SIZE; i++)
62 if (c > 127) c = 255 - c;
67 plasmaPal[i] = (r<<11) | (g<<5) | b;
74 static void destroy(void)
81 static void start(long trans_time)
83 startingTime = time_msec;
86 static void draw(void)
92 float dt = (float)(time_msec - startingTime) / 1000.0f;
93 int t1 = sin(0.1f * dt) * 132 + 132;
94 int t2 = sin(0.2f * dt) * 248 + 248;
95 int t3 = sin(0.5f * dt) * 380 + 380;
97 unsigned int *vram32 = (unsigned int*)vmem_back;
99 for (y = 0; y < fb_height; y++)
103 for (x = 0; x < fb_width; x+=2)
105 c = psin1[x + t1] + s1 + psin3[x + y + t3] + psin1[psin2[x + t2] + s2 + t3];
107 c = psin1[x + 1 + t1] + s1 + psin3[x + 1 + y + t3] + psin1[psin2[x + 1 + t2] + s2 + t3];
110 *vram32++ = (p1 << 16) | p0;
114 drawFps((unsigned short*)vmem_back);