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

  1.   /* Fichier clock.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 <exec/memory.h>
  8. #include <intuition/intuition.h>
  9. #include <intuition/gadgetclass.h>
  10. #include <graphics/gfx.h>
  11. #include <graphics/gfxbase.h>
  12. #include <dos/dos.h>
  13. #include <graphics/gfxmacros.h>
  14. #include <graphics/rastport.h>
  15. #include <graphics/displayinfo.h>
  16. #include <clib/exec_protos.h>
  17. #include <clib/intuition_protos.h>
  18. #include <clib/dos_protos.h>
  19. #include <clib/graphics_protos.h>
  20. #include <clib/diskfont_protos.h>
  21.  
  22.  
  23. #include "/includes/struct.h"
  24. #include "/includes/tom_gadget.h"
  25.  
  26. struct Library        *DiskfontBase;
  27. extern  struct  GfxBase *GfxBase;
  28. extern    struct    appel_proc    *p_data_proc;
  29.  
  30. #define    VOID_ARG    void    __regargs
  31.  
  32. char    *p_text_info=
  33. "           Text v1.0\n"
  34. "\n"
  35. "This effect allow you to show\n"
  36. "a little text like on your screen\n"
  37. "\n"
  38. "Nothing really fantastic, but evry\n"
  39. "blanker should have this minima....\n"
  40. "\n"
  41. " @ Thomas Landspurg\n";
  42.  
  43. WORD    areabuffer[25];
  44. struct    AreaInfo    myarea;
  45. struct    TmpRas    tmpras;
  46.  
  47. struct    RastPort    *rp;
  48. struct    Screen        *s;
  49. struct    TextAttr myta={"topaz                   ",0,0,0};
  50.  
  51. UWORD    px,py,tx,ty,x,y;
  52. int    dirx,diry;
  53. #define    WIDTH    640
  54. #define    HEIGHT    256
  55.  
  56. UWORD  ScreenColors[] = {
  57.     0x000,
  58.     0xFFF,
  59.     0xFE2,
  60.     0x68B,
  61.     0xF90,
  62.     0x0F0,
  63.     0x00F,
  64.     0xF0F,
  65.     0x000 };
  66.  
  67. struct NewScreen Screen= {
  68.      0, 0, WIDTH, HEIGHT, 1,0,1,HIRES,CUSTOMSCREEN,NULL,NULL,NULL,NULL};
  69.  
  70.  
  71. #define    TAILLE_BUF    100
  72. char    buffer_text[TAILLE_BUF]="";
  73.  
  74. struct    tom_gadget    my_gadg[]={
  75.     {"T_ext",    STRING,  50, 10,250,14,0,TAILLE_BUF,0,0,buffer_text},
  76.     {"_Fonts",    FONT,    80, 25, 90,12,0,         0,0,0,(char *)&myta},
  77.     {"_Resolution",    SCREEN,  80, 40, 90,12,0,         0,0,0,0},
  78.     {"Speed_X",    SLIDER,  80, 60, 90,10,1,0,5,0,0},
  79.     {"Speed_Y",    SLIDER,  80, 80, 90,10,1,0,5,0,0},
  80.     {0,        END_LISTE,  0,  0,   0, 0, 0,0,0,0,0}};
  81.  
  82. static    short    int    centre_x,centre_y,old_x,old_y,rayon;
  83.  
  84.  
  85. VOID_ARG    init_rp(struct    RastPort *rp)
  86. {
  87.         struct TextFont *myfont;
  88.  
  89.     if(DiskfontBase){
  90.                if (myfont = OpenDiskFont(&myta))
  91.                     {
  92.                         SetFont(rp, myfont);
  93.                             SetSoftStyle(rp,   myta.ta_Style ^ myfont->tf_Style,
  94.                                       (FSF_BOLD | FSF_UNDERLINED | FSF_ITALIC));
  95.             }
  96.     }
  97. }
  98.  
  99. void    aff_texte(struct    RastPort *rp)
  100. {
  101.     int    len;
  102.     struct    TextExtent    result;
  103.  
  104.     SetAPen(rp,1);
  105.     len=strlen(my_gadg[0].p_data);
  106.     ty=myta.ta_YSize;
  107.     tx=TextLength(rp,my_gadg[0].p_data,len);
  108.     if(tx+10>s->Width){
  109.         tx=s->Width-10;
  110.         len=TextFit(rp,my_gadg[0].p_data,len,&result,NULL,1,s->Width-10,ty);
  111.         dirx=0;
  112.     }
  113.     x=(s->Width-tx)/2;
  114.     y=(s->Height-ty)/2;
  115.     Move(rp,x,y+ty);
  116.     ty+=8;
  117.     Text(rp,my_gadg[0].p_data,len);
  118.     
  119. }
  120.  
  121. void    dark()
  122. {
  123.   struct    tom_gadget *pg;
  124.  
  125.   pg=&my_gadg[2];
  126.   if((GfxBase->LibNode.lib_Version>=37)&&(pg->d3!=0)){
  127.     s=OpenScreenTags(  NULL,
  128.                SA_Width,(ULONG)pg->d1,
  129.                SA_Height,(ULONG)pg->d2,
  130.                            SA_Depth,(ULONG)pg->d3,
  131.                SA_Overscan,(ULONG)pg->value,
  132.                            SA_DisplayID,(ULONG)pg->p_data,
  133.                            SA_Quiet,TRUE,TAG_DONE);
  134. /*
  135.      width=pg->d1;
  136.      height=pg->d2;
  137. */
  138.    }else{
  139.     s=OpenScreen(&Screen);
  140.    }
  141.    if (s){
  142.  
  143.     rp = &(s->RastPort);
  144.  
  145.     SetRast(rp,0);
  146.     FreeSprite (0);
  147.     GfxBase->SpriteReserved|=1;
  148.     LoadRGB4(&s->ViewPort,ScreenColors,1<<3);
  149.  
  150.     dirx=-my_gadg[3].value;
  151.     diry=-my_gadg[4].value;
  152.     init_rp(rp);
  153.     aff_texte(rp);
  154.     while(tst_end()==FALSE){
  155.         WaitTOF();
  156.         ScrollRaster(rp,dirx,diry,x,y,x+tx,y+ty);
  157.         x-=dirx;
  158.         y-=diry;
  159.         if(x-dirx<=0){
  160.             dirx=-dirx;
  161.         }
  162.         if(y-diry<=0){
  163.             diry=-diry;
  164.         }
  165.         if(x-dirx+tx>=s->Width){
  166.             dirx=-dirx;
  167.         }
  168.         if(y-diry+ty>=s->Height){
  169.             diry=-diry;
  170.         }
  171.     }
  172.     CloseScreen(s);
  173.    }
  174. }
  175.  
  176. void    proc_init()
  177. {
  178.         DiskfontBase = OpenLibrary("diskfont.library", 37L);
  179.     p_data_proc->code_ret=DARK_WB_20;
  180. }
  181.  
  182. void    proc_save()
  183. {
  184. }
  185. void    proc_end()
  186. {
  187.     if(DiskfontBase)CloseLibrary(DiskfontBase);
  188. }
  189.  
  190.