home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 179.lha / ClipLines / start.c < prev   
Encoding:
C/C++ Source or Header  |  1988-04-28  |  6.0 KB  |  346 lines

  1.  
  2. /******************************************************************************
  3. *
  4. *   start_lines.c --- Copyright 1988 Commodore-Amiga, Inc.
  5. *
  6. *    Source Control
  7. *    --------------
  8. *    $Header: start_lines.c,v 36.0 88/05/18 20:18:49 bart Exp $
  9. *
  10. *    $Locker: bart $
  11. *
  12. *    $Log:    start_lines.c,v $
  13. *   Revision 36.0  88/05/18  20:18:49  bart
  14. *   added to rcs for updating
  15. *   
  16. *
  17. ******************************************************************************/
  18.  
  19. #define MAXPOINTS    50
  20. #define TMPRASWIDTH    640
  21. #define    TMPRASHEIGHT 200
  22.  
  23. #define NTSC_HEIGHT 200
  24. #define PAL_HEIGHT 256
  25.  
  26. #define NTSC_MAX_HEIGHT 200
  27. #define PAL_MAX_HEIGHT 256
  28.  
  29. #include <exec/types.h>
  30. #include <exec/nodes.h>
  31. #include <exec/lists.h>
  32. #include <graphics/gfx.h>
  33. #include <graphics/gfxbase.h>
  34. #include <graphics/clip.h>
  35. #include <graphics/rastport.h>
  36. #include <graphics/view.h>
  37. #include <graphics/text.h>
  38. #include <graphics/gfxmacros.h>
  39.  
  40. #include <graphics/layers.h>
  41. #include <intuition/intuition.h>
  42.  
  43. /*#define DEBUG*/
  44. /*#define KPRINTF*/
  45. /*#define NEWSCREEN*/
  46.  
  47. #ifdef KPRINTF
  48. #define printf kprintf
  49. #endif
  50.  
  51. #define TXHEIGHT 8
  52.  
  53. #define GADGETS
  54. #define RBG_ID 0x0001
  55. #define BBG_ID 0x0002
  56.  
  57. struct Image my_knob_image;
  58.  
  59. struct PropInfo my_knob =
  60. {
  61.     FREEVERT | AUTOKNOB,
  62.     0,
  63.     0,
  64.     MAXBODY,
  65.     MAXBODY/8
  66. };
  67.  
  68. struct Gadget my_gadget =
  69. {
  70.     NULL,
  71.     -16,0,16,-18,
  72.     GRELHEIGHT|GRELRIGHT,
  73.     GADGIMMEDIATE|RELVERIFY,
  74.     PROPGADGET,
  75.     &my_knob_image,
  76.     NULL,
  77.     NULL,
  78.     0,
  79.     &my_knob,
  80.     RBG_ID,
  81.     NULL
  82. };
  83.  
  84. struct Image bb_knob_image;
  85.  
  86. struct PropInfo bb_knob =
  87. {
  88.     FREEHORIZ | AUTOKNOB,
  89.     0,
  90.     0,
  91.     MAXBODY/8,
  92.     MAXBODY
  93. };
  94.  
  95. struct Gadget bb_gadget =
  96. {
  97.     &my_gadget,
  98.     0,-8,-16,9,
  99.     GRELWIDTH|GRELBOTTOM,
  100.     GADGIMMEDIATE|RELVERIFY|BOTTOMBORDER,
  101.     GZZGADGET|PROPGADGET,
  102.     &bb_knob_image,
  103.     NULL,
  104.     NULL,
  105.     0,
  106.     &bb_knob,
  107.     BBG_ID,
  108.     NULL
  109. };
  110.  
  111. struct Image rb_knob_image;
  112.  
  113. struct PropInfo rb_knob =
  114. {
  115.     FREEVERT | AUTOKNOB,
  116.     0,
  117.     0,
  118.     MAXBODY,
  119.     MAXBODY/8
  120. };
  121.  
  122. struct Gadget rb_gadget =
  123. {
  124.     &bb_gadget,
  125.     -15,10,16,-18,
  126.     GRELHEIGHT|GRELRIGHT,
  127.     GADGIMMEDIATE|RELVERIFY|RIGHTBORDER,
  128.     GZZGADGET|PROPGADGET,
  129.     &rb_knob_image,
  130.     NULL,
  131.     NULL,
  132.     0,
  133.     &rb_knob,
  134.     RBG_ID,
  135.     NULL
  136. };
  137.  
  138. struct Gadget *vgadget_ptr = &rb_gadget;
  139. struct Gadget *hgadget_ptr = &bb_gadget;
  140.  
  141. struct TextAttr TestFont =
  142.     {
  143.     "topaz.font",
  144.     TXHEIGHT,
  145.     0,
  146.     0,
  147.     };
  148.  
  149. long GfxBase = 0;
  150. long LayersBase = 0;
  151. long IntuitionBase = 0;
  152.  
  153. #define IS_PAL (((struct GfxBase *)GfxBase)->DisplayFlags & PAL)
  154.  
  155. struct    AreaInfo areainfo;
  156. UWORD    areafill[(MAXPOINTS/2)*5];
  157.  
  158. startgfx(x,y,height, width, n_bit_Planess, palette, gfxproc,s,flags,sbitmap)
  159. WORD x,y;
  160. WORD height, width, n_bit_Planess;
  161. UWORD *palette;
  162. int (*gfxproc)();
  163. UBYTE *s;
  164. struct BitMap *sbitmap;        /* optional parameter */
  165. {
  166.     struct Window *window;
  167.     struct RastPort *w=0;
  168.     register i, j;
  169.     int idcmp;
  170.     struct NewWindow nw;
  171.     UBYTE    *ras;
  172.  
  173.     GfxBase = OpenLibrary("graphics.library",32);
  174.     if (GfxBase == NULL)
  175.     {
  176. #ifdef DEBUG
  177.         printf("no graphics library\n");
  178. #endif
  179.         exit();
  180.     }
  181.  
  182.     LayersBase = OpenLibrary("layers.library",32);
  183.     if (LayersBase == NULL)
  184.     {
  185. #ifdef DEBUG
  186.         printf("no layers library\n");
  187. #endif
  188.         exit();
  189.     }
  190.  
  191.     IntuitionBase = OpenLibrary("intuition.library",32);
  192.     if (IntuitionBase == NULL)
  193.     {
  194. #ifdef DEBUG
  195.         printf("no intuition library\n");
  196. #endif
  197.         exit();
  198.     }
  199.  
  200.     /* intuition direct comunication message port */
  201.     idcmp = CLOSEWINDOW|REFRESHWINDOW|GADGETUP|GADGETDOWN|SIZEVERIFY|NEWSIZE;
  202.     nw.LeftEdge = x;
  203.     nw.TopEdge = y;
  204.     nw.Width = width;
  205.     nw.Height = height;
  206.     nw.DetailPen = -1;
  207.     nw.BlockPen = -1;
  208.     nw.IDCMPFlags = idcmp;
  209.     nw.Flags = WINDOWDEPTH|WINDOWSIZING|WINDOWDRAG|WINDOWCLOSE|flags;
  210.  
  211. #ifdef GADGETS
  212.     nw.FirstGadget = &rb_gadget;
  213. #endif
  214.  
  215.     nw.CheckMark = 0;
  216.     nw.Title = s;
  217.     nw.Screen = 0;
  218.     nw.BitMap = sbitmap;
  219.     nw.MinWidth = 80;
  220.     nw.MinHeight = 16;
  221.     nw.MaxWidth = 640;
  222.     nw.MaxHeight = ~0; /* V32 and above */
  223.     nw.Type = WBENCHSCREEN;
  224.     
  225. #ifdef DEBUG
  226.     printf("calling open window\n sbitmap=%lx\n",nw.BitMap);
  227. #endif
  228.     window = (struct Window *)OpenWindow(&nw);
  229.  
  230.     /* bart - 11.21.85 */
  231.     if (!window) return;
  232.  
  233. #ifdef DEBUG
  234.     printf("after call to open window\n");
  235. #endif
  236.  
  237.     /* bart - 11.13.85 */
  238.     SetWindowTitles(window,-1,s);
  239.  
  240.     w = window->RPort;
  241.     w->Layer->Window = window;
  242.  
  243.     InitArea(&areainfo,areafill,MAXPOINTS);
  244.     w->AreaInfo = &areainfo;
  245.  
  246.     (*gfxproc)(&window->WScreen->ViewPort,w);
  247.  
  248.     CloseWindow(window);
  249.  
  250.     /* restart workbench screen */
  251.  
  252. #ifdef NEWSCREEN
  253.         CloseScreen(ActiveGroup.ActiveScreen);
  254.         myscreen = OpenScreen(0,0,640,200,2,HIRES,WBENCHSCREEN,&TestFont);
  255. #endif
  256.  
  257. }
  258.  
  259. Get_RWidth(rp)
  260. struct RastPort *rp;
  261. {
  262.     int width;
  263.     struct Layer *cw;
  264.     if ( (cw = rp->Layer) == 0) width = rp->BitMap->BytesPerRow<<3;
  265.     else
  266.         if (cw->SuperBitMap == 0) width = cw->bounds.MaxX-cw->bounds.MinX + 1;
  267.     else width = cw->SuperBitMap->BytesPerRow<<3;
  268.     if (cw)
  269.     {
  270.         struct Window *window;
  271.         window = cw->Window;
  272.         if (window)
  273.         {
  274.             if ((window->Flags & GIMMEZEROZERO) == 0)
  275.                 width -= window->BorderLeft+window->BorderRight;
  276.         }
  277.     }
  278.     return (width);
  279. }
  280.  
  281. Get_RHeight(rp)
  282. struct RastPort *rp;
  283. {
  284.     int height;
  285.     struct Layer *cw;
  286.     if ( (cw = rp->Layer) == 0) height = rp->BitMap->Rows;
  287.     else
  288.         if (cw->SuperBitMap == 0) height = cw->bounds.MaxY-cw->bounds.MinY + 1;
  289.     else height =  cw->SuperBitMap->Rows;
  290.     if (cw)
  291.     {
  292.         struct Window *window;
  293.         if (window = cw->Window)
  294.             if ((window->Flags & GIMMEZEROZERO) == 0)
  295.                 height -= window->BorderTop+window->BorderBottom;
  296.     }
  297.     return(height);
  298. }
  299.  
  300. struct TmpRas *gettmpras(t,w,h)
  301. struct TmpRas *t;
  302. int w,h;
  303. {
  304.     char *ras;
  305.     ras = (char *)AllocRaster(w,h);
  306.     if (ras == 0)
  307.     {
  308. #ifdef DEBUG
  309.         printf("no ram for tmpras\n");
  310. #endif
  311.         exit(1);
  312.     }
  313.     return((struct TmpRas *)InitTmpRas(t,ras,RASSIZE(w,h)));
  314. }
  315.  
  316. Get_xoffset(rp)
  317. struct RastPort *rp;
  318. {
  319.     struct Layer *l;
  320.     struct Window *window;
  321.     l = rp->Layer;
  322.     if (l != 0)
  323.     {
  324.         window = l->Window;
  325.         if (window->Flags & GIMMEZEROZERO)    return(0);
  326.         else    return(window->BorderLeft);
  327.     }
  328.     else    return(0);
  329. }
  330.  
  331. Get_yoffset(rp)
  332. struct RastPort *rp;
  333. {
  334.     struct Layer *l;
  335.     struct Window *window;
  336.     l = rp->Layer;
  337.     if (l != 0)
  338.     {
  339.         window = l->Window;
  340.         if (window->Flags & GIMMEZEROZERO)    return(0);
  341.         else    return(window->BorderTop);
  342.     }
  343.     else    return(0);
  344. }
  345.  
  346.