home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / source / apilot.lha / APilot / APilot_Ser / vertb.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-03  |  2.1 KB  |  75 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. struct VertBData vertbdata;
  36. static struct Interrupt vbint;
  37. static BYTE   mainsignum = -1;
  38. UWORD  vb_counter = 0;
  39.  
  40. /*--------------------------------------------------------------------------*/
  41.  
  42. ULONG init_VertBServer( void )
  43. {
  44.   /* Allocate a signal so handler can signal main */
  45.   if (-1 == (mainsignum = AllocSignal(-1)))
  46.     cleanExit( RETURN_WARN, "** Could not allocate signal for vblank-server.\n" );
  47.  
  48.   /* Init vertbdata structure */    
  49.   vertbdata.maintask = FindTask(NULL);
  50.   vertbdata.mainsig  = 1L << mainsignum;
  51.   vertbdata.sigframe = APILOT_NFR;
  52.   vertbdata.nframes  = &vb_counter;
  53.  
  54.   vbint.is_Node.ln_Type = NT_INTERRUPT;         /* Initialize the node. */
  55.   vbint.is_Node.ln_Pri = 20;
  56.   vbint.is_Node.ln_Name = "VertB-APilot";
  57.   vbint.is_Data = (APTR)&vertbdata;
  58.   vbint.is_Code = VertBServer;
  59.  
  60.   AddIntServer(INTB_VERTB, &vbint); /* Kick this interrupt server to life. */
  61.  
  62.   return vertbdata.mainsig;
  63. }
  64.  
  65. /*--------------------------------------------------------------------------*/
  66.  
  67. void
  68. remove_VertBServer( void )
  69. {
  70.   if (mainsignum != -1) {
  71.     RemIntServer(INTB_VERTB, &vbint);
  72.     FreeSignal(mainsignum);
  73.   }
  74. }
  75.