home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / apilot.lha / APilot / APilot_Opt / vertb.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-03  |  2.1 KB  |  76 lines

  1. /***************************************************************************
  2.  *
  3.  * Vertb.c -- Initializes my vertical blank server
  4.  *
  5.  * This server counts frames on a global variable vb_counter.
  6.  * Using vb_counter the game could very easily be made framerate
  7.  * independant so that lower framerates doesn't make the ship
  8.  * move any slower on screen. Just a few small changes in main()
  9.  * are needed, but I still elected not to use it..Perhaps it's
  10.  * a matter of taste..
  11.  *
  12.  *-------------------------------------------------------------------------
  13.  * Authors: Casper Gripenberg  (casper@alpha.hut.fi)
  14.  *          Kjetil Jacobsen  (kjetilja@stud.cs.uit.no)
  15.  *
  16.  */
  17.  
  18. #include <exec/memory.h>
  19. #include <exec/interrupts.h>
  20. #include <dos/dos.h>
  21. #include <hardware/custom.h>
  22. #include <hardware/intbits.h>
  23. #include <stdio.h>
  24.  
  25. #include <proto/exec.h>
  26.  
  27. #include "main_protos.h"
  28. #include "defs.h"
  29. #include "vertb.h"
  30.  
  31. /*--------------------------------------------------------------------------*/
  32.  
  33. extern void VertBServer();  /* proto for asm interrupt server */
  34.  
  35. UWORD  vb_counter = 0;
  36.  
  37. struct VertBData vertbdata;
  38. static struct    Interrupt vbint;
  39. static BYTE      mainsignum = -1;
  40.  
  41. /*--------------------------------------------------------------------------*/
  42.  
  43. ULONG init_VertBServer( void )
  44. {
  45.   /* Allocate a signal so handler can signal main */
  46.   if (-1 == (mainsignum = AllocSignal(-1)))
  47.     cleanExit( RETURN_WARN, "** Could not allocate signal for vblank-server.\n" );
  48.  
  49.   /* Init vertbdata structure */    
  50.   vertbdata.maintask = FindTask(NULL);
  51.   vertbdata.mainsig  = 1L << mainsignum;
  52.   vertbdata.sigframe = APILOT_NFR;
  53.   vertbdata.nframes  = &vb_counter;
  54.  
  55.   vbint.is_Node.ln_Type = NT_INTERRUPT;         /* Initialize the node. */
  56.   vbint.is_Node.ln_Pri  = 20;
  57.   vbint.is_Node.ln_Name = "VertB-APilot";
  58.   vbint.is_Data = (APTR)&vertbdata;
  59.   vbint.is_Code = VertBServer;
  60.  
  61.   AddIntServer(INTB_VERTB, &vbint); /* Kick this interrupt server to life. */
  62.  
  63.   return vertbdata.mainsig;
  64. }
  65.  
  66. /*--------------------------------------------------------------------------*/
  67.  
  68. void
  69. remove_VertBServer( void )
  70. {
  71.   if (mainsignum != -1) {
  72.     RemIntServer(INTB_VERTB, &vbint);
  73.     FreeSignal(mainsignum);
  74.   }
  75. }
  76.