1 // Just a test with a run of the mill plasma
10 static void destroy(void);
11 static void start(long trans_time);
12 static void draw(void);
14 static struct screen scr = {
23 static unsigned long startingTime;
25 #define PSIN_SIZE 4096
28 static unsigned char *psin1, *psin2, *psin3;
29 static unsigned short *plasmaPal;
31 static unsigned short myBuffer[320 * 240];
34 struct screen *plasma_screen(void)
43 psin1 = (unsigned char*)malloc(sizeof(unsigned char) * PSIN_SIZE);
44 psin2 = (unsigned char*)malloc(sizeof(unsigned char) * PSIN_SIZE);
45 psin3 = (unsigned char*)malloc(sizeof(unsigned char) * PSIN_SIZE);
47 for (i = 0; i < PSIN_SIZE; i++)
49 psin1[i] = (unsigned char)(sin((double)i / 45.0) * 63.0 + 63.0);
50 psin2[i] = (unsigned char)(sin((double)i / 75.0) * 42.0 + 42.0);
51 psin3[i] = (unsigned char)(sin((double)i / 32.0) * 88.0 + 88.0);
54 plasmaPal = (unsigned short*)malloc(sizeof(unsigned short) * PPAL_SIZE);
55 for (i=0; i<PPAL_SIZE; i++)
59 if (c > 127) c = 255 - c;
64 plasmaPal[i] = (r<<11) | (g<<5) | b;
70 static void destroy(void)
77 static void start(long trans_time)
79 startingTime = time_msec;
82 static void draw(void)
88 float dt = (float)(time_msec - startingTime) / 1000.0f;
89 int t1 = sin(0.1f * dt) * 132 + 132;
90 int t2 = sin(0.2f * dt) * 248 + 248;
91 int t3 = sin(0.5f * dt) * 380 + 380;
93 unsigned int *vram32 = (unsigned int*)fb_pixels;
95 for (y = 0; y < fb_height; y++)
99 for (x = 0; x < fb_width; x+=2)
101 c = psin1[x + t1] + s1 + psin3[x + y + t3] + psin1[psin2[x + t2] + s2 + t3];
103 c = psin1[x + 1 + t1] + s1 + psin3[x + 1 + y + t3] + psin1[psin2[x + 1 + t2] + s2 + t3];
106 *vram32++ = (p1 << 16) | p0;