mirror of
https://github.com/deater/dos33fsprogs.git
synced 2025-02-15 12:31:53 +00:00
water: trying a new effect
This commit is contained in:
parent
2bccf8d2aa
commit
a4cf65e28f
39
gr-sim/fluid/water.c
Normal file
39
gr-sim/fluid/water.c
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
// Based on Fluid_Sim
|
||||||
|
// an IOCCC 2012 winner
|
||||||
|
// by Yusuke Endoh
|
||||||
|
|
||||||
|
#define G 1 // gravity
|
||||||
|
#define P 4 // pressure
|
||||||
|
#define V 8 // viscosity
|
||||||
|
|
||||||
|
#include <stdio.h>// .IOCCC Fluid- #
|
||||||
|
#include <unistd.h> //2012 _Sim!_ #
|
||||||
|
#include <complex.h> //|||| ,____. IOCCC- #
|
||||||
|
double complex a[97687], *p, *q, *r = a, w = 0, d;
|
||||||
|
int x , y;
|
||||||
|
char b [6856] = "\x1b[2J" "\x1b" "[1;1H ", *o = b, *t;
|
||||||
|
|
||||||
|
int main(
|
||||||
|
) {
|
||||||
|
|
||||||
|
for (; 0 < (x = getc(stdin));)
|
||||||
|
w = x > 10 ? 32 < x ? 4[*r++ = w, r] = w + 1, *r = r[5] = x == 35, r += 9 : 0, w - I : (x = w + 2);;
|
||||||
|
for (;; puts(o), o = b + 4) {
|
||||||
|
for (p = a; p[2] = p[1] * 9, p < r; p += 5)
|
||||||
|
for (q = a; w = cabs(d = *p - *q) / 2 - 1, q < r; q += 5)
|
||||||
|
if (0 < (x = 1 - w))
|
||||||
|
p[2] += w * w;
|
||||||
|
for (p = a; p[3] = G, p < r; p += 5)
|
||||||
|
for (q = a; w = cabs(d = *p - *q) / 2 - 1, q < r; q += 5)
|
||||||
|
if (0 < (x = 1 - w))
|
||||||
|
p[3] += w * (d * (3 - p[2] - q[2]) * P + p[4] * V - q[4] * V) / p[2];
|
||||||
|
for (x = 011; 2012 - 1 > x++;)
|
||||||
|
b[x] = 0;
|
||||||
|
for (p = a; (t = b + 10 + (x = *p * I) + 80 * (y = *p / 2), *p += p[4] += p[3] / 10 * !p[1]), p < r; p += 5)
|
||||||
|
x = 0 <= x && x < 79 && 0 <= y && y < 23 ? 1[1[*t |= 8, t] |= 4, t += 80] = 1, *t |= 2 : 0;
|
||||||
|
for (x = 011; 2012 - 1 > x++;)
|
||||||
|
b[x] = " '`-.|//,\\" "|\\_" "\\/\x23\n"[x % 80 - 9 ? x[b] : 16];;
|
||||||
|
|
||||||
|
usleep(12321);
|
||||||
|
} return 0;
|
||||||
|
}
|
28
gr-sim/water/Makefile
Normal file
28
gr-sim/water/Makefile
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
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: water
|
||||||
|
|
||||||
|
|
||||||
|
####
|
||||||
|
#demo_title.c: ../gr-utils/png2rle ../tfv/demo.png
|
||||||
|
# ../gr-utils/png2rle c ../tfv/demo.png demo_rle > demo_title.c
|
||||||
|
|
||||||
|
|
||||||
|
####
|
||||||
|
|
||||||
|
water: water.o $(GR_SIM)
|
||||||
|
$(CC) $(LFLAGS) $(SDL_LIBS) -o water water.o $(GR_SIM)
|
||||||
|
|
||||||
|
water.o: water.c demo_title.c
|
||||||
|
$(CC) $(CFLAGS) -c water.c
|
||||||
|
|
||||||
|
####
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *~ *.o water
|
53
gr-sim/water/demo_title.c
Normal file
53
gr-sim/water/demo_title.c
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
unsigned char demo_rle[]={
|
||||||
|
0x28, /* ysize=40 */
|
||||||
|
0xAF,0x00,0xA7,0xCC,0x40,0xA0,0x21,0x00,0xA4,0x04,0xCC,0xCC,0x44,
|
||||||
|
0xA0,0x11,0x00,0xFF,0x6F,0xA3,0xFF,0x6F,0xFF,0x2F,
|
||||||
|
0xFF,0x6F,0x6F,0xFF,0x2F,0x2F,0xFF,0x50,0xA3,0x00,
|
||||||
|
0xC0,0xCC,0x4C,0x44,0x00,0xFF,0x6F,0x6F,
|
||||||
|
0xFF,0x2F,0x2F,0x6F,0xA3,0xFF,0x6F,0xFF,0x2F,
|
||||||
|
0xFF,0xFF,0x50,0xFF,0x66,0xF6,0x6F,0xF6,
|
||||||
|
0x66,0x22,0xFF,0x22,0x66,0xFF,0x66,
|
||||||
|
0x22,0x2F,0xFF,0x55,0x00,0x00,0xC0,0xCC,
|
||||||
|
0x4C,0x44,0x00,0x00,0xFF,0x66,0xFF,0x66,
|
||||||
|
0x22,0x2F,0x66,0xF6,0x6F,0xF6,0x66,
|
||||||
|
0x22,0xFF,0x22,0xFF,0x55,0xFF,0x66,
|
||||||
|
0xA3,0xFF,0x66,0x22,0xFF,0x22,0x66,0xFF,
|
||||||
|
0x66,0x22,0xFF,0xFF,0x55,0x00,0xC0,0xCC,
|
||||||
|
0x4C,0x44,0xA3,0x00,0xFF,0x66,0xFF,0x66,
|
||||||
|
0x22,0xF2,0x66,0xA3,0xFF,0x66,0x22,0xFF,
|
||||||
|
0x22,0xFF,0x55,0xFF,0xF6,0xA3,0xFF,0xF6,
|
||||||
|
0xFF,0xF2,0xFF,0xF6,0xF6,0xFF,0xF2,0xF2,0xFF,
|
||||||
|
0x55,0x00,0xCC,0xCC,0x44,0xA4,0x00,0xFF,0xF6,0xF6,
|
||||||
|
0xFF,0xF2,0xF2,0xF6,0xA3,0xFF,0xF6,0xFF,0xF2,
|
||||||
|
0xFF,0xFF,0x55,0x00,0xAF,0x05,0x00,0xCC,0xCC,0x44,
|
||||||
|
0xA5,0x00,0xAF,0x05,0xA3,0x00,0xA8,0x80,0xA6,0x00,0xCC,0xCC,0x44,
|
||||||
|
0xA0,0x17,0x00,0x88,0x88,0xA4,0x28,0xB8,0x28,0xA3,0x20,0xA4,0x00,
|
||||||
|
0x04,0x04,0xA0,0x18,0x00,0x88,0x22,0xFB,0x0B,0x22,
|
||||||
|
0xB2,0x22,0xFB,0x0B,0x22,0x00,0x00,0x60,
|
||||||
|
0x76,0xA0,0x14,0x00,0x10,0xA5,0x00,0x88,0xA4,0xB2,0x3B,
|
||||||
|
0x32,0xB2,0x02,0x02,0x00,0x60,0x76,0x07,
|
||||||
|
0xA0,0x11,0x00,0x10,0x00,0x10,0x11,0x01,0xA4,0x00,
|
||||||
|
0x88,0x55,0xA5,0xBB,0xA3,0x00,0x60,0x76,0x07,
|
||||||
|
0xA6,0x00,0xD0,0x0D,0x00,0xD0,0x0D,0x00,
|
||||||
|
0xD0,0xA5,0x00,0x11,0xA8,0x00,0x88,0x85,0xA3,0xBB,
|
||||||
|
0xB1,0x0B,0x00,0x0D,0xD0,0x76,0x07,
|
||||||
|
0xA5,0x00,0xD0,0xDD,0xD0,0xD0,0xDD,0xD0,0xD0,0xDD,
|
||||||
|
0xD0,0xA3,0x00,0x01,0x01,0x11,0x01,0x01,0xA5,0x00,0x80,
|
||||||
|
0x88,0x98,0xB8,0xB3,0xB3,0xB0,0x30,0x33,
|
||||||
|
0xF3,0xFF,0xFD,0xA3,0xF0,0xA3,0x00,0xDD,0xA7,0xBB,
|
||||||
|
0xDD,0xA4,0x00,0x10,0x11,0x10,0xA6,0x00,0x88,
|
||||||
|
0xA3,0x99,0x9B,0xBB,0xBB,0x9B,0x93,0x00,0xFF,0xFF,
|
||||||
|
0xF7,0xF0,0xFF,0xFF,0x70,0x00,0xDD,0xBB,
|
||||||
|
0xBF,0xB0,0xBB,0xBF,0xB0,0xBB,0xDD,
|
||||||
|
0xA3,0x00,0x10,0xA3,0x11,0x10,0xA5,0x00,0x08,0x99,
|
||||||
|
0xB9,0xA6,0x99,0x80,0xA3,0x8F,0xFF,0xFF,0x0F,0x07,
|
||||||
|
0x00,0xDD,0xDB,0xBB,0x3B,0x33,0xBB,0xBB,
|
||||||
|
0xDB,0xDD,0xA3,0x00,0x01,0x01,0x11,0x01,0x01,0xA6,0x00,
|
||||||
|
0x99,0xBB,0xA4,0x99,0x09,0x80,0xA4,0xFF,0xF7,
|
||||||
|
0x0F,0xA3,0x00,0xDD,0xDD,0xA5,0xBB,0xDD,0xDD,0xA5,0x00,0x11,
|
||||||
|
0xA8,0x00,0x99,0xBB,0xA3,0xB9,0x99,0x88,0xA5,0xFF,
|
||||||
|
0xA5,0x00,0x0D,0x00,0xBB,0xA3,0xB1,0xBB,0x00,
|
||||||
|
0x0D,0xA4,0x00,0xBB,0xBB,0xA7,0x00,0x99,0x99,0xA4,0x9B,0xFB,
|
||||||
|
0xA6,0xFF,0xA8,0x00,0xBB,0xBB,0xA6,0x00,0x20,0x22,0x2B,
|
||||||
|
0x0B,0xA6,0x00,0x90,0xA5,0x99,0xF9,0xA7,0xFF,0xA5,0x00,
|
||||||
|
0x20,0xA6,0x22,0xA3,0x20,0x22,0x22,0x02,0xA6,0x00,0xA1, };
|
@ -1,39 +1,148 @@
|
|||||||
// Based on Fluid_Sim
|
#include <stdio.h>
|
||||||
// an IOCCC 2012 winner
|
#include <stdlib.h>
|
||||||
// by Yusuke Endoh
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#define G 1 // gravity
|
#include "gr-sim.h"
|
||||||
#define P 4 // pressure
|
#include "tfv_utils.h"
|
||||||
#define V 8 // viscosity
|
#include "tfv_zp.h"
|
||||||
|
|
||||||
#include <stdio.h>// .IOCCC Fluid- #
|
#include "demo_title.c"
|
||||||
#include <unistd.h> //2012 _Sim!_ #
|
#if 0
|
||||||
#include <complex.h> //|||| ,____. IOCCC- #
|
static int fade_map[2][16]={
|
||||||
double complex a[97687], *p, *q, *r = a, w = 0, d;
|
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
|
||||||
int x , y;
|
{0,1,2,2,4,5,2,5, 8,8,5,3,4,8,4,7},
|
||||||
char b [6856] = "\x1b[2J" "\x1b" "[1;1H ", *o = b, *t;
|
{0,0,0,5,0,0,5,5, 0,0,0,5,8,5,5,5},
|
||||||
|
|
||||||
int main(
|
};
|
||||||
) {
|
#endif
|
||||||
|
|
||||||
for (; 0 < (x = getc(stdin));)
|
static int fade_map[2][16]={
|
||||||
w = x > 10 ? 32 < x ? 4[*r++ = w, r] = w + 1, *r = r[5] = x == 35, r += 9 : 0, w - I : (x = w + 2);;
|
// 0 1 2 3 4 5 6 7 8 9 a b c d e f
|
||||||
for (;; puts(o), o = b + 4) {
|
{0,0,0,2,0,0,2,5, 5,8,5,3,4,8,4,7},
|
||||||
for (p = a; p[2] = p[1] * 9, p < r; p += 5)
|
{0,0,0,0,0,0,5,0, 0,0,0,0,8,0,0,5},
|
||||||
for (q = a; w = cabs(d = *p - *q) / 2 - 1, q < r; q += 5)
|
|
||||||
if (0 < (x = 1 - w))
|
|
||||||
p[2] += w * w;
|
|
||||||
for (p = a; p[3] = G, p < r; p += 5)
|
|
||||||
for (q = a; w = cabs(d = *p - *q) / 2 - 1, q < r; q += 5)
|
|
||||||
if (0 < (x = 1 - w))
|
|
||||||
p[3] += w * (d * (3 - p[2] - q[2]) * P + p[4] * V - q[4] * V) / p[2];
|
|
||||||
for (x = 011; 2012 - 1 > x++;)
|
|
||||||
b[x] = 0;
|
|
||||||
for (p = a; (t = b + 10 + (x = *p * I) + 80 * (y = *p / 2), *p += p[4] += p[3] / 10 * !p[1]), p < r; p += 5)
|
|
||||||
x = 0 <= x && x < 79 && 0 <= y && y < 23 ? 1[1[*t |= 8, t] |= 4, t += 80] = 1, *t |= 2 : 0;
|
|
||||||
for (x = 011; 2012 - 1 > x++;)
|
|
||||||
b[x] = " '`-.|//,\\" "|\\_" "\\/\x23\n"[x % 80 - 9 ? x[b] : 16];;
|
|
||||||
|
|
||||||
usleep(12321);
|
};
|
||||||
} return 0;
|
|
||||||
|
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
|
int x,temph,templ,ch;
|
||||||
|
|
||||||
|
grsim_init();
|
||||||
|
gr();
|
||||||
|
|
||||||
|
// clear_screens();
|
||||||
|
|
||||||
|
ram[DRAW_PAGE]=PAGE0;
|
||||||
|
clear_bottom();
|
||||||
|
ram[DRAW_PAGE]=PAGE1;
|
||||||
|
clear_bottom();
|
||||||
|
ram[DRAW_PAGE]=PAGE2;
|
||||||
|
clear_bottom();
|
||||||
|
|
||||||
|
|
||||||
|
// clear_bottom(PAGE0);
|
||||||
|
// clear_bottom(PAGE1);
|
||||||
|
// clear_bottom(PAGE2);
|
||||||
|
|
||||||
|
// grsim_unrle(demo_rle,0x400);
|
||||||
|
grsim_unrle(demo_rle,0xc00);
|
||||||
|
|
||||||
|
gr_copy_to_current(0xc00);
|
||||||
|
page_flip();
|
||||||
|
gr_copy_to_current(0xc00);
|
||||||
|
page_flip();
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
repeat_until_keypressed();
|
||||||
|
|
||||||
|
/* Fade step 1 */
|
||||||
|
for(x=0xc00;x<0x1000;x++) {
|
||||||
|
temph=ram[x]&0xf0;
|
||||||
|
templ=ram[x]&0x0f;
|
||||||
|
|
||||||
|
templ=fade_map[0][templ];
|
||||||
|
temph=fade_map[0][temph>>4];
|
||||||
|
|
||||||
|
ram[x-0x800]=(temph<<4)|templ;
|
||||||
|
}
|
||||||
|
grsim_update();
|
||||||
|
|
||||||
|
ch=repeat_until_keypressed();
|
||||||
|
if (ch=='q') break;
|
||||||
|
|
||||||
|
/* Fade step 2 */
|
||||||
|
|
||||||
|
for(x=0xc00;x<0x1000;x++) {
|
||||||
|
temph=ram[x]&0xf0;
|
||||||
|
templ=ram[x]&0x0f;
|
||||||
|
|
||||||
|
templ=fade_map[1][templ];
|
||||||
|
temph=fade_map[1][temph>>4];
|
||||||
|
|
||||||
|
ram[x-0x800]=(temph<<4)|templ;
|
||||||
|
}
|
||||||
|
grsim_update();
|
||||||
|
|
||||||
|
ch=repeat_until_keypressed();
|
||||||
|
if (ch=='q') break;
|
||||||
|
|
||||||
|
/* Fade to black */
|
||||||
|
|
||||||
|
for(x=0x400;x<0x800;x++) {
|
||||||
|
ram[x]=0x00;
|
||||||
|
}
|
||||||
|
grsim_update();
|
||||||
|
|
||||||
|
ch=repeat_until_keypressed();
|
||||||
|
if (ch=='q') break;
|
||||||
|
|
||||||
|
|
||||||
|
/* Unfade step 2 */
|
||||||
|
for(x=0xc00;x<0x1000;x++) {
|
||||||
|
temph=ram[x]&0xf0;
|
||||||
|
templ=ram[x]&0x0f;
|
||||||
|
|
||||||
|
templ=fade_map[1][templ];
|
||||||
|
temph=fade_map[1][temph>>4];
|
||||||
|
|
||||||
|
ram[x-0x800]=(temph<<4)|templ;
|
||||||
|
}
|
||||||
|
grsim_update();
|
||||||
|
|
||||||
|
ch=repeat_until_keypressed();
|
||||||
|
if (ch=='q') break;
|
||||||
|
|
||||||
|
/* Unfade step 1 */
|
||||||
|
for(x=0xc00;x<0x1000;x++) {
|
||||||
|
temph=ram[x]&0xf0;
|
||||||
|
templ=ram[x]&0x0f;
|
||||||
|
|
||||||
|
templ=fade_map[0][templ];
|
||||||
|
temph=fade_map[0][temph>>4];
|
||||||
|
|
||||||
|
ram[x-0x800]=(temph<<4)|templ;
|
||||||
|
}
|
||||||
|
grsim_update();
|
||||||
|
|
||||||
|
ch=repeat_until_keypressed();
|
||||||
|
if (ch=='q') break;
|
||||||
|
|
||||||
|
/* Total unfade */
|
||||||
|
for(x=0xc00;x<0x1000;x++) {
|
||||||
|
temph=ram[x]&0xf0;
|
||||||
|
templ=ram[x]&0x0f;
|
||||||
|
|
||||||
|
ram[x-0x800]=(temph)|templ;
|
||||||
|
}
|
||||||
|
grsim_update();
|
||||||
|
|
||||||
|
ch=repeat_until_keypressed();
|
||||||
|
if (ch=='q') break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user