From 08a448f8fc823db1b9e402c440c81cffc9f1df02 Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Mon, 1 Feb 2021 13:09:26 -0500 Subject: [PATCH] drops: seeing if possible --- utils/gr-sim/Makefile | 2 + utils/gr-sim/drops/Makefile | 17 ++++ utils/gr-sim/drops/README | 4 + utils/gr-sim/drops/drops.c | 157 ++++++++++++++++++++++++++++++++++++ 4 files changed, 180 insertions(+) create mode 100644 utils/gr-sim/drops/Makefile create mode 100644 utils/gr-sim/drops/README create mode 100644 utils/gr-sim/drops/drops.c diff --git a/utils/gr-sim/Makefile b/utils/gr-sim/Makefile index 39570156..bea57146 100644 --- a/utils/gr-sim/Makefile +++ b/utils/gr-sim/Makefile @@ -9,6 +9,7 @@ SDL_INCLUDE= `sdl-config --cflags` all: gr-sim.a make -C 6502_test make -C dos + make -C drops make -C fade make -C fire # make -C fluid @@ -58,6 +59,7 @@ clean: rm -f *~ *.o *.a make -C 6502_test clean make -C dos clean + make -C drops clean make -C fade clean make -C fire clean make -C fluid clean diff --git a/utils/gr-sim/drops/Makefile b/utils/gr-sim/drops/Makefile new file mode 100644 index 00000000..c76d9032 --- /dev/null +++ b/utils/gr-sim/drops/Makefile @@ -0,0 +1,17 @@ +CC = gcc +CFLAGS = -O2 -Wall -I.. -g + +SDL_LIBS= `sdl-config --libs` +SDL_INCLUDE= `sdl-config --cflags` +GR_SIM = ../gr-sim.a + +all: drops + +drops: drops.o + $(CC) $(LFLAGS) -o drops drops.o $(GR_SIM) $(SDL_LIBS) + +drops.o: drops.c + $(CC) $(CFLAGS) -c drops.c + +clean: + rm -f *~ *.o drops diff --git a/utils/gr-sim/drops/README b/utils/gr-sim/drops/README new file mode 100644 index 00000000..8c0af098 --- /dev/null +++ b/utils/gr-sim/drops/README @@ -0,0 +1,4 @@ +raindrop type visualization + +Roughly based on this code by Seban/Slight +https://github.com/seban-slt/Atari8BitBot/blob/master/ASM/water/water.m65 diff --git a/utils/gr-sim/drops/drops.c b/utils/gr-sim/drops/drops.c new file mode 100644 index 00000000..2be936df --- /dev/null +++ b/utils/gr-sim/drops/drops.c @@ -0,0 +1,157 @@ +/* Based on https://twitter.com/seban_slt/status/1349084515755548676 + https://github.com/seban-slt/Atari8BitBot/blob/master/ASM/water/water.m65 */ + +#include +#include +#include + +#include "gr-sim.h" +#include "tfv_zp.h" + +#define XSIZE 40 +#define YSIZE 48 + +static unsigned char buffer1[XSIZE*YSIZE]; +static unsigned char buffer2[XSIZE*YSIZE]; +static unsigned int frame=0; + + +static void update_frame2(void) { + int xx,yy,temp; + + for(yy=0;yy0) temp+=buffer1[(yy-1)*XSIZE+xx]; + if (yy0) temp+=buffer1[yy*XSIZE+xx-1]; + if (xx0) temp+=buffer2[(yy-1)*XSIZE+xx]; + if (yy0) temp+=buffer2[yy*XSIZE+xx-1]; + if (xxXSIZE-1) xx--; + if (yy>YSIZE-1) yy--; + + + buffer1[yy*XSIZE+xx]=0x1f; + buffer1[yy*XSIZE+xx+1]=0x1f; + buffer1[yy*XSIZE+xx-1]=0x1f; + buffer1[(yy+1)*XSIZE+xx]=0x1f; + buffer1[(yy-1)*XSIZE+xx]=0x1f; + + } + + grsim_update(); + + usleep(60000); + frame++; + + ch=grsim_input(); + if (ch=='q') return 0; + if (ch==27) return 0; + } + + return 0; +}