home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / dos / grafik / tc_3d / tc-11.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-13  |  17.2 KB  |  449 lines

  1. /* tc-11.c */
  2. /* Draws a computer-shaded sphere using the
  3.     plane equation method of hidden surface removal and the
  4.     surface normal method od halftone shading
  5.  
  6.     REQUIRES EITHER EGA OR VGA!! */
  7.  
  8. /* ----------------------------------------------------------------------- */
  9. /* INCLUDE FILES */
  10. #include <process.h>
  11. #include <bios.h>
  12. #include <stdio.h>
  13. #include <graphics.h>
  14. #include <math.h>
  15.  
  16. /* ----------------------------------------------------------------------- */
  17. /* DECLARATIONS */
  18.  
  19. float        x=0.0,y=0.0,z=0.0;                                              /* world coordinates */
  20. float        x1=0.0,x2=0.0,x3=0.0,x4=0.0;                                /* polygon vertices */
  21. float        y01=0.0,y2=0.0,y3=0.0,y4=0.0;                                /* polygon vertices */
  22. float        z1=0.0,z2=0.0,z3=0.0,z4=0.0;                                /* polygon vertices */
  23. float        sx1=0.0,sx2=0.0,sx3=0.0,sx4=0.0,sx5=0.0;                /* display coordinaes */
  24. float        sy1=0.0,sy2=0.0,sy3=0.0,sy4=0.0,sy5=0.0;                /* display coordinates */
  25. float        sx=0.0,sy=0.0;                                                    /* output of 3d perspective formulas */
  26. float        xa=0.0,ya=0.0,za=0.0;                                        /* temporary values in 3d formulas */
  27. float        d=1000.0;                                                    /* angular perspective value */
  28. double    r1=6.19592;                                                        /* yaw angle in radians */
  29. double    r2=.523590;                                                        /* roll angle in radians */
  30. double    r3=5.39778;                                                        /* pitch angle in radians */
  31. double    sr1=0.0,sr2=0.0,sr3=0.0;                                    /* sine rotation factors */
  32. double    cr1=0.0,cr2=0.0,cr3=0.0;                                    /* cosine rotation factors */
  33. float        mx=0.0,my=0.0,mz=-150.0;                                    /* viewpoint position */
  34. int        maxx=639,minx=0,maxy=199,miny=0;                            /* scaling viewport */
  35. float        screen_x=639,screen_y=199;                                    /* dimensions of screen mode */
  36. int        C0=0,C1=1,C2=2,C3=3,C4=4,C5=5,C6=6,C7=7,C8=8,        /* color varariables */
  37.             C9=9,C10=10,C11=11,C12=12,C13=13,C14=14,C15=15,
  38.             mode_flag=0;
  39. float        rx=0.0,ry=0.0;                                                    /* scaling values used in mapping routine */
  40. int        t=0,t1=0,t2=0;                                                    /* loop counters */
  41. int        p1=0;                                                                /* array indexer */
  42. int        key_matte_clr=6;                                                /* exclusive key matte color */
  43. int        edge_clr=7;                                                        /* used to draw edges on models */
  44. int        solid_clr=0;                                                    /* used to fill surfaces of solid models */
  45. int        design_clr=1;                                                    /* used to draw the design on the model */
  46. float        x_res,y_res;                                                    /* used for 2d mappinf from 640*480 template */
  47. float        sp=0.0;                                                            /* visibility factor in hidden surface routine */
  48. float        sp1=0.0,sp2=0.0,sp3=0.0;                                    /* temporary values of sp */
  49. float        xlarge=0.0,xsmall=0.0;                                        /* when finding polygon center (not used) */
  50. float        ylarge=0.0,ysmall=0.0;
  51. float        zlarge=0.0,zsmall=0.0;
  52. float        x6=0.0,x7=0.0,y6=0.0,y7=0.0,z6=0.0,z7=0.0;
  53.  
  54. int        NORM_HUE=0;                                                        /* halftoning color */
  55. int        BASE_CLR=0;                                                        /* prep cooor for dithering */
  56. int        CC4=0;                                                            /* underlay color for dithering */
  57. int        CC5=0;                                                            /* overlay color for dithering */
  58. unsigned short CC6=0xffff;                                                /* pattern for dithering */
  59. float        xx1=0,yy1=.0,zz1=1;                                            /* location of light source - elevation 45 degrees, compas 135 degrees {{REDIFINED !!}}*/
  60. float        v4=0.0;                                                            /* illumination factor 0 to 1 range */
  61. int        v5=0;                                                                /* illumination factor base 1 range */
  62. int        v6=11;                                                            /* VGA and EGA illumination range */
  63. int        v7=0;                                                                /* temporary varaible used for illumination range */
  64. float        xu=0.0,yu=0.0,zu=0.0;                                        /* vector from vertex one to vertex two */
  65. float        xv=0.0,yv=0.0,zv=0.0;                                        /* vector from vertex 1 to vertex 3 */
  66. float        xn=0.0,y0n=0.0,zn=0.0;                                        /* surface perpendicular factor */
  67. float        v1=0.0,v2=0.0;                                                    /* length of surface perpendicular vector */
  68. float        v3=0.0;                                                            /* ratio of length to unit vector magnitude */
  69. float        xw=0.0,yw=0.0,zw=0.0;                                        /* surface perpendicual unit vector */
  70. int        polary[4][2];  /* used in my 3d solid polygon draw routine */
  71.  
  72. /* define halftone codes */
  73. char fill_0[]={0,0,0,0,0,0,0,0};                                        /* 0% fill */
  74. char fill_3[]={0,32,0,0,0,2,0,0};                                    /* 3% fill */
  75. char fill_6[]={32,0,2,0,128,0,8,0};                                    /* 6% fill */
  76. char fill_12[]={32,2,128,8,32,2,128,8};                            /* 12% fill */
  77. char fill_25[]={68,17,68,17,68,17,68,17};                            /* 25% fill */
  78. char fill_37[]={170,68,170,17,170,68,170,17};                    /* 37% fill */
  79. char fill_50[]={85,170,85,170,85,170,85,170};                    /* 50% fill */
  80. char fill_62[]={85,187,85,238,85,187,85,238};                    /* 62% fill */
  81. char fill_75[]={187,238,187,238,187,238,187,238};                /* 75% fill */
  82. char fill_87[]={223,253,127,247,223,253,127,247};                /* 87% fill */
  83. char fill_93[]={255,223,255,223,255,223,255,223};                /* 93% fill */
  84. char fill_100[]={255,255,255,255,255,255,255,255};                /* 100% fill */
  85.  
  86. int        q=0,q1=0,q2=0;                                                    /* sphere surface & vertex counters */
  87. double    r4=6.28319,r5=6.28319;                                        /* spherical coordinate angles */
  88. float        B11[36][3];                                                        /* 36 sets of xyz view coordinates, upper */
  89. float        B12[36][3];                                                        /* 36 sets of xyz view coordinates, lower */
  90. float        B21[36][2];                                                        /* 36 sets of sx,sy display coordinates, upper */
  91. float        B22[36][2];                                                        /* 36 sets of sx,sy display coordinates, lower */
  92. double    sr4=0.0,cr4=0.0,sr5=0.0,cr5=0.0;                            /* rotation factors */
  93.  
  94. /* declare global subroutines */
  95. void keyboard(void);void quit_pgm(void);void calc_3d(void);
  96. void rotation(void);void window(void);void graphics_setup(void);
  97. void coords(void);void draw_poly(void);void notice (int x,int y);
  98. void visibility_test(void);void polycenter(void);
  99. void illumination(void);void dither(void);void shade(void);
  100. void values(void);
  101.  
  102. void sphere_coords(void);void draw_4poly(void);
  103. void draw_3polynorth(void);void draw_3polysouth(void);
  104. void upper_coords(void);void lower_coords(void);
  105.  
  106. /* ----------------------------------------------------------------------- */
  107. /* MAIN ROUTINE */
  108.  
  109. main(){
  110. graphics_setup();
  111. setviewport(0,0,maxx,maxy,1);
  112. key_matte_clr=C6;
  113. edge_clr=C7;solid_clr=C3;
  114. NORM_HUE=C11;
  115.  
  116. rotation();
  117.  
  118. /* DRAW NORTH POLAR REGION */
  119. r5=0.0;r4=0.0;x=30;sphere_coords();calc_3d();window();
  120. B11[0][0]=x;B11[0][1]=y;B11[0][2]=z;
  121. B21[0][0]=sx;B21[0][1]=sy;
  122. x=-30;r5=.17453;r4=0.0;lower_coords();
  123. for (q1=0;q1<=35;q1++){
  124.     q2=q1+1;if (q2>35) q2=0;
  125.     draw_3polynorth();
  126.     keyboard();
  127. }
  128.  
  129. /* DRAW POLYGONS ALONG BELTS OF SPHERES */
  130. r5=.17453;
  131. for (t2=1;t2<=16;t2++){
  132.     x=30;r4=0.0;upper_coords();
  133.     x=30;r5=r5+.17453;r4=0.0;lower_coords();
  134.     for (q1=0;q1<=35;q1++){
  135.         q2=q1+1;if (q2>35) q2=0;
  136.         draw_4poly();
  137.         keyboard();
  138.         }
  139.     }
  140.  
  141. /* DRAW SOUTH POLAR REGIONS */
  142. r5=3.14159;r4=0.0;x=30;sphere_coords();calc_3d();window();
  143. B21[0][0]=x;B21[0][1]=y;B21[0][2]=z;
  144. B22[0][0]=sx;B22[0][1]=sy;
  145. x=30;r5=2.96706;r4=0.0;upper_coords();
  146. for (q1=0;q1<=35;q1++){
  147.     q2=q1+1;if (q2>35) q2=0;
  148.     draw_3polysouth();
  149.     keyboard();
  150.     }
  151.  
  152. setcolor(C7);notice(0,0);
  153. for (t1=1;t1!=2;) keyboard();
  154. quit_pgm();
  155. }
  156.  
  157. /* ----------------------------------------------------------------------- */
  158. /* SUBROUTINE: CALCULATE AND STORE COORDS FOR BELT */
  159.  
  160. void upper_coords(void){
  161. for (t=0;t<=35;t++){
  162.     x=30;sphere_coords();calc_3d();window();
  163.     B11[t][0]=x;B11[t][1]=y;B11[t][2]=z;
  164.     B21[t][0]=sx;B21[t][1]=sy;
  165.     r4=r4+.17453;
  166.     keyboard();}
  167.     return;}
  168.  
  169. void lower_coords(void){
  170.     for (t=0;t<=35;t++){
  171.     x=30;sphere_coords();calc_3d();window();
  172.     B12[t][0]=x;B12[t][1]=y;B12[t][2]=z;
  173.     B22[t][0]=sx;B22[t][1]=sy;
  174.     r4=r4+.17453;
  175.     keyboard();}
  176. return;}
  177.  
  178. /* ----------------------------------------------------------------------- */
  179. /* SUBROUTINE: CALCULATE WORLD COORDINATES FOR SPHERE */
  180.  
  181. void sphere_coords(void){
  182. sr4=sin(r4);cr4=cos(r4);sr5=sin(r5);
  183. cr5=cos(r5);x1=sr5*x;y=cr5*x;x=cr4*x1;z=sr4*x1;return;}
  184.  
  185. /* ----------------------------------------------------------------------- */
  186. /* SUBROUTINE: DRAW 4 SIDED POLYGON SURFACE ON SPHERE */
  187.  
  188. void draw_4poly(void){
  189. x1=B11[q1][0];y01=B11[q1][1];z1=B11[q1][2];
  190. x2=B11[q2][0];y2=B11[q2][1];z2=B11[q2][2];
  191. x3=B12[q2][0];y3=B12[q2][1];z3=B12[q2][2];
  192. x4=B12[q1][0];y4=B12[q1][1];z4=B12[q1][2];
  193. visibility_test();if (sp>-100) return;
  194. sx1=B21[q1][0];sy1=B21[q1][1];
  195. sx2=B21[q2][0];sy2=B21[q2][1];
  196. sx3=B22[q2][0];sy3=B22[q2][1];
  197. sx4=B22[q1][0];sy4=B22[q1][1];
  198. polycenter();
  199. draw_poly();
  200. illumination();shade();dither();
  201. return;}
  202.  
  203. /* ----------------------------------------------------------------------- */
  204. /* SUBROUTINE: DRAW 3 SIDED POLYGONAL SURFACE ON SPHERE */
  205.  
  206. void draw_3polynorth(void){
  207. x1=B12[q2][0];y01=B12[q2][1];z1=B12[q2][2];
  208. x2=B12[q1][0];y2=B12[q1][1];z2=B12[q1][2];
  209. x3=B11[0][0];y3=B11[0][1];z3=B11[0][2];
  210. visibility_test();if (sp>0) return;
  211. sx1=B22[q2][0];sy1=B22[q2][1];
  212. sx2=B22[q1][0];sy2=B22[q1][1];
  213. sx3=B21[0][0];sy3=B21[0][1];
  214. sx4=sx1;sy4=sy1;
  215. x4=x1+.5*(x2-x1);y4=y01+.5*(y2-y01);z4=z1+.5*(z2-z1);
  216. x=x3+.85*(x4-x3);y=y3+.85*(y4-y3);z=z3+.85*(z4-z3);
  217. sx=d*x/z;sy=d*y/z;window();sx5=sx;sy5=sy;
  218. polycenter();
  219. draw_poly();
  220. illumination();shade();dither();
  221. return;}
  222.  
  223. void draw_3polysouth(void){
  224. x1=B12[q1][0];y01=B12[q1][1];z1=B12[q1][2];
  225. x2=B12[q2][0];y2=B12[q2][1];z2=B12[q2][2];
  226. x3=B11[0][0];y3=B11[0][1];z3=B11[0][2];
  227. visibility_test(); if (sp>0) return;
  228. sx1=B21[q2][0];sy1=B21[q2][1];
  229. sx2=B21[q1][0];sy2=B21[q1][1];
  230. sx3=B22[0][0];sy3=B22[0][1];
  231. sx4=sx1;sy4=sy1;
  232. x4=x1+.5*(x2-x1);y4=y01+.5*(y2-y01);z4=z1+.5*(z2-z1);
  233. x=x3+.85*(x4-x3);y=y3+.85*(y4-y3);z=z3+.85*(z4-z3);
  234. sx=d*x/z;sy=d*y/z;window();sx5=sx;sy5=sy;
  235. draw_poly();
  236. illumination();shade();dither();
  237. return;}
  238. /* ----------------------------------------------------------------------- */
  239. /* SUBROUTINE: IDENTIFY CENTER OF POLYGON - not used */
  240.  
  241. void polycenter(void){x6=x2+.5*(x1-x2);y6=y2+.5*(y01-y2);
  242. z6=z2+.5*(z1-z2);x7=x3+.5*(x4-x3);y7=y3+.5*(y4-y3);z7=z3+.5*(z4-z3);
  243. x=x7+.5*(x6-x7);y=y7+.5*(y6-y7);z=z7+.5*(z6-z7);sx=d*x/z;sy=d*y/z;
  244. window();sx5=sx;sy5=sy;return;}
  245.  
  246. /* ----------------------------------------------------------------------- */
  247. /* SUBROUTINE: CALCULATE SIN,COS FACTORS */
  248.  
  249. void rotation(void){
  250. sr1=sin(r1);sr2=sin(r2);sr3=sin(r3);cr1=cos(r1);cr2=cos(r2);
  251. cr3=cos(r3);return;}
  252.  
  253. /* ----------------------------------------------------------------------- */
  254. /* SUBROUTINE: STANDARD 3D FORMULAS */
  255. /* Pass: x,y,z cartesian world coordinates.
  256.    Returns: sx,sy cartesian display coordinates.
  257.           x,y,z catesian view coordinates */
  258.  
  259. void calc_3d(void){
  260. x=(-1)*x;xa=cr1*x-sr1*z;za=sr1*x+cr1*z;x=cr2*xa+sr2*y;
  261. ya=cr2*y-sr2*xa;z=cr3*za-sr3*ya;y=sr3*za+cr3*ya;x=x+mx;y=y+my;
  262. z=z+mz;sx=d*x/z;sy=d*y/z;return;}
  263.  
  264. /* ----------------------------------------------------------------------- */
  265. /* HIDDEN SURFACE VISIBILTY TEST */
  266. void visibility_test(void){
  267. sp1=x1*(y2*z3-y3*z2);sp1=(-1)*sp1;sp2=x2*(y3*z1-y01*z3);
  268. sp3=x3*(y01*z2-y2*z1);sp=sp1-sp2-sp3;return;}
  269.  
  270. /* ----------------------------------------------------------------------- */
  271. /* SUBROUTINE: DRAW 4-SIDED SOLID POLYGON IN 3D SPACE */
  272.  
  273. void draw_poly(void){
  274. setlinestyle(USERBIT_LINE,0xffff,NORM_WIDTH);
  275. setfillstyle(SOLID_FILL,solid_clr);
  276. setcolor(edge_clr);
  277.  
  278. polary[0][0]=sx1;polary[0][1]=sy1;polary[1][0]=sx2;polary[1][1]=sy2;
  279. polary[2][0]=sx3;polary[2][1]=sy3;polary[3][0]=sx4;polary[3][1]=sy4;
  280.  
  281. fillpoly (4,(int far*) polary);
  282. return;
  283. }
  284.  
  285. /* ----------------------------------------------------------------------- */
  286. /* SUBROUTINES: CALCULATE ILLUMINATION LEVEL */
  287.  
  288. void illumination(void){
  289. xu=x2-x1;yu=y2-y01;zu=z2-z1;                                        /* vector from vertex 1 to vertex 2 */
  290. xv=x3-x1;yv=y3-y01;zv=z3-z1;                                        /* vector from vertex 1 to vertex 3 */
  291. xn=(yu*zv)-(zu*yv);y0n=(zu*xv)-(xu*zv);
  292.     zn=(xu*yv)-(yu*xv);                                                /* surface perpendicular vector */
  293. y0n=y0n*(-1);zn=zn*(-1);                                            /* convert to cartesian system */
  294. v1=(xn*xn)+(y0n*y0n)+(zn*zn);
  295. v2=sqrt(v1);                                                            /* magnitude of surface perpendicular vector */
  296. v3=1/v2;                                                                    /* ratio of magnitude to length of unit vector */
  297. xw=v3*xn;yw=v3*y0n;zw=v3*zn;                                        /* surface perpendicular to unit vector */
  298. v4=(xw*xx1)+(yw*yy1)+(zw*zz1);                                    /* illumination factor 0 to 1 */
  299. v4=v4*v6;                                                                /* expand illumination range from base 0 */
  300. v7=v4;                                                                    /* convert illumination range to integer */
  301. v5=v7+1;                                                                    /* illumination range from base 1 */
  302. return;
  303. }
  304.  
  305. /* ----------------------------------------------------------------------- */
  306. /* SUBROUTINE: ILLUMINATION MATRIX */
  307.  
  308. void shade(void){
  309. switch (v5){
  310.     case 1:setfillpattern(fill_6,NORM_HUE);CC6=0x1010;values();return;
  311.     case 2:setfillpattern(fill_6,NORM_HUE);CC6=0x1010;values();return;
  312.     case 3:setfillpattern(fill_6,NORM_HUE);CC6=0x1010;values();return;
  313.     case 4:setfillpattern(fill_12,NORM_HUE);CC6=0x2020;values();return;
  314.     case 5:setfillpattern(fill_25,NORM_HUE);CC6=0x2222;values();return;
  315.     case 6:setfillpattern(fill_37,NORM_HUE);CC6=0xaaaa;values();return;
  316.     case 7:setfillpattern(fill_50,NORM_HUE);CC6=0xaaaa;values();return;
  317.     case 8:setfillpattern(fill_62,NORM_HUE);CC6=0xaaaa;values();return;
  318.     case 9:setfillpattern(fill_75,NORM_HUE);CC6=0xbbbb;values();return;
  319.     case 10:setfillpattern(fill_87,NORM_HUE);CC6=0xdddd;values();return;
  320.     case 11:setfillpattern(fill_93,NORM_HUE);CC6=0xefef;values();return;
  321.     case 12:setfillpattern(fill_100,NORM_HUE);CC6=0xffff;values();return;
  322.     defualt:setfillpattern(fill_6,NORM_HUE);CC6=0x1010;values();}
  323. return;}
  324.  
  325. /* ----------------------------------------------------------------------- */
  326. /* LOCAL SUBROUTINE: prep fill and set dithering variables */
  327. void values(void){
  328. floodfill(sx5,sy5,edge_clr);CC4=BASE_CLR;CC5=NORM_HUE;return;}
  329.  
  330. /* ----------------------------------------------------------------------- */
  331. /* SUBROUTINE: APPLY DITHERING */
  332.  
  333. void dither(void){
  334. setlinestyle(USERBIT_LINE,0xffff,NORM_WIDTH);setcolor(CC4);
  335. moveto (sx1,sy1);lineto(sx2,sy2);lineto(sx3,sy3);
  336. lineto(sx4,sy4);lineto(sx1,sy1);
  337. setlinestyle(USERBIT_LINE,CC6,NORM_WIDTH);setcolor(CC5);
  338. moveto(sx1,sy1);lineto(sx2,sy2);lineto(sx3,sy3);
  339. lineto(sx4,sy4);lineto(sx1,sy1);
  340. return;
  341. }
  342. /* ----------------------------------------------------------------------- */
  343. /* SUBROUTINE: MAP CARTESIAN COORDS TO PHYSICAL SCREEN COORDS */
  344.  
  345. void window(void){
  346. sx=sx+399;sy=sy+299;rx=screen_x/799;ry=screen_y/599;sx=sx*rx;
  347. sy=sy*ry;return;}
  348.  
  349. /* ----------------------------------------------------------------------- */
  350. /* SUBROUTINE: CHACK THE KEYBOARD BUFFER */
  351. void keyboard(void){
  352. if (bioskey(1)==0) return; else quit_pgm();}
  353.  
  354. /* ----------------------------------------------------------------------- */
  355. /* SUBROUTINE: GRACEFUL EXIT FROM PROGRAM */
  356.  
  357. void quit_pgm(void){
  358. cleardevice();restorecrtmode();exit(0);}
  359.  
  360. /* ----------------------------------------------------------------------- */
  361. /* SUBROUTINE: VGA/EGA/MCGA/CGA COMPATIBILITY MODULE */
  362.  
  363. void graphics_setup(void){
  364. int graphics_adapter,graphics_mode;
  365. detectgraph(&graphics_adapter,&graphics_mode);
  366. if (graphics_adapter==VGA) goto VGA_mode;
  367. if (graphics_mode==EGAHI) goto EGA_ECD_mode;
  368. if (graphics_mode==EGALO) goto EGA_SCD_mode;
  369. if (graphics_adapter==CGA) goto abort_message;
  370. if (graphics_adapter==MCGA) goto abort_message;
  371. goto abort_message;
  372.  
  373. VGA_mode:
  374. graphics_adapter=VGA;graphics_mode=VGAHI;
  375. initgraph(&graphics_adapter,&graphics_mode,"");
  376. x_res=640;y_res=480;mode_flag=1;
  377.         maxx=639;minx=0;maxy=479;miny=0;screen_x=639;screen_y=479;
  378.         setcolor(7);moveto(0,472);
  379.           outtext("Revisions by A. Helder");
  380.         moveto(472,472);
  381.         outtext("Press any key to quit");
  382.         moveto(160,0);
  383.           outtext("USING C TO GENERATE A 3D SHADED SPHERE");
  384.         return;
  385.  
  386. EGA_ECD_mode:
  387. graphics_adapter=EGA;graphics_mode=EGAHI;
  388. initgraph(&graphics_adapter,&graphics_mode,"");
  389. x_res=640;y_res=350;mode_flag=2;
  390.         maxx=639;minx=0;maxy=349;miny=0;screen_x=639;screen_y=349;
  391.         setcolor(7);moveto(0,342);
  392.           outtext("Revisions by A. Helder");
  393.         moveto(472,342);
  394.         outtext ("Press any key to quit");
  395.         moveto(160,0);
  396.           outtext("USING C TO GENERATE A 3D SHADED SPHERE");
  397.         return;
  398.  
  399. EGA_SCD_mode:
  400. graphics_adapter=EGA;graphics_mode=EGALO;
  401. initgraph(&graphics_adapter,&graphics_mode,"");
  402. x_res=640;y_res=200;mode_flag=3;
  403.         maxx=639;minx=0;maxy=199;miny=0;screen_x=639;screen_y=199;
  404.         setcolor(7);moveto(0,192);
  405.           outtext("Revisions by A. Helder");
  406.         moveto(472,192);
  407.         outtext("PRESS ANY KEY TO QUIT");
  408.         moveto(160,0);
  409.           outtext("USING C TO GENERATE A 3D SHADED SPHERE");
  410.         return;
  411.  
  412. abort_message:
  413. printf("\n\nUnable to proceed - Requires VGA,EGA adapter");
  414. printf("\nWith appropriate monitor");
  415. exit(0);
  416. }
  417.  
  418. /* ----------------------------------------------------------------------- */
  419. /* SUBROUTINE: MAP 640*480 TEMPLATE TO 2D SCREEN */
  420. void coords(void)
  421. {
  422. sx=sx*(x_res/640);sy=sy*(y_res/480);return;
  423. }
  424.  
  425. /* ----------------------------------------------------------------------- */
  426. /* SUBROUTINE: COPYRIGHT NOTICE */
  427.  
  428. int copyright[][3]={0x7c00,0x0000,0x0000,0x8231,
  429. 0x819c,0x645e,0xba4a,0x4252,0x96d0,0xa231,0x8252,0x955e,0xba4a,
  430. 0x43d2,0xf442,0x8231,0x825c,0x945e,0x7c00,0x0000,0x0000};
  431.  
  432. void notice(int x, int y){
  433. int a,b,c; int t1=0;
  434.  
  435. for (t1=0;t1<=6;t1++)
  436.     {
  437.     a=copyright[t1][0];b=copyright[t1][1];
  438.     c=copyright[t1][2];
  439.     setlinestyle(USERBIT_LINE,a,NORM_WIDTH);
  440.     moveto(x,y);lineto(x+15,y);
  441.     setlinestyle(USERBIT_LINE,b,NORM_WIDTH);
  442.     moveto(x+16,y);lineto(x+31,y);
  443.     setlinestyle(USERBIT_LINE,c,NORM_WIDTH);
  444.     moveto(x+32,y);lineto(x+47,y);y++;
  445.     };
  446. setlinestyle(USERBIT_LINE,0xFFFF,NORM_WIDTH);
  447. return;}
  448.  
  449.