home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / PRINTING / HPPS76.ZIP / HPPS.ASM next >
Assembly Source File  |  1989-06-20  |  14KB  |  628 lines

  1.         page    78,122
  2.         title    HPPS -- HP LaserJet+/SeriesII PrtSc Driver 7.6
  3. ;Revision history:
  4. ;06/02/89 Modified to read from all planes in EGA mode : 7.6
  5. ;05/14/89 Modified Text Screen printing for BBS's status lines : 7.5
  6. ;01/30/89 Translation table purged if /2 option (SeriesII) used : 7.4
  7. ;01/11/89 Added Margin Reset and released source code : 7.3
  8. ;01/04/89 Added Printer Reset to init strings : 7.2
  9. ;----------------------------------------------------------------------------
  10.  
  11. data        segment at 40h
  12.  
  13.         org    84h
  14. rows        db    ?
  15.  
  16. data        ends
  17.  
  18. ;----------------------------------------------------------------------------
  19.  
  20. EGA_seg        segment at 0a000h
  21. EGA_seg        ends
  22.  
  23. ;----------------------------------------------------------------------------
  24.  
  25. MON_seg        segment at 0b000h
  26. MON_seg        ends
  27.  
  28. ;----------------------------------------------------------------------------
  29.  
  30. CGA_seg        segment at 0b800h
  31. CGA_seg        ends
  32.  
  33. ;----------------------------------------------------------------------------
  34.  
  35. code        segment para 'code' 
  36.         assume    cs:code,ds:code,es:code
  37.  
  38. cseg_start    equ    $
  39.  
  40.         org    100h
  41.  
  42. start:        jmp    PrtSc
  43.  
  44. ;---------------------------------------
  45.  
  46. hp_EGAinit    db    27,'E',27,'9',27,'&l0O',27,'&a1000h720V',27,'*t75R',27,'*r1A',0 
  47. hp_EGAline     db    27,'*b44W',0
  48. hp_EGAlineE     db    27,'*b50W',0
  49. hp_CGAinit    db    27,'E',27,'9',27,'&l0O',27,'&a600h600V',27,'*t100R',27,'*r1A',0 
  50. hp_CGAline     db    27,'*b80W',0
  51. hp_Text        db    27,'E',27,'9',27,'(8U',27,'(s0p10H',0
  52. hp_Text2    db    27,'E',27,'9',27,'(10U',27,'(s0p10H',0
  53. hp_CGAtext40    db    27,'&a0C',27,'&p40X',0
  54. hp_CGAtext80    db    27,'&a0C',27,'&p80X',0
  55. hp_end        db    27,'*rB',27,'&a0C',12,0 
  56. hp_crlf        db    13,10,0 
  57. hp_ff        db    12,0 
  58.  
  59. busy        db    0 
  60. reverse        db    0
  61. seriesII    db    0
  62.  
  63. mode        db    ? 
  64. width_        db    ? 
  65. vpage        db    ?
  66.  
  67. vid_seg        dw    ?
  68. delta        dw    ?
  69.  
  70. line_buffer    db    352 dup (0) 
  71.  
  72. ;---------------------------------------
  73. ;        Screen snapshot routine 
  74.  
  75. snapshot:    cmp    cs:[busy],0    ;Continue if not busy 
  76.         jz    go_ahead    ;
  77.         iret            ; 
  78.  
  79. go_ahead:    inc    cs:[busy]    ;Set busy 
  80.  
  81.         sti            ;let the dogs back in
  82.  
  83.         push    ax         ;save state
  84.         push    bx 
  85.         push    cx 
  86.         push    dx 
  87.         push    bp 
  88.             push    si 
  89.         push    di 
  90.         push    ds 
  91.         push    es 
  92.  
  93.         mov    ax,cs        ;setup ds,es
  94.          mov    ds,ax        ;
  95.         mov    es,ax        ;
  96.  
  97.         cld            ;set direction flag
  98.  
  99.         mov    ah,15        ;Get video mode 
  100.         int    10H        ; 
  101.         mov    [mode],al    ; 
  102.         mov    [width_],ah    ; 
  103.         mov    [vpage],bh    ; 
  104.  
  105.         cmp    al,4        ;See if 0-3 
  106.         jb    CGA_Text    ;Text modes use same routine 
  107.  
  108.         cmp    al,7        ;see if mode 4-6
  109.         je    CGA_Text    ;mod 7 is text
  110.         ja    try_EGAmD    ;
  111.         jmp    CGA_G6        ;
  112.  
  113. try_EGAmD:    cmp    al,0dH        ;CGA/EGA 320x200
  114.         jne    try_EGAmE
  115.         jmp    EGA_modeDE
  116.  
  117. try_EGAmE:    cmp    al,0eh        ;CGA/EGA 640x200
  118.         jne    try_MONmF    ;
  119.         jmp    EGA_modeDE    ;
  120.  
  121. try_MONmF:    cmp    al,0fh        ;MON 640x350
  122.         jne    try_EGAm10    ;
  123.         jmp    MON_modeF    ;
  124.  
  125. try_EGAm10:    cmp    al,10H        ;EGA Hi-res modes 
  126.         jne    cant_do
  127.          jmp    EGA_mode10
  128.  
  129. cant_do:    call    beep        ;beep now and again
  130.         jmp    exit        ;none of the above 
  131.  
  132. ;---------------------------------------
  133.  
  134. CGA_Text:    mov    ah,3        ;get cursor position
  135.         int    10h        ;
  136.         push    dx        ;save it for later restore
  137.  
  138.         mov    bx,offset hp_Text    ;Init Printer
  139.         cmp    [seriesII],0        ;for LaserJet+
  140.         je    init_text        ;
  141.         mov    bx,offset hp_Text2    ;for SeriesII
  142. init_text:    call    print_msg        ;
  143.  
  144.         xor    dx,dx        ;set to start at top of screen
  145.  
  146.         mov    ax,1200h    ;see if EGA here
  147.         mov    bx,0ff10h    ;set bh to illegal value
  148.         int    10h        ;
  149.  
  150.         mov    cl,[width_]
  151.         mov    ch,25        ;25 lines default for CGA adapter
  152.  
  153.         cmp    bh,0ffh        ;see if bh changed
  154.         je    T1        ;no -- don't update ch
  155.  
  156.         assume    ds:data
  157.         push    ds        ;save ds
  158.         mov    ax,data        ;set for BIOS data area
  159.         mov    ds,ax        ;
  160.         mov    ch,[rows]    ;
  161.         inc    ch        ;
  162.         pop    ds        ;
  163.         assume    ds:code
  164.  
  165. T1:        mov    bx,offset hp_CGAtext40
  166.         cmp    cl,40
  167.         je    T2
  168.         mov    bx,offset hp_CGAtext80
  169.  
  170. T2:        push    bx
  171.         push    dx
  172.         call    print_msg
  173.         pop    dx
  174.  
  175. T3:        push    dx        ;save cursor position 
  176.  
  177.         mov    bh,[vpage]    ;set new cursor position
  178.         mov    ah,2        ;
  179.         int    10h        ;
  180.  
  181.         mov    ah,8        ;read char at cursor position
  182.         int    10h        ;
  183.  
  184.         cmp    [seriesII],0    ;see if seriesII
  185.         jnz    series2        ;yes - skip xlate
  186.         mov    bx,offset xlat_
  187.         xlat            ;translate char
  188.  
  189. series2:    xor    dx,dx        ;set for lpt1:
  190.         xor    ah,ah        ;ah=0 print char
  191.         int    17h        ;print it
  192.         
  193.         pop    dx        ;restore cursor position
  194.  
  195.         inc    dl        ;bump column counter
  196.         cmp    dl,cl        ;EOL ?
  197.         jnz    T3        ;no -- same line, do next char
  198.  
  199.         xor    dl,dl        ;reset column counter
  200.  
  201.         push    dx
  202.         mov    bx,offset hp_crlf    ;print crlf 
  203.         call    print_msg        ; 
  204.         pop    dx
  205.  
  206.         pop    bx
  207.  
  208.         inc    dh        ;bump row counter
  209.         cmp    dh,ch        ;end of screen ?
  210.         jnz    T2        ;no -- do next line
  211.  
  212.         pop    dx        ;restore cursor position
  213.         mov    ah,2        ;
  214.         mov    bh,[vpage]    ;
  215.         int    10h        ;
  216.  
  217.         mov    bx,offset hp_ff    ;eject page
  218.         call    print_msg
  219.  
  220.         jmp    exit        ;bye
  221.         
  222. ;---------------------------------------
  223.  
  224. CGA_G6:        mov    ax,CGA_Seg
  225.         mov    ds,ax
  226.  
  227.         mov    bx,offset hp_CGAinit
  228.         call    print_msg
  229.  
  230.         mov    si,0H
  231.  
  232.         mov    cx,100
  233. CGA_G6loop1:    push    cx
  234.         push    si
  235.  
  236.         mov    cx,2        ;print two lines per iteration
  237. CGA_G6loop1a:    push    cx
  238.         push    si
  239.  
  240.         mov    cx,2        ;print each line twice for aspect ratio
  241. CGA_G6loop2:    push    cx
  242.         push    si        ;save SI for second time printing
  243.  
  244.         mov    bx,offset hp_CGAline
  245.         call    print_msg
  246.  
  247.         mov    cx,80
  248. CGA_G6loop3:    lodsb                
  249.         xor    al,cs:[reverse]
  250.         xor    ah,ah
  251.         int    17H
  252.         loop    CGA_g6loop3
  253.  
  254.         pop    si
  255.  
  256.         pop    cx
  257.         loop    CGA_G6loop2
  258.  
  259.         pop    si
  260.         add    si,8*1024    ;odd scan lines are 8K further in buffer
  261.  
  262.         pop    cx
  263.         loop    CGA_G6loop1a
  264.  
  265.         pop    si
  266.         add    si,80        ;next even line is 80 bytes in buffer
  267.  
  268.         pop    cx
  269.         loop    CGA_G6loop1
  270.  
  271.         mov    bx,offset hp_end
  272.         call    print_msg
  273.  
  274.         jmp    exit
  275.  
  276. ;---------------------------------------
  277.  
  278. EGA_modeDE:    mov    bx,40
  279.         mov    cx,8192/16
  280.  
  281.         cmp    al,0dh        ;320x200 ?
  282.         je    no_shift    ;yes dont adjust
  283.  
  284.         shl    bx,1        ;bx=80
  285.         shl    cx,1        ;cx=16384/16
  286.  
  287. no_shift:    mov    al,[vpage]    ;index into correct page
  288.         xor    ah,ah        ;
  289.         mul    cx        ;
  290.         add    ax,EGA_seg    ;
  291.         mov    [vid_seg],ax    ;
  292.  
  293.         mov    cx,bx        ;
  294.         mov    [delta],bx    ;
  295.         
  296.         mov    bx,offset hp_EGAinit
  297.         call    print_msg
  298.  
  299. EGAmEloop1:    push    cx        ;
  300.  
  301.         mov    si,cx
  302.         dec    si
  303.  
  304.         mov    ax,[vid_seg]    ;EGA RAM Buffer
  305.         push    ds
  306.         mov    ds,ax
  307.         mov    di,offset line_buffer    ;
  308.         mov    cx,200        ;read in one column for 200 rows
  309. EGAmEloop2:      call    get_byteEGA     ;(DS:SI) --> (ES:DI)
  310.                 inc     di
  311.         add    si,es:[delta]    ; move pointers
  312.         loop    EGAmEloop2
  313.         pop    ds
  314.  
  315.         mov    cx,8
  316. EGAmEloop3:    push    cx
  317.  
  318.         mov    cx,1
  319.         cmp    [mode],0dh    ; 320x200 mode ?
  320.         jne    dont_repeat    ;no
  321.         inc    cx        ;print line twice
  322.  
  323. dont_repeat:    push    cx
  324.  
  325.         mov    bx,offset hp_EGAlineE
  326.                call    print_msg
  327.  
  328.         mov    si,offset line_buffer
  329.         mov    cx,50        ;50 bytes will be output
  330. EGAmEloop4:    push    cx        ;
  331.  
  332.         xor    al,al        ;clear acc
  333.         mov    cx,4        ;
  334. EGAmEloop5:    shl    al,1        ;bump acc
  335.         mov    ah,[si]        ;get byte
  336.         and    ah,1        ;get lsb
  337.         or    al,ah        ;move into acc
  338.         shl    al,1        ;bump acc
  339.         or    al,ah        ;merge
  340.         inc    si
  341.         loop    EGAmEloop5    ;
  342.  
  343.         xor    al,[reverse]
  344.         xor    ah,ah        ; Output Byte
  345.         int    17h        ;
  346.  
  347.         pop    cx        ;
  348.         loop    EGAmEloop4    ;
  349.  
  350.         pop    cx        ;do second line?
  351.         loop    dont_repeat    ;if cx=2 then yes
  352.  
  353.         mov    si,offset line_buffer
  354.         mov    cx,200        ;
  355. EGAmEloop6:    shr    byte ptr [si],1    ;shift byte for next time
  356.         inc    si
  357.         loop    EGAmEloop6
  358.  
  359.         pop    cx
  360.         loop    EGAmEloop3
  361.  
  362.         pop    cx        ;do next column
  363.         loop    EGAmEloop1    ;
  364.  
  365.         mov    bx,offset hp_end
  366.         call    print_msg
  367.  
  368.         jmp    exit
  369.  
  370. ;---------------------------------------
  371.  
  372. MON_modeF:    mov    ax,MON_seg
  373.         jmp    short EGA_hires
  374.  
  375. EGA_mode10:    mov    ax,EGA_seg
  376.  
  377. EGA_hires:    mov    [vid_seg],ax
  378.  
  379.         mov    bx,offset hp_EGAinit
  380.         call    print_msg
  381.  
  382.         mov    cx,80        ;loop through 80 cols
  383. EGAm10loop1:    push    cx        ;
  384.  
  385.         mov    si,cx
  386.         dec    si
  387.  
  388.         mov    ax,[vid_seg]    ;MON/EGA RAM Buffer
  389.         push    ds
  390.         mov    ds,ax
  391.         mov    di,offset line_buffer    ;
  392.         mov    cx,350        ;read in one column for 350 rows
  393.  
  394. EGAm10loop2:    call    get_byteEGA     ;(DS:SI) --> (ES:DI)
  395.                 inc     di
  396.         add    si,80           ; move pointers
  397.         loop    EGAm10loop2
  398.         pop    ds
  399.  
  400.         mov    cx,8
  401. EGAm10loop3:    push    cx
  402.  
  403.         mov    bx,offset hp_EGAline
  404.                call    print_msg
  405.  
  406.         mov    si,offset line_buffer
  407.         mov    cx,44        ;44 bytes will be output
  408. EGAm10loop4:    push    cx        ;
  409.  
  410.         xor    al,al        ;clear acc
  411.         mov    cx,8        ;build each 44 bit by bit
  412. EGAm10loop5:    shl    al,1        ;bump acc
  413.         mov    ah,[si]        ;get byte
  414.         and    ah,1        ;get lsb
  415.         or    al,ah        ;move into acc
  416.         shr    byte ptr [si],1    ;shift byte for next time
  417.         inc    si
  418.         loop    EGAm10loop5    ;
  419.  
  420.         xor    al,[reverse]    ;
  421.         xor    ah,ah        ; Output Byte
  422.         int    17h        ;
  423.  
  424.         pop    cx        ;
  425.         loop    EGAm10loop4    ;    
  426.  
  427.         pop    cx
  428.         loop    EGAm10loop3
  429.  
  430.         pop    cx        ;do next column
  431.         loop    EGAm10loop1    ;
  432.  
  433.         mov    bx,offset hp_end
  434.         call    print_msg    ;fall through to exit:
  435.  
  436. exit:        call    beep        ; signal done
  437.                                         ;        
  438.         pop    es        ; Restore state
  439.         pop    ds
  440.         pop    di
  441.         pop    si
  442.         pop    bp
  443.         pop    dx
  444.         pop    cx
  445.         pop    bx
  446.         pop    ax
  447.                                         ;
  448.         cli
  449.         dec    cs:[busy]    ; Clear busy
  450.         iret
  451.  
  452. ;---------------------------------------
  453. ;
  454. ; get byte from DS:[SI] into ES:[DI] ( was movsb )
  455. ; but now modified to allow reading all planes
  456. ;
  457. get_byteEGA:    push    dx
  458.         xor    bl,bl        ; clear ans
  459.                                         ;
  460.                 mov     dx,3ceh         ; address 1 & 2 reg
  461.                 mov     al,4            ; read_map sel reg
  462.                 out     dx,al
  463.                 inc     dx              ; data reg
  464.                                         ;
  465.                 mov     al,0
  466.                 out     dx,al           ; sel plane 0
  467.         mov    ah,[si]        ; get byte
  468.         or    bl,ah        ; move into bl
  469.                                         ;
  470.                 mov     al,1
  471.                 out     dx,al           ; sel plane 1
  472.         mov    ah,[si]        ; get byte
  473.         or    bl,ah        ; move into bl
  474.                                         ;
  475.                 mov     al,2
  476.                 out     dx,al           ; sel plane 2
  477.         mov    ah,[si]        ; get byte
  478.         or    bl,ah        ; move into bl
  479.                                         ;
  480.                 mov     es:[di],bl      ; answer
  481.                 pop     dx
  482.                 ret
  483.  
  484. ;---------------------------------------
  485. ;        print string at [bx]
  486. print_msg:    mov    al,cs:[bx]    ;print string at bx to printer
  487.         or    al,al
  488.         jnz    print_ok
  489.         ret
  490.  
  491. print_ok:      xor    ah,ah
  492.         xor    dx,dx
  493.         int    17h
  494.         inc    bx
  495.         jmp    print_msg
  496.  
  497. ;---------------------------------------
  498. ;        beep when done
  499.  
  500. beep:        mov    bx,8080h
  501.         xor    ch,ch
  502.         in    al,61h
  503.         push    ax
  504. b1:        and    al,0fch
  505.         out    61h,al
  506.         mov    cl,bl
  507. b2:        loop    b2
  508.         or    al,2
  509.         out    61h,al
  510.         mov    cl,bl
  511. b3:        loop    b3
  512.         dec    bh
  513.         jnz    b1
  514.         pop    ax
  515.         out    61h,al
  516.         ret
  517.                                         ;
  518. cseg_end1    equ    $-cseg_start
  519.  
  520. ;----------------------------------------------------------------------------
  521. ;    The translation table is located here so that it can be purged
  522. ;    if the /2 (Series II) option is selected.
  523.  
  524. xlat_        db      0,  1,  2, 72, 68, 67, 83,  7,252,  9,252, 11, 12, 13, 14, 42
  525.         db     62, 60, 18, 19,240,189, 95, 23, 94,118,253,251, 28, 29, 30, 31
  526.         db     32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47
  527.         db     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63
  528.         db     64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79
  529.         db     80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95
  530.         db     96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111
  531.         db    112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127
  532.         db    180,207,197,192,204,200,212,181,193,205,201,221,209,217,216,208
  533.         db    220,215,211,194,206,202,195,203,239,218,219,191,187,188,000,190
  534.         db    196,213,198,199,183,182,249,250,185,246,246,248,247,184,251,253
  535.         db    127,127,127,124,124,124,124,246,246,124,124,246,246,246,246,246
  536.         db    246,246,246,124,246, 43,124,124,246,246,246,246,124,246, 43,246
  537.         db    246,246,246,246,246,246,246, 43, 43,246,246,252,252,252,252,252
  538.         db    000,222,000,000,000,000,000,000,000,000,000,000,000,210,000,000
  539.         db    000,254,000,000,000,000,000,000,179,000,000,000,000,000,252,000
  540.  
  541. cseg_end2    equ    $-cseg_start
  542.  
  543. ;---------------------------------------
  544. ;
  545. ;    Init Code
  546. ;
  547.  
  548. PrtSc:        mov    dx,offset greeting
  549.         mov    ah,09h        ;print string
  550.         int    21H        ;
  551.  
  552.         mov    cl,ds:[80h]    ;parse command line for -r or /r
  553.         xor    ch,ch        ;
  554.         or    cl,cl        ;
  555.         jz    no_parm        ;
  556.  
  557.         mov    si,81h        ;command line buffer
  558. parm_loop:    lodsb            ;get byte
  559.         cmp    al,' '
  560.         jz    get_next
  561.         cmp    al,09h        ;tab
  562.         jz    get_next
  563.         cmp    al,'/'        ;option switch?
  564.         jz    get_option
  565.         cmp    al,'-'        ;option switch?
  566.         jz    get_option    ;
  567.  
  568. bad_parm:    mov    dx,offset bad_parm_msg
  569.         mov    ah,09h        ;print message
  570.         int    21h        ;
  571.  
  572. abort:        mov    ax,4c01h    ;exit
  573.         int    21h        ;
  574.         
  575. get_next:    loop    parm_loop
  576.         jmp    short no_parm
  577.  
  578. get_option:    lodsb            ;get option
  579.         dec    cx        ;adjust command char count
  580.         cmp    al,'R'        ;reverse image option
  581.         je    set_reverse    ;
  582.         cmp    al,'r'        ;
  583.         je    set_reverse    ;
  584.         cmp    al,'2'        ;Series II option
  585.         je    set_seriesII    ;
  586.         cmp    al,'?'        ;Syntax
  587.         je    disp_syntax    ;
  588.         jmp    bad_parm    ;
  589.  
  590. set_reverse:    mov    [reverse],255    ;set reverse flag
  591.         jmp    get_next
  592.  
  593. set_seriesII:    mov    [seriesII],255    ;set seriesII flag
  594.         jmp    get_next
  595.  
  596. disp_syntax:    mov    dx,offset syntax    ;display syntax
  597.         mov    ah,09h            ;write string
  598.         int    21h
  599.         
  600.         jmp    abort
  601.  
  602. no_parm:    mov    dx,offset snapshot
  603.         mov    ax,2505h    ;Set PrtSc int vector
  604.         int    21h
  605.  
  606.         mov    es,ds:[002cH]    ;release environment segment
  607.         mov    ah,49H        ;
  608.         int    21H        ;
  609.  
  610.         mov    dx,cseg_end2/16+1    ; remove translation table
  611.         cmp    [seriesII],0        ; if /2 (SeriesII) option
  612.         je    not_II            ; selected.
  613.  
  614.         mov    dx,cseg_end1/16+1
  615. not_II:        mov    ax,3100h    ;Terminate but stay resident
  616.         int    21h        ;bye!
  617.  
  618. greeting    db    'HP LaserJet+/SeriesII Print Screen Driver version 7.6'
  619.         db    13,10,'$'
  620. syntax        db    10,'Syntax:',13,10
  621.         db    '   -r or /r = Reverse Image',13,10
  622.         db    '   -2 or /2 = SeriesII',13,10,'$'
  623. bad_parm_msg    db    07,10,'Illegal parameter',13,10,'$'
  624.  
  625. code        ends
  626.         end    start
  627.  
  628.