home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / LASER / HPPS75.ZIP / HPPS.ASM next >
Encoding:
Assembly Source File  |  1989-09-20  |  13.0 KB  |  644 lines

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