home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast.iso / screen / hzpcsave.asm < prev    next >
Assembly Source File  |  1994-03-05  |  10KB  |  287 lines

  1.     NAME        HZPCSAVE
  2.     PAGE        55,132
  3.         TITLE           'SCREEN SAVER FOR HZ150 PC SERIES'
  4. ;
  5. ;  SCRNSAVE patched for Heath/Zenith 150 PC series
  6. ;----------------------------------------------------------------------;
  7. ;  This program was written by John Socha and published in SOFTALK for ;
  8. ;  the IBM Personal Computer, December 1983.  The program turns the    ;
  9. ;  screen display off after 3 minutes of no activity (ie: no data is   ;
  10. ;  sent to the screen).  Pressing any key will reactivate the screen   ;
  11. ;  display.                                   ;
  12. ;                                       ;
  13. ;  This version has been patched by Mike Berman to operate on the      ;
  14. ;  Heath/Zenith 150 PC series.    The video board on these computers     ;
  15. ;  has been enhanced to stop blinking when scrolling, but this           ;
  16. ;  required an additional video register at port 3DA; when bit 0 of    ;
  17. ;  this register is enabled, the bit used to turn off the screen by    ;
  18. ;  the original version of this program is overriden, and nothing      ;
  19. ;  happens.                                   ;
  20. ;                                       ;
  21. ;  CAVEAT: Since I don't know how to find the current contents of      ;
  22. ;  the 3DA port, this program assumes that all other bits = 0, which   ;
  23. ;  apparently is the default.  If this is not true, the screen may     ;
  24. ;  be restored to a different state than when it was blanked.  This    ;
  25. ;  doesn't cause problems with the software I use, but users of this   ;
  26. ;  routine should be aware of it.                       ;
  27. ;                                       ;
  28. ;  ACKNOWLEDGEMENT: Thanks to Dave Tweten for explaining it.           ;
  29. ;----------------------------------------------------------------------;
  30. ;
  31. ;----------------------------------------------------------------------;
  32. ;  These are the interrupt vectors for the clock, keyboard and video   ;
  33. ;  io calls.                                   ;
  34. ;----------------------------------------------------------------------;
  35. ;
  36. VECTORS         SEGMENT AT 0H
  37.     ORG        8H*4
  38. TIME_OF_DAY_VECTOR    LABEL    DWORD ;Clock interrupt, 18.2 per sec
  39.     ORG        9H*4
  40. KEYBOARD_INT_VECTOR    LABEL    DWORD
  41.     ORG        10H*4
  42. VIDEO_IO_VECTOR     LABEL    DWORD
  43. VECTORS         ENDS
  44. ;
  45. ;----------------------------------------------------------------------;
  46. ;  This is the data area starting at 400H used by the ROM BIOS           ;
  47. ;  routines.  ADDR_6845 contains the base address, 3x4, of the current ;
  48. ;  display adapter and CRT_MODE_SET contains the current setting of    ;
  49. ;  display mode -- the 3x8 register.  The x is B for the monochrome    ;
  50. ;  display adapter, and D for the color-graphics adapter.           ;
  51. ;----------------------------------------------------------------------;
  52. ;
  53. ROM_BIOS_DATA        SEGMENT AT 40H
  54.     ORG        10H
  55. EQUIP_FLAG        DW    ?    ;Used to determine display type
  56.     ORG        60H
  57. CURSOR_MODE        DW    ?    ;Current cursor mode (start, stop line)
  58.     ORG        63H
  59. ADDR_6845        DW    ?    ;Base address for active display card
  60. CRT_MODE_SET        DB    ?    ;Current setting of 3x8 register
  61. ROM_BIOS_DATA        ENDS
  62. ;
  63. ;----------------------------------------------------------------------;
  64. ;  This is the start of the local data and executable code.           ;
  65. ;----------------------------------------------------------------------;
  66. ;
  67. CODE_SEG        SEGMENT
  68.     ASSUME        CS:CODE_SEG
  69.     ORG        100H
  70. BEGIN:    JMP        INIT_VECTORS    ;Initialize vectors and attach to DOS
  71. ;
  72. ROM_TIME_OF_DAY_INT    DD        ;Addresses for ROM routines
  73. ROM_KEYBOARD_INT    DD
  74. ROM_VIDEO_IO_INT    DD
  75. TIMER_DELAY        DW    0CCCH    ;Delay before turning off video
  76. THREE_MIN_COUNTER    DW    ?    ;Clock ticks in 3 minutes
  77. OLD_CURSOR_TYPE     DW    0    ;Hold the old cursor type
  78. ;
  79. ;----------------------------------------------------------------------;
  80. ;  Turn the video display off after three minutes of no use.           ;
  81. ;                                       ;
  82. ;  Calls:    ROM_TIME_OF_DAY_INT                       ;
  83. ;  Reads:    ADDR-6845, CRT_MODE_SET                    ;
  84. ;  Writes:    THREE_MIN_COUNTER, OLD_CURSOR_TYPE               ;
  85. ;----------------------------------------------------------------------;
  86. ;
  87. INTERCEPT_TIME_OF_DAY    PROC    NEAR
  88.     PUSH    AX
  89.     PUSH    DS
  90.     MOV    AX,CS            ;Set data segment to current segment
  91.     MOV    DS,AX
  92.     ASSUME    DS:CODE_SEG
  93.     DEC    THREE_MIN_COUNTER    ;Have 3 minutes elapsed?
  94.     JZ    TURN_VIDEO_OFF        ;Yes, turn video off
  95.     JG    GOTO_ROM_TIME_OF_DAY    ;No, keep video on
  96.     MOV    THREE_MIN_COUNTER,0    ;Video is off, reset counter to 0 again
  97. GOTO_ROM_TIME_OF_DAY:
  98.     POP    DS
  99.     POP    AX
  100.     ASSUME    DS:NOTHING
  101.     JMP    ROM_TIME_OF_DAY_INT
  102. TURN_VIDEO_OFF:
  103.     ASSUME    DS:CODE_SEG
  104.     PUSH    BX
  105.     PUSH    CX
  106.     PUSH    DX
  107.     MOV    AH,3            ;Get current cusor type into CX
  108.     PUSHF                ;Push flags to simulate INT with CALL
  109.     CALL    ROM_VIDEO_IO_INT    ;Must use CALL since INT 10 points here
  110.     MOV    OLD_CURSOR_TYPE,CX    ;And save it
  111.     MOV    CH,0FH            ;Now remove cursor from screen
  112.     MOV    CL,0
  113.     MOV    AH,1
  114.     PUSHF                ;Push flags to simulate INT with CALL
  115.     CALL    ROM_VIDEO_IO_INT    ;Must use CALL since INT 10 points here
  116.     POP    DX
  117.     POP    CX
  118.     POP    BX
  119.     PUSH    DX            ;Turn the display video off
  120.     MOV    AX,ROM_BIOS_DATA
  121.     MOV    DS,AX
  122.     ASSUME    DS:ROM_BIOS_DATA
  123.     MOV    DX,ADDR_6845        ;Get base address for display adapter
  124.     ADD    DX,4            ;IO address for 3x8 register
  125.     MOV    AL,CRT_MODE_SET
  126.     AND    AL,0F7H         ;Turn video off
  127.     OUT    DX,AL
  128. ;----------------------------------------------------------------------;
  129. ;      HZ 150 PC Patch Starts Here                       ;
  130. ;----------------------------------------------------------------------;
  131.     MOV    DX,3DAH         ;Auxiliary video register on HZ309 card
  132.     MOV    AL,0
  133.     OUT    DX,AL            ;Turn off Video Enable Override
  134. ;----------------------------------------------------------------------;
  135. ;      END of Patch                               ;
  136. ;----------------------------------------------------------------------;
  137.     POP    DX
  138.     JMP    GOTO_ROM_TIME_OF_DAY
  139. ;
  140. INTERCEPT_TIME_OF_DAY    ENDP
  141. ;
  142. ;----------------------------------------------------------------------;
  143. ;  This procedure resets the timer count to 0CCCH and turns the        ;
  144. ;  display on if it was off.                           ;
  145. ;----------------------------------------------------------------------;
  146. ;
  147. RESET_COUNTER    PROC    NEAR
  148.     PUSH    AX
  149.     PUSH    DX
  150.     PUSH    DS
  151.     MOV    AX,CS
  152.     MOV    DS,AX
  153.     ASSUME    DS:CODE_SEG
  154.     CMP    THREE_MIN_COUNTER,0    ;Was the display off?
  155.     JG    VIDEO_NOT_OFF        ;No, then just reset counter
  156.     PUSH    DS            ;Yes, then turn video back on
  157.     MOV    AX,ROM_BIOS_DATA
  158.     MOV    DS,AX
  159.     ASSUME    DS:ROM_BIOS_DATA
  160.     MOV    DX,ADDR_6845        ;Get base address for display adapter
  161.     ADD    DX,4            ;IO address for 3x8 register
  162.     MOV    AL,CRT_MODE_SET
  163.     OR    AL,8            ;Turn video on again
  164.     OUT    DX,AL
  165. ;----------------------------------------------------------------------;
  166. ;      HZ 150 PC Patch Starts Here                       ;
  167. ;----------------------------------------------------------------------;
  168.     MOV    DX,3DAH         ;Auxiliary video register on HZ309 card
  169.     MOV    AL,1
  170.     OUT    DX,AL            ;Turn on Video Enable Override
  171. ;----------------------------------------------------------------------;
  172. ;      END of Patch                               ;
  173. ;----------------------------------------------------------------------;
  174.     POP    DS
  175.     ASSUME    DS:CODE_SEG
  176.     PUSH    CX            ;Now restore the cursor
  177.     MOV    CX,OLD_CURSOR_TYPE
  178.     MOV    AH,1            ;Restore the old cursor type
  179.     PUSHF                ;Push flags to simulate INT with CALL
  180.     CALL    ROM_VIDEO_IO_INT    ;Must use CALL since INT 10 points here
  181.     POP    CX
  182. VIDEO_NOT_OFF:
  183.     MOV    AX,TIMER_DELAY
  184.     MOV    THREE_MIN_COUNTER,AX
  185.     POP    DS
  186.     POP    DX
  187.     POP    AX
  188.     RET
  189. RESET_COUNTER    ENDP
  190. ;
  191. INTERCEPT_KEYBOARD_INT    PROC    NEAR
  192.     ASSUME    DS:NOTHING
  193.     CALL    RESET_COUNTER        ;Reset the time out counter
  194.     JMP    ROM_KEYBOARD_INT    ;Pass control to ROM routine
  195. INTERCEPT_KEYBOARD_INT    ENDP
  196. ;
  197. ;----------------------------------------------------------------------;
  198. ;  This procedure resets the cursor type to the default type for the   ;
  199. ;  display adapter in use: 607H for the color/graphics adapter and     ;
  200. ;  0C0BH for the monochrome display adapter.                   ;
  201. ;----------------------------------------------------------------------;
  202. ;
  203. SET_CURSOR_MODE     PROC    NEAR
  204.     PUSH    AX
  205.     PUSH    CX
  206.     PUSH    DS
  207.     MOV    AX,ROM_BIOS_DATA
  208.     MOV    DS,AX            ;Point to ROM BIOS data area
  209.     ASSUME    DS:ROM_BIOS_DATA
  210.     MOV    AX,EQUIP_FLAG        ;Determine which adapter is active
  211.     AND    AL,30H            ;Isolate adapter information
  212.     MOV    CX,607H         ;Set for color/graphics adapter
  213.     CMP    AL,30H            ;Is monochrome display adapter active?
  214.     JNE    COLOR_ACTIVE        ;No, set cursor type
  215.     MOV    CX,0B0CH        ;Cursor mode for monochrome display
  216. COLOR_ACTIVE:
  217.     MOV    AH,1
  218.     PUSHF                ;Simulate INT 10 with PUSHF and CALL
  219.     CALL    ROM_VIDEO_IO_INT
  220.     POP    DS
  221.     POP    CX
  222.     POP    AX
  223.     RET
  224. SET_CURSOR_MODE     ENDP
  225. ;
  226. ;----------------------------------------------------------------------;
  227. ;  This procedure resets the time-out counter, and passes control on   ;
  228. ;  to the ROM VIDEO_IO routines.                       ;
  229. ;----------------------------------------------------------------------;
  230. ;
  231. INTERCEPT_VIDEO_IO    PROC    NEAR
  232.     ASSUME    DS:NOTHING
  233.     CALL    RESET_COUNTER        ;Reset time-out counter
  234.     PUSHF                ;Simulate INT 10 with PUSHF and CALL
  235.     CALL    ROM_VIDEO_IO_INT    ;Do VIDEO_IO function
  236.     OR    AH,AH            ;Asking for set-mode function?
  237.     JNZ    NOT_MODE_SET        ;No, then return
  238.     CALL    SET_CURSOR_MODE     ;Yes, then set cursor mode to default
  239. ;
  240. NOT_MODE_SET:
  241.     IRET
  242. ;
  243. INTERCEPT_VIDEO_IO    ENDP
  244. ;
  245. ;----------------------------------------------------------------------;
  246. ;  This procedure initializes the interrupt vectors.               ;
  247. ;----------------------------------------------------------------------;
  248. ;
  249. INIT_VECTORS        PROC    NEAR
  250.     ASSUME    DS:VECTORS
  251.     MOV    AX,VECTORS        ;Set up the data segment for vectors
  252.     MOV    DS,AX
  253.         CLI                               ;Don't allow interrupts
  254.     MOV    AX,word ptr TIME_OF_DAY_VECTOR      ;Save addresses of BIOS routines
  255.     MOV    word ptr ROM_TIME_OF_DAY_INT,AX
  256.     MOV    AX,word ptr TIME_OF_DAY_VECTOR[2]
  257.     MOV    word ptr ROM_TIME_OF_DAY_INT[2],AX
  258.     MOV    word ptr TIME_OF_DAY_VECTOR,OFFSET INTERCEPT_TIME_OF_DAY
  259.     MOV    word ptr TIME_OF_DAY_VECTOR[2],CS
  260. ;
  261.     MOV    AX,word ptr KEYBOARD_INT_VECTOR
  262.     MOV    word ptr ROM_KEYBOARD_INT,AX
  263.     MOV    AX,word ptr KEYBOARD_INT_VECTOR[2]
  264.     MOV    word ptr ROM_KEYBOARD_INT[2],AX
  265.     MOV    word ptr KEYBOARD_INT_VECTOR,OFFSET INTERCEPT_KEYBOARD_INT
  266.     MOV    word ptr KEYBOARD_INT_VECTOR[2],CS
  267. ;
  268.     MOV    AX,word ptr VIDEO_IO_VECTOR
  269.     MOV    word ptr ROM_VIDEO_IO_INT,AX
  270.     MOV    AX,word ptr VIDEO_IO_VECTOR[2]
  271.     MOV    word ptr ROM_VIDEO_IO_INT[2],AX
  272.     MOV    word ptr VIDEO_IO_VECTOR,OFFSET INTERCEPT_VIDEO_IO
  273.     MOV    word ptr VIDEO_IO_VECTOR[2],CS
  274. ;
  275.     MOV    AX,TIMER_DELAY        ;Set the delay to 3 minutes
  276.     MOV    THREE_MIN_COUNTER,AX
  277. ;
  278.     STI                ;Allow interrupts again
  279.     CALL    SET_CURSOR_MODE     ;Set cursor mode to default
  280.     MOV    DX,OFFSET INIT_VECTORS    ;End of resident portion
  281.     INT    27H            ;Terminate but stay resident
  282. INIT_VECTORS        ENDP
  283. ;
  284. CODE_SEG        ENDS
  285. ;
  286.     END        BEGIN
  287.