mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-03-02 21:29:24 +00:00
drops: seeing if possible
This commit is contained in:
parent
854e176e09
commit
08a448f8fc
@ -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
|
||||
|
17
utils/gr-sim/drops/Makefile
Normal file
17
utils/gr-sim/drops/Makefile
Normal file
@ -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
|
4
utils/gr-sim/drops/README
Normal file
4
utils/gr-sim/drops/README
Normal file
@ -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
|
157
utils/gr-sim/drops/drops.c
Normal file
157
utils/gr-sim/drops/drops.c
Normal file
@ -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 <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#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;yy<YSIZE;yy++) {
|
||||
for(xx=0;xx<XSIZE;xx++) {
|
||||
temp=0;
|
||||
if (yy>0) temp+=buffer1[(yy-1)*XSIZE+xx];
|
||||
if (yy<YSIZE-1) temp+=buffer1[(yy+1)*XSIZE+xx];
|
||||
if (xx>0) temp+=buffer1[yy*XSIZE+xx-1];
|
||||
if (xx<XSIZE-1) temp+=buffer1[yy*XSIZE+xx+1];
|
||||
temp/=2;
|
||||
temp-=buffer2[yy*XSIZE+xx];
|
||||
if (temp<0) temp=-temp;
|
||||
buffer2[yy*XSIZE+xx]=temp;
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
static void update_frame1(void) {
|
||||
int xx,yy,temp;
|
||||
|
||||
for(yy=0;yy<YSIZE;yy++) {
|
||||
for(xx=0;xx<XSIZE;xx++) {
|
||||
temp=0;
|
||||
if (yy>0) temp+=buffer2[(yy-1)*XSIZE+xx];
|
||||
if (yy<YSIZE-1) temp+=buffer2[(yy+1)*XSIZE+xx];
|
||||
if (xx>0) temp+=buffer2[yy*XSIZE+xx-1];
|
||||
if (xx<XSIZE-1) temp+=buffer2[yy*XSIZE+xx+1];
|
||||
temp/=2;
|
||||
temp-=buffer1[yy*XSIZE+xx];
|
||||
if (temp<0) temp=-temp;
|
||||
buffer1[yy*XSIZE+xx]=temp;
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
static void plot_frame1(void) {
|
||||
|
||||
int xx,yy,c;
|
||||
|
||||
for(yy=0;yy<YSIZE;yy++) {
|
||||
for(xx=0;xx<XSIZE;xx++) {
|
||||
c=buffer1[yy*XSIZE+xx];
|
||||
c/=2;
|
||||
if (c==0) c=0;
|
||||
else if (c==1) c=2;
|
||||
else if (c==2) c=6;
|
||||
else if (c==3) c=14;
|
||||
else if (c==4) c=7;
|
||||
else c=15;
|
||||
color_equals(c);
|
||||
plot(xx,yy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void plot_frame2(void) {
|
||||
|
||||
int xx,yy,c;
|
||||
|
||||
for(yy=0;yy<YSIZE;yy++) {
|
||||
for(xx=0;xx<XSIZE;xx++) {
|
||||
c=buffer1[yy*XSIZE+xx];
|
||||
c/=2;
|
||||
if (c==0) c=0;
|
||||
else if (c==1) c=2;
|
||||
else if (c==2) c=6;
|
||||
else if (c==3) c=14;
|
||||
else if (c==4) c=7;
|
||||
else c=15;
|
||||
color_equals(c);
|
||||
plot(xx,yy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
|
||||
int xx,yy;
|
||||
int ch;
|
||||
|
||||
grsim_init();
|
||||
|
||||
gr();
|
||||
|
||||
clear_screens();
|
||||
|
||||
ram[DRAW_PAGE]=0;
|
||||
|
||||
frame=0;
|
||||
|
||||
while(1) {
|
||||
|
||||
if (frame&1) {
|
||||
update_frame1();
|
||||
plot_frame1();
|
||||
}
|
||||
else {
|
||||
update_frame2();
|
||||
plot_frame2();
|
||||
}
|
||||
|
||||
if ((frame&0x1f)==0) {
|
||||
|
||||
xx=rand()%XSIZE;
|
||||
yy=rand()%YSIZE;
|
||||
|
||||
if (xx==0) xx++;
|
||||
if (yy==0) yy++;
|
||||
if (xx>XSIZE-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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user