home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_02_09 / 2n09053a < prev    next >
Text File  |  1991-08-04  |  19KB  |  443 lines

  1.         PAGE    ,132
  2.         TITLE   SCROLOCK -- Holds screen every page
  3.  
  4. COMMENT $
  5.         SCROLOCK.EXE -- Locks scrolling of screen
  6.  
  7.         Generate EXE file using the following commands:
  8.         MASM SCROLOCK;
  9.         LINK SCROLOCK;
  10.  
  11.         Load from CONFIG.SYS file by use of the command:
  12.         DEVICE=SCROLOCK.EXE followed by an optional line count
  13.         and an optional keyword ON. If no line count is given,
  14.         the CGA normal line count of 25 will be used. If the
  15.         keyword ON is used, Scroll-Lock will be turned on.
  16.  
  17.         Load at system command or from within AUTOEXEC.BAT.
  18.         Type: SCROLOCK followed by an optional line count and
  19.         an optional keyword ON as above.
  20.  
  21.         To use, toggle the Scroll-Lock key to activate and
  22.         deactivate. If active, the screen will fill to the 
  23.         bottom, then it will scroll until the line where the 
  24.         cursor was when the last key was struck is now at the
  25.         top of the screen, then it will freeze with the 
  26.         cursor in the bottom left corner. To get the next 
  27.         screen-full, hit any key. Note: The key will be used 
  28.         later, so if you want just another screen-full, hit 
  29.         the Alt or either Shift key.
  30.         $
  31.  
  32. ;       ************************************************************
  33. ;       *                                                          *
  34. ;       *               Dummy Device Driver Header                 *
  35. ;       *                                                          *
  36. ;       ************************************************************
  37.  
  38. CSEG    SEGMENT
  39.         ORG     0000H                   ; For all device drivers
  40.  
  41. Header          DD      -1              ; One device
  42.                 DW      08000H          ; Character device
  43. StratA          DW      Strat           ; Strategy entrance
  44. IntrA           DW      Intr            ; Interrupt entrance
  45.                 DB      'Scrolock'      ; 8 character dummy name
  46.  
  47. ;       ************************************************************
  48. ;       *                                                          *
  49. ;       *                     Resident data                        *
  50. ;       *                                                          *
  51. ;       ************************************************************
  52.  
  53. ;       ROM BIOS DATA AREAS
  54. ;       -------------------
  55. BIOS_DATA               SEGMENT AT 00040H
  56.                 ORG     00017H
  57. KB_FLAG         DB      ?
  58. SCROLL_STATE    EQU     010H
  59.                 ORG     00050H
  60.  
  61. CURSOR_POSN     DW      8 DUP(?)        ; 8 pages of cursor positions
  62. CURSOR_MODE     DW      ?               ; Current cursor mode setting
  63. ACTIVE_PAGE     DB      ?               ; Current page being displayed
  64. BIOS_DATA       ENDS
  65.  
  66. ;       RESIDENT DATA
  67. ;       -------------
  68. OldIntr09       DW      ?               ; Interrupt vector storage
  69.                 DW      ?
  70. OldIntr10       DW      ?
  71.                 DW      ?
  72. LineCount       DB      ?               ; Line counter
  73. OddEven         DB      0               ; CR sets even = 0
  74. MaxRows         DB      25              ; Maximum screen rows
  75.  
  76. ;       ************************************************************
  77. ;       *                                                          *
  78. ;       *                     Resident code                        *
  79. ;       *                                                          *
  80. ;       ************************************************************
  81.  
  82. ;       Intercept of Interrupt 10H -- BIOS Video Call
  83. ;       ---------------------------------------------
  84.  
  85.         ASSUME  CS:CSEG, DS:NOTHING, ES:NOTHING
  86. NewIntr10:
  87.         STI                             ; Allow interrupts
  88.         PUSH    DS                      ; Save registers
  89.         PUSH    ES
  90.         PUSH    AX
  91.         PUSH    BX
  92.         PUSH    CX
  93.         PUSH    AX
  94.         MOV     AX,SEG BIOS_DATA        ; Set ES = BIOS_DATA segment
  95.         MOV     ES,AX
  96.         POP     AX
  97.         PUSH    CS                      ; Set DS = CS
  98.         POP     DS
  99.         ASSUME  DS:CSEG, ES:BIOS_DATA
  100.         TEST    KB_FLAG,SCROLL_STATE    ; Scroll-Lock on?
  101.         JZ      ExitIntr10              ; No, not locked
  102.         CMP     AH,000H                 ; Change video mode?
  103.         JE      ClrScr                  ; Yes, stop at bottom
  104.         CMP     AX,00600H               ; Clear video screen?
  105.         JE      ClrScr                  ; Yes, stop at bottom
  106.         CMP     AX,00601H               ; Roll up one line?
  107.         JE      RollUp                  ; Yes, do that type
  108.         CMP     OddEven,002H            ; Is roll active?
  109.         JE      ExitIntr10              ; Yes, don't do cursor
  110.         CMP     AH,002H                 ; Cursor command?
  111.         JE      CurMov                  ; Yes, test what move
  112. ExitIntr10:
  113.         POP     CX                      ; Restore registers
  114.         POP     BX
  115.         POP     AX
  116.         POP     ES
  117.         POP     DS
  118.         ASSUME  DS:NOTHING, ES:NOTHING
  119.         JMP     DWORD PTR OldIntr10     ; Perform video request
  120.  
  121.  
  122.         ASSUME  DS:CSEG, ES:BIOS_DATA
  123. ClrScr:
  124.         MOV     AL,MaxRows
  125.         MOV     LineCount,AL            ; Do not allow any roll
  126.         MOV     OddEven,000H            ; Reset CR LF counter
  127.         JMP     ExitIntr10              ; Exit Intr svc.
  128.  
  129. RollUp:
  130.         CMP     CX,000H                 ; From first line?
  131.         JNE     ExitIntr10              ; No, exit
  132.         MOV     AL,MaxRows
  133.         CMP     DH,AL                   ; To last line?
  134.         JNE     ExitIntr10              ; No, exit
  135.         INC     LineCount               ; Yes, now count lines
  136.         MOV     OddEven,002H            ; Turn off cursor type
  137. RollLoop:
  138.         CMP     LineCount,AL            ; Maximum roll?
  139.         JA      RollLoop                ; Yes, loop until key pressed
  140.         JMP     ExitIntr10              ; No, roll some more
  141.  
  142. CurMov:
  143.         CMP     BH,ACTIVE_PAGE          ; Cursor for active page?
  144.         JNE     ExitIntr10              ; No, set for other page
  145.         MOV     BL,BH                   ; Get cursor pointer
  146.         SUB     BH,BH
  147.         SHL     BX,1
  148.         MOV     CX,[BX+CURSOR_POSN]     ; Get cursor position
  149.         CMP     CH,MaxRows              ; At bottom row?
  150.         JNE     ExitIntr10              ; No, don't do anything
  151.         OR      DL,DL                   ; To column 0?
  152.         JNE     ExitIntr10              ; No, exit
  153.         CMP     DH,MaxRows              ; To last line?
  154.         JNE     ExitIntr10              ; No, exit
  155.         OR      CL,CL                   ; From column 0?
  156.         JE      NotEven                 ; Yes, probably a LF
  157.         MOV     OddEven,000H            ; A CR for sure - even up
  158. NotEven:
  159.         NOT     OddEven                 ; Alternate CR LF
  160.         CMP     OddEven,000H            ; Probable LF?
  161.         JE      ExitIntr10              ; Yes, skip LFs
  162.         INC     LineCount               ; No, now count lines
  163.         CMP     LineCount,AL            ; Maximum roll?
  164.         JNA     ExitIntr10              ; No, roll some more
  165.         MOV     AH,002H                 ; Put cursor in corner
  166.         MOV     BH,ACTIVE_PAGE
  167.         PUSHF
  168.         CALL    DWORD PTR OldIntr10
  169.         MOV     AL,MaxRows              ; Needed for release
  170.         JMP     RollLoop                ; Loop as above
  171.  
  172. ;       Intrercept of Intrerrupt 9H -- Hardware Keyboard
  173. ;       ----------------------------------------------
  174.  
  175. NewIntr09:
  176.         ASSUME  DS:NOTHING, ES:NOTHING
  177.         PUSH    AX                      ; Save registers
  178.         IN      AL,060H                 ; Read scan code
  179.         TEST    AL,080H                 ; Key pressed?
  180.         JNE     ExitIntr09              ; No, exit
  181.         PUSH    BX                      ; Save registers
  182.  
  183.         PUSH    CX
  184.         PUSH    DX
  185.         PUSH    ES
  186.         MOV     AX,SEG BIOS_DATA        ; Set ES = BIOS_DATA segment
  187.         MOV     ES,AX
  188.         ASSUME  ES:BIOS_DATA
  189.         MOV     BL,ACTIVE_PAGE          ; Get cursor pointer
  190.         SUB     BH,BH
  191.         SHL     BX,1
  192.         MOV     DX,[BX+CURSOR_POSN]     ; Get cursor position
  193.         MOV     AH,MaxRows              ; Calculate rows to bottom
  194.         SUB     AH,DH
  195.         MOV     LineCount,AH            ; Allow roll again
  196.         POP     ES
  197.         ASSUME  ES:NOTHING
  198.         POP     DX                      ; Restore registers
  199.         POP     CX
  200.         POP     BX
  201. ExitIntr09:
  202.         POP     AX
  203.         JMP     DWORD PTR OldIntr09     ; Perform keyboard request
  204.  
  205. ;       ************************************************************
  206. ;       *                                                          *
  207. ;       *                   Installation data                      *
  208. ;       *                                                          *
  209. ;       ************************************************************
  210.  
  211. Init    PROC    FAR
  212.  
  213. Packet          DD      0               ; Request packet address
  214. ;       DEVICE DRIVER REQUEST PACKET
  215. ;       ----------------------------
  216. IOPacket        STRUC
  217. IO_CMDLEN       DB      ?
  218. IO_UNIT         DB      ?
  219. IO_CMD          DB      ?
  220. IO_STATUS       DW      ?
  221.                 DB      8 DUP(?)
  222. IO_MEDIA        DB      ?
  223. IO_ADDRESS      DW      ?
  224.                 DW      ?
  225. IO_COUNT        DW      ?
  226. IO_START        DW      ?
  227. IOPacket        ENDS
  228.  
  229. Message         DB      'SCROLOCK installed',00DH,00AH,'$'
  230.  
  231. ;       ************************************************************
  232. ;       *                                                          *
  233. ;       *                   Installation code                      *
  234. ;       *                                                          *
  235. ;       ************************************************************
  236.  
  237.         ASSUME  DS:NOTHING, ES:NOTHING
  238. Strat:
  239.         MOV     WORD PTR Packet,BX      ; Save Packet info
  240.         MOV     WORD PTR Packet+2,ES
  241.         PUSH    BX                      ; Save registers
  242.         PUSH    DS
  243.  
  244.         PUSH    AX
  245.         PUSH    DX
  246.         PUSH    ES
  247.         PUSH    SI
  248.  
  249. ;       NORMAL TSR INSTALLATION
  250. ;       -----------------------
  251.         LDS     BX,DWORD PTR Packet     ; Get command line location
  252.         LDS     SI,DWORD PTR [BX+IO_COUNT]
  253.         SUB     BX,BX                   ; Zero counter
  254. Bypass:
  255.         LODSB                           ; Get CMD character
  256.         CMP     AL,00DH                 ; CR code?
  257.         JE      Install                 ; Yes, done with analysis
  258.         CMP     AL,00AH                 ; LF code?
  259.         JE      Install                 ; Yes, done with analysis
  260.         CMP     AL,01AH                 ; EOF code?
  261.         JE      Install                 ; Yes, done with analysis
  262.         CALL    Delimit                 ; Is it a delimiter?
  263.         JNE     Bypass                  ; No, skip garbage
  264. CommandLoop:
  265.         LODSB                           ; Get a character
  266.         CMP     AL,00DH                 ; CR code?
  267.         JE      Install                 ; Yes, done with analysis
  268.         CMP     AL,00AH                 ; LF code?
  269.         JE      Install                 ; Yes, done with analysis
  270.         CMP     AL,01AH                 ; EOF code?
  271.         JE      Install                 ; Yes, done with analysis
  272.         CMP     AL,'0'                  ; Below digits?
  273.         JB      CommandLoop             ; Yes, ignore all
  274.         CMP     AL,'9'                  ; Within digits?
  275.         JNA     Digits                  ; Yes, accumulate count
  276.         AND     AL,NOT 020H             ; Translate lower case
  277.         CMP     AL,'N'                  ; N of ON?
  278.         JNE     CommandLoop             ; No, ignore all
  279.         PUSH    DS                      ; Yes, set Scroll-Lock
  280.         MOV     AX,SEG BIOS_DATA        ; bit in low
  281.         MOV     DS,AX                   ; memory 0040:0017
  282.         ASSUME  DS:BIOS_DATA
  283.         OR      KB_FLAG,SCROLL_STATE
  284.         POP     DS
  285.         ASSUME  DS:CSEG
  286.         JMP     CommandLoop             ; and look for more
  287.  
  288. Digits:
  289.         SUB     AL,'0'                  ; Convert to value
  290.         SHL     BL,1                    ; Multiply BL by 10
  291.         ADD     AL,BL                   ; by shifts and adds
  292.         SHL     BL,1
  293.         SHL     BL,1
  294.         ADD     BL,AL                   ; Keep value in BL
  295.         JMP     CommandLoop             ; Get more
  296.  
  297. Install:
  298.         OR      BL,BL                   ; Any value found?
  299.         JNZ     HasDigits               ; Yes, bypass set-to-25
  300.         MOV     BL,25                   ; No, set to 25
  301. HasDigits:
  302.         PUSH    CS                      ; DS = CS for DOS functs
  303.         POP     DS
  304.  
  305.         ASSUME  DS:CSEG
  306.         MOV     MaxRows,BL              ; Save for scroll limits
  307.         DEC     MaxRows                 ; Adjust line count down
  308.         MOV     LineCount,000H          ; Scroll full page
  309.         MOV     AX,03509H               ; Get interrupt 9 vector
  310.         INT     021H
  311.         MOV     OldIntr09,BX            ; Save it
  312.         MOV     OldIntr09+2,ES
  313.         MOV     DX,OFFSET NewIntr09     ; Set new interrupt 9 vector
  314.         MOV     AX,02509H
  315.         INT     021H
  316.         MOV     AX,03510H               ; Get interrupt 10 vector
  317.         INT     021H
  318.         MOV     OldIntr10,BX            ; Save it
  319.         MOV     OldIntr10+2,ES
  320.         MOV     DX,OFFSET NewIntr10     ; Set new interrupt 10 vector
  321.         MOV     AX,02510H
  322.         INT     021H
  323.         MOV     DX,OFFSET Message       ; Show installed message
  324.         MOV     AH,009H
  325.         INT     021H
  326. ;       SPECIAL DDD TERMINATION
  327. ;       -----------------------
  328.         POP     SI                      ; Restore registers
  329.         POP     ES
  330.         POP     DX
  331.         POP     AX
  332.         ASSUME  DS:NOTHING, ES:NOTHING
  333.         LDS     BX,DWORD PTR Packet     ; Restore Packet info
  334.         MOV     WORD PTR [BX+IO_ADDRESS],OFFSET Init
  335.                                         ; Set memory request
  336.         MOV     WORD PTR [BX+IO_ADDRESS+2],CS   ; to be resident
  337.         MOV     [BX+IO_STATUS],00100H   ; Set done bits
  338.         POP     DS                      ; Restore registers used
  339.         POP     BX
  340. Intr:
  341.         RET                             ; Exit device installaion
  342. Init    ENDP
  343.  
  344. Delimit PROC    NEAR
  345.         CMP     AL,9                    ; Tab?
  346.         JE      DelimitEnd
  347.         CMP     AL,' '                  ; Space?
  348.         JE      DelimitEnd
  349.         CMP     AL,'/'                  ; Switch?
  350.         JE      DelimitEnd
  351.         CMP     AL,'-'                  ; Unix switch?
  352.         JE      DelimitEnd
  353.         OR      AL,AL                   ; Null?
  354. DelimitEnd:
  355.         RET                             ; Exit Z or NZ
  356. Delimit ENDP
  357. CSEG    ENDS
  358.  
  359. ;       ************************************************************
  360. ;       *                                                          *
  361. ;       *                    Execution data                        *
  362. ;       *                                                          *
  363. ;       ************************************************************
  364.  
  365.  
  366. EXESEG  SEGMENT PARA
  367. ;       PROGRAM SEGMENT PREFIX
  368. ;       ----------------------
  369. PSP     SEGMENT AT 00000H
  370. FilPerProc      EQU     20
  371. PSP_Exit_Call   DW      ?               ; INT int_abort system terminate
  372. PSP_block_len   DW      ?               ; size of execution block
  373.                 DB      ?
  374. PSP_CPM_Call    DB      5 DUP (?)       ; ancient call to system
  375. PSP_Exit        DD      ?               ; pointer to exit routine
  376. PSP_Ctrl_C      DD      ?               ; pointer to ^C routine
  377. PSP_Fatal_abort DD      ?               ; pointer to fatal error
  378. PSP_Parent_PID  DW      ?               ; PID of parent (terminate PID)
  379. PSP_JFN_Table   DB      FilPerProc DUP (?)
  380.                                         ; indices into system table
  381. PSP_environ     DW      ?               ; seg addr of PSP_environment
  382. PSP_User_stack  DD      ?               ; stack of self during system calls
  383. PSP_PAD1        DB      1EH DUP (?)
  384. PSP_Call_system DB      5 DUP (?)       ; portable method of system call
  385. PSP_PAD2        DB      6H DUP (?)      ;
  386.                 ORG     00080H
  387. PSP_CMD_Line    DB      ?
  388. PSP     ENDS
  389.  
  390. EXEPacket       IOPacket        <>      ; Requires packet space
  391. ToStrat         DD      StratA
  392. ToIntr          DD      IntrA
  393.  
  394. ;       ************************************************************
  395. ;       *                                                          *
  396. ;       *                    Execution code                        *
  397. ;       *                                                          *
  398. ;       ************************************************************
  399.  
  400.         ASSUME  CS:EXESEG,DS:PSP,ES:NOTHING
  401. Start   PROC    NEAR                    ; Execute DDD installation
  402.         PUSH    DS                      ; Save for PSP:0081
  403.         MOV     AH,049H                 ; Release environment
  404.         MOV     ES,PSP_environ 
  405.         INT     021H
  406.         ASSUME  DS:CSEG
  407.         LDS     BX,ToStrat              ; Get address of StratA
  408.         MOV     AX,[BX]                 ; to get address of Strat
  409.         MOV     WORD PTR ToStrat,AX     ; for FAR CALL
  410.         LDS     BX,ToIntr               ; Get address of IntrA
  411.         MOV     AX,[BX]                 ; to get address of Intr
  412.         MOV     WORD PTR ToIntr,AX      ; for FAR CALL
  413.         PUSH    CS
  414.         POP     DS
  415.         PUSH    CS
  416.         POP     ES
  417.         ASSUME  DS:EXESEG,ES:EXESEG
  418.         POP     EXEPacket.IO_COUNT+2    ; Put PSP:0081 address in packet
  419.         MOV     EXEPacket.IO_COUNT,OFFSET PSP_CMD_Line+1
  420.         SUB     AL,AL                   ; 0 = Initialize DDD
  421.         MOV     EXEPacket.IO_CMD,AL     ; Put command in packet
  422.         MOV     BX,OFFSET EXEPacket     ; ES:BX = packet address
  423.         CALL    ToStrat                 ; Perform strategy
  424.         CALL    ToIntr                  ; Perform interrupt
  425.         MOV     DX,EXEPacket.IO_ADDRESS ; Get ending address
  426.  
  427.         ADD     DX,0010FH               ; Add PSP and round up
  428.         MOV     CL,4                    ; Convert to paragraphs
  429.         SHR     DX,CL
  430.         ADD     DX,EXEPacket.IO_ADDRESS+2
  431.                                         ; Add highest segment
  432.         SUB     DX,SEG CSEG             ; Subtract lowest segment
  433.         MOV     AX,03100H               ; DOS stay resident function
  434.         INT     021H
  435. Start   ENDP
  436. EXESEG  ENDS
  437.  
  438. STACK   SEGMENT STACK
  439.                 DW      0100H DUP (?)
  440. STACK   ENDS
  441.         END     Start
  442. ; End of File
  443.