home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / commodities / superdark / blankers / plasam_cycle.dark.c < prev    next >
C/C++ Source or Header  |  1992-12-16  |  3KB  |  168 lines

  1.  /* Fichier plasma_cycle.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/gfxmacros.h>
  12. #include    <graphics/rastport.h>
  13. #include    <clib/exec_protos.h>
  14. #include    <clib/intuition_protos.h>
  15. #include    "bug.c"
  16. #include    "struct.h"
  17. #include    "tom_gadget.h"
  18.  
  19. extern    struct    RastPort    *rp;
  20. extern    struct    Screen    *s;
  21. extern    struct    appel_proc    *p_data_proc;
  22.  
  23. #define    WIDTH    320
  24. #define    HEIGHT    256
  25.  
  26. char    *p_text_info="Effet 'Plasma_Cycle'\nPar T.Landspurg";
  27.  
  28. #define reg register
  29. extern    void __asm MultiPlot(reg __a0 struct Screen *,reg __d0 WORD, reg __d1 WORD,reg __d2 WORD);
  30.  
  31. struct NewScreen    Screen = {
  32.     0, 0, WIDTH,  HEIGHT, 4, 0,0, 0, CUSTOMSCREEN, NULL, NULL ,NULL, NULL};
  33.  
  34. UWORD  ScreenColors[] = {
  35.     0x000,
  36.     0xF00,
  37.     0xF30,
  38.     0xF50,
  39.     0xF70,
  40.     0xF90,
  41.     0xFA0,
  42.     0xFB0,
  43.     0xFC0,
  44.     0xFD0,
  45.     0xFE0,
  46.     0xFF0,
  47.     0xBF0,
  48.     0x8F0,
  49.     0x7D0,
  50.     0x5B0,
  51.     0x000,
  52.     0x490,
  53.     0x360,
  54.     0x340,
  55.     0x444,
  56.     0x555,
  57.     0x666,
  58.     0x777,
  59.     0x888,
  60.     0x999,
  61.     0xAAA,
  62.     0xBBB,
  63.     0xCCC,
  64.     0xDDD,
  65.     0xEEE,
  66.     0xFFF,
  67.     0x000 };
  68.  
  69. #define    MAX_LEVEL    8
  70.  
  71. struct tom_gadget my_gadg[]={
  72.     {"_Level",SLIDER,    125,14,139,9,1, 1,MAX_LEVEL,0,0},
  73.     {0,        END_LISTE,  0,  0,   0, 0, 0,0,0,0,0}
  74. };
  75.  
  76.  
  77. UBYTE    t[1<<MAX_LEVEL][1<<MAX_LEVEL];
  78.  
  79. unsigned    int    seed;
  80.  
  81. void    my_text(rp,x,y,p_c)
  82. struct    RastPort    *rp;
  83. int    x,y;
  84. char    *p_c;
  85. {
  86.     if(rp!=0){
  87.         Move(rp,x,y);
  88.         Text(rp,p_c,strlen(p_c));
  89.     }
  90. }
  91.  
  92. unsigned        int     my_rand()
  93. {
  94.         
  95.         seed=25173*seed+138490;
  96.         return(seed);
  97. }
  98.  
  99. void    moyenne(int x1,int y1,int x2,int y2,int level)
  100. {
  101.     int    deltax,deltay,moyenne;
  102.     deltax=(x2-x1)/2;
  103.     deltay=(y2-y1)/2;
  104.     moyenne=(t[x1][y1]+t[x2][y2])/2;
  105.     alt=rand()%(level*10)+moyenne;
  106.     t[x+deltax][y+deltay]=alt;
  107.     MultiPlot(s,(WORD)(x+deltax),(WORD)(y+deltay),alt);
  108. }
  109.  
  110. void    calcul(int x,int y,int pas)
  111. {
  112.     pas=pas/2;
  113.     if(pas!=pas_min){
  114.         if(x==0)moyenne(x,y,x+pas,y,level);
  115.         if(y==0)moyenne(x,y,x,y+pas,level);
  116.         moyenne(x,y,x+pas,y+pas,level);
  117.         moyenne(x+pas,y,x+pas,y+pas,level);
  118.         moyenne(x,y+pas,x+pas,y+pas,level);
  119.  
  120.         calcul(x,y,pas);
  121.         calcul(x+pas,y,pas);
  122.         calcul(x,y+pas,pas);
  123.         calcul(x+pas,y+pas,pas);
  124.     }
  125.  
  126. }
  127.  
  128. /********************************************************** dark ***/
  129.  
  130. void    __saveds    dark()
  131. {
  132.     int    d,i;
  133.  
  134.         if ( NOT( s = OpenScreen(&Screen)))
  135.         return;
  136.  
  137.     rp = &(s->RastPort);
  138.     d=1<<(s->BitMap.Depth);
  139.     LoadRGB4(&s->ViewPort,ScreenColors,d);
  140.  
  141.     SetRast(rp,0);
  142.  
  143.     for(i=0;i<MAX_LEVEL;i++){
  144.         for(j=0;j<MAX_LEVEL;j++){
  145.             t[i][j]=0;
  146.         }
  147.     }
  148.     pas_min=1;
  149.     calcul(0,0,1<<MAX_LEVEL);
  150.  
  151.     wait_end();
  152.  
  153.     CloseScreen(s);
  154. }
  155.  
  156. void    proc_init()
  157. {
  158.         seed=VBeamPos();
  159. }
  160. void    proc_save()
  161. {
  162. }
  163.  
  164. void    proc_end()
  165. {
  166. }
  167.  
  168.