home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 145.lha / BonsaiConstructionSet / trees3.h < prev   
C/C++ Source or Header  |  1986-11-21  |  6KB  |  215 lines

  1. /* trees3.h--definitions, etc with a little help from Lattice et al */
  2.  
  3. #include "exec/types.h"
  4. #include "exec/nodes.h"
  5. #include "exec/lists.h"
  6. #include "exec/ports.h"
  7. #include "exec/devices.h"
  8. #include "devices/keymap.h"
  9. #include "graphics/regions.h"
  10. #include "graphics/copper.h"
  11. #include "graphics/gels.h"
  12. #include "graphics/gfxbase.h"
  13. #include "graphics/gfx.h"
  14. #include "graphics/sprite.h"
  15. #include "graphics/clip.h"
  16. #include "graphics/view.h"
  17. #include "graphics/rastport.h"
  18. #include "graphics/layers.h"
  19. #include "devices/timer.h"
  20. #include "libraries/dos.h"
  21. #include "lattice/stdio.h"
  22. #include "lattice/math.h"
  23. #include "intuition/intuition.h"
  24. #include "hardware/dmabits.h"
  25. #include "hardware/custom.h"
  26. #include "hardware/blit.h"
  27. #include "graphics/text.h"
  28. #define NL 0
  29. long GfxBase = 0;   /* Base of graphics library */
  30. long IntuitionBase = 0;      /* Base of Intuition library */
  31. struct Window *OpenWindow();
  32. struct DateStamp now;
  33. long holdtime;
  34. static struct timerequest Time_Req;
  35. static struct MsgPort *Timer_Port = NULL, *CreatePort();
  36. struct InputEvent *Intuition();
  37. struct Screen *OpenScreen();
  38. struct TextAttr TestFont = {
  39.    "topaz.font",TOPAZ_SIXTY,FS_NORMAL,FPF_ROMFONT, /* Define text font for screen */
  40.    };
  41. USHORT class;   /* Intu event class */
  42. USHORT code;   /* Intu event code */
  43. struct Window *wd;      /* Lots of pointers for lots of things */
  44. struct RastPort *rp;
  45. struct ViewPort *vp;
  46. struct Screen *screen;
  47. #define  height 14
  48. struct SpriteImage {
  49. UWORD posctl[2];
  50. UWORD sprdata[2][height];
  51. UWORD reserved[2];
  52. };
  53.  
  54. /********************Sprite-Pointer-Defines*********************/
  55.  
  56. struct SpriteImage PointImage = {
  57.    100,100,
  58.    0x0000, 0x3ffe,
  59.    0x0000, 0x3ffe,
  60.    0x0080, 0x3ffe,
  61.    0x0080, 0x1ffc,
  62.    0x0080, 0x1ffc,
  63.    0x0080, 0x0ff8,
  64.    0x0080, 0x0ff8,
  65.    0x0000, 0x07f0,
  66.    0x0080, 0x07f0,
  67.    0x0080, 0x07f0,
  68.    0x0000, 0x03e0,
  69.    0x0000, 0x03e0,
  70.    0x0000, 0x01c0,
  71.    0x0000, 0x0080,
  72.    NULL,NULL
  73. };
  74. struct SpriteImage TreeImage = {
  75.    100,100,
  76.    0x0000, 0x0080,
  77.    0x0000, 0x01c0,
  78.    0x0000, 0x03e0,
  79.    0x0000, 0x07f0,
  80.    0x0000, 0x0ff8,
  81.    0x0000, 0x1ffc,
  82.    0x0000, 0x3ffe,
  83.    0x0000, 0x7fff,
  84.    0x01c0, 0x01c0,
  85.    0x01c0, 0x01c0,
  86.    0x01c0, 0x01c0,
  87.    0x01c0, 0x01c0,
  88.    0x01c0, 0x01c0,
  89.    0x01c0, 0x01c0,
  90.    NULL,NULL
  91. };
  92.  
  93. int MathBase;
  94. int MathTransBase;
  95. union kludge1
  96. {
  97.    FLOAT num1;
  98.    int i1;
  99. } k1;
  100. union kludge2
  101. {
  102.    FLOAT num2;
  103.    int i2;
  104. } k2;
  105. union kludge3
  106. {
  107.    FLOAT num3;
  108.    int i3;
  109. } k3;
  110. union kludge4
  111. {
  112.    FLOAT num4;
  113.    int i4;
  114. } k4;
  115. union kludge5
  116. {
  117.    FLOAT num5;
  118.    int i5;
  119. } k5;
  120. union kludge6
  121. {
  122.    FLOAT num6;
  123.    int i6;
  124. } k6;
  125. /************************ Screen Defines ***********************************/
  126.  
  127. struct NewScreen ns = {
  128.    0,0,         /* start pos.*/
  129.    320,200,5,      /* width height depth (5 bit planes) */
  130.    0,1,         /* detail pen, block pen */
  131.    0,       /* viewing mode (normal 320x200) */
  132.    CUSTOMSCREEN,      /* screen type */
  133.    &TestFont,      /* font */
  134.    NULL,      /* screen title */
  135.    NULL,
  136.    NULL,      /* gadget pointer */
  137.    };
  138.  
  139. /************************ Window Defines ***********************************/
  140.  
  141. struct NewWindow nw = {
  142.       0,0,         /* Starting corner */
  143.       320,200,      /* Width, height */
  144.       0,3,         /* detail, block pens */
  145.       CLOSEWINDOW | MENUPICK
  146.       | REFRESHWINDOW | MOUSEBUTTONS | MOUSEMOVE,         /* IDCMP flags */
  147.       SMART_REFRESH | ACTIVATE | BORDERLESS | WINDOWCLOSE
  148.       | REPORTMOUSE | GIMMEZEROZERO,
  149.                /* Window flags */
  150.       NULL,         /* Pointer to first gadget */
  151.       NULL,         /* Pointer to checkmark */
  152.       "BCS",      /* title */
  153.       NULL,         /* screen pointer */
  154.       NULL,         /* bitmap pointer */
  155.       0,0,0,0,      /* sizing limits */
  156.       CUSTOMSCREEN      /* type of screen */
  157.       };
  158. /************************ Set-Up routine ***********************************
  159. *   This function opens the Intuition and Graphics libraries, then     *
  160. *       opens up our custom screen and window, defining screen colors,     *
  161. *   size, etc...                        *
  162. ***************************************************************************/
  163. initwind()
  164. {
  165.    register int dd,n;
  166.  
  167.    GfxBase = OpenLibrary("graphics.library",0); /* Get graphics driver */
  168.    if(GfxBase == NULL)
  169.    {
  170.       printf("Can't open graphics library...\n");
  171.       exit();
  172.    }
  173.    if((MathBase=OpenLibrary("mathffp.library",0)) < 1) {
  174.       printf("n\n*** ERROR *** Can't open mathffp.library");
  175.       exit();
  176.    }
  177.    if((MathTransBase=OpenLibrary("mathtrans.library",0)) < 1) {
  178.       printf("n\n*** ERROR *** Can't open mathtrans.library");
  179.       exit();
  180.    }
  181.    IntuitionBase = OpenLibrary("intuition.library",0); /*Get Intuition*/  
  182.    if(IntuitionBase == NULL)
  183.    {
  184.       printf("Can't open intuition library...\n");
  185.       exit();
  186.    }
  187.    screen = OpenScreen(&ns); /* Open our new screen */
  188.    if(screen == NULL)
  189.    {
  190.       exit(0);
  191.    }
  192.    Timer_Port = CreatePort("Timer Port",0);
  193.    if(Timer_Port == NULL)
  194.    {
  195.       printf("Can't create timer port...\n");
  196.       exit();
  197.    }
  198.    if (OpenDevice(TIMERNAME, UNIT_VBLANK, (char *) &Time_Req,0) != NULL)
  199.    {
  200.       printf("Can't open timer device");
  201.       exit();
  202.    }
  203.    DateStamp(&now);
  204.    holdtime = now.ds_Minute + now.ds_Tick;
  205.    srand48(holdtime);   /* randomize random generator */
  206.    nw.Screen = screen;
  207.    wd = OpenWindow(&nw);      /* Open our new window */
  208.    rp = wd->RPort;         /* Get the raster port pointer */
  209.    vp = &screen->ViewPort;   /* Get the view port pointer */
  210.    SetDrMd(rp,JAM1);
  211.    for (n=0;n<=holdtime;n++)
  212.       dd=RangeRand(15);
  213. }
  214.  
  215.