dos33fsprogs/utils/gr-sim/plasma/plasma.c

91 lines
1.5 KiB
C
Raw Normal View History

2019-08-28 04:12:10 +00:00
/* for demoscene, you need a plasma effect... */
/* https://rosettacode.org/wiki/Plasma_effect */
/* https://www.bidouille.org/prog/plasma */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include "tfv_zp.h"
#include "gr-sim.h"
#define pi 3.14159265358979323846264338327950
2019-08-28 18:53:02 +00:00
#if 0
static unsigned char color_lookup[]={0x0, 0x0, 0x5, 0x5,
0x7, 0x7, 0xf, 0xf,
0x7, 0x7, 0x6, 0x6,
0x2, 0x2, 0x5, 0x5};
#endif
static unsigned char color_lookup[]={0x0, 0x5, 0x7, 0xf,
0x7, 0x6, 0x2, 0x5,
0x0, 0x5, 0x7, 0xf,
0x7, 0x6, 0x2, 0x5};
2019-08-28 04:12:10 +00:00
int main(int argc, char **argv) {
2019-08-28 18:53:02 +00:00
int ch,xx,yy,col;
// double dx,dy,dv;
double r;
double sec=0.0;
2019-08-28 04:12:10 +00:00
grsim_init();
gr();
2019-08-28 18:53:02 +00:00
soft_switch(MIXCLR);
2019-08-28 04:12:10 +00:00
2019-08-28 18:53:02 +00:00
clear_screens();
2019-08-28 04:12:10 +00:00
ram[DRAW_PAGE]=0x0;
while(1) {
2019-08-28 18:53:02 +00:00
// sec+=0.00625;
sec+=0.000625;
2019-08-28 04:12:10 +00:00
2019-08-28 18:53:02 +00:00
for(yy=0;yy<48;yy++) {
2019-08-28 04:12:10 +00:00
for(xx=0;xx<40;xx++) {
2019-08-28 18:53:02 +00:00
// r=sin(8*((xx*2)*sin(sec/2)+(yy*2)*cos(sec/4))+sec/8);
r=sin(8*((xx*2)*sin(sec/2)+(yy*4)*cos(sec/4))+sec/128);
2019-08-28 04:12:10 +00:00
2019-08-28 18:53:02 +00:00
// printf("%d %d %f %f %f %f\n",xx,yy,dx,dy,dv,r);
// setcolor(COLOR(255*fabs(sin(dv*pi)),255*fabs(sin(dv*pi + 2*pi/3)),255*fabs(sin(dv*pi + 4*pi/3))));
col=(int)((r+1)*8);
if ((col<0) || (col>15)) {
printf("Invalid color %d\n",col);
}
color_equals(color_lookup[col]);
2019-08-28 04:12:10 +00:00
plot(xx,yy);
}
}
grsim_update();
ch=grsim_input();
if (ch=='q') exit(0);
2019-08-28 18:53:02 +00:00
if (ch==' ') {
while(1) {
ch=grsim_input();
if (ch) break;
}
}
2019-08-28 04:12:10 +00:00
usleep(20000);
}
return 0;
}