comparison 3x666.c @ 0:0e4f2da58161

Initial import.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 15 Mar 2013 05:00:01 +0200
parents
children 4dd2b0c81ad2
comparison
equal deleted inserted replaced
-1:000000000000 0:0e4f2da58161
1 #include "math.h"
2 #include "stdio.h"
3 #include "stdlib.h"
4 #include "fcntl.h"
5 #include "unistd.h"
6 #include "malloc.h"
7 #include "time.h"
8 #include "sys/time.h"
9
10 #include "config.h"
11 #include "oxl.h"
12 #include "3xfont.h"
13
14 #ifdef __linux__
15 #include "linux/string.h"
16 #else
17 #include "string.h"
18 #endif
19
20 extern int TIKLGT;
21
22 /** typedefs **/
23
24 typedef struct { signed int x,y,z; } vec3d;
25
26 /**/
27
28 char *ruutu;
29 int *mxbuf;
30
31 int *ballz;
32
33 /**************** tEXT dRAWiNG rOUTiNES **********
34
35 bitmaps are for lamers :) let's use a little 12-segment calculator font...
36 ascii chars 32..90, 16 bits per char unpacked -> 114 bytes for the whole
37 font ;) let's credit karl/nooon for the original idea. */
38
39 void drawseg(int y,int x,int w,int h)
40 {
41 /* clip clip clip */
42 if(x+w>BUFW)w=BUFW-x;
43 if(x<0){w+=x;x=0;}
44 if(y+h>BUFH)h=BUFH-y;
45 if(y<0){h+=y;y=0;}
46 if(w>0)if(h>0){
47 char *b=ruutu+y*BUFW+x;
48 for(;h;h--){memset(b,122,w);b+=BUFW;}
49 } }
50
51 void drawchar(int x,int y,int c,int xunit,int yunit)
52 { x-=xunit*2;
53 y-=yunit*3;
54 for(;;){
55 if(!c)break;
56
57 if(c&1)drawseg(y,x+1, xunit*2-2,yunit);
58 if(c&2)drawseg(y,x+1+xunit*2,xunit*2-2,yunit);
59 y++;
60
61 c>>=2;
62 if(!c)break;
63
64 if(c&1)drawseg(y,x, xunit,yunit*3-2);
65 if(c&2)drawseg(y,x+((xunit*3)>>1),xunit,yunit*3-2);
66 if(c&4)drawseg(y,x+xunit*3,xunit,yunit*3-2);
67
68 y+=yunit*2;
69 c>>=3;
70 }}
71
72 void drawtxtscr(char*z)
73 {
74 int x=BUFW>>4,y=BUFH>>3;
75 while(*z){
76 if(*z>=32){
77 drawchar(x,y,phont[*z-32],BUFW/50,BUFW/80);
78 x+=BUFW/10;
79 }else{x=BUFW>>4;y+=BUFW/10;}
80 z++;
81 } }
82
83
84 void flashtxt(char*txt)
85 {
86 int x=(BUFW>>1)-(strlen(txt)+1)*3*BUFW/80;
87 while(*txt){
88 drawchar(x,BUFH>>1,phont[*txt++-32],BUFW/50,BUFW/80);
89 x+=BUFW/10;}
90 }
91
92 /*************************** DA PHONGBALL HEAVEN **************
93
94 A short course on phongball theory!
95
96 A sphere: x^2+y^2+z^2=R^2
97
98 Diffuse shading: intensity = dotproduct(surfacenormal,lightvector)
99
100 (doing this for every drawn point of the surface is sometimes called
101 phong shading even if the normals aren't actually interpolated)
102
103 For a sphere, a normal vector at a point of the surface == constant *
104 the coordinates of the point (if center == origo).
105
106 Thus, the function for the intensity of a 2d-projected phongball can be
107 stated as
108
109 intensity(x,y) = l.x*x + l.y*y + l.z*z, z = sqrt(R^2-x^2-y^2)
110
111 The first two muls can be eliminated easily. (and will be eliminated by
112 a good compiler even if you are lazy)
113
114 The third mul can be eliminated by approximating l.z*z with a function
115 of the form f(x)=a*x^2+c. This approximation makes the ball look a bit
116 "twisty" but who cares, it just looks damn cool ;)
117
118 ***/
119
120 #if BUFH<BUFW
121 #define maxR (BUFH>>1)
122 #else
123 #define maxR (BUFW>>1)
124 #endif
125
126 struct{int *tab;signed int R;}balltab[50];
127
128 void preball()
129 {
130 unsigned int rR; signed int R;
131
132 for(rR=0;rR<48;rR++){
133 int R2,*d;signed int y;
134 R=(maxR*(rR+4))/52;
135 if(R<2)R=2;
136 R2=R*R;
137 balltab[rR].R=R;
138 d=balltab[rR].tab=malloc(R*2*sizeof(int));
139 for(y=-R+1;y<R-1;y++)*d++=sqrt(R2-y*y);
140 }
141
142 balltab[49].R=balltab[48].R=balltab[47].R;
143 balltab[49].tab=balltab[48].tab=balltab[47].tab;
144 }
145
146 /**
147 The i386 innerloop compiled by gcc sucked a bit so here's another
148 one. Hope it runs faster :) I tried to optimize it for the 386,
149 maybe 486 (not pentium kos it suxx)
150
151 **/
152
153 inline void drawball_inloop
154 (char *d,int dotxyz,int ddot,int dddot,int x)
155 {
156 #if ASMLOOPS==386
157
158 __asm__("
159
160 movl %%edx,%%ebp
161
162 movl %%ecx,%%eax
163 andb $3,%%al
164 je 1f
165 cmpb $1,%%al
166 je 2f
167 cmpb $2,%%al
168 je 3f
169
170 4: addl %%ebx,%%ebp
171 addl %%ebp,%%esi
172 shldl $16,%%esi,%%eax
173 stosb
174
175 3: addl %%ebx,%%ebp
176 addl %%ebp,%%esi
177 shldl $16,%%esi,%%eax
178 stosb
179
180 2: addl %%ebx,%%ebp
181 addl %%ebp,%%esi
182 shldl $16,%%esi,%%eax
183 stosb
184
185 1: shrl $2,%%ecx
186 je 9f
187 jne 8f
188
189 .align 4
190
191 8: addl %%ebx,%%ebp
192 addl %%ebp,%%esi
193
194 addl %%ebx,%%ebp
195 shldl $24,%%esi,%%edx
196 addl %%ebp,%%esi
197 shldl $24,%%esi,%%eax
198
199 addl %%ebx,%%ebp
200 movb %%dh,%%al
201 addl %%ebp,%%esi
202 stosw
203 shldl $24,%%esi,%%edx
204
205 addl %%ebx,%%ebp
206 addl %%ebp,%%esi
207 shldl $24,%%esi,%%eax
208 movb %%dh,%%al
209
210 decl %%ecx
211 stosw
212 jne 8b
213
214 9:
215 "
216 :: "c"(x),
217 "D"(d),
218
219 "S"(dotxyz),
220 "d"(ddot),
221 "b"(dddot)
222
223 : "ax","bx","cx","dx","si","di","bp");
224
225 #else
226
227 for(;x;x--){
228 dotxyz+=ddot;
229 ddot+=dddot;
230 *d++=dotxyz>>16;}
231
232 #endif
233 }
234
235 void drawball(char *d,vec3d *l,int relR)
236 {
237 int R=balltab[relR].R,*s=balltab[relR].tab;
238
239 signed int doty=(-(R-1)*l->y);
240 signed int y=R*2-2;
241
242 d+=(BUFW>>1)-R+((BUFH>>1)-R)*BUFW;
243
244 if(y)for(;y;y--){
245 int halfw=*s++;
246 if(halfw)
247 drawball_inloop(
248 d+R-halfw,
249 (doty-(l->x*halfw))<<8,
250 (l->x+l->z)<<8,
251 0-((l->z<<8)/halfw),
252 halfw<<1);
253 d+=BUFW;
254 doty+=l->y;
255 } }
256
257 /* some extra for freaks: a plasma made with the phongball innerloop :)
258 looks ugly.
259
260 void drawplasma(char *d,float t)
261 {
262 int y=BUFH; float u=0,du=500/BUFH;
263
264 for(;y;y--){
265 drawball_inloop(d,
266 sin(t*0.02+0+u*0.033)*65536*256,
267 cos(t*0.04+1+u*0.022)*65536*4096/BUFW,
268 -2*cos(t*0.04+1+u*0.022)*65536*4096/(BUFW*BUFW), BUFW);
269 d+=BUFW;
270 u+=du;
271 }
272 }
273 */
274
275 /************************ oTHA FX ***************/
276
277 void rotochess(char *d,int du,int dv,int iu,int iv)
278 {
279 int hu=iu-(dv*(BUFH>>1))-(du*(BUFW>>1)),
280 hv=iv+(du*(BUFH>>1))-(dv*(BUFW>>1));
281
282 #if (ASMLOOPS==386) && (!(BUFW&3))
283
284 __asm__("
285
286 movl %%eax,%%ebp
287
288 1: pushl %%ecx
289 pushl %%ebx
290 pushl %%edx
291
292 movl %0,%%ecx
293 jmp 0f
294
295 .align 4
296
297 0: addl %%ebp,%%ebx
298 movb %%bh,%%al
299 addl %%esi,%%edx
300 xorb %%dh,%%al
301
302 addl %%ebp,%%ebx
303 movb %%bh,%%ah
304 addl %%esi,%%edx
305 xorb %%dh,%%ah
306
307 addl %%ebp,%%ebx
308 andl $0xb1b1,%%eax
309 stosw
310 movb %%bh,%%al
311 addl %%esi,%%edx
312 xorb %%dh,%%al
313
314 addl %%ebp,%%ebx
315 movb %%bh,%%ah
316 addl %%esi,%%edx
317 xorb %%dh,%%ah
318 andl $0xb1b1,%%eax
319
320 decl %%ecx
321 stosw
322 jne 0b
323
324 popl %%edx
325 popl %%ebx
326 popl %%ecx
327
328 subl %%ebp,%%edx
329 addl %%esi,%%ebx
330
331 decl %%ecx
332 jne 1b
333 "
334 :: "m"(BUFW/4),
335
336 "c"(BUFH), // ecx == x
337 "D"(d), // edi == *d
338
339 "b"(hu),"a"(du),
340 "d"(hv),"S"(dv)
341
342 : "ax","bx","cx","dx","si","di","bp");
343 d+=BUFW;
344 #else
345 int y;
346 for(y=BUFH;y;y--){
347 {register int u=hu,v=hv,x=BUFW;
348 for(;x;x--){
349 u+=du;v+=dv;*d++=((u^v)>>8)&0xb1;}}
350 hu+=dv;hv-=du;}
351 #endif
352 }
353
354 /***************************************************************/
355
356 rgb pal[256],pal2[256];
357 void setpal()
358 {
359 int i,a=3,b=0;
360 for(i=255;i;i--){
361 rgb*d=&pal[(i+128)&255];
362 d->r=(abs(i-140)>>a)&255;
363 d->g=((abs(i-128)>>b)&255)^1;
364 d->b=(abs(i-96)>>b)&255;
365 if(i==128){a=0;b=1;}
366 }
367 oxl_setpalette(pal);
368 }
369
370 void unitvec(vec3d *v,float a,float b,float c,float m)
371 {
372 float cam=cos(a)*m,sam=sin(a)*m,sbcam=sin(b)*cam;
373
374 v->x=cos(b)*cam;
375 v->y=cos(c)*sam-sin(c)*sbcam;
376 v->z=cos(c)*sbcam+sin(c)*sam;
377 }
378
379 /************************* MUSiC cODE **************************/
380
381 #if AUDIO
382
383 /* This table was ripped (and reduced and rudely integerized) from the
384 Maube tracker by K .. keep on the good work man! ;) */
385
386 const int noterate[3*12] = {
387 1000, 1059, 1122, 1189, 1259, 1334,
388 1414, 1498, 1587, 1681, 1781, 1887,
389
390 2000, 2118, 2244, 2378, 2519, 2669,
391 2828, 2996, 3174, 3363, 3563, 3775,
392
393 4000, 4237, 4489, 4756, 5039, 5339,
394 5656, 5993, 6349, 6727, 7127, 7550
395 };
396
397 /* 64 bytes of pure musical power ;)
398 Originally composed with Scream Tracker. */
399
400 const char basstrak[32]={
401 12,0, 24,12,
402 12,24,12,24,
403 12,0, 24,12,
404 12,24,12,24,
405 15,0, 27,15,
406 15,27,15,27,
407 14,0, 26,14,
408 15,27,17,29};
409
410 const char melody[32]={
411 24,12,19,15,
412 24,0, 19,0,
413 24,12,19,15,
414 24,0, 15,19,
415 15,19,15,19,
416 22,0, 15,19,
417 14,17,21,14,
418 22,17,17,22};
419
420 signed int*drum0,*drum1;
421
422 void audio_precalcs()
423 /* sampling sucks! */
424 {
425 int drumlgt=TIKLGT*ROWTIX*4;
426 int *d=drum0=malloc(drumlgt*sizeof(int)),
427 *e=drum1=malloc(drumlgt*sizeof(int)),i,
428 vol=24680,dvol=35000/(float)drumlgt;
429 int o=0,oo=0;float a=0,da=386/(float)drumlgt,dda=da/(float)drumlgt;
430
431 printf("aCtIvATiNg 303 eMuLAtOR\n");
432
433 for(i=drumlgt;i;i--){
434 int u;
435
436 o=(o>>1)+(rand()%vol)-(rand()%vol);
437 oo=(oo*2+((rand()%vol)-(rand()%vol)))/3;
438
439 o*=sin(a);oo*=sin(a);
440
441 u=o*2;if(u<-65535)u=-65535;if(u>65535)u=65535;
442 *d++=(vol*sin((a/2)+((float)u)/80000));
443 *e++=(vol*sin(a+((float)oo)/60000));
444
445 a+=da;da-=dda;vol-=dvol;
446 } }
447
448 int*audio_mix(void)
449 /* mixes the next row of music into b */
450 {
451 static int rowno=0;
452 static signed int delta=-5;
453 static char ismelody=0,silend=0;
454
455 int rowlgt=TIKLGT*ROWTIX,i;
456 int *d=mxbuf,note;
457
458 /* BASS (sawtooth ofcoz) */
459
460 *d++=rowlgt;
461
462 note=basstrak[(rowno>>1)&31];
463
464 if(!note)note=basstrak[((rowno>>1)&31)-1];
465 else if(rowno&1)note=0;
466 if((rowno&3)==3)note=0;
467 if(note){
468 int ps=16384,dps;
469 note+=delta;
470 dps=((noterate[note]<<10)/AUFREQ);
471 for(i=rowlgt;i;i--){
472 *d++=ps;ps=(ps+dps)&32767; }
473 }else
474 for(i=rowlgt;i;i--)*d++=16384;
475
476 /* MELODY (sawtooth as well :) */
477
478 if(!(silend&&((rowno&63)>47))){
479
480 if(ismelody){
481 d=mxbuf+1;
482 if(rowno&1)note=0;else note=melody[(rowno>>1)&31];
483 if(note){
484 int ps=16384,dps; /* this loop is different */
485 note+=delta;
486 dps=((noterate[note]<<12)/AUFREQ);
487 for(i=rowlgt;i;i--){
488 *d+++=ps;ps=(ps+dps)&32767;}
489 }}
490 /* DRUMS (rave on!!!) */
491
492 {
493 int *s=drum1;d=mxbuf+1;
494 if(rowno&4)s=drum0;
495 s+=(rowno&3)*rowlgt;
496
497 for(i=rowlgt;i;i--)*d+++=*s++;
498 }
499 }
500 /* PATTERN SHIFT */
501
502 rowno++;
503
504 /* no switch+case? just check out how gcc handles them!
505 it's 1024+ bytes for every phukken switch statement!
506 in this case we can prefer size to speed, can't we? */
507
508 if(!(rowno&63)){
509 int r=rowno>>6;
510 if(r==2)delta=0;
511 if(r==4)ismelody=1;
512 if((r==6)||(r==10))delta=5;
513 if((r==7)||(r==11))silend=1;
514 if(r==8)delta=silend=0;
515 if(r==12){rowno=ismelody=silend=0;delta=-5;}
516 }
517 return mxbuf;
518 }
519
520 #endif
521
522 /**************** tEXT gENERATORS eTC ***************/
523
524 char skrtxt[]={
525 " HI THERE ! THIS IS THE FIRST OCSA RELEASE FOR LINUX ! "
526 "IT'S A STUPID INTRO CALLED 3X666 ! " };
527
528 void plainscroll(int t)
529 #define CHTIME 16
530 #define CHPSCR 8
531 {
532 int chno=t/CHTIME;
533 int x=0-((t%CHTIME)*(BUFW/CHPSCR))/CHTIME;
534 int h=(abs((t%48)-24)*BUFH)/256,i;
535 char*c=skrtxt+chno;
536
537 for(i=0;i<CHPSCR+1;i++){
538 drawchar(x,(BUFH*3)/4,phont[*c++-32],BUFW/(6*CHPSCR),h);
539 x+=BUFW/CHPSCR;
540 } }
541
542 char*lyrix(void)
543 {
544 static int phinext=0,philast;
545 int phiwsty;
546 char*phiword;
547
548 phiwsty=phinext;
549
550 if(!phiwsty){
551 if(!(rand()&3))phiwsty=13;
552 else phiwsty=1+(rand()&1);
553 }
554 if(phiwsty==1){
555 char *w[]={"HERE","THERE","NOW","TOMORROW","TODAY","NEVER"};
556 phiword=w[rand()%6];
557 if(rand()&1)phinext=2;else phinext=12;
558 }else
559 if(phiwsty==2){
560 char nx[]={5,10,7,3,11};
561 philast=rand()&1;
562 if(!philast)phiword="YOU";else phiword="I";
563 phinext=nx[rand()%5];
564 }else
565 if(phiwsty==3){
566 char *w[]={"DON'T","CAN'T","WON'T","COULDN'T"};
567 phiword=w[rand()%4];phinext=7+(rand()&4);
568 }else
569 if(phiwsty==4){
570 if(rand()&1)phiword="YOU";else phiword="ME";
571 if(rand()&1)phinext=6;else if(rand()&1)phinext=0;else phinext=11;
572 }else
573 if(phiwsty==5){
574 if(philast)phiword="AM";else phiword="ARE";
575 if(rand()&1)phinext=6;else phinext=12+(rand()&1);
576 }else
577 if(phiwsty==6){
578 char *w[]={"FALLING","THINKING","DREAMING","CRYING",
579 "LYING","REACHING","BREATHING","BURNING","RUNNING"};
580 phiword=w[rand()%9];
581 if(rand()&1)phinext=9;else if(rand()&1)phinext=0;else phinext=13;
582 }else
583 if(phiwsty==7){
584 char nx[]={8,4,12};
585 if(rand()&1)phiword="NEED";else phiword="WANT";
586 phinext=nx[rand()%3];
587 }else
588 if(phiwsty==8){phiword="TO";phinext=11;
589 }else
590 if(phiwsty==9){
591 char *w[]={"DOWN","OFF","OUT","UP","ABOUT"};
592 phiword=w[rand()%5];
593 if(rand()&1)phinext=rand()&4;else phinext=12+(rand()&1);
594 }else
595 if(phiwsty==10){
596 char *w[]={"CAN","COULD","WOULD","MAY","MIGHT"};
597 phiword=w[rand()%5];
598 if(rand()&1)phinext=11;else phinext=12;
599 }else
600 if(phiwsty==11){
601 char *w[]={"SEE","HEAR","FEEL","THINK"};
602 phiword=w[rand()%4];
603 if(rand()&1)phinext=12;else phinext=rand()&4;
604 }else
605 if(phiwsty==12){
606 char *w[]={"WHAT","SOMETHING","NOTHING","THINGS","WHATEVER"};
607 phiword=w[rand()%5];phinext=2;
608 }else
609 if(phiwsty==13){
610 phiword="THE";phinext=14;
611 }else{
612 char*w[]={"WAY","EYES","WORLD","ROBOT","FREEDOM","HATE"};
613 phiword=w[rand()%6];phinext=0;
614 }
615 return phiword;
616 }
617
618 char*dotxtscr(void)
619 {
620 static int cnt=0;
621 cnt++;
622 if(cnt==1)
623 return
624 "WHERES THE\n"
625 "DESIGN?\n\n"
626 "WHERES THE\n"
627 "ATTITUDE?!";
628
629 if(cnt==2)
630 return
631 "NOTHING\n"
632 "HAPPENED\n"
633 "IN 1997";
634
635 if(cnt==3)
636 return
637 "PERHAPS\n"
638 "IT IS TIME\n"
639 "FOR A NEW\n"
640 "PROPHECY?";
641
642 if(cnt==4)
643 return
644 "IN 1998,\n"
645 "SCENE WILL\n"
646 "DIE !!!!!";
647
648 if(cnt==5)
649 return
650 "PHONGBALLS\n"
651 "WILL\n"
652 "INVADE\n"
653 "THE WORLD";
654
655 if((cnt==6)||(cnt==7))
656 return
657 "HALUU OLLA\n"
658 "APPELSIINI";
659
660 return NULL;
661 }
662
663 const char*endscroll=
664 "THAT'S ALL
665 FOLKS !
666
667 ALL CODING +
668 COMPOSING
669 BY VIZNUT !
670
671 WHAT A
672 MARVELOUS
673 PALETTE !
674 WHAT A
675 SUPERB TUNE !
676
677 BUT IT'S ALL
678 BELOW 10 KB
679 AND RUNS
680 SMOOTHLY ON
681 A 386
682
683 GREETINGS TO
684 ALL THE
685 LINUX SCENE !
686
687 LET'S MAKE
688 THIS WORLD A
689 BETTER PLACE
690 TO LIVE IN !
691
692 THIS IS JUST
693 A PIECE OF
694 SHITTY CODE
695 BUT IT'S ALL
696 YOURS !
697
698 RIP OFF
699 EVERYTHING !
700 USE IT FOR
701 SOMETHING
702 CREATIVE !
703 "
704
705 "\n\n\nOCSA 1998";
706
707 void doendscroll(int t)
708 {
709 const char *s=endscroll;
710 int y=BUFH-(BUFH*t/512),x=BUFW/24;
711
712 while(*s){
713 if(*s<32){x=BUFW/24;y+=BUFH/8;}else{
714 if(y>=0-(BUFH/8))if(y<BUFH){
715 drawchar(x,y,phont[*s-32],BUFW/60,BUFH/60);
716 x+=BUFW/13;}
717 }
718 s++;}
719 }
720
721 /********************** tHA kORE bEGiNS *********************/
722
723 #define BLACKBG 1
724 #define FLASHBG 2
725 #define OCSALOGO 4
726 #define SCROLL0 8
727 #define BALLIE 16
728 #define BALLJUMPS 32
729 #define COUNTAH 64
730 #define CHESSBG 128
731 #define PLASMABG 256
732 #define FLASHTXT 512
733 #define TXTSCR 1024
734 #define ENDSCR 2048
735 #define DEMOEND 4096
736
737 const short dezign[]={
738 0, BLACKBG|OCSALOGO|SCROLL0,
739 256,FLASHBG|BALLIE|BALLJUMPS|COUNTAH,
740 384,BLACKBG|BALLIE|BALLJUMPS|COUNTAH|OCSALOGO,
741 400,BLACKBG|BALLIE|COUNTAH|OCSALOGO,
742 416,BLACKBG|BALLIE,
743 448,BLACKBG|BALLIE|TXTSCR,
744 512,CHESSBG|BALLIE|BALLJUMPS|TXTSCR,
745 576,CHESSBG|BALLIE|BALLJUMPS|TXTSCR,
746 640,CHESSBG|BALLIE|BALLJUMPS|TXTSCR,
747 704,CHESSBG|BALLIE|BALLJUMPS|TXTSCR,
748 768,FLASHBG|FLASHTXT,
749 896,FLASHBG|FLASHTXT|TXTSCR,
750 962,FLASHBG|FLASHTXT|TXTSCR|BALLIE|BALLJUMPS,
751 1024,BLACKBG|BALLIE|ENDSCR,
752 1152,CHESSBG|BALLIE|BALLJUMPS|ENDSCR,
753 1344,FLASHBG|BALLIE|BALLJUMPS|ENDSCR,
754 1536,DEMOEND
755 };
756
757
758 /* don't look at the rest of the code, it just sucks :) */
759
760 void main(void)
761 {
762 vec3d joo;
763
764 int flagz=0;const short*dez=dezign;
765 char *phiword=NULL,*dizainword=NULL;int flixtim=0;
766
767 ruutu=malloc(BUFH*BUFW*sizeof(char));
768 preball();
769
770 srand((int)time(NULL));
771
772 #define MAXROWLGT TIKLGT*ROWTIX
773
774 #if AUDIO!=0
775 oxl_init_audio(ROWTIX);
776 TIKLGT=AUFREQ/DEMOHZ;
777 mxbuf=malloc(MAXROWLGT*sizeof(int));
778 audio_precalcs();
779 #endif
780
781 oxl_init_video();
782 oxl_init_timer();
783
784 setpal();
785
786 for(;;){
787 int t=oxl_timer();
788
789 while((t/ROWTIX>=*dez)&&(!(flagz&DEMOEND)))
790 {dez++;flagz=*dez++;
791 if(flagz&FLASHTXT)flixtim=*(dez-2);
792 if(flagz&TXTSCR)dizainword=dotxtscr();
793 }
794 if(flagz&FLASHTXT)
795 while((t/ROWTIX)>=flixtim){phiword=lyrix();flixtim+=4;}
796
797 if(flagz&DEMOEND)break;
798
799 if(flagz&BLACKBG)memset(ruutu,0,BUFH*BUFW);else
800 if(flagz&FLASHBG)
801 { unsigned char col=130+(t%48)*2;
802 #if ASMLOOPS==386
803 /* the original asm/string.h by linus does this with stosb, so */
804 __asm__("rep;stosl"::"D"(ruutu),"c"((BUFH*BUFW)>>2),
805 "a"(col|(col<<8)|(col<<16)|(col<<24)):"ax","cx","di");
806 #else
807 memset(ruutu,col,BUFH*BUFW);
808 #endif
809 }
810
811 if(flagz&CHESSBG){int zoom=((10+abs(((t>>1)%96)-48))*4096/BUFW);
812 rotochess(ruutu,
813 sin(t*0.03)*zoom,cos(t*0.03)*zoom,0,0);}
814
815 /* if(flagz&PLASMABG) drawplasma(ruutu,t); */
816
817 if(flagz&OCSALOGO){
818 #define U (BUFW/40)
819 drawchar(U*6,U*4,phont['O'-32],U+U*sin(t*0.10+3),U);
820 drawchar(U*14,U*4,phont['C'-32],U,U+U*sin(t*0.11+3));
821 drawchar(U*22,U*4,phont['S'-32],U,U+U*sin(t*0.12+3));
822 drawchar(U*30,U*4,phont['A'-32],U+U*sin(t*0.13+3),U);
823 #undef U
824 }
825
826 if(flagz&SCROLL0)plainscroll(t);
827
828 if(flagz&BALLIE){
829 int zoom;
830 if(flagz&BALLJUMPS)zoom=abs((t%96)-48);else zoom=47;
831 if(zoom<0)zoom=0;else if(zoom>47)zoom=47;
832
833 unitvec(&joo,0.038*t,0.023*t,0.011*t,32000/balltab[zoom].R);
834 joo.z<<=1;
835
836 drawball(ruutu,&joo,zoom);
837 }
838
839 if(flagz&FLASHTXT)flashtxt(phiword);
840 if(flagz&TXTSCR)if((t/ROWTIX)&2)drawtxtscr(dizainword);
841
842 if(flagz&ENDSCR)doendscroll(t-1024*ROWTIX);
843
844 #define U (BUFW/40)
845 if(flagz&COUNTAH)
846 {int n=((t*50/48)-256*6);
847 int dis=(rand()%U)>>1;
848 if(n>666)n=666;
849 if(n>600){
850 drawchar(U*12+dis,(BUFH>>1)+dis+U*6,phont['X'-32],U,U);
851 drawchar(U*22+dis,(BUFH>>1)+dis+U*6,phont['3'-32],U,U);}
852 drawchar(U*28+dis,BUFH>>1,phont[16+(n%10)],U,U);n/=10;
853 drawchar(U*18+dis,BUFH>>1,phont[16+(n%10)],U,U);n/=10;
854 drawchar(U*8+dis,BUFH>>1,phont[16+(n%10)],U,U);n/=10;
855 }
856 #undef U
857
858 /* blitzz */
859
860 oxl_doframe(ruutu);
861 #if AUDIO!=0
862 oxl_doaudio(audio_mix);
863 #endif
864 while(t==oxl_timer()){
865 #if SLEEPY
866 usleep(250000/DEMOHZ);
867 #endif
868 }
869 }
870 oxl_end();
871 }