home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / assemblr / library / devdriv / ddd / scrolock.asm < prev    next >
Assembly Source File  |  1989-04-19  |  9KB  |  345 lines

  1.     PAGE    ,132
  2.  
  3. CSEG    SEGMENT
  4.     ASSUME    CS:CSEG, DS:NOTHING, ES:NOTHING
  5.     ORG    0000H            ; For all device drivers
  6.  
  7. Header    DD    -1            ; One device
  8.     DW    08000H            ; Character device
  9. StratA    DW    Strat            ; Strategy entrance
  10. IntrA    DW    Intr            ; Interrupt entrance
  11.     DB    'Scrolock'        ; 8 character dummy name
  12.  
  13. ;    Note: Put resident part of DDD here.
  14.     TITLE    SCROLOCK -- Holds screen every page
  15.  
  16. COMMENT    $
  17.     SCROLOCK.COM -- Locks scrolling of screen
  18.  
  19.     Generate EXE file using the following commands:
  20.     MASM SCROLOCK;
  21.     LINK SCROLOCK;
  22.  
  23.     Load from CONFIG.SYS file by use of the command:
  24.     DEVICE=SCROLOCK.EXE followed by an optional line count
  25.     and an optional keyword ON. If no line count is given,
  26.     the CGA normal line count of 25 will be used. If the
  27.     keyword ON is used, Scroll-Lock will be turned on.
  28.  
  29.     Load at system command or from within AUTOEXEC.BAT.
  30.     Type: SCROLOCK followed by an optional line count and
  31.     an optional keyword ON. If no line count is given, the
  32.     CGA normal line count of 25 will be used. If the keyword
  33.     ON is used, Scroll-Lock will be turned on.
  34.  
  35.     To use, toggle the Scroll-Lock key to activate and
  36.     deactivate. If active, screen will fill to the bottom
  37.     line, will scroll until the line where the cursor was is
  38.     at the top and then the screen will freeze with the
  39.     cursor in the bottom left corner. To get the next
  40.     screen-full, hit any key. Note: The key will be
  41.     used later, so if you want just another screen-full,
  42.     hit the Ctrl, Alt or either Shift key.
  43.  
  44.     If your CONFIG.SYS file contains the line
  45.     DEVICE=ANSI.SYS
  46.     you MUST change ANSI.SYS with these instructions:
  47.     
  48.     DEBUG ANSI.SYS
  49.     E 29D 90 90
  50.     E 2A1 90 90
  51.     W
  52.     Q
  53.  
  54.     $
  55.  
  56. ;    All Data
  57. ;    --------
  58.  
  59. DATA        SEGMENT AT 00040H    ; ROM-BIOS Data area
  60.         ORG    00017H
  61. KB_FLAG        DB    ?
  62. SCROLL_STATE    EQU    010H
  63. DATA        ENDS
  64.  
  65. OldIntr09    DW    ?        ; Interrupt vector storage
  66.         DW    ?
  67. OldIntr10    DW    ?
  68.         DW    ?
  69. LineCount    DB    ?        ; Line counter
  70. ActPage        DB    ?        ; Active page (0 usually)
  71. MaxRows        DB    25        ; Maximum screen rows
  72.  
  73. COMMENT    $
  74.     If your screen has more than 25 lines, enter the
  75.     correct number on the command line after SCROLOCK.
  76.     You may use SCROLOCK for each screen length you have
  77.     available on your video board. Otherwise, don't load
  78.     SCROLOCK more than once.
  79.     $
  80.  
  81. ;    Intercept of Interrupt 10H -- BIOS Video Call
  82. ;    ---------------------------------------------
  83.  
  84. NewIntr10:
  85.     STI                ; Allow interrupts
  86.     PUSH    DS            ; Save registers
  87.     PUSH    AX
  88.     PUSH    CS            ; Set DS = CS
  89.     POP    DS
  90.     ASSUME    DS:CSEG
  91.     CMP    AH,005H            ; Change active page?
  92.     JE    SetPage            ; Yes, save page
  93.     CMP    AH,000H            ; Change video mode?
  94.     JE    ClrScrAndPage        ; Yes, stop at bottom
  95.     CMP    AX,00600H        ; Clear video screen?
  96.     JE    ClrScr            ; Yes, stop at bottom
  97.     CMP    AX,00601H        ; Roll up one line?
  98.     JNE    ExitIntr10        ; No, exit
  99.     CMP    CX,000H            ; From first line?
  100.     JNE    ExitIntr10        ; No, exit
  101.     MOV    AL,MaxRows
  102.     CMP    DH,AL            ; To last line?
  103.     JNE    ExitIntr10        ; No, exit
  104.     PUSH    DS            ; Yes, set up for keyboard
  105.     MOV    AX,SEG DATA        ; status check in low
  106.     MOV    DS,AX            ; memory 0040:0017
  107.     ASSUME    DS:DATA
  108.     TEST    KB_FLAG,SCROLL_STATE
  109.     POP    DS            ; Scroll-Lock locked?
  110.     ASSUME    DS:CSEG
  111.     JZ    ExitIntr10        ; No, not locked
  112.     INC    LineCount        ; Yes, now count lines
  113.     MOV    AL,MaxRows        ; Overflow point
  114. LoopUntil:
  115.     CMP    LineCount,AL        ; Maximum roll?
  116.     JA    LoopUntil        ; Yes, loop until key pressed
  117.     JMP    SHORT ExitIntr10    ; No, roll some more
  118.  
  119. ClrScrAndPage:
  120.     MOV    ActPage,000H        ; Reset page zero
  121. ClrScr:
  122.     MOV    AL,MaxRows
  123.     MOV    LineCount,AL        ; Do not allow any roll
  124.     JMP    SHORT ExitIntr10
  125.  
  126. SetPage:
  127.     MOV    ActPage,AL        ; Save new page
  128. ExitIntr10:
  129.     POP    AX            ; Restore registers
  130.     POP    DS
  131.     JMP    DWORD PTR CS:OldIntr10    ; Perform video request
  132.  
  133. ;    Intercept of Interrupt 9H -- Hardware Keyboard
  134. ;    ----------------------------------------------
  135.  
  136. NewIntr09:
  137.     ASSUME    DS:NOTHING
  138.     PUSH    AX            ; Save registers
  139.     PUSH    BX
  140.     PUSH    CX
  141.     PUSH    DX
  142.     STI                ; Allow interrupts
  143.     IN    AL,060H            ; Read scan code
  144.     TEST    AL,080H            ; Key pressed?
  145.     JNE    ExitIntr09        ; No, exit
  146.     MOV    AH,003H            ; Yes, get cursor line
  147.     MOV    BH,ActPage        ; for this page
  148.     INT    010H
  149.     MOV    AH,MaxRows        ; Calculate rows to bottom
  150.     SUB    AH,DH
  151.     MOV    LineCount,AH        ; Allow roll again
  152. ExitIntr09:
  153.     POP    DX            ; Restore registers
  154.     POP    CX
  155.     POP    BX
  156.     POP    AX
  157.     JMP    DWORD PTR CS:OldIntr09    ; Perform keyboard request
  158.  
  159. IOPacket    STRUC
  160. IO_CMDLEN    DB    ?
  161. IO_UNIT        DB    ?
  162. IO_CMD        DB    ?
  163. IO_STATUS    DW    ?
  164.         DB    8 DUP(?)
  165. IO_MEDIA    DB    ?
  166. IO_ADDRESS    DW    ?
  167.         DW    ?
  168. IO_COUNT    DW    ?
  169. IO_START    DW    ?
  170. IOPacket    ENDS
  171.  
  172. Init    PROC    FAR
  173.     ASSUME    DS:NOTHING, ES:NOTHING
  174.  
  175. Packet    DD    0            ; Request packet address
  176.  
  177. Strat:
  178.     MOV    WORD PTR Packet,BX    ; Save Packet info
  179.     MOV    WORD PTR Packet+2,ES
  180.     RET
  181.  
  182. Intr:
  183.     PUSH    BX            ; Save registers
  184.     PUSH    DS
  185.  
  186. ;    Note: Put initialization code here.
  187. ;    Save all registers used except DS & BX.
  188. ;    After code, restore same registers and
  189. ;    JMP to "Exit".
  190.  
  191. ;    Initialization Procedure
  192. ;    ------------------------
  193.  
  194.     PUSH    AX            ; Save registers used
  195.     PUSH    DX
  196.     PUSH    ES
  197.     PUSH     SI
  198.     LDS    BX,DWORD PTR Packet
  199.     LDS    SI,DWORD PTR [BX+IO_COUNT]
  200.     SUB    BX,BX            ; Zero counter
  201. Bypass:
  202.     LODSB                ; Get CMD character
  203.     CMP    AL,00DH            ; CR code?
  204.     JE    Install            ; Yes, done with analysis
  205.     CMP    AL,00AH            ; LF code?
  206.     JE    Install            ; Yes, done with analysis
  207.     CMP    AL,01AH            ; EOF code?
  208.     JE    Install            ; Yes, done with analysis
  209.     CALL    Delimit            ; Is it a delimiter?
  210.     JNE    Bypass            ; No, skip garbage
  211. CommandLoop:
  212.     LODSB                ; Get a character
  213.     CMP    AL,00DH            ; CR code?
  214.     JE    Install            ; Yes, done with analysis
  215.     CMP    AL,00AH            ; LF code?
  216.     JE    Install            ; Yes, done with analysis
  217.     CMP    AL,01AH            ; EOF code?
  218.     JE    Install            ; Yes, done with analysis
  219.     CMP    AL,'0'            ; Below digits?
  220.     JB    CommandLoop        ; Yes, ignore all
  221.     CMP    AL,'9'            ; Within digits?
  222.     JNA    Digits            ; Yes, accumulate count
  223.     AND    AL,NOT 020H        ; Translate lower case
  224.     CMP    AL,'N'            ; N of ON?
  225.     JNE    CommandLoop        ; No, ignore all
  226.     PUSH    DS            ; Yes, set Scroll-Lock
  227.     MOV    AX,SEG DATA        ; bit in low
  228.     MOV    DS,AX            ; memory 0040:0017
  229.     ASSUME    DS:DATA
  230.     OR    KB_FLAG,SCROLL_STATE
  231.     POP    DS
  232.     ASSUME    DS:CSEG
  233.     JMP    CommandLoop        ; and look for more
  234.  
  235. Digits:
  236.     SUB    AL,'0'            ; Convert to value
  237.     SHL    BL,1            ; Multiply BL by 10
  238.     ADD    AL,BL            ; by shifts and adds
  239.     SHL    BL,1
  240.     SHL    BL,1
  241.     ADD    BL,AL            ; Keep value in BL
  242.     JMP    CommandLoop        ; Get more
  243.  
  244. Install:
  245.     OR    BL,BL            ; Any value found?
  246.     JNZ    HasDigits        ; Yes, bypass set-to-25
  247.     MOV    BL,25            ; No, set to 25
  248. HasDigits:
  249.     PUSH    CS            ; DS = CS for DOS functs
  250.     POP    DS
  251.     ASSUME    DS:CSEG
  252.     MOV    MaxRows,BL        ; Save for scroll limits
  253.     DEC    MaxRows            ; Adjust line count down
  254.     MOV    LineCount,000H        ; Scroll full page
  255.     MOV    ActPage,000H        ; Assume page 0
  256.     MOV    AX,03509H        ; Get interrupt 9 vector
  257.     INT    021H
  258.     MOV    OldIntr09,BX        ; Save it
  259.     MOV    OldIntr09+2,ES
  260.     MOV    DX,OFFSET NewIntr09    ; Set new interrupt 9 vector
  261.     MOV    AX,02509H
  262.     INT    021H
  263.     MOV    AX,03510H        ; Get interrupt 10 vector
  264.     INT    021H
  265.     MOV    OldIntr10,BX        ; Save it
  266.     MOV    OldIntr10+2,ES
  267.     MOV    DX,OFFSET NewIntr10    ; Set new interrupt 10 vector
  268.     MOV    AX,02510H
  269.     INT    021H
  270.     MOV    DX,OFFSET Message    ; Show installed message
  271.     MOV    AH,009H
  272.     INT    021H
  273.     POP    SI            ; Restore registers
  274.     POP    ES
  275.     POP    DX
  276.     POP    AX
  277.     JMP    SHORT Exit
  278.  
  279. Delimit    PROC    NEAR
  280.     CMP    AL,9            ; Tab?
  281.     JE    DelimitEnd
  282.     CMP    AL,' '            ; Space?
  283.     JE    DelimitEnd
  284.     CMP    AL,'/'            ; Switch?
  285.     JE    DelimitEnd
  286.     CMP    AL,'-'            ; Unix switch?
  287.     JE    DelimitEnd
  288.     OR    AL,AL            ; Null?
  289. DelimitEnd:
  290.     RET                ; Exit Z or NZ
  291. Delimit    ENDP
  292.  
  293. Message        DB    'SCROLOCK installed',00DH,00AH,'$'
  294.  
  295. Exit:
  296.     ASSUME    DS:NOTHING, ES:NOTHING
  297.     LDS    BX,DWORD PTR Packet    ; Restore Packet info
  298.     MOV    WORD PTR [BX+IO_ADDRESS],OFFSET Init    ; Set memory
  299. ;    Note: Change "Init" above to correct ending address
  300.     MOV    WORD PTR [BX+IO_ADDRESS+2],CS    ; to be resident
  301.     MOV    [BX+IO_STATUS],00100H    ; Set done bits
  302.     POP    DS            ; Restore registers used
  303.     POP    BX
  304.     RET                ; Exit device installaion
  305. Init    ENDP
  306.  
  307. ;    Delete lines containing "ENDS" and "END" above.
  308.  
  309. EXEPacket    IOPacket    <>    ; Requires packet space
  310.  
  311. Start    PROC    NEAR            ; Execute DDD installation
  312.     MOV    SP,OFFSET StackTop    ; Shorten stack
  313.     PUSH    ES            ; Save PSP segment
  314.     MOV    AH,049H            ; Release environment
  315.     MOV    ES,ES:0002CH
  316.     INT    021H
  317.     PUSH    CS            ; DS = CS
  318.     POP    DS
  319.     ASSUME    DS:CSEG
  320.     POP    AX            ; ES:0081 = Command string
  321.     MOV    EXEPacket.IO_COUNT+2,AX    ; Put address in packet
  322.     MOV    EXEPacket.IO_COUNT,00081H
  323.     SUB    AL,AL            ; 0 = Initialize DDD
  324.     MOV    EXEPacket.IO_CMD,AL    ; Put command in packet
  325.     MOV    BX,OFFSET EXEPacket    ; ES:BX = packet address
  326.     PUSH    CS
  327.     POP    ES
  328.     ASSUME    ES:CSEG
  329.     PUSH    CS            ; FAR return
  330.     CALL    StratA            ; Perform strategy
  331.     PUSH    CS            ; FAR return
  332.     CALL    IntrA            ; Perform interrupt
  333.     MOV    DX,EXEPacket.IO_ADDRESS    ; Get ending address
  334.     ADD    DX,0010FH        ; Add PSP and round up
  335.     MOV    CL,4            ; Convert to paragraphs
  336.     SHR    DX,CL
  337.     MOV    AX,03100H        ; DOS stay resident function
  338.     INT    021H
  339.  
  340.         DW    080H DUP (?)
  341. StackTop    DW    0
  342. Start    ENDP
  343. CSEG    ENDS
  344.     END    Start
  345.