From 0e3577d6fe5ac6748481abbc701d520b0cb64c2b Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Wed, 28 Aug 2019 00:12:10 -0400 Subject: [PATCH] gr-sim: looking at some plasma --- gr-sim/plasma/Makefile | 21 +++++++++++++ gr-sim/plasma/plasma.c | 70 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) create mode 100644 gr-sim/plasma/Makefile create mode 100644 gr-sim/plasma/plasma.c diff --git a/gr-sim/plasma/Makefile b/gr-sim/plasma/Makefile new file mode 100644 index 00000000..f1a139e2 --- /dev/null +++ b/gr-sim/plasma/Makefile @@ -0,0 +1,21 @@ +CC = gcc +CFLAGS = -Wall -O2 -I.. -g +LFLAGS = -lm + +SDL_LIBS= `sdl-config --libs` +SDL_INCLUDE= `sdl-config --cflags` +GR_SIM = ../gr-sim.a + +all: plasma + + +plasma: plasma.o $(GR_SIM) + $(CC) $(LFLAGS) $(SDL_LIBS) -o plasma plasma.o \ + $(GR_SIM) + +plasma.o: plasma.c + $(CC) $(CFLAGS) -c plasma.c + + +clean: + rm -f *~ *.o plasma diff --git a/gr-sim/plasma/plasma.c b/gr-sim/plasma/plasma.c new file mode 100644 index 00000000..c7c52488 --- /dev/null +++ b/gr-sim/plasma/plasma.c @@ -0,0 +1,70 @@ +/* for demoscene, you need a plasma effect... */ +/* https://rosettacode.org/wiki/Plasma_effect */ +/* https://www.bidouille.org/prog/plasma */ + +#include +#include +#include +#include + +#include "tfv_zp.h" +#include "gr-sim.h" + +#define pi 3.14159265358979323846264338327950 + + +unsigned char colors[]={15,13,9,1,8,5,0,0}; + + +int main(int argc, char **argv) { + + int ch,xx,yy,sec=128; + double dx,dy,dv,r; + + grsim_init(); + + gr(); + clear_screens(); + + color_equals(15); + hlin(0,0,40,39); + + ram[DRAW_PAGE]=0x0; + + while(1) { + + sec++; + + for(yy=0;yy<40;yy++) { + for(xx=0;xx<40;xx++) { + +// dx = xx + .5 * sin(sec/5.0); + dx = sin(xx+sec); + dy = yy + .5 * cos(sec/3.0); + dv = sin(xx*10 + sec) + + sin(10*(xx*sin(sec/2.0) + + yy*cos(sec/3.0)) + sec) + + sin(sqrt(100*(dx*dx + dy*dy)+1) + sec); + r=fabs(sin(dv*pi))*16; + 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)))); + + + + color_equals(fabs(dx)*16); + plot(xx,yy); + //plot(xx-r+2,yy); +// printf("plot %d,%d = %d\n",xx,yy,colors[col]); + } + + } + + grsim_update(); + ch=grsim_input(); + if (ch=='q') exit(0); + usleep(20000); + + } + + return 0; +}