home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 17 / CD_ASCQ_17_101194.iso / dos / prg / sphinx / examples / tsr / vgablank.c__ < prev   
Encoding:
Text File  |  1994-05-29  |  2.4 KB  |  95 lines

  1. /*                                                        
  2.      SPHINX C-- source file for VGABLANK.COM
  3.  
  4.      DESCRIPTION:  A very small screen saver.
  5.                    VGA or higher required.
  6. */
  7.  
  8.  
  9. ?resize FALSE   /* turn off auto memory resizing */
  10.  
  11. ?include "WRITE.H--"
  12. ?include "VGA.H--"
  13. ?include "DOS.H--"
  14. ?include "TSR.H--"
  15.  
  16. ?define MAXCOUNT  3*1092     /* minutes * (18.2 * 60 seconds) */
  17.  
  18. ?define KEYINT    0x9
  19. ?define TIMERINT  0x8
  20.  
  21. word oldtimerhandle[2]={};    /* address holder for old INT 0x8 handle */
  22. word oldkeyboardhandle[2]={}; /* address holder for old INT 0x9 handle */
  23.  
  24. word counter=0;  /* tick counter of idle time without keystroke */
  25. byte blanked=0;  /* flag used to indicate whether screen has been blanked */       
  26.  
  27. /* 
  28.    Assignment '=' required for all variables to force the compiler to
  29.    create them as initialized types, therefore they will be located at
  30.    the location declared, not between the program code segment and 
  31.    stack segment, where uninitialized variables are stored.
  32. */
  33.  
  34.  
  35. interrupt timerhandle()   
  36. {
  37. $ PUSHF
  38. $ CS:
  39. $ CALL FAR oldtimerhandle;   /* chain to old interrupt handle */
  40.  
  41. $ PUSH DS
  42. $ PUSH AX
  43. DS = CS;                     /* make memory variable addressable */
  44. IF( blanked == 0 )
  45.     {counter++;
  46.     IF( counter > MAXCOUNT )
  47.         {$ PUSH DX
  48.         blanked = 1;
  49.         @ BLANKVGA();   /* blank display on VGA using port 0x3C6 */
  50.         $ POP DX
  51.         }
  52.     }
  53. $ POP AX
  54. $ POP DS
  55. }
  56.  
  57.  
  58. interrupt keyboardhandle()
  59. {
  60. $ PUSHF
  61. $ CS:
  62. $ CALL FAR oldkeyboardhandle;   /* chain to old interrupt handle */
  63.  
  64. $ PUSH DS
  65. $ PUSH AX
  66. DS = CS;                  /* make memory variables addressable */
  67. IF( blanked == 1 )
  68.     {$ PUSH DX
  69.     @ UNBLANKVGA();    /* unblank VGA display */
  70.     $ POP DX
  71.     blanked = 0;
  72.     }
  73. counter = 0;
  74. $ POP AX
  75. $ POP DS
  76. }
  77.  
  78.  
  79. main ()
  80. {
  81. GETINTVECT(#oldkeyboardhandle,KEYINT); /* get old keyboard interrupt handle */
  82. SETINTVECT( ,KEYINT,CS,#keyboardhandle); /* attach to keyboard interrupt */
  83.  
  84. GETINTVECT(#oldtimerhandle,TIMERINT);   /* get old timer interrupt handle */
  85. SETINTVECT( ,TIMERINT,CS,#timerhandle); /* attach to timer interrupt */
  86.  
  87. WRITESTR("VGA SCREEN BLANKER INSTALLED.\n");
  88. WRITESTR("Screen will blank after 3 minutes of keyboard inactivity.\n");
  89. WRITESTR("Program created using SPHINX C--.  Resident code 688 bytes.\n");
  90.  
  91. @ KEEP( , , ,#main+1);   /* TSR, memory saved up to start of main() */
  92. }
  93.  
  94. /* end of VGABLANK.C-- */
  95.