forked from gbezyuk/bb-osx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
scene8.c
115 lines (114 loc) · 3.03 KB
/
scene8.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*
* BB: The portable demo
*
* (C) 1997 by AA-group (e-mail: aa@horac.ta.jcu.cz)
*
* 3rd August 1997
* version: 1.2 [final3]
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public Licences as by published
* by the Free Software Foundation; either version 2; or (at your option)
* any later version
*
* This program is distributed in the hope that it will entertaining,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILTY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Publis License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.
* 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdlib.h>
#include <math.h>
#include "bb.h"
#define STATE1 (TIME-starttime1)
#define STATE (time-starttime)
#define IN(v2,v1) (((double)(v1)*mul1+(v2)*mul2)/div)
extern struct image zeb;
static int xs, xe, ys, ye, starttime1;
static int sxs, sys, sye, sxe, cs, ce, bs, be, rs, re;
static void mydraw(void)
{
int cx, cy;
int sx, sy;
int time = TIME;
int mul1, mul2, div = (endtime - starttime) >> 8;
if (time < starttime)
time = starttime;
if (time > endtime)
time = endtime;
mul1 = STATE >> 8, mul2 = (endtime - time) >> 8, div = (endtime - starttime) >> 8;
if (mul2 < 0)
mul1 -= mul2, mul2 = 0;
cx = IN(xs, xe) + sin(STATE1 / 300000.0) * 40;
cy = IN(ys, ye) + cos(STATE1 / 500000.0) * 40;
sx = IN(sxs, sxe) + sin(STATE1 / 520000.0) * 70;
sy = IN(sys, sye) + cos(STATE1 / 700000.0) * 70;
params->contrast = IN(cs, ce);
params->bright = IN(bs, be);
params->randomval = IN(rs, re);
scale(&zeb, (cx - sx) * zeb.width / 1000,
(cy - sy) * zeb.height / 1000,
(cx + sx) * zeb.width / 1000,
(cy + sy) * zeb.height / 1000);
}
void scene8()
{
decompressimg(&zeb);
drawptr = mydraw;
starttime1 = starttime;
bs = -255;
be = 0;
rs = 100;
re = 100;
cs = 100, ce = 100;
xs = xe = 300;
ys = ye = 400;
sxs = sys = sxe = sye = 100;
timestuff(0, NULL, draw, 2 * 1000000);
bs = be;
re = 0;
timestuff(0, NULL, draw, 1 * 1000000);
rs = re;
timestuff(0, NULL, draw, 5 * 1000000);
sxe = 200;
sye = 200;
xs = xe;
ys = ye;
xe = 750;
ye = 300;
timestuff(0, NULL, draw, 3 * 1000000);
xs = xe;
ys = ye;
sxs = sxe, sys = sye;
ce = 20;
sxe = 300;
sye = 300;
timestuff(0, NULL, draw, 1 * 1000000);
cs = ce;
xs = xe;
ys = ye;
sxs = sxe, sys = sye;
ye = 400;
sxe = 600;
sye = 600;
timestuff(0, NULL, draw, 2 * 1000000);
xs = xe;
ys = ye;
sxs = sxe, sys = sye;
sxe = 200;
sye = 200;
timestuff(0, NULL, draw, 1 * 1000000);
xs = xe;
ys = ye;
sxs = sxe, sys = sye;
be = 255;
sxe = 120;
sye = 120;
timestuff(0, NULL, draw, 0.2 * 1000000);
free(zeb.decompressed);
params->bright = 0;
params->contrast = 0;
}