home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / Misc / TRSICAT.LZX / CATS_CD2_TRSI / Reference_Library / lib_examples / vertb.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-21  |  1.7 KB  |  51 lines

  1. ;/* vertb.c - Execute me to compile me with SAS C 5.10
  2. LC -d0 -b1 -cfistq -v -y -j73 vertb.c
  3. Blink FROM LIB:c.o,vertb.o,vertbserver.o TO vertb LIBRARY LIB:LC.lib,LIB:Amiga.lib
  4. quit ; */
  5. /* vertb.c - Vertical blank interrupt server example.  Must be linked with vertbserver.o. */
  6.  
  7. #include <exec/memory.h>
  8. #include <exec/interrupts.h>
  9. #include <dos/dos.h>
  10. #include <hardware/custom.h>
  11. #include <hardware/intbits.h>
  12. #include <clib/exec_protos.h>
  13. #include <stdio.h>
  14.  
  15. #ifdef LATTICE
  16. int CXBRK(void)  { return(0); }  /* Disable Lattice CTRL/C handling */
  17. void chkabort(void) { return; }  /* really */
  18. #endif
  19.  
  20. extern void VertBServer();  /* proto for asm interrupt server */
  21.  
  22. void main(void)
  23. {
  24.     struct Interrupt *vbint;
  25.     ULONG counter = 0;
  26.     ULONG endcount;
  27.                                                                          /* Allocate memory for  */
  28.     if (vbint = AllocMem(sizeof(struct Interrupt), MEMF_PUBLIC|MEMF_CLEAR))   /* interrupt node. */
  29.     {
  30.         vbint->is_Node.ln_Type = NT_INTERRUPT;         /* Initialize the node. */
  31.         vbint->is_Node.ln_Pri = -60;
  32.         vbint->is_Node.ln_Name = "VertB-Example";
  33.         vbint->is_Data = (APTR)&counter;
  34.         vbint->is_Code = VertBServer;
  35.  
  36.  
  37.         AddIntServer(INTB_VERTB, vbint); /* Kick this interrupt server to life. */
  38.  
  39.         printf("VBlank server will increment a counter every frame.\n");
  40.         printf("counter started at zero, CTRL-C to remove server\n");
  41.  
  42.         Wait(SIGBREAKF_CTRL_C);
  43.         endcount = counter;
  44.         printf("%ld vertical blanks occurred\nRemoving server\n", endcount);
  45.  
  46.         RemIntServer(INTB_VERTB, vbint);
  47.         FreeMem(vbint, sizeof(struct Interrupt));
  48.     }
  49.     else printf("Can't allocate memory for interrupt node\n");
  50. }
  51.