home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d178 / ciatimer.lha / CIATimer / Readme < prev    next >
Text File  |  1989-02-04  |  2KB  |  49 lines

  1. [ Ed note:  for convenience the following was excerpted from the 
  2.             ciatimer.c file.  -Fred ><> ]
  3.  
  4. /* TIMER - Amiga CIA Timer Control Software
  5.  
  6.   originally by Paul Higginbottom, Public Domain, published in AmigaMail
  7.  
  8.   hacked on by Karl Lehenbauer to produce a monotonically increasing 
  9.   microsecond clock, 12/30/88. All changes are Public Domain.
  10.  
  11.   cc +p ciatimer.c
  12.   ln ciatimer.o -lcl32
  13.  
  14.     By providing a solid, high-accuracy realtime clock, this code
  15.     provides a way for timer-releated code that needs to run at
  16.     specific realtimes, like a SMUS player, MIDI sequencer, etc,
  17.     to compensate for delays in their execution caused by interrupts,
  18.     cycle stealing by the blitter, etc.
  19.  
  20.     What you do is keep track of when in realtime you next want to 
  21.     run (by adding time intervals to a time returned by ElapsedTime
  22.     when you start, then when you're ready to set up your timer.device
  23.     MICROHZ delay timer, call ElapsedTime and calculate the difference 
  24.     in seconds and microseconds as your arguments for your timer.device
  25.     request.
  26.  
  27.     The routine ElapsedTime gets the time by getting the number of
  28.     65536 microsecond ticks that the handler has seen and retrieving
  29.     the 0-46911 number of 1.397 microsecond ticks from the CIA timer
  30.     registers, scaling them to 1.000 microsecond ticks and returning
  31.     the shifted-and-ored result.
  32.  
  33.     A couple routines at the bottom of the file that're commented out 
  34.     are from my SMUS player and demonstrate how to perform the time 
  35.     arithmetic as described above.
  36.  
  37.     Note that what we really want is an improved timer.device where a
  38.     flag in the timer request could say  "schedule me at this microsecond-
  39.     resolution time of day seconds and microseconds" instead of only
  40.     "schedule me in this many seconds and microseconds."
  41.  
  42.     When the CIA interrupt handler is installed, other tasks need a
  43.     way to get the count maintained by the timer routine, too.
  44.     I was thinking maybe a library could be used and, by opening it,
  45.     tasks could get to the address of the long word that the interrupt
  46.     handler increments every time it runs.
  47. */
  48.  
  49.