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 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
|
/*
* BB: The portable demo
*
* (C) 1997 by AA-group (e-mail: [email protected])
*
* 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 <string.h>
#include <malloc.h>
#include <math.h>
#include "bb.h"
#include "tex.h"
static unsigned char *helpbuffer;
static unsigned char *text, *text1;
static int aaval = -1, colorval;
static int sstarttime;
#define DEANTIALIAS(a) (((a)!=0)*255*mul acolor*(255-mul))>>8;
static void do3d()
{
int t = pow((TIME - sstarttime) / 30000 / 200.0, 1.3) * 200;
if (t < 0)
t = 0;
alfa = beta = gama = t;
beta = 90;
alfa %= 360;
beta %= 360;
gama %= 360;
disp3d();
}
static void mydraw(void)
{
int x, y;
unsigned char *pos = context->imagebuffer;
unsigned char *pos1 = helpbuffer;
if (aaval >= 0) {
for (y = 0; y < aa_imgheight(context); y = 2) {
int mul;
mul = (-y) * 8 aaval;
if (mul < 0)
mul = 0;
if (mul > 255)
mul = 255;
for (x = 0; x < aa_imgwidth(context); x = 2) {
int acolor;
if (*pos1 || *(pos1 1) || *(pos1 aa_imgwidth(context)) || *(pos1 1 aa_imgwidth(context)))
acolor = 255;
else
acolor = 0;
*pos = DEANTIALIAS(*pos1);
*(pos 1) = DEANTIALIAS(*(pos1 1));
*(pos aa_imgwidth(context)) = DEANTIALIAS(*(pos1 aa_imgwidth(context)));
*(pos 1 aa_imgwidth(context)) = DEANTIALIAS(*(pos1 1 aa_imgwidth(context)));
pos = 2;
pos1 = 2;
}
pos = aa_imgwidth(context);
pos1 = aa_imgwidth(context);
}
}
else
clrscr();
drawprujezd(text, starttime);
}
static void mydraw1(void)
{
int x, y;
unsigned char *pos = context->imagebuffer;
unsigned char *pos1 = helpbuffer;
int mul2 = 255 * (255 - colorval);
if (aaval >= 0) {
for (y = 0; y < aa_imgheight(context); y = 1) {
for (x = 0; x < aa_imgwidth(context); x = 1) {
*pos = (*pos1 * colorval ((*pos1) != 0) * mul2) >> 8;
pos ;
pos1 ;
}
}
}
else
clrscr();
drawprujezd(text, starttime);
}
static void mydraw2(void)
{
do3d();
drawprujezd(text, starttime);
}
static void mydraw3(void)
{
clrscr();
drawlepic(text);
}
static void mydraw4(void)
{
do3d();
drawlepic(text);
}
static void mydraw5(void)
{
do3d();
drawlevotoc(text, text1, starttime);
}
static void mydraw6(void)
{
do3d();
drawhorotoc(text, text1, starttime);
}
static void mydraw8(void)
{
do3d();
/*params->bright=-(TIME-starttime)*256/(endtime-starttime); */
centerx = (TIME - starttime) * 400 / (endtime - starttime);
}
static void mydraw7(void)
{
do3d();
drawpravotoc(text, text1, starttime);
}
static void decaaval(int i)
{
aaval = 7 * i;
}
static void inccolor(int i)
{
colorval = (TIME - starttime) * 256 / (endtime - starttime);
}
static void incgama(int i)
{
params->gamma = 1.0 (TIME - starttime) * 4.0 / (endtime - starttime);
}
static void decgama(int i)
{
params->gamma = 1.0 (endtime - TIME) * 4.0 / (endtime - starttime);
}
static void incrandom(int i)
{
if (TIME < (endtime starttime) / 2) {
params->randomval = (TIME - starttime) * 256 / (endtime - starttime);
}
else
params->randomval = (endtime - TIME) * 256 / (endtime - starttime);
}
static void pauzicka()
{
drawptr = do3d;
timestuff(0, NULL, draw, 2 * 1000000);
}
static void stmivac()
{
drawptr = mydraw8;
timestuff(0, NULL, draw, 2 * 1000000);
}
void scene5(void)
{
aaval = -1;
set_zbuff();
helpbuffer = malloc(aa_imgwidth(context) * aa_imgheight(context));
alfa = 0;
beta = 90;
gama = 0;
centerx = 0;
centery = 0;
centerz = 0;
zoom = 1.5;
torusconstructor();
disp3d();
memcpy(helpbuffer, context->imagebuffer, aa_imgwidth(context) * aa_imgheight(context));
params->dither = AA_NONE;
text = "Supports";
drawptr = mydraw3;
initlepic();
timestuff(-60, ctrllepic, draw, 2 * 1000000);
drawptr = mydraw;
aaval = 0;
text = "ANTIALIASING";
timestuff(60, NULL, draw, 5 * 1000000);
text = "";
timestuff(-60, decaaval, draw, 3 * 1000000);
text = "256 colors-ascii";
colorval = 0;
drawptr = mydraw1;
timestuff(-60, inccolor, draw, 6 * 1000000);
sstarttime = TIME;
pauzicka();
initlepic();
text = "dithering";
drawptr = mydraw4;
timestuff(-60, ctrllepic, draw, 2 * 1000000);
pauzicka();
text = "random";
drawptr = mydraw2;
timestuff(-60, incrandom, draw, 3 * 1000000);
params->randomval = 0;
pauzicka();
text1 = " ";
text = "Error";
drawptr = mydraw6;
timestuff(60, NULL, draw, 1 * 1000000);
params->dither = AA_ERRORDISTRIB;
text1 = "Error";
text = "distribution";
drawptr = mydraw6;
timestuff(60, NULL, draw, 1 * 1000000);
text1 = "distribution";
text = " ";
drawptr = mydraw6;
timestuff(60, NULL, draw, 1 * 1000000);
params->randomval = 0;
pauzicka();
text1 = " ";
text = "Floyd-";
drawptr = mydraw5;
timestuff(60, NULL, draw, 1 * 1000000);
params->dither = AA_FLOYD_S;
text1 = "Floyd-";
text = "Steinberg";
drawptr = mydraw5;
timestuff(60, NULL, draw, 1 * 1000000);
text1 = "Steinberg";
text = " ";
drawptr = mydraw5;
timestuff(60, NULL, draw, 1 * 1000000);
pauzicka();
text1 = " ";
text = "Gamma ";
drawptr = mydraw7;
timestuff(-60, incgama, draw, 1 * 1000000);
params->dither = AA_FLOYD_S;
text1 = "Gamma ";
text = "Correction";
drawptr = mydraw7;
timestuff(60, NULL, draw, 1 * 1000000);
text1 = "Correction";
text = " ";
drawptr = mydraw7;
timestuff(-60, decgama, draw, 1.5 * 1000000);
params->gamma = 1.0;
pauzicka();
stmivac();
centerx = 0;
}
|