diff --git a/utils/gr-sim/plasma/Makefile b/utils/gr-sim/plasma/Makefile index d066924b..82e53a28 100644 --- a/utils/gr-sim/plasma/Makefile +++ b/utils/gr-sim/plasma/Makefile @@ -6,7 +6,7 @@ SDL_LIBS= `sdl-config --libs` SDL_INCLUDE= `sdl-config --cflags` GR_SIM = ../gr-sim.a -all: plasma plasma_fixed +all: plasma plasma_fixed plasma_new ### @@ -19,6 +19,16 @@ plasma.o: plasma.c ### +plasma_new: plasma_new.o $(GR_SIM) + $(CC) -o plasma_new plasma_new.o \ + $(GR_SIM) $(LFLAGS) $(SDL_LIBS) + +plasma_new.o: plasma_new.c + $(CC) $(CFLAGS) -c plasma_new.c + + +### + plasma_fixed: plasma_fixed.o $(GR_SIM) $(CC) -o plasma_fixed plasma_fixed.o \ $(GR_SIM) $(LFLAGS) $(SDL_LIBS) diff --git a/utils/gr-sim/plasma/plasma_new.c b/utils/gr-sim/plasma/plasma_new.c new file mode 100644 index 00000000..28d5b562 --- /dev/null +++ b/utils/gr-sim/plasma/plasma_new.c @@ -0,0 +1,110 @@ +/* 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 + + +#if 1 +static unsigned char color_lookup[]={0x0, 0x0, 0x5, 0x5, + 0x7, 0x7, 0xf, 0xf, + 0x7, 0x7, 0x6, 0x6, + 0x2, 0x2, 0x5, 0x5}; +#else + +static unsigned char color_lookup[]={0x0, 0x5, 0x7, 0xf, + 0x7, 0x6, 0x2, 0x5, + 0x0, 0x5, 0x7, 0xf, + 0x7, 0x6, 0x2, 0x5}; + +#endif + +static int offscreen[40][40]; + +int main(int argc, char **argv) { + + int ch,xx,yy,col; + + grsim_init(); + + gr(); + soft_switch(MIXCLR); + + clear_screens(); + + ram[DRAW_PAGE]=0x0; + + for(yy=0;yy<40;yy++) { + for(xx=0;xx<40;xx++) { + +// col = ( 32.0 + (32.0 * sin(xx / 4.0)) + // + 32.0 + (32.0 * sin(yy / 4.0)) + // ) / 2; + + +// col = ( 8.0 + (8.0 * sin(xx *PI/8.0)) + // + 8.0 + (8.0 * sin(yy *PI/8.0)) + // ) / 2; + +#if 0 + col = (int) + ( + 128.0 + (128.0 * sin(xx / 16.0)) + + 128.0 + (128.0 * sin(yy / 8.0)) + + 128.0 + (128.0 * sin((xx + yy) / 16.0)) + + 128.0 + (128.0 * sin(sqrt( (double)(xx * xx + yy * yy)) / 8.0)) + ) / 4; +#else + col = (int) + (( + 4.0 + sin(xx / 16.0) + + sin(yy / 8.0) + + sin((xx + yy) / 16.0) + // + sin(sqrt(xx * xx + yy * yy) / 8.0) + )*32) ; + + printf("%d %d %d\n",xx,yy,col); +#endif + + + offscreen[xx][yy]=col; + } + } + + while(1) { + for(yy=0;yy<40;yy++) { + for(xx=0;xx<40;xx++) { + col=offscreen[xx][yy]; + color_equals(color_lookup[col]); + col++; + col&=0xf; + offscreen[xx][yy]=col; + plot(xx,yy); + } + } + + grsim_update(); + + ch=grsim_input(); + if (ch=='q') exit(0); + + if (ch==' ') { + while(1) { + ch=grsim_input(); + if (ch) break; + } + } + usleep(200000); + } + + + return 0; +}