From 4d7046ab0c9ae969e22fdb9fd0337fa2adb71cf2 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Sat, 29 Dec 2018 00:28:07 -0500 Subject: [PATCH] gr-sim: add fire demo --- gr-sim/fire/Makefile | 36 ++++++++++++++++++++++++++++ gr-sim/fire/fire.c | 53 +++++++++++++++++++++++++++++++++++++++++ gr-sim/fire/fire2.c | 53 +++++++++++++++++++++++++++++++++++++++++ gr-sim/fire/fire_blue.c | 53 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 195 insertions(+) create mode 100644 gr-sim/fire/Makefile create mode 100644 gr-sim/fire/fire.c create mode 100644 gr-sim/fire/fire2.c create mode 100644 gr-sim/fire/fire_blue.c diff --git a/gr-sim/fire/Makefile b/gr-sim/fire/Makefile new file mode 100644 index 00000000..9f46ff0b --- /dev/null +++ b/gr-sim/fire/Makefile @@ -0,0 +1,36 @@ +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: fire fire2 fire_blue + + +fire: fire.o $(GR_SIM) + $(CC) $(LFLAGS) $(SDL_LIBS) -o fire fire.o \ + $(GR_SIM) + +fire.o: fire.c + $(CC) $(CFLAGS) -c fire.c + + +fire2: fire2.o $(GR_SIM) + $(CC) $(LFLAGS) $(SDL_LIBS) -o fire2 fire2.o \ + $(GR_SIM) + +fire2.o: fire2.c + $(CC) $(CFLAGS) -c fire2.c + + +fire_blue: fire_blue.o $(GR_SIM) + $(CC) $(LFLAGS) $(SDL_LIBS) -o fire_blue fire_blue.o \ + $(GR_SIM) + +fire_blue.o: fire_blue.c + $(CC) $(CFLAGS) -c fire_blue.c + +clean: + rm -f *~ *.o fire fire2 fire_blue diff --git a/gr-sim/fire/fire.c b/gr-sim/fire/fire.c new file mode 100644 index 00000000..f92fb4cf --- /dev/null +++ b/gr-sim/fire/fire.c @@ -0,0 +1,53 @@ +#include +#include +#include +#include + +#include "tfv_zp.h" +#include "gr-sim.h" + // 0 1 2 3 4 5 6 7 +unsigned char colors[]={15,13,9,1,8,5,0,0}; + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 +unsigned char reverse[]={6,3,6,6,6,5,6,6,4,2,6, 6, 6, 1, 6, 0}; + +int main(int argc, char **argv) { + + int ch,xx,yy,col,r; + + grsim_init(); + + gr(); + clear_screens(); + + color_equals(15); + hlin(0,0,40,39); + + ram[DRAW_PAGE]=0x0; + + while(1) { + + + for(yy=0;yy<39;yy++) { + for(xx=1;xx<39;xx++) { + + r=rand()&3; + + col=scrn(xx,yy+1); + col=reverse[col]; + color_equals(colors[col+(r&1)]); + 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; +} diff --git a/gr-sim/fire/fire2.c b/gr-sim/fire/fire2.c new file mode 100644 index 00000000..7c3741ea --- /dev/null +++ b/gr-sim/fire/fire2.c @@ -0,0 +1,53 @@ +#include +#include +#include +#include + +#include "tfv_zp.h" +#include "gr-sim.h" + // 0 1 2 3 4 5 6 7 +unsigned char colors[]={15,13,9,1,8,5,0,0}; + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 +unsigned char reverse[]={6,3,6,6,6,5,6,6,4,2,6, 6, 6, 1, 6, 0}; + +int main(int argc, char **argv) { + + int ch,xx,yy,col,r; + + grsim_init(); + + gr(); + clear_screens(); + + color_equals(15); + hlin(0,0,40,39); + + ram[DRAW_PAGE]=0x0; + + while(1) { + + + for(yy=0;yy<39;yy++) { + for(xx=1;xx<38;xx++) { + + r=rand()&3; + + col=scrn(xx,yy+1); + col=reverse[col]; + color_equals(colors[col+(r&1)]); +// 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; +} diff --git a/gr-sim/fire/fire_blue.c b/gr-sim/fire/fire_blue.c new file mode 100644 index 00000000..06109656 --- /dev/null +++ b/gr-sim/fire/fire_blue.c @@ -0,0 +1,53 @@ +#include +#include +#include +#include + +#include "tfv_zp.h" +#include "gr-sim.h" + // 0 1 2 3 4 5 6 7 +unsigned char colors[]={15,14,7,6,2,3,0,0}; + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 +unsigned char reverse[]={6,6,4,5,6,6,3,2,6,6,6, 6, 6, 6, 1, 0}; + +int main(int argc, char **argv) { + + int ch,xx,yy,col,r; + + grsim_init(); + + gr(); + clear_screens(); + + color_equals(15); + hlin(0,0,40,39); + + ram[DRAW_PAGE]=0x0; + + while(1) { + + + for(yy=0;yy<39;yy++) { + for(xx=1;xx<39;xx++) { + + r=rand()&3; + + col=scrn(xx,yy+1); + col=reverse[col]; + color_equals(colors[col+(r&1)]); + 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; +}