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 >
Wrap
C/C++ Source or Header
|
1989-03-31
|
5KB
|
117 lines
/* standard Intuition include files */
#include<exec/types.h>
#include<exec/memory.h>
#include<functions.h>
#include<math.h>
#include<intuition/intuition.h>
#include<graphics/rastport.h>
#include<stdio.h>
/* Include file specifically for Snip */
#include "Snip.h"
struct Window *Window; /* the display window */
char title[30]; /* Window title */
struct GfxBase *GfxBase = NULL;
struct IntuitionBase *IntuitionBase;
struct DMsg *WMsg, *TMsg;
struct Disp *Disp0, *DispPW, *DispWN;
struct Dat *Dat;
struct MsgPort *WtPort, *RdPort;
SHORT i;
LONG Mark;
FLOAT base;
main()
{
printf("testprog says hello\n");
if(!(IntuitionBase=(struct IntuitionBase *)
OpenLibrary("intuition.library",0L)))
{ printf("no intuition library\n"); /* some sort of message */
exit(0L);} /* in event of failure */
if(!(WtPort = CreatePort("SnipWPort", 0L ))) /* make a message port */
{ printf("can't create Port\n"); /* some sort of message */
goto dropout;
}
RdPort = FindPort("SnipRPort"); /* find Snip's port !!! */
if(RdPort == 0) { printf("no RdPort found"); exit(0L);} /* can't find it */
WMsg = (struct DMsg *)AllocMem( (LONG)(sizeof(struct DMsg)),
MEMF_CLEAR | MEMF_PUBLIC );
if( !(WMsg) ){
printf(" no message allocated\n");
exit(0L);
}
WMsg->Msg.mn_Node.ln_Type = NT_MESSAGE;
WMsg->Msg.mn_Node.ln_Pri = 0;
WMsg->Msg.mn_ReplyPort = WtPort;
/* make a message and */
PutMsg(RdPort,WMsg); /* tell Snip we're ready */
printf("message sent %ld\n", (LONG)WMsg);
Wait(1L<<WtPort->mp_SigBit); /* wait for reply message */
TMsg = (struct DMsg *)GetMsg(WtPort); /* remove the message */
/*----------------------------------------------------------------------*/
/* */
/* FOR REALLY, REALLY ADVANCED USERS WHO WISH TO GO WHERE ANGELS (like */
/* me) AND GURUS FEAR TO TREAD. */
/* */
/* Alternatively, at this stage a reply could be */
/* sent to reactivate Snip. This would allow both programs to be active */
/* simultaneously but be aware that changes in the data will affect */
/* both programs. */
/* Creating or deleting channels ( Duplicate, Delete, Average and */
/* arithmetic ) will disrupt the expected arrangement of data unless */
/* strict attention is paid to updating variables which keep track of */
/* such things. - Expect the worst, don't blame me if it blows */
/* everything apart and feel free to make reasonable and practical */
/* suggestions for better documentation. - Good luck !! */
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* */
/* FOR MERE MORTALS ( Of high calibre, of course - or they wouldn't be */
/* programming the AMIGA ). */
/* */
/*---------------------| Insert program code here |---------------------*/
printf("Window %d Active, Previously Window %d\n", WMsg->WN, WMsg->PrevWN );
Disp0 = *( WMsg->Disp ); /* pointer to first Disp pointer */
DispPW = *( WMsg->Disp + WMsg->PrevWN);
DispWN = *( WMsg->Disp + WMsg->WN);
Dat = *( WMsg->Dat );
printf("Window 0 Channel %d, from %ld for %ld points\n",
Disp0->Chan, Disp0->firstx, Disp0->nx );
printf("current chan %d from %ld for %ld\n",
DispWN->Chan, DispWN->firstx, DispWN->nx );
printf("previous chan %d from %ld for %ld\n",
DispPW->Chan, DispPW->firstx, DispPW->nx );
printf("%d Channels displayed, %d Channels hidden\n",
WMsg->DChans, WMsg->RChans );
printf("cursor value %f at position %ld\n", WMsg->base, WMsg->Mark);
printf("Last window opened - %d\n", WMsg->LastWin);
/*-------------------------| End of user code |-------------------------*/
PutMsg(RdPort,WMsg); /* send message to reactivate Snip */
Wait(1L<<WtPort->mp_SigBit); /* wait for reply message */
TMsg = (struct DMsg *)GetMsg(WtPort); /* remove the message */
printf("Test done");
dropout: /* then tidy up and leave */
if( WMsg ) FreeMem ( WMsg, (LONG)sizeof(struct DMsg) );
printf(", IO message deleted");
if( WtPort ) RemPort ( WtPort );
if( WtPort ) DeletePort ( WtPort );
printf(", Port deleted");
if( IntuitionBase ) CloseLibrary( IntuitionBase );
printf("Intuition closed\n");
}