home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / j / jonix / !Jonix / h / riscos < prev   
Encoding:
Text File  |  1997-01-26  |  950 b   |  37 lines

  1. /* riscos.h -- Jonix RISC OS polling library
  2. */
  3.  
  4. #define riscos
  5. #include "swis.h"
  6. #define riscos_TIMESLICE 5 // cs
  7. #define riscos_WAIT 15 // cs
  8.  
  9. unsigned int riscos_TASKHANDLE = 0;
  10. int riscos_LAST = 0;
  11. int *riscos_POLLBLOCK;
  12.  
  13. void riscos_initialise (void)
  14. {
  15.     int messages[1]={0};
  16.     riscos_TASKHANDLE = _swi (Wimp_Initialise, _IN(0)|_IN(1)|_IN(2)|_IN(3)|_RETURN(1),
  17.                                 310, 0x4b534154, "Jonix", messages);
  18.     riscos_POLLBLOCK = (int *) malloc (256);
  19.     _swi (OS_ReadMonotonicTime, _OUT(0), &riscos_LAST);
  20. }
  21.  
  22. void riscos_shutdown (void)
  23. {
  24.     _swi (Wimp_CloseDown, _IN(0)|_IN(1), riscos_TASKHANDLE, 0x4b534154);
  25. }
  26.  
  27. void riscos_poll (FILE *fin)
  28. {
  29.     int current_time, action;
  30.     _swi (OS_ReadMonotonicTime, _OUT(0), ¤t_time);
  31.     if ((riscos_LAST + riscos_TIMESLICE) < current_time)
  32.     {
  33.         _swi (Wimp_PollIdle, _IN(0)|_IN(1)|_IN(2)|_OUT(0), 0, riscos_POLLBLOCK, current_time + riscos_WAIT, &action);
  34.         _swi (OS_ReadMonotonicTime, _OUT(0), &riscos_LAST);
  35.     }
  36. }
  37.