home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / pascal / 4618 < prev    next >
Encoding:
Text File  |  1992-07-30  |  2.0 KB  |  52 lines

  1. Newsgroups: comp.lang.pascal
  2. Path: sparky!uunet!wupost!usc!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!s.psych.uiuc.edu!amead
  3. From: amead@s.psych.uiuc.edu (Alan Mead)
  4. Subject: how long is a clock cycle (was source for DELAY procedure)?
  5. Message-ID: <Bs7Hv8.Bqz@news.cso.uiuc.edu>
  6. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  7. Organization: UIUC Department of Psychology
  8. Date: Thu, 30 Jul 1992 14:35:30 GMT
  9. Lines: 41
  10.  
  11. Tim C wonders who has the source for Crt.Delay.  I know how it works,
  12. it initializes itself at start-up.  Probably by running an empty loop
  13. for a clock tick or two.  If you have a fairly long delay and a clone
  14. with a turbo button, try this experiment:  toggle the turbo during the
  15. delay.  Since Delay() has already initialized, it will completely
  16. screw it up.
  17.  
  18. I want to run another process during a Delay().  I don't want people to
  19. overflow the BIOS keyboard buffer (it beeps then and that is bad for this
  20. app).  I think the easiest way will do this is something like:
  21.  
  22. procedure BusyDelay( period:integer );
  23.   const shorter = 200;
  24.   begin
  25.     number := period DIV shorter;
  26.     for i := 1 to number-1 do
  27.       begin
  28.         delay( shorter );
  29.         FlushKBD; { this is my own procedure to flush the BIOS keyboard buffer }
  30.       end; 
  31.     delay( period - number*shorter );
  32.   end; { proc Busy Delay }
  33.  
  34. But I see several problems.  FlushKBD will, depending on how I
  35. implement it, take a different amount of time to execute depending on
  36. how many keystrokes are in the buffer.
  37.  
  38. Also, the delay will be longer than period milliseconds by number*<the
  39. time it takes to execute FlushKBD>.
  40.  
  41. Which all seems to bear on the value of shorter.  I think that the
  42. bigger I make it, the less trouble I accrue from the other points.
  43.  
  44. And all this stuff would seem to be processor (even machine!)
  45. specific.  Different machines will execute FlushKBD at different
  46. speeds.
  47.  
  48. Anyone have any suggestions?  Anyone know where in the executable code
  49. I can find the Delay procedure's initialization data?
  50.  
  51. -alan mead
  52.