# HG changeset patch # User Matti Hamalainen # Date 1363316473 -7200 # Node ID 4dd2b0c81ad2c625f0edb810b273f89debac9c48 # Parent 9d245230df76d34ea8a079274cc9f1fb1bbb4651 Cleanups, removing cruft, re-indent. diff -r 9d245230df76 -r 4dd2b0c81ad2 3x666.c --- a/3x666.c Fri Mar 15 05:01:00 2013 +0200 +++ b/3x666.c Fri Mar 15 05:01:13 2013 +0200 @@ -1,29 +1,19 @@ -#include "math.h" -#include "stdio.h" -#include "stdlib.h" -#include "fcntl.h" -#include "unistd.h" -#include "malloc.h" -#include "time.h" -#include "sys/time.h" - +#include +#include +#include +#include +#include #include "config.h" -#include "oxl.h" #include "3xfont.h" -#ifdef __linux__ -#include "linux/string.h" -#else -#include "string.h" -#endif - extern int TIKLGT; /** typedefs **/ -typedef struct { signed int x,y,z; } vec3d; - -/**/ +typedef struct +{ + signed int x, y, z; +} vec3d; char *ruutu; int *mxbuf; @@ -36,57 +26,93 @@ ascii chars 32..90, 16 bits per char unpacked -> 114 bytes for the whole font ;) let's credit karl/nooon for the original idea. */ -void drawseg(int y,int x,int w,int h) +void drawseg(int y, int x, int w, int h) { - /* clip clip clip */ - if(x+w>BUFW)w=BUFW-x; - if(x<0){w+=x;x=0;} - if(y+h>BUFH)h=BUFH-y; - if(y<0){h+=y;y=0;} - if(w>0)if(h>0){ - char *b=ruutu+y*BUFW+x; - for(;h;h--){memset(b,122,w);b+=BUFW;} -} } + /* clip clip clip */ + if (x + w > BUFW) + w = BUFW - x; + if (x < 0) + { + w += x; + x = 0; + } + if (y + h > BUFH) + h = BUFH - y; + if (y < 0) + { + h += y; + y = 0; + } + if (w > 0 && h > 0) + { + char *b = ruutu + y * BUFW + x; + for (; h; h--) + { + memset(b, 122, w); + b += BUFW; + } + } +} -void drawchar(int x,int y,int c,int xunit,int yunit) -{ x-=xunit*2; - y-=yunit*3; - for(;;){ - if(!c)break; - - if(c&1)drawseg(y,x+1, xunit*2-2,yunit); - if(c&2)drawseg(y,x+1+xunit*2,xunit*2-2,yunit); - y++; +void drawchar(int x, int y, int c, int xunit, int yunit) +{ + x -= xunit * 2; + y -= yunit * 3; + for (;;) + { + if (!c) + break; - c>>=2; - if(!c)break; + if (c & 1) + drawseg(y, x + 1, xunit * 2 - 2, yunit); + if (c & 2) + drawseg(y, x + 1 + xunit * 2, xunit * 2 - 2, yunit); + y++; - if(c&1)drawseg(y,x, xunit,yunit*3-2); - if(c&2)drawseg(y,x+((xunit*3)>>1),xunit,yunit*3-2); - if(c&4)drawseg(y,x+xunit*3,xunit,yunit*3-2); + c >>= 2; + if (!c) + break; - y+=yunit*2; - c>>=3; -}} + if (c & 1) + drawseg(y, x, xunit, yunit * 3 - 2); + if (c & 2) + drawseg(y, x + ((xunit * 3) >> 1), xunit, yunit * 3 - 2); + if (c & 4) + drawseg(y, x + xunit * 3, xunit, yunit * 3 - 2); -void drawtxtscr(char*z) + y += yunit * 2; + c >>= 3; + } +} + +void drawtxtscr(char *z) { - int x=BUFW>>4,y=BUFH>>3; - while(*z){ - if(*z>=32){ - drawchar(x,y,phont[*z-32],BUFW/50,BUFW/80); - x+=BUFW/10; - }else{x=BUFW>>4;y+=BUFW/10;} - z++; -} } + int x = BUFW >> 4, y = BUFH >> 3; + while (*z) + { + if (*z >= 32) + { + drawchar(x, y, phont[*z - 32], BUFW / 50, BUFW / 80); + x += BUFW / 10; + } + else + { + x = BUFW >> 4; + y += BUFW / 10; + } + z++; + } +} -void flashtxt(char*txt) +void flashtxt(char *txt) { - int x=(BUFW>>1)-(strlen(txt)+1)*3*BUFW/80; - while(*txt){ - drawchar(x,BUFH>>1,phont[*txt++-32],BUFW/50,BUFW/80); - x+=BUFW/10;} + int x = (BUFW >> 1) - (strlen(txt) + 1) * 3 * BUFW / 80; + while (*txt) + { + drawchar(x, BUFH >> 1, phont[*txt++ - 32], BUFW / 50, BUFW / 80); + x += BUFW / 10; + } } /*************************** DA PHONGBALL HEAVEN ************** @@ -113,34 +139,43 @@ The third mul can be eliminated by approximating l.z*z with a function of the form f(x)=a*x^2+c. This approximation makes the ball look a bit -"twisty" but who cares, it just looks damn cool ;) +"twisty" but who cares, it just looks damn cool ;) ***/ -#if BUFH>1) +#if (BUFH < BUFW) +#define maxR (BUFH>>1) #else - #define maxR (BUFW>>1) +#define maxR (BUFW>>1) #endif -struct{int *tab;signed int R;}balltab[50]; +struct +{ + int *tab; + signed int R; +} balltab[50]; void preball() { - unsigned int rR; signed int R; + unsigned int rR; + signed int R; - for(rR=0;rR<48;rR++){ - int R2,*d;signed int y; - R=(maxR*(rR+4))/52; - if(R<2)R=2; - R2=R*R; - balltab[rR].R=R; - d=balltab[rR].tab=malloc(R*2*sizeof(int)); - for(y=-R+1;y>16;} - -#endif + for (; x; x--) + { + dotxyz += ddot; + ddot += dddot; + *d++ = dotxyz >> 16; + } } -void drawball(char *d,vec3d *l,int relR) +void drawball(char *d, vec3d * l, int relR) { - int R=balltab[relR].R,*s=balltab[relR].tab; - - signed int doty=(-(R-1)*l->y); - signed int y=R*2-2; + int R = balltab[relR].R, *s = balltab[relR].tab; - d+=(BUFW>>1)-R+((BUFH>>1)-R)*BUFW; + signed int doty = (-(R - 1) * l->y); + signed int y = R * 2 - 2; + + d += (BUFW >> 1) - R + ((BUFH >> 1) - R) * BUFW; - if(y)for(;y;y--){ - int halfw=*s++; - if(halfw) - drawball_inloop( - d+R-halfw, - (doty-(l->x*halfw))<<8, - (l->x+l->z)<<8, - 0-((l->z<<8)/halfw), - halfw<<1); - d+=BUFW; - doty+=l->y; -} } + if (y) + for (; y; y--) + { + int halfw = *s++; + if (halfw) + drawball_inloop(d + R - halfw, + (doty - (l->x * halfw)) << 8, + (l->x + l->z) << 8, + 0 - ((l->z << 8) / halfw), halfw << 1); + d += BUFW; + doty += l->y; + } +} /* some extra for freaks: a plasma made with the phongball innerloop :) looks ugly. @@ -274,598 +238,679 @@ /************************ oTHA FX ***************/ -void rotochess(char *d,int du,int dv,int iu,int iv) +void rotochess(char *d, int du, int dv, int iu, int iv) { - int hu=iu-(dv*(BUFH>>1))-(du*(BUFW>>1)), - hv=iv+(du*(BUFH>>1))-(dv*(BUFW>>1)); - -#if (ASMLOOPS==386) && (!(BUFW&3)) - -__asm__(" - - movl %%eax,%%ebp - -1: pushl %%ecx - pushl %%ebx - pushl %%edx - - movl %0,%%ecx - jmp 0f - - .align 4 - -0: addl %%ebp,%%ebx - movb %%bh,%%al - addl %%esi,%%edx - xorb %%dh,%%al - - addl %%ebp,%%ebx - movb %%bh,%%ah - addl %%esi,%%edx - xorb %%dh,%%ah - - addl %%ebp,%%ebx - andl $0xb1b1,%%eax - stosw - movb %%bh,%%al - addl %%esi,%%edx - xorb %%dh,%%al + int hu = iu - (dv * (BUFH >> 1)) - (du * (BUFW >> 1)), + hv = iv + (du * (BUFH >> 1)) - (dv * (BUFW >> 1)); - addl %%ebp,%%ebx - movb %%bh,%%ah - addl %%esi,%%edx - xorb %%dh,%%ah - andl $0xb1b1,%%eax - - decl %%ecx - stosw - jne 0b - - popl %%edx - popl %%ebx - popl %%ecx - - subl %%ebp,%%edx - addl %%esi,%%ebx - - decl %%ecx - jne 1b -" -:: "m"(BUFW/4), - - "c"(BUFH), // ecx == x - "D"(d), // edi == *d - - "b"(hu),"a"(du), - "d"(hv),"S"(dv) - -: "ax","bx","cx","dx","si","di","bp"); - d+=BUFW; -#else - int y; - for(y=BUFH;y;y--){ - {register int u=hu,v=hv,x=BUFW; - for(;x;x--){ - u+=du;v+=dv;*d++=((u^v)>>8)&0xb1;}} - hu+=dv;hv-=du;} -#endif + int y; + for (y = BUFH; y; y--) + { + { + register int u = hu, v = hv, x = BUFW; + for (; x; x--) + { + u += du; + v += dv; + *d++ = ((u ^ v) >> 8) & 0xb1; + } + } + hu += dv; + hv -= du; + } } /***************************************************************/ -rgb pal[256],pal2[256]; -void setpal() +rgb pal[256], pal2[256]; +void setpal() { - int i,a=3,b=0; - for(i=255;i;i--){ - rgb*d=&pal[(i+128)&255]; - d->r=(abs(i-140)>>a)&255; - d->g=((abs(i-128)>>b)&255)^1; - d->b=(abs(i-96)>>b)&255; - if(i==128){a=0;b=1;} - } - oxl_setpalette(pal); + int i, a = 3, b = 0; + for (i = 255; i; i--) + { + rgb *d = &pal[(i + 128) & 255]; + d->r = (abs(i - 140) >> a) & 255; + d->g = ((abs(i - 128) >> b) & 255) ^ 1; + d->b = (abs(i - 96) >> b) & 255; + if (i == 128) + { + a = 0; + b = 1; + } + } + oxl_setpalette(pal); } -void unitvec(vec3d *v,float a,float b,float c,float m) +void unitvec(vec3d * v, float a, float b, float c, float m) { - float cam=cos(a)*m,sam=sin(a)*m,sbcam=sin(b)*cam; - - v->x=cos(b)*cam; - v->y=cos(c)*sam-sin(c)*sbcam; - v->z=cos(c)*sbcam+sin(c)*sam; + float cam = cos(a) * m, sam = sin(a) * m, sbcam = sin(b) * cam; + + v->x = cos(b) * cam; + v->y = cos(c) * sam - sin(c) * sbcam; + v->z = cos(c) * sbcam + sin(c) * sam; } /************************* MUSiC cODE **************************/ -#if AUDIO - /* This table was ripped (and reduced and rudely integerized) from the Maube tracker by K .. keep on the good work man! ;) */ -const int noterate[3*12] = { - 1000, 1059, 1122, 1189, 1259, 1334, - 1414, 1498, 1587, 1681, 1781, 1887, - - 2000, 2118, 2244, 2378, 2519, 2669, - 2828, 2996, 3174, 3363, 3563, 3775, - - 4000, 4237, 4489, 4756, 5039, 5339, - 5656, 5993, 6349, 6727, 7127, 7550 +const int noterate[3 * 12] = { + 1000, 1059, 1122, 1189, 1259, 1334, + 1414, 1498, 1587, 1681, 1781, 1887, + + 2000, 2118, 2244, 2378, 2519, 2669, + 2828, 2996, 3174, 3363, 3563, 3775, + + 4000, 4237, 4489, 4756, 5039, 5339, + 5656, 5993, 6349, 6727, 7127, 7550 }; -/* 64 bytes of pure musical power ;) +/* 64 bytes of pure musical power ;) Originally composed with Scream Tracker. */ -const char basstrak[32]={ - 12,0, 24,12, - 12,24,12,24, - 12,0, 24,12, - 12,24,12,24, - 15,0, 27,15, - 15,27,15,27, - 14,0, 26,14, - 15,27,17,29}; +const char basstrak[32] = { + 12, 0, 24, 12, + 12, 24, 12, 24, + 12, 0, 24, 12, + 12, 24, 12, 24, + 15, 0, 27, 15, + 15, 27, 15, 27, + 14, 0, 26, 14, + 15, 27, 17, 29 +}; -const char melody[32]={ - 24,12,19,15, - 24,0, 19,0, - 24,12,19,15, - 24,0, 15,19, - 15,19,15,19, - 22,0, 15,19, - 14,17,21,14, - 22,17,17,22}; +const char melody[32] = { + 24, 12, 19, 15, + 24, 0, 19, 0, + 24, 12, 19, 15, + 24, 0, 15, 19, + 15, 19, 15, 19, + 22, 0, 15, 19, + 14, 17, 21, 14, + 22, 17, 17, 22 +}; -signed int*drum0,*drum1; +signed int *drum0, *drum1; +/* sampling sucks! */ void audio_precalcs() -/* sampling sucks! */ { - int drumlgt=TIKLGT*ROWTIX*4; - int *d=drum0=malloc(drumlgt*sizeof(int)), - *e=drum1=malloc(drumlgt*sizeof(int)),i, - vol=24680,dvol=35000/(float)drumlgt; - int o=0,oo=0;float a=0,da=386/(float)drumlgt,dda=da/(float)drumlgt; + int drumlgt = TIKLGT * ROWTIX * 4; + int *d = drum0 = malloc(drumlgt * sizeof(int)), + *e = drum1 = malloc(drumlgt * sizeof(int)), i, + vol = 24680, dvol = 35000 / (float) drumlgt; + int o = 0, oo = 0; + float a = 0, da = 386 / (float) drumlgt, dda = da / (float) drumlgt; + + printf("aCtIvATiNg 303 eMuLAtOR\n"); + + for (i = drumlgt; i; i--) + { + int u; + + o = (o >> 1) + (rand() % vol) - (rand() % vol); + oo = (oo * 2 + ((rand() % vol) - (rand() % vol))) / 3; - printf("aCtIvATiNg 303 eMuLAtOR\n"); - - for(i=drumlgt;i;i--){ - int u; - - o=(o>>1)+(rand()%vol)-(rand()%vol); - oo=(oo*2+((rand()%vol)-(rand()%vol)))/3; - - o*=sin(a);oo*=sin(a); + o *= sin(a); + oo *= sin(a); - u=o*2;if(u<-65535)u=-65535;if(u>65535)u=65535; - *d++=(vol*sin((a/2)+((float)u)/80000)); - *e++=(vol*sin(a+((float)oo)/60000)); + u = o * 2; + if (u < -65535) + u = -65535; + if (u > 65535) + u = 65535; + *d++ = (vol * sin((a / 2) + ((float) u) / 80000)); + *e++ = (vol * sin(a + ((float) oo) / 60000)); - a+=da;da-=dda;vol-=dvol; -} } + a += da; + da -= dda; + vol -= dvol; +}} -int*audio_mix(void) + /* mixes the next row of music into b */ +int *audio_mix(void) { - static int rowno=0; - static signed int delta=-5; - static char ismelody=0,silend=0; - - int rowlgt=TIKLGT*ROWTIX,i; - int *d=mxbuf,note; - - /* BASS (sawtooth ofcoz) */ + static int rowno = 0; + static signed int delta = -5; + static char ismelody = 0, silend = 0; + + int rowlgt = TIKLGT * ROWTIX, i; + int *d = mxbuf, note; + + /* BASS (sawtooth ofcoz) */ + + *d++ = rowlgt; + + note = basstrak[(rowno >> 1) & 31]; - *d++=rowlgt; - - note=basstrak[(rowno>>1)&31]; - - if(!note)note=basstrak[((rowno>>1)&31)-1]; - else if(rowno&1)note=0; - if((rowno&3)==3)note=0; - if(note){ - int ps=16384,dps; - note+=delta; - dps=((noterate[note]<<10)/AUFREQ); - for(i=rowlgt;i;i--){ - *d++=ps;ps=(ps+dps)&32767; } - }else - for(i=rowlgt;i;i--)*d++=16384; + if (!note) + note = basstrak[((rowno >> 1) & 31) - 1]; + else if (rowno & 1) + note = 0; + if ((rowno & 3) == 3) + note = 0; + if (note) + { + int ps = 16384, dps; + note += delta; + dps = ((noterate[note] << 10) / AUFREQ); + for (i = rowlgt; i; i--) + { + *d++ = ps; + ps = (ps + dps) & 32767; + } + } + else + for (i = rowlgt; i; i--) + *d++ = 16384; - /* MELODY (sawtooth as well :) */ - - if(!(silend&&((rowno&63)>47))){ + /* MELODY (sawtooth as well :) */ - if(ismelody){ - d=mxbuf+1; - if(rowno&1)note=0;else note=melody[(rowno>>1)&31]; - if(note){ - int ps=16384,dps; /* this loop is different */ - note+=delta; - dps=((noterate[note]<<12)/AUFREQ); - for(i=rowlgt;i;i--){ - *d+++=ps;ps=(ps+dps)&32767;} - }} - /* DRUMS (rave on!!!) */ + if (!(silend && ((rowno & 63) > 47))) + { + if (ismelody) + { + d = mxbuf + 1; + if (rowno & 1) + note = 0; + else + note = melody[(rowno >> 1) & 31]; + if (note) + { + int ps = 16384, dps; /* this loop is different */ + note += delta; + dps = ((noterate[note] << 12) / AUFREQ); + for (i = rowlgt; i; i--) + { + *d++ += ps; + ps = (ps + dps) & 32767; + } + } + } + /* DRUMS (rave on!!!) */ + + { + int *s = drum1; + d = mxbuf + 1; + if (rowno & 4) + s = drum0; + s += (rowno & 3) * rowlgt; - { - int *s=drum1;d=mxbuf+1; - if(rowno&4)s=drum0; - s+=(rowno&3)*rowlgt; - - for(i=rowlgt;i;i--)*d+++=*s++; - } - } - /* PATTERN SHIFT */ + for (i = rowlgt; i; i--) + *d++ += *s++; + } + } + /* PATTERN SHIFT */ + + rowno++; + + /* no switch+case? just check out how gcc handles them! + it's 1024+ bytes for every phukken switch statement! + in this case we can prefer size to speed, can't we? */ - rowno++; - - /* no switch+case? just check out how gcc handles them! - it's 1024+ bytes for every phukken switch statement! - in this case we can prefer size to speed, can't we? */ - - if(!(rowno&63)){ - int r=rowno>>6; - if(r==2)delta=0; - if(r==4)ismelody=1; - if((r==6)||(r==10))delta=5; - if((r==7)||(r==11))silend=1; - if(r==8)delta=silend=0; - if(r==12){rowno=ismelody=silend=0;delta=-5;} - } - return mxbuf; + if (!(rowno & 63)) + { + int r = rowno >> 6; + if (r == 2) + delta = 0; + if (r == 4) + ismelody = 1; + if ((r == 6) || (r == 10)) + delta = 5; + if ((r == 7) || (r == 11)) + silend = 1; + if (r == 8) + delta = silend = 0; + if (r == 12) + { + rowno = ismelody = silend = 0; + delta = -5; + } + } + return mxbuf; } -#endif /**************** tEXT gENERATORS eTC ***************/ -char skrtxt[]={ -" HI THERE ! THIS IS THE FIRST OCSA RELEASE FOR LINUX ! " -"IT'S A STUPID INTRO CALLED 3X666 ! " }; +char skrtxt[] = { + " HI THERE ! THIS IS THE FIRST OCSA RELEASE FOR LINUX ! " + "IT'S A STUPID INTRO CALLED 3X666 ! " +}; -void plainscroll(int t) + #define CHTIME 16 #define CHPSCR 8 -{ - int chno=t/CHTIME; - int x=0-((t%CHTIME)*(BUFW/CHPSCR))/CHTIME; - int h=(abs((t%48)-24)*BUFH)/256,i; - char*c=skrtxt+chno; - - for(i=0;i=0-(BUFH/8))if(y= 0 - (BUFH / 8) && y < BUFH) + { + drawchar(x, y, phont[*s - 32], BUFW / 60, BUFH / 60); + x += BUFW / 13; + } + s++; + } } /********************** tHA kORE bEGiNS *********************/ -#define BLACKBG 1 -#define FLASHBG 2 -#define OCSALOGO 4 -#define SCROLL0 8 -#define BALLIE 16 -#define BALLJUMPS 32 -#define COUNTAH 64 -#define CHESSBG 128 -#define PLASMABG 256 -#define FLASHTXT 512 -#define TXTSCR 1024 -#define ENDSCR 2048 -#define DEMOEND 4096 +#define BLACKBG 0x0001 +#define FLASHBG 0x0002 +#define OCSALOGO 0x0004 +#define SCROLL0 0x0008 +#define BALLIE 0x0010 +#define BALLJUMPS 0x0020 +#define COUNTAH 0x0040 +#define CHESSBG 0x0080 +#define PLASMABG 0x0100 +#define FLASHTXT 0x0200 +#define TXTSCR 0x0400 +#define ENDSCR 0x0800 +#define DEMOEND 0x1000 -const short dezign[]={ - 0, BLACKBG|OCSALOGO|SCROLL0, - 256,FLASHBG|BALLIE|BALLJUMPS|COUNTAH, - 384,BLACKBG|BALLIE|BALLJUMPS|COUNTAH|OCSALOGO, - 400,BLACKBG|BALLIE|COUNTAH|OCSALOGO, - 416,BLACKBG|BALLIE, - 448,BLACKBG|BALLIE|TXTSCR, - 512,CHESSBG|BALLIE|BALLJUMPS|TXTSCR, - 576,CHESSBG|BALLIE|BALLJUMPS|TXTSCR, - 640,CHESSBG|BALLIE|BALLJUMPS|TXTSCR, - 704,CHESSBG|BALLIE|BALLJUMPS|TXTSCR, - 768,FLASHBG|FLASHTXT, - 896,FLASHBG|FLASHTXT|TXTSCR, - 962,FLASHBG|FLASHTXT|TXTSCR|BALLIE|BALLJUMPS, - 1024,BLACKBG|BALLIE|ENDSCR, - 1152,CHESSBG|BALLIE|BALLJUMPS|ENDSCR, - 1344,FLASHBG|BALLIE|BALLJUMPS|ENDSCR, - 1536,DEMOEND +const short dezign[] = { + 0, BLACKBG | OCSALOGO | SCROLL0, + 256, FLASHBG | BALLIE | BALLJUMPS | COUNTAH, + 384, BLACKBG | BALLIE | BALLJUMPS | COUNTAH | OCSALOGO, + 400, BLACKBG | BALLIE | COUNTAH | OCSALOGO, + 416, BLACKBG | BALLIE, + 448, BLACKBG | BALLIE | TXTSCR, + 512, CHESSBG | BALLIE | BALLJUMPS | TXTSCR, + 576, CHESSBG | BALLIE | BALLJUMPS | TXTSCR, + 640, CHESSBG | BALLIE | BALLJUMPS | TXTSCR, + 704, CHESSBG | BALLIE | BALLJUMPS | TXTSCR, + 768, FLASHBG | FLASHTXT, + 896, FLASHBG | FLASHTXT | TXTSCR, + 962, FLASHBG | FLASHTXT | TXTSCR | BALLIE | BALLJUMPS, + 1024, BLACKBG | BALLIE | ENDSCR, + 1152, CHESSBG | BALLIE | BALLJUMPS | ENDSCR, + 1344, FLASHBG | BALLIE | BALLJUMPS | ENDSCR, + 1536, DEMOEND }; /* don't look at the rest of the code, it just sucks :) */ -void main(void) +int main(int argc, char *argv[]) { - vec3d joo; + vec3d joo; + const int U = BUFW / 40; - int flagz=0;const short*dez=dezign; - char *phiword=NULL,*dizainword=NULL;int flixtim=0; + int flagz = 0; + const short *dez = dezign; + char *phiword = NULL, *dizainword = NULL; + int flixtim = 0; - ruutu=malloc(BUFH*BUFW*sizeof(char)); - preball(); + ruutu = malloc(BUFH * BUFW * sizeof(char)); + preball(); - srand((int)time(NULL)); + srand((int) time(NULL)); #define MAXROWLGT TIKLGT*ROWTIX - -#if AUDIO!=0 - oxl_init_audio(ROWTIX); - TIKLGT=AUFREQ/DEMOHZ; - mxbuf=malloc(MAXROWLGT*sizeof(int)); - audio_precalcs(); -#endif + + oxl_init_audio(ROWTIX); + TIKLGT = AUFREQ / DEMOHZ; + mxbuf = malloc(MAXROWLGT * sizeof(int)); + audio_precalcs(); + + oxl_init_video(); + oxl_init_timer(); + + setpal(); - oxl_init_video(); - oxl_init_timer(); + for (;;) + { + int t = oxl_timer(); - setpal(); - - for(;;){ - int t=oxl_timer(); + while ((t / ROWTIX >= *dez) && (flagz & DEMOEND) == 0) + { + dez++; + flagz = *dez++; + if (flagz & FLASHTXT) + flixtim = *(dez - 2); + if (flagz & TXTSCR) + dizainword = dotxtscr(); + } - while((t/ROWTIX>=*dez)&&(!(flagz&DEMOEND))) - {dez++;flagz=*dez++; - if(flagz&FLASHTXT)flixtim=*(dez-2); - if(flagz&TXTSCR)dizainword=dotxtscr(); - } - if(flagz&FLASHTXT) - while((t/ROWTIX)>=flixtim){phiword=lyrix();flixtim+=4;} + if (flagz & FLASHTXT) + { + while ((t / ROWTIX) >= flixtim) + { + phiword = lyrix(); + flixtim += 4; + } + } - if(flagz&DEMOEND)break; + if (flagz & DEMOEND) + break; - if(flagz&BLACKBG)memset(ruutu,0,BUFH*BUFW);else - if(flagz&FLASHBG) - { unsigned char col=130+(t%48)*2; - #if ASMLOOPS==386 - /* the original asm/string.h by linus does this with stosb, so */ - __asm__("rep;stosl"::"D"(ruutu),"c"((BUFH*BUFW)>>2), - "a"(col|(col<<8)|(col<<16)|(col<<24)):"ax","cx","di"); - #else - memset(ruutu,col,BUFH*BUFW); - #endif - } + if (flagz & BLACKBG) + { + memset(ruutu, 0, BUFH * BUFW); + } + else + if (flagz & FLASHBG) + { + unsigned char col = 130 + (t % 48) * 2; + memset(ruutu, col, BUFH * BUFW); + } - if(flagz&CHESSBG){int zoom=((10+abs(((t>>1)%96)-48))*4096/BUFW); - rotochess(ruutu, - sin(t*0.03)*zoom,cos(t*0.03)*zoom,0,0);} + if (flagz & CHESSBG) + { + int zoom = ((10 + abs(((t >> 1) % 96) - 48)) * 4096 / BUFW); + rotochess(ruutu, + sin(t * 0.03) * zoom, cos(t * 0.03) * zoom, 0, 0); + } /* if(flagz&PLASMABG) drawplasma(ruutu,t); */ - if(flagz&OCSALOGO){ - #define U (BUFW/40) - drawchar(U*6,U*4,phont['O'-32],U+U*sin(t*0.10+3),U); - drawchar(U*14,U*4,phont['C'-32],U,U+U*sin(t*0.11+3)); - drawchar(U*22,U*4,phont['S'-32],U,U+U*sin(t*0.12+3)); - drawchar(U*30,U*4,phont['A'-32],U+U*sin(t*0.13+3),U); - #undef U - } - - if(flagz&SCROLL0)plainscroll(t); - - if(flagz&BALLIE){ - int zoom; - if(flagz&BALLJUMPS)zoom=abs((t%96)-48);else zoom=47; - if(zoom<0)zoom=0;else if(zoom>47)zoom=47; - - unitvec(&joo,0.038*t,0.023*t,0.011*t,32000/balltab[zoom].R); - joo.z<<=1; - - drawball(ruutu,&joo,zoom); - } + if (flagz & OCSALOGO) + { + drawchar(U * 6, U * 4, phont['O' - 32], U + U * sin(t * 0.10 + 3), + U); + drawchar(U * 14, U * 4, phont['C' - 32], U, + U + U * sin(t * 0.11 + 3)); + drawchar(U * 22, U * 4, phont['S' - 32], U, + U + U * sin(t * 0.12 + 3)); + drawchar(U * 30, U * 4, phont['A' - 32], + U + U * sin(t * 0.13 + 3), U); + } + + if (flagz & SCROLL0) + plainscroll(t); - if(flagz&FLASHTXT)flashtxt(phiword); - if(flagz&TXTSCR)if((t/ROWTIX)&2)drawtxtscr(dizainword); + if (flagz & BALLIE) + { + int zoom; + if (flagz & BALLJUMPS) + zoom = abs((t % 96) - 48); + else + zoom = 47; + if (zoom < 0) + zoom = 0; + else if (zoom > 47) + zoom = 47; - if(flagz&ENDSCR)doendscroll(t-1024*ROWTIX); + unitvec(&joo, 0.038 * t, 0.023 * t, 0.011 * t, + 32000 / balltab[zoom].R); + joo.z <<= 1; + + drawball(ruutu, &joo, zoom); + } - #define U (BUFW/40) - if(flagz&COUNTAH) - {int n=((t*50/48)-256*6); - int dis=(rand()%U)>>1; - if(n>666)n=666; - if(n>600){ - drawchar(U*12+dis,(BUFH>>1)+dis+U*6,phont['X'-32],U,U); - drawchar(U*22+dis,(BUFH>>1)+dis+U*6,phont['3'-32],U,U);} - drawchar(U*28+dis,BUFH>>1,phont[16+(n%10)],U,U);n/=10; - drawchar(U*18+dis,BUFH>>1,phont[16+(n%10)],U,U);n/=10; - drawchar(U*8+dis,BUFH>>1,phont[16+(n%10)],U,U);n/=10; - } - #undef U - - /* blitzz */ - - oxl_doframe(ruutu); - #if AUDIO!=0 - oxl_doaudio(audio_mix); - #endif - while(t==oxl_timer()){ - #if SLEEPY - usleep(250000/DEMOHZ); - #endif - } - } - oxl_end(); + if (flagz & FLASHTXT) + flashtxt(phiword); + if (flagz & TXTSCR) + if ((t / ROWTIX) & 2) + drawtxtscr(dizainword); + + if (flagz & ENDSCR) + doendscroll(t - 1024 * ROWTIX); + + if (flagz & COUNTAH) + { + int n = ((t * 50 / 48) - 256 * 6); + int dis = (rand() % U) >> 1; + if (n > 666) + n = 666; + if (n > 600) + { + drawchar(U * 12 + dis, (BUFH >> 1) + dis + U * 6, + phont['X' - 32], U, U); + drawchar(U * 22 + dis, (BUFH >> 1) + dis + U * 6, + phont['3' - 32], U, U); + } + drawchar(U * 28 + dis, BUFH >> 1, phont[16 + (n % 10)], U, U); + n /= 10; + drawchar(U * 18 + dis, BUFH >> 1, phont[16 + (n % 10)], U, U); + n /= 10; + drawchar(U * 8 + dis, BUFH >> 1, phont[16 + (n % 10)], U, U); + n /= 10; + } + + /* blitzz */ + + oxl_doframe(ruutu); + oxl_doaudio(audio_mix); + while (t == oxl_timer()) + { + usleep(250000 / DEMOHZ); + } + } + oxl_end(); }