home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / screen / sdark15c.lha / programmer.lha / prog / line.dark.c < prev    next >
C/C++ Source or Header  |  1993-03-21  |  5KB  |  227 lines

  1. /* Fichier line.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 <intuition/intuition.h>
  8. #include <graphics/gfx.h>
  9. #include <graphics/gfxbase.h>
  10. #include <graphics/gfxmacros.h>
  11. #include <graphics/rastport.h>
  12. #include <libraries/gadtools.h>
  13. #include <graphics/displayinfo.h>
  14. #include <graphics/gfx.h>
  15. /*
  16. #include <clib/exec_protos.h>
  17. #include <clib/intuition_protos.h>
  18. #include <clib/gadtools_protos.h>
  19. */
  20. #include    "/includes/struct.h"
  21. #include     "/includes/tom_gadget.h"
  22.  
  23. /***************************************************************************/
  24.  
  25. extern    struct my_data    *p_info;
  26. extern    struct    appel_proc    *p_data_proc;
  27. extern    struct    GfxBase    *GfxBase;
  28. struct    RastPort    *rp,*rps;
  29. struct    Screen    *s;
  30. int    width,height;
  31.  
  32. UBYTE         *TypeLabels[] = {
  33.     "Line 1",
  34.     "Line 2",
  35.     "Squares",
  36.     "Random",
  37.     0l };
  38.  
  39. #define reg register
  40. extern    void __asm MultiPlot(reg __a0 struct Screen *,reg __d0 WORD, reg __d1 WORD,reg __d2 WORD);
  41.  
  42. char    p_ver[]=" $VER: Line v1.1 (28/02/93)";
  43.  
  44. char    *p_text_info="\n   Line V1.1\n Your current screen will slowly\ndisappear...\n 3 kinds of disparitions are availaible:\n  - line1 and 2 are line based effect,\n  - Squares will draw plenty of little\n    squares...\n\nby T.Landspurg\n";
  45.  
  46. struct tom_gadget my_gadg[]={
  47.     {"Type",    MX,    139,13,17,40,0, 0,0,0,(char *)TypeLabels},
  48.     {0,        END_LISTE,  0,  0,   0, 0, 0,0,0,0,0}
  49. };
  50.  
  51. /***************************************************************************/
  52.  
  53. void    effet1()
  54. {
  55.     int    i;
  56.  
  57.     SetAPen(rp,0);
  58.     for(i=0;(i<height-1)&&(tst_end()==FALSE);i+=2){
  59.         WaitTOF();
  60.         Move(rp,0,i);
  61.         Draw(rp,width-1,height-i-1);
  62.  
  63.         Move(rp,width-1,i);
  64.         Draw(rp,0,height-i-1);
  65.     }
  66.     for(i=0;(i<width-1)&&(tst_end()==FALSE);i+=2){
  67.         WaitTOF();
  68.         Move(rp,i,0);
  69.         Draw(rp,width-i-1,height-1);
  70.  
  71.         Move(rp,width-i-1,0);
  72.         Draw(rp,i,height-1);
  73.     }
  74. }
  75.  
  76. /***************************************************************************/
  77.  
  78. void    efface(dec)
  79. int    dec;
  80. {
  81.     int    i;
  82.     SetAPen(rp,0);
  83.     for(i=dec;(i<height-1)&&(tst_end()==FALSE);i+=4){
  84.         Move(rp,width/2,height/2);
  85.         Draw(rp,0,i);
  86.     }
  87.     for(i=dec;(i<width-1)&&(tst_end()==FALSE);i+=4){
  88.         Move(rp,width/2,height/2);
  89.         Draw(rp,i,height-1);
  90.     }
  91.     for(i=dec;(i<height-1)&&(tst_end()==FALSE);i+=4){
  92.         Move(rp,width/2,height/2);
  93.         Draw(rp,width-1,height-i-1);
  94.     }
  95.     for(i=dec;(i<width-1)&&(tst_end()==FALSE);i+=4){
  96.         Move(rp,width/2,height/2);
  97.         Draw(rp,width-i-1,0);
  98.     }
  99. }
  100. /**************************************************************** effet2() **/
  101.  
  102. void    effet2()
  103. {
  104.     int    i;
  105.  
  106.     for(i=0;i<4;i++){
  107.         efface(i);
  108.     }
  109. }
  110.  
  111. /************************************************************ effet_square() **/
  112.  
  113. void    effet_square()
  114. {
  115.     int    i;
  116.     int    j;
  117.     int    haut,bas,droite,gauche;
  118.     int    tx,ty;
  119.     int    dx,dy;        /* Direction */
  120.     int    px,py;        /* Position de depart */
  121.     tx=16;
  122.     ty=16;
  123.     haut=ty-1;
  124.     bas=0;
  125.     droite=tx-1;
  126.     gauche=0;
  127.     SetAPen(rp,0);
  128.     
  129.     dx=1;        /* On commence par aller a droite */
  130.     dy=0;
  131.  
  132.     px=0;
  133.     py=0;
  134.     do{
  135.         WaitTOF();
  136.         for(i=0;(i<=height/ty)&&(tst_end()==FALSE);i++){
  137.             for(j=0;(j<=width/tx)&&(tst_end()==FALSE);j++){
  138.                 MultiPlot(s,(WORD)(px+j*tx),(WORD)(py+i*ty),0);
  139.             }
  140.         }
  141.         px+=dx;
  142.         py+=dy;
  143.         if(dx!=0){
  144.             if((px==droite)&&(dx==1)){
  145.                 bas++;
  146.                 dx=0;
  147.                 dy=1;    /* arrive a droite, on va en bas */
  148.             }
  149.             if((px==gauche)&&(dx==-1)){
  150.                 haut--;
  151.                 dy=-1;
  152.                 dx=0;
  153.             }
  154.         }else {
  155.             if((py==haut)&&(dy==1)){
  156.                 droite--;
  157.                 dx=-1;    /* arrive a droite, on va en bas */
  158.                 dy=0;
  159.             }
  160.             if((py==bas)&&(dy==-1)){
  161.                 gauche++;
  162.                 dy=0;
  163.                 dx=1;
  164.             }
  165.         }
  166.     }while((bas!=haut+1)&&(droite+1!=gauche)&&(tst_end()==FALSE));
  167.     SetRast(rp,0);
  168. }
  169.  
  170. /***************************************************************************/
  171.  
  172. void    __saveds    dark()
  173. {
  174.  int    i,color,cr,cg,cb,cr2,cg2,cb2,num;
  175.  
  176.  rp=p_data_proc->rp;
  177.  rps=p_data_proc->rps;
  178.  s=p_data_proc->s;
  179.  width=p_data_proc->width;
  180.  height=p_data_proc->height;
  181.  
  182.  if(s!=0){
  183.     FreeSprite (0);
  184.     GfxBase->SpriteReserved|=1;
  185.     if(my_gadg[0].value==3){
  186.         num=rand()%3;
  187.     }else{
  188.         num=my_gadg[0].value;
  189.     }
  190.     switch(num){
  191.         case 0:effet1();
  192.             break;
  193.         case 1:effet2();
  194.             break;
  195.         case 2:effet_square();
  196.             break;
  197.     }
  198.  
  199.     color=GetRGB4(s->ViewPort.ColorMap,0);
  200.     cr=(color&0xf00)>>8;
  201.     cg=(color&0xf0)>>4;
  202.     cb=color&0xf;
  203.     for(i=16;(i!=0)&&(tst_end()==FALSE);i--){
  204.         WaitTOF();
  205.         cr2=(cr*i)>>4;
  206.         cg2=(cg*i)>>4;
  207.         cb2=(cb*i)>>4;
  208.         SetRGB4(&(s->ViewPort),0,cr2,cg2,cb2);
  209.     }
  210.   }
  211.   wait_end();
  212. }
  213.  
  214. /***************************************************************************/
  215.  
  216. void    proc_init()
  217. {
  218.     p_data_proc->type_screen=SCR_GIVEN;
  219. }
  220. void    proc_save()
  221. {
  222. }
  223. void    proc_end()
  224. {
  225. }
  226.  
  227.