?login_element?

Subversion Repositories NedoOS

Rev

Rev 1634 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <intrz80.h>
  4. #include <stdlib.h>
  5. #include <oscalls.h>
  6. unsigned char *p;
  7.  
  8. void error(void)
  9. {
  10.         printf("Usage: sleep.com delay \r\n");
  11.         printf("Delay in range from 0 to 32000 ms with step of 50ms\r\n");
  12.         printf("If delay = 0 then program waiting for keypress\r\n");
  13.         exit(0);
  14. }
  15.  
  16. C_task main(int argc, char *argv[])
  17. {
  18.         unsigned int counter;
  19.         long start, finish;
  20.         unsigned char key;
  21.         os_initstdio();
  22.  
  23.         if (argc == 2)
  24.         {
  25.                 p = argv[1];
  26.                 counter = atoi(p);
  27.                 if (counter > 32000)
  28.                 {
  29.                         counter = 0;
  30.                 }
  31.  
  32.                 if (counter == 0)
  33.                 {
  34.                         do
  35.                         {
  36.                                 key = _low_level_get();
  37.                         } while (key == 0);
  38.                         exit(0);
  39.                 }
  40.                 counter = counter / 20;
  41.                 if (counter < 1)
  42.                 {
  43.                         counter = 1;
  44.                 }
  45.                 start = time();
  46.                 finish = start + counter;
  47.  
  48.                 while (start < finish)
  49.                 {
  50.                         start = time();
  51.                         YIELD();
  52.                 }
  53.                 exit(0);
  54.         }
  55.         error();
  56.         //      return 0;
  57. }
  58.