gr-sim: add fire demo

This commit is contained in:
Vince Weaver 2018-12-29 00:28:07 -05:00
parent 1f96e82a8e
commit 4d7046ab0c
4 changed files with 195 additions and 0 deletions

36
gr-sim/fire/Makefile Normal file
View File

@ -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

53
gr-sim/fire/fire.c Normal file
View File

@ -0,0 +1,53 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#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;
}

53
gr-sim/fire/fire2.c Normal file
View File

@ -0,0 +1,53 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#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;
}

53
gr-sim/fire/fire_blue.c Normal file
View File

@ -0,0 +1,53 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#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;
}