Mercurial > hg > forks > pwpunix
comparison final_isi/effu.c @ 69:c13a2f8c5b10
Rename files and some minor cleanups.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 01 Jun 2012 17:41:15 +0300 |
parents | final_isi/fisieffu.c@53676367d46f |
children | deedd4fae98d |
comparison
equal
deleted
inserted
replaced
68:48c3defeca8f | 69:c13a2f8c5b10 |
---|---|
1 #include "wrapper.h" | |
2 | |
3 #include "fisi.h" | |
4 | |
5 /* #include "dos.h" */ | |
6 | |
7 #define uchar unsigned char | |
8 #define uint unsigned int | |
9 #define sint signed int | |
10 | |
11 #include "sini.h" | |
12 | |
13 extern void waitretrace(); | |
14 extern signed int mul32(signed int a,signed int b); | |
15 | |
16 /*************** setup *******************/ | |
17 | |
18 char setup_rtc=1; | |
19 char setup_force25=0; | |
20 char setup_nohibit=0; | |
21 | |
22 /*************** multimedia interface **********/ | |
23 | |
24 char buffclass; /* preparebuff == setmode etc */ | |
25 | |
26 int bgcol=0; | |
27 int txtcol=0; | |
28 int ansifrom=0; | |
29 | |
30 /*************/ | |
31 | |
32 char fx_main=0; | |
33 char fx_main_spex=0; | |
34 char fx_3d=0; | |
35 char fx_flare=0; | |
36 | |
37 /*************/ | |
38 | |
39 uchar txl[6][20]; | |
40 | |
41 /*************** cOnstANTZ eTC *************/ | |
42 | |
43 uchar ruutu__[80*25*2]; | |
44 uchar*ruutu=ruutu__; | |
45 | |
46 uchar symtab[50][80]; | |
47 uchar videobuf[80*50]; /* 80x50! */ | |
48 uchar textbuf[80*50]; | |
49 uchar ansibuf[80*25*2]; /* 80x25! */ | |
50 /*char xorru[120*75];*/ | |
51 uchar*abb=ansibuf; | |
52 uchar*txb=textbuf; | |
53 uchar*vib=videobuf; | |
54 | |
55 /*********/ | |
56 | |
57 /***************.: STATiK dEMO mAiNLOOP eT sETUppES :.******************/ | |
58 | |
59 | |
60 /******************.: tABLES, pRECALX :.*********************/ | |
61 | |
62 char fadetab[256]; /* fadetaulu on ihan hY™DYKE */ | |
63 void fadetab_make(char *ft) | |
64 { | |
65 int s;char d; | |
66 for(s=0;s<256;s++){ | |
67 switch(s&0x88){ | |
68 case(0x88):d=s&~8;break; /* 99 -> 91 */ | |
69 case(0x80):d=(s&0x70)|(s>>4);break; /* 91 -> 19 */ | |
70 case(0x08):if(s&0xf0)d=((s&7)<<4)|(s&7); | |
71 else d=(s&7)<<4; break; /* 19 -> 11 */ | |
72 /* 09 -> 10 */ | |
73 case(0x00): | |
74 if((s&0xf0)&&(s&0x0f))d=s&0xf0; /* 11 -> 10 */ | |
75 else d=s>>4; /* 10 -> 01 */ | |
76 break; | |
77 } | |
78 *ft++=d;} | |
79 } | |
80 | |
81 uchar sqrt[256]; | |
82 void sqrt_make() | |
83 { | |
84 uint l=0,l2=0,sq; /* m„„rjoukko: 0..255 */ | |
85 /* arvojoukko: 0..255 (=<<8) */ | |
86 for(;l<256;l++){ | |
87 sq=(l*l)>>8; | |
88 while(l2<=sq) sqrt[l2++]=l; | |
89 } | |
90 while(l2<=255) sqrt[l2++]=255; | |
91 } | |
92 | |
93 /************************ xORRUTUS *************************/ | |
94 | |
95 /************************* TUNNELZ ************************/ | |
96 /************************* TUNNELZ ************************/ | |
97 /************************* TUNNELZ etc ******************/ | |
98 | |
99 char lenssprite[256]={ | |
100 0x00,0x00,0x00,0x00,0x00,0x88,0xff,0xff,0xff,0xff,0x88,0x00,0x00,0x00,0x00,0x00, | |
101 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, | |
102 0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00, | |
103 0x00,0x00,0xff,0xff,0xff,0xff,0x77,0x88,0x88,0x77,0xff,0xff,0xff,0xff,0x00,0x00, | |
104 0x00,0xff,0xff,0xff,0x77,0x00,0x00,0x00,0x00,0x00,0x00,0x77,0xff,0xff,0xff,0x00, | |
105 0x88,0xff,0xff,0xff,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x88,0xff,0xff,0xff,0x88, | |
106 0xff,0xff,0xff,0x77,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x77,0xff,0xff,0xff, | |
107 0xff,0xff,0xff,0x88,0x00,0x00,0x00,0x88,0x88,0x00,0x00,0x00,0x88,0xff,0xff,0xff, | |
108 0xff,0xff,0xff,0x88,0x00,0x00,0x00,0x88,0x88,0x00,0x00,0x00,0x88,0xff,0xff,0xff, | |
109 0xff,0xff,0xff,0x77,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x77,0xff,0xff,0xff, | |
110 0x88,0xff,0xff,0xff,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x88,0xff,0xff,0xff,0x88, | |
111 0x00,0xff,0xff,0xff,0x77,0x00,0x00,0x00,0x00,0x00,0x00,0x77,0xff,0xff,0xff,0x00, | |
112 0x00,0x00,0xff,0xff,0xff,0xff,0x77,0x88,0x88,0x77,0xff,0xff,0xff,0xff,0x00,0x00, | |
113 0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00, | |
114 0x00,0x00,0x00,0x00,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x00,0x00,0x00,0x00, | |
115 0x00,0x00,0x00,0x00,0x00,0x77,0xff,0xff,0xff,0xff,0x77,0x00,0x00,0x00,0x00,0x00 | |
116 }; | |
117 | |
118 | |
119 /* | |
120 symtab_tunnel() | |
121 { | |
122 int x,y; | |
123 uchar*d=symtab[0]; | |
124 for(y=0;y<50;y++) | |
125 for(x=0;x<80;x++){ | |
126 sint r=(x-40)*(x-40)+(y-25)*(y-25); | |
127 *d++=sqrt[r/10]; | |
128 } | |
129 } | |
130 | |
131 uchar tunxlat[4*16]={ | |
132 0x00,0x00,0x00,0x00, | |
133 0x01,0x01,0x10,0x10, | |
134 0x11,0x11,0x11,0x19, | |
135 0x19,0x91,0x99,0xff, | |
136 | |
137 0x00,0x08,0x80,0x88, | |
138 0x87,0x78,0x77,0x7f, | |
139 0xff,0xff,0xff,0xff, | |
140 0xfe,0xef,0xee,0xe6, | |
141 | |
142 0x00,0x00,0x00,0x00, | |
143 0x02,0x02,0x20,0x20, | |
144 0x20,0x22,0x22,0x22, | |
145 0x2a,0x2a,0xa2,0xa2, | |
146 | |
147 0x00,0x08,0x80,0x88, | |
148 0x87,0x78,0x77,0x7f, | |
149 0xff,0xff,0xff,0xff, | |
150 0xfe,0xef,0xee,0xe6, | |
151 }; | |
152 | |
153 | |
154 xorrutab() | |
155 { | |
156 int x,y; | |
157 uchar*d=xorru; | |
158 for(y=0;y<75;y++) | |
159 for(x=0;x<120;x++){ | |
160 char joo; | |
161 sint r=(x-60)*(x-60)+(y-37)*(y-37); | |
162 r=sqrt[r/20]; | |
163 joo=tunxlat[(r>>3)&15]; | |
164 if(r&16)joo^=0xcc; | |
165 *d++=joo; | |
166 } | |
167 } | |
168 | |
169 do_xorru(int t) | |
170 { | |
171 sint x,y,zoom,q=t/6; | |
172 uchar*s0,*s1; | |
173 uchar*d=videobuf; | |
174 | |
175 x=sini[t&255];y=sini[(t+64)&255]; | |
176 x=20+(x/4);y=12+(y/10); | |
177 s0=xorru+x+120*y; | |
178 | |
179 x=sini[(-t+q+128+47)&255];y=sini[(-t+q+128+64+22)&255]*zoom; | |
180 x=20+(x/4);y=12+(y/10); | |
181 s1=xorru+x+120*y; | |
182 | |
183 xorrase(s0,s1,videobuf,bgcol); | |
184 } | |
185 | |
186 char paletti[255]; | |
187 | |
188 dotunneltxt(int t) | |
189 { | |
190 int i,j=0;uchar*d=paletti; | |
191 for(i=64;i;i--){ | |
192 j+=i+192; | |
193 *d++=fadetab[tunxlat[((t+(j>>6))>>4)&63]|bgcol]; | |
194 } | |
195 for(i=192;i;i--){ | |
196 j+=i; | |
197 *d++=tunxlat[((t+(j>>6))>>4)&63]|bgcol; | |
198 } | |
199 } | |
200 */ | |
201 | |
202 /* | |
203 tunxshl() | |
204 { | |
205 int l; | |
206 for(l=0;l<16;l++) tunxlat[l]<<=1; | |
207 } | |
208 */ | |
209 | |
210 /* ^^3 ^^2 */ | |
211 | |
212 | |
213 /******************.: eFFECTZ hANDLER :.*********************/ | |
214 | |
215 char wirez[16]={ | |
216 ' ', '¼', 'È', 'Í', '»', 'º', 'Î', 'É', | |
217 'É', 'Î', 'º', '»', 'Í', 'È', '¼', ' ' }; | |
218 | |
219 char zbpalli[]={ | |
220 0x00,0x01,0x10,0x11,0x13,0x31,0x33,0x3c,0xc3,0xcc,0xcf,0xfc,0xff}; | |
221 | |
222 int fps=0,framez,lasttik=0; | |
223 | |
224 void preparebuff(int c) | |
225 { | |
226 if(c!=buffclass) | |
227 switch(c){ | |
228 case(NONE):case(HYBRID):txtmode(0); | |
229 memfill(ruutu,0x0000,80*25*2); | |
230 memfill(ansibuf,253,80*25*2); | |
231 break; | |
232 | |
233 case(SINGLE): | |
234 txtmode(1-setup_force25); | |
235 if(!setup_force25)memfill(ruutu,176+256*176,80*50*2); | |
236 else memfill(ruutu,223+256*223,80*25*2); | |
237 break; | |
238 } | |
239 buffclass=c; | |
240 } | |
241 | |
242 /* | |
243 txtmode(int c) | |
244 { | |
245 #ifdef MSDOS | |
246 _AX=0x0003;_BX=0;geninterrupt(0x10); | |
247 _AX=0x1003;_BX=0;geninterrupt(0x10); | |
248 if (c){_AX=0x1112;_BX=0;geninterrupt(0x10);} | |
249 #else | |
250 #endif | |
251 } | |
252 */ | |
253 | |
254 /**********************************/ | |
255 | |
256 framekey o0[7]={ | |
257 40*32,40*32,1024, /* OX */ | |
258 25*32,25*32,1024, /* OY */ | |
259 25000,25000,1024, /* OZOOM */ | |
260 0,0,1024, /* OROT */ | |
261 | |
262 25*256,25*256,4096,/* OHGT */ | |
263 0*256,0*256,4096,/* OFLX */ | |
264 0*256,0*256,4096 /* OFLY */ | |
265 }; | |
266 | |
267 char ltcols[]={ | |
268 0x00, | |
269 0x00, | |
270 0x00, | |
271 0x80, | |
272 0x00, | |
273 0x08, | |
274 0x88, | |
275 0x88, | |
276 0x87, | |
277 0x78, | |
278 0x77, | |
279 0x87, | |
280 0x7e, | |
281 0xe7, | |
282 0xe6, | |
283 0xee, | |
284 0xef, | |
285 0xfe, | |
286 0xf7, | |
287 0xff, | |
288 0xff, | |
289 0xff, | |
290 0xff | |
291 }; | |
292 | |
293 uchar*ltloc; | |
294 void doltsrc(char*b,int x,int y,int lev) | |
295 { | |
296 int i;char*tmp; | |
297 x+=40;y+=25; | |
298 b+=x+y*80;ltloc=b; | |
299 | |
300 *b=0xff; | |
301 | |
302 tmp=b; | |
303 i=lev;if(i>x-1)i=x-1; | |
304 if(i>0) | |
305 while(i--){tmp--;*tmp|=ltcols[i+(rand()&3)];} | |
306 tmp=b; | |
307 i=lev;if(i>79-x)i=79-x; | |
308 if(i>0) | |
309 while(i--){tmp++;*tmp|=ltcols[i+(rand()&3)];} | |
310 | |
311 tmp=b; | |
312 i=lev;if(i>y-1)i=y-1; | |
313 if(i>0) | |
314 while(i--){tmp-=80;*tmp|=ltcols[i+(rand()&3)];} | |
315 | |
316 tmp=b; | |
317 i=lev;if(i>49-y)i=49-y; | |
318 if(i>0) | |
319 while(i--){tmp+=80;*tmp|=ltcols[i+(rand()&3)];} | |
320 } | |
321 | |
322 /********************************************/ | |
323 | |
324 void psetpic(char *buf, char *pic, sint x, sint y, int xsize, int ysize,int method) | |
325 { | |
326 sint xstart=0,ystart=0,xclip=xsize,yclip=ysize; | |
327 x-=(xsize>>1);y-=(ysize>>1); | |
328 | |
329 if (x>=0-xsize) if (x<=80+xsize) | |
330 if (y>=0-ysize) if (y<=50+ysize){ | |
331 | |
332 if (x<0){xstart=0-x;xclip-=xstart;x=0;} | |
333 if (y<0){ystart=0-y;yclip-=ystart;y=0;} | |
334 | |
335 if (x+xclip>79) xclip-=abs((x+xclip)-79); | |
336 if (y+yclip>49) yclip-=abs((y+yclip)-49); | |
337 | |
338 if (xclip>0) if (yclip>0) | |
339 picmov(pic+xsize*ystart+xstart, | |
340 buf+y*80+x, | |
341 xsize,xclip,yclip,method); | |
342 }} | |
343 | |
344 char lensb[256],lensg[256],lensr[256]; | |
345 | |
346 void lflare_do(signed int x,signed int y) | |
347 { | |
348 if(abs(x)<40*4)if(abs(y)<25*4) | |
349 if(*ltloc==0xff){ | |
350 doltsrc(videobuf,(x+(rand()&1)) >>2,(y+(rand()&1)) >>2,20); | |
351 psetpic(videobuf,lensr,40-(x>>3),25-(y>>3),16,16,1); | |
352 psetpic(videobuf,lensb,40-(x>>2),25-(y>>2),16,16,1); | |
353 psetpic(videobuf,lensg,40-(x>>1),25-(y>>1),16,16,1); | |
354 } | |
355 } | |
356 | |
357 void flarez_init() | |
358 { | |
359 char*s=lenssprite; | |
360 char*d0=lensb,*d1=lensg,*d2=lensr; | |
361 int i; | |
362 for(i=256;i;i--){*d0++=*s&0x9c; | |
363 *d1++=*s&0x9a;*d2++=*s++&0xec;} | |
364 } | |
365 | |
366 | |
367 void do3ddezign(int tskip) | |
368 { | |
369 int i; | |
370 for(i=0;i<7;i++){ | |
371 o0[i].curr+= | |
372 tskip*mul32(o0[i].targ-o0[i].curr,o0[i].frac); | |
373 } | |
374 | |
375 if(o0[OZOOM].curr>100)eggine_do(videobuf,o0[OROT].curr&255, | |
376 o0[OZOOM].curr,o0[OX].curr,o0[OY].curr); | |
377 } | |
378 | |
379 void precalx() | |
380 { | |
381 /* cprintf("cREATiNG!!! ");*/ | |
382 fillbuf(textbuf,0,80*50); | |
383 eggine_init(); | |
384 flarez_init(); | |
385 } | |
386 | |
387 void effu(int t) | |
388 { | |
389 static int lastt=0; | |
390 char*ggg; | |
391 | |
392 switch(buffclass){ | |
393 case(SINGLE): | |
394 #ifdef MSDOS | |
395 if(!setup_force25) | |
396 #endif | |
397 if(txtcol) | |
398 attr2dump(textbuf,videobuf,ruutu+1, | |
399 80*50,txtcol); | |
400 else | |
401 attrdump(videobuf,ruutu+1,80*50); | |
402 #ifdef MSDOS | |
403 else{ | |
404 int z=0xf0f0;if(setup_nohibit)z=0x7070; | |
405 if(!txtcol) | |
406 dump16(videobuf,ruutu,z);else | |
407 dump216(textbuf,videobuf,ruutu,txtcol,z); | |
408 } | |
409 #endif | |
410 break; | |
411 | |
412 case(HYBRID): | |
413 if(ansifrom)ggg=ansibuf;else ggg=textbuf; | |
414 if(ansifrom==2)if(t&16)ggg=textbuf; | |
415 dumphybrid(ggg,videobuf,ruutu); | |
416 break; | |
417 } | |
418 | |
419 /* framez++;gotoxy(1,1);textcolor(15);cprintf("%i %i %i ..%i ",taimeri,buffclass,fps,fx_3d); | |
420 if (taimeri>lasttik+70) { lasttik=taimeri;fps=framez;framez=0;}*/ | |
421 | |
422 /*** EFFUEZ ***/ | |
423 | |
424 /* o0[OFLX].curr=sini[(t/3)&255]*30; | |
425 o0[OFLY].curr=sini[(t+64)&255]*30;*/ | |
426 | |
427 if (buffclass){ | |
428 int c=bgcol; | |
429 if(buffclass==1)c*=0x101; | |
430 | |
431 /*if(fx_main==NONE)fillbuf(videobuf,c,80*50);*/ | |
432 | |
433 if(fx_main==SCROLLER)scroller_do(videobuf,t,o0[OHGT].curr>>8); | |
434 | |
435 if(fx_flare) | |
436 doltsrc(videobuf,o0[OFLX].curr>>8,o0[OFLY].curr>>8,10); | |
437 if(fx_3d)do3ddezign(t-lastt); | |
438 if(fx_flare)lflare_do(o0[OFLX].curr>>6,o0[OFLY].curr>>6); | |
439 } | |
440 /**************/ | |
441 | |
442 | |
443 lastt=t; | |
444 } | |
445 | |
446 /*****************************************/ | |
447 /*****************************************/ | |
448 /*****************************************/ | |
449 /*****************************************/ | |
450 /*****************************************/ | |
451 /*****************************************/ | |
452 /*****************************************/ | |
453 /*****************************************/ | |
454 /*****************************************/ | |
455 /*****************************************/ | |
456 /*****************************************/ | |
457 /*****************************************/ | |
458 /*****************************************/ | |
459 /*****************************************/ | |
460 /*****************************************/ | |
461 /*****************************************/ | |
462 /*****************************************/ | |
463 /*****************************************/ | |
464 /*****************************************/ | |
465 /*****************************************/ | |
466 /*****************************************/ | |
467 /*****************************************/ | |
468 /*****************************************/ | |
469 /*****************************************/ | |
470 /*****************************************/ | |
471 /*****************************************/ | |
472 /*****************************************/ | |
473 /*****************************************/ | |
474 |