home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / screen / vblank / vblank.asm < prev    next >
Assembly Source File  |  1990-09-23  |  4KB  |  119 lines

  1.         PAGE    78,132
  2. ; ----------                VBLANK VGA Screen Blanker
  3. ; ----------                       Version 1d
  4. ; ----------             Placed in the public domain by
  5. ; ----------     Richard M. Utter, ProLogic, Scottsville, New York
  6. ; ----------                      3 September 1990
  7. ; ----------
  8. ; ---------- Fine Print: There's no charge. Neither is there a warranty.
  9. ; ----------
  10. ; ---------- VBLANK.EXE is a TSR designed to blank a VGA monitor after a 
  11. ; ---------- fixed interval. Pressing any key will unblank the monitor. RAM
  12. ; ---------- required is about 500 bytes.
  13. ; ----------
  14. ; ---------- Assemble VBLANK.ASM with MASM 5.1. Then link VBLANK.OBJ any old
  15. ; ---------- way. Use Microsoft's EXEMOD or a similar utility to reduce
  16. ; ---------- VBLANK.EXE's memory requirement to the minimum. (For EXEMOD, the
  17. ; ---------- command would be "EXEMOD VBLANK.EXE /MAX 0".) Run VBLANK from the
  18. ; ---------- DOS command line or via AUTOEXEC.BAT. 
  19. ; ---------- 
  20. ; ---------- Timer threshold: 5000 / 18.2 = 275 seconds or thereabouts. The
  21. ; ---------- VGA monitor will be blanked after roughly 4.5 minutes of keyboard
  22. ; ---------- inactivity.
  23. MAXT    EQU     5000
  24.         .MODEL  SMALL
  25. ; ---------- "Short stack."
  26.         .STACK  16
  27.         .CODE
  28. TSR     PROC    FAR
  29.         JMP     SHORT _1000
  30. OLD_1C  DD      0
  31. OLD_09  DD      0
  32. TCOUNT  DW      0
  33. ; ---------- Grab old INT 1C and 9 vectors before replacing them.
  34. _1000:  MOV     AX,351CH
  35.         INT     21H
  36.         MOV     WORD PTR OLD_1C,BX
  37.         MOV     WORD PTR OLD_1C+2,ES
  38.  
  39.         MOV     AX,3509H
  40.         INT     21H
  41.         MOV     WORD PTR OLD_09,BX
  42.         MOV     WORD PTR OLD_09+2,ES
  43. ; ---------- Point INT 8 and 9 at our interrupt routines.
  44.         PUSH    CS
  45.         POP     DS
  46.         MOV     AX,251CH
  47.         MOV     DX,OFFSET INTTIME
  48.         INT     21H
  49.  
  50.         MOV     AX,2509H
  51.         MOV     DX,OFFSET INTKB
  52.         INT     21H
  53. ; ---------- "Terminate and stay resident", reserving 432 bytes for ourselves.
  54. ; ---------- 432 is a bit more than 256 + 157 + 16 (PSP plus code size plus
  55. ; ---------- stack size).
  56.         MOV     AX,3100H
  57.         MOV     DX,27
  58.         INT     21H
  59. TSR     ENDP
  60.  
  61. ; ---------- Timer ISR.
  62. INTTIME PROC    FAR
  63. ; ---------- Save DS before pointing it at local data.
  64.         PUSH    DS
  65.         PUSH    CS
  66.         POP     DS
  67. ; ---------- Screen already blanked?
  68.         CMP     TCOUNT,MAXT
  69. ; ---------- Yes. Go away.
  70.         JE      _2000
  71. ; ---------- Increment and test counter.
  72.         ADD     TCOUNT,1
  73.         CMP     TCOUNT,MAXT
  74.         JL      _2000
  75. ; ---------- We've reached the threshold. Disable VGA screen refresh.
  76.         PUSH    AX
  77.         PUSH    DX
  78.         MOV     AL,1
  79.         MOV     DX,3C4H
  80.         OUT     DX,AL
  81.         INC     DX
  82.         IN      AL,DX
  83.         OR      AL,20H
  84.         OUT     DX,AL
  85.         POP     DX
  86.         POP     AX
  87. ; ---------- Restore DS to entry value, then vector to old timer ISR.
  88. _2000:  POP     DS
  89.         JMP     OLD_1C
  90. INTTIME ENDP        
  91.  
  92. ; ---------- K/B ISR.
  93. INTKB   PROC    FAR
  94.         PUSH    DS
  95.         PUSH    CS
  96.         POP     DS
  97. ; ---------- Is the screen blanked? If not, unblanking it is redundant.
  98.         CMP     TCOUNT,MAXT
  99.         JL      _3000
  100. ; ---------- Screen is blanked. Enable VGA screen refresh.
  101.         PUSH    AX
  102.         PUSH    DX
  103.         MOV     AL,1
  104.         MOV     DX,3C4H
  105.         OUT     DX,AL
  106.         INC     DX
  107.         IN      AL,DX
  108.         AND     AL,NOT 20H
  109.         OUT     DX,AL
  110.         POP     DX
  111.         POP     AX
  112. ; ---------- Zero the counter.
  113. _3000:  MOV     TCOUNT,0
  114.         POP     DS
  115. ; ---------- Vector to the real K/B ISR.
  116.         JMP     OLD_09
  117. INTKB   ENDP
  118.         END     TSR
  119.