home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / commodities / superdark / blankers / star.dark.c < prev    next >
C/C++ Source or Header  |  1993-03-10  |  4KB  |  180 lines

  1.  /* Fichier star.dark.c                */
  2. /* Module appele par le programme principal    */
  3. /* pour effectuer un effet defini..appele par    */
  4. /* loadseg                    */
  5.  
  6. #include    <exec/types.h>
  7. #include    <dos/dos.h>
  8. #include    <intuition/intuition.h>
  9. #include    <intuition/gadgetclass.h>
  10. #include    <graphics/gfx.h>
  11. #include    <graphics/gfxbase.h>
  12. #include    <graphics/gfxmacros.h>
  13. #include    <graphics/rastport.h>
  14. #include    <graphics/displayinfo.h>
  15. #include    <clib/exec_protos.h>
  16. #include    <clib/intuition_protos.h>
  17. #include    "/includes/struct.h"
  18. #include    "/includes/tom_gadget.h"
  19.  
  20. struct    RastPort    *rp;
  21. struct    Screen    *s;
  22. extern    struct    appel_proc    *p_data_proc;
  23. extern    struct    GfxBase    *GfxBase;
  24.  
  25. #define    WIDTH    640
  26. #define    HEIGHT    256
  27.  
  28. SHORT    width=WIDTH;
  29. SHORT    height=HEIGHT;
  30. SHORT    depth=2;
  31. ULONG    did;
  32.  
  33. char    *p_text_info=
  34. "Effect 'Stars'\n"
  35. "\n"
  36. "\n"
  37. "By T.Landspurg";
  38. #define    MAX_SPEED    20
  39.  
  40. #define reg register
  41. extern    void __asm MultiPlot(reg __a0 struct Screen *,reg __d0 WORD, reg __d1 WORD,reg __d2 WORD);
  42.  
  43. struct NewScreen    Screen = {
  44.     0, 0, WIDTH,  HEIGHT, 2, 0,0, HIRES, CUSTOMSCREEN, NULL, NULL ,NULL, NULL};
  45.  
  46. #define    MAX_STAR    151
  47. struct tom_gadget my_gadg[]={
  48.     {"Stars _number",SLIDER,    125,14,139,9,50, 10,MAX_STAR-1,0,0},
  49.     {"_Speed",SLIDER,    125,27,139,9,10, 2,20,0,0},
  50.     {0,        END_LISTE,  0,  0,   0, 0, 0,0,0,0,0}
  51. };
  52.  
  53. typedef    struct    pt_3d
  54. {
  55.     SHORT    x,y,z,speed;
  56. };
  57. typedef    struct    pt_2d{
  58.     SHORT    x,y;
  59. };
  60.  
  61. struct    pt_3d    tab_pt_3d[MAX_STAR];
  62. struct    pt_2d    tab_old[MAX_STAR];
  63. #define    DE    200
  64. #define    de    1000
  65.  
  66. /*************************************************** Nouvelle etoile ****/
  67.  
  68. void    new_star(p)
  69. struct    pt_3d    *p;
  70. {
  71.     p->x=1500-rand()%3000;
  72.     p->y=1000-rand()%2000;
  73.     p->z=1000+rand()%2000;
  74.     p->speed=rand()%10+my_gadg[1].value;
  75. }
  76.  
  77. /********************************************************** dark1 ***/
  78.  
  79. void    __saveds    dark()
  80. {
  81.     SHORT    d,i,x,y;
  82.  
  83.     struct    pt_3d    *p;
  84.     struct    pt_2d    *p2;
  85.  
  86.     depth=2;
  87.     width=0;
  88.     find_res((SHORT)TRUE,&depth,&width,&height,&did);
  89.  
  90.     Screen.Width=width;
  91.     Screen.Height=height;
  92.     Screen.ViewModes=did;
  93.     if(depth<2)return;
  94.  
  95.         if ( NOT( s = OpenScreen(&Screen)))
  96.         return;
  97.  
  98.     FreeSprite (0);
  99.     GfxBase->SpriteReserved|=1;
  100.     rp = &(s->RastPort);
  101.     d=1<<(s->BitMap.Depth);
  102.     for(i=0;i<d;i++){
  103.         SetRGB4(&s->ViewPort,i,(16*i)/d,(16*i)/d,(16*i)/d);
  104.     }
  105.  
  106.     SetRast(rp,0);
  107.  
  108.     for(i=0;i<my_gadg[0].value;i++){
  109.         new_star(&tab_pt_3d[i]);
  110.         tab_old[i].x=0;
  111.         tab_old[i].y=0;
  112.     }
  113.  
  114.     while(tst_end()==FALSE){
  115.         p2=tab_old;
  116.         p=tab_pt_3d;
  117.         for(i=0;i<my_gadg[0].value;i++){
  118.             x=p2->x;
  119.             y=p2->y;
  120.             if(p->z>1000){
  121.                 MultiPlot(s,(WORD)x,(WORD)y,0);
  122.             }else if(p->z>200){
  123.                 MultiPlot(s,(WORD)x,(WORD)y,0);
  124.                 MultiPlot(s,(WORD)x+1,(WORD)y,0);
  125.             }else{
  126.                 MultiPlot(s,(WORD)x,(WORD)y,0);
  127.                 MultiPlot(s,(WORD)x+1,(WORD)y,0);
  128.                 MultiPlot(s,(WORD)x,(WORD)y+1,0);
  129.                 MultiPlot(s,(WORD)x+1,(WORD)y+1,0);
  130.             }
  131.             p->z-=p->speed;
  132.             if(p->z<=-de){
  133.                 new_star(p);
  134.             }
  135.             x=width/2+(DE*p->x)/(p->z+de);
  136.             y=height/2+(DE*p->y)/(p->z+de);
  137.             if((x<0)||(x>=width)||(y<0)||(y>=height)){
  138.                 new_star(p);
  139.                 p2->x=0;
  140.                 p2->y=0;
  141.             }else{
  142.                 p2->x=x;
  143.                 p2->y=y;
  144.                 if(p->z>2000){
  145.                     MultiPlot(s,(WORD)x,(WORD)y,1);
  146.                 }else if(p->z>1500){
  147.                     MultiPlot(s,(WORD)x,(WORD)y,2);
  148.                 }else if(p->z>1000){
  149.                     MultiPlot(s,(WORD)x,(WORD)y,3);
  150.                 }else if(p->z>200){
  151.                     MultiPlot(s,(WORD)x,(WORD)y,3);
  152.                     MultiPlot(s,(WORD)x+1,(WORD)y,3);
  153.                 }else {
  154.                     MultiPlot(s,(WORD)x,(WORD)y,3);
  155.                     MultiPlot(s,(WORD)x+1,(WORD)y,3);
  156.                     MultiPlot(s,(WORD)x,(WORD)y+1,3);
  157.                     MultiPlot(s,(WORD)x+1,(WORD)y+1,3);
  158.  
  159.                 }
  160.             }
  161.             p2++;
  162.             p++;
  163.         }
  164.     }
  165.     CloseScreen(s);
  166. }
  167.  
  168. void    proc_init()
  169. {
  170.     p_data_proc->type_screen=SCR_OWN;
  171. }
  172. void    proc_save()
  173. {
  174. }
  175.  
  176. void    proc_end()
  177. {
  178. }
  179.  
  180.