home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d199 / snipdemo.lha / SnipDemo / Custom / Custom.c < prev    next >
C/C++ Source or Header  |  1989-03-31  |  5KB  |  117 lines

  1. /* standard Intuition include files */
  2.  
  3. #include<exec/types.h>
  4. #include<exec/memory.h>
  5. #include<functions.h>
  6. #include<math.h>
  7. #include<intuition/intuition.h>
  8. #include<graphics/rastport.h>
  9. #include<stdio.h>
  10.  
  11. /* Include file specifically for Snip */
  12.  
  13. #include "Snip.h"
  14.  
  15. struct Window  *Window;                /*   the display window       */
  16. char           title[30];              /*   Window title             */
  17. struct GfxBase       *GfxBase = NULL;
  18.  
  19. struct IntuitionBase *IntuitionBase;
  20. struct DMsg     *WMsg, *TMsg;
  21. struct Disp     *Disp0, *DispPW, *DispWN;
  22. struct Dat      *Dat;
  23. struct MsgPort  *WtPort, *RdPort;
  24. SHORT i;
  25. LONG   Mark;
  26. FLOAT  base;
  27.  
  28. main()
  29. {
  30. printf("testprog says hello\n");
  31. if(!(IntuitionBase=(struct IntuitionBase *)
  32.                                      OpenLibrary("intuition.library",0L)))
  33.    { printf("no intuition library\n");          /* some sort of message */
  34.    exit(0L);}                                   /* in event of failure  */
  35. if(!(WtPort = CreatePort("SnipWPort", 0L )))  /* make a message port  */
  36.    { printf("can't create Port\n");             /* some sort of message */
  37.    goto dropout;
  38.    }
  39. RdPort = FindPort("SnipRPort");               /* find Snip's port !!! */
  40. if(RdPort == 0) { printf("no RdPort found"); exit(0L);} /* can't find it */
  41. WMsg = (struct DMsg *)AllocMem( (LONG)(sizeof(struct DMsg)),
  42.         MEMF_CLEAR | MEMF_PUBLIC );
  43. if( !(WMsg) ){
  44.    printf(" no message allocated\n");
  45.    exit(0L);
  46. }
  47. WMsg->Msg.mn_Node.ln_Type = NT_MESSAGE;
  48. WMsg->Msg.mn_Node.ln_Pri  = 0;
  49. WMsg->Msg.mn_ReplyPort    = WtPort;
  50.                                                 /* make a message and   */
  51. PutMsg(RdPort,WMsg);                           /* tell Snip we're ready */
  52. printf("message sent %ld\n", (LONG)WMsg);
  53. Wait(1L<<WtPort->mp_SigBit);                  /* wait for reply message */
  54. TMsg = (struct DMsg *)GetMsg(WtPort);         /* remove the message     */
  55.  
  56. /*----------------------------------------------------------------------*/
  57. /*                                                                      */
  58. /* FOR REALLY, REALLY ADVANCED USERS WHO WISH TO GO WHERE ANGELS (like  */
  59. /* me) AND GURUS FEAR TO TREAD.                                         */
  60. /*                                                                      */
  61. /* Alternatively, at this stage a reply could be                        */
  62. /* sent to reactivate Snip. This would allow both programs to be active */
  63. /* simultaneously but be aware that changes in the data will affect     */
  64. /* both programs.                                                       */
  65. /* Creating or deleting channels ( Duplicate, Delete, Average and       */
  66. /* arithmetic ) will disrupt the expected arrangement of data unless    */
  67. /* strict attention is paid to updating variables which keep track of   */
  68. /* such things. - Expect the worst, don't blame me if it blows          */
  69. /* everything apart and feel free to make reasonable and practical      */
  70. /* suggestions for better documentation. - Good luck !!                 */
  71. /*----------------------------------------------------------------------*/
  72.  
  73. /*----------------------------------------------------------------------*/
  74. /*                                                                      */
  75. /* FOR MERE MORTALS ( Of high calibre, of course - or they wouldn't be  */
  76. /* programming the AMIGA ).                                             */
  77. /*                                                                      */
  78. /*---------------------| Insert program code here |---------------------*/
  79.  
  80. printf("Window %d Active, Previously Window %d\n", WMsg->WN, WMsg->PrevWN );
  81. Disp0  = *( WMsg->Disp );                /* pointer to first Disp pointer */
  82. DispPW = *( WMsg->Disp + WMsg->PrevWN);
  83. DispWN = *( WMsg->Disp + WMsg->WN);
  84.  
  85. Dat    = *( WMsg->Dat );
  86.  
  87. printf("Window 0 Channel %d, from %ld for %ld points\n",
  88.             Disp0->Chan, Disp0->firstx, Disp0->nx );
  89.  
  90. printf("current chan %d from %ld for %ld\n",
  91.       DispWN->Chan, DispWN->firstx, DispWN->nx );
  92.  
  93. printf("previous chan %d from %ld for %ld\n",
  94.       DispPW->Chan, DispPW->firstx, DispPW->nx );
  95.  
  96. printf("%d Channels displayed, %d Channels hidden\n",
  97.                                                WMsg->DChans, WMsg->RChans );
  98.  
  99. printf("cursor value %f at position %ld\n", WMsg->base, WMsg->Mark);
  100. printf("Last window opened - %d\n", WMsg->LastWin);
  101. /*-------------------------| End of user code |-------------------------*/
  102.  
  103. PutMsg(RdPort,WMsg);                 /* send message to reactivate Snip */
  104. Wait(1L<<WtPort->mp_SigBit);                  /* wait for reply message */
  105. TMsg = (struct DMsg *)GetMsg(WtPort);         /* remove the message     */
  106. printf("Test done");
  107. dropout:                                      /* then tidy up and leave */
  108. if( WMsg ) FreeMem ( WMsg, (LONG)sizeof(struct DMsg) );
  109. printf(", IO message deleted");
  110. if( WtPort ) RemPort ( WtPort );
  111. if( WtPort ) DeletePort ( WtPort );
  112. printf(", Port deleted");
  113. if( IntuitionBase ) CloseLibrary( IntuitionBase );
  114. printf("Intuition closed\n");
  115. }
  116.  
  117.